Commit c1ba92a8 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

bnxt_en: Refactor __bnxt_xmit_xdp().

__bnxt_xmit_xdp() is used by XDP_TX and ethtool loopback packet transmit.
Refactor it so that it can be re-used by the XDP_REDIRECT logic.
Restructure the TX interrupt handler logic to cleanly separate XDP_TX
logic in preparation for XDP_REDIRECT.
Acked-by: default avatarAndy Gospodarek <gospo@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 52c06092
...@@ -596,6 +596,7 @@ struct bnxt_sw_tx_bd { ...@@ -596,6 +596,7 @@ struct bnxt_sw_tx_bd {
DEFINE_DMA_UNMAP_ADDR(mapping); DEFINE_DMA_UNMAP_ADDR(mapping);
u8 is_gso; u8 is_gso;
u8 is_push; u8 is_push;
u8 action;
union { union {
unsigned short nr_frags; unsigned short nr_frags;
u16 rx_prod; u16 rx_prod;
......
...@@ -2799,7 +2799,7 @@ static int bnxt_run_loopback(struct bnxt *bp) ...@@ -2799,7 +2799,7 @@ static int bnxt_run_loopback(struct bnxt *bp)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return -EIO; return -EIO;
} }
__bnxt_xmit_xdp(bp, txr, map, pkt_size, 0); bnxt_xmit_bd(bp, txr, map, pkt_size);
/* Sync BD data before updating doorbell */ /* Sync BD data before updating doorbell */
wmb(); wmb();
......
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
#include "bnxt.h" #include "bnxt.h"
#include "bnxt_xdp.h" #include "bnxt_xdp.h"
void __bnxt_xmit_xdp(struct bnxt *bp, struct bnxt_tx_ring_info *txr, struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp,
dma_addr_t mapping, u32 len, u16 rx_prod) struct bnxt_tx_ring_info *txr,
dma_addr_t mapping, u32 len)
{ {
struct bnxt_sw_tx_bd *tx_buf; struct bnxt_sw_tx_bd *tx_buf;
struct tx_bd *txbd; struct tx_bd *txbd;
...@@ -29,7 +30,6 @@ void __bnxt_xmit_xdp(struct bnxt *bp, struct bnxt_tx_ring_info *txr, ...@@ -29,7 +30,6 @@ void __bnxt_xmit_xdp(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
prod = txr->tx_prod; prod = txr->tx_prod;
tx_buf = &txr->tx_buf_ring[prod]; tx_buf = &txr->tx_buf_ring[prod];
tx_buf->rx_prod = rx_prod;
txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)];
flags = (len << TX_BD_LEN_SHIFT) | (1 << TX_BD_FLAGS_BD_CNT_SHIFT) | flags = (len << TX_BD_LEN_SHIFT) | (1 << TX_BD_FLAGS_BD_CNT_SHIFT) |
...@@ -40,30 +40,43 @@ void __bnxt_xmit_xdp(struct bnxt *bp, struct bnxt_tx_ring_info *txr, ...@@ -40,30 +40,43 @@ void __bnxt_xmit_xdp(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
prod = NEXT_TX(prod); prod = NEXT_TX(prod);
txr->tx_prod = prod; txr->tx_prod = prod;
return tx_buf;
}
static void __bnxt_xmit_xdp(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
dma_addr_t mapping, u32 len, u16 rx_prod)
{
struct bnxt_sw_tx_bd *tx_buf;
tx_buf = bnxt_xmit_bd(bp, txr, mapping, len);
tx_buf->rx_prod = rx_prod;
tx_buf->action = XDP_TX;
} }
void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts) void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts)
{ {
struct bnxt_tx_ring_info *txr = bnapi->tx_ring; struct bnxt_tx_ring_info *txr = bnapi->tx_ring;
struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; struct bnxt_rx_ring_info *rxr = bnapi->rx_ring;
bool rx_doorbell_needed = false;
struct bnxt_sw_tx_bd *tx_buf; struct bnxt_sw_tx_bd *tx_buf;
u16 tx_cons = txr->tx_cons; u16 tx_cons = txr->tx_cons;
u16 last_tx_cons = tx_cons; u16 last_tx_cons = tx_cons;
u16 rx_prod;
int i; int i;
for (i = 0; i < nr_pkts; i++) { for (i = 0; i < nr_pkts; i++) {
last_tx_cons = tx_cons; tx_buf = &txr->tx_buf_ring[tx_cons];
if (tx_buf->action == XDP_TX) {
rx_doorbell_needed = true;
last_tx_cons = tx_cons;
}
tx_cons = NEXT_TX(tx_cons); tx_cons = NEXT_TX(tx_cons);
} }
txr->tx_cons = tx_cons; txr->tx_cons = tx_cons;
if (bnxt_tx_avail(bp, txr) == bp->tx_ring_size) { if (rx_doorbell_needed) {
rx_prod = rxr->rx_prod;
} else {
tx_buf = &txr->tx_buf_ring[last_tx_cons]; tx_buf = &txr->tx_buf_ring[last_tx_cons];
rx_prod = tx_buf->rx_prod; bnxt_db_write(bp, &rxr->rx_db, tx_buf->rx_prod);
} }
bnxt_db_write(bp, &rxr->rx_db, rx_prod);
} }
/* returns the following: /* returns the following:
......
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
#ifndef BNXT_XDP_H #ifndef BNXT_XDP_H
#define BNXT_XDP_H #define BNXT_XDP_H
void __bnxt_xmit_xdp(struct bnxt *bp, struct bnxt_tx_ring_info *txr, struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp,
dma_addr_t mapping, u32 len, u16 rx_prod); struct bnxt_tx_ring_info *txr,
dma_addr_t mapping, u32 len);
void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts); void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts);
bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons, bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons,
struct page *page, u8 **data_ptr, unsigned int *len, struct page *page, u8 **data_ptr, unsigned int *len,
......
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