Skip to content

Commit b80b8d7

Browse files
committed
Merge branch 'mlx5e-xdp'
Tariq Toukan says: ==================== mlx5e XDP support This series adds XDP support in mlx5e driver. This includes the use cases: XDP_DROP, XDP_PASS, and XDP_TX. Single stream performance tests show 16.5 Mpps for XDP_DROP, and 12.4 Mpps for XDP_TX, with nice scalability for multiple streams/rings. This rate of XDP_DROP is lower than the 32 Mpps we got in previous implementation, when Striding RQ was used. We moved to non-Striding RQ, as some XDP_TX requirements (like headroom, packet-per-page) cannot be satisfied with the current Striding RQ HW, and we decided to fully support both DROP/TX. Few directions are considered in order to enable the faster rate for XDP_DROP, e.g a possibility for users to enable Striding RQ so they choose optimized XDP_DROP on the price of partial XDP_TX functionality, or some HW changes. Series generated against net-next commit: cf714ac 'ipvlan: Fix dependency issue' Thanks, Tariq V2: * patch 8: - when XDP_TX fails, call mlx5e_page_release and drop the packet. - update xdp_tx counter within mlx5e_xmit_xdp_frame. (mlx5e_xmit_xdp_frame return value becomes obsolete, change it to void) - drop the packet for unknown XDP return code. * patch 9: - use a boolean for xdp_doorbell in SQ struct, instead of dragging it throughout the functions calls. - handle doorbell and counters within mlx5e_xmit_xdp_frame. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents f9616c3 + 35b510e commit b80b8d7

File tree

6 files changed

+757
-263
lines changed

6 files changed

+757
-263
lines changed

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

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
#define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW 0x3
6666
#define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW 0x6
6767

68+
#define MLX5_RX_HEADROOM NET_SKB_PAD
69+
6870
#define MLX5_MPWRQ_LOG_STRIDE_SIZE 6 /* >= 6, HW restriction */
6971
#define MLX5_MPWRQ_LOG_STRIDE_SIZE_CQE_COMPRESS 8 /* >= 6, HW restriction */
7072
#define MLX5_MPWRQ_LOG_WQE_SZ 18
@@ -99,6 +101,18 @@
99101
#define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */
100102
#define MLX5E_SQ_BF_BUDGET 16
101103

104+
#define MLX5E_ICOSQ_MAX_WQEBBS \
105+
(DIV_ROUND_UP(sizeof(struct mlx5e_umr_wqe), MLX5_SEND_WQE_BB))
106+
107+
#define MLX5E_XDP_MIN_INLINE (ETH_HLEN + VLAN_HLEN)
108+
#define MLX5E_XDP_IHS_DS_COUNT \
109+
DIV_ROUND_UP(MLX5E_XDP_MIN_INLINE - 2, MLX5_SEND_WQE_DS)
110+
#define MLX5E_XDP_TX_DS_COUNT \
111+
(MLX5E_XDP_IHS_DS_COUNT + \
112+
(sizeof(struct mlx5e_tx_wqe) / MLX5_SEND_WQE_DS) + 1 /* SG DS */)
113+
#define MLX5E_XDP_TX_WQEBBS \
114+
DIV_ROUND_UP(MLX5E_XDP_TX_DS_COUNT, MLX5_SEND_WQEBB_NUM_DS)
115+
102116
#define MLX5E_NUM_MAIN_GROUPS 9
103117

