Skip to content

Commit 68f236d

Browse files
akiyanodavem330
authored andcommitted
net: ena: add support for the rx offset feature
Newer ENA devices can write data to rx buffers with an offset from the beginning of the buffer. This commit adds support for this feature in the driver. Signed-off-by: Sameeh Jubran <[email protected]> Signed-off-by: Arthur Kiyanovski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b79f91f commit 68f236d

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

drivers/net/ethernet/amazon/ena/ena_admin_defs.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,8 @@ struct ena_admin_host_info {
813813

814814
u16 reserved;
815815

816-
/* 1 :0 : reserved
816+
/* 0 : reserved
817+
* 1 : rx_offset
817818
* 2 : interrupt_moderation
818819
* 31:3 : reserved
819820
*/
@@ -1124,6 +1125,8 @@ struct ena_admin_ena_mmio_req_read_less_resp {
11241125
#define ENA_ADMIN_HOST_INFO_DEVICE_MASK GENMASK(7, 3)
11251126
#define ENA_ADMIN_HOST_INFO_BUS_SHIFT 8
11261127
#define ENA_ADMIN_HOST_INFO_BUS_MASK GENMASK(15, 8)
1128+
#define ENA_ADMIN_HOST_INFO_RX_OFFSET_SHIFT 1
1129+
#define ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK BIT(1)
11271130
#define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_SHIFT 2
11281131
#define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK BIT(2)
11291132

drivers/net/ethernet/amazon/ena/ena_eth_com.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq,
519519
struct ena_eth_io_rx_cdesc_base *cdesc = NULL;
520520
u16 cdesc_idx = 0;
521521
u16 nb_hw_desc;
522-
u16 i;
522+
u16 i = 0;
523523

524524
WARN(io_cq->direction != ENA_COM_IO_QUEUE_DIRECTION_RX, "wrong Q type");
525525

@@ -538,13 +538,19 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq,
538538
return -ENOSPC;
539539
}
540540

541-
for (i = 0; i < nb_hw_desc; i++) {
541+
cdesc = ena_com_rx_cdesc_idx_to_ptr(io_cq, cdesc_idx);
542+
ena_rx_ctx->pkt_offset = cdesc->offset;
543+
544+
do {
545+
ena_buf[i].len = cdesc->length;
546+
ena_buf[i].req_id = cdesc->req_id;
547+
548+
if (++i >= nb_hw_desc)
549+
break;
550+
542551
cdesc = ena_com_rx_cdesc_idx_to_ptr(io_cq, cdesc_idx + i);
543552

544-
ena_buf->len = cdesc->length;
545-
ena_buf->req_id = cdesc->req_id;
546-
ena_buf++;
547-
}
553+
} while (1);
548554

549555
/* Update SQ head ptr */
550556
io_sq->next_to_comp += nb_hw_desc;

drivers/net/ethernet/amazon/ena/ena_eth_com.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct ena_com_rx_ctx {
7373
u32 hash;
7474
u16 descs;
7575
int max_bufs;
76+
u8 pkt_offset;
7677
};
7778

7879
int ena_com_prepare_tx(struct ena_com_io_sq *io_sq,

drivers/net/ethernet/amazon/ena/ena_eth_io_defs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ struct ena_eth_io_rx_cdesc_base {
264264

265265
u16 sub_qid;
266266

267-
u16 reserved;
267+
u8 offset;
268+
269+
u8 reserved;
268270
};
269271

270272
/* 8-word format */

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,8 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
14351435

14361436
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page,
14371437
rx_info->page_offset, len, ENA_PAGE_SIZE);
1438+
/* The offset is non zero only for the first buffer */
1439+
rx_info->page_offset = 0;
14381440

14391441
netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev,
14401442
"rx skb updated. len %d. data_len %d\n",
@@ -1590,6 +1592,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
15901592
{
15911593
u16 next_to_clean = rx_ring->next_to_clean;
15921594
struct ena_com_rx_ctx ena_rx_ctx;
1595+
struct ena_rx_buffer *rx_info;
15931596
struct ena_adapter *adapter;
15941597
u32 res_budget, work_done;
15951598
int rx_copybreak_pkt = 0;
@@ -1614,6 +1617,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
16141617
ena_rx_ctx.ena_bufs = rx_ring->ena_bufs;
16151618
ena_rx_ctx.max_bufs = rx_ring->sgl_size;
16161619
ena_rx_ctx.descs = 0;
1620+
ena_rx_ctx.pkt_offset = 0;
16171621
rc = ena_com_rx_pkt(rx_ring->ena_com_io_cq,
16181622
rx_ring->ena_com_io_sq,
16191623
&ena_rx_ctx);
@@ -1623,6 +1627,9 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
16231627
if (unlikely(ena_rx_ctx.descs == 0))
16241628
break;
16251629

1630+
rx_info = &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0].req_id];
1631+
rx_info->page_offset = ena_rx_ctx.pkt_offset;
1632+
16261633
netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev,
16271634
"rx_poll: q %d got packet from ena. descs #: %d l3 proto %d l4 proto %d hash: %x\n",
16281635
rx_ring->qid, ena_rx_ctx.descs, ena_rx_ctx.l3_proto,
@@ -3111,6 +3118,7 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev,
31113118
host_info->num_cpus = num_online_cpus();
31123119

31133120
host_info->driver_supported_features =
3121+
ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK |
31143122
ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK;
31153123

31163124
rc = ena_com_set_host_attributes(ena_dev);

0 commit comments

Comments
 (0)