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 11D46A0A02; Thu, 20 Oct 2022 04:22:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 912CB42C94; Thu, 20 Oct 2022 04:21:19 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2120.outbound.protection.outlook.com [40.107.101.120]) by mails.dpdk.org (Postfix) with ESMTP id 1668F42C85 for ; Thu, 20 Oct 2022 04:21:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZTm3ToTsqFHHNoBReENZHKz692jcKzUpZQSDia54Ftr9hghCiV8nxXwHAuSOZLnYIJvxta0Th1d/+umb/jN14h0L2ts1h2SuSJspr1rXYNMkxC79F72QkgzqiM4REGILRxQ95lNSGM4qaduAFbJaYDVt34vOQOK1gAugkwxqr425eNZZQtSqqkspbPLaEt9pV9FW0JUVwFl3KX43Z3zj5RzoV6ZrSCf+DnK5ioyxyr5Nx1YCltuwuxpq/oJRvPIvPOx1PSQqvDoDxH59lt7q51azyoHC1FHav15fid/eKTMnb5fGArrljVlMfhCMubQ4JGbOWO8qwPjX4rQ1T5ZSjw== 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=z+3XlJ+7uhKcKT6XQDSX7a9LW6wVJJK16Fg7CYtA69E=; b=LmAIs9BOPVpuXTMOmzX7NY5EyNbRxLRWrm1Gmg5vdVcwCpg+MH+H2U0YjBmPBjPoV7drUHX4X7PORrM7UkYDzhdWal1yUKwyxlzWa4g4zhCGTdMVQk8nKxJXL+ymbQqK8JIAypJD77NQgJ+ZPl7akX0UtHDXd3KNZo6bNalLAqa0M50GD0pqDKTIga9P4trdEzIYjrrtTRgxWwoZHZnXo7XB9jnp5EPsbNaOXZrj6uoxZ3pBuWgkfc7M1JZmHM7wpdty2JNiImfPhRm0JYjlqoULSVeyc57gyhO88pDLKXC7utVYXJyabgr9WgM3xAuGmudpaTpDvM0ylbE1dFDprA== 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=z+3XlJ+7uhKcKT6XQDSX7a9LW6wVJJK16Fg7CYtA69E=; b=h0F8U1rZ6rMfwJj4WCt6C3hL7b8FCbu6Ls9xA2XBi1qncyGQEgjyO4EZOoLyvlpCeB6ntgTUCv3W9WLNgKNeiIddozHOlQmW4cNcMNgSzTU9ZqJdF1LBJK/zEV4lu5ttHO3l1AXsOwWNO9XgsgEjJy5JehchKXhOwxx8SjtItSg= 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 DM4PR13MB5906.namprd13.prod.outlook.com (2603:10b6:8:4c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16; Thu, 20 Oct 2022 02:21:14 +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; Thu, 20 Oct 2022 02:21:14 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v5 10/25] net/nfp: support TCP flow item Date: Thu, 20 Oct 2022 10:19:36 +0800 Message-Id: <1666232391-29152-11-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666232391-29152-1-git-send-email-chaoyong.he@corigine.com> References: <1666092434-10357-1-git-send-email-chaoyong.he@corigine.com> <1666232391-29152-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:196::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|DM4PR13MB5906:EE_ X-MS-Office365-Filtering-Correlation-Id: 37395ed9-4e96-4021-5110-08dab241c31f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l5SYtfmvPIyzXiHH+k65OqlZnswqvMOpsp3ZYfo/IcfR2mjqxhuwBhWqB/AtetfVMOzjFLs2I+bCgbbi9bWSWwdFm4M6R+Qrx0ECvO1D/LNWmObhjrB8gm43oOLmLMldkcdGnlO6UG9YMtxpJChTWwe3w3Kv7gaQeJB0pLEblHS1Zb56Ar4jScNSAXD41ZFhIP/LZMqZlqCiBuye7r1/+OXXq3sbv97LVsgiJM5aL1DwY7YZ6uTXBBHXvnwWv15QaoeaSb+POfgTS9lHG1t4FKIXhgL20ODcgV/3hOqGSqyvu7WHEO/tjSNpvshjqbCWiyDRu3KJE9uGIeOOJTEv9zyKVrAx/sFQSG8yxG/ZqbKvnc3XEjxogWbYhEqg95VTXFg6VKpumBTiqluzTU1F0f+p3GnHEIdmrhMQJPXdgG79U7YlrpSJFC74kPXvQI4Q8uXrEFlJEGnCLV4A3HX2zxhzrfLUMEpvtyDCxVcZ2RftcR7jel+6WnCIHCUWS4hnFPyei6IxSeQdWyxhkdTD59imgOI+3fTnarY668o4Ldd8k/BmDSL7x/5SemVFvC0gB5r11w4gUfj4Kd90l6ziiEnEZafoEzzEOuCBDH1hIRYP1iTXrA9wj3nO0Ae8kwom18fXJJ0rgRFjQyGyoe3cb95DTTgqF0/sCgjtUos5/aOQ7L0hErlv9o0twl+7LkcX5ZUwhp58JvIyRb86bQ/EW0xo0yEewfeCH/hgbs2pwxYc8WjJpkprzyBynphRHXijXdxrm18wRwmIO9Gtlj+RiTbvKQbRhaz1vAMXuHbOwbMeMuVCEjJsP1qlY0aY4VyF8camGgQ763EhQ+YSd2fN+Q== 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)(376002)(39840400004)(346002)(396003)(366004)(451199015)(38100700002)(478600001)(38350700002)(316002)(6916009)(2906002)(186003)(66476007)(52116002)(66556008)(6666004)(66946007)(107886003)(4326008)(6506007)(2616005)(41300700001)(5660300002)(36756003)(8676002)(6486002)(8936002)(26005)(44832011)(86362001)(83380400001)(6512007)(473944003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UFRzakZaZjZJb3g0dDUvSXRhOU04RDZvb2lXWS92aVhndXduR3ZSd1I4aHQy?= =?utf-8?B?a09qd0RVZUtnbU9XdlVFcnpvN0FFQ2psOGgvL2d4NXNrWnQrT2FVRHI3ejJJ?= =?utf-8?B?QmtwWVZ4OHc4QkViOGh0bmo1bmV6U3ZXT05UYU1LdHpVdldEWEdmdWVyZ2tv?= =?utf-8?B?RHRuQjdSWEFVcmFRQnJpNGxRMUNabUpWMWJiU2k4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?B?T3F1NUFwc0ViZm40TDFFck9QUHFKcFhqcWFSTEh2cjRvbmdxYit4RnY2L0R5?= =?utf-8?B?OWdONEZHZFJEdVZMZ0NDOFhyckF6NnpqV1M5VjI4WFJwNjhtWDIySXlRdUY1?= =?utf-8?B?V21mbXVkR2RwK3FXYzlKbWxxb2VaN2pFUmQwcEt5a3VodTlRdUZZcDU5WmlR?= =?utf-8?B?ZGc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37395ed9-4e96-4021-5110-08dab241c31f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2022 02:21:14.3988 (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: QiPUkHevmw310XZ/sKun0JREUW4CcCB9NWaUaKS5C5m2lg9gUASHmIAd5rKnaOmOpFsRlYr9ViJeESIzseF1iOPjivTA/cJuJkwdh0DJQGQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR13MB5906 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 4869b45..670c12f 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -31,6 +31,7 @@ eth = Y ipv4 = Y ipv6 = 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 b2360fd..2e89a22 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -532,6 +532,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; @@ -761,6 +766,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] = { @@ -797,6 +874,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, @@ -812,6 +890,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), @@ -828,6 +907,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 6e5b0fa..ebea1cf 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