From patchwork Fri Jan 22 10:18:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 87088 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D93A0A0A0A; Fri, 22 Jan 2021 11:20:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3CC4140F50; Fri, 22 Jan 2021 11:19:28 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id 5CF4E140F0D for ; Fri, 22 Jan 2021 11:19:17 +0100 (CET) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DMZvx75SmzjBrt; Fri, 22 Jan 2021 18:18:05 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Fri, 22 Jan 2021 18:19:10 +0800 From: Lijun Ou To: , CC: , Date: Fri, 22 Jan 2021 18:18:42 +0800 Message-ID: <1611310732-51975-5-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611310732-51975-1-git-send-email-oulijun@huawei.com> References: <1611310732-51975-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 04/14] net/hns3: move judgment conditions to separated functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Here moves some judgement conditions to a separated function for parsing IPv4 hdr and TCP hdr in hns3_parse_normal function. Also, move the check of the selected input tuple of RSS to a separated functions named hns3_rss_input_tuple_supported in order to enhance scalability and complexity. Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_flow.c | 69 ++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index f303df4..889fa2f 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -525,6 +525,17 @@ hns3_parse_vlan(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, return 0; } +static bool +hns3_check_ipv4_mask_supported(const struct rte_flow_item_ipv4 *ipv4_mask) +{ + if (ipv4_mask->hdr.total_length || ipv4_mask->hdr.packet_id || + ipv4_mask->hdr.fragment_offset || ipv4_mask->hdr.time_to_live || + ipv4_mask->hdr.hdr_checksum) + return false; + + return true; +} + static int hns3_parse_ipv4(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, struct rte_flow_error *error) @@ -546,11 +557,7 @@ hns3_parse_ipv4(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, if (item->mask) { ipv4_mask = item->mask; - if (ipv4_mask->hdr.total_length || - ipv4_mask->hdr.packet_id || - ipv4_mask->hdr.fragment_offset || - ipv4_mask->hdr.time_to_live || - ipv4_mask->hdr.hdr_checksum) { + if (!hns3_check_ipv4_mask_supported(ipv4_mask)) { return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_MASK, item, @@ -648,6 +655,18 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, return 0; } +static bool +hns3_check_tcp_mask_supported(const struct rte_flow_item_tcp *tcp_mask) +{ + if (tcp_mask->hdr.sent_seq || tcp_mask->hdr.recv_ack || + tcp_mask->hdr.data_off || tcp_mask->hdr.tcp_flags || + tcp_mask->hdr.rx_win || tcp_mask->hdr.cksum || + tcp_mask->hdr.tcp_urp) + return false; + + return true; +} + static int hns3_parse_tcp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, struct rte_flow_error *error) @@ -670,10 +689,7 @@ hns3_parse_tcp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, if (item->mask) { tcp_mask = item->mask; - if (tcp_mask->hdr.sent_seq || tcp_mask->hdr.recv_ack || - tcp_mask->hdr.data_off || tcp_mask->hdr.tcp_flags || - tcp_mask->hdr.rx_win || tcp_mask->hdr.cksum || - tcp_mask->hdr.tcp_urp) { + if (!hns3_check_tcp_mask_supported(tcp_mask)) { return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_MASK, item, @@ -1328,6 +1344,28 @@ hns3_rss_conf_copy(struct hns3_rss_conf *out, return 0; } +static bool +hns3_rss_input_tuple_supported(struct hns3_hw *hw, + const struct rte_flow_action_rss *rss) +{ + /* + * For IP packet, it is not supported to use src/dst port fields to RSS + * hash for the following packet types. + * - IPV4 FRAG | IPV4 NONFRAG | IPV6 FRAG | IPV6 NONFRAG + * Besides, for Kunpeng920, the NIC HW is not supported to use src/dst + * port fields to RSS hash for IPV6 SCTP packet type. However, the + * Kunpeng930 and future kunpeng series support to use src/dst port + * fields to RSS hash for IPv6 SCTP packet type. + */ + if (rss->types & (ETH_RSS_L4_DST_ONLY | ETH_RSS_L4_SRC_ONLY) && + (rss->types & ETH_RSS_IP || + (!hw->rss_info.ipv6_sctp_offload_supported && + rss->types & ETH_RSS_NONFRAG_IPV6_SCTP))) + return false; + + return true; +} + /* * This function is used to parse rss action validatation. */ @@ -1386,18 +1424,7 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, "RSS hash key must be exactly 40 bytes"); - /* - * For Kunpeng920 and Kunpeng930 NIC hardware, it is not supported to - * use dst port/src port fields to RSS hash for the following packet - * types. - * - IPV4 FRAG | IPV4 NONFRAG | IPV6 FRAG | IPV6 NONFRAG - * Besides, for Kunpeng920, The NIC hardware is not supported to use - * src/dst port fields to RSS hash for IPV6 SCTP packet type. - */ - if (rss->types & (ETH_RSS_L4_DST_ONLY | ETH_RSS_L4_SRC_ONLY) && - (rss->types & ETH_RSS_IP || - (!hw->rss_info.ipv6_sctp_offload_supported && - rss->types & ETH_RSS_NONFRAG_IPV6_SCTP))) + if (!hns3_rss_input_tuple_supported(hw, rss)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, &rss->types,