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 D368BA0032; Thu, 1 Sep 2022 10:24:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2F4E40684; Thu, 1 Sep 2022 10:24:56 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2052.outbound.protection.outlook.com [40.107.100.52]) by mails.dpdk.org (Postfix) with ESMTP id 3967340395 for ; Thu, 1 Sep 2022 10:24:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UyP/tLTutaftSPBtScUFPHP+2m7f+MbyAgMkIRmTdhCdzIolaiYde1UrZgzVaWeghWfUAUWnmfFwPG6t7vsjY6CdFr0EOS7e9mcNwU0ziRFf0QwEuRycleI3/mLRcA2Y16wlL1AiXbsodV49wfA0JK+KgpfJnM7kf9tsd5hiwArBJQ1KuMoVhERuieQkaAWjNGe5X45NspsTykWGShHO3KRCCfiyOSlTu08nKWD/z/Lce4JnHaEgaUyLqSRAJGgY3KOdwvHe8aqT+qM9voYovxEH8aAaMmn7DPKiw1qeBIxpuYa8x2QLkHxc2dZiqjIx1nyqf8F7SnqsGgkzeWZifQ== 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=NZitVahXNnGiN7A7wxE1Zr5OkKrr/y4rvALq9x3imSA=; b=IgbEPX0/xnjJzsClnilyYqsmHsoTGwgzIiqoKhovnioqkpK2HSNDkYdwS0e6dLX+oebgseyVTt0C0bS3Rk/RYP1qA8l7x/EEXkE4C7ZHwml+yCdiyZWkBktFQ7O/P7DORdxewKptL1rpLwAOQzqhm7C+8R1PpCDqjPHtU3XLKhEkvYYewmzov8GlrAwLp/B4eLgZ/8iToV4vPqPpaTuLZNiFx5trK8j/PlcOtPgkCsWVmZHTOI4T640wbxumH6BWlug0JJt6Q5UYS+5DKihbwhKF/Npv9N6ZDdSyGFgX/ygEhb7TVJc+xDKg/ahwxNGD3FfE5wP+djbmEkRBYOoJrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) 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=NZitVahXNnGiN7A7wxE1Zr5OkKrr/y4rvALq9x3imSA=; b=Oab/Dnjyo+hY8ceJeIgVLPMuY9ETkOucTicknBeXafwWks2hf21Cs41ZOxOX0d2rNOpEyR5P/nvi1YJLUyI6pT2pwM0XmBjSCU/m4YJAghoLCUET2nqqXBNFeUDl2OPtgqhfs2UDFfER04sAYEMKenzNmrZYjpYVRNyQCv0Xhsx7XhToV0YHPcCLZhCTn2oVDEk55WJFCjimuSBSt/WxEIjatGaGhbXk8UMo+9cEDLJtE8HuRw9DWZf8HmDqwEuRSDShLn6QpJ2jPCv2dI0f5O4KZwQfjxDB9bCEWIVEiFxWuvXkwFW4BCGws8YmHvDKnq/BZRkP3x8hV5OCwhfqew== Received: from DS7PR03CA0278.namprd03.prod.outlook.com (2603:10b6:5:3ad::13) by MN0PR12MB5955.namprd12.prod.outlook.com (2603:10b6:208:37e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Thu, 1 Sep 2022 08:24:53 +0000 Received: from DM6NAM11FT078.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::cf) by DS7PR03CA0278.outlook.office365.com (2603:10b6:5:3ad::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Thu, 1 Sep 2022 08:24:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT078.mail.protection.outlook.com (10.13.173.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5588.10 via Frontend Transport; Thu, 1 Sep 2022 08:24:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Thu, 1 Sep 2022 08:24:52 +0000 Received: from nvidia.com (10.126.231.35) 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.29; Thu, 1 Sep 2022 01:24:50 -0700 From: Gerry Gribbon To: CC: , , Ori Kam Subject: [PATCH] regex/mlx5: add support for combined rof file Date: Thu, 1 Sep 2022 08:24:33 +0000 Message-ID: <20220901082433.2434700-1-ggribbon@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9d1f7c83-e6ee-4138-2e9f-08da8bf37213 X-MS-TrafficTypeDiagnostic: MN0PR12MB5955:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W37xtJmGeLTY8EBiy7/06Tllvtcn9GOkOCv/8EZ0RkFdAthOfgSo/eQtDG3Go0tlFIkImQzRZfxWeqafaneW8Kk4PfqnONGv9MQWWXNqrj3GcygfQAptvVWlDxPnOcb21C6/p8CWUDagukg4r9IVLBlu6+YeEzkzVfXdzLqZeU5IuxVgPxC3pd1ypEG87fdQylN+toq0DViSxqZeItCEL63ILwSMXmFpcbAQeSOGQW0woRv4o2QlauO1ixtMC/D7on5ERq8ize7a2oUHMmaV9Z4M8fl+sKH9OEabxpnpQC26b/WdV+qDOatmdjCkCoj8esQ26VzqcWvzaIlz9uoHLH+JrYQfYgPOjiw+OJwW1YTO0uj+K3kTOOmpUxaCS7HMt101ENe0Mcpet3v5Zzrj7qyA2GpiD6HXWUzw5FMFPX611qE8ESIWP5Q79jBNwGU2AZUqVF7E7d1kRLBJXFjdQVEYB0qCvMeEfjTmM8W7qZ+SpEhHR3A9xT5P+65RAJZ692nPkSevR3QhTDIT4FIfOvfkC2R7pmJghkd4VBkMlYCX7XlKnXdd2+4y1djGmzcoSr7Sd0zjSCbJgGpvrNDLsJyCBKj0OKS4tVre8pT9eZj0Wg8SNyuYxmbCJI+yG8EZyxkeKwtvXPoZXnCozJ+0R+ClIFhW1DgjAJxuHJSJLQtIW5FzSwHkoZYCIYzyzfY+YRPWMLD/THsNF+R2e7y9phZzidsD+fuiARQnMELeOmoq8AhD4AywuFjxrWunETSacCGu7BeY5lxKBV8ER/NqmtFa/q4H7u54PM91OqO23uHosOoGnowPQ9tR0ylkseeE X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(346002)(376002)(396003)(136003)(39860400002)(46966006)(40470700004)(36840700001)(7696005)(54906003)(6916009)(86362001)(8936002)(356005)(82740400003)(81166007)(2906002)(40460700003)(6286002)(70206006)(70586007)(107886003)(6666004)(26005)(4326008)(55016003)(8676002)(82310400005)(40480700001)(478600001)(83380400001)(36860700001)(1076003)(186003)(2616005)(16526019)(336012)(47076005)(426003)(36756003)(316002)(41300700001)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2022 08:24:53.2270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d1f7c83-e6ee-4138-2e9f-08da8bf37213 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT078.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5955 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 Added support to allow parsing of a combined rof file to locate compatible binary rof data for the Bluefield hardware being run on. Signed-off-by: Gerry Gribbon Acked-by: Ori Kam --- drivers/regex/mlx5/mlx5_regex.h | 4 + drivers/regex/mlx5/mlx5_rxp.c | 148 ++++++++++++++++++++++++++++++++ drivers/regex/mlx5/mlx5_rxp.h | 4 + 3 files changed, 156 insertions(+) diff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h index 89495301ac..c8dfea4e94 100644 --- a/drivers/regex/mlx5/mlx5_regex.h +++ b/drivers/regex/mlx5/mlx5_regex.h @@ -74,6 +74,10 @@ int mlx5_regex_configure(struct rte_regexdev *dev, const struct rte_regexdev_config *cfg); int mlx5_regex_rules_db_import(struct rte_regexdev *dev, const char *rule_db, uint32_t rule_db_len); +int mlx5_regex_check_rof_version(uint32_t combined_rof_version); +int mlx5_regex_parse_rules_db(struct mlx5_regex_priv *priv, + const char **rule_db, uint32_t *rule_db_len); +int mlx5_regex_get_rxp_vers(uint32_t regexp_version, uint32_t *target_rxp_vers); /* mlx5_regex_devx.c */ int mlx5_devx_regex_rules_program(void *ctx, uint8_t engine, uint32_t rof_mkey, diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c index ed3af15e40..4cda8692e7 100644 --- a/drivers/regex/mlx5/mlx5_rxp.c +++ b/drivers/regex/mlx5/mlx5_rxp.c @@ -26,6 +26,8 @@ #define MLX5_REGEX_RXP_ROF2_LINE_LEN 34 +const uint64_t combined_rof_tag = 0xff52544424a52475; + /* Private Declarations */ static int rxp_create_mkey(struct mlx5_regex_priv *priv, void *ptr, size_t size, @@ -88,6 +90,147 @@ rxp_destroy_mkey(struct mlx5_regex_mkey *mkey) claim_zero(mlx5_glue->devx_umem_dereg(mkey->umem)); } +int +mlx5_regex_get_rxp_vers(uint32_t regexp_version, uint32_t *target_rxp_vers) +{ + int ret = 0; + switch (regexp_version) { + case MLX5_RXP_BF2_IDENTIFIER: + *target_rxp_vers = MLX5_RXP_BF2_ROF_VERSION_STRING; + break; + case MLX5_RXP_BF3_IDENTIFIER: + *target_rxp_vers = MLX5_RXP_BF3_ROF_VERSION_STRING; + break; + default: + DRV_LOG(ERR, "Unsupported rxp version: %u", regexp_version); + ret = -EINVAL; + break; + } + return ret; +} + +int +mlx5_regex_check_rof_version(uint32_t combined_rof_vers) +{ + int ret = 0; + /* Check if combined rof version is supported */ + switch (combined_rof_vers) { + case 1: + break; + default: + DRV_LOG(ERR, "Unsupported combined rof version: %u", + combined_rof_vers); + ret = -EINVAL; + break; + } + return ret; +} + +int +mlx5_regex_parse_rules_db(struct mlx5_regex_priv *priv, + const char **rules_db, uint32_t *rules_db_len) +{ + int i = 0; + uint32_t j = 0; + int ret = 0; + bool combined_rof = true; + const char *rof_ptr = *rules_db; + uint32_t combined_rof_vers = 0; + uint32_t num_rof_blocks = 0; + uint32_t rxpc_vers = 0; + uint32_t target_rxp_vers = 0; + uint32_t byte_count = 0; + uint32_t rof_bytes_read = 0; + bool rof_binary_found = false; + struct mlx5_hca_attr *attr = &priv->cdev->config.hca_attr; + + /* Need minimum of 8 bytes to process single or combined rof */ + if (*rules_db_len < 8) + return -EINVAL; + + for (i = 0; i < 8; i++) { + if ((char) *rof_ptr != + (char)((combined_rof_tag >> (i * 8)) & 0xFF)) { + combined_rof = false; + break; + } + rof_ptr++; + } + rof_bytes_read += 8; + + if (combined_rof == true) { + /* Need at least 24 bytes of header info: 16 byte combined */ + /* rof header and 8 byte binary rof blob header. */ + if (*rules_db_len < 24) + return -EINVAL; + + /* Read the combined rof version and number of rof blocks */ + for (i = 0; i < 4; i++) { + combined_rof_vers |= *rof_ptr << (i * 8); + rof_ptr++; + } + + rof_bytes_read += 4; + ret = mlx5_regex_check_rof_version(combined_rof_vers); + if (ret < 0) + return ret; + + for (i = 0; i < 4; i++) { + num_rof_blocks |= *rof_ptr << (i * 8); + rof_ptr++; + } + rof_bytes_read += 4; + + if (num_rof_blocks == 0) + return -EINVAL; + + /* Get the version of rxp we need the rof for */ + ret = mlx5_regex_get_rxp_vers(attr->regexp_version, &target_rxp_vers); + if (ret < 0) + return ret; + + /* Try to find the rof binary blob for this version of rxp */ + for (j = 0; j < num_rof_blocks; j++) { + rxpc_vers = 0; + byte_count = 0; + for (i = 0; i < 4; i++) { + rxpc_vers |= (*rof_ptr & 0xFF) << (i * 8); + rof_ptr++; + } + for (i = 0; i < 4; i++) { + byte_count |= (*rof_ptr & 0xFF) << (i * 8); + rof_ptr++; + } + rof_bytes_read += 8; + + if (rxpc_vers == target_rxp_vers) { + /* Found corresponding binary rof entry */ + if (rof_bytes_read + byte_count <= (*rules_db_len)) + rof_binary_found = true; + else + DRV_LOG(ERR, "Compatible rof file found - invalid length!"); + break; + } + /* Move on to next rof blob */ + if (rof_bytes_read + byte_count + 8 < (*rules_db_len)) { + rof_ptr += byte_count; + rof_bytes_read += byte_count; + } else { + /* Cannot parse any more of combined rof file */ + break; + } + } + if (rof_binary_found == true) { + *rules_db = rof_ptr; + *rules_db_len = byte_count; + } else { + DRV_LOG(ERR, "Compatible rof file not found!"); + return -EINVAL; + } + } + return 0; +} + int mlx5_regex_rules_db_import(struct rte_regexdev *dev, const char *rule_db, uint32_t rule_db_len) @@ -108,6 +251,11 @@ mlx5_regex_rules_db_import(struct rte_regexdev *dev, } if (rule_db_len == 0) return -EINVAL; + + ret = mlx5_regex_parse_rules_db(priv, &rule_db, &rule_db_len); + if (ret < 0) + return ret; + /* copy rules - rules have to be 4KB aligned. */ ptr = rte_malloc("", rule_db_len, 1 << 12); if (!ptr) { diff --git a/drivers/regex/mlx5/mlx5_rxp.h b/drivers/regex/mlx5/mlx5_rxp.h index eddc577d79..b38b53cc14 100644 --- a/drivers/regex/mlx5/mlx5_rxp.h +++ b/drivers/regex/mlx5/mlx5_rxp.h @@ -6,9 +6,13 @@ #define RTE_PMD_MLX5_REGEX_RXP_H_ #define MLX5_RXP_BF2_IDENTIFIER 0x0 +#define MLX5_RXP_BF3_IDENTIFIER 0x1 #define MLX5_RXP_MAX_JOB_LENGTH 16384 #define MLX5_RXP_MAX_SUBSETS 4095 #define MLX5_RXP_CSR_NUM_ENTRIES 31 +#define MLX5_RXP_BF2_ROF_VERSION_STRING 0x07055254 +#define MLX5_RXP_BF3_ROF_VERSION_STRING 0x00065254 +#define MLX5_RXP_BF4_ROF_VERSION_STRING 0x00075254 #define MLX5_RXP_CTRL_TYPE_MASK 7 #define MLX5_RXP_CTRL_TYPE_JOB_DESCRIPTOR 0 -- 2.25.1