diff --git a/0221-net-hns3-fix-log-about-indirection-table-size.patch b/0221-net-hns3-fix-log-about-indirection-table-size.patch new file mode 100644 index 0000000000000000000000000000000000000000..613aaf4e0abec50ee2a3e46bd6943216a14abb62 --- /dev/null +++ b/0221-net-hns3-fix-log-about-indirection-table-size.patch @@ -0,0 +1,53 @@ +From 55cc3ba793a896aeac7abb05a247b3b32d2adc75 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:51 +0800 +Subject: net/hns3: fix log about indirection table size + +[ upstream commit b55516a94246364f272db802f5dfb9aeb8d3a2f2 ] + +The error log about indirection table size during initialization phase +of PF and VF is unreasonable. + +In addition, VF driver should use error level to print this log. + +Fixes: 0fce2c46dc16 ("net/hns3: fix RSS indirection table size") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_ethdev.c | 2 +- + drivers/net/hns3/hns3_ethdev_vf.c | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 25f9c9fab1..ed273b5b69 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2679,7 +2679,7 @@ hns3_check_dev_specifications(struct hns3_hw *hw) + { + if (hw->rss_ind_tbl_size == 0 || + hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_err(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", ++ hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", + hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + return -EINVAL; + } +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index de44b07691..8a3a3cc657 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -718,8 +718,8 @@ hns3vf_check_dev_specifications(struct hns3_hw *hw) + { + if (hw->rss_ind_tbl_size == 0 || + hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_warn(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", +- hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); ++ hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", ++ hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + return -EINVAL; + } + +-- +2.23.0 + diff --git a/0222-net-hns3-extract-common-function-to-query-device.patch b/0222-net-hns3-extract-common-function-to-query-device.patch new file mode 100644 index 0000000000000000000000000000000000000000..99e65ff9c4db77b2b2c6eb6f380f5e585e6a6023 --- /dev/null +++ b/0222-net-hns3-extract-common-function-to-query-device.patch @@ -0,0 +1,291 @@ +From 6fb8330396b77c4a4acc73ff895a8d2b62a5ab93 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:52 +0800 +Subject: net/hns3: extract common function to query device + +[ upstream commit 52a4e960b49c526dd1ad7c1e91ebcfa664a38e6d ] + +Extract common function to query device specifications used by VF and +PF. + +Fixes: 9c740336f024 ("net/hns3: get device specifications from firmware") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_common.c | 75 +++++++++++++++++++++++++++++++ + drivers/net/hns3/hns3_common.h | 2 + + drivers/net/hns3/hns3_ethdev.c | 63 -------------------------- + drivers/net/hns3/hns3_ethdev_vf.c | 65 +-------------------------- + 4 files changed, 79 insertions(+), 126 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 2ebcf5695b..212b35d842 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -10,6 +10,7 @@ + #include "hns3_logs.h" + #include "hns3_regs.h" + #include "hns3_rxtx.h" ++#include "hns3_dcb.h" + #include "hns3_common.h" + + int +@@ -843,3 +844,77 @@ hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id) + + return 0; + } ++ ++void ++hns3_set_default_dev_specifications(struct hns3_hw *hw) ++{ ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ ++ hw->max_non_tso_bd_num = HNS3_MAX_NON_TSO_BD_PER_PKT; ++ hw->rss_ind_tbl_size = HNS3_RSS_IND_TBL_SIZE; ++ hw->rss_key_size = HNS3_RSS_KEY_SIZE; ++ hw->intr.int_ql_max = HNS3_INTR_QL_NONE; ++ ++ if (hns->is_vf) ++ return; ++ ++ hw->max_tm_rate = HNS3_ETHER_MAX_RATE; ++} ++ ++static void ++hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) ++{ ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ struct hns3_dev_specs_0_cmd *req0; ++ struct hns3_dev_specs_1_cmd *req1; ++ ++ req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; ++ req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; ++ ++ hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; ++ hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); ++ hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); ++ hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); ++ hw->min_tx_pkt_len = req1->min_tx_pkt_len; ++ ++ if (hns->is_vf) ++ return; ++ ++ hw->max_tm_rate = rte_le_to_cpu_32(req0->max_tm_rate); ++} ++ ++static int ++hns3_check_dev_specifications(struct hns3_hw *hw) ++{ ++ if (hw->rss_ind_tbl_size == 0 || ++ hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { ++ hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", ++ hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++int ++hns3_query_dev_specifications(struct hns3_hw *hw) ++{ ++ struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; ++ int ret; ++ int i; ++ ++ for (i = 0; i < HNS3_QUERY_DEV_SPECS_BD_NUM - 1; i++) { ++ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, ++ true); ++ desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); ++ } ++ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, true); ++ ++ ret = hns3_cmd_send(hw, desc, HNS3_QUERY_DEV_SPECS_BD_NUM); ++ if (ret) ++ return ret; ++ ++ hns3_parse_dev_specifications(hw, desc); ++ ++ return hns3_check_dev_specifications(hw); ++} +diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h +index 5aa001f0cc..8eaeda26e7 100644 +--- a/drivers/net/hns3/hns3_common.h ++++ b/drivers/net/hns3/hns3_common.h +@@ -60,5 +60,7 @@ 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); ++void hns3_set_default_dev_specifications(struct hns3_hw *hw); ++int hns3_query_dev_specifications(struct hns3_hw *hw); + + #endif /* HNS3_COMMON_H */ +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index ed273b5b69..8fa12d91bb 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2647,69 +2647,6 @@ hns3_parse_speed(int speed_cmd, uint32_t *speed) + return 0; + } + +-static void +-hns3_set_default_dev_specifications(struct hns3_hw *hw) +-{ +- hw->max_non_tso_bd_num = HNS3_MAX_NON_TSO_BD_PER_PKT; +- hw->rss_ind_tbl_size = HNS3_RSS_IND_TBL_SIZE; +- hw->rss_key_size = HNS3_RSS_KEY_SIZE; +- hw->max_tm_rate = HNS3_ETHER_MAX_RATE; +- hw->intr.int_ql_max = HNS3_INTR_QL_NONE; +-} +- +-static void +-hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) +-{ +- struct hns3_dev_specs_0_cmd *req0; +- struct hns3_dev_specs_1_cmd *req1; +- +- req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; +- req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; +- +- hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; +- hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); +- hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); +- hw->max_tm_rate = rte_le_to_cpu_32(req0->max_tm_rate); +- hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); +- hw->min_tx_pkt_len = req1->min_tx_pkt_len; +-} +- +-static int +-hns3_check_dev_specifications(struct hns3_hw *hw) +-{ +- if (hw->rss_ind_tbl_size == 0 || +- hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", +- hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); +- return -EINVAL; +- } +- +- return 0; +-} +- +-static int +-hns3_query_dev_specifications(struct hns3_hw *hw) +-{ +- struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; +- int ret; +- int i; +- +- for (i = 0; i < HNS3_QUERY_DEV_SPECS_BD_NUM - 1; i++) { +- hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, +- true); +- desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); +- } +- hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, true); +- +- ret = hns3_cmd_send(hw, desc, HNS3_QUERY_DEV_SPECS_BD_NUM); +- if (ret) +- return ret; +- +- hns3_parse_dev_specifications(hw, desc); +- +- return hns3_check_dev_specifications(hw); +-} +- + static int + hns3_get_capability(struct hns3_hw *hw) + { +diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c +index 8a3a3cc657..a3a1b71a63 100644 +--- a/drivers/net/hns3/hns3_ethdev_vf.c ++++ b/drivers/net/hns3/hns3_ethdev_vf.c +@@ -688,67 +688,6 @@ hns3vf_interrupt_handler(void *param) + hns3vf_enable_irq0(hw); + } + +-static void +-hns3vf_set_default_dev_specifications(struct hns3_hw *hw) +-{ +- hw->max_non_tso_bd_num = HNS3_MAX_NON_TSO_BD_PER_PKT; +- hw->rss_ind_tbl_size = HNS3_RSS_IND_TBL_SIZE; +- hw->rss_key_size = HNS3_RSS_KEY_SIZE; +- hw->intr.int_ql_max = HNS3_INTR_QL_NONE; +-} +- +-static void +-hns3vf_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) +-{ +- struct hns3_dev_specs_0_cmd *req0; +- struct hns3_dev_specs_1_cmd *req1; +- +- req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; +- req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; +- +- hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; +- hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); +- hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); +- hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); +- hw->min_tx_pkt_len = req1->min_tx_pkt_len; +-} +- +-static int +-hns3vf_check_dev_specifications(struct hns3_hw *hw) +-{ +- if (hw->rss_ind_tbl_size == 0 || +- hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { +- hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", +- hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); +- return -EINVAL; +- } +- +- return 0; +-} +- +-static int +-hns3vf_query_dev_specifications(struct hns3_hw *hw) +-{ +- struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; +- int ret; +- int i; +- +- for (i = 0; i < HNS3_QUERY_DEV_SPECS_BD_NUM - 1; i++) { +- hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, +- true); +- desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); +- } +- hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, true); +- +- ret = hns3_cmd_send(hw, desc, HNS3_QUERY_DEV_SPECS_BD_NUM); +- if (ret) +- return ret; +- +- hns3vf_parse_dev_specifications(hw, desc); +- +- return hns3vf_check_dev_specifications(hw); +-} +- + void + hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported) + { +@@ -826,7 +765,7 @@ hns3vf_get_capability(struct hns3_hw *hw) + return ret; + + if (hw->revision < PCI_REVISION_ID_HIP09_A) { +- hns3vf_set_default_dev_specifications(hw); ++ 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; + hw->tso_mode = HNS3_TSO_SW_CAL_PSEUDO_H_CSUM; +@@ -837,7 +776,7 @@ hns3vf_get_capability(struct hns3_hw *hw) + return 0; + } + +- ret = hns3vf_query_dev_specifications(hw); ++ ret = hns3_query_dev_specifications(hw); + if (ret) { + PMD_INIT_LOG(ERR, + "failed to query dev specifications, ret = %d", +-- +2.23.0 + diff --git a/0223-net-hns3-refactor-set-RSS-hash-algorithm-and-key-int.patch b/0223-net-hns3-refactor-set-RSS-hash-algorithm-and-key-int.patch new file mode 100644 index 0000000000000000000000000000000000000000..7d48ce2d17c0339bb14ce178dfd7f47308b82707 --- /dev/null +++ b/0223-net-hns3-refactor-set-RSS-hash-algorithm-and-key-int.patch @@ -0,0 +1,149 @@ +From d0c9a7b130290b2079dfaeaf301b95982480912c Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:53 +0800 +Subject: net/hns3: refactor set RSS hash algorithm and key interface + +[ upstream commit 88347111eb53bc54c598dde81715a06ca1dbd132 ] + +The hns3_rss_set_algo_key() is used to set RSS hash algorithm and key to +hardware. +The maximum execution time of the command sent to the firmware is +proportional to the length of the key. +However, now this times is fixed, which isn't good for key expansion. + +In addition, hash algorithm comes from rss_info::hash_algo maintained in +the driver, which also isn't good for the usage of this function. + +Interface is updated to get hash algorithm and key length as input +parameters. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 3 ++- + drivers/net/hns3/hns3_rss.c | 48 ++++++++++++++++-------------------- + drivers/net/hns3/hns3_rss.h | 4 ++- + 3 files changed, 26 insertions(+), 29 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index a2c1589c39..95609f8483 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1494,7 +1494,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + if (ret) + return ret; + +- ret = hns3_rss_set_algo_key(hw, rss_config->key); ++ ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, ++ rss_config->key, HNS3_RSS_KEY_SIZE); + if (ret) + return ret; + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index ca5a129234..3db7bf0445 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -277,45 +277,37 @@ static const struct { + + /* + * rss_generic_config command function, opcode:0x0D01. +- * Used to set algorithm, key_offset and hash key of rss. ++ * Used to set algorithm and hash key of RSS. + */ + int +-hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key) ++hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, ++ const uint8_t *key, uint8_t key_len) + { +-#define HNS3_KEY_OFFSET_MAX 3 +-#define HNS3_SET_HASH_KEY_BYTE_FOUR 2 +- + struct hns3_rss_generic_config_cmd *req; + struct hns3_cmd_desc desc; +- uint32_t key_offset, key_size; +- const uint8_t *key_cur; +- uint8_t cur_offset; ++ const uint8_t *cur_key; ++ uint16_t cur_key_size; ++ uint16_t max_bd_num; ++ uint16_t idx; + int ret; + + req = (struct hns3_rss_generic_config_cmd *)desc.data; + +- /* +- * key_offset=0, hash key byte0~15 is set to hardware. +- * key_offset=1, hash key byte16~31 is set to hardware. +- * key_offset=2, hash key byte32~39 is set to hardware. +- */ +- for (key_offset = 0; key_offset < HNS3_KEY_OFFSET_MAX; key_offset++) { ++ max_bd_num = DIV_ROUND_UP(key_len, HNS3_RSS_HASH_KEY_NUM); ++ for (idx = 0; idx < max_bd_num; idx++) { + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_GENERIC_CONFIG, + false); + +- req->hash_config |= +- (hw->rss_info.hash_algo & HNS3_RSS_HASH_ALGO_MASK); +- req->hash_config |= (key_offset << HNS3_RSS_HASH_KEY_OFFSET_B); ++ req->hash_config |= (hash_algo & HNS3_RSS_HASH_ALGO_MASK); ++ req->hash_config |= (idx << HNS3_RSS_HASH_KEY_OFFSET_B); + +- if (key_offset == HNS3_SET_HASH_KEY_BYTE_FOUR) +- key_size = HNS3_RSS_KEY_SIZE - HNS3_RSS_HASH_KEY_NUM * +- HNS3_SET_HASH_KEY_BYTE_FOUR; ++ if (idx == max_bd_num - 1) ++ cur_key_size = key_len % HNS3_RSS_HASH_KEY_NUM; + else +- key_size = HNS3_RSS_HASH_KEY_NUM; ++ cur_key_size = HNS3_RSS_HASH_KEY_NUM; + +- cur_offset = key_offset * HNS3_RSS_HASH_KEY_NUM; +- key_cur = key + cur_offset; +- memcpy(req->hash_key, key_cur, key_size); ++ cur_key = key + idx * HNS3_RSS_HASH_KEY_NUM; ++ memcpy(req->hash_key, cur_key, cur_key_size); + + ret = hns3_cmd_send(hw, &desc, 1); + if (ret) { +@@ -518,7 +510,8 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + goto set_tuple_fail; + + if (key) { +- ret = hns3_rss_set_algo_key(hw, key); ++ ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, ++ key, HNS3_RSS_KEY_SIZE); + if (ret) + goto set_algo_key_fail; + } +@@ -795,8 +788,9 @@ hns3_config_rss(struct hns3_adapter *hns) + break; + } + +- /* Configure RSS hash algorithm and hash key offset */ +- ret = hns3_rss_set_algo_key(hw, hash_key); ++ /* Configure RSS hash algorithm and hash key */ ++ ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, hash_key, ++ HNS3_RSS_KEY_SIZE); + if (ret) + return ret; + +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index 8e8b056f4e..b7f62ca1ee 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -109,6 +109,8 @@ int hns3_rss_reset_indir_table(struct hns3_hw *hw); + int hns3_config_rss(struct hns3_adapter *hns); + void hns3_rss_uninit(struct hns3_adapter *hns); + int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); +-int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key); ++int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, ++ const uint8_t *key, uint8_t key_len); ++ + + #endif /* HNS3_RSS_H */ +-- +2.23.0 + diff --git a/0224-net-hns3-fix-RSS-key-size-compatibility.patch b/0224-net-hns3-fix-RSS-key-size-compatibility.patch new file mode 100644 index 0000000000000000000000000000000000000000..ed823ecb3a6835fd6fa5df93f3e50ca8c7f04ffd --- /dev/null +++ b/0224-net-hns3-fix-RSS-key-size-compatibility.patch @@ -0,0 +1,209 @@ +From 7d81fd5ed42af46c6e5eef15b4dce7172a2e571d Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:54 +0800 +Subject: net/hns3: fix RSS key size compatibility + +[ upstream commit 5172f9c464aa315a9d45b9177af71b4f99d55cdb ] + +For better compatibility, the RSS key size of PF and VF are obtained +from firmware. However, the outdated HNS3_RSS_KEY_SIZE macro is still +utilized in many locations as the key size. + +Fixes: 9c740336f024 ("net/hns3: get device specifications from firmware") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_common.c | 12 +++++++++++- + drivers/net/hns3/hns3_flow.c | 26 ++++++++++++-------------- + drivers/net/hns3/hns3_rss.c | 23 +++++++++++------------ + drivers/net/hns3/hns3_rss.h | 3 ++- + 4 files changed, 36 insertions(+), 28 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 212b35d842..9bfbe1161f 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -129,7 +129,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) + }; + + info->reta_size = hw->rss_ind_tbl_size; +- info->hash_key_size = HNS3_RSS_KEY_SIZE; ++ info->hash_key_size = hw->rss_key_size; + info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; + + info->default_rxportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; +@@ -893,6 +893,16 @@ hns3_check_dev_specifications(struct hns3_hw *hw) + return -EINVAL; + } + ++ if (hw->rss_key_size == 0 || hw->rss_key_size > HNS3_RSS_KEY_SIZE_MAX) { ++ hns3_err(hw, "the RSS key size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", ++ hw->rss_key_size, HNS3_RSS_KEY_SIZE_MAX); ++ return -EINVAL; ++ } ++ ++ if (hw->rss_key_size > HNS3_RSS_KEY_SIZE) ++ hns3_warn(hw, "the RSS key size obtained (%u) is greater than the default key size (%u)", ++ hw->rss_key_size, HNS3_RSS_KEY_SIZE); ++ + return 0; + } + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 95609f8483..a18ec7650d 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1406,10 +1406,10 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, + "a nonzero RSS encapsulation level is not supported"); +- if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) ++ if (rss->key_len && rss->key_len != hw->rss_key_size) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, +- "RSS hash key must be exactly 40 bytes"); ++ "invalid RSS key length"); + + if (!hns3_rss_input_tuple_supported(hw, rss)) + return rte_flow_error_set(error, EINVAL, +@@ -1443,16 +1443,6 @@ hns3_disable_rss(struct hns3_hw *hw) + return 0; + } + +-static void +-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"); +- rss_conf->key = hns3_hash_key; +- rss_conf->key_len = HNS3_RSS_KEY_SIZE; +- } +-} +- + static int + hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, + uint8_t *hash_algo) +@@ -1485,9 +1475,16 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, + static int + hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + { ++ uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; ++ bool use_default_key = false; + int ret; + +- hns3_adjust_rss_key(hw, rss_config); ++ if (rss_config->key == NULL || rss_config->key_len != hw->rss_key_size) { ++ hns3_warn(hw, "Default RSS hash key to be set"); ++ memcpy(rss_key, hns3_hash_key, ++ RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); ++ use_default_key = true; ++ } + + ret = hns3_parse_rss_algorithm(hw, &rss_config->func, + &hw->rss_info.hash_algo); +@@ -1495,7 +1492,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) + return ret; + + ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, +- rss_config->key, HNS3_RSS_KEY_SIZE); ++ use_default_key ? rss_key : rss_config->key, ++ hw->rss_key_size); + if (ret) + return ret; + +diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c +index 3db7bf0445..d6e0754273 100644 +--- a/drivers/net/hns3/hns3_rss.c ++++ b/drivers/net/hns3/hns3_rss.c +@@ -316,7 +316,7 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + } + } + /* Update the shadow RSS key with user specified */ +- memcpy(hw->rss_info.key, key, HNS3_RSS_KEY_SIZE); ++ memcpy(hw->rss_info.key, key, hw->rss_key_size); + return 0; + } + +@@ -498,9 +498,9 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + uint8_t *key = rss_conf->rss_key; + int ret; + +- if (key && key_len != HNS3_RSS_KEY_SIZE) { ++ if (key && key_len != hw->rss_key_size) { + hns3_err(hw, "the hash key len(%u) is invalid, must be %u", +- key_len, HNS3_RSS_KEY_SIZE); ++ key_len, hw->rss_key_size); + return -EINVAL; + } + +@@ -511,7 +511,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, + + if (key) { + ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, +- key, HNS3_RSS_KEY_SIZE); ++ key, hw->rss_key_size); + if (ret) + goto set_algo_key_fail; + } +@@ -547,9 +547,9 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev, + rss_conf->rss_hf = rss_cfg->conf.types; + + /* Get the RSS Key required by the user */ +- if (rss_conf->rss_key && rss_conf->rss_key_len >= HNS3_RSS_KEY_SIZE) { +- memcpy(rss_conf->rss_key, rss_cfg->key, HNS3_RSS_KEY_SIZE); +- rss_conf->rss_key_len = HNS3_RSS_KEY_SIZE; ++ if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) { ++ memcpy(rss_conf->rss_key, rss_cfg->key, hw->rss_key_size); ++ rss_conf->rss_key_len = hw->rss_key_size; + } + rte_spinlock_unlock(&hw->lock); + +@@ -754,8 +754,8 @@ hns3_rss_set_default_args(struct hns3_hw *hw) + /* Default hash algorithm */ + rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + +- /* Default RSS key */ +- memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE); ++ memcpy(rss_cfg->key, hns3_hash_key, ++ RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); + + /* Initialize RSS indirection table */ + for (i = 0; i < hw->rss_ind_tbl_size; i++) +@@ -788,9 +788,8 @@ hns3_config_rss(struct hns3_adapter *hns) + break; + } + +- /* Configure RSS hash algorithm and hash key */ +- ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, hash_key, +- HNS3_RSS_KEY_SIZE); ++ ret = hns3_rss_set_algo_key(hw, rss_cfg->hash_algo, ++ hash_key, hw->rss_key_size); + if (ret) + return ret; + +diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h +index b7f62ca1ee..d6f81996f4 100644 +--- a/drivers/net/hns3/hns3_rss.h ++++ b/drivers/net/hns3/hns3_rss.h +@@ -29,6 +29,7 @@ + #define HNS3_RSS_IND_TBL_SIZE 512 /* The size of hash lookup table */ + #define HNS3_RSS_IND_TBL_SIZE_MAX 2048 + #define HNS3_RSS_KEY_SIZE 40 ++#define HNS3_RSS_KEY_SIZE_MAX 128 + #define HNS3_RSS_SET_BITMAP_MSK 0xffff + + #define HNS3_RSS_HASH_ALGO_TOEPLITZ 0 +@@ -41,7 +42,7 @@ struct hns3_rss_conf { + /* RSS parameters :algorithm, flow_types, key, queue */ + struct rte_flow_action_rss conf; + uint8_t hash_algo; /* hash function type defined by hardware */ +- uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */ ++ uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ + uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; + uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ + bool valid; /* check if RSS rule is valid */ +-- +2.23.0 + diff --git a/0225-net-hns3-fix-clearing-RSS-configuration.patch b/0225-net-hns3-fix-clearing-RSS-configuration.patch new file mode 100644 index 0000000000000000000000000000000000000000..2a850e23ae2447fa3677292e3f0c0e6f6d13aff2 --- /dev/null +++ b/0225-net-hns3-fix-clearing-RSS-configuration.patch @@ -0,0 +1,42 @@ +From b81a2f05658192464916c0d4f5cc1349d9d3aca4 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:55 +0800 +Subject: net/hns3: fix clearing RSS configuration + +[ upstream commit 1aa5222454725001939ff571e685225f6cf85653 ] + +When a RSS rule has an unsupported action, the RSS configuration is +cleared by mistake. + +Remove clearing RSS configuration in this case. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index a18ec7650d..c338eab049 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1421,12 +1421,10 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, + + /* Check if the next not void action is END */ + NEXT_ITEM_OF_ACTION(act, actions, act_index); +- if (act->type != RTE_FLOW_ACTION_TYPE_END) { +- memset(rss_conf, 0, sizeof(struct hns3_rss_conf)); ++ if (act->type != RTE_FLOW_ACTION_TYPE_END) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + act, "Not supported action."); +- } + + return 0; + } +-- +2.23.0 + diff --git a/0226-net-hns3-use-RSS-filter-list-to-check-duplicated-rul.patch b/0226-net-hns3-use-RSS-filter-list-to-check-duplicated-rul.patch new file mode 100644 index 0000000000000000000000000000000000000000..4f3099640cb14f471e5a74ba0511ac371b6e274c --- /dev/null +++ b/0226-net-hns3-use-RSS-filter-list-to-check-duplicated-rul.patch @@ -0,0 +1,89 @@ +From dd5efbef75ed9511f497e2da05131e902dc4f277 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:56 +0800 +Subject: net/hns3: use RSS filter list to check duplicated rule + +[ upstream commit 6afde23d843ecf67453eaf69924bd79873f6f207 ] + +All rules from user are saved in RSS filter list, so use RSS +filter list to check duplicated rule. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 35 +++++++++++++++++++++-------------- + 1 file changed, 21 insertions(+), 14 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index c338eab049..303275ae93 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1300,7 +1300,7 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, + !memcmp(comp->key, with->key, with->key_len); + + return (func_is_same && rss_key_is_same && +- comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) && ++ comp->types == with->types && + comp->level == with->level && + comp->queue_num == with->queue_num && + !memcmp(comp->queue, with->queue, +@@ -1596,15 +1596,7 @@ hns3_config_rss_filter(struct hns3_hw *hw, + } + + /* Set hash algorithm and flow types by the user's config */ +- ret = hns3_hw_rss_hash_set(hw, &rss_flow_conf); +- if (ret) +- return ret; +- +- ret = hns3_rss_conf_copy(rss_info, &rss_flow_conf); +- if (ret) +- hns3_err(hw, "RSS config init fail(%d)", ret); +- +- return ret; ++ return hns3_hw_rss_hash_set(hw, &rss_flow_conf); + } + + static int +@@ -1676,17 +1668,32 @@ hns3_restore_filter(struct hns3_adapter *hns) + return hns3_restore_rss_filter(hw); + } + ++static bool ++hns3_rss_action_is_dup(struct hns3_hw *hw, ++ const struct rte_flow_action_rss *act) ++{ ++ struct hns3_rss_conf_ele *filter; ++ ++ TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) { ++ if (!filter->filter_info.valid) ++ continue; ++ ++ if (hns3_action_rss_same(&filter->filter_info.conf, act)) ++ return true; ++ } ++ ++ return false; ++} ++ + static int + hns3_flow_parse_rss(struct rte_eth_dev *dev, + const struct hns3_rss_conf *conf, bool add) + { + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +- bool ret; + +- ret = hns3_action_rss_same(&hw->rss_info.conf, &conf->conf); +- if (ret) { +- hns3_err(hw, "Enter duplicate RSS configuration : %d", ret); ++ if (hns3_rss_action_is_dup(hw, &conf->conf)) { ++ hns3_err(hw, "duplicate RSS configuration"); + return -EINVAL; + } + +-- +2.23.0 + diff --git a/0227-net-hns3-remove-useless-code-when-destroy-valid-RSS-.patch b/0227-net-hns3-remove-useless-code-when-destroy-valid-RSS-.patch new file mode 100644 index 0000000000000000000000000000000000000000..082bc028db3671659c7eb1495a621066b9f95abe --- /dev/null +++ b/0227-net-hns3-remove-useless-code-when-destroy-valid-RSS-.patch @@ -0,0 +1,91 @@ +From 1f32e5059ee95c4433d1c37034e02f8c4a722418 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:57 +0800 +Subject: net/hns3: remove useless code when destroy valid RSS rule + +[ upstream commit 546031ba551485c3e3aa57c3698975c2852cbef1 ] + +When all rules are flushed the hw::rss_info::conf::func set to +RTE_ETH_HASH_FUNCTION_MAX and hw::rss_info::conf::queue set to NULL +which indicates no flow rules is issued. +See: commit eb158fc756a5 ("net/hns3: fix config when creating RSS rule +after flush"). + +Actually, the way determining whether there are rules has been changed +by walking the flow RSS list. +See: commit 705a50800334 ("net/hns3: fix RSS filter restore"). + +In addition, the rte_flow_action_rss from user isn't saved to 'conf' in +hw->rss_info now. So this code can be removed. + +Fixes: eb158fc756a5 ("net/hns3: fix config when creating RSS rule after flush") +Fixes: 705a50800334 ("net/hns3: fix RSS filter restore") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 26 ++------------------------ + 1 file changed, 2 insertions(+), 24 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 303275ae93..7adde16cbc 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1279,19 +1279,8 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, + bool rss_key_is_same; + bool func_is_same; + +- /* +- * When user flush all RSS rule, RSS func is set invalid with +- * RTE_ETH_HASH_FUNCTION_MAX. Then the user create a flow after +- * flushed, any validate RSS func is different with it before +- * flushed. Others, when user create an action RSS with RSS func +- * specified RTE_ETH_HASH_FUNCTION_DEFAULT, the func is the same +- * between continuous RSS flow. +- */ +- if (comp->func == RTE_ETH_HASH_FUNCTION_MAX) +- func_is_same = false; +- else +- func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? +- (comp->func == with->func) : true; ++ func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? ++ (comp->func == with->func) : true; + + if (with->key_len == 0 || with->key == NULL) + rss_key_is_same = 1; +@@ -1533,7 +1522,6 @@ static int + hns3_config_rss_filter(struct hns3_hw *hw, + const struct hns3_rss_conf *conf, bool add) + { +- struct hns3_rss_conf *rss_info; + uint64_t flow_types; + uint16_t num; + int ret; +@@ -1560,7 +1548,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, + /* Update the useful flow types */ + rss_flow_conf.types = flow_types; + +- rss_info = &hw->rss_info; + if (!add) { + if (!conf->valid) + return 0; +@@ -1571,15 +1558,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, + return ret; + } + +- if (rss_flow_conf.queue_num) { +- /* +- * Due the content of queue pointer have been reset to +- * 0, the rss_info->conf.queue should be set to NULL +- */ +- rss_info->conf.queue = NULL; +- rss_info->conf.queue_num = 0; +- } +- + return 0; + } + +-- +2.23.0 + diff --git a/0228-net-hns3-fix-warning-on-flush-or-destroy-rule.patch b/0228-net-hns3-fix-warning-on-flush-or-destroy-rule.patch new file mode 100644 index 0000000000000000000000000000000000000000..5a7fecfcaef0922c158f301ccdde8a2f1039ea00 --- /dev/null +++ b/0228-net-hns3-fix-warning-on-flush-or-destroy-rule.patch @@ -0,0 +1,66 @@ +From 21b43c2f2d66de594ed174a0ba18da03a6fe5296 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:58 +0800 +Subject: net/hns3: fix warning on flush or destroy rule + +[ upstream commit a7bf2789168c8d49ca4dec5bb7bb0b3f765fc1bd ] + +Although flow rules will no longer be used when user flush all rules +or destroy a rule a warning is generated like: +"modified RSS types based on hardware support, requested:0x137f83fffc +configured:0x3ffc". + +Prevent warning for flush or destroy rule case. + +Fixes: ec674cb742e5 ("net/hns3: fix flushing RSS rule") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 22 +++++++++++----------- + 1 file changed, 11 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 7adde16cbc..fbc38dd3d4 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1537,17 +1537,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, + .queue = conf->conf.queue, + }; + +- /* Filter the unsupported flow types */ +- flow_types = conf->conf.types ? +- rss_flow_conf.types & HNS3_ETH_RSS_SUPPORT : +- hw->rss_info.conf.types; +- if (flow_types != rss_flow_conf.types) +- hns3_warn(hw, "modified RSS types based on hardware support, " +- "requested:0x%" PRIx64 " configured:0x%" PRIx64, +- rss_flow_conf.types, flow_types); +- /* Update the useful flow types */ +- rss_flow_conf.types = flow_types; +- + if (!add) { + if (!conf->valid) + return 0; +@@ -1573,6 +1562,17 @@ hns3_config_rss_filter(struct hns3_hw *hw, + return ret; + } + ++ /* Filter the unsupported flow types */ ++ flow_types = conf->conf.types ? ++ rss_flow_conf.types & HNS3_ETH_RSS_SUPPORT : ++ hw->rss_info.conf.types; ++ if (flow_types != rss_flow_conf.types) ++ hns3_warn(hw, "modified RSS types based on hardware support," ++ " requested:0x%" PRIx64 " configured:0x%" PRIx64, ++ rss_flow_conf.types, flow_types); ++ /* Update the useful flow types */ ++ rss_flow_conf.types = flow_types; ++ + /* Set hash algorithm and flow types by the user's config */ + return hns3_hw_rss_hash_set(hw, &rss_flow_conf); + } +-- +2.23.0 + diff --git a/0229-net-hns3-fix-config-struct-used-for-conversion.patch b/0229-net-hns3-fix-config-struct-used-for-conversion.patch new file mode 100644 index 0000000000000000000000000000000000000000..9706fe1c3edc1b7560d90ab6aaa498b49cc0f800 --- /dev/null +++ b/0229-net-hns3-fix-config-struct-used-for-conversion.patch @@ -0,0 +1,133 @@ +From e59403adf4cc2485d10fba148bf935b037170fb7 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:02:59 +0800 +Subject: net/hns3: fix config struct used for conversion + +[ upstream commit 815c7db53167f7ee1573dca18fa7f889e44764d4 ] + +When the type in 'struct rte_flow_action' is RTE_FLOW_ACTION_TYPE_RSS, +the 'conf' pointer references the 'struct rte_flow_action_rss' instead +of the 'struct hns3_rss_conf' in driver. But driver uses 'struct +hns3_rss_conf' to convert this 'conf' pointer to get RSS action +configuration. + +In addition, RSS filter configuration is directly cloned to RSS filter +node instead of coping it after successfully setting to hardware. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 59 ++++++++++++++---------------------- + 1 file changed, 22 insertions(+), 37 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index fbc38dd3d4..a30b19cfdb 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -95,8 +95,8 @@ static const struct rte_flow_action * + hns3_find_rss_general_action(const struct rte_flow_item pattern[], + const struct rte_flow_action actions[]) + { ++ const struct rte_flow_action_rss *rss_act; + const struct rte_flow_action *act = NULL; +- const struct hns3_rss_conf *rss; + bool have_eth = false; + + for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { +@@ -115,8 +115,8 @@ hns3_find_rss_general_action(const struct rte_flow_item pattern[], + } + } + +- rss = act->conf; +- if (have_eth && rss->conf.queue_num) { ++ rss_act = act->conf; ++ if (have_eth && rss_act->queue_num) { + /* + * Pattern have ETH and action's queue_num > 0, indicate this is + * queue region configuration. +@@ -1296,30 +1296,6 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, + sizeof(*with->queue) * with->queue_num)); + } + +-static int +-hns3_rss_conf_copy(struct hns3_rss_conf *out, +- const struct rte_flow_action_rss *in) +-{ +- if (in->key_len > RTE_DIM(out->key) || +- in->queue_num > RTE_DIM(out->queue)) +- return -EINVAL; +- if (in->key == NULL && in->key_len) +- return -EINVAL; +- out->conf = (struct rte_flow_action_rss) { +- .func = in->func, +- .level = in->level, +- .types = in->types, +- .key_len = in->key_len, +- .queue_num = in->queue_num, +- }; +- out->conf.queue = memcpy(out->queue, in->queue, +- sizeof(*in->queue) * in->queue_num); +- if (in->key) +- out->conf.key = memcpy(out->key, in->key, in->key_len); +- +- return 0; +-} +- + static bool + hns3_rss_input_tuple_supported(struct hns3_hw *hw, + const struct rte_flow_action_rss *rss) +@@ -1733,9 +1709,10 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + struct rte_flow *flow) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ const struct rte_flow_action_rss *rss_act; + struct hns3_rss_conf_ele *rss_filter_ptr; + struct hns3_rss_conf_ele *filter_ptr; +- const struct hns3_rss_conf *rss_conf; ++ struct hns3_rss_conf *new_conf; + int ret; + + rss_filter_ptr = rte_zmalloc("hns3 rss filter", +@@ -1745,19 +1722,27 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, + 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); ++ rss_act = (const struct rte_flow_action_rss *)act->conf; ++ new_conf = &rss_filter_ptr->filter_info; ++ memcpy(&new_conf->conf, rss_act, sizeof(*rss_act)); ++ if (rss_act->queue_num > 0) { ++ memcpy(new_conf->queue, rss_act->queue, ++ rss_act->queue_num * sizeof(new_conf->queue[0])); ++ new_conf->conf.queue = new_conf->queue; ++ } ++ if (rss_act->key_len > 0) { ++ if (rss_act->key != NULL) { ++ memcpy(new_conf->key, rss_act->key, ++ rss_act->key_len * sizeof(new_conf->key[0])); ++ new_conf->conf.key = new_conf->key; ++ } ++ } ++ ++ ret = hns3_flow_parse_rss(dev, new_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; + + /* +-- +2.23.0 + diff --git a/0230-net-hns3-fix-duplicate-RSS-rule-check.patch b/0230-net-hns3-fix-duplicate-RSS-rule-check.patch new file mode 100644 index 0000000000000000000000000000000000000000..02518e8c17e2fc073321b4dd9b33cefa70a0723d --- /dev/null +++ b/0230-net-hns3-fix-duplicate-RSS-rule-check.patch @@ -0,0 +1,108 @@ +From 4aa7369a34a576a630beb0680b55b7c3c8b982f5 Mon Sep 17 00:00:00 2001 +From: Huisong Li +Date: Tue, 31 Jan 2023 21:03:00 +0800 +Subject: net/hns3: fix duplicate RSS rule check + +[ upstream commit 150fd8f839e332d68aa7b60646c2033084544cb7 ] + +Currently, the interface for verifying duplicate RSS rules has +some problems: +1) If the value of 'func' in configuring RSS rule is default + value, this rule is mistakenly considered as a duplicate rule. +2) If key length is zero or 'key' is NULL in configuring RSS rule + this rule is also mistakenly considered as a duplicate rule. +3) If 'key' or 'queue' in struct rte_flow_action_rss being NULL + is used to memcpy, which may cause segment fault. + +Fixes: c37ca66f2b27 ("net/hns3: support RSS") +Cc: stable@dpdk.org + +Signed-off-by: Huisong Li +Signed-off-by: Dongdong Liu +--- + drivers/net/hns3/hns3_flow.c | 63 +++++++++++++++++++++++++++--------- + 1 file changed, 47 insertions(+), 16 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index a30b19cfdb..e80ec0f053 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -1272,28 +1272,59 @@ hns3_filterlist_flush(struct rte_eth_dev *dev) + } + } + ++static bool ++hns3_flow_rule_key_same(const struct rte_flow_action_rss *comp, ++ const struct rte_flow_action_rss *with) ++{ ++ if (comp->key_len != with->key_len) ++ return false; ++ ++ if (with->key_len == 0) ++ return true; ++ ++ if (comp->key == NULL && with->key == NULL) ++ return true; ++ ++ if (!(comp->key != NULL && with->key != NULL)) ++ return false; ++ ++ return !memcmp(comp->key, with->key, with->key_len); ++} ++ ++static bool ++hns3_flow_rule_queues_same(const struct rte_flow_action_rss *comp, ++ const struct rte_flow_action_rss *with) ++{ ++ if (comp->queue_num != with->queue_num) ++ return false; ++ ++ if (with->queue_num == 0) ++ return true; ++ ++ if (comp->queue == NULL && with->queue == NULL) ++ return true; ++ ++ if (!(comp->queue != NULL && with->queue != NULL)) ++ return false; ++ ++ return !memcmp(comp->queue, with->queue, with->queue_num); ++} ++ + static bool + hns3_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) + { +- bool rss_key_is_same; +- bool func_is_same; ++ bool same_level; ++ bool same_types; ++ bool same_func; + +- func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? +- (comp->func == with->func) : true; ++ same_level = (comp->level == with->level); ++ same_types = (comp->types == with->types); ++ same_func = (comp->func == with->func); + +- if (with->key_len == 0 || with->key == NULL) +- rss_key_is_same = 1; +- else +- rss_key_is_same = comp->key_len == with->key_len && +- !memcmp(comp->key, with->key, with->key_len); +- +- return (func_is_same && rss_key_is_same && +- comp->types == with->types && +- comp->level == with->level && +- comp->queue_num == with->queue_num && +- !memcmp(comp->queue, with->queue, +- sizeof(*with->queue) * with->queue_num)); ++ return same_level && same_types && same_func && ++ hns3_flow_rule_key_same(comp, with) && ++ hns3_flow_rule_queues_same(comp, with); + } + + static bool +-- +2.23.0 + diff --git a/dpdk.spec b/dpdk.spec index 1c673eba4ebc7c7661ce5aa303b4bf58c65cf615..f8b0ffa3e6f4cd64ec9b8b7c0f3c04f1d4c69bef 100644 --- a/dpdk.spec +++ b/dpdk.spec @@ -1,6 +1,6 @@ Name: dpdk Version: 21.11 -Release: 31 +Release: 32 Packager: packaging@6wind.com URL: http://dpdk.org %global source_version 21.11 @@ -238,6 +238,16 @@ Patch9217: 0217-kni-use-dedicated-function-to-set-MAC-address.patch Patch9218: 0218-linux-igb_uio-fix-build-for-switch-fall-through.patch Patch9219: 0219-linux-igb_uio-fix-build-with-kernel-5.18.patch Patch9220: 0220-net-hns3-fix-inaccurate-RTC-time-to-read.patch +Patch9221: 0221-net-hns3-fix-log-about-indirection-table-size.patch +Patch9222: 0222-net-hns3-extract-common-function-to-query-device.patch +Patch9223: 0223-net-hns3-refactor-set-RSS-hash-algorithm-and-key-int.patch +Patch9224: 0224-net-hns3-fix-RSS-key-size-compatibility.patch +Patch9225: 0225-net-hns3-fix-clearing-RSS-configuration.patch +Patch9226: 0226-net-hns3-use-RSS-filter-list-to-check-duplicated-rul.patch +Patch9227: 0227-net-hns3-remove-useless-code-when-destroy-valid-RSS-.patch +Patch9228: 0228-net-hns3-fix-warning-on-flush-or-destroy-rule.patch +Patch9229: 0229-net-hns3-fix-config-struct-used-for-conversion.patch +Patch9230: 0230-net-hns3-fix-duplicate-RSS-rule-check.patch Summary: Data Plane Development Kit core Group: System Environment/Libraries @@ -380,6 +390,19 @@ strip -g $RPM_BUILD_ROOT/lib/modules/%{kern_devel_ver}/extra/dpdk/igb_uio.ko /usr/sbin/depmod %changelog +* Wed Feb 15 2023 chenjiji - 21.11-32 + Sync some RSS bugfix for hns3 PMD. And patchs are as follows: + - net/hns3: fix log about indirection table size + - net/hns3: extract common function to query device + - net/hns3: refactor set RSS hash algorithm and key interface + - net/hns3: fix RSS key size compatibility + - net/hns3: fix clearing RSS configuration + - net/hns3: use RSS filter list to check duplicated rule + - net/hns3: remove useless code when destroy valid RSS rule + - net/hns3: fix warning on flush or destroy rule + - net/hns3: fix config struct used for conversion + - net/hns3: fix duplicate RSS rule check + * Mon Feb 06 2023 jiangheng - 21.11-31 - linux/igb_uio: fix build with kernel 5.18+