[dpdk-dev] net/i40e: fix VSI MAC filter on primary address change

Message ID 20180103142923.3528-1-olivier.matz@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Helin Zhang
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Olivier Matz Jan. 3, 2018, 2:29 p.m. UTC
  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 <laurent.hardy@6wind.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---

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(+)
  

Comments

Xing, Beilei Jan. 4, 2018, 5:39 a.m. UTC | #1
> -----Original Message-----
> From: Olivier Matz [mailto:olivier.matz@6wind.com]
> Sent: Wednesday, January 3, 2018 10:29 PM
> To: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>
> Cc: stable@dpdk.org; Laurent Hardy <laurent.hardy@6wind.com>
> Subject: [PATCH] net/i40e: fix VSI MAC filter on primary address change
> 
> 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 <laurent.hardy@6wind.com>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>

Thanks for the fix.
Acked-by: Beilei Xing <beilei.xing@intel.com>
  
Igor Ryzhov Jan. 5, 2018, 12:34 p.m. UTC | #2
Thank you for the patch! Comments inline.

On Wed, Jan 3, 2018 at 5:29 PM, Olivier Matz <olivier.matz@6wind.com> wrote:
>
>  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;
>         }
>
>
Is following check really necessary here?
i40e_vsi_delete_mac(vsi, &pf->dev_addr) will do absolutely the same.

+       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);
>

Shouldn't mac_filter.filter_type be set to RTE_MACVLAN_PERFECT_MATCH?


> +       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 */
>

In Linux driver I40E_AQC_WRITE_TYPE_LAA_WOL is used as a flag instead of
0x3.
Shouldn't we use the same flag?


>         i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes, NULL);
>  }
> --
> 2.11.0
>
>
Best regards,
Igor
  
Zhang, Helin Jan. 8, 2018, 6:36 a.m. UTC | #3
Hi Developers and maintainers

Could you help to address the comments from Igor?

Regards,
Helin

> -----Original Message-----

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Igor Ryzhov

> Sent: Friday, January 5, 2018 8:35 PM

> To: Olivier Matz

> Cc: dev@dpdk.org; Wu, Jingjing; Xing, Beilei; stable@dpdk.org; Laurent Hardy

> Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary address

> change

> 

> Thank you for the patch! Comments inline.

> 

> On Wed, Jan 3, 2018 at 5:29 PM, Olivier Matz <olivier.matz@6wind.com>

> wrote:

> >

> >  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;

> >         }

> >

> >

> Is following check really necessary here?

> i40e_vsi_delete_mac(vsi, &pf->dev_addr) will do absolutely the same.

> 

> +       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);

> >

> 

> Shouldn't mac_filter.filter_type be set to RTE_MACVLAN_PERFECT_MATCH?

> 

> 

> > +       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 */

> >

> 

> In Linux driver I40E_AQC_WRITE_TYPE_LAA_WOL is used as a flag instead of

> 0x3.

> Shouldn't we use the same flag?

> 

> 

> >         i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes,

> > NULL);  }

> > --

> > 2.11.0

> >

> >

> Best regards,

> Igor
  
Zhang, Helin Jan. 10, 2018, 1:57 p.m. UTC | #4
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xing, Beilei
> Sent: Thursday, January 4, 2018 1:39 PM
> To: Olivier Matz; dev@dpdk.org; Wu, Jingjing
> Cc: stable@dpdk.org; Laurent Hardy
> Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary address
> change
> 
> 
> 
> > -----Original Message-----
> > From: Olivier Matz [mailto:olivier.matz@6wind.com]
> > Sent: Wednesday, January 3, 2018 10:29 PM
> > To: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>
> > Cc: stable@dpdk.org; Laurent Hardy <laurent.hardy@6wind.com>
> > Subject: [PATCH] net/i40e: fix VSI MAC filter on primary address
> > change
> >
> > 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 <laurent.hardy@6wind.com>
> > Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> 
> Thanks for the fix.
> Acked-by: Beilei Xing <beilei.xing@intel.com>
Applied to dpdk-next-net-intel, thanks!

/Helin
  
Igor Ryzhov Jan. 10, 2018, 10:46 p.m. UTC | #5
Hello everyone.

It's sad that my comments were unanswered.
I'm ok with the first two – they were mostly style-related.
But I made an investigation on the third one and it is a bug.

This is a description (from X710 datasheet) of flags sent to
mac_address_write command:

By bits:
0-7 – Reserved
8 – MAC_MAG_EN
9 – LAA_WOL_PRESERVE
10-13 – Reserved
14-15 – Write type (00 – Update LAA only, 01 – Update LAA and WOL, 10 –
Update port address, 11 – Reserved, but used in Linux to enable multicast
magic packet wake up)

