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 6A4194281E; Fri, 24 Mar 2023 04:27:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EEC50406B8; Fri, 24 Mar 2023 04:27:27 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2086.outbound.protection.outlook.com [40.107.93.86]) by mails.dpdk.org (Postfix) with ESMTP id CE85C4068E for ; Fri, 24 Mar 2023 04:27:26 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d1oLUQR0L7EYEMYwat1EbIXs0mrP0OeOmgG5npPVcQ9ezojsLRe9jImCOFZBAIpP7otf+2XsvGde637jVrU7TA6/ivkVN6K/H9pOKRM66DJ2PpeJ4fpYjfDcF1tO6npWtkzPK/GvcyL7qD1XVV3lBn+7ir5h6RmN7SlbZ4QuUCsdUfpjM2o1P1AfEK1HowNPFqYnpomv5Ac/Hc/mPdFmYWJ3ESrw92LSxFk1eDebOsfkupgaUS+PvGuRufvFduriFZWC8Olf7hFaG+OqpjmENs+g9sBli+Nt2hZKhZg7MQZoucPkypJIVdJhCxSgbAcg6dhAoZ6NlHEF+FBMSAxk3A== 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=PEFea37agfGB4hpUuh26JPti8D7vVX4rELuzoA7KgMk=; b=eLr7d2C+Q2Vj5Rbrv96OqfqaWC26dZQBuT1d+CJuOSjciuEPDXAqlJA+TM+5OseI3Hoh24SCwUVY/tt6mdv8ua2tp1DZqopyhcHaV7GdkVOr+4JsSAKBhY6FW2AqogcvN5COCqfHi67YoBNITepLIJx1TlZW5AgV78phrrwZFyRXkgweMhzfK8A9PQAkRuEmLDsvHzMtvI2NxCsvk+boOB21orGCvjxy0tXwNnS15286DaY/5ZsFXSM4vFpMjJWWsZ8slV8qXzgfLK21Q6WsQxJGukurL4H8rc9YiFa2VvOIETFNMSkW5h12pp5oZc/IOvckXMUoeLXA+FCF6AHetw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PEFea37agfGB4hpUuh26JPti8D7vVX4rELuzoA7KgMk=; b=ICB3g4TudNy5VPIb2oV5ddZ77I+2eX7Do1aMOVpB7lv53OxqBrhCkT3WoUeuNjomOYpqQIni1G2Zve7wZU0f3lF6o0nkwYaH7phvvT35GD5EZs+kfAqHJkkk/Or0GM/IKHFAQ3C38OSpgDO3jsY5jHDP9G41QegNebEBpSl8eXvvz7++3uJ/f0DPBlOWlRcgASuxYtzCsJpvs/eQZmYdUNDuOX6Q5pAddKVvmrTZ+1ZCgufqYwFAU3ztS4m4j+YrFyzjtyjlQBRzjWYwGJRgBZvC10GfDEsqfAUJyzta8lfvAGWt+afqclEao2JWjF/sy73YTjFO6Oz81vOfrU/jIg== Received: from BN9PR03CA0988.namprd03.prod.outlook.com (2603:10b6:408:109::33) by SJ1PR12MB6097.namprd12.prod.outlook.com (2603:10b6:a03:488::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Fri, 24 Mar 2023 03:27:24 +0000 Received: from BN8NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::7e) by BN9PR03CA0988.outlook.office365.com (2603:10b6:408:109::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38 via Frontend Transport; Fri, 24 Mar 2023 03:27:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT052.mail.protection.outlook.com (10.13.177.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.22 via Frontend Transport; Fri, 24 Mar 2023 03:27:23 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 23 Mar 2023 20:27:12 -0700 Received: from nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 23 Mar 2023 20:27:09 -0700 From: dong zhou To: , , Aman Singh , Yuying Zhang , "Ferruh Yigit" , Andrew Rybchenko , Olivier Matz CC: , , Dong Zhou Subject: [RFC PATCH] ethdev: add flow item for RoCE infiniband BTH Date: Fri, 24 Mar 2023 06:26:15 +0300 Message-ID: <20230324032615.4141031-1-dongzhou@nvidia.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT052:EE_|SJ1PR12MB6097:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e642fb1-9736-40c0-aebd-08db2c17af39 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UVPidcYmH0mHSOb+3LsSFBn3CnUCT403rWcAgEZ95obwCwRZKv44OeFM4l/j7etUfOscOJj9B79uTEj4SZlgvzRxoAtlps4Y/ua++HQwYAbriJuRNlzOHqP+TV+ylLHqwFJsFN//YZZJ1gkxlRrPCGderW1nR3BVMB2HA6vvALekpLEd3t0xYdhqHwUcGy/nzcmqvsJPDYixn/zT4ySgkS4YmpPwmipBn5mNCk1qxnCJR7bQL491f65qtupq9nxIqAog1FKa+qmOWLMwElrwZeU584CNHHpk+GHiwUrIbj0RsQIeHK/q0G6Smcu7B7BLdCkkQ6PXCd9qvritVT+HXFnXa3Y6HGGzrjY9U1+y0+IeRLJhbUlm0ZEU/XET4+G4QP50QC5Vra+n3BDw2ED1N3Jzpr4C7qGVPBAnuKDAgPmi7+pixGVTg4ZCE/AUKA/H/OADI2aND+QEWh9T5v6K8IeMUMnhcyfdWo7xgEcRpqTTjjOpnntdz2UnoXDtv9FrOpxlMTN1vDcxhv0k85JDuNehydnNDTlV1mNsEei1CzGDFwoZDq8i17V1Sy5incPkg/VDoC36ekZscPZdrXE4s6zc1TXhqOgV3CeuMrRX+Hg9cMU2rZUukhfDQMMmXS1d6yiagvDR8VxeLRKbC7SyAl8wKV9MIDmUxOeN9mz9HkXtUgQZun+0GWlfeALIim3xEvDdp1KNkAoLDWyc3vyb3HfVSiSqZGyjOYuK7/ghkgow4z+swooHGonBFX+9OmEx X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(376002)(39860400002)(346002)(451199018)(46966006)(36840700001)(40470700004)(47076005)(478600001)(66574015)(426003)(1076003)(6666004)(107886003)(16526019)(6286002)(186003)(26005)(55016003)(40480700001)(86362001)(36756003)(7696005)(2906002)(336012)(40460700003)(8936002)(82310400005)(2616005)(5660300002)(356005)(8676002)(4326008)(70586007)(70206006)(83380400001)(316002)(36860700001)(110136005)(41300700001)(7636003)(54906003)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2023 03:27:23.6689 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e642fb1-9736-40c0-aebd-08db2c17af39 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6097 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 From: Dong Zhou IB(InfiniBand) is one type of networking used in high-performance computing with high throughput and low latency. Like Ethernet, IB defines a layered protocol (Physical, Link, Network, Transport Layers). IB provides native support for RDMA(Remote DMA), an extension of the DMA that allows direct access to remote host memory without CPU intervention. IB network requires NICs and switches to support the IB protocol. RoCE(RDMA over Converged Ethernet) is a network protocol that allows RDMA to run on Ethernet. RoCE encapsulates IB packets on ethernet and has two versions, RoCEv1 and RoCEv2. RoCEv1 is an ethernet link layer protocol, IB packets are encapsulated in the ethernet layer and use ethernet type 0x8915. RoCEv2 is an internet layer protocol, IB packets are encapsulated in UDP payload and use a destination port 4791, The format of the RoCEv2 packet is as follows: ETH + IP + UDP(dport 4791) + IB(BTH + ExtHDR + PAYLOAD + CRC) BTH(Base Transport Header) is the IB transport layer header, RoCEv1 and RoCEv2 both contain this header. This patch introduces a new RTE item to match the IB BTH in RoCE packets. One use of this match is that the user can monitor RoCEv2's CNP(Congestion Notification Packet) by matching BTH opcode 0x81. This patch also adds the testpmd command line to match the RoCEv2 BTH. Usage example: testpmd> flow create 0 group 1 ingress pattern eth / ipv4 / udp dst is 4791 / ib_bth opcode is 0x81 dst_qp is 0xd3 / end actions queue index 0 / end Signed-off-by: Dong Zhou --- app/test-pmd/cmdline_flow.c | 58 ++++++++++++++++++ doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 +++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 ++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 27 ++++++++ lib/net/rte_ib.h | 68 +++++++++++++++++++++ 7 files changed, 168 insertions(+) create mode 100644 lib/net/rte_ib.h diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 5fbc450849..3ff33b281d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -531,6 +531,11 @@ enum index { ITEM_QUOTA_STATE_NAME, ITEM_PORT_AFFINITY, ITEM_PORT_AFFINITY_VALUE, + ITEM_IB_BTH, + ITEM_IB_BTH_OPCODE, + ITEM_IB_BTH_PKEY, + ITEM_IB_BTH_DST_QPN, + ITEM_IB_BTH_PSN, /* Validate/create actions. */ ACTIONS, @@ -1517,6 +1522,7 @@ static const enum index next_item[] = { ITEM_QUOTA, ITEM_PORT_AFFINITY, ITEM_IPSEC_SYNDROME, + ITEM_IB_BTH, END_SET, ZERO, }; @@ -2025,6 +2031,15 @@ static const enum index item_ipsec_syndrome[] = { ZERO, }; +static const enum index item_ib_bth[] = { + ITEM_IB_BTH_OPCODE, + ITEM_IB_BTH_PKEY, + ITEM_IB_BTH_DST_QPN, + ITEM_IB_BTH_PSN, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -5750,6 +5765,46 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct mlx5_flow_item_ipsec_syndrome, syndrome)), }, + [ITEM_IB_BTH] = { + .name = "ib_bth", + .help = "match ib bth fields", + .priv = PRIV_ITEM(IB_BTH, + sizeof(struct rte_flow_item_ib_bth)), + .next = NEXT(item_ib_bth), + .call = parse_vc, + }, + [ITEM_IB_BTH_OPCODE] = { + .name = "opcode", + .help = "match ib bth opcode", + .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth, + hdr.opcode)), + }, + [ITEM_IB_BTH_PKEY] = { + .name = "pkey", + .help = "partition key", + .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth, + hdr.pkey)), + }, + [ITEM_IB_BTH_DST_QPN] = { + .name = "dst_qp", + .help = "destination qp", + .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth, + hdr.dst_qp)), + }, + [ITEM_IB_BTH_PSN] = { + .name = "psn", + .help = "packet sequence number", + .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth, + hdr.psn)), + }, /* Validate/create actions. */ [ACTIONS] = { .name = "actions", @@ -12634,6 +12689,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT: mask = &ipv6_routing_ext_default_mask; break; + case RTE_FLOW_ITEM_TYPE_IB_BTH: + mask = &rte_flow_item_ib_bth_mask; + break; default: break; } diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 510cc6679d..54045a29a0 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -103,6 +103,7 @@ gtpc = gtpu = gtp_psc = higig2 = +ib_bth = icmp = icmp6 = icmp6_nd_na = diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 1d81334e96..363bbdd5d8 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1574,6 +1574,13 @@ Matches ipv6 routing extension header. - ``type``: IPv6 routing extension header type. - ``segments_left``: How many IPv6 destination addresses carries on +Item: ``IB_BTH`` +^^^^^^^^^^^^^^^^ + +Matches an InfiniBand base transport header in RoCE packet. + +- ``hdr``: InfiniBand base transport header definition (``rte_ib.h``). + Actions ~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 0c3317ee06..de90958596 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3741,6 +3741,12 @@ This section lists supported pattern items and their attributes, if any. - ``send_to_kernel``: send packets to kernel. +- ``ib_bth``: match InfiniBand BTH(base transport header). + + - ``opcode {unsigned}``: Opcode. + - ``pkey {unsigned}``: Partition key. + - ``dst_qp {unsigned}``: Destination Queue Pair. + - ``psn {unsigned}``: Packet Sequence Number. Actions list ^^^^^^^^^^^^ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 515edb0c01..61066aa615 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -179,6 +179,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PORT_AFFINITY, sizeof(struct rte_flow_item_port_affinity)), MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext), rte_flow_item_ipv6_routing_ext_conv), + MK_FLOW_ITEM(IB_BTH, sizeof(struct rte_flow_item_ib_bth)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 1590cd0498..d78bcf17cd 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -691,6 +692,13 @@ enum rte_flow_item_type { * See struct rte_flow_item_ipv6_routing_ext. */ RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT, + + /** + * Matches an InfiniBand base transport header in RoCE packet. + * + * See struct rte_flow_item_ib_bth. + */ + RTE_FLOW_ITEM_TYPE_IB_BTH, }; /** @@ -2284,6 +2292,25 @@ rte_flow_item_port_affinity_mask = { }; #endif +/** + * RTE_FLOW_ITEM_TYPE_IB_BTH. + * + * Matches an InfiniBand base transport header in RoCE packet. + */ +struct rte_flow_item_ib_bth { + struct rte_ib_bth hdr; /**< InfiniBand base transport header definition. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_IB_BTH. */ +#ifndef __cplusplus +static const struct rte_flow_item_ib_bth rte_flow_item_ib_bth_mask = { + .hdr = { + .opcode = 0xff, + .dst_qp = "\xff\xff\xff", + }, +}; +#endif + /** * Action types. * diff --git a/lib/net/rte_ib.h b/lib/net/rte_ib.h new file mode 100644 index 0000000000..c1b2797815 --- /dev/null +++ b/lib/net/rte_ib.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2023 NVIDIA Corporation & Affiliates + */ + +#ifndef RTE_IB_H +#define RTE_IB_H + +/** + * @file + * + * InfiniBand headers definitions + * + * The infiniBand headers are used by RoCE (RDMA over Converged Ethernet). + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * InfiniBand Base Transport Header according to + * IB Specification Vol 1-Release-1.4. + */ +__extension__ +struct rte_ib_bth { + uint8_t opcode; /**< Opcode. */ +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + uint8_t tver:4; /**< Transport Header Version. */ + uint8_t padcnt:2; /**< Pad Count. */ + uint8_t m:1; /**< MigReq. */ + uint8_t se:1; /**< Solicited Event. */ +#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint8_t se:1; /**< Solicited Event. */ + uint8_t m:1; /**< MigReq. */ + uint8_t padcnt:2; /**< Pad Count. */ + uint8_t tver:4; /**< Transport Header Version. */ +#endif + rte_be16_t pkey; /**< Partition key. */ +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + uint8_t rsvd0:6; /**< Reserved. */ + uint8_t b:1; /**< BECN. */ + uint8_t f:1; /**< FECN. */ +#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint8_t f:1; /**< FECN. */ + uint8_t b:1; /**< BECN. */ + uint8_t rsvd0:6; /**< Reserved. */ +#endif + uint8_t dst_qp[3]; /**< Destination QP */ +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + uint8_t rsvd1:7; /**< Reserved. */ + uint8_t a:1; /**< Acknowledge Request. */ +#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint8_t a:1; /**< Acknowledge Request. */ + uint8_t rsvd1:7; /**< Reserved. */ +#endif + uint8_t psn[3]; /**< Packet Sequence Number */ +} __rte_packed; + +/** RoCEv2 default port. */ +#define RTE_ROCEV2_DEFAULT_PORT 4791 + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_IB_H */ -- 2.27.0