Commit 0f505c60 authored by Arthur Kiyanovski's avatar Arthur Kiyanovski Committed by David S. Miller

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: default avatarArthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0dcec686
...@@ -816,7 +816,8 @@ struct ena_admin_host_info { ...@@ -816,7 +816,8 @@ struct ena_admin_host_info {
/* 0 : reserved /* 0 : reserved
* 1 : rx_offset * 1 : rx_offset
* 2 : interrupt_moderation * 2 : interrupt_moderation
* 31:3 : reserved * 3 : rx_buf_mirroring
* 31:4 : reserved
*/ */
u32 driver_supported_features; u32 driver_supported_features;
}; };
...@@ -1129,6 +1130,8 @@ struct ena_admin_ena_mmio_req_read_less_resp { ...@@ -1129,6 +1130,8 @@ struct ena_admin_ena_mmio_req_read_less_resp {
#define ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK BIT(1) #define ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK BIT(1)
#define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_SHIFT 2 #define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_SHIFT 2
#define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK BIT(2) #define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK BIT(2)
#define ENA_ADMIN_HOST_INFO_RX_BUF_MIRRORING_SHIFT 3
#define ENA_ADMIN_HOST_INFO_RX_BUF_MIRRORING_MASK BIT(3)
/* aenq_common_desc */ /* aenq_common_desc */
#define ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK BIT(0) #define ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK BIT(0)
......
...@@ -959,8 +959,11 @@ static int ena_alloc_rx_page(struct ena_ring *rx_ring, ...@@ -959,8 +959,11 @@ static int ena_alloc_rx_page(struct ena_ring *rx_ring,
return -ENOMEM; return -ENOMEM;
} }
/* To enable NIC-side port-mirroring, AKA SPAN port,
* we make the buffer readable from the nic as well
*/
dma = dma_map_page(rx_ring->dev, page, 0, ENA_PAGE_SIZE, dma = dma_map_page(rx_ring->dev, page, 0, ENA_PAGE_SIZE,
DMA_FROM_DEVICE); DMA_BIDIRECTIONAL);
if (unlikely(dma_mapping_error(rx_ring->dev, dma))) { if (unlikely(dma_mapping_error(rx_ring->dev, dma))) {
u64_stats_update_begin(&rx_ring->syncp); u64_stats_update_begin(&rx_ring->syncp);
rx_ring->rx_stats.dma_mapping_err++; rx_ring->rx_stats.dma_mapping_err++;
...@@ -993,10 +996,9 @@ static void ena_free_rx_page(struct ena_ring *rx_ring, ...@@ -993,10 +996,9 @@ static void ena_free_rx_page(struct ena_ring *rx_ring,
return; return;
} }
dma_unmap_page(rx_ring->dev, dma_unmap_page(rx_ring->dev, ena_buf->paddr - rx_ring->rx_headroom,
ena_buf->paddr - rx_ring->rx_headroom,
ENA_PAGE_SIZE, ENA_PAGE_SIZE,
DMA_FROM_DEVICE); DMA_BIDIRECTIONAL);
__free_page(page); __free_page(page);
rx_info->page = NULL; rx_info->page = NULL;
...@@ -1431,7 +1433,7 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring, ...@@ -1431,7 +1433,7 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
do { do {
dma_unmap_page(rx_ring->dev, dma_unmap_page(rx_ring->dev,
dma_unmap_addr(&rx_info->ena_buf, paddr), dma_unmap_addr(&rx_info->ena_buf, paddr),
ENA_PAGE_SIZE, DMA_FROM_DEVICE); ENA_PAGE_SIZE, DMA_BIDIRECTIONAL);
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page, skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page,
rx_info->page_offset, len, ENA_PAGE_SIZE); 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 ...@@ -3123,7 +3125,8 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev, struct pci_dev *pd
host_info->driver_supported_features = host_info->driver_supported_features =
ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK | ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK |
ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK; ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK |
ENA_ADMIN_HOST_INFO_RX_BUF_MIRRORING_MASK;
rc = ena_com_set_host_attributes(ena_dev); rc = ena_com_set_host_attributes(ena_dev);
if (rc) { if (rc) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment