On Thu, Jan 04, 2018 at 07:59:38AM -0800, Xiao Wang wrote:
[...]
> +static void
> +virtio_notify_peers(struct rte_eth_dev *dev)
> +{
> +     struct virtio_hw *hw = dev->data->dev_private;
> +     struct virtnet_tx *txvq = dev->data->tx_queues[0];
> +     struct virtnet_rx *rxvq = dev->data->rx_queues[0];
> +     struct rte_mbuf **rarp_buf;
> +
> +     rarp_buf = rte_zmalloc("rarp_buf", sizeof(struct rte_mbuf *), 0);
> +     if (!rarp_buf) {
> +             PMD_INIT_LOG(ERR, "Failed to allocate rarp pointer");
> +             return;
> +     }
> +
> +     rarp_buf[0] = rte_mbuf_raw_alloc(rxvq->mpool);
> +     if (rarp_buf[0] == NULL) {
> +             PMD_DRV_LOG(ERR, "first mbuf allocate free_bufed");
> +             goto free_buf;
> +     }
> +
> +     if (make_rarp_packet(rarp_buf[0],
> +                             (struct ether_addr *)hw->mac_addr)) {
> +             rte_pktmbuf_free(rarp_buf[0]);
> +             goto free_buf;
> +     }
> +
> +     /* If virtio port just stopped, no need to send RARP */
> +     if (virtio_dev_pause(dev) < 0) {
> +             rte_pktmbuf_free(rarp_buf[0]);
> +             goto free_buf;
> +     }
> +
> +     virtio_inject_pkts(dev, txvq, rarp_buf, 1);

You don't need to define rarp_buf as `struct rte_mbuf **`,
and dynamically alloc the mbuf pointer. You could alloc a
mbuf pointer on the stack directly, e.g.:

        struct rte_mbuf *rarp_mbuf;
        rarp_mbuf = rte_pktmbuf_alloc(...);
        ...
        if (make_rarp_packet(rarp_mbuf, ...))
                ...
        virtio_inject_pkts(..., &rarp_mbuf, 1);

Thanks,
Tiwei

Reply via email to