net/nfp: update descriptors logic
PATCH 1/1 net/nfp: update descriptors logic
From: Jin Liu <[email protected]>
The minimum value of TX/RX descriptors for NFP3800 card is not same with NFP4000 card, the minimum value of NFP4000 card is 256 while NFP3800 card is 512, add the minimum descriptor macro for NFP3800 card.
Modify the logic of get descriptor value, assign the value of descriptor for the corresponding network card according to its type.
In TX stage, firmware with NFD3 use one descriptor per packet while firmware with NFDk use two descriptors. In order to be consistent with the kernel driver, the number of descriptor of firmware with NFDk should be divided by 2.
--- drivers/net/nfp/nfp_common.c | 86 ++++++++++++++++++++++++++++++++++-- drivers/net/nfp/nfp_common.h | 6 +++ drivers/net/nfp/nfp_rxtx.c | 51 ++++++++++++++------- drivers/net/nfp/nfp_rxtx.h | 3 ++ 4 files changed, 127 insertions(+), 19 deletions(-)
drivers/net/nfp/nfp_common.c +82 -4
@@ -697,13 +697,91 @@ nfp_net_stats_reset(struct rte_eth_dev *dev)return 0 ; } +int +nfp_net_rx_desc_limits (struct nfp_net_hw *hw, +uint16_t *min_rx_desc, +uint16_t *max_rx_desc) +{ + *max_rx_desc =NFP_NET_MAX_RX_DESC ; + +switch (hw->device_id) { +case PCI_DEVICE_ID_NFP3800_PF_NIC : +case PCI_DEVICE_ID_NFP3800_VF_NIC : + *min_rx_desc =NFP3800_NET_MIN_RX_DESC ; +return 0 ; +case PCI_DEVICE_ID_NFP4000_PF_NIC : +case PCI_DEVICE_ID_NFP6000_PF_NIC : +case PCI_DEVICE_ID_NFP6000_VF_NIC : + *min_rx_desc =NFP_NET_MIN_RX_DESC ; +return 0 ; +default : +PMD_DRV_LOG (ERR ,"Unknown NFP device id." ); +return -EINVAL ; + } +} + +int +nfp_net_tx_desc_limits (struct nfp_net_hw *hw, +uint16_t *min_tx_desc, +uint16_t *max_tx_desc) +{ +uint16_t tx_dpp; + +switch (NFD_CFG_CLASS_VER_of (hw->ver)) { +case NFP_NET_CFG_VERSION_DP_NFD3 : + tx_dpp =NFD3_TX_DESC_PER_SIMPLE_PKT ; +break ; +case NFP_NET_CFG_VERSION_DP_NFDK : +if (NFD_CFG_MAJOR_VERSION_of (hw->ver) <5 ) { +PMD_DRV_LOG (ERR ,"NFDK must use ABI 5 or newer, found: %d" , +NFD_CFG_MAJOR_VERSION_of (hw->ver)); +return -EINVAL ; + } + tx_dpp =NFDK_TX_DESC_PER_SIMPLE_PKT ; +break ; +default : +PMD_DRV_LOG (ERR ,"The version of firmware is not correct." ); +return -EINVAL ; + } + + *max_tx_desc =NFP_NET_MAX_TX_DESC / tx_dpp; + +switch (hw->device_id) { +case PCI_DEVICE_ID_NFP3800_PF_NIC : +case PCI_DEVICE_ID_NFP3800_VF_NIC : + *min_tx_desc =NFP3800_NET_MIN_TX_DESC / tx_dpp; +return 0 ; +case PCI_DEVICE_ID_NFP4000_PF_NIC : +case PCI_DEVICE_ID_NFP6000_PF_NIC : +case PCI_DEVICE_ID_NFP6000_VF_NIC : + *min_tx_desc =NFP_NET_MIN_TX_DESC / tx_dpp; +return 0 ; +default : +PMD_DRV_LOG (ERR ,"Unknown NFP device id." ); +return -EINVAL ; + } +} +int nfp_net_infos_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { +int ret; +uint16_t min_rx_desc; +uint16_t max_rx_desc; +uint16_t min_tx_desc; +uint16_t max_tx_desc;struct nfp_net_hw *hw; hw =NFP_NET_DEV_PRIVATE_TO_HW (dev->data->dev_private); + ret =nfp_net_rx_desc_limits (hw, &min_rx_desc, &max_rx_desc); +if (ret !=0 ) +return ret; + + ret =nfp_net_tx_desc_limits (hw, &min_tx_desc, &max_tx_desc); +if (ret !=0 ) +return ret; + dev_info->max_rx_queues = (uint16_t )hw->max_rx_queues; dev_info->max_tx_queues = (uint16_t )hw->max_tx_queues; dev_info->min_rx_bufsize =RTE_ETHER_MIN_MTU ;
@@ -764,14 +842,14 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) }; dev_info->rx_desc_lim = (struct rte_eth_desc_lim ) { - .nb_max =NFP_NET_MAX_RX_DESC , - .nb_min =NFP_NET_MIN_RX_DESC , + .nb_max = max_rx_desc, + .nb_min = min_rx_desc, .nb_align =NFP_ALIGN_RING_DESC , }; dev_info->tx_desc_lim = (struct rte_eth_desc_lim ) { - .nb_max =NFP_NET_MAX_TX_DESC , - .nb_min =NFP_NET_MIN_TX_DESC , + .nb_max = max_tx_desc, + .nb_min = min_tx_desc, .nb_align =NFP_ALIGN_RING_DESC , .nb_seg_max =NFP_TX_MAX_SEG , .nb_mtu_seg_max =NFP_TX_MAX_MTU_SEG ,
drivers/net/nfp/nfp_common.h +6 -0
@@ -447,6 +447,12 @@ void nfp_net_close_rx_queue(struct rte_eth_dev *dev);void nfp_net_stop_tx_queue (struct rte_eth_dev *dev);void nfp_net_close_tx_queue (struct rte_eth_dev *dev);int nfp_net_set_vxlan_port (struct nfp_net_hw *hw,size_t idx,uint16_t port); +int nfp_net_rx_desc_limits (struct nfp_net_hw *hw, +uint16_t *min_rx_desc, +uint16_t *max_rx_desc); +int nfp_net_tx_desc_limits (struct nfp_net_hw *hw, +uint16_t *min_tx_desc, +uint16_t *max_tx_desc);#define NFP_NET_DEV_PRIVATE_TO_HW (adapter)\ (&((struct nfp_net_adapter *)adapter)->hw)
drivers/net/nfp/nfp_rxtx.c +36 -15
136 lines not on this page · raw message
drivers/net/nfp/nfp_rxtx.h +3 -0
@@ -31,9 +31,11 @@*/ #define NFP_NET_MAX_TX_DESC (32 * 1024)#define NFP_NET_MIN_TX_DESC 256 +#define NFP3800_NET_MIN_TX_DESC 512#define NFP_NET_MAX_RX_DESC (32 * 1024)#define NFP_NET_MIN_RX_DESC 256 +#define NFP3800_NET_MIN_RX_DESC 512/* Descriptor alignment */ #define NFP_ALIGN_RING_DESC 128
@@ -57,6 +59,7 @@#define NFDK_DESC_TX_DMA_LEN_HEAD 0x0fff#define NFDK_DESC_TX_TYPE_HEAD 0xf000#define NFDK_DESC_TX_DMA_LEN 0x3fff +#define NFD3_TX_DESC_PER_SIMPLE_PKT 1#define NFDK_TX_DESC_PER_SIMPLE_PKT 2#define NFDK_DESC_TX_TYPE_TSO 2#define NFDK_DESC_TX_TYPE_SIMPLE 8
Signature · 1 line
2.38.1
Ferruh Yigit
AppliedQuoted 15 lines · Niklas Söderlund
From: Jin Liu <[email protected]>
The minimum value of TX/RX descriptors for NFP3800 card is not same with NFP4000 card, the minimum value of NFP4000 card is 256 while NFP3800 card is 512, add the minimum descriptor macro for NFP3800 card.
Modify the logic of get descriptor value, assign the value of descriptor for the corresponding network card according to its type.
In TX stage, firmware with NFD3 use one descriptor per packet while firmware with NFDk use two descriptors. In order to be consistent with the kernel driver, the number of descriptor of firmware with NFDk should be divided by 2.
Quoted 4 lines
Signed-off-by Jin Liu <[email protected]>Reviewed-by Chaoyong He <[email protected]>Reviewed-by Niklas Söderlund <[email protected]>Signed-off-by Niklas Söderlund <[email protected]>
Applied to dpdk-next-net/main, thanks.