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 10204A0032; Sat, 22 Oct 2022 10:27:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A8BA9415D7; Sat, 22 Oct 2022 10:25:40 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2114.outbound.protection.outlook.com [40.107.95.114]) by mails.dpdk.org (Postfix) with ESMTP id C608C42BC1 for ; Sat, 22 Oct 2022 10:25:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hxy2i60zHDzXjIw3k2A6sf4gT/Q+xPjfTJVpnzEITOKNYyWF22Rv32t6rIxQdi0MpdE5Yq8jD7o7rs0P9a3pF4H8Z9a3JLXW2lUxuRntRJ6YMK55Y7J2h3Tz9hxIhT7lpkyq1nwA5Ntxldb4ESWxYrLc/XDybmin13mh8OPKe6uKFGciIfA+xu7FzIEqiPT0pr3KvdHc9zOmHBRB20/wssOmFYn+497xPG+6ItNuVhK3NPoBJxuARVHQId4d7DKciKZnaCml4HRZgIDhdz48dPltqEfqxdCPwKYTxgYGX/wE6py30qJ5SqxLZd+OI+dbXGXx4bZdm52/o4gVHe6rbg== 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=k3jluhVp7ZYGWqGy5QXnikSGwOipQSy75/tgeorU1T0=; b=XRk4b+160GCAwrkqm62nJJGTkDZKu36ZYgloSdhrGzJ8lKjb/Ss4dlXbCZ4fhSy9UWo3UNG/yi2hP6GUs9zczqoWLr7TYbAlzuy7oMZORufnnOr3uT/e0KuLosO2xbYtDOVEb5xq00/JG6Xlqpo75VEs0CPqeCTOr5EfzjodFLAF8/VnXM/glGkzrYTJUEtq3GGf47+U5cdHL1Lck/OAKr38e38aSj97XtmiPhOl5zqmBCp59ocynFTdkObkMA/nqqTfZa1t8oCJWJasfuEJMr2/C0TdWZl3+J31zFuISlmcZn3HGAEY7axalngVG7aTmVzgb1OzOjnMilwlDutTfw== 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=k3jluhVp7ZYGWqGy5QXnikSGwOipQSy75/tgeorU1T0=; b=VzFpuTDFQlMCM7eou+7btUGrL038O8jDlKcBg1tL08z4PzDKq4UPLzl4rhqqJpBcrNR8YChueNYQx4dIS/T6FiZ/4db0IPj38j452swtdAwozXMExcOBkZ0LehWepUrFj55rB4oU05RDNrhj/3rs4x4I9WAK3Bi2bsIOl2sEUxU= 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 CH2PR13MB3848.namprd13.prod.outlook.com (2603:10b6:610:9d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Sat, 22 Oct 2022 08:25:33 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7c26:1a0b:2825:6f4b]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7c26:1a0b:2825:6f4b%4]) with mapi id 15.20.5723.014; Sat, 22 Oct 2022 08:25:33 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 21/25] net/nfp: support IPv4 NVGRE flow item Date: Sat, 22 Oct 2022 16:24:25 +0800 Message-Id: <1666427069-10553-22-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666427069-10553-1-git-send-email-chaoyong.he@corigine.com> References: <1666063359-34283-1-git-send-email-chaoyong.he@corigine.com> <1666427069-10553-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR02CA0056.apcprd02.prod.outlook.com (2603:1096:4:54::20) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CH2PR13MB3848:EE_ X-MS-Office365-Filtering-Correlation-Id: 013e8f7c-67be-4de9-8f60-08dab406fcc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LVpSYao9wGDs4+BtIw2RsPbssw0GJBMK/zzNO/kwbHdMaDYfkRuRHfThQIpBj8w2ItAK7fwR6KBslqB3vsKkqGc5Wt36jvkTWtZF5Ltw17Wng7MiYu/jcISSk0s8m8Iy9TML0bCdXyTViFuO87HpgCO8pVg7BwrkpVllG0MtIQYHxrEBwTHU17dSvoGo965yLz1OO6T+JlV4Zt8s8Dmm2PKqiuQX9TryF9cseJIyMQDeHPQEnwhaVkpkuXGeQaaHBBHPQXxZ5u1PmzxJQ7XS4jD3xziApOeIEpeRNQpYNqafK/f/5SxlhTM1AIuSv/wNQ8bIpK3xK9oYHCf6svy6qqK8zZ9+VJqswQ42IFeenK9HQ0yeRLmvgu10okChjbqjuGk1P+PLk0hJcJDl2u0KrH5Glck3dZfQxfzV9uVJ+cjTPzd33gVGl6b7OhyulWnrTBwR7I9Wbq+LXF7Y/mmpI+dgVli4i1BjL6vS6VJjDc1ZoPkiMG3zjdVXuGOGZCX3jEP3GBgCSbt28sVYC/ZHQONPUZu0e5De8WOC+Go0XXlRdkfvGxvqoWJi8OjajITxR868qH01X//KCvkknK4oG+wpv+aadjlt47BcrrpUAtZ0w09Q45J5Ug7JrCtx8HU4XM6m6S5XHujUsxTYZaRdJnwtqBr90MKnZbGGdNNgdgj5qd2nZwBYxyNrhvn0MhYvbAQKEBWvNEwZZ6lnJJrMgmSzMFNuekpjClQvSUOS9thdt+R/y6ga27Toeyn1Ew923P443wnvLI5na6JUpdpT9Q== 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:(13230022)(4636009)(136003)(366004)(396003)(39830400003)(346002)(376002)(451199015)(4326008)(107886003)(36756003)(38100700002)(66946007)(66556008)(316002)(6512007)(83380400001)(52116002)(66476007)(8676002)(44832011)(6666004)(6506007)(38350700002)(5660300002)(8936002)(6916009)(2616005)(478600001)(186003)(41300700001)(26005)(6486002)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aWhRU3RKSjFRcG9iRVgvWEV1L1NuUGVhWVpmL01kOGxnaEtVQUVSU1NoS3kr?= =?utf-8?B?VENaZXJTbXk5ajd0VzdwUVpNdW1uekxYV0hLTk56V2dhWm4zYUpCdXBialJi?= =?utf-8?B?SXhzTEUvUUtjTHQ3bWUvM1VJRjlRa3dLZFdzN2lsalUycFFhQWRVVUVFT3ZV?= =?utf-8?B?dFJkUW9qSllYN3VrU2Q2TFdHaGNRekhIZkxHZ0kzUUNiNXZqbTlONW9kbTY0?= =?utf-8?B?SW12RTBnTUZ1N1VMNDNhekVtdWN2TkZKdFFXNjIwOFJMbjNUV2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?B?bEVDc3RKaXAzSTR6SG1Tc3BEaXJyeTdtbHhjNTZBaE43UkdpZlRDMEtYOEVU?= =?utf-8?B?T1k2RXA4RjRFbmlJZGMyM3pXS3cyTTlrRi94dnBXVkh1U2NVbS9DYzQ1MlFJ?= =?utf-8?B?V0E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 013e8f7c-67be-4de9-8f60-08dab406fcc6 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2022 08:25:33.1114 (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: E3L2OJr1x515gWKycsZUGc2kipASEorQ8CT3tSo6cwupbXRxafHPJcgHUBe/IFbWYB4U97csKIg5IZ0SJROyYQr/eZk3E8WZU9ge7sAazIY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR13MB3848 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 Add the corresponding logics to support the offload of IPv4 NVGRE item. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- doc/guides/nics/features/nfp.ini | 2 + drivers/net/nfp/nfp_flow.c | 99 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index f6b658b..2acc809 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -29,6 +29,8 @@ Usage doc = Y [rte_flow items] eth = Y geneve = Y +gre = Y +gre_key = Y ipv4 = Y ipv6 = Y port_id = Y diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index 26d3854..0a43bf3 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -820,6 +820,26 @@ struct nfp_pre_tun_entry { return -EINVAL; } break; + case RTE_FLOW_ITEM_TYPE_GRE: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_GRE detected"); + /* Clear IPv4 bits */ + key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV4; + key_ls->tun_type = NFP_FL_TUN_GRE; + key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META; + key_ls->key_layer_two |= NFP_FLOWER_LAYER2_GRE; + key_ls->key_size += sizeof(struct nfp_flower_ext_meta); + if (outer_ip4_flag) { + key_ls->key_size += sizeof(struct nfp_flower_ipv4_gre_tun); + /* + * The outer l3 layer information is + * in `struct nfp_flower_ipv4_gre_tun` + */ + key_ls->key_size -= sizeof(struct nfp_flower_ipv4); + } + break; + case RTE_FLOW_ITEM_TYPE_GRE_KEY: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_GRE_KEY detected"); + break; default: PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type); return -ENOTSUP; @@ -1540,6 +1560,62 @@ struct nfp_pre_tun_entry { return ret; } +static int +nfp_flow_merge_gre(__rte_unused struct nfp_app_fw_flower *app_fw_flower, + __rte_unused struct rte_flow *nfp_flow, + char **mbuf_off, + __rte_unused const struct rte_flow_item *item, + __rte_unused const struct nfp_flow_item_proc *proc, + bool is_mask, + __rte_unused bool is_outer_layer) +{ + struct nfp_flower_ipv4_gre_tun *tun4; + + /* NVGRE is the only supported GRE tunnel type */ + tun4 = (struct nfp_flower_ipv4_gre_tun *)*mbuf_off; + if (is_mask) + tun4->ethertype = rte_cpu_to_be_16(~0); + else + tun4->ethertype = rte_cpu_to_be_16(0x6558); + + return 0; +} + +static int +nfp_flow_merge_gre_key(__rte_unused struct nfp_app_fw_flower *app_fw_flower, + __rte_unused struct rte_flow *nfp_flow, + char **mbuf_off, + const struct rte_flow_item *item, + __rte_unused const struct nfp_flow_item_proc *proc, + bool is_mask, + __rte_unused bool is_outer_layer) +{ + rte_be32_t tun_key; + const rte_be32_t *spec; + const rte_be32_t *mask; + struct nfp_flower_ipv4_gre_tun *tun4; + + spec = item->spec; + if (spec == NULL) { + PMD_DRV_LOG(DEBUG, "nfp flow merge gre key: no item->spec!"); + goto gre_key_end; + } + + mask = item->mask ? item->mask : proc->mask_default; + tun_key = is_mask ? *mask : *spec; + + tun4 = (struct nfp_flower_ipv4_gre_tun *)*mbuf_off; + tun4->tun_key = tun_key; + tun4->tun_flags = rte_cpu_to_be_16(NFP_FL_GRE_FLAG_KEY); + +gre_key_end: + *mbuf_off += sizeof(struct nfp_flower_ipv4_gre_tun); + + return 0; +} + +const rte_be32_t nfp_flow_item_gre_key = 0xffffffff; + /* Graph of supported items and associated process function */ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = { [RTE_FLOW_ITEM_TYPE_END] = { @@ -1580,7 +1656,8 @@ struct nfp_pre_tun_entry { [RTE_FLOW_ITEM_TYPE_IPV4] = { .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP, RTE_FLOW_ITEM_TYPE_UDP, - RTE_FLOW_ITEM_TYPE_SCTP), + RTE_FLOW_ITEM_TYPE_SCTP, + RTE_FLOW_ITEM_TYPE_GRE), .mask_support = &(const struct rte_flow_item_ipv4){ .hdr = { .type_of_service = 0xff, @@ -1671,6 +1748,23 @@ struct nfp_pre_tun_entry { .mask_sz = sizeof(struct rte_flow_item_geneve), .merge = nfp_flow_merge_geneve, }, + [RTE_FLOW_ITEM_TYPE_GRE] = { + .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_GRE_KEY), + .mask_support = &(const struct rte_flow_item_gre){ + .c_rsvd0_ver = RTE_BE16(0xa000), + .protocol = RTE_BE16(0xffff), + }, + .mask_default = &rte_flow_item_gre_mask, + .mask_sz = sizeof(struct rte_flow_item_gre), + .merge = nfp_flow_merge_gre, + }, + [RTE_FLOW_ITEM_TYPE_GRE_KEY] = { + .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_ETH), + .mask_support = &nfp_flow_item_gre_key, + .mask_default = &nfp_flow_item_gre_key, + .mask_sz = sizeof(rte_be32_t), + .merge = nfp_flow_merge_gre_key, + }, }; static int @@ -1728,7 +1822,8 @@ struct nfp_pre_tun_entry { nfp_flow_is_tun_item(const struct rte_flow_item *item) { if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN || - item->type == RTE_FLOW_ITEM_TYPE_GENEVE) + item->type == RTE_FLOW_ITEM_TYPE_GENEVE || + item->type == RTE_FLOW_ITEM_TYPE_GRE_KEY) return true; return false; -- 1.8.3.1