misc updates for hns3 PMD driver
cover misc updates for hns3 PMD driver
This series are improvement and bugfixes for hns3 PMD driver.
Chengchang Tang (2):
net/hns3: replace PF vport id zero with private macro net/hns3: fix promiscuous config not clear for PF on uninit
Lijun Ou (2):
net/hns3: add RSS hash offload to port Rx configuration net/hns3: fix key length when configuring RSS
Wei Hu (Xavier) (1):
net/hns3: fix preparing sending packets less than 60 bytes
drivers/net/hns3/hns3_ethdev.c | 102 ++++++++++++++++++++++++-------------- drivers/net/hns3/hns3_ethdev.h | 3 ++ drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_flow.c | 8 +++ drivers/net/hns3/hns3_rxtx.c | 6 --- 5 files changed, 78 insertions(+), 42 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/5 net/hns3: replace PF vport id zero with private macro
From: Chengchang Tang <[email protected]>
In hns3 PMD driver, the vport id 0 denote PF, and the vport id 1 denote the first VF device of the port.
This patch adds two macros named HNS3_PF_FUNC_ID and HNS3_1ST_VF_FUNC_ID, and replaces this two numbers to improve code readability.
--- drivers/net/hns3/hns3_ethdev.c | 48 +++++++++++++++++++----------------------- drivers/net/hns3/hns3_ethdev.h | 3 +++ 2 files changed, 25 insertions(+), 26 deletions(-)
drivers/net/hns3/hns3_ethdev.c +22 -26
@@ -474,10 +474,9 @@ hns3_set_vlan_rx_offload_cfg(struct hns3_adapter *hns,/* * In current version VF is not supported when PF is driven by DPDK -* driver, the PF-related vf_id is 0, just need to configure parameters -* for vport_id 0. +* driver, just need to configure parameters for PF vport. */ - vport_id =0 ; + vport_id =HNS3_PF_FUNC_ID ; req->vf_offset = vport_id /HNS3_VF_NUM_PER_CMD ; bitmap =1 << (vport_id %HNS3_VF_NUM_PER_BYTE ); req->vf_bitmap[req->vf_offset] = bitmap;
@@ -564,14 +563,16 @@ hns3_vlan_filter_init(struct hns3_adapter *hns)int ret; ret =hns3_set_vlan_filter_ctrl (hw,HNS3_FILTER_TYPE_VF , -HNS3_FILTER_FE_EGRESS , false,0 ); +HNS3_FILTER_FE_EGRESS , false, +HNS3_PF_FUNC_ID );if (ret) {hns3_err (hw,"failed to init vf vlan filter, ret = %d" , ret);return ret; } ret =hns3_set_vlan_filter_ctrl (hw,HNS3_FILTER_TYPE_PORT , -HNS3_FILTER_FE_INGRESS , false,0 ); +HNS3_FILTER_FE_INGRESS , false, +HNS3_PF_FUNC_ID );if (ret)hns3_err (hw,"failed to init port vlan filter, ret = %d" , ret);
@@ -585,7 +586,8 @@ hns3_enable_vlan_filter(struct hns3_adapter *hns, bool enable)int ret; ret =hns3_set_vlan_filter_ctrl (hw,HNS3_FILTER_TYPE_PORT , -HNS3_FILTER_FE_INGRESS , enable,0 ); +HNS3_FILTER_FE_INGRESS , enable, +HNS3_PF_FUNC_ID );if (ret)hns3_err (hw,"failed to %s port vlan filter, ret = %d" , enable ?"enable" :"disable" , ret);
@@ -674,10 +676,9 @@ hns3_set_vlan_tx_offload_cfg(struct hns3_adapter *hns,/* * In current version VF is not supported when PF is driven by DPDK -* driver, the PF-related vf_id is 0, just need to configure parameters -* for vport_id 0. +* driver, just need to configure parameters for PF vport. */ - vport_id =0 ; + vport_id =HNS3_PF_FUNC_ID ; req->vf_offset = vport_id /HNS3_VF_NUM_PER_CMD ; bitmap =1 << (vport_id %HNS3_VF_NUM_PER_BYTE ); req->vf_bitmap[req->vf_offset] = bitmap;
@@ -1425,10 +1426,9 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)/* * In current version VF is not supported when PF is driven by DPDK -* driver, the PF-related vf_id is 0, just need to configure parameters -* for vf_id 0. +* driver, just need to configure parameters for PF vport. */ - vf_id =0 ; + vf_id =HNS3_PF_FUNC_ID ;hns3_set_field (egress_port,HNS3_MAC_EPORT_VFID_M ,HNS3_MAC_EPORT_VFID_S , vf_id);
@@ -1781,10 +1781,9 @@ hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)/* * In current version VF is not supported when PF is driven by DPDK -* driver, the PF-related vf_id is 0, just need to configure parameters -* for vf_id 0. +* driver, just need to configure parameters for PF vport. */ - vf_id =0 ; + vf_id =HNS3_PF_FUNC_ID ;hns3_update_desc_vfid (desc, vf_id, false); ret =hns3_add_mac_vlan_tbl (hw, &req, desc);if (ret) {
@@ -1824,10 +1823,9 @@ hns3_remove_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)/* * This mac addr exist, remove this handle's VFID for it. * In current version VF is not supported when PF is driven by -* DPDK driver, the PF-related vf_id is 0, just need to -* configure parameters for vf_id 0. +* DPDK driver, just need to configure parameters for PF vport. */ - vf_id =0 ; + vf_id =HNS3_PF_FUNC_ID ;hns3_update_desc_vfid (desc, vf_id, true);/* All the vfid is zero, so need to delete this entry */
@@ -2926,8 +2924,8 @@ hns3_map_tqp(struct hns3_hw *hw)*/ tqp_id =0 ; num =DIV_ROUND_UP (hw->total_tqps_num,HNS3_MAX_TQP_NUM_PER_FUNC ); -for (func_id =0 ; func_id < num; func_id++) { - is_pf = func_id ==0 ? true : false; +for (func_id =HNS3_PF_FUNC_ID ; func_id < num; func_id++) { + is_pf = func_id ==HNS3_PF_FUNC_ID ? true : false;for (i =0 ; i <HNS3_MAX_TQP_NUM_PER_FUNC && tqp_id < tqps_num; i++) { ret = hns3_map_tqps_to_func(hw, func_id, tqp_id++, i,
@@ -3819,10 +3817,9 @@ hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc)/* * In current version VF is not supported when PF is driven by DPDK -* driver, the PF-related vf_id is 0, just need to configure parameters -* for vf_id 0. +* driver, just need to configure parameters for PF vport. */ - vf_id =0 ; + vf_id =HNS3_PF_FUNC_ID ;hns3_promisc_param_init (¶m, en_uc_pmc, en_mc_pmc, en_bc_pmc, vf_id);return hns3_cmd_set_promisc_mode (hw, ¶m);
@@ -3837,8 +3834,7 @@ hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw)uint16_t func_id;int ret; -/* func_id 0 is denoted PF, the VFs start from 1 */ -for (func_id =1 ; func_id < pf->func_num; func_id++) { +for (func_id =HNS3_1ST_VF_FUNC_ID ; func_id < pf->func_num; func_id++) {hns3_promisc_param_init (¶m, false, false, false, func_id); ret =hns3_cmd_set_promisc_mode (hw, ¶m);if (ret)
@@ -5056,7 +5052,7 @@ hns3_prepare_reset(struct hns3_adapter *hns)switch (hw->reset.level) {case HNS3_FUNC_RESET : - ret =hns3_func_reset_cmd (hw,0 ); + ret =hns3_func_reset_cmd (hw,HNS3_PF_FUNC_ID );if (ret)return ret;
drivers/net/hns3/hns3_ethdev.h +3 -0
@@ -30,6 +30,9 @@#define HNS3_PCI_REVISION_ID 0x08#define HNS3_PCI_REVISION_ID_LEN 1 +#define HNS3_PF_FUNC_ID 0 +#define HNS3_1ST_VF_FUNC_ID 1 +#define HNS3_UC_MACADDR_NUM 128#define HNS3_VF_UC_MACADDR_NUM 48#define HNS3_MC_MACADDR_NUM 128
Signature · 1 line
2.7.4
PATCH 2/5 net/hns3: fix promiscuous config not clear for PF on uninit
In reply to Wei Hu (Xavier)From: Chengchang Tang <[email protected]>
Currently, promiscuous mode configuration are not cleared during unintialziation based on hns3 PF device. The residual entries may cause unnecessary bandwidth usage.
So, we need clear the PF's promisc mode status during the uninit.
--- drivers/net/hns3/hns3_ethdev.c | 53 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-)
drivers/net/hns3/hns3_ethdev.c +43 -10
@@ -3826,7 +3826,7 @@ hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc) }static int -hns3_clear_all_vfs_promisc_mode (struct hns3_hw *hw) +hns3_promisc_init (struct hns3_hw *hw) {struct hns3_adapter *hns =HNS3_DEV_HW_TO_ADAPTER (hw);struct hns3_pf *pf = &hns->pf;
@@ -3834,16 +3834,54 @@ hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw)uint16_t func_id;int ret; + ret =hns3_set_promisc_mode (hw, false, false); +if (ret) { +PMD_INIT_LOG (ERR ,"failed to set promisc mode, ret = %d" , ret); +return ret; + } + +/* +* In current version VFs are not supported when PF is driven by DPDK +* driver. After PF has been taken over by DPDK, the original VF will +* be invalid. So, there is a possibility of entry residues. It should +* clear VFs's promisc mode to avoid unnecessary bandwidth usage +* during init. +*/ for (func_id =HNS3_1ST_VF_FUNC_ID ; func_id < pf->func_num; func_id++) {hns3_promisc_param_init (¶m, false, false, false, func_id); ret =hns3_cmd_set_promisc_mode (hw, ¶m); -if (ret) +if (ret) { +PMD_INIT_LOG (ERR ,"failed to clear vf:%d promisc mode," +" ret = %d" , func_id, ret);return ret; + } }return 0 ; } +static void +hns3_promisc_uninit (struct hns3_hw *hw) +{ +struct hns3_promisc_param param; +uint16_t func_id; +int ret; + + func_id =HNS3_PF_FUNC_ID ; + +/* +* In current version VFs are not supported when PF is driven by +* DPDK driver, and VFs' promisc mode status has been cleared during +* init and their status will not change. So just clear PF's promisc +* mode status during uninit. +*/ +hns3_promisc_param_init (¶m, false, false, false, func_id); + ret =hns3_cmd_set_promisc_mode (hw, ¶m); +if (ret) +PMD_INIT_LOG (ERR ,"failed to clear promisc status during" +" uninit, ret = %d" , ret); +} +static int hns3_dev_promiscuous_enable (struct rte_eth_dev *dev) {
@@ -4186,15 +4224,9 @@ hns3_init_hardware(struct hns3_adapter *hns) goto err_mac_init; } - ret =hns3_set_promisc_mode (hw, false, false); -if (ret) { -PMD_INIT_LOG (ERR ,"Failed to set promisc mode: %d" , ret); - goto err_mac_init; - } - - ret =hns3_clear_all_vfs_promisc_mode (hw); + ret =hns3_promisc_init (hw);if (ret) { -PMD_INIT_LOG (ERR ,"Failed to clear all vfs promisc mode: %d" , +PMD_INIT_LOG (ERR ,"Failed to init promisc: %d" , ret); goto err_mac_init; }
@@ -4353,6 +4385,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev)hns3_enable_hw_error_intr (hns, false);hns3_rss_uninit (hns); +hns3_promisc_uninit (hw);hns3_fdir_filter_uninit (hns);hns3_uninit_umv_space (hw);hns3_pf_disable_irq0 (hw);
Signature · 1 line
2.7.4
PATCH 3/5 net/hns3: fix preparing sending packets less than 60 bytes
In reply to Wei Hu (Xavier)Currently, when running testpmd application based on hns3 network engine with csum fwd mode by "set fwd csum" command in the prompt line, sending 42 consecutive bytes of arp packets to network port with packets generator, But in fact hardware can't send the arp packets and the related logs as below:
"Preparing packet burst to failed: Invalid argument"
The hardware doesn't support transmit packets less than 60 bytes, and in the '.tx_pkt_burst' ops implementation function named hns3_xmit_pkts appending operation has been added for less than 60 bytes packets. So the interception needs to be removed in the '.tx_pkt_prepare' ops implementation function named hns3_prep_pkts.
--- drivers/net/hns3/hns3_rxtx.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/net/hns3/hns3_rxtx.c +0 -6
@@ -2313,12 +2313,6 @@ hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,for (i =0 ; i < nb_pkts; i++) { m = tx_pkts[i]; -/* check the size of packet */ -if (m->pkt_len <RTE_ETHER_MIN_LEN ) { - rte_errno =EINVAL ; -return i; - } -if (hns3_pkt_is_tso (m) && (hns3_pkt_need_linearized (m, m->nb_segs) ||hns3_check_tso_pkt_valid (m))) {
Signature · 1 line
2.7.4
PATCH 4/5 net/hns3: add RSS hash offload to port Rx configuration
In reply to Wei Hu (Xavier)From: Lijun Ou <[email protected]>
Rx offload flag DEV_RX_OFFLOAD_RSS_HASH which can be used to enable/disable PMDs write to rte_mbuf::hash::rss. The hns3 PMD driver already can notify the validity of rte_mbuf::hash:rss to the application by enabling PKT_RX_RSS_HASH flag in rte_mbuf::ol_flags.
--- drivers/net/hns3/hns3_ethdev.c | 1 + drivers/net/hns3/hns3_ethdev_vf.c | 1 + 2 files changed, 2 insertions(+)
drivers/net/hns3/hns3_ethdev.c +1 -0
@@ -2312,6 +2312,7 @@ hns3_dev_configure(struct rte_eth_dev *dev)/* When RSS is not configured, redirect the packet queue 0 */ if ((uint32_t )mq_mode Ð_MQ_RX_RSS_FLAG ) { + conf->rxmode.offloads |=DEV_RX_OFFLOAD_RSS_HASH ; rss_conf = conf->rx_adv_conf.rss_conf;if (rss_conf.rss_key ==NULL ) { rss_conf.rss_key = rss_cfg->key;
drivers/net/hns3/hns3_ethdev_vf.c +1 -0
@@ -784,6 +784,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)/* When RSS is not configured, redirect the packet queue 0 */ if ((uint32_t )mq_mode Ð_MQ_RX_RSS_FLAG ) { + conf->rxmode.offloads |=DEV_RX_OFFLOAD_RSS_HASH ; rss_conf = conf->rx_adv_conf.rss_conf;if (rss_conf.rss_key ==NULL ) { rss_conf.rss_key = rss_cfg->key;
Signature · 1 line
2.7.4
PATCH 5/5 net/hns3: fix key length when configuring RSS
In reply to Wei Hu (Xavier)From: Lijun Ou <[email protected]>
When users set the length of rss hash key greater than the supported length by hardware, the pmd driver should intercept and can not configure the wrong key into the hardware.
--- drivers/net/hns3/hns3_flow.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/hns3/hns3_flow.c +8 -0
@@ -1475,6 +1475,14 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,return -EINVAL ; } +if (rss_flow_conf.key_len && + rss_flow_conf.key_len >RTE_DIM (rss_info->key)) { +hns3_err (hw, +"input hash key(%u) greater than supported len(%lu)" , + rss_flow_conf.key_len,RTE_DIM (rss_info->key)); +return -EINVAL ; + } +/* Filter the unsupported flow types */ flow_types = rss_flow_conf.types &HNS3_ETH_RSS_SUPPORT ;if (flow_types != rss_flow_conf.types)
Signature · 1 line
2.7.4
Quoted 1 line · Wei Hu (Xavier)
This series are improvement and bugfixes for hns3 PMD driver.
Hi Xavier,
We are planning to have the -rc4 this weekend and the release on Tuesday. So we are literally a few days away from the release.
It is definitely not good idea to change the code this close to the release, that is why we are saying -rc4 for the critical defects only.
I will postpone this series to the next release, fyi.
Quoted 19 lines
Chengchang Tang (2):
net/hns3: replace PF vport id zero with private macro net/hns3: fix promiscuous config not clear for PF on uninitLijun Ou (2):
net/hns3: add RSS hash offload to port Rx configuration net/hns3: fix key length when configuring RSSWei Hu (Xavier) (1):
net/hns3: fix preparing sending packets less than 60 bytesdrivers/net/hns3/hns3_ethdev.c | 102 ++++++++++++++++++++++++-------------- drivers/net/hns3/hns3_ethdev.h | 3 ++ drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_flow.c | 8 +++ drivers/net/hns3/hns3_rxtx.c | 6 --- 5 files changed, 78 insertions(+), 42 deletions(-)
Quoted 11 lines · Ferruh Yigit
Quoted 1 line · Wei Hu (Xavier)
This series are improvement and bugfixes for hns3 PMD driver.
Hi Xavier,
We are planning to have the -rc4 this weekend and the release on Tuesday. So we are literally a few days away from the release.
It is definitely not good idea to change the code this close to the release, that is why we are saying -rc4 for the critical defects only.
I will postpone this series to the next release, fyi.
Hi, Ferruh Yigit
I got it. I will adjust the frequency of sending patches to the
community in future.
Thank you.
Regards
Xavier
Quoted 19 lines
Quoted 18 lines
Chengchang Tang (2):
net/hns3: replace PF vport id zero with private macro net/hns3: fix promiscuous config not clear for PF on uninitLijun Ou (2):
net/hns3: add RSS hash offload to port Rx configuration net/hns3: fix key length when configuring RSSWei Hu (Xavier) (1):
net/hns3: fix preparing sending packets less than 60 bytesdrivers/net/hns3/hns3_ethdev.c | 102 ++++++++++++++++++++++++-------------- drivers/net/hns3/hns3_ethdev.h | 3 ++ drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/hns3_flow.c | 8 +++ drivers/net/hns3/hns3_rxtx.c | 6 --- 5 files changed, 78 insertions(+), 42 deletions(-)
Quoted 6 lines · Wei Hu (Xavier)
This series are improvement and bugfixes for hns3 PMD driver.
Chengchang Tang (2):
net/hns3: replace PF vport id zero with private macro net/hns3: fix promiscuous config not clear for PF on uninit
Quoted 7 lines
Lijun Ou (2):
net/hns3: add RSS hash offload to port Rx configuration net/hns3: fix key length when configuring RSSWei Hu (Xavier) (1):
net/hns3: fix preparing sending packets less than 60 bytes
Series applied to dpdk-next-net/master, thanks.
A minor modification done [1] to fix 32-bit build error [2].
[1]
drivers/net/hns3/hns3_flow.c +1 -1
@@ -1478,7 +1478,7 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,if (rss_flow_conf.key_len && rss_flow_conf.key_len >RTE_DIM (rss_info->key)) {hns3_err (hw, -"input hash key(%u) greater than supported len(%lu)" , +"input hash key(%u) greater than supported len(%zu)" , rss_flow_conf.key_len,RTE_DIM (rss_info->key));return -EINVAL ; }
[2]
In file included from .../drivers/net/hns3/hns3_flow.c:12:.../drivers/net/hns3/hns3_flow.c: In function ‘hns3_config_rss_filter’:.../drivers/net/hns3/hns3_logs.h:16:38: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘unsigned int’ [-Werror=format=]
16 | rte_log(level, hns3_logtype_driver, "%s %s(): " fmt, \
| ^~~~~~~~~~~.../drivers/net/hns3/hns3_logs.h:20:2: note: in expansion of macro ‘PMD_DRV_LOG_RAW’
20 | PMD_DRV_LOG_RAW(hw, RTE_LOG_ERR, fmt "\n", ## args)
| ^~~~~~~~~~~~~~~
.../drivers/net/hns3/hns3_flow.c:1480:3: note: in expansion of macro ‘hns3_err’
1480 | hns3_err(hw,
| ^~~~~~~~
.../drivers/net/hns3/hns3_flow.c:1481:53: note: format string is defined here
1481 | "input hash key(%u) greater than supported len(%lu)",
| ~~^
| |
| long unsigned int
| %ucc1: all warnings being treated as errors
Hi, Ferruh Yigit
Quoted 55 lines · Ferruh Yigit
Quoted 6 lines · Wei Hu (Xavier)
This series are improvement and bugfixes for hns3 PMD driver.
Chengchang Tang (2):
net/hns3: replace PF vport id zero with private macro net/hns3: fix promiscuous config not clear for PF on uninitQuoted 7 lines
Lijun Ou (2):
net/hns3: add RSS hash offload to port Rx configuration net/hns3: fix key length when configuring RSSWei Hu (Xavier) (1):
net/hns3: fix preparing sending packets less than 60 bytesSeries applied to dpdk-next-net/master, thanks.
A minor modification done [1] to fix 32-bit build error [2].
[1]
drivers/net/hns3/hns3_flow.c +1
-1@@ -1478,7 +1478,7 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,if (rss_flow_conf.key_len && rss_flow_conf.key_len >RTE_DIM (rss_info->key)) {hns3_err (hw, -"input hash key(%u) greater than supported len(%lu)" , +"input hash key(%u) greater than supported len(%zu)" , rss_flow_conf.key_len,RTE_DIM (rss_info->key));return -EINVAL ; }[2]
In file included from.../drivers/net/hns3/hns3_flow.c:12:.../drivers/net/hns3/hns3_flow.c: In function ‘hns3_config_rss_filter’:.../drivers/net/hns3/hns3_logs.h:16:38: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘unsigned int’ [-Werror=format=]16 | rte_log(level, hns3_logtype_driver, "%s %s(): " fmt, \ | ^~~~~~~~~~~ .../drivers/net/hns3/hns3_logs.h:20:2: note: in expansion of macro ‘PMD_DRV_LOG_RAW’ 20 | PMD_DRV_LOG_RAW(hw, RTE_LOG_ERR, fmt "\n", ## args) | ^~~~~~~~~~~~~~~ .../drivers/net/hns3/hns3_flow.c:1480:3: note: in expansion of macro ‘hns3_err’ 1480 | hns3_err(hw, | ^~~~~~~~ .../drivers/net/hns3/hns3_flow.c:1481:53: note: format string is defined here 1481 | "input hash key(%u) greater than supported len(%lu)", | ~~^ | | | long unsigned int | %u
Quoted 3 lines
cc1: all warnings being treated as errors
Thank you very much!
Xavier