Commit a759ab6d authored by Shalom Toledo's avatar Shalom Toledo Committed by David S. Miller

mlxsw: spectrum_buffers: Add the ability to query the CPU port's shared buffer

While debugging packet loss towards the CPU, it is useful to be able to
query the CPU port's shared buffer quotas and occupancy.

Since the CPU port has no ingress buffers, all the shared buffers ingress
information will be cleared.
Signed-off-by: default avatarShalom Toledo <shalomt@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 28b1987e
...@@ -250,6 +250,10 @@ static int mlxsw_sp_sb_pm_occ_clear(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -250,6 +250,10 @@ static int mlxsw_sp_sb_pm_occ_clear(struct mlxsw_sp *mlxsw_sp, u8 local_port,
&mlxsw_sp->sb_vals->pool_dess[pool_index]; &mlxsw_sp->sb_vals->pool_dess[pool_index];
char sbpm_pl[MLXSW_REG_SBPM_LEN]; char sbpm_pl[MLXSW_REG_SBPM_LEN];
if (local_port == MLXSW_PORT_CPU_PORT &&
des->dir == MLXSW_REG_SBXX_DIR_INGRESS)
return 0;
mlxsw_reg_sbpm_pack(sbpm_pl, local_port, des->pool, des->dir, mlxsw_reg_sbpm_pack(sbpm_pl, local_port, des->pool, des->dir,
true, 0, 0); true, 0, 0);
return mlxsw_reg_trans_query(mlxsw_sp->core, MLXSW_REG(sbpm), sbpm_pl, return mlxsw_reg_trans_query(mlxsw_sp->core, MLXSW_REG(sbpm), sbpm_pl,
...@@ -273,6 +277,10 @@ static int mlxsw_sp_sb_pm_occ_query(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -273,6 +277,10 @@ static int mlxsw_sp_sb_pm_occ_query(struct mlxsw_sp *mlxsw_sp, u8 local_port,
char sbpm_pl[MLXSW_REG_SBPM_LEN]; char sbpm_pl[MLXSW_REG_SBPM_LEN];
struct mlxsw_sp_sb_pm *pm; struct mlxsw_sp_sb_pm *pm;
if (local_port == MLXSW_PORT_CPU_PORT &&
des->dir == MLXSW_REG_SBXX_DIR_INGRESS)
return 0;
pm = mlxsw_sp_sb_pm_get(mlxsw_sp, local_port, pool_index); pm = mlxsw_sp_sb_pm_get(mlxsw_sp, local_port, pool_index);
mlxsw_reg_sbpm_pack(sbpm_pl, local_port, des->pool, des->dir, mlxsw_reg_sbpm_pack(sbpm_pl, local_port, des->pool, des->dir,
false, 0, 0); false, 0, 0);
...@@ -1197,6 +1205,11 @@ static void mlxsw_sp_sb_sr_occ_query_cb(struct mlxsw_core *mlxsw_core, ...@@ -1197,6 +1205,11 @@ static void mlxsw_sp_sb_sr_occ_query_cb(struct mlxsw_core *mlxsw_core,
local_port < mlxsw_core_max_ports(mlxsw_core); local_port++) { local_port < mlxsw_core_max_ports(mlxsw_core); local_port++) {
if (!mlxsw_sp->ports[local_port]) if (!mlxsw_sp->ports[local_port])
continue; continue;
if (local_port == MLXSW_PORT_CPU_PORT) {
/* Ingress quotas are not supported for the CPU port */
masked_count++;
continue;
}
for (i = 0; i < MLXSW_SP_SB_ING_TC_COUNT; i++) { for (i = 0; i < MLXSW_SP_SB_ING_TC_COUNT; i++) {
cm = mlxsw_sp_sb_cm_get(mlxsw_sp, local_port, i, cm = mlxsw_sp_sb_cm_get(mlxsw_sp, local_port, i,
MLXSW_REG_SBXX_DIR_INGRESS); MLXSW_REG_SBXX_DIR_INGRESS);
...@@ -1232,7 +1245,7 @@ int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, ...@@ -1232,7 +1245,7 @@ int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
char *sbsr_pl; char *sbsr_pl;
u8 masked_count; u8 masked_count;
u8 local_port_1; u8 local_port_1;
u8 local_port = 0; u8 local_port;
int i; int i;
int err; int err;
int err2; int err2;
...@@ -1241,8 +1254,8 @@ int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, ...@@ -1241,8 +1254,8 @@ int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
if (!sbsr_pl) if (!sbsr_pl)
return -ENOMEM; return -ENOMEM;
local_port = MLXSW_PORT_CPU_PORT;
next_batch: next_batch:
local_port++;
local_port_1 = local_port; local_port_1 = local_port;
masked_count = 0; masked_count = 0;
mlxsw_reg_sbsr_pack(sbsr_pl, false); mlxsw_reg_sbsr_pack(sbsr_pl, false);
...@@ -1253,7 +1266,11 @@ int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, ...@@ -1253,7 +1266,11 @@ int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
for (; local_port < mlxsw_core_max_ports(mlxsw_core); local_port++) { for (; local_port < mlxsw_core_max_ports(mlxsw_core); local_port++) {
if (!mlxsw_sp->ports[local_port]) if (!mlxsw_sp->ports[local_port])
continue; continue;
mlxsw_reg_sbsr_ingress_port_mask_set(sbsr_pl, local_port, 1); if (local_port != MLXSW_PORT_CPU_PORT) {
/* Ingress quotas are not supported for the CPU port */
mlxsw_reg_sbsr_ingress_port_mask_set(sbsr_pl,
local_port, 1);
}
mlxsw_reg_sbsr_egress_port_mask_set(sbsr_pl, local_port, 1); mlxsw_reg_sbsr_egress_port_mask_set(sbsr_pl, local_port, 1);
for (i = 0; i < mlxsw_sp->sb_vals->pool_count; i++) { for (i = 0; i < mlxsw_sp->sb_vals->pool_count; i++) {
err = mlxsw_sp_sb_pm_occ_query(mlxsw_sp, local_port, i, err = mlxsw_sp_sb_pm_occ_query(mlxsw_sp, local_port, i,
...@@ -1274,8 +1291,10 @@ int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, ...@@ -1274,8 +1291,10 @@ int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
cb_priv); cb_priv);
if (err) if (err)
goto out; goto out;
if (local_port < mlxsw_core_max_ports(mlxsw_core)) if (local_port < mlxsw_core_max_ports(mlxsw_core)) {
local_port++;
goto next_batch; goto next_batch;
}
out: out:
err2 = mlxsw_reg_trans_bulk_wait(&bulk_list); err2 = mlxsw_reg_trans_bulk_wait(&bulk_list);
...@@ -1292,7 +1311,7 @@ int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, ...@@ -1292,7 +1311,7 @@ int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
LIST_HEAD(bulk_list); LIST_HEAD(bulk_list);
char *sbsr_pl; char *sbsr_pl;
unsigned int masked_count; unsigned int masked_count;
u8 local_port = 0; u8 local_port;
int i; int i;
int err; int err;
int err2; int err2;
...@@ -1301,8 +1320,8 @@ int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, ...@@ -1301,8 +1320,8 @@ int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
if (!sbsr_pl) if (!sbsr_pl)
return -ENOMEM; return -ENOMEM;
local_port = MLXSW_PORT_CPU_PORT;
next_batch: next_batch:
local_port++;
masked_count = 0; masked_count = 0;
mlxsw_reg_sbsr_pack(sbsr_pl, true); mlxsw_reg_sbsr_pack(sbsr_pl, true);
for (i = 0; i < MLXSW_SP_SB_ING_TC_COUNT; i++) for (i = 0; i < MLXSW_SP_SB_ING_TC_COUNT; i++)
...@@ -1312,7 +1331,11 @@ int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, ...@@ -1312,7 +1331,11 @@ int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
for (; local_port < mlxsw_core_max_ports(mlxsw_core); local_port++) { for (; local_port < mlxsw_core_max_ports(mlxsw_core); local_port++) {
if (!mlxsw_sp->ports[local_port]) if (!mlxsw_sp->ports[local_port])
continue; continue;
mlxsw_reg_sbsr_ingress_port_mask_set(sbsr_pl, local_port, 1); if (local_port != MLXSW_PORT_CPU_PORT) {
/* Ingress quotas are not supported for the CPU port */
mlxsw_reg_sbsr_ingress_port_mask_set(sbsr_pl,
local_port, 1);
}
mlxsw_reg_sbsr_egress_port_mask_set(sbsr_pl, local_port, 1); mlxsw_reg_sbsr_egress_port_mask_set(sbsr_pl, local_port, 1);
for (i = 0; i < mlxsw_sp->sb_vals->pool_count; i++) { for (i = 0; i < mlxsw_sp->sb_vals->pool_count; i++) {
err = mlxsw_sp_sb_pm_occ_clear(mlxsw_sp, local_port, i, err = mlxsw_sp_sb_pm_occ_clear(mlxsw_sp, local_port, i,
...@@ -1329,8 +1352,10 @@ int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, ...@@ -1329,8 +1352,10 @@ int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
&bulk_list, NULL, 0); &bulk_list, NULL, 0);
if (err) if (err)
goto out; goto out;
if (local_port < mlxsw_core_max_ports(mlxsw_core)) if (local_port < mlxsw_core_max_ports(mlxsw_core)) {
local_port++;
goto next_batch; goto next_batch;
}
out: out:
err2 = mlxsw_reg_trans_bulk_wait(&bulk_list); err2 = mlxsw_reg_trans_bulk_wait(&bulk_list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment