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>
.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
- 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
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),
}
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);
+}
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;
}
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 }
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);