lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240918083552.77531-2-haakon.bugge@oracle.com>
Date: Wed, 18 Sep 2024 10:35:51 +0200
From: Håkon Bugge <haakon.bugge@...cle.com>
To: Jason Gunthorpe <jgg@...pe.ca>, Leon Romanovsky <leon@...nel.org>,
        Allison Henderson <allison.henderson@...cle.com>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>
Cc: linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org,
        netdev@...r.kernel.org, rds-devel@....oracle.com
Subject: [MAINLINE 1/2] RDMA/core: Enable legacy ULPs to use RDMA DIM

The RDMA DIM mechanism is not available for legacy ULPs using
ib_create_cq(). Hence, enable it in ib_create_cq_user() if
IB_CQ_MODERATE is set in cq_attr.flags.

This way, legacy ULPs can take advantage of RDMA DIM.

Signed-off-by: Håkon Bugge <haakon.bugge@...cle.com>
---
 drivers/infiniband/core/cq.c    |  7 +++++--
 drivers/infiniband/core/cq.h    | 16 ++++++++++++++++
 drivers/infiniband/core/verbs.c |  6 ++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 drivers/infiniband/core/cq.h

diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c
index a70876a0a2312..8e582eca6987f 100644
--- a/drivers/infiniband/core/cq.c
+++ b/drivers/infiniband/core/cq.c
@@ -7,6 +7,7 @@
 #include <rdma/ib_verbs.h>
 
 #include "core_priv.h"
+#include "cq.h"
 
 #include <trace/events/rdma_core.h>
 /* Max size for shared CQ, may require tuning */
@@ -50,7 +51,7 @@ static void ib_cq_rdma_dim_work(struct work_struct *w)
 	cq->device->ops.modify_cq(cq, comps, usec);
 }
 
-static void rdma_dim_init(struct ib_cq *cq)
+void rdma_dim_init(struct ib_cq *cq)
 {
 	struct dim *dim;
 
@@ -70,8 +71,9 @@ static void rdma_dim_init(struct ib_cq *cq)
 
 	INIT_WORK(&dim->work, ib_cq_rdma_dim_work);
 }
+EXPORT_SYMBOL(rdma_dim_init);
 
-static void rdma_dim_destroy(struct ib_cq *cq)
+void rdma_dim_destroy(struct ib_cq *cq)
 {
 	if (!cq->dim)
 		return;
@@ -79,6 +81,7 @@ static void rdma_dim_destroy(struct ib_cq *cq)
 	cancel_work_sync(&cq->dim->work);
 	kfree(cq->dim);
 }
+EXPORT_SYMBOL(rdma_dim_destroy);
 
 static int __poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc)
 {
diff --git a/drivers/infiniband/core/cq.h b/drivers/infiniband/core/cq.h
new file mode 100644
index 0000000000000..c55f7d3f1cbf4
--- /dev/null
+++ b/drivers/infiniband/core/cq.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Let other files use rdma_dim_{init,destroy}
+ *
+ * Author: Håkon Bugge <haakon.bugge@...cle.com>
+ *
+ * Copyright (c) 2024 Oracle and/or its affiliates.
+ */
+
+#ifndef CQ_H
+#define CQ_H
+
+void rdma_dim_init(struct ib_cq *cq);
+void rdma_dim_destroy(struct ib_cq *cq);
+
+#endif
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 473ee0831307c..60a64ea77ae25 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -53,6 +53,7 @@
 #include <rdma/lag.h>
 
 #include "core_priv.h"
+#include "cq.h"
 #include <trace/events/rdma_core.h>
 
 static int ib_resolve_eth_dmac(struct ib_device *device,
@@ -2161,6 +2162,9 @@ struct ib_cq *__ib_create_cq(struct ib_device *device,
 		return ERR_PTR(ret);
 	}
 
+	if (cq_attr->flags & IB_CQ_MODERATE)
+		rdma_dim_init(cq);
+
 	rdma_restrack_add(&cq->res);
 	return cq;
 }
@@ -2187,6 +2191,8 @@ int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata)
 	if (atomic_read(&cq->usecnt))
 		return -EBUSY;
 
+	rdma_dim_destroy(cq);
+
 	ret = cq->device->ops.destroy_cq(cq, udata);
 	if (ret)
 		return ret;
-- 
2.43.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