net/nfp: move common Rx/Tx functions for flower use

Move some common Rx and Tx logic to the header file so that
they can be re-used by flower Tx and Rx logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Heinrich Kuhn <heinrich.kuhn@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
This commit is contained in:
Chaoyong He 2022-09-26 14:59:51 +08:00 committed by Ferruh Yigit
parent 945441ebdb
commit d981d315ac
2 changed files with 32 additions and 31 deletions

View File

@ -116,12 +116,6 @@ nfp_net_rx_queue_count(void *rx_queue)
return count;
}
static inline void
nfp_net_mbuf_alloc_failed(struct nfp_net_rxq *rxq)
{
rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++;
}
/*
* nfp_net_set_hash - Set mbuf hash data
*
@ -583,7 +577,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
* @txq: TX queue to work with
* Returns number of descriptors freed
*/
static int
int
nfp_net_tx_free_bufs(struct nfp_net_txq *txq)
{
uint32_t qcp_rd_p;
@ -774,30 +768,6 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
return 0;
}
/* Leaving always free descriptors for avoiding wrapping confusion */
static inline
uint32_t nfp_net_nfd3_free_tx_desc(struct nfp_net_txq *txq)
{
if (txq->wr_p >= txq->rd_p)
return txq->tx_count - (txq->wr_p - txq->rd_p) - 8;
else
return txq->rd_p - txq->wr_p - 8;
}
/*
* nfp_net_txq_full - Check if the TX queue free descriptors
* is below tx_free_threshold
*
* @txq: TX queue to check
*
* This function uses the host copy* of read/write pointers
*/
static inline
uint32_t nfp_net_nfd3_txq_full(struct nfp_net_txq *txq)
{
return (nfp_net_nfd3_free_tx_desc(txq) < txq->tx_free_thresh);
}
/* nfp_net_tx_tso - Set TX descriptor for TSO */
static inline void
nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq, struct nfp_net_nfd3_tx_desc *txd,

View File

@ -330,6 +330,36 @@ struct nfp_net_rxq {
int rx_qcidx;
} __rte_aligned(64);
static inline void
nfp_net_mbuf_alloc_failed(struct nfp_net_rxq *rxq)
{
rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++;
}
/* Leaving always free descriptors for avoiding wrapping confusion */
static inline uint32_t
nfp_net_nfd3_free_tx_desc(struct nfp_net_txq *txq)
{
if (txq->wr_p >= txq->rd_p)
return txq->tx_count - (txq->wr_p - txq->rd_p) - 8;
else
return txq->rd_p - txq->wr_p - 8;
}
/*
* nfp_net_nfd3_txq_full - Check if the TX queue free descriptors
* is below tx_free_threshold
*
* @txq: TX queue to check
*
* This function uses the host copy* of read/write pointers
*/
static inline uint32_t
nfp_net_nfd3_txq_full(struct nfp_net_txq *txq)
{
return (nfp_net_nfd3_free_tx_desc(txq) < txq->tx_free_thresh);
}
int nfp_net_rx_freelist_setup(struct rte_eth_dev *dev);
uint32_t nfp_net_rx_queue_count(void *rx_queue);
uint16_t nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
@ -352,6 +382,7 @@ int nfp_net_tx_queue_setup(struct rte_eth_dev *dev,
uint16_t nfp_net_nfdk_xmit_pkts(void *tx_queue,
struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
int nfp_net_tx_free_bufs(struct nfp_net_txq *txq);
#endif /* _NFP_RXTX_H_ */
/*