fix and feature for hns3 PMD
cover fix and feature for hns3 PMD
This patch contains 15 patches, which include fixing codecheck warning ,code refactor and indirect counter action support.
Chengwen Feng (4):
net/hns3: remove invalid encapsulation function
net/hns3: delete strerror invoke
net/hns3: rename function
net/hns3: support indirect counter action
Huisong Li (10):
net/hns3: remove unnecessary assignment
net/hns3: fix a misjudgment expression
net/hns3: extract a common API to initialize MAC addrs net/hns3: remove unnecessary black lines
net/hns3: extract a function to handle reset fail net/hns3: extract functions to create RSS and FDIR flow rule net/hns3: remove unused variables
net/hns3: remove the number of queue descriptors net/hns3: remove the printing of memory addresses net/hns3: extract a common interface to obtain revision ID
Jie Hai (1):
net/hns3: remove unnecessary 'inline'
drivers/net/hns3/hns3_cmd.c | 12 +- drivers/net/hns3/hns3_common.c | 76 ++++++ drivers/net/hns3/hns3_common.h | 3 + drivers/net/hns3/hns3_dcb.c | 12 +- drivers/net/hns3/hns3_ethdev.c | 85 ++----- drivers/net/hns3/hns3_ethdev.h | 5 - drivers/net/hns3/hns3_ethdev_vf.c | 93 +------ drivers/net/hns3/hns3_fdir.c | 3 +- drivers/net/hns3/hns3_fdir.h | 1 + drivers/net/hns3/hns3_flow.c | 399 ++++++++++++++++++++++++------ drivers/net/hns3/hns3_flow.h | 11 +- drivers/net/hns3/hns3_intr.c | 54 ++-- drivers/net/hns3/hns3_rxtx.c | 6 - drivers/net/hns3/hns3_rxtx.h | 2 - 14 files changed, 476 insertions(+), 286 deletions(-)
Signature · 1 line
2.33.0
PATCH 1/15 net/hns3: remove unnecessary assignment
From: Huisong Li <[email protected]>
Remove unnecessary assignment.
--- drivers/net/hns3/hns3_flow.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/hns3/hns3_flow.c +0 -1
@@ -1890,7 +1890,6 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, } }rte_free (flow); - flow =NULL ;return 0 ; }
Signature · 1 line
2.33.0
PATCH 2/15 net/hns3: fix a misjudgment expression
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
The enum type variables cannot be used as bool variables. This patch fixes for "with->func" in hns3_action_rss_same().
--- drivers/net/hns3/hns3_flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_flow.c +2 -1
@@ -1251,7 +1251,8 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp,if (comp->func ==RTE_ETH_HASH_FUNCTION_MAX ) func_is_same = false;else - func_is_same = with->func ? (comp->func == with->func) : true; + func_is_same = (with->func !=RTE_ETH_HASH_FUNCTION_DEFAULT ) ? + (comp->func == with->func) : true; return (func_is_same && comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) &&
Signature · 1 line
2.33.0
PATCH 3/15 net/hns3: extract a common API to initialize MAC addrs
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
The code logic to initialize "data->mac_addrs" for PF and VF is similar. This patch extracts a common API to initialize it to improve code maintainabiliy.
--- drivers/net/hns3/hns3_common.c | 54 +++++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 1 + drivers/net/hns3/hns3_ethdev.c | 31 +++--------------- drivers/net/hns3/hns3_ethdev_vf.c | 33 +++---------------- 4 files changed, 63 insertions(+), 56 deletions(-)
drivers/net/hns3/hns3_common.c +54 -0
@@ -581,6 +581,60 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) } } +int +hns3_init_mac_addrs (struct rte_eth_dev *dev) +{ +struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct hns3_adapter *hns =HNS3_DEV_HW_TO_ADAPTER (hw); +const char *memory_name = hns->is_vf ?"hns3vf-mac" :"hns3-mac" ; +uint16_t mac_addrs_capa = hns->is_vf ?HNS3_VF_UC_MACADDR_NUM : +HNS3_UC_MACADDR_NUM ; +char mac_str[RTE_ETHER_ADDR_FMT_SIZE ]; +struct rte_ether_addr *eth_addr; + +/* Allocate memory for storing MAC addresses */ + dev->data->mac_addrs =rte_zmalloc (memory_name, +sizeof (struct rte_ether_addr ) * mac_addrs_capa, +0 ); +if (dev->data->mac_addrs ==NULL ) { +hns3_err (hw,"failed to allocate %zx bytes needed to store MAC addresses" , +sizeof (struct rte_ether_addr ) * mac_addrs_capa); +return -ENOMEM ; + } + + eth_addr = (struct rte_ether_addr *)hw->mac.mac_addr; +if (!hns->is_vf) { +if (!rte_is_valid_assigned_ether_addr (eth_addr)) { +rte_eth_random_addr (hw->mac.mac_addr); +hns3_ether_format_addr (mac_str,RTE_ETHER_ADDR_FMT_SIZE , + (struct rte_ether_addr *)hw->mac.mac_addr); +hns3_warn (hw,"default mac_addr from firmware is an invalid " +"unicast address, using random MAC address %s" , + mac_str); + } + }else { +/* +* The hns3 PF ethdev driver in kernel support setting VF MAC +* address on the host by "ip link set ..." command. To avoid +* some incorrect scenes, for example, hns3 VF PMD driver fails +* to receive and send packets after user configure the MAC +* address by using the "ip link set ..." command, hns3 VF PMD +* driver keep the same MAC address strategy as the hns3 kernel +* ethdev driver in the initialization. If user configure a MAC +* address by the ip command for VF device, then hns3 VF PMD +* driver will start with it, otherwise start with a random MAC +* address in the initialization. +*/ +if (rte_is_zero_ether_addr (eth_addr)) +rte_eth_random_addr (hw->mac.mac_addr); + } + +rte_ether_addr_copy ((struct rte_ether_addr *)hw->mac.mac_addr, + &dev->data->mac_addrs[0 ]); + +return 0 ; +} +int hns3_init_ring_with_vector (struct hns3_hw *hw) {
drivers/net/hns3/hns3_common.h +1 -0
@@ -52,6 +52,7 @@ int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, uint32_t nb_mc_addr);void hns3_ether_format_addr (char *buf,uint16_t size,const struct rte_ether_addr *ether_addr); +int hns3_init_mac_addrs (struct rte_eth_dev *dev);int hns3_init_ring_with_vector (struct hns3_hw *hw);int hns3_map_rx_interrupt (struct rte_eth_dev *dev);
drivers/net/hns3/hns3_ethdev.c +4 -27
@@ -6623,8 +6623,6 @@ static int hns3_dev_init(struct rte_eth_dev *eth_dev) {struct hns3_adapter *hns = eth_dev->data->dev_private; -char mac_str[RTE_ETHER_ADDR_FMT_SIZE ]; -struct rte_ether_addr *eth_addr;struct hns3_hw *hw = &hns->hw;int ret;
@@ -6667,30 +6665,9 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) goto err_init_pf; } -/* Allocate memory for storing MAC addresses */ - eth_dev->data->mac_addrs =rte_zmalloc ("hns3-mac" , -sizeof (struct rte_ether_addr ) * -HNS3_UC_MACADDR_NUM ,0 ); -if (eth_dev->data->mac_addrs ==NULL ) { -PMD_INIT_LOG (ERR ,"Failed to allocate %zx bytes needed " -"to store MAC addresses" , -sizeof (struct rte_ether_addr ) * -HNS3_UC_MACADDR_NUM ); - ret = -ENOMEM ; - goto err_rte_zmalloc; - } - - eth_addr = (struct rte_ether_addr *)hw->mac.mac_addr; -if (!rte_is_valid_assigned_ether_addr (eth_addr)) { -rte_eth_random_addr (hw->mac.mac_addr); -hns3_ether_format_addr (mac_str,RTE_ETHER_ADDR_FMT_SIZE , - (struct rte_ether_addr *)hw->mac.mac_addr); -hns3_warn (hw,"default mac_addr from firmware is an invalid " -"unicast address, using random MAC address %s" , - mac_str); - } -rte_ether_addr_copy ((struct rte_ether_addr *)hw->mac.mac_addr, - ð_dev->data->mac_addrs[0 ]); + ret =hns3_init_mac_addrs (eth_dev); +if (ret !=0 ) + goto err_init_mac_addrs; hw->adapter_state =HNS3_NIC_INITIALIZED ;
@@ -6706,7 +6683,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev)hns3_info (hw,"hns3 dev initialization successful!" );return 0 ; -err_rte_zmalloc: +err_init_mac_addrs:hns3_uninit_pf (eth_dev); err_init_pf:
drivers/net/hns3/hns3_ethdev_vf.c +4 -29
@@ -2400,34 +2400,9 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) goto err_init_vf; } -/* Allocate memory for storing MAC addresses */ - eth_dev->data->mac_addrs =rte_zmalloc ("hns3vf-mac" , -sizeof (struct rte_ether_addr ) * -HNS3_VF_UC_MACADDR_NUM ,0 ); -if (eth_dev->data->mac_addrs ==NULL ) { -PMD_INIT_LOG (ERR ,"Failed to allocate %zx bytes needed " -"to store MAC addresses" , -sizeof (struct rte_ether_addr ) * -HNS3_VF_UC_MACADDR_NUM ); - ret = -ENOMEM ; - goto err_rte_zmalloc; - } - -/* -* The hns3 PF ethdev driver in kernel support setting VF MAC address -* on the host by "ip link set ..." command. To avoid some incorrect -* scenes, for example, hns3 VF PMD fails to receive and send -* packets after user configure the MAC address by using the -* "ip link set ..." command, hns3 VF PMD keep the same MAC -* address strategy as the hns3 kernel ethdev driver in the -* initialization. If user configure a MAC address by the ip command -* for VF device, then hns3 VF PMD will start with it, otherwise -* start with a random MAC address in the initialization. -*/ -if (rte_is_zero_ether_addr ((struct rte_ether_addr *)hw->mac.mac_addr)) -rte_eth_random_addr (hw->mac.mac_addr); -rte_ether_addr_copy ((struct rte_ether_addr *)hw->mac.mac_addr, - ð_dev->data->mac_addrs[0 ]); + ret =hns3_init_mac_addrs (eth_dev); +if (ret !=0 ) + goto err_init_mac_addrs; hw->adapter_state =HNS3_NIC_INITIALIZED ;
@@ -2443,7 +2418,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) eth_dev);return 0 ; -err_rte_zmalloc: +err_init_mac_addrs:hns3vf_uninit_vf (eth_dev); err_init_vf:
Signature · 1 line
2.33.0
PATCH 4/15 net/hns3: remove unnecessary 'inline'
In reply to Min Hu (Connor)From: Jie Hai <[email protected]>
This function is a control-plane interface and does not need to use inline.
--- drivers/net/hns3/hns3_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hns3/hns3_ethdev.c +1 -1
@@ -4859,7 +4859,7 @@ hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds)return 0 ; } -static inline uint32_t +static uint32_t hns3_get_link_speed (uint32_t link_speeds) {uint32_t speed =RTE_ETH_SPEED_NUM_NONE ;
Signature · 1 line
2.33.0
PATCH 5/15 net/hns3: remove unnecessary black lines
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Remove unnecessary black lines.
--- drivers/net/hns3/hns3_ethdev.c | 1 - drivers/net/hns3/hns3_rxtx.h | 2 -- 2 files changed, 3 deletions(-)
drivers/net/hns3/hns3_ethdev.c +0 -1
@@ -6301,7 +6301,6 @@ hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode)struct hns3_adapter *hns = dev->data->dev_private;struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (hns);struct hns3_pf *pf = &hns->pf; -struct rte_eth_fec_capa fec_capa[FEC_CAPA_NUM ];uint32_t cur_capa;uint32_t num =FEC_CAPA_NUM ;
drivers/net/hns3/hns3_rxtx.h +0 -2
@@ -344,7 +344,6 @@ struct hns3_rx_queue {struct rte_mbuf fake_mbuf;/* fake mbuf used with vector rx */ -/* * The following fields are not accessed in the I/O path, so they are * placed at the end.
@@ -518,7 +517,6 @@ struct hns3_tx_queue {struct hns3_tx_basic_stats basic_stats;struct hns3_tx_dfx_stats dfx_stats; -/* * The following fields are not accessed in the I/O path, so they are * placed at the end.
Signature · 1 line
2.33.0
PATCH 6/15 net/hns3: extract a function to handle reset fail
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Extract a function to handle reset fail for clearer code logic.
--- drivers/net/hns3/hns3_intr.c | 54 +++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 22 deletions(-)
drivers/net/hns3/hns3_intr.c +32 -22
@@ -2770,6 +2770,37 @@ hns3_reset_post(struct hns3_adapter *hns)return -EIO ; } +static void +hns3_reset_fail_handle (struct hns3_adapter *hns) +{ +struct hns3_hw *hw = &hns->hw; +struct timeval tv_delta; +struct timeval tv; + +hns3_clear_reset_level (hw, &hw->reset.pending); +if (hns3_reset_err_handle (hns)) { + hw->reset.stage =RESET_STAGE_PREWAIT ; +hns3_schedule_reset (hns); +return ; + } + +rte_spinlock_lock (&hw->lock); +if (hw->reset.mbuf_deferred_free) { +hns3_dev_release_mbufs (hns); + hw->reset.mbuf_deferred_free = false; + } +rte_spinlock_unlock (&hw->lock); +__atomic_store_n (&hns->hw.reset.resetting,0 , __ATOMIC_RELAXED); + hw->reset.stage =RESET_STAGE_NONE ; +hns3_clock_gettime (&tv); +timersub (&tv, &hw->reset.start_time, &tv_delta); +hns3_warn (hw,"%s reset fail delta %" PRIu64" ms time=%ld.%.6ld" , + reset_string[hw->reset.level], +hns3_clock_calctime_ms (&tv_delta), + tv.tv_sec, tv.tv_usec); + hw->reset.level =HNS3_NONE_RESET ; +} +/* * There are three scenarios as follows: * When the reset is not in progress, the reset process starts.
@@ -2784,7 +2815,6 @@ int hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) { struct hns3_hw *hw = &hns->hw; -struct timeval tv_delta;struct timeval tv;int ret;
@@ -2843,27 +2873,7 @@ hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level)if (ret == -EAGAIN )return ret; err: -hns3_clear_reset_level (hw, &hw->reset.pending); -if (hns3_reset_err_handle (hns)) { - hw->reset.stage =RESET_STAGE_PREWAIT ; -hns3_schedule_reset (hns); - }else { -rte_spinlock_lock (&hw->lock); -if (hw->reset.mbuf_deferred_free) { -hns3_dev_release_mbufs (hns); - hw->reset.mbuf_deferred_free = false; - } -rte_spinlock_unlock (&hw->lock); -__atomic_store_n (&hns->hw.reset.resetting,0 , __ATOMIC_RELAXED); - hw->reset.stage =RESET_STAGE_NONE ; -hns3_clock_gettime (&tv); -timersub (&tv, &hw->reset.start_time, &tv_delta); -hns3_warn (hw,"%s reset fail delta %" PRIu64" ms time=%ld.%.6ld" , - reset_string[hw->reset.level], -hns3_clock_calctime_ms (&tv_delta), - tv.tv_sec, tv.tv_usec); - hw->reset.level =HNS3_NONE_RESET ; - } +hns3_reset_fail_handle (hns);return -EIO ; }
Signature · 1 line
2.33.0
PATCH 7/15 net/hns3: extract functions to create RSS and FDIR flow rule
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Extract two functions to create the RSS and FDIR flow rule for clearer code logic.
--- drivers/net/hns3/hns3_flow.c | 173 +++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 67 deletions(-)
drivers/net/hns3/hns3_flow.c +106 -67
@@ -1706,6 +1706,105 @@ hns3_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,return hns3_parse_fdir_filter (dev, pattern, actions, &fdir_rule, error); } +static int +hns3_flow_create_rss_rule (struct rte_eth_dev *dev, +const struct rte_flow_action *act, +struct rte_flow *flow) +{ +struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct hns3_rss_conf_ele *rss_filter_ptr; +const struct hns3_rss_conf *rss_conf; +int ret; + + rss_filter_ptr =rte_zmalloc ("hns3 rss filter" , +sizeof (struct hns3_rss_conf_ele ),0 ); +if (rss_filter_ptr ==NULL ) { +hns3_err (hw,"failed to allocate hns3_rss_filter memory" ); +return -ENOMEM ; + } + +/* +* After all the preceding tasks are successfully configured, configure +* rules to the hardware to simplify the rollback of rules in the +* hardware. +*/ + rss_conf = (const struct hns3_rss_conf *)act->conf; + ret =hns3_flow_parse_rss (dev, rss_conf, true); +if (ret !=0 ) { +rte_free (rss_filter_ptr); +return ret; + } + +hns3_rss_conf_copy (&rss_filter_ptr->filter_info, &rss_conf->conf); + rss_filter_ptr->filter_info.valid = true; +TAILQ_INSERT_TAIL (&hw->flow_rss_list, rss_filter_ptr, entries); + flow->rule = rss_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_HASH ; + +return 0 ; +} + +static int +hns3_flow_create_fdir_rule (struct rte_eth_dev *dev, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error, +struct rte_flow *flow) +{ +struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct hns3_adapter *hns =HNS3_DEV_HW_TO_ADAPTER (hw); +struct hns3_fdir_rule_ele *fdir_rule_ptr; +struct hns3_fdir_rule fdir_rule; +int ret; + +memset (&fdir_rule,0 ,sizeof (struct hns3_fdir_rule )); + ret =hns3_parse_fdir_filter (dev, pattern, actions, &fdir_rule, error); +if (ret !=0 ) +return ret; + +if (fdir_rule.flags &HNS3_RULE_FLAG_COUNTER ) { + ret =hns3_counter_new (dev, fdir_rule.act_cnt.shared, + fdir_rule.act_cnt.id, error); +if (ret !=0 ) +return ret; + + flow->counter_id = fdir_rule.act_cnt.id; + } + + fdir_rule_ptr =rte_zmalloc ("hns3 fdir rule" , +sizeof (struct hns3_fdir_rule_ele ),0 ); +if (fdir_rule_ptr ==NULL ) { +hns3_err (hw,"failed to allocate fdir_rule memory." ); + ret = -ENOMEM ; + goto err_malloc; + } + +/* +* After all the preceding tasks are successfully configured, configure +* rules to the hardware to simplify the rollback of rules in the +* hardware. +*/ + ret =hns3_fdir_filter_program (hns, &fdir_rule, false); +if (ret !=0 ) + goto err_fdir_filter; + +memcpy (&fdir_rule_ptr->fdir_conf, &fdir_rule, +sizeof (struct hns3_fdir_rule )); +TAILQ_INSERT_TAIL (&hw->flow_fdir_list, fdir_rule_ptr, entries); + flow->rule = fdir_rule_ptr; + flow->filter_type =RTE_ETH_FILTER_FDIR ; + +return 0 ; + +err_fdir_filter: +rte_free (fdir_rule_ptr); +err_malloc: +if (fdir_rule.flags &HNS3_RULE_FLAG_COUNTER ) +hns3_counter_release (dev, fdir_rule.act_cnt.id); + +return ret; +} +/* * Create or destroy a flow rule. * Theorically one rule can match more than one filters.
@@ -1720,13 +1819,9 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, {struct hns3_adapter *hns = dev->data->dev_private;struct hns3_hw *hw = &hns->hw; -const struct hns3_rss_conf *rss_conf; -struct hns3_fdir_rule_ele *fdir_rule_ptr; -struct hns3_rss_conf_ele *rss_filter_ptr;struct hns3_flow_mem *flow_node;const struct rte_flow_action *act;struct rte_flow *flow; -struct hns3_fdir_rule fdir_rule;int ret; ret =hns3_flow_validate (dev, attr, pattern, actions, error);
@@ -1752,76 +1847,20 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,TAILQ_INSERT_TAIL (&hw->flow_list, flow_node, entries); act =hns3_find_rss_general_action (pattern, actions); -if (act) { - rss_conf = act->conf; - - ret =hns3_flow_parse_rss (dev, rss_conf, true); -if (ret) - goto err; - - rss_filter_ptr =rte_zmalloc ("hns3 rss filter" , -sizeof (struct hns3_rss_conf_ele ), -0 ); -if (rss_filter_ptr ==NULL ) { -hns3_err (hw, -"Failed to allocate hns3_rss_filter memory" ); - ret = -ENOMEM ; - goto err; - } -hns3_rss_conf_copy (&rss_filter_ptr->filter_info, - &rss_conf->conf); - rss_filter_ptr->filter_info.valid = true; -TAILQ_INSERT_TAIL (&hw->flow_rss_list, rss_filter_ptr, entries); - - flow->rule = rss_filter_ptr; - flow->filter_type =RTE_ETH_FILTER_HASH ; -return flow; - } - -memset (&fdir_rule,0 ,sizeof (struct hns3_fdir_rule )); - ret =hns3_parse_fdir_filter (dev, pattern, actions, &fdir_rule, error); -if (ret) - goto out; - -if (fdir_rule.flags &HNS3_RULE_FLAG_COUNTER ) { - ret =hns3_counter_new (dev,0 , fdir_rule.act_cnt.id, error); -if (ret) - goto out; - - flow->counter_id = fdir_rule.act_cnt.id; - } - - fdir_rule_ptr =rte_zmalloc ("hns3 fdir rule" , -sizeof (struct hns3_fdir_rule_ele ), -0 ); -if (fdir_rule_ptr ==NULL ) { -hns3_err (hw,"failed to allocate fdir_rule memory." ); - ret = -ENOMEM ; - goto err_fdir; - } - - ret =hns3_fdir_filter_program (hns, &fdir_rule, false); -if (!ret) { -memcpy (&fdir_rule_ptr->fdir_conf, &fdir_rule, -sizeof (struct hns3_fdir_rule )); -TAILQ_INSERT_TAIL (&hw->flow_fdir_list, fdir_rule_ptr, entries); - flow->rule = fdir_rule_ptr; - flow->filter_type =RTE_ETH_FILTER_FDIR ; - +if (act) + ret =hns3_flow_create_rss_rule (dev, act, flow); +else + ret =hns3_flow_create_fdir_rule (dev, pattern, actions, + error, flow); +if (ret ==0 )return flow; - } -rte_free (fdir_rule_ptr); -err_fdir: -if (fdir_rule.flags &HNS3_RULE_FLAG_COUNTER ) -hns3_counter_release (dev, fdir_rule.act_cnt.id); -err:rte_flow_error_set (error, -ret,RTE_FLOW_ERROR_TYPE_HANDLE ,NULL ,"Failed to create flow" ); -out:TAILQ_REMOVE (&hw->flow_list, flow_node, entries);rte_free (flow_node);rte_free (flow); +return NULL ; }
Signature · 1 line
2.33.0
PATCH 8/15 net/hns3: remove unused variables
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Remove unused variables.
--- drivers/net/hns3/hns3_dcb.c | 12 +----------- drivers/net/hns3/hns3_ethdev.c | 3 --- drivers/net/hns3/hns3_ethdev.h | 2 -- 3 files changed, 1 insertion(+), 16 deletions(-)
drivers/net/hns3/hns3_dcb.c +1 -11
@@ -750,19 +750,9 @@ static int hns3_dcb_update_tc_queue_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, uint16_t nb_tx_q) { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -struct hns3_pf *pf = &hns->pf; -int ret; - hw->num_tc = hw->dcb_info.num_tc; - ret =hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q); -if (ret) -return ret; -if (!hns->is_vf) -memcpy (pf->prio_tc, hw->dcb_info.prio_tc,HNS3_MAX_USER_PRIO ); - -return 0 ; +return hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q); }int
drivers/net/hns3/hns3_ethdev.c +0 -3
@@ -2552,9 +2552,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc) cfg->media_type =hns3_get_field (rte_le_to_cpu_32 (req->param[1 ]),HNS3_CFG_MEDIA_TP_M ,HNS3_CFG_MEDIA_TP_S ); - cfg->rx_buf_len =hns3_get_field (rte_le_to_cpu_32 (req->param[1 ]), -HNS3_CFG_RX_BUF_LEN_M , -HNS3_CFG_RX_BUF_LEN_S );/* get mac address */ mac_addr_tmp =rte_le_to_cpu_32 (req->param[2 ]); mac_addr_tmp_high = hns3_get_field(rte_le_to_cpu_32(req->param[3]),
drivers/net/hns3/hns3_ethdev.h +0 -2
@@ -156,7 +156,6 @@ struct hns3_tc_queue_info {struct hns3_cfg {uint8_t tc_num;uint16_t tqp_desc_num; -uint16_t rx_buf_len;uint16_t rss_size_max;uint8_t phy_addr;uint8_t media_type;
@@ -804,7 +803,6 @@ struct hns3_pf {uint8_t tc_max;/* max number of tc driver supported */ uint8_t local_max_tc;/* max number of local tc */ uint8_t pfc_max; -uint8_t prio_tc[HNS3_MAX_USER_PRIO ];/* TC indexed by prio */ uint16_t pause_time;bool support_fc_autoneg;/* support FC autonegotiate */ bool support_multi_tc_pause;
Signature · 1 line
2.33.0
PATCH 9/15 net/hns3: remove the number of queue descriptors
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Application can specify the number of Rx/Tx queue descriptors in DPDK. So driver does not obtain the default value from firmware and PF.
--- drivers/net/hns3/hns3_ethdev.c | 5 ----- drivers/net/hns3/hns3_ethdev.h | 3 --- drivers/net/hns3/hns3_ethdev_vf.c | 26 -------------------------- 3 files changed, 34 deletions(-)
drivers/net/hns3/hns3_ethdev.c +0 -5
@@ -2542,9 +2542,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc)/* get the configuration */ cfg->tc_num =hns3_get_field (rte_le_to_cpu_32 (req->param[0 ]),HNS3_CFG_TC_NUM_M ,HNS3_CFG_TC_NUM_S ); - cfg->tqp_desc_num =hns3_get_field (rte_le_to_cpu_32 (req->param[0 ]), -HNS3_CFG_TQP_DESC_N_M , -HNS3_CFG_TQP_DESC_N_S ); cfg->phy_addr = hns3_get_field(rte_le_to_cpu_32(req->param[1]), HNS3_CFG_PHY_ADDR_M,
@@ -2855,8 +2852,6 @@ hns3_get_board_configuration(struct hns3_hw *hw) hw->rss_dis_flag = false;memcpy (hw->mac.mac_addr, cfg.mac_addr,RTE_ETHER_ADDR_LEN ); hw->mac.phy_addr = cfg.phy_addr; - hw->num_tx_desc = cfg.tqp_desc_num; - hw->num_rx_desc = cfg.tqp_desc_num; hw->dcb_info.num_pg =1 ; hw->dcb_info.hw_pfc_map =0 ;
drivers/net/hns3/hns3_ethdev.h +0 -3
@@ -155,7 +155,6 @@ struct hns3_tc_queue_info {struct hns3_cfg {uint8_t tc_num; -uint16_t tqp_desc_num;uint16_t rss_size_max;uint8_t phy_addr;uint8_t media_type;
@@ -512,8 +511,6 @@ struct hns3_hw {uint16_t intr_tqps_num;/* num queue pairs mapping interrupt */ uint16_t rss_size_max;/* HW defined max RSS task queue */ uint16_t rx_buf_len;/* hold min hardware rx buf len */ -uint16_t num_tx_desc;/* desc num of per tx queue */ -uint16_t num_rx_desc;/* desc num of per rx queue */ uint32_t mng_entry_num;/* number of manager table entry */ uint32_t mac_entry_num;/* number of mac-vlan table entry */
drivers/net/hns3/hns3_ethdev_vf.c +0 -26
@@ -941,27 +941,6 @@ hns3vf_get_queue_info(struct hns3_hw *hw)return hns3vf_check_tqp_info (hw); } -static int -hns3vf_get_queue_depth (struct hns3_hw *hw) -{ -#define HNS3VF_TQPS_DEPTH_INFO_LEN 4 -uint8_t resp_msg[HNS3VF_TQPS_DEPTH_INFO_LEN ]; -int ret; - - ret =hns3_send_mbx_msg (hw,HNS3_MBX_GET_QDEPTH ,0 ,NULL ,0 , true, - resp_msg,HNS3VF_TQPS_DEPTH_INFO_LEN ); -if (ret) { -PMD_INIT_LOG (ERR ,"Failed to get tqp depth info from PF: %d" , - ret); -return ret; - } - -memcpy (&hw->num_tx_desc, &resp_msg[0 ],sizeof (uint16_t )); -memcpy (&hw->num_rx_desc, &resp_msg[2 ],sizeof (uint16_t )); - -return 0 ; -} -static void hns3vf_update_caps (struct hns3_hw *hw,uint32_t caps) {
@@ -1052,11 +1031,6 @@ hns3vf_get_configuration(struct hns3_hw *hw)if (ret)return ret; -/* Get queue depth info from PF */ - ret =hns3vf_get_queue_depth (hw); -if (ret) -return ret; -/* Get user defined VF MAC addr from PF */ ret =hns3vf_get_host_mac_addr (hw);if (ret)
Signature · 1 line
2.33.0
PATCH 10/15 net/hns3: remove the printing of memory addresses
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Remove the printing of memory addresses.
--- drivers/net/hns3/hns3_cmd.c | 12 ++++-------- drivers/net/hns3/hns3_rxtx.c | 6 ------ 2 files changed, 4 insertions(+), 14 deletions(-)
drivers/net/hns3/hns3_cmd.c +4 -8
@@ -60,18 +60,14 @@ hns3_allocate_dma_mem(struct hns3_hw *hw, struct hns3_cmq_ring *ring, ring->desc = mz->addr; ring->desc_dma_addr = mz->iova; ring->zone = (const void *)mz; -hns3_dbg (hw,"memzone %s allocated with physical address: %" PRIu64, - mz->name, ring->desc_dma_addr); +hns3_dbg (hw,"cmd ring memzone name: %s" , mz->name);return 0 ; }static void -hns3_free_dma_mem (struct hns3_hw *hw,struct hns3_cmq_ring *ring) +hns3_free_dma_mem (struct hns3_cmq_ring *ring) { -hns3_dbg (hw,"memzone %s to be freed with physical address: %" PRIu64, - ((const struct rte_memzone *)ring->zone)->name, - ring->desc_dma_addr);rte_memzone_free ((const struct rte_memzone *)ring->zone); ring->buf_size =0 ; ring->desc =NULL ;
@@ -93,10 +89,10 @@ hns3_alloc_cmd_desc(struct hns3_hw *hw, struct hns3_cmq_ring *ring) }static void -hns3_free_cmd_desc (struct hns3_hw *hw,struct hns3_cmq_ring *ring) +hns3_free_cmd_desc(__rte_unused struct hns3_hw *hw, struct hns3_cmq_ring *ring) {if (ring->desc) -hns3_free_dma_mem (hw, ring); +hns3_free_dma_mem (ring); } static int
drivers/net/hns3/hns3_rxtx.c +0 -6
@@ -1382,9 +1382,6 @@ hns3_alloc_rxq_and_dma_zone(struct rte_eth_dev *dev, rxq->rx_ring = (struct hns3_desc *)rx_mz->addr; rxq->rx_ring_phys_addr = rx_mz->iova; -hns3_dbg (hw,"No.%u rx descriptors iova 0x%" PRIx64, q_info->idx, - rxq->rx_ring_phys_addr); -return rxq; }
@@ -1469,9 +1466,6 @@ hns3_alloc_txq_and_dma_zone(struct rte_eth_dev *dev, txq->tx_ring = (struct hns3_desc *)tx_mz->addr; txq->tx_ring_phys_addr = tx_mz->iova; -hns3_dbg (hw,"No.%u tx descriptors iova 0x%" PRIx64, q_info->idx, - txq->tx_ring_phys_addr); -/* Clear tx bd */ desc = txq->tx_ring;for (i =0 ; i < txq->nb_tx_desc; i++) {
Signature · 1 line
2.33.0
PATCH 11/15 net/hns3: extract a common interface to obtain revision ID
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
The code logic of obtaining the revision ID of PCI device is the same for PF and VF driver. This patch extracts a common interface to do it.
--- drivers/net/hns3/hns3_common.c | 22 ++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 2 ++ drivers/net/hns3/hns3_ethdev.c | 16 ++++------------ drivers/net/hns3/hns3_ethdev_vf.c | 21 ++++----------------- 4 files changed, 32 insertions(+), 29 deletions(-)
drivers/net/hns3/hns3_common.c +22 -0
@@ -815,3 +815,25 @@ hns3_restore_rx_interrupt(struct hns3_hw *hw)return 0 ; } + +int +hns3_get_pci_revision_id (struct hns3_hw *hw,uint8_t *revision_id) +{ +struct rte_pci_device *pci_dev; +struct rte_eth_dev *eth_dev; +uint8_t revision; +int ret; + + eth_dev = &rte_eth_devices[hw->data->port_id]; + pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + ret =rte_pci_read_config (pci_dev, &revision,HNS3_PCI_REVISION_ID_LEN , +HNS3_PCI_REVISION_ID ); +if (ret !=HNS3_PCI_REVISION_ID_LEN ) { +hns3_err (hw,"failed to read pci revision id, ret = %d" , ret); +return -EIO ; + } + + *revision_id = revision; + +return 0 ; +}
drivers/net/hns3/hns3_common.h +2 -0
@@ -59,4 +59,6 @@ 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); +int hns3_get_pci_revision_id (struct hns3_hw *hw,uint8_t *revision_id); +#endif /* _HNS3_COMMON_H_ */
drivers/net/hns3/hns3_ethdev.c +4 -12
@@ -5,7 +5,6 @@#include <rte_alarm.h> #include <rte_bus_pci.h> #include <ethdev_pci.h> -#include <rte_pci.h> #include "hns3_ethdev.h" #include "hns3_common.h"
@@ -2738,7 +2737,6 @@ hns3_get_capability(struct hns3_hw *hw)struct hns3_pf *pf = &hns->pf;struct rte_eth_dev *eth_dev;uint16_t device_id; -uint8_t revision;int ret; eth_dev = &rte_eth_devices[hw->data->port_id];
@@ -2751,17 +2749,11 @@ hns3_get_capability(struct hns3_hw *hw) device_id == HNS3_DEV_ID_200G_RDMA)hns3_set_bit (hw->capability,HNS3_DEV_SUPPORT_DCB_B ,1 ); -/* Get PCI revision id */ - ret =rte_pci_read_config (pci_dev, &revision,HNS3_PCI_REVISION_ID_LEN , -HNS3_PCI_REVISION_ID ); -if (ret !=HNS3_PCI_REVISION_ID_LEN ) { -PMD_INIT_LOG (ERR ,"failed to read pci revision id, ret = %d" , - ret); -return -EIO ; - } - hw->revision = revision; + ret =hns3_get_pci_revision_id (hw, &hw->revision); +if (ret) +return ret; -if (revision <PCI_REVISION_ID_HIP09_A ) { +if (hw->revision <PCI_REVISION_ID_HIP09_A ) {hns3_set_default_dev_specifications (hw); hw->intr.mapping_mode =HNS3_INTR_MAPPING_VEC_RSV_ONE ; hw->intr.gl_unit =HNS3_INTR_COALESCE_GL_UINT_2US ;
drivers/net/hns3/hns3_ethdev_vf.c +4 -17
@@ -6,7 +6,6 @@#include <rte_alarm.h> #include <ethdev_pci.h> #include <rte_io.h> -#include <rte_pci.h> #include <rte_vfio.h> #include "hns3_ethdev.h"
@@ -810,25 +809,13 @@ hns3vf_get_push_lsc_cap(struct hns3_hw *hw)static int hns3vf_get_capability (struct hns3_hw *hw) { -struct rte_pci_device *pci_dev; -struct rte_eth_dev *eth_dev; -uint8_t revision;int ret; - eth_dev = &rte_eth_devices[hw->data->port_id]; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); - -/* Get PCI revision id */ - ret =rte_pci_read_config (pci_dev, &revision,HNS3_PCI_REVISION_ID_LEN , -HNS3_PCI_REVISION_ID ); -if (ret !=HNS3_PCI_REVISION_ID_LEN ) { -PMD_INIT_LOG (ERR ,"failed to read pci revision id, ret = %d" , - ret); -return -EIO ; - } - hw->revision = revision; + ret =hns3_get_pci_revision_id (hw, &hw->revision); +if (ret) +return ret; -if (revision <PCI_REVISION_ID_HIP09_A ) { +if (hw->revision <PCI_REVISION_ID_HIP09_A ) {hns3vf_set_default_dev_specifications (hw); hw->intr.mapping_mode =HNS3_INTR_MAPPING_VEC_RSV_ONE ; hw->intr.gl_unit =HNS3_INTR_COALESCE_GL_UINT_2US ;
Signature · 1 line
2.33.0
PATCH 12/15 net/hns3: remove invalid encapsulation function
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch remove invalid encapsulation functions.
--- drivers/net/hns3/hns3_ethdev.c | 27 ++++++++------------------- drivers/net/hns3/hns3_ethdev_vf.c | 13 ++----------- 2 files changed, 10 insertions(+), 30 deletions(-)
drivers/net/hns3/hns3_ethdev.c +8 -19
@@ -593,22 +593,6 @@ hns3_set_vlan_rx_offload_cfg(struct hns3_adapter *hns,return ret; } -static void -hns3_update_rx_offload_cfg (struct hns3_adapter *hns, -struct hns3_rx_vtag_cfg *vcfg) -{ -struct hns3_pf *pf = &hns->pf; -memcpy (&pf->vtag_config.rx_vcfg, vcfg,sizeof (pf->vtag_config.rx_vcfg)); -} - -static void -hns3_update_tx_offload_cfg (struct hns3_adapter *hns, -struct hns3_tx_vtag_cfg *vcfg) -{ -struct hns3_pf *pf = &hns->pf; -memcpy (&pf->vtag_config.tx_vcfg, vcfg,sizeof (pf->vtag_config.tx_vcfg)); -} -static int hns3_en_hw_strip_rxvtag (struct hns3_adapter *hns,bool enable) {
@@ -638,7 +622,8 @@ hns3_en_hw_strip_rxvtag(struct hns3_adapter *hns, bool enable)return ret; } -hns3_update_rx_offload_cfg (hns, &rxvlan_cfg); +memcpy (&hns->pf.vtag_config.rx_vcfg, &rxvlan_cfg, +sizeof (struct hns3_rx_vtag_cfg ));return ret; }
@@ -836,7 +821,9 @@ hns3_vlan_txvlan_cfg(struct hns3_adapter *hns, uint16_t port_base_vlan_state,return ret; } -hns3_update_tx_offload_cfg (hns, &txvlan_cfg); +memcpy (&hns->pf.vtag_config.tx_vcfg, &txvlan_cfg, +sizeof (struct hns3_tx_vtag_cfg )); +return ret; }
@@ -962,7 +949,9 @@ hns3_en_pvid_strip(struct hns3_adapter *hns, int on)if (ret)return ret; -hns3_update_rx_offload_cfg (hns, &rx_vlan_cfg); +memcpy (&hns->pf.vtag_config.rx_vcfg, &rx_vlan_cfg, +sizeof (struct hns3_rx_vtag_cfg )); +return ret; }
drivers/net/hns3/hns3_ethdev_vf.c +2 -11
@@ -1026,15 +1026,6 @@ hns3vf_get_configuration(struct hns3_hw *hw)return hns3vf_get_port_base_vlan_filter_state (hw); } -static int -hns3vf_set_tc_queue_mapping (struct hns3_adapter *hns,uint16_t nb_rx_q, -uint16_t nb_tx_q) -{ -struct hns3_hw *hw = &hns->hw; - -return hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q); -} -static void hns3vf_request_link_info (struct hns3_hw *hw) {
@@ -1530,7 +1521,7 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) goto err_set_tc_queue; } - ret =hns3vf_set_tc_queue_mapping (hns, hw->tqps_num, hw->tqps_num); + ret =hns3_queue_to_tc_mapping (hw, hw->tqps_num, hw->tqps_num);if (ret) {PMD_INIT_LOG (ERR ,"failed to set tc info, ret = %d." , ret); goto err_set_tc_queue;
@@ -1739,7 +1730,7 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)uint16_t nb_tx_q = hw->data->nb_tx_queues;int ret; - ret =hns3vf_set_tc_queue_mapping (hns, nb_rx_q, nb_tx_q); + ret =hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q);if (ret)return ret;
Signature · 1 line
2.33.0
PATCH 13/15 net/hns3: delete strerror invoke
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch delete strerror invoke which was non-reentrant.
--- drivers/net/hns3/hns3_fdir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/hns3/hns3_fdir.c +1 -2
@@ -919,8 +919,7 @@ static int hns3_insert_fdir_filter(struct hns3_hw *hw, sig =rte_hash_crc (key,sizeof (*key),0 ); ret =rte_hash_add_key_with_hash (fdir_info->hash_handle, key, sig);if (ret <0 ) { -hns3_err (hw,"Hash table full? err:%d(%s)!" , ret, -strerror (-ret)); +hns3_err (hw,"Hash table full? err:%d!" , ret);return ret; }
Signature · 1 line
2.33.0
PATCH 14/15 net/hns3: rename function
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch rename hns3_parse_rss_key with hns3_adjust_rss_key to improve readability.
--- drivers/net/hns3/hns3_flow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_flow.c +2 -2
@@ -1405,7 +1405,7 @@ hns3_disable_rss(struct hns3_hw *hw) }static void -hns3_parse_rss_key (struct hns3_hw *hw,struct rte_flow_action_rss *rss_conf) +hns3_adjust_rss_key (struct hns3_hw *hw,struct rte_flow_action_rss *rss_conf) {if (rss_conf->key ==NULL || rss_conf->key_len <HNS3_RSS_KEY_SIZE ) {hns3_warn (hw,"Default RSS hash key to be set" );
@@ -1449,7 +1449,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)struct hns3_rss_tuple_cfg *tuple;int ret; -hns3_parse_rss_key (hw, rss_config); +hns3_adjust_rss_key (hw, rss_config); ret =hns3_parse_rss_algorithm (hw, &rss_config->func, &hw->rss_info.hash_algo);
Signature · 1 line
2.33.0
PATCH 15/15 net/hns3: support indirect counter action
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch support indirect counter action because the shared counter attribute has been deprecated in DPDK 21.11.
--- drivers/net/hns3/hns3_fdir.h | 1 + drivers/net/hns3/hns3_flow.c | 222 +++++++++++++++++++++++++++++++++-- drivers/net/hns3/hns3_flow.h | 11 +- 3 files changed, 224 insertions(+), 10 deletions(-)
drivers/net/hns3/hns3_fdir.h +1 -0
@@ -125,6 +125,7 @@ struct hns3_fd_ad_data {#define HNS3_RULE_FLAG_FDID 0x1#define HNS3_RULE_FLAG_VF_ID 0x2#define HNS3_RULE_FLAG_COUNTER 0x4 +#define HNS3_RULE_FLAG_COUNTER_INDIR 0x8struct hns3_fdir_key_conf {struct hns3_fd_rule_tuples spec;
drivers/net/hns3/hns3_flow.c +213 -9
293 lines not on this page · raw message
drivers/net/hns3/hns3_flow.h +10 -1
@@ -9,7 +9,7 @@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 indirect:1 ;/* Indirect counter flag */ uint32_t ref_cnt:31 ;/* Reference counter. */ uint16_t id;/* Counter ID. */ uint64_t hits;/* Number of packets matched by the rule. */
@@ -33,6 +33,15 @@ struct hns3_flow_mem {struct rte_flow *flow; }; +enum { +HNS3_INDIRECT_ACTION_TYPE_COUNT =1 , +}; + +struct rte_flow_action_handle { +int indirect_type; +uint32_t counter_id; +}; +TAILQ_HEAD (hns3_rss_filter_list, hns3_rss_conf_ele);TAILQ_HEAD (hns3_flow_mem_list, hns3_flow_mem);
Signature · 1 line
2.33.0
Quoted 22 lines · Min Hu (Connor)
This patch contains 15 patches, which include fixing codecheck warning ,code refactor and indirect counter action support.
Chengwen Feng (4):
net/hns3: remove invalid encapsulation function net/hns3: delete strerror invoke net/hns3: rename function
net/hns3: support indirect counter actionHuisong Li (10):
net/hns3: remove unnecessary assignment
net/hns3: fix a misjudgment expression
net/hns3: extract a common API to initialize MAC addrs net/hns3: remove unnecessary black lines
net/hns3: extract a function to handle reset fail net/hns3: extract functions to create RSS and FDIR flow rule net/hns3: remove unused variables
net/hns3: remove the number of queue descriptors net/hns3: remove the printing of memory addresses net/hns3: extract a common interface to obtain revision ID
Quoted 3 lines
Jie Hai (1):
net/hns3: remove unnecessary 'inline'
Hi Connor,
Patch by patch build fails, first failing patch is 7/15. Can you please fix it with a new version?
Hi, Ferruh,
fixed in v2, thanks.
Quoted 32 lines · Ferruh Yigit
Quoted 22 lines · Min Hu (Connor)
This patch contains 15 patches, which include fixing codecheck warning ,code refactor and indirect counter action support.
Chengwen Feng (4):
net/hns3: remove invalid encapsulation function net/hns3: delete strerror invoke net/hns3: rename function
net/hns3: support indirect counter actionHuisong Li (10):
net/hns3: remove unnecessary assignment
net/hns3: fix a misjudgment expression
net/hns3: extract a common API to initialize MAC addrs net/hns3: remove unnecessary black lines
net/hns3: extract a function to handle reset fail net/hns3: extract functions to create RSS and FDIR flow rule net/hns3: remove unused variables
net/hns3: remove the number of queue descriptors net/hns3: remove the printing of memory addresses net/hns3: extract a common interface to obtain revision IDQuoted 3 lines
Jie Hai (1):
net/hns3: remove unnecessary 'inline'Hi Connor,
Patch by patch build fails, first failing patch is 7/15. Can you please fix it with a new version?
.
v2 cover fix and feature for hns3 PMD
In reply to Min Hu (Connor)This patch contains 15 patches, which include fixing codecheck warning ,code refactor and indirect counter action support.
Chengwen Feng (4):
net/hns3: remove invalid encapsulation function
net/hns3: delete strerror invoke
net/hns3: rename function
net/hns3: support indirect counter action
Huisong Li (10):
net/hns3: remove unnecessary assignment
net/hns3: fix a misjudgment expression
net/hns3: extract a common API to initialize MAC addrs net/hns3: remove unnecessary black lines
net/hns3: extract a function to handle reset fail net/hns3: remove unused variables
net/hns3: remove the number of queue descriptors net/hns3: remove the printing of memory addresses net/hns3: extract a common interface to obtain revision ID net/hns3: extract functions to create RSS and FDIR flow rule
Jie Hai (1):
net/hns3: remove unnecessary 'inline'
V2:
* fix compiling errors.
drivers/net/hns3/hns3_cmd.c | 12 +- drivers/net/hns3/hns3_common.c | 76 ++++++ drivers/net/hns3/hns3_common.h | 3 + drivers/net/hns3/hns3_dcb.c | 12 +- drivers/net/hns3/hns3_ethdev.c | 85 ++----- drivers/net/hns3/hns3_ethdev.h | 5 - drivers/net/hns3/hns3_ethdev_vf.c | 93 +------ drivers/net/hns3/hns3_fdir.c | 3 +- drivers/net/hns3/hns3_fdir.h | 1 + drivers/net/hns3/hns3_flow.c | 399 ++++++++++++++++++++++++------ drivers/net/hns3/hns3_flow.h | 11 +- drivers/net/hns3/hns3_intr.c | 54 ++-- drivers/net/hns3/hns3_rxtx.c | 6 - drivers/net/hns3/hns3_rxtx.h | 2 - 14 files changed, 476 insertions(+), 286 deletions(-)
Signature · 1 line
2.33.0
PATCH v2 1/15 net/hns3: remove unnecessary assignment
From: Huisong Li <[email protected]>
Remove unnecessary assignment.
--- drivers/net/hns3/hns3_flow.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/hns3/hns3_flow.c +0 -1
@@ -1890,7 +1890,6 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, } }rte_free (flow); - flow =NULL ;return 0 ; }
Signature · 1 line
2.33.0
PATCH v2 2/15 net/hns3: fix a misjudgment expression
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
The enum type variables cannot be used as bool variables. This patch fixes for "with->func" in hns3_action_rss_same().
--- drivers/net/hns3/hns3_flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_flow.c +2 -1
@@ -1251,7 +1251,8 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp,if (comp->func ==RTE_ETH_HASH_FUNCTION_MAX ) func_is_same = false;else - func_is_same = with->func ? (comp->func == with->func) : true; + func_is_same = (with->func !=RTE_ETH_HASH_FUNCTION_DEFAULT ) ? + (comp->func == with->func) : true; return (func_is_same && comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) &&
Signature · 1 line
2.33.0
PATCH v2 3/15 net/hns3: extract a common API to initialize MAC addrs
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
The code logic to initialize "data->mac_addrs" for PF and VF is similar. This patch extracts a common API to initialize it to improve code maintainabiliy.
--- drivers/net/hns3/hns3_common.c | 54 +++++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 1 + drivers/net/hns3/hns3_ethdev.c | 31 +++--------------- drivers/net/hns3/hns3_ethdev_vf.c | 33 +++---------------- 4 files changed, 63 insertions(+), 56 deletions(-)
drivers/net/hns3/hns3_common.c +54 -0
@@ -581,6 +581,60 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) } } +int +hns3_init_mac_addrs (struct rte_eth_dev *dev) +{ +struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct hns3_adapter *hns =HNS3_DEV_HW_TO_ADAPTER (hw); +const char *memory_name = hns->is_vf ?"hns3vf-mac" :"hns3-mac" ; +uint16_t mac_addrs_capa = hns->is_vf ?HNS3_VF_UC_MACADDR_NUM : +HNS3_UC_MACADDR_NUM ; +char mac_str[RTE_ETHER_ADDR_FMT_SIZE ]; +struct rte_ether_addr *eth_addr; + +/* Allocate memory for storing MAC addresses */ + dev->data->mac_addrs =rte_zmalloc (memory_name, +sizeof (struct rte_ether_addr ) * mac_addrs_capa, +0 ); +if (dev->data->mac_addrs ==NULL ) { +hns3_err (hw,"failed to allocate %zx bytes needed to store MAC addresses" , +sizeof (struct rte_ether_addr ) * mac_addrs_capa); +return -ENOMEM ; + } + + eth_addr = (struct rte_ether_addr *)hw->mac.mac_addr; +if (!hns->is_vf) { +if (!rte_is_valid_assigned_ether_addr (eth_addr)) { +rte_eth_random_addr (hw->mac.mac_addr); +hns3_ether_format_addr (mac_str,RTE_ETHER_ADDR_FMT_SIZE , + (struct rte_ether_addr *)hw->mac.mac_addr); +hns3_warn (hw,"default mac_addr from firmware is an invalid " +"unicast address, using random MAC address %s" , + mac_str); + } + }else { +/* +* The hns3 PF ethdev driver in kernel support setting VF MAC +* address on the host by "ip link set ..." command. To avoid +* some incorrect scenes, for example, hns3 VF PMD driver fails +* to receive and send packets after user configure the MAC +* address by using the "ip link set ..." command, hns3 VF PMD +* driver keep the same MAC address strategy as the hns3 kernel +* ethdev driver in the initialization. If user configure a MAC +* address by the ip command for VF device, then hns3 VF PMD +* driver will start with it, otherwise start with a random MAC +* address in the initialization. +*/ +if (rte_is_zero_ether_addr (eth_addr)) +rte_eth_random_addr (hw->mac.mac_addr); + } + +rte_ether_addr_copy ((struct rte_ether_addr *)hw->mac.mac_addr, + &dev->data->mac_addrs[0 ]); + +return 0 ; +} +int hns3_init_ring_with_vector (struct hns3_hw *hw) {
drivers/net/hns3/hns3_common.h +1 -0
@@ -52,6 +52,7 @@ int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, uint32_t nb_mc_addr);void hns3_ether_format_addr (char *buf,uint16_t size,const struct rte_ether_addr *ether_addr); +int hns3_init_mac_addrs (struct rte_eth_dev *dev);int hns3_init_ring_with_vector (struct hns3_hw *hw);int hns3_map_rx_interrupt (struct rte_eth_dev *dev);
drivers/net/hns3/hns3_ethdev.c +4 -27
@@ -6623,8 +6623,6 @@ static int hns3_dev_init(struct rte_eth_dev *eth_dev) {struct hns3_adapter *hns = eth_dev->data->dev_private; -char mac_str[RTE_ETHER_ADDR_FMT_SIZE ]; -struct rte_ether_addr *eth_addr;struct hns3_hw *hw = &hns->hw;int ret;
@@ -6667,30 +6665,9 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) goto err_init_pf; } -/* Allocate memory for storing MAC addresses */ - eth_dev->data->mac_addrs =rte_zmalloc ("hns3-mac" , -sizeof (struct rte_ether_addr ) * -HNS3_UC_MACADDR_NUM ,0 ); -if (eth_dev->data->mac_addrs ==NULL ) { -PMD_INIT_LOG (ERR ,"Failed to allocate %zx bytes needed " -"to store MAC addresses" , -sizeof (struct rte_ether_addr ) * -HNS3_UC_MACADDR_NUM ); - ret = -ENOMEM ; - goto err_rte_zmalloc; - } - - eth_addr = (struct rte_ether_addr *)hw->mac.mac_addr; -if (!rte_is_valid_assigned_ether_addr (eth_addr)) { -rte_eth_random_addr (hw->mac.mac_addr); -hns3_ether_format_addr (mac_str,RTE_ETHER_ADDR_FMT_SIZE , - (struct rte_ether_addr *)hw->mac.mac_addr); -hns3_warn (hw,"default mac_addr from firmware is an invalid " -"unicast address, using random MAC address %s" , - mac_str); - } -rte_ether_addr_copy ((struct rte_ether_addr *)hw->mac.mac_addr, - ð_dev->data->mac_addrs[0 ]); + ret =hns3_init_mac_addrs (eth_dev); +if (ret !=0 ) + goto err_init_mac_addrs; hw->adapter_state =HNS3_NIC_INITIALIZED ;
@@ -6706,7 +6683,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev)hns3_info (hw,"hns3 dev initialization successful!" );return 0 ; -err_rte_zmalloc: +err_init_mac_addrs:hns3_uninit_pf (eth_dev); err_init_pf:
drivers/net/hns3/hns3_ethdev_vf.c +4 -29
@@ -2400,34 +2400,9 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) goto err_init_vf; } -/* Allocate memory for storing MAC addresses */ - eth_dev->data->mac_addrs =rte_zmalloc ("hns3vf-mac" , -sizeof (struct rte_ether_addr ) * -HNS3_VF_UC_MACADDR_NUM ,0 ); -if (eth_dev->data->mac_addrs ==NULL ) { -PMD_INIT_LOG (ERR ,"Failed to allocate %zx bytes needed " -"to store MAC addresses" , -sizeof (struct rte_ether_addr ) * -HNS3_VF_UC_MACADDR_NUM ); - ret = -ENOMEM ; - goto err_rte_zmalloc; - } - -/* -* The hns3 PF ethdev driver in kernel support setting VF MAC address -* on the host by "ip link set ..." command. To avoid some incorrect -* scenes, for example, hns3 VF PMD fails to receive and send -* packets after user configure the MAC address by using the -* "ip link set ..." command, hns3 VF PMD keep the same MAC -* address strategy as the hns3 kernel ethdev driver in the -* initialization. If user configure a MAC address by the ip command -* for VF device, then hns3 VF PMD will start with it, otherwise -* start with a random MAC address in the initialization. -*/ -if (rte_is_zero_ether_addr ((struct rte_ether_addr *)hw->mac.mac_addr)) -rte_eth_random_addr (hw->mac.mac_addr); -rte_ether_addr_copy ((struct rte_ether_addr *)hw->mac.mac_addr, - ð_dev->data->mac_addrs[0 ]); + ret =hns3_init_mac_addrs (eth_dev); +if (ret !=0 ) + goto err_init_mac_addrs; hw->adapter_state =HNS3_NIC_INITIALIZED ;
@@ -2443,7 +2418,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) eth_dev);return 0 ; -err_rte_zmalloc: +err_init_mac_addrs:hns3vf_uninit_vf (eth_dev); err_init_vf:
Signature · 1 line
2.33.0
PATCH v2 4/15 net/hns3: remove unnecessary 'inline'
In reply to Min Hu (Connor)From: Jie Hai <[email protected]>
This function is a control-plane interface and does not need to use inline.
--- drivers/net/hns3/hns3_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hns3/hns3_ethdev.c +1 -1
@@ -4859,7 +4859,7 @@ hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds)return 0 ; } -static inline uint32_t +static uint32_t hns3_get_link_speed (uint32_t link_speeds) {uint32_t speed =RTE_ETH_SPEED_NUM_NONE ;
Signature · 1 line
2.33.0
PATCH v2 5/15 net/hns3: remove unnecessary black lines
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Remove unnecessary black lines.
--- drivers/net/hns3/hns3_ethdev.c | 1 - drivers/net/hns3/hns3_rxtx.h | 2 -- 2 files changed, 3 deletions(-)
drivers/net/hns3/hns3_ethdev.c +0 -1
@@ -6301,7 +6301,6 @@ hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode)struct hns3_adapter *hns = dev->data->dev_private;struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (hns);struct hns3_pf *pf = &hns->pf; -struct rte_eth_fec_capa fec_capa[FEC_CAPA_NUM ];uint32_t cur_capa;uint32_t num =FEC_CAPA_NUM ;
drivers/net/hns3/hns3_rxtx.h +0 -2
@@ -344,7 +344,6 @@ struct hns3_rx_queue {struct rte_mbuf fake_mbuf;/* fake mbuf used with vector rx */ -/* * The following fields are not accessed in the I/O path, so they are * placed at the end.
@@ -518,7 +517,6 @@ struct hns3_tx_queue {struct hns3_tx_basic_stats basic_stats;struct hns3_tx_dfx_stats dfx_stats; -/* * The following fields are not accessed in the I/O path, so they are * placed at the end.
Signature · 1 line
2.33.0
PATCH v2 6/15 net/hns3: extract a function to handle reset fail
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Extract a function to handle reset fail for clearer code logic.
--- drivers/net/hns3/hns3_intr.c | 54 +++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 22 deletions(-)
drivers/net/hns3/hns3_intr.c +32 -22
@@ -2770,6 +2770,37 @@ hns3_reset_post(struct hns3_adapter *hns)return -EIO ; } +static void +hns3_reset_fail_handle (struct hns3_adapter *hns) +{ +struct hns3_hw *hw = &hns->hw; +struct timeval tv_delta; +struct timeval tv; + +hns3_clear_reset_level (hw, &hw->reset.pending); +if (hns3_reset_err_handle (hns)) { + hw->reset.stage =RESET_STAGE_PREWAIT ; +hns3_schedule_reset (hns); +return ; + } + +rte_spinlock_lock (&hw->lock); +if (hw->reset.mbuf_deferred_free) { +hns3_dev_release_mbufs (hns); + hw->reset.mbuf_deferred_free = false; + } +rte_spinlock_unlock (&hw->lock); +__atomic_store_n (&hns->hw.reset.resetting,0 , __ATOMIC_RELAXED); + hw->reset.stage =RESET_STAGE_NONE ; +hns3_clock_gettime (&tv); +timersub (&tv, &hw->reset.start_time, &tv_delta); +hns3_warn (hw,"%s reset fail delta %" PRIu64" ms time=%ld.%.6ld" , + reset_string[hw->reset.level], +hns3_clock_calctime_ms (&tv_delta), + tv.tv_sec, tv.tv_usec); + hw->reset.level =HNS3_NONE_RESET ; +} +/* * There are three scenarios as follows: * When the reset is not in progress, the reset process starts.
@@ -2784,7 +2815,6 @@ int hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) { struct hns3_hw *hw = &hns->hw; -struct timeval tv_delta;struct timeval tv;int ret;
@@ -2843,27 +2873,7 @@ hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level)if (ret == -EAGAIN )return ret; err: -hns3_clear_reset_level (hw, &hw->reset.pending); -if (hns3_reset_err_handle (hns)) { - hw->reset.stage =RESET_STAGE_PREWAIT ; -hns3_schedule_reset (hns); - }else { -rte_spinlock_lock (&hw->lock); -if (hw->reset.mbuf_deferred_free) { -hns3_dev_release_mbufs (hns); - hw->reset.mbuf_deferred_free = false; - } -rte_spinlock_unlock (&hw->lock); -__atomic_store_n (&hns->hw.reset.resetting,0 , __ATOMIC_RELAXED); - hw->reset.stage =RESET_STAGE_NONE ; -hns3_clock_gettime (&tv); -timersub (&tv, &hw->reset.start_time, &tv_delta); -hns3_warn (hw,"%s reset fail delta %" PRIu64" ms time=%ld.%.6ld" , - reset_string[hw->reset.level], -hns3_clock_calctime_ms (&tv_delta), - tv.tv_sec, tv.tv_usec); - hw->reset.level =HNS3_NONE_RESET ; - } +hns3_reset_fail_handle (hns);return -EIO ; }
Signature · 1 line
2.33.0
PATCH v2 7/15 net/hns3: remove unused variables
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Remove unused variables.
--- drivers/net/hns3/hns3_dcb.c | 12 +----------- drivers/net/hns3/hns3_ethdev.c | 3 --- drivers/net/hns3/hns3_ethdev.h | 2 -- 3 files changed, 1 insertion(+), 16 deletions(-)
drivers/net/hns3/hns3_dcb.c +1 -11
@@ -750,19 +750,9 @@ static int hns3_dcb_update_tc_queue_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, uint16_t nb_tx_q) { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -struct hns3_pf *pf = &hns->pf; -int ret; - hw->num_tc = hw->dcb_info.num_tc; - ret =hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q); -if (ret) -return ret; -if (!hns->is_vf) -memcpy (pf->prio_tc, hw->dcb_info.prio_tc,HNS3_MAX_USER_PRIO ); - -return 0 ; +return hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q); }int
drivers/net/hns3/hns3_ethdev.c +0 -3
@@ -2552,9 +2552,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc) cfg->media_type =hns3_get_field (rte_le_to_cpu_32 (req->param[1 ]),HNS3_CFG_MEDIA_TP_M ,HNS3_CFG_MEDIA_TP_S ); - cfg->rx_buf_len =hns3_get_field (rte_le_to_cpu_32 (req->param[1 ]), -HNS3_CFG_RX_BUF_LEN_M , -HNS3_CFG_RX_BUF_LEN_S );/* get mac address */ mac_addr_tmp =rte_le_to_cpu_32 (req->param[2 ]); mac_addr_tmp_high = hns3_get_field(rte_le_to_cpu_32(req->param[3]),
drivers/net/hns3/hns3_ethdev.h +0 -2
@@ -156,7 +156,6 @@ struct hns3_tc_queue_info {struct hns3_cfg {uint8_t tc_num;uint16_t tqp_desc_num; -uint16_t rx_buf_len;uint16_t rss_size_max;uint8_t phy_addr;uint8_t media_type;
@@ -804,7 +803,6 @@ struct hns3_pf {uint8_t tc_max;/* max number of tc driver supported */ uint8_t local_max_tc;/* max number of local tc */ uint8_t pfc_max; -uint8_t prio_tc[HNS3_MAX_USER_PRIO ];/* TC indexed by prio */ uint16_t pause_time;bool support_fc_autoneg;/* support FC autonegotiate */ bool support_multi_tc_pause;
Signature · 1 line
2.33.0
PATCH v2 8/15 net/hns3: remove the number of queue descriptors
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Application can specify the number of Rx/Tx queue descriptors in DPDK. So driver does not obtain the default value from firmware and PF.
--- drivers/net/hns3/hns3_ethdev.c | 5 ----- drivers/net/hns3/hns3_ethdev.h | 3 --- drivers/net/hns3/hns3_ethdev_vf.c | 26 -------------------------- 3 files changed, 34 deletions(-)
drivers/net/hns3/hns3_ethdev.c +0 -5
@@ -2542,9 +2542,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc)/* get the configuration */ cfg->tc_num =hns3_get_field (rte_le_to_cpu_32 (req->param[0 ]),HNS3_CFG_TC_NUM_M ,HNS3_CFG_TC_NUM_S ); - cfg->tqp_desc_num =hns3_get_field (rte_le_to_cpu_32 (req->param[0 ]), -HNS3_CFG_TQP_DESC_N_M , -HNS3_CFG_TQP_DESC_N_S ); cfg->phy_addr = hns3_get_field(rte_le_to_cpu_32(req->param[1]), HNS3_CFG_PHY_ADDR_M,
@@ -2855,8 +2852,6 @@ hns3_get_board_configuration(struct hns3_hw *hw) hw->rss_dis_flag = false;memcpy (hw->mac.mac_addr, cfg.mac_addr,RTE_ETHER_ADDR_LEN ); hw->mac.phy_addr = cfg.phy_addr; - hw->num_tx_desc = cfg.tqp_desc_num; - hw->num_rx_desc = cfg.tqp_desc_num; hw->dcb_info.num_pg =1 ; hw->dcb_info.hw_pfc_map =0 ;
drivers/net/hns3/hns3_ethdev.h +0 -3
@@ -155,7 +155,6 @@ struct hns3_tc_queue_info {struct hns3_cfg {uint8_t tc_num; -uint16_t tqp_desc_num;uint16_t rss_size_max;uint8_t phy_addr;uint8_t media_type;
@@ -512,8 +511,6 @@ struct hns3_hw {uint16_t intr_tqps_num;/* num queue pairs mapping interrupt */ uint16_t rss_size_max;/* HW defined max RSS task queue */ uint16_t rx_buf_len;/* hold min hardware rx buf len */ -uint16_t num_tx_desc;/* desc num of per tx queue */ -uint16_t num_rx_desc;/* desc num of per rx queue */ uint32_t mng_entry_num;/* number of manager table entry */ uint32_t mac_entry_num;/* number of mac-vlan table entry */
drivers/net/hns3/hns3_ethdev_vf.c +0 -26
@@ -941,27 +941,6 @@ hns3vf_get_queue_info(struct hns3_hw *hw)return hns3vf_check_tqp_info (hw); } -static int -hns3vf_get_queue_depth (struct hns3_hw *hw) -{ -#define HNS3VF_TQPS_DEPTH_INFO_LEN 4 -uint8_t resp_msg[HNS3VF_TQPS_DEPTH_INFO_LEN ]; -int ret; - - ret =hns3_send_mbx_msg (hw,HNS3_MBX_GET_QDEPTH ,0 ,NULL ,0 , true, - resp_msg,HNS3VF_TQPS_DEPTH_INFO_LEN ); -if (ret) { -PMD_INIT_LOG (ERR ,"Failed to get tqp depth info from PF: %d" , - ret); -return ret; - } - -memcpy (&hw->num_tx_desc, &resp_msg[0 ],sizeof (uint16_t )); -memcpy (&hw->num_rx_desc, &resp_msg[2 ],sizeof (uint16_t )); - -return 0 ; -} -static void hns3vf_update_caps (struct hns3_hw *hw,uint32_t caps) {
@@ -1052,11 +1031,6 @@ hns3vf_get_configuration(struct hns3_hw *hw)if (ret)return ret; -/* Get queue depth info from PF */ - ret =hns3vf_get_queue_depth (hw); -if (ret) -return ret; -/* Get user defined VF MAC addr from PF */ ret =hns3vf_get_host_mac_addr (hw);if (ret)
Signature · 1 line
2.33.0
PATCH v2 9/15 net/hns3: remove the printing of memory addresses
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Remove the printing of memory addresses.
--- drivers/net/hns3/hns3_cmd.c | 12 ++++-------- drivers/net/hns3/hns3_rxtx.c | 6 ------ 2 files changed, 4 insertions(+), 14 deletions(-)
drivers/net/hns3/hns3_cmd.c +4 -8
@@ -60,18 +60,14 @@ hns3_allocate_dma_mem(struct hns3_hw *hw, struct hns3_cmq_ring *ring, ring->desc = mz->addr; ring->desc_dma_addr = mz->iova; ring->zone = (const void *)mz; -hns3_dbg (hw,"memzone %s allocated with physical address: %" PRIu64, - mz->name, ring->desc_dma_addr); +hns3_dbg (hw,"cmd ring memzone name: %s" , mz->name);return 0 ; }static void -hns3_free_dma_mem (struct hns3_hw *hw,struct hns3_cmq_ring *ring) +hns3_free_dma_mem (struct hns3_cmq_ring *ring) { -hns3_dbg (hw,"memzone %s to be freed with physical address: %" PRIu64, - ((const struct rte_memzone *)ring->zone)->name, - ring->desc_dma_addr);rte_memzone_free ((const struct rte_memzone *)ring->zone); ring->buf_size =0 ; ring->desc =NULL ;
@@ -93,10 +89,10 @@ hns3_alloc_cmd_desc(struct hns3_hw *hw, struct hns3_cmq_ring *ring) }static void -hns3_free_cmd_desc (struct hns3_hw *hw,struct hns3_cmq_ring *ring) +hns3_free_cmd_desc(__rte_unused struct hns3_hw *hw, struct hns3_cmq_ring *ring) {if (ring->desc) -hns3_free_dma_mem (hw, ring); +hns3_free_dma_mem (ring); } static int
drivers/net/hns3/hns3_rxtx.c +0 -6
@@ -1382,9 +1382,6 @@ hns3_alloc_rxq_and_dma_zone(struct rte_eth_dev *dev, rxq->rx_ring = (struct hns3_desc *)rx_mz->addr; rxq->rx_ring_phys_addr = rx_mz->iova; -hns3_dbg (hw,"No.%u rx descriptors iova 0x%" PRIx64, q_info->idx, - rxq->rx_ring_phys_addr); -return rxq; }
@@ -1469,9 +1466,6 @@ hns3_alloc_txq_and_dma_zone(struct rte_eth_dev *dev, txq->tx_ring = (struct hns3_desc *)tx_mz->addr; txq->tx_ring_phys_addr = tx_mz->iova; -hns3_dbg (hw,"No.%u tx descriptors iova 0x%" PRIx64, q_info->idx, - txq->tx_ring_phys_addr); -/* Clear tx bd */ desc = txq->tx_ring;for (i =0 ; i < txq->nb_tx_desc; i++) {
Signature · 1 line
2.33.0
PATCH v2 10/15 net/hns3: extract a common interface to obtain revision ID
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
The code logic of obtaining the revision ID of PCI device is the same for PF and VF driver. This patch extracts a common interface to do it.
--- drivers/net/hns3/hns3_common.c | 22 ++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 2 ++ drivers/net/hns3/hns3_ethdev.c | 16 ++++------------ drivers/net/hns3/hns3_ethdev_vf.c | 21 ++++----------------- 4 files changed, 32 insertions(+), 29 deletions(-)
drivers/net/hns3/hns3_common.c +22 -0
@@ -815,3 +815,25 @@ hns3_restore_rx_interrupt(struct hns3_hw *hw)return 0 ; } + +int +hns3_get_pci_revision_id (struct hns3_hw *hw,uint8_t *revision_id) +{ +struct rte_pci_device *pci_dev; +struct rte_eth_dev *eth_dev; +uint8_t revision; +int ret; + + eth_dev = &rte_eth_devices[hw->data->port_id]; + pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + ret =rte_pci_read_config (pci_dev, &revision,HNS3_PCI_REVISION_ID_LEN , +HNS3_PCI_REVISION_ID ); +if (ret !=HNS3_PCI_REVISION_ID_LEN ) { +hns3_err (hw,"failed to read pci revision id, ret = %d" , ret); +return -EIO ; + } + + *revision_id = revision; + +return 0 ; +}
drivers/net/hns3/hns3_common.h +2 -0
@@ -59,4 +59,6 @@ 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); +int hns3_get_pci_revision_id (struct hns3_hw *hw,uint8_t *revision_id); +#endif /* _HNS3_COMMON_H_ */
drivers/net/hns3/hns3_ethdev.c +4 -12
@@ -5,7 +5,6 @@#include <rte_alarm.h> #include <rte_bus_pci.h> #include <ethdev_pci.h> -#include <rte_pci.h> #include "hns3_ethdev.h" #include "hns3_common.h"
@@ -2738,7 +2737,6 @@ hns3_get_capability(struct hns3_hw *hw)struct hns3_pf *pf = &hns->pf;struct rte_eth_dev *eth_dev;uint16_t device_id; -uint8_t revision;int ret; eth_dev = &rte_eth_devices[hw->data->port_id];
@@ -2751,17 +2749,11 @@ hns3_get_capability(struct hns3_hw *hw) device_id == HNS3_DEV_ID_200G_RDMA)hns3_set_bit (hw->capability,HNS3_DEV_SUPPORT_DCB_B ,1 ); -/* Get PCI revision id */ - ret =rte_pci_read_config (pci_dev, &revision,HNS3_PCI_REVISION_ID_LEN , -HNS3_PCI_REVISION_ID ); -if (ret !=HNS3_PCI_REVISION_ID_LEN ) { -PMD_INIT_LOG (ERR ,"failed to read pci revision id, ret = %d" , - ret); -return -EIO ; - } - hw->revision = revision; + ret =hns3_get_pci_revision_id (hw, &hw->revision); +if (ret) +return ret; -if (revision <PCI_REVISION_ID_HIP09_A ) { +if (hw->revision <PCI_REVISION_ID_HIP09_A ) {hns3_set_default_dev_specifications (hw); hw->intr.mapping_mode =HNS3_INTR_MAPPING_VEC_RSV_ONE ; hw->intr.gl_unit =HNS3_INTR_COALESCE_GL_UINT_2US ;
drivers/net/hns3/hns3_ethdev_vf.c +4 -17
@@ -6,7 +6,6 @@#include <rte_alarm.h> #include <ethdev_pci.h> #include <rte_io.h> -#include <rte_pci.h> #include <rte_vfio.h> #include "hns3_ethdev.h"
@@ -810,25 +809,13 @@ hns3vf_get_push_lsc_cap(struct hns3_hw *hw)static int hns3vf_get_capability (struct hns3_hw *hw) { -struct rte_pci_device *pci_dev; -struct rte_eth_dev *eth_dev; -uint8_t revision;int ret; - eth_dev = &rte_eth_devices[hw->data->port_id]; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); - -/* Get PCI revision id */ - ret =rte_pci_read_config (pci_dev, &revision,HNS3_PCI_REVISION_ID_LEN , -HNS3_PCI_REVISION_ID ); -if (ret !=HNS3_PCI_REVISION_ID_LEN ) { -PMD_INIT_LOG (ERR ,"failed to read pci revision id, ret = %d" , - ret); -return -EIO ; - } - hw->revision = revision; + ret =hns3_get_pci_revision_id (hw, &hw->revision); +if (ret) +return ret; -if (revision <PCI_REVISION_ID_HIP09_A ) { +if (hw->revision <PCI_REVISION_ID_HIP09_A ) {hns3vf_set_default_dev_specifications (hw); hw->intr.mapping_mode =HNS3_INTR_MAPPING_VEC_RSV_ONE ; hw->intr.gl_unit =HNS3_INTR_COALESCE_GL_UINT_2US ;
Signature · 1 line
2.33.0
PATCH v2 11/15 net/hns3: remove invalid encapsulation function
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch remove invalid encapsulation functions.
--- drivers/net/hns3/hns3_ethdev.c | 27 ++++++++------------------- drivers/net/hns3/hns3_ethdev_vf.c | 13 ++----------- 2 files changed, 10 insertions(+), 30 deletions(-)
drivers/net/hns3/hns3_ethdev.c +8 -19
@@ -593,22 +593,6 @@ hns3_set_vlan_rx_offload_cfg(struct hns3_adapter *hns,return ret; } -static void -hns3_update_rx_offload_cfg (struct hns3_adapter *hns, -struct hns3_rx_vtag_cfg *vcfg) -{ -struct hns3_pf *pf = &hns->pf; -memcpy (&pf->vtag_config.rx_vcfg, vcfg,sizeof (pf->vtag_config.rx_vcfg)); -} - -static void -hns3_update_tx_offload_cfg (struct hns3_adapter *hns, -struct hns3_tx_vtag_cfg *vcfg) -{ -struct hns3_pf *pf = &hns->pf; -memcpy (&pf->vtag_config.tx_vcfg, vcfg,sizeof (pf->vtag_config.tx_vcfg)); -} -static int hns3_en_hw_strip_rxvtag (struct hns3_adapter *hns,bool enable) {
@@ -638,7 +622,8 @@ hns3_en_hw_strip_rxvtag(struct hns3_adapter *hns, bool enable)return ret; } -hns3_update_rx_offload_cfg (hns, &rxvlan_cfg); +memcpy (&hns->pf.vtag_config.rx_vcfg, &rxvlan_cfg, +sizeof (struct hns3_rx_vtag_cfg ));return ret; }
@@ -836,7 +821,9 @@ hns3_vlan_txvlan_cfg(struct hns3_adapter *hns, uint16_t port_base_vlan_state,return ret; } -hns3_update_tx_offload_cfg (hns, &txvlan_cfg); +memcpy (&hns->pf.vtag_config.tx_vcfg, &txvlan_cfg, +sizeof (struct hns3_tx_vtag_cfg )); +return ret; }
@@ -962,7 +949,9 @@ hns3_en_pvid_strip(struct hns3_adapter *hns, int on)if (ret)return ret; -hns3_update_rx_offload_cfg (hns, &rx_vlan_cfg); +memcpy (&hns->pf.vtag_config.rx_vcfg, &rx_vlan_cfg, +sizeof (struct hns3_rx_vtag_cfg )); +return ret; }
drivers/net/hns3/hns3_ethdev_vf.c +2 -11
@@ -1026,15 +1026,6 @@ hns3vf_get_configuration(struct hns3_hw *hw)return hns3vf_get_port_base_vlan_filter_state (hw); } -static int -hns3vf_set_tc_queue_mapping (struct hns3_adapter *hns,uint16_t nb_rx_q, -uint16_t nb_tx_q) -{ -struct hns3_hw *hw = &hns->hw; - -return hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q); -} -static void hns3vf_request_link_info (struct hns3_hw *hw) {
@@ -1530,7 +1521,7 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) goto err_set_tc_queue; } - ret =hns3vf_set_tc_queue_mapping (hns, hw->tqps_num, hw->tqps_num); + ret =hns3_queue_to_tc_mapping (hw, hw->tqps_num, hw->tqps_num);if (ret) {PMD_INIT_LOG (ERR ,"failed to set tc info, ret = %d." , ret); goto err_set_tc_queue;
@@ -1739,7 +1730,7 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)uint16_t nb_tx_q = hw->data->nb_tx_queues;int ret; - ret =hns3vf_set_tc_queue_mapping (hns, nb_rx_q, nb_tx_q); + ret =hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q);if (ret)return ret;
Signature · 1 line
2.33.0
Re: [PATCH v2 11/15] net/hns3: remove invalid encapsulation function
Quoted 3 lines · Min Hu (Connor)
From: Chengwen Feng <[email protected]>
This patch remove invalid encapsulation functions.
removed functions don't look like encapsulation functions, updating commit log while merging.
Quoted 104 lines
Signed-off-by Chengwen Feng <[email protected]>--- drivers/net/hns3/hns3_ethdev.c | 27 ++++++++------------------- drivers/net/hns3/hns3_ethdev_vf.c | 13 ++----------- 2 files changed, 10 insertions(+), 30 deletions(-)drivers/net/hns3/hns3_ethdev.c +8
-19@@ -593,22 +593,6 @@ hns3_set_vlan_rx_offload_cfg(struct hns3_adapter *hns,return ret; } -static void -hns3_update_rx_offload_cfg (struct hns3_adapter *hns, -struct hns3_rx_vtag_cfg *vcfg) -{ -struct hns3_pf *pf = &hns->pf; -memcpy (&pf->vtag_config.rx_vcfg, vcfg,sizeof (pf->vtag_config.rx_vcfg)); -} - -static void -hns3_update_tx_offload_cfg (struct hns3_adapter *hns, -struct hns3_tx_vtag_cfg *vcfg) -{ -struct hns3_pf *pf = &hns->pf; -memcpy (&pf->vtag_config.tx_vcfg, vcfg,sizeof (pf->vtag_config.tx_vcfg)); -} -static int hns3_en_hw_strip_rxvtag (struct hns3_adapter *hns,bool enable) {@@ -638,7 +622,8 @@ hns3_en_hw_strip_rxvtag(struct hns3_adapter *hns, bool enable)return ret; } -hns3_update_rx_offload_cfg (hns, &rxvlan_cfg); +memcpy (&hns->pf.vtag_config.rx_vcfg, &rxvlan_cfg, +sizeof (struct hns3_rx_vtag_cfg ));return ret; }@@ -836,7 +821,9 @@ hns3_vlan_txvlan_cfg(struct hns3_adapter *hns, uint16_t port_base_vlan_state,return ret; } -hns3_update_tx_offload_cfg (hns, &txvlan_cfg); +memcpy (&hns->pf.vtag_config.tx_vcfg, &txvlan_cfg, +sizeof (struct hns3_tx_vtag_cfg )); +return ret; }@@ -962,7 +949,9 @@ hns3_en_pvid_strip(struct hns3_adapter *hns, int on)if (ret)return ret; -hns3_update_rx_offload_cfg (hns, &rx_vlan_cfg); +memcpy (&hns->pf.vtag_config.rx_vcfg, &rx_vlan_cfg, +sizeof (struct hns3_rx_vtag_cfg )); +return ret; }drivers/net/hns3/hns3_ethdev_vf.c +2
-11@@ -1026,15 +1026,6 @@ hns3vf_get_configuration(struct hns3_hw *hw)return hns3vf_get_port_base_vlan_filter_state (hw); } -static int -hns3vf_set_tc_queue_mapping (struct hns3_adapter *hns,uint16_t nb_rx_q, -uint16_t nb_tx_q) -{ -struct hns3_hw *hw = &hns->hw; - -return hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q); -} -static void hns3vf_request_link_info (struct hns3_hw *hw) {@@ -1530,7 +1521,7 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) goto err_set_tc_queue; } - ret =hns3vf_set_tc_queue_mapping (hns, hw->tqps_num, hw->tqps_num); + ret =hns3_queue_to_tc_mapping (hw, hw->tqps_num, hw->tqps_num);if (ret) {PMD_INIT_LOG (ERR ,"failed to set tc info, ret = %d." , ret); goto err_set_tc_queue;@@ -1739,7 +1730,7 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)uint16_t nb_tx_q = hw->data->nb_tx_queues;int ret; - ret =hns3vf_set_tc_queue_mapping (hns, nb_rx_q, nb_tx_q); + ret =hns3_queue_to_tc_mapping (hw, nb_rx_q, nb_tx_q);if (ret)return ret;
PATCH v2 12/15 net/hns3: delete strerror invoke
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch delete strerror invoke which was non-reentrant.
--- drivers/net/hns3/hns3_fdir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/hns3/hns3_fdir.c +1 -2
@@ -919,8 +919,7 @@ static int hns3_insert_fdir_filter(struct hns3_hw *hw, sig =rte_hash_crc (key,sizeof (*key),0 ); ret =rte_hash_add_key_with_hash (fdir_info->hash_handle, key, sig);if (ret <0 ) { -hns3_err (hw,"Hash table full? err:%d(%s)!" , ret, -strerror (-ret)); +hns3_err (hw,"Hash table full? err:%d!" , ret);return ret; }
Signature · 1 line
2.33.0
PATCH v2 13/15 net/hns3: rename function
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch rename hns3_parse_rss_key with hns3_adjust_rss_key to improve readability.
--- drivers/net/hns3/hns3_flow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_flow.c +2 -2
@@ -1405,7 +1405,7 @@ hns3_disable_rss(struct hns3_hw *hw) }static void -hns3_parse_rss_key (struct hns3_hw *hw,struct rte_flow_action_rss *rss_conf) +hns3_adjust_rss_key (struct hns3_hw *hw,struct rte_flow_action_rss *rss_conf) {if (rss_conf->key ==NULL || rss_conf->key_len <HNS3_RSS_KEY_SIZE ) {hns3_warn (hw,"Default RSS hash key to be set" );
@@ -1449,7 +1449,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)struct hns3_rss_tuple_cfg *tuple;int ret; -hns3_parse_rss_key (hw, rss_config); +hns3_adjust_rss_key (hw, rss_config); ret =hns3_parse_rss_algorithm (hw, &rss_config->func, &hw->rss_info.hash_algo);
Signature · 1 line
2.33.0
PATCH v2 14/15 net/hns3: extract functions to create RSS and FDIR flow rule
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
Extract two functions to create the RSS and FDIR flow rule for clearer code logic.
--- drivers/net/hns3/hns3_flow.c | 173 +++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 67 deletions(-)
drivers/net/hns3/hns3_flow.c +106 -67
@@ -1706,6 +1706,105 @@ hns3_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,return hns3_parse_fdir_filter (dev, pattern, actions, &fdir_rule, error); } +static int +hns3_flow_create_rss_rule (struct rte_eth_dev *dev, +const struct rte_flow_action *act, +struct rte_flow *flow) +{ +struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct hns3_rss_conf_ele *rss_filter_ptr; +const struct hns3_rss_conf *rss_conf; +int ret; + + rss_filter_ptr =rte_zmalloc ("hns3 rss filter" , +sizeof (struct hns3_rss_conf_ele ),0 ); +if (rss_filter_ptr ==NULL ) { +hns3_err (hw,"failed to allocate hns3_rss_filter memory" ); +return -ENOMEM ; + } + +/* +* After all the preceding tasks are successfully configured, configure +* rules to the hardware to simplify the rollback of rules in the +* hardware. +*/ + rss_conf = (const struct hns3_rss_conf *)act->conf; + ret =hns3_flow_parse_rss (dev, rss_conf, true); +if (ret !=0 ) { +rte_free (rss_filter_ptr); +return ret; + } + +hns3_rss_conf_copy (&rss_filter_ptr->filter_info, &rss_conf->conf); + rss_filter_ptr->filter_info.valid = true; +TAILQ_INSERT_TAIL (&hw->flow_rss_list, rss_filter_ptr, entries); + flow->rule = rss_filter_ptr; + flow->filter_type =RTE_ETH_FILTER_HASH ; + +return 0 ; +} + +static int +hns3_flow_create_fdir_rule (struct rte_eth_dev *dev, +const struct rte_flow_item pattern[], +const struct rte_flow_action actions[], +struct rte_flow_error *error, +struct rte_flow *flow) +{ +struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct hns3_adapter *hns =HNS3_DEV_HW_TO_ADAPTER (hw); +struct hns3_fdir_rule_ele *fdir_rule_ptr; +struct hns3_fdir_rule fdir_rule; +int ret; + +memset (&fdir_rule,0 ,sizeof (struct hns3_fdir_rule )); + ret =hns3_parse_fdir_filter (dev, pattern, actions, &fdir_rule, error); +if (ret !=0 ) +return ret; + +if (fdir_rule.flags &HNS3_RULE_FLAG_COUNTER ) { + ret =hns3_counter_new (dev,0 , + fdir_rule.act_cnt.id, error); +if (ret !=0 ) +return ret; + + flow->counter_id = fdir_rule.act_cnt.id; + } + + fdir_rule_ptr =rte_zmalloc ("hns3 fdir rule" , +sizeof (struct hns3_fdir_rule_ele ),0 ); +if (fdir_rule_ptr ==NULL ) { +hns3_err (hw,"failed to allocate fdir_rule memory." ); + ret = -ENOMEM ; + goto err_malloc; + } + +/* +* After all the preceding tasks are successfully configured, configure +* rules to the hardware to simplify the rollback of rules in the +* hardware. +*/ + ret =hns3_fdir_filter_program (hns, &fdir_rule, false); +if (ret !=0 ) + goto err_fdir_filter; + +memcpy (&fdir_rule_ptr->fdir_conf, &fdir_rule, +sizeof (struct hns3_fdir_rule )); +TAILQ_INSERT_TAIL (&hw->flow_fdir_list, fdir_rule_ptr, entries); + flow->rule = fdir_rule_ptr; + flow->filter_type =RTE_ETH_FILTER_FDIR ; + +return 0 ; + +err_fdir_filter: +rte_free (fdir_rule_ptr); +err_malloc: +if (fdir_rule.flags &HNS3_RULE_FLAG_COUNTER ) +hns3_counter_release (dev, fdir_rule.act_cnt.id); + +return ret; +} +/* * Create or destroy a flow rule. * Theorically one rule can match more than one filters.
@@ -1720,13 +1819,9 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, {struct hns3_adapter *hns = dev->data->dev_private;struct hns3_hw *hw = &hns->hw; -const struct hns3_rss_conf *rss_conf; -struct hns3_fdir_rule_ele *fdir_rule_ptr; -struct hns3_rss_conf_ele *rss_filter_ptr;struct hns3_flow_mem *flow_node;const struct rte_flow_action *act;struct rte_flow *flow; -struct hns3_fdir_rule fdir_rule;int ret; ret =hns3_flow_validate (dev, attr, pattern, actions, error);
@@ -1752,76 +1847,20 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,TAILQ_INSERT_TAIL (&hw->flow_list, flow_node, entries); act =hns3_find_rss_general_action (pattern, actions); -if (act) { - rss_conf = act->conf; - - ret =hns3_flow_parse_rss (dev, rss_conf, true); -if (ret) - goto err; - - rss_filter_ptr =rte_zmalloc ("hns3 rss filter" , -sizeof (struct hns3_rss_conf_ele ), -0 ); -if (rss_filter_ptr ==NULL ) { -hns3_err (hw, -"Failed to allocate hns3_rss_filter memory" ); - ret = -ENOMEM ; - goto err; - } -hns3_rss_conf_copy (&rss_filter_ptr->filter_info, - &rss_conf->conf); - rss_filter_ptr->filter_info.valid = true; -TAILQ_INSERT_TAIL (&hw->flow_rss_list, rss_filter_ptr, entries); - - flow->rule = rss_filter_ptr; - flow->filter_type =RTE_ETH_FILTER_HASH ; -return flow; - } - -memset (&fdir_rule,0 ,sizeof (struct hns3_fdir_rule )); - ret =hns3_parse_fdir_filter (dev, pattern, actions, &fdir_rule, error); -if (ret) - goto out; - -if (fdir_rule.flags &HNS3_RULE_FLAG_COUNTER ) { - ret =hns3_counter_new (dev,0 , fdir_rule.act_cnt.id, error); -if (ret) - goto out; - - flow->counter_id = fdir_rule.act_cnt.id; - } - - fdir_rule_ptr =rte_zmalloc ("hns3 fdir rule" , -sizeof (struct hns3_fdir_rule_ele ), -0 ); -if (fdir_rule_ptr ==NULL ) { -hns3_err (hw,"failed to allocate fdir_rule memory." ); - ret = -ENOMEM ; - goto err_fdir; - } - - ret =hns3_fdir_filter_program (hns, &fdir_rule, false); -if (!ret) { -memcpy (&fdir_rule_ptr->fdir_conf, &fdir_rule, -sizeof (struct hns3_fdir_rule )); -TAILQ_INSERT_TAIL (&hw->flow_fdir_list, fdir_rule_ptr, entries); - flow->rule = fdir_rule_ptr; - flow->filter_type =RTE_ETH_FILTER_FDIR ; - +if (act) + ret =hns3_flow_create_rss_rule (dev, act, flow); +else + ret =hns3_flow_create_fdir_rule (dev, pattern, actions, + error, flow); +if (ret ==0 )return flow; - } -rte_free (fdir_rule_ptr); -err_fdir: -if (fdir_rule.flags &HNS3_RULE_FLAG_COUNTER ) -hns3_counter_release (dev, fdir_rule.act_cnt.id); -err:rte_flow_error_set (error, -ret,RTE_FLOW_ERROR_TYPE_HANDLE ,NULL ,"Failed to create flow" ); -out:TAILQ_REMOVE (&hw->flow_list, flow_node, entries);rte_free (flow_node);rte_free (flow); +return NULL ; }
Signature · 1 line
2.33.0
PATCH v2 15/15 net/hns3: support indirect counter action
In reply to Min Hu (Connor)From: Chengwen Feng <[email protected]>
This patch support indirect counter action because the shared counter attribute has been deprecated in DPDK 21.11.
--- drivers/net/hns3/hns3_fdir.h | 1 + drivers/net/hns3/hns3_flow.c | 222 +++++++++++++++++++++++++++++++++-- drivers/net/hns3/hns3_flow.h | 11 +- 3 files changed, 224 insertions(+), 10 deletions(-)
drivers/net/hns3/hns3_fdir.h +1 -0
@@ -125,6 +125,7 @@ struct hns3_fd_ad_data {#define HNS3_RULE_FLAG_FDID 0x1#define HNS3_RULE_FLAG_VF_ID 0x2#define HNS3_RULE_FLAG_COUNTER 0x4 +#define HNS3_RULE_FLAG_COUNTER_INDIR 0x8struct hns3_fdir_key_conf {struct hns3_fd_rule_tuples spec;
drivers/net/hns3/hns3_flow.c +213 -9
293 lines not on this page · raw message
drivers/net/hns3/hns3_flow.h +10 -1
@@ -9,7 +9,7 @@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 indirect:1 ;/* Indirect counter flag */ uint32_t ref_cnt:31 ;/* Reference counter. */ uint16_t id;/* Counter ID. */ uint64_t hits;/* Number of packets matched by the rule. */
@@ -33,6 +33,15 @@ struct hns3_flow_mem {struct rte_flow *flow; }; +enum { +HNS3_INDIRECT_ACTION_TYPE_COUNT =1 , +}; + +struct rte_flow_action_handle { +int indirect_type; +uint32_t counter_id; +}; +TAILQ_HEAD (hns3_rss_filter_list, hns3_rss_conf_ele);TAILQ_HEAD (hns3_flow_mem_list, hns3_flow_mem);
Signature · 1 line
2.33.0
Quoted 21 lines · Min Hu (Connor)
This patch contains 15 patches, which include fixing codecheck warning ,code refactor and indirect counter action support.
Chengwen Feng (4):
net/hns3: remove invalid encapsulation function net/hns3: delete strerror invoke net/hns3: rename function
net/hns3: support indirect counter actionHuisong Li (10):
net/hns3: remove unnecessary assignment
net/hns3: fix a misjudgment expression
net/hns3: extract a common API to initialize MAC addrs net/hns3: remove unnecessary black lines
net/hns3: extract a function to handle reset fail net/hns3: remove unused variables
net/hns3: remove the number of queue descriptors net/hns3: remove the printing of memory addresses net/hns3: extract a common interface to obtain revision ID net/hns3: extract functions to create RSS and FDIR flow rule
Quoted 3 lines
Jie Hai (1):
net/hns3: remove unnecessary 'inline'
Hi Connor,
There are some patches in the set that are sent by non maintainers, for them it requires maintainer ack.
Since you are sending the patch, it implies that you are OK with them but can you please add your explicit review/ack tags to them?
Ferruh Yigit
Acked-by Min Hu (Connor)Quoted 26 lines · Ferruh Yigit
Quoted 21 lines · Min Hu (Connor)
This patch contains 15 patches, which include fixing codecheck warning ,code refactor and indirect counter action support.
Chengwen Feng (4):
net/hns3: remove invalid encapsulation function net/hns3: delete strerror invoke net/hns3: rename function
net/hns3: support indirect counter actionHuisong Li (10):
net/hns3: remove unnecessary assignment
net/hns3: fix a misjudgment expression
net/hns3: extract a common API to initialize MAC addrs net/hns3: remove unnecessary black lines
net/hns3: extract a function to handle reset fail net/hns3: remove unused variables
net/hns3: remove the number of queue descriptors net/hns3: remove the printing of memory addresses net/hns3: extract a common interface to obtain revision ID net/hns3: extract functions to create RSS and FDIR flow ruleQuoted 3 lines
Jie Hai (1):
net/hns3: remove unnecessary 'inline'
Quoted 6 lines
Hi Connor,
There are some patches in the set that are sent by non maintainers, for them it requires maintainer ack.
Since you are sending the patch, it implies that you are OK with them but can you please add your explicit review/ack tags to them?
Implicit ack converted to an explicit one:
For series,
Series applied to dpdk-next-net/main, thanks.
Quoted 27 lines · Ferruh Yigit
Quoted 26 lines · Ferruh Yigit
Quoted 24 lines · Min Hu (Connor)
This patch contains 15 patches, which include fixing codecheck warning ,code refactor and indirect counter action support.
Chengwen Feng (4):
net/hns3: remove invalid encapsulation function net/hns3: delete strerror invoke net/hns3: rename function
net/hns3: support indirect counter actionHuisong Li (10):
net/hns3: remove unnecessary assignment
net/hns3: fix a misjudgment expression
net/hns3: extract a common API to initialize MAC addrs net/hns3: remove unnecessary black lines
net/hns3: extract a function to handle reset fail net/hns3: remove unused variables
net/hns3: remove the number of queue descriptors net/hns3: remove the printing of memory addresses net/hns3: extract a common interface to obtain revision ID net/hns3: extract functions to create RSS and FDIR flow ruleJie Hai (1):
net/hns3: remove unnecessary 'inline'
Quoted 6 lines
Quoted 6 lines
Hi Connor,
There are some patches in the set that are sent by non maintainers, for them it requires maintainer ack.
Since you are sending the patch, it implies that you are OK with them but can you please add your explicit review/ack tags to them?
Yes, I am OK with them.
Quoted 3 lines
Implicit ack converted to an explicit one:
Thanks Ferruh.
Quoted 6 lines
For series,
Acked-by Min Hu (Connor) <[email protected]>Series applied to dpdk-next-net/main, thanks.
.