Skip to contentSkip to conversation

ethdev: fix setting of MAC address

PATCH NAK Olivier Matz 6 participants 15 messages Dec 14, 2017 – Jan 8, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethdev: fix setting of MAC address

From: Laurent Hardy <[email protected]>

When a new mac address is set, it is saved in dev->data->mac_addrs before the ethdev handler is called.

First, it is inconsistent with the other ethdev functions rte_eth_dev_mac_addr_remove() and rte_eth_dev_mac_addr_add().

Moreover, it prevents the drivers from wrongly comparing the old address and the new one, like it's done in i40evf driver:

	if (is_same_ether_addr(mac_addr, dev->data->mac_addrs))
		return;
Fixes 943c2d899a0c ("net/i40e: set VF MAC from VF")
Fixes 854d8ad4ef68 ("ethdev: add default mac address modifier")
---
 lib/librte_ether/rte_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +2 -2
index 4f492e3db..297c02a54 100644
@@ -2643,11 +2643,11 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
 
+	(*dev->dev_ops->mac_addr_set)(dev, addr);
+
 	/* Update default address in NIC data structure */
 	ether_addr_copy(addr, &dev->data->mac_addrs[0]);
 
-	(*dev->dev_ops->mac_addr_set)(dev, addr);
-
 	return 0;
 }
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 30 lines · Olivier Matz

From: Laurent Hardy <[email protected]>

When a new mac address is set, it is saved in dev->data->mac_addrs before the ethdev handler is called.

First, it is inconsistent with the other ethdev functions rte_eth_dev_mac_addr_remove() and rte_eth_dev_mac_addr_add().

Moreover, it prevents the drivers from wrongly comparing the old address and the new one, like it's done in i40evf driver:

	if (is_same_ether_addr(mac_addr, dev->data->mac_addrs))
		return;
Fixes 943c2d899a0c ("net/i40e: set VF MAC from VF")
Fixes 854d8ad4ef68 ("ethdev: add default mac address modifier")
---
  lib/librte_ether/rte_ethdev.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -0
index 4f492e3db..297c02a54 100644
@@ -2643,11 +2643,11 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
  	dev = &rte_eth_devices[port_id];
  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);

lib/librte_ether/rte_ethdev.c rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr) · line 2652

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +2 -2
 
+	(*dev->dev_ops->mac_addr_set)(dev, addr);
+
  	/* Update default address in NIC data structure */
  	ether_addr_copy(addr, &dev->data->mac_addrs[0]);
 
-	(*dev->dev_ops->mac_addr_set)(dev, addr);
-
  	return 0;
  }

NACK, unfortunately it will break net/sfc in one of branches when a new MAC is set using restart. It relies on the fact that a new MAC is already available in device data.

#2 lore raw

Hello Andrew,

Don't you think that it's not correct that net/sfc works that way?

If we go further, dev->dev_ops->mac_addr_set not only should be called before ether_addr_copy.
It should return status code, and in case of error ether_addr_copy shouldn't be called at all.
Am I wrong?

Best regards,
Igor

On Mon, Dec 18, 2017 at 1:35 PM, Andrew Rybchenko <[email protected]

Quoted 51 lines

wrote:

Quoted 31 lines · Olivier Matz

From: Laurent Hardy <[email protected]>

When a new mac address is set, it is saved in dev->data->mac_addrs before the ethdev handler is called.

First, it is inconsistent with the other ethdev functions rte_eth_dev_mac_addr_remove() and rte_eth_dev_mac_addr_add().

Moreover, it prevents the drivers from wrongly comparing the old address and the new one, like it's done in i40evf driver:

        if (is_same_ether_addr(mac_addr, dev->data->mac_addrs))
                return;
Fixes 943c2d899a0c ("net/i40e: set VF MAC from VF")
Fixes 854d8ad4ef68 ("ethdev: add default mac address modifier")
---
  lib/librte_ether/rte_ethdev.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev. renamed from lib/librte_ether/rte_ethdev.c +0 -0

c
index 4f492e3db..297c02a54 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -2643,11 +2643,11 @@ rte_eth_dev_default_mac_addr_set(uint16_t
 port_id, struct ether_addr *addr)
        dev = &rte_eth_devices[port_id];

