Commit ea5c4600 authored by David Arinzon's avatar David Arinzon Committed by Jakub Kicinski

net: ena: Always register RX queue info

The RX queue info contains information about the RX queue which might
be relevant to the kernel.

To avoid configuring this queue for different scenarios, this patch
moves the RX queue configuration to ena_up()/ena_down() function and
makes it configured every interface state toggle.
Signed-off-by: default avatarShay Agroskin <shayagr@amazon.com>
Signed-off-by: default avatarDavid Arinzon <darinzon@amazon.com>
Link: https://lore.kernel.org/r/20240101190855.18739-10-darinzon@amazon.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 2b02e332
...@@ -753,6 +753,7 @@ static void ena_destroy_all_rx_queues(struct ena_adapter *adapter) ...@@ -753,6 +753,7 @@ static void ena_destroy_all_rx_queues(struct ena_adapter *adapter)
for (i = 0; i < adapter->num_io_queues; i++) { for (i = 0; i < adapter->num_io_queues; i++) {
ena_qid = ENA_IO_RXQ_IDX(i); ena_qid = ENA_IO_RXQ_IDX(i);
cancel_work_sync(&adapter->ena_napi[i].dim.work); cancel_work_sync(&adapter->ena_napi[i].dim.work);
ena_xdp_unregister_rxq_info(&adapter->rx_ring[i]);
ena_com_destroy_io_queue(adapter->ena_dev, ena_qid); ena_com_destroy_io_queue(adapter->ena_dev, ena_qid);
} }
} }
...@@ -1984,12 +1985,15 @@ static int ena_create_all_io_rx_queues(struct ena_adapter *adapter) ...@@ -1984,12 +1985,15 @@ static int ena_create_all_io_rx_queues(struct ena_adapter *adapter)
if (rc) if (rc)
goto create_err; goto create_err;
INIT_WORK(&adapter->ena_napi[i].dim.work, ena_dim_work); INIT_WORK(&adapter->ena_napi[i].dim.work, ena_dim_work);
ena_xdp_register_rxq_info(&adapter->rx_ring[i]);
} }
return 0; return 0;
create_err: create_err:
while (i--) { while (i--) {
ena_xdp_unregister_rxq_info(&adapter->rx_ring[i]);
cancel_work_sync(&adapter->ena_napi[i].dim.work); cancel_work_sync(&adapter->ena_napi[i].dim.work);
ena_com_destroy_io_queue(ena_dev, ENA_IO_RXQ_IDX(i)); ena_com_destroy_io_queue(ena_dev, ENA_IO_RXQ_IDX(i));
} }
......
...@@ -191,12 +191,14 @@ int ena_setup_and_create_all_xdp_queues(struct ena_adapter *adapter) ...@@ -191,12 +191,14 @@ int ena_setup_and_create_all_xdp_queues(struct ena_adapter *adapter)
/* Provides a way for both kernel and bpf-prog to know /* Provides a way for both kernel and bpf-prog to know
* more about the RX-queue a given XDP frame arrived on. * more about the RX-queue a given XDP frame arrived on.
*/ */
static int ena_xdp_register_rxq_info(struct ena_ring *rx_ring) int ena_xdp_register_rxq_info(struct ena_ring *rx_ring)
{ {
int rc; int rc;
rc = xdp_rxq_info_reg(&rx_ring->xdp_rxq, rx_ring->netdev, rx_ring->qid, 0); rc = xdp_rxq_info_reg(&rx_ring->xdp_rxq, rx_ring->netdev, rx_ring->qid, 0);
netif_dbg(rx_ring->adapter, ifup, rx_ring->netdev, "Registering RX info for queue %d",
rx_ring->qid);
if (rc) { if (rc) {
netif_err(rx_ring->adapter, ifup, rx_ring->netdev, netif_err(rx_ring->adapter, ifup, rx_ring->netdev,
"Failed to register xdp rx queue info. RX queue num %d rc: %d\n", "Failed to register xdp rx queue info. RX queue num %d rc: %d\n",
...@@ -217,8 +219,11 @@ static int ena_xdp_register_rxq_info(struct ena_ring *rx_ring) ...@@ -217,8 +219,11 @@ static int ena_xdp_register_rxq_info(struct ena_ring *rx_ring)
return rc; return rc;
} }
static void ena_xdp_unregister_rxq_info(struct ena_ring *rx_ring) void ena_xdp_unregister_rxq_info(struct ena_ring *rx_ring)
{ {
netif_dbg(rx_ring->adapter, ifdown, rx_ring->netdev,
"Unregistering RX info for queue %d",
rx_ring->qid);
xdp_rxq_info_unreg_mem_model(&rx_ring->xdp_rxq); xdp_rxq_info_unreg_mem_model(&rx_ring->xdp_rxq);
xdp_rxq_info_unreg(&rx_ring->xdp_rxq); xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
} }
...@@ -236,10 +241,8 @@ void ena_xdp_exchange_program_rx_in_range(struct ena_adapter *adapter, ...@@ -236,10 +241,8 @@ void ena_xdp_exchange_program_rx_in_range(struct ena_adapter *adapter,
old_bpf_prog = xchg(&rx_ring->xdp_bpf_prog, prog); old_bpf_prog = xchg(&rx_ring->xdp_bpf_prog, prog);
if (!old_bpf_prog && prog) { if (!old_bpf_prog && prog) {
ena_xdp_register_rxq_info(rx_ring);
rx_ring->rx_headroom = XDP_PACKET_HEADROOM; rx_ring->rx_headroom = XDP_PACKET_HEADROOM;
} else if (old_bpf_prog && !prog) { } else if (old_bpf_prog && !prog) {
ena_xdp_unregister_rxq_info(rx_ring);
rx_ring->rx_headroom = NET_SKB_PAD; rx_ring->rx_headroom = NET_SKB_PAD;
} }
} }
......
...@@ -42,6 +42,8 @@ int ena_xdp_xmit_frame(struct ena_ring *tx_ring, ...@@ -42,6 +42,8 @@ int ena_xdp_xmit_frame(struct ena_ring *tx_ring,
int ena_xdp_xmit(struct net_device *dev, int n, int ena_xdp_xmit(struct net_device *dev, int n,
struct xdp_frame **frames, u32 flags); struct xdp_frame **frames, u32 flags);
int ena_xdp(struct net_device *netdev, struct netdev_bpf *bpf); int ena_xdp(struct net_device *netdev, struct netdev_bpf *bpf);
int ena_xdp_register_rxq_info(struct ena_ring *rx_ring);
void ena_xdp_unregister_rxq_info(struct ena_ring *rx_ring);
enum ena_xdp_errors_t { enum ena_xdp_errors_t {
ENA_XDP_ALLOWED = 0, ENA_XDP_ALLOWED = 0,
......
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