Skip to content

Commit 859b4df

Browse files
Andre Guedesanguy11
authored andcommitted
igc: Replace IGC_TX_FLAGS_XDP flag by an enum
Up to this point, Tx buffers are associated with either a skb or a xdpf, and the IGC_TX_FLAGS_XDP flag was enough to distinguish between these two case. However, with upcoming patches that will add AF_XDP zero-copy support, a third case will be introduced so this flag-based approach won't fit well. In preparation to land AF_XDP zero-copy support, replace the IGC_TX_FLAGS_XDP flag by an enum which will be extended once zero-copy support is introduced to the driver. Signed-off-by: Andre Guedes <[email protected]> Signed-off-by: Vedang Patel <[email protected]> Signed-off-by: Jithu Joseph <[email protected]> Reviewed-by: Maciej Fijalkowski <[email protected]> Tested-by: Dvora Fuxbrumer <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 6123429 commit 859b4df

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

drivers/net/ethernet/intel/igc/igc.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,6 @@ enum igc_tx_flags {
390390
/* olinfo flags */
391391
IGC_TX_FLAGS_IPV4 = 0x10,
392392
IGC_TX_FLAGS_CSUM = 0x20,
393-
394-
IGC_TX_FLAGS_XDP = 0x100,
395393
};
396394

397395
enum igc_boards {
@@ -408,12 +406,18 @@ enum igc_boards {
408406
#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IGC_MAX_DATA_PER_TXD)
409407
#define DESC_NEEDED (MAX_SKB_FRAGS + 4)
410408

409+
enum igc_tx_buffer_type {
410+
IGC_TX_BUFFER_TYPE_SKB,
411+
IGC_TX_BUFFER_TYPE_XDP,
412+
};
413+
411414
/* wrapper around a pointer to a socket buffer,
412415
* so a DMA handle can be stored along with the buffer
413416
*/
414417
struct igc_tx_buffer {
415418
union igc_adv_tx_desc *next_to_watch;
416419
unsigned long time_stamp;
420+
enum igc_tx_buffer_type type;
417421
union {
418422
struct sk_buff *skb;
419423
struct xdp_frame *xdpf;

drivers/net/ethernet/intel/igc/igc_main.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,17 @@ static void igc_clean_tx_ring(struct igc_ring *tx_ring)
191191
while (i != tx_ring->next_to_use) {
192192
union igc_adv_tx_desc *eop_desc, *tx_desc;
193193

194-
if (tx_buffer->tx_flags & IGC_TX_FLAGS_XDP)
194+
switch (tx_buffer->type) {
195+
case IGC_TX_BUFFER_TYPE_XDP:
195196
xdp_return_frame(tx_buffer->xdpf);
196-
else
197+
break;
198+
case IGC_TX_BUFFER_TYPE_SKB:
197199
dev_kfree_skb_any(tx_buffer->skb);
200+
break;
201+
default:
202+
netdev_warn_once(tx_ring->netdev, "Unknown Tx buffer type\n");
203+
break;
204+
}
198205

199206
igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
200207

@@ -1360,6 +1367,7 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb,
13601367

13611368
/* record the location of the first descriptor for this packet */
13621369
first = &tx_ring->tx_buffer_info[tx_ring->next_to_use];
1370+
first->type = IGC_TX_BUFFER_TYPE_SKB;
13631371
first->skb = skb;
13641372
first->bytecount = skb->len;
13651373
first->gso_segs = 1;
@@ -1943,8 +1951,8 @@ static int igc_xdp_init_tx_buffer(struct igc_tx_buffer *buffer,
19431951
return -ENOMEM;
19441952
}
19451953

1954+
buffer->type = IGC_TX_BUFFER_TYPE_XDP;
19461955
buffer->xdpf = xdpf;
1947-
buffer->tx_flags = IGC_TX_FLAGS_XDP;
19481956
buffer->protocol = 0;
19491957
buffer->bytecount = xdpf->len;
19501958
buffer->gso_segs = 1;
@@ -2305,10 +2313,17 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget)
23052313
total_bytes += tx_buffer->bytecount;
23062314
total_packets += tx_buffer->gso_segs;
23072315

2308-
if (tx_buffer->tx_flags & IGC_TX_FLAGS_XDP)
2316+
switch (tx_buffer->type) {
2317+
case IGC_TX_BUFFER_TYPE_XDP:
23092318
xdp_return_frame(tx_buffer->xdpf);
2310-
else
2319+
break;
2320+
case IGC_TX_BUFFER_TYPE_SKB:
23112321
napi_consume_skb(tx_buffer->skb, napi_budget);
2322+
break;
2323+
default:
2324+
netdev_warn_once(tx_ring->netdev, "Unknown Tx buffer type\n");
2325+
break;
2326+
}
23122327

23132328
igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
23142329

0 commit comments

Comments
 (0)