From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-18 21:10:24
While doing the last polishing of the drivers/ethernet
changes I realized we have a handful of drivers offsetting
some base MAC addr by an id. So I decided to add a helper
for it. The helper takes care of wrapping which is probably
not 100% necessary but seems like a good idea. And it saves
driver side LoC (the diffstat is actually negative if we
compare against the changes I'd have to make if I was to
convert all these drivers to not operate directly on
netdev->dev_addr).
Jakub Kicinski (6):
ethernet: add a helper for assigning port addresses
ethernet: ocelot: use eth_hw_addr_gen()
ethernet: prestera: use eth_hw_addr_gen()
ethernet: fec: use eth_hw_addr_gen()
ethernet: mlxsw: use eth_hw_addr_gen()
ethernet: sparx5: use eth_hw_addr_gen()
drivers/net/ethernet/freescale/fec_main.c | 5 +----
.../ethernet/marvell/prestera/prestera_main.c | 7 +++++--
drivers/net/ethernet/mellanox/mlxsw/minimal.c | 10 +++------
.../net/ethernet/mellanox/mlxsw/spectrum.c | 8 +++----
.../ethernet/microchip/sparx5/sparx5_netdev.c | 4 +---
drivers/net/ethernet/mscc/ocelot_net.c | 3 +--
include/linux/etherdevice.h | 21 +++++++++++++++++++
7 files changed, 36 insertions(+), 22 deletions(-)
--
2.31.1
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-18 21:10:25
We have 5 drivers which offset base MAC addr by port id.
Create a helper for them.
This helper takes care of overflows, which some drivers
did not do, please complain if that's going to break
anything!
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
--
- eth_hw_addr_set_port() -> eth_hw_addr_gen()
- id u8 -> unsigned int
---
include/linux/etherdevice.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-18 21:10:26
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.
Vadym and Taras report that the current behavior of the driver
is not exactly expected and it's better to add the port id in
like other drivers do.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/marvell/prestera/prestera_main.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
@@ -338,11 +338,14 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)gotoerr_port_init;}+eth_hw_addr_gen(dev,sw->base_mac,port->fp_id);/* firmware requires that port's MAC address consist of the first*5bytesofthebaseMACaddress*/-memcpy(dev->dev_addr,sw->base_mac,dev->addr_len-1);-dev->dev_addr[dev->addr_len-1]=port->fp_id;+if(memcmp(dev->dev_addr,sw->base_mac,ETH_ALEN-1)){+dev_warn(prestera_dev(sw),"Port MAC address wraps for port(%u)\n",id);+dev_addr_mod(dev,0,sw->base_mac,ETH_ALEN-1);+}err=prestera_hw_port_mac_set(port,dev->dev_addr);if(err){
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-18 21:10:26
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/mscc/ocelot_net.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-18 21:10:26
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-18 21:10:30
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
- remove the dev temp variable as well
---
drivers/net/ethernet/mellanox/mlxsw/minimal.c | 10 +++-------
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 8 ++++----
2 files changed, 7 insertions(+), 11 deletions(-)
@@ -200,20 +200,16 @@ static intmlxsw_m_port_dev_addr_get(structmlxsw_m_port*mlxsw_m_port){structmlxsw_m*mlxsw_m=mlxsw_m_port->mlxsw_m;-structnet_device*dev=mlxsw_m_port->dev;charppad_pl[MLXSW_REG_PPAD_LEN];+u8addr[ETH_ALEN];interr;mlxsw_reg_ppad_pack(ppad_pl,false,0);err=mlxsw_reg_query(mlxsw_m->core,MLXSW_REG(ppad),ppad_pl);if(err)returnerr;-mlxsw_reg_ppad_mac_memcpy_from(ppad_pl,dev->dev_addr);-/* The last byte value in base mac address is guaranteed-*tobesuchitdoesnotoverflowwhenaddinglocal_port-*value.-*/-dev->dev_addr[ETH_ALEN-1]+=mlxsw_m_port->module+1;+mlxsw_reg_ppad_mac_memcpy_from(ppad_pl,addr);+eth_hw_addr_gen(mlxsw_m_port->dev,addr,mlxsw_m_port->module+1);return0;}
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-18 21:10:31
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/freescale/fec_main.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
@@ -1768,11 +1768,8 @@ static int fec_get_mac(struct net_device *ndev)return0;}-eth_hw_addr_set(ndev,iap);-/* Adjust MAC if using macaddr */-if(iap==macaddr)-ndev->dev_addr[ETH_ALEN-1]=macaddr[ETH_ALEN-1]+fep->dev_id;+eth_hw_addr_gen(ndev,iap,iap==macaddr?fep->dev_id:0);return0;}
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-10-18 21:33:42
On Mon, Oct 18, 2021 at 02:10:03PM -0700, Jakub Kicinski wrote:
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-10-18 21:38:14
On Mon, Oct 18, 2021 at 02:10:02PM -0700, Jakub Kicinski wrote:
We have 5 drivers which offset base MAC addr by port id.
Create a helper for them.
This helper takes care of overflows, which some drivers
did not do, please complain if that's going to break
anything!
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
--
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
From: Shannon Nelson <hidden> Date: 2021-10-18 21:54:53
On 10/18/21 2:10 PM, Jakub Kicinski wrote:
We have 5 drivers which offset base MAC addr by port id.
Create a helper for them.
This helper takes care of overflows, which some drivers
did not do, please complain if that's going to break
anything!
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-10-18 23:19:39
On Mon, Oct 18, 2021 at 02:10:05PM -0700, Jakub Kicinski wrote:
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
On Mon, Oct 18, 2021 at 02:10:02PM -0700, Jakub Kicinski wrote:
We have 5 drivers which offset base MAC addr by port id.
Create a helper for them.
This helper takes care of overflows, which some drivers
did not do, please complain if that's going to break
anything!
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
--
- eth_hw_addr_set_port() -> eth_hw_addr_gen()
- id u8 -> unsigned int
On Mon, Oct 18, 2021 at 02:10:06PM -0700, Jakub Kicinski wrote:
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Hello:
This series was applied to netdev/net-next.git (master)
by David S. Miller [off-list ref]:
On Mon, 18 Oct 2021 14:10:01 -0700 you wrote:
While doing the last polishing of the drivers/ethernet
changes I realized we have a handful of drivers offsetting
some base MAC addr by an id. So I decided to add a helper
for it. The helper takes care of wrapping which is probably
not 100% necessary but seems like a good idea. And it saves
driver side LoC (the diffstat is actually negative if we
compare against the changes I'd have to make if I was to
convert all these drivers to not operate directly on
netdev->dev_addr).
[...]