lib/librte_ether/rte_ethdev.c rte_eth_dev_default_mac_addr_set(uint16_t · line 2653

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +1 -1
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
  +     (*dev->dev_ops->mac_addr_set)(dev, addr);
+
        /* Update default address in NIC data structure */
        ether_addr_copy(addr, &dev->data->mac_addrs[0]);
  -     (*dev->dev_ops->mac_addr_set)(dev, addr);
-
        return 0;
  }
 

NACK, unfortunately it will break net/sfc in one of branches when a new MAC is set using restart. It relies on the fact that a new MAC is already available in
device data.

#3 lore raw
Quoted 59 lines · Igor Ryzhov

On Mon, Dec 18, 2017 at 1:35 PM, Andrew Rybchenko <[email protected] <mailto:[email protected]>> wrote:

    On 12/14/2017 08:15 PM, Olivier Matz wrote:

        From: Laurent Hardy <[email protected]
        <mailto:[email protected]>>

        When a new mac address is set, it is saved in dev->data->mac_addrs
        before the ethdev handler is called.

        First, it is inconsistent with the other ethdev functions
        rte_eth_dev_mac_addr_remove() and rte_eth_dev_mac_addr_add().

        Moreover, it prevents the drivers from wrongly comparing the
        old address
        and the new one, like it's done in i40evf driver:

                if (is_same_ether_addr(mac_addr, dev->data->mac_addrs))
                        return;

        Fixes: 943c2d899a0c ("net/i40e: set VF MAC from VF")
        Fixes: 854d8ad4ef68 ("ethdev: add default mac address modifier")
        Cc: [email protected] <mailto:[email protected]>

        Signed-off-by: Laurent Hardy <[email protected]
        <mailto:[email protected]>>
        ---
          lib/librte_ether/rte_ethdev.c | 4 ++--
          1 file changed, 2 insertions(+), 2 deletions(-)

        diff --git a/lib/librte_ether/rte_ethdev.c
        b/lib/librte_ether/rte_ethdev.c
        index 4f492e3db..297c02a54 100644
        --- a/lib/librte_ether/rte_ethdev.c
        +++ b/lib/librte_ether/rte_ethdev.c
        @@ -2643,11 +2643,11 @@
        rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct
        ether_addr *addr)
                dev = &rte_eth_devices[port_id];
                RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set,
        -ENOTSUP);
          +     (*dev->dev_ops->mac_addr_set)(dev, addr);
        +
                /* Update default address in NIC data structure */
                ether_addr_copy(addr, &dev->data->mac_addrs[0]);
          -     (*dev->dev_ops->mac_addr_set)(dev, addr);
        -
                return 0;
          }


    NACK, unfortunately it will break net/sfc in one of branches when
    a new MAC
    is set using restart. It relies on the fact that a new MAC is
    already available in
    device data.
Quoted 6 lines

Hello Andrew,

Don't you think that it's not correct that net/sfc works that way?

If we go further, dev->dev_ops->mac_addr_set not only should be called before ether_addr_copy. It should return status code, and in case of error ether_addr_copy shouldn't be

called at all.

Quoted 1 line

Am I wrong?

Current behaviour is convenient. Alternative will require copy of MAC address to set in device private data and one more copy in the function to rollback in the case of failure. If there are good reasons to change behaviour, I don't mind but PMDs should be reviewed carefully and fixed before the change.

#4 lore raw

Hi,

Quoted 63 lines · Andrew Rybchenko
Quoted 62 lines · Igor Ryzhov

