From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 657E31DBE for ; Mon, 3 Sep 2018 17:00:49 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2018 08:00:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,325,1531810800"; d="scan'208";a="260342502" Received: from fyigit-mobl.ger.corp.intel.com (HELO [10.237.221.56]) ([10.237.221.56]) by fmsmga006.fm.intel.com with ESMTP; 03 Sep 2018 08:00:47 -0700 To: Cian Ferriter Cc: dev@dpdk.org References: <1535983725-84966-1-git-send-email-cian.ferriter@intel.com> From: Ferruh Yigit Openpgp: preference=signencrypt Message-ID: <958caf71-2ebe-f436-117b-aa7151688608@intel.com> Date: Mon, 3 Sep 2018 16:00:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1535983725-84966-1-git-send-email-cian.ferriter@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net/pcap: Generate unique MAC addresses for interfaces 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, 03 Sep 2018 15:00:49 -0000 On 9/3/2018 3:08 PM, Cian Ferriter wrote: > The MAC addresses are generated in the same manner as in the TAP PMD, > where the address is based on the number of PCAP ports created. > > Signed-off-by: Cian Ferriter > --- > drivers/net/pcap/rte_eth_pcap.c | 6 ++++++ > 1 files changed, 6 insertions(+), 0 deletions(-) > > diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c > index e8810a1..ced9cd9 100644 > --- a/drivers/net/pcap/rte_eth_pcap.c > +++ b/drivers/net/pcap/rte_eth_pcap.c > @@ -417,11 +417,17 @@ struct pmd_devargs { > static int > eth_dev_start(struct rte_eth_dev *dev) > { > + static int iface_idx; > unsigned int i; > struct pmd_internals *internals = dev->data->dev_private; > struct pcap_tx_queue *tx; > struct pcap_rx_queue *rx; > > + /* Interface MAC = 00:70:63:61:70: */ > + memcpy((char *)dev->data->mac_addrs->addr_bytes, "\0pcap", > + ETHER_ADDR_LEN); > + dev->data->mac_addrs->addr_bytes[ETHER_ADDR_LEN - 1] = iface_idx++; This won't work as you expected, you will end up having same MAC for pcap interfaces because data->mac_addrs points to same memory for all instances. It is better to have "struct ether_addr" in "pmd_internals" and set the MAC address for that interface in "pmd_init_internals()". It can be good to set fixed part of the MAC as macro and add static variable (iface_idx) where other global variables are declared. And it would be nice if you can add why you need this, what is enabled by having this update, in commit log. Thanks, ferruh