Skip to content

Commit 1e66220

Browse files
Adham FarisSaeed Mahameed
authored andcommitted
net/mlx5e: Update rx ring hw mtu upon each rx-fcs flag change
rq->hw_mtu is used in function en_rx.c/mlx5e_skb_from_cqe_mpwrq_linear() to catch oversized packets. If FCS is concatenated to the end of the packet then the check should be updated accordingly. Rx rings initialization (mlx5e_init_rxq_rq()) invoked for every new set of channels, as part of mlx5e_safe_switch_params(), unknowingly if it runs with default configuration or not. Current rq->hw_mtu initialization assumes default configuration and ignores params->scatter_fcs_en flag state. Fix this, by accounting for params->scatter_fcs_en flag state during rq->hw_mtu initialization. In addition, updating rq->hw_mtu value during ingress traffic might lead to packets drop and oversize_pkts_sw_drop counter increase with no good reason. Hence we remove this optimization and switch the set of channels with a new one, to make sure we don't get false positives on the oversize_pkts_sw_drop counter. Fixes: 102722f ("net/mlx5e: Add support for RXFCS feature flag") Signed-off-by: Adham Faris <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 565b482 commit 1e66220

File tree

1 file changed

+15
-71
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+15
-71
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 15 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,8 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param
591591
rq->ix = c->ix;
592592
rq->channel = c;
593593
rq->mdev = mdev;
594-
rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
594+
rq->hw_mtu =
595+
MLX5E_SW2HW_MTU(params, params->sw_mtu) - ETH_FCS_LEN * !params->scatter_fcs_en;
595596
rq->xdpsq = &c->rq_xdpsq;
596597
rq->stats = &c->priv->channel_stats[c->ix]->rq;
597598
rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev);
@@ -1014,35 +1015,6 @@ int mlx5e_flush_rq(struct mlx5e_rq *rq, int curr_state)
10141015
return mlx5e_rq_to_ready(rq, curr_state);
10151016
}
10161017

1017-
static int mlx5e_modify_rq_scatter_fcs(struct mlx5e_rq *rq, bool enable)
1018-
{
1019-
struct mlx5_core_dev *mdev = rq->mdev;
1020-
1021-
void *in;
1022-
void *rqc;
1023-
int inlen;
1024-
int err;
1025-
1026-
inlen = MLX5_ST_SZ_BYTES(modify_rq_in);
1027-
in = kvzalloc(inlen, GFP_KERNEL);
1028-
if (!in)
1029-
return -ENOMEM;
1030-
1031-
rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
1032-
1033-
MLX5_SET(modify_rq_in, in, rq_state, MLX5_RQC_STATE_RDY);
1034-
MLX5_SET64(modify_rq_in, in, modify_bitmask,
1035-
MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_SCATTER_FCS);
1036-
MLX5_SET(rqc, rqc, scatter_fcs, enable);
1037-
MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RDY);
1038-
1039-
err = mlx5_core_modify_rq(mdev, rq->rqn, in);
1040-
1041-
kvfree(in);
1042-
1043-
return err;
1044-
}
1045-
10461018
static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
10471019
{
10481020
struct mlx5_core_dev *mdev = rq->mdev;
@@ -3314,20 +3286,6 @@ static void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv)
33143286
mlx5e_destroy_tises(priv);
33153287
}
33163288

3317-
static int mlx5e_modify_channels_scatter_fcs(struct mlx5e_channels *chs, bool enable)
3318-
{
3319-
int err = 0;
3320-
int i;
3321-
3322-
for (i = 0; i < chs->num; i++) {
3323-
err = mlx5e_modify_rq_scatter_fcs(&chs->c[i]->rq, enable);
3324-
if (err)
3325-
return err;
3326-
}
3327-
3328-
return 0;
3329-
}
3330-
33313289
static int mlx5e_modify_channels_vsd(struct mlx5e_channels *chs, bool vsd)
33323290
{
33333291
int err;
@@ -3903,41 +3861,27 @@ static int mlx5e_set_rx_port_ts(struct mlx5_core_dev *mdev, bool enable)
39033861
return mlx5_set_ports_check(mdev, in, sizeof(in));
39043862
}
39053863

3864+
static int mlx5e_set_rx_port_ts_wrap(struct mlx5e_priv *priv, void *ctx)
3865+
{
3866+
struct mlx5_core_dev *mdev = priv->mdev;
3867+
bool enable = *(bool *)ctx;
3868+
3869+
return mlx5e_set_rx_port_ts(mdev, enable);
3870+
}
3871+
39063872
static int set_feature_rx_fcs(struct net_device *netdev, bool enable)
39073873
{
39083874
struct mlx5e_priv *priv = netdev_priv(netdev);
39093875
struct mlx5e_channels *chs = &priv->channels;
3910-
struct mlx5_core_dev *mdev = priv->mdev;
3876+
struct mlx5e_params new_params;
39113877
int err;
39123878

39133879
mutex_lock(&priv->state_lock);
39143880

3915-
if (enable) {
3916-
err = mlx5e_set_rx_port_ts(mdev, false);
3917-
if (err)
3918-
goto out;
3919-
3920-
chs->params.scatter_fcs_en = true;
3921-
err = mlx5e_modify_channels_scatter_fcs(chs, true);
3922-
if (err) {
3923-
chs->params.scatter_fcs_en = false;
3924-
mlx5e_set_rx_port_ts(mdev, true);
3925-
}
3926-
} else {
3927-
chs->params.scatter_fcs_en = false;
3928-
err = mlx5e_modify_channels_scatter_fcs(chs, false);
3929-
if (err) {
3930-
chs->params.scatter_fcs_en = true;
3931-
goto out;
3932-
}
3933-
err = mlx5e_set_rx_port_ts(mdev, true);
3934-
if (err) {
3935-
mlx5_core_warn(mdev, "Failed to set RX port timestamp %d\n", err);
3936-
err = 0;
3937-
}
3938-
}
3939-
3940-
out:
3881+
new_params = chs->params;
3882+
new_params.scatter_fcs_en = enable;
3883+
err = mlx5e_safe_switch_params(priv, &new_params, mlx5e_set_rx_port_ts_wrap,
3884+
&new_params.scatter_fcs_en, true);
39413885
mutex_unlock(&priv->state_lock);
39423886
return err;
39433887
}

0 commit comments

Comments
 (0)