[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220629094007.827621-5-idosch@nvidia.com>
Date: Wed, 29 Jun 2022 12:40:01 +0300
From: Ido Schimmel <idosch@...dia.com>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
edumazet@...gle.com, petrm@...dia.com, amcohen@...dia.com,
mlxsw@...dia.com, Ido Schimmel <idosch@...dia.com>
Subject: [PATCH net-next 04/10] mlxsw: spectrum_switchdev: Save MAC and FID as a key in 'struct mlxsw_sp_mdb_entry'
From: Amit Cohen <amcohen@...dia.com>
The next patch will add support for storing all the MDB entries in a hash
table. As a preparation, save the MAC address and the FID in a
separate structure. This structure will be used later as a key for the
hash table.
Signed-off-by: Amit Cohen <amcohen@...dia.com>
Signed-off-by: Ido Schimmel <idosch@...dia.com>
---
.../mellanox/mlxsw/spectrum_switchdev.c | 24 +++++++++++--------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index bd182736f44d..d1a1d55b0068 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -102,10 +102,14 @@ struct mlxsw_sp_switchdev_ops {
void (*init)(struct mlxsw_sp *mlxsw_sp);
};
-struct mlxsw_sp_mdb_entry {
- struct list_head list;
+struct mlxsw_sp_mdb_entry_key {
unsigned char addr[ETH_ALEN];
u16 fid;
+};
+
+struct mlxsw_sp_mdb_entry {
+ struct list_head list;
+ struct mlxsw_sp_mdb_entry_key key;
u16 mid;
bool in_hw;
unsigned long *ports_in_mid; /* bits array */
@@ -1713,8 +1717,8 @@ __mlxsw_sp_mc_get(struct mlxsw_sp_bridge_device *bridge_device,
struct mlxsw_sp_mdb_entry *mdb_entry;
list_for_each_entry(mdb_entry, &bridge_device->mdb_list, list) {
- if (ether_addr_equal(mdb_entry->addr, addr) &&
- mdb_entry->fid == fid)
+ if (ether_addr_equal(mdb_entry->key.addr, addr) &&
+ mdb_entry->key.fid == fid)
return mdb_entry;
}
return NULL;
@@ -1790,8 +1794,8 @@ mlxsw_sp_mc_write_mdb_entry(struct mlxsw_sp *mlxsw_sp,
if (err)
return err;
- err = mlxsw_sp_port_mdb_op(mlxsw_sp, mdb_entry->addr, mdb_entry->fid,
- mid_idx, true);
+ err = mlxsw_sp_port_mdb_op(mlxsw_sp, mdb_entry->key.addr,
+ mdb_entry->key.fid, mid_idx, true);
if (err)
return err;
@@ -1808,8 +1812,8 @@ static int mlxsw_sp_mc_remove_mdb_entry(struct mlxsw_sp *mlxsw_sp,
clear_bit(mdb_entry->mid, mlxsw_sp->bridge->mids_bitmap);
mdb_entry->in_hw = false;
- return mlxsw_sp_port_mdb_op(mlxsw_sp, mdb_entry->addr, mdb_entry->fid,
- mdb_entry->mid, false);
+ return mlxsw_sp_port_mdb_op(mlxsw_sp, mdb_entry->key.addr,
+ mdb_entry->key.fid, mdb_entry->mid, false);
}
static struct mlxsw_sp_mdb_entry *
@@ -1829,8 +1833,8 @@ __mlxsw_sp_mc_alloc(struct mlxsw_sp *mlxsw_sp,
if (!mdb_entry->ports_in_mid)
goto err_ports_in_mid_alloc;
- ether_addr_copy(mdb_entry->addr, addr);
- mdb_entry->fid = fid;
+ ether_addr_copy(mdb_entry->key.addr, addr);
+ mdb_entry->key.fid = fid;
mdb_entry->in_hw = false;
if (!bridge_device->multicast_enabled)
--
2.36.1
Powered by blists - more mailing lists