Commit 37c4947a authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by Jakub Kicinski

net: tn40xx: add basic Rx handling

This patch adds basic Rx handling. The Rx logic uses three major data
structures; two ring buffers with NIC and one database. One ring
buffer is used to send information to NIC about memory to be stored
packets to be received. The other is used to get information from NIC
about received packets. The database is used to keep the information
about DMA mapping. After a packet arrived, the db is used to pass the
packet to the network stack.
Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: default avatarHans-Frieder Vogt <hfdevel@gmx.net>
Link: https://patch.msgid.link/20240623235507.108147-6-fujita.tomonori@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent dd2a0ff5
......@@ -26,6 +26,7 @@ config TEHUTI
config TEHUTI_TN40
tristate "Tehuti Networks TN40xx 10G Ethernet adapters"
depends on PCI
select PAGE_POOL
select FW_LOADER
help
This driver supports 10G Ethernet adapters using Tehuti Networks
......
This diff is collapsed.
......@@ -60,6 +60,25 @@ struct tn40_txd_fifo {
struct tn40_fifo m; /* The minimal set of variables used by all fifos */
};
struct tn40_rxf_fifo {
struct tn40_fifo m; /* The minimal set of variables used by all fifos */
};
struct tn40_rxd_fifo {
struct tn40_fifo m; /* The minimal set of variables used by all fifos */
};
struct tn40_rx_map {
struct page *page;
};
struct tn40_rxdb {
unsigned int *stack;
struct tn40_rx_map *elems;
unsigned int nelem;
unsigned int top;
};
union tn40_tx_dma_addr {
dma_addr_t dma;
struct sk_buff *skb;
......@@ -87,6 +106,13 @@ struct tn40_priv {
struct net_device *ndev;
struct pci_dev *pdev;
struct napi_struct napi;
/* RX FIFOs: 1 for data (full) descs, and 2 for free descs */
struct tn40_rxd_fifo rxd_fifo0;
struct tn40_rxf_fifo rxf_fifo0;
struct tn40_rxdb *rxdb0; /* Rx dbs to store skb pointers */
struct page_pool *page_pool;
/* Tx FIFOs: 1 for data desc, 1 for empty (acks) desc */
struct tn40_txd_fifo txd_fifo0;
struct tn40_txf_fifo txf_fifo0;
......@@ -116,6 +142,32 @@ struct tn40_priv {
char *b0_va; /* Virtual address of buffer */
};
/* RX FREE descriptor - 64bit */
struct tn40_rxf_desc {
__le32 info; /* Buffer Count + Info - described below */
__le32 va_lo; /* VAdr[31:0] */
__le32 va_hi; /* VAdr[63:32] */
__le32 pa_lo; /* PAdr[31:0] */
__le32 pa_hi; /* PAdr[63:32] */
__le32 len; /* Buffer Length */
};
#define TN40_GET_RXD_BC(x) FIELD_GET(GENMASK(4, 0), (x))
#define TN40_GET_RXD_ERR(x) FIELD_GET(GENMASK(26, 21), (x))
#define TN40_GET_RXD_PKT_ID(x) FIELD_GET(GENMASK(30, 28), (x))
#define TN40_GET_RXD_VTAG(x) FIELD_GET(BIT(31), (x))
#define TN40_GET_RXD_VLAN_TCI(x) FIELD_GET(GENMASK(15, 0), (x))
struct tn40_rxd_desc {
__le32 rxd_val1;
__le16 len;
__le16 rxd_vlan;
__le32 va_lo;
__le32 va_hi;
__le32 rss_lo;
__le32 rss_hash;
};
#define TN40_MAX_PBL (19)
/* PBL describes each virtual buffer to be transmitted from the host. */
struct tn40_pbl {
......
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