On Mon, Dec 18, 2017 at 1:35 PM, Andrew Rybchenko <[email protected] <mailto:[email protected]>> wrote:

    On 12/14/2017 08:15 PM, Olivier Matz wrote:

        From: Laurent Hardy <[email protected]
        <mailto:[email protected]>>

        When a new mac address is set, it is saved in dev->data->mac_addrs
        before the ethdev handler is called.

        First, it is inconsistent with the other ethdev functions
        rte_eth_dev_mac_addr_remove() and rte_eth_dev_mac_addr_add().

        Moreover, it prevents the drivers from wrongly comparing the
        old address
        and the new one, like it's done in i40evf driver:

                if (is_same_ether_addr(mac_addr, dev->data->mac_addrs))
                        return;

        Fixes: 943c2d899a0c ("net/i40e: set VF MAC from VF")
        Fixes: 854d8ad4ef68 ("ethdev: add default mac address modifier")
        Cc: [email protected] <mailto:[email protected]>

        Signed-off-by: Laurent Hardy <[email protected]
        <mailto:[email protected]>>
        ---
          lib/librte_ether/rte_ethdev.c | 4 ++--
          1 file changed, 2 insertions(+), 2 deletions(-)

        diff --git a/lib/librte_ether/rte_ethdev.c
        b/lib/librte_ether/rte_ethdev.c
        index 4f492e3db..297c02a54 100644
        --- a/lib/librte_ether/rte_ethdev.c
        +++ b/lib/librte_ether/rte_ethdev.c
        @@ -2643,11 +2643,11 @@
        rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct
        ether_addr *addr)
                dev = &rte_eth_devices[port_id];
                RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set,
        -ENOTSUP);
          +     (*dev->dev_ops->mac_addr_set)(dev, addr);
        +
                /* Update default address in NIC data structure */
                ether_addr_copy(addr, &dev->data->mac_addrs[0]);
          -     (*dev->dev_ops->mac_addr_set)(dev, addr);
        -
                return 0;
          }


    NACK, unfortunately it will break net/sfc in one of branches when
    a new MAC
    is set using restart. It relies on the fact that a new MAC is
    already available in
    device data.

Hello Andrew,

Quoted 8 lines
Quoted 3 lines

Don't you think that it's not correct that net/sfc works that way?

If we go further, dev->dev_ops->mac_addr_set not only should be called

before ether_addr_copy.

Quoted 2 lines

It should return status code, and in case of error ether_addr_copy shouldn't be

called at all.

Quoted 1 line

Am I wrong?

Yes, I also have the same feeling.

Quoted 6 lines

Current behaviour is convenient. Alternative will require copy of MAC address
to set in device private data and one more copy in the function to rollback in
the case of failure. If there are good reasons to change behaviour, I don't mind but PMDs should be reviewed carefully and fixed before the change.

Right. The first version of the patch was just a fix of the i40e code, which was of course less risky. But we finally decided to to that way for consistency.

I will review the other PMDs and send a v2 that should not break them. If you have any guidelines for net/sfc, they will be welcome :)

Thanks for the review.
Olivier

#5 lore raw
Quoted 81 lines · Olivier MATZ

Hi,

Quoted 62 lines · Andrew Rybchenko
Quoted 61 lines · Igor Ryzhov

On Mon, Dec 18, 2017 at 1:35 PM, Andrew Rybchenko <[email protected] <mailto:[email protected]>> wrote:

     On 12/14/2017 08:15 PM, Olivier Matz wrote:

         From: Laurent Hardy <[email protected]
         <mailto:[email protected]>>

         When a new mac address is set, it is saved in dev->data->mac_addrs
         before the ethdev handler is called.

         First, it is inconsistent with the other ethdev functions
         rte_eth_dev_mac_addr_remove() and rte_eth_dev_mac_addr_add().

         Moreover, it prevents the drivers from wrongly comparing the
         old address
         and the new one, like it's done in i40evf driver:

                 if (is_same_ether_addr(mac_addr, dev->data->mac_addrs))
                         return;

         Fixes: 943c2d899a0c ("net/i40e: set VF MAC from VF")
         Fixes: 854d8ad4ef68 ("ethdev: add default mac address modifier")
         Cc: [email protected] <mailto:[email protected]>

         Signed-off-by: Laurent Hardy <[email protected]
         <mailto:[email protected]>>
         ---
           lib/librte_ether/rte_ethdev.c | 4 ++--
           1 file changed, 2 insertions(+), 2 deletions(-)

         diff --git a/lib/librte_ether/rte_ethdev.c
         b/lib/librte_ether/rte_ethdev.c
         index 4f492e3db..297c02a54 100644
         --- a/lib/librte_ether/rte_ethdev.c
         +++ b/lib/librte_ether/rte_ethdev.c
         @@ -2643,11 +2643,11 @@
         rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct
         ether_addr *addr)
                 dev = &rte_eth_devices[port_id];
                 RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set,
         -ENOTSUP);
           +     (*dev->dev_ops->mac_addr_set)(dev, addr);
         +
                 /* Update default address in NIC data structure */
                 ether_addr_copy(addr, &dev->data->mac_addrs[0]);
           -     (*dev->dev_ops->mac_addr_set)(dev, addr);
         -
                 return 0;
           }


     NACK, unfortunately it will break net/sfc in one of branches when
     a new MAC
     is set using restart. It relies on the fact that a new MAC is
     already available in
     device data.

