public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: "Håkon Bugge" <haakon.bugge@oracle.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Allison Henderson <allison.henderson@oracle.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, rds-devel@oss.oracle.com
Subject: [MAINLINE 1/2] RDMA/core: Enable legacy ULPs to use RDMA DIM
Date: Wed, 18 Sep 2024 10:35:51 +0200	[thread overview]
Message-ID: <20240918083552.77531-2-haakon.bugge@oracle.com> (raw)
In-Reply-To: <20240918083552.77531-1-haakon.bugge@oracle.com>

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@oracle.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@oracle.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


  reply	other threads:[~2024-09-18  8:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-18  8:35 [MAINLINE 0/2] Enable DIM for legacy ULPs and use it in RDS Håkon Bugge
2024-09-18  8:35 ` Håkon Bugge [this message]
2024-09-18  8:35 ` [MAINLINE 2/2] rds: ib: Add Dynamic Interrupt Moderation to CQs Håkon Bugge
2024-09-20  7:47   ` Zhu Yanjun
2024-09-20  9:42     ` Haakon Bugge
2024-09-20 12:51       ` Zhu Yanjun
2024-09-21 13:43   ` Zhu Yanjun
2024-09-19 14:17 ` [MAINLINE 0/2] Enable DIM for legacy ULPs and use it in RDS Christoph Hellwig
2024-09-20  9:46   ` Haakon Bugge
2024-09-20 13:51     ` Christoph Hellwig
2024-09-21  2:28       ` Zhu Yanjun
2024-09-22 14:11         ` Leon Romanovsky
2024-09-23 12:03         ` Christoph Hellwig
2024-09-24  1:58           ` Zhu Yanjun
2024-09-24  6:54             ` Christoph Hellwig
2024-09-24 13:59               ` Zhu Yanjun
2024-09-24 15:16                 ` Haakon Bugge
2024-09-25  2:04                   ` Zhu Yanjun
2024-09-25  9:26                     ` Leon Romanovsky
2024-09-26 15:25                       ` Zhu Yanjun
2024-09-24  7:01       ` Christoph Hellwig
2024-09-24  8:59         ` Haakon Bugge
2024-09-24 15:20           ` Allison Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240918083552.77531-2-haakon.bugge@oracle.com \
    --to=haakon.bugge@oracle.com \
    --cc=allison.henderson@oracle.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jgg@ziepe.ca \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rds-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox