From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>, linux-rdma@vger.kernel.org
Cc: Jiri Pirko <jiri@resnulli.us>,
patches@lists.linux.dev,
Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Subject: [PATCH 6/6] RDMA/core: Move flow related functions to ib_uverbs_support.ko
Date: Wed, 13 May 2026 14:33:28 -0300 [thread overview]
Message-ID: <6-v1-045258567bd6+9fe-ib_uverbs_support_ko_jgg@nvidia.com> (raw)
In-Reply-To: <0-v1-045258567bd6+9fe-ib_uverbs_support_ko_jgg@nvidia.com>
mlx5 uses these as part of the driver implementation, move them to the
support module instead.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/infiniband/core/Makefile | 3 +-
drivers/infiniband/core/uverbs_cmd.c | 76 --------------------------
drivers/infiniband/core/uverbs_flow.c | 78 +++++++++++++++++++++++++++
3 files changed, 80 insertions(+), 77 deletions(-)
create mode 100644 drivers/infiniband/core/uverbs_flow.c
diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile
index 697468cf88b16f..69f72b63e961ab 100644
--- a/drivers/infiniband/core/Makefile
+++ b/drivers/infiniband/core/Makefile
@@ -48,4 +48,5 @@ ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_marshall.o \
uverbs_std_types_qp.o
ib_uverbs_support-y := rdma_core.o \
- ucaps.o
+ ucaps.o \
+ uverbs_flow.o
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index a768436ba46805..fce6eb18287a19 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2589,82 +2589,6 @@ static int ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs)
return ret;
}
-struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
-{
- struct ib_uflow_resources *resources;
-
- resources = kzalloc_obj(*resources);
-
- if (!resources)
- return NULL;
-
- if (!num_specs)
- goto out;
-
- resources->counters =
- kzalloc_objs(*resources->counters, num_specs);
- resources->collection =
- kzalloc_objs(*resources->collection, num_specs);
-
- if (!resources->counters || !resources->collection)
- goto err;
-
-out:
- resources->max = num_specs;
- return resources;
-
-err:
- kfree(resources->counters);
- kfree(resources);
-
- return NULL;
-}
-EXPORT_SYMBOL(flow_resources_alloc);
-
-void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res)
-{
- unsigned int i;
-
- if (!uflow_res)
- return;
-
- for (i = 0; i < uflow_res->collection_num; i++)
- atomic_dec(&uflow_res->collection[i]->usecnt);
-
- for (i = 0; i < uflow_res->counters_num; i++)
- atomic_dec(&uflow_res->counters[i]->usecnt);
-
- kfree(uflow_res->collection);
- kfree(uflow_res->counters);
- kfree(uflow_res);
-}
-EXPORT_SYMBOL(ib_uverbs_flow_resources_free);
-
-void flow_resources_add(struct ib_uflow_resources *uflow_res,
- enum ib_flow_spec_type type,
- void *ibobj)
-{
- WARN_ON(uflow_res->num >= uflow_res->max);
-
- switch (type) {
- case IB_FLOW_SPEC_ACTION_HANDLE:
- atomic_inc(&((struct ib_flow_action *)ibobj)->usecnt);
- uflow_res->collection[uflow_res->collection_num++] =
- (struct ib_flow_action *)ibobj;
- break;
- case IB_FLOW_SPEC_ACTION_COUNT:
- atomic_inc(&((struct ib_counters *)ibobj)->usecnt);
- uflow_res->counters[uflow_res->counters_num++] =
- (struct ib_counters *)ibobj;
- break;
- default:
- WARN_ON(1);
- }
-
- uflow_res->num++;
-}
-EXPORT_SYMBOL(flow_resources_add);
-
static int kern_spec_to_ib_spec_action(struct uverbs_attr_bundle *attrs,
struct ib_uverbs_flow_spec *kern_spec,
union ib_flow_spec *ib_spec,
diff --git a/drivers/infiniband/core/uverbs_flow.c b/drivers/infiniband/core/uverbs_flow.c
new file mode 100644
index 00000000000000..1528a294f7f85f
--- /dev/null
+++ b/drivers/infiniband/core/uverbs_flow.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
+#include "uverbs.h"
+
+struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
+{
+ struct ib_uflow_resources *resources;
+
+ resources = kzalloc_obj(*resources);
+
+ if (!resources)
+ return NULL;
+
+ if (!num_specs)
+ goto out;
+
+ resources->counters =
+ kzalloc_objs(*resources->counters, num_specs);
+ resources->collection =
+ kzalloc_objs(*resources->collection, num_specs);
+
+ if (!resources->counters || !resources->collection)
+ goto err;
+
+out:
+ resources->max = num_specs;
+ return resources;
+
+err:
+ kfree(resources->counters);
+ kfree(resources);
+
+ return NULL;
+}
+EXPORT_SYMBOL(flow_resources_alloc);
+
+void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res)
+{
+ unsigned int i;
+
+ if (!uflow_res)
+ return;
+
+ for (i = 0; i < uflow_res->collection_num; i++)
+ atomic_dec(&uflow_res->collection[i]->usecnt);
+
+ for (i = 0; i < uflow_res->counters_num; i++)
+ atomic_dec(&uflow_res->counters[i]->usecnt);
+
+ kfree(uflow_res->collection);
+ kfree(uflow_res->counters);
+ kfree(uflow_res);
+}
+EXPORT_SYMBOL(ib_uverbs_flow_resources_free);
+
+void flow_resources_add(struct ib_uflow_resources *uflow_res,
+ enum ib_flow_spec_type type,
+ void *ibobj)
+{
+ WARN_ON(uflow_res->num >= uflow_res->max);
+
+ switch (type) {
+ case IB_FLOW_SPEC_ACTION_HANDLE:
+ atomic_inc(&((struct ib_flow_action *)ibobj)->usecnt);
+ uflow_res->collection[uflow_res->collection_num++] =
+ (struct ib_flow_action *)ibobj;
+ break;
+ case IB_FLOW_SPEC_ACTION_COUNT:
+ atomic_inc(&((struct ib_counters *)ibobj)->usecnt);
+ uflow_res->counters[uflow_res->counters_num++] =
+ (struct ib_counters *)ibobj;
+ break;
+ default:
+ WARN_ON(1);
+ }
+
+ uflow_res->num++;
+}
+EXPORT_SYMBOL(flow_resources_add);
--
2.43.0
next prev parent reply other threads:[~2026-05-13 17:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 17:33 [PATCH 0/6] Remove driver dependencies on ib_uverbs.ko Jason Gunthorpe
2026-05-13 17:33 ` [PATCH 1/6] RDMA/core: Move the _ib_copy_validate_udata* functions to ib_core_uverbs Jason Gunthorpe
2026-05-15 23:12 ` Jason Gunthorpe
2026-05-13 17:33 ` [PATCH 2/6] RDMA/core: Move many of the little EXPORTs from uverbs_ioctl into ib_core_uverbs Jason Gunthorpe
2026-05-13 17:33 ` [PATCH 3/6] RDMA/core: Remove uverbs_async_event_release() Jason Gunthorpe
2026-05-13 17:33 ` [PATCH 4/6] RDMA/core: Make a new module for the uverbs components needed by drivers Jason Gunthorpe
2026-05-13 17:33 ` [PATCH 5/6] RDMA/core: Move ucaps into ib_uverbs_support.ko Jason Gunthorpe
2026-05-13 17:33 ` Jason Gunthorpe [this message]
2026-05-15 18:23 ` [PATCH 6/6] RDMA/core: Move flow related functions to ib_uverbs_support.ko kernel test robot
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=6-v1-045258567bd6+9fe-ib_uverbs_support_ko_jgg@nvidia.com \
--to=jgg@nvidia.com \
--cc=jiri@resnulli.us \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=sriharsha.basavapatna@broadcom.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