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 89232A0543; Tue, 25 Oct 2022 10:03:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B58242C5E; Tue, 25 Oct 2022 10:00:44 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2113.outbound.protection.outlook.com [40.107.237.113]) by mails.dpdk.org (Postfix) with ESMTP id DB8FE42BB3 for ; Tue, 25 Oct 2022 10:00:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UoJpM39km37rxrfyGOmsVCg9bk6EOupcSUvLKQIx4DqFdXAo5piF7+2I6LNNdbwvgoN80gbR+us/HDoKOqLPcLAK60YbjLksd9TzK7oNNTXaQjt0jz6eJAPvqTVxUJ7UvbpYrkKnEwOsFjWXGZUHM61UgaRFW+XOK/PZuSKgxJyK1lZUYUO8HVKj44UbtiUPhyneEhbzCCncIoRKzV0HPH70J189aqQBvDDyihphz5BRzef6LoTA1lQb1LlgNawdUgBvTC42eBGCfrtaIuxNpfKF3mlAM8q89pHku/OTCLv1vbVW4CMZRyfcHavALSR/h4aRvh/eWCEOpwG5+f158g== 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=tzKKfexIZqVdBOtDdXBJyjHWLQeR1QJz65yWp+Y6ju8=; b=Hq7OktOdV0D+Yt8pGGYc/7GKzj7w0FhIWwJDQ/d/tKS20tfyD2M6GnS4FbwuP1xMn8LiGaBLhxnTgYdGf8wgJDm0yT2EzFdqQaw+7XjiwDegcPeEKVYoaB9wXODe8G1ySI0WhmGB8JzLac+TLGTA90moT7JzcShEF1tg7BAkqQFkwI1+4QX2LSUKBRhA4tLLIthcO8KKaQEP2V1EeTzWfaWwv+u22AYN5q52JXIEDxA+Fjsesmtt2uq4JZTUXCdMFrg3Tiipb9hVVhntheMfiGxeOWa3DTgVbcsnXtJ+nlb/INdKwVQd+T45kllkjUgJ6+sXEN8Qt4bJjusgIbEoOA== 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=tzKKfexIZqVdBOtDdXBJyjHWLQeR1QJz65yWp+Y6ju8=; b=uwIajkjJyT8RXRmNNBTiaUYG9DeyiTi+/AP97XKJR+U+c9B7eJC+6Fx2sOdE4ZEh5YHdHJVDdFk8JRR5rM+iyjcETI1uX8l6dWpT2sDCg/K3Ib/HJagWHTBLS5cvQsdvIAEeNPJYprku5M/4kpQNGZZs/7LYpS1nHo4W1n/M0LY= 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 BLAPR13MB4739.namprd13.prod.outlook.com (2603:10b6:208:306::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.25; Tue, 25 Oct 2022 08:00:36 +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; Tue, 25 Oct 2022 08:00:36 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v3 22/26] net/nfp: support IPv4 NVGRE flow item Date: Tue, 25 Oct 2022 15:59:14 +0800 Message-Id: <20221025075918.7778-23-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20221025075918.7778-1-chaoyong.he@corigine.com> References: <1666427069-10553-1-git-send-email-chaoyong.he@corigine.com> <20221025075918.7778-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR01CA0142.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::22) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BLAPR13MB4739:EE_ X-MS-Office365-Filtering-Correlation-Id: a1774843-6e32-4ce2-2b10-08dab65effe1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VbV3+Mpg8VNsR2ZoGRZHtxkTTEVnzrZcHMs4lmpLU4fiPx2xyjdT9JHpQe+oYXuuowGBuqkX817BzaMoNO1l5/4DM3UzoO/yoSa1IYSah+wYYQpkL69SJKsvRVGN+7vlUff2HjdJPWzn0s3nKw/YAprVXMmrN8qsIj9FoYYU33jNQUZ07VkKfRgTwfH7peYvBAJ8vlqWcklQvkesCLvO3xnF1zIs0SVfbjI4MwI0Z4OhQ+zU3rr5y7jPvky929aHhjTcOrqCQWxrEdysB21zxpQTp9rae3hp1agvFAhiT447Cmxz2RBGFGAHzegHNCZEeeiNtpyneLbhm4FU5kHhJl9uw4GjNaWSF3V1n5v3pYJj4VNT2fIAbZBKOyuwQWxNLhFib4dHkoyIiDFCpUmZlno+AKuQWvZXO+/Q9MRVSjOV2936d4Ipei3RSMorO9fJ2tZiwqO5AM8uukgOFNJCFkKD5JqEkMpaJL2tkUGbwi5RKoRWAX6UKLVLrKbpIiO3KYYtN03fPey/BmsIq2GQBePlc5QmLDUiB1FKwQTS0e4/r5Bz+4uJwrFoz3H7pgFgAXvtkQmImXdXLFfhg1AhIWGo1AQnWi0BQkpDqs4mjPq43mqbcytx3zeJbd7QOCELa2Si+IbCPXO7Mdj3tDVLY8wj66qJjkEnyBp7eKH9jDq3LtKIcefJFXhE9xOxCmajnnk0CdZmcEYLZ77K+4A3chM47If2sKmQsSsQvwbaXkNMMaNXfpA7M2zXWB2pp6hCtsiK1gyf+ckskLuRIbdIyw== 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)(376002)(366004)(396003)(136003)(39850400004)(346002)(451199015)(36756003)(38350700002)(86362001)(38100700002)(41300700001)(83380400001)(66946007)(1076003)(2906002)(6512007)(6666004)(26005)(186003)(6916009)(6506007)(52116002)(107886003)(478600001)(44832011)(66556008)(5660300002)(8936002)(2616005)(6486002)(8676002)(316002)(66476007)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SVJEbWFFQXhSQklJMlM2Nm1rUWVieHZ4QUJ3RTFtVE5aeXV6TzllZXU4SnZy?= =?utf-8?B?ckhwVDlRcU1RWjRsU1JWYXI3ZCtrM0J4cFZKWHRJcWtpZDBDNEJaZ0h5UkRR?= =?utf-8?B?U2orZW83RFIzcDd2R1N3VDl5RTlJTGN4OWpxd3g2bGJRYnhFSWF1MEJOUFNx?= =?utf-8?B?WDdpQmdxcWtlUmtJV1kyWGk4ZXBncVJPRnlVeUYxb0VPaVkvWmwrVlFYSFdi?= =?utf-8?B?N1hialZrRHRuM1VSbDRid3VWMktkRVJyMkhv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ZXI2cWFW?= =?utf-8?B?Z0tycUJjWWw0cGVESmlxbWRHTUl5am1sU3JJZTBQV0IxaXpSd0NDQkNYTkJ2?= =?utf-8?B?VllOMTRrdFd2QmVPdFNiajMwUE9pc1ZhOWYvNS85UHBmK3EzUkNxZzNuVGQ0?= =?utf-8?B?elE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1774843-6e32-4ce2-2b10-08dab65effe1 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 08:00:36.4342 (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: PR+xwaUQdECbB6exqI75zShxnxks0+D68V1YmlHm/o9gITBSR7PE3JBhgjlhl+3yEA1eNJh+8pw36La9ksf4gXoJsGpyc8ynq1+99M1CTY8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR13MB4739 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 fe1cb971f1..9e075a680b 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 0353eed499..226fc7d590 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -820,6 +820,26 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[], 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 @@ nfp_flow_merge_geneve(struct nfp_app_fw_flower *app_fw_flower, 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 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = { [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 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = { .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 @@ static bool 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; -- 2.29.3