Hello Andrew,

Quoted 8 lines
Quoted 3 lines

Don't you think that it's not correct that net/sfc works that way?

If we go further, dev->dev_ops->mac_addr_set not only should be called

before ether_addr_copy.

Quoted 2 lines

It should return status code, and in case of error ether_addr_copy shouldn't be

called at all.

Quoted 1 line

Am I wrong?

Yes, I also have the same feeling.

Quoted 6 lines

Current behaviour is convenient. Alternative will require copy of MAC address
to set in device private data and one more copy in the function to rollback in
the case of failure. If there are good reasons to change behaviour, I don't mind but PMDs should be reviewed carefully and fixed before the change.

Quoted 6 lines

Right. The first version of the patch was just a fix of the i40e code, which was of course less risky. But we finally decided to to that way for consistency.

I will review the other PMDs and send a v2 that should not break them. If you have any guidelines for net/sfc, they will be welcome :)

We'll send net/sfc patch today/tomorrow to fix it.

Thanks,
Andrew.

#6 lore raw
Quoted 82 lines · Andrew Rybchenko
Quoted 81 lines · Olivier MATZ

Hi,

Quoted 62 lines · Andrew Rybchenko
Quoted 61 lines · Igor Ryzhov

On Mon, Dec 18, 2017 at 1:35 PM, Andrew Rybchenko <[email protected] <mailto:[email protected]>> wrote:

     On 12/14/2017 08:15 PM, Olivier Matz wrote:

         From: Laurent Hardy <[email protected] <mailto:[email protected]>>

         When a new mac address is set, it is saved in dev->data->mac_addrs before the ethdev handler is called.

         First, it is inconsistent with the other ethdev functions rte_eth_dev_mac_addr_remove() and rte_eth_dev_mac_addr_add().

         Moreover, it prevents the drivers from wrongly comparing the old address
         and the new one, like it's done in i40evf driver:

                 if (is_same_ether_addr(mac_addr, dev->data->mac_addrs)) return;

Fixes 943c2d899a0c ("net/i40e: set VF MAC from VF")
Fixes 854d8ad4ef68 ("ethdev: add default mac address modifier")

         <mailto:[email protected]>>
         ---
           lib/librte_ether/rte_ethdev.c | 4 ++--

           1 file changed, 2 insertions(+), 2 deletions(-)

         diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
         index 4f492e3db..297c02a54 100644
         --- a/lib/librte_ether/rte_ethdev.c
         +++ b/lib/librte_ether/rte_ethdev.c
         @@ -2643,11 +2643,11 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
                 dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
           +     (*dev->dev_ops->mac_addr_set)(dev, addr); +
                 /* Update default address in NIC data structure */ ether_addr_copy(addr, &dev->data->mac_addrs[0]); -     (*dev->dev_ops->mac_addr_set)(dev, addr); -
                 return 0;
           }

     NACK, unfortunately it will break net/sfc in one of branches when a new MAC
     is set using restart. It relies on the fact that a new MAC is already available in
     device data.

Hello Andrew,

Quoted 8 lines
Quoted 3 lines

Don't you think that it's not correct that net/sfc works that way?

If we go further, dev->dev_ops->mac_addr_set not only should be called

before ether_addr_copy.

Quoted 2 lines

It should  return status code, and in case of error ether_addr_copy shouldn't be

called at all.

Quoted 1 line

Am I wrong?

Yes, I also have the same feeling.

Quoted 6 lines

Current behaviour is convenient. Alternative will require copy of MAC address
to set in device private data and one more copy in the function to rollback in
the case of failure. If there are good reasons to change behaviour, I don't mind but PMDs should be reviewed carefully and fixed before the change.

Quoted 8 lines
Quoted 6 lines

Right. The first version of the patch was just a fix of the i40e code, which was of course less risky. But we finally decided to to that way for consistency.

