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 C6CD343787; Mon, 25 Dec 2023 11:24:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D58EC402E3; Mon, 25 Dec 2023 11:24:50 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2057.outbound.protection.outlook.com [40.107.93.57]) by mails.dpdk.org (Postfix) with ESMTP id 4642240297 for ; Mon, 25 Dec 2023 11:24:49 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hfXcbTLg1VrZV4JqZnJ3xdrufU8E5M/i5vGRbAlrHMxzDxBPqBPu3ilgg8dqZcAxw5D0KOI3NYrFQ93FmIEAobpbYU3mc9bkWWou7uwy7niKxf7Y2RvTl3pNPNmpuZAOL7QVONotYtMKebjYjxE9KZq7UpJZ0YMJVvpWCmx9lwFBi6Yj/kYwnNN5mIvBtmaxq+ag/S9qks0PGyRvLCClYyop/2Cg3s74cCCLdhNuqOGRVbU5Xz4O3Dt2PRnHYaHs9l5n8tdJlibgt9lcOPhGe9khrs6OSIAF+PhCgSpoK6rG+WwE3Yzx5GncnIR4NhZZ2Wpy5Ec6MsRADmYT92VjYw== 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=sRqDBJ5hDgzSBliPfpsrMl19lbrPLZXMFVJLkqsWBBE=; b=oXjqMiWQZWSq8Pm4F0jwHSIkL/rNZMxwIexXQiBatnZRFtG7vsg0x80OUaC90OIN3ZDLL0UDZM9Ut1nkIHKinPUF+si04YB2uiVy+HfYIw4ZQ3/UnqQnm+YNSVtT5W/kBAXOIveV54nTJ0OMCklxzxTAYGJcEUuq2gUBMfNZcXYrtEtP2tk9ZKnrYjieJfIuN+aZsyhtSSIv6tDeYweUZ6FGlAEx0vVroiXzB2KBiaMOZSpm0YgHxfsJ43w5S6+Ul9amt0SMU/SHuD1HVcblx3gBZ6Da+N0x5VpFfy2UN3sCg8/Og4Ptl4el9/8bJPga3bGglCd4xkfSeXBqPyNxLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=dpdk.org 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 (0) 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=sRqDBJ5hDgzSBliPfpsrMl19lbrPLZXMFVJLkqsWBBE=; b=GszhzoBLta3zeMugSP1Y1keJTmZUTmO4tqmk8Sa3JY+OuVs/krgo9Y/YBK+xDl1mKNUI0dZwF5nlbH4a2nYklS0kGzvTSH3p8nFjdnmk81zFr3co4F8A7t2LL2jwKHogxzWbS8vL9MbnS6vTPz1xESNtAijmF8Xm0E2uLdmFumNUdPIphWpnzQecf/0ZGcFdcyO0BBqzo1t3ZktAhb/4CV5MlNfF6uv4dJjh/0ljIoEMj3zbcA2UlFs3WliV39cFMILt75fK3w2FTXsfNE1EsDGK6TP5zS5jP8y4OU4yDL56Fr624NOZJ+K8MzxFpJg1Xs/MAYBS754ExwzSckc5cw== Received: from BYAPR06CA0006.namprd06.prod.outlook.com (2603:10b6:a03:d4::19) by SJ2PR12MB9244.namprd12.prod.outlook.com (2603:10b6:a03:574::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 10:24:47 +0000 Received: from CO1PEPF000044EE.namprd05.prod.outlook.com (2603:10b6:a03:d4:cafe::a3) by BYAPR06CA0006.outlook.office365.com (2603:10b6:a03:d4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26 via Frontend Transport; Mon, 25 Dec 2023 10:24:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CO1PEPF000044EE.mail.protection.outlook.com (10.167.241.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.14 via Frontend Transport; Mon, 25 Dec 2023 10:24:46 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 25 Dec 2023 02:24:45 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 25 Dec 2023 02:24:45 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41 via Frontend Transport; Mon, 25 Dec 2023 02:24:43 -0800 From: Michael Baum To: CC: Matan Azrad , Dariusz Sosnowski , Raslan Darawsheh , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Erez Shitrit Subject: [PATCH v4 1/2] net/mlx5/hws: add support for random number match Date: Mon, 25 Dec 2023 12:24:34 +0200 Message-ID: <20231225102435.2419716-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231225102435.2419716-1-michaelba@nvidia.com> References: <20231214151248.1654878-1-michaelba@nvidia.com> <20231225102435.2419716-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044EE:EE_|SJ2PR12MB9244:EE_ X-MS-Office365-Filtering-Correlation-Id: 70e1d7e3-eead-4883-b2eb-08dc0533b7f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kt9nSzOyNL+FVZS5cAwGWYrXKxMOqxsTEfK/S2FT8AnRRTrQfTGr1KIi8HrA57POy+8D9xVkXd/8JjdFUtelc/8Sx96zBw4t9oqrJG3XYaDLxcsgO4ySbQBuoOGuL6wolxMrx8skxShom4lYqxZNBT2PLum2AVYFsmXovW96I41dHpmao6naJa/aY2kW5JUtRICNchCnZPbd1LfLKRR7uogavrEvq6mvnNcJc1kSdzt6NC4olFxbBDyscmEiA8iW9kugRhnmhRnvQJyoG28i06pIOkKQ9DENdFNRDT5VbZWqjwfGQSBlawVC7JvUpT3BMTyNt5jjLbo4IvVt7yMcqgA7dB4K68vbOyjjVXPDUZs5awJv3ZbGxqMV+PKl6+SYOD/3/N2oTC/Z1JN6BfrDXXlFMs6APQ9r1Avfg0B5KKthzB7Z26aq0GgHh3BKvFofUDNY8JH7QZyFAym3DKNCgbrj6kVQoYYfyOV5pvBS3VHWHOLTWCZBwdVz2bQko6H51h0mqQcr94O6JJgOWFO1XAP8/lQo6sSUVlF3A9jsuRPCGNw+gitKypHBO6Gi/mIQorD+SjenPAHCj6L1AndLVuuxXuiym4mKTl+tRZ/3gYyWpCQWME1rCeO+zj483tyTYBrjxs945/TeSclT1h3oAsUliqXZ5mLS/OK1xbg7kFi0DuokqaumRPUFatLvuw1sFSwJw515F6zVD3YkD3IbUy1vD84wYb8GFaSAz5ZMEAS+QvloqdoTMpcoEi6tUj75 X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(346002)(396003)(136003)(376002)(230922051799003)(82310400011)(186009)(64100799003)(451199024)(1800799012)(36840700001)(46966006)(40470700004)(40480700001)(2906002)(6916009)(70206006)(70586007)(5660300002)(40460700003)(55016003)(4326008)(8676002)(8936002)(316002)(54906003)(41300700001)(47076005)(7696005)(36756003)(478600001)(6666004)(2616005)(107886003)(26005)(1076003)(86362001)(336012)(426003)(83380400001)(6286002)(36860700001)(82740400003)(7636003)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 10:24:46.6724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70e1d7e3-eead-4883-b2eb-08dc0533b7f4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044EE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9244 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: Erez Shitrit The HW adds a random number per each hash, this value can be used for statistic calculation over the packets, for example by setting one bit in the mask of that field we will get half of the traffic in the flow, and so on with the rest of the mask. Signed-off-by: Erez Shitrit --- drivers/net/mlx5/hws/mlx5dr_definer.c | 33 +++++++++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_definer.h | 8 ++++++- drivers/net/mlx5/mlx5_flow.h | 3 +++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index 0b60479406..005733372a 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -182,6 +182,7 @@ struct mlx5dr_definer_conv_data { X(SET_BE32, ipsec_sequence_number, v->hdr.seq, rte_flow_item_esp) \ X(SET, ib_l4_udp_port, UDP_ROCEV2_PORT, rte_flow_item_ib_bth) \ X(SET, ib_l4_opcode, v->hdr.opcode, rte_flow_item_ib_bth) \ + X(SET, random_number, v->value, rte_flow_item_random) \ X(SET, ib_l4_bth_a, v->hdr.a, rte_flow_item_ib_bth) \ /* Item set function format */ @@ -2173,6 +2174,33 @@ mlx5dr_definer_conv_item_ipv6_routing_ext(struct mlx5dr_definer_conv_data *cd, return 0; } +static int +mlx5dr_definer_conv_item_random(struct mlx5dr_definer_conv_data *cd, + struct rte_flow_item *item, + int item_idx) +{ + const struct rte_flow_item_random *m = item->mask; + const struct rte_flow_item_random *l = item->last; + struct mlx5dr_definer_fc *fc; + + if (!m) + return 0; + + if (m->value != (m->value & UINT16_MAX)) { + DR_LOG(ERR, "Random value is 16 bits only"); + rte_errno = EINVAL; + return rte_errno; + } + + fc = &cd->fc[MLX5DR_DEFINER_FNAME_RANDOM_NUM]; + fc->item_idx = item_idx; + fc->tag_set = &mlx5dr_definer_random_number_set; + fc->is_range = l && l->value; + DR_CALC_SET_HDR(fc, random_number, random_number); + + return 0; +} + static int mlx5dr_definer_mt_set_fc(struct mlx5dr_match_template *mt, struct mlx5dr_definer_fc *fc, @@ -2224,6 +2252,7 @@ mlx5dr_definer_check_item_range_supp(struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_TAG: case RTE_FLOW_ITEM_TYPE_META: case MLX5_RTE_FLOW_ITEM_TYPE_TAG: + case RTE_FLOW_ITEM_TYPE_RANDOM: return 0; default: DR_LOG(ERR, "Range not supported over item type %d", item->type); @@ -2537,6 +2566,10 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, ret = mlx5dr_definer_conv_item_ptype(&cd, items, i); item_flags |= MLX5_FLOW_ITEM_PTYPE; break; + case RTE_FLOW_ITEM_TYPE_RANDOM: + ret = mlx5dr_definer_conv_item_random(&cd, items, i); + item_flags |= MLX5_FLOW_ITEM_RANDOM; + break; default: DR_LOG(ERR, "Unsupported item type %d", items->type); rte_errno = ENOTSUP; diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.h b/drivers/net/mlx5/hws/mlx5dr_definer.h index 6f1c99e37a..18591ef853 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.h +++ b/drivers/net/mlx5/hws/mlx5dr_definer.h @@ -150,6 +150,7 @@ enum mlx5dr_definer_fname { MLX5DR_DEFINER_FNAME_PTYPE_TUNNEL, MLX5DR_DEFINER_FNAME_PTYPE_FRAG_O, MLX5DR_DEFINER_FNAME_PTYPE_FRAG_I, + MLX5DR_DEFINER_FNAME_RANDOM_NUM, MLX5DR_DEFINER_FNAME_MAX, }; @@ -407,6 +408,11 @@ struct mlx5_ifc_definer_hl_ipv4_src_dst_bits { u8 destination_address[0x20]; }; +struct mlx5_ifc_definer_hl_random_number_bits { + u8 random_number[0x10]; + u8 reserved[0x10]; +}; + struct mlx5_ifc_definer_hl_ipv6_addr_bits { u8 ipv6_address_127_96[0x20]; u8 ipv6_address_95_64[0x20]; @@ -516,7 +522,7 @@ struct mlx5_ifc_definer_hl_bits { struct mlx5_ifc_definer_hl_mpls_bits mpls_inner; u8 unsupported_config_headers_outer[0x80]; u8 unsupported_config_headers_inner[0x80]; - u8 unsupported_random_number[0x20]; + struct mlx5_ifc_definer_hl_random_number_bits random_number; struct mlx5_ifc_definer_hl_ipsec_bits ipsec; struct mlx5_ifc_definer_hl_metadata_bits metadata; u8 unsupported_utc_timestamp[0x40]; diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 6dde9de688..0a83c7f384 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -277,6 +277,9 @@ enum mlx5_feature_name { /* NSH ITEM */ #define MLX5_FLOW_ITEM_NSH (1ull << 53) +/* Random ITEM */ +#define MLX5_FLOW_ITEM_RANDOM (1ull << 54) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) -- 2.25.1