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 6BC7B43AE5; Sat, 10 Feb 2024 11:43:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8F8A42EC4; Sat, 10 Feb 2024 11:42:46 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2114.outbound.protection.outlook.com [40.107.223.114]) by mails.dpdk.org (Postfix) with ESMTP id 918CD42EC4 for ; Sat, 10 Feb 2024 11:42:45 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iW0B/iKA7MtCxWEtz0GdG6o9CwywaxMH0ZdC9POB3H1iHbHDkwwKmfon4yDX9IHNM2v4kMceqoHhHU/PsqVyMXcCgOHN8B8nIv9siXLb9RxVi/Gd+hRzYElA1Bjs4g2GBI+FVcELrdX1RitIvP085xdftuSVGvgPhpe5yMXRnU8CKkslBEhmtMq5mZhTyTZ1iFMs63s2zu3FKroRcUi2G+UruXhq6EMjYPK5JzX1vqKZ9Gg4u7k91NmUimqb0ScXznNSzm6WIJkIdH+Dx+U0r9W/Clh856yg8y7PWc9NgivNz/Cm2v8ZaCt5FP7KvmJ2b1or7oGjTftryKSLXY4Ojw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aLRD/Wgu9Ytk2Knc6MGZthmjVImpgYrrCMwzObDgp2Q=; b=Mk/FUFJ5/QvhgwS2zhkGziDiyqI9XVL6/4/oQIjXlT3qaPbyeuxnMLtsRszantMXGNxVxGm8EXYNUTRVYZztzC/AvK8zY5SyyiB/avbfhDTeGXk/E1kzM4j1OcGWfRJTL1gsUOcKaLD1TKBIC0trPZQdH9/S7UKharhCYnLQNVMOXjlBz6iqW9WyGiRw/9391XM2e2rtMDMMA8XlimwUoQU7u5GulSZGxTVjh9IRyyHkHCKQhgC8fV/2XHDk9jgNTyuUU/0Vq884tYvHeQ8w0gQYTVfLWbOEnot3WtzAFSMxahhz26i5WiP3WNybskDvIDrKBerx6I40tM/S1gh4zg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aLRD/Wgu9Ytk2Knc6MGZthmjVImpgYrrCMwzObDgp2Q=; b=DyBsh7pjtEsG2VaRxbSgUWMsU1c6VBolP1/sUC2KPeSsF0iLrr3I3lz8m88NZBZ9aZeX5hhyOAUs/9wMbFxwnlUzQe0neWglkfNLiu2nud0F9OP7GlCS6w/U4BhhOCYfEutUP1oLZ8GQYh+oe8Dg6J9H/b2cHylkTPtc9ixZFnM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by PH0PR13MB5421.namprd13.prod.outlook.com (2603:10b6:510:142::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.24; Sat, 10 Feb 2024 10:42:44 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa%7]) with mapi id 15.20.7270.031; Sat, 10 Feb 2024 10:42:44 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Chaoyong He , Peng Zhang Subject: [PATCH 4/4] net/nfp: support RSS flow action Date: Sat, 10 Feb 2024 18:42:13 +0800 Message-Id: <20240210104214.1248772-5-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240210104214.1248772-1-chaoyong.he@corigine.com> References: <20240210104214.1248772-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0129.apcprd02.prod.outlook.com (2603:1096:4:188::19) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH0PR13MB5421:EE_ X-MS-Office365-Filtering-Correlation-Id: 51a0ee39-2965-42fc-1ed4-08dc2a250371 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +iA/KfGZ4TWsPEnXOfyYqeCvVaf8VkKWDbdBCZYFC10fzqfihu1M6f5kKDzm41KCHYbYfbEbZYxPnG56cToOomHaC1Wt9nKtLC6gQ7XvdSqUIKsTlR6vm5V2wI2utFQPxaFSC5HUi3spRJEB+1uKRMVC3OFn4WYzHFmeT3qPlVoLgngQ+Ppx8Jp/V2oSSFtHxL9wKvLI6KU5WDtpvAX22GXaY1nHM81W6lStVl2fBIuKMa1ssx400nOYlKXNW5No8CZVOFWlt8lXpneNR3HzQjWXZdJkAY88e9naUOQ7qArZUUKYTGu3naS8gY9mCSrDAhYrLA1lpFux6PcylDo5jzrjpflZ8vSmbuLOHNR/HiYaxXIjzt2sz4RUC4GWdi0IliP/kVwkvOZByWeU/qB64ax3KvU0NuiGtlE/dYAb9azsxfwxGIzPcWg5efVRVEwh7Wz4Tx16R1Rqgh76Ur1JE56Vv5TlNsepxzwQJeFzaW3Jpzwx9gQGoLgzZSCLFFaBT4vo4wtBtmNN74hbwweS+5tebEAxVb1OEmS7GKi267E/HNETD95Z26GjWOsv4MUrQ7ja5hRODwGrh48Cd7tHoT/dZw13PVeahZoDiGgWZtVyGRgeE3vqq1Nir5hQazH1 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(366004)(39830400003)(396003)(136003)(376002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(38100700002)(66556008)(6666004)(52116002)(478600001)(316002)(86362001)(6512007)(6486002)(5660300002)(6506007)(4326008)(66946007)(44832011)(66476007)(2906002)(6916009)(2616005)(8676002)(1076003)(107886003)(83380400001)(26005)(41300700001)(54906003)(8936002)(36756003)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?8gzol+17jdUmFpee2fHYv57g9UqAQAWZm66Y9j3+eXHP6MuPTBzoRpJGvH7l?= =?us-ascii?Q?HUT8NgMVh2EBzwu5rf5XHtQC3Qx9xq676PN821ABwsGf24gQ535YjoIoxPfE?= =?us-ascii?Q?nAVf6jMzJyFdsezaySiNgSJwVhbte7uxfIpFWMW49FR6U9Wm9H5T5a87rnRk?= =?us-ascii?Q?RE/+sdAc1mKMMenuy02YUvYkURyqP+FQeN2sKen63Uh3zdpFtDGoliuMFDwl?= =?us-ascii?Q?eamReM4rYJcwzEF4LK9a8wJVdm6Lem1WbKRcgMy62gnLftUs9F8061Je7rFY?= =?us-ascii?Q?UW2iCPZCUVTqEqtLmjIh41sQusixCpaEwt52VYTUTLfTSuSkgt7vuRoYsk2G?= =?us-ascii?Q?knzpaVRikOntuhjbAdTpaSyf7FDmOailb+CdbqebrPtaoidxjyHbgnXTrSbg?= =?us-ascii?Q?xda1Sk5yWwt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ascii?Q?r1eVzDcNYLFh3NTWW+BqH7EBWoxymf7/gT1sK+YIfimJuqgr5LvmV7X+KqDO?= =?us-ascii?Q?FoEsr7xYb8KI762c4vK0foGszLaEl7mGjPW+/0+ThkGku0e3P327AJvtS3O6?= =?us-ascii?Q?TZmHTl6B9kmw4h3j7Ye+6J51TS/j0TYEKiCOIqvce0+hp0Tl4IcBldmfV7jO?= =?us-ascii?Q?bBrmlFbeE+sv9CoOZiwC7wQVY4SUTh5/5rdbbS7Bp0+slAoacnr0xWqJh4Oc?= =?us-ascii?Q?Xcyuptsr+Q4ZCiuYjYmxhDpDfVYDcSg+B16NkvNQTFBCRzOSSreS7tfevAex?= =?us-ascii?Q?mA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51a0ee39-2965-42fc-1ed4-08dc2a250371 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2024 10:42:44.1015 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2N2A9a63qre75vl/1pejl88buN+5/ymtrCG6MrQo72q0LvcCVmptr7z1g310mZ85dauSFbhT+9bsFSlz1f2gHvc4JlioC0FSebTsdph2X/Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5421 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 From: Long Wu Add the corresponding logics to support the offload of RSS action. Signed-off-by: Long Wu Reviewed-by: Chaoyong He Reviewed-by: Peng Zhang --- doc/guides/nics/features/nfp.ini | 1 + drivers/net/nfp/flower/nfp_flower_flow.c | 124 ++++++++++++++++++ drivers/net/nfp/flower/nfp_flower_flow.h | 8 ++ .../net/nfp/flower/nfp_flower_representor.c | 6 + .../net/nfp/flower/nfp_flower_representor.h | 1 + 5 files changed, 140 insertions(+) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index 3494111f86..b20049b4f5 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -59,6 +59,7 @@ queue = Y raw_decap = Y raw_encap = Y represented_port = Y +rss = Y port_id = Y set_ipv4_dscp = Y set_ipv4_dst = Y diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index 07833fdbdb..1e208b9107 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -1143,6 +1143,9 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[], key_ls->act_size += sizeof(struct nfp_fl_act_mark); PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected"); break; + case RTE_FLOW_ACTION_TYPE_RSS: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RSS detected"); + break; default: PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type); return -ENOTSUP; @@ -3509,6 +3512,116 @@ nfp_flow_action_mark(char *act_data, fl_mark->mark = rte_cpu_to_be_32(mark->id); } +static int +nfp_flow_action_rss_add(struct nfp_flower_representor *representor, + const struct rte_flow_action *action, + struct nfp_fl_rss **rss_store) +{ + int ret; + struct nfp_net_hw *pf_hw; + struct rte_eth_rss_conf rss_conf; + struct nfp_fl_rss *rss_store_tmp; + const struct rte_flow_action_rss *rss; + uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ]; + + if (nfp_flower_repr_is_vf(representor)) + return 0; + + rss = action->conf; + + if (rss->key_len > NFP_NET_CFG_RSS_KEY_SZ) { + PMD_DRV_LOG(ERR, "Unsupported rss key length."); + return -ENOTSUP; + } + + rss_conf.rss_hf = 0; + rss_conf.rss_key = rss_key; + pf_hw = representor->app_fw_flower->pf_hw; + ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Get RSS conf failed."); + return ret; + } + + rss_store_tmp = calloc(1, sizeof(struct nfp_fl_rss)); + if (rss_store_tmp == NULL) { + PMD_DRV_LOG(ERR, "Alloc memory for rss storage failed."); + return -ENOMEM; + } + + if (rss->types != 0) { + rss_conf.rss_hf |= rss->types; + + rss_store_tmp->types = rss->types; + } + + if (rss->key_len != 0 && rss->key != NULL) { + memcpy(rss_conf.rss_key, rss->key, rss->key_len); + rss_conf.rss_key_len = rss->key_len; + + memcpy(rss_store_tmp->key, rss->key, rss->key_len); + rss_store_tmp->key_len = rss->key_len; + } + + ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Update RSS conf failed."); + free(rss_store_tmp); + return ret; + } + + *rss_store = rss_store_tmp; + + return 0; +} + +static int +nfp_flow_action_rss_del(struct nfp_flower_representor *representor, + struct rte_flow *nfp_flow) +{ + int ret; + struct nfp_net_hw *pf_hw; + struct nfp_fl_rss *rss_store; + struct rte_eth_rss_conf rss_conf; + uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ]; + + if (nfp_flower_repr_is_vf(representor)) + return 0; + + rss_conf.rss_hf = 0; + rss_conf.rss_key = rss_key; + pf_hw = representor->app_fw_flower->pf_hw; + ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Get RSS conf failed."); + goto exit; + } + + rss_store = nfp_flow->rss; + + if ((rss_conf.rss_hf & rss_store->types) != 0) + rss_conf.rss_hf &= (~(rss_store->types)); + + /* Need default RSS configuration */ + if (rss_conf.rss_hf == 0) + rss_conf.rss_hf = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6; + + if (rss_conf.rss_key_len == rss_store->key_len && + memcmp(rss_conf.rss_key, rss_store->key, rss_store->key_len) == 0) { + rss_conf.rss_key = NULL; + rss_conf.rss_key_len = 0; + } + + ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf); + if (ret != 0) + PMD_DRV_LOG(ERR, "Update RSS conf failed."); + +exit: + free(nfp_flow->rss); + + return ret; +} + static uint32_t nfp_flow_count_output(const struct rte_flow_action actions[]) { @@ -3761,6 +3874,13 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor, nfp_flow_action_mark(position, action); position += sizeof(struct nfp_fl_act_mark); break; + case RTE_FLOW_ACTION_TYPE_RSS: + PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_RSS"); + ret = nfp_flow_action_rss_add(representor, action, &nfp_flow->rss); + if (ret != 0) + return ret; + nfp_flow->type = NFP_FLOW_RSS; + break; default: PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type); return -ENOTSUP; @@ -4099,6 +4219,10 @@ nfp_flow_destroy(struct rte_eth_dev *dev, /* Delete the entry in pre tunnel table */ ret = nfp_pre_tun_table_check_del(representor, nfp_flow); break; + case NFP_FLOW_RSS: + /* Clear corresponding RSS configuration */ + ret = nfp_flow_action_rss_del(representor, nfp_flow); + break; default: PMD_DRV_LOG(ERR, "Invalid nfp flow type %d.", nfp_flow->type); ret = -EINVAL; diff --git a/drivers/net/nfp/flower/nfp_flower_flow.h b/drivers/net/nfp/flower/nfp_flower_flow.h index 75f18c6bd5..5d927edde9 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.h +++ b/drivers/net/nfp/flower/nfp_flower_flow.h @@ -33,6 +33,7 @@ enum nfp_flow_type { NFP_FLOW_COMMON, NFP_FLOW_ENCAP, NFP_FLOW_DECAP, + NFP_FLOW_RSS, }; struct nfp_fl_key_ls { @@ -121,6 +122,12 @@ struct nfp_ipv6_addr_entry { int ref_count; }; +struct nfp_fl_rss { + uint8_t key[NFP_NET_CFG_RSS_KEY_SZ]; + uint32_t key_len; + uint64_t types; +}; + #define NFP_TUN_PRE_TUN_RULE_LIMIT 32 struct nfp_flow_priv { @@ -166,6 +173,7 @@ struct nfp_flow_priv { struct rte_flow { struct nfp_fl_payload payload; struct nfp_fl_tun tun; + struct nfp_fl_rss *rss; size_t length; uint32_t hash_key; uint32_t mtr_id; diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 7284a1e84d..b2c55879ca 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -860,3 +860,9 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower) return ret; } + +bool +nfp_flower_repr_is_vf(struct nfp_flower_representor *repr) +{ + return repr->repr_type == NFP_REPR_TYPE_VF; +} diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h index 8053617562..7a4e7ecfc1 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.h +++ b/drivers/net/nfp/flower/nfp_flower_representor.h @@ -24,5 +24,6 @@ struct nfp_flower_representor { }; int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower); +bool nfp_flower_repr_is_vf(struct nfp_flower_representor *repr); #endif /* __NFP_FLOWER_REPRESENTOR_H__ */ -- 2.39.1