Skip to content

Commit

Permalink
net/mlx5: E-Switch, move QoS specific fields to existing qos struct
Browse files Browse the repository at this point in the history
Function QoS related fields are already defined in qos related struct.
min and max rate are left out to mlx5_vport_info struct.

Move them to existing qos struct.

Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Parav Pandit authored and Saeed Mahameed committed Apr 2, 2021
1 parent cadb129 commit e591605
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ static int esw_vport_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport)
return err;

/* Attach vport to the eswitch rate limiter */
esw_vport_enable_qos(esw, vport, vport->info.max_rate, vport->qos.bw_share);
esw_vport_enable_qos(esw, vport, vport->qos.max_rate, vport->qos.bw_share);

if (mlx5_esw_is_manager_vport(esw, vport_num))
return 0;
Expand Down Expand Up @@ -2078,8 +2078,8 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
ivi->qos = evport->info.qos;
ivi->spoofchk = evport->info.spoofchk;
ivi->trusted = evport->info.trusted;
ivi->min_tx_rate = evport->info.min_rate;
ivi->max_tx_rate = evport->info.max_rate;
ivi->min_tx_rate = evport->qos.min_rate;
ivi->max_tx_rate = evport->qos.max_rate;
mutex_unlock(&esw->state_lock);

return 0;
Expand Down Expand Up @@ -2319,9 +2319,9 @@ static u32 calculate_vports_min_rate_divider(struct mlx5_eswitch *esw)
int i;

mlx5_esw_for_all_vports(esw, i, evport) {
if (!evport->enabled || evport->info.min_rate < max_guarantee)
if (!evport->enabled || evport->qos.min_rate < max_guarantee)
continue;
max_guarantee = evport->info.min_rate;
max_guarantee = evport->qos.min_rate;
}

if (max_guarantee)
Expand All @@ -2343,8 +2343,8 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw)
mlx5_esw_for_all_vports(esw, i, evport) {
if (!evport->enabled)
continue;
vport_min_rate = evport->info.min_rate;
vport_max_rate = evport->info.max_rate;
vport_min_rate = evport->qos.min_rate;
vport_max_rate = evport->qos.max_rate;
bw_share = 0;

if (divider)
Expand Down Expand Up @@ -2391,24 +2391,24 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,

mutex_lock(&esw->state_lock);

if (min_rate == evport->info.min_rate)
if (min_rate == evport->qos.min_rate)
goto set_max_rate;

previous_min_rate = evport->info.min_rate;
evport->info.min_rate = min_rate;
previous_min_rate = evport->qos.min_rate;
evport->qos.min_rate = min_rate;
err = normalize_vports_min_rate(esw);
if (err) {
evport->info.min_rate = previous_min_rate;
evport->qos.min_rate = previous_min_rate;
goto unlock;
}

set_max_rate:
if (max_rate == evport->info.max_rate)
if (max_rate == evport->qos.max_rate)
goto unlock;

err = esw_vport_qos_config(esw, evport, max_rate, evport->qos.bw_share);
if (!err)
evport->info.max_rate = max_rate;
evport->qos.max_rate = max_rate;

unlock:
mutex_unlock(&esw->state_lock);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ struct mlx5_vport_info {
u16 vlan;
u64 node_guid;
int link_state;
u32 min_rate;
u32 max_rate;
u8 qos;
u8 spoofchk: 1;
u8 trusted: 1;
Expand Down Expand Up @@ -154,6 +152,8 @@ struct mlx5_vport {
bool enabled;
u32 esw_tsar_ix;
u32 bw_share;
u32 min_rate;
u32 max_rate;
} qos;

bool enabled;
Expand Down

0 comments on commit e591605

Please sign in to comment.