Current code uses 0x3 flag, apparently trying to update LAA, WOL and port
address, but it sets first two bits instead of last two.
These bits are reserved, that's why it doesn't break anything.
At the same time, last two bits are set to zero, and the command changes
LAA address only – it's enough to work in simple case.

The last question – which flag is correct to use – 01 (LAA + WOL) or 11
(LAA + WOL + port).
Linux driver uses the first one, and here is the patch to fix the issue:
https://dpdk.org/dev/patchwork/patch/33524/

Best regards,
Igor

On Wed, Jan 10, 2018 at 4:57 PM, Zhang, Helin <helin.zhang@intel.com> wrote:

>
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xing, Beilei
> > Sent: Thursday, January 4, 2018 1:39 PM
> > To: Olivier Matz; dev@dpdk.org; Wu, Jingjing
> > Cc: stable@dpdk.org; Laurent Hardy
> > Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary
> address
> > change
> >
> >
> >
> > > -----Original Message-----
> > > From: Olivier Matz [mailto:olivier.matz@6wind.com]
> > > Sent: Wednesday, January 3, 2018 10:29 PM
> > > To: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> > > <beilei.xing@intel.com>
> > > Cc: stable@dpdk.org; Laurent Hardy <laurent.hardy@6wind.com>
> > > Subject: [PATCH] net/i40e: fix VSI MAC filter on primary address
> > > change
> > >
> > > 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 <laurent.hardy@6wind.com>
> > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> >
> > Thanks for the fix.
> > Acked-by: Beilei Xing <beilei.xing@intel.com>
> Applied to dpdk-next-net-intel, thanks!
>
> /Helin
>
  
Xing, Beilei Jan. 11, 2018, 8:21 a.m. UTC | #6
Hi Igor,

Thanks for the catch, and glad to see your patch☺ It resolves a potential problem in PMD.
The patch looks OK for me except some minor comments (in another mail thread).

Best Regards,
Beilei

From: Igor Ryzhov [mailto:iryzhov@nfware.com]

Sent: Thursday, January 11, 2018 6:47 AM
To: Zhang, Helin <helin.zhang@intel.com>
Cc: Xing, Beilei <beilei.xing@intel.com>; Olivier Matz <olivier.matz@6wind.com>; dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; stable@dpdk.org; Laurent Hardy <laurent.hardy@6wind.com>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary address change

Hello everyone.

It's sad that my comments were unanswered.
I'm ok with the first two – they were mostly style-related.
But I made an investigation on the third one and it is a bug.

This is a description (from X710 datasheet) of flags sent to mac_address_write command:

By bits:
0-7 – Reserved
8 – MAC_MAG_EN
9 – LAA_WOL_PRESERVE
10-13 – Reserved
14-15 – Write type (00 – Update LAA only, 01 – Update LAA and WOL, 10 – Update port address, 11 – Reserved, but used in Linux to enable multicast magic packet wake up)

Current code uses 0x3 flag, apparently trying to update LAA, WOL and port address, but it sets first two bits instead of last two.
These bits are reserved, that's why it doesn't break anything.
At the same time, last two bits are set to zero, and the command changes LAA address only – it's enough to work in simple case.

The last question – which flag is correct to use – 01 (LAA + WOL) or 11 (LAA + WOL + port).
Linux driver uses the first one, and here is the patch to fix the issue:
https://dpdk.org/dev/patchwork/patch/33524/

Best regards,
Igor

On Wed, Jan 10, 2018 at 4:57 PM, Zhang, Helin <helin.zhang@intel.com<mailto:helin.zhang@intel.com>> wrote:


> -----Original Message-----

> From: dev [mailto:dev-bounces@dpdk.org<mailto:dev-bounces@dpdk.org>] On Behalf Of Xing, Beilei

> Sent: Thursday, January 4, 2018 1:39 PM

> To: Olivier Matz; dev@dpdk.org<mailto:dev@dpdk.org>; Wu, Jingjing

> Cc: stable@dpdk.org<mailto:stable@dpdk.org>; Laurent Hardy

> Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary address

> change

>

>

>

> > -----Original Message-----

> > From: Olivier Matz [mailto:olivier.matz@6wind.com<mailto:olivier.matz@6wind.com>]

> > Sent: Wednesday, January 3, 2018 10:29 PM

> > To: dev@dpdk.org<mailto:dev@dpdk.org>; Wu, Jingjing <jingjing.wu@intel.com<mailto:jingjing.wu@intel.com>>; Xing, Beilei

> > <beilei.xing@intel.com<mailto:beilei.xing@intel.com>>

> > Cc: stable@dpdk.org<mailto:stable@dpdk.org>; Laurent Hardy <laurent.hardy@6wind.com<mailto:laurent.hardy@6wind.com>>

> > Subject: [PATCH] net/i40e: fix VSI MAC filter on primary address

> > change

> >

> > 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<mailto:stable@dpdk.org>

> >

> > Signed-off-by: Laurent Hardy <laurent.hardy@6wind.com<mailto:laurent.hardy@6wind.com>>

> > Signed-off-by: Olivier Matz <olivier.matz@6wind.com<mailto:olivier.matz@6wind.com>>

>

> Thanks for the fix.

> Acked-by: Beilei Xing <beilei.xing@intel.com<mailto:beilei.xing@intel.com>>

Applied to dpdk-next-net-intel, thanks!

/Helin
  
Igor Ryzhov Jan. 11, 2018, 10:08 a.m. UTC | #7
Sent v2: https://dpdk.org/dev/patchwork/patch/33570/

On Thu, Jan 11, 2018 at 11:21 AM, Xing, Beilei <beilei.xing@intel.com>
wrote:

> Hi Igor,
>
>
>
> Thanks for the catch, and glad to see your patchJ It resolves a potential
> problem in PMD.
>
> The patch looks OK for me except some minor comments (in another mail
> thread).
>
>
>
> Best Regards,
>
> Beilei
>
>
>
> *From:* Igor Ryzhov [mailto:iryzhov@nfware.com]
> *Sent:* Thursday, January 11, 2018 6:47 AM
> *To:* Zhang, Helin <helin.zhang@intel.com>
> *Cc:* Xing, Beilei <beilei.xing@intel.com>; Olivier Matz <
> olivier.matz@6wind.com>; dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>;
> stable@dpdk.org; Laurent Hardy <laurent.hardy@6wind.com>
>
> *Subject:* Re: [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary
> address change
>
>
>
> Hello everyone.
>
>
>
> It's sad that my comments were unanswered.
>
> I'm ok with the first two – they were mostly style-related.
>
> But I made an investigation on the third one and it is a bug.
>
>
>
> This is a description (from X710 datasheet) of flags sent to
> mac_address_write command:
>
>
>
> By bits:
>
> 0-7 – Reserved
>
> 8 – MAC_MAG_EN
>
> 9 – LAA_WOL_PRESERVE
>
> 10-13 – Reserved
>
> 14-15 – Write type (00 – Update LAA only, 01 – Update LAA and WOL, 10 –
> Update port address, 11 – Reserved, but used in Linux to enable multicast
> magic packet wake up)
>
>
>
> Current code uses 0x3 flag, apparently trying to update LAA, WOL and port
> address, but it sets first two bits instead of last two.
>
> These bits are reserved, that's why it doesn't break anything.
>
> At the same time, last two bits are set to zero, and the command changes
> LAA address only – it's enough to work in simple case.
>
>
>
> The last question – which flag is correct to use – 01 (LAA + WOL) or 11
> (LAA + WOL + port).
>
> Linux driver uses the first one, and here is the patch to fix the issue:
>
> https://dpdk.org/dev/patchwork/patch/33524/
>
>
>
> Best regards,
>
> Igor
>
>
>
> On Wed, Jan 10, 2018 at 4:57 PM, Zhang, Helin <helin.zhang@intel.com>
> wrote:
>
>
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xing, Beilei
> > Sent: Thursday, January 4, 2018 1:39 PM
> > To: Olivier Matz; dev@dpdk.org; Wu, Jingjing
> > Cc: stable@dpdk.org; Laurent Hardy
> > Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary
> address
> > change
> >
> >
> >
> > > -----Original Message-----
> > > From: Olivier Matz [mailto:olivier.matz@6wind.com]
> > > Sent: Wednesday, January 3, 2018 10:29 PM
> > > To: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> > > <beilei.xing@intel.com>
> > > Cc: stable@dpdk.org; Laurent Hardy <laurent.hardy@6wind.com>
> > > Subject: [PATCH] net/i40e: fix VSI MAC filter on primary address
> > > change
> > >
> > > 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 <laurent.hardy@6wind.com>
> > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> >
> > Thanks for the fix.
> > Acked-by: Beilei Xing <beilei.xing@intel.com>
>
> Applied to dpdk-next-net-intel, thanks!
>
> /Helin
>
>
>
  

Patch

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);
 }