From: Michael Guralnik Date: Mon, 30 Mar 2026 17:31:17 +0000 (+0300) Subject: rdma: Add FRMR pools set aging command X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26c8bc1e65635beb7f5061a482aafaba1966b67c;p=thirdparty%2Fiproute2.git rdma: Add FRMR pools set aging command 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 Reviewed-by: Patrisious Haddad Reviewed-by: Chiara Meiohas Signed-off-by: David Ahern --- diff --git a/man/man8/rdma-resource.8 b/man/man8/rdma-resource.8 index 4dfb8218..dffbdebe 100644 --- a/man/man8/rdma-resource.8 +++ b/man/man8/rdma-resource.8 @@ -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), diff --git a/rdma/res-frmr-pools.c b/rdma/res-frmr-pools.c index 7d99a728..c9d80c4b 100644 --- a/rdma/res-frmr-pools.c +++ b/rdma/res-frmr-pools.c @@ -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); +} diff --git a/rdma/res.c b/rdma/res.c index f1f13d74..63d8386a 100644 --- a/rdma/res.c +++ b/rdma/res.c @@ -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 } diff --git a/rdma/res.h b/rdma/res.h index 7c3e88f2..aace637d 100644 --- a/rdma/res.h +++ b/rdma/res.h @@ -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);