104118
static inline u16 mlx5_min_rx_wqes(int wq_type, u32 wq_size)
@@ -302,10 +316,20 @@ struct mlx5e_page_cache {
302316
struct mlx5e_rq {
303317
/* data path */
304318
struct mlx5_wq_ll wq;
305-
u32 wqe_sz;
306-
struct sk_buff **skb;
307-
struct mlx5e_mpw_info *wqe_info;
308-
void *mtt_no_align;
319+
320+
union {
321+
struct mlx5e_dma_info *dma_info;
322+
struct {
323+
struct mlx5e_mpw_info *info;
324+
void *mtt_no_align;
325+
u32 mtt_offset;
326+
} mpwqe;
327+
};
328+
struct {
329+
u8 page_order;
330+
u32 wqe_sz; /* wqe data buffer size */
331+
u8 map_dir; /* dma map direction */
332+
} buff;
309333
__be32 mkey_be;
310334

311335
struct device *pdev;
@@ -321,9 +345,9 @@ struct mlx5e_rq {
321345

322346
unsigned long state;
323347
int ix;
324-
u32 mpwqe_mtt_offset;
325348

326349
struct mlx5e_rx_am am; /* Adaptive Moderation */
350+
struct bpf_prog *xdp_prog;
327351

328352
/* control */
329353
struct mlx5_wq_ctrl wq_ctrl;
@@ -370,11 +394,17 @@ enum {
370394
MLX5E_SQ_STATE_BF_ENABLE,
371395
};
372396

373-
struct mlx5e_ico_wqe_info {
397+
struct mlx5e_sq_wqe_info {
374398
u8 opcode;
375399
u8 num_wqebbs;
376400
};
377401

402+
enum mlx5e_sq_type {
403+
MLX5E_SQ_TXQ,
404+
MLX5E_SQ_ICO,
405+
MLX5E_SQ_XDP
406+
};
407+
378408
struct mlx5e_sq {
379409
/* data path */
380410

@@ -392,10 +422,20 @@ struct mlx5e_sq {
392422

393423
struct mlx5e_cq cq;
394424

395-
/* pointers to per packet info: write@xmit, read@completion */
396-
struct sk_buff **skb;
397-
struct mlx5e_sq_dma *dma_fifo;
398-
struct mlx5e_tx_wqe_info *wqe_info;
425+
/* pointers to per tx element info: write@xmit, read@completion */
426+
union {
427+
struct {
428+
struct sk_buff **skb;
429+
struct mlx5e_sq_dma *dma_fifo;
430+
struct mlx5e_tx_wqe_info *wqe_info;
431+
} txq;
432+
struct mlx5e_sq_wqe_info *ico_wqe;
433+
struct {
434+
struct mlx5e_sq_wqe_info *wqe_info;
435+
struct mlx5e_dma_info *di;
436+
bool doorbell;
437+
} xdp;
438+
} db;
399439

400440
/* read only */
401441
struct mlx5_wq_cyc wq;
@@ -417,8 +457,8 @@ struct mlx5e_sq {
417457
struct mlx5_uar uar;
418458
struct mlx5e_channel *channel;
419459
int tc;
420-
struct mlx5e_ico_wqe_info *ico_wqe_info;
421460
u32 rate_limit;
461+
u8 type;
422462
} ____cacheline_aligned_in_smp;
423463

424464
static inline bool mlx5e_sq_has_room_for(struct mlx5e_sq *sq, u16 n)
@@ -434,8 +474,10 @@ enum channel_flags {
434474
struct mlx5e_channel {
435475
/* data path */
436476
struct mlx5e_rq rq;
477+
struct mlx5e_sq xdp_sq;
437478
struct mlx5e_sq sq[MLX5E_MAX_NUM_TC];
438479
struct mlx5e_sq icosq; /* internal control operations */
480+
bool xdp;
439481
struct napi_struct napi;
440482
struct device *pdev;
441483
struct net_device *netdev;
@@ -617,6 +659,7 @@ struct mlx5e_priv {
617659
/* priv data path fields - start */
618660
struct mlx5e_sq **txq_to_sq_map;
619661
int channeltc_to_txq_map[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC];
662+
struct bpf_prog *xdp_prog;
620663
/* priv data path fields - end */
621664

622665
unsigned long state;
@@ -663,7 +706,7 @@ void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event);
663706
int mlx5e_napi_poll(struct napi_struct *napi, int budget);
664707
bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget);
665708
int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);
666-
void mlx5e_free_tx_descs(struct mlx5e_sq *sq);
709+
void mlx5e_free_sq_descs(struct mlx5e_sq *sq);
667710

668711
void mlx5e_page_release(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info,
669712
bool recycle);
@@ -764,7 +807,7 @@ static inline void mlx5e_cq_arm(struct mlx5e_cq *cq)
764807

765808
static inline u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix)
766809
{
767-
return rq->mpwqe_mtt_offset +
810+
return rq->mpwqe.mtt_offset +
768811
wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8);
769812
}
770813

0 commit comments

Comments
 (0)