Skip to content

Commit 0f505c6

Browse files
akiyanodavem330
authored andcommitted
net: ena: add support for traffic mirroring
Add support for traffic mirroring, where the hardware reads the buffer from the instance memory directly. Traffic Mirroring needs access to the rx buffers in the instance. To have this access, this patch: 1. Changes the code to map and unmap the rx buffers bidirectionally. 2. Enables the relevant bit in driver_supported_features to indicate to the FW that this driver supports traffic mirroring. Rx completion is not generated until mirroring is done to avoid the situation where the driver changes the buffer before it is mirrored. Signed-off-by: Arthur Kiyanovski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0dcec68 commit 0f505c6

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
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
@@ -816,7 +816,8 @@ struct ena_admin_host_info {
816816
/* 0 : reserved
817817
* 1 : rx_offset
818818
* 2 : interrupt_moderation
819-
* 31:3 : reserved
819+
* 3 : rx_buf_mirroring
820+
* 31:4 : reserved
820821
*/
821822
u32 driver_supported_features;
822823
};
@@ -1129,6 +1130,8 @@ struct ena_admin_ena_mmio_req_read_less_resp {
11291130
#define ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK BIT(1)
11301131
#define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_SHIFT 2
11311132
#define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK BIT(2)
1133+
#define ENA_ADMIN_HOST_INFO_RX_BUF_MIRRORING_SHIFT 3
1134+
#define ENA_ADMIN_HOST_INFO_RX_BUF_MIRRORING_MASK BIT(3)
11321135

11331136
/* aenq_common_desc */
11341137
#define ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK BIT(0)

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,11 @@ static int ena_alloc_rx_page(struct ena_ring *rx_ring,
959959
return -ENOMEM;
960960
}
961961

962+
/* To enable NIC-side port-mirroring, AKA SPAN port,
963+
* we make the buffer readable from the nic as well
964+
*/
962965
dma = dma_map_page(rx_ring->dev, page, 0, ENA_PAGE_SIZE,
963-
DMA_FROM_DEVICE);
966+
DMA_BIDIRECTIONAL);
964967
if (unlikely(dma_mapping_error(rx_ring->dev, dma))) {
965968
u64_stats_update_begin(&rx_ring->syncp);
966969
rx_ring->rx_stats.dma_mapping_err++;
@@ -993,10 +996,9 @@ static void ena_free_rx_page(struct ena_ring *rx_ring,
993996
return;
994997
}
995998

996-
dma_unmap_page(rx_ring->dev,
997-
ena_buf->paddr - rx_ring->rx_headroom,
999+
dma_unmap_page(rx_ring->dev, ena_buf->paddr - rx_ring->rx_headroom,
9981000
ENA_PAGE_SIZE,
999-
DMA_FROM_DEVICE);
1001+
DMA_BIDIRECTIONAL);
10001002

10011003
__free_page(page);
10021004
rx_info->page = NULL;
@@ -1431,7 +1433,7 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
14311433
do {
14321434
dma_unmap_page(rx_ring->dev,
14331435
dma_unmap_addr(&rx_info->ena_buf, paddr),
1434-
ENA_PAGE_SIZE, DMA_FROM_DEVICE);
1436+
ENA_PAGE_SIZE, DMA_BIDIRECTIONAL);
14351437

14361438
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page,
14371439
rx_info->page_offset, len, ENA_PAGE_SIZE);
@@ -3123,7 +3125,8 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev, struct pci_dev *pd
31233125

31243126
host_info->driver_supported_features =
31253127
ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK |
3126-
ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK;
3128+
ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK |
3129+
ENA_ADMIN_HOST_INFO_RX_BUF_MIRRORING_MASK;
31273130

31283131
rc = ena_com_set_host_attributes(ena_dev);
31293132
if (rc) {

0 commit comments

Comments
 (0)