1 // SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2 /* Do not edit directly, auto-generated from: */
3 /* Documentation/netlink/specs/devlink.yaml */
4 /* YNL-GEN user source */
8 #include "devlink-user.h"
10 #include <linux/devlink.h>
12 #include <libmnl/libmnl.h>
13 #include <linux/genetlink.h>
16 static const char * const devlink_op_strmap[] = {
19 [DEVLINK_CMD_PORT_NEW] = "port-new",
22 [21] = "sb-port-pool-get",
23 [25] = "sb-tc-pool-bind-get",
24 [DEVLINK_CMD_ESWITCH_GET] = "eswitch-get",
25 [DEVLINK_CMD_DPIPE_TABLE_GET] = "dpipe-table-get",
26 [DEVLINK_CMD_DPIPE_ENTRIES_GET] = "dpipe-entries-get",
27 [DEVLINK_CMD_DPIPE_HEADERS_GET] = "dpipe-headers-get",
28 [DEVLINK_CMD_RESOURCE_DUMP] = "resource-dump",
29 [DEVLINK_CMD_RELOAD] = "reload",
30 [DEVLINK_CMD_PARAM_GET] = "param-get",
31 [DEVLINK_CMD_REGION_GET] = "region-get",
32 [DEVLINK_CMD_REGION_NEW] = "region-new",
33 [DEVLINK_CMD_REGION_READ] = "region-read",
34 [DEVLINK_CMD_PORT_PARAM_GET] = "port-param-get",
35 [DEVLINK_CMD_INFO_GET] = "info-get",
36 [DEVLINK_CMD_HEALTH_REPORTER_GET] = "health-reporter-get",
37 [DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET] = "health-reporter-dump-get",
39 [67] = "trap-group-get",
40 [71] = "trap-policer-get",
42 [80] = "linecard-get",
43 [DEVLINK_CMD_SELFTESTS_GET] = "selftests-get",
46 const char *devlink_op_str(int op)
48 if (op < 0 || op >= (int)MNL_ARRAY_SIZE(devlink_op_strmap))
50 return devlink_op_strmap[op];
53 static const char * const devlink_sb_pool_type_strmap[] = {
58 const char *devlink_sb_pool_type_str(enum devlink_sb_pool_type value)
60 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_sb_pool_type_strmap))
62 return devlink_sb_pool_type_strmap[value];
65 static const char * const devlink_port_type_strmap[] = {
72 const char *devlink_port_type_str(enum devlink_port_type value)
74 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_port_type_strmap))
76 return devlink_port_type_strmap[value];
79 static const char * const devlink_port_flavour_strmap[] = {
90 const char *devlink_port_flavour_str(enum devlink_port_flavour value)
92 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_port_flavour_strmap))
94 return devlink_port_flavour_strmap[value];
97 static const char * const devlink_port_fn_state_strmap[] = {
102 const char *devlink_port_fn_state_str(enum devlink_port_fn_state value)
104 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_port_fn_state_strmap))
106 return devlink_port_fn_state_strmap[value];
109 static const char * const devlink_port_fn_opstate_strmap[] = {
114 const char *devlink_port_fn_opstate_str(enum devlink_port_fn_opstate value)
116 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_port_fn_opstate_strmap))
118 return devlink_port_fn_opstate_strmap[value];
121 static const char * const devlink_port_fn_attr_cap_strmap[] = {
123 [1] = "migratable-bit",
124 [2] = "ipsec-crypto-bit",
125 [3] = "ipsec-packet-bit",
128 const char *devlink_port_fn_attr_cap_str(enum devlink_port_fn_attr_cap value)
130 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_port_fn_attr_cap_strmap))
132 return devlink_port_fn_attr_cap_strmap[value];
135 static const char * const devlink_sb_threshold_type_strmap[] = {
140 const char *devlink_sb_threshold_type_str(enum devlink_sb_threshold_type value)
142 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_sb_threshold_type_strmap))
144 return devlink_sb_threshold_type_strmap[value];
147 static const char * const devlink_eswitch_mode_strmap[] = {
152 const char *devlink_eswitch_mode_str(enum devlink_eswitch_mode value)
154 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_eswitch_mode_strmap))
156 return devlink_eswitch_mode_strmap[value];
159 static const char * const devlink_eswitch_inline_mode_strmap[] = {
167 devlink_eswitch_inline_mode_str(enum devlink_eswitch_inline_mode value)
169 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_eswitch_inline_mode_strmap))
171 return devlink_eswitch_inline_mode_strmap[value];
174 static const char * const devlink_eswitch_encap_mode_strmap[] = {
180 devlink_eswitch_encap_mode_str(enum devlink_eswitch_encap_mode value)
182 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_eswitch_encap_mode_strmap))
184 return devlink_eswitch_encap_mode_strmap[value];
187 static const char * const devlink_dpipe_match_type_strmap[] = {
191 const char *devlink_dpipe_match_type_str(enum devlink_dpipe_match_type value)
193 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_dpipe_match_type_strmap))
195 return devlink_dpipe_match_type_strmap[value];
198 static const char * const devlink_dpipe_action_type_strmap[] = {
199 [0] = "field-modify",
202 const char *devlink_dpipe_action_type_str(enum devlink_dpipe_action_type value)
204 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_dpipe_action_type_strmap))
206 return devlink_dpipe_action_type_strmap[value];
209 static const char * const devlink_dpipe_field_mapping_type_strmap[] = {
215 devlink_dpipe_field_mapping_type_str(enum devlink_dpipe_field_mapping_type value)
217 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_dpipe_field_mapping_type_strmap))
219 return devlink_dpipe_field_mapping_type_strmap[value];
222 static const char * const devlink_resource_unit_strmap[] = {
226 const char *devlink_resource_unit_str(enum devlink_resource_unit value)
228 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_resource_unit_strmap))
230 return devlink_resource_unit_strmap[value];
233 static const char * const devlink_reload_action_strmap[] = {
234 [1] = "driver-reinit",
238 const char *devlink_reload_action_str(enum devlink_reload_action value)
240 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_reload_action_strmap))
242 return devlink_reload_action_strmap[value];
245 static const char * const devlink_param_cmode_strmap[] = {
251 const char *devlink_param_cmode_str(enum devlink_param_cmode value)
253 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_param_cmode_strmap))
255 return devlink_param_cmode_strmap[value];
258 static const char * const devlink_flash_overwrite_strmap[] = {
259 [0] = "settings-bit",
260 [1] = "identifiers-bit",
263 const char *devlink_flash_overwrite_str(enum devlink_flash_overwrite value)
265 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_flash_overwrite_strmap))
267 return devlink_flash_overwrite_strmap[value];
270 static const char * const devlink_trap_action_strmap[] = {
276 const char *devlink_trap_action_str(enum devlink_trap_action value)
278 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_trap_action_strmap))
280 return devlink_trap_action_strmap[value];
284 struct ynl_policy_attr devlink_dl_dpipe_match_policy[DEVLINK_ATTR_MAX + 1] = {
285 [DEVLINK_ATTR_DPIPE_MATCH_TYPE] = { .name = "dpipe-match-type", .type = YNL_PT_U32, },
286 [DEVLINK_ATTR_DPIPE_HEADER_ID] = { .name = "dpipe-header-id", .type = YNL_PT_U32, },
287 [DEVLINK_ATTR_DPIPE_HEADER_GLOBAL] = { .name = "dpipe-header-global", .type = YNL_PT_U8, },
288 [DEVLINK_ATTR_DPIPE_HEADER_INDEX] = { .name = "dpipe-header-index", .type = YNL_PT_U32, },
289 [DEVLINK_ATTR_DPIPE_FIELD_ID] = { .name = "dpipe-field-id", .type = YNL_PT_U32, },
292 struct ynl_policy_nest devlink_dl_dpipe_match_nest = {
293 .max_attr = DEVLINK_ATTR_MAX,
294 .table = devlink_dl_dpipe_match_policy,
297 struct ynl_policy_attr devlink_dl_dpipe_match_value_policy[DEVLINK_ATTR_MAX + 1] = {
298 [DEVLINK_ATTR_DPIPE_MATCH] = { .name = "dpipe-match", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_match_nest, },
299 [DEVLINK_ATTR_DPIPE_VALUE] = { .name = "dpipe-value", .type = YNL_PT_BINARY,},
300 [DEVLINK_ATTR_DPIPE_VALUE_MASK] = { .name = "dpipe-value-mask", .type = YNL_PT_BINARY,},
301 [DEVLINK_ATTR_DPIPE_VALUE_MAPPING] = { .name = "dpipe-value-mapping", .type = YNL_PT_U32, },
304 struct ynl_policy_nest devlink_dl_dpipe_match_value_nest = {
305 .max_attr = DEVLINK_ATTR_MAX,
306 .table = devlink_dl_dpipe_match_value_policy,
309 struct ynl_policy_attr devlink_dl_dpipe_action_policy[DEVLINK_ATTR_MAX + 1] = {
310 [DEVLINK_ATTR_DPIPE_ACTION_TYPE] = { .name = "dpipe-action-type", .type = YNL_PT_U32, },
311 [DEVLINK_ATTR_DPIPE_HEADER_ID] = { .name = "dpipe-header-id", .type = YNL_PT_U32, },
312 [DEVLINK_ATTR_DPIPE_HEADER_GLOBAL] = { .name = "dpipe-header-global", .type = YNL_PT_U8, },
313 [DEVLINK_ATTR_DPIPE_HEADER_INDEX] = { .name = "dpipe-header-index", .type = YNL_PT_U32, },
314 [DEVLINK_ATTR_DPIPE_FIELD_ID] = { .name = "dpipe-field-id", .type = YNL_PT_U32, },
317 struct ynl_policy_nest devlink_dl_dpipe_action_nest = {
318 .max_attr = DEVLINK_ATTR_MAX,
319 .table = devlink_dl_dpipe_action_policy,
322 struct ynl_policy_attr devlink_dl_dpipe_action_value_policy[DEVLINK_ATTR_MAX + 1] = {
323 [DEVLINK_ATTR_DPIPE_ACTION] = { .name = "dpipe-action", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_action_nest, },
324 [DEVLINK_ATTR_DPIPE_VALUE] = { .name = "dpipe-value", .type = YNL_PT_BINARY,},
325 [DEVLINK_ATTR_DPIPE_VALUE_MASK] = { .name = "dpipe-value-mask", .type = YNL_PT_BINARY,},
326 [DEVLINK_ATTR_DPIPE_VALUE_MAPPING] = { .name = "dpipe-value-mapping", .type = YNL_PT_U32, },
329 struct ynl_policy_nest devlink_dl_dpipe_action_value_nest = {
330 .max_attr = DEVLINK_ATTR_MAX,
331 .table = devlink_dl_dpipe_action_value_policy,
334 struct ynl_policy_attr devlink_dl_dpipe_field_policy[DEVLINK_ATTR_MAX + 1] = {
335 [DEVLINK_ATTR_DPIPE_FIELD_NAME] = { .name = "dpipe-field-name", .type = YNL_PT_NUL_STR, },
336 [DEVLINK_ATTR_DPIPE_FIELD_ID] = { .name = "dpipe-field-id", .type = YNL_PT_U32, },
337 [DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH] = { .name = "dpipe-field-bitwidth", .type = YNL_PT_U32, },
338 [DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE] = { .name = "dpipe-field-mapping-type", .type = YNL_PT_U32, },
341 struct ynl_policy_nest devlink_dl_dpipe_field_nest = {
342 .max_attr = DEVLINK_ATTR_MAX,
343 .table = devlink_dl_dpipe_field_policy,
346 struct ynl_policy_attr devlink_dl_resource_policy[DEVLINK_ATTR_MAX + 1] = {
347 [DEVLINK_ATTR_RESOURCE_NAME] = { .name = "resource-name", .type = YNL_PT_NUL_STR, },
348 [DEVLINK_ATTR_RESOURCE_ID] = { .name = "resource-id", .type = YNL_PT_U64, },
349 [DEVLINK_ATTR_RESOURCE_SIZE] = { .name = "resource-size", .type = YNL_PT_U64, },
350 [DEVLINK_ATTR_RESOURCE_SIZE_NEW] = { .name = "resource-size-new", .type = YNL_PT_U64, },
351 [DEVLINK_ATTR_RESOURCE_SIZE_VALID] = { .name = "resource-size-valid", .type = YNL_PT_U8, },
352 [DEVLINK_ATTR_RESOURCE_SIZE_MIN] = { .name = "resource-size-min", .type = YNL_PT_U64, },
353 [DEVLINK_ATTR_RESOURCE_SIZE_MAX] = { .name = "resource-size-max", .type = YNL_PT_U64, },
354 [DEVLINK_ATTR_RESOURCE_SIZE_GRAN] = { .name = "resource-size-gran", .type = YNL_PT_U64, },
355 [DEVLINK_ATTR_RESOURCE_UNIT] = { .name = "resource-unit", .type = YNL_PT_U8, },
356 [DEVLINK_ATTR_RESOURCE_OCC] = { .name = "resource-occ", .type = YNL_PT_U64, },
359 struct ynl_policy_nest devlink_dl_resource_nest = {
360 .max_attr = DEVLINK_ATTR_MAX,
361 .table = devlink_dl_resource_policy,
364 struct ynl_policy_attr devlink_dl_info_version_policy[DEVLINK_ATTR_MAX + 1] = {
365 [DEVLINK_ATTR_INFO_VERSION_NAME] = { .name = "info-version-name", .type = YNL_PT_NUL_STR, },
366 [DEVLINK_ATTR_INFO_VERSION_VALUE] = { .name = "info-version-value", .type = YNL_PT_NUL_STR, },
369 struct ynl_policy_nest devlink_dl_info_version_nest = {
370 .max_attr = DEVLINK_ATTR_MAX,
371 .table = devlink_dl_info_version_policy,
374 struct ynl_policy_attr devlink_dl_fmsg_policy[DEVLINK_ATTR_MAX + 1] = {
375 [DEVLINK_ATTR_FMSG_OBJ_NEST_START] = { .name = "fmsg-obj-nest-start", .type = YNL_PT_FLAG, },
376 [DEVLINK_ATTR_FMSG_PAIR_NEST_START] = { .name = "fmsg-pair-nest-start", .type = YNL_PT_FLAG, },
377 [DEVLINK_ATTR_FMSG_ARR_NEST_START] = { .name = "fmsg-arr-nest-start", .type = YNL_PT_FLAG, },
378 [DEVLINK_ATTR_FMSG_NEST_END] = { .name = "fmsg-nest-end", .type = YNL_PT_FLAG, },
379 [DEVLINK_ATTR_FMSG_OBJ_NAME] = { .name = "fmsg-obj-name", .type = YNL_PT_NUL_STR, },
382 struct ynl_policy_nest devlink_dl_fmsg_nest = {
383 .max_attr = DEVLINK_ATTR_MAX,
384 .table = devlink_dl_fmsg_policy,
387 struct ynl_policy_attr devlink_dl_port_function_policy[DEVLINK_PORT_FUNCTION_ATTR_MAX + 1] = {
388 [DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] = { .name = "hw-addr", .type = YNL_PT_BINARY,},
389 [DEVLINK_PORT_FN_ATTR_STATE] = { .name = "state", .type = YNL_PT_U8, },
390 [DEVLINK_PORT_FN_ATTR_OPSTATE] = { .name = "opstate", .type = YNL_PT_U8, },
391 [DEVLINK_PORT_FN_ATTR_CAPS] = { .name = "caps", .type = YNL_PT_BITFIELD32, },
394 struct ynl_policy_nest devlink_dl_port_function_nest = {
395 .max_attr = DEVLINK_PORT_FUNCTION_ATTR_MAX,
396 .table = devlink_dl_port_function_policy,
399 struct ynl_policy_attr devlink_dl_reload_stats_entry_policy[DEVLINK_ATTR_MAX + 1] = {
400 [DEVLINK_ATTR_RELOAD_STATS_LIMIT] = { .name = "reload-stats-limit", .type = YNL_PT_U8, },
401 [DEVLINK_ATTR_RELOAD_STATS_VALUE] = { .name = "reload-stats-value", .type = YNL_PT_U32, },
404 struct ynl_policy_nest devlink_dl_reload_stats_entry_nest = {
405 .max_attr = DEVLINK_ATTR_MAX,
406 .table = devlink_dl_reload_stats_entry_policy,
409 struct ynl_policy_attr devlink_dl_reload_act_stats_policy[DEVLINK_ATTR_MAX + 1] = {
410 [DEVLINK_ATTR_RELOAD_STATS_ENTRY] = { .name = "reload-stats-entry", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_stats_entry_nest, },
413 struct ynl_policy_nest devlink_dl_reload_act_stats_nest = {
414 .max_attr = DEVLINK_ATTR_MAX,
415 .table = devlink_dl_reload_act_stats_policy,
418 struct ynl_policy_attr devlink_dl_selftest_id_policy[DEVLINK_ATTR_SELFTEST_ID_MAX + 1] = {
419 [DEVLINK_ATTR_SELFTEST_ID_FLASH] = { .name = "flash", .type = YNL_PT_FLAG, },
422 struct ynl_policy_nest devlink_dl_selftest_id_nest = {
423 .max_attr = DEVLINK_ATTR_SELFTEST_ID_MAX,
424 .table = devlink_dl_selftest_id_policy,
427 struct ynl_policy_attr devlink_dl_dpipe_table_matches_policy[DEVLINK_ATTR_MAX + 1] = {
428 [DEVLINK_ATTR_DPIPE_MATCH] = { .name = "dpipe-match", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_match_nest, },
431 struct ynl_policy_nest devlink_dl_dpipe_table_matches_nest = {
432 .max_attr = DEVLINK_ATTR_MAX,
433 .table = devlink_dl_dpipe_table_matches_policy,
436 struct ynl_policy_attr devlink_dl_dpipe_table_actions_policy[DEVLINK_ATTR_MAX + 1] = {
437 [DEVLINK_ATTR_DPIPE_ACTION] = { .name = "dpipe-action", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_action_nest, },
440 struct ynl_policy_nest devlink_dl_dpipe_table_actions_nest = {
441 .max_attr = DEVLINK_ATTR_MAX,
442 .table = devlink_dl_dpipe_table_actions_policy,
445 struct ynl_policy_attr devlink_dl_dpipe_entry_match_values_policy[DEVLINK_ATTR_MAX + 1] = {
446 [DEVLINK_ATTR_DPIPE_MATCH_VALUE] = { .name = "dpipe-match-value", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_match_value_nest, },
449 struct ynl_policy_nest devlink_dl_dpipe_entry_match_values_nest = {
450 .max_attr = DEVLINK_ATTR_MAX,
451 .table = devlink_dl_dpipe_entry_match_values_policy,
454 struct ynl_policy_attr devlink_dl_dpipe_entry_action_values_policy[DEVLINK_ATTR_MAX + 1] = {
455 [DEVLINK_ATTR_DPIPE_ACTION_VALUE] = { .name = "dpipe-action-value", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_action_value_nest, },
458 struct ynl_policy_nest devlink_dl_dpipe_entry_action_values_nest = {
459 .max_attr = DEVLINK_ATTR_MAX,
460 .table = devlink_dl_dpipe_entry_action_values_policy,
463 struct ynl_policy_attr devlink_dl_dpipe_header_fields_policy[DEVLINK_ATTR_MAX + 1] = {
464 [DEVLINK_ATTR_DPIPE_FIELD] = { .name = "dpipe-field", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_field_nest, },
467 struct ynl_policy_nest devlink_dl_dpipe_header_fields_nest = {
468 .max_attr = DEVLINK_ATTR_MAX,
469 .table = devlink_dl_dpipe_header_fields_policy,
472 struct ynl_policy_attr devlink_dl_resource_list_policy[DEVLINK_ATTR_MAX + 1] = {
473 [DEVLINK_ATTR_RESOURCE] = { .name = "resource", .type = YNL_PT_NEST, .nest = &devlink_dl_resource_nest, },
476 struct ynl_policy_nest devlink_dl_resource_list_nest = {
477 .max_attr = DEVLINK_ATTR_MAX,
478 .table = devlink_dl_resource_list_policy,
481 struct ynl_policy_attr devlink_dl_reload_act_info_policy[DEVLINK_ATTR_MAX + 1] = {
482 [DEVLINK_ATTR_RELOAD_ACTION] = { .name = "reload-action", .type = YNL_PT_U8, },
483 [DEVLINK_ATTR_RELOAD_ACTION_STATS] = { .name = "reload-action-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_act_stats_nest, },
486 struct ynl_policy_nest devlink_dl_reload_act_info_nest = {
487 .max_attr = DEVLINK_ATTR_MAX,
488 .table = devlink_dl_reload_act_info_policy,
491 struct ynl_policy_attr devlink_dl_dpipe_table_policy[DEVLINK_ATTR_MAX + 1] = {
492 [DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .name = "dpipe-table-name", .type = YNL_PT_NUL_STR, },
493 [DEVLINK_ATTR_DPIPE_TABLE_SIZE] = { .name = "dpipe-table-size", .type = YNL_PT_U64, },
494 [DEVLINK_ATTR_DPIPE_TABLE_MATCHES] = { .name = "dpipe-table-matches", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_table_matches_nest, },
495 [DEVLINK_ATTR_DPIPE_TABLE_ACTIONS] = { .name = "dpipe-table-actions", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_table_actions_nest, },
496 [DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED] = { .name = "dpipe-table-counters-enabled", .type = YNL_PT_U8, },
497 [DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID] = { .name = "dpipe-table-resource-id", .type = YNL_PT_U64, },
498 [DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS] = { .name = "dpipe-table-resource-units", .type = YNL_PT_U64, },
501 struct ynl_policy_nest devlink_dl_dpipe_table_nest = {
502 .max_attr = DEVLINK_ATTR_MAX,
503 .table = devlink_dl_dpipe_table_policy,
506 struct ynl_policy_attr devlink_dl_dpipe_entry_policy[DEVLINK_ATTR_MAX + 1] = {
507 [DEVLINK_ATTR_DPIPE_ENTRY_INDEX] = { .name = "dpipe-entry-index", .type = YNL_PT_U64, },
508 [DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES] = { .name = "dpipe-entry-match-values", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_entry_match_values_nest, },
509 [DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES] = { .name = "dpipe-entry-action-values", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_entry_action_values_nest, },
510 [DEVLINK_ATTR_DPIPE_ENTRY_COUNTER] = { .name = "dpipe-entry-counter", .type = YNL_PT_U64, },
513 struct ynl_policy_nest devlink_dl_dpipe_entry_nest = {
514 .max_attr = DEVLINK_ATTR_MAX,
515 .table = devlink_dl_dpipe_entry_policy,
518 struct ynl_policy_attr devlink_dl_dpipe_header_policy[DEVLINK_ATTR_MAX + 1] = {
519 [DEVLINK_ATTR_DPIPE_HEADER_NAME] = { .name = "dpipe-header-name", .type = YNL_PT_NUL_STR, },
520 [DEVLINK_ATTR_DPIPE_HEADER_ID] = { .name = "dpipe-header-id", .type = YNL_PT_U32, },
521 [DEVLINK_ATTR_DPIPE_HEADER_GLOBAL] = { .name = "dpipe-header-global", .type = YNL_PT_U8, },
522 [DEVLINK_ATTR_DPIPE_HEADER_FIELDS] = { .name = "dpipe-header-fields", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_header_fields_nest, },
525 struct ynl_policy_nest devlink_dl_dpipe_header_nest = {
526 .max_attr = DEVLINK_ATTR_MAX,
527 .table = devlink_dl_dpipe_header_policy,
530 struct ynl_policy_attr devlink_dl_reload_stats_policy[DEVLINK_ATTR_MAX + 1] = {
531 [DEVLINK_ATTR_RELOAD_ACTION_INFO] = { .name = "reload-action-info", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_act_info_nest, },
534 struct ynl_policy_nest devlink_dl_reload_stats_nest = {
535 .max_attr = DEVLINK_ATTR_MAX,
536 .table = devlink_dl_reload_stats_policy,
539 struct ynl_policy_attr devlink_dl_dpipe_tables_policy[DEVLINK_ATTR_MAX + 1] = {
540 [DEVLINK_ATTR_DPIPE_TABLE] = { .name = "dpipe-table", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_table_nest, },
543 struct ynl_policy_nest devlink_dl_dpipe_tables_nest = {
544 .max_attr = DEVLINK_ATTR_MAX,
545 .table = devlink_dl_dpipe_tables_policy,
548 struct ynl_policy_attr devlink_dl_dpipe_entries_policy[DEVLINK_ATTR_MAX + 1] = {
549 [DEVLINK_ATTR_DPIPE_ENTRY] = { .name = "dpipe-entry", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_entry_nest, },
552 struct ynl_policy_nest devlink_dl_dpipe_entries_nest = {
553 .max_attr = DEVLINK_ATTR_MAX,
554 .table = devlink_dl_dpipe_entries_policy,
557 struct ynl_policy_attr devlink_dl_dpipe_headers_policy[DEVLINK_ATTR_MAX + 1] = {
558 [DEVLINK_ATTR_DPIPE_HEADER] = { .name = "dpipe-header", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_header_nest, },
561 struct ynl_policy_nest devlink_dl_dpipe_headers_nest = {
562 .max_attr = DEVLINK_ATTR_MAX,
563 .table = devlink_dl_dpipe_headers_policy,
566 struct ynl_policy_attr devlink_dl_dev_stats_policy[DEVLINK_ATTR_MAX + 1] = {
567 [DEVLINK_ATTR_RELOAD_STATS] = { .name = "reload-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_stats_nest, },
568 [DEVLINK_ATTR_REMOTE_RELOAD_STATS] = { .name = "remote-reload-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_stats_nest, },
571 struct ynl_policy_nest devlink_dl_dev_stats_nest = {
572 .max_attr = DEVLINK_ATTR_MAX,
573 .table = devlink_dl_dev_stats_policy,
576 struct ynl_policy_attr devlink_policy[DEVLINK_ATTR_MAX + 1] = {
577 [DEVLINK_ATTR_BUS_NAME] = { .name = "bus-name", .type = YNL_PT_NUL_STR, },
578 [DEVLINK_ATTR_DEV_NAME] = { .name = "dev-name", .type = YNL_PT_NUL_STR, },
579 [DEVLINK_ATTR_PORT_INDEX] = { .name = "port-index", .type = YNL_PT_U32, },
580 [DEVLINK_ATTR_PORT_TYPE] = { .name = "port-type", .type = YNL_PT_U16, },
581 [DEVLINK_ATTR_PORT_SPLIT_COUNT] = { .name = "port-split-count", .type = YNL_PT_U32, },
582 [DEVLINK_ATTR_SB_INDEX] = { .name = "sb-index", .type = YNL_PT_U32, },
583 [DEVLINK_ATTR_SB_POOL_INDEX] = { .name = "sb-pool-index", .type = YNL_PT_U16, },
584 [DEVLINK_ATTR_SB_POOL_TYPE] = { .name = "sb-pool-type", .type = YNL_PT_U8, },
585 [DEVLINK_ATTR_SB_POOL_SIZE] = { .name = "sb-pool-size", .type = YNL_PT_U32, },
586 [DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE] = { .name = "sb-pool-threshold-type", .type = YNL_PT_U8, },
587 [DEVLINK_ATTR_SB_THRESHOLD] = { .name = "sb-threshold", .type = YNL_PT_U32, },
588 [DEVLINK_ATTR_SB_TC_INDEX] = { .name = "sb-tc-index", .type = YNL_PT_U16, },
589 [DEVLINK_ATTR_ESWITCH_MODE] = { .name = "eswitch-mode", .type = YNL_PT_U16, },
590 [DEVLINK_ATTR_ESWITCH_INLINE_MODE] = { .name = "eswitch-inline-mode", .type = YNL_PT_U16, },
591 [DEVLINK_ATTR_DPIPE_TABLES] = { .name = "dpipe-tables", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_tables_nest, },
592 [DEVLINK_ATTR_DPIPE_TABLE] = { .name = "dpipe-table", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_table_nest, },
593 [DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .name = "dpipe-table-name", .type = YNL_PT_NUL_STR, },
594 [DEVLINK_ATTR_DPIPE_TABLE_SIZE] = { .name = "dpipe-table-size", .type = YNL_PT_U64, },
595 [DEVLINK_ATTR_DPIPE_TABLE_MATCHES] = { .name = "dpipe-table-matches", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_table_matches_nest, },
596 [DEVLINK_ATTR_DPIPE_TABLE_ACTIONS] = { .name = "dpipe-table-actions", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_table_actions_nest, },
597 [DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED] = { .name = "dpipe-table-counters-enabled", .type = YNL_PT_U8, },
598 [DEVLINK_ATTR_DPIPE_ENTRIES] = { .name = "dpipe-entries", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_entries_nest, },
599 [DEVLINK_ATTR_DPIPE_ENTRY] = { .name = "dpipe-entry", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_entry_nest, },
600 [DEVLINK_ATTR_DPIPE_ENTRY_INDEX] = { .name = "dpipe-entry-index", .type = YNL_PT_U64, },
601 [DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES] = { .name = "dpipe-entry-match-values", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_entry_match_values_nest, },
602 [DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES] = { .name = "dpipe-entry-action-values", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_entry_action_values_nest, },
603 [DEVLINK_ATTR_DPIPE_ENTRY_COUNTER] = { .name = "dpipe-entry-counter", .type = YNL_PT_U64, },
604 [DEVLINK_ATTR_DPIPE_MATCH] = { .name = "dpipe-match", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_match_nest, },
605 [DEVLINK_ATTR_DPIPE_MATCH_VALUE] = { .name = "dpipe-match-value", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_match_value_nest, },
606 [DEVLINK_ATTR_DPIPE_MATCH_TYPE] = { .name = "dpipe-match-type", .type = YNL_PT_U32, },
607 [DEVLINK_ATTR_DPIPE_ACTION] = { .name = "dpipe-action", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_action_nest, },
608 [DEVLINK_ATTR_DPIPE_ACTION_VALUE] = { .name = "dpipe-action-value", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_action_value_nest, },
609 [DEVLINK_ATTR_DPIPE_ACTION_TYPE] = { .name = "dpipe-action-type", .type = YNL_PT_U32, },
610 [DEVLINK_ATTR_DPIPE_VALUE] = { .name = "dpipe-value", .type = YNL_PT_BINARY,},
611 [DEVLINK_ATTR_DPIPE_VALUE_MASK] = { .name = "dpipe-value-mask", .type = YNL_PT_BINARY,},
612 [DEVLINK_ATTR_DPIPE_VALUE_MAPPING] = { .name = "dpipe-value-mapping", .type = YNL_PT_U32, },
613 [DEVLINK_ATTR_DPIPE_HEADERS] = { .name = "dpipe-headers", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_headers_nest, },
614 [DEVLINK_ATTR_DPIPE_HEADER] = { .name = "dpipe-header", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_header_nest, },
615 [DEVLINK_ATTR_DPIPE_HEADER_NAME] = { .name = "dpipe-header-name", .type = YNL_PT_NUL_STR, },
616 [DEVLINK_ATTR_DPIPE_HEADER_ID] = { .name = "dpipe-header-id", .type = YNL_PT_U32, },
617 [DEVLINK_ATTR_DPIPE_HEADER_FIELDS] = { .name = "dpipe-header-fields", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_header_fields_nest, },
618 [DEVLINK_ATTR_DPIPE_HEADER_GLOBAL] = { .name = "dpipe-header-global", .type = YNL_PT_U8, },
619 [DEVLINK_ATTR_DPIPE_HEADER_INDEX] = { .name = "dpipe-header-index", .type = YNL_PT_U32, },
620 [DEVLINK_ATTR_DPIPE_FIELD] = { .name = "dpipe-field", .type = YNL_PT_NEST, .nest = &devlink_dl_dpipe_field_nest, },
621 [DEVLINK_ATTR_DPIPE_FIELD_NAME] = { .name = "dpipe-field-name", .type = YNL_PT_NUL_STR, },
622 [DEVLINK_ATTR_DPIPE_FIELD_ID] = { .name = "dpipe-field-id", .type = YNL_PT_U32, },
623 [DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH] = { .name = "dpipe-field-bitwidth", .type = YNL_PT_U32, },
624 [DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE] = { .name = "dpipe-field-mapping-type", .type = YNL_PT_U32, },
625 [DEVLINK_ATTR_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, },
626 [DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = { .name = "eswitch-encap-mode", .type = YNL_PT_U8, },
627 [DEVLINK_ATTR_RESOURCE_LIST] = { .name = "resource-list", .type = YNL_PT_NEST, .nest = &devlink_dl_resource_list_nest, },
628 [DEVLINK_ATTR_RESOURCE] = { .name = "resource", .type = YNL_PT_NEST, .nest = &devlink_dl_resource_nest, },
629 [DEVLINK_ATTR_RESOURCE_NAME] = { .name = "resource-name", .type = YNL_PT_NUL_STR, },
630 [DEVLINK_ATTR_RESOURCE_ID] = { .name = "resource-id", .type = YNL_PT_U64, },
631 [DEVLINK_ATTR_RESOURCE_SIZE] = { .name = "resource-size", .type = YNL_PT_U64, },
632 [DEVLINK_ATTR_RESOURCE_SIZE_NEW] = { .name = "resource-size-new", .type = YNL_PT_U64, },
633 [DEVLINK_ATTR_RESOURCE_SIZE_VALID] = { .name = "resource-size-valid", .type = YNL_PT_U8, },
634 [DEVLINK_ATTR_RESOURCE_SIZE_MIN] = { .name = "resource-size-min", .type = YNL_PT_U64, },
635 [DEVLINK_ATTR_RESOURCE_SIZE_MAX] = { .name = "resource-size-max", .type = YNL_PT_U64, },
636 [DEVLINK_ATTR_RESOURCE_SIZE_GRAN] = { .name = "resource-size-gran", .type = YNL_PT_U64, },
637 [DEVLINK_ATTR_RESOURCE_UNIT] = { .name = "resource-unit", .type = YNL_PT_U8, },
638 [DEVLINK_ATTR_RESOURCE_OCC] = { .name = "resource-occ", .type = YNL_PT_U64, },
639 [DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID] = { .name = "dpipe-table-resource-id", .type = YNL_PT_U64, },
640 [DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS] = { .name = "dpipe-table-resource-units", .type = YNL_PT_U64, },
641 [DEVLINK_ATTR_PORT_FLAVOUR] = { .name = "port-flavour", .type = YNL_PT_U16, },
642 [DEVLINK_ATTR_PARAM_NAME] = { .name = "param-name", .type = YNL_PT_NUL_STR, },
643 [DEVLINK_ATTR_PARAM_TYPE] = { .name = "param-type", .type = YNL_PT_U8, },
644 [DEVLINK_ATTR_PARAM_VALUE_CMODE] = { .name = "param-value-cmode", .type = YNL_PT_U8, },
645 [DEVLINK_ATTR_REGION_NAME] = { .name = "region-name", .type = YNL_PT_NUL_STR, },
646 [DEVLINK_ATTR_REGION_SNAPSHOT_ID] = { .name = "region-snapshot-id", .type = YNL_PT_U32, },
647 [DEVLINK_ATTR_REGION_CHUNK_ADDR] = { .name = "region-chunk-addr", .type = YNL_PT_U64, },
648 [DEVLINK_ATTR_REGION_CHUNK_LEN] = { .name = "region-chunk-len", .type = YNL_PT_U64, },
649 [DEVLINK_ATTR_INFO_DRIVER_NAME] = { .name = "info-driver-name", .type = YNL_PT_NUL_STR, },
650 [DEVLINK_ATTR_INFO_SERIAL_NUMBER] = { .name = "info-serial-number", .type = YNL_PT_NUL_STR, },
651 [DEVLINK_ATTR_INFO_VERSION_FIXED] = { .name = "info-version-fixed", .type = YNL_PT_NEST, .nest = &devlink_dl_info_version_nest, },
652 [DEVLINK_ATTR_INFO_VERSION_RUNNING] = { .name = "info-version-running", .type = YNL_PT_NEST, .nest = &devlink_dl_info_version_nest, },
653 [DEVLINK_ATTR_INFO_VERSION_STORED] = { .name = "info-version-stored", .type = YNL_PT_NEST, .nest = &devlink_dl_info_version_nest, },
654 [DEVLINK_ATTR_INFO_VERSION_NAME] = { .name = "info-version-name", .type = YNL_PT_NUL_STR, },
655 [DEVLINK_ATTR_INFO_VERSION_VALUE] = { .name = "info-version-value", .type = YNL_PT_NUL_STR, },
656 [DEVLINK_ATTR_FMSG] = { .name = "fmsg", .type = YNL_PT_NEST, .nest = &devlink_dl_fmsg_nest, },
657 [DEVLINK_ATTR_FMSG_OBJ_NEST_START] = { .name = "fmsg-obj-nest-start", .type = YNL_PT_FLAG, },
658 [DEVLINK_ATTR_FMSG_PAIR_NEST_START] = { .name = "fmsg-pair-nest-start", .type = YNL_PT_FLAG, },
659 [DEVLINK_ATTR_FMSG_ARR_NEST_START] = { .name = "fmsg-arr-nest-start", .type = YNL_PT_FLAG, },
660 [DEVLINK_ATTR_FMSG_NEST_END] = { .name = "fmsg-nest-end", .type = YNL_PT_FLAG, },
661 [DEVLINK_ATTR_FMSG_OBJ_NAME] = { .name = "fmsg-obj-name", .type = YNL_PT_NUL_STR, },
662 [DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .name = "health-reporter-name", .type = YNL_PT_NUL_STR, },
663 [DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD] = { .name = "health-reporter-graceful-period", .type = YNL_PT_U64, },
664 [DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER] = { .name = "health-reporter-auto-recover", .type = YNL_PT_U8, },
665 [DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME] = { .name = "flash-update-file-name", .type = YNL_PT_NUL_STR, },
666 [DEVLINK_ATTR_FLASH_UPDATE_COMPONENT] = { .name = "flash-update-component", .type = YNL_PT_NUL_STR, },
667 [DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = { .name = "port-pci-pf-number", .type = YNL_PT_U16, },
668 [DEVLINK_ATTR_TRAP_NAME] = { .name = "trap-name", .type = YNL_PT_NUL_STR, },
669 [DEVLINK_ATTR_TRAP_ACTION] = { .name = "trap-action", .type = YNL_PT_U8, },
670 [DEVLINK_ATTR_TRAP_GROUP_NAME] = { .name = "trap-group-name", .type = YNL_PT_NUL_STR, },
671 [DEVLINK_ATTR_RELOAD_FAILED] = { .name = "reload-failed", .type = YNL_PT_U8, },
672 [DEVLINK_ATTR_NETNS_FD] = { .name = "netns-fd", .type = YNL_PT_U32, },
673 [DEVLINK_ATTR_NETNS_PID] = { .name = "netns-pid", .type = YNL_PT_U32, },
674 [DEVLINK_ATTR_NETNS_ID] = { .name = "netns-id", .type = YNL_PT_U32, },
675 [DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP] = { .name = "health-reporter-auto-dump", .type = YNL_PT_U8, },
676 [DEVLINK_ATTR_TRAP_POLICER_ID] = { .name = "trap-policer-id", .type = YNL_PT_U32, },
677 [DEVLINK_ATTR_TRAP_POLICER_RATE] = { .name = "trap-policer-rate", .type = YNL_PT_U64, },
678 [DEVLINK_ATTR_TRAP_POLICER_BURST] = { .name = "trap-policer-burst", .type = YNL_PT_U64, },
679 [DEVLINK_ATTR_PORT_FUNCTION] = { .name = "port-function", .type = YNL_PT_NEST, .nest = &devlink_dl_port_function_nest, },
680 [DEVLINK_ATTR_PORT_CONTROLLER_NUMBER] = { .name = "port-controller-number", .type = YNL_PT_U32, },
681 [DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK] = { .name = "flash-update-overwrite-mask", .type = YNL_PT_BITFIELD32, },
682 [DEVLINK_ATTR_RELOAD_ACTION] = { .name = "reload-action", .type = YNL_PT_U8, },
683 [DEVLINK_ATTR_RELOAD_ACTIONS_PERFORMED] = { .name = "reload-actions-performed", .type = YNL_PT_BITFIELD32, },
684 [DEVLINK_ATTR_RELOAD_LIMITS] = { .name = "reload-limits", .type = YNL_PT_BITFIELD32, },
685 [DEVLINK_ATTR_DEV_STATS] = { .name = "dev-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_dev_stats_nest, },
686 [DEVLINK_ATTR_RELOAD_STATS] = { .name = "reload-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_stats_nest, },
687 [DEVLINK_ATTR_RELOAD_STATS_ENTRY] = { .name = "reload-stats-entry", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_stats_entry_nest, },
688 [DEVLINK_ATTR_RELOAD_STATS_LIMIT] = { .name = "reload-stats-limit", .type = YNL_PT_U8, },
689 [DEVLINK_ATTR_RELOAD_STATS_VALUE] = { .name = "reload-stats-value", .type = YNL_PT_U32, },
690 [DEVLINK_ATTR_REMOTE_RELOAD_STATS] = { .name = "remote-reload-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_stats_nest, },
691 [DEVLINK_ATTR_RELOAD_ACTION_INFO] = { .name = "reload-action-info", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_act_info_nest, },
692 [DEVLINK_ATTR_RELOAD_ACTION_STATS] = { .name = "reload-action-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_act_stats_nest, },
693 [DEVLINK_ATTR_PORT_PCI_SF_NUMBER] = { .name = "port-pci-sf-number", .type = YNL_PT_U32, },
694 [DEVLINK_ATTR_RATE_TX_SHARE] = { .name = "rate-tx-share", .type = YNL_PT_U64, },
695 [DEVLINK_ATTR_RATE_TX_MAX] = { .name = "rate-tx-max", .type = YNL_PT_U64, },
696 [DEVLINK_ATTR_RATE_NODE_NAME] = { .name = "rate-node-name", .type = YNL_PT_NUL_STR, },
697 [DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .name = "rate-parent-node-name", .type = YNL_PT_NUL_STR, },
698 [DEVLINK_ATTR_LINECARD_INDEX] = { .name = "linecard-index", .type = YNL_PT_U32, },
699 [DEVLINK_ATTR_LINECARD_TYPE] = { .name = "linecard-type", .type = YNL_PT_NUL_STR, },
700 [DEVLINK_ATTR_SELFTESTS] = { .name = "selftests", .type = YNL_PT_NEST, .nest = &devlink_dl_selftest_id_nest, },
701 [DEVLINK_ATTR_RATE_TX_PRIORITY] = { .name = "rate-tx-priority", .type = YNL_PT_U32, },
702 [DEVLINK_ATTR_RATE_TX_WEIGHT] = { .name = "rate-tx-weight", .type = YNL_PT_U32, },
703 [DEVLINK_ATTR_REGION_DIRECT] = { .name = "region-direct", .type = YNL_PT_FLAG, },
706 struct ynl_policy_nest devlink_nest = {
707 .max_attr = DEVLINK_ATTR_MAX,
708 .table = devlink_policy,
711 /* Common nested types */
712 void devlink_dl_dpipe_match_free(struct devlink_dl_dpipe_match *obj)
716 int devlink_dl_dpipe_match_parse(struct ynl_parse_arg *yarg,
717 const struct nlattr *nested)
719 struct devlink_dl_dpipe_match *dst = yarg->data;
720 const struct nlattr *attr;
722 mnl_attr_for_each_nested(attr, nested) {
723 unsigned int type = mnl_attr_get_type(attr);
725 if (type == DEVLINK_ATTR_DPIPE_MATCH_TYPE) {
726 if (ynl_attr_validate(yarg, attr))
728 dst->_present.dpipe_match_type = 1;
729 dst->dpipe_match_type = mnl_attr_get_u32(attr);
730 } else if (type == DEVLINK_ATTR_DPIPE_HEADER_ID) {
731 if (ynl_attr_validate(yarg, attr))
733 dst->_present.dpipe_header_id = 1;
734 dst->dpipe_header_id = mnl_attr_get_u32(attr);
735 } else if (type == DEVLINK_ATTR_DPIPE_HEADER_GLOBAL) {
736 if (ynl_attr_validate(yarg, attr))
738 dst->_present.dpipe_header_global = 1;
739 dst->dpipe_header_global = mnl_attr_get_u8(attr);
740 } else if (type == DEVLINK_ATTR_DPIPE_HEADER_INDEX) {
741 if (ynl_attr_validate(yarg, attr))
743 dst->_present.dpipe_header_index = 1;
744 dst->dpipe_header_index = mnl_attr_get_u32(attr);
745 } else if (type == DEVLINK_ATTR_DPIPE_FIELD_ID) {
746 if (ynl_attr_validate(yarg, attr))
748 dst->_present.dpipe_field_id = 1;
749 dst->dpipe_field_id = mnl_attr_get_u32(attr);
757 devlink_dl_dpipe_match_value_free(struct devlink_dl_dpipe_match_value *obj)
761 for (i = 0; i < obj->n_dpipe_match; i++)
762 devlink_dl_dpipe_match_free(&obj->dpipe_match[i]);
763 free(obj->dpipe_match);
764 free(obj->dpipe_value);
765 free(obj->dpipe_value_mask);
768 int devlink_dl_dpipe_match_value_parse(struct ynl_parse_arg *yarg,
769 const struct nlattr *nested)
771 struct devlink_dl_dpipe_match_value *dst = yarg->data;
772 unsigned int n_dpipe_match = 0;
773 const struct nlattr *attr;
774 struct ynl_parse_arg parg;
779 if (dst->dpipe_match)
780 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-match-value.dpipe-match)");
782 mnl_attr_for_each_nested(attr, nested) {
783 unsigned int type = mnl_attr_get_type(attr);
785 if (type == DEVLINK_ATTR_DPIPE_MATCH) {
787 } else if (type == DEVLINK_ATTR_DPIPE_VALUE) {
790 if (ynl_attr_validate(yarg, attr))
793 len = mnl_attr_get_payload_len(attr);
794 dst->_present.dpipe_value_len = len;
795 dst->dpipe_value = malloc(len);
796 memcpy(dst->dpipe_value, mnl_attr_get_payload(attr), len);
797 } else if (type == DEVLINK_ATTR_DPIPE_VALUE_MASK) {
800 if (ynl_attr_validate(yarg, attr))
803 len = mnl_attr_get_payload_len(attr);
804 dst->_present.dpipe_value_mask_len = len;
805 dst->dpipe_value_mask = malloc(len);
806 memcpy(dst->dpipe_value_mask, mnl_attr_get_payload(attr), len);
807 } else if (type == DEVLINK_ATTR_DPIPE_VALUE_MAPPING) {
808 if (ynl_attr_validate(yarg, attr))
810 dst->_present.dpipe_value_mapping = 1;
811 dst->dpipe_value_mapping = mnl_attr_get_u32(attr);
816 dst->dpipe_match = calloc(n_dpipe_match, sizeof(*dst->dpipe_match));
817 dst->n_dpipe_match = n_dpipe_match;
819 parg.rsp_policy = &devlink_dl_dpipe_match_nest;
820 mnl_attr_for_each_nested(attr, nested) {
821 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_MATCH) {
822 parg.data = &dst->dpipe_match[i];
823 if (devlink_dl_dpipe_match_parse(&parg, attr))
833 void devlink_dl_dpipe_action_free(struct devlink_dl_dpipe_action *obj)
837 int devlink_dl_dpipe_action_parse(struct ynl_parse_arg *yarg,
838 const struct nlattr *nested)
840 struct devlink_dl_dpipe_action *dst = yarg->data;
841 const struct nlattr *attr;
843 mnl_attr_for_each_nested(attr, nested) {
844 unsigned int type = mnl_attr_get_type(attr);
846 if (type == DEVLINK_ATTR_DPIPE_ACTION_TYPE) {
847 if (ynl_attr_validate(yarg, attr))
849 dst->_present.dpipe_action_type = 1;
850 dst->dpipe_action_type = mnl_attr_get_u32(attr);
851 } else if (type == DEVLINK_ATTR_DPIPE_HEADER_ID) {
852 if (ynl_attr_validate(yarg, attr))
854 dst->_present.dpipe_header_id = 1;
855 dst->dpipe_header_id = mnl_attr_get_u32(attr);
856 } else if (type == DEVLINK_ATTR_DPIPE_HEADER_GLOBAL) {
857 if (ynl_attr_validate(yarg, attr))
859 dst->_present.dpipe_header_global = 1;
860 dst->dpipe_header_global = mnl_attr_get_u8(attr);
861 } else if (type == DEVLINK_ATTR_DPIPE_HEADER_INDEX) {
862 if (ynl_attr_validate(yarg, attr))
864 dst->_present.dpipe_header_index = 1;
865 dst->dpipe_header_index = mnl_attr_get_u32(attr);
866 } else if (type == DEVLINK_ATTR_DPIPE_FIELD_ID) {
867 if (ynl_attr_validate(yarg, attr))
869 dst->_present.dpipe_field_id = 1;
870 dst->dpipe_field_id = mnl_attr_get_u32(attr);
878 devlink_dl_dpipe_action_value_free(struct devlink_dl_dpipe_action_value *obj)
882 for (i = 0; i < obj->n_dpipe_action; i++)
883 devlink_dl_dpipe_action_free(&obj->dpipe_action[i]);
884 free(obj->dpipe_action);
885 free(obj->dpipe_value);
886 free(obj->dpipe_value_mask);
889 int devlink_dl_dpipe_action_value_parse(struct ynl_parse_arg *yarg,
890 const struct nlattr *nested)
892 struct devlink_dl_dpipe_action_value *dst = yarg->data;
893 unsigned int n_dpipe_action = 0;
894 const struct nlattr *attr;
895 struct ynl_parse_arg parg;
900 if (dst->dpipe_action)
901 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-action-value.dpipe-action)");
903 mnl_attr_for_each_nested(attr, nested) {
904 unsigned int type = mnl_attr_get_type(attr);
906 if (type == DEVLINK_ATTR_DPIPE_ACTION) {
908 } else if (type == DEVLINK_ATTR_DPIPE_VALUE) {
911 if (ynl_attr_validate(yarg, attr))
914 len = mnl_attr_get_payload_len(attr);
915 dst->_present.dpipe_value_len = len;
916 dst->dpipe_value = malloc(len);
917 memcpy(dst->dpipe_value, mnl_attr_get_payload(attr), len);
918 } else if (type == DEVLINK_ATTR_DPIPE_VALUE_MASK) {
921 if (ynl_attr_validate(yarg, attr))
924 len = mnl_attr_get_payload_len(attr);
925 dst->_present.dpipe_value_mask_len = len;
926 dst->dpipe_value_mask = malloc(len);
927 memcpy(dst->dpipe_value_mask, mnl_attr_get_payload(attr), len);
928 } else if (type == DEVLINK_ATTR_DPIPE_VALUE_MAPPING) {
929 if (ynl_attr_validate(yarg, attr))
931 dst->_present.dpipe_value_mapping = 1;
932 dst->dpipe_value_mapping = mnl_attr_get_u32(attr);
936 if (n_dpipe_action) {
937 dst->dpipe_action = calloc(n_dpipe_action, sizeof(*dst->dpipe_action));
938 dst->n_dpipe_action = n_dpipe_action;
940 parg.rsp_policy = &devlink_dl_dpipe_action_nest;
941 mnl_attr_for_each_nested(attr, nested) {
942 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_ACTION) {
943 parg.data = &dst->dpipe_action[i];
944 if (devlink_dl_dpipe_action_parse(&parg, attr))
954 void devlink_dl_dpipe_field_free(struct devlink_dl_dpipe_field *obj)
956 free(obj->dpipe_field_name);
959 int devlink_dl_dpipe_field_parse(struct ynl_parse_arg *yarg,
960 const struct nlattr *nested)
962 struct devlink_dl_dpipe_field *dst = yarg->data;
963 const struct nlattr *attr;
965 mnl_attr_for_each_nested(attr, nested) {
966 unsigned int type = mnl_attr_get_type(attr);
968 if (type == DEVLINK_ATTR_DPIPE_FIELD_NAME) {
971 if (ynl_attr_validate(yarg, attr))
974 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
975 dst->_present.dpipe_field_name_len = len;
976 dst->dpipe_field_name = malloc(len + 1);
977 memcpy(dst->dpipe_field_name, mnl_attr_get_str(attr), len);
978 dst->dpipe_field_name[len] = 0;
979 } else if (type == DEVLINK_ATTR_DPIPE_FIELD_ID) {
980 if (ynl_attr_validate(yarg, attr))
982 dst->_present.dpipe_field_id = 1;
983 dst->dpipe_field_id = mnl_attr_get_u32(attr);
984 } else if (type == DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH) {
985 if (ynl_attr_validate(yarg, attr))
987 dst->_present.dpipe_field_bitwidth = 1;
988 dst->dpipe_field_bitwidth = mnl_attr_get_u32(attr);
989 } else if (type == DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE) {
990 if (ynl_attr_validate(yarg, attr))
992 dst->_present.dpipe_field_mapping_type = 1;
993 dst->dpipe_field_mapping_type = mnl_attr_get_u32(attr);
1000 void devlink_dl_resource_free(struct devlink_dl_resource *obj)
1002 free(obj->resource_name);
1005 int devlink_dl_resource_parse(struct ynl_parse_arg *yarg,
1006 const struct nlattr *nested)
1008 struct devlink_dl_resource *dst = yarg->data;
1009 const struct nlattr *attr;
1011 mnl_attr_for_each_nested(attr, nested) {
1012 unsigned int type = mnl_attr_get_type(attr);
1014 if (type == DEVLINK_ATTR_RESOURCE_NAME) {
1017 if (ynl_attr_validate(yarg, attr))
1018 return MNL_CB_ERROR;
1020 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
1021 dst->_present.resource_name_len = len;
1022 dst->resource_name = malloc(len + 1);
1023 memcpy(dst->resource_name, mnl_attr_get_str(attr), len);
1024 dst->resource_name[len] = 0;
1025 } else if (type == DEVLINK_ATTR_RESOURCE_ID) {
1026 if (ynl_attr_validate(yarg, attr))
1027 return MNL_CB_ERROR;
1028 dst->_present.resource_id = 1;
1029 dst->resource_id = mnl_attr_get_u64(attr);
1030 } else if (type == DEVLINK_ATTR_RESOURCE_SIZE) {
1031 if (ynl_attr_validate(yarg, attr))
1032 return MNL_CB_ERROR;
1033 dst->_present.resource_size = 1;
1034 dst->resource_size = mnl_attr_get_u64(attr);
1035 } else if (type == DEVLINK_ATTR_RESOURCE_SIZE_NEW) {
1036 if (ynl_attr_validate(yarg, attr))
1037 return MNL_CB_ERROR;
1038 dst->_present.resource_size_new = 1;
1039 dst->resource_size_new = mnl_attr_get_u64(attr);
1040 } else if (type == DEVLINK_ATTR_RESOURCE_SIZE_VALID) {
1041 if (ynl_attr_validate(yarg, attr))
1042 return MNL_CB_ERROR;
1043 dst->_present.resource_size_valid = 1;
1044 dst->resource_size_valid = mnl_attr_get_u8(attr);
1045 } else if (type == DEVLINK_ATTR_RESOURCE_SIZE_MIN) {
1046 if (ynl_attr_validate(yarg, attr))
1047 return MNL_CB_ERROR;
1048 dst->_present.resource_size_min = 1;
1049 dst->resource_size_min = mnl_attr_get_u64(attr);
1050 } else if (type == DEVLINK_ATTR_RESOURCE_SIZE_MAX) {
1051 if (ynl_attr_validate(yarg, attr))
1052 return MNL_CB_ERROR;
1053 dst->_present.resource_size_max = 1;
1054 dst->resource_size_max = mnl_attr_get_u64(attr);
1055 } else if (type == DEVLINK_ATTR_RESOURCE_SIZE_GRAN) {
1056 if (ynl_attr_validate(yarg, attr))
1057 return MNL_CB_ERROR;
1058 dst->_present.resource_size_gran = 1;
1059 dst->resource_size_gran = mnl_attr_get_u64(attr);
1060 } else if (type == DEVLINK_ATTR_RESOURCE_UNIT) {
1061 if (ynl_attr_validate(yarg, attr))
1062 return MNL_CB_ERROR;
1063 dst->_present.resource_unit = 1;
1064 dst->resource_unit = mnl_attr_get_u8(attr);
1065 } else if (type == DEVLINK_ATTR_RESOURCE_OCC) {
1066 if (ynl_attr_validate(yarg, attr))
1067 return MNL_CB_ERROR;
1068 dst->_present.resource_occ = 1;
1069 dst->resource_occ = mnl_attr_get_u64(attr);
1076 void devlink_dl_info_version_free(struct devlink_dl_info_version *obj)
1078 free(obj->info_version_name);
1079 free(obj->info_version_value);
1082 int devlink_dl_info_version_parse(struct ynl_parse_arg *yarg,
1083 const struct nlattr *nested)
1085 struct devlink_dl_info_version *dst = yarg->data;
1086 const struct nlattr *attr;
1088 mnl_attr_for_each_nested(attr, nested) {
1089 unsigned int type = mnl_attr_get_type(attr);
1091 if (type == DEVLINK_ATTR_INFO_VERSION_NAME) {
1094 if (ynl_attr_validate(yarg, attr))
1095 return MNL_CB_ERROR;
1097 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
1098 dst->_present.info_version_name_len = len;
1099 dst->info_version_name = malloc(len + 1);
1100 memcpy(dst->info_version_name, mnl_attr_get_str(attr), len);
1101 dst->info_version_name[len] = 0;
1102 } else if (type == DEVLINK_ATTR_INFO_VERSION_VALUE) {
1105 if (ynl_attr_validate(yarg, attr))
1106 return MNL_CB_ERROR;
1108 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
1109 dst->_present.info_version_value_len = len;
1110 dst->info_version_value = malloc(len + 1);
1111 memcpy(dst->info_version_value, mnl_attr_get_str(attr), len);
1112 dst->info_version_value[len] = 0;
1119 void devlink_dl_fmsg_free(struct devlink_dl_fmsg *obj)
1121 free(obj->fmsg_obj_name);
1124 int devlink_dl_fmsg_parse(struct ynl_parse_arg *yarg,
1125 const struct nlattr *nested)
1127 struct devlink_dl_fmsg *dst = yarg->data;
1128 const struct nlattr *attr;
1130 mnl_attr_for_each_nested(attr, nested) {
1131 unsigned int type = mnl_attr_get_type(attr);
1133 if (type == DEVLINK_ATTR_FMSG_OBJ_NEST_START) {
1134 if (ynl_attr_validate(yarg, attr))
1135 return MNL_CB_ERROR;
1136 dst->_present.fmsg_obj_nest_start = 1;
1137 } else if (type == DEVLINK_ATTR_FMSG_PAIR_NEST_START) {
1138 if (ynl_attr_validate(yarg, attr))
1139 return MNL_CB_ERROR;
1140 dst->_present.fmsg_pair_nest_start = 1;
1141 } else if (type == DEVLINK_ATTR_FMSG_ARR_NEST_START) {
1142 if (ynl_attr_validate(yarg, attr))
1143 return MNL_CB_ERROR;
1144 dst->_present.fmsg_arr_nest_start = 1;
1145 } else if (type == DEVLINK_ATTR_FMSG_NEST_END) {
1146 if (ynl_attr_validate(yarg, attr))
1147 return MNL_CB_ERROR;
1148 dst->_present.fmsg_nest_end = 1;
1149 } else if (type == DEVLINK_ATTR_FMSG_OBJ_NAME) {
1152 if (ynl_attr_validate(yarg, attr))
1153 return MNL_CB_ERROR;
1155 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
1156 dst->_present.fmsg_obj_name_len = len;
1157 dst->fmsg_obj_name = malloc(len + 1);
1158 memcpy(dst->fmsg_obj_name, mnl_attr_get_str(attr), len);
1159 dst->fmsg_obj_name[len] = 0;
1166 void devlink_dl_port_function_free(struct devlink_dl_port_function *obj)
1171 int devlink_dl_port_function_put(struct nlmsghdr *nlh, unsigned int attr_type,
1172 struct devlink_dl_port_function *obj)
1174 struct nlattr *nest;
1176 nest = mnl_attr_nest_start(nlh, attr_type);
1177 if (obj->_present.hw_addr_len)
1178 mnl_attr_put(nlh, DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR, obj->_present.hw_addr_len, obj->hw_addr);
1179 if (obj->_present.state)
1180 mnl_attr_put_u8(nlh, DEVLINK_PORT_FN_ATTR_STATE, obj->state);
1181 if (obj->_present.opstate)
1182 mnl_attr_put_u8(nlh, DEVLINK_PORT_FN_ATTR_OPSTATE, obj->opstate);
1183 if (obj->_present.caps)
1184 mnl_attr_put(nlh, DEVLINK_PORT_FN_ATTR_CAPS, sizeof(struct nla_bitfield32), &obj->caps);
1185 mnl_attr_nest_end(nlh, nest);
1191 devlink_dl_reload_stats_entry_free(struct devlink_dl_reload_stats_entry *obj)
1195 int devlink_dl_reload_stats_entry_parse(struct ynl_parse_arg *yarg,
1196 const struct nlattr *nested)
1198 struct devlink_dl_reload_stats_entry *dst = yarg->data;
1199 const struct nlattr *attr;
1201 mnl_attr_for_each_nested(attr, nested) {
1202 unsigned int type = mnl_attr_get_type(attr);
1204 if (type == DEVLINK_ATTR_RELOAD_STATS_LIMIT) {
1205 if (ynl_attr_validate(yarg, attr))
1206 return MNL_CB_ERROR;
1207 dst->_present.reload_stats_limit = 1;
1208 dst->reload_stats_limit = mnl_attr_get_u8(attr);
1209 } else if (type == DEVLINK_ATTR_RELOAD_STATS_VALUE) {
1210 if (ynl_attr_validate(yarg, attr))
1211 return MNL_CB_ERROR;
1212 dst->_present.reload_stats_value = 1;
1213 dst->reload_stats_value = mnl_attr_get_u32(attr);
1220 void devlink_dl_reload_act_stats_free(struct devlink_dl_reload_act_stats *obj)
1224 for (i = 0; i < obj->n_reload_stats_entry; i++)
1225 devlink_dl_reload_stats_entry_free(&obj->reload_stats_entry[i]);
1226 free(obj->reload_stats_entry);
1229 int devlink_dl_reload_act_stats_parse(struct ynl_parse_arg *yarg,
1230 const struct nlattr *nested)
1232 struct devlink_dl_reload_act_stats *dst = yarg->data;
1233 unsigned int n_reload_stats_entry = 0;
1234 const struct nlattr *attr;
1235 struct ynl_parse_arg parg;
1240 if (dst->reload_stats_entry)
1241 return ynl_error_parse(yarg, "attribute already present (dl-reload-act-stats.reload-stats-entry)");
1243 mnl_attr_for_each_nested(attr, nested) {
1244 unsigned int type = mnl_attr_get_type(attr);
1246 if (type == DEVLINK_ATTR_RELOAD_STATS_ENTRY) {
1247 n_reload_stats_entry++;
1251 if (n_reload_stats_entry) {
1252 dst->reload_stats_entry = calloc(n_reload_stats_entry, sizeof(*dst->reload_stats_entry));
1253 dst->n_reload_stats_entry = n_reload_stats_entry;
1255 parg.rsp_policy = &devlink_dl_reload_stats_entry_nest;
1256 mnl_attr_for_each_nested(attr, nested) {
1257 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_RELOAD_STATS_ENTRY) {
1258 parg.data = &dst->reload_stats_entry[i];
1259 if (devlink_dl_reload_stats_entry_parse(&parg, attr))
1260 return MNL_CB_ERROR;
1269 void devlink_dl_selftest_id_free(struct devlink_dl_selftest_id *obj)
1273 int devlink_dl_selftest_id_put(struct nlmsghdr *nlh, unsigned int attr_type,
1274 struct devlink_dl_selftest_id *obj)
1276 struct nlattr *nest;
1278 nest = mnl_attr_nest_start(nlh, attr_type);
1279 if (obj->_present.flash)
1280 mnl_attr_put(nlh, DEVLINK_ATTR_SELFTEST_ID_FLASH, 0, NULL);
1281 mnl_attr_nest_end(nlh, nest);
1287 devlink_dl_dpipe_table_matches_free(struct devlink_dl_dpipe_table_matches *obj)
1291 for (i = 0; i < obj->n_dpipe_match; i++)
1292 devlink_dl_dpipe_match_free(&obj->dpipe_match[i]);
1293 free(obj->dpipe_match);
1296 int devlink_dl_dpipe_table_matches_parse(struct ynl_parse_arg *yarg,
1297 const struct nlattr *nested)
1299 struct devlink_dl_dpipe_table_matches *dst = yarg->data;
1300 unsigned int n_dpipe_match = 0;
1301 const struct nlattr *attr;
1302 struct ynl_parse_arg parg;
1307 if (dst->dpipe_match)
1308 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-table-matches.dpipe-match)");
1310 mnl_attr_for_each_nested(attr, nested) {
1311 unsigned int type = mnl_attr_get_type(attr);
1313 if (type == DEVLINK_ATTR_DPIPE_MATCH) {
1318 if (n_dpipe_match) {
1319 dst->dpipe_match = calloc(n_dpipe_match, sizeof(*dst->dpipe_match));
1320 dst->n_dpipe_match = n_dpipe_match;
1322 parg.rsp_policy = &devlink_dl_dpipe_match_nest;
1323 mnl_attr_for_each_nested(attr, nested) {
1324 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_MATCH) {
1325 parg.data = &dst->dpipe_match[i];
1326 if (devlink_dl_dpipe_match_parse(&parg, attr))
1327 return MNL_CB_ERROR;
1337 devlink_dl_dpipe_table_actions_free(struct devlink_dl_dpipe_table_actions *obj)
1341 for (i = 0; i < obj->n_dpipe_action; i++)
1342 devlink_dl_dpipe_action_free(&obj->dpipe_action[i]);
1343 free(obj->dpipe_action);
1346 int devlink_dl_dpipe_table_actions_parse(struct ynl_parse_arg *yarg,
1347 const struct nlattr *nested)
1349 struct devlink_dl_dpipe_table_actions *dst = yarg->data;
1350 unsigned int n_dpipe_action = 0;
1351 const struct nlattr *attr;
1352 struct ynl_parse_arg parg;
1357 if (dst->dpipe_action)
1358 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-table-actions.dpipe-action)");
1360 mnl_attr_for_each_nested(attr, nested) {
1361 unsigned int type = mnl_attr_get_type(attr);
1363 if (type == DEVLINK_ATTR_DPIPE_ACTION) {
1368 if (n_dpipe_action) {
1369 dst->dpipe_action = calloc(n_dpipe_action, sizeof(*dst->dpipe_action));
1370 dst->n_dpipe_action = n_dpipe_action;
1372 parg.rsp_policy = &devlink_dl_dpipe_action_nest;
1373 mnl_attr_for_each_nested(attr, nested) {
1374 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_ACTION) {
1375 parg.data = &dst->dpipe_action[i];
1376 if (devlink_dl_dpipe_action_parse(&parg, attr))
1377 return MNL_CB_ERROR;
1387 devlink_dl_dpipe_entry_match_values_free(struct devlink_dl_dpipe_entry_match_values *obj)
1391 for (i = 0; i < obj->n_dpipe_match_value; i++)
1392 devlink_dl_dpipe_match_value_free(&obj->dpipe_match_value[i]);
1393 free(obj->dpipe_match_value);
1396 int devlink_dl_dpipe_entry_match_values_parse(struct ynl_parse_arg *yarg,
1397 const struct nlattr *nested)
1399 struct devlink_dl_dpipe_entry_match_values *dst = yarg->data;
1400 unsigned int n_dpipe_match_value = 0;
1401 const struct nlattr *attr;
1402 struct ynl_parse_arg parg;
1407 if (dst->dpipe_match_value)
1408 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-entry-match-values.dpipe-match-value)");
1410 mnl_attr_for_each_nested(attr, nested) {
1411 unsigned int type = mnl_attr_get_type(attr);
1413 if (type == DEVLINK_ATTR_DPIPE_MATCH_VALUE) {
1414 n_dpipe_match_value++;
1418 if (n_dpipe_match_value) {
1419 dst->dpipe_match_value = calloc(n_dpipe_match_value, sizeof(*dst->dpipe_match_value));
1420 dst->n_dpipe_match_value = n_dpipe_match_value;
1422 parg.rsp_policy = &devlink_dl_dpipe_match_value_nest;
1423 mnl_attr_for_each_nested(attr, nested) {
1424 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_MATCH_VALUE) {
1425 parg.data = &dst->dpipe_match_value[i];
1426 if (devlink_dl_dpipe_match_value_parse(&parg, attr))
1427 return MNL_CB_ERROR;
1437 devlink_dl_dpipe_entry_action_values_free(struct devlink_dl_dpipe_entry_action_values *obj)
1441 for (i = 0; i < obj->n_dpipe_action_value; i++)
1442 devlink_dl_dpipe_action_value_free(&obj->dpipe_action_value[i]);
1443 free(obj->dpipe_action_value);
1446 int devlink_dl_dpipe_entry_action_values_parse(struct ynl_parse_arg *yarg,
1447 const struct nlattr *nested)
1449 struct devlink_dl_dpipe_entry_action_values *dst = yarg->data;
1450 unsigned int n_dpipe_action_value = 0;
1451 const struct nlattr *attr;
1452 struct ynl_parse_arg parg;
1457 if (dst->dpipe_action_value)
1458 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-entry-action-values.dpipe-action-value)");
1460 mnl_attr_for_each_nested(attr, nested) {
1461 unsigned int type = mnl_attr_get_type(attr);
1463 if (type == DEVLINK_ATTR_DPIPE_ACTION_VALUE) {
1464 n_dpipe_action_value++;
1468 if (n_dpipe_action_value) {
1469 dst->dpipe_action_value = calloc(n_dpipe_action_value, sizeof(*dst->dpipe_action_value));
1470 dst->n_dpipe_action_value = n_dpipe_action_value;
1472 parg.rsp_policy = &devlink_dl_dpipe_action_value_nest;
1473 mnl_attr_for_each_nested(attr, nested) {
1474 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_ACTION_VALUE) {
1475 parg.data = &dst->dpipe_action_value[i];
1476 if (devlink_dl_dpipe_action_value_parse(&parg, attr))
1477 return MNL_CB_ERROR;
1487 devlink_dl_dpipe_header_fields_free(struct devlink_dl_dpipe_header_fields *obj)
1491 for (i = 0; i < obj->n_dpipe_field; i++)
1492 devlink_dl_dpipe_field_free(&obj->dpipe_field[i]);
1493 free(obj->dpipe_field);
1496 int devlink_dl_dpipe_header_fields_parse(struct ynl_parse_arg *yarg,
1497 const struct nlattr *nested)
1499 struct devlink_dl_dpipe_header_fields *dst = yarg->data;
1500 unsigned int n_dpipe_field = 0;
1501 const struct nlattr *attr;
1502 struct ynl_parse_arg parg;
1507 if (dst->dpipe_field)
1508 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-header-fields.dpipe-field)");
1510 mnl_attr_for_each_nested(attr, nested) {
1511 unsigned int type = mnl_attr_get_type(attr);
1513 if (type == DEVLINK_ATTR_DPIPE_FIELD) {
1518 if (n_dpipe_field) {
1519 dst->dpipe_field = calloc(n_dpipe_field, sizeof(*dst->dpipe_field));
1520 dst->n_dpipe_field = n_dpipe_field;
1522 parg.rsp_policy = &devlink_dl_dpipe_field_nest;
1523 mnl_attr_for_each_nested(attr, nested) {
1524 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_FIELD) {
1525 parg.data = &dst->dpipe_field[i];
1526 if (devlink_dl_dpipe_field_parse(&parg, attr))
1527 return MNL_CB_ERROR;
1536 void devlink_dl_resource_list_free(struct devlink_dl_resource_list *obj)
1540 for (i = 0; i < obj->n_resource; i++)
1541 devlink_dl_resource_free(&obj->resource[i]);
1542 free(obj->resource);
1545 int devlink_dl_resource_list_parse(struct ynl_parse_arg *yarg,
1546 const struct nlattr *nested)
1548 struct devlink_dl_resource_list *dst = yarg->data;
1549 unsigned int n_resource = 0;
1550 const struct nlattr *attr;
1551 struct ynl_parse_arg parg;
1557 return ynl_error_parse(yarg, "attribute already present (dl-resource-list.resource)");
1559 mnl_attr_for_each_nested(attr, nested) {
1560 unsigned int type = mnl_attr_get_type(attr);
1562 if (type == DEVLINK_ATTR_RESOURCE) {
1568 dst->resource = calloc(n_resource, sizeof(*dst->resource));
1569 dst->n_resource = n_resource;
1571 parg.rsp_policy = &devlink_dl_resource_nest;
1572 mnl_attr_for_each_nested(attr, nested) {
1573 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_RESOURCE) {
1574 parg.data = &dst->resource[i];
1575 if (devlink_dl_resource_parse(&parg, attr))
1576 return MNL_CB_ERROR;
1585 void devlink_dl_reload_act_info_free(struct devlink_dl_reload_act_info *obj)
1589 for (i = 0; i < obj->n_reload_action_stats; i++)
1590 devlink_dl_reload_act_stats_free(&obj->reload_action_stats[i]);
1591 free(obj->reload_action_stats);
1594 int devlink_dl_reload_act_info_parse(struct ynl_parse_arg *yarg,
1595 const struct nlattr *nested)
1597 struct devlink_dl_reload_act_info *dst = yarg->data;
1598 unsigned int n_reload_action_stats = 0;
1599 const struct nlattr *attr;
1600 struct ynl_parse_arg parg;
1605 if (dst->reload_action_stats)
1606 return ynl_error_parse(yarg, "attribute already present (dl-reload-act-info.reload-action-stats)");
1608 mnl_attr_for_each_nested(attr, nested) {
1609 unsigned int type = mnl_attr_get_type(attr);
1611 if (type == DEVLINK_ATTR_RELOAD_ACTION) {
1612 if (ynl_attr_validate(yarg, attr))
1613 return MNL_CB_ERROR;
1614 dst->_present.reload_action = 1;
1615 dst->reload_action = mnl_attr_get_u8(attr);
1616 } else if (type == DEVLINK_ATTR_RELOAD_ACTION_STATS) {
1617 n_reload_action_stats++;
1621 if (n_reload_action_stats) {
1622 dst->reload_action_stats = calloc(n_reload_action_stats, sizeof(*dst->reload_action_stats));
1623 dst->n_reload_action_stats = n_reload_action_stats;
1625 parg.rsp_policy = &devlink_dl_reload_act_stats_nest;
1626 mnl_attr_for_each_nested(attr, nested) {
1627 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_RELOAD_ACTION_STATS) {
1628 parg.data = &dst->reload_action_stats[i];
1629 if (devlink_dl_reload_act_stats_parse(&parg, attr))
1630 return MNL_CB_ERROR;
1639 void devlink_dl_dpipe_table_free(struct devlink_dl_dpipe_table *obj)
1641 free(obj->dpipe_table_name);
1642 devlink_dl_dpipe_table_matches_free(&obj->dpipe_table_matches);
1643 devlink_dl_dpipe_table_actions_free(&obj->dpipe_table_actions);
1646 int devlink_dl_dpipe_table_parse(struct ynl_parse_arg *yarg,
1647 const struct nlattr *nested)
1649 struct devlink_dl_dpipe_table *dst = yarg->data;
1650 const struct nlattr *attr;
1651 struct ynl_parse_arg parg;
1655 mnl_attr_for_each_nested(attr, nested) {
1656 unsigned int type = mnl_attr_get_type(attr);
1658 if (type == DEVLINK_ATTR_DPIPE_TABLE_NAME) {
1661 if (ynl_attr_validate(yarg, attr))
1662 return MNL_CB_ERROR;
1664 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
1665 dst->_present.dpipe_table_name_len = len;
1666 dst->dpipe_table_name = malloc(len + 1);
1667 memcpy(dst->dpipe_table_name, mnl_attr_get_str(attr), len);
1668 dst->dpipe_table_name[len] = 0;
1669 } else if (type == DEVLINK_ATTR_DPIPE_TABLE_SIZE) {
1670 if (ynl_attr_validate(yarg, attr))
1671 return MNL_CB_ERROR;
1672 dst->_present.dpipe_table_size = 1;
1673 dst->dpipe_table_size = mnl_attr_get_u64(attr);
1674 } else if (type == DEVLINK_ATTR_DPIPE_TABLE_MATCHES) {
1675 if (ynl_attr_validate(yarg, attr))
1676 return MNL_CB_ERROR;
1677 dst->_present.dpipe_table_matches = 1;
1679 parg.rsp_policy = &devlink_dl_dpipe_table_matches_nest;
1680 parg.data = &dst->dpipe_table_matches;
1681 if (devlink_dl_dpipe_table_matches_parse(&parg, attr))
1682 return MNL_CB_ERROR;
1683 } else if (type == DEVLINK_ATTR_DPIPE_TABLE_ACTIONS) {
1684 if (ynl_attr_validate(yarg, attr))
1685 return MNL_CB_ERROR;
1686 dst->_present.dpipe_table_actions = 1;
1688 parg.rsp_policy = &devlink_dl_dpipe_table_actions_nest;
1689 parg.data = &dst->dpipe_table_actions;
1690 if (devlink_dl_dpipe_table_actions_parse(&parg, attr))
1691 return MNL_CB_ERROR;
1692 } else if (type == DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED) {
1693 if (ynl_attr_validate(yarg, attr))
1694 return MNL_CB_ERROR;
1695 dst->_present.dpipe_table_counters_enabled = 1;
1696 dst->dpipe_table_counters_enabled = mnl_attr_get_u8(attr);
1697 } else if (type == DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID) {
1698 if (ynl_attr_validate(yarg, attr))
1699 return MNL_CB_ERROR;
1700 dst->_present.dpipe_table_resource_id = 1;
1701 dst->dpipe_table_resource_id = mnl_attr_get_u64(attr);
1702 } else if (type == DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS) {
1703 if (ynl_attr_validate(yarg, attr))
1704 return MNL_CB_ERROR;
1705 dst->_present.dpipe_table_resource_units = 1;
1706 dst->dpipe_table_resource_units = mnl_attr_get_u64(attr);
1713 void devlink_dl_dpipe_entry_free(struct devlink_dl_dpipe_entry *obj)
1715 devlink_dl_dpipe_entry_match_values_free(&obj->dpipe_entry_match_values);
1716 devlink_dl_dpipe_entry_action_values_free(&obj->dpipe_entry_action_values);
1719 int devlink_dl_dpipe_entry_parse(struct ynl_parse_arg *yarg,
1720 const struct nlattr *nested)
1722 struct devlink_dl_dpipe_entry *dst = yarg->data;
1723 const struct nlattr *attr;
1724 struct ynl_parse_arg parg;
1728 mnl_attr_for_each_nested(attr, nested) {
1729 unsigned int type = mnl_attr_get_type(attr);
1731 if (type == DEVLINK_ATTR_DPIPE_ENTRY_INDEX) {
1732 if (ynl_attr_validate(yarg, attr))
1733 return MNL_CB_ERROR;
1734 dst->_present.dpipe_entry_index = 1;
1735 dst->dpipe_entry_index = mnl_attr_get_u64(attr);
1736 } else if (type == DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES) {
1737 if (ynl_attr_validate(yarg, attr))
1738 return MNL_CB_ERROR;
1739 dst->_present.dpipe_entry_match_values = 1;
1741 parg.rsp_policy = &devlink_dl_dpipe_entry_match_values_nest;
1742 parg.data = &dst->dpipe_entry_match_values;
1743 if (devlink_dl_dpipe_entry_match_values_parse(&parg, attr))
1744 return MNL_CB_ERROR;
1745 } else if (type == DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES) {
1746 if (ynl_attr_validate(yarg, attr))
1747 return MNL_CB_ERROR;
1748 dst->_present.dpipe_entry_action_values = 1;
1750 parg.rsp_policy = &devlink_dl_dpipe_entry_action_values_nest;
1751 parg.data = &dst->dpipe_entry_action_values;
1752 if (devlink_dl_dpipe_entry_action_values_parse(&parg, attr))
1753 return MNL_CB_ERROR;
1754 } else if (type == DEVLINK_ATTR_DPIPE_ENTRY_COUNTER) {
1755 if (ynl_attr_validate(yarg, attr))
1756 return MNL_CB_ERROR;
1757 dst->_present.dpipe_entry_counter = 1;
1758 dst->dpipe_entry_counter = mnl_attr_get_u64(attr);
1765 void devlink_dl_dpipe_header_free(struct devlink_dl_dpipe_header *obj)
1767 free(obj->dpipe_header_name);
1768 devlink_dl_dpipe_header_fields_free(&obj->dpipe_header_fields);
1771 int devlink_dl_dpipe_header_parse(struct ynl_parse_arg *yarg,
1772 const struct nlattr *nested)
1774 struct devlink_dl_dpipe_header *dst = yarg->data;
1775 const struct nlattr *attr;
1776 struct ynl_parse_arg parg;
1780 mnl_attr_for_each_nested(attr, nested) {
1781 unsigned int type = mnl_attr_get_type(attr);
1783 if (type == DEVLINK_ATTR_DPIPE_HEADER_NAME) {
1786 if (ynl_attr_validate(yarg, attr))
1787 return MNL_CB_ERROR;
1789 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
1790 dst->_present.dpipe_header_name_len = len;
1791 dst->dpipe_header_name = malloc(len + 1);
1792 memcpy(dst->dpipe_header_name, mnl_attr_get_str(attr), len);
1793 dst->dpipe_header_name[len] = 0;
1794 } else if (type == DEVLINK_ATTR_DPIPE_HEADER_ID) {
1795 if (ynl_attr_validate(yarg, attr))
1796 return MNL_CB_ERROR;
1797 dst->_present.dpipe_header_id = 1;
1798 dst->dpipe_header_id = mnl_attr_get_u32(attr);
1799 } else if (type == DEVLINK_ATTR_DPIPE_HEADER_GLOBAL) {
1800 if (ynl_attr_validate(yarg, attr))
1801 return MNL_CB_ERROR;
1802 dst->_present.dpipe_header_global = 1;
1803 dst->dpipe_header_global = mnl_attr_get_u8(attr);
1804 } else if (type == DEVLINK_ATTR_DPIPE_HEADER_FIELDS) {
1805 if (ynl_attr_validate(yarg, attr))
1806 return MNL_CB_ERROR;
1807 dst->_present.dpipe_header_fields = 1;
1809 parg.rsp_policy = &devlink_dl_dpipe_header_fields_nest;
1810 parg.data = &dst->dpipe_header_fields;
1811 if (devlink_dl_dpipe_header_fields_parse(&parg, attr))
1812 return MNL_CB_ERROR;
1819 void devlink_dl_reload_stats_free(struct devlink_dl_reload_stats *obj)
1823 for (i = 0; i < obj->n_reload_action_info; i++)
1824 devlink_dl_reload_act_info_free(&obj->reload_action_info[i]);
1825 free(obj->reload_action_info);
1828 int devlink_dl_reload_stats_parse(struct ynl_parse_arg *yarg,
1829 const struct nlattr *nested)
1831 struct devlink_dl_reload_stats *dst = yarg->data;
1832 unsigned int n_reload_action_info = 0;
1833 const struct nlattr *attr;
1834 struct ynl_parse_arg parg;
1839 if (dst->reload_action_info)
1840 return ynl_error_parse(yarg, "attribute already present (dl-reload-stats.reload-action-info)");
1842 mnl_attr_for_each_nested(attr, nested) {
1843 unsigned int type = mnl_attr_get_type(attr);
1845 if (type == DEVLINK_ATTR_RELOAD_ACTION_INFO) {
1846 n_reload_action_info++;
1850 if (n_reload_action_info) {
1851 dst->reload_action_info = calloc(n_reload_action_info, sizeof(*dst->reload_action_info));
1852 dst->n_reload_action_info = n_reload_action_info;
1854 parg.rsp_policy = &devlink_dl_reload_act_info_nest;
1855 mnl_attr_for_each_nested(attr, nested) {
1856 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_RELOAD_ACTION_INFO) {
1857 parg.data = &dst->reload_action_info[i];
1858 if (devlink_dl_reload_act_info_parse(&parg, attr))
1859 return MNL_CB_ERROR;
1868 void devlink_dl_dpipe_tables_free(struct devlink_dl_dpipe_tables *obj)
1872 for (i = 0; i < obj->n_dpipe_table; i++)
1873 devlink_dl_dpipe_table_free(&obj->dpipe_table[i]);
1874 free(obj->dpipe_table);
1877 int devlink_dl_dpipe_tables_parse(struct ynl_parse_arg *yarg,
1878 const struct nlattr *nested)
1880 struct devlink_dl_dpipe_tables *dst = yarg->data;
1881 unsigned int n_dpipe_table = 0;
1882 const struct nlattr *attr;
1883 struct ynl_parse_arg parg;
1888 if (dst->dpipe_table)
1889 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-tables.dpipe-table)");
1891 mnl_attr_for_each_nested(attr, nested) {
1892 unsigned int type = mnl_attr_get_type(attr);
1894 if (type == DEVLINK_ATTR_DPIPE_TABLE) {
1899 if (n_dpipe_table) {
1900 dst->dpipe_table = calloc(n_dpipe_table, sizeof(*dst->dpipe_table));
1901 dst->n_dpipe_table = n_dpipe_table;
1903 parg.rsp_policy = &devlink_dl_dpipe_table_nest;
1904 mnl_attr_for_each_nested(attr, nested) {
1905 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_TABLE) {
1906 parg.data = &dst->dpipe_table[i];
1907 if (devlink_dl_dpipe_table_parse(&parg, attr))
1908 return MNL_CB_ERROR;
1917 void devlink_dl_dpipe_entries_free(struct devlink_dl_dpipe_entries *obj)
1921 for (i = 0; i < obj->n_dpipe_entry; i++)
1922 devlink_dl_dpipe_entry_free(&obj->dpipe_entry[i]);
1923 free(obj->dpipe_entry);
1926 int devlink_dl_dpipe_entries_parse(struct ynl_parse_arg *yarg,
1927 const struct nlattr *nested)
1929 struct devlink_dl_dpipe_entries *dst = yarg->data;
1930 unsigned int n_dpipe_entry = 0;
1931 const struct nlattr *attr;
1932 struct ynl_parse_arg parg;
1937 if (dst->dpipe_entry)
1938 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-entries.dpipe-entry)");
1940 mnl_attr_for_each_nested(attr, nested) {
1941 unsigned int type = mnl_attr_get_type(attr);
1943 if (type == DEVLINK_ATTR_DPIPE_ENTRY) {
1948 if (n_dpipe_entry) {
1949 dst->dpipe_entry = calloc(n_dpipe_entry, sizeof(*dst->dpipe_entry));
1950 dst->n_dpipe_entry = n_dpipe_entry;
1952 parg.rsp_policy = &devlink_dl_dpipe_entry_nest;
1953 mnl_attr_for_each_nested(attr, nested) {
1954 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_ENTRY) {
1955 parg.data = &dst->dpipe_entry[i];
1956 if (devlink_dl_dpipe_entry_parse(&parg, attr))
1957 return MNL_CB_ERROR;
1966 void devlink_dl_dpipe_headers_free(struct devlink_dl_dpipe_headers *obj)
1970 for (i = 0; i < obj->n_dpipe_header; i++)
1971 devlink_dl_dpipe_header_free(&obj->dpipe_header[i]);
1972 free(obj->dpipe_header);
1975 int devlink_dl_dpipe_headers_parse(struct ynl_parse_arg *yarg,
1976 const struct nlattr *nested)
1978 struct devlink_dl_dpipe_headers *dst = yarg->data;
1979 unsigned int n_dpipe_header = 0;
1980 const struct nlattr *attr;
1981 struct ynl_parse_arg parg;
1986 if (dst->dpipe_header)
1987 return ynl_error_parse(yarg, "attribute already present (dl-dpipe-headers.dpipe-header)");
1989 mnl_attr_for_each_nested(attr, nested) {
1990 unsigned int type = mnl_attr_get_type(attr);
1992 if (type == DEVLINK_ATTR_DPIPE_HEADER) {
1997 if (n_dpipe_header) {
1998 dst->dpipe_header = calloc(n_dpipe_header, sizeof(*dst->dpipe_header));
1999 dst->n_dpipe_header = n_dpipe_header;
2001 parg.rsp_policy = &devlink_dl_dpipe_header_nest;
2002 mnl_attr_for_each_nested(attr, nested) {
2003 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_DPIPE_HEADER) {
2004 parg.data = &dst->dpipe_header[i];
2005 if (devlink_dl_dpipe_header_parse(&parg, attr))
2006 return MNL_CB_ERROR;
2015 void devlink_dl_dev_stats_free(struct devlink_dl_dev_stats *obj)
2017 devlink_dl_reload_stats_free(&obj->reload_stats);
2018 devlink_dl_reload_stats_free(&obj->remote_reload_stats);
2021 int devlink_dl_dev_stats_parse(struct ynl_parse_arg *yarg,
2022 const struct nlattr *nested)
2024 struct devlink_dl_dev_stats *dst = yarg->data;
2025 const struct nlattr *attr;
2026 struct ynl_parse_arg parg;
2030 mnl_attr_for_each_nested(attr, nested) {
2031 unsigned int type = mnl_attr_get_type(attr);
2033 if (type == DEVLINK_ATTR_RELOAD_STATS) {
2034 if (ynl_attr_validate(yarg, attr))
2035 return MNL_CB_ERROR;
2036 dst->_present.reload_stats = 1;
2038 parg.rsp_policy = &devlink_dl_reload_stats_nest;
2039 parg.data = &dst->reload_stats;
2040 if (devlink_dl_reload_stats_parse(&parg, attr))
2041 return MNL_CB_ERROR;
2042 } else if (type == DEVLINK_ATTR_REMOTE_RELOAD_STATS) {
2043 if (ynl_attr_validate(yarg, attr))
2044 return MNL_CB_ERROR;
2045 dst->_present.remote_reload_stats = 1;
2047 parg.rsp_policy = &devlink_dl_reload_stats_nest;
2048 parg.data = &dst->remote_reload_stats;
2049 if (devlink_dl_reload_stats_parse(&parg, attr))
2050 return MNL_CB_ERROR;
2057 /* ============== DEVLINK_CMD_GET ============== */
2058 /* DEVLINK_CMD_GET - do */
2059 void devlink_get_req_free(struct devlink_get_req *req)
2061 free(req->bus_name);
2062 free(req->dev_name);
2066 void devlink_get_rsp_free(struct devlink_get_rsp *rsp)
2068 free(rsp->bus_name);
2069 free(rsp->dev_name);
2070 devlink_dl_dev_stats_free(&rsp->dev_stats);
2074 int devlink_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
2076 struct ynl_parse_arg *yarg = data;
2077 struct devlink_get_rsp *dst;
2078 const struct nlattr *attr;
2079 struct ynl_parse_arg parg;
2084 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
2085 unsigned int type = mnl_attr_get_type(attr);
2087 if (type == DEVLINK_ATTR_BUS_NAME) {
2090 if (ynl_attr_validate(yarg, attr))
2091 return MNL_CB_ERROR;
2093 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2094 dst->_present.bus_name_len = len;
2095 dst->bus_name = malloc(len + 1);
2096 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
2097 dst->bus_name[len] = 0;
2098 } else if (type == DEVLINK_ATTR_DEV_NAME) {
2101 if (ynl_attr_validate(yarg, attr))
2102 return MNL_CB_ERROR;
2104 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2105 dst->_present.dev_name_len = len;
2106 dst->dev_name = malloc(len + 1);
2107 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
2108 dst->dev_name[len] = 0;
2109 } else if (type == DEVLINK_ATTR_RELOAD_FAILED) {
2110 if (ynl_attr_validate(yarg, attr))
2111 return MNL_CB_ERROR;
2112 dst->_present.reload_failed = 1;
2113 dst->reload_failed = mnl_attr_get_u8(attr);
2114 } else if (type == DEVLINK_ATTR_DEV_STATS) {
2115 if (ynl_attr_validate(yarg, attr))
2116 return MNL_CB_ERROR;
2117 dst->_present.dev_stats = 1;
2119 parg.rsp_policy = &devlink_dl_dev_stats_nest;
2120 parg.data = &dst->dev_stats;
2121 if (devlink_dl_dev_stats_parse(&parg, attr))
2122 return MNL_CB_ERROR;
2129 struct devlink_get_rsp *
2130 devlink_get(struct ynl_sock *ys, struct devlink_get_req *req)
2132 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
2133 struct devlink_get_rsp *rsp;
2134 struct nlmsghdr *nlh;
2137 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_GET, 1);
2138 ys->req_policy = &devlink_nest;
2139 yrs.yarg.rsp_policy = &devlink_nest;
2141 if (req->_present.bus_name_len)
2142 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2143 if (req->_present.dev_name_len)
2144 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2146 rsp = calloc(1, sizeof(*rsp));
2147 yrs.yarg.data = rsp;
2148 yrs.cb = devlink_get_rsp_parse;
2151 err = ynl_exec(ys, nlh, &yrs);
2158 devlink_get_rsp_free(rsp);
2162 /* DEVLINK_CMD_GET - dump */
2163 void devlink_get_list_free(struct devlink_get_list *rsp)
2165 struct devlink_get_list *next = rsp;
2167 while ((void *)next != YNL_LIST_END) {
2171 free(rsp->obj.bus_name);
2172 free(rsp->obj.dev_name);
2173 devlink_dl_dev_stats_free(&rsp->obj.dev_stats);
2178 struct devlink_get_list *devlink_get_dump(struct ynl_sock *ys)
2180 struct ynl_dump_state yds = {};
2181 struct nlmsghdr *nlh;
2185 yds.alloc_sz = sizeof(struct devlink_get_list);
2186 yds.cb = devlink_get_rsp_parse;
2188 yds.rsp_policy = &devlink_nest;
2190 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_GET, 1);
2192 err = ynl_exec_dump(ys, nlh, &yds);
2199 devlink_get_list_free(yds.first);
2203 /* ============== DEVLINK_CMD_PORT_GET ============== */
2204 /* DEVLINK_CMD_PORT_GET - do */
2205 void devlink_port_get_req_free(struct devlink_port_get_req *req)
2207 free(req->bus_name);
2208 free(req->dev_name);
2212 void devlink_port_get_rsp_free(struct devlink_port_get_rsp *rsp)
2214 free(rsp->bus_name);
2215 free(rsp->dev_name);
2219 int devlink_port_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
2221 struct ynl_parse_arg *yarg = data;
2222 struct devlink_port_get_rsp *dst;
2223 const struct nlattr *attr;
2227 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
2228 unsigned int type = mnl_attr_get_type(attr);
2230 if (type == DEVLINK_ATTR_BUS_NAME) {
2233 if (ynl_attr_validate(yarg, attr))
2234 return MNL_CB_ERROR;
2236 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2237 dst->_present.bus_name_len = len;
2238 dst->bus_name = malloc(len + 1);
2239 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
2240 dst->bus_name[len] = 0;
2241 } else if (type == DEVLINK_ATTR_DEV_NAME) {
2244 if (ynl_attr_validate(yarg, attr))
2245 return MNL_CB_ERROR;
2247 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2248 dst->_present.dev_name_len = len;
2249 dst->dev_name = malloc(len + 1);
2250 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
2251 dst->dev_name[len] = 0;
2252 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
2253 if (ynl_attr_validate(yarg, attr))
2254 return MNL_CB_ERROR;
2255 dst->_present.port_index = 1;
2256 dst->port_index = mnl_attr_get_u32(attr);
2263 struct devlink_port_get_rsp *
2264 devlink_port_get(struct ynl_sock *ys, struct devlink_port_get_req *req)
2266 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
2267 struct devlink_port_get_rsp *rsp;
2268 struct nlmsghdr *nlh;
2271 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PORT_GET, 1);
2272 ys->req_policy = &devlink_nest;
2273 yrs.yarg.rsp_policy = &devlink_nest;
2275 if (req->_present.bus_name_len)
2276 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2277 if (req->_present.dev_name_len)
2278 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2279 if (req->_present.port_index)
2280 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
2282 rsp = calloc(1, sizeof(*rsp));
2283 yrs.yarg.data = rsp;
2284 yrs.cb = devlink_port_get_rsp_parse;
2287 err = ynl_exec(ys, nlh, &yrs);
2294 devlink_port_get_rsp_free(rsp);
2298 /* DEVLINK_CMD_PORT_GET - dump */
2299 int devlink_port_get_rsp_dump_parse(const struct nlmsghdr *nlh, void *data)
2301 struct devlink_port_get_rsp_dump *dst;
2302 struct ynl_parse_arg *yarg = data;
2303 const struct nlattr *attr;
2307 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
2308 unsigned int type = mnl_attr_get_type(attr);
2310 if (type == DEVLINK_ATTR_BUS_NAME) {
2313 if (ynl_attr_validate(yarg, attr))
2314 return MNL_CB_ERROR;
2316 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2317 dst->_present.bus_name_len = len;
2318 dst->bus_name = malloc(len + 1);
2319 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
2320 dst->bus_name[len] = 0;
2321 } else if (type == DEVLINK_ATTR_DEV_NAME) {
2324 if (ynl_attr_validate(yarg, attr))
2325 return MNL_CB_ERROR;
2327 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2328 dst->_present.dev_name_len = len;
2329 dst->dev_name = malloc(len + 1);
2330 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
2331 dst->dev_name[len] = 0;
2332 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
2333 if (ynl_attr_validate(yarg, attr))
2334 return MNL_CB_ERROR;
2335 dst->_present.port_index = 1;
2336 dst->port_index = mnl_attr_get_u32(attr);
2343 void devlink_port_get_rsp_list_free(struct devlink_port_get_rsp_list *rsp)
2345 struct devlink_port_get_rsp_list *next = rsp;
2347 while ((void *)next != YNL_LIST_END) {
2351 free(rsp->obj.bus_name);
2352 free(rsp->obj.dev_name);
2357 struct devlink_port_get_rsp_list *
2358 devlink_port_get_dump(struct ynl_sock *ys,
2359 struct devlink_port_get_req_dump *req)
2361 struct ynl_dump_state yds = {};
2362 struct nlmsghdr *nlh;
2366 yds.alloc_sz = sizeof(struct devlink_port_get_rsp_list);
2367 yds.cb = devlink_port_get_rsp_dump_parse;
2369 yds.rsp_policy = &devlink_nest;
2371 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_PORT_GET, 1);
2372 ys->req_policy = &devlink_nest;
2374 if (req->_present.bus_name_len)
2375 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2376 if (req->_present.dev_name_len)
2377 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2379 err = ynl_exec_dump(ys, nlh, &yds);
2386 devlink_port_get_rsp_list_free(yds.first);
2390 /* ============== DEVLINK_CMD_PORT_SET ============== */
2391 /* DEVLINK_CMD_PORT_SET - do */
2392 void devlink_port_set_req_free(struct devlink_port_set_req *req)
2394 free(req->bus_name);
2395 free(req->dev_name);
2396 devlink_dl_port_function_free(&req->port_function);
2400 int devlink_port_set(struct ynl_sock *ys, struct devlink_port_set_req *req)
2402 struct nlmsghdr *nlh;
2405 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PORT_SET, 1);
2406 ys->req_policy = &devlink_nest;
2408 if (req->_present.bus_name_len)
2409 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2410 if (req->_present.dev_name_len)
2411 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2412 if (req->_present.port_index)
2413 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
2414 if (req->_present.port_type)
2415 mnl_attr_put_u16(nlh, DEVLINK_ATTR_PORT_TYPE, req->port_type);
2416 if (req->_present.port_function)
2417 devlink_dl_port_function_put(nlh, DEVLINK_ATTR_PORT_FUNCTION, &req->port_function);
2419 err = ynl_exec(ys, nlh, NULL);
2426 /* ============== DEVLINK_CMD_PORT_NEW ============== */
2427 /* DEVLINK_CMD_PORT_NEW - do */
2428 void devlink_port_new_req_free(struct devlink_port_new_req *req)
2430 free(req->bus_name);
2431 free(req->dev_name);
2435 void devlink_port_new_rsp_free(struct devlink_port_new_rsp *rsp)
2437 free(rsp->bus_name);
2438 free(rsp->dev_name);
2442 int devlink_port_new_rsp_parse(const struct nlmsghdr *nlh, void *data)
2444 struct ynl_parse_arg *yarg = data;
2445 struct devlink_port_new_rsp *dst;
2446 const struct nlattr *attr;
2450 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
2451 unsigned int type = mnl_attr_get_type(attr);
2453 if (type == DEVLINK_ATTR_BUS_NAME) {
2456 if (ynl_attr_validate(yarg, attr))
2457 return MNL_CB_ERROR;
2459 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2460 dst->_present.bus_name_len = len;
2461 dst->bus_name = malloc(len + 1);
2462 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
2463 dst->bus_name[len] = 0;
2464 } else if (type == DEVLINK_ATTR_DEV_NAME) {
2467 if (ynl_attr_validate(yarg, attr))
2468 return MNL_CB_ERROR;
2470 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2471 dst->_present.dev_name_len = len;
2472 dst->dev_name = malloc(len + 1);
2473 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
2474 dst->dev_name[len] = 0;
2475 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
2476 if (ynl_attr_validate(yarg, attr))
2477 return MNL_CB_ERROR;
2478 dst->_present.port_index = 1;
2479 dst->port_index = mnl_attr_get_u32(attr);
2486 struct devlink_port_new_rsp *
2487 devlink_port_new(struct ynl_sock *ys, struct devlink_port_new_req *req)
2489 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
2490 struct devlink_port_new_rsp *rsp;
2491 struct nlmsghdr *nlh;
2494 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PORT_NEW, 1);
2495 ys->req_policy = &devlink_nest;
2496 yrs.yarg.rsp_policy = &devlink_nest;
2498 if (req->_present.bus_name_len)
2499 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2500 if (req->_present.dev_name_len)
2501 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2502 if (req->_present.port_index)
2503 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
2504 if (req->_present.port_flavour)
2505 mnl_attr_put_u16(nlh, DEVLINK_ATTR_PORT_FLAVOUR, req->port_flavour);
2506 if (req->_present.port_pci_pf_number)
2507 mnl_attr_put_u16(nlh, DEVLINK_ATTR_PORT_PCI_PF_NUMBER, req->port_pci_pf_number);
2508 if (req->_present.port_pci_sf_number)
2509 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_PCI_SF_NUMBER, req->port_pci_sf_number);
2510 if (req->_present.port_controller_number)
2511 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_CONTROLLER_NUMBER, req->port_controller_number);
2513 rsp = calloc(1, sizeof(*rsp));
2514 yrs.yarg.data = rsp;
2515 yrs.cb = devlink_port_new_rsp_parse;
2516 yrs.rsp_cmd = DEVLINK_CMD_PORT_NEW;
2518 err = ynl_exec(ys, nlh, &yrs);
2525 devlink_port_new_rsp_free(rsp);
2529 /* ============== DEVLINK_CMD_PORT_DEL ============== */
2530 /* DEVLINK_CMD_PORT_DEL - do */
2531 void devlink_port_del_req_free(struct devlink_port_del_req *req)
2533 free(req->bus_name);
2534 free(req->dev_name);
2538 int devlink_port_del(struct ynl_sock *ys, struct devlink_port_del_req *req)
2540 struct nlmsghdr *nlh;
2543 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PORT_DEL, 1);
2544 ys->req_policy = &devlink_nest;
2546 if (req->_present.bus_name_len)
2547 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2548 if (req->_present.dev_name_len)
2549 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2550 if (req->_present.port_index)
2551 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
2553 err = ynl_exec(ys, nlh, NULL);
2560 /* ============== DEVLINK_CMD_PORT_SPLIT ============== */
2561 /* DEVLINK_CMD_PORT_SPLIT - do */
2562 void devlink_port_split_req_free(struct devlink_port_split_req *req)
2564 free(req->bus_name);
2565 free(req->dev_name);
2569 int devlink_port_split(struct ynl_sock *ys, struct devlink_port_split_req *req)
2571 struct nlmsghdr *nlh;
2574 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PORT_SPLIT, 1);
2575 ys->req_policy = &devlink_nest;
2577 if (req->_present.bus_name_len)
2578 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2579 if (req->_present.dev_name_len)
2580 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2581 if (req->_present.port_index)
2582 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
2583 if (req->_present.port_split_count)
2584 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_SPLIT_COUNT, req->port_split_count);
2586 err = ynl_exec(ys, nlh, NULL);
2593 /* ============== DEVLINK_CMD_PORT_UNSPLIT ============== */
2594 /* DEVLINK_CMD_PORT_UNSPLIT - do */
2595 void devlink_port_unsplit_req_free(struct devlink_port_unsplit_req *req)
2597 free(req->bus_name);
2598 free(req->dev_name);
2602 int devlink_port_unsplit(struct ynl_sock *ys,
2603 struct devlink_port_unsplit_req *req)
2605 struct nlmsghdr *nlh;
2608 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PORT_UNSPLIT, 1);
2609 ys->req_policy = &devlink_nest;
2611 if (req->_present.bus_name_len)
2612 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2613 if (req->_present.dev_name_len)
2614 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2615 if (req->_present.port_index)
2616 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
2618 err = ynl_exec(ys, nlh, NULL);
2625 /* ============== DEVLINK_CMD_SB_GET ============== */
2626 /* DEVLINK_CMD_SB_GET - do */
2627 void devlink_sb_get_req_free(struct devlink_sb_get_req *req)
2629 free(req->bus_name);
2630 free(req->dev_name);
2634 void devlink_sb_get_rsp_free(struct devlink_sb_get_rsp *rsp)
2636 free(rsp->bus_name);
2637 free(rsp->dev_name);
2641 int devlink_sb_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
2643 struct ynl_parse_arg *yarg = data;
2644 struct devlink_sb_get_rsp *dst;
2645 const struct nlattr *attr;
2649 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
2650 unsigned int type = mnl_attr_get_type(attr);
2652 if (type == DEVLINK_ATTR_BUS_NAME) {
2655 if (ynl_attr_validate(yarg, attr))
2656 return MNL_CB_ERROR;
2658 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2659 dst->_present.bus_name_len = len;
2660 dst->bus_name = malloc(len + 1);
2661 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
2662 dst->bus_name[len] = 0;
2663 } else if (type == DEVLINK_ATTR_DEV_NAME) {
2666 if (ynl_attr_validate(yarg, attr))
2667 return MNL_CB_ERROR;
2669 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2670 dst->_present.dev_name_len = len;
2671 dst->dev_name = malloc(len + 1);
2672 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
2673 dst->dev_name[len] = 0;
2674 } else if (type == DEVLINK_ATTR_SB_INDEX) {
2675 if (ynl_attr_validate(yarg, attr))
2676 return MNL_CB_ERROR;
2677 dst->_present.sb_index = 1;
2678 dst->sb_index = mnl_attr_get_u32(attr);
2685 struct devlink_sb_get_rsp *
2686 devlink_sb_get(struct ynl_sock *ys, struct devlink_sb_get_req *req)
2688 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
2689 struct devlink_sb_get_rsp *rsp;
2690 struct nlmsghdr *nlh;
2693 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_GET, 1);
2694 ys->req_policy = &devlink_nest;
2695 yrs.yarg.rsp_policy = &devlink_nest;
2697 if (req->_present.bus_name_len)
2698 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2699 if (req->_present.dev_name_len)
2700 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2701 if (req->_present.sb_index)
2702 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
2704 rsp = calloc(1, sizeof(*rsp));
2705 yrs.yarg.data = rsp;
2706 yrs.cb = devlink_sb_get_rsp_parse;
2709 err = ynl_exec(ys, nlh, &yrs);
2716 devlink_sb_get_rsp_free(rsp);
2720 /* DEVLINK_CMD_SB_GET - dump */
2721 void devlink_sb_get_list_free(struct devlink_sb_get_list *rsp)
2723 struct devlink_sb_get_list *next = rsp;
2725 while ((void *)next != YNL_LIST_END) {
2729 free(rsp->obj.bus_name);
2730 free(rsp->obj.dev_name);
2735 struct devlink_sb_get_list *
2736 devlink_sb_get_dump(struct ynl_sock *ys, struct devlink_sb_get_req_dump *req)
2738 struct ynl_dump_state yds = {};
2739 struct nlmsghdr *nlh;
2743 yds.alloc_sz = sizeof(struct devlink_sb_get_list);
2744 yds.cb = devlink_sb_get_rsp_parse;
2746 yds.rsp_policy = &devlink_nest;
2748 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SB_GET, 1);
2749 ys->req_policy = &devlink_nest;
2751 if (req->_present.bus_name_len)
2752 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2753 if (req->_present.dev_name_len)
2754 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2756 err = ynl_exec_dump(ys, nlh, &yds);
2763 devlink_sb_get_list_free(yds.first);
2767 /* ============== DEVLINK_CMD_SB_POOL_GET ============== */
2768 /* DEVLINK_CMD_SB_POOL_GET - do */
2769 void devlink_sb_pool_get_req_free(struct devlink_sb_pool_get_req *req)
2771 free(req->bus_name);
2772 free(req->dev_name);
2776 void devlink_sb_pool_get_rsp_free(struct devlink_sb_pool_get_rsp *rsp)
2778 free(rsp->bus_name);
2779 free(rsp->dev_name);
2783 int devlink_sb_pool_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
2785 struct devlink_sb_pool_get_rsp *dst;
2786 struct ynl_parse_arg *yarg = data;
2787 const struct nlattr *attr;
2791 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
2792 unsigned int type = mnl_attr_get_type(attr);
2794 if (type == DEVLINK_ATTR_BUS_NAME) {
2797 if (ynl_attr_validate(yarg, attr))
2798 return MNL_CB_ERROR;
2800 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2801 dst->_present.bus_name_len = len;
2802 dst->bus_name = malloc(len + 1);
2803 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
2804 dst->bus_name[len] = 0;
2805 } else if (type == DEVLINK_ATTR_DEV_NAME) {
2808 if (ynl_attr_validate(yarg, attr))
2809 return MNL_CB_ERROR;
2811 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2812 dst->_present.dev_name_len = len;
2813 dst->dev_name = malloc(len + 1);
2814 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
2815 dst->dev_name[len] = 0;
2816 } else if (type == DEVLINK_ATTR_SB_INDEX) {
2817 if (ynl_attr_validate(yarg, attr))
2818 return MNL_CB_ERROR;
2819 dst->_present.sb_index = 1;
2820 dst->sb_index = mnl_attr_get_u32(attr);
2821 } else if (type == DEVLINK_ATTR_SB_POOL_INDEX) {
2822 if (ynl_attr_validate(yarg, attr))
2823 return MNL_CB_ERROR;
2824 dst->_present.sb_pool_index = 1;
2825 dst->sb_pool_index = mnl_attr_get_u16(attr);
2832 struct devlink_sb_pool_get_rsp *
2833 devlink_sb_pool_get(struct ynl_sock *ys, struct devlink_sb_pool_get_req *req)
2835 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
2836 struct devlink_sb_pool_get_rsp *rsp;
2837 struct nlmsghdr *nlh;
2840 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_POOL_GET, 1);
2841 ys->req_policy = &devlink_nest;
2842 yrs.yarg.rsp_policy = &devlink_nest;
2844 if (req->_present.bus_name_len)
2845 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2846 if (req->_present.dev_name_len)
2847 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2848 if (req->_present.sb_index)
2849 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
2850 if (req->_present.sb_pool_index)
2851 mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_POOL_INDEX, req->sb_pool_index);
2853 rsp = calloc(1, sizeof(*rsp));
2854 yrs.yarg.data = rsp;
2855 yrs.cb = devlink_sb_pool_get_rsp_parse;
2858 err = ynl_exec(ys, nlh, &yrs);
2865 devlink_sb_pool_get_rsp_free(rsp);
2869 /* DEVLINK_CMD_SB_POOL_GET - dump */
2870 void devlink_sb_pool_get_list_free(struct devlink_sb_pool_get_list *rsp)
2872 struct devlink_sb_pool_get_list *next = rsp;
2874 while ((void *)next != YNL_LIST_END) {
2878 free(rsp->obj.bus_name);
2879 free(rsp->obj.dev_name);
2884 struct devlink_sb_pool_get_list *
2885 devlink_sb_pool_get_dump(struct ynl_sock *ys,
2886 struct devlink_sb_pool_get_req_dump *req)
2888 struct ynl_dump_state yds = {};
2889 struct nlmsghdr *nlh;
2893 yds.alloc_sz = sizeof(struct devlink_sb_pool_get_list);
2894 yds.cb = devlink_sb_pool_get_rsp_parse;
2896 yds.rsp_policy = &devlink_nest;
2898 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SB_POOL_GET, 1);
2899 ys->req_policy = &devlink_nest;
2901 if (req->_present.bus_name_len)
2902 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2903 if (req->_present.dev_name_len)
2904 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2906 err = ynl_exec_dump(ys, nlh, &yds);
2913 devlink_sb_pool_get_list_free(yds.first);
2917 /* ============== DEVLINK_CMD_SB_POOL_SET ============== */
2918 /* DEVLINK_CMD_SB_POOL_SET - do */
2919 void devlink_sb_pool_set_req_free(struct devlink_sb_pool_set_req *req)
2921 free(req->bus_name);
2922 free(req->dev_name);
2926 int devlink_sb_pool_set(struct ynl_sock *ys,
2927 struct devlink_sb_pool_set_req *req)
2929 struct nlmsghdr *nlh;
2932 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_POOL_SET, 1);
2933 ys->req_policy = &devlink_nest;
2935 if (req->_present.bus_name_len)
2936 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
2937 if (req->_present.dev_name_len)
2938 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
2939 if (req->_present.sb_index)
2940 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
2941 if (req->_present.sb_pool_index)
2942 mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_POOL_INDEX, req->sb_pool_index);
2943 if (req->_present.sb_pool_threshold_type)
2944 mnl_attr_put_u8(nlh, DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE, req->sb_pool_threshold_type);
2945 if (req->_present.sb_pool_size)
2946 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_POOL_SIZE, req->sb_pool_size);
2948 err = ynl_exec(ys, nlh, NULL);
2955 /* ============== DEVLINK_CMD_SB_PORT_POOL_GET ============== */
2956 /* DEVLINK_CMD_SB_PORT_POOL_GET - do */
2958 devlink_sb_port_pool_get_req_free(struct devlink_sb_port_pool_get_req *req)
2960 free(req->bus_name);
2961 free(req->dev_name);
2966 devlink_sb_port_pool_get_rsp_free(struct devlink_sb_port_pool_get_rsp *rsp)
2968 free(rsp->bus_name);
2969 free(rsp->dev_name);
2973 int devlink_sb_port_pool_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
2975 struct devlink_sb_port_pool_get_rsp *dst;
2976 struct ynl_parse_arg *yarg = data;
2977 const struct nlattr *attr;
2981 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
2982 unsigned int type = mnl_attr_get_type(attr);
2984 if (type == DEVLINK_ATTR_BUS_NAME) {
2987 if (ynl_attr_validate(yarg, attr))
2988 return MNL_CB_ERROR;
2990 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
2991 dst->_present.bus_name_len = len;
2992 dst->bus_name = malloc(len + 1);
2993 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
2994 dst->bus_name[len] = 0;
2995 } else if (type == DEVLINK_ATTR_DEV_NAME) {
2998 if (ynl_attr_validate(yarg, attr))
2999 return MNL_CB_ERROR;
3001 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3002 dst->_present.dev_name_len = len;
3003 dst->dev_name = malloc(len + 1);
3004 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
3005 dst->dev_name[len] = 0;
3006 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
3007 if (ynl_attr_validate(yarg, attr))
3008 return MNL_CB_ERROR;
3009 dst->_present.port_index = 1;
3010 dst->port_index = mnl_attr_get_u32(attr);
3011 } else if (type == DEVLINK_ATTR_SB_INDEX) {
3012 if (ynl_attr_validate(yarg, attr))
3013 return MNL_CB_ERROR;
3014 dst->_present.sb_index = 1;
3015 dst->sb_index = mnl_attr_get_u32(attr);
3016 } else if (type == DEVLINK_ATTR_SB_POOL_INDEX) {
3017 if (ynl_attr_validate(yarg, attr))
3018 return MNL_CB_ERROR;
3019 dst->_present.sb_pool_index = 1;
3020 dst->sb_pool_index = mnl_attr_get_u16(attr);
3027 struct devlink_sb_port_pool_get_rsp *
3028 devlink_sb_port_pool_get(struct ynl_sock *ys,
3029 struct devlink_sb_port_pool_get_req *req)
3031 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
3032 struct devlink_sb_port_pool_get_rsp *rsp;
3033 struct nlmsghdr *nlh;
3036 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_PORT_POOL_GET, 1);
3037 ys->req_policy = &devlink_nest;
3038 yrs.yarg.rsp_policy = &devlink_nest;
3040 if (req->_present.bus_name_len)
3041 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3042 if (req->_present.dev_name_len)
3043 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3044 if (req->_present.port_index)
3045 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
3046 if (req->_present.sb_index)
3047 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
3048 if (req->_present.sb_pool_index)
3049 mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_POOL_INDEX, req->sb_pool_index);
3051 rsp = calloc(1, sizeof(*rsp));
3052 yrs.yarg.data = rsp;
3053 yrs.cb = devlink_sb_port_pool_get_rsp_parse;
3056 err = ynl_exec(ys, nlh, &yrs);
3063 devlink_sb_port_pool_get_rsp_free(rsp);
3067 /* DEVLINK_CMD_SB_PORT_POOL_GET - dump */
3069 devlink_sb_port_pool_get_list_free(struct devlink_sb_port_pool_get_list *rsp)
3071 struct devlink_sb_port_pool_get_list *next = rsp;
3073 while ((void *)next != YNL_LIST_END) {
3077 free(rsp->obj.bus_name);
3078 free(rsp->obj.dev_name);
3083 struct devlink_sb_port_pool_get_list *
3084 devlink_sb_port_pool_get_dump(struct ynl_sock *ys,
3085 struct devlink_sb_port_pool_get_req_dump *req)
3087 struct ynl_dump_state yds = {};
3088 struct nlmsghdr *nlh;
3092 yds.alloc_sz = sizeof(struct devlink_sb_port_pool_get_list);
3093 yds.cb = devlink_sb_port_pool_get_rsp_parse;
3095 yds.rsp_policy = &devlink_nest;
3097 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SB_PORT_POOL_GET, 1);
3098 ys->req_policy = &devlink_nest;
3100 if (req->_present.bus_name_len)
3101 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3102 if (req->_present.dev_name_len)
3103 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3105 err = ynl_exec_dump(ys, nlh, &yds);
3112 devlink_sb_port_pool_get_list_free(yds.first);
3116 /* ============== DEVLINK_CMD_SB_PORT_POOL_SET ============== */
3117 /* DEVLINK_CMD_SB_PORT_POOL_SET - do */
3119 devlink_sb_port_pool_set_req_free(struct devlink_sb_port_pool_set_req *req)
3121 free(req->bus_name);
3122 free(req->dev_name);
3126 int devlink_sb_port_pool_set(struct ynl_sock *ys,
3127 struct devlink_sb_port_pool_set_req *req)
3129 struct nlmsghdr *nlh;
3132 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_PORT_POOL_SET, 1);
3133 ys->req_policy = &devlink_nest;
3135 if (req->_present.bus_name_len)
3136 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3137 if (req->_present.dev_name_len)
3138 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3139 if (req->_present.port_index)
3140 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
3141 if (req->_present.sb_index)
3142 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
3143 if (req->_present.sb_pool_index)
3144 mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_POOL_INDEX, req->sb_pool_index);
3145 if (req->_present.sb_threshold)
3146 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_THRESHOLD, req->sb_threshold);
3148 err = ynl_exec(ys, nlh, NULL);
3155 /* ============== DEVLINK_CMD_SB_TC_POOL_BIND_GET ============== */
3156 /* DEVLINK_CMD_SB_TC_POOL_BIND_GET - do */
3158 devlink_sb_tc_pool_bind_get_req_free(struct devlink_sb_tc_pool_bind_get_req *req)
3160 free(req->bus_name);
3161 free(req->dev_name);
3166 devlink_sb_tc_pool_bind_get_rsp_free(struct devlink_sb_tc_pool_bind_get_rsp *rsp)
3168 free(rsp->bus_name);
3169 free(rsp->dev_name);
3173 int devlink_sb_tc_pool_bind_get_rsp_parse(const struct nlmsghdr *nlh,
3176 struct devlink_sb_tc_pool_bind_get_rsp *dst;
3177 struct ynl_parse_arg *yarg = data;
3178 const struct nlattr *attr;
3182 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
3183 unsigned int type = mnl_attr_get_type(attr);
3185 if (type == DEVLINK_ATTR_BUS_NAME) {
3188 if (ynl_attr_validate(yarg, attr))
3189 return MNL_CB_ERROR;
3191 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3192 dst->_present.bus_name_len = len;
3193 dst->bus_name = malloc(len + 1);
3194 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
3195 dst->bus_name[len] = 0;
3196 } else if (type == DEVLINK_ATTR_DEV_NAME) {
3199 if (ynl_attr_validate(yarg, attr))
3200 return MNL_CB_ERROR;
3202 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3203 dst->_present.dev_name_len = len;
3204 dst->dev_name = malloc(len + 1);
3205 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
3206 dst->dev_name[len] = 0;
3207 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
3208 if (ynl_attr_validate(yarg, attr))
3209 return MNL_CB_ERROR;
3210 dst->_present.port_index = 1;
3211 dst->port_index = mnl_attr_get_u32(attr);
3212 } else if (type == DEVLINK_ATTR_SB_INDEX) {
3213 if (ynl_attr_validate(yarg, attr))
3214 return MNL_CB_ERROR;
3215 dst->_present.sb_index = 1;
3216 dst->sb_index = mnl_attr_get_u32(attr);
3217 } else if (type == DEVLINK_ATTR_SB_POOL_TYPE) {
3218 if (ynl_attr_validate(yarg, attr))
3219 return MNL_CB_ERROR;
3220 dst->_present.sb_pool_type = 1;
3221 dst->sb_pool_type = mnl_attr_get_u8(attr);
3222 } else if (type == DEVLINK_ATTR_SB_TC_INDEX) {
3223 if (ynl_attr_validate(yarg, attr))
3224 return MNL_CB_ERROR;
3225 dst->_present.sb_tc_index = 1;
3226 dst->sb_tc_index = mnl_attr_get_u16(attr);
3233 struct devlink_sb_tc_pool_bind_get_rsp *
3234 devlink_sb_tc_pool_bind_get(struct ynl_sock *ys,
3235 struct devlink_sb_tc_pool_bind_get_req *req)
3237 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
3238 struct devlink_sb_tc_pool_bind_get_rsp *rsp;
3239 struct nlmsghdr *nlh;
3242 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_TC_POOL_BIND_GET, 1);
3243 ys->req_policy = &devlink_nest;
3244 yrs.yarg.rsp_policy = &devlink_nest;
3246 if (req->_present.bus_name_len)
3247 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3248 if (req->_present.dev_name_len)
3249 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3250 if (req->_present.port_index)
3251 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
3252 if (req->_present.sb_index)
3253 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
3254 if (req->_present.sb_pool_type)
3255 mnl_attr_put_u8(nlh, DEVLINK_ATTR_SB_POOL_TYPE, req->sb_pool_type);
3256 if (req->_present.sb_tc_index)
3257 mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_TC_INDEX, req->sb_tc_index);
3259 rsp = calloc(1, sizeof(*rsp));
3260 yrs.yarg.data = rsp;
3261 yrs.cb = devlink_sb_tc_pool_bind_get_rsp_parse;
3264 err = ynl_exec(ys, nlh, &yrs);
3271 devlink_sb_tc_pool_bind_get_rsp_free(rsp);
3275 /* DEVLINK_CMD_SB_TC_POOL_BIND_GET - dump */
3277 devlink_sb_tc_pool_bind_get_list_free(struct devlink_sb_tc_pool_bind_get_list *rsp)
3279 struct devlink_sb_tc_pool_bind_get_list *next = rsp;
3281 while ((void *)next != YNL_LIST_END) {
3285 free(rsp->obj.bus_name);
3286 free(rsp->obj.dev_name);
3291 struct devlink_sb_tc_pool_bind_get_list *
3292 devlink_sb_tc_pool_bind_get_dump(struct ynl_sock *ys,
3293 struct devlink_sb_tc_pool_bind_get_req_dump *req)
3295 struct ynl_dump_state yds = {};
3296 struct nlmsghdr *nlh;
3300 yds.alloc_sz = sizeof(struct devlink_sb_tc_pool_bind_get_list);
3301 yds.cb = devlink_sb_tc_pool_bind_get_rsp_parse;
3303 yds.rsp_policy = &devlink_nest;
3305 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SB_TC_POOL_BIND_GET, 1);
3306 ys->req_policy = &devlink_nest;
3308 if (req->_present.bus_name_len)
3309 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3310 if (req->_present.dev_name_len)
3311 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3313 err = ynl_exec_dump(ys, nlh, &yds);
3320 devlink_sb_tc_pool_bind_get_list_free(yds.first);
3324 /* ============== DEVLINK_CMD_SB_TC_POOL_BIND_SET ============== */
3325 /* DEVLINK_CMD_SB_TC_POOL_BIND_SET - do */
3327 devlink_sb_tc_pool_bind_set_req_free(struct devlink_sb_tc_pool_bind_set_req *req)
3329 free(req->bus_name);
3330 free(req->dev_name);
3334 int devlink_sb_tc_pool_bind_set(struct ynl_sock *ys,
3335 struct devlink_sb_tc_pool_bind_set_req *req)
3337 struct nlmsghdr *nlh;
3340 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_TC_POOL_BIND_SET, 1);
3341 ys->req_policy = &devlink_nest;
3343 if (req->_present.bus_name_len)
3344 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3345 if (req->_present.dev_name_len)
3346 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3347 if (req->_present.port_index)
3348 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
3349 if (req->_present.sb_index)
3350 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
3351 if (req->_present.sb_pool_index)
3352 mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_POOL_INDEX, req->sb_pool_index);
3353 if (req->_present.sb_pool_type)
3354 mnl_attr_put_u8(nlh, DEVLINK_ATTR_SB_POOL_TYPE, req->sb_pool_type);
3355 if (req->_present.sb_tc_index)
3356 mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_TC_INDEX, req->sb_tc_index);
3357 if (req->_present.sb_threshold)
3358 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_THRESHOLD, req->sb_threshold);
3360 err = ynl_exec(ys, nlh, NULL);
3367 /* ============== DEVLINK_CMD_SB_OCC_SNAPSHOT ============== */
3368 /* DEVLINK_CMD_SB_OCC_SNAPSHOT - do */
3369 void devlink_sb_occ_snapshot_req_free(struct devlink_sb_occ_snapshot_req *req)
3371 free(req->bus_name);
3372 free(req->dev_name);
3376 int devlink_sb_occ_snapshot(struct ynl_sock *ys,
3377 struct devlink_sb_occ_snapshot_req *req)
3379 struct nlmsghdr *nlh;
3382 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_OCC_SNAPSHOT, 1);
3383 ys->req_policy = &devlink_nest;
3385 if (req->_present.bus_name_len)
3386 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3387 if (req->_present.dev_name_len)
3388 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3389 if (req->_present.sb_index)
3390 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
3392 err = ynl_exec(ys, nlh, NULL);
3399 /* ============== DEVLINK_CMD_SB_OCC_MAX_CLEAR ============== */
3400 /* DEVLINK_CMD_SB_OCC_MAX_CLEAR - do */
3402 devlink_sb_occ_max_clear_req_free(struct devlink_sb_occ_max_clear_req *req)
3404 free(req->bus_name);
3405 free(req->dev_name);
3409 int devlink_sb_occ_max_clear(struct ynl_sock *ys,
3410 struct devlink_sb_occ_max_clear_req *req)
3412 struct nlmsghdr *nlh;
3415 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_OCC_MAX_CLEAR, 1);
3416 ys->req_policy = &devlink_nest;
3418 if (req->_present.bus_name_len)
3419 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3420 if (req->_present.dev_name_len)
3421 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3422 if (req->_present.sb_index)
3423 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
3425 err = ynl_exec(ys, nlh, NULL);
3432 /* ============== DEVLINK_CMD_ESWITCH_GET ============== */
3433 /* DEVLINK_CMD_ESWITCH_GET - do */
3434 void devlink_eswitch_get_req_free(struct devlink_eswitch_get_req *req)
3436 free(req->bus_name);
3437 free(req->dev_name);
3441 void devlink_eswitch_get_rsp_free(struct devlink_eswitch_get_rsp *rsp)
3443 free(rsp->bus_name);
3444 free(rsp->dev_name);
3448 int devlink_eswitch_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
3450 struct devlink_eswitch_get_rsp *dst;
3451 struct ynl_parse_arg *yarg = data;
3452 const struct nlattr *attr;
3456 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
3457 unsigned int type = mnl_attr_get_type(attr);
3459 if (type == DEVLINK_ATTR_BUS_NAME) {
3462 if (ynl_attr_validate(yarg, attr))
3463 return MNL_CB_ERROR;
3465 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3466 dst->_present.bus_name_len = len;
3467 dst->bus_name = malloc(len + 1);
3468 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
3469 dst->bus_name[len] = 0;
3470 } else if (type == DEVLINK_ATTR_DEV_NAME) {
3473 if (ynl_attr_validate(yarg, attr))
3474 return MNL_CB_ERROR;
3476 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3477 dst->_present.dev_name_len = len;
3478 dst->dev_name = malloc(len + 1);
3479 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
3480 dst->dev_name[len] = 0;
3481 } else if (type == DEVLINK_ATTR_ESWITCH_MODE) {
3482 if (ynl_attr_validate(yarg, attr))
3483 return MNL_CB_ERROR;
3484 dst->_present.eswitch_mode = 1;
3485 dst->eswitch_mode = mnl_attr_get_u16(attr);
3486 } else if (type == DEVLINK_ATTR_ESWITCH_INLINE_MODE) {
3487 if (ynl_attr_validate(yarg, attr))
3488 return MNL_CB_ERROR;
3489 dst->_present.eswitch_inline_mode = 1;
3490 dst->eswitch_inline_mode = mnl_attr_get_u16(attr);
3491 } else if (type == DEVLINK_ATTR_ESWITCH_ENCAP_MODE) {
3492 if (ynl_attr_validate(yarg, attr))
3493 return MNL_CB_ERROR;
3494 dst->_present.eswitch_encap_mode = 1;
3495 dst->eswitch_encap_mode = mnl_attr_get_u8(attr);
3502 struct devlink_eswitch_get_rsp *
3503 devlink_eswitch_get(struct ynl_sock *ys, struct devlink_eswitch_get_req *req)
3505 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
3506 struct devlink_eswitch_get_rsp *rsp;
3507 struct nlmsghdr *nlh;
3510 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_ESWITCH_GET, 1);
3511 ys->req_policy = &devlink_nest;
3512 yrs.yarg.rsp_policy = &devlink_nest;
3514 if (req->_present.bus_name_len)
3515 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3516 if (req->_present.dev_name_len)
3517 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3519 rsp = calloc(1, sizeof(*rsp));
3520 yrs.yarg.data = rsp;
3521 yrs.cb = devlink_eswitch_get_rsp_parse;
3522 yrs.rsp_cmd = DEVLINK_CMD_ESWITCH_GET;
3524 err = ynl_exec(ys, nlh, &yrs);
3531 devlink_eswitch_get_rsp_free(rsp);
3535 /* ============== DEVLINK_CMD_ESWITCH_SET ============== */
3536 /* DEVLINK_CMD_ESWITCH_SET - do */
3537 void devlink_eswitch_set_req_free(struct devlink_eswitch_set_req *req)
3539 free(req->bus_name);
3540 free(req->dev_name);
3544 int devlink_eswitch_set(struct ynl_sock *ys,
3545 struct devlink_eswitch_set_req *req)
3547 struct nlmsghdr *nlh;
3550 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_ESWITCH_SET, 1);
3551 ys->req_policy = &devlink_nest;
3553 if (req->_present.bus_name_len)
3554 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3555 if (req->_present.dev_name_len)
3556 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3557 if (req->_present.eswitch_mode)
3558 mnl_attr_put_u16(nlh, DEVLINK_ATTR_ESWITCH_MODE, req->eswitch_mode);
3559 if (req->_present.eswitch_inline_mode)
3560 mnl_attr_put_u16(nlh, DEVLINK_ATTR_ESWITCH_INLINE_MODE, req->eswitch_inline_mode);
3561 if (req->_present.eswitch_encap_mode)
3562 mnl_attr_put_u8(nlh, DEVLINK_ATTR_ESWITCH_ENCAP_MODE, req->eswitch_encap_mode);
3564 err = ynl_exec(ys, nlh, NULL);
3571 /* ============== DEVLINK_CMD_DPIPE_TABLE_GET ============== */
3572 /* DEVLINK_CMD_DPIPE_TABLE_GET - do */
3573 void devlink_dpipe_table_get_req_free(struct devlink_dpipe_table_get_req *req)
3575 free(req->bus_name);
3576 free(req->dev_name);
3577 free(req->dpipe_table_name);
3581 void devlink_dpipe_table_get_rsp_free(struct devlink_dpipe_table_get_rsp *rsp)
3583 free(rsp->bus_name);
3584 free(rsp->dev_name);
3585 devlink_dl_dpipe_tables_free(&rsp->dpipe_tables);
3589 int devlink_dpipe_table_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
3591 struct devlink_dpipe_table_get_rsp *dst;
3592 struct ynl_parse_arg *yarg = data;
3593 const struct nlattr *attr;
3594 struct ynl_parse_arg parg;
3599 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
3600 unsigned int type = mnl_attr_get_type(attr);
3602 if (type == DEVLINK_ATTR_BUS_NAME) {
3605 if (ynl_attr_validate(yarg, attr))
3606 return MNL_CB_ERROR;
3608 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3609 dst->_present.bus_name_len = len;
3610 dst->bus_name = malloc(len + 1);
3611 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
3612 dst->bus_name[len] = 0;
3613 } else if (type == DEVLINK_ATTR_DEV_NAME) {
3616 if (ynl_attr_validate(yarg, attr))
3617 return MNL_CB_ERROR;
3619 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3620 dst->_present.dev_name_len = len;
3621 dst->dev_name = malloc(len + 1);
3622 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
3623 dst->dev_name[len] = 0;
3624 } else if (type == DEVLINK_ATTR_DPIPE_TABLES) {
3625 if (ynl_attr_validate(yarg, attr))
3626 return MNL_CB_ERROR;
3627 dst->_present.dpipe_tables = 1;
3629 parg.rsp_policy = &devlink_dl_dpipe_tables_nest;
3630 parg.data = &dst->dpipe_tables;
3631 if (devlink_dl_dpipe_tables_parse(&parg, attr))
3632 return MNL_CB_ERROR;
3639 struct devlink_dpipe_table_get_rsp *
3640 devlink_dpipe_table_get(struct ynl_sock *ys,
3641 struct devlink_dpipe_table_get_req *req)
3643 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
3644 struct devlink_dpipe_table_get_rsp *rsp;
3645 struct nlmsghdr *nlh;
3648 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_DPIPE_TABLE_GET, 1);
3649 ys->req_policy = &devlink_nest;
3650 yrs.yarg.rsp_policy = &devlink_nest;
3652 if (req->_present.bus_name_len)
3653 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3654 if (req->_present.dev_name_len)
3655 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3656 if (req->_present.dpipe_table_name_len)
3657 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DPIPE_TABLE_NAME, req->dpipe_table_name);
3659 rsp = calloc(1, sizeof(*rsp));
3660 yrs.yarg.data = rsp;
3661 yrs.cb = devlink_dpipe_table_get_rsp_parse;
3662 yrs.rsp_cmd = DEVLINK_CMD_DPIPE_TABLE_GET;
3664 err = ynl_exec(ys, nlh, &yrs);
3671 devlink_dpipe_table_get_rsp_free(rsp);
3675 /* ============== DEVLINK_CMD_DPIPE_ENTRIES_GET ============== */
3676 /* DEVLINK_CMD_DPIPE_ENTRIES_GET - do */
3678 devlink_dpipe_entries_get_req_free(struct devlink_dpipe_entries_get_req *req)
3680 free(req->bus_name);
3681 free(req->dev_name);
3682 free(req->dpipe_table_name);
3687 devlink_dpipe_entries_get_rsp_free(struct devlink_dpipe_entries_get_rsp *rsp)
3689 free(rsp->bus_name);
3690 free(rsp->dev_name);
3691 devlink_dl_dpipe_entries_free(&rsp->dpipe_entries);
3695 int devlink_dpipe_entries_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
3697 struct devlink_dpipe_entries_get_rsp *dst;
3698 struct ynl_parse_arg *yarg = data;
3699 const struct nlattr *attr;
3700 struct ynl_parse_arg parg;
3705 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
3706 unsigned int type = mnl_attr_get_type(attr);
3708 if (type == DEVLINK_ATTR_BUS_NAME) {
3711 if (ynl_attr_validate(yarg, attr))
3712 return MNL_CB_ERROR;
3714 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3715 dst->_present.bus_name_len = len;
3716 dst->bus_name = malloc(len + 1);
3717 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
3718 dst->bus_name[len] = 0;
3719 } else if (type == DEVLINK_ATTR_DEV_NAME) {
3722 if (ynl_attr_validate(yarg, attr))
3723 return MNL_CB_ERROR;
3725 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3726 dst->_present.dev_name_len = len;
3727 dst->dev_name = malloc(len + 1);
3728 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
3729 dst->dev_name[len] = 0;
3730 } else if (type == DEVLINK_ATTR_DPIPE_ENTRIES) {
3731 if (ynl_attr_validate(yarg, attr))
3732 return MNL_CB_ERROR;
3733 dst->_present.dpipe_entries = 1;
3735 parg.rsp_policy = &devlink_dl_dpipe_entries_nest;
3736 parg.data = &dst->dpipe_entries;
3737 if (devlink_dl_dpipe_entries_parse(&parg, attr))
3738 return MNL_CB_ERROR;
3745 struct devlink_dpipe_entries_get_rsp *
3746 devlink_dpipe_entries_get(struct ynl_sock *ys,
3747 struct devlink_dpipe_entries_get_req *req)
3749 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
3750 struct devlink_dpipe_entries_get_rsp *rsp;
3751 struct nlmsghdr *nlh;
3754 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_DPIPE_ENTRIES_GET, 1);
3755 ys->req_policy = &devlink_nest;
3756 yrs.yarg.rsp_policy = &devlink_nest;
3758 if (req->_present.bus_name_len)
3759 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3760 if (req->_present.dev_name_len)
3761 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3762 if (req->_present.dpipe_table_name_len)
3763 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DPIPE_TABLE_NAME, req->dpipe_table_name);
3765 rsp = calloc(1, sizeof(*rsp));
3766 yrs.yarg.data = rsp;
3767 yrs.cb = devlink_dpipe_entries_get_rsp_parse;
3768 yrs.rsp_cmd = DEVLINK_CMD_DPIPE_ENTRIES_GET;
3770 err = ynl_exec(ys, nlh, &yrs);
3777 devlink_dpipe_entries_get_rsp_free(rsp);
3781 /* ============== DEVLINK_CMD_DPIPE_HEADERS_GET ============== */
3782 /* DEVLINK_CMD_DPIPE_HEADERS_GET - do */
3784 devlink_dpipe_headers_get_req_free(struct devlink_dpipe_headers_get_req *req)
3786 free(req->bus_name);
3787 free(req->dev_name);
3792 devlink_dpipe_headers_get_rsp_free(struct devlink_dpipe_headers_get_rsp *rsp)
3794 free(rsp->bus_name);
3795 free(rsp->dev_name);
3796 devlink_dl_dpipe_headers_free(&rsp->dpipe_headers);
3800 int devlink_dpipe_headers_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
3802 struct devlink_dpipe_headers_get_rsp *dst;
3803 struct ynl_parse_arg *yarg = data;
3804 const struct nlattr *attr;
3805 struct ynl_parse_arg parg;
3810 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
3811 unsigned int type = mnl_attr_get_type(attr);
3813 if (type == DEVLINK_ATTR_BUS_NAME) {
3816 if (ynl_attr_validate(yarg, attr))
3817 return MNL_CB_ERROR;
3819 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3820 dst->_present.bus_name_len = len;
3821 dst->bus_name = malloc(len + 1);
3822 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
3823 dst->bus_name[len] = 0;
3824 } else if (type == DEVLINK_ATTR_DEV_NAME) {
3827 if (ynl_attr_validate(yarg, attr))
3828 return MNL_CB_ERROR;
3830 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3831 dst->_present.dev_name_len = len;
3832 dst->dev_name = malloc(len + 1);
3833 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
3834 dst->dev_name[len] = 0;
3835 } else if (type == DEVLINK_ATTR_DPIPE_HEADERS) {
3836 if (ynl_attr_validate(yarg, attr))
3837 return MNL_CB_ERROR;
3838 dst->_present.dpipe_headers = 1;
3840 parg.rsp_policy = &devlink_dl_dpipe_headers_nest;
3841 parg.data = &dst->dpipe_headers;
3842 if (devlink_dl_dpipe_headers_parse(&parg, attr))
3843 return MNL_CB_ERROR;
3850 struct devlink_dpipe_headers_get_rsp *
3851 devlink_dpipe_headers_get(struct ynl_sock *ys,
3852 struct devlink_dpipe_headers_get_req *req)
3854 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
3855 struct devlink_dpipe_headers_get_rsp *rsp;
3856 struct nlmsghdr *nlh;
3859 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_DPIPE_HEADERS_GET, 1);
3860 ys->req_policy = &devlink_nest;
3861 yrs.yarg.rsp_policy = &devlink_nest;
3863 if (req->_present.bus_name_len)
3864 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3865 if (req->_present.dev_name_len)
3866 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3868 rsp = calloc(1, sizeof(*rsp));
3869 yrs.yarg.data = rsp;
3870 yrs.cb = devlink_dpipe_headers_get_rsp_parse;
3871 yrs.rsp_cmd = DEVLINK_CMD_DPIPE_HEADERS_GET;
3873 err = ynl_exec(ys, nlh, &yrs);
3880 devlink_dpipe_headers_get_rsp_free(rsp);
3884 /* ============== DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET ============== */
3885 /* DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET - do */
3887 devlink_dpipe_table_counters_set_req_free(struct devlink_dpipe_table_counters_set_req *req)
3889 free(req->bus_name);
3890 free(req->dev_name);
3891 free(req->dpipe_table_name);
3895 int devlink_dpipe_table_counters_set(struct ynl_sock *ys,
3896 struct devlink_dpipe_table_counters_set_req *req)
3898 struct nlmsghdr *nlh;
3901 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET, 1);
3902 ys->req_policy = &devlink_nest;
3904 if (req->_present.bus_name_len)
3905 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3906 if (req->_present.dev_name_len)
3907 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3908 if (req->_present.dpipe_table_name_len)
3909 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DPIPE_TABLE_NAME, req->dpipe_table_name);
3910 if (req->_present.dpipe_table_counters_enabled)
3911 mnl_attr_put_u8(nlh, DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED, req->dpipe_table_counters_enabled);
3913 err = ynl_exec(ys, nlh, NULL);
3920 /* ============== DEVLINK_CMD_RESOURCE_SET ============== */
3921 /* DEVLINK_CMD_RESOURCE_SET - do */
3922 void devlink_resource_set_req_free(struct devlink_resource_set_req *req)
3924 free(req->bus_name);
3925 free(req->dev_name);
3929 int devlink_resource_set(struct ynl_sock *ys,
3930 struct devlink_resource_set_req *req)
3932 struct nlmsghdr *nlh;
3935 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_RESOURCE_SET, 1);
3936 ys->req_policy = &devlink_nest;
3938 if (req->_present.bus_name_len)
3939 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
3940 if (req->_present.dev_name_len)
3941 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
3942 if (req->_present.resource_id)
3943 mnl_attr_put_u64(nlh, DEVLINK_ATTR_RESOURCE_ID, req->resource_id);
3944 if (req->_present.resource_size)
3945 mnl_attr_put_u64(nlh, DEVLINK_ATTR_RESOURCE_SIZE, req->resource_size);
3947 err = ynl_exec(ys, nlh, NULL);
3954 /* ============== DEVLINK_CMD_RESOURCE_DUMP ============== */
3955 /* DEVLINK_CMD_RESOURCE_DUMP - do */
3956 void devlink_resource_dump_req_free(struct devlink_resource_dump_req *req)
3958 free(req->bus_name);
3959 free(req->dev_name);
3963 void devlink_resource_dump_rsp_free(struct devlink_resource_dump_rsp *rsp)
3965 free(rsp->bus_name);
3966 free(rsp->dev_name);
3967 devlink_dl_resource_list_free(&rsp->resource_list);
3971 int devlink_resource_dump_rsp_parse(const struct nlmsghdr *nlh, void *data)
3973 struct devlink_resource_dump_rsp *dst;
3974 struct ynl_parse_arg *yarg = data;
3975 const struct nlattr *attr;
3976 struct ynl_parse_arg parg;
3981 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
3982 unsigned int type = mnl_attr_get_type(attr);
3984 if (type == DEVLINK_ATTR_BUS_NAME) {
3987 if (ynl_attr_validate(yarg, attr))
3988 return MNL_CB_ERROR;
3990 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
3991 dst->_present.bus_name_len = len;
3992 dst->bus_name = malloc(len + 1);
3993 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
3994 dst->bus_name[len] = 0;
3995 } else if (type == DEVLINK_ATTR_DEV_NAME) {
3998 if (ynl_attr_validate(yarg, attr))
3999 return MNL_CB_ERROR;
4001 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4002 dst->_present.dev_name_len = len;
4003 dst->dev_name = malloc(len + 1);
4004 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
4005 dst->dev_name[len] = 0;
4006 } else if (type == DEVLINK_ATTR_RESOURCE_LIST) {
4007 if (ynl_attr_validate(yarg, attr))
4008 return MNL_CB_ERROR;
4009 dst->_present.resource_list = 1;
4011 parg.rsp_policy = &devlink_dl_resource_list_nest;
4012 parg.data = &dst->resource_list;
4013 if (devlink_dl_resource_list_parse(&parg, attr))
4014 return MNL_CB_ERROR;
4021 struct devlink_resource_dump_rsp *
4022 devlink_resource_dump(struct ynl_sock *ys,
4023 struct devlink_resource_dump_req *req)
4025 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
4026 struct devlink_resource_dump_rsp *rsp;
4027 struct nlmsghdr *nlh;
4030 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_RESOURCE_DUMP, 1);
4031 ys->req_policy = &devlink_nest;
4032 yrs.yarg.rsp_policy = &devlink_nest;
4034 if (req->_present.bus_name_len)
4035 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4036 if (req->_present.dev_name_len)
4037 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4039 rsp = calloc(1, sizeof(*rsp));
4040 yrs.yarg.data = rsp;
4041 yrs.cb = devlink_resource_dump_rsp_parse;
4042 yrs.rsp_cmd = DEVLINK_CMD_RESOURCE_DUMP;
4044 err = ynl_exec(ys, nlh, &yrs);
4051 devlink_resource_dump_rsp_free(rsp);
4055 /* ============== DEVLINK_CMD_RELOAD ============== */
4056 /* DEVLINK_CMD_RELOAD - do */
4057 void devlink_reload_req_free(struct devlink_reload_req *req)
4059 free(req->bus_name);
4060 free(req->dev_name);
4064 void devlink_reload_rsp_free(struct devlink_reload_rsp *rsp)
4066 free(rsp->bus_name);
4067 free(rsp->dev_name);
4071 int devlink_reload_rsp_parse(const struct nlmsghdr *nlh, void *data)
4073 struct ynl_parse_arg *yarg = data;
4074 struct devlink_reload_rsp *dst;
4075 const struct nlattr *attr;
4079 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
4080 unsigned int type = mnl_attr_get_type(attr);
4082 if (type == DEVLINK_ATTR_BUS_NAME) {
4085 if (ynl_attr_validate(yarg, attr))
4086 return MNL_CB_ERROR;
4088 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4089 dst->_present.bus_name_len = len;
4090 dst->bus_name = malloc(len + 1);
4091 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
4092 dst->bus_name[len] = 0;
4093 } else if (type == DEVLINK_ATTR_DEV_NAME) {
4096 if (ynl_attr_validate(yarg, attr))
4097 return MNL_CB_ERROR;
4099 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4100 dst->_present.dev_name_len = len;
4101 dst->dev_name = malloc(len + 1);
4102 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
4103 dst->dev_name[len] = 0;
4104 } else if (type == DEVLINK_ATTR_RELOAD_ACTIONS_PERFORMED) {
4105 if (ynl_attr_validate(yarg, attr))
4106 return MNL_CB_ERROR;
4107 dst->_present.reload_actions_performed = 1;
4108 memcpy(&dst->reload_actions_performed, mnl_attr_get_payload(attr), sizeof(struct nla_bitfield32));
4115 struct devlink_reload_rsp *
4116 devlink_reload(struct ynl_sock *ys, struct devlink_reload_req *req)
4118 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
4119 struct devlink_reload_rsp *rsp;
4120 struct nlmsghdr *nlh;
4123 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_RELOAD, 1);
4124 ys->req_policy = &devlink_nest;
4125 yrs.yarg.rsp_policy = &devlink_nest;
4127 if (req->_present.bus_name_len)
4128 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4129 if (req->_present.dev_name_len)
4130 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4131 if (req->_present.reload_action)
4132 mnl_attr_put_u8(nlh, DEVLINK_ATTR_RELOAD_ACTION, req->reload_action);
4133 if (req->_present.reload_limits)
4134 mnl_attr_put(nlh, DEVLINK_ATTR_RELOAD_LIMITS, sizeof(struct nla_bitfield32), &req->reload_limits);
4135 if (req->_present.netns_pid)
4136 mnl_attr_put_u32(nlh, DEVLINK_ATTR_NETNS_PID, req->netns_pid);
4137 if (req->_present.netns_fd)
4138 mnl_attr_put_u32(nlh, DEVLINK_ATTR_NETNS_FD, req->netns_fd);
4139 if (req->_present.netns_id)
4140 mnl_attr_put_u32(nlh, DEVLINK_ATTR_NETNS_ID, req->netns_id);
4142 rsp = calloc(1, sizeof(*rsp));
4143 yrs.yarg.data = rsp;
4144 yrs.cb = devlink_reload_rsp_parse;
4145 yrs.rsp_cmd = DEVLINK_CMD_RELOAD;
4147 err = ynl_exec(ys, nlh, &yrs);
4154 devlink_reload_rsp_free(rsp);
4158 /* ============== DEVLINK_CMD_PARAM_GET ============== */
4159 /* DEVLINK_CMD_PARAM_GET - do */
4160 void devlink_param_get_req_free(struct devlink_param_get_req *req)
4162 free(req->bus_name);
4163 free(req->dev_name);
4164 free(req->param_name);
4168 void devlink_param_get_rsp_free(struct devlink_param_get_rsp *rsp)
4170 free(rsp->bus_name);
4171 free(rsp->dev_name);
4172 free(rsp->param_name);
4176 int devlink_param_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
4178 struct devlink_param_get_rsp *dst;
4179 struct ynl_parse_arg *yarg = data;
4180 const struct nlattr *attr;
4184 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
4185 unsigned int type = mnl_attr_get_type(attr);
4187 if (type == DEVLINK_ATTR_BUS_NAME) {
4190 if (ynl_attr_validate(yarg, attr))
4191 return MNL_CB_ERROR;
4193 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4194 dst->_present.bus_name_len = len;
4195 dst->bus_name = malloc(len + 1);
4196 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
4197 dst->bus_name[len] = 0;
4198 } else if (type == DEVLINK_ATTR_DEV_NAME) {
4201 if (ynl_attr_validate(yarg, attr))
4202 return MNL_CB_ERROR;
4204 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4205 dst->_present.dev_name_len = len;
4206 dst->dev_name = malloc(len + 1);
4207 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
4208 dst->dev_name[len] = 0;
4209 } else if (type == DEVLINK_ATTR_PARAM_NAME) {
4212 if (ynl_attr_validate(yarg, attr))
4213 return MNL_CB_ERROR;
4215 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4216 dst->_present.param_name_len = len;
4217 dst->param_name = malloc(len + 1);
4218 memcpy(dst->param_name, mnl_attr_get_str(attr), len);
4219 dst->param_name[len] = 0;
4226 struct devlink_param_get_rsp *
4227 devlink_param_get(struct ynl_sock *ys, struct devlink_param_get_req *req)
4229 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
4230 struct devlink_param_get_rsp *rsp;
4231 struct nlmsghdr *nlh;
4234 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PARAM_GET, 1);
4235 ys->req_policy = &devlink_nest;
4236 yrs.yarg.rsp_policy = &devlink_nest;
4238 if (req->_present.bus_name_len)
4239 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4240 if (req->_present.dev_name_len)
4241 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4242 if (req->_present.param_name_len)
4243 mnl_attr_put_strz(nlh, DEVLINK_ATTR_PARAM_NAME, req->param_name);
4245 rsp = calloc(1, sizeof(*rsp));
4246 yrs.yarg.data = rsp;
4247 yrs.cb = devlink_param_get_rsp_parse;
4248 yrs.rsp_cmd = DEVLINK_CMD_PARAM_GET;
4250 err = ynl_exec(ys, nlh, &yrs);
4257 devlink_param_get_rsp_free(rsp);
4261 /* DEVLINK_CMD_PARAM_GET - dump */
4262 void devlink_param_get_list_free(struct devlink_param_get_list *rsp)
4264 struct devlink_param_get_list *next = rsp;
4266 while ((void *)next != YNL_LIST_END) {
4270 free(rsp->obj.bus_name);
4271 free(rsp->obj.dev_name);
4272 free(rsp->obj.param_name);
4277 struct devlink_param_get_list *
4278 devlink_param_get_dump(struct ynl_sock *ys,
4279 struct devlink_param_get_req_dump *req)
4281 struct ynl_dump_state yds = {};
4282 struct nlmsghdr *nlh;
4286 yds.alloc_sz = sizeof(struct devlink_param_get_list);
4287 yds.cb = devlink_param_get_rsp_parse;
4288 yds.rsp_cmd = DEVLINK_CMD_PARAM_GET;
4289 yds.rsp_policy = &devlink_nest;
4291 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_PARAM_GET, 1);
4292 ys->req_policy = &devlink_nest;
4294 if (req->_present.bus_name_len)
4295 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4296 if (req->_present.dev_name_len)
4297 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4299 err = ynl_exec_dump(ys, nlh, &yds);
4306 devlink_param_get_list_free(yds.first);
4310 /* ============== DEVLINK_CMD_PARAM_SET ============== */
4311 /* DEVLINK_CMD_PARAM_SET - do */
4312 void devlink_param_set_req_free(struct devlink_param_set_req *req)
4314 free(req->bus_name);
4315 free(req->dev_name);
4316 free(req->param_name);
4320 int devlink_param_set(struct ynl_sock *ys, struct devlink_param_set_req *req)
4322 struct nlmsghdr *nlh;
4325 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PARAM_SET, 1);
4326 ys->req_policy = &devlink_nest;
4328 if (req->_present.bus_name_len)
4329 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4330 if (req->_present.dev_name_len)
4331 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4332 if (req->_present.param_name_len)
4333 mnl_attr_put_strz(nlh, DEVLINK_ATTR_PARAM_NAME, req->param_name);
4334 if (req->_present.param_type)
4335 mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_TYPE, req->param_type);
4336 if (req->_present.param_value_cmode)
4337 mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_VALUE_CMODE, req->param_value_cmode);
4339 err = ynl_exec(ys, nlh, NULL);
4346 /* ============== DEVLINK_CMD_REGION_GET ============== */
4347 /* DEVLINK_CMD_REGION_GET - do */
4348 void devlink_region_get_req_free(struct devlink_region_get_req *req)
4350 free(req->bus_name);
4351 free(req->dev_name);
4352 free(req->region_name);
4356 void devlink_region_get_rsp_free(struct devlink_region_get_rsp *rsp)
4358 free(rsp->bus_name);
4359 free(rsp->dev_name);
4360 free(rsp->region_name);
4364 int devlink_region_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
4366 struct devlink_region_get_rsp *dst;
4367 struct ynl_parse_arg *yarg = data;
4368 const struct nlattr *attr;
4372 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
4373 unsigned int type = mnl_attr_get_type(attr);
4375 if (type == DEVLINK_ATTR_BUS_NAME) {
4378 if (ynl_attr_validate(yarg, attr))
4379 return MNL_CB_ERROR;
4381 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4382 dst->_present.bus_name_len = len;
4383 dst->bus_name = malloc(len + 1);
4384 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
4385 dst->bus_name[len] = 0;
4386 } else if (type == DEVLINK_ATTR_DEV_NAME) {
4389 if (ynl_attr_validate(yarg, attr))
4390 return MNL_CB_ERROR;
4392 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4393 dst->_present.dev_name_len = len;
4394 dst->dev_name = malloc(len + 1);
4395 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
4396 dst->dev_name[len] = 0;
4397 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
4398 if (ynl_attr_validate(yarg, attr))
4399 return MNL_CB_ERROR;
4400 dst->_present.port_index = 1;
4401 dst->port_index = mnl_attr_get_u32(attr);
4402 } else if (type == DEVLINK_ATTR_REGION_NAME) {
4405 if (ynl_attr_validate(yarg, attr))
4406 return MNL_CB_ERROR;
4408 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4409 dst->_present.region_name_len = len;
4410 dst->region_name = malloc(len + 1);
4411 memcpy(dst->region_name, mnl_attr_get_str(attr), len);
4412 dst->region_name[len] = 0;
4419 struct devlink_region_get_rsp *
4420 devlink_region_get(struct ynl_sock *ys, struct devlink_region_get_req *req)
4422 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
4423 struct devlink_region_get_rsp *rsp;
4424 struct nlmsghdr *nlh;
4427 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_REGION_GET, 1);
4428 ys->req_policy = &devlink_nest;
4429 yrs.yarg.rsp_policy = &devlink_nest;
4431 if (req->_present.bus_name_len)
4432 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4433 if (req->_present.dev_name_len)
4434 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4435 if (req->_present.port_index)
4436 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
4437 if (req->_present.region_name_len)
4438 mnl_attr_put_strz(nlh, DEVLINK_ATTR_REGION_NAME, req->region_name);
4440 rsp = calloc(1, sizeof(*rsp));
4441 yrs.yarg.data = rsp;
4442 yrs.cb = devlink_region_get_rsp_parse;
4443 yrs.rsp_cmd = DEVLINK_CMD_REGION_GET;
4445 err = ynl_exec(ys, nlh, &yrs);
4452 devlink_region_get_rsp_free(rsp);
4456 /* DEVLINK_CMD_REGION_GET - dump */
4457 void devlink_region_get_list_free(struct devlink_region_get_list *rsp)
4459 struct devlink_region_get_list *next = rsp;
4461 while ((void *)next != YNL_LIST_END) {
4465 free(rsp->obj.bus_name);
4466 free(rsp->obj.dev_name);
4467 free(rsp->obj.region_name);
4472 struct devlink_region_get_list *
4473 devlink_region_get_dump(struct ynl_sock *ys,
4474 struct devlink_region_get_req_dump *req)
4476 struct ynl_dump_state yds = {};
4477 struct nlmsghdr *nlh;
4481 yds.alloc_sz = sizeof(struct devlink_region_get_list);
4482 yds.cb = devlink_region_get_rsp_parse;
4483 yds.rsp_cmd = DEVLINK_CMD_REGION_GET;
4484 yds.rsp_policy = &devlink_nest;
4486 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_REGION_GET, 1);
4487 ys->req_policy = &devlink_nest;
4489 if (req->_present.bus_name_len)
4490 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4491 if (req->_present.dev_name_len)
4492 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4494 err = ynl_exec_dump(ys, nlh, &yds);
4501 devlink_region_get_list_free(yds.first);
4505 /* ============== DEVLINK_CMD_REGION_NEW ============== */
4506 /* DEVLINK_CMD_REGION_NEW - do */
4507 void devlink_region_new_req_free(struct devlink_region_new_req *req)
4509 free(req->bus_name);
4510 free(req->dev_name);
4511 free(req->region_name);
4515 void devlink_region_new_rsp_free(struct devlink_region_new_rsp *rsp)
4517 free(rsp->bus_name);
4518 free(rsp->dev_name);
4519 free(rsp->region_name);
4523 int devlink_region_new_rsp_parse(const struct nlmsghdr *nlh, void *data)
4525 struct devlink_region_new_rsp *dst;
4526 struct ynl_parse_arg *yarg = data;
4527 const struct nlattr *attr;
4531 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
4532 unsigned int type = mnl_attr_get_type(attr);
4534 if (type == DEVLINK_ATTR_BUS_NAME) {
4537 if (ynl_attr_validate(yarg, attr))
4538 return MNL_CB_ERROR;
4540 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4541 dst->_present.bus_name_len = len;
4542 dst->bus_name = malloc(len + 1);
4543 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
4544 dst->bus_name[len] = 0;
4545 } else if (type == DEVLINK_ATTR_DEV_NAME) {
4548 if (ynl_attr_validate(yarg, attr))
4549 return MNL_CB_ERROR;
4551 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4552 dst->_present.dev_name_len = len;
4553 dst->dev_name = malloc(len + 1);
4554 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
4555 dst->dev_name[len] = 0;
4556 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
4557 if (ynl_attr_validate(yarg, attr))
4558 return MNL_CB_ERROR;
4559 dst->_present.port_index = 1;
4560 dst->port_index = mnl_attr_get_u32(attr);
4561 } else if (type == DEVLINK_ATTR_REGION_NAME) {
4564 if (ynl_attr_validate(yarg, attr))
4565 return MNL_CB_ERROR;
4567 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4568 dst->_present.region_name_len = len;
4569 dst->region_name = malloc(len + 1);
4570 memcpy(dst->region_name, mnl_attr_get_str(attr), len);
4571 dst->region_name[len] = 0;
4572 } else if (type == DEVLINK_ATTR_REGION_SNAPSHOT_ID) {
4573 if (ynl_attr_validate(yarg, attr))
4574 return MNL_CB_ERROR;
4575 dst->_present.region_snapshot_id = 1;
4576 dst->region_snapshot_id = mnl_attr_get_u32(attr);
4583 struct devlink_region_new_rsp *
4584 devlink_region_new(struct ynl_sock *ys, struct devlink_region_new_req *req)
4586 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
4587 struct devlink_region_new_rsp *rsp;
4588 struct nlmsghdr *nlh;
4591 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_REGION_NEW, 1);
4592 ys->req_policy = &devlink_nest;
4593 yrs.yarg.rsp_policy = &devlink_nest;
4595 if (req->_present.bus_name_len)
4596 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4597 if (req->_present.dev_name_len)
4598 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4599 if (req->_present.port_index)
4600 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
4601 if (req->_present.region_name_len)
4602 mnl_attr_put_strz(nlh, DEVLINK_ATTR_REGION_NAME, req->region_name);
4603 if (req->_present.region_snapshot_id)
4604 mnl_attr_put_u32(nlh, DEVLINK_ATTR_REGION_SNAPSHOT_ID, req->region_snapshot_id);
4606 rsp = calloc(1, sizeof(*rsp));
4607 yrs.yarg.data = rsp;
4608 yrs.cb = devlink_region_new_rsp_parse;
4609 yrs.rsp_cmd = DEVLINK_CMD_REGION_NEW;
4611 err = ynl_exec(ys, nlh, &yrs);
4618 devlink_region_new_rsp_free(rsp);
4622 /* ============== DEVLINK_CMD_REGION_DEL ============== */
4623 /* DEVLINK_CMD_REGION_DEL - do */
4624 void devlink_region_del_req_free(struct devlink_region_del_req *req)
4626 free(req->bus_name);
4627 free(req->dev_name);
4628 free(req->region_name);
4632 int devlink_region_del(struct ynl_sock *ys, struct devlink_region_del_req *req)
4634 struct nlmsghdr *nlh;
4637 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_REGION_DEL, 1);
4638 ys->req_policy = &devlink_nest;
4640 if (req->_present.bus_name_len)
4641 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4642 if (req->_present.dev_name_len)
4643 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4644 if (req->_present.port_index)
4645 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
4646 if (req->_present.region_name_len)
4647 mnl_attr_put_strz(nlh, DEVLINK_ATTR_REGION_NAME, req->region_name);
4648 if (req->_present.region_snapshot_id)
4649 mnl_attr_put_u32(nlh, DEVLINK_ATTR_REGION_SNAPSHOT_ID, req->region_snapshot_id);
4651 err = ynl_exec(ys, nlh, NULL);
4658 /* ============== DEVLINK_CMD_REGION_READ ============== */
4659 /* DEVLINK_CMD_REGION_READ - dump */
4660 int devlink_region_read_rsp_dump_parse(const struct nlmsghdr *nlh, void *data)
4662 struct devlink_region_read_rsp_dump *dst;
4663 struct ynl_parse_arg *yarg = data;
4664 const struct nlattr *attr;
4668 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
4669 unsigned int type = mnl_attr_get_type(attr);
4671 if (type == DEVLINK_ATTR_BUS_NAME) {
4674 if (ynl_attr_validate(yarg, attr))
4675 return MNL_CB_ERROR;
4677 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4678 dst->_present.bus_name_len = len;
4679 dst->bus_name = malloc(len + 1);
4680 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
4681 dst->bus_name[len] = 0;
4682 } else if (type == DEVLINK_ATTR_DEV_NAME) {
4685 if (ynl_attr_validate(yarg, attr))
4686 return MNL_CB_ERROR;
4688 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4689 dst->_present.dev_name_len = len;
4690 dst->dev_name = malloc(len + 1);
4691 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
4692 dst->dev_name[len] = 0;
4693 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
4694 if (ynl_attr_validate(yarg, attr))
4695 return MNL_CB_ERROR;
4696 dst->_present.port_index = 1;
4697 dst->port_index = mnl_attr_get_u32(attr);
4698 } else if (type == DEVLINK_ATTR_REGION_NAME) {
4701 if (ynl_attr_validate(yarg, attr))
4702 return MNL_CB_ERROR;
4704 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4705 dst->_present.region_name_len = len;
4706 dst->region_name = malloc(len + 1);
4707 memcpy(dst->region_name, mnl_attr_get_str(attr), len);
4708 dst->region_name[len] = 0;
4716 devlink_region_read_rsp_list_free(struct devlink_region_read_rsp_list *rsp)
4718 struct devlink_region_read_rsp_list *next = rsp;
4720 while ((void *)next != YNL_LIST_END) {
4724 free(rsp->obj.bus_name);
4725 free(rsp->obj.dev_name);
4726 free(rsp->obj.region_name);
4731 struct devlink_region_read_rsp_list *
4732 devlink_region_read_dump(struct ynl_sock *ys,
4733 struct devlink_region_read_req_dump *req)
4735 struct ynl_dump_state yds = {};
4736 struct nlmsghdr *nlh;
4740 yds.alloc_sz = sizeof(struct devlink_region_read_rsp_list);
4741 yds.cb = devlink_region_read_rsp_dump_parse;
4742 yds.rsp_cmd = DEVLINK_CMD_REGION_READ;
4743 yds.rsp_policy = &devlink_nest;
4745 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_REGION_READ, 1);
4746 ys->req_policy = &devlink_nest;
4748 if (req->_present.bus_name_len)
4749 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4750 if (req->_present.dev_name_len)
4751 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4752 if (req->_present.port_index)
4753 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
4754 if (req->_present.region_name_len)
4755 mnl_attr_put_strz(nlh, DEVLINK_ATTR_REGION_NAME, req->region_name);
4756 if (req->_present.region_snapshot_id)
4757 mnl_attr_put_u32(nlh, DEVLINK_ATTR_REGION_SNAPSHOT_ID, req->region_snapshot_id);
4758 if (req->_present.region_direct)
4759 mnl_attr_put(nlh, DEVLINK_ATTR_REGION_DIRECT, 0, NULL);
4760 if (req->_present.region_chunk_addr)
4761 mnl_attr_put_u64(nlh, DEVLINK_ATTR_REGION_CHUNK_ADDR, req->region_chunk_addr);
4762 if (req->_present.region_chunk_len)
4763 mnl_attr_put_u64(nlh, DEVLINK_ATTR_REGION_CHUNK_LEN, req->region_chunk_len);
4765 err = ynl_exec_dump(ys, nlh, &yds);
4772 devlink_region_read_rsp_list_free(yds.first);
4776 /* ============== DEVLINK_CMD_PORT_PARAM_GET ============== */
4777 /* DEVLINK_CMD_PORT_PARAM_GET - do */
4778 void devlink_port_param_get_req_free(struct devlink_port_param_get_req *req)
4780 free(req->bus_name);
4781 free(req->dev_name);
4785 void devlink_port_param_get_rsp_free(struct devlink_port_param_get_rsp *rsp)
4787 free(rsp->bus_name);
4788 free(rsp->dev_name);
4792 int devlink_port_param_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
4794 struct devlink_port_param_get_rsp *dst;
4795 struct ynl_parse_arg *yarg = data;
4796 const struct nlattr *attr;
4800 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
4801 unsigned int type = mnl_attr_get_type(attr);
4803 if (type == DEVLINK_ATTR_BUS_NAME) {
4806 if (ynl_attr_validate(yarg, attr))
4807 return MNL_CB_ERROR;
4809 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4810 dst->_present.bus_name_len = len;
4811 dst->bus_name = malloc(len + 1);
4812 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
4813 dst->bus_name[len] = 0;
4814 } else if (type == DEVLINK_ATTR_DEV_NAME) {
4817 if (ynl_attr_validate(yarg, attr))
4818 return MNL_CB_ERROR;
4820 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
4821 dst->_present.dev_name_len = len;
4822 dst->dev_name = malloc(len + 1);
4823 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
4824 dst->dev_name[len] = 0;
4825 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
4826 if (ynl_attr_validate(yarg, attr))
4827 return MNL_CB_ERROR;
4828 dst->_present.port_index = 1;
4829 dst->port_index = mnl_attr_get_u32(attr);
4836 struct devlink_port_param_get_rsp *
4837 devlink_port_param_get(struct ynl_sock *ys,
4838 struct devlink_port_param_get_req *req)
4840 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
4841 struct devlink_port_param_get_rsp *rsp;
4842 struct nlmsghdr *nlh;
4845 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PORT_PARAM_GET, 1);
4846 ys->req_policy = &devlink_nest;
4847 yrs.yarg.rsp_policy = &devlink_nest;
4849 if (req->_present.bus_name_len)
4850 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4851 if (req->_present.dev_name_len)
4852 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4853 if (req->_present.port_index)
4854 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
4856 rsp = calloc(1, sizeof(*rsp));
4857 yrs.yarg.data = rsp;
4858 yrs.cb = devlink_port_param_get_rsp_parse;
4859 yrs.rsp_cmd = DEVLINK_CMD_PORT_PARAM_GET;
4861 err = ynl_exec(ys, nlh, &yrs);
4868 devlink_port_param_get_rsp_free(rsp);
4872 /* DEVLINK_CMD_PORT_PARAM_GET - dump */
4873 void devlink_port_param_get_list_free(struct devlink_port_param_get_list *rsp)
4875 struct devlink_port_param_get_list *next = rsp;
4877 while ((void *)next != YNL_LIST_END) {
4881 free(rsp->obj.bus_name);
4882 free(rsp->obj.dev_name);
4887 struct devlink_port_param_get_list *
4888 devlink_port_param_get_dump(struct ynl_sock *ys)
4890 struct ynl_dump_state yds = {};
4891 struct nlmsghdr *nlh;
4895 yds.alloc_sz = sizeof(struct devlink_port_param_get_list);
4896 yds.cb = devlink_port_param_get_rsp_parse;
4897 yds.rsp_cmd = DEVLINK_CMD_PORT_PARAM_GET;
4898 yds.rsp_policy = &devlink_nest;
4900 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_PORT_PARAM_GET, 1);
4902 err = ynl_exec_dump(ys, nlh, &yds);
4909 devlink_port_param_get_list_free(yds.first);
4913 /* ============== DEVLINK_CMD_PORT_PARAM_SET ============== */
4914 /* DEVLINK_CMD_PORT_PARAM_SET - do */
4915 void devlink_port_param_set_req_free(struct devlink_port_param_set_req *req)
4917 free(req->bus_name);
4918 free(req->dev_name);
4922 int devlink_port_param_set(struct ynl_sock *ys,
4923 struct devlink_port_param_set_req *req)
4925 struct nlmsghdr *nlh;
4928 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PORT_PARAM_SET, 1);
4929 ys->req_policy = &devlink_nest;
4931 if (req->_present.bus_name_len)
4932 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
4933 if (req->_present.dev_name_len)
4934 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
4935 if (req->_present.port_index)
4936 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
4938 err = ynl_exec(ys, nlh, NULL);
4945 /* ============== DEVLINK_CMD_INFO_GET ============== */
4946 /* DEVLINK_CMD_INFO_GET - do */
4947 void devlink_info_get_req_free(struct devlink_info_get_req *req)
4949 free(req->bus_name);
4950 free(req->dev_name);
4954 void devlink_info_get_rsp_free(struct devlink_info_get_rsp *rsp)
4958 free(rsp->bus_name);
4959 free(rsp->dev_name);
4960 free(rsp->info_driver_name);
4961 free(rsp->info_serial_number);
4962 for (i = 0; i < rsp->n_info_version_fixed; i++)
4963 devlink_dl_info_version_free(&rsp->info_version_fixed[i]);
4964 free(rsp->info_version_fixed);
4965 for (i = 0; i < rsp->n_info_version_running; i++)
4966 devlink_dl_info_version_free(&rsp->info_version_running[i]);
4967 free(rsp->info_version_running);
4968 for (i = 0; i < rsp->n_info_version_stored; i++)
4969 devlink_dl_info_version_free(&rsp->info_version_stored[i]);
4970 free(rsp->info_version_stored);
4974 int devlink_info_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
4976 unsigned int n_info_version_running = 0;
4977 unsigned int n_info_version_stored = 0;
4978 unsigned int n_info_version_fixed = 0;
4979 struct ynl_parse_arg *yarg = data;
4980 struct devlink_info_get_rsp *dst;
4981 const struct nlattr *attr;
4982 struct ynl_parse_arg parg;
4988 if (dst->info_version_fixed)
4989 return ynl_error_parse(yarg, "attribute already present (devlink.info-version-fixed)");
4990 if (dst->info_version_running)
4991 return ynl_error_parse(yarg, "attribute already present (devlink.info-version-running)");
4992 if (dst->info_version_stored)
4993 return ynl_error_parse(yarg, "attribute already present (devlink.info-version-stored)");
4995 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
4996 unsigned int type = mnl_attr_get_type(attr);
4998 if (type == DEVLINK_ATTR_BUS_NAME) {
5001 if (ynl_attr_validate(yarg, attr))
5002 return MNL_CB_ERROR;
5004 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5005 dst->_present.bus_name_len = len;
5006 dst->bus_name = malloc(len + 1);
5007 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
5008 dst->bus_name[len] = 0;
5009 } else if (type == DEVLINK_ATTR_DEV_NAME) {
5012 if (ynl_attr_validate(yarg, attr))
5013 return MNL_CB_ERROR;
5015 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5016 dst->_present.dev_name_len = len;
5017 dst->dev_name = malloc(len + 1);
5018 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
5019 dst->dev_name[len] = 0;
5020 } else if (type == DEVLINK_ATTR_INFO_DRIVER_NAME) {
5023 if (ynl_attr_validate(yarg, attr))
5024 return MNL_CB_ERROR;
5026 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5027 dst->_present.info_driver_name_len = len;
5028 dst->info_driver_name = malloc(len + 1);
5029 memcpy(dst->info_driver_name, mnl_attr_get_str(attr), len);
5030 dst->info_driver_name[len] = 0;
5031 } else if (type == DEVLINK_ATTR_INFO_SERIAL_NUMBER) {
5034 if (ynl_attr_validate(yarg, attr))
5035 return MNL_CB_ERROR;
5037 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5038 dst->_present.info_serial_number_len = len;
5039 dst->info_serial_number = malloc(len + 1);
5040 memcpy(dst->info_serial_number, mnl_attr_get_str(attr), len);
5041 dst->info_serial_number[len] = 0;
5042 } else if (type == DEVLINK_ATTR_INFO_VERSION_FIXED) {
5043 n_info_version_fixed++;
5044 } else if (type == DEVLINK_ATTR_INFO_VERSION_RUNNING) {
5045 n_info_version_running++;
5046 } else if (type == DEVLINK_ATTR_INFO_VERSION_STORED) {
5047 n_info_version_stored++;
5051 if (n_info_version_fixed) {
5052 dst->info_version_fixed = calloc(n_info_version_fixed, sizeof(*dst->info_version_fixed));
5053 dst->n_info_version_fixed = n_info_version_fixed;
5055 parg.rsp_policy = &devlink_dl_info_version_nest;
5056 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
5057 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_INFO_VERSION_FIXED) {
5058 parg.data = &dst->info_version_fixed[i];
5059 if (devlink_dl_info_version_parse(&parg, attr))
5060 return MNL_CB_ERROR;
5065 if (n_info_version_running) {
5066 dst->info_version_running = calloc(n_info_version_running, sizeof(*dst->info_version_running));
5067 dst->n_info_version_running = n_info_version_running;
5069 parg.rsp_policy = &devlink_dl_info_version_nest;
5070 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
5071 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_INFO_VERSION_RUNNING) {
5072 parg.data = &dst->info_version_running[i];
5073 if (devlink_dl_info_version_parse(&parg, attr))
5074 return MNL_CB_ERROR;
5079 if (n_info_version_stored) {
5080 dst->info_version_stored = calloc(n_info_version_stored, sizeof(*dst->info_version_stored));
5081 dst->n_info_version_stored = n_info_version_stored;
5083 parg.rsp_policy = &devlink_dl_info_version_nest;
5084 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
5085 if (mnl_attr_get_type(attr) == DEVLINK_ATTR_INFO_VERSION_STORED) {
5086 parg.data = &dst->info_version_stored[i];
5087 if (devlink_dl_info_version_parse(&parg, attr))
5088 return MNL_CB_ERROR;
5097 struct devlink_info_get_rsp *
5098 devlink_info_get(struct ynl_sock *ys, struct devlink_info_get_req *req)
5100 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
5101 struct devlink_info_get_rsp *rsp;
5102 struct nlmsghdr *nlh;
5105 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_INFO_GET, 1);
5106 ys->req_policy = &devlink_nest;
5107 yrs.yarg.rsp_policy = &devlink_nest;
5109 if (req->_present.bus_name_len)
5110 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5111 if (req->_present.dev_name_len)
5112 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5114 rsp = calloc(1, sizeof(*rsp));
5115 yrs.yarg.data = rsp;
5116 yrs.cb = devlink_info_get_rsp_parse;
5117 yrs.rsp_cmd = DEVLINK_CMD_INFO_GET;
5119 err = ynl_exec(ys, nlh, &yrs);
5126 devlink_info_get_rsp_free(rsp);
5130 /* DEVLINK_CMD_INFO_GET - dump */
5131 void devlink_info_get_list_free(struct devlink_info_get_list *rsp)
5133 struct devlink_info_get_list *next = rsp;
5135 while ((void *)next != YNL_LIST_END) {
5141 free(rsp->obj.bus_name);
5142 free(rsp->obj.dev_name);
5143 free(rsp->obj.info_driver_name);
5144 free(rsp->obj.info_serial_number);
5145 for (i = 0; i < rsp->obj.n_info_version_fixed; i++)
5146 devlink_dl_info_version_free(&rsp->obj.info_version_fixed[i]);
5147 free(rsp->obj.info_version_fixed);
5148 for (i = 0; i < rsp->obj.n_info_version_running; i++)
5149 devlink_dl_info_version_free(&rsp->obj.info_version_running[i]);
5150 free(rsp->obj.info_version_running);
5151 for (i = 0; i < rsp->obj.n_info_version_stored; i++)
5152 devlink_dl_info_version_free(&rsp->obj.info_version_stored[i]);
5153 free(rsp->obj.info_version_stored);
5158 struct devlink_info_get_list *devlink_info_get_dump(struct ynl_sock *ys)
5160 struct ynl_dump_state yds = {};
5161 struct nlmsghdr *nlh;
5165 yds.alloc_sz = sizeof(struct devlink_info_get_list);
5166 yds.cb = devlink_info_get_rsp_parse;
5167 yds.rsp_cmd = DEVLINK_CMD_INFO_GET;
5168 yds.rsp_policy = &devlink_nest;
5170 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_INFO_GET, 1);
5172 err = ynl_exec_dump(ys, nlh, &yds);
5179 devlink_info_get_list_free(yds.first);
5183 /* ============== DEVLINK_CMD_HEALTH_REPORTER_GET ============== */
5184 /* DEVLINK_CMD_HEALTH_REPORTER_GET - do */
5186 devlink_health_reporter_get_req_free(struct devlink_health_reporter_get_req *req)
5188 free(req->bus_name);
5189 free(req->dev_name);
5190 free(req->health_reporter_name);
5195 devlink_health_reporter_get_rsp_free(struct devlink_health_reporter_get_rsp *rsp)
5197 free(rsp->bus_name);
5198 free(rsp->dev_name);
5199 free(rsp->health_reporter_name);
5203 int devlink_health_reporter_get_rsp_parse(const struct nlmsghdr *nlh,
5206 struct devlink_health_reporter_get_rsp *dst;
5207 struct ynl_parse_arg *yarg = data;
5208 const struct nlattr *attr;
5212 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
5213 unsigned int type = mnl_attr_get_type(attr);
5215 if (type == DEVLINK_ATTR_BUS_NAME) {
5218 if (ynl_attr_validate(yarg, attr))
5219 return MNL_CB_ERROR;
5221 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5222 dst->_present.bus_name_len = len;
5223 dst->bus_name = malloc(len + 1);
5224 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
5225 dst->bus_name[len] = 0;
5226 } else if (type == DEVLINK_ATTR_DEV_NAME) {
5229 if (ynl_attr_validate(yarg, attr))
5230 return MNL_CB_ERROR;
5232 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5233 dst->_present.dev_name_len = len;
5234 dst->dev_name = malloc(len + 1);
5235 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
5236 dst->dev_name[len] = 0;
5237 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
5238 if (ynl_attr_validate(yarg, attr))
5239 return MNL_CB_ERROR;
5240 dst->_present.port_index = 1;
5241 dst->port_index = mnl_attr_get_u32(attr);
5242 } else if (type == DEVLINK_ATTR_HEALTH_REPORTER_NAME) {
5245 if (ynl_attr_validate(yarg, attr))
5246 return MNL_CB_ERROR;
5248 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5249 dst->_present.health_reporter_name_len = len;
5250 dst->health_reporter_name = malloc(len + 1);
5251 memcpy(dst->health_reporter_name, mnl_attr_get_str(attr), len);
5252 dst->health_reporter_name[len] = 0;
5259 struct devlink_health_reporter_get_rsp *
5260 devlink_health_reporter_get(struct ynl_sock *ys,
5261 struct devlink_health_reporter_get_req *req)
5263 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
5264 struct devlink_health_reporter_get_rsp *rsp;
5265 struct nlmsghdr *nlh;
5268 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_GET, 1);
5269 ys->req_policy = &devlink_nest;
5270 yrs.yarg.rsp_policy = &devlink_nest;
5272 if (req->_present.bus_name_len)
5273 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5274 if (req->_present.dev_name_len)
5275 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5276 if (req->_present.port_index)
5277 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
5278 if (req->_present.health_reporter_name_len)
5279 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
5281 rsp = calloc(1, sizeof(*rsp));
5282 yrs.yarg.data = rsp;
5283 yrs.cb = devlink_health_reporter_get_rsp_parse;
5284 yrs.rsp_cmd = DEVLINK_CMD_HEALTH_REPORTER_GET;
5286 err = ynl_exec(ys, nlh, &yrs);
5293 devlink_health_reporter_get_rsp_free(rsp);
5297 /* DEVLINK_CMD_HEALTH_REPORTER_GET - dump */
5299 devlink_health_reporter_get_list_free(struct devlink_health_reporter_get_list *rsp)
5301 struct devlink_health_reporter_get_list *next = rsp;
5303 while ((void *)next != YNL_LIST_END) {
5307 free(rsp->obj.bus_name);
5308 free(rsp->obj.dev_name);
5309 free(rsp->obj.health_reporter_name);
5314 struct devlink_health_reporter_get_list *
5315 devlink_health_reporter_get_dump(struct ynl_sock *ys,
5316 struct devlink_health_reporter_get_req_dump *req)
5318 struct ynl_dump_state yds = {};
5319 struct nlmsghdr *nlh;
5323 yds.alloc_sz = sizeof(struct devlink_health_reporter_get_list);
5324 yds.cb = devlink_health_reporter_get_rsp_parse;
5325 yds.rsp_cmd = DEVLINK_CMD_HEALTH_REPORTER_GET;
5326 yds.rsp_policy = &devlink_nest;
5328 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_GET, 1);
5329 ys->req_policy = &devlink_nest;
5331 if (req->_present.bus_name_len)
5332 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5333 if (req->_present.dev_name_len)
5334 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5335 if (req->_present.port_index)
5336 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
5338 err = ynl_exec_dump(ys, nlh, &yds);
5345 devlink_health_reporter_get_list_free(yds.first);
5349 /* ============== DEVLINK_CMD_HEALTH_REPORTER_SET ============== */
5350 /* DEVLINK_CMD_HEALTH_REPORTER_SET - do */
5352 devlink_health_reporter_set_req_free(struct devlink_health_reporter_set_req *req)
5354 free(req->bus_name);
5355 free(req->dev_name);
5356 free(req->health_reporter_name);
5360 int devlink_health_reporter_set(struct ynl_sock *ys,
5361 struct devlink_health_reporter_set_req *req)
5363 struct nlmsghdr *nlh;
5366 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_SET, 1);
5367 ys->req_policy = &devlink_nest;
5369 if (req->_present.bus_name_len)
5370 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5371 if (req->_present.dev_name_len)
5372 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5373 if (req->_present.port_index)
5374 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
5375 if (req->_present.health_reporter_name_len)
5376 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
5377 if (req->_present.health_reporter_graceful_period)
5378 mnl_attr_put_u64(nlh, DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD, req->health_reporter_graceful_period);
5379 if (req->_present.health_reporter_auto_recover)
5380 mnl_attr_put_u8(nlh, DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER, req->health_reporter_auto_recover);
5381 if (req->_present.health_reporter_auto_dump)
5382 mnl_attr_put_u8(nlh, DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP, req->health_reporter_auto_dump);
5384 err = ynl_exec(ys, nlh, NULL);
5391 /* ============== DEVLINK_CMD_HEALTH_REPORTER_RECOVER ============== */
5392 /* DEVLINK_CMD_HEALTH_REPORTER_RECOVER - do */
5394 devlink_health_reporter_recover_req_free(struct devlink_health_reporter_recover_req *req)
5396 free(req->bus_name);
5397 free(req->dev_name);
5398 free(req->health_reporter_name);
5402 int devlink_health_reporter_recover(struct ynl_sock *ys,
5403 struct devlink_health_reporter_recover_req *req)
5405 struct nlmsghdr *nlh;
5408 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_RECOVER, 1);
5409 ys->req_policy = &devlink_nest;
5411 if (req->_present.bus_name_len)
5412 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5413 if (req->_present.dev_name_len)
5414 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5415 if (req->_present.port_index)
5416 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
5417 if (req->_present.health_reporter_name_len)
5418 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
5420 err = ynl_exec(ys, nlh, NULL);
5427 /* ============== DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE ============== */
5428 /* DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE - do */
5430 devlink_health_reporter_diagnose_req_free(struct devlink_health_reporter_diagnose_req *req)
5432 free(req->bus_name);
5433 free(req->dev_name);
5434 free(req->health_reporter_name);
5438 int devlink_health_reporter_diagnose(struct ynl_sock *ys,
5439 struct devlink_health_reporter_diagnose_req *req)
5441 struct nlmsghdr *nlh;
5444 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE, 1);
5445 ys->req_policy = &devlink_nest;
5447 if (req->_present.bus_name_len)
5448 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5449 if (req->_present.dev_name_len)
5450 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5451 if (req->_present.port_index)
5452 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
5453 if (req->_present.health_reporter_name_len)
5454 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
5456 err = ynl_exec(ys, nlh, NULL);
5463 /* ============== DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET ============== */
5464 /* DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET - dump */
5465 int devlink_health_reporter_dump_get_rsp_dump_parse(const struct nlmsghdr *nlh,
5468 struct devlink_health_reporter_dump_get_rsp_dump *dst;
5469 struct ynl_parse_arg *yarg = data;
5470 const struct nlattr *attr;
5471 struct ynl_parse_arg parg;
5476 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
5477 unsigned int type = mnl_attr_get_type(attr);
5479 if (type == DEVLINK_ATTR_FMSG) {
5480 if (ynl_attr_validate(yarg, attr))
5481 return MNL_CB_ERROR;
5482 dst->_present.fmsg = 1;
5484 parg.rsp_policy = &devlink_dl_fmsg_nest;
5485 parg.data = &dst->fmsg;
5486 if (devlink_dl_fmsg_parse(&parg, attr))
5487 return MNL_CB_ERROR;
5495 devlink_health_reporter_dump_get_rsp_list_free(struct devlink_health_reporter_dump_get_rsp_list *rsp)
5497 struct devlink_health_reporter_dump_get_rsp_list *next = rsp;
5499 while ((void *)next != YNL_LIST_END) {
5503 devlink_dl_fmsg_free(&rsp->obj.fmsg);
5508 struct devlink_health_reporter_dump_get_rsp_list *
5509 devlink_health_reporter_dump_get_dump(struct ynl_sock *ys,
5510 struct devlink_health_reporter_dump_get_req_dump *req)
5512 struct ynl_dump_state yds = {};
5513 struct nlmsghdr *nlh;
5517 yds.alloc_sz = sizeof(struct devlink_health_reporter_dump_get_rsp_list);
5518 yds.cb = devlink_health_reporter_dump_get_rsp_dump_parse;
5519 yds.rsp_cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET;
5520 yds.rsp_policy = &devlink_nest;
5522 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET, 1);
5523 ys->req_policy = &devlink_nest;
5525 if (req->_present.bus_name_len)
5526 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5527 if (req->_present.dev_name_len)
5528 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5529 if (req->_present.port_index)
5530 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
5531 if (req->_present.health_reporter_name_len)
5532 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
5534 err = ynl_exec_dump(ys, nlh, &yds);
5541 devlink_health_reporter_dump_get_rsp_list_free(yds.first);
5545 /* ============== DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR ============== */
5546 /* DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR - do */
5548 devlink_health_reporter_dump_clear_req_free(struct devlink_health_reporter_dump_clear_req *req)
5550 free(req->bus_name);
5551 free(req->dev_name);
5552 free(req->health_reporter_name);
5556 int devlink_health_reporter_dump_clear(struct ynl_sock *ys,
5557 struct devlink_health_reporter_dump_clear_req *req)
5559 struct nlmsghdr *nlh;
5562 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR, 1);
5563 ys->req_policy = &devlink_nest;
5565 if (req->_present.bus_name_len)
5566 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5567 if (req->_present.dev_name_len)
5568 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5569 if (req->_present.port_index)
5570 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
5571 if (req->_present.health_reporter_name_len)
5572 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
5574 err = ynl_exec(ys, nlh, NULL);
5581 /* ============== DEVLINK_CMD_FLASH_UPDATE ============== */
5582 /* DEVLINK_CMD_FLASH_UPDATE - do */
5583 void devlink_flash_update_req_free(struct devlink_flash_update_req *req)
5585 free(req->bus_name);
5586 free(req->dev_name);
5587 free(req->flash_update_file_name);
5588 free(req->flash_update_component);
5592 int devlink_flash_update(struct ynl_sock *ys,
5593 struct devlink_flash_update_req *req)
5595 struct nlmsghdr *nlh;
5598 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_FLASH_UPDATE, 1);
5599 ys->req_policy = &devlink_nest;
5601 if (req->_present.bus_name_len)
5602 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5603 if (req->_present.dev_name_len)
5604 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5605 if (req->_present.flash_update_file_name_len)
5606 mnl_attr_put_strz(nlh, DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME, req->flash_update_file_name);
5607 if (req->_present.flash_update_component_len)
5608 mnl_attr_put_strz(nlh, DEVLINK_ATTR_FLASH_UPDATE_COMPONENT, req->flash_update_component);
5609 if (req->_present.flash_update_overwrite_mask)
5610 mnl_attr_put(nlh, DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK, sizeof(struct nla_bitfield32), &req->flash_update_overwrite_mask);
5612 err = ynl_exec(ys, nlh, NULL);
5619 /* ============== DEVLINK_CMD_TRAP_GET ============== */
5620 /* DEVLINK_CMD_TRAP_GET - do */
5621 void devlink_trap_get_req_free(struct devlink_trap_get_req *req)
5623 free(req->bus_name);
5624 free(req->dev_name);
5625 free(req->trap_name);
5629 void devlink_trap_get_rsp_free(struct devlink_trap_get_rsp *rsp)
5631 free(rsp->bus_name);
5632 free(rsp->dev_name);
5633 free(rsp->trap_name);
5637 int devlink_trap_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
5639 struct ynl_parse_arg *yarg = data;
5640 struct devlink_trap_get_rsp *dst;
5641 const struct nlattr *attr;
5645 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
5646 unsigned int type = mnl_attr_get_type(attr);
5648 if (type == DEVLINK_ATTR_BUS_NAME) {
5651 if (ynl_attr_validate(yarg, attr))
5652 return MNL_CB_ERROR;
5654 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5655 dst->_present.bus_name_len = len;
5656 dst->bus_name = malloc(len + 1);
5657 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
5658 dst->bus_name[len] = 0;
5659 } else if (type == DEVLINK_ATTR_DEV_NAME) {
5662 if (ynl_attr_validate(yarg, attr))
5663 return MNL_CB_ERROR;
5665 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5666 dst->_present.dev_name_len = len;
5667 dst->dev_name = malloc(len + 1);
5668 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
5669 dst->dev_name[len] = 0;
5670 } else if (type == DEVLINK_ATTR_TRAP_NAME) {
5673 if (ynl_attr_validate(yarg, attr))
5674 return MNL_CB_ERROR;
5676 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5677 dst->_present.trap_name_len = len;
5678 dst->trap_name = malloc(len + 1);
5679 memcpy(dst->trap_name, mnl_attr_get_str(attr), len);
5680 dst->trap_name[len] = 0;
5687 struct devlink_trap_get_rsp *
5688 devlink_trap_get(struct ynl_sock *ys, struct devlink_trap_get_req *req)
5690 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
5691 struct devlink_trap_get_rsp *rsp;
5692 struct nlmsghdr *nlh;
5695 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_TRAP_GET, 1);
5696 ys->req_policy = &devlink_nest;
5697 yrs.yarg.rsp_policy = &devlink_nest;
5699 if (req->_present.bus_name_len)
5700 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5701 if (req->_present.dev_name_len)
5702 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5703 if (req->_present.trap_name_len)
5704 mnl_attr_put_strz(nlh, DEVLINK_ATTR_TRAP_NAME, req->trap_name);
5706 rsp = calloc(1, sizeof(*rsp));
5707 yrs.yarg.data = rsp;
5708 yrs.cb = devlink_trap_get_rsp_parse;
5711 err = ynl_exec(ys, nlh, &yrs);
5718 devlink_trap_get_rsp_free(rsp);
5722 /* DEVLINK_CMD_TRAP_GET - dump */
5723 void devlink_trap_get_list_free(struct devlink_trap_get_list *rsp)
5725 struct devlink_trap_get_list *next = rsp;
5727 while ((void *)next != YNL_LIST_END) {
5731 free(rsp->obj.bus_name);
5732 free(rsp->obj.dev_name);
5733 free(rsp->obj.trap_name);
5738 struct devlink_trap_get_list *
5739 devlink_trap_get_dump(struct ynl_sock *ys,
5740 struct devlink_trap_get_req_dump *req)
5742 struct ynl_dump_state yds = {};
5743 struct nlmsghdr *nlh;
5747 yds.alloc_sz = sizeof(struct devlink_trap_get_list);
5748 yds.cb = devlink_trap_get_rsp_parse;
5750 yds.rsp_policy = &devlink_nest;
5752 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_TRAP_GET, 1);
5753 ys->req_policy = &devlink_nest;
5755 if (req->_present.bus_name_len)
5756 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5757 if (req->_present.dev_name_len)
5758 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5760 err = ynl_exec_dump(ys, nlh, &yds);
5767 devlink_trap_get_list_free(yds.first);
5771 /* ============== DEVLINK_CMD_TRAP_SET ============== */
5772 /* DEVLINK_CMD_TRAP_SET - do */
5773 void devlink_trap_set_req_free(struct devlink_trap_set_req *req)
5775 free(req->bus_name);
5776 free(req->dev_name);
5777 free(req->trap_name);
5781 int devlink_trap_set(struct ynl_sock *ys, struct devlink_trap_set_req *req)
5783 struct nlmsghdr *nlh;
5786 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_TRAP_SET, 1);
5787 ys->req_policy = &devlink_nest;
5789 if (req->_present.bus_name_len)
5790 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5791 if (req->_present.dev_name_len)
5792 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5793 if (req->_present.trap_name_len)
5794 mnl_attr_put_strz(nlh, DEVLINK_ATTR_TRAP_NAME, req->trap_name);
5795 if (req->_present.trap_action)
5796 mnl_attr_put_u8(nlh, DEVLINK_ATTR_TRAP_ACTION, req->trap_action);
5798 err = ynl_exec(ys, nlh, NULL);
5805 /* ============== DEVLINK_CMD_TRAP_GROUP_GET ============== */
5806 /* DEVLINK_CMD_TRAP_GROUP_GET - do */
5807 void devlink_trap_group_get_req_free(struct devlink_trap_group_get_req *req)
5809 free(req->bus_name);
5810 free(req->dev_name);
5811 free(req->trap_group_name);
5815 void devlink_trap_group_get_rsp_free(struct devlink_trap_group_get_rsp *rsp)
5817 free(rsp->bus_name);
5818 free(rsp->dev_name);
5819 free(rsp->trap_group_name);
5823 int devlink_trap_group_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
5825 struct devlink_trap_group_get_rsp *dst;
5826 struct ynl_parse_arg *yarg = data;
5827 const struct nlattr *attr;
5831 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
5832 unsigned int type = mnl_attr_get_type(attr);
5834 if (type == DEVLINK_ATTR_BUS_NAME) {
5837 if (ynl_attr_validate(yarg, attr))
5838 return MNL_CB_ERROR;
5840 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5841 dst->_present.bus_name_len = len;
5842 dst->bus_name = malloc(len + 1);
5843 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
5844 dst->bus_name[len] = 0;
5845 } else if (type == DEVLINK_ATTR_DEV_NAME) {
5848 if (ynl_attr_validate(yarg, attr))
5849 return MNL_CB_ERROR;
5851 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5852 dst->_present.dev_name_len = len;
5853 dst->dev_name = malloc(len + 1);
5854 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
5855 dst->dev_name[len] = 0;
5856 } else if (type == DEVLINK_ATTR_TRAP_GROUP_NAME) {
5859 if (ynl_attr_validate(yarg, attr))
5860 return MNL_CB_ERROR;
5862 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
5863 dst->_present.trap_group_name_len = len;
5864 dst->trap_group_name = malloc(len + 1);
5865 memcpy(dst->trap_group_name, mnl_attr_get_str(attr), len);
5866 dst->trap_group_name[len] = 0;
5873 struct devlink_trap_group_get_rsp *
5874 devlink_trap_group_get(struct ynl_sock *ys,
5875 struct devlink_trap_group_get_req *req)
5877 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
5878 struct devlink_trap_group_get_rsp *rsp;
5879 struct nlmsghdr *nlh;
5882 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_TRAP_GROUP_GET, 1);
5883 ys->req_policy = &devlink_nest;
5884 yrs.yarg.rsp_policy = &devlink_nest;
5886 if (req->_present.bus_name_len)
5887 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5888 if (req->_present.dev_name_len)
5889 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5890 if (req->_present.trap_group_name_len)
5891 mnl_attr_put_strz(nlh, DEVLINK_ATTR_TRAP_GROUP_NAME, req->trap_group_name);
5893 rsp = calloc(1, sizeof(*rsp));
5894 yrs.yarg.data = rsp;
5895 yrs.cb = devlink_trap_group_get_rsp_parse;
5898 err = ynl_exec(ys, nlh, &yrs);
5905 devlink_trap_group_get_rsp_free(rsp);
5909 /* DEVLINK_CMD_TRAP_GROUP_GET - dump */
5910 void devlink_trap_group_get_list_free(struct devlink_trap_group_get_list *rsp)
5912 struct devlink_trap_group_get_list *next = rsp;
5914 while ((void *)next != YNL_LIST_END) {
5918 free(rsp->obj.bus_name);
5919 free(rsp->obj.dev_name);
5920 free(rsp->obj.trap_group_name);
5925 struct devlink_trap_group_get_list *
5926 devlink_trap_group_get_dump(struct ynl_sock *ys,
5927 struct devlink_trap_group_get_req_dump *req)
5929 struct ynl_dump_state yds = {};
5930 struct nlmsghdr *nlh;
5934 yds.alloc_sz = sizeof(struct devlink_trap_group_get_list);
5935 yds.cb = devlink_trap_group_get_rsp_parse;
5937 yds.rsp_policy = &devlink_nest;
5939 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_TRAP_GROUP_GET, 1);
5940 ys->req_policy = &devlink_nest;
5942 if (req->_present.bus_name_len)
5943 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5944 if (req->_present.dev_name_len)
5945 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5947 err = ynl_exec_dump(ys, nlh, &yds);
5954 devlink_trap_group_get_list_free(yds.first);
5958 /* ============== DEVLINK_CMD_TRAP_GROUP_SET ============== */
5959 /* DEVLINK_CMD_TRAP_GROUP_SET - do */
5960 void devlink_trap_group_set_req_free(struct devlink_trap_group_set_req *req)
5962 free(req->bus_name);
5963 free(req->dev_name);
5964 free(req->trap_group_name);
5968 int devlink_trap_group_set(struct ynl_sock *ys,
5969 struct devlink_trap_group_set_req *req)
5971 struct nlmsghdr *nlh;
5974 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_TRAP_GROUP_SET, 1);
5975 ys->req_policy = &devlink_nest;
5977 if (req->_present.bus_name_len)
5978 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
5979 if (req->_present.dev_name_len)
5980 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
5981 if (req->_present.trap_group_name_len)
5982 mnl_attr_put_strz(nlh, DEVLINK_ATTR_TRAP_GROUP_NAME, req->trap_group_name);
5983 if (req->_present.trap_action)
5984 mnl_attr_put_u8(nlh, DEVLINK_ATTR_TRAP_ACTION, req->trap_action);
5985 if (req->_present.trap_policer_id)
5986 mnl_attr_put_u32(nlh, DEVLINK_ATTR_TRAP_POLICER_ID, req->trap_policer_id);
5988 err = ynl_exec(ys, nlh, NULL);
5995 /* ============== DEVLINK_CMD_TRAP_POLICER_GET ============== */
5996 /* DEVLINK_CMD_TRAP_POLICER_GET - do */
5998 devlink_trap_policer_get_req_free(struct devlink_trap_policer_get_req *req)
6000 free(req->bus_name);
6001 free(req->dev_name);
6006 devlink_trap_policer_get_rsp_free(struct devlink_trap_policer_get_rsp *rsp)
6008 free(rsp->bus_name);
6009 free(rsp->dev_name);
6013 int devlink_trap_policer_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
6015 struct devlink_trap_policer_get_rsp *dst;
6016 struct ynl_parse_arg *yarg = data;
6017 const struct nlattr *attr;
6021 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
6022 unsigned int type = mnl_attr_get_type(attr);
6024 if (type == DEVLINK_ATTR_BUS_NAME) {
6027 if (ynl_attr_validate(yarg, attr))
6028 return MNL_CB_ERROR;
6030 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
6031 dst->_present.bus_name_len = len;
6032 dst->bus_name = malloc(len + 1);
6033 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
6034 dst->bus_name[len] = 0;
6035 } else if (type == DEVLINK_ATTR_DEV_NAME) {
6038 if (ynl_attr_validate(yarg, attr))
6039 return MNL_CB_ERROR;
6041 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
6042 dst->_present.dev_name_len = len;
6043 dst->dev_name = malloc(len + 1);
6044 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
6045 dst->dev_name[len] = 0;
6046 } else if (type == DEVLINK_ATTR_TRAP_POLICER_ID) {
6047 if (ynl_attr_validate(yarg, attr))
6048 return MNL_CB_ERROR;
6049 dst->_present.trap_policer_id = 1;
6050 dst->trap_policer_id = mnl_attr_get_u32(attr);
6057 struct devlink_trap_policer_get_rsp *
6058 devlink_trap_policer_get(struct ynl_sock *ys,
6059 struct devlink_trap_policer_get_req *req)
6061 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
6062 struct devlink_trap_policer_get_rsp *rsp;
6063 struct nlmsghdr *nlh;
6066 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_TRAP_POLICER_GET, 1);
6067 ys->req_policy = &devlink_nest;
6068 yrs.yarg.rsp_policy = &devlink_nest;
6070 if (req->_present.bus_name_len)
6071 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6072 if (req->_present.dev_name_len)
6073 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6074 if (req->_present.trap_policer_id)
6075 mnl_attr_put_u32(nlh, DEVLINK_ATTR_TRAP_POLICER_ID, req->trap_policer_id);
6077 rsp = calloc(1, sizeof(*rsp));
6078 yrs.yarg.data = rsp;
6079 yrs.cb = devlink_trap_policer_get_rsp_parse;
6082 err = ynl_exec(ys, nlh, &yrs);
6089 devlink_trap_policer_get_rsp_free(rsp);
6093 /* DEVLINK_CMD_TRAP_POLICER_GET - dump */
6095 devlink_trap_policer_get_list_free(struct devlink_trap_policer_get_list *rsp)
6097 struct devlink_trap_policer_get_list *next = rsp;
6099 while ((void *)next != YNL_LIST_END) {
6103 free(rsp->obj.bus_name);
6104 free(rsp->obj.dev_name);
6109 struct devlink_trap_policer_get_list *
6110 devlink_trap_policer_get_dump(struct ynl_sock *ys,
6111 struct devlink_trap_policer_get_req_dump *req)
6113 struct ynl_dump_state yds = {};
6114 struct nlmsghdr *nlh;
6118 yds.alloc_sz = sizeof(struct devlink_trap_policer_get_list);
6119 yds.cb = devlink_trap_policer_get_rsp_parse;
6121 yds.rsp_policy = &devlink_nest;
6123 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_TRAP_POLICER_GET, 1);
6124 ys->req_policy = &devlink_nest;
6126 if (req->_present.bus_name_len)
6127 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6128 if (req->_present.dev_name_len)
6129 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6131 err = ynl_exec_dump(ys, nlh, &yds);
6138 devlink_trap_policer_get_list_free(yds.first);
6142 /* ============== DEVLINK_CMD_TRAP_POLICER_SET ============== */
6143 /* DEVLINK_CMD_TRAP_POLICER_SET - do */
6145 devlink_trap_policer_set_req_free(struct devlink_trap_policer_set_req *req)
6147 free(req->bus_name);
6148 free(req->dev_name);
6152 int devlink_trap_policer_set(struct ynl_sock *ys,
6153 struct devlink_trap_policer_set_req *req)
6155 struct nlmsghdr *nlh;
6158 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_TRAP_POLICER_SET, 1);
6159 ys->req_policy = &devlink_nest;
6161 if (req->_present.bus_name_len)
6162 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6163 if (req->_present.dev_name_len)
6164 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6165 if (req->_present.trap_policer_id)
6166 mnl_attr_put_u32(nlh, DEVLINK_ATTR_TRAP_POLICER_ID, req->trap_policer_id);
6167 if (req->_present.trap_policer_rate)
6168 mnl_attr_put_u64(nlh, DEVLINK_ATTR_TRAP_POLICER_RATE, req->trap_policer_rate);
6169 if (req->_present.trap_policer_burst)
6170 mnl_attr_put_u64(nlh, DEVLINK_ATTR_TRAP_POLICER_BURST, req->trap_policer_burst);
6172 err = ynl_exec(ys, nlh, NULL);
6179 /* ============== DEVLINK_CMD_HEALTH_REPORTER_TEST ============== */
6180 /* DEVLINK_CMD_HEALTH_REPORTER_TEST - do */
6182 devlink_health_reporter_test_req_free(struct devlink_health_reporter_test_req *req)
6184 free(req->bus_name);
6185 free(req->dev_name);
6186 free(req->health_reporter_name);
6190 int devlink_health_reporter_test(struct ynl_sock *ys,
6191 struct devlink_health_reporter_test_req *req)
6193 struct nlmsghdr *nlh;
6196 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_TEST, 1);
6197 ys->req_policy = &devlink_nest;
6199 if (req->_present.bus_name_len)
6200 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6201 if (req->_present.dev_name_len)
6202 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6203 if (req->_present.port_index)
6204 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
6205 if (req->_present.health_reporter_name_len)
6206 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
6208 err = ynl_exec(ys, nlh, NULL);
6215 /* ============== DEVLINK_CMD_RATE_GET ============== */
6216 /* DEVLINK_CMD_RATE_GET - do */
6217 void devlink_rate_get_req_free(struct devlink_rate_get_req *req)
6219 free(req->bus_name);
6220 free(req->dev_name);
6221 free(req->rate_node_name);
6225 void devlink_rate_get_rsp_free(struct devlink_rate_get_rsp *rsp)
6227 free(rsp->bus_name);
6228 free(rsp->dev_name);
6229 free(rsp->rate_node_name);
6233 int devlink_rate_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
6235 struct ynl_parse_arg *yarg = data;
6236 struct devlink_rate_get_rsp *dst;
6237 const struct nlattr *attr;
6241 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
6242 unsigned int type = mnl_attr_get_type(attr);
6244 if (type == DEVLINK_ATTR_BUS_NAME) {
6247 if (ynl_attr_validate(yarg, attr))
6248 return MNL_CB_ERROR;
6250 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
6251 dst->_present.bus_name_len = len;
6252 dst->bus_name = malloc(len + 1);
6253 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
6254 dst->bus_name[len] = 0;
6255 } else if (type == DEVLINK_ATTR_DEV_NAME) {
6258 if (ynl_attr_validate(yarg, attr))
6259 return MNL_CB_ERROR;
6261 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
6262 dst->_present.dev_name_len = len;
6263 dst->dev_name = malloc(len + 1);
6264 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
6265 dst->dev_name[len] = 0;
6266 } else if (type == DEVLINK_ATTR_PORT_INDEX) {
6267 if (ynl_attr_validate(yarg, attr))
6268 return MNL_CB_ERROR;
6269 dst->_present.port_index = 1;
6270 dst->port_index = mnl_attr_get_u32(attr);
6271 } else if (type == DEVLINK_ATTR_RATE_NODE_NAME) {
6274 if (ynl_attr_validate(yarg, attr))
6275 return MNL_CB_ERROR;
6277 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
6278 dst->_present.rate_node_name_len = len;
6279 dst->rate_node_name = malloc(len + 1);
6280 memcpy(dst->rate_node_name, mnl_attr_get_str(attr), len);
6281 dst->rate_node_name[len] = 0;
6288 struct devlink_rate_get_rsp *
6289 devlink_rate_get(struct ynl_sock *ys, struct devlink_rate_get_req *req)
6291 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
6292 struct devlink_rate_get_rsp *rsp;
6293 struct nlmsghdr *nlh;
6296 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_RATE_GET, 1);
6297 ys->req_policy = &devlink_nest;
6298 yrs.yarg.rsp_policy = &devlink_nest;
6300 if (req->_present.bus_name_len)
6301 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6302 if (req->_present.dev_name_len)
6303 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6304 if (req->_present.port_index)
6305 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
6306 if (req->_present.rate_node_name_len)
6307 mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_NODE_NAME, req->rate_node_name);
6309 rsp = calloc(1, sizeof(*rsp));
6310 yrs.yarg.data = rsp;
6311 yrs.cb = devlink_rate_get_rsp_parse;
6314 err = ynl_exec(ys, nlh, &yrs);
6321 devlink_rate_get_rsp_free(rsp);
6325 /* DEVLINK_CMD_RATE_GET - dump */
6326 void devlink_rate_get_list_free(struct devlink_rate_get_list *rsp)
6328 struct devlink_rate_get_list *next = rsp;
6330 while ((void *)next != YNL_LIST_END) {
6334 free(rsp->obj.bus_name);
6335 free(rsp->obj.dev_name);
6336 free(rsp->obj.rate_node_name);
6341 struct devlink_rate_get_list *
6342 devlink_rate_get_dump(struct ynl_sock *ys,
6343 struct devlink_rate_get_req_dump *req)
6345 struct ynl_dump_state yds = {};
6346 struct nlmsghdr *nlh;
6350 yds.alloc_sz = sizeof(struct devlink_rate_get_list);
6351 yds.cb = devlink_rate_get_rsp_parse;
6353 yds.rsp_policy = &devlink_nest;
6355 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_RATE_GET, 1);
6356 ys->req_policy = &devlink_nest;
6358 if (req->_present.bus_name_len)
6359 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6360 if (req->_present.dev_name_len)
6361 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6363 err = ynl_exec_dump(ys, nlh, &yds);
6370 devlink_rate_get_list_free(yds.first);
6374 /* ============== DEVLINK_CMD_RATE_SET ============== */
6375 /* DEVLINK_CMD_RATE_SET - do */
6376 void devlink_rate_set_req_free(struct devlink_rate_set_req *req)
6378 free(req->bus_name);
6379 free(req->dev_name);
6380 free(req->rate_node_name);
6381 free(req->rate_parent_node_name);
6385 int devlink_rate_set(struct ynl_sock *ys, struct devlink_rate_set_req *req)
6387 struct nlmsghdr *nlh;
6390 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_RATE_SET, 1);
6391 ys->req_policy = &devlink_nest;
6393 if (req->_present.bus_name_len)
6394 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6395 if (req->_present.dev_name_len)
6396 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6397 if (req->_present.rate_node_name_len)
6398 mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_NODE_NAME, req->rate_node_name);
6399 if (req->_present.rate_tx_share)
6400 mnl_attr_put_u64(nlh, DEVLINK_ATTR_RATE_TX_SHARE, req->rate_tx_share);
6401 if (req->_present.rate_tx_max)
6402 mnl_attr_put_u64(nlh, DEVLINK_ATTR_RATE_TX_MAX, req->rate_tx_max);
6403 if (req->_present.rate_tx_priority)
6404 mnl_attr_put_u32(nlh, DEVLINK_ATTR_RATE_TX_PRIORITY, req->rate_tx_priority);
6405 if (req->_present.rate_tx_weight)
6406 mnl_attr_put_u32(nlh, DEVLINK_ATTR_RATE_TX_WEIGHT, req->rate_tx_weight);
6407 if (req->_present.rate_parent_node_name_len)
6408 mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_PARENT_NODE_NAME, req->rate_parent_node_name);
6410 err = ynl_exec(ys, nlh, NULL);
6417 /* ============== DEVLINK_CMD_RATE_NEW ============== */
6418 /* DEVLINK_CMD_RATE_NEW - do */
6419 void devlink_rate_new_req_free(struct devlink_rate_new_req *req)
6421 free(req->bus_name);
6422 free(req->dev_name);
6423 free(req->rate_node_name);
6424 free(req->rate_parent_node_name);
6428 int devlink_rate_new(struct ynl_sock *ys, struct devlink_rate_new_req *req)
6430 struct nlmsghdr *nlh;
6433 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_RATE_NEW, 1);
6434 ys->req_policy = &devlink_nest;
6436 if (req->_present.bus_name_len)
6437 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6438 if (req->_present.dev_name_len)
6439 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6440 if (req->_present.rate_node_name_len)
6441 mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_NODE_NAME, req->rate_node_name);
6442 if (req->_present.rate_tx_share)
6443 mnl_attr_put_u64(nlh, DEVLINK_ATTR_RATE_TX_SHARE, req->rate_tx_share);
6444 if (req->_present.rate_tx_max)
6445 mnl_attr_put_u64(nlh, DEVLINK_ATTR_RATE_TX_MAX, req->rate_tx_max);
6446 if (req->_present.rate_tx_priority)
6447 mnl_attr_put_u32(nlh, DEVLINK_ATTR_RATE_TX_PRIORITY, req->rate_tx_priority);
6448 if (req->_present.rate_tx_weight)
6449 mnl_attr_put_u32(nlh, DEVLINK_ATTR_RATE_TX_WEIGHT, req->rate_tx_weight);
6450 if (req->_present.rate_parent_node_name_len)
6451 mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_PARENT_NODE_NAME, req->rate_parent_node_name);
6453 err = ynl_exec(ys, nlh, NULL);
6460 /* ============== DEVLINK_CMD_RATE_DEL ============== */
6461 /* DEVLINK_CMD_RATE_DEL - do */
6462 void devlink_rate_del_req_free(struct devlink_rate_del_req *req)
6464 free(req->bus_name);
6465 free(req->dev_name);
6466 free(req->rate_node_name);
6470 int devlink_rate_del(struct ynl_sock *ys, struct devlink_rate_del_req *req)
6472 struct nlmsghdr *nlh;
6475 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_RATE_DEL, 1);
6476 ys->req_policy = &devlink_nest;
6478 if (req->_present.bus_name_len)
6479 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6480 if (req->_present.dev_name_len)
6481 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6482 if (req->_present.rate_node_name_len)
6483 mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_NODE_NAME, req->rate_node_name);
6485 err = ynl_exec(ys, nlh, NULL);
6492 /* ============== DEVLINK_CMD_LINECARD_GET ============== */
6493 /* DEVLINK_CMD_LINECARD_GET - do */
6494 void devlink_linecard_get_req_free(struct devlink_linecard_get_req *req)
6496 free(req->bus_name);
6497 free(req->dev_name);
6501 void devlink_linecard_get_rsp_free(struct devlink_linecard_get_rsp *rsp)
6503 free(rsp->bus_name);
6504 free(rsp->dev_name);
6508 int devlink_linecard_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
6510 struct devlink_linecard_get_rsp *dst;
6511 struct ynl_parse_arg *yarg = data;
6512 const struct nlattr *attr;
6516 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
6517 unsigned int type = mnl_attr_get_type(attr);
6519 if (type == DEVLINK_ATTR_BUS_NAME) {
6522 if (ynl_attr_validate(yarg, attr))
6523 return MNL_CB_ERROR;
6525 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
6526 dst->_present.bus_name_len = len;
6527 dst->bus_name = malloc(len + 1);
6528 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
6529 dst->bus_name[len] = 0;
6530 } else if (type == DEVLINK_ATTR_DEV_NAME) {
6533 if (ynl_attr_validate(yarg, attr))
6534 return MNL_CB_ERROR;
6536 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
6537 dst->_present.dev_name_len = len;
6538 dst->dev_name = malloc(len + 1);
6539 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
6540 dst->dev_name[len] = 0;
6541 } else if (type == DEVLINK_ATTR_LINECARD_INDEX) {
6542 if (ynl_attr_validate(yarg, attr))
6543 return MNL_CB_ERROR;
6544 dst->_present.linecard_index = 1;
6545 dst->linecard_index = mnl_attr_get_u32(attr);
6552 struct devlink_linecard_get_rsp *
6553 devlink_linecard_get(struct ynl_sock *ys, struct devlink_linecard_get_req *req)
6555 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
6556 struct devlink_linecard_get_rsp *rsp;
6557 struct nlmsghdr *nlh;
6560 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_LINECARD_GET, 1);
6561 ys->req_policy = &devlink_nest;
6562 yrs.yarg.rsp_policy = &devlink_nest;
6564 if (req->_present.bus_name_len)
6565 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6566 if (req->_present.dev_name_len)
6567 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6568 if (req->_present.linecard_index)
6569 mnl_attr_put_u32(nlh, DEVLINK_ATTR_LINECARD_INDEX, req->linecard_index);
6571 rsp = calloc(1, sizeof(*rsp));
6572 yrs.yarg.data = rsp;
6573 yrs.cb = devlink_linecard_get_rsp_parse;
6576 err = ynl_exec(ys, nlh, &yrs);
6583 devlink_linecard_get_rsp_free(rsp);
6587 /* DEVLINK_CMD_LINECARD_GET - dump */
6588 void devlink_linecard_get_list_free(struct devlink_linecard_get_list *rsp)
6590 struct devlink_linecard_get_list *next = rsp;
6592 while ((void *)next != YNL_LIST_END) {
6596 free(rsp->obj.bus_name);
6597 free(rsp->obj.dev_name);
6602 struct devlink_linecard_get_list *
6603 devlink_linecard_get_dump(struct ynl_sock *ys,
6604 struct devlink_linecard_get_req_dump *req)
6606 struct ynl_dump_state yds = {};
6607 struct nlmsghdr *nlh;
6611 yds.alloc_sz = sizeof(struct devlink_linecard_get_list);
6612 yds.cb = devlink_linecard_get_rsp_parse;
6614 yds.rsp_policy = &devlink_nest;
6616 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_LINECARD_GET, 1);
6617 ys->req_policy = &devlink_nest;
6619 if (req->_present.bus_name_len)
6620 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6621 if (req->_present.dev_name_len)
6622 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6624 err = ynl_exec_dump(ys, nlh, &yds);
6631 devlink_linecard_get_list_free(yds.first);
6635 /* ============== DEVLINK_CMD_LINECARD_SET ============== */
6636 /* DEVLINK_CMD_LINECARD_SET - do */
6637 void devlink_linecard_set_req_free(struct devlink_linecard_set_req *req)
6639 free(req->bus_name);
6640 free(req->dev_name);
6641 free(req->linecard_type);
6645 int devlink_linecard_set(struct ynl_sock *ys,
6646 struct devlink_linecard_set_req *req)
6648 struct nlmsghdr *nlh;
6651 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_LINECARD_SET, 1);
6652 ys->req_policy = &devlink_nest;
6654 if (req->_present.bus_name_len)
6655 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6656 if (req->_present.dev_name_len)
6657 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6658 if (req->_present.linecard_index)
6659 mnl_attr_put_u32(nlh, DEVLINK_ATTR_LINECARD_INDEX, req->linecard_index);
6660 if (req->_present.linecard_type_len)
6661 mnl_attr_put_strz(nlh, DEVLINK_ATTR_LINECARD_TYPE, req->linecard_type);
6663 err = ynl_exec(ys, nlh, NULL);
6670 /* ============== DEVLINK_CMD_SELFTESTS_GET ============== */
6671 /* DEVLINK_CMD_SELFTESTS_GET - do */
6672 void devlink_selftests_get_req_free(struct devlink_selftests_get_req *req)
6674 free(req->bus_name);
6675 free(req->dev_name);
6679 void devlink_selftests_get_rsp_free(struct devlink_selftests_get_rsp *rsp)
6681 free(rsp->bus_name);
6682 free(rsp->dev_name);
6686 int devlink_selftests_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
6688 struct devlink_selftests_get_rsp *dst;
6689 struct ynl_parse_arg *yarg = data;
6690 const struct nlattr *attr;
6694 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
6695 unsigned int type = mnl_attr_get_type(attr);
6697 if (type == DEVLINK_ATTR_BUS_NAME) {
6700 if (ynl_attr_validate(yarg, attr))
6701 return MNL_CB_ERROR;
6703 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
6704 dst->_present.bus_name_len = len;
6705 dst->bus_name = malloc(len + 1);
6706 memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
6707 dst->bus_name[len] = 0;
6708 } else if (type == DEVLINK_ATTR_DEV_NAME) {
6711 if (ynl_attr_validate(yarg, attr))
6712 return MNL_CB_ERROR;
6714 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
6715 dst->_present.dev_name_len = len;
6716 dst->dev_name = malloc(len + 1);
6717 memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
6718 dst->dev_name[len] = 0;
6725 struct devlink_selftests_get_rsp *
6726 devlink_selftests_get(struct ynl_sock *ys,
6727 struct devlink_selftests_get_req *req)
6729 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
6730 struct devlink_selftests_get_rsp *rsp;
6731 struct nlmsghdr *nlh;
6734 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SELFTESTS_GET, 1);
6735 ys->req_policy = &devlink_nest;
6736 yrs.yarg.rsp_policy = &devlink_nest;
6738 if (req->_present.bus_name_len)
6739 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6740 if (req->_present.dev_name_len)
6741 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6743 rsp = calloc(1, sizeof(*rsp));
6744 yrs.yarg.data = rsp;
6745 yrs.cb = devlink_selftests_get_rsp_parse;
6746 yrs.rsp_cmd = DEVLINK_CMD_SELFTESTS_GET;
6748 err = ynl_exec(ys, nlh, &yrs);
6755 devlink_selftests_get_rsp_free(rsp);
6759 /* DEVLINK_CMD_SELFTESTS_GET - dump */
6760 void devlink_selftests_get_list_free(struct devlink_selftests_get_list *rsp)
6762 struct devlink_selftests_get_list *next = rsp;
6764 while ((void *)next != YNL_LIST_END) {
6768 free(rsp->obj.bus_name);
6769 free(rsp->obj.dev_name);
6774 struct devlink_selftests_get_list *
6775 devlink_selftests_get_dump(struct ynl_sock *ys)
6777 struct ynl_dump_state yds = {};
6778 struct nlmsghdr *nlh;
6782 yds.alloc_sz = sizeof(struct devlink_selftests_get_list);
6783 yds.cb = devlink_selftests_get_rsp_parse;
6784 yds.rsp_cmd = DEVLINK_CMD_SELFTESTS_GET;
6785 yds.rsp_policy = &devlink_nest;
6787 nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SELFTESTS_GET, 1);
6789 err = ynl_exec_dump(ys, nlh, &yds);
6796 devlink_selftests_get_list_free(yds.first);
6800 /* ============== DEVLINK_CMD_SELFTESTS_RUN ============== */
6801 /* DEVLINK_CMD_SELFTESTS_RUN - do */
6802 void devlink_selftests_run_req_free(struct devlink_selftests_run_req *req)
6804 free(req->bus_name);
6805 free(req->dev_name);
6806 devlink_dl_selftest_id_free(&req->selftests);
6810 int devlink_selftests_run(struct ynl_sock *ys,
6811 struct devlink_selftests_run_req *req)
6813 struct nlmsghdr *nlh;
6816 nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SELFTESTS_RUN, 1);
6817 ys->req_policy = &devlink_nest;
6819 if (req->_present.bus_name_len)
6820 mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
6821 if (req->_present.dev_name_len)
6822 mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
6823 if (req->_present.selftests)
6824 devlink_dl_selftest_id_put(nlh, DEVLINK_ATTR_SELFTESTS, &req->selftests);
6826 err = ynl_exec(ys, nlh, NULL);
6833 const struct ynl_family ynl_devlink_family = {