From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2185F427F6 for ; Tue, 21 Mar 2023 10:24:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C7B7410DF; Tue, 21 Mar 2023 10:24:30 +0100 (CET) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 7ABFB40A7F for ; Tue, 21 Mar 2023 10:24:27 +0100 (CET) Received: from kwepemm600004.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4PgmPx1JKzz9vW7; Tue, 21 Mar 2023 17:24:05 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Tue, 21 Mar 2023 17:24:25 +0800 From: Huisong Li To: , CC: , , , Subject: [PATCH 21.11 07/17] net/hns3: use hardware config to report hash types Date: Tue, 21 Mar 2023 17:22:56 +0800 Message-ID: <20230321092306.16918-8-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230321092306.16918-1-lihuisong@huawei.com> References: <20230321092306.16918-1-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit 406b25c7ffd2d84b1e09665872f69755c75e7d89 ] Use the configuration in hardware to report hash types instead of data maintained in software. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_rss.c | 260 ++++++++++++++++++++++++++++-------- drivers/net/hns3/hns3_rss.h | 1 + 2 files changed, 208 insertions(+), 53 deletions(-) diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index 7c0ca04400..f535161e77 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -70,6 +70,17 @@ enum hns3_tuple_field { HNS3_RSS_FIELD_IPV6_FRAG_IP_S }; +#define HNS3_RSS_TUPLE_IPV4_TCP_M GENMASK(3, 0) +#define HNS3_RSS_TUPLE_IPV4_UDP_M GENMASK(11, 8) +#define HNS3_RSS_TUPLE_IPV4_SCTP_M GENMASK(20, 16) +#define HNS3_RSS_TUPLE_IPV4_NONF_M GENMASK(25, 24) +#define HNS3_RSS_TUPLE_IPV4_FLAG_M GENMASK(27, 26) +#define HNS3_RSS_TUPLE_IPV6_TCP_M GENMASK(35, 32) +#define HNS3_RSS_TUPLE_IPV6_UDP_M GENMASK(43, 40) +#define HNS3_RSS_TUPLE_IPV6_SCTP_M GENMASK(52, 48) +#define HNS3_RSS_TUPLE_IPV6_NONF_M GENMASK(57, 56) +#define HNS3_RSS_TUPLE_IPV6_FLAG_M GENMASK(59, 58) + enum hns3_rss_tuple_type { HNS3_RSS_IP_TUPLE, HNS3_RSS_IP_L4_TUPLE, @@ -79,200 +90,249 @@ static const struct { uint64_t rss_types; uint16_t tuple_type; uint64_t rss_field; + uint64_t tuple_mask; } hns3_set_tuple_table[] = { /* IPV4-FRAG */ { RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S), + HNS3_RSS_TUPLE_IPV4_FLAG_M }, { RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_DST_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D), + HNS3_RSS_TUPLE_IPV4_FLAG_M }, { RTE_ETH_RSS_FRAG_IPV4, HNS3_RSS_IP_TUPLE, BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) | - BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D), + HNS3_RSS_TUPLE_IPV4_FLAG_M }, /* IPV4 */ { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S), + HNS3_RSS_TUPLE_IPV4_NONF_M }, { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_DST_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D), + HNS3_RSS_TUPLE_IPV4_NONF_M }, { RTE_ETH_RSS_IPV4, HNS3_RSS_IP_TUPLE, BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | - BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D), + HNS3_RSS_TUPLE_IPV4_NONF_M }, /* IPV4-OTHER */ { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S), + HNS3_RSS_TUPLE_IPV4_NONF_M }, { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_DST_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D), + HNS3_RSS_TUPLE_IPV4_NONF_M }, { RTE_ETH_RSS_NONFRAG_IPV4_OTHER, HNS3_RSS_IP_TUPLE, BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) | - BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D), + HNS3_RSS_TUPLE_IPV4_NONF_M }, /* IPV4-TCP */ { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L3_SRC_ONLY, HNS3_RSS_IP_L4_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S), + HNS3_RSS_TUPLE_IPV4_TCP_M }, { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L3_DST_ONLY, HNS3_RSS_IP_L4_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D), + HNS3_RSS_TUPLE_IPV4_TCP_M }, { RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L4_SRC_ONLY, HNS3_RSS_IP_L4_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV4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PV6, HNS3_RSS_IP_TUPLE, BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S) | - BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D), + HNS3_RSS_TUPLE_IPV6_FLAG_M }, /* IPV6 */ { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S), + HNS3_RSS_TUPLE_IPV6_NONF_M }, { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D), + HNS3_RSS_TUPLE_IPV6_NONF_M }, { RTE_ETH_RSS_IPV6, HNS3_RSS_IP_TUPLE, BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | - BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D), + HNS3_RSS_TUPLE_IPV6_NONF_M }, /* IPV6-OTHER */ { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_SRC_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S), + HNS3_RSS_TUPLE_IPV6_NONF_M }, { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_DST_ONLY, HNS3_RSS_IP_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D), + HNS3_RSS_TUPLE_IPV6_NONF_M }, { RTE_ETH_RSS_NONFRAG_IPV6_OTHER, HNS3_RSS_IP_TUPLE, BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) | - BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D), + HNS3_RSS_TUPLE_IPV6_NONF_M }, /* IPV6-TCP */ { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L3_SRC_ONLY, HNS3_RSS_IP_L4_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S), + HNS3_RSS_TUPLE_IPV6_TCP_M }, { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L3_DST_ONLY, HNS3_RSS_IP_L4_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D), + HNS3_RSS_TUPLE_IPV6_TCP_M }, { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L4_SRC_ONLY, HNS3_RSS_IP_L4_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S), + HNS3_RSS_TUPLE_IPV6_TCP_M }, { RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L4_DST_ONLY, HNS3_RSS_IP_L4_TUPLE, - BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D), + HNS3_RSS_TUPLE_IPV6_TCP_M }, { RTE_ETH_RSS_NONFRAG_I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UPLE_IPV6_SCTP_M }, { RTE_ETH_RSS_NONFRAG_IPV6_SCTP, HNS3_RSS_IP_L4_TUPLE, BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) | BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) | BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) | BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) | - BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER) }, + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER), + HNS3_RSS_TUPLE_IPV6_SCTP_M }, }; /* @@ -623,6 +683,96 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, return ret; } +int +hns3_get_rss_tuple_field(struct hns3_hw *hw, uint64_t *tuple_fields) +{ + struct hns3_rss_input_tuple_cmd *req; + struct hns3_cmd_desc desc; + int ret; + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, true); + req = (struct hns3_rss_input_tuple_cmd *)desc.data; + ret = hns3_cmd_send(hw, &desc, 1); + if (ret != 0) { + hns3_err(hw, "fail to get RSS hash tuple fields from firmware, ret = %d", + ret); + return ret; + } + + *tuple_fields = rte_le_to_cpu_64(req->tuple_field); + + return 0; +} + +static uint64_t +hns3_rss_tuple_fields_to_rss_hf(struct hns3_hw *hw, uint64_t tuple_fields) +{ + uint64_t ipv6_sctp_l4_mask = + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) | + BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S); + uint64_t rss_hf = 0; + uint64_t tuple_mask; + uint32_t i; + + for (i = 0; i < RTE_DIM(hns3_set_tuple_table); i++) { + tuple_mask = hns3_set_tuple_table[i].tuple_mask; + /* + * The RSS hash of the packet type is disabled if its tuples is + * zero. + */ + if ((tuple_fields & tuple_mask) == 0) + continue; + + /* + * Some hardware don't support to use src/dst port fields to + * hash for IPV6-SCTP packet. + */ + if ((hns3_set_tuple_table[i].rss_types & + RTE_ETH_RSS_NONFRAG_IPV6_SCTP) && + !hw->rss_info.ipv6_sctp_offload_supported) + tuple_mask &= ~ipv6_sctp_l4_mask; + + /* + * The framework (ethdev ops) or driver (rte flow API) ensure + * that both L3_SRC/DST_ONLY and L4_SRC/DST_ONLY cannot be set + * to driver at the same time. But if user doesn't specify + * anything L3/L4_SRC/DST_ONLY, driver enables all tuple fields. + * In this case, driver should not report L3/L4_SRC/DST_ONLY. + */ + if ((tuple_fields & tuple_mask) == tuple_mask) { + /* Skip the item enabled part tuples. */ + if ((tuple_fields & hns3_set_tuple_table[i].rss_field) != + tuple_mask) + continue; + + rss_hf |= hns3_set_tuple_table[i].rss_types; + continue; + } + + /* Match the item enabled part tuples.*/ + if ((tuple_fields & hns3_set_tuple_table[i].rss_field) == + hns3_set_tuple_table[i].rss_field) + rss_hf |= hns3_set_tuple_table[i].rss_types; + } + + return rss_hf; +} + +static int +hns3_rss_hash_get_rss_hf(struct hns3_hw *hw, uint64_t *rss_hf) +{ + uint64_t tuple_fields; + int ret; + + ret = hns3_get_rss_tuple_field(hw, &tuple_fields); + if (ret != 0) + return ret; + + *rss_hf = hns3_rss_tuple_fields_to_rss_hf(hw, tuple_fields); + + return 0; +} + /* * Get rss key and rss_hf types set of RSS hash configuration. * @param dev @@ -638,28 +788,32 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev, { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - struct hns3_rss_conf *rss_cfg = &hw->rss_info; uint8_t hash_algo; int ret; rte_spinlock_lock(&hw->lock); - rss_conf->rss_hf = rss_cfg->conf.types; + ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf); + if (ret != 0) { + hns3_err(hw, "obtain hash tuples failed, ret = %d", ret); + goto out; + } /* Get the RSS Key required by the user */ if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) { ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key, hw->rss_key_size); if (ret != 0) { - rte_spinlock_unlock(&hw->lock); hns3_err(hw, "obtain hash algo and key failed, ret = %d", ret); - return ret; + goto out; } rss_conf->rss_key_len = hw->rss_key_size; } + +out: rte_spinlock_unlock(&hw->lock); - return 0; + return ret; } /* diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h index 598381df84..cc53f363ae 100644 --- a/drivers/net/hns3/hns3_rss.h +++ b/drivers/net/hns3/hns3_rss.h @@ -112,6 +112,7 @@ 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_get_rss_tuple_field(struct hns3_hw *hw, uint64_t *tuple_fields); int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, const uint8_t *key, uint8_t key_len); int hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo, -- 2.22.0