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 921BDA0548; Thu, 27 May 2021 15:39:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5AA524111D; Thu, 27 May 2021 15:39:04 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2069.outbound.protection.outlook.com [40.107.220.69]) by mails.dpdk.org (Postfix) with ESMTP id 5CBE440150 for ; Thu, 27 May 2021 15:39:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W/OF1ub1MoieLIQf65YaTn5WcD32Xi1P4jbMQRzy5H62aYcqIfAYIZxBsy2pCvOTWL/742JRSEWXA1ceblt/VHEgkzKonJVKryBJE0Ie7PkSPCwF+jP1EIZgjC9W2/x1kfaml+1TTdQecrzHZ4zBw5UWgCdHR7Lwod7VV46/P5b7y+YTrnEaRwKthAydql6vNoI5GS9mBZeUfd9yhUtPO8BJfPjMTA0cVY+jAUlrNSSiWDV4U9Rqy66przwjb5R015N3vg6qTyH7J+ftt+tcUXmT4wQjcNhw+qP1B6EXkRPwdv1CrtFf6wvMiYl9ClnYfT1FszTBaBsdVX+puDpLgQ== 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-SenderADCheck; bh=WTQ8qOGUIprfsNwvgTddMJLNS2AHuHo59ElR3fykCCo=; b=YDwQf75btJYpijjNp2Jm8ZAU3JBhrtNPaniLUP4O3cO/ReQGEUIplrEs9lKqAlDAGpwCMDp0KRGjuLRXxNdVzPGzF9a+IewdsNIl4qlksJSEHp5l1sq/2Uo+x9UQ0d1CW4moanIXRVUgDJfNAMQ2bNj8McvzX2sIGBovoWWxCKyT7kCC0VQyczSpZj73RPLAMQ/48X/ZOkOI03jjc840QbrCTGUDAOFQCefcv8FxlJ+rh9UgMQWCVsJ6asgDWxiyG8Z3pJYGyy4XXTEIY2vJDMVNGiL4W9PMr5rfdpoFFQ/g950bBFItI47l1ch+vnJngRRvqvcJO63pEDszUWXS+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=WTQ8qOGUIprfsNwvgTddMJLNS2AHuHo59ElR3fykCCo=; b=PqdvyNP9ahM0DaJMxB2sUqPuW7Z6tkuIy1UWgTYSMm4168eR5GwMJUN1ksblWbNPPxVublE2O4SVgor3j1ZlLqopom+wppgcfWBUBsBMHi2uoxd3JGXLFrpQMEAT3fwXbw3KlPYCtcjD0Br2sN+65ngurAty/BNUkdOWoluLN9gEoGJxQ2xQ/yYmG/kouHGLdYAUsRMpwpbohbTGjc/+DmOWw1FccRDVFyeY/wa5ctRdKAZ8XKJZ7uFKmB8SgwnYZDAn/kRvL4c+u0uc+ic0qhcwLFYGX2neJGyBqavCFxGJGWg244WJdXiBu5yB+2L4J/WLcSn2wR1i6rQ0JtNm7A== Received: from CO2PR04CA0175.namprd04.prod.outlook.com (2603:10b6:104:4::29) by BYAPR12MB2872.namprd12.prod.outlook.com (2603:10b6:a03:12e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.21; Thu, 27 May 2021 13:39:00 +0000 Received: from CO1NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:104:4:cafe::40) by CO2PR04CA0175.outlook.office365.com (2603:10b6:104:4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Thu, 27 May 2021 13:39:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT035.mail.protection.outlook.com (10.13.175.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4129.25 via Frontend Transport; Thu, 27 May 2021 13:38:59 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 27 May 2021 13:38:58 +0000 From: Xueming Li To: Viacheslav Ovsiienko CC: , , Ori Kam Date: Thu, 27 May 2021 16:37:50 +0300 Message-ID: <20210527133759.17401-6-xuemingl@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210527133759.17401-1-xuemingl@nvidia.com> References: <20210527133759.17401-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a521fc46-4003-43e0-8b7d-08d92114c898 X-MS-TrafficTypeDiagnostic: BYAPR12MB2872: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XmMUaQKqaR5AbspupRuLE2TUQgnnq3gF613cy1tPYsJrmIp3nh01jE06UWMUvt17Q6Nx2+dwlRZMT+Y3rOJPjM5tXEnwZQCywAfaSC0DVEVweygrjDgrlh17417nFYi3Xxwpk8JNodLpdVsrrC/Zw/9+7C/MQ6jZhf+CYpvllTlKt7HXIh/m0rZbV23I6oF2gZqVuYXZOgxbApA2A1vDNpdc4AAaGDA+C+zeKB89A6xbgeKKeTgKiioMaKpu8eNq/szxVBrGb4Ir9L5OqI09FnKFgp+4wfqxkSTHOULe5woMl5ZahaoWbqxcfe5NWdbQjmqyGuwDwcrDoQDOGq0w5UH2BM+k5rxdXfBlVrt2FfitXkFwMwE/2/pUc96+3yOFDVq5bLc4hfJMzN1aPn7P5Bv1ZBl7JmIXv1PaCQ9SdmuDAkgrNTHCWkU9CdlGs0MH91UcopN0D5OW+26UlMQEpO5Rk3gcB+gz0k4gYc85Ru3ya5tg8IeI6Kcsf/JfsUdZQhkAh3LgLvlT7XIsa3McnjHa7L+dUaMrYuBC5+M6a4Ffjc+J1pDvjbXM+78kg8WbKBhBBTGXTbL6qYTyhICMsRo16cHYBphZYkYKIaq3VTpkjQ/F/uOazOVPb0+vBF+eFxxzjt/Af9rBCd8YRtJMdltVN7FFPystPTLko5GvHNs= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(39860400002)(346002)(136003)(376002)(396003)(46966006)(36840700001)(186003)(16526019)(426003)(336012)(356005)(7696005)(54906003)(26005)(82310400003)(47076005)(55016002)(6666004)(36756003)(2616005)(86362001)(6636002)(8936002)(8676002)(2906002)(107886003)(4326008)(70586007)(6862004)(37006003)(70206006)(5660300002)(82740400003)(1076003)(6286002)(7636003)(316002)(36906005)(478600001)(83380400001)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2021 13:38:59.7089 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a521fc46-4003-43e0-8b7d-08d92114c898 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2872 Subject: [dpdk-dev] [RFC 05/14] regex/mlx5: migrate to common driver 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 Sender: "dev" To support auxiliary bus, upgrades driver to use mlx5 common driver structure. Signed-off-by: Xueming Li --- drivers/regex/mlx5/mlx5_regex.c | 49 ++++++++++++--------------------- drivers/regex/mlx5/mlx5_regex.h | 1 - 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c index dcb2ced88e..9151e477c0 100644 --- a/drivers/regex/mlx5/mlx5_regex.c +++ b/drivers/regex/mlx5/mlx5_regex.c @@ -9,8 +9,8 @@ #include #include #include +#include -#include #include #include #include @@ -76,15 +76,13 @@ mlx5_regex_engines_status(struct ibv_context *ctx, int num_engines) } static void -mlx5_regex_get_name(char *name, struct rte_pci_device *pci_dev __rte_unused) +mlx5_regex_get_name(char *name, struct rte_device *dev) { - sprintf(name, "mlx5_regex_%02x:%02x.%02x", pci_dev->addr.bus, - pci_dev->addr.devid, pci_dev->addr.function); + sprintf(name, "mlx5_regex_%s", dev->name); } static int -mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, - struct rte_pci_device *pci_dev) +mlx5_regex_dev_probe(struct rte_device *rte_dev) { struct ibv_device *ibv; struct mlx5_regex_priv *priv = NULL; @@ -94,16 +92,10 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, int ret; uint32_t val; - ibv = mlx5_os_get_ibv_device(&pci_dev->addr); - if (!ibv) { - DRV_LOG(ERR, "No matching IB device for PCI slot " - PCI_PRI_FMT ".", pci_dev->addr.domain, - pci_dev->addr.bus, pci_dev->addr.devid, - pci_dev->addr.function); + ibv = mlx5_get_ibv_device(rte_dev); + if (ibv == NULL) return -rte_errno; - } - DRV_LOG(INFO, "PCI information matches for device \"%s\".", - ibv->name); + DRV_LOG(INFO, "Probe device \"%s\".", ibv->name); ctx = mlx5_glue->dv_open_device(ibv); if (!ctx) { DRV_LOG(ERR, "Failed to open IB device \"%s\".", ibv->name); @@ -146,7 +138,7 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, priv->is_bf2 = 1; /* Default RXP programming mode to Shared. */ priv->prog_mode = MLX5_RXP_SHARED_PROG_MODE; - mlx5_regex_get_name(name, pci_dev); + mlx5_regex_get_name(name, rte_dev); priv->regexdev = rte_regexdev_register(name); if (priv->regexdev == NULL) { DRV_LOG(ERR, "Failed to register RegEx device."); @@ -180,7 +172,7 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, priv->regexdev->enqueue = mlx5_regexdev_enqueue_gga; #endif priv->regexdev->dequeue = mlx5_regexdev_dequeue; - priv->regexdev->device = (struct rte_device *)pci_dev; + priv->regexdev->device = rte_dev; priv->regexdev->data->dev_private = priv; priv->regexdev->state = RTE_REGEXDEV_READY; priv->mr_scache.reg_mr_cb = mlx5_common_verbs_reg_mr; @@ -213,13 +205,13 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, } static int -mlx5_regex_pci_remove(struct rte_pci_device *pci_dev) +mlx5_regex_dev_remove(struct rte_device *rte_dev) { char name[RTE_REGEXDEV_NAME_MAX_LEN]; struct rte_regexdev *dev; struct mlx5_regex_priv *priv = NULL; - mlx5_regex_get_name(name, pci_dev); + mlx5_regex_get_name(name, rte_dev); dev = rte_regexdev_get_device_by_name(name); if (!dev) return 0; @@ -254,24 +246,19 @@ static const struct rte_pci_id mlx5_regex_pci_id_map[] = { } }; -static struct mlx5_pci_driver mlx5_regex_driver = { - .driver_class = MLX5_CLASS_REGEX, - .pci_driver = { - .driver = { - .name = RTE_STR(MLX5_REGEX_DRIVER_NAME), - }, - .id_table = mlx5_regex_pci_id_map, - .probe = mlx5_regex_pci_probe, - .remove = mlx5_regex_pci_remove, - .drv_flags = 0, - }, +static struct mlx5_class_driver mlx5_regex_driver = { + .drv_class = MLX5_CLASS_REGEX, + .name = RTE_STR(MLX5_REGEX_DRIVER_NAME), + .id_table = mlx5_regex_pci_id_map, + .probe = mlx5_regex_dev_probe, + .remove = mlx5_regex_dev_remove, }; RTE_INIT(rte_mlx5_regex_init) { mlx5_common_init(); if (mlx5_glue) - mlx5_pci_driver_register(&mlx5_regex_driver); + mlx5_class_driver_register(&mlx5_regex_driver); } RTE_LOG_REGISTER_DEFAULT(mlx5_regex_logtype, NOTICE) diff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h index 51a2101e53..45200bf937 100644 --- a/drivers/regex/mlx5/mlx5_regex.h +++ b/drivers/regex/mlx5/mlx5_regex.h @@ -59,7 +59,6 @@ struct mlx5_regex_db { struct mlx5_regex_priv { TAILQ_ENTRY(mlx5_regex_priv) next; struct ibv_context *ctx; /* Device context. */ - struct rte_pci_device *pci_dev; struct rte_regexdev *regexdev; /* Pointer to the RegEx dev. */ uint16_t nb_queues; /* Number of queues. */ struct mlx5_regex_qp *qps; /* Pointer to the qp array. */ -- 2.25.1