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 CA13F430CF; Tue, 22 Aug 2023 12:36:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30B1942FB2; Tue, 22 Aug 2023 12:36:34 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2077.outbound.protection.outlook.com [40.107.223.77]) by mails.dpdk.org (Postfix) with ESMTP id 8DD2642B8B for ; Tue, 22 Aug 2023 12:36:31 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dcc7XZDrxUB0EQnKafIZDudf0gpYNt9Y7cx7EoAXSfgWV22+7BvdmehUEIA/LrM8p+WxoF+aNqqgddWnwzylYwQCstpJQY6L5UNegTUuIxJrwi2D/XSsW+ES6xgCW2mElS/UpsN00wDuFZ9EOsZq7l9gGv1pb7JgPPND9MDAkUr3LkF1rPDdPIjvsLH49dMFqokFMPob5EtCSonpmnp31Ej7X2wc71OoG6qYjihTnXrIzwMDQIxUnqm9SKxrpSWrCXw8VfCgryrf0yDvOkyjx1pa1vAho8PH2sjwPAI/jyQo2InIh6PphDXq2ze4I2Q9WeHLH3h4Q7Q5ZI9knFNHJg== 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=Q4m6nlnclpblavTxnNi6Wk0MFi3icc9Dr5nooYEkVCY=; b=giX1isZauUszeD02+a6BXzAeib/+VymHAKedpWhV7w4fB3QBmOKtZNEnbp2J/VPK34sYYac1cFvunNYoq9qMq4i4bmTk5d57AMP+KfAVb0BDShSqP4iOJiwNkw3IplFerA0etnLFs313YbYYaNHe36NVl97kJTMuebVg+2Ne4HMJyKMuMKCTGZpotw8mjqG+/XFtDZJg+Yj4V0Lrw7AdPKgaKIoNVAHeZhPZqTKxjNbOOQ3VM5U9oqmDbISIB0UCiC/27Y8g9v5kIkrU7LOfutXIMDBDGJRbYHDuO05eSEFb5ftnFyZ6YjUL2IueGEQYH6l0P0Z34WMUbTzwelwo6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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 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=Q4m6nlnclpblavTxnNi6Wk0MFi3icc9Dr5nooYEkVCY=; b=r+MYVIX/mxC2F58rSizkh6Dvp4H3bsXe/+OA3bk1eKEkSru5C1jjN0/aJr1i+3ed/BaQY3YONc+l4jAHqU5NBKkdo55ZGag2/+A8wW0iR2lFMbRyJgoq0RIvplBiZlTFjXHTWzzNTwrC5JFsMdGOWjQ0GNMZUEWtluUJdZZqEcY/heCsQh/V4AuEne1lXLaIILDC15XaSU2LUxHQdCR4XN7R+l02UYdHO+nNbPvrkd1Loh8fMjRAhQVNtTr8c72Cif6waW9esFhjf7QQKXtpFS24UHboGCTu3vhSp/OcbUe/JMHAqIp8Lv2Wd5f/Ig8MkA4anqTGt/yAM6e6Dgp03w== Received: from MW2PR2101CA0003.namprd21.prod.outlook.com (2603:10b6:302:1::16) by DM6PR12MB4465.namprd12.prod.outlook.com (2603:10b6:5:28f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 10:36:28 +0000 Received: from CO1PEPF000044F0.namprd05.prod.outlook.com (2603:10b6:302:1:cafe::39) by MW2PR2101CA0003.outlook.office365.com (2603:10b6:302:1::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.7 via Frontend Transport; Tue, 22 Aug 2023 10:36:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1PEPF000044F0.mail.protection.outlook.com (10.167.241.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Tue, 22 Aug 2023 10:36:27 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 22 Aug 2023 03:36:14 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 22 Aug 2023 03:36:13 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37 via Frontend Transport; Tue, 22 Aug 2023 03:36:11 -0700 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Erez Shitrit Subject: [PATCH 1/2] net/mlx5/hws: add support for random number match Date: Tue, 22 Aug 2023 13:35:59 +0300 Message-ID: <20230822103600.3247680-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230822103600.3247680-1-michaelba@nvidia.com> References: <20230822103600.3247680-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: CO1PEPF000044F0:EE_|DM6PR12MB4465:EE_ X-MS-Office365-Filtering-Correlation-Id: a6328fd1-10d6-45af-9ee9-08dba2fba44d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WQ1pPBgjSRHH7LBI0zyG2UFvfQQ990KQc+9atBj1XKtsk7PXvCnM91qxL7ILCUu0DGzCyRlTtBKV7lcjbYiOdzLBTpCD+FmLzjMrOOtFlZA8w27IArc4cuBo54tKZkqQaoalY4KP477Y9B3cTjkO1ornWlYb8QPRtERKiNYP5yhJyu/JybntRCFt0pBc/e4nE+wbt9MiK6nj7p6hZ12603JAAg1d+y+UD8vx9fQ8/ofShc0IT6gJA5BaqWVDvLvr2MTgx5hOHu/9Vq5pzHUfPQaNDr3SNBpApJ94Nt8PyE9fqyTMtWdSNl+w1JhlXDJ4vgCjJLJ+QGA+6mH+UWi1T+Zj8m/YK9XTMD5Wm8KVnmAheeGKzIR+Pt0qk7baOqs8okq1RulR3u+zbdKj5BiMH01LDZdc5WN8OrVn7f2Z0nSiAKg2stT3f1S+lVveFURLr7UyGap0oHwudJNic2rbdY/wDEpeFeU1yGwvLs0JK5PPd3PJZCJ3K0RjsGWyrFdyslkETvR1e/lv9qtkhVmWU2mlFsGE9TnK5yeaDuYRjHWwN/Fkh0em2L6g5Fc1ecLWT8EzeL5UgXewgE1/VP8AwohsRfnhzCRLM042XOAsdn5N3YF4gbLGj4WU+2VJ9AWL4Sb0lhulvzuY/cQPaOMAkdrTMBVT28yL6Bv+2/YJe6pniR7bNCy6pQ0+B7UqRdHw8rOos/TamnGxW7InSAXTdCmkHWVI6AIsN6RZdKX5YR4oksm5fVhGax3kJx3awHmF X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(376002)(346002)(39860400002)(1800799009)(186009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(54906003)(6916009)(70206006)(70586007)(316002)(8676002)(8936002)(2616005)(107886003)(4326008)(7636003)(40460700003)(36756003)(41300700001)(1076003)(82740400003)(356005)(478600001)(6666004)(55016003)(40480700001)(83380400001)(2906002)(86362001)(7696005)(47076005)(36860700001)(336012)(426003)(5660300002)(26005)(6286002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 10:36:27.9161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a6328fd1-10d6-45af-9ee9-08dba2fba44d 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4465 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 filed 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 | 35 ++++++++++++++++++++++++++- drivers/net/mlx5/hws/mlx5dr_definer.h | 8 +++++- drivers/net/mlx5/mlx5_flow.h | 3 +++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index 33d0f2d18e..a20ea73605 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -177,7 +177,8 @@ struct mlx5dr_definer_conv_data { X(SET_BE32, ipsec_spi, v->hdr.spi, rte_flow_item_esp) \ 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, ib_l4_opcode, v->hdr.opcode, rte_flow_item_ib_bth) \ + X(SET, random_number, v->value, rte_flow_item_random) \ /* Item set function format */ #define X(set_type, func_name, value, item_type) \ @@ -1965,6 +1966,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, @@ -2016,6 +2044,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); @@ -2319,6 +2348,10 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, ret = mlx5dr_definer_conv_item_ib_l4(&cd, items, i); item_flags |= MLX5_FLOW_ITEM_IB_BTH; 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 6b645f4cf0..1405c752b8 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.h +++ b/drivers/net/mlx5/hws/mlx5dr_definer.h @@ -136,6 +136,7 @@ enum mlx5dr_definer_fname { MLX5DR_DEFINER_FNAME_OKS2_MPLS4_I, MLX5DR_DEFINER_FNAME_IB_L4_OPCODE, MLX5DR_DEFINER_FNAME_IB_L4_QPN, + MLX5DR_DEFINER_FNAME_RANDOM_NUM, MLX5DR_DEFINER_FNAME_MAX, }; @@ -392,6 +393,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]; @@ -501,7 +507,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 3a97975d69..8a9bd71692 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -233,6 +233,9 @@ enum mlx5_feature_name { /* IB BTH ITEM. */ #define MLX5_FLOW_ITEM_IB_BTH (1ull << 51) +/* Random ITEM */ +#define MLX5_FLOW_ITEM_RANDOM (1ull << 52) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) -- 2.25.1