code optimization for hns3 PMD
Subsystems (2)
cover code optimization for hns3 PMD
This patch set contains refactor patches and code check patches.
Chengwen Feng (1):
net/hns3: remove PF/VF duplicate code
Huisong Li (7):
net/hns3: fix the shift of DMA address in Rx/Tx queue net/hns3: remove a redundant function declaration net/hns3: modifying code alignment
net/hns3: use unsigned integer for bitwise operations net/hns3: extract a common file
net/hns3: remove magic numbers
net/hns3: fix the return value of the function
Min Hu (Connor) (1):
net/hns3: add hns3 flow header file
drivers/net/hns3/hns3_cmd.c | 2 +- drivers/net/hns3/hns3_common.c | 762 ++++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 61 +++ drivers/net/hns3/hns3_ethdev.c | 748 +---------------------------- drivers/net/hns3/hns3_ethdev.h | 47 +- drivers/net/hns3/hns3_ethdev_vf.c | 327 +------------ drivers/net/hns3/hns3_fdir.h | 31 -- drivers/net/hns3/hns3_flow.c | 1 + drivers/net/hns3/hns3_flow.h | 44 ++ drivers/net/hns3/hns3_intr.c | 2 +- drivers/net/hns3/hns3_mbx.c | 2 +- drivers/net/hns3/hns3_rxtx.c | 8 +- drivers/net/hns3/hns3_rxtx.h | 1 - drivers/net/hns3/hns3_tm.c | 2 +- drivers/net/hns3/meson.build | 1 + 15 files changed, 901 insertions(+), 1138 deletions(-) create mode 100644 drivers/net/hns3/hns3_common.c create mode 100644 drivers/net/hns3/hns3_common.h create mode 100644 drivers/net/hns3/hns3_flow.h
Signature · 1 line
2.33.0
PATCH 1/9 net/hns3: fix the shift of DMA address in Rx/Tx queue
From: Huisong Li <[email protected]>
The patch obtains the upper 32 bits of the Rx/Tx queue DMA address in one step instead of two steps.
--- drivers/net/hns3/hns3_rxtx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_rxtx.c +2 -2
@@ -322,7 +322,7 @@ hns3_init_rx_queue_hw(struct hns3_rx_queue *rxq)hns3_write_dev (rxq,HNS3_RING_RX_BASEADDR_L_REG , (uint32_t )dma_addr);hns3_write_dev (rxq,HNS3_RING_RX_BASEADDR_H_REG , - (uint32_t )((dma_addr >>31 ) >>1 )); + (uint32_t )(dma_addr >>32 ));hns3_write_dev (rxq,HNS3_RING_RX_BD_LEN_REG ,hns3_buf_size2type (rx_buf_len));
@@ -337,7 +337,7 @@ hns3_init_tx_queue_hw(struct hns3_tx_queue *txq)hns3_write_dev (txq,HNS3_RING_TX_BASEADDR_L_REG , (uint32_t )dma_addr);hns3_write_dev (txq,HNS3_RING_TX_BASEADDR_H_REG , - (uint32_t )((dma_addr >>31 ) >>1 )); + (uint32_t )(dma_addr >>32 ));hns3_write_dev (txq,HNS3_RING_TX_BD_NUM_REG ,HNS3_CFG_DESC_NUM (txq->nb_tx_desc));
Signature · 1 line
2.33.0
PATCH 2/9 net/hns3: remove a redundant function declaration
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
This patch removes a redundant function declaration for hns3_rx_check_vec_support().
--- drivers/net/hns3/hns3_rxtx.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/hns3/hns3_rxtx.h +0 -1
@@ -711,7 +711,6 @@ uint16_t hns3_recv_pkts_vec_sve(void *rx_queue, struct rte_mbuf **rx_pkts,int hns3_rx_burst_mode_get (struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,struct rte_eth_burst_mode *mode); -int hns3_rx_check_vec_support (struct rte_eth_dev *dev); uint16_t hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); uint16_t hns3_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
Signature · 1 line
2.33.0
PATCH 3/9 net/hns3: modifying code alignment
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
This patch modifies some code alignment issues to make the code style more consistent.
--- drivers/net/hns3/hns3_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hns3/hns3_rxtx.c +1 -1
@@ -1907,7 +1907,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,*/ if (hns->is_vf || hw->vlan_mode ==HNS3_SW_SHIFT_AND_DISCARD_MODE ) rxq->pvid_sw_discard_en = hw->port_base_vlan_cfg.state == -HNS3_PORT_BASE_VLAN_ENABLE ; +HNS3_PORT_BASE_VLAN_ENABLE ;else rxq->pvid_sw_discard_en = false; rxq->ptype_en =hns3_dev_get_support (hw,RXD_ADV_LAYOUT ) ? true : false;
Signature · 1 line
2.33.0
PATCH 4/9 net/hns3: use unsigned integer for bitwise operations
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Bitwise operations should be used only with unsigned integer. This patch modifies some code that does not meet this rule.
--- drivers/net/hns3/hns3_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_ethdev.c +2 -2
@@ -2104,7 +2104,7 @@ hns3_check_mq_mode(struct rte_eth_dev *dev)int max_tc =0 ;int i; -if ((rx_mq_mode &RTE_ETH_MQ_RX_VMDQ_FLAG ) || +if (((uint32_t )rx_mq_mode &RTE_ETH_MQ_RX_VMDQ_FLAG ) || (tx_mq_mode ==RTE_ETH_MQ_TX_VMDQ_DCB || tx_mq_mode ==RTE_ETH_MQ_TX_VMDQ_ONLY )) { hns3_err(hw, "VMDQ is not supported, rx_mq_mode = %d, tx_mq_mode = %d.",
@@ -2114,7 +2114,7 @@ hns3_check_mq_mode(struct rte_eth_dev *dev) dcb_rx_conf = &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf; dcb_tx_conf = &dev->data->dev_conf.tx_adv_conf.dcb_tx_conf; -if (rx_mq_mode &RTE_ETH_MQ_RX_DCB_FLAG ) { +if ((uint32_t )rx_mq_mode &RTE_ETH_MQ_RX_DCB_FLAG ) {if (dcb_rx_conf->nb_tcs > pf->tc_max) {hns3_err (hw,"nb_tcs(%u) > max_tc(%u) driver supported." , dcb_rx_conf->nb_tcs, pf->tc_max);
Signature · 1 line
2.33.0
PATCH 5/9 net/hns3: extract a common file
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
This patch extracts a common file to store the common code for PF and VF driver.
--- drivers/net/hns3/hns3_cmd.c | 2 +- drivers/net/hns3/hns3_common.c | 427 +++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 48 ++++ drivers/net/hns3/hns3_ethdev.c | 430 +----------------------------- drivers/net/hns3/hns3_ethdev.h | 30 +-- drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_intr.c | 2 +- drivers/net/hns3/hns3_mbx.c | 2 +- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/hns3/meson.build | 1 + 10 files changed, 485 insertions(+), 460 deletions(-) create mode 100644 drivers/net/hns3/hns3_common.c create mode 100644 drivers/net/hns3/hns3_common.h
drivers/net/hns3/hns3_cmd.c +1 -1
@@ -5,7 +5,7 @@#include <ethdev_pci.h> #include <rte_io.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_regs.h" #include "hns3_intr.h" #include "hns3_logs.h"
drivers/net/hns3/hns3_common.c new file +427 -0
427 lines not on this page · raw message
drivers/net/hns3/hns3_common.h new file +48 -0
48 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.c +1 -429
474 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.h +3 -27
@@ -6,7 +6,6 @@#define _HNS3_ETHDEV_H_#include <pthread.h> -#include <sys/time.h> #include <ethdev_driver.h> #include <rte_byteorder.h> #include <rte_io.h>
@@ -869,14 +868,6 @@ struct hns3_adapter { struct hns3_ptype_table ptype_tbl __rte_cache_aligned; }; -enum { -HNS3_IO_FUNC_HINT_NONE =0 , -HNS3_IO_FUNC_HINT_VEC , -HNS3_IO_FUNC_HINT_SVE , -HNS3_IO_FUNC_HINT_SIMPLE , -HNS3_IO_FUNC_HINT_COMMON -}; -#define HNS3_DEVARG_RX_FUNC_HINT "rx_func_hint"#define HNS3_DEVARG_TX_FUNC_HINT "tx_func_hint"
@@ -1011,13 +1002,6 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) } \ }while (0 ) -#define MSEC_PER_SEC 1000L -#define USEC_PER_MSEC 1000L - -void hns3_clock_gettime (struct timeval *tv); -uint64_t hns3_clock_calctime_ms (struct timeval *tv); -uint64_t hns3_clock_gettime_ms (void ); - static inline uint64_thns3_atomic_test_bit (unsigned int nr,volatile uint64_t *addr) {
@@ -1047,28 +1031,20 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)return __atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED) & mask; } +uint32_t hns3_get_speed_capa (struct hns3_hw *hw); +int hns3_buffer_alloc (struct hns3_hw *hw);int hns3_dev_flow_ops_get (struct rte_eth_dev *dev,const struct rte_flow_ops **ops);bool hns3_is_reset_pending (struct hns3_adapter *hns);bool hns3vf_is_reset_pending (struct hns3_adapter *hns);void hns3_update_linkstatus_and_event (struct hns3_hw *hw,bool query); -void hns3_ether_format_addr (char *buf,uint16_t size, -const struct rte_ether_addr *ether_addr);int hns3_dev_infos_get (struct rte_eth_dev *eth_dev,struct rte_eth_dev_info *info);void hns3vf_update_link_status (struct hns3_hw *hw,uint8_t link_status,uint32_t link_speed,uint8_t link_duplex); -void hns3_parse_devargs (struct rte_eth_dev *dev);void hns3vf_update_push_lsc_cap (struct hns3_hw *hw,bool supported); -int hns3_configure_all_mc_mac_addr (struct hns3_adapter *hns,bool del); -int hns3_configure_all_mac_addr (struct hns3_adapter *hns,bool del); -int hns3_add_mac_addr (struct rte_eth_dev *dev,struct rte_ether_addr *mac_addr, - __rte_unused uint32_t idx, __rte_unused uint32_t pool); -void hns3_remove_mac_addr (struct rte_eth_dev *dev,uint32_t idx); -int hns3_set_mc_mac_addr_list (struct rte_eth_dev *dev, -struct rte_ether_addr *mc_addr_set, -uint32_t nb_mc_addr); +int hns3_restore_ptp (struct hns3_adapter *hns);int hns3_mbuf_dyn_rx_timestamp_register (struct rte_eth_dev *dev,struct rte_eth_conf *conf);
drivers/net/hns3/hns3_ethdev_vf.c +1 -0
@@ -10,6 +10,7 @@#include <rte_vfio.h> #include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_logs.h" #include "hns3_rxtx.h" #include "hns3_regs.h"
drivers/net/hns3/hns3_intr.c +1 -1
@@ -8,7 +8,7 @@#include <rte_io.h> #include <rte_malloc.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_logs.h" #include "hns3_intr.h" #include "hns3_regs.h"
drivers/net/hns3/hns3_mbx.c +1 -1
@@ -5,7 +5,7 @@#include <ethdev_driver.h> #include <rte_io.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_regs.h" #include "hns3_logs.h" #include "hns3_intr.h"
drivers/net/hns3/hns3_rxtx.c +1 -1
@@ -16,7 +16,7 @@#include <rte_vect.h> #endif -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_rxtx.h" #include "hns3_regs.h" #include "hns3_logs.h"
drivers/net/hns3/meson.build +1 -0
@@ -29,6 +29,7 @@ sources = files( 'hns3_mp.c', 'hns3_tm.c', 'hns3_ptp.c', + 'hns3_common.c', ) deps += ['hash']
Signature · 1 line
2.33.0
PATCH 6/9 net/hns3: add hns3 flow header file
In reply to Min Hu (Connor)This patch adds a hns3_flow.h to make the code easier to maintain.
--- drivers/net/hns3/hns3_ethdev.c | 1 + drivers/net/hns3/hns3_ethdev.h | 3 +-- drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_fdir.h | 31 ---------------------- drivers/net/hns3/hns3_flow.c | 1 + drivers/net/hns3/hns3_flow.h | 44 +++++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 drivers/net/hns3/hns3_flow.h
drivers/net/hns3/hns3_ethdev.c +1 -0
@@ -15,6 +15,7 @@#include "hns3_regs.h" #include "hns3_dcb.h" #include "hns3_mp.h" +#include "hns3_flow.h" #define HNS3_SERVICE_INTERVAL 1000000/* us */ #define HNS3_SERVICE_QUICK_INTERVAL 10
drivers/net/hns3/hns3_ethdev.h +1 -2
@@ -17,6 +17,7 @@#include "hns3_fdir.h" #include "hns3_stats.h" #include "hns3_tm.h" +#include "hns3_flow.h" /* Vendor ID */ #define PCI_VENDOR_ID_HUAWEI 0x19e5
@@ -1034,8 +1035,6 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)uint32_t hns3_get_speed_capa (struct hns3_hw *hw);int hns3_buffer_alloc (struct hns3_hw *hw); -int hns3_dev_flow_ops_get (struct rte_eth_dev *dev, -const struct rte_flow_ops **ops);bool hns3_is_reset_pending (struct hns3_adapter *hns);bool hns3vf_is_reset_pending (struct hns3_adapter *hns);void hns3_update_linkstatus_and_event (struct hns3_hw *hw,bool query);
drivers/net/hns3/hns3_ethdev_vf.c +1 -0
@@ -17,6 +17,7 @@#include "hns3_intr.h" #include "hns3_dcb.h" #include "hns3_mp.h" +#include "hns3_flow.h" #define HNS3VF_KEEP_ALIVE_INTERVAL 2000000/* us */ #define HNS3VF_SERVICE_INTERVAL 1000000/* us */
drivers/net/hns3/hns3_fdir.h +0 -31
@@ -5,8 +5,6 @@ #ifndef _HNS3_FDIR_H_ #define _HNS3_FDIR_H_ -#include <rte_flow.h> - struct hns3_fd_key_cfg { uint8_t key_sel; uint8_t inner_sipv6_word_en;
@@ -124,14 +122,6 @@ struct hns3_fd_ad_data {uint16_t rule_id; }; -struct hns3_flow_counter { -LIST_ENTRY (hns3_flow_counter) next;/* Pointer to the next counter. */ -uint32_t shared:1 ;/* Share counter ID with other flow rules. */ -uint32_t ref_cnt:31 ;/* Reference counter. */ -uint16_t id;/* Counter ID. */ -uint64_t hits;/* Number of packets matched by the rule. */ -}; -#define HNS3_RULE_FLAG_FDID 0x1#define HNS3_RULE_FLAG_VF_ID 0x2#define HNS3_RULE_FLAG_COUNTER 0x4
@@ -173,21 +163,7 @@ struct hns3_fdir_rule_ele {struct hns3_fdir_rule fdir_conf; }; -/* rss filter list structure */ -struct hns3_rss_conf_ele { -TAILQ_ENTRY (hns3_rss_conf_ele) entries; -struct hns3_rss_conf filter_info; -}; - -/* hns3_flow memory list structure */ -struct hns3_flow_mem { -TAILQ_ENTRY (hns3_flow_mem) entries; -struct rte_flow *flow; -}; -TAILQ_HEAD (hns3_fdir_rule_list, hns3_fdir_rule_ele); -TAILQ_HEAD (hns3_rss_filter_list, hns3_rss_conf_ele); -TAILQ_HEAD (hns3_flow_mem_list, hns3_flow_mem);/* * A structure used to define fields of a FDIR related info.
@@ -199,11 +175,6 @@ struct hns3_fdir_info {struct hns3_fd_cfg fd_cfg; }; -struct rte_flow { -enum rte_filter_type filter_type; -void *rule; -uint32_t counter_id; -};struct hns3_adapter ;int hns3_init_fd_config (struct hns3_adapter *hns);
@@ -213,8 +184,6 @@ int hns3_fdir_filter_program(struct hns3_adapter *hns, struct hns3_fdir_rule *rule, bool del);int hns3_clear_all_fdir_filter (struct hns3_adapter *hns);int hns3_get_count (struct hns3_hw *hw,uint32_t id,uint64_t *value); -void hns3_flow_init (struct rte_eth_dev *dev); -void hns3_flow_uninit (struct rte_eth_dev *dev);int hns3_restore_all_fdir_filter (struct hns3_adapter *hns);#endif /* _HNS3_FDIR_H_ */
drivers/net/hns3/hns3_flow.c +1 -0
@@ -8,6 +8,7 @@#include "hns3_ethdev.h" #include "hns3_logs.h" +#include "hns3_flow.h" /* Default default keys */ static uint8_t hns3_hash_key[] = {
drivers/net/hns3/hns3_flow.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.33.0
PATCH 7/9 net/hns3: remove magic numbers
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Removing magic numbers with macros.
--- drivers/net/hns3/hns3_common.c | 4 ++-- drivers/net/hns3/hns3_common.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_common.c +2 -2
@@ -54,7 +54,7 @@ hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args)RTE_SET_USED (key); - val =strtoull (value,NULL ,16 ); + val =strtoull (value,NULL ,HNS3_CONVERT_TO_HEXADECIMAL ); *(uint64_t *)extra_args = val;return 0 ;
@@ -67,7 +67,7 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args)RTE_SET_USED (key); - val =strtoul (value,NULL ,10 ); + val =strtoul (value,NULL ,HNS3_CONVERT_TO_DECIMAL );if (val >HNS3_MBX_DEF_TIME_LIMIT_MS && val <=UINT16_MAX ) *(uint16_t *)extra_args = val;
drivers/net/hns3/hns3_common.h +3 -0
@@ -9,6 +9,9 @@#include "hns3_ethdev.h" +#define HNS3_CONVERT_TO_DECIMAL 10 +#define HNS3_CONVERT_TO_HEXADECIMAL 16 +enum {HNS3_IO_FUNC_HINT_NONE =0 ,HNS3_IO_FUNC_HINT_VEC ,
Signature · 1 line
2.33.0
PATCH 8/9 net/hns3: fix the return value of the function
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Fixing the return value of the function to clear static warning.
--- drivers/net/hns3/hns3_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/hns3/hns3_common.c +4 -4
@@ -154,10 +154,10 @@ hns3_clock_gettime_ms(void)void hns3_ether_format_addr (char *buf,uint16_t size,const struct rte_ether_addr *ether_addr) { -snprintf (buf, size,"%02X:**:**:**:%02X:%02X" , - ether_addr->addr_bytes[0 ], - ether_addr->addr_bytes[4 ], - ether_addr->addr_bytes[5 ]); + (void )snprintf (buf, size,"%02X:**:**:**:%02X:%02X" , + ether_addr->addr_bytes[0 ], + ether_addr->addr_bytes[4 ], + ether_addr->addr_bytes[5 ]); } static int
Signature · 1 line
2.33.0
PATCH 9/9 net/hns3: remove PF/VF duplicate code
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch remove PF/VF duplicate code of:
1. get firmware version.
2. get device info.
3. rx interrupt related functions.
--- drivers/net/hns3/hns3_common.c | 337 +++++++++++++++++++++++++++++- drivers/net/hns3/hns3_common.h | 10 + drivers/net/hns3/hns3_ethdev.c | 313 +-------------------------- drivers/net/hns3/hns3_ethdev.h | 14 +- drivers/net/hns3/hns3_ethdev_vf.c | 325 +--------------------------- drivers/net/hns3/hns3_tm.c | 2 +- 6 files changed, 361 insertions(+), 640 deletions(-)
drivers/net/hns3/hns3_common.c +336 -1
@@ -3,9 +3,153 @@*/ #include <rte_kvargs.h> +#include <rte_bus_pci.h> +#include <ethdev_pci.h> +#include <rte_pci.h> -#include "hns3_logs.h" #include "hns3_common.h" +#include "hns3_logs.h" +#include "hns3_regs.h" +#include "hns3_rxtx.h" + +int +hns3_fw_version_get (struct rte_eth_dev *eth_dev,char *fw_version, +size_t fw_size) +{ +struct hns3_adapter *hns = eth_dev->data->dev_private; +struct hns3_hw *hw = &hns->hw; +uint32_t version = hw->fw_version; +int ret; + + ret =snprintf (fw_version, fw_size,"%lu.%lu.%lu.%lu" , +hns3_get_field (version,HNS3_FW_VERSION_BYTE3_M , +HNS3_FW_VERSION_BYTE3_S ), +hns3_get_field (version,HNS3_FW_VERSION_BYTE2_M , +HNS3_FW_VERSION_BYTE2_S ), +hns3_get_field (version,HNS3_FW_VERSION_BYTE1_M , +HNS3_FW_VERSION_BYTE1_S ), +hns3_get_field (version,HNS3_FW_VERSION_BYTE0_M , +HNS3_FW_VERSION_BYTE0_S )); +if (ret <0 ) +return -EINVAL ; + + ret +=1 ;/* add the size of '\0' */ +if (fw_size < (size_t )ret) +return ret; +else +return 0 ; +} + +int +hns3_dev_infos_get (struct rte_eth_dev *eth_dev,struct rte_eth_dev_info *info) +{ +struct hns3_adapter *hns = eth_dev->data->dev_private; +struct hns3_hw *hw = &hns->hw; +uint16_t queue_num = hw->tqps_num; + +/* +* In interrupt mode, 'max_rx_queues' is set based on the number of +* MSI-X interrupt resources of the hardware. +*/ +if (hw->data->dev_conf.intr_conf.rxq ==1 ) + queue_num = hw->intr_tqps_num; + + info->max_rx_queues = queue_num; + info->max_tx_queues = hw->tqps_num; + info->max_rx_pktlen =HNS3_MAX_FRAME_LEN ;/* CRC included */ + info->min_rx_bufsize =HNS3_MIN_BD_BUF_SIZE ; + info->max_mtu = info->max_rx_pktlen -HNS3_ETH_OVERHEAD ; + info->max_lro_pkt_size =HNS3_MAX_LRO_SIZE ; + info->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM | +DEV_RX_OFFLOAD_TCP_CKSUM | +DEV_RX_OFFLOAD_UDP_CKSUM | +DEV_RX_OFFLOAD_SCTP_CKSUM | +DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | +DEV_RX_OFFLOAD_OUTER_UDP_CKSUM | +DEV_RX_OFFLOAD_SCATTER | +DEV_RX_OFFLOAD_VLAN_STRIP | +DEV_RX_OFFLOAD_VLAN_FILTER | +DEV_RX_OFFLOAD_RSS_HASH | +DEV_RX_OFFLOAD_TCP_LRO ); + info->tx_offload_capa = (DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | +DEV_TX_OFFLOAD_IPV4_CKSUM | +DEV_TX_OFFLOAD_TCP_CKSUM | +DEV_TX_OFFLOAD_UDP_CKSUM | +DEV_TX_OFFLOAD_SCTP_CKSUM | +DEV_TX_OFFLOAD_MULTI_SEGS | +DEV_TX_OFFLOAD_TCP_TSO | +DEV_TX_OFFLOAD_VXLAN_TNL_TSO | +DEV_TX_OFFLOAD_GRE_TNL_TSO | +DEV_TX_OFFLOAD_GENEVE_TNL_TSO | +DEV_TX_OFFLOAD_MBUF_FAST_FREE | +DEV_TX_OFFLOAD_VLAN_INSERT ); + +if (!hw->port_base_vlan_cfg.state) + info->tx_offload_capa |=DEV_TX_OFFLOAD_QINQ_INSERT ; + +if (hns3_dev_get_support (hw,OUTER_UDP_CKSUM )) + info->tx_offload_capa |=DEV_TX_OFFLOAD_OUTER_UDP_CKSUM ; + +if (hns3_dev_get_support (hw,INDEP_TXRX )) + info->dev_capa =RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | +RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP ; + +if (hns3_dev_get_support (hw,PTP )) + info->rx_offload_capa |=DEV_RX_OFFLOAD_TIMESTAMP ; + + info->rx_desc_lim = (struct rte_eth_desc_lim ) { + .nb_max =HNS3_MAX_RING_DESC , + .nb_min =HNS3_MIN_RING_DESC , + .nb_align =HNS3_ALIGN_RING_DESC , + }; + + info->tx_desc_lim = (struct rte_eth_desc_lim ) { + .nb_max =HNS3_MAX_RING_DESC , + .nb_min =HNS3_MIN_RING_DESC , + .nb_align =HNS3_ALIGN_RING_DESC , + .nb_seg_max =HNS3_MAX_TSO_BD_PER_PKT , + .nb_mtu_seg_max = hw->max_non_tso_bd_num, + }; + + info->default_rxconf = (struct rte_eth_rxconf ) { + .rx_free_thresh =HNS3_DEFAULT_RX_FREE_THRESH , +/* +* If there are no available Rx buffer descriptors, incoming +* packets are always dropped by hardware based on hns3 network +* engine. +*/ + .rx_drop_en =1 , + .offloads =0 , + }; + info->default_txconf = (struct rte_eth_txconf ) { + .tx_rs_thresh =HNS3_DEFAULT_TX_RS_THRESH , + .offloads =0 , + }; + + info->reta_size = hw->rss_ind_tbl_size; + info->hash_key_size =HNS3_RSS_KEY_SIZE ; + info->flow_type_rss_offloads =HNS3_ETH_RSS_SUPPORT ; + + info->default_rxportconf.burst_size =HNS3_DEFAULT_PORT_CONF_BURST_SIZE ; + info->default_txportconf.burst_size =HNS3_DEFAULT_PORT_CONF_BURST_SIZE ; + info->default_rxportconf.nb_queues =HNS3_DEFAULT_PORT_CONF_QUEUES_NUM ; + info->default_txportconf.nb_queues =HNS3_DEFAULT_PORT_CONF_QUEUES_NUM ; + info->default_rxportconf.ring_size =HNS3_DEFAULT_RING_DESC ; + info->default_txportconf.ring_size =HNS3_DEFAULT_RING_DESC ; + +/* +* Next is the PF/VF difference section. +*/ +if (!hns->is_vf) { + info->max_mac_addrs =HNS3_UC_MACADDR_NUM ; + info->rx_offload_capa |=DEV_RX_OFFLOAD_KEEP_CRC ; + info->speed_capa =hns3_get_speed_capa (hw); + }else { + info->max_mac_addrs =HNS3_VF_UC_MACADDR_NUM ; + } + +return 0 ; +}static int hns3_parse_io_hint_func (const char *key,const char *value,void *extra_args)
@@ -68,6 +212,12 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args)RTE_SET_USED (key); val =strtoul (value,NULL ,HNS3_CONVERT_TO_DECIMAL ); + +/* +* 500ms is empirical value in process of mailbox communication. If +* the delay value is set to one lower thanthe empirical value, mailbox +* communication may fail. +*/ if (val >HNS3_MBX_DEF_TIME_LIMIT_MS && val <=UINT16_MAX ) *(uint16_t *)extra_args = val;
@@ -116,6 +266,11 @@ hns3_parse_devargs(struct rte_eth_dev *dev)hns3_warn (hw,"parsed %s = 0x%" PRIx64"." ,HNS3_DEVARG_DEV_CAPS_MASK , dev_caps_mask); hns->dev_caps_mask = dev_caps_mask; + +if (mbx_time_limit_ms !=HNS3_MBX_DEF_TIME_LIMIT_MS ) +hns3_warn (hw,"parsed %s = %u." ,HNS3_DEVARG_MBX_TIME_LIMIT_MS , + mbx_time_limit_ms); + hns->mbx_time_limit_ms = mbx_time_limit_ms; }void
@@ -425,3 +580,183 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) } } +int +hns3_init_ring_with_vector (struct hns3_hw *hw) +{ +uint16_t vec; +int ret; +int i; + +/* +* In hns3 network engine, vector 0 is always the misc interrupt of this +* function, vector 1~N can be used respectively for the queues of the +* function. Tx and Rx queues with the same number share the interrupt +* vector. In the initialization clearing the all hardware mapping +* relationship configurations between queues and interrupt vectors is +* needed, so some error caused by the residual configurations, such as +* the unexpected Tx interrupt, can be avoid. +*/ + vec = hw->num_msi -1 ;/* vector 0 for misc interrupt, not for queue */ +if (hw->intr.mapping_mode ==HNS3_INTR_MAPPING_VEC_RSV_ONE ) + vec = vec -1 ;/* the last interrupt is reserved */ + hw->intr_tqps_num =RTE_MIN (vec, hw->tqps_num); +for (i =0 ; i < hw->intr_tqps_num; i++) { +/* +* Set gap limiter/rate limiter/quanity limiter algorithm +* configuration for interrupt coalesce of queue's interrupt. +*/ +hns3_set_queue_intr_gl (hw, i,HNS3_RING_GL_RX , +HNS3_TQP_INTR_GL_DEFAULT ); +hns3_set_queue_intr_gl (hw, i,HNS3_RING_GL_TX , +HNS3_TQP_INTR_GL_DEFAULT ); +hns3_set_queue_intr_rl (hw, i,HNS3_TQP_INTR_RL_DEFAULT ); +/* +* QL(quantity limiter) is not used currently, just set 0 to +* close it. +*/ +hns3_set_queue_intr_ql (hw, i,HNS3_TQP_INTR_QL_DEFAULT ); + + ret = hw->ops.bind_ring_with_vector (hw, vec, false, +HNS3_RING_TYPE_TX , i); +if (ret) { +PMD_INIT_LOG (ERR ,"fail to unbind TX ring(%d) with " +"vector: %u, ret=%d" , i, vec, ret); +return ret; + } + + ret = hw->ops.bind_ring_with_vector (hw, vec, false, +HNS3_RING_TYPE_RX , i); +if (ret) { +PMD_INIT_LOG (ERR ,"fail to unbind RX ring(%d) with " +"vector: %u, ret=%d" , i, vec, ret); +return ret; + } + } + +return 0 ; +} + +int +hns3_map_rx_interrupt (struct rte_eth_dev *dev) +{ +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private); +uint16_t base =RTE_INTR_VEC_ZERO_OFFSET ; +uint16_t vec =RTE_INTR_VEC_ZERO_OFFSET ; +uint32_t intr_vector; +uint16_t q_id; +int ret; + +/* +* hns3 needs a separate interrupt to be used as event interrupt which +* could not be shared with task queue pair, so KERNEL drivers need +* support multiple interrupt vectors. +*/ +if (dev->data->dev_conf.intr_conf.rxq ==0 || + !rte_intr_cap_multiple (intr_handle)) +return 0 ; + +rte_intr_disable (intr_handle); + intr_vector = hw->used_rx_queues; +/* creates event fd for each intr vector when MSIX is used */ +if (rte_intr_efd_enable (intr_handle, intr_vector)) +return -EINVAL ; + +/* Allocate vector list */ +if (rte_intr_vec_list_alloc (intr_handle,"intr_vec" , + hw->used_rx_queues)) { +hns3_err (hw,"failed to allocate %u rx_queues intr_vec" , + hw->used_rx_queues); + ret = -ENOMEM ; + goto alloc_intr_vec_error; + } + +if (rte_intr_allow_others (intr_handle)) { + vec =RTE_INTR_VEC_RXTX_OFFSET ; + base =RTE_INTR_VEC_RXTX_OFFSET ; + } + +for (q_id =0 ; q_id < hw->used_rx_queues; q_id++) { + ret = hw->ops.bind_ring_with_vector (hw, vec, true, +HNS3_RING_TYPE_RX , q_id); +if (ret) + goto bind_vector_error; + +if (rte_intr_vec_list_index_set (intr_handle, q_id, vec)) + goto bind_vector_error; +/* +* If there are not enough efds (e.g. not enough interrupt), +* remaining queues will be bond to the last interrupt. +*/ +if (vec < base +rte_intr_nb_efd_get (intr_handle) -1 ) + vec++; + } +rte_intr_enable (intr_handle); +return 0 ; + +bind_vector_error: +rte_intr_vec_list_free (intr_handle); +alloc_intr_vec_error: +rte_intr_efd_disable (intr_handle); +return ret; +} + +void +hns3_unmap_rx_interrupt (struct rte_eth_dev *dev) +{ +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; +struct hns3_adapter *hns = dev->data->dev_private; +struct hns3_hw *hw = &hns->hw; +uint8_t base =RTE_INTR_VEC_ZERO_OFFSET ; +uint8_t vec =RTE_INTR_VEC_ZERO_OFFSET ; +uint16_t q_id; + +if (dev->data->dev_conf.intr_conf.rxq ==0 ) +return ; + +/* unmap the ring with vector */ +if (rte_intr_allow_others (intr_handle)) { + vec =RTE_INTR_VEC_RXTX_OFFSET ; + base =RTE_INTR_VEC_RXTX_OFFSET ; + } +if (rte_intr_dp_is_en (intr_handle)) { +for (q_id =0 ; q_id < hw->used_rx_queues; q_id++) { + (void )hw->ops.bind_ring_with_vector (hw, vec, false, +HNS3_RING_TYPE_RX , + q_id); +if (vec < base +rte_intr_nb_efd_get (intr_handle) -1 ) + vec++; + } + } +/* Clean datapath event and queue/vec mapping */ +rte_intr_efd_disable (intr_handle); +rte_intr_vec_list_free (intr_handle); +} + +int +hns3_restore_rx_interrupt (struct hns3_hw *hw) +{ +struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +uint16_t q_id; +int ret; + +if (dev->data->dev_conf.intr_conf.rxq ==0 ) +return 0 ; + +if (rte_intr_dp_is_en (intr_handle)) { +for (q_id =0 ; q_id < hw->used_rx_queues; q_id++) { + ret = hw->ops.bind_ring_with_vector (hw, +rte_intr_vec_list_index_get (intr_handle, + q_id), + true,HNS3_RING_TYPE_RX , q_id); +if (ret) +return ret; + } + } + +return 0 ; +}
drivers/net/hns3/hns3_common.h +10 -0
@@ -30,6 +30,11 @@ enum {#define MSEC_PER_SEC 1000L#define USEC_PER_MSEC 1000L +int hns3_fw_version_get (struct rte_eth_dev *eth_dev,char *fw_version, +size_t fw_size); +int hns3_dev_infos_get (struct rte_eth_dev *eth_dev, +struct rte_eth_dev_info *info); +void hns3_clock_gettime (struct timeval *tv);uint64_t hns3_clock_calctime_ms (struct timeval *tv);uint64_t hns3_clock_gettime_ms (void );
@@ -48,4 +53,9 @@ int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev,void hns3_ether_format_addr (char *buf,uint16_t size,const struct rte_ether_addr *ether_addr); +int hns3_init_ring_with_vector (struct hns3_hw *hw); +int hns3_map_rx_interrupt (struct rte_eth_dev *dev); +void hns3_unmap_rx_interrupt (struct rte_eth_dev *dev); +int hns3_restore_rx_interrupt (struct hns3_hw *hw); +#endif /* _HNS3_COMMON_H_ */
drivers/net/hns3/hns3_ethdev.c +2 -311
349 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.h +3 -11
@@ -437,6 +437,9 @@ struct hns3_hw_ops { struct rte_ether_addr *mac_addr);int (*del_uc_mac_addr)(struct hns3_hw *hw,struct rte_ether_addr *mac_addr); +int (*bind_ring_with_vector)(struct hns3_hw *hw,uint16_t vector_id, +bool en,enum hns3_ring_type queue_type, +uint16_t queue_id); };#define HNS3_INTR_MAPPING_VEC_RSV_ONE 0
@@ -1038,8 +1041,6 @@ int hns3_buffer_alloc(struct hns3_hw *hw);bool hns3_is_reset_pending (struct hns3_adapter *hns);bool hns3vf_is_reset_pending (struct hns3_adapter *hns);void hns3_update_linkstatus_and_event (struct hns3_hw *hw,bool query); -int hns3_dev_infos_get (struct rte_eth_dev *eth_dev, -struct rte_eth_dev_info *info);void hns3vf_update_link_status (struct hns3_hw *hw,uint8_t link_status,uint32_t link_speed,uint8_t link_duplex);void hns3vf_update_push_lsc_cap (struct hns3_hw *hw,bool supported);
@@ -1071,13 +1072,4 @@ is_reset_pending(struct hns3_adapter *hns) return ret; } -static inline uint64_t -hns3_txvlan_cap_get (struct hns3_hw *hw) -{ -if (hw->port_base_vlan_cfg.state) -return RTE_ETH_TX_OFFLOAD_VLAN_INSERT ; -else -return RTE_ETH_TX_OFFLOAD_VLAN_INSERT |RTE_ETH_TX_OFFLOAD_QINQ_INSERT ; -} -#endif /* _HNS3_ETHDEV_H_ */
drivers/net/hns3/hns3_ethdev_vf.c +9 -316
403 lines not on this page · raw message
drivers/net/hns3/hns3_tm.c +1 -1
@@ -4,7 +4,7 @@#include <rte_malloc.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_dcb.h" #include "hns3_logs.h" #include "hns3_tm.h"
Signature · 1 line
2.33.0
Re: [dpdk-dev] [PATCH 9/9] net/hns3: remove PF/VF duplicate code
Quoted 9 lines · Min Hu (Connor)
From: Chengwen Feng <[email protected]>
This patch remove PF/VF duplicate code of:
1. get firmware version.
2. get device info.
3. rx interrupt related functions.Signed-off-by Chengwen Feng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>
<...>
Quoted 33 lines
drivers/net/hns3/hns3_common.c +33
-0+int +hns3_dev_infos_get (struct rte_eth_dev *eth_dev,struct rte_eth_dev_info *info) +{ +struct hns3_adapter *hns = eth_dev->data->dev_private; +struct hns3_hw *hw = &hns->hw; +uint16_t queue_num = hw->tqps_num; + +/* +* In interrupt mode, 'max_rx_queues' is set based on the number of +* MSI-X interrupt resources of the hardware. +*/ +if (hw->data->dev_conf.intr_conf.rxq ==1 ) + queue_num = hw->intr_tqps_num; + + info->max_rx_queues = queue_num; + info->max_tx_queues = hw->tqps_num; + info->max_rx_pktlen =HNS3_MAX_FRAME_LEN ;/* CRC included */ + info->min_rx_bufsize =HNS3_MIN_BD_BUF_SIZE ; + info->max_mtu = info->max_rx_pktlen -HNS3_ETH_OVERHEAD ; + info->max_lro_pkt_size =HNS3_MAX_LRO_SIZE ; + info->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM | +DEV_RX_OFFLOAD_TCP_CKSUM | +DEV_RX_OFFLOAD_UDP_CKSUM | +DEV_RX_OFFLOAD_SCTP_CKSUM | +DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | +DEV_RX_OFFLOAD_OUTER_UDP_CKSUM | +DEV_RX_OFFLOAD_SCATTER | +DEV_RX_OFFLOAD_VLAN_STRIP | +DEV_RX_OFFLOAD_VLAN_FILTER | +DEV_RX_OFFLOAD_RSS_HASH | +DEV_RX_OFFLOAD_TCP_LRO ); + info->tx_offload_capa = (DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | + DEV_TX_OFFLOAD_IPV4_CKSUM |
drivers/net/hns3/hns3_common.c line 85
Quoted 10 lines
drivers/net/hns3/hns3_common.c +10
-0+DEV_TX_OFFLOAD_TCP_CKSUM | +DEV_TX_OFFLOAD_UDP_CKSUM | +DEV_TX_OFFLOAD_SCTP_CKSUM | +DEV_TX_OFFLOAD_MULTI_SEGS | +DEV_TX_OFFLOAD_TCP_TSO | +DEV_TX_OFFLOAD_VXLAN_TNL_TSO | +DEV_TX_OFFLOAD_GRE_TNL_TSO | +DEV_TX_OFFLOAD_GENEVE_TNL_TSO | +DEV_TX_OFFLOAD_MBUF_FAST_FREE | + DEV_TX_OFFLOAD_VLAN_INSERT);
The function changed while moving, please be aware renamed macros in upsteram. Can you please rebase your patch on top of latest next-net?
Re: [dpdk-dev] [PATCH 9/9] net/hns3: remove PF/VF duplicate code
Hi,
Quoted 52 lines · Ferruh Yigit
Quoted 9 lines · Min Hu (Connor)
From: Chengwen Feng <[email protected]>
This patch remove PF/VF duplicate code of:
1. get firmware version.
2. get device info.
3. rx interrupt related functions.Signed-off-by Chengwen Feng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]><...>
Quoted 39 lines
(quoted diff) +2
-0+int +hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct
rte_eth_dev_info*info)drivers/net/hns3/hns3_common.c +36
-0+{ + struct hns3_adapter *hns = eth_dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; + uint16_t queue_num = hw->tqps_num; + + /* + * In interrupt mode, 'max_rx_queues' is set based on the number of + * MSI-X interrupt resources of the hardware. + */ + if (hw->data->dev_conf.intr_conf.rxq == 1) + queue_num = hw->intr_tqps_num; + + info->max_rx_queues = queue_num; + info->max_tx_queues = hw->tqps_num; + info->max_rx_pktlen = HNS3_MAX_FRAME_LEN; /* CRC included */ + info->min_rx_bufsize = HNS3_MIN_BD_BUF_SIZE; + info->max_mtu = info->max_rx_pktlen - HNS3_ETH_OVERHEAD; + info->max_lro_pkt_size = HNS3_MAX_LRO_SIZE; + info->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_SCTP_CKSUM | + DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | + DEV_RX_OFFLOAD_OUTER_UDP_CKSUM | + DEV_RX_OFFLOAD_SCATTER | + DEV_RX_OFFLOAD_VLAN_STRIP | + DEV_RX_OFFLOAD_VLAN_FILTER | + DEV_RX_OFFLOAD_RSS_HASH | + DEV_RX_OFFLOAD_TCP_LRO); + info->tx_offload_capa = (DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | + DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_SCTP_CKSUM | + DEV_TX_OFFLOAD_MULTI_SEGS | + DEV_TX_OFFLOAD_TCP_TSO |
Quoted 8 lines
Quoted 5 lines
+
DEV_TX_OFFLOAD_VXLAN_TNL_TSO|
+DEV_TX_OFFLOAD_GRE_TNL_TSO|
+DEV_TX_OFFLOAD_GENEVE_TNL_TSO|
+DEV_TX_OFFLOAD_MBUF_FAST_FREE|
+DEV_TX_OFFLOAD_VLAN_INSERT);The function changed while moving, please be aware renamed macros in upsteram. Can you please rebase your patch on top of latest next-net?
fixed in v2, thanks.
Quoted 2 lines
.
v2 cover code optimization for hns3 PMD
In reply to Min Hu (Connor)This patch set contains refactor patches and code check patches.
Chengwen Feng (1):
net/hns3: remove PF/VF duplicate code
Huisong Li (7):
net/hns3: fix the shift of DMA address in Rx/Tx queue net/hns3: remove a redundant function declaration net/hns3: modifying code alignment
net/hns3: use unsigned integer for bitwise operations net/hns3: extract a common file
net/hns3: remove magic numbers
net/hns3: fix the return value of the function
Min Hu (Connor) (1):
net/hns3: add hns3 flow header file
---
v2:
* rebase patch on top of latest next-net
drivers/net/hns3.tar.gz | Bin 0 -> 203522 bytes drivers/net/hns3/hns3_cmd.c | 2 +- drivers/net/hns3/hns3_common.c | 763 ++++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 61 +++ drivers/net/hns3/hns3_ethdev.c | 749 +---------------------------- drivers/net/hns3/hns3_ethdev.h | 47 +- drivers/net/hns3/hns3_ethdev_vf.c | 328 +------------ drivers/net/hns3/hns3_fdir.h | 31 -- drivers/net/hns3/hns3_flow.c | 1 + drivers/net/hns3/hns3_flow.h | 44 ++ drivers/net/hns3/hns3_intr.c | 2 +- drivers/net/hns3/hns3_mbx.c | 2 +- drivers/net/hns3/hns3_rxtx.c | 8 +- drivers/net/hns3/hns3_rxtx.h | 1 - drivers/net/hns3/hns3_tm.c | 2 +- drivers/net/hns3/meson.build | 1 + 16 files changed, 902 insertions(+), 1140 deletions(-) create mode 100644 drivers/net/hns3.tar.gz create mode 100644 drivers/net/hns3/hns3_common.c create mode 100644 drivers/net/hns3/hns3_common.h create mode 100644 drivers/net/hns3/hns3_flow.h
Signature · 1 line
2.33.0
PATCH v2 1/9 net/hns3: fix the shift of DMA address in Rx/Tx queue
From: Huisong Li <[email protected]>
The patch obtains the upper 32 bits of the Rx/Tx queue DMA address in one step instead of two steps.
--- drivers/net/hns3/hns3_rxtx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_rxtx.c +2 -2
@@ -322,7 +322,7 @@ hns3_init_rx_queue_hw(struct hns3_rx_queue *rxq)hns3_write_dev (rxq,HNS3_RING_RX_BASEADDR_L_REG , (uint32_t )dma_addr);hns3_write_dev (rxq,HNS3_RING_RX_BASEADDR_H_REG , - (uint32_t )((dma_addr >>31 ) >>1 )); + (uint32_t )(dma_addr >>32 ));hns3_write_dev (rxq,HNS3_RING_RX_BD_LEN_REG ,hns3_buf_size2type (rx_buf_len));
@@ -337,7 +337,7 @@ hns3_init_tx_queue_hw(struct hns3_tx_queue *txq)hns3_write_dev (txq,HNS3_RING_TX_BASEADDR_L_REG , (uint32_t )dma_addr);hns3_write_dev (txq,HNS3_RING_TX_BASEADDR_H_REG , - (uint32_t )((dma_addr >>31 ) >>1 )); + (uint32_t )(dma_addr >>32 ));hns3_write_dev (txq,HNS3_RING_TX_BD_NUM_REG ,HNS3_CFG_DESC_NUM (txq->nb_tx_desc));
Signature · 1 line
2.33.0
Re: [dpdk-dev] [PATCH v2 1/9] net/hns3: fix the shift of DMA address in Rx/Tx queue
Quoted 8 lines · Min Hu (Connor)
From: Huisong Li<[email protected]>
The patch obtains the upper 32 bits of the Rx/Tx queue DMA address in one step instead of two steps.
Fixes bba636698316 ("net/hns3: support Rx/Tx and related operations")Signed-off-by Huisong Li<[email protected]>
Hi Connor,
This patch requires PMD maintainer's review/ack.
Re: [dpdk-dev] [PATCH v2 1/9] net/hns3: fix the shift of DMA address in Rx/Tx queue
In reply to Min Hu (Connor)Quoted 7 lines · Min Hu (Connor)
From: Huisong Li<[email protected]>
The patch obtains the upper 32 bits of the Rx/Tx queue DMA address in one step instead of two steps.
Fixes bba636698316 ("net/hns3: support Rx/Tx and related operations")
Missing 'stable' tag.
Quoted 1 line
Signed-off-by Huisong Li<[email protected]>
PATCH v2 2/9 net/hns3: remove a redundant function declaration
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
This patch removes a redundant function declaration for hns3_rx_check_vec_support().
--- drivers/net/hns3/hns3_rxtx.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/hns3/hns3_rxtx.h +0 -1
@@ -711,7 +711,6 @@ uint16_t hns3_recv_pkts_vec_sve(void *rx_queue, struct rte_mbuf **rx_pkts,int hns3_rx_burst_mode_get (struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,struct rte_eth_burst_mode *mode); -int hns3_rx_check_vec_support (struct rte_eth_dev *dev); uint16_t hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); uint16_t hns3_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
Signature · 1 line
2.33.0
PATCH v2 3/9 net/hns3: modifying code alignment
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
This patch modifies some code alignment issues to make the code style more consistent.
--- drivers/net/hns3/hns3_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hns3/hns3_rxtx.c +1 -1
@@ -1907,7 +1907,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,*/ if (hns->is_vf || hw->vlan_mode ==HNS3_SW_SHIFT_AND_DISCARD_MODE ) rxq->pvid_sw_discard_en = hw->port_base_vlan_cfg.state == -HNS3_PORT_BASE_VLAN_ENABLE ; +HNS3_PORT_BASE_VLAN_ENABLE ;else rxq->pvid_sw_discard_en = false; rxq->ptype_en =hns3_dev_get_support (hw,RXD_ADV_LAYOUT ) ? true : false;
Signature · 1 line
2.33.0
PATCH v2 4/9 net/hns3: use unsigned integer for bitwise operations
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Bitwise operations should be used only with unsigned integer. This patch modifies some code that does not meet this rule.
--- drivers/net/hns3/hns3_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_ethdev.c +2 -2
@@ -2104,7 +2104,7 @@ hns3_check_mq_mode(struct rte_eth_dev *dev)int max_tc =0 ;int i; -if ((rx_mq_mode &RTE_ETH_MQ_RX_VMDQ_FLAG ) || +if (((uint32_t )rx_mq_mode &RTE_ETH_MQ_RX_VMDQ_FLAG ) || (tx_mq_mode ==RTE_ETH_MQ_TX_VMDQ_DCB || tx_mq_mode ==RTE_ETH_MQ_TX_VMDQ_ONLY )) { hns3_err(hw, "VMDQ is not supported, rx_mq_mode = %d, tx_mq_mode = %d.",
@@ -2114,7 +2114,7 @@ hns3_check_mq_mode(struct rte_eth_dev *dev) dcb_rx_conf = &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf; dcb_tx_conf = &dev->data->dev_conf.tx_adv_conf.dcb_tx_conf; -if (rx_mq_mode &RTE_ETH_MQ_RX_DCB_FLAG ) { +if ((uint32_t )rx_mq_mode &RTE_ETH_MQ_RX_DCB_FLAG ) {if (dcb_rx_conf->nb_tcs > pf->tc_max) {hns3_err (hw,"nb_tcs(%u) > max_tc(%u) driver supported." , dcb_rx_conf->nb_tcs, pf->tc_max);
Signature · 1 line
2.33.0
PATCH v2 5/9 net/hns3: extract a common file
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
This patch extracts a common file to store the common code for PF and VF driver.
--- drivers/net/hns3/hns3_cmd.c | 2 +- drivers/net/hns3/hns3_common.c | 427 +++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 48 ++++ drivers/net/hns3/hns3_ethdev.c | 430 +----------------------------- drivers/net/hns3/hns3_ethdev.h | 30 +-- drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_intr.c | 2 +- drivers/net/hns3/hns3_mbx.c | 2 +- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/hns3/meson.build | 1 + 10 files changed, 485 insertions(+), 460 deletions(-) create mode 100644 drivers/net/hns3/hns3_common.c create mode 100644 drivers/net/hns3/hns3_common.h
drivers/net/hns3/hns3_cmd.c +1 -1
@@ -5,7 +5,7 @@#include <ethdev_pci.h> #include <rte_io.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_regs.h" #include "hns3_intr.h" #include "hns3_logs.h"
drivers/net/hns3/hns3_common.c new file +427 -0
427 lines not on this page · raw message
drivers/net/hns3/hns3_common.h new file +48 -0
48 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.c +1 -429
474 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.h +3 -27
@@ -6,7 +6,6 @@#define _HNS3_ETHDEV_H_#include <pthread.h> -#include <sys/time.h> #include <ethdev_driver.h> #include <rte_byteorder.h> #include <rte_io.h>
@@ -869,14 +868,6 @@ struct hns3_adapter { struct hns3_ptype_table ptype_tbl __rte_cache_aligned; }; -enum { -HNS3_IO_FUNC_HINT_NONE =0 , -HNS3_IO_FUNC_HINT_VEC , -HNS3_IO_FUNC_HINT_SVE , -HNS3_IO_FUNC_HINT_SIMPLE , -HNS3_IO_FUNC_HINT_COMMON -}; -#define HNS3_DEVARG_RX_FUNC_HINT "rx_func_hint"#define HNS3_DEVARG_TX_FUNC_HINT "tx_func_hint"
@@ -1011,13 +1002,6 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) } \ }while (0 ) -#define MSEC_PER_SEC 1000L -#define USEC_PER_MSEC 1000L - -void hns3_clock_gettime (struct timeval *tv); -uint64_t hns3_clock_calctime_ms (struct timeval *tv); -uint64_t hns3_clock_gettime_ms (void ); - static inline uint64_thns3_atomic_test_bit (unsigned int nr,volatile uint64_t *addr) {
@@ -1047,28 +1031,20 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)return __atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED) & mask; } +uint32_t hns3_get_speed_capa (struct hns3_hw *hw); +int hns3_buffer_alloc (struct hns3_hw *hw);int hns3_dev_flow_ops_get (struct rte_eth_dev *dev,const struct rte_flow_ops **ops);bool hns3_is_reset_pending (struct hns3_adapter *hns);bool hns3vf_is_reset_pending (struct hns3_adapter *hns);void hns3_update_linkstatus_and_event (struct hns3_hw *hw,bool query); -void hns3_ether_format_addr (char *buf,uint16_t size, -const struct rte_ether_addr *ether_addr);int hns3_dev_infos_get (struct rte_eth_dev *eth_dev,struct rte_eth_dev_info *info);void hns3vf_update_link_status (struct hns3_hw *hw,uint8_t link_status,uint32_t link_speed,uint8_t link_duplex); -void hns3_parse_devargs (struct rte_eth_dev *dev);void hns3vf_update_push_lsc_cap (struct hns3_hw *hw,bool supported); -int hns3_configure_all_mc_mac_addr (struct hns3_adapter *hns,bool del); -int hns3_configure_all_mac_addr (struct hns3_adapter *hns,bool del); -int hns3_add_mac_addr (struct rte_eth_dev *dev,struct rte_ether_addr *mac_addr, - __rte_unused uint32_t idx, __rte_unused uint32_t pool); -void hns3_remove_mac_addr (struct rte_eth_dev *dev,uint32_t idx); -int hns3_set_mc_mac_addr_list (struct rte_eth_dev *dev, -struct rte_ether_addr *mc_addr_set, -uint32_t nb_mc_addr); +int hns3_restore_ptp (struct hns3_adapter *hns);int hns3_mbuf_dyn_rx_timestamp_register (struct rte_eth_dev *dev,struct rte_eth_conf *conf);
drivers/net/hns3/hns3_ethdev_vf.c +1 -0
@@ -10,6 +10,7 @@#include <rte_vfio.h> #include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_logs.h" #include "hns3_rxtx.h" #include "hns3_regs.h"
drivers/net/hns3/hns3_intr.c +1 -1
@@ -8,7 +8,7 @@#include <rte_io.h> #include <rte_malloc.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_logs.h" #include "hns3_intr.h" #include "hns3_regs.h"
drivers/net/hns3/hns3_mbx.c +1 -1
@@ -5,7 +5,7 @@#include <ethdev_driver.h> #include <rte_io.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_regs.h" #include "hns3_logs.h" #include "hns3_intr.h"
drivers/net/hns3/hns3_rxtx.c +1 -1
@@ -16,7 +16,7 @@#include <rte_vect.h> #endif -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_rxtx.h" #include "hns3_regs.h" #include "hns3_logs.h"
drivers/net/hns3/meson.build +1 -0
@@ -29,6 +29,7 @@ sources = files( 'hns3_mp.c', 'hns3_tm.c', 'hns3_ptp.c', + 'hns3_common.c', ) deps += ['hash']
Signature · 1 line
2.33.0
Re: [dpdk-dev] [PATCH v2 5/9] net/hns3: extract a common file
drivers/net/hns3/hns3_ethdev.h hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr) · line 1035
Quoted 6 lines · Min Hu (Connor)
drivers/net/hns3/hns3_ethdev.h +2
-0@@ -1047,28 +1031,20 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)return __atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED) & mask; } +uint32_t hns3_get_speed_capa (struct hns3_hw *hw); +
This looks git rebase error, above function is unrelated with the moved functions, also it cause a build error in the middle of the set because that function is static in this patch.
Above change is required in last patch, 9/9, where this function made non-static.
PATCH v2 6/9 net/hns3: add hns3 flow header file
In reply to Min Hu (Connor)This patch adds a hns3_flow.h to make the code easier to maintain.
--- drivers/net/hns3/hns3_ethdev.c | 1 + drivers/net/hns3/hns3_ethdev.h | 3 +-- drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_fdir.h | 31 ---------------------- drivers/net/hns3/hns3_flow.c | 1 + drivers/net/hns3/hns3_flow.h | 44 +++++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 drivers/net/hns3/hns3_flow.h
drivers/net/hns3/hns3_ethdev.c +1 -0
@@ -15,6 +15,7 @@#include "hns3_regs.h" #include "hns3_dcb.h" #include "hns3_mp.h" +#include "hns3_flow.h" #define HNS3_SERVICE_INTERVAL 1000000/* us */ #define HNS3_SERVICE_QUICK_INTERVAL 10
drivers/net/hns3/hns3_ethdev.h +1 -2
@@ -17,6 +17,7 @@#include "hns3_fdir.h" #include "hns3_stats.h" #include "hns3_tm.h" +#include "hns3_flow.h" /* Vendor ID */ #define PCI_VENDOR_ID_HUAWEI 0x19e5
@@ -1034,8 +1035,6 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)uint32_t hns3_get_speed_capa (struct hns3_hw *hw);int hns3_buffer_alloc (struct hns3_hw *hw); -int hns3_dev_flow_ops_get (struct rte_eth_dev *dev, -const struct rte_flow_ops **ops);bool hns3_is_reset_pending (struct hns3_adapter *hns);bool hns3vf_is_reset_pending (struct hns3_adapter *hns);void hns3_update_linkstatus_and_event (struct hns3_hw *hw,bool query);
drivers/net/hns3/hns3_ethdev_vf.c +1 -0
@@ -17,6 +17,7 @@#include "hns3_intr.h" #include "hns3_dcb.h" #include "hns3_mp.h" +#include "hns3_flow.h" #define HNS3VF_KEEP_ALIVE_INTERVAL 2000000/* us */ #define HNS3VF_SERVICE_INTERVAL 1000000/* us */
drivers/net/hns3/hns3_fdir.h +0 -31
@@ -5,8 +5,6 @@ #ifndef _HNS3_FDIR_H_ #define _HNS3_FDIR_H_ -#include <rte_flow.h> - struct hns3_fd_key_cfg { uint8_t key_sel; uint8_t inner_sipv6_word_en;
@@ -124,14 +122,6 @@ struct hns3_fd_ad_data {uint16_t rule_id; }; -struct hns3_flow_counter { -LIST_ENTRY (hns3_flow_counter) next;/* Pointer to the next counter. */ -uint32_t shared:1 ;/* Share counter ID with other flow rules. */ -uint32_t ref_cnt:31 ;/* Reference counter. */ -uint16_t id;/* Counter ID. */ -uint64_t hits;/* Number of packets matched by the rule. */ -}; -#define HNS3_RULE_FLAG_FDID 0x1#define HNS3_RULE_FLAG_VF_ID 0x2#define HNS3_RULE_FLAG_COUNTER 0x4
@@ -173,21 +163,7 @@ struct hns3_fdir_rule_ele {struct hns3_fdir_rule fdir_conf; }; -/* rss filter list structure */ -struct hns3_rss_conf_ele { -TAILQ_ENTRY (hns3_rss_conf_ele) entries; -struct hns3_rss_conf filter_info; -}; - -/* hns3_flow memory list structure */ -struct hns3_flow_mem { -TAILQ_ENTRY (hns3_flow_mem) entries; -struct rte_flow *flow; -}; -TAILQ_HEAD (hns3_fdir_rule_list, hns3_fdir_rule_ele); -TAILQ_HEAD (hns3_rss_filter_list, hns3_rss_conf_ele); -TAILQ_HEAD (hns3_flow_mem_list, hns3_flow_mem);/* * A structure used to define fields of a FDIR related info.
@@ -199,11 +175,6 @@ struct hns3_fdir_info {struct hns3_fd_cfg fd_cfg; }; -struct rte_flow { -enum rte_filter_type filter_type; -void *rule; -uint32_t counter_id; -};struct hns3_adapter ;int hns3_init_fd_config (struct hns3_adapter *hns);
@@ -213,8 +184,6 @@ int hns3_fdir_filter_program(struct hns3_adapter *hns, struct hns3_fdir_rule *rule, bool del);int hns3_clear_all_fdir_filter (struct hns3_adapter *hns);int hns3_get_count (struct hns3_hw *hw,uint32_t id,uint64_t *value); -void hns3_flow_init (struct rte_eth_dev *dev); -void hns3_flow_uninit (struct rte_eth_dev *dev);int hns3_restore_all_fdir_filter (struct hns3_adapter *hns);#endif /* _HNS3_FDIR_H_ */
drivers/net/hns3/hns3_flow.c +1 -0
@@ -8,6 +8,7 @@#include "hns3_ethdev.h" #include "hns3_logs.h" +#include "hns3_flow.h" /* Default default keys */ static uint8_t hns3_hash_key[] = {
drivers/net/hns3/hns3_flow.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.33.0
PATCH v2 7/9 net/hns3: remove magic numbers
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Removing magic numbers with macros.
--- drivers/net/hns3/hns3_common.c | 4 ++-- drivers/net/hns3/hns3_common.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_common.c +2 -2
@@ -54,7 +54,7 @@ hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args)RTE_SET_USED (key); - val =strtoull (value,NULL ,16 ); + val =strtoull (value,NULL ,HNS3_CONVERT_TO_HEXADECIMAL ); *(uint64_t *)extra_args = val;return 0 ;
@@ -67,7 +67,7 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args)RTE_SET_USED (key); - val =strtoul (value,NULL ,10 ); + val =strtoul (value,NULL ,HNS3_CONVERT_TO_DECIMAL );if (val >HNS3_MBX_DEF_TIME_LIMIT_MS && val <=UINT16_MAX ) *(uint16_t *)extra_args = val;
drivers/net/hns3/hns3_common.h +3 -0
@@ -9,6 +9,9 @@#include "hns3_ethdev.h" +#define HNS3_CONVERT_TO_DECIMAL 10 +#define HNS3_CONVERT_TO_HEXADECIMAL 16 +enum {HNS3_IO_FUNC_HINT_NONE =0 ,HNS3_IO_FUNC_HINT_VEC ,
Signature · 1 line
2.33.0
PATCH v2 8/9 net/hns3: fix the return value of the function
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Fixing the return value of the function to clear static warning.
--- drivers/net/hns3/hns3_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/hns3/hns3_common.c +4 -4
@@ -154,10 +154,10 @@ hns3_clock_gettime_ms(void)void hns3_ether_format_addr (char *buf,uint16_t size,const struct rte_ether_addr *ether_addr) { -snprintf (buf, size,"%02X:**:**:**:%02X:%02X" , - ether_addr->addr_bytes[0 ], - ether_addr->addr_bytes[4 ], - ether_addr->addr_bytes[5 ]); + (void )snprintf (buf, size,"%02X:**:**:**:%02X:%02X" , + ether_addr->addr_bytes[0 ], + ether_addr->addr_bytes[4 ], + ether_addr->addr_bytes[5 ]); } static int
Signature · 1 line
2.33.0
Re: [dpdk-dev] [PATCH v2 8/9] net/hns3: fix the return value of the function
Quoted 4 lines · Min Hu (Connor)
From: Huisong Li<[email protected]>
Fixing the return value of the function to clear static warning.
Missing fixes tag. (And stable based on what is fixed)
Quoted 2 lines
Signed-off-by Huisong Li<[email protected]>Signed-off-by Min Hu (Connor)<[email protected]>
PATCH v2 9/9 net/hns3: remove PF/VF duplicate code
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch remove PF/VF duplicate code of:
1. get firmware version.
2. get device info.
3. rx interrupt related functions.
--- drivers/net/hns3.tar.gz | Bin 0 -> 203522 bytes drivers/net/hns3/hns3_common.c | 338 +++++++++++++++++++++++++++++- drivers/net/hns3/hns3_common.h | 10 + drivers/net/hns3/hns3_ethdev.c | 314 +-------------------------- drivers/net/hns3/hns3_ethdev.h | 14 +- drivers/net/hns3/hns3_ethdev_vf.c | 326 +--------------------------- drivers/net/hns3/hns3_tm.c | 2 +- 7 files changed, 362 insertions(+), 642 deletions(-) create mode 100644 drivers/net/hns3.tar.gz
drivers/net/hns3.tar.gz new file binary +0 -0
drivers/net/hns3/hns3_common.c +337 -1
362 lines not on this page · raw message
drivers/net/hns3/hns3_common.h +10 -0
@@ -30,6 +30,11 @@ enum {#define MSEC_PER_SEC 1000L#define USEC_PER_MSEC 1000L +int hns3_fw_version_get (struct rte_eth_dev *eth_dev,char *fw_version, +size_t fw_size); +int hns3_dev_infos_get (struct rte_eth_dev *eth_dev, +struct rte_eth_dev_info *info); +void hns3_clock_gettime (struct timeval *tv);uint64_t hns3_clock_calctime_ms (struct timeval *tv);uint64_t hns3_clock_gettime_ms (void );
@@ -48,4 +53,9 @@ int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev,void hns3_ether_format_addr (char *buf,uint16_t size,const struct rte_ether_addr *ether_addr); +int hns3_init_ring_with_vector (struct hns3_hw *hw); +int hns3_map_rx_interrupt (struct rte_eth_dev *dev); +void hns3_unmap_rx_interrupt (struct rte_eth_dev *dev); +int hns3_restore_rx_interrupt (struct hns3_hw *hw); +#endif /* _HNS3_COMMON_H_ */
drivers/net/hns3/hns3_ethdev.c +2 -312
350 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.h +3 -11
@@ -437,6 +437,9 @@ struct hns3_hw_ops { struct rte_ether_addr *mac_addr);int (*del_uc_mac_addr)(struct hns3_hw *hw,struct rte_ether_addr *mac_addr); +int (*bind_ring_with_vector)(struct hns3_hw *hw,uint16_t vector_id, +bool en,enum hns3_ring_type queue_type, +uint16_t queue_id); };#define HNS3_INTR_MAPPING_VEC_RSV_ONE 0
@@ -1038,8 +1041,6 @@ int hns3_buffer_alloc(struct hns3_hw *hw);bool hns3_is_reset_pending (struct hns3_adapter *hns);bool hns3vf_is_reset_pending (struct hns3_adapter *hns);void hns3_update_linkstatus_and_event (struct hns3_hw *hw,bool query); -int hns3_dev_infos_get (struct rte_eth_dev *eth_dev, -struct rte_eth_dev_info *info);void hns3vf_update_link_status (struct hns3_hw *hw,uint8_t link_status,uint32_t link_speed,uint8_t link_duplex);void hns3vf_update_push_lsc_cap (struct hns3_hw *hw,bool supported);
@@ -1071,13 +1072,4 @@ is_reset_pending(struct hns3_adapter *hns) return ret; } -static inline uint64_t -hns3_txvlan_cap_get (struct hns3_hw *hw) -{ -if (hw->port_base_vlan_cfg.state) -return RTE_ETH_TX_OFFLOAD_VLAN_INSERT ; -else -return RTE_ETH_TX_OFFLOAD_VLAN_INSERT |RTE_ETH_TX_OFFLOAD_QINQ_INSERT ; -} -#endif /* _HNS3_ETHDEV_H_ */
drivers/net/hns3/hns3_ethdev_vf.c +9 -317
404 lines not on this page · raw message
drivers/net/hns3/hns3_tm.c +1 -1
@@ -4,7 +4,7 @@#include <rte_malloc.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_dcb.h" #include "hns3_logs.h" #include "hns3_tm.h"
Signature · 1 line
2.33.0
Re: [dpdk-dev] [PATCH v2 9/9] net/hns3: remove PF/VF duplicate code
Quoted 11 lines · Min Hu (Connor)
From: Chengwen Feng<[email protected]>
This patch remove PF/VF duplicate code of:
1. get firmware version.
2. get device info.
3. rx interrupt related functions.Signed-off-by Chengwen Feng<[email protected]>Signed-off-by Min Hu (Connor)<[email protected]>--- drivers/net/hns3.tar.gz | Bin 0 -> 203522 bytes
I expect this to be blocked by mail list, but somehow it seems passed. Can you please send a new version without it?
v3 cover code optimization for hns3 PMD
In reply to Min Hu (Connor)This patch set contains refactor patches and code check patches.
Chengwen Feng (1):
net/hns3: remove PF/VF duplicate code
Huisong Li (7):
net/hns3: fix the shift of DMA address in Rx/Tx queue net/hns3: remove a redundant function declaration net/hns3: modifying code alignment
net/hns3: use unsigned integer for bitwise operations net/hns3: extract a common file
net/hns3: remove magic numbers
net/hns3: fix the return value of the function
Min Hu (Connor) (1):
net/hns3: add hns3 flow header file
---
v3:
* fixed build error and some other adjustment.
v2:
* rebase patch on top of latest next-net.
drivers/net/hns3/hns3_cmd.c | 2 +- drivers/net/hns3/hns3_common.c | 763 ++++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 61 +++ drivers/net/hns3/hns3_ethdev.c | 749 +---------------------------- drivers/net/hns3/hns3_ethdev.h | 47 +- drivers/net/hns3/hns3_ethdev_vf.c | 328 +------------ drivers/net/hns3/hns3_fdir.h | 31 -- drivers/net/hns3/hns3_flow.c | 1 + drivers/net/hns3/hns3_flow.h | 44 ++ drivers/net/hns3/hns3_intr.c | 2 +- drivers/net/hns3/hns3_mbx.c | 2 +- drivers/net/hns3/hns3_rxtx.c | 8 +- drivers/net/hns3/hns3_rxtx.h | 1 - drivers/net/hns3/hns3_tm.c | 2 +- drivers/net/hns3/meson.build | 1 + 15 files changed, 902 insertions(+), 1140 deletions(-) create mode 100644 drivers/net/hns3/hns3_common.c create mode 100644 drivers/net/hns3/hns3_common.h create mode 100644 drivers/net/hns3/hns3_flow.h
Signature · 1 line
2.33.0
PATCH v3 1/9 net/hns3: fix the shift of DMA address in Rx/Tx queue
From: Huisong Li <[email protected]>
The patch obtains the upper 32 bits of the Rx/Tx queue DMA address in one step instead of two steps.
--- drivers/net/hns3/hns3_rxtx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_rxtx.c +2 -2
@@ -322,7 +322,7 @@ hns3_init_rx_queue_hw(struct hns3_rx_queue *rxq)hns3_write_dev (rxq,HNS3_RING_RX_BASEADDR_L_REG , (uint32_t )dma_addr);hns3_write_dev (rxq,HNS3_RING_RX_BASEADDR_H_REG , - (uint32_t )((dma_addr >>31 ) >>1 )); + (uint32_t )(dma_addr >>32 ));hns3_write_dev (rxq,HNS3_RING_RX_BD_LEN_REG ,hns3_buf_size2type (rx_buf_len));
@@ -337,7 +337,7 @@ hns3_init_tx_queue_hw(struct hns3_tx_queue *txq)hns3_write_dev (txq,HNS3_RING_TX_BASEADDR_L_REG , (uint32_t )dma_addr);hns3_write_dev (txq,HNS3_RING_TX_BASEADDR_H_REG , - (uint32_t )((dma_addr >>31 ) >>1 )); + (uint32_t )(dma_addr >>32 ));hns3_write_dev (txq,HNS3_RING_TX_BD_NUM_REG ,HNS3_CFG_DESC_NUM (txq->nb_tx_desc));
Signature · 1 line
2.33.0
PATCH v3 2/9 net/hns3: remove a redundant function declaration
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
This patch removes a redundant function declaration for hns3_rx_check_vec_support().
--- drivers/net/hns3/hns3_rxtx.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/hns3/hns3_rxtx.h +0 -1
@@ -711,7 +711,6 @@ uint16_t hns3_recv_pkts_vec_sve(void *rx_queue, struct rte_mbuf **rx_pkts,int hns3_rx_burst_mode_get (struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,struct rte_eth_burst_mode *mode); -int hns3_rx_check_vec_support (struct rte_eth_dev *dev); uint16_t hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); uint16_t hns3_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
Signature · 1 line
2.33.0
PATCH v3 3/9 net/hns3: modifying code alignment
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
This patch modifies some code alignment issues to make the code style more consistent.
--- drivers/net/hns3/hns3_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hns3/hns3_rxtx.c +1 -1
@@ -1907,7 +1907,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,*/ if (hns->is_vf || hw->vlan_mode ==HNS3_SW_SHIFT_AND_DISCARD_MODE ) rxq->pvid_sw_discard_en = hw->port_base_vlan_cfg.state == -HNS3_PORT_BASE_VLAN_ENABLE ; +HNS3_PORT_BASE_VLAN_ENABLE ;else rxq->pvid_sw_discard_en = false; rxq->ptype_en =hns3_dev_get_support (hw,RXD_ADV_LAYOUT ) ? true : false;
Signature · 1 line
2.33.0
PATCH v3 4/9 net/hns3: use unsigned integer for bitwise operations
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Bitwise operations should be used only with unsigned integer. This patch modifies some code that does not meet this rule.
--- drivers/net/hns3/hns3_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_ethdev.c +2 -2
@@ -2104,7 +2104,7 @@ hns3_check_mq_mode(struct rte_eth_dev *dev)int max_tc =0 ;int i; -if ((rx_mq_mode &RTE_ETH_MQ_RX_VMDQ_FLAG ) || +if (((uint32_t )rx_mq_mode &RTE_ETH_MQ_RX_VMDQ_FLAG ) || (tx_mq_mode ==RTE_ETH_MQ_TX_VMDQ_DCB || tx_mq_mode ==RTE_ETH_MQ_TX_VMDQ_ONLY )) { hns3_err(hw, "VMDQ is not supported, rx_mq_mode = %d, tx_mq_mode = %d.",
@@ -2114,7 +2114,7 @@ hns3_check_mq_mode(struct rte_eth_dev *dev) dcb_rx_conf = &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf; dcb_tx_conf = &dev->data->dev_conf.tx_adv_conf.dcb_tx_conf; -if (rx_mq_mode &RTE_ETH_MQ_RX_DCB_FLAG ) { +if ((uint32_t )rx_mq_mode &RTE_ETH_MQ_RX_DCB_FLAG ) {if (dcb_rx_conf->nb_tcs > pf->tc_max) {hns3_err (hw,"nb_tcs(%u) > max_tc(%u) driver supported." , dcb_rx_conf->nb_tcs, pf->tc_max);
Signature · 1 line
2.33.0
PATCH v3 5/9 net/hns3: extract a common file
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
This patch extracts a common file to store the common code for PF and VF driver.
--- drivers/net/hns3/hns3_cmd.c | 2 +- drivers/net/hns3/hns3_common.c | 426 +++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 48 ++++ drivers/net/hns3/hns3_ethdev.c | 430 +----------------------------- drivers/net/hns3/hns3_ethdev.h | 28 +- drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_intr.c | 2 +- drivers/net/hns3/hns3_mbx.c | 2 +- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/hns3/meson.build | 1 + 10 files changed, 482 insertions(+), 460 deletions(-) create mode 100644 drivers/net/hns3/hns3_common.c create mode 100644 drivers/net/hns3/hns3_common.h
drivers/net/hns3/hns3_cmd.c +1 -1
@@ -5,7 +5,7 @@#include <ethdev_pci.h> #include <rte_io.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_regs.h" #include "hns3_intr.h" #include "hns3_logs.h"
drivers/net/hns3/hns3_common.c new file +426 -0
426 lines not on this page · raw message
drivers/net/hns3/hns3_common.h new file +48 -0
48 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.c +1 -429
474 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.h +1 -27
@@ -6,7 +6,6 @@#define _HNS3_ETHDEV_H_#include <pthread.h> -#include <sys/time.h> #include <ethdev_driver.h> #include <rte_byteorder.h> #include <rte_io.h>
@@ -869,14 +868,6 @@ struct hns3_adapter { struct hns3_ptype_table ptype_tbl __rte_cache_aligned; }; -enum { -HNS3_IO_FUNC_HINT_NONE =0 , -HNS3_IO_FUNC_HINT_VEC , -HNS3_IO_FUNC_HINT_SVE , -HNS3_IO_FUNC_HINT_SIMPLE , -HNS3_IO_FUNC_HINT_COMMON -}; -#define HNS3_DEVARG_RX_FUNC_HINT "rx_func_hint"#define HNS3_DEVARG_TX_FUNC_HINT "tx_func_hint"
@@ -1011,13 +1002,6 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) } \ }while (0 ) -#define MSEC_PER_SEC 1000L -#define USEC_PER_MSEC 1000L - -void hns3_clock_gettime (struct timeval *tv); -uint64_t hns3_clock_calctime_ms (struct timeval *tv); -uint64_t hns3_clock_gettime_ms (void ); - static inline uint64_thns3_atomic_test_bit (unsigned int nr,volatile uint64_t *addr) {
@@ -1053,22 +1037,12 @@ int hns3_dev_flow_ops_get(struct rte_eth_dev *dev,bool hns3_is_reset_pending (struct hns3_adapter *hns);bool hns3vf_is_reset_pending (struct hns3_adapter *hns);void hns3_update_linkstatus_and_event (struct hns3_hw *hw,bool query); -void hns3_ether_format_addr (char *buf,uint16_t size, -const struct rte_ether_addr *ether_addr);int hns3_dev_infos_get (struct rte_eth_dev *eth_dev,struct rte_eth_dev_info *info);void hns3vf_update_link_status (struct hns3_hw *hw,uint8_t link_status,uint32_t link_speed,uint8_t link_duplex); -void hns3_parse_devargs (struct rte_eth_dev *dev);void hns3vf_update_push_lsc_cap (struct hns3_hw *hw,bool supported); -int hns3_configure_all_mc_mac_addr (struct hns3_adapter *hns,bool del); -int hns3_configure_all_mac_addr (struct hns3_adapter *hns,bool del); -int hns3_add_mac_addr (struct rte_eth_dev *dev,struct rte_ether_addr *mac_addr, - __rte_unused uint32_t idx, __rte_unused uint32_t pool); -void hns3_remove_mac_addr (struct rte_eth_dev *dev,uint32_t idx); -int hns3_set_mc_mac_addr_list (struct rte_eth_dev *dev, -struct rte_ether_addr *mc_addr_set, -uint32_t nb_mc_addr); +int hns3_restore_ptp (struct hns3_adapter *hns);int hns3_mbuf_dyn_rx_timestamp_register (struct rte_eth_dev *dev,struct rte_eth_conf *conf);
drivers/net/hns3/hns3_ethdev_vf.c +1 -0
@@ -10,6 +10,7 @@#include <rte_vfio.h> #include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_logs.h" #include "hns3_rxtx.h" #include "hns3_regs.h"
drivers/net/hns3/hns3_intr.c +1 -1
@@ -8,7 +8,7 @@#include <rte_io.h> #include <rte_malloc.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_logs.h" #include "hns3_intr.h" #include "hns3_regs.h"
drivers/net/hns3/hns3_mbx.c +1 -1
@@ -5,7 +5,7 @@#include <ethdev_driver.h> #include <rte_io.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_regs.h" #include "hns3_logs.h" #include "hns3_intr.h"
drivers/net/hns3/hns3_rxtx.c +1 -1
@@ -16,7 +16,7 @@#include <rte_vect.h> #endif -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_rxtx.h" #include "hns3_regs.h" #include "hns3_logs.h"
drivers/net/hns3/meson.build +1 -0
@@ -29,6 +29,7 @@ sources = files( 'hns3_mp.c', 'hns3_tm.c', 'hns3_ptp.c', + 'hns3_common.c', ) deps += ['hash']
Signature · 1 line
2.33.0
PATCH v3 6/9 net/hns3: add hns3 flow header file
In reply to Min Hu (Connor)This patch adds a hns3_flow.h to make the code easier to maintain.
--- drivers/net/hns3/hns3_ethdev.c | 1 + drivers/net/hns3/hns3_ethdev.h | 3 +-- drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_fdir.h | 31 ---------------------- drivers/net/hns3/hns3_flow.c | 1 + drivers/net/hns3/hns3_flow.h | 44 +++++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 drivers/net/hns3/hns3_flow.h
drivers/net/hns3/hns3_ethdev.c +1 -0
@@ -15,6 +15,7 @@#include "hns3_regs.h" #include "hns3_dcb.h" #include "hns3_mp.h" +#include "hns3_flow.h" #define HNS3_SERVICE_INTERVAL 1000000/* us */ #define HNS3_SERVICE_QUICK_INTERVAL 10
drivers/net/hns3/hns3_ethdev.h +1 -2
@@ -17,6 +17,7 @@#include "hns3_fdir.h" #include "hns3_stats.h" #include "hns3_tm.h" +#include "hns3_flow.h" /* Vendor ID */ #define PCI_VENDOR_ID_HUAWEI 0x19e5
@@ -1032,8 +1033,6 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr) }int hns3_buffer_alloc (struct hns3_hw *hw); -int hns3_dev_flow_ops_get (struct rte_eth_dev *dev, -const struct rte_flow_ops **ops);bool hns3_is_reset_pending (struct hns3_adapter *hns);bool hns3vf_is_reset_pending (struct hns3_adapter *hns);void hns3_update_linkstatus_and_event (struct hns3_hw *hw,bool query);
drivers/net/hns3/hns3_ethdev_vf.c +1 -0
@@ -17,6 +17,7 @@#include "hns3_intr.h" #include "hns3_dcb.h" #include "hns3_mp.h" +#include "hns3_flow.h" #define HNS3VF_KEEP_ALIVE_INTERVAL 2000000/* us */ #define HNS3VF_SERVICE_INTERVAL 1000000/* us */
drivers/net/hns3/hns3_fdir.h +0 -31
@@ -5,8 +5,6 @@ #ifndef _HNS3_FDIR_H_ #define _HNS3_FDIR_H_ -#include <rte_flow.h> - struct hns3_fd_key_cfg { uint8_t key_sel; uint8_t inner_sipv6_word_en;
@@ -124,14 +122,6 @@ struct hns3_fd_ad_data {uint16_t rule_id; }; -struct hns3_flow_counter { -LIST_ENTRY (hns3_flow_counter) next;/* Pointer to the next counter. */ -uint32_t shared:1 ;/* Share counter ID with other flow rules. */ -uint32_t ref_cnt:31 ;/* Reference counter. */ -uint16_t id;/* Counter ID. */ -uint64_t hits;/* Number of packets matched by the rule. */ -}; -#define HNS3_RULE_FLAG_FDID 0x1#define HNS3_RULE_FLAG_VF_ID 0x2#define HNS3_RULE_FLAG_COUNTER 0x4
@@ -173,21 +163,7 @@ struct hns3_fdir_rule_ele {struct hns3_fdir_rule fdir_conf; }; -/* rss filter list structure */ -struct hns3_rss_conf_ele { -TAILQ_ENTRY (hns3_rss_conf_ele) entries; -struct hns3_rss_conf filter_info; -}; - -/* hns3_flow memory list structure */ -struct hns3_flow_mem { -TAILQ_ENTRY (hns3_flow_mem) entries; -struct rte_flow *flow; -}; -TAILQ_HEAD (hns3_fdir_rule_list, hns3_fdir_rule_ele); -TAILQ_HEAD (hns3_rss_filter_list, hns3_rss_conf_ele); -TAILQ_HEAD (hns3_flow_mem_list, hns3_flow_mem);/* * A structure used to define fields of a FDIR related info.
@@ -199,11 +175,6 @@ struct hns3_fdir_info {struct hns3_fd_cfg fd_cfg; }; -struct rte_flow { -enum rte_filter_type filter_type; -void *rule; -uint32_t counter_id; -};struct hns3_adapter ;int hns3_init_fd_config (struct hns3_adapter *hns);
@@ -213,8 +184,6 @@ int hns3_fdir_filter_program(struct hns3_adapter *hns, struct hns3_fdir_rule *rule, bool del);int hns3_clear_all_fdir_filter (struct hns3_adapter *hns);int hns3_get_count (struct hns3_hw *hw,uint32_t id,uint64_t *value); -void hns3_flow_init (struct rte_eth_dev *dev); -void hns3_flow_uninit (struct rte_eth_dev *dev);int hns3_restore_all_fdir_filter (struct hns3_adapter *hns);#endif /* _HNS3_FDIR_H_ */
drivers/net/hns3/hns3_flow.c +1 -0
@@ -8,6 +8,7 @@#include "hns3_ethdev.h" #include "hns3_logs.h" +#include "hns3_flow.h" /* Default default keys */ static uint8_t hns3_hash_key[] = {
drivers/net/hns3/hns3_flow.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.33.0
PATCH v3 7/9 net/hns3: remove magic numbers
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Removing magic numbers with macros.
--- drivers/net/hns3/hns3_common.c | 4 ++-- drivers/net/hns3/hns3_common.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_common.c +2 -2
@@ -54,7 +54,7 @@ hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args)RTE_SET_USED (key); - val =strtoull (value,NULL ,16 ); + val =strtoull (value,NULL ,HNS3_CONVERT_TO_HEXADECIMAL ); *(uint64_t *)extra_args = val;return 0 ;
@@ -67,7 +67,7 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args)RTE_SET_USED (key); - val =strtoul (value,NULL ,10 ); + val =strtoul (value,NULL ,HNS3_CONVERT_TO_DECIMAL );if (val >HNS3_MBX_DEF_TIME_LIMIT_MS && val <=UINT16_MAX ) *(uint16_t *)extra_args = val;
drivers/net/hns3/hns3_common.h +3 -0
@@ -9,6 +9,9 @@#include "hns3_ethdev.h" +#define HNS3_CONVERT_TO_DECIMAL 10 +#define HNS3_CONVERT_TO_HEXADECIMAL 16 +enum {HNS3_IO_FUNC_HINT_NONE =0 ,HNS3_IO_FUNC_HINT_VEC ,
Signature · 1 line
2.33.0
PATCH v3 8/9 net/hns3: fix the return value of the function
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Fixing the return value of the function to clear static warning.
--- drivers/net/hns3/hns3_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/hns3/hns3_common.c +4 -4
@@ -154,10 +154,10 @@ hns3_clock_gettime_ms(void)void hns3_ether_format_addr (char *buf,uint16_t size,const struct rte_ether_addr *ether_addr) { -snprintf (buf, size,"%02X:**:**:**:%02X:%02X" , - ether_addr->addr_bytes[0 ], - ether_addr->addr_bytes[4 ], - ether_addr->addr_bytes[5 ]); + (void )snprintf (buf, size,"%02X:**:**:**:%02X:%02X" , + ether_addr->addr_bytes[0 ], + ether_addr->addr_bytes[4 ], + ether_addr->addr_bytes[5 ]); } static int
Signature · 1 line
2.33.0
PATCH v3 9/9 net/hns3: remove PF/VF duplicate code
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch remove PF/VF duplicate code of:
1. get firmware version.
2. get device info.
3. rx interrupt related functions.
--- drivers/net/hns3/hns3_common.c | 339 +++++++++++++++++++++++++++++- drivers/net/hns3/hns3_common.h | 10 + drivers/net/hns3/hns3_ethdev.c | 314 +-------------------------- drivers/net/hns3/hns3_ethdev.h | 16 +- drivers/net/hns3/hns3_ethdev_vf.c | 326 +--------------------------- drivers/net/hns3/hns3_tm.c | 2 +- 6 files changed, 365 insertions(+), 642 deletions(-)
drivers/net/hns3/hns3_common.c +338 -1
@@ -3,9 +3,154 @@*/ #include <rte_kvargs.h> +#include <rte_bus_pci.h> +#include <ethdev_pci.h> +#include <rte_pci.h> -#include "hns3_logs.h" #include "hns3_common.h" +#include "hns3_logs.h" +#include "hns3_regs.h" +#include "hns3_rxtx.h" + +int +hns3_fw_version_get (struct rte_eth_dev *eth_dev,char *fw_version, +size_t fw_size) +{ +struct hns3_adapter *hns = eth_dev->data->dev_private; +struct hns3_hw *hw = &hns->hw; +uint32_t version = hw->fw_version; +int ret; + + ret =snprintf (fw_version, fw_size,"%lu.%lu.%lu.%lu" , +hns3_get_field (version,HNS3_FW_VERSION_BYTE3_M , +HNS3_FW_VERSION_BYTE3_S ), +hns3_get_field (version,HNS3_FW_VERSION_BYTE2_M , +HNS3_FW_VERSION_BYTE2_S ), +hns3_get_field (version,HNS3_FW_VERSION_BYTE1_M , +HNS3_FW_VERSION_BYTE1_S ), +hns3_get_field (version,HNS3_FW_VERSION_BYTE0_M , +HNS3_FW_VERSION_BYTE0_S )); +if (ret <0 ) +return -EINVAL ; + + ret +=1 ;/* add the size of '\0' */ +if (fw_size < (size_t )ret) +return ret; +else +return 0 ; +} + +int +hns3_dev_infos_get (struct rte_eth_dev *eth_dev,struct rte_eth_dev_info *info) +{ +struct hns3_adapter *hns = eth_dev->data->dev_private; +struct hns3_hw *hw = &hns->hw; +uint16_t queue_num = hw->tqps_num; + +/* +* In interrupt mode, 'max_rx_queues' is set based on the number of +* MSI-X interrupt resources of the hardware. +*/ +if (hw->data->dev_conf.intr_conf.rxq ==1 ) + queue_num = hw->intr_tqps_num; + + info->max_rx_queues = queue_num; + info->max_tx_queues = hw->tqps_num; + info->max_rx_pktlen =HNS3_MAX_FRAME_LEN ;/* CRC included */ + info->min_rx_bufsize =HNS3_MIN_BD_BUF_SIZE ; + info->max_mtu = info->max_rx_pktlen -HNS3_ETH_OVERHEAD ; + info->max_lro_pkt_size =HNS3_MAX_LRO_SIZE ; + info->rx_offload_capa = (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | +RTE_ETH_RX_OFFLOAD_TCP_CKSUM | +RTE_ETH_RX_OFFLOAD_UDP_CKSUM | +RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | +RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | +RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM | +RTE_ETH_RX_OFFLOAD_SCATTER | +RTE_ETH_RX_OFFLOAD_VLAN_STRIP | +RTE_ETH_RX_OFFLOAD_VLAN_FILTER | +RTE_ETH_RX_OFFLOAD_RSS_HASH | +RTE_ETH_RX_OFFLOAD_TCP_LRO ); + info->tx_offload_capa = (RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | +RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | +RTE_ETH_TX_OFFLOAD_TCP_CKSUM | +RTE_ETH_TX_OFFLOAD_UDP_CKSUM | +RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | +RTE_ETH_TX_OFFLOAD_MULTI_SEGS | +RTE_ETH_TX_OFFLOAD_TCP_TSO | +RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | +RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | +RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | +RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | +RTE_ETH_TX_OFFLOAD_VLAN_INSERT ); + +if (!hw->port_base_vlan_cfg.state) + info->tx_offload_capa |=RTE_ETH_TX_OFFLOAD_QINQ_INSERT ; + +if (hns3_dev_get_support (hw,OUTER_UDP_CKSUM )) + info->tx_offload_capa |=RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM ; + +if (hns3_dev_get_support (hw,INDEP_TXRX )) + info->dev_capa =RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | +RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP ; + info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP ; + +if (hns3_dev_get_support (hw,PTP )) + info->rx_offload_capa |=RTE_ETH_RX_OFFLOAD_TIMESTAMP ; + + info->rx_desc_lim = (struct rte_eth_desc_lim ) { + .nb_max =HNS3_MAX_RING_DESC , + .nb_min =HNS3_MIN_RING_DESC , + .nb_align =HNS3_ALIGN_RING_DESC , + }; + + info->tx_desc_lim = (struct rte_eth_desc_lim ) { + .nb_max =HNS3_MAX_RING_DESC , + .nb_min =HNS3_MIN_RING_DESC , + .nb_align =HNS3_ALIGN_RING_DESC , + .nb_seg_max =HNS3_MAX_TSO_BD_PER_PKT , + .nb_mtu_seg_max = hw->max_non_tso_bd_num, + }; + + info->default_rxconf = (struct rte_eth_rxconf ) { + .rx_free_thresh =HNS3_DEFAULT_RX_FREE_THRESH , +/* +* If there are no available Rx buffer descriptors, incoming +* packets are always dropped by hardware based on hns3 network +* engine. +*/ + .rx_drop_en =1 , + .offloads =0 , + }; + info->default_txconf = (struct rte_eth_txconf ) { + .tx_rs_thresh =HNS3_DEFAULT_TX_RS_THRESH , + .offloads =0 , + }; + + info->reta_size = hw->rss_ind_tbl_size; + info->hash_key_size =HNS3_RSS_KEY_SIZE ; + info->flow_type_rss_offloads =HNS3_ETH_RSS_SUPPORT ; + + info->default_rxportconf.burst_size =HNS3_DEFAULT_PORT_CONF_BURST_SIZE ; + info->default_txportconf.burst_size =HNS3_DEFAULT_PORT_CONF_BURST_SIZE ; + info->default_rxportconf.nb_queues =HNS3_DEFAULT_PORT_CONF_QUEUES_NUM ; + info->default_txportconf.nb_queues =HNS3_DEFAULT_PORT_CONF_QUEUES_NUM ; + info->default_rxportconf.ring_size =HNS3_DEFAULT_RING_DESC ; + info->default_txportconf.ring_size =HNS3_DEFAULT_RING_DESC ; + +/* +* Next is the PF/VF difference section. +*/ +if (!hns->is_vf) { + info->max_mac_addrs =HNS3_UC_MACADDR_NUM ; + info->rx_offload_capa |=RTE_ETH_RX_OFFLOAD_KEEP_CRC ; + info->speed_capa =hns3_get_speed_capa (hw); + }else { + info->max_mac_addrs =HNS3_VF_UC_MACADDR_NUM ; + } + +return 0 ; +}static int hns3_parse_io_hint_func (const char *key,const char *value,void *extra_args)
@@ -68,6 +213,12 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args)RTE_SET_USED (key); val =strtoul (value,NULL ,HNS3_CONVERT_TO_DECIMAL ); + +/* +* 500ms is empirical value in process of mailbox communication. If +* the delay value is set to one lower thanthe empirical value, mailbox +* communication may fail. +*/ if (val >HNS3_MBX_DEF_TIME_LIMIT_MS && val <=UINT16_MAX ) *(uint16_t *)extra_args = val;
@@ -116,6 +267,11 @@ hns3_parse_devargs(struct rte_eth_dev *dev)hns3_warn (hw,"parsed %s = 0x%" PRIx64"." ,HNS3_DEVARG_DEV_CAPS_MASK , dev_caps_mask); hns->dev_caps_mask = dev_caps_mask; + +if (mbx_time_limit_ms !=HNS3_MBX_DEF_TIME_LIMIT_MS ) +hns3_warn (hw,"parsed %s = %u." ,HNS3_DEVARG_MBX_TIME_LIMIT_MS , + mbx_time_limit_ms); + hns->mbx_time_limit_ms = mbx_time_limit_ms; }void
@@ -424,3 +580,184 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) ret); } } + +int +hns3_init_ring_with_vector (struct hns3_hw *hw) +{ +uint16_t vec; +int ret; +int i; + +/* +* In hns3 network engine, vector 0 is always the misc interrupt of this +* function, vector 1~N can be used respectively for the queues of the +* function. Tx and Rx queues with the same number share the interrupt +* vector. In the initialization clearing the all hardware mapping +* relationship configurations between queues and interrupt vectors is +* needed, so some error caused by the residual configurations, such as +* the unexpected Tx interrupt, can be avoid. +*/ + vec = hw->num_msi -1 ;/* vector 0 for misc interrupt, not for queue */ +if (hw->intr.mapping_mode ==HNS3_INTR_MAPPING_VEC_RSV_ONE ) + vec = vec -1 ;/* the last interrupt is reserved */ + hw->intr_tqps_num =RTE_MIN (vec, hw->tqps_num); +for (i =0 ; i < hw->intr_tqps_num; i++) { +/* +* Set gap limiter/rate limiter/quanity limiter algorithm +* configuration for interrupt coalesce of queue's interrupt. +*/ +hns3_set_queue_intr_gl (hw, i,HNS3_RING_GL_RX , +HNS3_TQP_INTR_GL_DEFAULT ); +hns3_set_queue_intr_gl (hw, i,HNS3_RING_GL_TX , +HNS3_TQP_INTR_GL_DEFAULT ); +hns3_set_queue_intr_rl (hw, i,HNS3_TQP_INTR_RL_DEFAULT ); +/* +* QL(quantity limiter) is not used currently, just set 0 to +* close it. +*/ +hns3_set_queue_intr_ql (hw, i,HNS3_TQP_INTR_QL_DEFAULT ); + + ret = hw->ops.bind_ring_with_vector (hw, vec, false, +HNS3_RING_TYPE_TX , i); +if (ret) { +PMD_INIT_LOG (ERR ,"fail to unbind TX ring(%d) with " +"vector: %u, ret=%d" , i, vec, ret); +return ret; + } + + ret = hw->ops.bind_ring_with_vector (hw, vec, false, +HNS3_RING_TYPE_RX , i); +if (ret) { +PMD_INIT_LOG (ERR ,"fail to unbind RX ring(%d) with " +"vector: %u, ret=%d" , i, vec, ret); +return ret; + } + } + +return 0 ; +} + +int +hns3_map_rx_interrupt (struct rte_eth_dev *dev) +{ +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private); +uint16_t base =RTE_INTR_VEC_ZERO_OFFSET ; +uint16_t vec =RTE_INTR_VEC_ZERO_OFFSET ; +uint32_t intr_vector; +uint16_t q_id; +int ret; + +/* +* hns3 needs a separate interrupt to be used as event interrupt which +* could not be shared with task queue pair, so KERNEL drivers need +* support multiple interrupt vectors. +*/ +if (dev->data->dev_conf.intr_conf.rxq ==0 || + !rte_intr_cap_multiple (intr_handle)) +return 0 ; + +rte_intr_disable (intr_handle); + intr_vector = hw->used_rx_queues; +/* creates event fd for each intr vector when MSIX is used */ +if (rte_intr_efd_enable (intr_handle, intr_vector)) +return -EINVAL ; + +/* Allocate vector list */ +if (rte_intr_vec_list_alloc (intr_handle,"intr_vec" , + hw->used_rx_queues)) { +hns3_err (hw,"failed to allocate %u rx_queues intr_vec" , + hw->used_rx_queues); + ret = -ENOMEM ; + goto alloc_intr_vec_error; + } + +if (rte_intr_allow_others (intr_handle)) { + vec =RTE_INTR_VEC_RXTX_OFFSET ; + base =RTE_INTR_VEC_RXTX_OFFSET ; + } + +for (q_id =0 ; q_id < hw->used_rx_queues; q_id++) { + ret = hw->ops.bind_ring_with_vector (hw, vec, true, +HNS3_RING_TYPE_RX , q_id); +if (ret) + goto bind_vector_error; + +if (rte_intr_vec_list_index_set (intr_handle, q_id, vec)) + goto bind_vector_error; +/* +* If there are not enough efds (e.g. not enough interrupt), +* remaining queues will be bond to the last interrupt. +*/ +if (vec < base +rte_intr_nb_efd_get (intr_handle) -1 ) + vec++; + } +rte_intr_enable (intr_handle); +return 0 ; + +bind_vector_error: +rte_intr_vec_list_free (intr_handle); +alloc_intr_vec_error: +rte_intr_efd_disable (intr_handle); +return ret; +} + +void +hns3_unmap_rx_interrupt (struct rte_eth_dev *dev) +{ +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct hns3_adapter *hns = dev->data->dev_private; +struct hns3_hw *hw = &hns->hw; +uint8_t base =RTE_INTR_VEC_ZERO_OFFSET ; +uint8_t vec =RTE_INTR_VEC_ZERO_OFFSET ; +uint16_t q_id; + +if (dev->data->dev_conf.intr_conf.rxq ==0 ) +return ; + +/* unmap the ring with vector */ +if (rte_intr_allow_others (intr_handle)) { + vec =RTE_INTR_VEC_RXTX_OFFSET ; + base =RTE_INTR_VEC_RXTX_OFFSET ; + } +if (rte_intr_dp_is_en (intr_handle)) { +for (q_id =0 ; q_id < hw->used_rx_queues; q_id++) { + (void )hw->ops.bind_ring_with_vector (hw, vec, false, +HNS3_RING_TYPE_RX , + q_id); +if (vec < base +rte_intr_nb_efd_get (intr_handle) -1 ) + vec++; + } + } +/* Clean datapath event and queue/vec mapping */ +rte_intr_efd_disable (intr_handle); +rte_intr_vec_list_free (intr_handle); +} + +int +hns3_restore_rx_interrupt (struct hns3_hw *hw) +{ +struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +uint16_t q_id; +int ret; + +if (dev->data->dev_conf.intr_conf.rxq ==0 ) +return 0 ; + +if (rte_intr_dp_is_en (intr_handle)) { +for (q_id =0 ; q_id < hw->used_rx_queues; q_id++) { + ret = hw->ops.bind_ring_with_vector (hw, +rte_intr_vec_list_index_get (intr_handle, + q_id), + true,HNS3_RING_TYPE_RX , q_id); +if (ret) +return ret; + } + } + +return 0 ; +}
drivers/net/hns3/hns3_common.h +10 -0
@@ -30,6 +30,11 @@ enum {#define MSEC_PER_SEC 1000L#define USEC_PER_MSEC 1000L +int hns3_fw_version_get (struct rte_eth_dev *eth_dev,char *fw_version, +size_t fw_size); +int hns3_dev_infos_get (struct rte_eth_dev *eth_dev, +struct rte_eth_dev_info *info); +void hns3_clock_gettime (struct timeval *tv);uint64_t hns3_clock_calctime_ms (struct timeval *tv);uint64_t hns3_clock_gettime_ms (void );
@@ -48,4 +53,9 @@ int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev,void hns3_ether_format_addr (char *buf,uint16_t size,const struct rte_ether_addr *ether_addr); +int hns3_init_ring_with_vector (struct hns3_hw *hw); +int hns3_map_rx_interrupt (struct rte_eth_dev *dev); +void hns3_unmap_rx_interrupt (struct rte_eth_dev *dev); +int hns3_restore_rx_interrupt (struct hns3_hw *hw); +#endif /* _HNS3_COMMON_H_ */
drivers/net/hns3/hns3_ethdev.c +2 -312
350 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.h +5 -11
@@ -437,6 +437,9 @@ struct hns3_hw_ops { struct rte_ether_addr *mac_addr);int (*del_uc_mac_addr)(struct hns3_hw *hw,struct rte_ether_addr *mac_addr); +int (*bind_ring_with_vector)(struct hns3_hw *hw,uint16_t vector_id, +bool en,enum hns3_ring_type queue_type, +uint16_t queue_id); };#define HNS3_INTR_MAPPING_VEC_RSV_ONE 0
@@ -1032,12 +1035,12 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)return __atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED) & mask; } +uint32_t hns3_get_speed_capa (struct hns3_hw *hw); +int hns3_buffer_alloc (struct hns3_hw *hw);bool hns3_is_reset_pending (struct hns3_adapter *hns);bool hns3vf_is_reset_pending (struct hns3_adapter *hns);void hns3_update_linkstatus_and_event (struct hns3_hw *hw,bool query); -int hns3_dev_infos_get (struct rte_eth_dev *eth_dev, -struct rte_eth_dev_info *info);void hns3vf_update_link_status (struct hns3_hw *hw,uint8_t link_status,uint32_t link_speed,uint8_t link_duplex);void hns3vf_update_push_lsc_cap (struct hns3_hw *hw,bool supported);
@@ -1069,13 +1072,4 @@ is_reset_pending(struct hns3_adapter *hns) return ret; } -static inline uint64_t -hns3_txvlan_cap_get (struct hns3_hw *hw) -{ -if (hw->port_base_vlan_cfg.state) -return RTE_ETH_TX_OFFLOAD_VLAN_INSERT ; -else -return RTE_ETH_TX_OFFLOAD_VLAN_INSERT |RTE_ETH_TX_OFFLOAD_QINQ_INSERT ; -} -#endif /* _HNS3_ETHDEV_H_ */
drivers/net/hns3/hns3_ethdev_vf.c +9 -317
404 lines not on this page · raw message
drivers/net/hns3/hns3_tm.c +1 -1
@@ -4,7 +4,7 @@#include <rte_malloc.h> -#include "hns3_ethdev.h" +#include "hns3_common.h" #include "hns3_dcb.h" #include "hns3_logs.h" #include "hns3_tm.h"
Signature · 1 line
2.33.0
Quoted 14 lines · Min Hu (Connor)
This patch set contains refactor patches and code check patches.
Chengwen Feng (1):
net/hns3: remove PF/VF duplicate codeHuisong Li (7):
net/hns3: fix the shift of DMA address in Rx/Tx queue net/hns3: remove a redundant function declaration net/hns3: modifying code alignment
net/hns3: use unsigned integer for bitwise operations net/hns3: extract a common file
net/hns3: remove magic numbers
net/hns3: fix the return value of the function
Quoted 9 lines
Min Hu (Connor) (1):
net/hns3: add hns3 flow header file
---
v3:
* fixed build error and some other adjustment.v2:
* rebase patch on top of latest next-net.
Series applied to dpdk-next-net/main, thanks.