1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
7 #include "devl_internal.h"
9 static const struct devlink_param devlink_param_generic[] = {
11 .id = DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
12 .name = DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME,
13 .type = DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE,
16 .id = DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
17 .name = DEVLINK_PARAM_GENERIC_MAX_MACS_NAME,
18 .type = DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE,
21 .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV,
22 .name = DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME,
23 .type = DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE,
26 .id = DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
27 .name = DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME,
28 .type = DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE,
31 .id = DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI,
32 .name = DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME,
33 .type = DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE,
36 .id = DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
37 .name = DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME,
38 .type = DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE,
41 .id = DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
42 .name = DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME,
43 .type = DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE,
46 .id = DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY,
47 .name = DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME,
48 .type = DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE,
51 .id = DEVLINK_PARAM_GENERIC_ID_RESET_DEV_ON_DRV_PROBE,
52 .name = DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_NAME,
53 .type = DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_TYPE,
56 .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE,
57 .name = DEVLINK_PARAM_GENERIC_ENABLE_ROCE_NAME,
58 .type = DEVLINK_PARAM_GENERIC_ENABLE_ROCE_TYPE,
61 .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_REMOTE_DEV_RESET,
62 .name = DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_NAME,
63 .type = DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_TYPE,
66 .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH,
67 .name = DEVLINK_PARAM_GENERIC_ENABLE_ETH_NAME,
68 .type = DEVLINK_PARAM_GENERIC_ENABLE_ETH_TYPE,
71 .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
72 .name = DEVLINK_PARAM_GENERIC_ENABLE_RDMA_NAME,
73 .type = DEVLINK_PARAM_GENERIC_ENABLE_RDMA_TYPE,
76 .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_VNET,
77 .name = DEVLINK_PARAM_GENERIC_ENABLE_VNET_NAME,
78 .type = DEVLINK_PARAM_GENERIC_ENABLE_VNET_TYPE,
81 .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_IWARP,
82 .name = DEVLINK_PARAM_GENERIC_ENABLE_IWARP_NAME,
83 .type = DEVLINK_PARAM_GENERIC_ENABLE_IWARP_TYPE,
86 .id = DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE,
87 .name = DEVLINK_PARAM_GENERIC_IO_EQ_SIZE_NAME,
88 .type = DEVLINK_PARAM_GENERIC_IO_EQ_SIZE_TYPE,
91 .id = DEVLINK_PARAM_GENERIC_ID_EVENT_EQ_SIZE,
92 .name = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME,
93 .type = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE,
97 static int devlink_param_generic_verify(const struct devlink_param *param)
99 /* verify it match generic parameter by id and name */
100 if (param->id > DEVLINK_PARAM_GENERIC_ID_MAX)
102 if (strcmp(param->name, devlink_param_generic[param->id].name))
105 WARN_ON(param->type != devlink_param_generic[param->id].type);
110 static int devlink_param_driver_verify(const struct devlink_param *param)
114 if (param->id <= DEVLINK_PARAM_GENERIC_ID_MAX)
116 /* verify no such name in generic params */
117 for (i = 0; i <= DEVLINK_PARAM_GENERIC_ID_MAX; i++)
118 if (!strcmp(param->name, devlink_param_generic[i].name))
124 static struct devlink_param_item *
125 devlink_param_find_by_name(struct xarray *params, const char *param_name)
127 struct devlink_param_item *param_item;
128 unsigned long param_id;
130 xa_for_each(params, param_id, param_item) {
131 if (!strcmp(param_item->param->name, param_name))
137 static struct devlink_param_item *
138 devlink_param_find_by_id(struct xarray *params, u32 param_id)
140 return xa_load(params, param_id);
144 devlink_param_cmode_is_supported(const struct devlink_param *param,
145 enum devlink_param_cmode cmode)
147 return test_bit(cmode, ¶m->supported_cmodes);
150 static int devlink_param_get(struct devlink *devlink,
151 const struct devlink_param *param,
152 struct devlink_param_gset_ctx *ctx)
156 return param->get(devlink, param->id, ctx);
159 static int devlink_param_set(struct devlink *devlink,
160 const struct devlink_param *param,
161 struct devlink_param_gset_ctx *ctx)
165 return param->set(devlink, param->id, ctx);
169 devlink_param_type_to_nla_type(enum devlink_param_type param_type)
171 switch (param_type) {
172 case DEVLINK_PARAM_TYPE_U8:
174 case DEVLINK_PARAM_TYPE_U16:
176 case DEVLINK_PARAM_TYPE_U32:
178 case DEVLINK_PARAM_TYPE_STRING:
180 case DEVLINK_PARAM_TYPE_BOOL:
188 devlink_nl_param_value_fill_one(struct sk_buff *msg,
189 enum devlink_param_type type,
190 enum devlink_param_cmode cmode,
191 union devlink_param_value val)
193 struct nlattr *param_value_attr;
195 param_value_attr = nla_nest_start_noflag(msg,
196 DEVLINK_ATTR_PARAM_VALUE);
197 if (!param_value_attr)
198 goto nla_put_failure;
200 if (nla_put_u8(msg, DEVLINK_ATTR_PARAM_VALUE_CMODE, cmode))
201 goto value_nest_cancel;
204 case DEVLINK_PARAM_TYPE_U8:
205 if (nla_put_u8(msg, DEVLINK_ATTR_PARAM_VALUE_DATA, val.vu8))
206 goto value_nest_cancel;
208 case DEVLINK_PARAM_TYPE_U16:
209 if (nla_put_u16(msg, DEVLINK_ATTR_PARAM_VALUE_DATA, val.vu16))
210 goto value_nest_cancel;
212 case DEVLINK_PARAM_TYPE_U32:
213 if (nla_put_u32(msg, DEVLINK_ATTR_PARAM_VALUE_DATA, val.vu32))
214 goto value_nest_cancel;
216 case DEVLINK_PARAM_TYPE_STRING:
217 if (nla_put_string(msg, DEVLINK_ATTR_PARAM_VALUE_DATA,
219 goto value_nest_cancel;
221 case DEVLINK_PARAM_TYPE_BOOL:
223 nla_put_flag(msg, DEVLINK_ATTR_PARAM_VALUE_DATA))
224 goto value_nest_cancel;
228 nla_nest_end(msg, param_value_attr);
232 nla_nest_cancel(msg, param_value_attr);
237 static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
238 unsigned int port_index,
239 struct devlink_param_item *param_item,
240 enum devlink_command cmd,
241 u32 portid, u32 seq, int flags)
243 union devlink_param_value param_value[DEVLINK_PARAM_CMODE_MAX + 1];
244 bool param_value_set[DEVLINK_PARAM_CMODE_MAX + 1] = {};
245 const struct devlink_param *param = param_item->param;
246 struct devlink_param_gset_ctx ctx;
247 struct nlattr *param_values_list;
248 struct nlattr *param_attr;
254 /* Get value from driver part to driverinit configuration mode */
255 for (i = 0; i <= DEVLINK_PARAM_CMODE_MAX; i++) {
256 if (!devlink_param_cmode_is_supported(param, i))
258 if (i == DEVLINK_PARAM_CMODE_DRIVERINIT) {
259 if (param_item->driverinit_value_new_valid)
260 param_value[i] = param_item->driverinit_value_new;
261 else if (param_item->driverinit_value_valid)
262 param_value[i] = param_item->driverinit_value;
267 err = devlink_param_get(devlink, param, &ctx);
270 param_value[i] = ctx.val;
272 param_value_set[i] = true;
275 hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
279 if (devlink_nl_put_handle(msg, devlink))
282 if (cmd == DEVLINK_CMD_PORT_PARAM_GET ||
283 cmd == DEVLINK_CMD_PORT_PARAM_NEW ||
284 cmd == DEVLINK_CMD_PORT_PARAM_DEL)
285 if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX, port_index))
288 param_attr = nla_nest_start_noflag(msg, DEVLINK_ATTR_PARAM);
291 if (nla_put_string(msg, DEVLINK_ATTR_PARAM_NAME, param->name))
292 goto param_nest_cancel;
293 if (param->generic && nla_put_flag(msg, DEVLINK_ATTR_PARAM_GENERIC))
294 goto param_nest_cancel;
296 nla_type = devlink_param_type_to_nla_type(param->type);
298 goto param_nest_cancel;
299 if (nla_put_u8(msg, DEVLINK_ATTR_PARAM_TYPE, nla_type))
300 goto param_nest_cancel;
302 param_values_list = nla_nest_start_noflag(msg,
303 DEVLINK_ATTR_PARAM_VALUES_LIST);
304 if (!param_values_list)
305 goto param_nest_cancel;
307 for (i = 0; i <= DEVLINK_PARAM_CMODE_MAX; i++) {
308 if (!param_value_set[i])
310 err = devlink_nl_param_value_fill_one(msg, param->type,
313 goto values_list_nest_cancel;
316 nla_nest_end(msg, param_values_list);
317 nla_nest_end(msg, param_attr);
318 genlmsg_end(msg, hdr);
321 values_list_nest_cancel:
322 nla_nest_end(msg, param_values_list);
324 nla_nest_cancel(msg, param_attr);
326 genlmsg_cancel(msg, hdr);
330 static void devlink_param_notify(struct devlink *devlink,
331 unsigned int port_index,
332 struct devlink_param_item *param_item,
333 enum devlink_command cmd)
338 WARN_ON(cmd != DEVLINK_CMD_PARAM_NEW && cmd != DEVLINK_CMD_PARAM_DEL &&
339 cmd != DEVLINK_CMD_PORT_PARAM_NEW &&
340 cmd != DEVLINK_CMD_PORT_PARAM_DEL);
342 /* devlink_notify_register() / devlink_notify_unregister()
343 * will replay the notifications if the params are added/removed
344 * outside of the lifetime of the instance.
346 if (!devl_is_registered(devlink) || !devlink_nl_notify_need(devlink))
349 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
352 err = devlink_nl_param_fill(msg, devlink, port_index, param_item, cmd,
359 devlink_nl_notify_send(devlink, msg);
362 static void devlink_params_notify(struct devlink *devlink,
363 enum devlink_command cmd)
365 struct devlink_param_item *param_item;
366 unsigned long param_id;
368 xa_for_each(&devlink->params, param_id, param_item)
369 devlink_param_notify(devlink, 0, param_item, cmd);
372 void devlink_params_notify_register(struct devlink *devlink)
374 devlink_params_notify(devlink, DEVLINK_CMD_PARAM_NEW);
377 void devlink_params_notify_unregister(struct devlink *devlink)
379 devlink_params_notify(devlink, DEVLINK_CMD_PARAM_DEL);
382 static int devlink_nl_param_get_dump_one(struct sk_buff *msg,
383 struct devlink *devlink,
384 struct netlink_callback *cb,
387 struct devlink_nl_dump_state *state = devlink_dump_state(cb);
388 struct devlink_param_item *param_item;
389 unsigned long param_id;
392 xa_for_each_start(&devlink->params, param_id, param_item, state->idx) {
393 err = devlink_nl_param_fill(msg, devlink, 0, param_item,
394 DEVLINK_CMD_PARAM_GET,
395 NETLINK_CB(cb->skb).portid,
396 cb->nlh->nlmsg_seq, flags);
397 if (err == -EOPNOTSUPP) {
400 state->idx = param_id;
408 int devlink_nl_param_get_dumpit(struct sk_buff *skb,
409 struct netlink_callback *cb)
411 return devlink_nl_dumpit(skb, cb, devlink_nl_param_get_dump_one);
415 devlink_param_type_get_from_info(struct genl_info *info,
416 enum devlink_param_type *param_type)
418 if (GENL_REQ_ATTR_CHECK(info, DEVLINK_ATTR_PARAM_TYPE))
421 switch (nla_get_u8(info->attrs[DEVLINK_ATTR_PARAM_TYPE])) {
423 *param_type = DEVLINK_PARAM_TYPE_U8;
426 *param_type = DEVLINK_PARAM_TYPE_U16;
429 *param_type = DEVLINK_PARAM_TYPE_U32;
432 *param_type = DEVLINK_PARAM_TYPE_STRING;
435 *param_type = DEVLINK_PARAM_TYPE_BOOL;
445 devlink_param_value_get_from_info(const struct devlink_param *param,
446 struct genl_info *info,
447 union devlink_param_value *value)
449 struct nlattr *param_data;
452 param_data = info->attrs[DEVLINK_ATTR_PARAM_VALUE_DATA];
454 if (param->type != DEVLINK_PARAM_TYPE_BOOL && !param_data)
457 switch (param->type) {
458 case DEVLINK_PARAM_TYPE_U8:
459 if (nla_len(param_data) != sizeof(u8))
461 value->vu8 = nla_get_u8(param_data);
463 case DEVLINK_PARAM_TYPE_U16:
464 if (nla_len(param_data) != sizeof(u16))
466 value->vu16 = nla_get_u16(param_data);
468 case DEVLINK_PARAM_TYPE_U32:
469 if (nla_len(param_data) != sizeof(u32))
471 value->vu32 = nla_get_u32(param_data);
473 case DEVLINK_PARAM_TYPE_STRING:
474 len = strnlen(nla_data(param_data), nla_len(param_data));
475 if (len == nla_len(param_data) ||
476 len >= __DEVLINK_PARAM_MAX_STRING_VALUE)
478 strcpy(value->vstr, nla_data(param_data));
480 case DEVLINK_PARAM_TYPE_BOOL:
481 if (param_data && nla_len(param_data))
483 value->vbool = nla_get_flag(param_data);
489 static struct devlink_param_item *
490 devlink_param_get_from_info(struct xarray *params, struct genl_info *info)
494 if (GENL_REQ_ATTR_CHECK(info, DEVLINK_ATTR_PARAM_NAME))
497 param_name = nla_data(info->attrs[DEVLINK_ATTR_PARAM_NAME]);
498 return devlink_param_find_by_name(params, param_name);
501 int devlink_nl_param_get_doit(struct sk_buff *skb,
502 struct genl_info *info)
504 struct devlink *devlink = info->user_ptr[0];
505 struct devlink_param_item *param_item;
509 param_item = devlink_param_get_from_info(&devlink->params, info);
513 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
517 err = devlink_nl_param_fill(msg, devlink, 0, param_item,
518 DEVLINK_CMD_PARAM_GET,
519 info->snd_portid, info->snd_seq, 0);
525 return genlmsg_reply(msg, info);
528 static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,
529 unsigned int port_index,
530 struct xarray *params,
531 struct genl_info *info,
532 enum devlink_command cmd)
534 enum devlink_param_type param_type;
535 struct devlink_param_gset_ctx ctx;
536 enum devlink_param_cmode cmode;
537 struct devlink_param_item *param_item;
538 const struct devlink_param *param;
539 union devlink_param_value value;
542 param_item = devlink_param_get_from_info(params, info);
545 param = param_item->param;
546 err = devlink_param_type_get_from_info(info, ¶m_type);
549 if (param_type != param->type)
551 err = devlink_param_value_get_from_info(param, info, &value);
554 if (param->validate) {
555 err = param->validate(devlink, param->id, value, info->extack);
560 if (GENL_REQ_ATTR_CHECK(info, DEVLINK_ATTR_PARAM_VALUE_CMODE))
562 cmode = nla_get_u8(info->attrs[DEVLINK_ATTR_PARAM_VALUE_CMODE]);
563 if (!devlink_param_cmode_is_supported(param, cmode))
566 if (cmode == DEVLINK_PARAM_CMODE_DRIVERINIT) {
567 param_item->driverinit_value_new = value;
568 param_item->driverinit_value_new_valid = true;
574 err = devlink_param_set(devlink, param, &ctx);
579 devlink_param_notify(devlink, port_index, param_item, cmd);
583 int devlink_nl_param_set_doit(struct sk_buff *skb, struct genl_info *info)
585 struct devlink *devlink = info->user_ptr[0];
587 return __devlink_nl_cmd_param_set_doit(devlink, 0, &devlink->params,
588 info, DEVLINK_CMD_PARAM_NEW);
591 int devlink_nl_port_param_get_dumpit(struct sk_buff *msg,
592 struct netlink_callback *cb)
594 NL_SET_ERR_MSG(cb->extack, "Port params are not supported");
598 int devlink_nl_port_param_get_doit(struct sk_buff *skb,
599 struct genl_info *info)
601 NL_SET_ERR_MSG(info->extack, "Port params are not supported");
605 int devlink_nl_port_param_set_doit(struct sk_buff *skb,
606 struct genl_info *info)
608 NL_SET_ERR_MSG(info->extack, "Port params are not supported");
612 static int devlink_param_verify(const struct devlink_param *param)
614 if (!param || !param->name || !param->supported_cmodes)
617 return devlink_param_generic_verify(param);
619 return devlink_param_driver_verify(param);
622 static int devlink_param_register(struct devlink *devlink,
623 const struct devlink_param *param)
625 struct devlink_param_item *param_item;
628 WARN_ON(devlink_param_verify(param));
629 WARN_ON(devlink_param_find_by_name(&devlink->params, param->name));
631 if (param->supported_cmodes == BIT(DEVLINK_PARAM_CMODE_DRIVERINIT))
632 WARN_ON(param->get || param->set);
634 WARN_ON(!param->get || !param->set);
636 param_item = kzalloc(sizeof(*param_item), GFP_KERNEL);
640 param_item->param = param;
642 err = xa_insert(&devlink->params, param->id, param_item, GFP_KERNEL);
646 devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
654 static void devlink_param_unregister(struct devlink *devlink,
655 const struct devlink_param *param)
657 struct devlink_param_item *param_item;
659 param_item = devlink_param_find_by_id(&devlink->params, param->id);
660 if (WARN_ON(!param_item))
662 devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_DEL);
663 xa_erase(&devlink->params, param->id);
668 * devl_params_register - register configuration parameters
671 * @params: configuration parameters array
672 * @params_count: number of parameters provided
674 * Register the configuration parameters supported by the driver.
676 int devl_params_register(struct devlink *devlink,
677 const struct devlink_param *params,
680 const struct devlink_param *param = params;
683 lockdep_assert_held(&devlink->lock);
685 for (i = 0; i < params_count; i++, param++) {
686 err = devlink_param_register(devlink, param);
696 for (param--; i > 0; i--, param--)
697 devlink_param_unregister(devlink, param);
700 EXPORT_SYMBOL_GPL(devl_params_register);
702 int devlink_params_register(struct devlink *devlink,
703 const struct devlink_param *params,
709 err = devl_params_register(devlink, params, params_count);
710 devl_unlock(devlink);
713 EXPORT_SYMBOL_GPL(devlink_params_register);
716 * devl_params_unregister - unregister configuration parameters
718 * @params: configuration parameters to unregister
719 * @params_count: number of parameters provided
721 void devl_params_unregister(struct devlink *devlink,
722 const struct devlink_param *params,
725 const struct devlink_param *param = params;
728 lockdep_assert_held(&devlink->lock);
730 for (i = 0; i < params_count; i++, param++)
731 devlink_param_unregister(devlink, param);
733 EXPORT_SYMBOL_GPL(devl_params_unregister);
735 void devlink_params_unregister(struct devlink *devlink,
736 const struct devlink_param *params,
740 devl_params_unregister(devlink, params, params_count);
741 devl_unlock(devlink);
743 EXPORT_SYMBOL_GPL(devlink_params_unregister);
746 * devl_param_driverinit_value_get - get configuration parameter
747 * value for driver initializing
750 * @param_id: parameter ID
751 * @val: pointer to store the value of parameter in driverinit
754 * This function should be used by the driver to get driverinit
755 * configuration for initialization after reload command.
757 * Note that lockless call of this function relies on the
758 * driver to maintain following basic sane behavior:
759 * 1) Driver ensures a call to this function cannot race with
760 * registering/unregistering the parameter with the same parameter ID.
761 * 2) Driver ensures a call to this function cannot race with
762 * devl_param_driverinit_value_set() call with the same parameter ID.
763 * 3) Driver ensures a call to this function cannot race with
765 * If the driver is not able to comply, it has to take the devlink->lock
766 * while calling this.
768 int devl_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
769 union devlink_param_value *val)
771 struct devlink_param_item *param_item;
773 if (WARN_ON(!devlink_reload_supported(devlink->ops)))
776 param_item = devlink_param_find_by_id(&devlink->params, param_id);
780 if (!param_item->driverinit_value_valid)
783 if (WARN_ON(!devlink_param_cmode_is_supported(param_item->param,
784 DEVLINK_PARAM_CMODE_DRIVERINIT)))
787 *val = param_item->driverinit_value;
791 EXPORT_SYMBOL_GPL(devl_param_driverinit_value_get);
794 * devl_param_driverinit_value_set - set value of configuration
795 * parameter for driverinit
799 * @param_id: parameter ID
800 * @init_val: value of parameter to set for driverinit configuration mode
802 * This function should be used by the driver to set driverinit
803 * configuration mode default value.
805 void devl_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
806 union devlink_param_value init_val)
808 struct devlink_param_item *param_item;
810 devl_assert_locked(devlink);
812 param_item = devlink_param_find_by_id(&devlink->params, param_id);
813 if (WARN_ON(!param_item))
816 if (WARN_ON(!devlink_param_cmode_is_supported(param_item->param,
817 DEVLINK_PARAM_CMODE_DRIVERINIT)))
820 param_item->driverinit_value = init_val;
821 param_item->driverinit_value_valid = true;
823 devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
825 EXPORT_SYMBOL_GPL(devl_param_driverinit_value_set);
827 void devlink_params_driverinit_load_new(struct devlink *devlink)
829 struct devlink_param_item *param_item;
830 unsigned long param_id;
832 xa_for_each(&devlink->params, param_id, param_item) {
833 if (!devlink_param_cmode_is_supported(param_item->param,
834 DEVLINK_PARAM_CMODE_DRIVERINIT) ||
835 !param_item->driverinit_value_new_valid)
837 param_item->driverinit_value = param_item->driverinit_value_new;
838 param_item->driverinit_value_valid = true;
839 param_item->driverinit_value_new_valid = false;
844 * devl_param_value_changed - notify devlink on a parameter's value
845 * change. Should be called by the driver
846 * right after the change.
849 * @param_id: parameter ID
851 * This function should be used by the driver to notify devlink on value
852 * change, excluding driverinit configuration mode.
853 * For driverinit configuration mode driver should use the function
855 void devl_param_value_changed(struct devlink *devlink, u32 param_id)
857 struct devlink_param_item *param_item;
859 param_item = devlink_param_find_by_id(&devlink->params, param_id);
860 WARN_ON(!param_item);
862 devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
864 EXPORT_SYMBOL_GPL(devl_param_value_changed);