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 72A6243412; Thu, 30 Nov 2023 17:40:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 60A9042EF4; Thu, 30 Nov 2023 17:40:32 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2083.outbound.protection.outlook.com [40.107.220.83]) by mails.dpdk.org (Postfix) with ESMTP id 7515B42EF2 for ; Thu, 30 Nov 2023 17:40:30 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JwZ1n/ef76EDcN1W9e43T6YS0MrgWCg/5nXzoE8X/sBH19QhCAsvPYL4UBmohvth0xrEGIAADKRuOsTQeCXXmy1q5OjRmkFoDqXSSqeHiAncqqU6MLYhDaWdfAguRhO9bOE34srXiMEQhlqjjxPHOImc6JG3Dp1PeVkgxziaODQna9S8dY/0oUjC2oMnBcSKk7gvOJHHLj0pkSYUwBP6bM+iKxzsSn0GGuBWMda7hYJFh7CGW0yH+RGfTcNaEZubZxs85k+Wp2JXdEmJe3c7hH1oz7lUWSjjmMxkfEf8O43SrM1lQodQ5q5KOH8ipRk+hWdd8GlnfwiZ0UlJfC//0w== 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=CJVmuKh481RvookRQ8eSEVWsahXF2l8g7jBApEIIN5M=; b=CnoAK/0v5ysVU+WisbrSNf6NU1n1FElZ9OrmgPcfDh4X0iCMtGL/6WaZxyVBMFC0hCHOvMlWTLcOHMfKKPlurOdtxyyJA/lcI4vl4AdVX/QU0oBQqOnpzRSVFvNhcH4AtS3b4F4yhY+OxYKKLdaPLqRWQW5Dm7p0GJ4auxMhh0Iv7Afj39E+tpp/jGDAjtt1WJQuuu0/g8zgg8qVXCeWpIxP7BWy9x7ZmaghOn9xmsZW1BcLNZ68dyjqrR5tn0tPV556Ysx0T6tifE+JxHPpXmwfKNAhTVFreKA26BlMVn4/rmyCAA6N4Sz0zpK+IxP+Cm+RPgO4s3o7WntjGS6qbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=CJVmuKh481RvookRQ8eSEVWsahXF2l8g7jBApEIIN5M=; b=hio0CrDb2cINYcgWQ9GGcUXAGH/qOgx7ukQB0mBMVO0JVSFxuhMoNUu+XIJe30x5PI/wa+BPIoQGilFhGpR61o7i0YET/E9awVX/GvHpggGPv21iHOJVMc+3aEENpewqN91kwYwmCYJPnPFDR4HcxTddZ7H5RXvENsmPZbUPAOLgpjHm4LeFwl8NfD2V4Qu7+ma5szkq4cF3RC1Ws9i5rHSwf/oxcm7Ig4SCO+cYQ+oRz6Bz62DRMkY40+ENOCxNBGeodNWay/iOKKt7/vQ6j2Qp5Oq+LUjJMfgZoAaIrQ3lia2lJzpUF3r6aBT0GHMGSh/9C8ah26YyY0xxwDx2gw== Received: from BYAPR21CA0006.namprd21.prod.outlook.com (2603:10b6:a03:114::16) by PH0PR12MB7011.namprd12.prod.outlook.com (2603:10b6:510:21c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.23; Thu, 30 Nov 2023 16:40:27 +0000 Received: from MWH0EPF000971E8.namprd02.prod.outlook.com (2603:10b6:a03:114:cafe::7a) by BYAPR21CA0006.outlook.office365.com (2603:10b6:a03:114::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.11 via Frontend Transport; Thu, 30 Nov 2023 16:40:27 +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 MWH0EPF000971E8.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.17 via Frontend Transport; Thu, 30 Nov 2023 16:40:27 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.41; Thu, 30 Nov 2023 08:40:10 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.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.41; Thu, 30 Nov 2023 08:40:10 -0800 Received: from nvidia.com (10.127.8.13) by mail.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.41 via Frontend Transport; Thu, 30 Nov 2023 08:40:08 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Erez Shitrit Subject: [PATCH v2 1/2] net/mlx5/hws: add support for random number match Date: Thu, 30 Nov 2023 18:40:00 +0200 Message-ID: <20231130164001.666702-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231130164001.666702-1-michaelba@nvidia.com> References: <20230822103600.3247680-1-michaelba@nvidia.com> <20231130164001.666702-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: MWH0EPF000971E8:EE_|PH0PR12MB7011:EE_ X-MS-Office365-Filtering-Correlation-Id: f1b240e2-f9c0-4930-2312-08dbf1c30ec2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RF2q/Upf3Yfv2oHYbVQg4XnSXeSVHYrw6o+r52tGsnvf44n45kXbT8cdjKSkgWoPzj6s2xSwPhVctjn/ImDG4TZxEONHbBw/89IhiLUervgoX2e6nv42+QOxXVuO6fC5hEO71OexhH5AtHE5xg1YUGvyZiBYNGKPk4u/LUjMvTCfTWoA6TnsVOu57RvtM0sxIawdxey5yKSV2KJxVCluC0I2+IymWhI76hGuxgaKZVcW4dBAKuiMOCqmqDA+F9JfaVprCGs61TKPvTzjm4ugPmDb2c1/3juIwAF8Y5qUhXbin6wJsoTEcEh9TxWBFIm97fzmCtiITj4aIZTbiwbi5Im4WHqKwgxeXBIKG8R+yQldJtjEsvxhNAdOs++AIOqZUCzdhLM3GVi4dddXF1lARzhXkSt1Qbt/zOIOnB/6OXuPddj0htbwRrgHQ3rW6tA7TtSKMTsGgO+MCkeLM7uTXCKUhfFxySDKOpgHvol+CWwOK+LCTcdHWI0ZHCGhmA2cmLavT8K8RB44FvaE8/SCReLPfOAeT6HX+u5R6MfEB44IUuqa9hrDfHvIS0PR9vHEZLxP3ziXltkTQXySidGpFPi+w7Fc+V6Muf+deMlN7Jm5HNLzLqanrT35teW+vJdIigdTiwq7oxXv3f01w08IB4CrknQHmiCbXXaz/PbyYSXtVMsIgGAxUMA4qI/nrjEzVD7taxTSStO5Fk6vKzjAgaWqcESrrdNov5Wj5+PLVVye44SWyPLS0Eda3z1spIL5 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:(13230031)(4636009)(136003)(396003)(346002)(39860400002)(376002)(230922051799003)(82310400011)(186009)(451199024)(1800799012)(64100799003)(36840700001)(40470700004)(46966006)(426003)(336012)(36860700001)(55016003)(40480700001)(40460700003)(83380400001)(7636003)(47076005)(356005)(316002)(2906002)(5660300002)(4326008)(86362001)(8676002)(8936002)(70586007)(6916009)(70206006)(54906003)(82740400003)(6666004)(7696005)(478600001)(41300700001)(36756003)(2616005)(26005)(6286002)(107886003)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2023 16:40:27.0640 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1b240e2-f9c0-4930-2312-08dbf1c30ec2 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: MWH0EPF000971E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7011 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 | 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..14311eff10 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 << 53) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) -- 2.25.1