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 9A40BA0560; Tue, 18 Oct 2022 13:28:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3739442B73; Tue, 18 Oct 2022 13:27:56 +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 22D1142B79 for ; Tue, 18 Oct 2022 13:27:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UgwTsZJGDT0HdZRpoIalCaQG5//xlSL+lBxwXFE5GiZU4E+ajcYe/SL1Gec4AmdDDq02KheMqhi9en6wBKHWyAq84pL9oAelg9VvTdsMPmv99jf3GOtScRaB07DOnRzh+T7ZOzroN/wvpyAo4NRL8vyGshKkX71JToKwhd9s+8Zxm8SY2lIof8aspiWDH7AYErcSudCS/SZFJ9Pl0kaped33Zxie+izdnMWR5p/i+w+rfSgTS9NLe5dMVIKa01ksiPE6qBTfIutXJqUHDfQuh2ujkci7WPXK2Ijl/dOiJW2a2hPrj81vFWv8LzmW9Jn4W8rsPecp8pC+SsmBTq6S1w== 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=Lx7Z77tzTIDsPGHr7GAo0ww5hzyIJvK56nPQ6r6C/uQ=; b=flxUagUDZ19nWJXz2PKkMWFP46Z879x0n6MTu6bZwItLfH0Ev4hKR6WIeN5nCnHI1jRsXrt9fESG9nx2mcupqMRiiLeZd32Lc6AFZbL14K4lLdJer7kz4VnI2x9LLVau1qz8Rvc+Es2oZ0EEkOz8WcOp2Xf3JDfWAbBBe6tJnFFJ9V90F9zTeW9ffzGdIJiQIoPbr8Dfzn8OWjsTo3lLeitiD7PLcx/rhUZiZvHvxy/h2HqyYuQmpBZ+RqFGSNHnFow7iNlJnsdPbM8yslY47SUQsopF71Fn1MOn1zDHWIw2C4X46HzrDiHO7DzuEwzg28kAy1FNNuWSy3suOD3x/g== 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=Lx7Z77tzTIDsPGHr7GAo0ww5hzyIJvK56nPQ6r6C/uQ=; b=FX6+HtE1UQQd7dKIJzDt9tKuUE83bPmhKl6y/HPEHTo8AtbUa30Z9yMyZIwzJm6nLxpjeMiFVp4KnfbemjuHtMiUHKRDxubyT+NZ0htyYQbywzJVNPJA+yGYl05yDB5h1x69QT5DDuLFA8NWkYphx6dfcrOThg3DzPnBy5xJ5tA= 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 CO3PR13MB5686.namprd13.prod.outlook.com (2603:10b6:303:179::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16; Tue, 18 Oct 2022 11:27:53 +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, 18 Oct 2022 11:27:53 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v4 10/25] net/nfp: support TCP flow item Date: Tue, 18 Oct 2022 19:26:59 +0800 Message-Id: <1666092434-10357-11-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666092434-10357-1-git-send-email-chaoyong.he@corigine.com> References: <1666092434-10357-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR02CA0052.apcprd02.prod.outlook.com (2603:1096:4:54::16) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CO3PR13MB5686:EE_ X-MS-Office365-Filtering-Correlation-Id: a8ed9ae5-9385-4d34-e53f-08dab0fbcc53 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ReAag5J8UK/CJ0SDdXWHtbFLtDLrycwiTxpRS9kFotFikqvPTDh4L4Cy0wOF60BJVDh0Z7BrF1AKTRn8h3m6Bu4BQcXAQRcigJECY/XZBh0op1iyCSYhc136DjbgOBkNiNKiXfIF+YlwLAjUy3678G0X5WDPyyG0RxMRTk1QGlqQOvAuM8rAkwkgdQE6dsq9Q99dl7gdD3P7GqiDY4q49gK07pm7vU1TcCP1PQ2Fn+o7uU+E8dEDztE7dC71DAvEp464sqmmoHaq8HPEFmqowXm+UWZq8dlqQ/amekv8yXhuB3fNtHt5Jv7BrKiOOgGVO2RQxU2i6resiGCbS8JlBlPLQExW3WW9nMbuYKrIFydgpXEG2afzrnJkjHlgkWSYYGPgYvvLyukr8/7JR9euRw6y+WrNtP2pGBzHJqxAf6aavxaIA59hyEiT4a1DuzLMBQQmvcop/KhY1qwCAu4vbvx/MQWseFGAAR6hdyUNCUdaKXMzHjJxN5MLQGGSl2OA18jX0yuWW2Z6dH4jDYwl9f/RzBipdEIVTuWDCeXQHw5fBFnU8uD2d8LmXHSR8eeonc20YXENUpVOGfhDGcDTNxjKpdMsodZojfzLIuW8TZwZ11yU3hGIvtwRU7Vd07oHxKLovyJhodUmKeKGPpIRO2NDJyV8z/y+uq6DJE8DbMDezKyH737HGj//OpX8weqxhxBSQRX5venV8erHuHG093Xb86FtSMW79up7R37Rus2as1/CrphbMsizmZBJAKmFHM5ObmxRpFFVMacNoLKpaytL3LMtzANXYeyJi4suCSCPYjZ2HYbMl88wUENeydA2 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)(346002)(366004)(39840400004)(396003)(136003)(376002)(451199015)(38350700002)(38100700002)(2906002)(41300700001)(316002)(66946007)(66556008)(66476007)(83380400001)(4326008)(8676002)(6916009)(86362001)(44832011)(2616005)(8936002)(186003)(36756003)(5660300002)(6506007)(107886003)(6486002)(478600001)(26005)(6512007)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YTMvci8zM3NseWpUdm1qdmg0dHM5bmR2QXVQaTJqTlRVSXRsTHJPUzIwRGNW?= =?utf-8?B?T3Y3VUJoNCtOMmVDVGV5bkJDSnRPaE5iM0RJWklVU1JuckZRTTl6NEhwVmww?= =?utf-8?B?ZlNGdmVPTEdWdmk0aVIvaEwrTTdnK1phcktyejJWTDY0L3Vpd0dNalBXdFFo?= =?utf-8?B?SmZDTWZIY25EYnI2SU9icE9GUGNKdHl3UUpwdmMzZFQ0MWJoSGlEaTZORDUz?= =?utf-8?B?RjJ0c1NrZUx3ajhoZERpTGhwTXdxbVdQT3QzK2s0SzhiQ1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?B?S2tXY1JNZDVSWWd4ZXF6b2JCbUc1YXhNZm1XRG9sSlhMMVJxSkY4bUkyTGlW?= =?utf-8?B?eGF1WFZaWUxaY1RjQ0FPYnBTNXcvanJRZ3lrVlBrc1FpVDBZdGpwakNhVTBP?= =?utf-8?B?SFE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8ed9ae5-9385-4d34-e53f-08dab0fbcc53 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 11:27:53.8770 (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: T+1ALVZxGmCpoO8yRVPYdbR8W2q4Ql6xTUNNbowaGLW6Xr5ISO3TqZPjpkkfsCSVWe0/gJ/AehuvVf93pWAwadTIBdFU+//aD8nghmph6ZI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO3PR13MB5686 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 TCP item. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- doc/guides/nics/features/nfp.ini | 1 + drivers/net/nfp/nfp_flow.c | 91 ++++++++++++++++++++++++++++++++++++++++ drivers/net/nfp/nfp_flow.h | 7 ++++ 3 files changed, 99 insertions(+) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index fb40473..108f47d 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -32,6 +32,7 @@ ipv4 = Y ipv6 = Y ipv6_frag_ext = Y port_id = Y +tcp = Y vlan = Y [rte_flow actions] diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index 043e5f8..7727c32 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -544,6 +544,11 @@ struct nfp_mask_id_entry { key_ls->key_layer |= NFP_FLOWER_LAYER_IPV6; key_ls->key_size += sizeof(struct nfp_flower_ipv6); break; + case RTE_FLOW_ITEM_TYPE_TCP: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_TCP detected"); + key_ls->key_layer |= NFP_FLOWER_LAYER_TP; + key_ls->key_size += sizeof(struct nfp_flower_tp_ports); + break; default: PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type); return -ENOTSUP; @@ -773,6 +778,78 @@ struct nfp_mask_id_entry { return 0; } +static int +nfp_flow_merge_tcp(struct rte_flow *nfp_flow, + char **mbuf_off, + const struct rte_flow_item *item, + const struct nfp_flow_item_proc *proc, + bool is_mask) +{ + uint8_t tcp_flags; + struct nfp_flower_tp_ports *ports; + struct nfp_flower_ipv4 *ipv4 = NULL; + struct nfp_flower_ipv6 *ipv6 = NULL; + const struct rte_flow_item_tcp *spec; + const struct rte_flow_item_tcp *mask; + struct nfp_flower_meta_tci *meta_tci; + + spec = item->spec; + if (spec == NULL) { + PMD_DRV_LOG(DEBUG, "nfp flow merge tcp: no item->spec!"); + return 0; + } + + meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data; + if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) { + ipv4 = (struct nfp_flower_ipv4 *) + (*mbuf_off - sizeof(struct nfp_flower_ipv4)); + ports = (struct nfp_flower_tp_ports *) + ((char *)ipv4 - sizeof(struct nfp_flower_tp_ports)); + } else { /* IPv6 */ + ipv6 = (struct nfp_flower_ipv6 *) + (*mbuf_off - sizeof(struct nfp_flower_ipv6)); + ports = (struct nfp_flower_tp_ports *) + ((char *)ipv6 - sizeof(struct nfp_flower_tp_ports)); + } + + mask = item->mask ? item->mask : proc->mask_default; + if (is_mask) { + ports->port_src = mask->hdr.src_port; + ports->port_dst = mask->hdr.dst_port; + tcp_flags = mask->hdr.tcp_flags; + } else { + ports->port_src = spec->hdr.src_port; + ports->port_dst = spec->hdr.dst_port; + tcp_flags = spec->hdr.tcp_flags; + } + + if (ipv4) { + if (tcp_flags & RTE_TCP_FIN_FLAG) + ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_FIN; + if (tcp_flags & RTE_TCP_SYN_FLAG) + ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_SYN; + if (tcp_flags & RTE_TCP_RST_FLAG) + ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_RST; + if (tcp_flags & RTE_TCP_PSH_FLAG) + ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_PSH; + if (tcp_flags & RTE_TCP_URG_FLAG) + ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_URG; + } else { /* IPv6 */ + if (tcp_flags & RTE_TCP_FIN_FLAG) + ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_FIN; + if (tcp_flags & RTE_TCP_SYN_FLAG) + ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_SYN; + if (tcp_flags & RTE_TCP_RST_FLAG) + ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_RST; + if (tcp_flags & RTE_TCP_PSH_FLAG) + ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_PSH; + if (tcp_flags & RTE_TCP_URG_FLAG) + ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_URG; + } + + 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] = { @@ -809,6 +886,7 @@ struct nfp_mask_id_entry { .merge = nfp_flow_merge_vlan, }, [RTE_FLOW_ITEM_TYPE_IPV4] = { + .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP), .mask_support = &(const struct rte_flow_item_ipv4){ .hdr = { .type_of_service = 0xff, @@ -824,6 +902,7 @@ struct nfp_mask_id_entry { .merge = nfp_flow_merge_ipv4, }, [RTE_FLOW_ITEM_TYPE_IPV6] = { + .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP), .mask_support = &(const struct rte_flow_item_ipv6){ .hdr = { .vtc_flow = RTE_BE32(0x0ff00000), @@ -840,6 +919,18 @@ struct nfp_mask_id_entry { .mask_sz = sizeof(struct rte_flow_item_ipv6), .merge = nfp_flow_merge_ipv6, }, + [RTE_FLOW_ITEM_TYPE_TCP] = { + .mask_support = &(const struct rte_flow_item_tcp){ + .hdr = { + .tcp_flags = 0xff, + .src_port = RTE_BE16(0xffff), + .dst_port = RTE_BE16(0xffff), + }, + }, + .mask_default = &rte_flow_item_tcp_mask, + .mask_sz = sizeof(struct rte_flow_item_tcp), + .merge = nfp_flow_merge_tcp, + }, }; static int diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h index f6bd3e4..b3bd949 100644 --- a/drivers/net/nfp/nfp_flow.h +++ b/drivers/net/nfp/nfp_flow.h @@ -23,6 +23,13 @@ #define NFP_FLOWER_LAYER2_GENEVE_OP (1 << 6) #define NFP_FLOWER_LAYER2_TUN_IPV6 (1 << 7) +/* Compressed HW representation of TCP Flags */ +#define NFP_FL_TCP_FLAG_FIN (1 << 0) +#define NFP_FL_TCP_FLAG_SYN (1 << 1) +#define NFP_FL_TCP_FLAG_RST (1 << 2) +#define NFP_FL_TCP_FLAG_PSH (1 << 3) +#define NFP_FL_TCP_FLAG_URG (1 << 4) + #define NFP_FL_META_FLAG_MANAGE_MASK (1 << 7) #define NFP_FLOWER_MASK_VLAN_CFI (1 << 12) -- 1.8.3.1