Skip to content

Commit 315702e

Browse files
pmachatakuba-moo
authored andcommitted
mlxsw: spectrum_fid: Add hooks for RSP table maintenance
In the CFF flood mode, the driver has to allocate a table within PGT, which holds flood vectors for router subport FIDs. For LAGs, these flood vectors have to obviously be maintained dynamically as port membership in a LAG changes. But even for physical ports, the flood vectors have to be kept valid, and may not contain enabled bits corresponding to non-existent ports. It is therefore not possible to precompute the port part of the RSP table, it has to be maintained as ports come and go due to splits. To support the RSP table maintenance, add to FID ops two new ops: fid_port_init and fid_port_fini, for when a port comes to existence, or joins a lag, and vice versa. Invoke these ops from mlxsw_sp_port_fids_init() and mlxsw_sp_port_fids_fini(), which are called when port is added and removed, respectively. Also add two new hooks for LAG maintenance, mlxsw_sp_fid_port_join_lag() / _leave_lag() which transitively call into the same ops. Later patches will actually add the op implementations themselves, this just adds the scaffolding. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Amit Cohen <amcohen@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://lore.kernel.org/r/234398a23540317abb25f74f920a5c8121faecf0.1701183892.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a59316f commit 315702e

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4515,6 +4515,10 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port,
45154515
mlxsw_sp_port->lagged = 1;
45164516
lag->ref_count++;
45174517

4518+
err = mlxsw_sp_fid_port_join_lag(mlxsw_sp_port);
4519+
if (err)
4520+
goto err_fid_port_join_lag;
4521+
45184522
/* Port is no longer usable as a router interface */
45194523
if (mlxsw_sp_port->default_vlan->fid)
45204524
mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port->default_vlan);
@@ -4534,6 +4538,8 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port,
45344538
err_replay:
45354539
mlxsw_sp_router_port_leave_lag(mlxsw_sp_port, lag_dev);
45364540
err_router_join:
4541+
mlxsw_sp_fid_port_leave_lag(mlxsw_sp_port);
4542+
err_fid_port_join_lag:
45374543
lag->ref_count--;
45384544
mlxsw_sp_port->lagged = 0;
45394545
mlxsw_core_lag_mapping_clear(mlxsw_sp->core, lag_id,
@@ -4569,6 +4575,8 @@ static void mlxsw_sp_port_lag_leave(struct mlxsw_sp_port *mlxsw_sp_port,
45694575
*/
45704576
mlxsw_sp_port_lag_uppers_cleanup(mlxsw_sp_port, lag_dev);
45714577

4578+
mlxsw_sp_fid_port_leave_lag(mlxsw_sp_port);
4579+
45724580
if (lag->ref_count == 1)
45734581
mlxsw_sp_lag_destroy(mlxsw_sp, lag_id);
45744582

drivers/net/ethernet/mellanox/mlxsw/spectrum.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,8 @@ struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
13281328
void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
13291329
int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
13301330
void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1331+
int mlxsw_sp_fid_port_join_lag(const struct mlxsw_sp_port *mlxsw_sp_port);
1332+
void mlxsw_sp_fid_port_leave_lag(const struct mlxsw_sp_port *mlxsw_sp_port);
13311333

13321334
extern const struct mlxsw_sp_fid_core_ops mlxsw_sp1_fid_core_ops;
13331335
extern const struct mlxsw_sp_fid_core_ops mlxsw_sp2_fid_core_ops;

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

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ struct mlxsw_sp_fid_ops {
103103
const struct mlxsw_sp_flood_table *flood_table);
104104
void (*fid_pack)(char *sfmr_pl, const struct mlxsw_sp_fid *fid,
105105
enum mlxsw_reg_sfmr_op op);
106+
107+
/* These are specific to RFID families and we assume are only
108+
* implemented by RFID families, if at all.
109+
*/
110+
int (*fid_port_init)(const struct mlxsw_sp_fid_family *fid_family,
111+
const struct mlxsw_sp_port *mlxsw_sp_port);
112+
void (*fid_port_fini)(const struct mlxsw_sp_fid_family *fid_family,
113+
const struct mlxsw_sp_port *mlxsw_sp_port);
106114
};
107115

108116
struct mlxsw_sp_fid_family {
@@ -1836,26 +1844,74 @@ mlxsw_sp_fid_family_unregister(struct mlxsw_sp *mlxsw_sp,
18361844
kfree(fid_family);
18371845
}
18381846

1847+
static int mlxsw_sp_fid_port_init(const struct mlxsw_sp_port *mlxsw_sp_port)
1848+
{
1849+
const enum mlxsw_sp_fid_type type_rfid = MLXSW_SP_FID_TYPE_RFID;
1850+
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
1851+
struct mlxsw_sp_fid_family *rfid_family;
1852+
1853+
rfid_family = mlxsw_sp->fid_core->fid_family_arr[type_rfid];
1854+
if (rfid_family->ops->fid_port_init)
1855+
return rfid_family->ops->fid_port_init(rfid_family,
1856+
mlxsw_sp_port);
1857+
return 0;
1858+
}
1859+
1860+
static void mlxsw_sp_fid_port_fini(const struct mlxsw_sp_port *mlxsw_sp_port)
1861+
{
1862+
const enum mlxsw_sp_fid_type type_rfid = MLXSW_SP_FID_TYPE_RFID;
1863+
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
1864+
struct mlxsw_sp_fid_family *rfid_family;
1865+
1866+
rfid_family = mlxsw_sp->fid_core->fid_family_arr[type_rfid];
1867+
if (rfid_family->ops->fid_port_fini)
1868+
rfid_family->ops->fid_port_fini(rfid_family, mlxsw_sp_port);
1869+
}
1870+
18391871
int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port)
18401872
{
18411873
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
1874+
int err;
18421875

18431876
/* Track number of FIDs configured on the port with mapping type
18441877
* PORT_VID_TO_FID, so that we know when to transition the port
18451878
* back to non-virtual (VLAN) mode.
18461879
*/
18471880
mlxsw_sp->fid_core->port_fid_mappings[mlxsw_sp_port->local_port] = 0;
18481881

1849-
return mlxsw_sp_port_vp_mode_set(mlxsw_sp_port, false);
1882+
err = mlxsw_sp_fid_port_init(mlxsw_sp_port);
1883+
if (err)
1884+
return err;
1885+
1886+
err = mlxsw_sp_port_vp_mode_set(mlxsw_sp_port, false);
1887+
if (err)
1888+
goto err_vp_mode_set;
1889+
1890+
return 0;
1891+
1892+
err_vp_mode_set:
1893+
mlxsw_sp_fid_port_fini(mlxsw_sp_port);
1894+
return err;
18501895
}
18511896

18521897
void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port)
18531898
{
18541899
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
18551900

1901+
mlxsw_sp_fid_port_fini(mlxsw_sp_port);
18561902
mlxsw_sp->fid_core->port_fid_mappings[mlxsw_sp_port->local_port] = 0;
18571903
}
18581904

1905+
int mlxsw_sp_fid_port_join_lag(const struct mlxsw_sp_port *mlxsw_sp_port)
1906+
{
1907+
return mlxsw_sp_fid_port_init(mlxsw_sp_port);
1908+
}
1909+
1910+
void mlxsw_sp_fid_port_leave_lag(const struct mlxsw_sp_port *mlxsw_sp_port)
1911+
{
1912+
mlxsw_sp_fid_port_fini(mlxsw_sp_port);
1913+
}
1914+
18591915
static int
18601916
mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp,
18611917
const struct mlxsw_sp_fid_family *fid_family_arr[])

0 commit comments

Comments
 (0)