From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.31 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796385015; b=V/9HoaQ26Wuq61ycSmjxB1ZV73uTJsusnJcCddXNKdOlgzghOg7nFMDL+K3EJVxg+Gss hZrRSKgaF0PtviYOXffdz34exO/jnlfvKuQE2Mx/RMzXBmKP/ASFnau/kKQE8nwxEfjFF T7Dfk8U/jAepBQYoYnOpLhklqpF2B1Vlc9IEhM73I+ztas0wYSaS0xYI0uOLwGToSPQQr xuNgxOzKYKDBx4oTHV5e1wDM6WWSX+9kI3ql+hdpQQpAXPdXyQymPJfeOzu6oOpljoxbw 3//SVY+CIYRzse1wgPWUczgy93iHnvdkrMZ4xqxnDR/adf6+5xJqjOD/lUvHD/mgYAA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385015; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Received:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: Content-Type:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=6BVlNB5fbfhwvFfHWTzQF69YOMQDA4c+RxyKfyc+KZE=; b=MUCOLEBR709E4UQiH4soB9uH/9jktqFgKLvJtmd77LsLE0vZpTP9CLF6fEM2uX3ge4be ghX9fI6l2YV3tzGrlBGnGN/Nhz86TOe5Kte1X6UJA/DYw941Bs4LAjBC4xX728i/WPExd FqTscYQwb+pzBgfSmZuekQM4rJI0znKJAemyU+ymubTbCQ01UN/W2LPAz7SDlJh6Yh0+V y7+EksY+uacruZBJ/+jy3YleldhqnY3JuIvj8rqS5DJa9rFwRiQQyghHR4/gu2ClWvZny ek4EF3qadhy+vjJu9ynX82h1WZFrw2MyofJ8WO1JTVFMg5gO54Bdnvi9peUpd79D2Aw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=XJ5NdXCV; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.31 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010031.outbound.protection.outlook.com [52.101.61.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28C2A606A32C; Fri, 4 Dec 2026 11:50:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 28C2A606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=XJ5NdXCV ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z2WtGfj7aLog1bnnOF6olGaIBWTcVon/DbVHde5B5pZryBH1zhcFRMixufxZXtuxoHRyLPduk3a2+aJ4R/ANBmcvo3bbfZtKKQtqRWCGIq7UGqMItF5HP6K7vO7fKC1vGajQ6MxkYXhvsMkITTIhm17dWyGQVP57PaTEzPDRX5PJsp3dBXtCj7swW5SDi9wztUaJDguAOeUsNys36Rhq1D86nbXNlHF4/sqJBp+vR29U+/79Ni2qzIKkm8YymTCt+foqLh+SFq2Zp8PXvbKBKXqLajGtjjbBmCAEgQdqBqCYg/ZTjk+lgIkVgDS6tEfp1wEkji+6iAx4d2onFd8xiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=6BVlNB5fbfhwvFfHWTzQF69YOMQDA4c+RxyKfyc+KZE=; b=jkxcaHuEinEIzEOvEANmfhOp/8xzmg06Yb45Z5IvS+dTN5yedV+fmYhaxrDFNaVkHRVTOXUYjbg4zMIOPlPAwbOtwuWJpt+vqc9783VoHQcHbBnq/ahdQzAfrZ1RE9CjaisMTaOVnZvCCh0IPeQOyzwWtf53jcKR1fO5gLqwHa4wbWB3vJ1x2ntPEcGdY7fqqzIHKO0NhNNdZyYwoNY3sk4wKsCqoBgzSZIQrJmXXZeLzHzvBYKby3qG1Lkmen9lPF9/LobB9ozfyDdottWDXLqyGgGeX1MZO32FszU7SaJRAbTH5SvCLa+HpQElU8+OH/PFOnM1FXHkx83LJe+4jA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=ziepe.ca smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6BVlNB5fbfhwvFfHWTzQF69YOMQDA4c+RxyKfyc+KZE=; b=XJ5NdXCVwB7fy8N4hPwPBjGN+FLfKvdyS2rbvALXcybQ8HO62jBx8VDknagpfByXev4KErid6bN4ephTYaMbeqrQJauMoxoOal6Quyi4YjskWqMQ9fqlxDFdFjoy+GTaKpBiXN7HnYCgD6Gf5IyKxo+1i9kCAqy+9jvyZP4dhJU= Received: from CYXPR03CA0064.namprd03.prod.outlook.com (2603:10b6:930:d1::19) by SN7PR12MB7369.namprd12.prod.outlook.com (2603:10b6:806:298::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Fri, 4 Dec 2026 11:50:08 +0000 Received: from CY5PEPF00000E85.namprd05.prod.outlook.com (2603:10b6:930:d1:cafe::2e) by CYXPR03CA0064.outlook.office365.com (2603:10b6:930:d1::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.13 via Frontend Transport; Fri, 4 Dec 2026 11:50:07 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by CY5PEPF00000E85.mail.protection.outlook.com (10.167.247.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Fri, 4 Dec 2026 11:50:07 +0000 Received: from Satlexmb09.amd.com (10.181.42.218) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 05:50:06 -0600 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb09.amd.com (10.181.42.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 05:50:06 -0600 Received: from xhdipdslab46.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Fri, 4 Dec 2026 05:50:04 -0600 From: Abhijit Gangurde To: , CC: , , , , "Abhijit Gangurde" , Jiri Pirko Subject: [for-next v5 3/4] RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes Date: Fri, 4 Dec 2026 17:19:42 +0530 Message-ID: <20261204114943.3530599-4-abhijit.gangurde@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261204114943.3530599-1-abhijit.gangurde@amd.com> References: <20261204114943.3530599-1-abhijit.gangurde@amd.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PEPF00000E85:EE_|SN7PR12MB7369:EE_ X-MS-Office365-Filtering-Correlation-Id: 7256d720-fbb7-4611-8a29-08df51fcbe12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700016|1800799024|23010399003|261009223027099003|18002099003|22082099003|261021135927099003|5023799004|261022075727099003|56012099006|261102123227099003|10067099003|11063799006|261026140227099003|261021121427099003|261021123027099003|261026121527099003|261022105027099003|261028144727099003; X-Microsoft-Antispam-Message-Info: aAJlC8xHno4ajKfPGwyN4pOybIqmhoJx8NKeSxcN33RXuyQeEVk9cKRG0PWS5eCYn7QyrfMvOfOjltzGwp7E+VsyksA2394S4Nmrr2xlFz3+jH2K9nauHzjbChvJQysCrvxxR6N9+QyNzC9sPpJagOQHSSL0SzvsZI9ewNVjrhHYosQ7SZYe/mCKJWrn9ZcPHydjC8dW3XdptK3nH8tRrR0qv6/H89/WFnMc9Ea6i/gcwESFoQJ+Dnx7eInqkAwIXfpkaWXPzjdruNWKyXMZTAYm3EcsaphP6pE7p/HcfJVTzGNrGohT3Me1IjqmdOWFwB8hVM6PzVZmsEAXHb91OIh2c8t06YP1yTYPQkcUPoWPOP4nNaaOU8VlLVH0PruWbsfw8QQ7/HXz3fleoK6p39gOKlTao58TARG4DZNe2pFeMAPgX4TJ69BEoOSdX7Rbjyo5F/tvcXgO8OoH/LdbCgimk5Qf4oitaM0621P/AjC6mTHOvVbDtZlk25rRRB2YOXGXqzL2aix08f5dN/yYHZcuCKiAgsdmKY6F4wg5+Fnw528Xipe/BPGjw+2UH5/TMW6+d6RdQlgQtT1mhFPSmxwCZN0UAhjshO2Bahll8MW0pNTJY5CojHdXtgAqZpbhx8jeS3V6CSwyOM9W3XiLiU1ONvx9u5Q4tSIKQQu4+LcMVHZ4fq8gC7siriO5laAMqiDiPwb6DHQqG3nfiwT/7g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700016)(1800799024)(23010399003)(261009223027099003)(18002099003)(22082099003)(261021135927099003)(5023799004)(261022075727099003)(56012099006)(261102123227099003)(10067099003)(11063799006)(261026140227099003)(261021121427099003)(261021123027099003)(261026121527099003)(261022105027099003)(261028144727099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I0yLAxGZTkaCxCjyWvpyC/L22DERsq1arp/QVskKU3ANEN7vxQEo2KNVTFFMRyKj148kjCesa0pQ47Pif1Mp0rc+3Cw+zjbAeTL4eeR6aaxWUV6cVOQNjJ54YyxrRa3Y+UvTq0i1CxO7pGXKdcYKyqkdMGBqYWVGngaWBbYzeUiQC80gUrbwRSSX1q8GSIvDBh9Igca/NABIZTx5ULClfVjinhylE5Qw7IXvmKYa8W5CWeId3y785KFOQPKGGWk3aeylOoR0ZPhbFstMvDImbEeuUjdE+3sMlvv+/ieJ+5oIriyuZcMIhSXJumyhsSmhOxkZLyB5ePvtTxCtorbXRHoV8wx4K5qfBb+YflxShiiF/a2400vyIUrA1WdPywjuUIJPpC0pxs7e6tHo0YB6SwRcp3mVahw+8hkVm0IYD05w0FaMtECxgOC8p5VTGzCW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 11:50:07.1552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7256d720-fbb7-4611-8a29-08df51fcbe12 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY5PEPF00000E85.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7369 Userspace can now pass each enabled CQ ring to create_cq as a struct ib_uverbs_buffer_desc in a per-UDMA driver attribute, instead of only as a raw address in ionic_cq_req. Register two optional UVERBS_ATTR_UMEM attributes, IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0 and _1, on UVERBS_METHOD_CQ_CREATE through ibdev->driver_def. Support is advertised to userspace in the next patch, once the QP rings are handled as well. For each UDMA index in udma_mask, ionic_cq_get_user_umem() pins the ring with ib_umem_get_attr() on the attribute for that index. The core resolves the descriptor, so the ring can be a virtual address or a dma-buf and the driver does not look inside it. req_cq->addr is not used when the attribute is present. Without the attribute the ring is pinned from req_cq->addr with DMA_FROM_DEVICE, as before. A ring passed in the attribute must be exactly req_cq->size bytes, so the page table given to the device covers the ring and nothing else. Any other length is rejected with -EINVAL. The page table is built from PAGE_SIZE blocks, so the ring must also map as whole pages. ib_umem_find_best_pgsz() checks this on the pinned umem, and a dma-buf whose DMA segments are not page aligned is rejected with -EINVAL. A ring pinned from a virtual address always passes. A ring passed as a virtual address descriptor is mapped DMA_BIDIRECTIONAL, because ib_umem_get_attr() derives the direction from the access flags. The core CQ helpers that map DMA_FROM_DEVICE only take UVERBS_ATTR_CREATE_CQ_BUF_UMEM, not a driver attribute. An attribute for a UDMA index that is not in udma_mask is rejected with -EINVAL. The kernel admin CQ path passes no attribute bundle and is unchanged. ionic_cq_req and ionic_cq_resp are not changed, so older providers continue to use the write command path. Reviewed-by: Jiri Pirko Signed-off-by: Abhijit Gangurde --- MAINTAINERS | 1 + drivers/infiniband/hw/ionic/ionic_admin.c | 2 +- .../infiniband/hw/ionic/ionic_controlpath.c | 56 +++++++++++++++---- drivers/infiniband/hw/ionic/ionic_ibdev.c | 17 ++++++ drivers/infiniband/hw/ionic/ionic_ibdev.h | 2 + include/uapi/rdma/ionic_user_ioctl_cmds.h | 15 +++++ 6 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 include/uapi/rdma/ionic_user_ioctl_cmds.h diff --git a/MAINTAINERS b/MAINTAINERS index 222b7fc2c3aa..9d79cea2ab84 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1293,6 +1293,7 @@ S: Maintained F: Documentation/networking/device_drivers/ethernet/pensando/ionic_rdma.rst F: drivers/infiniband/hw/ionic/ F: include/uapi/rdma/ionic-abi.h +F: include/uapi/rdma/ionic_user_ioctl_cmds.h AMD PMC DRIVER M: Shyam Sundar S K diff --git a/drivers/infiniband/hw/ionic/ionic_admin.c b/drivers/infiniband/hw/ionic/ionic_admin.c index 859893568538..ae2a67daa9e8 100644 --- a/drivers/infiniband/hw/ionic/ionic_admin.c +++ b/drivers/infiniband/hw/ionic/ionic_admin.c @@ -575,7 +575,7 @@ static struct ionic_vcq *ionic_create_rdma_admincq(struct ionic_ibdev *dev, vcq->udma_mask = 1; cq = &vcq->cq[0]; - rc = ionic_create_cq_common(vcq, &buf, &attr, NULL, NULL, + rc = ionic_create_cq_common(vcq, &buf, &attr, NULL, NULL, NULL, NULL, 0); if (rc) goto err_init; diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c index 3abb8c01daf6..b15494ace1f4 100644 --- a/drivers/infiniband/hw/ionic/ionic_controlpath.c +++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c @@ -76,8 +76,15 @@ static void ionic_put_cqid(struct ionic_ibdev *dev, u32 cqid) ionic_resid_put(&dev->inuse_cqid, bitid); } +static const u16 ionic_cq_buf_attrs[] = { + IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0, + IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1, +}; + static int ionic_cq_get_user_umem(struct ionic_ibdev *dev, struct ionic_cq *cq, - const struct ionic_qdesc *req_cq) + const struct ionic_qdesc *req_cq, + const struct uverbs_attr_bundle *attrs, + int udma_idx) { struct ib_umem *umem; int rc; @@ -86,13 +93,23 @@ static int ionic_cq_get_user_umem(struct ionic_ibdev *dev, struct ionic_cq *cq, if (rc) return rc; - umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL, req_cq->addr, - req_cq->size, IB_ACCESS_LOCAL_WRITE); + umem = ib_umem_get_attr(&dev->ibdev, attrs, + ionic_cq_buf_attrs[udma_idx], req_cq->size, + IB_ACCESS_LOCAL_WRITE); if (IS_ERR(umem)) return PTR_ERR(umem); - /* The ring is given to the device as whole pages */ - if (ib_umem_offset(umem)) { + if (!umem) { + umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL, + req_cq->addr, req_cq->size, + IB_ACCESS_LOCAL_WRITE); + if (IS_ERR(umem)) + return PTR_ERR(umem); + } + + /* The device is given whole pages, and only those of the ring */ + if (umem->length != req_cq->size || ib_umem_offset(umem) || + !ib_umem_find_best_pgsz(umem, PAGE_SIZE, 0)) { ib_umem_release(umem); return -EINVAL; } @@ -106,6 +123,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq, const struct ib_cq_init_attr *attr, struct ionic_ctx *ctx, struct ib_udata *udata, + const struct uverbs_attr_bundle *attrs, struct ionic_qdesc *req_cq, int udma_idx) { @@ -134,7 +152,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq, INIT_LIST_HEAD(&cq->flush_rq); if (udata) { - rc = ionic_cq_get_user_umem(dev, cq, req_cq); + rc = ionic_cq_get_user_umem(dev, cq, req_cq, attrs, udma_idx); if (rc) goto err_qdesc; @@ -1383,6 +1401,20 @@ static int ionic_destroy_cq_cmd(struct ionic_ibdev *dev, u32 cqid) return ionic_admin_wait(dev, &wr, IONIC_ADMIN_F_TEARDOWN); } +static bool ionic_cq_unused_buf_attr(const struct uverbs_attr_bundle *attrs, + u8 udma_mask) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(ionic_cq_buf_attrs); i++) { + if (!(udma_mask & BIT(i)) && + uverbs_attr_is_valid(attrs, ionic_cq_buf_attrs[i])) + return true; + } + + return false; +} + int ionic_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, struct uverbs_attr_bundle *attrs) { @@ -1393,7 +1425,7 @@ int ionic_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, struct ionic_vcq *vcq = to_ionic_vcq(ibcq); struct ionic_tbl_buf buf = {}; struct ionic_cq_resp resp = {}; - struct ionic_cq_req req; + struct ionic_cq_req req = {}; int udma_idx = 0, rc; if (udata) { @@ -1412,13 +1444,17 @@ int ionic_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, goto err_init; } + if (udata && ionic_cq_unused_buf_attr(attrs, vcq->udma_mask)) { + rc = -EINVAL; + goto err_init; + } + for (; udma_idx < dev->lif_cfg.udma_count; ++udma_idx) { if (!(vcq->udma_mask & BIT(udma_idx))) continue; - rc = ionic_create_cq_common(vcq, &buf, attr, ctx, udata, - &req.cq[udma_idx], - udma_idx); + rc = ionic_create_cq_common(vcq, &buf, attr, ctx, udata, attrs, + &req.cq[udma_idx], udma_idx); if (rc) goto err_init; diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.c b/drivers/infiniband/hw/ionic/ionic_ibdev.c index b4d4544bb7ac..e64c8e891f30 100644 --- a/drivers/infiniband/hw/ionic/ionic_ibdev.c +++ b/drivers/infiniband/hw/ionic/ionic_ibdev.c @@ -11,6 +11,9 @@ #include "ionic_ibdev.h" +#define UVERBS_MODULE_NAME ionic_rdma +#include + #define DRIVER_DESCRIPTION "AMD Pensando RoCE HCA driver" #define DEVICE_DESCRIPTION "AMD Pensando RoCE HCA" @@ -217,6 +220,18 @@ static void ionic_disassociate_ucontext(struct ib_ucontext *ibcontext) */ } +ADD_UVERBS_ATTRIBUTES_SIMPLE( + ionic_cq_create, + UVERBS_OBJECT_CQ, + UVERBS_METHOD_CQ_CREATE, + UVERBS_ATTR_UMEM(IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0, UA_OPTIONAL), + UVERBS_ATTR_UMEM(IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1, UA_OPTIONAL)); + +static const struct uapi_definition ionic_uapi_defs[] = { + UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_CQ, &ionic_cq_create), + {}, +}; + static const struct ib_device_ops ionic_dev_ops = { .owner = THIS_MODULE, .driver_id = RDMA_DRIVER_IONIC, @@ -376,6 +391,8 @@ static struct ionic_ibdev *ionic_create_ibdev(struct ionic_aux_dev *ionic_adev) ionic_stats_init(dev); + ibdev->driver_def = ionic_uapi_defs; + rc = ib_register_device(ibdev, "ionic_%d", ibdev->dev.parent); if (rc) goto err_register; diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h index 8e7e52c9f492..6cf8bad98672 100644 --- a/drivers/infiniband/hw/ionic/ionic_ibdev.h +++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -490,6 +491,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq, const struct ib_cq_init_attr *attr, struct ionic_ctx *ctx, struct ib_udata *udata, + const struct uverbs_attr_bundle *attrs, struct ionic_qdesc *req_cq, int udma_idx); int ionic_post_create_cq_cmd(struct ionic_cq *cq, diff --git a/include/uapi/rdma/ionic_user_ioctl_cmds.h b/include/uapi/rdma/ionic_user_ioctl_cmds.h new file mode 100644 index 000000000000..98bb8d7238e6 --- /dev/null +++ b/include/uapi/rdma/ionic_user_ioctl_cmds.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* Copyright (C) 2026, Advanced Micro Devices, Inc */ + +#ifndef IONIC_USER_IOCTL_CMDS_H +#define IONIC_USER_IOCTL_CMDS_H + +#include +#include + +enum ionic_ib_create_cq_attrs { + IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0 = UVERBS_ID_DRIVER_NS_WITH_UHW, + IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1, +}; + +#endif -- 2.43.0