Skip to content

Commit 121e892

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: Refactor RQ XDP_TX indication
Make the xdp_xmit indication available for Striding RQ by taking it out of the type-specific union. This refactor is a preparation for a downstream patch that adds XDP support over Striding RQ. In addition, use a bitmap instead of a boolean for possible future flags. Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 619a8f2 commit 121e892

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ typedef struct sk_buff *
479479
typedef bool (*mlx5e_fp_post_rx_wqes)(struct mlx5e_rq *rq);
480480
typedef void (*mlx5e_fp_dealloc_wqe)(struct mlx5e_rq*, u16);
481481

482+
enum mlx5e_rq_flag {
483+
MLX5E_RQ_FLAG_XDP_XMIT = BIT(0),
484+
};
485+
482486
struct mlx5e_rq {
483487
/* data path */
484488
struct mlx5_wq_ll wq;
@@ -489,7 +493,6 @@ struct mlx5e_rq {
489493
u32 frag_sz; /* max possible skb frag_sz */
490494
union {
491495
bool page_reuse;
492-
bool xdp_xmit;
493496
};
494497
} wqe;
495498
struct {
@@ -528,6 +531,7 @@ struct mlx5e_rq {
528531
struct bpf_prog *xdp_prog;
529532
unsigned int hw_mtu;
530533
struct mlx5e_xdpsq xdpsq;
534+
DECLARE_BITMAP(flags, 8);
531535

532536
/* control */
533537
struct mlx5_wq_ctrl wq_ctrl;

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ static inline bool mlx5e_xmit_xdp_frame(struct mlx5e_rq *rq,
788788
/* move page to reference to sq responsibility,
789789
* and mark so it's not put back in page-cache.
790790
*/
791-
rq->wqe.xdp_xmit = true;
791+
__set_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags); /* non-atomic */
792792
sq->db.di[pi] = *di;
793793
sq->pc++;
794794

@@ -913,9 +913,8 @@ void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
913913
skb = skb_from_cqe(rq, cqe, wi, cqe_bcnt);
914914
if (!skb) {
915915
/* probably for XDP */
916-
if (rq->wqe.xdp_xmit) {
916+
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
917917
wi->di.page = NULL;
918-
rq->wqe.xdp_xmit = false;
919918
/* do not return page to cache, it will be returned on XDP_TX completion */
920919
goto wq_ll_pop;
921920
}
@@ -955,9 +954,8 @@ void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
955954

956955
skb = skb_from_cqe(rq, cqe, wi, cqe_bcnt);
957956
if (!skb) {
958-
if (rq->wqe.xdp_xmit) {
957+
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
959958
wi->di.page = NULL;
960-
rq->wqe.xdp_xmit = false;
961959
/* do not return page to cache, it will be returned on XDP_TX completion */
962960
goto wq_ll_pop;
963961
}

0 commit comments

Comments
 (0)