Skip to content

Commit fe94df6

Browse files
Amit CohenPaolo Abeni
authored andcommitted
mlxsw: spectrum_fid: Configure flooding entries using PGT APIs
The PGT (Port Group Table) table maps an index to a bitmap of local ports to which a packet needs to be replicated. This table is used for layer 2 multicast and flooding. In the legacy model, software did not interact with PGT table directly. Instead, it was accessed by firmware in response to registers such as SFTR and SMID. In the new model, the SFTR register is deprecated and software has full control over the PGT table using the SMID register. Use the new PGT APIs to allocate entries for flooding as part of flood tables initialization. Add mlxsw_sp_fid_flood_tables_fini() to free the allocated indexes. In addition, use PGT APIs to add/remove ports from PGT table. The existing code which configures the flood entries via SFTR2 will be removed later. Signed-off-by: Amit Cohen <[email protected]> Reviewed-by: Petr Machata <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 9f6f467 commit fe94df6

File tree

1 file changed

+59
-6
lines changed

1 file changed

+59
-6
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,20 @@ mlxsw_sp_fid_flood_table_lookup(const struct mlxsw_sp_fid *fid,
322322
return NULL;
323323
}
324324

325+
static u16
326+
mlxsw_sp_fid_family_num_fids(const struct mlxsw_sp_fid_family *fid_family)
327+
{
328+
return fid_family->end_index - fid_family->start_index + 1;
329+
}
330+
325331
static u16
326332
mlxsw_sp_fid_flood_table_mid(const struct mlxsw_sp_fid_family *fid_family,
327333
const struct mlxsw_sp_flood_table *flood_table,
328334
u16 fid_offset)
329335
{
330336
u16 num_fids;
331337

332-
num_fids = fid_family->end_index - fid_family->start_index + 1;
338+
num_fids = mlxsw_sp_fid_family_num_fids(fid_family);
333339
return fid_family->pgt_base + num_fids * flood_table->table_index +
334340
fid_offset;
335341
}
@@ -342,6 +348,7 @@ int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
342348
const struct mlxsw_sp_fid_ops *ops = fid_family->ops;
343349
const struct mlxsw_sp_flood_table *flood_table;
344350
char *sftr2_pl;
351+
u16 mid_index;
345352
int err;
346353

347354
if (WARN_ON(!fid_family->flood_tables || !ops->flood_index))
@@ -351,6 +358,15 @@ int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
351358
if (!flood_table)
352359
return -ESRCH;
353360

361+
if (fid_family->mlxsw_sp->ubridge) {
362+
mid_index = mlxsw_sp_fid_flood_table_mid(fid_family,
363+
flood_table,
364+
fid->fid_offset);
365+
return mlxsw_sp_pgt_entry_port_set(fid_family->mlxsw_sp,
366+
mid_index, fid->fid_index,
367+
local_port, member);
368+
}
369+
354370
sftr2_pl = kmalloc(MLXSW_REG_SFTR2_LEN, GFP_KERNEL);
355371
if (!sftr2_pl)
356372
return -ENOMEM;
@@ -1169,17 +1185,20 @@ mlxsw_sp_fid_flood_table_init(struct mlxsw_sp_fid_family *fid_family,
11691185
const struct mlxsw_sp_flood_table *flood_table)
11701186
{
11711187
enum mlxsw_sp_flood_type packet_type = flood_table->packet_type;
1188+
struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp;
1189+
u16 mid_base, num_fids, table_index;
11721190
const int *sfgc_packet_types;
1173-
u16 mid_base, table_index;
1174-
int i;
1191+
int err, i;
11751192

11761193
mid_base = mlxsw_sp_fid_flood_table_mid(fid_family, flood_table, 0);
1194+
num_fids = mlxsw_sp_fid_family_num_fids(fid_family);
1195+
err = mlxsw_sp_pgt_mid_alloc_range(mlxsw_sp, mid_base, num_fids);
1196+
if (err)
1197+
return err;
11771198

11781199
sfgc_packet_types = mlxsw_sp_packet_type_sfgc_types[packet_type];
11791200
for (i = 0; i < MLXSW_REG_SFGC_TYPE_MAX; i++) {
1180-
struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp;
11811201
char sfgc_pl[MLXSW_REG_SFGC_LEN];
1182-
int err;
11831202

11841203
if (!sfgc_packet_types[i])
11851204
continue;
@@ -1193,10 +1212,27 @@ mlxsw_sp_fid_flood_table_init(struct mlxsw_sp_fid_family *fid_family,
11931212

11941213
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfgc), sfgc_pl);
11951214
if (err)
1196-
return err;
1215+
goto err_reg_write;
11971216
}
11981217

11991218
return 0;
1219+
1220+
err_reg_write:
1221+
mid_base = mlxsw_sp_fid_flood_table_mid(fid_family, flood_table, 0);
1222+
mlxsw_sp_pgt_mid_free_range(mlxsw_sp, mid_base, num_fids);
1223+
return err;
1224+
}
1225+
1226+
static void
1227+
mlxsw_sp_fid_flood_table_fini(struct mlxsw_sp_fid_family *fid_family,
1228+
const struct mlxsw_sp_flood_table *flood_table)
1229+
{
1230+
struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp;
1231+
u16 num_fids, mid_base;
1232+
1233+
mid_base = mlxsw_sp_fid_flood_table_mid(fid_family, flood_table, 0);
1234+
num_fids = mlxsw_sp_fid_family_num_fids(fid_family);
1235+
mlxsw_sp_pgt_mid_free_range(mlxsw_sp, mid_base, num_fids);
12001236
}
12011237

12021238
static int
@@ -1217,6 +1253,19 @@ mlxsw_sp_fid_flood_tables_init(struct mlxsw_sp_fid_family *fid_family)
12171253
return 0;
12181254
}
12191255

1256+
static void
1257+
mlxsw_sp_fid_flood_tables_fini(struct mlxsw_sp_fid_family *fid_family)
1258+
{
1259+
int i;
1260+
1261+
for (i = 0; i < fid_family->nr_flood_tables; i++) {
1262+
const struct mlxsw_sp_flood_table *flood_table;
1263+
1264+
flood_table = &fid_family->flood_tables[i];
1265+
mlxsw_sp_fid_flood_table_fini(fid_family, flood_table);
1266+
}
1267+
}
1268+
12201269
static int mlxsw_sp_fid_family_register(struct mlxsw_sp *mlxsw_sp,
12211270
const struct mlxsw_sp_fid_family *tmpl)
12221271
{
@@ -1258,6 +1307,10 @@ mlxsw_sp_fid_family_unregister(struct mlxsw_sp *mlxsw_sp,
12581307
struct mlxsw_sp_fid_family *fid_family)
12591308
{
12601309
mlxsw_sp->fid_core->fid_family_arr[fid_family->type] = NULL;
1310+
1311+
if (fid_family->flood_tables)
1312+
mlxsw_sp_fid_flood_tables_fini(fid_family);
1313+
12611314
bitmap_free(fid_family->fids_bitmap);
12621315
WARN_ON_ONCE(!list_empty(&fid_family->fids_list));
12631316
kfree(fid_family);

0 commit comments

Comments
 (0)