Commit be8b38a7 authored by Ong Boon Leong's avatar Ong Boon Leong Committed by David S. Miller

net: stmmac: Add support for XDP_TX action

This patch adds support for XDP_TX action which enables XDP program to
transmit back received frames.

This patch has been tested with the "xdp2" app located in samples/bpf
dir. The DUT receives burst traffic packet generated using pktgen script
'pktgen_sample03_burst_single_flow.sh'.

v4: Moved stmmac_tx_timer_arm() to be done once at the end of NAPI RX.
    Fixed stmmac_xdp_xmit_back() to return STMMAC_XDP_CONSUMED if
    XDP buffer to frame conversion fails. Thanks to Jakub's input.

v3: Added 'nq->trans_start = jiffies' to avoid TX time-out as we are
    sharing TX queue between slow path and XDP. Thanks to Jakub Kicinski
    for pointing out.
Signed-off-by: default avatarOng Boon Leong <boon.leong.ong@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5fabb012
...@@ -36,12 +36,18 @@ struct stmmac_resources { ...@@ -36,12 +36,18 @@ struct stmmac_resources {
int tx_irq[MTL_MAX_TX_QUEUES]; int tx_irq[MTL_MAX_TX_QUEUES];
}; };
enum stmmac_txbuf_type {
STMMAC_TXBUF_T_SKB,
STMMAC_TXBUF_T_XDP_TX,
};
struct stmmac_tx_info { struct stmmac_tx_info {
dma_addr_t buf; dma_addr_t buf;
bool map_as_page; bool map_as_page;
unsigned len; unsigned len;
bool last_segment; bool last_segment;
bool is_jumbo; bool is_jumbo;
enum stmmac_txbuf_type buf_type;
}; };
#define STMMAC_TBS_AVAIL BIT(0) #define STMMAC_TBS_AVAIL BIT(0)
...@@ -57,7 +63,10 @@ struct stmmac_tx_queue { ...@@ -57,7 +63,10 @@ struct stmmac_tx_queue {
struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp; struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
struct dma_edesc *dma_entx; struct dma_edesc *dma_entx;
struct dma_desc *dma_tx; struct dma_desc *dma_tx;
union {
struct sk_buff **tx_skbuff; struct sk_buff **tx_skbuff;
struct xdp_frame **xdpf;
};
struct stmmac_tx_info *tx_skbuff_dma; struct stmmac_tx_info *tx_skbuff_dma;
unsigned int cur_tx; unsigned int cur_tx;
unsigned int dirty_tx; unsigned int dirty_tx;
...@@ -77,6 +86,7 @@ struct stmmac_rx_buffer { ...@@ -77,6 +86,7 @@ struct stmmac_rx_buffer {
struct stmmac_rx_queue { struct stmmac_rx_queue {
u32 rx_count_frames; u32 rx_count_frames;
u32 queue_index; u32 queue_index;
struct xdp_rxq_info xdp_rxq;
struct page_pool *page_pool; struct page_pool *page_pool;
struct stmmac_rx_buffer *buf_pool; struct stmmac_rx_buffer *buf_pool;
struct stmmac_priv *priv_data; struct stmmac_priv *priv_data;
......
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