net/nfp: move Rx/Tx functions to header file
The flower firmware application makes use of the same Rx and Tx checksum logic as the normal PMD. Expose it so that flower firmware application also can make use of it. 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:
parent
831c44ab78
commit
a5f377d8f5
@ -38,9 +38,9 @@
|
||||
#include "nfpcore/nfp_nsp.h"
|
||||
|
||||
#include "nfp_common.h"
|
||||
#include "nfp_ctrl.h"
|
||||
#include "nfp_rxtx.h"
|
||||
#include "nfp_logs.h"
|
||||
#include "nfp_ctrl.h"
|
||||
#include "nfp_cpp_bridge.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -33,9 +33,9 @@
|
||||
#include "nfpcore/nfp_nsp.h"
|
||||
|
||||
#include "nfp_common.h"
|
||||
#include "nfp_ctrl.h"
|
||||
#include "nfp_rxtx.h"
|
||||
#include "nfp_logs.h"
|
||||
#include "nfp_ctrl.h"
|
||||
#include "nfp_cpp_bridge.h"
|
||||
|
||||
#include "flower/nfp_flower.h"
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include "nfpcore/nfp_rtsym.h"
|
||||
|
||||
#include "nfp_common.h"
|
||||
#include "nfp_ctrl.h"
|
||||
#include "nfp_rxtx.h"
|
||||
#include "nfp_logs.h"
|
||||
#include "nfp_ctrl.h"
|
||||
|
||||
static void
|
||||
nfp_netvf_read_mac(struct nfp_net_hw *hw)
|
||||
|
@ -17,9 +17,9 @@
|
||||
#include <ethdev_pci.h>
|
||||
|
||||
#include "nfp_common.h"
|
||||
#include "nfp_ctrl.h"
|
||||
#include "nfp_rxtx.h"
|
||||
#include "nfp_logs.h"
|
||||
#include "nfp_ctrl.h"
|
||||
#include "nfpcore/nfp_mip.h"
|
||||
#include "nfpcore/nfp_rtsym.h"
|
||||
#include "nfpcore/nfp-common/nfp_platform.h"
|
||||
@ -208,34 +208,6 @@ nfp_net_set_hash(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd,
|
||||
}
|
||||
}
|
||||
|
||||
/* nfp_net_rx_cksum - set mbuf checksum flags based on RX descriptor flags */
|
||||
static inline void
|
||||
nfp_net_rx_cksum(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd,
|
||||
struct rte_mbuf *mb)
|
||||
{
|
||||
struct nfp_net_hw *hw = rxq->hw;
|
||||
|
||||
if (!(hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM))
|
||||
return;
|
||||
|
||||
/* If IPv4 and IP checksum error, fail */
|
||||
if (unlikely((rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM) &&
|
||||
!(rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM_OK)))
|
||||
mb->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
|
||||
else
|
||||
mb->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
|
||||
|
||||
/* If neither UDP nor TCP return */
|
||||
if (!(rxd->rxd.flags & PCIE_DESC_RX_TCP_CSUM) &&
|
||||
!(rxd->rxd.flags & PCIE_DESC_RX_UDP_CSUM))
|
||||
return;
|
||||
|
||||
if (likely(rxd->rxd.flags & PCIE_DESC_RX_L4_CSUM_OK))
|
||||
mb->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
|
||||
else
|
||||
mb->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
|
||||
}
|
||||
|
||||
/*
|
||||
* RX path design:
|
||||
*
|
||||
@ -768,67 +740,6 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 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,
|
||||
struct rte_mbuf *mb)
|
||||
{
|
||||
uint64_t ol_flags;
|
||||
struct nfp_net_hw *hw = txq->hw;
|
||||
|
||||
if (!(hw->cap & NFP_NET_CFG_CTRL_LSO_ANY))
|
||||
goto clean_txd;
|
||||
|
||||
ol_flags = mb->ol_flags;
|
||||
|
||||
if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG))
|
||||
goto clean_txd;
|
||||
|
||||
txd->l3_offset = mb->l2_len;
|
||||
txd->l4_offset = mb->l2_len + mb->l3_len;
|
||||
txd->lso_hdrlen = mb->l2_len + mb->l3_len + mb->l4_len;
|
||||
txd->mss = rte_cpu_to_le_16(mb->tso_segsz);
|
||||
txd->flags = PCIE_DESC_TX_LSO;
|
||||
return;
|
||||
|
||||
clean_txd:
|
||||
txd->flags = 0;
|
||||
txd->l3_offset = 0;
|
||||
txd->l4_offset = 0;
|
||||
txd->lso_hdrlen = 0;
|
||||
txd->mss = 0;
|
||||
}
|
||||
|
||||
/* nfp_net_tx_cksum - Set TX CSUM offload flags in TX descriptor */
|
||||
static inline void
|
||||
nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq, struct nfp_net_nfd3_tx_desc *txd,
|
||||
struct rte_mbuf *mb)
|
||||
{
|
||||
uint64_t ol_flags;
|
||||
struct nfp_net_hw *hw = txq->hw;
|
||||
|
||||
if (!(hw->cap & NFP_NET_CFG_CTRL_TXCSUM))
|
||||
return;
|
||||
|
||||
ol_flags = mb->ol_flags;
|
||||
|
||||
/* IPv6 does not need checksum */
|
||||
if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM)
|
||||
txd->flags |= PCIE_DESC_TX_IP4_CSUM;
|
||||
|
||||
switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
|
||||
case RTE_MBUF_F_TX_UDP_CKSUM:
|
||||
txd->flags |= PCIE_DESC_TX_UDP_CSUM;
|
||||
break;
|
||||
case RTE_MBUF_F_TX_TCP_CKSUM:
|
||||
txd->flags |= PCIE_DESC_TX_TCP_CSUM;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK))
|
||||
txd->flags |= PCIE_DESC_TX_CSUM;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
|
||||
{
|
||||
|
@ -360,6 +360,96 @@ nfp_net_nfd3_txq_full(struct nfp_net_txq *txq)
|
||||
return (nfp_net_nfd3_free_tx_desc(txq) < txq->tx_free_thresh);
|
||||
}
|
||||
|
||||
/* set mbuf checksum flags based on RX descriptor flags */
|
||||
static inline void
|
||||
nfp_net_rx_cksum(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd,
|
||||
struct rte_mbuf *mb)
|
||||
{
|
||||
struct nfp_net_hw *hw = rxq->hw;
|
||||
|
||||
if (!(hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM))
|
||||
return;
|
||||
|
||||
/* If IPv4 and IP checksum error, fail */
|
||||
if (unlikely((rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM) &&
|
||||
!(rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM_OK)))
|
||||
mb->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
|
||||
else
|
||||
mb->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
|
||||
|
||||
/* If neither UDP nor TCP return */
|
||||
if (!(rxd->rxd.flags & PCIE_DESC_RX_TCP_CSUM) &&
|
||||
!(rxd->rxd.flags & PCIE_DESC_RX_UDP_CSUM))
|
||||
return;
|
||||
|
||||
if (likely(rxd->rxd.flags & PCIE_DESC_RX_L4_CSUM_OK))
|
||||
mb->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
|
||||
else
|
||||
mb->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
|
||||
}
|
||||
|
||||
/* Set NFD3 TX descriptor for TSO */
|
||||
static inline void
|
||||
nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq,
|
||||
struct nfp_net_nfd3_tx_desc *txd,
|
||||
struct rte_mbuf *mb)
|
||||
{
|
||||
uint64_t ol_flags;
|
||||
struct nfp_net_hw *hw = txq->hw;
|
||||
|
||||
if (!(hw->cap & NFP_NET_CFG_CTRL_LSO_ANY))
|
||||
goto clean_txd;
|
||||
|
||||
ol_flags = mb->ol_flags;
|
||||
|
||||
if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG))
|
||||
goto clean_txd;
|
||||
|
||||
txd->l3_offset = mb->l2_len;
|
||||
txd->l4_offset = mb->l2_len + mb->l3_len;
|
||||
txd->lso_hdrlen = mb->l2_len + mb->l3_len + mb->l4_len;
|
||||
txd->mss = rte_cpu_to_le_16(mb->tso_segsz);
|
||||
txd->flags = PCIE_DESC_TX_LSO;
|
||||
return;
|
||||
|
||||
clean_txd:
|
||||
txd->flags = 0;
|
||||
txd->l3_offset = 0;
|
||||
txd->l4_offset = 0;
|
||||
txd->lso_hdrlen = 0;
|
||||
txd->mss = 0;
|
||||
}
|
||||
|
||||
/* Set TX CSUM offload flags in NFD3 TX descriptor */
|
||||
static inline void
|
||||
nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq, struct nfp_net_nfd3_tx_desc *txd,
|
||||
struct rte_mbuf *mb)
|
||||
{
|
||||
uint64_t ol_flags;
|
||||
struct nfp_net_hw *hw = txq->hw;
|
||||
|
||||
if (!(hw->cap & NFP_NET_CFG_CTRL_TXCSUM))
|
||||
return;
|
||||
|
||||
ol_flags = mb->ol_flags;
|
||||
|
||||
/* IPv6 does not need checksum */
|
||||
if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM)
|
||||
txd->flags |= PCIE_DESC_TX_IP4_CSUM;
|
||||
|
||||
switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
|
||||
case RTE_MBUF_F_TX_UDP_CKSUM:
|
||||
txd->flags |= PCIE_DESC_TX_UDP_CSUM;
|
||||
break;
|
||||
case RTE_MBUF_F_TX_TCP_CKSUM:
|
||||
txd->flags |= PCIE_DESC_TX_TCP_CSUM;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK))
|
||||
txd->flags |= PCIE_DESC_TX_CSUM;
|
||||
}
|
||||
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user