net/nfp: move datapath functions to their own file

Create a new rxtx file and move the Rx/Tx functions to this file. This
commit will also move the needed shared functions to the nfp_net_pmd.h
file as needed.

Signed-off-by: Heinrich Kuhn <heinrich.kuhn@netronome.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
This commit is contained in:
Heinrich Kuhn 2021-07-29 15:47:06 +02:00 committed by Ferruh Yigit
parent 74f99d454e
commit 79c7601a64
5 changed files with 1173 additions and 1131 deletions

View File

@ -19,4 +19,5 @@ sources = files(
'nfpcore/nfp_nsp_eth.c', 'nfpcore/nfp_nsp_eth.c',
'nfpcore/nfp_hwinfo.c', 'nfpcore/nfp_hwinfo.c',
'nfp_net.c', 'nfp_net.c',
'nfp_rxtx.c',
) )

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,12 @@ struct nfp_net_adapter;
#define NFP_QCP_QUEUE_STS_HI 0x000c #define NFP_QCP_QUEUE_STS_HI 0x000c
#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_mask (0x3ffff) #define NFP_QCP_QUEUE_STS_HI_WRITEPTR_mask (0x3ffff)
/* The offset of the queue controller queues in the PCIe Target */
#define NFP_PCIE_QUEUE(_q) (0x80000 + (NFP_QCP_QUEUE_ADDR_SZ * ((_q) & 0xff)))
/* Maximum value which can be added to a queue with one transaction */
#define NFP_QCP_MAX_ADD 0x7f
/* Interrupt definitions */ /* Interrupt definitions */
#define NFP_NET_IRQ_LSC_IDX 0 #define NFP_NET_IRQ_LSC_IDX 0
@ -95,47 +101,11 @@ struct nfp_net_adapter;
#include <linux/types.h> #include <linux/types.h>
#include <rte_io.h> #include <rte_io.h>
static inline uint8_t nn_readb(volatile const void *addr) /* nfp_qcp_ptr - Read or Write Pointer of a queue */
{ enum nfp_qcp_ptr {
return rte_read8(addr); NFP_QCP_READ_PTR = 0,
} NFP_QCP_WRITE_PTR
};
static inline void nn_writeb(uint8_t val, volatile void *addr)
{
rte_write8(val, addr);
}
static inline uint32_t nn_readl(volatile const void *addr)
{
return rte_read32(addr);
}
static inline void nn_writel(uint32_t val, volatile void *addr)
{
rte_write32(val, addr);
}
static inline void nn_writew(uint16_t val, volatile void *addr)
{
rte_write16(val, addr);
}
static inline uint64_t nn_readq(volatile void *addr)
{
const volatile uint32_t *p = addr;
uint32_t low, high;
high = nn_readl((volatile const void *)(p + 1));
low = nn_readl((volatile const void *)p);
return low + ((uint64_t)high << 32);
}
static inline void nn_writeq(uint64_t val, volatile void *addr)
{
nn_writel(val >> 32, (volatile char *)addr + 4);
nn_writel(val, addr);
}
struct nfp_pf_dev { struct nfp_pf_dev {
/* Backpointer to associated pci device */ /* Backpointer to associated pci device */
@ -247,6 +217,138 @@ struct nfp_net_adapter {
struct nfp_net_hw hw; struct nfp_net_hw hw;
}; };
static inline uint8_t nn_readb(volatile const void *addr)
{
return rte_read8(addr);
}
static inline void nn_writeb(uint8_t val, volatile void *addr)
{
rte_write8(val, addr);
}
static inline uint32_t nn_readl(volatile const void *addr)
{
return rte_read32(addr);
}
static inline void nn_writel(uint32_t val, volatile void *addr)
{
rte_write32(val, addr);
}
static inline void nn_writew(uint16_t val, volatile void *addr)
{
rte_write16(val, addr);
}
static inline uint64_t nn_readq(volatile void *addr)
{
const volatile uint32_t *p = addr;
uint32_t low, high;
high = nn_readl((volatile const void *)(p + 1));
low = nn_readl((volatile const void *)p);
return low + ((uint64_t)high << 32);
}
static inline void nn_writeq(uint64_t val, volatile void *addr)
{
nn_writel(val >> 32, (volatile char *)addr + 4);
nn_writel(val, addr);
}
/*
* Functions to read/write from/to Config BAR
* Performs any endian conversion necessary.
*/
static inline uint8_t
nn_cfg_readb(struct nfp_net_hw *hw, int off)
{
return nn_readb(hw->ctrl_bar + off);
}
static inline void
nn_cfg_writeb(struct nfp_net_hw *hw, int off, uint8_t val)
{
nn_writeb(val, hw->ctrl_bar + off);
}
static inline uint32_t
nn_cfg_readl(struct nfp_net_hw *hw, int off)
{
return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
}
static inline void
nn_cfg_writel(struct nfp_net_hw *hw, int off, uint32_t val)
{
nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
}
static inline uint64_t
nn_cfg_readq(struct nfp_net_hw *hw, int off)
{
return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
}
static inline void
nn_cfg_writeq(struct nfp_net_hw *hw, int off, uint64_t val)
{
nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
}
/*
* nfp_qcp_ptr_add - Add the value to the selected pointer of a queue
* @q: Base address for queue structure
* @ptr: Add to the Read or Write pointer
* @val: Value to add to the queue pointer
*
* If @val is greater than @NFP_QCP_MAX_ADD multiple writes are performed.
*/
static inline void
nfp_qcp_ptr_add(uint8_t *q, enum nfp_qcp_ptr ptr, uint32_t val)
{
uint32_t off;
if (ptr == NFP_QCP_READ_PTR)
off = NFP_QCP_QUEUE_ADD_RPTR;
else
off = NFP_QCP_QUEUE_ADD_WPTR;
while (val > NFP_QCP_MAX_ADD) {
nn_writel(rte_cpu_to_le_32(NFP_QCP_MAX_ADD), q + off);
val -= NFP_QCP_MAX_ADD;
}
nn_writel(rte_cpu_to_le_32(val), q + off);
}
/*
* nfp_qcp_read - Read the current Read/Write pointer value for a queue
* @q: Base address for queue structure
* @ptr: Read or Write pointer
*/
static inline uint32_t
nfp_qcp_read(uint8_t *q, enum nfp_qcp_ptr ptr)
{
uint32_t off;
uint32_t val;
if (ptr == NFP_QCP_READ_PTR)
off = NFP_QCP_QUEUE_STS_LO;
else
off = NFP_QCP_QUEUE_STS_HI;
val = rte_cpu_to_le_32(nn_readl(q + off));
if (ptr == NFP_QCP_READ_PTR)
return val & NFP_QCP_QUEUE_STS_LO_READPTR_mask;
else
return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_mask;
}
#define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\ #define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\
(&((struct nfp_net_adapter *)adapter)->hw) (&((struct nfp_net_adapter *)adapter)->hw)

1002
drivers/net/nfp/nfp_rxtx.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,14 @@
#include <linux/types.h> #include <linux/types.h>
#include <rte_io.h> #include <rte_io.h>
#define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
#define NFP_HASH_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 4)
#define NFP_HASH_TYPE_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 8)
#define RTE_MBUF_DMA_ADDR_DEFAULT(mb) \
((uint64_t)((mb)->buf_iova + RTE_PKTMBUF_HEADROOM))
/* /*
* The maximum number of descriptors is limited by design as * The maximum number of descriptors is limited by design as
* DPDK uses uint16_t variables for these values * DPDK uses uint16_t variables for these values
@ -266,6 +274,25 @@ struct nfp_net_rxq {
int rx_qcidx; int rx_qcidx;
} __rte_aligned(64); } __rte_aligned(64);
int nfp_net_rx_freelist_setup(struct rte_eth_dev *dev);
uint32_t nfp_net_rx_queue_count(struct rte_eth_dev *dev,
uint16_t queue_idx);
uint16_t nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
void nfp_net_rx_queue_release(void *rxq);
void nfp_net_reset_rx_queue(struct nfp_net_rxq *rxq);
int nfp_net_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
uint16_t nb_desc, unsigned int socket_id,
const struct rte_eth_rxconf *rx_conf,
struct rte_mempool *mp);
void nfp_net_tx_queue_release(void *txq);
void nfp_net_reset_tx_queue(struct nfp_net_txq *txq);
int nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
uint16_t nb_desc, unsigned int socket_id,
const struct rte_eth_txconf *tx_conf);
uint16_t nfp_net_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
#endif /* _NFP_RXTX_H_ */ #endif /* _NFP_RXTX_H_ */
/* /*
* Local variables: * Local variables: