Skip to content

Commit 20fd0c1

Browse files
Saeed Mahameeddavem330
authored andcommitted
net/mlx5e: RX handlers per netdev profile
In order to have different RX handler per profile, fix and refactor the current code to take the rx handler directly from the netdevice profile rather than computing it on runtime as it was done with the switchdev mode representor rx handler. This will also remove the current wrong assumption in mlx5e_alloc_rq code that mlx5e_priv->ppriv is of the type vport_rep. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Erez Shitrit <erezsh@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2585454 commit 20fd0c1

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,10 @@ struct mlx5e_profile {
779779
void (*disable)(struct mlx5e_priv *priv);
780780
void (*update_stats)(struct mlx5e_priv *priv);
781781
int (*max_nch)(struct mlx5_core_dev *mdev);
782+
struct {
783+
mlx5e_fp_handle_rx_cqe handle_rx_cqe;
784+
mlx5e_fp_handle_rx_cqe handle_rx_cqe_mpwqe;
785+
} rx_handlers;
782786
int max_tc;
783787
};
784788

@@ -1032,7 +1036,6 @@ int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev,
10321036
bool mlx5e_has_offload_stats(const struct net_device *dev, int attr_id);
10331037

10341038
bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv);
1035-
bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv);
10361039

10371040
/* mlx5e generic netdev management API */
10381041
struct net_device*

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -585,15 +585,17 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
585585

586586
switch (rq->wq_type) {
587587
case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
588-
if (mlx5e_is_vf_vport_rep(c->priv)) {
589-
err = -EINVAL;
590-
goto err_rq_wq_destroy;
591-
}
592588

593-
rq->handle_rx_cqe = mlx5e_handle_rx_cqe_mpwrq;
594589
rq->alloc_wqe = mlx5e_alloc_rx_mpwqe;
595590
rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe;
596591

592+
rq->handle_rx_cqe = c->priv->profile->rx_handlers.handle_rx_cqe_mpwqe;
593+
if (!rq->handle_rx_cqe) {
594+
err = -EINVAL;
595+
netdev_err(c->netdev, "RX handler of MPWQE RQ is not set, err %d\n", err);
596+
goto err_rq_wq_destroy;
597+
}
598+
597599
rq->mpwqe_stride_sz = BIT(params->mpwqe_log_stride_sz);
598600
rq->mpwqe_num_strides = BIT(params->mpwqe_log_num_strides);
599601

@@ -616,15 +618,17 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
616618
err = -ENOMEM;
617619
goto err_rq_wq_destroy;
618620
}
619-
620-
if (mlx5e_is_vf_vport_rep(c->priv))
621-
rq->handle_rx_cqe = mlx5e_handle_rx_cqe_rep;
622-
else
623-
rq->handle_rx_cqe = mlx5e_handle_rx_cqe;
624-
625621
rq->alloc_wqe = mlx5e_alloc_rx_wqe;
626622
rq->dealloc_wqe = mlx5e_dealloc_rx_wqe;
627623

624+
rq->handle_rx_cqe = c->priv->profile->rx_handlers.handle_rx_cqe;
625+
if (!rq->handle_rx_cqe) {
626+
kfree(rq->dma_info);
627+
err = -EINVAL;
628+
netdev_err(c->netdev, "RX handler of RQ is not set, err %d\n", err);
629+
goto err_rq_wq_destroy;
630+
}
631+
628632
rq->buff.wqe_sz = params->lro_en ?
629633
params->lro_wqe_sz :
630634
MLX5E_SW2HW_MTU(c->netdev->mtu);
@@ -4229,6 +4233,8 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
42294233
.disable = mlx5e_nic_disable,
42304234
.update_stats = mlx5e_update_stats,
42314235
.max_nch = mlx5e_get_max_num_channels,
4236+
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe,
4237+
.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
42324238
.max_tc = MLX5E_MAX_NUM_TC,
42334239
};
42344240

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
329329
return false;
330330
}
331331

332-
bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
332+
static bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
333333
{
334334
struct mlx5_eswitch_rep *rep = (struct mlx5_eswitch_rep *)priv->ppriv;
335335

@@ -538,6 +538,8 @@ static struct mlx5e_profile mlx5e_rep_profile = {
538538
.cleanup_tx = mlx5e_cleanup_nic_tx,
539539
.update_stats = mlx5e_rep_update_stats,
540540
.max_nch = mlx5e_get_rep_max_num_channels,
541+
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep,
542+
.rx_handlers.handle_rx_cqe_mpwqe = NULL /* Not supported */,
541543
.max_tc = 1,
542544
};
543545

0 commit comments

Comments
 (0)