Skip to content

Commit

Permalink
net/mlx5e: Maintain MQPRIO mode parameter
Browse files Browse the repository at this point in the history
This is in preparation for supporting MQPRIO CHANNEL mode in
downstream patch, in addition to DCB mode that's supported today.

Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Tariq Toukan authored and Saeed Mahameed committed Aug 16, 2021
1 parent 86d747a commit e2aeac4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
4 changes: 3 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ struct mlx5e_params {
u8 log_rq_mtu_frames;
u16 num_channels;
struct {
u16 mode;
u8 num_tc;
} mqprio;
bool rx_cqe_compress_def;
Expand All @@ -272,7 +273,8 @@ struct mlx5e_params {

static inline u8 mlx5e_get_dcb_num_tc(struct mlx5e_params *params)
{
return params->mqprio.num_tc;
return params->mqprio.mode == TC_MQPRIO_MODE_DCB ?
params->mqprio.num_tc : 1;
}

enum {
Expand Down
41 changes: 25 additions & 16 deletions drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2847,41 +2847,47 @@ static int mlx5e_modify_channels_vsd(struct mlx5e_channels *chs, bool vsd)
return 0;
}

static int mlx5e_setup_tc_mqprio(struct mlx5e_priv *priv,
struct tc_mqprio_qopt *mqprio)
static int mlx5e_setup_tc_mqprio_dcb(struct mlx5e_priv *priv,
struct tc_mqprio_qopt *mqprio)
{
struct mlx5e_params new_params;
u8 tc = mqprio->num_tc;
int err = 0;
int err;

mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;

if (tc && tc != MLX5E_MAX_NUM_TC)
return -EINVAL;

mutex_lock(&priv->state_lock);

/* MQPRIO is another toplevel qdisc that can't be attached
* simultaneously with the offloaded HTB.
*/
if (WARN_ON(priv->htb.maj_id)) {
err = -EINVAL;
goto out;
}

new_params = priv->channels.params;
new_params.mqprio.mode = TC_MQPRIO_MODE_DCB;
new_params.mqprio.num_tc = tc ? tc : 1;

err = mlx5e_safe_switch_params(priv, &new_params,
mlx5e_num_channels_changed_ctx, NULL, true);

out:
priv->max_opened_tc = max_t(u8, priv->max_opened_tc,
mlx5e_get_dcb_num_tc(&priv->channels.params));
mutex_unlock(&priv->state_lock);
return err;
}

static int mlx5e_setup_tc_mqprio(struct mlx5e_priv *priv,
struct tc_mqprio_qopt_offload *mqprio)
{
/* MQPRIO is another toplevel qdisc that can't be attached
* simultaneously with the offloaded HTB.
*/
if (WARN_ON(priv->htb.maj_id))
return -EINVAL;

switch (mqprio->mode) {
case TC_MQPRIO_MODE_DCB:
return mlx5e_setup_tc_mqprio_dcb(priv, &mqprio->qopt);
default:
return -EOPNOTSUPP;
}
}

static int mlx5e_setup_tc_htb(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb)
{
int res;
Expand Down Expand Up @@ -2951,7 +2957,10 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
priv, priv, true);
}
case TC_SETUP_QDISC_MQPRIO:
return mlx5e_setup_tc_mqprio(priv, type_data);
mutex_lock(&priv->state_lock);
err = mlx5e_setup_tc_mqprio(priv, type_data);
mutex_unlock(&priv->state_lock);
return err;
case TC_SETUP_QDISC_HTB:
mutex_lock(&priv->state_lock);
err = mlx5e_setup_tc_htb(priv, type_data);
Expand Down

0 comments on commit e2aeac4

Please sign in to comment.