From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 073857D19 for ; Thu, 4 Jan 2018 12:13:48 +0100 (CET) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jan 2018 03:13:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,507,1508828400"; d="scan'208";a="164116517" Received: from debian-xvivbkq.sh.intel.com ([10.67.104.226]) by orsmga004.jf.intel.com with ESMTP; 04 Jan 2018 03:13:46 -0800 Date: Thu, 4 Jan 2018 19:13:19 +0800 From: Tiwei Bie To: Xiao Wang Cc: dev@dpdk.org, yliu@fridaylinux.org, stephen@networkplumber.org Message-ID: <20180104111319.xckitk5hxpxzgsj4@debian-xvivbkq.sh.intel.com> References: <1515051700-117262-3-git-send-email-xiao.w.wang@intel.com> <1515081578-30649-1-git-send-email-xiao.w.wang@intel.com> <1515081578-30649-4-git-send-email-xiao.w.wang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1515081578-30649-4-git-send-email-xiao.w.wang@intel.com> User-Agent: NeoMutt/20170609 (1.8.3) Subject: Re: [dpdk-dev] [PATCH v4 3/3] net/virtio: support GUEST ANNOUNCE X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 11:13:49 -0000 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