]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
rdma: Add FRMR pools set aging command
authorMichael Guralnik <michaelgur@nvidia.com>
Mon, 30 Mar 2026 17:31:17 +0000 (20:31 +0300)
committerDavid Ahern <dsahern@kernel.org>
Sun, 5 Apr 2026 17:02:13 +0000 (11:02 -0600)
Add support for configuring the aging period of FRMR pools.
The aging mechanism frees unused FRMR handles that have not been
in use for the specified period.

Usage:
  rdma resource set frmr_pools dev DEV aging AGING_PERIOD

Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Reviewed-by: Patrisious Haddad <phaddad@nvidia.com>
Reviewed-by: Chiara Meiohas <cmeiohas@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
man/man8/rdma-resource.8
rdma/res-frmr-pools.c
rdma/res.c
rdma/res.h

index 4dfb8218b9a2035862854d5fd26b19a627dcf75e..dffbdebe5cd43fe2b779c28fc17ebb71b444b7da 100644 (file)
@@ -26,6 +26,13 @@ rdma-resource \- rdma resource configuration
 .B rdma resource show
 .RI "[ " DEV/PORT_INDEX " ]"
 
+.ti -8
+.B rdma resource set frmr_pools
+.BR dev
+.IR DEV
+.BR aging
+.IR AGING_PERIOD
+
 .ti -8
 .B rdma resource help
 
@@ -37,6 +44,16 @@ rdma-resource \- rdma resource configuration
 - specifies the RDMA link to show.
 If this argument is omitted all links are listed.
 
+.SS rdma resource set - configure resource related parameters
+
+.PP
+.I "DEV"
+- specifies the RDMA device to configure.
+
+.PP
+.I "AGING_PERIOD"
+- specifies the aging period in seconds for unused FRMR handles. Handles unused for this period will be freed.
+
 .SH "EXAMPLES"
 .PP
 rdma resource show
@@ -119,6 +136,11 @@ rdma resource show frmr_pools ats 1
 Show FRMR pools that have ats attribute set.
 .RE
 .PP
+rdma resource set frmr_pools dev rocep8s0f0 aging 120
+.RS 4
+Set the aging period for FRMR pools on device rocep8s0f0 to 120 seconds.
+.RE
+.PP
 
 .SH SEE ALSO
 .BR rdma (8),
index 7d99a728128fdf54744ae66fb8194a6f3121ddb8..c9d80c4bfa39ab353fbb7e7dbcc19e23f236ad27 100644 (file)
@@ -172,3 +172,62 @@ int res_frmr_pools_parse_cb(const struct nlmsghdr *nlh, void *data)
        }
        return ret;
 }
+
+static int res_frmr_pools_one_set_aging(struct rd *rd)
+{
+       uint32_t aging_period;
+       uint32_t seq;
+
+       if (rd_no_arg(rd)) {
+               pr_err("Please provide aging period value.\n");
+               return -EINVAL;
+       }
+
+       if (get_u32(&aging_period, rd_argv(rd), 10)) {
+               pr_err("Invalid aging period value: %s\n", rd_argv(rd));
+               return -EINVAL;
+       }
+
+       if (aging_period == 0) {
+               pr_err("Setting the aging period to zero is not supported.\n");
+               return -EINVAL;
+       }
+
+       rd_prepare_msg(rd, RDMA_NLDEV_CMD_RES_FRMR_POOLS_SET, &seq,
+                      (NLM_F_REQUEST | NLM_F_ACK));
+       mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_DEV_INDEX, rd->dev_idx);
+       mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_RES_FRMR_POOL_AGING_PERIOD,
+                        aging_period);
+
+       return rd_sendrecv_msg(rd, seq);
+}
+
+static int res_frmr_pools_one_set_help(struct rd *rd)
+{
+       pr_out("Usage: %s set frmr_pools dev DEV aging AGING_PERIOD\n",
+              rd->filename);
+       return 0;
+}
+
+static int res_frmr_pools_one_set(struct rd *rd)
+{
+       const struct rd_cmd cmds[] = {
+               { NULL, res_frmr_pools_one_set_help },
+               { "help", res_frmr_pools_one_set_help },
+               { "aging", res_frmr_pools_one_set_aging },
+               { 0 }
+       };
+
+       return rd_exec_cmd(rd, cmds, "resource set frmr_pools command");
+}
+
+int res_frmr_pools_set(struct rd *rd)
+{
+       int ret;
+
+       ret = rd_set_arg_to_devname(rd);
+       if (ret)
+               return ret;
+
+       return rd_exec_require_dev(rd, res_frmr_pools_one_set);
+}
index f1f13d74bde48f4aa4fc002fb974a99bdb005b22..63d8386aa7e88cd5277c7f5009bc761b35aaeacc 100644 (file)
@@ -28,6 +28,7 @@ static int res_help(struct rd *rd)
        pr_out("          resource show srq dev [DEV] [FILTER-NAME FILTER-VALUE]\n");
        pr_out("          resource show frmr_pools dev [DEV]\n");
        pr_out("          resource show frmr_pools dev [DEV] [FILTER-NAME FILTER-VALUE]\n");
+       pr_out("          resource set frmr_pools dev DEV aging AGING_PERIOD\n");
        return 0;
 }
 
@@ -252,11 +253,23 @@ static int res_show(struct rd *rd)
        return rd_exec_cmd(rd, cmds, "parameter");
 }
 
+static int res_set(struct rd *rd)
+{
+       const struct rd_cmd cmds[] = {
+               { NULL,         res_help },
+               { "frmr_pools", res_frmr_pools_set },
+               { 0 }
+       };
+
+       return rd_exec_cmd(rd, cmds, "resource set command");
+}
+
 int cmd_res(struct rd *rd)
 {
        const struct rd_cmd cmds[] = {
                { NULL,         res_show },
                { "show",       res_show },
+               { "set",        res_set },
                { "list",       res_show },
                { "help",       res_help },
                { 0 }
index 7c3e88f217a933e5d36eb6ccc22cc09c76327031..aace637d24206b79ccfbe8bb4190bd04c9f132f1 100644 (file)
@@ -202,6 +202,7 @@ struct filters frmr_pools_valid_filters[MAX_NUMBER_OF_FILTERS] = {
 RES_FUNC(res_frmr_pools, RDMA_NLDEV_CMD_RES_FRMR_POOLS_GET,
         frmr_pools_valid_filters, true, 0);
 
+int res_frmr_pools_set(struct rd *rd);
 void print_dev(uint32_t idx, const char *name);
 void print_link(uint32_t idx, const char *name, uint32_t port, struct nlattr **nla_line);
 void print_key(const char *name, uint64_t val, struct nlattr *nlattr);