Skip to content

Commit 0b676aa

Browse files
Eran Ben ElishaSaeed Mahameed
authored andcommitted
net/mlx5e: Change skb fifo push/pop API to be used without SQ
The skb fifo push/pop API used pre-defined attributes within the mlx5e_txqsq. In order to share the skb fifo API with other non-SQ use cases, change the API input to get newly defined mlx5e_skb_fifo struct. Signed-off-by: Eran Ben Elisha <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 4ad40d8 commit 0b676aa

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ struct mlx5e_tx_mpwqe {
331331
u8 inline_on;
332332
};
333333

334+
struct mlx5e_skb_fifo {
335+
struct sk_buff **fifo;
336+
u16 *pc;
337+
u16 *cc;
338+
u16 mask;
339+
};
340+
334341
struct mlx5e_txqsq {
335342
/* data path */
336343

@@ -351,11 +358,10 @@ struct mlx5e_txqsq {
351358
/* read only */
352359
struct mlx5_wq_cyc wq;
353360
u32 dma_fifo_mask;
354-
u16 skb_fifo_mask;
355361
struct mlx5e_sq_stats *stats;
356362
struct {
357363
struct mlx5e_sq_dma *dma_fifo;
358-
struct sk_buff **skb_fifo;
364+
struct mlx5e_skb_fifo skb_fifo;
359365
struct mlx5e_tx_wqe_info *wqe_info;
360366
} db;
361367
void __iomem *uar_map;

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,24 @@ mlx5e_dma_push(struct mlx5e_txqsq *sq, dma_addr_t addr, u32 size,
250250
dma->type = map_type;
251251
}
252252

253-
static inline struct sk_buff **mlx5e_skb_fifo_get(struct mlx5e_txqsq *sq, u16 i)
253+
static inline
254+
struct sk_buff **mlx5e_skb_fifo_get(struct mlx5e_skb_fifo *fifo, u16 i)
254255
{
255-
return &sq->db.skb_fifo[i & sq->skb_fifo_mask];
256+
return &fifo->fifo[i & fifo->mask];
256257
}
257258

258-
static inline void mlx5e_skb_fifo_push(struct mlx5e_txqsq *sq, struct sk_buff *skb)
259+
static inline
260+
void mlx5e_skb_fifo_push(struct mlx5e_skb_fifo *fifo, struct sk_buff *skb)
259261
{
260-
struct sk_buff **skb_item = mlx5e_skb_fifo_get(sq, sq->skb_fifo_pc++);
262+
struct sk_buff **skb_item = mlx5e_skb_fifo_get(fifo, (*fifo->pc)++);
261263

262264
*skb_item = skb;
263265
}
264266

265-
static inline struct sk_buff *mlx5e_skb_fifo_pop(struct mlx5e_txqsq *sq)
267+
static inline
268+
struct sk_buff *mlx5e_skb_fifo_pop(struct mlx5e_skb_fifo *fifo)
266269
{
267-
return *mlx5e_skb_fifo_get(sq, sq->skb_fifo_cc++);
270+
return *mlx5e_skb_fifo_get(fifo, (*fifo->cc)++);
268271
}
269272

270273
static inline void

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ static void mlx5e_free_icosq(struct mlx5e_icosq *sq)
10861086
static void mlx5e_free_txqsq_db(struct mlx5e_txqsq *sq)
10871087
{
10881088
kvfree(sq->db.wqe_info);
1089-
kvfree(sq->db.skb_fifo);
1089+
kvfree(sq->db.skb_fifo.fifo);
10901090
kvfree(sq->db.dma_fifo);
10911091
}
10921092

@@ -1098,19 +1098,22 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
10981098
sq->db.dma_fifo = kvzalloc_node(array_size(df_sz,
10991099
sizeof(*sq->db.dma_fifo)),
11001100
GFP_KERNEL, numa);
1101-
sq->db.skb_fifo = kvzalloc_node(array_size(df_sz,
1102-
sizeof(*sq->db.skb_fifo)),
1101+
sq->db.skb_fifo.fifo = kvzalloc_node(array_size(df_sz,
1102+
sizeof(*sq->db.skb_fifo.fifo)),
11031103
GFP_KERNEL, numa);
11041104
sq->db.wqe_info = kvzalloc_node(array_size(wq_sz,
11051105
sizeof(*sq->db.wqe_info)),
11061106
GFP_KERNEL, numa);
1107-
if (!sq->db.dma_fifo || !sq->db.skb_fifo || !sq->db.wqe_info) {
1107+
if (!sq->db.dma_fifo || !sq->db.skb_fifo.fifo || !sq->db.wqe_info) {
11081108
mlx5e_free_txqsq_db(sq);
11091109
return -ENOMEM;
11101110
}
11111111

11121112
sq->dma_fifo_mask = df_sz - 1;
1113-
sq->skb_fifo_mask = df_sz - 1;
1113+
1114+
sq->db.skb_fifo.pc = &sq->skb_fifo_pc;
1115+
sq->db.skb_fifo.cc = &sq->skb_fifo_cc;
1116+
sq->db.skb_fifo.mask = df_sz - 1;
11141117

11151118
return 0;
11161119
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ mlx5e_sq_xmit_mpwqe(struct mlx5e_txqsq *sq, struct sk_buff *skb,
579579
goto err_unmap;
580580
mlx5e_dma_push(sq, txd.dma_addr, txd.len, MLX5E_DMA_MAP_SINGLE);
581581

582-
mlx5e_skb_fifo_push(sq, skb);
582+
mlx5e_skb_fifo_push(&sq->db.skb_fifo, skb);
583583

584584
mlx5e_tx_mpwqe_add_dseg(sq, &txd);
585585

@@ -719,7 +719,7 @@ static void mlx5e_tx_wi_consume_fifo_skbs(struct mlx5e_txqsq *sq, struct mlx5e_t
719719
int i;
720720

721721
for (i = 0; i < wi->num_fifo_pkts; i++) {
722-
struct sk_buff *skb = mlx5e_skb_fifo_pop(sq);
722+
struct sk_buff *skb = mlx5e_skb_fifo_pop(&sq->db.skb_fifo);
723723

724724
mlx5e_consume_skb(sq, skb, cqe, napi_budget);
725725
}
@@ -839,7 +839,7 @@ static void mlx5e_tx_wi_kfree_fifo_skbs(struct mlx5e_txqsq *sq, struct mlx5e_tx_
839839
int i;
840840

841841
for (i = 0; i < wi->num_fifo_pkts; i++)
842-
dev_kfree_skb_any(mlx5e_skb_fifo_pop(sq));
842+
dev_kfree_skb_any(mlx5e_skb_fifo_pop(&sq->db.skb_fifo));
843843
}
844844

845845
void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq)

0 commit comments

Comments
 (0)