I will review the other PMDs and send a v2 that should not break them. If you have any guidelines for net/sfc, they will be welcome :)

We'll send net/sfc patch today/tomorrow to fix it.

Done [1]

[1] http://dpdk.org/ml/archives/dev/2017-December/084526.html

#7 lore raw

Hi,

Quoted 92 lines · Andrew Rybchenko
Quoted 91 lines · Andrew Rybchenko
Quoted 90 lines · Olivier MATZ

Hi,

Quoted 65 lines · Andrew Rybchenko
Quoted 64 lines · Igor Ryzhov

On Mon, Dec 18, 2017 at 1:35 PM, Andrew Rybchenko <[email protected] <mailto:[email protected]>> wrote:

     On 12/14/2017 08:15 PM, Olivier Matz wrote:

         From: Laurent Hardy <[email protected] <mailto:[email protected]>>

         When a new mac address is set, it is saved in dev->data->mac_addrs
         before the ethdev handler is called.

         First, it is inconsistent with the other ethdev functions rte_eth_dev_mac_addr_remove() and rte_eth_dev_mac_addr_add().

         Moreover, it prevents the drivers from wrongly comparing the old address
         and the new one, like it's done in i40evf driver:

                 if (is_same_ether_addr(mac_addr,
dev->data->mac_addrs))
                         return;

Fixes 943c2d899a0c ("net/i40e: set VF MAC from VF")
Fixes 854d8ad4ef68 ("ethdev: add default mac

address modifier")
         Cc: [email protected] <mailto:[email protected]>

         <mailto:[email protected]>>
         ---
           lib/librte_ether/rte_ethdev.c | 4 ++--

           1 file changed, 2 insertions(+), 2 deletions(-)

         diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
         index 4f492e3db..297c02a54 100644
         --- a/lib/librte_ether/rte_ethdev.c
         +++ b/lib/librte_ether/rte_ethdev.c
         @@ -2643,11 +2643,11 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
                 dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
           +     (*dev->dev_ops->mac_addr_set)(dev, addr); +
                 /* Update default address in NIC data structure */ ether_addr_copy(addr, &dev->data->mac_addrs[0]); -     (*dev->dev_ops->mac_addr_set)(dev, addr); -
                 return 0;
           }

     NACK, unfortunately it will break net/sfc in one of branches when a new MAC
     is set using restart. It relies on the fact that a new MAC is already available in
     device data.

Hello Andrew,

Quoted 8 lines
Quoted 3 lines

Don't you think that it's not correct that net/sfc works that way?

If we go further, dev->dev_ops->mac_addr_set not only should be called

before ether_addr_copy.

Quoted 2 lines

It should  return status code, and in case of error ether_addr_copy shouldn't be

called at all.

Quoted 1 line

Am I wrong?

Yes, I also have the same feeling.

Quoted 8 lines

Current behaviour is convenient. Alternative will require copy of MAC address
to set in device private data and one more copy in the function to rollback
in
the case of failure. If there are good reasons to change behaviour, I don't
mind but PMDs should be reviewed carefully and fixed before the change.

Right. The first version of the patch was just a fix of the i40e code, which was of course less risky. But we finally decided to to that way for consistency.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I will review the other PMDs and send a v2 that should not break them. If you have any guidelines for net/sfc, they will be welcome :)

We'll send net/sfc patch today/tomorrow to fix it.

Done [1]

[1] http://dpdk.org/ml/archives/dev/2017-December/084526.html

I've walked through the PMDs as suggested by Andrew, and there was indeed some conflicts with the initial patch. I've just submitted the patch for vmxnet3 [1] and bnxt [2].

But there is still an issue with the qede driver, that overwrites the MAC address in dev->data by the previous one if it cannot be set. It seems it's the only driver that does this in error case, but anyway, this behavior will be broken by the initial patch.

So I submitted a v2 that only changes the behavior for i40evf [3].

I propose to include these 3 patches for 18.02, and announce an ABI change for 18.05 to add a return value to dev_ops->mac_addr_set() and move the ether_addr_copy() after the callback, only in case of success.

Any opinions?

[1] https://dpdk.org/dev/patchwork/patch/32855/
[2] https://dpdk.org/dev/patchwork/patch/32855/
[3] https://dpdk.org/dev/patchwork/patch/32855/

