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 7ADABA0032; Fri, 21 Oct 2022 10:03:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02B7142BE5; Fri, 21 Oct 2022 10:02:47 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2100.outbound.protection.outlook.com [40.107.236.100]) by mails.dpdk.org (Postfix) with ESMTP id 7239342C08 for ; Fri, 21 Oct 2022 10:02:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J7XtnQWYelXyDHCi8jsf8rRvF06c/wvIFE4AaWfBRhHXImEWH3N5je2TGuQVVQkmhztkCiIBg6kV/T1fM527quZN9zY72hiykrhkQQAijwCKDcjWV+17M/jsqYwOPSS4QTN/U94BR8iER5pQZoUWxvY3mBkOMWa/Y9RRWSKVfhG1QX0thftZY07mztpaDiokgbUf1lpmLrlsvjbeBMvwrL42yXYvAccEhRwFXN7ywWC4aDoarhg7jfLf5X6XEXxzfkl/Gh6uJ5MbLE6tNjGHpOlzNeUba48cJTtgZC/0yR9r00rzh/O/6QfFc2fXERznTHsV7xmytsTXNl4z0DaFCQ== 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=EnraWQCnO/SlEhcNY5hrDMkh9EFDZif4t9RZi0t/D7s=; b=hvLLwQ7KcTHD747CqHOSPOyBKxih8HpWUHJ2h7ShH2Hph4lNDc266Da6Mau8OtlV0phi189wmN6kDu30WaaNbP8KlaP3VkWWspNaPLEek1rqdaGHzmJ5swbZOhQJKAMObGna1aE2WKiYfOnIrTXBkPmx7Tfho5C24OhOP2Fb8/xxIz/yMMtRZYzTb82FUhX4fabqQ1kvq2tQ4Vpn3coG86Xj3Z5sWZ72cl0nXm3n9Dw8L+OUvRSpDTUiNwyO7ODLwTOYcV9usJ0Ylbnuska/TzZQDHvZwTrdeYhpaS1sVZXN+yKR4iu9i8+C2V9+lNeY+7lBlVrRKAkK6Oio4rBzYg== 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=EnraWQCnO/SlEhcNY5hrDMkh9EFDZif4t9RZi0t/D7s=; b=Pm+tyLV71lGiLxbPrjfev08JirG92rKtYchM37nmMN88xSzYhWJuk2RaO9goO86T4lrjeHjbMGxcOClEL6Ud/fhw4GMOEu8qeW6bLBoHEuUnsNklFE9Hev/YNdtBkkF3UPWULsaVl4tjLhr3DgPRiV00Dgp6JqDnWeyuqWezSZM= 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 BL3PR13MB5162.namprd13.prod.outlook.com (2603:10b6:208:339::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.17; Fri, 21 Oct 2022 08:02:41 +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; Fri, 21 Oct 2022 08:02:41 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v6 10/27] net/nfp: support IPv4 flow item Date: Fri, 21 Oct 2022 16:01:46 +0800 Message-Id: <1666339323-24016-11-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666339323-24016-1-git-send-email-chaoyong.he@corigine.com> References: <1666232391-29152-1-git-send-email-chaoyong.he@corigine.com> <1666339323-24016-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0051.apcprd01.prod.exchangelabs.com (2603:1096:4:193::6) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BL3PR13MB5162:EE_ X-MS-Office365-Filtering-Correlation-Id: b2fc4e6a-41df-49a2-1934-08dab33aa09e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9SLGWgTVzHWp7uHqWOr5K0KPe2fpINwYLCjYatkzl3f6bQgjoRfFU5F5v2rkP5Dn17MaOdcIaJnESpidtANYINv6rqNiYCfHLzd/WhLATzKgyIHlwTzdfPdMNNxiIWNYtdeWuOUWV1Ccg8aM2KprHyr1ctqW4VWjqKfrXHxO23cJtCvramFMhZkFecXGoyH4cCUjD14xRHHR72NrvsBqyGDXnu/d4PmyYI3mv2M/aq/5cO1iB0HcuUbA54cVGqnWF5SguZ90M/3NBKczyL9wnwIAvLHycUDOr0AEwQUhToFbkcMMXPl+MH2ADk6jaTGoYE2n/iRn9gC2h63ZGgAswoedDk0Ty3AcADL0KaDLzvYBnVTwuiLJxQiDbcPZxGR7tMPpk3cD5Iptq493q8yoB7CYUduZTyFnXrBGR88ZOO7M0gYRFphTGiILsRujtEj641Z/urZ2nexT49BIVbW4aTbTqKhlZlTqMB/mQ/X2TwtteIgePJBF2q3fxx1W8zQPAcDnRC7ZJsnEShuUSAli6EhIBiku3dRKIQu/XwwS6FNhM6X3YRsGM0EUvYz9dmSTUypxzmCF3IsklrpugpcEb0ErQ3ydYzUdM06aE/Z6W3jj1LnYzkxRdCj9iwcRGlEz9RPIHeAFspp026bCrOgq/ABXmsOtOr6fBI2Q9pdmvPp8yuQHKqAbPcBu9314Bv+dhucCWOT99eFP36rD+n8bVTfxn83JxrMHCMOW+mIPgAH+HAzGz9573Ep7qwlD/+np 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)(396003)(346002)(136003)(39840400004)(366004)(451199015)(2616005)(6916009)(38350700002)(6512007)(6506007)(52116002)(8936002)(66946007)(4326008)(186003)(107886003)(8676002)(41300700001)(2906002)(66556008)(316002)(66476007)(38100700002)(44832011)(26005)(5660300002)(83380400001)(478600001)(66574015)(6486002)(86362001)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YmNic1pWb2RWVjJUQUg3V29uMDh5R3VFbHI3emRnaWVIWHRmVVRnZGFHWWE0?= =?utf-8?B?TGtlRW00YVZhVVhwbWR1Um1VQVI4MklNeFZhZHZhdzBBblV1SGYxd3hnL0ht?= =?utf-8?B?UVUrdW81THdQeVU1NHIyLzNyM0c1YTYyRjd2RGVpWGJzcklHSmFjdzB0aGFR?= =?utf-8?B?VCs3RDZ5dVE1ZmxrcDJyS005d1c1RVRVSzhOT2FLRXpYbSthaXMvQU5WMVI4?= =?utf-8?B?NmJmSzdrNFl0eXE3eWVqY0NOWTE1MDFOUXNudlNJUlBJcTVPVGJCTXI3bnNt?= =?utf-8?B?RGt2dWt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NmdwVzZ3M08xYjc5cUlIL3B6N3cr?= =?utf-8?B?Rk5Fbk5wZksxU0Y2OXZFNXdvTTh5MFhKRnE5TFRlekVld0c1NG5mM1lZUmVE?= =?utf-8?B?RkE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2fc4e6a-41df-49a2-1934-08dab33aa09e X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2022 08:02:41.3505 (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: 9B+6niU7gThTdA9cov1qrI7dAy4Twh2hcFWUXiUeXBDR+p/HcSu60QwbRuO37mnty/GzX+SHkzr9aTAzAEQ9mz5smD0QTGo3kRCf7Mz4j4o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR13MB5162 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 data structure and logics, to support the offload of IPv4 item. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- doc/guides/nics/features/nfp.ini | 1 + drivers/net/nfp/flower/nfp_flower_cmsg.h | 38 ++++++++++++++++++ drivers/net/nfp/nfp_flow.c | 68 +++++++++++++++++++++++++++++++- 3 files changed, 106 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index b0af2a0..bf59123 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -28,6 +28,7 @@ Usage doc = Y [rte_flow items] eth = Y +ipv4 = Y port_id = Y vlan = Y diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index d776e37..5964ecf 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -253,6 +253,44 @@ struct nfp_flower_mac_mpls { rte_be32_t mpls_lse; }; +/* + * L4 ports (for UDP, TCP, SCTP) (1W/4B) + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | port_src | port_dst | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_flower_tp_ports { + rte_be16_t port_src; + rte_be16_t port_dst; +}; + +struct nfp_flower_ip_ext { + uint8_t tos; + uint8_t proto; + uint8_t ttl; + uint8_t flags; +}; + +/* + * L3 IPv4 details (3W/12B) + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | DSCP |ECN| protocol | ttl | flags | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv4_addr_src | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv4_addr_dst | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_flower_ipv4 { + struct nfp_flower_ip_ext ip_ext; + rte_be32_t ipv4_src; + rte_be32_t ipv4_dst; +}; + struct nfp_fl_act_head { uint8_t jump_id; uint8_t len_lw; diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index 802fa6a..7a7a873 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -522,6 +522,11 @@ struct nfp_mask_id_entry { PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_VLAN detected"); key_ls->vlan = NFP_FLOWER_MASK_VLAN_CFI; break; + case RTE_FLOW_ITEM_TYPE_IPV4: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV4 detected"); + key_ls->key_layer |= NFP_FLOWER_LAYER_IPV4; + key_ls->key_size += sizeof(struct nfp_flower_ipv4); + break; default: PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type); return -ENOTSUP; @@ -656,13 +661,58 @@ struct nfp_mask_id_entry { return 0; } +static int +nfp_flow_merge_ipv4(struct rte_flow *nfp_flow, + char **mbuf_off, + const struct rte_flow_item *item, + const struct nfp_flow_item_proc *proc, + bool is_mask) +{ + struct nfp_flower_ipv4 *ipv4; + const struct rte_ipv4_hdr *hdr; + struct nfp_flower_meta_tci *meta_tci; + const struct rte_flow_item_ipv4 *spec; + const struct rte_flow_item_ipv4 *mask; + + spec = item->spec; + mask = item->mask ? item->mask : proc->mask_default; + meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data; + + if (spec == NULL) { + PMD_DRV_LOG(DEBUG, "nfp flow merge ipv4: no item->spec!"); + goto ipv4_end; + } + + /* + * reserve space for L4 info. + * rte_flow has ipv4 before L4 but NFP flower fw requires L4 before ipv4 + */ + if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_TP) + *mbuf_off += sizeof(struct nfp_flower_tp_ports); + + hdr = is_mask ? &mask->hdr : &spec->hdr; + ipv4 = (struct nfp_flower_ipv4 *)*mbuf_off; + + ipv4->ip_ext.tos = hdr->type_of_service; + ipv4->ip_ext.proto = hdr->next_proto_id; + ipv4->ip_ext.ttl = hdr->time_to_live; + ipv4->ipv4_src = hdr->src_addr; + ipv4->ipv4_dst = hdr->dst_addr; + +ipv4_end: + *mbuf_off += sizeof(struct nfp_flower_ipv4); + + return 0; +} + /* 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] = { .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_ETH), }, [RTE_FLOW_ITEM_TYPE_ETH] = { - .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_VLAN), + .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_VLAN, + RTE_FLOW_ITEM_TYPE_IPV4), .mask_support = &(const struct rte_flow_item_eth){ .hdr = { .dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", @@ -676,6 +726,7 @@ struct nfp_mask_id_entry { .merge = nfp_flow_merge_eth, }, [RTE_FLOW_ITEM_TYPE_VLAN] = { + .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_IPV4), .mask_support = &(const struct rte_flow_item_vlan){ .hdr = { .vlan_tci = RTE_BE16(0xefff), @@ -687,6 +738,21 @@ struct nfp_mask_id_entry { .mask_sz = sizeof(struct rte_flow_item_vlan), .merge = nfp_flow_merge_vlan, }, + [RTE_FLOW_ITEM_TYPE_IPV4] = { + .mask_support = &(const struct rte_flow_item_ipv4){ + .hdr = { + .type_of_service = 0xff, + .fragment_offset = RTE_BE16(0xffff), + .time_to_live = 0xff, + .next_proto_id = 0xff, + .src_addr = RTE_BE32(0xffffffff), + .dst_addr = RTE_BE32(0xffffffff), + }, + }, + .mask_default = &rte_flow_item_ipv4_mask, + .mask_sz = sizeof(struct rte_flow_item_ipv4), + .merge = nfp_flow_merge_ipv4, + }, }; static int -- 1.8.3.1