From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id C92251B1E1; Wed, 3 Jan 2018 15:47:24 +0100 (CET) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 8BCD911CC91; Wed, 3 Jan 2018 15:46:34 +0100 (CET) From: Olivier Matz To: dev@dpdk.org, Jingjing Wu , Beilei Xing Cc: stable@dpdk.org, Laurent Hardy Date: Wed, 3 Jan 2018 15:29:23 +0100 Message-Id: <20180103142923.3528-1-olivier.matz@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary address change 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: Wed, 03 Jan 2018 14:47:24 -0000 When primary address mac is changed, the mac filters were not updated in the VSI with the new mac addr and incoming packets with this destination address are dropped by the hardware filters. This patch removes the VSI mac filter for the previous mac address and adds a new one for new mac address. Fixes: e18e01e92c29 ("i40e: support default MAC address setting") Cc: stable@dpdk.org Signed-off-by: Laurent Hardy Signed-off-by: Olivier Matz --- Please, review the patch carefully since I'm not an i40e expert ;) To reproduce the issue: make config T=x86_64-native-linuxapp-gcc make -j4 mkdir -p /mnt/huge mount -t hugetlbfs nodev /mnt/huge echo 256 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages echo 256 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages modprobe uio_pci_generic insmod ./build/kmod/igb_uio.ko python usertools/dpdk-devbind.py -b igb_uio 0000:02:00.0 ./build/app/testpmd -l 0,1 --log-level 8 -- --total-num-mbufs=65536 -i --port-topology=chained # note: the MAC address of port is 68:05:CA:38:6D:C0 set promisc all off show port info 0 set fwd rxonly set verbose 1 start # on a tester node, send a packet with scapy # it is properly received by the PMD sendp(Ether(dst='68:05:CA:38:6D:C0')/IP()/UDP()/Raw("x"*10), iface='ens3f2') # back on DUT, change primary mac addr on port 0 stop mac_addr set 0 00:00:01:02:03:04 start # Without the patch, this packet is not received sendp(Ether(dst='00:00:01:02:03:04')/IP()/UDP()/Raw("x"*10), iface='ens3f2') # Without the patch, this packet with the old addr is received sendp(Ether(dst='68:05:CA:38:6D:C0')/IP()/UDP()/Raw("x"*10), iface='ens3f2') drivers/net/i40e/i40e_ethdev.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 811cc9ffe..e7d070879 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -10818,12 +10818,41 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr) { struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct i40e_vsi *vsi = pf->main_vsi; + struct i40e_mac_filter_info mac_filter; + struct i40e_mac_filter *f; + int ret; if (!is_valid_assigned_ether_addr(mac_addr)) { PMD_DRV_LOG(ERR, "Tried to set invalid MAC address."); return; } + TAILQ_FOREACH(f, &vsi->mac_list, next) { + if (is_same_ether_addr(&pf->dev_addr, &f->mac_info.mac_addr)) + break; + } + + if (f == NULL) { + PMD_DRV_LOG(ERR, "Failed to find filter for default mac"); + return; + } + + mac_filter = f->mac_info; + ret = i40e_vsi_delete_mac(vsi, &mac_filter.mac_addr); + if (ret != I40E_SUCCESS) { + PMD_DRV_LOG(ERR, "Failed to delete mac filter"); + return; + } + memcpy(&mac_filter.mac_addr, mac_addr, ETH_ADDR_LEN); + ret = i40e_vsi_add_mac(vsi, &mac_filter); + if (ret != I40E_SUCCESS) { + PMD_DRV_LOG(ERR, "Failed to add mac filter"); + return; + } + memcpy(&pf->dev_addr, mac_addr, ETH_ADDR_LEN); + /* Flags: 0x3 updates port address */ i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes, NULL); } -- 2.11.0