#8 lore raw
Quoted 15 lines · Olivier Matz

I've walked through the PMDs as suggested by Andrew, and there was indeed some conflicts with the initial patch. I've just submitted the patch for vmxnet3 [1] and bnxt [2].

But there is still an issue with the qede driver, that overwrites the MAC address in dev->data by the previous one if it cannot be set. It seems it's the only driver that does this in error case, but anyway, this behavior will be broken by the initial patch.

So I submitted a v2 that only changes the behavior for i40evf [3].

I propose to include these 3 patches for 18.02, and announce an ABI change for 18.05 to add a return value to dev_ops->mac_addr_set() and move the ether_addr_copy() after the callback, only in case of success.

Quoted 6 lines

Any opinions?

[1] https://dpdk.org/dev/patchwork/patch/32855/
[2] https://dpdk.org/dev/patchwork/patch/32855/
[3] https://dpdk.org/dev/patchwork/patch/32855/

Sorry:

[1] https://dpdk.org/dev/patchwork/patch/32855/
[2] https://dpdk.org/dev/patchwork/patch/32856/
[3] https://dpdk.org/dev/patchwork/patch/32857/

#9 lore raw
Quoted 10 lines · Olivier Matz
Quoted 9 lines · Olivier Matz

I've walked through the PMDs as suggested by Andrew, and there was indeed some conflicts with the initial patch. I've just submitted the patch for vmxnet3 [1] and bnxt [2].

But there is still an issue with the qede driver, that overwrites the MAC address in dev->data by the previous one if it cannot be set. It seems it's the only driver that does this in error case, but anyway, this behavior will be broken by the initial patch.

Quoted 7 lines
Quoted 7 lines

So I submitted a v2 that only changes the behavior for i40evf [3].

I propose to include these 3 patches for 18.02, and announce an ABI change for 18.05 to add a return value to dev_ops->mac_addr_set() and move the ether_addr_copy() after the callback, only in case of success.

Any opinions?

I'm not sure if dev_ops->mac_addr_set() is a part of ABI.
It is an internal interface between rte_ethdev library and drivers. Yes, out-of-tree drivers will be broken.
rte_eth_dev_default_mac_addr_set() is definitely a part of API/ABI, but it already has return value.
So, I'm not sure that we have to wait for 18.05, but it is still may be too late for 18.02 since integration deadline is pretty close.

Quoted 3 lines

[1] https://dpdk.org/dev/patchwork/patch/32855/
[2] https://dpdk.org/dev/patchwork/patch/32856/
[3] https://dpdk.org/dev/patchwork/patch/32857/

Many thanks for drivers review and fixes.

#10 lore raw
Quoted 19 lines · Andrew Rybchenko
Quoted 10 lines · Olivier Matz
Quoted 9 lines · Olivier Matz

I've walked through the PMDs as suggested by Andrew, and there was indeed some conflicts with the initial patch. I've just submitted the patch for vmxnet3 [1] and bnxt [2].

But there is still an issue with the qede driver, that overwrites the MAC address in dev->data by the previous one if it cannot be set. It seems it's the only driver that does this in error case, but anyway, this behavior will be broken by the initial patch.

Quoted 7 lines
Quoted 7 lines

So I submitted a v2 that only changes the behavior for i40evf [3].

I propose to include these 3 patches for 18.02, and announce an ABI change for 18.05 to add a return value to dev_ops->mac_addr_set() and move the ether_addr_copy() after the callback, only in case of success.

Any opinions?

Quoted 7 lines

I'm not sure if dev_ops->mac_addr_set() is a part of ABI.
It is an internal interface between rte_ethdev library and drivers. Yes, out-of-tree drivers will be broken.
rte_eth_dev_default_mac_addr_set() is definitely a part of API/ABI, but it already has return value.
So, I'm not sure that we have to wait for 18.05, but it is still may be too late for 18.02 since integration deadline is pretty close.

I think there is no API/ABI breakage, but it can be good to announce the change and give time for modifications.

+1 for proposal.

Quoted 6 lines
Quoted 4 lines

[1] https://dpdk.org/dev/patchwork/patch/32855/
[2] https://dpdk.org/dev/patchwork/patch/32856/
[3] https://dpdk.org/dev/patchwork/patch/32857/

