get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/105545/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 105545,
    "url": "http://patchwork.dpdk.org/api/patches/105545/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20220102070638.2211160-3-michaelba@nvidia.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20220102070638.2211160-3-michaelba@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220102070638.2211160-3-michaelba@nvidia.com",
    "date": "2022-01-02T07:06:37",
    "name": "[RFC,2/3] common/mlx5: add shared PD support",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "71efda9cca5898b22b3c756f52eba76ebea638ab",
    "submitter": {
        "id": 1949,
        "url": "http://patchwork.dpdk.org/api/people/1949/?format=api",
        "name": "Michael Baum",
        "email": "michaelba@nvidia.com"
    },
    "delegate": {
        "id": 3268,
        "url": "http://patchwork.dpdk.org/api/users/3268/?format=api",
        "username": "rasland",
        "first_name": "Raslan",
        "last_name": "Darawsheh",
        "email": "rasland@nvidia.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20220102070638.2211160-3-michaelba@nvidia.com/mbox/",
    "series": [
        {
            "id": 21045,
            "url": "http://patchwork.dpdk.org/api/series/21045/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=21045",
            "date": "2022-01-02T07:06:35",
            "name": "net/mlx5: add external RxQ support",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/21045/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/105545/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/105545/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 57C10A0093;\n\tSun,  2 Jan 2022 08:07:13 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 737BF406FF;\n\tSun,  2 Jan 2022 08:07:06 +0100 (CET)",
            "from NAM10-DM6-obe.outbound.protection.outlook.com\n (mail-dm6nam10on2049.outbound.protection.outlook.com [40.107.93.49])\n by mails.dpdk.org (Postfix) with ESMTP id E972F41145\n for <dev@dpdk.org>; Sun,  2 Jan 2022 08:07:04 +0100 (CET)",
            "from DM5PR07CA0127.namprd07.prod.outlook.com (2603:10b6:3:13e::17)\n by DM5PR12MB2359.namprd12.prod.outlook.com (2603:10b6:4:b4::12) with\n Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Sun, 2 Jan\n 2022 07:07:02 +0000",
            "from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com\n (2603:10b6:3:13e:cafe::aa) by DM5PR07CA0127.outlook.office365.com\n (2603:10b6:3:13e::17) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.13 via Frontend\n Transport; Sun, 2 Jan 2022 07:07:02 +0000",
            "from mail.nvidia.com (12.22.5.234) by\n DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP\n Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id\n 15.20.4844.14 via Frontend Transport; Sun, 2 Jan 2022 07:07:02 +0000",
            "from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com\n (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18;\n Sun, 2 Jan 2022 07:07:01 +0000",
            "from nvidia.com (172.20.187.6) by rnnvmail201.nvidia.com\n (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.9; Sat, 1 Jan 2022\n 23:06:59 -0800"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n b=d18SCcC9/pa7HeWB7M4X6B4iUphYkM6umEQUex4RzxJfnGH1I+VNycatZRbcYJpto17SHc5fE7h5bQq5CM+fU148zkG04r1VP1FbKhf0fRYwl8soL9FTblV5I4ntopJ2G5KwL017PXEL/ZEpKeqTonA5Cjx2LXIs5R99uIciTwvySJlQPxOlLNpHr8yD+Q4uW1P5rOOUdcjzlgv1MqnvkQGyv4m6KHRJvzw0y0SQC1R2QrWBUleD/4yDVHLbQn9tMjiVi3tsH5DwJ+GDBRzF/X3XXn5hqvEGMvHzBy+dT93mi6edHe30Ob773Yeq91mL0WhJd5OnDqCtCDHF7w/WLQ==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector9901;\n 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;\n bh=OP0vx9dw8ftr97wXAZs+NJfH+skIMSpJExNrM0ugv7c=;\n b=QALA6+mlQLXHa7mFuI2u9Y1oinX/WAUfKGDnnhuszab9yAQfMJlZOx3H9CxEHFZMCVeaTcRHbWbVqT28Y3G0s9oinb9ML/DJccdMutnTmGIzY+6FyL3TYTpXYkeeC3CbEsFSjuyu7AapGdIqScjsOXS15O6t4OqM+K7HFtm8gS3I1TZFynAdHDHlfAzbWyRhqlyRmeWhj1WHU0WYr5EaXtuzP+OGLsuYrQm91N31aqvKAIut+KFqItEc2VVfJlbU1isB9c509Fvdz/MLwSBgeWA5jhonW4PpGOxFWTEVwNwxq7XXMqaWQaTwwlXHW8p/md8tR57qYjKvum0GL1gK4Q==",
        "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 12.22.5.234) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass\n (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none\n (message not signed); arc=none",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com;\n s=selector2;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=OP0vx9dw8ftr97wXAZs+NJfH+skIMSpJExNrM0ugv7c=;\n b=STaJfBPyP07WsuVCNZqI3n+kSdwRKM6AvEAgGfnzoUxOdu2xDQlHE4Vy0leUKbJJkidkX/0q854dKNBXlr9tRXLU17p+wnwcePa/vOxph3bJnNAHxK/DdD2jQrbrxBak9znRXeNbz4QzhTpA8B8QyOHJtVR8va3MhN601pKB7S4SJy9xpXCMACiQDIV9yOm2Wy7bGYI1nNT2ChdXI6g5hThVpJ31l/TYfwp9qpZXzUKJBqWTkBQGsHEMbjKMMIpclGhAtgJ9mwMOUlGki2ZTKiXbUIsXYNkSgxPyo+MkIbDDiZGUp05HIK0czHi2DABi5Z8sHeVi3HJkVxxxcop8Bw==",
        "X-MS-Exchange-Authentication-Results": "spf=pass (sender IP is 12.22.5.234)\n smtp.mailfrom=nvidia.com; dkim=none (message not signed)\n header.d=none;dmarc=pass action=none header.from=nvidia.com;",
        "Received-SPF": "Pass (protection.outlook.com: domain of nvidia.com designates\n 12.22.5.234 as permitted sender) receiver=protection.outlook.com;\n client-ip=12.22.5.234; helo=mail.nvidia.com;",
        "From": "<michaelba@nvidia.com>",
        "To": "<dev@dpdk.org>",
        "CC": "Matan Azrad <matan@nvidia.com>, Raslan Darawsheh <rasland@nvidia.com>,\n Viacheslav Ovsiienko <viacheslavo@nvidia.com>, Michael Baum\n <michaelba@nvidia.com>",
        "Subject": "[RFC 2/3] common/mlx5: add shared PD support",
        "Date": "Sun, 2 Jan 2022 09:06:37 +0200",
        "Message-ID": "<20220102070638.2211160-3-michaelba@nvidia.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220102070638.2211160-1-michaelba@nvidia.com>",
        "References": "<20220102070638.2211160-1-michaelba@nvidia.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[172.20.187.6]",
        "X-ClientProxiedBy": "HQMAIL107.nvidia.com (172.20.187.13) To\n rnnvmail201.nvidia.com (10.129.68.8)",
        "X-EOPAttributedMessage": "0",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-Office365-Filtering-Correlation-Id": "daf375ac-ac4e-4f11-71fe-08d9cdbe79e4",
        "X-MS-TrafficTypeDiagnostic": "DM5PR12MB2359:EE_",
        "X-Microsoft-Antispam-PRVS": "\n <DM5PR12MB235991D7677626C636A56C5ECC489@DM5PR12MB2359.namprd12.prod.outlook.com>",
        "X-MS-Oob-TLC-OOBClassifiers": "OLM:17;",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;",
        "X-Microsoft-Antispam-Message-Info": "\n f27QRoZ4Gj5XcSur1b/+1xuW3kXIY1XQvo3TLRKBi7Igq2R/pY66ZGCGMv9gyIgUkpeebDgF5o5gbffJl3OvQHuo4rOxj61kJ3rsnnX/cfA6EFMVIXaUtEJzOkNorIT9QJuB68kLxWdKHXFaYUP8L992CrD+k5O6L+SqvyyQqxAQ+pw2UheNwpx1Gh0PVoyaCPEHSbeKnJs0CUmLBoWAZ39Ah4XO6cD5HtR4qXgPATv0XfzY8oi82jfmn7K/Q8DgzambHNg2XKUsSF8r94BEUA5qLEosx7x/OLNXIXgbe9FJ+fc+3iD14RTyu6kAfNzBG5Nofsa0fxzjy1y4Gkh3Nl4vSdekjnfB4U4LwLjGUimy29ML5C/k79jgFG4F9NzbM53FaCMDEz6feU50jeELZ0I+m6LVFLSHktDzXUN3dc+9tD1XnkkRM0zzB3oq0iQsJryLgjCLVMpt31zAyFdCuMtByKSdRst4aTdiEF3uAopJP08BMTcY1qGZLJSOsyt0olwA0YIgEaSzzBaeTBUP7TVA1ei52vFCEnF2xjf2OM6Ih5CMh0cqRgm9iGCa/sqr75DKqvvpIU9Ttlw0WkmmCt6uSoONnDW2Mn4Mm0BQ9q6iPcUSx55gs1z3qMty1Vc7fZov8ff7zhsG0O78g5fqAb2eBQa16VPwxwpioyj+CcSvfe0lEXYMGCjvsnIv0L4y754rCFCeow+Tau7u/tL4IHW3uPiPmKUzF8DreFuyPdXf43GRjT3zl0AEGcctn4U3f5fQT26O2SNp9gDu51TlJYpeDzS2TFy6cRLlXHTr5S3F+8rlz1Sp4yi3FKO3IVar7IE0e4MjR3/auxgyFHY1sQ==",
        "X-Forefront-Antispam-Report": "CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:;\n IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE;\n SFS:(4636009)(36840700001)(40470700002)(46966006)(6666004)(6286002)(316002)(2906002)(36756003)(36860700001)(7696005)(81166007)(8676002)(4326008)(107886003)(26005)(70206006)(40460700001)(47076005)(16526019)(8936002)(186003)(70586007)(508600001)(2616005)(1076003)(6916009)(86362001)(336012)(5660300002)(54906003)(356005)(55016003)(82310400004)(83380400001)(2876002)(30864003)(426003)(36900700001)(309714004);\n DIR:OUT; SFP:1101;",
        "X-OriginatorOrg": "Nvidia.com",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "02 Jan 2022 07:07:02.0412 (UTC)",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n daf375ac-ac4e-4f11-71fe-08d9cdbe79e4",
        "X-MS-Exchange-CrossTenant-Id": "43083d15-7273-40c1-b7db-39efd9ccc17a",
        "X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp": "\n TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234];\n Helo=[mail.nvidia.com]",
        "X-MS-Exchange-CrossTenant-AuthSource": "\n DM6NAM11FT054.eop-nam11.prod.protection.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Anonymous",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "HybridOnPrem",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "DM5PR12MB2359",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "From: Michael Baum <michaelba@nvidia.com>\n\nAdd option to probe common device using import CTX/PD functions instead\nof create functions.\nThis option requires accepting the context FD and the PD handle as\ndevargs.\n\nSigned-off-by: Michael Baum <michaelba@nvidia.com>\n---\n drivers/common/mlx5/linux/mlx5_common_os.c   | 160 +++++++++++++++++--\n drivers/common/mlx5/linux/mlx5_common_os.h   |   6 -\n drivers/common/mlx5/mlx5_common.c            |  32 ++--\n drivers/common/mlx5/mlx5_common.h            |   6 +-\n drivers/common/mlx5/windows/mlx5_common_os.c |  29 +++-\n drivers/common/mlx5/windows/mlx5_common_os.h |   1 -\n 6 files changed, 196 insertions(+), 38 deletions(-)",
    "diff": "diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c\nindex 0d3e24e04e..a8226e987f 100644\n--- a/drivers/common/mlx5/linux/mlx5_common_os.c\n+++ b/drivers/common/mlx5/linux/mlx5_common_os.c\n@@ -416,7 +416,7 @@ mlx5_glue_constructor(void)\n  * @return\n  *   0 on success, a negative errno value otherwise and rte_errno is set.\n  */\n-int\n+static int\n mlx5_os_pd_create(struct mlx5_common_device *cdev)\n {\n #ifdef HAVE_IBV_FLOW_DV_SUPPORT\n@@ -450,6 +450,65 @@ mlx5_os_pd_create(struct mlx5_common_device *cdev)\n #endif /* HAVE_IBV_FLOW_DV_SUPPORT */\n }\n \n+/**\n+ * Import Protection Domain object according to given pdn.\n+ *\n+ * @param[out] cdev\n+ *   Pointer to the mlx5 device.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+static int\n+mlx5_os_pd_import(struct mlx5_common_device *cdev)\n+{\n+\tstruct mlx5_common_dev_config *config = &cdev->config;\n+\n+\tcdev->pd = mlx5_glue->import_pd(cdev->ctx, config->pd_handle);\n+\tif (cdev->pd == NULL) {\n+\t\tDRV_LOG(ERR, \"Failed to import PD.\");\n+\t\treturn errno ? -errno : -ENOMEM;\n+\t}\n+\tcdev->pdn = config->pd_handle;\n+\treturn 0;\n+}\n+\n+/**\n+ * Prepare Protection Domain object and extract its pdn using DV API.\n+ *\n+ * @param[out] cdev\n+ *   Pointer to the mlx5 device.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+int\n+mlx5_os_pd_prepare(struct mlx5_common_device *cdev)\n+{\n+\tif (cdev->config.pd_handle == MLX5_ARG_UNSET)\n+\t\treturn mlx5_os_pd_create(cdev);\n+\telse\n+\t\treturn mlx5_os_pd_import(cdev);\n+}\n+\n+/**\n+ * Release Protection Domain object.\n+ *\n+ * @param[out] cdev\n+ *   Pointer to the mlx5 device.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise.\n+ */\n+int\n+mlx5_os_pd_release(struct mlx5_common_device *cdev)\n+{\n+\tif (cdev->config.pd_handle == MLX5_ARG_UNSET)\n+\t\treturn mlx5_glue->dealloc_pd(cdev->pd);\n+\tmlx5_glue->unimport_pd(cdev->pd);\n+\treturn 0;\n+}\n+\n static struct ibv_device *\n mlx5_os_get_ibv_device(const struct rte_pci_addr *addr)\n {\n@@ -648,28 +707,28 @@ mlx5_restore_doorbell_mapping_env(int value)\n /**\n  * Function API to open IB device.\n  *\n- *\n  * @param cdev\n  *   Pointer to the mlx5 device.\n  * @param classes\n  *   Chosen classes come from device arguments.\n  *\n  * @return\n- *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ *   Pointer to ibv_context on success, NULL otherwise and rte_errno is set.\n  */\n-int\n-mlx5_os_open_device(struct mlx5_common_device *cdev, uint32_t classes)\n+static struct ibv_context *\n+mlx5_open_device(struct mlx5_common_device *cdev, uint32_t classes)\n {\n \tstruct ibv_device *ibv;\n \tstruct ibv_context *ctx = NULL;\n \tint dbmap_env;\n \n+\tMLX5_ASSERT(cdev->config.device_fd == MLX5_ARG_UNSET);\n \tif (classes & MLX5_CLASS_VDPA)\n \t\tibv = mlx5_vdpa_get_ibv_dev(cdev->dev);\n \telse\n \t\tibv = mlx5_os_get_ibv_dev(cdev->dev);\n \tif (!ibv)\n-\t\treturn -rte_errno;\n+\t\treturn NULL;\n \tDRV_LOG(INFO, \"Dev information matches for device \\\"%s\\\".\", ibv->name);\n \t/*\n \t * Configure environment variable \"MLX5_BF_SHUT_UP\" before the device\n@@ -682,29 +741,104 @@ mlx5_os_open_device(struct mlx5_common_device *cdev, uint32_t classes)\n \tctx = mlx5_glue->dv_open_device(ibv);\n \tif (ctx) {\n \t\tcdev->config.devx = 1;\n-\t\tDRV_LOG(DEBUG, \"DevX is supported.\");\n \t} else if (classes == MLX5_CLASS_ETH) {\n \t\t/* The environment variable is still configured. */\n \t\tctx = mlx5_glue->open_device(ibv);\n \t\tif (ctx == NULL)\n \t\t\tgoto error;\n-\t\tDRV_LOG(DEBUG, \"DevX is NOT supported.\");\n \t} else {\n \t\tgoto error;\n \t}\n \t/* The device is created, no need for environment. */\n \tmlx5_restore_doorbell_mapping_env(dbmap_env);\n-\t/* Hint libmlx5 to use PMD allocator for data plane resources */\n-\tmlx5_set_context_attr(cdev->dev, ctx);\n-\tcdev->ctx = ctx;\n-\treturn 0;\n+\treturn ctx;\n error:\n \trte_errno = errno ? errno : ENODEV;\n \t/* The device creation is failed, no need for environment. */\n \tmlx5_restore_doorbell_mapping_env(dbmap_env);\n \tDRV_LOG(ERR, \"Failed to open IB device \\\"%s\\\".\", ibv->name);\n-\treturn -rte_errno;\n+\treturn NULL;\n }\n+\n+/**\n+ * Function API to import IB device.\n+ *\n+ * @param cdev\n+ *   Pointer to the mlx5 device.\n+ *\n+ * @return\n+ *   Pointer to ibv_context on success, NULL otherwise and rte_errno is set.\n+ */\n+static struct ibv_context *\n+mlx5_import_device(struct mlx5_common_device *cdev)\n+{\n+\tstruct ibv_context *ctx = NULL;\n+\n+\tMLX5_ASSERT(cdev->config.device_fd != MLX5_ARG_UNSET);\n+\tctx = mlx5_glue->import_device(cdev->config.device_fd);\n+\tif (!ctx) {\n+\t\tDRV_LOG(ERR, \"Failed to import device for fd=%d.\",\n+\t\t\tcdev->config.device_fd);\n+\t\trte_errno = errno;\n+\t}\n+\treturn ctx;\n+}\n+\n+/**\n+ * Function API to prepare IB device.\n+ *\n+ * @param cdev\n+ *   Pointer to the mlx5 device.\n+ * @param classes\n+ *   Chosen classes come from device arguments.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+int\n+mlx5_os_open_device(struct mlx5_common_device *cdev, uint32_t classes)\n+{\n+\n+\tstruct ibv_context *ctx = NULL;\n+\n+\tif (cdev->config.device_fd == MLX5_ARG_UNSET)\n+\t\tctx = mlx5_open_device(cdev, classes);\n+\telse\n+\t\tctx = mlx5_import_device(cdev);\n+\tif (ctx == NULL)\n+\t\treturn -rte_errno;\n+\t/* Hint libmlx5 to use PMD allocator for data plane resources */\n+\tmlx5_set_context_attr(cdev->dev, ctx);\n+\tcdev->ctx = ctx;\n+\treturn 0;\n+}\n+\n+/**\n+ * Query HCA attributes.\n+ * For remote context, it is check if DevX is supported.\n+ *\n+ * @param cdev\n+ *   Pointer to mlx5 device structure.\n+ *\n+ * @return\n+ *   0 on success, a negative value otherwise.\n+ */\n+int\n+mlx5_os_query_hca_attr(struct mlx5_common_device *cdev)\n+{\n+\tint ret;\n+\n+\tret = mlx5_devx_cmd_query_hca_attr(cdev->ctx, &cdev->config.hca_attr);\n+\tif (ret) {\n+\t\tif (cdev->config.device_fd == MLX5_ARG_UNSET) {\n+\t\t\trte_errno = ENOTSUP;\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\tcdev->config.devx = 0;\n+\t}\n+\treturn 0;\n+}\n+\n int\n mlx5_get_device_guid(const struct rte_pci_addr *dev, uint8_t *guid, size_t len)\n {\ndiff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h\nindex 83066e752d..246e8b2784 100644\n--- a/drivers/common/mlx5/linux/mlx5_common_os.h\n+++ b/drivers/common/mlx5/linux/mlx5_common_os.h\n@@ -203,12 +203,6 @@ mlx5_os_get_devx_uar_page_id(void *uar)\n #endif\n }\n \n-static inline int\n-mlx5_os_dealloc_pd(void *pd)\n-{\n-\treturn mlx5_glue->dealloc_pd(pd);\n-}\n-\n __rte_internal\n static inline void *\n mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access)\ndiff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c\nindex f1650f94c6..bd7f0021d5 100644\n--- a/drivers/common/mlx5/mlx5_common.c\n+++ b/drivers/common/mlx5/mlx5_common.c\n@@ -133,6 +133,10 @@ mlx5_common_args_check_handler(const char *key, const char *val, void *opaque)\n \t\tconfig->mr_mempool_reg_en = !!tmp;\n \t} else if (strcmp(key, \"sys_mem_en\") == 0) {\n \t\tconfig->sys_mem_en = !!tmp;\n+\t} else if (strcmp(key, \"device_fd\") == 0) {\n+\t\tconfig->device_fd = !!tmp;\n+\t} else if (strcmp(key, \"pd_handle\") == 0) {\n+\t\tconfig->pd_handle = !!tmp;\n \t}\n \treturn 0;\n }\n@@ -160,6 +164,8 @@ mlx5_common_config_get(struct rte_devargs *devargs,\n \tconfig->mr_mempool_reg_en = 1;\n \tconfig->sys_mem_en = 0;\n \tconfig->dbnc = MLX5_ARG_UNSET;\n+\tconfig->device_fd = MLX5_ARG_UNSET;\n+\tconfig->pd_handle = MLX5_ARG_UNSET;\n \tif (devargs == NULL)\n \t\treturn 0;\n \tkvlist = rte_kvargs_parse(devargs->args, NULL);\n@@ -492,7 +498,7 @@ static void\n mlx5_dev_hw_global_release(struct mlx5_common_device *cdev)\n {\n \tif (cdev->pd != NULL) {\n-\t\tclaim_zero(mlx5_os_dealloc_pd(cdev->pd));\n+\t\tclaim_zero(mlx5_os_pd_release(cdev));\n \t\tcdev->pd = NULL;\n \t}\n \tif (cdev->ctx != NULL) {\n@@ -522,19 +528,23 @@ mlx5_dev_hw_global_prepare(struct mlx5_common_device *cdev, uint32_t classes)\n \tif (ret < 0)\n \t\treturn ret;\n \t/* Allocate Protection Domain object and extract its pdn. */\n-\tret = mlx5_os_pd_create(cdev);\n+\tret = mlx5_os_pd_prepare(cdev);\n \tif (ret)\n \t\tgoto error;\n-\t/* All actions taken below are relevant only when DevX is supported */\n-\tif (cdev->config.devx == 0)\n-\t\treturn 0;\n-\t/* Query HCA attributes. */\n-\tret = mlx5_devx_cmd_query_hca_attr(cdev->ctx, &cdev->config.hca_attr);\n-\tif (ret) {\n-\t\tDRV_LOG(ERR, \"Unable to read HCA capabilities.\");\n-\t\trte_errno = ENOTSUP;\n-\t\tgoto error;\n+\t/*\n+\t * TODO: write it again...\n+\t * All actions taken below are relevant only when DevX is supported\n+\t */\n+\tif (cdev->config.devx || cdev->config.device_fd != MLX5_ARG_UNSET) {\n+\t\t/* Query HCA attributes. */\n+\t\tret = mlx5_os_query_hca_attr(cdev);\n+\t\tif (ret) {\n+\t\t\tDRV_LOG(ERR, \"Unable to read HCA capabilities.\");\n+\t\t\trte_errno = ENOTSUP;\n+\t\t\tgoto error;\n+\t\t}\n \t}\n+\tDRV_LOG(DEBUG, \"DevX is %ssupported.\", cdev->config.devx ? \"\" : \"NOT \");\n \treturn 0;\n error:\n \tmlx5_dev_hw_global_release(cdev);\ndiff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h\nindex e8809844af..78c8a29740 100644\n--- a/drivers/common/mlx5/mlx5_common.h\n+++ b/drivers/common/mlx5/mlx5_common.h\n@@ -414,6 +414,8 @@ void mlx5_common_init(void);\n struct mlx5_common_dev_config {\n \tstruct mlx5_hca_attr hca_attr; /* HCA attributes. */\n \tint dbnc; /* Skip doorbell register write barrier. */\n+\tint device_fd; /* Device file descriptor for importation. */\n+\tint pd_handle; /* Protection Domain handle for importation.  */\n \tunsigned int devx:1; /* Whether devx interface is available or not. */\n \tunsigned int sys_mem_en:1; /* The default memory allocator. */\n \tunsigned int mr_mempool_reg_en:1;\n@@ -507,7 +509,9 @@ mlx5_devx_uar_release(struct mlx5_uar *uar);\n /* mlx5_common_os.c */\n \n int mlx5_os_open_device(struct mlx5_common_device *cdev, uint32_t classes);\n-int mlx5_os_pd_create(struct mlx5_common_device *cdev);\n+int mlx5_os_query_hca_attr(struct mlx5_common_device *cdev);\n+int mlx5_os_pd_prepare(struct mlx5_common_device *cdev);\n+int mlx5_os_pd_release(struct mlx5_common_device *cdev);\n \n /* mlx5 PMD wrapped MR struct. */\n struct mlx5_pmd_wrapped_mr {\ndiff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c\nindex 162c7476cc..d8410f57c1 100644\n--- a/drivers/common/mlx5/windows/mlx5_common_os.c\n+++ b/drivers/common/mlx5/windows/mlx5_common_os.c\n@@ -25,21 +25,38 @@ mlx5_glue_constructor(void)\n {\n }\n \n+/**\n+ * Query HCA attributes.\n+ *\n+ * @param cdev\n+ *   Pointer to mlx5 device structure.\n+ *\n+ * @return\n+ *   0 on success, a negative value otherwise.\n+ */\n+int\n+mlx5_os_query_hca_attr(struct mlx5_common_device *cdev)\n+{\n+\treturn mlx5_devx_cmd_query_hca_attr(cdev->ctx, &cdev->config.hca_attr);\n+}\n+\n /**\n  * Release PD. Releases a given mlx5_pd object\n  *\n- * @param[in] pd\n- *   Pointer to mlx5_pd.\n+ * @param[in] cdev\n+ *   Pointer to the mlx5 device.\n  *\n  * @return\n  *   Zero if pd is released successfully, negative number otherwise.\n  */\n int\n-mlx5_os_dealloc_pd(void *pd)\n+mlx5_os_pd_release(struct mlx5_common_device *cdev)\n {\n+\tstruct mlx5_pd *pd = cdev->pd;\n+\n \tif (!pd)\n \t\treturn -EINVAL;\n-\tmlx5_devx_cmd_destroy(((struct mlx5_pd *)pd)->obj);\n+\tmlx5_devx_cmd_destroy(pd->obj);\n \tmlx5_free(pd);\n \treturn 0;\n }\n@@ -47,14 +64,14 @@ mlx5_os_dealloc_pd(void *pd)\n /**\n  * Allocate Protection Domain object and extract its pdn using DV API.\n  *\n- * @param[out] dev\n+ * @param[out] cdev\n  *   Pointer to the mlx5 device.\n  *\n  * @return\n  *   0 on success, a negative value otherwise.\n  */\n int\n-mlx5_os_pd_create(struct mlx5_common_device *cdev)\n+mlx5_os_pd_prepare(struct mlx5_common_device *cdev)\n {\n \tstruct mlx5_pd *pd;\n \ndiff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h\nindex 3afce56cd9..a6a1b6890f 100644\n--- a/drivers/common/mlx5/windows/mlx5_common_os.h\n+++ b/drivers/common/mlx5/windows/mlx5_common_os.h\n@@ -248,7 +248,6 @@ mlx5_os_devx_subscribe_devx_event(void *eventc,\n \treturn -ENOTSUP;\n }\n \n-int mlx5_os_dealloc_pd(void *pd);\n __rte_internal\n void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);\n __rte_internal\n",
    "prefixes": [
        "RFC",
        "2/3"
    ]
}