From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E42D85F21 for ; Mon, 5 Mar 2018 15:21:04 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2018 06:21:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,427,1515484800"; d="scan'208";a="180002651" Received: from fyigit-mobl.ger.corp.intel.com (HELO [10.237.221.62]) ([10.237.221.62]) by orsmga004.jf.intel.com with ESMTP; 05 Mar 2018 06:21:01 -0800 To: Mallesh Koujalagi , dev@dpdk.org Cc: Tetsuya Mukawa References: <1517623898-53443-1-git-send-email-malleshx.koujalagi@intel.com> From: Ferruh Yigit Message-ID: <66d0e1c9-61a9-a077-2e3a-b4509b4a59fc@intel.com> Date: Mon, 5 Mar 2018 14:21:00 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1517623898-53443-1-git-send-email-malleshx.koujalagi@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH] net/null:Different mac address support 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: Mon, 05 Mar 2018 14:21:05 -0000 On 2/3/2018 2:11 AM, Mallesh Koujalagi wrote: > After attaching two Null device to ovs, seeing "00.00.00.00.00.00" mac > address for both null devices. Fix this issue, by setting different mac > address. > > Signed-off-by: Mallesh Koujalagi > --- > drivers/net/null/rte_eth_null.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c > index 9385ffd..98ac115 100644 > --- a/drivers/net/null/rte_eth_null.c > +++ b/drivers/net/null/rte_eth_null.c > @@ -85,8 +85,17 @@ struct pmd_internals { > uint8_t rss_key[40]; /**< 40-byte hash key. */ > }; > > +static struct ether_addr base_eth_addr = { > + .addr_bytes = { > + 0x4E /* N */, > + 0x55 /* U */, > + 0x4C /* L */, > + 0x4C /* L */, > + 0x00, > + 0x00 > + } > +}; > > -static struct ether_addr eth_addr = { .addr_bytes = {0} }; > static struct rte_eth_link pmd_link = { > .link_speed = ETH_SPEED_NUM_10G, > .link_duplex = ETH_LINK_FULL_DUPLEX, > @@ -492,6 +501,7 @@ eth_dev_null_create(struct rte_vdev_device *dev, > struct rte_eth_dev_data *data = NULL; > struct pmd_internals *internals = NULL; > struct rte_eth_dev *eth_dev = NULL; > + struct ether_addr *eth_addr = NULL; > > static const uint8_t default_rss_key[40] = { > 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, 0x41, 0x67, 0x25, 0x3D, > @@ -519,6 +529,15 @@ eth_dev_null_create(struct rte_vdev_device *dev, > rte_free(data); > return -ENOMEM; > } > + eth_addr = rte_zmalloc_socket(rte_vdev_device_name(dev), > + sizeof(*eth_addr), 0, dev->device.numa_node); Why not put "struct ether_addr" into "struct pmd_internals" as ring pmd does? This saves from extra memory allocation and error recovery complexity. > + if (eth_addr == NULL) { > + rte_eth_dev_release_port(eth_dev); > + rte_free(data); Need to free data->dev_private which has been allocated by rte_eth_vdev_allocate() And note rte_eth_vdev_allocate() should be done after that since it memset the data. Also needs to free eth_addr in rte_pmd_null_remove() > + return -ENOMEM; > + } > + *eth_addr = base_eth_addr; > + eth_addr->addr_bytes[5] = eth_dev->data->port_id; > > /* now put it all together > * - store queue data in internals, > @@ -543,7 +562,7 @@ eth_dev_null_create(struct rte_vdev_device *dev, > data->nb_rx_queues = (uint16_t)nb_rx_queues; > data->nb_tx_queues = (uint16_t)nb_tx_queues; > data->dev_link = pmd_link; > - data->mac_addrs = ð_addr; > + data->mac_addrs = eth_addr; > > eth_dev->data = data; > eth_dev->dev_ops = &ops; >