Many thanks for drivers review and fixes.

#11 lore raw
Quoted 28 lines · Ferruh Yigit
Quoted 19 lines · Andrew Rybchenko
Quoted 10 lines · Olivier Matz
Quoted 9 lines · Olivier Matz

I've walked through the PMDs as suggested by Andrew, and there was indeed some conflicts with the initial patch. I've just submitted the patch for vmxnet3 [1] and bnxt [2].

But there is still an issue with the qede driver, that overwrites the MAC address in dev->data by the previous one if it cannot be set. It seems it's the only driver that does this in error case, but anyway, this behavior will be broken by the initial patch.

Quoted 7 lines
Quoted 7 lines

So I submitted a v2 that only changes the behavior for i40evf [3].

I propose to include these 3 patches for 18.02, and announce an ABI change for 18.05 to add a return value to dev_ops->mac_addr_set() and move the ether_addr_copy() after the callback, only in case of success.

Any opinions?

Quoted 7 lines

I'm not sure if dev_ops->mac_addr_set() is a part of ABI.
It is an internal interface between rte_ethdev library and drivers. Yes, out-of-tree drivers will be broken.
rte_eth_dev_default_mac_addr_set() is definitely a part of API/ABI, but it already has return value.
So, I'm not sure that we have to wait for 18.05, but it is still may be too late for 18.02 since integration deadline is pretty close.

Quoted 4 lines

I think there is no API/ABI breakage, but it can be good to announce the change and give time for modifications.

+1 for proposal.

Thanks Andrew and Ferruh for the feedback.
I'll send an RFC for this soon.

#12 lore raw

PATCH v2 1/1 net/i40e: fix setting of MAC address on i40evf

In reply to Olivier Matz

When setting the MAC address, the ethdev layer copies the new mac address in dev->data->mac_addrs[0] before calling the dev_ops.

Therefore, "is_same_ether_addr(mac_addr, dev->data->mac_addrs)" was always true, and the MAC was never set. Remove this test to fix the issue.

Fixes 943c2d899a0c ("net/i40e: set VF MAC from VF")
---
 drivers/net/i40e/i40e_ethdev_vf.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +0 -3
index 91b5bb033..17446ec23 100644
@@ -2681,9 +2681,6 @@ i40evf_set_default_mac_addr(struct rte_eth_dev *dev,
 		return;
 	}
 
-	if (is_same_ether_addr(mac_addr, dev->data->mac_addrs))
-		return;
-
 	if (vf->flags & I40E_FLAG_VF_MAC_BY_PF)
 		return;
 
Signature · 1 line
2.11.0
Acked-by on v2 1/1
#13 lore raw

Re: [PATCH v2] net/i40e: fix setting of MAC address on i40evf

Quoted 12 lines

-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Wednesday, January 3, 2018 9:34 PM
To: [email protected]; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]
Subject: [PATCH v2] net/i40e: fix setting of MAC address on i40evf

When setting the MAC address, the ethdev layer copies the new mac address in dev->data->mac_addrs[0] before calling the dev_ops.

Quoted 7 lines

Therefore, "is_same_ether_addr(mac_addr, dev->data->mac_addrs)" was always true, and the MAC was never set. Remove this test to fix the issue.

Fixes 943c2d899a0c ("net/i40e: set VF MAC from VF")
Applied
#14 lore raw

Re: [PATCH v2] net/i40e: fix setting of MAC address on i40evf

Quoted 25 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xing, Beilei
Sent: Thursday, January 4, 2018 3:40 PM
To: Olivier Matz; [email protected]; Wu, Jingjing
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix setting of MAC address on i40evf

Quoted 14 lines

-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Wednesday, January 3, 2018 9:34 PM
To: [email protected]; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]
Subject: [PATCH v2] net/i40e: fix setting of MAC address on i40evf

When setting the MAC address, the ethdev layer copies the new mac address in dev->data->mac_addrs[0] before calling the dev_ops.

Therefore, "is_same_ether_addr(mac_addr, dev->data->mac_addrs)" was always true, and the MAC was never set. Remove this test to fix the issue.

Quoted 6 lines
Quoted 4 lines
Fixes 943c2d899a0c ("net/i40e: set VF MAC from VF")

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

/Helin