162306a36Sopenharmony_ci// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
262306a36Sopenharmony_ci/* Do not edit directly, auto-generated from: */
362306a36Sopenharmony_ci/*	Documentation/netlink/specs/ethtool.yaml */
462306a36Sopenharmony_ci/* YNL-GEN user source */
562306a36Sopenharmony_ci/* YNL-ARG --user-header linux/ethtool_netlink.h --exclude-op stats-get */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include <stdlib.h>
862306a36Sopenharmony_ci#include <string.h>
962306a36Sopenharmony_ci#include "ethtool-user.h"
1062306a36Sopenharmony_ci#include "ynl.h"
1162306a36Sopenharmony_ci#include <linux/ethtool.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <libmnl/libmnl.h>
1462306a36Sopenharmony_ci#include <linux/genetlink.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include "linux/ethtool_netlink.h"
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* Enums */
1962306a36Sopenharmony_cistatic const char * const ethtool_op_strmap[] = {
2062306a36Sopenharmony_ci	[ETHTOOL_MSG_STRSET_GET] = "strset-get",
2162306a36Sopenharmony_ci	[ETHTOOL_MSG_LINKINFO_GET] = "linkinfo-get",
2262306a36Sopenharmony_ci	[3] = "linkinfo-ntf",
2362306a36Sopenharmony_ci	[ETHTOOL_MSG_LINKMODES_GET] = "linkmodes-get",
2462306a36Sopenharmony_ci	[5] = "linkmodes-ntf",
2562306a36Sopenharmony_ci	[ETHTOOL_MSG_LINKSTATE_GET] = "linkstate-get",
2662306a36Sopenharmony_ci	[ETHTOOL_MSG_DEBUG_GET] = "debug-get",
2762306a36Sopenharmony_ci	[8] = "debug-ntf",
2862306a36Sopenharmony_ci	[ETHTOOL_MSG_WOL_GET] = "wol-get",
2962306a36Sopenharmony_ci	[10] = "wol-ntf",
3062306a36Sopenharmony_ci	[ETHTOOL_MSG_FEATURES_GET] = "features-get",
3162306a36Sopenharmony_ci	[ETHTOOL_MSG_FEATURES_SET] = "features-set",
3262306a36Sopenharmony_ci	[13] = "features-ntf",
3362306a36Sopenharmony_ci	[14] = "privflags-get",
3462306a36Sopenharmony_ci	[15] = "privflags-ntf",
3562306a36Sopenharmony_ci	[16] = "rings-get",
3662306a36Sopenharmony_ci	[17] = "rings-ntf",
3762306a36Sopenharmony_ci	[18] = "channels-get",
3862306a36Sopenharmony_ci	[19] = "channels-ntf",
3962306a36Sopenharmony_ci	[20] = "coalesce-get",
4062306a36Sopenharmony_ci	[21] = "coalesce-ntf",
4162306a36Sopenharmony_ci	[22] = "pause-get",
4262306a36Sopenharmony_ci	[23] = "pause-ntf",
4362306a36Sopenharmony_ci	[24] = "eee-get",
4462306a36Sopenharmony_ci	[25] = "eee-ntf",
4562306a36Sopenharmony_ci	[26] = "tsinfo-get",
4662306a36Sopenharmony_ci	[27] = "cable-test-ntf",
4762306a36Sopenharmony_ci	[28] = "cable-test-tdr-ntf",
4862306a36Sopenharmony_ci	[29] = "tunnel-info-get",
4962306a36Sopenharmony_ci	[30] = "fec-get",
5062306a36Sopenharmony_ci	[31] = "fec-ntf",
5162306a36Sopenharmony_ci	[32] = "module-eeprom-get",
5262306a36Sopenharmony_ci	[34] = "phc-vclocks-get",
5362306a36Sopenharmony_ci	[35] = "module-get",
5462306a36Sopenharmony_ci	[36] = "module-ntf",
5562306a36Sopenharmony_ci	[37] = "pse-get",
5662306a36Sopenharmony_ci	[ETHTOOL_MSG_RSS_GET] = "rss-get",
5762306a36Sopenharmony_ci	[ETHTOOL_MSG_PLCA_GET_CFG] = "plca-get-cfg",
5862306a36Sopenharmony_ci	[40] = "plca-get-status",
5962306a36Sopenharmony_ci	[41] = "plca-ntf",
6062306a36Sopenharmony_ci	[ETHTOOL_MSG_MM_GET] = "mm-get",
6162306a36Sopenharmony_ci	[43] = "mm-ntf",
6262306a36Sopenharmony_ci};
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ciconst char *ethtool_op_str(int op)
6562306a36Sopenharmony_ci{
6662306a36Sopenharmony_ci	if (op < 0 || op >= (int)MNL_ARRAY_SIZE(ethtool_op_strmap))
6762306a36Sopenharmony_ci		return NULL;
6862306a36Sopenharmony_ci	return ethtool_op_strmap[op];
6962306a36Sopenharmony_ci}
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_cistatic const char * const ethtool_udp_tunnel_type_strmap[] = {
7262306a36Sopenharmony_ci	[0] = "vxlan",
7362306a36Sopenharmony_ci	[1] = "geneve",
7462306a36Sopenharmony_ci	[2] = "vxlan-gpe",
7562306a36Sopenharmony_ci};
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ciconst char *ethtool_udp_tunnel_type_str(int value)
7862306a36Sopenharmony_ci{
7962306a36Sopenharmony_ci	if (value < 0 || value >= (int)MNL_ARRAY_SIZE(ethtool_udp_tunnel_type_strmap))
8062306a36Sopenharmony_ci		return NULL;
8162306a36Sopenharmony_ci	return ethtool_udp_tunnel_type_strmap[value];
8262306a36Sopenharmony_ci}
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_cistatic const char * const ethtool_stringset_strmap[] = {
8562306a36Sopenharmony_ci};
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ciconst char *ethtool_stringset_str(enum ethtool_stringset value)
8862306a36Sopenharmony_ci{
8962306a36Sopenharmony_ci	if (value < 0 || value >= (int)MNL_ARRAY_SIZE(ethtool_stringset_strmap))
9062306a36Sopenharmony_ci		return NULL;
9162306a36Sopenharmony_ci	return ethtool_stringset_strmap[value];
9262306a36Sopenharmony_ci}
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci/* Policies */
9562306a36Sopenharmony_cistruct ynl_policy_attr ethtool_header_policy[ETHTOOL_A_HEADER_MAX + 1] = {
9662306a36Sopenharmony_ci	[ETHTOOL_A_HEADER_DEV_INDEX] = { .name = "dev-index", .type = YNL_PT_U32, },
9762306a36Sopenharmony_ci	[ETHTOOL_A_HEADER_DEV_NAME] = { .name = "dev-name", .type = YNL_PT_NUL_STR, },
9862306a36Sopenharmony_ci	[ETHTOOL_A_HEADER_FLAGS] = { .name = "flags", .type = YNL_PT_U32, },
9962306a36Sopenharmony_ci};
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cistruct ynl_policy_nest ethtool_header_nest = {
10262306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_HEADER_MAX,
10362306a36Sopenharmony_ci	.table = ethtool_header_policy,
10462306a36Sopenharmony_ci};
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_cistruct ynl_policy_attr ethtool_pause_stat_policy[ETHTOOL_A_PAUSE_STAT_MAX + 1] = {
10762306a36Sopenharmony_ci	[ETHTOOL_A_PAUSE_STAT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, },
10862306a36Sopenharmony_ci	[ETHTOOL_A_PAUSE_STAT_TX_FRAMES] = { .name = "tx-frames", .type = YNL_PT_U64, },
10962306a36Sopenharmony_ci	[ETHTOOL_A_PAUSE_STAT_RX_FRAMES] = { .name = "rx-frames", .type = YNL_PT_U64, },
11062306a36Sopenharmony_ci};
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_pause_stat_nest = {
11362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_PAUSE_STAT_MAX,
11462306a36Sopenharmony_ci	.table = ethtool_pause_stat_policy,
11562306a36Sopenharmony_ci};
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_cable_test_tdr_cfg_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX + 1] = {
11862306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST] = { .name = "first", .type = YNL_PT_U32, },
11962306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST] = { .name = "last", .type = YNL_PT_U32, },
12062306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP] = { .name = "step", .type = YNL_PT_U32, },
12162306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR] = { .name = "pair", .type = YNL_PT_U8, },
12262306a36Sopenharmony_ci};
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_cistruct ynl_policy_nest ethtool_cable_test_tdr_cfg_nest = {
12562306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX,
12662306a36Sopenharmony_ci	.table = ethtool_cable_test_tdr_cfg_policy,
12762306a36Sopenharmony_ci};
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_cistruct ynl_policy_attr ethtool_fec_stat_policy[ETHTOOL_A_FEC_STAT_MAX + 1] = {
13062306a36Sopenharmony_ci	[ETHTOOL_A_FEC_STAT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, },
13162306a36Sopenharmony_ci	[ETHTOOL_A_FEC_STAT_CORRECTED] = { .name = "corrected", .type = YNL_PT_BINARY,},
13262306a36Sopenharmony_ci	[ETHTOOL_A_FEC_STAT_UNCORR] = { .name = "uncorr", .type = YNL_PT_BINARY,},
13362306a36Sopenharmony_ci	[ETHTOOL_A_FEC_STAT_CORR_BITS] = { .name = "corr-bits", .type = YNL_PT_BINARY,},
13462306a36Sopenharmony_ci};
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_cistruct ynl_policy_nest ethtool_fec_stat_nest = {
13762306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_FEC_STAT_MAX,
13862306a36Sopenharmony_ci	.table = ethtool_fec_stat_policy,
13962306a36Sopenharmony_ci};
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_cistruct ynl_policy_attr ethtool_mm_stat_policy[ETHTOOL_A_MM_STAT_MAX + 1] = {
14262306a36Sopenharmony_ci	[ETHTOOL_A_MM_STAT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, },
14362306a36Sopenharmony_ci	[ETHTOOL_A_MM_STAT_REASSEMBLY_ERRORS] = { .name = "reassembly-errors", .type = YNL_PT_U64, },
14462306a36Sopenharmony_ci	[ETHTOOL_A_MM_STAT_SMD_ERRORS] = { .name = "smd-errors", .type = YNL_PT_U64, },
14562306a36Sopenharmony_ci	[ETHTOOL_A_MM_STAT_REASSEMBLY_OK] = { .name = "reassembly-ok", .type = YNL_PT_U64, },
14662306a36Sopenharmony_ci	[ETHTOOL_A_MM_STAT_RX_FRAG_COUNT] = { .name = "rx-frag-count", .type = YNL_PT_U64, },
14762306a36Sopenharmony_ci	[ETHTOOL_A_MM_STAT_TX_FRAG_COUNT] = { .name = "tx-frag-count", .type = YNL_PT_U64, },
14862306a36Sopenharmony_ci	[ETHTOOL_A_MM_STAT_HOLD_COUNT] = { .name = "hold-count", .type = YNL_PT_U64, },
14962306a36Sopenharmony_ci};
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_cistruct ynl_policy_nest ethtool_mm_stat_nest = {
15262306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_MM_STAT_MAX,
15362306a36Sopenharmony_ci	.table = ethtool_mm_stat_policy,
15462306a36Sopenharmony_ci};
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_cistruct ynl_policy_attr ethtool_cable_result_policy[ETHTOOL_A_CABLE_RESULT_MAX + 1] = {
15762306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_RESULT_PAIR] = { .name = "pair", .type = YNL_PT_U8, },
15862306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_RESULT_CODE] = { .name = "code", .type = YNL_PT_U8, },
15962306a36Sopenharmony_ci};
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_cistruct ynl_policy_nest ethtool_cable_result_nest = {
16262306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_CABLE_RESULT_MAX,
16362306a36Sopenharmony_ci	.table = ethtool_cable_result_policy,
16462306a36Sopenharmony_ci};
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_cistruct ynl_policy_attr ethtool_cable_fault_length_policy[ETHTOOL_A_CABLE_FAULT_LENGTH_MAX + 1] = {
16762306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR] = { .name = "pair", .type = YNL_PT_U8, },
16862306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_FAULT_LENGTH_CM] = { .name = "cm", .type = YNL_PT_U32, },
16962306a36Sopenharmony_ci};
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_cistruct ynl_policy_nest ethtool_cable_fault_length_nest = {
17262306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_CABLE_FAULT_LENGTH_MAX,
17362306a36Sopenharmony_ci	.table = ethtool_cable_fault_length_policy,
17462306a36Sopenharmony_ci};
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_cistruct ynl_policy_attr ethtool_bitset_bit_policy[ETHTOOL_A_BITSET_BIT_MAX + 1] = {
17762306a36Sopenharmony_ci	[ETHTOOL_A_BITSET_BIT_INDEX] = { .name = "index", .type = YNL_PT_U32, },
17862306a36Sopenharmony_ci	[ETHTOOL_A_BITSET_BIT_NAME] = { .name = "name", .type = YNL_PT_NUL_STR, },
17962306a36Sopenharmony_ci	[ETHTOOL_A_BITSET_BIT_VALUE] = { .name = "value", .type = YNL_PT_FLAG, },
18062306a36Sopenharmony_ci};
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_bitset_bit_nest = {
18362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_BITSET_BIT_MAX,
18462306a36Sopenharmony_ci	.table = ethtool_bitset_bit_policy,
18562306a36Sopenharmony_ci};
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_tunnel_udp_entry_policy[ETHTOOL_A_TUNNEL_UDP_ENTRY_MAX + 1] = {
18862306a36Sopenharmony_ci	[ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT] = { .name = "port", .type = YNL_PT_U16, },
18962306a36Sopenharmony_ci	[ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE] = { .name = "type", .type = YNL_PT_U32, },
19062306a36Sopenharmony_ci};
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_tunnel_udp_entry_nest = {
19362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_TUNNEL_UDP_ENTRY_MAX,
19462306a36Sopenharmony_ci	.table = ethtool_tunnel_udp_entry_policy,
19562306a36Sopenharmony_ci};
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_string_policy[ETHTOOL_A_STRING_MAX + 1] = {
19862306a36Sopenharmony_ci	[ETHTOOL_A_STRING_INDEX] = { .name = "index", .type = YNL_PT_U32, },
19962306a36Sopenharmony_ci	[ETHTOOL_A_STRING_VALUE] = { .name = "value", .type = YNL_PT_NUL_STR, },
20062306a36Sopenharmony_ci};
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_string_nest = {
20362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_STRING_MAX,
20462306a36Sopenharmony_ci	.table = ethtool_string_policy,
20562306a36Sopenharmony_ci};
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_cable_nest_policy[ETHTOOL_A_CABLE_NEST_MAX + 1] = {
20862306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_NEST_RESULT] = { .name = "result", .type = YNL_PT_NEST, .nest = &ethtool_cable_result_nest, },
20962306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_NEST_FAULT_LENGTH] = { .name = "fault-length", .type = YNL_PT_NEST, .nest = &ethtool_cable_fault_length_nest, },
21062306a36Sopenharmony_ci};
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_cable_nest_nest = {
21362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_CABLE_NEST_MAX,
21462306a36Sopenharmony_ci	.table = ethtool_cable_nest_policy,
21562306a36Sopenharmony_ci};
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_bitset_bits_policy[ETHTOOL_A_BITSET_BITS_MAX + 1] = {
21862306a36Sopenharmony_ci	[ETHTOOL_A_BITSET_BITS_BIT] = { .name = "bit", .type = YNL_PT_NEST, .nest = &ethtool_bitset_bit_nest, },
21962306a36Sopenharmony_ci};
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_cistruct ynl_policy_nest ethtool_bitset_bits_nest = {
22262306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_BITSET_BITS_MAX,
22362306a36Sopenharmony_ci	.table = ethtool_bitset_bits_policy,
22462306a36Sopenharmony_ci};
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_cistruct ynl_policy_attr ethtool_strings_policy[ETHTOOL_A_STRINGS_MAX + 1] = {
22762306a36Sopenharmony_ci	[ETHTOOL_A_STRINGS_STRING] = { .name = "string", .type = YNL_PT_NEST, .nest = &ethtool_string_nest, },
22862306a36Sopenharmony_ci};
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_cistruct ynl_policy_nest ethtool_strings_nest = {
23162306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_STRINGS_MAX,
23262306a36Sopenharmony_ci	.table = ethtool_strings_policy,
23362306a36Sopenharmony_ci};
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_cistruct ynl_policy_attr ethtool_bitset_policy[ETHTOOL_A_BITSET_MAX + 1] = {
23662306a36Sopenharmony_ci	[ETHTOOL_A_BITSET_NOMASK] = { .name = "nomask", .type = YNL_PT_FLAG, },
23762306a36Sopenharmony_ci	[ETHTOOL_A_BITSET_SIZE] = { .name = "size", .type = YNL_PT_U32, },
23862306a36Sopenharmony_ci	[ETHTOOL_A_BITSET_BITS] = { .name = "bits", .type = YNL_PT_NEST, .nest = &ethtool_bitset_bits_nest, },
23962306a36Sopenharmony_ci};
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_cistruct ynl_policy_nest ethtool_bitset_nest = {
24262306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_BITSET_MAX,
24362306a36Sopenharmony_ci	.table = ethtool_bitset_policy,
24462306a36Sopenharmony_ci};
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_cistruct ynl_policy_attr ethtool_stringset_policy[ETHTOOL_A_STRINGSET_MAX + 1] = {
24762306a36Sopenharmony_ci	[ETHTOOL_A_STRINGSET_ID] = { .name = "id", .type = YNL_PT_U32, },
24862306a36Sopenharmony_ci	[ETHTOOL_A_STRINGSET_COUNT] = { .name = "count", .type = YNL_PT_U32, },
24962306a36Sopenharmony_ci	[ETHTOOL_A_STRINGSET_STRINGS] = { .name = "strings", .type = YNL_PT_NEST, .nest = &ethtool_strings_nest, },
25062306a36Sopenharmony_ci};
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_stringset_nest = {
25362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_STRINGSET_MAX,
25462306a36Sopenharmony_ci	.table = ethtool_stringset_policy,
25562306a36Sopenharmony_ci};
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_tunnel_udp_table_policy[ETHTOOL_A_TUNNEL_UDP_TABLE_MAX + 1] = {
25862306a36Sopenharmony_ci	[ETHTOOL_A_TUNNEL_UDP_TABLE_SIZE] = { .name = "size", .type = YNL_PT_U32, },
25962306a36Sopenharmony_ci	[ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES] = { .name = "types", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
26062306a36Sopenharmony_ci	[ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY] = { .name = "entry", .type = YNL_PT_NEST, .nest = &ethtool_tunnel_udp_entry_nest, },
26162306a36Sopenharmony_ci};
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_cistruct ynl_policy_nest ethtool_tunnel_udp_table_nest = {
26462306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_TUNNEL_UDP_TABLE_MAX,
26562306a36Sopenharmony_ci	.table = ethtool_tunnel_udp_table_policy,
26662306a36Sopenharmony_ci};
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_cistruct ynl_policy_attr ethtool_stringsets_policy[ETHTOOL_A_STRINGSETS_MAX + 1] = {
26962306a36Sopenharmony_ci	[ETHTOOL_A_STRINGSETS_STRINGSET] = { .name = "stringset", .type = YNL_PT_NEST, .nest = &ethtool_stringset_nest, },
27062306a36Sopenharmony_ci};
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_stringsets_nest = {
27362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_STRINGSETS_MAX,
27462306a36Sopenharmony_ci	.table = ethtool_stringsets_policy,
27562306a36Sopenharmony_ci};
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_tunnel_udp_policy[ETHTOOL_A_TUNNEL_UDP_MAX + 1] = {
27862306a36Sopenharmony_ci	[ETHTOOL_A_TUNNEL_UDP_TABLE] = { .name = "table", .type = YNL_PT_NEST, .nest = &ethtool_tunnel_udp_table_nest, },
27962306a36Sopenharmony_ci};
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_cistruct ynl_policy_nest ethtool_tunnel_udp_nest = {
28262306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_TUNNEL_UDP_MAX,
28362306a36Sopenharmony_ci	.table = ethtool_tunnel_udp_policy,
28462306a36Sopenharmony_ci};
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_cistruct ynl_policy_attr ethtool_strset_policy[ETHTOOL_A_STRSET_MAX + 1] = {
28762306a36Sopenharmony_ci	[ETHTOOL_A_STRSET_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
28862306a36Sopenharmony_ci	[ETHTOOL_A_STRSET_STRINGSETS] = { .name = "stringsets", .type = YNL_PT_NEST, .nest = &ethtool_stringsets_nest, },
28962306a36Sopenharmony_ci	[ETHTOOL_A_STRSET_COUNTS_ONLY] = { .name = "counts-only", .type = YNL_PT_FLAG, },
29062306a36Sopenharmony_ci};
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_strset_nest = {
29362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_STRSET_MAX,
29462306a36Sopenharmony_ci	.table = ethtool_strset_policy,
29562306a36Sopenharmony_ci};
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_linkinfo_policy[ETHTOOL_A_LINKINFO_MAX + 1] = {
29862306a36Sopenharmony_ci	[ETHTOOL_A_LINKINFO_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
29962306a36Sopenharmony_ci	[ETHTOOL_A_LINKINFO_PORT] = { .name = "port", .type = YNL_PT_U8, },
30062306a36Sopenharmony_ci	[ETHTOOL_A_LINKINFO_PHYADDR] = { .name = "phyaddr", .type = YNL_PT_U8, },
30162306a36Sopenharmony_ci	[ETHTOOL_A_LINKINFO_TP_MDIX] = { .name = "tp-mdix", .type = YNL_PT_U8, },
30262306a36Sopenharmony_ci	[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] = { .name = "tp-mdix-ctrl", .type = YNL_PT_U8, },
30362306a36Sopenharmony_ci	[ETHTOOL_A_LINKINFO_TRANSCEIVER] = { .name = "transceiver", .type = YNL_PT_U8, },
30462306a36Sopenharmony_ci};
30562306a36Sopenharmony_ci
30662306a36Sopenharmony_cistruct ynl_policy_nest ethtool_linkinfo_nest = {
30762306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_LINKINFO_MAX,
30862306a36Sopenharmony_ci	.table = ethtool_linkinfo_policy,
30962306a36Sopenharmony_ci};
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_cistruct ynl_policy_attr ethtool_linkmodes_policy[ETHTOOL_A_LINKMODES_MAX + 1] = {
31262306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
31362306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_AUTONEG] = { .name = "autoneg", .type = YNL_PT_U8, },
31462306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_OURS] = { .name = "ours", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
31562306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_PEER] = { .name = "peer", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
31662306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_SPEED] = { .name = "speed", .type = YNL_PT_U32, },
31762306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_DUPLEX] = { .name = "duplex", .type = YNL_PT_U8, },
31862306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG] = { .name = "master-slave-cfg", .type = YNL_PT_U8, },
31962306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE] = { .name = "master-slave-state", .type = YNL_PT_U8, },
32062306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_LANES] = { .name = "lanes", .type = YNL_PT_U32, },
32162306a36Sopenharmony_ci	[ETHTOOL_A_LINKMODES_RATE_MATCHING] = { .name = "rate-matching", .type = YNL_PT_U8, },
32262306a36Sopenharmony_ci};
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_cistruct ynl_policy_nest ethtool_linkmodes_nest = {
32562306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_LINKMODES_MAX,
32662306a36Sopenharmony_ci	.table = ethtool_linkmodes_policy,
32762306a36Sopenharmony_ci};
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_cistruct ynl_policy_attr ethtool_linkstate_policy[ETHTOOL_A_LINKSTATE_MAX + 1] = {
33062306a36Sopenharmony_ci	[ETHTOOL_A_LINKSTATE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
33162306a36Sopenharmony_ci	[ETHTOOL_A_LINKSTATE_LINK] = { .name = "link", .type = YNL_PT_U8, },
33262306a36Sopenharmony_ci	[ETHTOOL_A_LINKSTATE_SQI] = { .name = "sqi", .type = YNL_PT_U32, },
33362306a36Sopenharmony_ci	[ETHTOOL_A_LINKSTATE_SQI_MAX] = { .name = "sqi-max", .type = YNL_PT_U32, },
33462306a36Sopenharmony_ci	[ETHTOOL_A_LINKSTATE_EXT_STATE] = { .name = "ext-state", .type = YNL_PT_U8, },
33562306a36Sopenharmony_ci	[ETHTOOL_A_LINKSTATE_EXT_SUBSTATE] = { .name = "ext-substate", .type = YNL_PT_U8, },
33662306a36Sopenharmony_ci	[ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT] = { .name = "ext-down-cnt", .type = YNL_PT_U32, },
33762306a36Sopenharmony_ci};
33862306a36Sopenharmony_ci
33962306a36Sopenharmony_cistruct ynl_policy_nest ethtool_linkstate_nest = {
34062306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_LINKSTATE_MAX,
34162306a36Sopenharmony_ci	.table = ethtool_linkstate_policy,
34262306a36Sopenharmony_ci};
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_cistruct ynl_policy_attr ethtool_debug_policy[ETHTOOL_A_DEBUG_MAX + 1] = {
34562306a36Sopenharmony_ci	[ETHTOOL_A_DEBUG_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
34662306a36Sopenharmony_ci	[ETHTOOL_A_DEBUG_MSGMASK] = { .name = "msgmask", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
34762306a36Sopenharmony_ci};
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_cistruct ynl_policy_nest ethtool_debug_nest = {
35062306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_DEBUG_MAX,
35162306a36Sopenharmony_ci	.table = ethtool_debug_policy,
35262306a36Sopenharmony_ci};
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_cistruct ynl_policy_attr ethtool_wol_policy[ETHTOOL_A_WOL_MAX + 1] = {
35562306a36Sopenharmony_ci	[ETHTOOL_A_WOL_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
35662306a36Sopenharmony_ci	[ETHTOOL_A_WOL_MODES] = { .name = "modes", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
35762306a36Sopenharmony_ci	[ETHTOOL_A_WOL_SOPASS] = { .name = "sopass", .type = YNL_PT_BINARY,},
35862306a36Sopenharmony_ci};
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_cistruct ynl_policy_nest ethtool_wol_nest = {
36162306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_WOL_MAX,
36262306a36Sopenharmony_ci	.table = ethtool_wol_policy,
36362306a36Sopenharmony_ci};
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_cistruct ynl_policy_attr ethtool_features_policy[ETHTOOL_A_FEATURES_MAX + 1] = {
36662306a36Sopenharmony_ci	[ETHTOOL_A_FEATURES_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
36762306a36Sopenharmony_ci	[ETHTOOL_A_FEATURES_HW] = { .name = "hw", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
36862306a36Sopenharmony_ci	[ETHTOOL_A_FEATURES_WANTED] = { .name = "wanted", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
36962306a36Sopenharmony_ci	[ETHTOOL_A_FEATURES_ACTIVE] = { .name = "active", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
37062306a36Sopenharmony_ci	[ETHTOOL_A_FEATURES_NOCHANGE] = { .name = "nochange", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
37162306a36Sopenharmony_ci};
37262306a36Sopenharmony_ci
37362306a36Sopenharmony_cistruct ynl_policy_nest ethtool_features_nest = {
37462306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_FEATURES_MAX,
37562306a36Sopenharmony_ci	.table = ethtool_features_policy,
37662306a36Sopenharmony_ci};
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_cistruct ynl_policy_attr ethtool_privflags_policy[ETHTOOL_A_PRIVFLAGS_MAX + 1] = {
37962306a36Sopenharmony_ci	[ETHTOOL_A_PRIVFLAGS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
38062306a36Sopenharmony_ci	[ETHTOOL_A_PRIVFLAGS_FLAGS] = { .name = "flags", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
38162306a36Sopenharmony_ci};
38262306a36Sopenharmony_ci
38362306a36Sopenharmony_cistruct ynl_policy_nest ethtool_privflags_nest = {
38462306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_PRIVFLAGS_MAX,
38562306a36Sopenharmony_ci	.table = ethtool_privflags_policy,
38662306a36Sopenharmony_ci};
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_cistruct ynl_policy_attr ethtool_rings_policy[ETHTOOL_A_RINGS_MAX + 1] = {
38962306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
39062306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_RX_MAX] = { .name = "rx-max", .type = YNL_PT_U32, },
39162306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_RX_MINI_MAX] = { .name = "rx-mini-max", .type = YNL_PT_U32, },
39262306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_RX_JUMBO_MAX] = { .name = "rx-jumbo-max", .type = YNL_PT_U32, },
39362306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_TX_MAX] = { .name = "tx-max", .type = YNL_PT_U32, },
39462306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_RX] = { .name = "rx", .type = YNL_PT_U32, },
39562306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_RX_MINI] = { .name = "rx-mini", .type = YNL_PT_U32, },
39662306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_RX_JUMBO] = { .name = "rx-jumbo", .type = YNL_PT_U32, },
39762306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_TX] = { .name = "tx", .type = YNL_PT_U32, },
39862306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_RX_BUF_LEN] = { .name = "rx-buf-len", .type = YNL_PT_U32, },
39962306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_TCP_DATA_SPLIT] = { .name = "tcp-data-split", .type = YNL_PT_U8, },
40062306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_CQE_SIZE] = { .name = "cqe-size", .type = YNL_PT_U32, },
40162306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_TX_PUSH] = { .name = "tx-push", .type = YNL_PT_U8, },
40262306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_RX_PUSH] = { .name = "rx-push", .type = YNL_PT_U8, },
40362306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN] = { .name = "tx-push-buf-len", .type = YNL_PT_U32, },
40462306a36Sopenharmony_ci	[ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX] = { .name = "tx-push-buf-len-max", .type = YNL_PT_U32, },
40562306a36Sopenharmony_ci};
40662306a36Sopenharmony_ci
40762306a36Sopenharmony_cistruct ynl_policy_nest ethtool_rings_nest = {
40862306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_RINGS_MAX,
40962306a36Sopenharmony_ci	.table = ethtool_rings_policy,
41062306a36Sopenharmony_ci};
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_cistruct ynl_policy_attr ethtool_channels_policy[ETHTOOL_A_CHANNELS_MAX + 1] = {
41362306a36Sopenharmony_ci	[ETHTOOL_A_CHANNELS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
41462306a36Sopenharmony_ci	[ETHTOOL_A_CHANNELS_RX_MAX] = { .name = "rx-max", .type = YNL_PT_U32, },
41562306a36Sopenharmony_ci	[ETHTOOL_A_CHANNELS_TX_MAX] = { .name = "tx-max", .type = YNL_PT_U32, },
41662306a36Sopenharmony_ci	[ETHTOOL_A_CHANNELS_OTHER_MAX] = { .name = "other-max", .type = YNL_PT_U32, },
41762306a36Sopenharmony_ci	[ETHTOOL_A_CHANNELS_COMBINED_MAX] = { .name = "combined-max", .type = YNL_PT_U32, },
41862306a36Sopenharmony_ci	[ETHTOOL_A_CHANNELS_RX_COUNT] = { .name = "rx-count", .type = YNL_PT_U32, },
41962306a36Sopenharmony_ci	[ETHTOOL_A_CHANNELS_TX_COUNT] = { .name = "tx-count", .type = YNL_PT_U32, },
42062306a36Sopenharmony_ci	[ETHTOOL_A_CHANNELS_OTHER_COUNT] = { .name = "other-count", .type = YNL_PT_U32, },
42162306a36Sopenharmony_ci	[ETHTOOL_A_CHANNELS_COMBINED_COUNT] = { .name = "combined-count", .type = YNL_PT_U32, },
42262306a36Sopenharmony_ci};
42362306a36Sopenharmony_ci
42462306a36Sopenharmony_cistruct ynl_policy_nest ethtool_channels_nest = {
42562306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_CHANNELS_MAX,
42662306a36Sopenharmony_ci	.table = ethtool_channels_policy,
42762306a36Sopenharmony_ci};
42862306a36Sopenharmony_ci
42962306a36Sopenharmony_cistruct ynl_policy_attr ethtool_coalesce_policy[ETHTOOL_A_COALESCE_MAX + 1] = {
43062306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
43162306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_RX_USECS] = { .name = "rx-usecs", .type = YNL_PT_U32, },
43262306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_RX_MAX_FRAMES] = { .name = "rx-max-frames", .type = YNL_PT_U32, },
43362306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_RX_USECS_IRQ] = { .name = "rx-usecs-irq", .type = YNL_PT_U32, },
43462306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ] = { .name = "rx-max-frames-irq", .type = YNL_PT_U32, },
43562306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_USECS] = { .name = "tx-usecs", .type = YNL_PT_U32, },
43662306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_MAX_FRAMES] = { .name = "tx-max-frames", .type = YNL_PT_U32, },
43762306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_USECS_IRQ] = { .name = "tx-usecs-irq", .type = YNL_PT_U32, },
43862306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ] = { .name = "tx-max-frames-irq", .type = YNL_PT_U32, },
43962306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_STATS_BLOCK_USECS] = { .name = "stats-block-usecs", .type = YNL_PT_U32, },
44062306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX] = { .name = "use-adaptive-rx", .type = YNL_PT_U8, },
44162306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX] = { .name = "use-adaptive-tx", .type = YNL_PT_U8, },
44262306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_PKT_RATE_LOW] = { .name = "pkt-rate-low", .type = YNL_PT_U32, },
44362306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_RX_USECS_LOW] = { .name = "rx-usecs-low", .type = YNL_PT_U32, },
44462306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW] = { .name = "rx-max-frames-low", .type = YNL_PT_U32, },
44562306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_USECS_LOW] = { .name = "tx-usecs-low", .type = YNL_PT_U32, },
44662306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW] = { .name = "tx-max-frames-low", .type = YNL_PT_U32, },
44762306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_PKT_RATE_HIGH] = { .name = "pkt-rate-high", .type = YNL_PT_U32, },
44862306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_RX_USECS_HIGH] = { .name = "rx-usecs-high", .type = YNL_PT_U32, },
44962306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH] = { .name = "rx-max-frames-high", .type = YNL_PT_U32, },
45062306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_USECS_HIGH] = { .name = "tx-usecs-high", .type = YNL_PT_U32, },
45162306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH] = { .name = "tx-max-frames-high", .type = YNL_PT_U32, },
45262306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL] = { .name = "rate-sample-interval", .type = YNL_PT_U32, },
45362306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_USE_CQE_MODE_TX] = { .name = "use-cqe-mode-tx", .type = YNL_PT_U8, },
45462306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_USE_CQE_MODE_RX] = { .name = "use-cqe-mode-rx", .type = YNL_PT_U8, },
45562306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES] = { .name = "tx-aggr-max-bytes", .type = YNL_PT_U32, },
45662306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES] = { .name = "tx-aggr-max-frames", .type = YNL_PT_U32, },
45762306a36Sopenharmony_ci	[ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS] = { .name = "tx-aggr-time-usecs", .type = YNL_PT_U32, },
45862306a36Sopenharmony_ci};
45962306a36Sopenharmony_ci
46062306a36Sopenharmony_cistruct ynl_policy_nest ethtool_coalesce_nest = {
46162306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_COALESCE_MAX,
46262306a36Sopenharmony_ci	.table = ethtool_coalesce_policy,
46362306a36Sopenharmony_ci};
46462306a36Sopenharmony_ci
46562306a36Sopenharmony_cistruct ynl_policy_attr ethtool_pause_policy[ETHTOOL_A_PAUSE_MAX + 1] = {
46662306a36Sopenharmony_ci	[ETHTOOL_A_PAUSE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
46762306a36Sopenharmony_ci	[ETHTOOL_A_PAUSE_AUTONEG] = { .name = "autoneg", .type = YNL_PT_U8, },
46862306a36Sopenharmony_ci	[ETHTOOL_A_PAUSE_RX] = { .name = "rx", .type = YNL_PT_U8, },
46962306a36Sopenharmony_ci	[ETHTOOL_A_PAUSE_TX] = { .name = "tx", .type = YNL_PT_U8, },
47062306a36Sopenharmony_ci	[ETHTOOL_A_PAUSE_STATS] = { .name = "stats", .type = YNL_PT_NEST, .nest = &ethtool_pause_stat_nest, },
47162306a36Sopenharmony_ci	[ETHTOOL_A_PAUSE_STATS_SRC] = { .name = "stats-src", .type = YNL_PT_U32, },
47262306a36Sopenharmony_ci};
47362306a36Sopenharmony_ci
47462306a36Sopenharmony_cistruct ynl_policy_nest ethtool_pause_nest = {
47562306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_PAUSE_MAX,
47662306a36Sopenharmony_ci	.table = ethtool_pause_policy,
47762306a36Sopenharmony_ci};
47862306a36Sopenharmony_ci
47962306a36Sopenharmony_cistruct ynl_policy_attr ethtool_eee_policy[ETHTOOL_A_EEE_MAX + 1] = {
48062306a36Sopenharmony_ci	[ETHTOOL_A_EEE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
48162306a36Sopenharmony_ci	[ETHTOOL_A_EEE_MODES_OURS] = { .name = "modes-ours", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
48262306a36Sopenharmony_ci	[ETHTOOL_A_EEE_MODES_PEER] = { .name = "modes-peer", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
48362306a36Sopenharmony_ci	[ETHTOOL_A_EEE_ACTIVE] = { .name = "active", .type = YNL_PT_U8, },
48462306a36Sopenharmony_ci	[ETHTOOL_A_EEE_ENABLED] = { .name = "enabled", .type = YNL_PT_U8, },
48562306a36Sopenharmony_ci	[ETHTOOL_A_EEE_TX_LPI_ENABLED] = { .name = "tx-lpi-enabled", .type = YNL_PT_U8, },
48662306a36Sopenharmony_ci	[ETHTOOL_A_EEE_TX_LPI_TIMER] = { .name = "tx-lpi-timer", .type = YNL_PT_U32, },
48762306a36Sopenharmony_ci};
48862306a36Sopenharmony_ci
48962306a36Sopenharmony_cistruct ynl_policy_nest ethtool_eee_nest = {
49062306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_EEE_MAX,
49162306a36Sopenharmony_ci	.table = ethtool_eee_policy,
49262306a36Sopenharmony_ci};
49362306a36Sopenharmony_ci
49462306a36Sopenharmony_cistruct ynl_policy_attr ethtool_tsinfo_policy[ETHTOOL_A_TSINFO_MAX + 1] = {
49562306a36Sopenharmony_ci	[ETHTOOL_A_TSINFO_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
49662306a36Sopenharmony_ci	[ETHTOOL_A_TSINFO_TIMESTAMPING] = { .name = "timestamping", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
49762306a36Sopenharmony_ci	[ETHTOOL_A_TSINFO_TX_TYPES] = { .name = "tx-types", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
49862306a36Sopenharmony_ci	[ETHTOOL_A_TSINFO_RX_FILTERS] = { .name = "rx-filters", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
49962306a36Sopenharmony_ci	[ETHTOOL_A_TSINFO_PHC_INDEX] = { .name = "phc-index", .type = YNL_PT_U32, },
50062306a36Sopenharmony_ci};
50162306a36Sopenharmony_ci
50262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_tsinfo_nest = {
50362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_TSINFO_MAX,
50462306a36Sopenharmony_ci	.table = ethtool_tsinfo_policy,
50562306a36Sopenharmony_ci};
50662306a36Sopenharmony_ci
50762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_cable_test_policy[ETHTOOL_A_CABLE_TEST_MAX + 1] = {
50862306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
50962306a36Sopenharmony_ci};
51062306a36Sopenharmony_ci
51162306a36Sopenharmony_cistruct ynl_policy_nest ethtool_cable_test_nest = {
51262306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_CABLE_TEST_MAX,
51362306a36Sopenharmony_ci	.table = ethtool_cable_test_policy,
51462306a36Sopenharmony_ci};
51562306a36Sopenharmony_ci
51662306a36Sopenharmony_cistruct ynl_policy_attr ethtool_cable_test_ntf_policy[ETHTOOL_A_CABLE_TEST_NTF_MAX + 1] = {
51762306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_NTF_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
51862306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_NTF_STATUS] = { .name = "status", .type = YNL_PT_U8, },
51962306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_NTF_NEST] = { .name = "nest", .type = YNL_PT_NEST, .nest = &ethtool_cable_nest_nest, },
52062306a36Sopenharmony_ci};
52162306a36Sopenharmony_ci
52262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_cable_test_ntf_nest = {
52362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_CABLE_TEST_NTF_MAX,
52462306a36Sopenharmony_ci	.table = ethtool_cable_test_ntf_policy,
52562306a36Sopenharmony_ci};
52662306a36Sopenharmony_ci
52762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_cable_test_tdr_policy[ETHTOOL_A_CABLE_TEST_TDR_MAX + 1] = {
52862306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_TDR_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
52962306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_TDR_CFG] = { .name = "cfg", .type = YNL_PT_NEST, .nest = &ethtool_cable_test_tdr_cfg_nest, },
53062306a36Sopenharmony_ci};
53162306a36Sopenharmony_ci
53262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_cable_test_tdr_nest = {
53362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_CABLE_TEST_TDR_MAX,
53462306a36Sopenharmony_ci	.table = ethtool_cable_test_tdr_policy,
53562306a36Sopenharmony_ci};
53662306a36Sopenharmony_ci
53762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_cable_test_tdr_ntf_policy[ETHTOOL_A_CABLE_TEST_TDR_NTF_MAX + 1] = {
53862306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_TDR_NTF_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
53962306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_TDR_NTF_STATUS] = { .name = "status", .type = YNL_PT_U8, },
54062306a36Sopenharmony_ci	[ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST] = { .name = "nest", .type = YNL_PT_NEST, .nest = &ethtool_cable_nest_nest, },
54162306a36Sopenharmony_ci};
54262306a36Sopenharmony_ci
54362306a36Sopenharmony_cistruct ynl_policy_nest ethtool_cable_test_tdr_ntf_nest = {
54462306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_CABLE_TEST_TDR_NTF_MAX,
54562306a36Sopenharmony_ci	.table = ethtool_cable_test_tdr_ntf_policy,
54662306a36Sopenharmony_ci};
54762306a36Sopenharmony_ci
54862306a36Sopenharmony_cistruct ynl_policy_attr ethtool_tunnel_info_policy[ETHTOOL_A_TUNNEL_INFO_MAX + 1] = {
54962306a36Sopenharmony_ci	[ETHTOOL_A_TUNNEL_INFO_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
55062306a36Sopenharmony_ci	[ETHTOOL_A_TUNNEL_INFO_UDP_PORTS] = { .name = "udp-ports", .type = YNL_PT_NEST, .nest = &ethtool_tunnel_udp_nest, },
55162306a36Sopenharmony_ci};
55262306a36Sopenharmony_ci
55362306a36Sopenharmony_cistruct ynl_policy_nest ethtool_tunnel_info_nest = {
55462306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_TUNNEL_INFO_MAX,
55562306a36Sopenharmony_ci	.table = ethtool_tunnel_info_policy,
55662306a36Sopenharmony_ci};
55762306a36Sopenharmony_ci
55862306a36Sopenharmony_cistruct ynl_policy_attr ethtool_fec_policy[ETHTOOL_A_FEC_MAX + 1] = {
55962306a36Sopenharmony_ci	[ETHTOOL_A_FEC_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
56062306a36Sopenharmony_ci	[ETHTOOL_A_FEC_MODES] = { .name = "modes", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, },
56162306a36Sopenharmony_ci	[ETHTOOL_A_FEC_AUTO] = { .name = "auto", .type = YNL_PT_U8, },
56262306a36Sopenharmony_ci	[ETHTOOL_A_FEC_ACTIVE] = { .name = "active", .type = YNL_PT_U32, },
56362306a36Sopenharmony_ci	[ETHTOOL_A_FEC_STATS] = { .name = "stats", .type = YNL_PT_NEST, .nest = &ethtool_fec_stat_nest, },
56462306a36Sopenharmony_ci};
56562306a36Sopenharmony_ci
56662306a36Sopenharmony_cistruct ynl_policy_nest ethtool_fec_nest = {
56762306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_FEC_MAX,
56862306a36Sopenharmony_ci	.table = ethtool_fec_policy,
56962306a36Sopenharmony_ci};
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_cistruct ynl_policy_attr ethtool_module_eeprom_policy[ETHTOOL_A_MODULE_EEPROM_MAX + 1] = {
57262306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_EEPROM_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
57362306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_EEPROM_OFFSET] = { .name = "offset", .type = YNL_PT_U32, },
57462306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_EEPROM_LENGTH] = { .name = "length", .type = YNL_PT_U32, },
57562306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_EEPROM_PAGE] = { .name = "page", .type = YNL_PT_U8, },
57662306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_EEPROM_BANK] = { .name = "bank", .type = YNL_PT_U8, },
57762306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS] = { .name = "i2c-address", .type = YNL_PT_U8, },
57862306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_EEPROM_DATA] = { .name = "data", .type = YNL_PT_BINARY,},
57962306a36Sopenharmony_ci};
58062306a36Sopenharmony_ci
58162306a36Sopenharmony_cistruct ynl_policy_nest ethtool_module_eeprom_nest = {
58262306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_MODULE_EEPROM_MAX,
58362306a36Sopenharmony_ci	.table = ethtool_module_eeprom_policy,
58462306a36Sopenharmony_ci};
58562306a36Sopenharmony_ci
58662306a36Sopenharmony_cistruct ynl_policy_attr ethtool_phc_vclocks_policy[ETHTOOL_A_PHC_VCLOCKS_MAX + 1] = {
58762306a36Sopenharmony_ci	[ETHTOOL_A_PHC_VCLOCKS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
58862306a36Sopenharmony_ci	[ETHTOOL_A_PHC_VCLOCKS_NUM] = { .name = "num", .type = YNL_PT_U32, },
58962306a36Sopenharmony_ci	[ETHTOOL_A_PHC_VCLOCKS_INDEX] = { .name = "index", .type = YNL_PT_BINARY,},
59062306a36Sopenharmony_ci};
59162306a36Sopenharmony_ci
59262306a36Sopenharmony_cistruct ynl_policy_nest ethtool_phc_vclocks_nest = {
59362306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_PHC_VCLOCKS_MAX,
59462306a36Sopenharmony_ci	.table = ethtool_phc_vclocks_policy,
59562306a36Sopenharmony_ci};
59662306a36Sopenharmony_ci
59762306a36Sopenharmony_cistruct ynl_policy_attr ethtool_module_policy[ETHTOOL_A_MODULE_MAX + 1] = {
59862306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
59962306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_POWER_MODE_POLICY] = { .name = "power-mode-policy", .type = YNL_PT_U8, },
60062306a36Sopenharmony_ci	[ETHTOOL_A_MODULE_POWER_MODE] = { .name = "power-mode", .type = YNL_PT_U8, },
60162306a36Sopenharmony_ci};
60262306a36Sopenharmony_ci
60362306a36Sopenharmony_cistruct ynl_policy_nest ethtool_module_nest = {
60462306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_MODULE_MAX,
60562306a36Sopenharmony_ci	.table = ethtool_module_policy,
60662306a36Sopenharmony_ci};
60762306a36Sopenharmony_ci
60862306a36Sopenharmony_cistruct ynl_policy_attr ethtool_pse_policy[ETHTOOL_A_PSE_MAX + 1] = {
60962306a36Sopenharmony_ci	[ETHTOOL_A_PSE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
61062306a36Sopenharmony_ci	[ETHTOOL_A_PODL_PSE_ADMIN_STATE] = { .name = "admin-state", .type = YNL_PT_U32, },
61162306a36Sopenharmony_ci	[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL] = { .name = "admin-control", .type = YNL_PT_U32, },
61262306a36Sopenharmony_ci	[ETHTOOL_A_PODL_PSE_PW_D_STATUS] = { .name = "pw-d-status", .type = YNL_PT_U32, },
61362306a36Sopenharmony_ci};
61462306a36Sopenharmony_ci
61562306a36Sopenharmony_cistruct ynl_policy_nest ethtool_pse_nest = {
61662306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_PSE_MAX,
61762306a36Sopenharmony_ci	.table = ethtool_pse_policy,
61862306a36Sopenharmony_ci};
61962306a36Sopenharmony_ci
62062306a36Sopenharmony_cistruct ynl_policy_attr ethtool_rss_policy[ETHTOOL_A_RSS_MAX + 1] = {
62162306a36Sopenharmony_ci	[ETHTOOL_A_RSS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
62262306a36Sopenharmony_ci	[ETHTOOL_A_RSS_CONTEXT] = { .name = "context", .type = YNL_PT_U32, },
62362306a36Sopenharmony_ci	[ETHTOOL_A_RSS_HFUNC] = { .name = "hfunc", .type = YNL_PT_U32, },
62462306a36Sopenharmony_ci	[ETHTOOL_A_RSS_INDIR] = { .name = "indir", .type = YNL_PT_BINARY,},
62562306a36Sopenharmony_ci	[ETHTOOL_A_RSS_HKEY] = { .name = "hkey", .type = YNL_PT_BINARY,},
62662306a36Sopenharmony_ci};
62762306a36Sopenharmony_ci
62862306a36Sopenharmony_cistruct ynl_policy_nest ethtool_rss_nest = {
62962306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_RSS_MAX,
63062306a36Sopenharmony_ci	.table = ethtool_rss_policy,
63162306a36Sopenharmony_ci};
63262306a36Sopenharmony_ci
63362306a36Sopenharmony_cistruct ynl_policy_attr ethtool_plca_policy[ETHTOOL_A_PLCA_MAX + 1] = {
63462306a36Sopenharmony_ci	[ETHTOOL_A_PLCA_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
63562306a36Sopenharmony_ci	[ETHTOOL_A_PLCA_VERSION] = { .name = "version", .type = YNL_PT_U16, },
63662306a36Sopenharmony_ci	[ETHTOOL_A_PLCA_ENABLED] = { .name = "enabled", .type = YNL_PT_U8, },
63762306a36Sopenharmony_ci	[ETHTOOL_A_PLCA_STATUS] = { .name = "status", .type = YNL_PT_U8, },
63862306a36Sopenharmony_ci	[ETHTOOL_A_PLCA_NODE_CNT] = { .name = "node-cnt", .type = YNL_PT_U32, },
63962306a36Sopenharmony_ci	[ETHTOOL_A_PLCA_NODE_ID] = { .name = "node-id", .type = YNL_PT_U32, },
64062306a36Sopenharmony_ci	[ETHTOOL_A_PLCA_TO_TMR] = { .name = "to-tmr", .type = YNL_PT_U32, },
64162306a36Sopenharmony_ci	[ETHTOOL_A_PLCA_BURST_CNT] = { .name = "burst-cnt", .type = YNL_PT_U32, },
64262306a36Sopenharmony_ci	[ETHTOOL_A_PLCA_BURST_TMR] = { .name = "burst-tmr", .type = YNL_PT_U32, },
64362306a36Sopenharmony_ci};
64462306a36Sopenharmony_ci
64562306a36Sopenharmony_cistruct ynl_policy_nest ethtool_plca_nest = {
64662306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_PLCA_MAX,
64762306a36Sopenharmony_ci	.table = ethtool_plca_policy,
64862306a36Sopenharmony_ci};
64962306a36Sopenharmony_ci
65062306a36Sopenharmony_cistruct ynl_policy_attr ethtool_mm_policy[ETHTOOL_A_MM_MAX + 1] = {
65162306a36Sopenharmony_ci	[ETHTOOL_A_MM_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, },
65262306a36Sopenharmony_ci	[ETHTOOL_A_MM_PMAC_ENABLED] = { .name = "pmac-enabled", .type = YNL_PT_U8, },
65362306a36Sopenharmony_ci	[ETHTOOL_A_MM_TX_ENABLED] = { .name = "tx-enabled", .type = YNL_PT_U8, },
65462306a36Sopenharmony_ci	[ETHTOOL_A_MM_TX_ACTIVE] = { .name = "tx-active", .type = YNL_PT_U8, },
65562306a36Sopenharmony_ci	[ETHTOOL_A_MM_TX_MIN_FRAG_SIZE] = { .name = "tx-min-frag-size", .type = YNL_PT_U32, },
65662306a36Sopenharmony_ci	[ETHTOOL_A_MM_RX_MIN_FRAG_SIZE] = { .name = "rx-min-frag-size", .type = YNL_PT_U32, },
65762306a36Sopenharmony_ci	[ETHTOOL_A_MM_VERIFY_ENABLED] = { .name = "verify-enabled", .type = YNL_PT_U8, },
65862306a36Sopenharmony_ci	[ETHTOOL_A_MM_VERIFY_STATUS] = { .name = "verify-status", .type = YNL_PT_U8, },
65962306a36Sopenharmony_ci	[ETHTOOL_A_MM_VERIFY_TIME] = { .name = "verify-time", .type = YNL_PT_U32, },
66062306a36Sopenharmony_ci	[ETHTOOL_A_MM_MAX_VERIFY_TIME] = { .name = "max-verify-time", .type = YNL_PT_U32, },
66162306a36Sopenharmony_ci	[ETHTOOL_A_MM_STATS] = { .name = "stats", .type = YNL_PT_NEST, .nest = &ethtool_mm_stat_nest, },
66262306a36Sopenharmony_ci};
66362306a36Sopenharmony_ci
66462306a36Sopenharmony_cistruct ynl_policy_nest ethtool_mm_nest = {
66562306a36Sopenharmony_ci	.max_attr = ETHTOOL_A_MM_MAX,
66662306a36Sopenharmony_ci	.table = ethtool_mm_policy,
66762306a36Sopenharmony_ci};
66862306a36Sopenharmony_ci
66962306a36Sopenharmony_ci/* Common nested types */
67062306a36Sopenharmony_civoid ethtool_header_free(struct ethtool_header *obj)
67162306a36Sopenharmony_ci{
67262306a36Sopenharmony_ci	free(obj->dev_name);
67362306a36Sopenharmony_ci}
67462306a36Sopenharmony_ci
67562306a36Sopenharmony_ciint ethtool_header_put(struct nlmsghdr *nlh, unsigned int attr_type,
67662306a36Sopenharmony_ci		       struct ethtool_header *obj)
67762306a36Sopenharmony_ci{
67862306a36Sopenharmony_ci	struct nlattr *nest;
67962306a36Sopenharmony_ci
68062306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
68162306a36Sopenharmony_ci	if (obj->_present.dev_index)
68262306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_HEADER_DEV_INDEX, obj->dev_index);
68362306a36Sopenharmony_ci	if (obj->_present.dev_name_len)
68462306a36Sopenharmony_ci		mnl_attr_put_strz(nlh, ETHTOOL_A_HEADER_DEV_NAME, obj->dev_name);
68562306a36Sopenharmony_ci	if (obj->_present.flags)
68662306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_HEADER_FLAGS, obj->flags);
68762306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
68862306a36Sopenharmony_ci
68962306a36Sopenharmony_ci	return 0;
69062306a36Sopenharmony_ci}
69162306a36Sopenharmony_ci
69262306a36Sopenharmony_ciint ethtool_header_parse(struct ynl_parse_arg *yarg,
69362306a36Sopenharmony_ci			 const struct nlattr *nested)
69462306a36Sopenharmony_ci{
69562306a36Sopenharmony_ci	struct ethtool_header *dst = yarg->data;
69662306a36Sopenharmony_ci	const struct nlattr *attr;
69762306a36Sopenharmony_ci
69862306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
69962306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
70062306a36Sopenharmony_ci
70162306a36Sopenharmony_ci		if (type == ETHTOOL_A_HEADER_DEV_INDEX) {
70262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
70362306a36Sopenharmony_ci				return MNL_CB_ERROR;
70462306a36Sopenharmony_ci			dst->_present.dev_index = 1;
70562306a36Sopenharmony_ci			dst->dev_index = mnl_attr_get_u32(attr);
70662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_HEADER_DEV_NAME) {
70762306a36Sopenharmony_ci			unsigned int len;
70862306a36Sopenharmony_ci
70962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
71062306a36Sopenharmony_ci				return MNL_CB_ERROR;
71162306a36Sopenharmony_ci
71262306a36Sopenharmony_ci			len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
71362306a36Sopenharmony_ci			dst->_present.dev_name_len = len;
71462306a36Sopenharmony_ci			dst->dev_name = malloc(len + 1);
71562306a36Sopenharmony_ci			memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
71662306a36Sopenharmony_ci			dst->dev_name[len] = 0;
71762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_HEADER_FLAGS) {
71862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
71962306a36Sopenharmony_ci				return MNL_CB_ERROR;
72062306a36Sopenharmony_ci			dst->_present.flags = 1;
72162306a36Sopenharmony_ci			dst->flags = mnl_attr_get_u32(attr);
72262306a36Sopenharmony_ci		}
72362306a36Sopenharmony_ci	}
72462306a36Sopenharmony_ci
72562306a36Sopenharmony_ci	return 0;
72662306a36Sopenharmony_ci}
72762306a36Sopenharmony_ci
72862306a36Sopenharmony_civoid ethtool_pause_stat_free(struct ethtool_pause_stat *obj)
72962306a36Sopenharmony_ci{
73062306a36Sopenharmony_ci}
73162306a36Sopenharmony_ci
73262306a36Sopenharmony_ciint ethtool_pause_stat_put(struct nlmsghdr *nlh, unsigned int attr_type,
73362306a36Sopenharmony_ci			   struct ethtool_pause_stat *obj)
73462306a36Sopenharmony_ci{
73562306a36Sopenharmony_ci	struct nlattr *nest;
73662306a36Sopenharmony_ci
73762306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
73862306a36Sopenharmony_ci	if (obj->_present.tx_frames)
73962306a36Sopenharmony_ci		mnl_attr_put_u64(nlh, ETHTOOL_A_PAUSE_STAT_TX_FRAMES, obj->tx_frames);
74062306a36Sopenharmony_ci	if (obj->_present.rx_frames)
74162306a36Sopenharmony_ci		mnl_attr_put_u64(nlh, ETHTOOL_A_PAUSE_STAT_RX_FRAMES, obj->rx_frames);
74262306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
74362306a36Sopenharmony_ci
74462306a36Sopenharmony_ci	return 0;
74562306a36Sopenharmony_ci}
74662306a36Sopenharmony_ci
74762306a36Sopenharmony_ciint ethtool_pause_stat_parse(struct ynl_parse_arg *yarg,
74862306a36Sopenharmony_ci			     const struct nlattr *nested)
74962306a36Sopenharmony_ci{
75062306a36Sopenharmony_ci	struct ethtool_pause_stat *dst = yarg->data;
75162306a36Sopenharmony_ci	const struct nlattr *attr;
75262306a36Sopenharmony_ci
75362306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
75462306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
75562306a36Sopenharmony_ci
75662306a36Sopenharmony_ci		if (type == ETHTOOL_A_PAUSE_STAT_TX_FRAMES) {
75762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
75862306a36Sopenharmony_ci				return MNL_CB_ERROR;
75962306a36Sopenharmony_ci			dst->_present.tx_frames = 1;
76062306a36Sopenharmony_ci			dst->tx_frames = mnl_attr_get_u64(attr);
76162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PAUSE_STAT_RX_FRAMES) {
76262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
76362306a36Sopenharmony_ci				return MNL_CB_ERROR;
76462306a36Sopenharmony_ci			dst->_present.rx_frames = 1;
76562306a36Sopenharmony_ci			dst->rx_frames = mnl_attr_get_u64(attr);
76662306a36Sopenharmony_ci		}
76762306a36Sopenharmony_ci	}
76862306a36Sopenharmony_ci
76962306a36Sopenharmony_ci	return 0;
77062306a36Sopenharmony_ci}
77162306a36Sopenharmony_ci
77262306a36Sopenharmony_civoid ethtool_cable_test_tdr_cfg_free(struct ethtool_cable_test_tdr_cfg *obj)
77362306a36Sopenharmony_ci{
77462306a36Sopenharmony_ci}
77562306a36Sopenharmony_ci
77662306a36Sopenharmony_civoid ethtool_fec_stat_free(struct ethtool_fec_stat *obj)
77762306a36Sopenharmony_ci{
77862306a36Sopenharmony_ci	free(obj->corrected);
77962306a36Sopenharmony_ci	free(obj->uncorr);
78062306a36Sopenharmony_ci	free(obj->corr_bits);
78162306a36Sopenharmony_ci}
78262306a36Sopenharmony_ci
78362306a36Sopenharmony_ciint ethtool_fec_stat_put(struct nlmsghdr *nlh, unsigned int attr_type,
78462306a36Sopenharmony_ci			 struct ethtool_fec_stat *obj)
78562306a36Sopenharmony_ci{
78662306a36Sopenharmony_ci	struct nlattr *nest;
78762306a36Sopenharmony_ci
78862306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
78962306a36Sopenharmony_ci	if (obj->_present.corrected_len)
79062306a36Sopenharmony_ci		mnl_attr_put(nlh, ETHTOOL_A_FEC_STAT_CORRECTED, obj->_present.corrected_len, obj->corrected);
79162306a36Sopenharmony_ci	if (obj->_present.uncorr_len)
79262306a36Sopenharmony_ci		mnl_attr_put(nlh, ETHTOOL_A_FEC_STAT_UNCORR, obj->_present.uncorr_len, obj->uncorr);
79362306a36Sopenharmony_ci	if (obj->_present.corr_bits_len)
79462306a36Sopenharmony_ci		mnl_attr_put(nlh, ETHTOOL_A_FEC_STAT_CORR_BITS, obj->_present.corr_bits_len, obj->corr_bits);
79562306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
79662306a36Sopenharmony_ci
79762306a36Sopenharmony_ci	return 0;
79862306a36Sopenharmony_ci}
79962306a36Sopenharmony_ci
80062306a36Sopenharmony_ciint ethtool_fec_stat_parse(struct ynl_parse_arg *yarg,
80162306a36Sopenharmony_ci			   const struct nlattr *nested)
80262306a36Sopenharmony_ci{
80362306a36Sopenharmony_ci	struct ethtool_fec_stat *dst = yarg->data;
80462306a36Sopenharmony_ci	const struct nlattr *attr;
80562306a36Sopenharmony_ci
80662306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
80762306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
80862306a36Sopenharmony_ci
80962306a36Sopenharmony_ci		if (type == ETHTOOL_A_FEC_STAT_CORRECTED) {
81062306a36Sopenharmony_ci			unsigned int len;
81162306a36Sopenharmony_ci
81262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
81362306a36Sopenharmony_ci				return MNL_CB_ERROR;
81462306a36Sopenharmony_ci
81562306a36Sopenharmony_ci			len = mnl_attr_get_payload_len(attr);
81662306a36Sopenharmony_ci			dst->_present.corrected_len = len;
81762306a36Sopenharmony_ci			dst->corrected = malloc(len);
81862306a36Sopenharmony_ci			memcpy(dst->corrected, mnl_attr_get_payload(attr), len);
81962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEC_STAT_UNCORR) {
82062306a36Sopenharmony_ci			unsigned int len;
82162306a36Sopenharmony_ci
82262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
82362306a36Sopenharmony_ci				return MNL_CB_ERROR;
82462306a36Sopenharmony_ci
82562306a36Sopenharmony_ci			len = mnl_attr_get_payload_len(attr);
82662306a36Sopenharmony_ci			dst->_present.uncorr_len = len;
82762306a36Sopenharmony_ci			dst->uncorr = malloc(len);
82862306a36Sopenharmony_ci			memcpy(dst->uncorr, mnl_attr_get_payload(attr), len);
82962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEC_STAT_CORR_BITS) {
83062306a36Sopenharmony_ci			unsigned int len;
83162306a36Sopenharmony_ci
83262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
83362306a36Sopenharmony_ci				return MNL_CB_ERROR;
83462306a36Sopenharmony_ci
83562306a36Sopenharmony_ci			len = mnl_attr_get_payload_len(attr);
83662306a36Sopenharmony_ci			dst->_present.corr_bits_len = len;
83762306a36Sopenharmony_ci			dst->corr_bits = malloc(len);
83862306a36Sopenharmony_ci			memcpy(dst->corr_bits, mnl_attr_get_payload(attr), len);
83962306a36Sopenharmony_ci		}
84062306a36Sopenharmony_ci	}
84162306a36Sopenharmony_ci
84262306a36Sopenharmony_ci	return 0;
84362306a36Sopenharmony_ci}
84462306a36Sopenharmony_ci
84562306a36Sopenharmony_civoid ethtool_mm_stat_free(struct ethtool_mm_stat *obj)
84662306a36Sopenharmony_ci{
84762306a36Sopenharmony_ci}
84862306a36Sopenharmony_ci
84962306a36Sopenharmony_ciint ethtool_mm_stat_parse(struct ynl_parse_arg *yarg,
85062306a36Sopenharmony_ci			  const struct nlattr *nested)
85162306a36Sopenharmony_ci{
85262306a36Sopenharmony_ci	struct ethtool_mm_stat *dst = yarg->data;
85362306a36Sopenharmony_ci	const struct nlattr *attr;
85462306a36Sopenharmony_ci
85562306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
85662306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
85762306a36Sopenharmony_ci
85862306a36Sopenharmony_ci		if (type == ETHTOOL_A_MM_STAT_REASSEMBLY_ERRORS) {
85962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
86062306a36Sopenharmony_ci				return MNL_CB_ERROR;
86162306a36Sopenharmony_ci			dst->_present.reassembly_errors = 1;
86262306a36Sopenharmony_ci			dst->reassembly_errors = mnl_attr_get_u64(attr);
86362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_STAT_SMD_ERRORS) {
86462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
86562306a36Sopenharmony_ci				return MNL_CB_ERROR;
86662306a36Sopenharmony_ci			dst->_present.smd_errors = 1;
86762306a36Sopenharmony_ci			dst->smd_errors = mnl_attr_get_u64(attr);
86862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_STAT_REASSEMBLY_OK) {
86962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
87062306a36Sopenharmony_ci				return MNL_CB_ERROR;
87162306a36Sopenharmony_ci			dst->_present.reassembly_ok = 1;
87262306a36Sopenharmony_ci			dst->reassembly_ok = mnl_attr_get_u64(attr);
87362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_STAT_RX_FRAG_COUNT) {
87462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
87562306a36Sopenharmony_ci				return MNL_CB_ERROR;
87662306a36Sopenharmony_ci			dst->_present.rx_frag_count = 1;
87762306a36Sopenharmony_ci			dst->rx_frag_count = mnl_attr_get_u64(attr);
87862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_STAT_TX_FRAG_COUNT) {
87962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
88062306a36Sopenharmony_ci				return MNL_CB_ERROR;
88162306a36Sopenharmony_ci			dst->_present.tx_frag_count = 1;
88262306a36Sopenharmony_ci			dst->tx_frag_count = mnl_attr_get_u64(attr);
88362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_STAT_HOLD_COUNT) {
88462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
88562306a36Sopenharmony_ci				return MNL_CB_ERROR;
88662306a36Sopenharmony_ci			dst->_present.hold_count = 1;
88762306a36Sopenharmony_ci			dst->hold_count = mnl_attr_get_u64(attr);
88862306a36Sopenharmony_ci		}
88962306a36Sopenharmony_ci	}
89062306a36Sopenharmony_ci
89162306a36Sopenharmony_ci	return 0;
89262306a36Sopenharmony_ci}
89362306a36Sopenharmony_ci
89462306a36Sopenharmony_civoid ethtool_cable_result_free(struct ethtool_cable_result *obj)
89562306a36Sopenharmony_ci{
89662306a36Sopenharmony_ci}
89762306a36Sopenharmony_ci
89862306a36Sopenharmony_ciint ethtool_cable_result_parse(struct ynl_parse_arg *yarg,
89962306a36Sopenharmony_ci			       const struct nlattr *nested)
90062306a36Sopenharmony_ci{
90162306a36Sopenharmony_ci	struct ethtool_cable_result *dst = yarg->data;
90262306a36Sopenharmony_ci	const struct nlattr *attr;
90362306a36Sopenharmony_ci
90462306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
90562306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
90662306a36Sopenharmony_ci
90762306a36Sopenharmony_ci		if (type == ETHTOOL_A_CABLE_RESULT_PAIR) {
90862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
90962306a36Sopenharmony_ci				return MNL_CB_ERROR;
91062306a36Sopenharmony_ci			dst->_present.pair = 1;
91162306a36Sopenharmony_ci			dst->pair = mnl_attr_get_u8(attr);
91262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CABLE_RESULT_CODE) {
91362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
91462306a36Sopenharmony_ci				return MNL_CB_ERROR;
91562306a36Sopenharmony_ci			dst->_present.code = 1;
91662306a36Sopenharmony_ci			dst->code = mnl_attr_get_u8(attr);
91762306a36Sopenharmony_ci		}
91862306a36Sopenharmony_ci	}
91962306a36Sopenharmony_ci
92062306a36Sopenharmony_ci	return 0;
92162306a36Sopenharmony_ci}
92262306a36Sopenharmony_ci
92362306a36Sopenharmony_civoid ethtool_cable_fault_length_free(struct ethtool_cable_fault_length *obj)
92462306a36Sopenharmony_ci{
92562306a36Sopenharmony_ci}
92662306a36Sopenharmony_ci
92762306a36Sopenharmony_ciint ethtool_cable_fault_length_parse(struct ynl_parse_arg *yarg,
92862306a36Sopenharmony_ci				     const struct nlattr *nested)
92962306a36Sopenharmony_ci{
93062306a36Sopenharmony_ci	struct ethtool_cable_fault_length *dst = yarg->data;
93162306a36Sopenharmony_ci	const struct nlattr *attr;
93262306a36Sopenharmony_ci
93362306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
93462306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
93562306a36Sopenharmony_ci
93662306a36Sopenharmony_ci		if (type == ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR) {
93762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
93862306a36Sopenharmony_ci				return MNL_CB_ERROR;
93962306a36Sopenharmony_ci			dst->_present.pair = 1;
94062306a36Sopenharmony_ci			dst->pair = mnl_attr_get_u8(attr);
94162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CABLE_FAULT_LENGTH_CM) {
94262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
94362306a36Sopenharmony_ci				return MNL_CB_ERROR;
94462306a36Sopenharmony_ci			dst->_present.cm = 1;
94562306a36Sopenharmony_ci			dst->cm = mnl_attr_get_u32(attr);
94662306a36Sopenharmony_ci		}
94762306a36Sopenharmony_ci	}
94862306a36Sopenharmony_ci
94962306a36Sopenharmony_ci	return 0;
95062306a36Sopenharmony_ci}
95162306a36Sopenharmony_ci
95262306a36Sopenharmony_civoid ethtool_bitset_bit_free(struct ethtool_bitset_bit *obj)
95362306a36Sopenharmony_ci{
95462306a36Sopenharmony_ci	free(obj->name);
95562306a36Sopenharmony_ci}
95662306a36Sopenharmony_ci
95762306a36Sopenharmony_ciint ethtool_bitset_bit_put(struct nlmsghdr *nlh, unsigned int attr_type,
95862306a36Sopenharmony_ci			   struct ethtool_bitset_bit *obj)
95962306a36Sopenharmony_ci{
96062306a36Sopenharmony_ci	struct nlattr *nest;
96162306a36Sopenharmony_ci
96262306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
96362306a36Sopenharmony_ci	if (obj->_present.index)
96462306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_BITSET_BIT_INDEX, obj->index);
96562306a36Sopenharmony_ci	if (obj->_present.name_len)
96662306a36Sopenharmony_ci		mnl_attr_put_strz(nlh, ETHTOOL_A_BITSET_BIT_NAME, obj->name);
96762306a36Sopenharmony_ci	if (obj->_present.value)
96862306a36Sopenharmony_ci		mnl_attr_put(nlh, ETHTOOL_A_BITSET_BIT_VALUE, 0, NULL);
96962306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
97062306a36Sopenharmony_ci
97162306a36Sopenharmony_ci	return 0;
97262306a36Sopenharmony_ci}
97362306a36Sopenharmony_ci
97462306a36Sopenharmony_ciint ethtool_bitset_bit_parse(struct ynl_parse_arg *yarg,
97562306a36Sopenharmony_ci			     const struct nlattr *nested)
97662306a36Sopenharmony_ci{
97762306a36Sopenharmony_ci	struct ethtool_bitset_bit *dst = yarg->data;
97862306a36Sopenharmony_ci	const struct nlattr *attr;
97962306a36Sopenharmony_ci
98062306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
98162306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
98262306a36Sopenharmony_ci
98362306a36Sopenharmony_ci		if (type == ETHTOOL_A_BITSET_BIT_INDEX) {
98462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
98562306a36Sopenharmony_ci				return MNL_CB_ERROR;
98662306a36Sopenharmony_ci			dst->_present.index = 1;
98762306a36Sopenharmony_ci			dst->index = mnl_attr_get_u32(attr);
98862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_BITSET_BIT_NAME) {
98962306a36Sopenharmony_ci			unsigned int len;
99062306a36Sopenharmony_ci
99162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
99262306a36Sopenharmony_ci				return MNL_CB_ERROR;
99362306a36Sopenharmony_ci
99462306a36Sopenharmony_ci			len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
99562306a36Sopenharmony_ci			dst->_present.name_len = len;
99662306a36Sopenharmony_ci			dst->name = malloc(len + 1);
99762306a36Sopenharmony_ci			memcpy(dst->name, mnl_attr_get_str(attr), len);
99862306a36Sopenharmony_ci			dst->name[len] = 0;
99962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_BITSET_BIT_VALUE) {
100062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
100162306a36Sopenharmony_ci				return MNL_CB_ERROR;
100262306a36Sopenharmony_ci			dst->_present.value = 1;
100362306a36Sopenharmony_ci		}
100462306a36Sopenharmony_ci	}
100562306a36Sopenharmony_ci
100662306a36Sopenharmony_ci	return 0;
100762306a36Sopenharmony_ci}
100862306a36Sopenharmony_ci
100962306a36Sopenharmony_civoid ethtool_tunnel_udp_entry_free(struct ethtool_tunnel_udp_entry *obj)
101062306a36Sopenharmony_ci{
101162306a36Sopenharmony_ci}
101262306a36Sopenharmony_ci
101362306a36Sopenharmony_ciint ethtool_tunnel_udp_entry_parse(struct ynl_parse_arg *yarg,
101462306a36Sopenharmony_ci				   const struct nlattr *nested)
101562306a36Sopenharmony_ci{
101662306a36Sopenharmony_ci	struct ethtool_tunnel_udp_entry *dst = yarg->data;
101762306a36Sopenharmony_ci	const struct nlattr *attr;
101862306a36Sopenharmony_ci
101962306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
102062306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
102162306a36Sopenharmony_ci
102262306a36Sopenharmony_ci		if (type == ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT) {
102362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
102462306a36Sopenharmony_ci				return MNL_CB_ERROR;
102562306a36Sopenharmony_ci			dst->_present.port = 1;
102662306a36Sopenharmony_ci			dst->port = mnl_attr_get_u16(attr);
102762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE) {
102862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
102962306a36Sopenharmony_ci				return MNL_CB_ERROR;
103062306a36Sopenharmony_ci			dst->_present.type = 1;
103162306a36Sopenharmony_ci			dst->type = mnl_attr_get_u32(attr);
103262306a36Sopenharmony_ci		}
103362306a36Sopenharmony_ci	}
103462306a36Sopenharmony_ci
103562306a36Sopenharmony_ci	return 0;
103662306a36Sopenharmony_ci}
103762306a36Sopenharmony_ci
103862306a36Sopenharmony_civoid ethtool_string_free(struct ethtool_string *obj)
103962306a36Sopenharmony_ci{
104062306a36Sopenharmony_ci	free(obj->value);
104162306a36Sopenharmony_ci}
104262306a36Sopenharmony_ci
104362306a36Sopenharmony_ciint ethtool_string_put(struct nlmsghdr *nlh, unsigned int attr_type,
104462306a36Sopenharmony_ci		       struct ethtool_string *obj)
104562306a36Sopenharmony_ci{
104662306a36Sopenharmony_ci	struct nlattr *nest;
104762306a36Sopenharmony_ci
104862306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
104962306a36Sopenharmony_ci	if (obj->_present.index)
105062306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_STRING_INDEX, obj->index);
105162306a36Sopenharmony_ci	if (obj->_present.value_len)
105262306a36Sopenharmony_ci		mnl_attr_put_strz(nlh, ETHTOOL_A_STRING_VALUE, obj->value);
105362306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
105462306a36Sopenharmony_ci
105562306a36Sopenharmony_ci	return 0;
105662306a36Sopenharmony_ci}
105762306a36Sopenharmony_ci
105862306a36Sopenharmony_ciint ethtool_string_parse(struct ynl_parse_arg *yarg,
105962306a36Sopenharmony_ci			 const struct nlattr *nested)
106062306a36Sopenharmony_ci{
106162306a36Sopenharmony_ci	struct ethtool_string *dst = yarg->data;
106262306a36Sopenharmony_ci	const struct nlattr *attr;
106362306a36Sopenharmony_ci
106462306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
106562306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
106662306a36Sopenharmony_ci
106762306a36Sopenharmony_ci		if (type == ETHTOOL_A_STRING_INDEX) {
106862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
106962306a36Sopenharmony_ci				return MNL_CB_ERROR;
107062306a36Sopenharmony_ci			dst->_present.index = 1;
107162306a36Sopenharmony_ci			dst->index = mnl_attr_get_u32(attr);
107262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_STRING_VALUE) {
107362306a36Sopenharmony_ci			unsigned int len;
107462306a36Sopenharmony_ci
107562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
107662306a36Sopenharmony_ci				return MNL_CB_ERROR;
107762306a36Sopenharmony_ci
107862306a36Sopenharmony_ci			len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
107962306a36Sopenharmony_ci			dst->_present.value_len = len;
108062306a36Sopenharmony_ci			dst->value = malloc(len + 1);
108162306a36Sopenharmony_ci			memcpy(dst->value, mnl_attr_get_str(attr), len);
108262306a36Sopenharmony_ci			dst->value[len] = 0;
108362306a36Sopenharmony_ci		}
108462306a36Sopenharmony_ci	}
108562306a36Sopenharmony_ci
108662306a36Sopenharmony_ci	return 0;
108762306a36Sopenharmony_ci}
108862306a36Sopenharmony_ci
108962306a36Sopenharmony_civoid ethtool_cable_nest_free(struct ethtool_cable_nest *obj)
109062306a36Sopenharmony_ci{
109162306a36Sopenharmony_ci	ethtool_cable_result_free(&obj->result);
109262306a36Sopenharmony_ci	ethtool_cable_fault_length_free(&obj->fault_length);
109362306a36Sopenharmony_ci}
109462306a36Sopenharmony_ci
109562306a36Sopenharmony_ciint ethtool_cable_nest_parse(struct ynl_parse_arg *yarg,
109662306a36Sopenharmony_ci			     const struct nlattr *nested)
109762306a36Sopenharmony_ci{
109862306a36Sopenharmony_ci	struct ethtool_cable_nest *dst = yarg->data;
109962306a36Sopenharmony_ci	const struct nlattr *attr;
110062306a36Sopenharmony_ci	struct ynl_parse_arg parg;
110162306a36Sopenharmony_ci
110262306a36Sopenharmony_ci	parg.ys = yarg->ys;
110362306a36Sopenharmony_ci
110462306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
110562306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
110662306a36Sopenharmony_ci
110762306a36Sopenharmony_ci		if (type == ETHTOOL_A_CABLE_NEST_RESULT) {
110862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
110962306a36Sopenharmony_ci				return MNL_CB_ERROR;
111062306a36Sopenharmony_ci			dst->_present.result = 1;
111162306a36Sopenharmony_ci
111262306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_cable_result_nest;
111362306a36Sopenharmony_ci			parg.data = &dst->result;
111462306a36Sopenharmony_ci			if (ethtool_cable_result_parse(&parg, attr))
111562306a36Sopenharmony_ci				return MNL_CB_ERROR;
111662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CABLE_NEST_FAULT_LENGTH) {
111762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
111862306a36Sopenharmony_ci				return MNL_CB_ERROR;
111962306a36Sopenharmony_ci			dst->_present.fault_length = 1;
112062306a36Sopenharmony_ci
112162306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_cable_fault_length_nest;
112262306a36Sopenharmony_ci			parg.data = &dst->fault_length;
112362306a36Sopenharmony_ci			if (ethtool_cable_fault_length_parse(&parg, attr))
112462306a36Sopenharmony_ci				return MNL_CB_ERROR;
112562306a36Sopenharmony_ci		}
112662306a36Sopenharmony_ci	}
112762306a36Sopenharmony_ci
112862306a36Sopenharmony_ci	return 0;
112962306a36Sopenharmony_ci}
113062306a36Sopenharmony_ci
113162306a36Sopenharmony_civoid ethtool_bitset_bits_free(struct ethtool_bitset_bits *obj)
113262306a36Sopenharmony_ci{
113362306a36Sopenharmony_ci	unsigned int i;
113462306a36Sopenharmony_ci
113562306a36Sopenharmony_ci	for (i = 0; i < obj->n_bit; i++)
113662306a36Sopenharmony_ci		ethtool_bitset_bit_free(&obj->bit[i]);
113762306a36Sopenharmony_ci	free(obj->bit);
113862306a36Sopenharmony_ci}
113962306a36Sopenharmony_ci
114062306a36Sopenharmony_ciint ethtool_bitset_bits_put(struct nlmsghdr *nlh, unsigned int attr_type,
114162306a36Sopenharmony_ci			    struct ethtool_bitset_bits *obj)
114262306a36Sopenharmony_ci{
114362306a36Sopenharmony_ci	struct nlattr *nest;
114462306a36Sopenharmony_ci
114562306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
114662306a36Sopenharmony_ci	for (unsigned int i = 0; i < obj->n_bit; i++)
114762306a36Sopenharmony_ci		ethtool_bitset_bit_put(nlh, ETHTOOL_A_BITSET_BITS_BIT, &obj->bit[i]);
114862306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
114962306a36Sopenharmony_ci
115062306a36Sopenharmony_ci	return 0;
115162306a36Sopenharmony_ci}
115262306a36Sopenharmony_ci
115362306a36Sopenharmony_ciint ethtool_bitset_bits_parse(struct ynl_parse_arg *yarg,
115462306a36Sopenharmony_ci			      const struct nlattr *nested)
115562306a36Sopenharmony_ci{
115662306a36Sopenharmony_ci	struct ethtool_bitset_bits *dst = yarg->data;
115762306a36Sopenharmony_ci	const struct nlattr *attr;
115862306a36Sopenharmony_ci	struct ynl_parse_arg parg;
115962306a36Sopenharmony_ci	unsigned int n_bit = 0;
116062306a36Sopenharmony_ci	int i;
116162306a36Sopenharmony_ci
116262306a36Sopenharmony_ci	parg.ys = yarg->ys;
116362306a36Sopenharmony_ci
116462306a36Sopenharmony_ci	if (dst->bit)
116562306a36Sopenharmony_ci		return ynl_error_parse(yarg, "attribute already present (bitset-bits.bit)");
116662306a36Sopenharmony_ci
116762306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
116862306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
116962306a36Sopenharmony_ci
117062306a36Sopenharmony_ci		if (type == ETHTOOL_A_BITSET_BITS_BIT) {
117162306a36Sopenharmony_ci			n_bit++;
117262306a36Sopenharmony_ci		}
117362306a36Sopenharmony_ci	}
117462306a36Sopenharmony_ci
117562306a36Sopenharmony_ci	if (n_bit) {
117662306a36Sopenharmony_ci		dst->bit = calloc(n_bit, sizeof(*dst->bit));
117762306a36Sopenharmony_ci		dst->n_bit = n_bit;
117862306a36Sopenharmony_ci		i = 0;
117962306a36Sopenharmony_ci		parg.rsp_policy = &ethtool_bitset_bit_nest;
118062306a36Sopenharmony_ci		mnl_attr_for_each_nested(attr, nested) {
118162306a36Sopenharmony_ci			if (mnl_attr_get_type(attr) == ETHTOOL_A_BITSET_BITS_BIT) {
118262306a36Sopenharmony_ci				parg.data = &dst->bit[i];
118362306a36Sopenharmony_ci				if (ethtool_bitset_bit_parse(&parg, attr))
118462306a36Sopenharmony_ci					return MNL_CB_ERROR;
118562306a36Sopenharmony_ci				i++;
118662306a36Sopenharmony_ci			}
118762306a36Sopenharmony_ci		}
118862306a36Sopenharmony_ci	}
118962306a36Sopenharmony_ci
119062306a36Sopenharmony_ci	return 0;
119162306a36Sopenharmony_ci}
119262306a36Sopenharmony_ci
119362306a36Sopenharmony_civoid ethtool_strings_free(struct ethtool_strings *obj)
119462306a36Sopenharmony_ci{
119562306a36Sopenharmony_ci	unsigned int i;
119662306a36Sopenharmony_ci
119762306a36Sopenharmony_ci	for (i = 0; i < obj->n_string; i++)
119862306a36Sopenharmony_ci		ethtool_string_free(&obj->string[i]);
119962306a36Sopenharmony_ci	free(obj->string);
120062306a36Sopenharmony_ci}
120162306a36Sopenharmony_ci
120262306a36Sopenharmony_ciint ethtool_strings_put(struct nlmsghdr *nlh, unsigned int attr_type,
120362306a36Sopenharmony_ci			struct ethtool_strings *obj)
120462306a36Sopenharmony_ci{
120562306a36Sopenharmony_ci	struct nlattr *nest;
120662306a36Sopenharmony_ci
120762306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
120862306a36Sopenharmony_ci	for (unsigned int i = 0; i < obj->n_string; i++)
120962306a36Sopenharmony_ci		ethtool_string_put(nlh, ETHTOOL_A_STRINGS_STRING, &obj->string[i]);
121062306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
121162306a36Sopenharmony_ci
121262306a36Sopenharmony_ci	return 0;
121362306a36Sopenharmony_ci}
121462306a36Sopenharmony_ci
121562306a36Sopenharmony_ciint ethtool_strings_parse(struct ynl_parse_arg *yarg,
121662306a36Sopenharmony_ci			  const struct nlattr *nested)
121762306a36Sopenharmony_ci{
121862306a36Sopenharmony_ci	struct ethtool_strings *dst = yarg->data;
121962306a36Sopenharmony_ci	const struct nlattr *attr;
122062306a36Sopenharmony_ci	struct ynl_parse_arg parg;
122162306a36Sopenharmony_ci	unsigned int n_string = 0;
122262306a36Sopenharmony_ci	int i;
122362306a36Sopenharmony_ci
122462306a36Sopenharmony_ci	parg.ys = yarg->ys;
122562306a36Sopenharmony_ci
122662306a36Sopenharmony_ci	if (dst->string)
122762306a36Sopenharmony_ci		return ynl_error_parse(yarg, "attribute already present (strings.string)");
122862306a36Sopenharmony_ci
122962306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
123062306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
123162306a36Sopenharmony_ci
123262306a36Sopenharmony_ci		if (type == ETHTOOL_A_STRINGS_STRING) {
123362306a36Sopenharmony_ci			n_string++;
123462306a36Sopenharmony_ci		}
123562306a36Sopenharmony_ci	}
123662306a36Sopenharmony_ci
123762306a36Sopenharmony_ci	if (n_string) {
123862306a36Sopenharmony_ci		dst->string = calloc(n_string, sizeof(*dst->string));
123962306a36Sopenharmony_ci		dst->n_string = n_string;
124062306a36Sopenharmony_ci		i = 0;
124162306a36Sopenharmony_ci		parg.rsp_policy = &ethtool_string_nest;
124262306a36Sopenharmony_ci		mnl_attr_for_each_nested(attr, nested) {
124362306a36Sopenharmony_ci			if (mnl_attr_get_type(attr) == ETHTOOL_A_STRINGS_STRING) {
124462306a36Sopenharmony_ci				parg.data = &dst->string[i];
124562306a36Sopenharmony_ci				if (ethtool_string_parse(&parg, attr))
124662306a36Sopenharmony_ci					return MNL_CB_ERROR;
124762306a36Sopenharmony_ci				i++;
124862306a36Sopenharmony_ci			}
124962306a36Sopenharmony_ci		}
125062306a36Sopenharmony_ci	}
125162306a36Sopenharmony_ci
125262306a36Sopenharmony_ci	return 0;
125362306a36Sopenharmony_ci}
125462306a36Sopenharmony_ci
125562306a36Sopenharmony_civoid ethtool_bitset_free(struct ethtool_bitset *obj)
125662306a36Sopenharmony_ci{
125762306a36Sopenharmony_ci	ethtool_bitset_bits_free(&obj->bits);
125862306a36Sopenharmony_ci}
125962306a36Sopenharmony_ci
126062306a36Sopenharmony_ciint ethtool_bitset_put(struct nlmsghdr *nlh, unsigned int attr_type,
126162306a36Sopenharmony_ci		       struct ethtool_bitset *obj)
126262306a36Sopenharmony_ci{
126362306a36Sopenharmony_ci	struct nlattr *nest;
126462306a36Sopenharmony_ci
126562306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
126662306a36Sopenharmony_ci	if (obj->_present.nomask)
126762306a36Sopenharmony_ci		mnl_attr_put(nlh, ETHTOOL_A_BITSET_NOMASK, 0, NULL);
126862306a36Sopenharmony_ci	if (obj->_present.size)
126962306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_BITSET_SIZE, obj->size);
127062306a36Sopenharmony_ci	if (obj->_present.bits)
127162306a36Sopenharmony_ci		ethtool_bitset_bits_put(nlh, ETHTOOL_A_BITSET_BITS, &obj->bits);
127262306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
127362306a36Sopenharmony_ci
127462306a36Sopenharmony_ci	return 0;
127562306a36Sopenharmony_ci}
127662306a36Sopenharmony_ci
127762306a36Sopenharmony_ciint ethtool_bitset_parse(struct ynl_parse_arg *yarg,
127862306a36Sopenharmony_ci			 const struct nlattr *nested)
127962306a36Sopenharmony_ci{
128062306a36Sopenharmony_ci	struct ethtool_bitset *dst = yarg->data;
128162306a36Sopenharmony_ci	const struct nlattr *attr;
128262306a36Sopenharmony_ci	struct ynl_parse_arg parg;
128362306a36Sopenharmony_ci
128462306a36Sopenharmony_ci	parg.ys = yarg->ys;
128562306a36Sopenharmony_ci
128662306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
128762306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
128862306a36Sopenharmony_ci
128962306a36Sopenharmony_ci		if (type == ETHTOOL_A_BITSET_NOMASK) {
129062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
129162306a36Sopenharmony_ci				return MNL_CB_ERROR;
129262306a36Sopenharmony_ci			dst->_present.nomask = 1;
129362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_BITSET_SIZE) {
129462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
129562306a36Sopenharmony_ci				return MNL_CB_ERROR;
129662306a36Sopenharmony_ci			dst->_present.size = 1;
129762306a36Sopenharmony_ci			dst->size = mnl_attr_get_u32(attr);
129862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_BITSET_BITS) {
129962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
130062306a36Sopenharmony_ci				return MNL_CB_ERROR;
130162306a36Sopenharmony_ci			dst->_present.bits = 1;
130262306a36Sopenharmony_ci
130362306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_bits_nest;
130462306a36Sopenharmony_ci			parg.data = &dst->bits;
130562306a36Sopenharmony_ci			if (ethtool_bitset_bits_parse(&parg, attr))
130662306a36Sopenharmony_ci				return MNL_CB_ERROR;
130762306a36Sopenharmony_ci		}
130862306a36Sopenharmony_ci	}
130962306a36Sopenharmony_ci
131062306a36Sopenharmony_ci	return 0;
131162306a36Sopenharmony_ci}
131262306a36Sopenharmony_ci
131362306a36Sopenharmony_civoid ethtool_stringset_free(struct ethtool_stringset_ *obj)
131462306a36Sopenharmony_ci{
131562306a36Sopenharmony_ci	unsigned int i;
131662306a36Sopenharmony_ci
131762306a36Sopenharmony_ci	for (i = 0; i < obj->n_strings; i++)
131862306a36Sopenharmony_ci		ethtool_strings_free(&obj->strings[i]);
131962306a36Sopenharmony_ci	free(obj->strings);
132062306a36Sopenharmony_ci}
132162306a36Sopenharmony_ci
132262306a36Sopenharmony_ciint ethtool_stringset_put(struct nlmsghdr *nlh, unsigned int attr_type,
132362306a36Sopenharmony_ci			  struct ethtool_stringset_ *obj)
132462306a36Sopenharmony_ci{
132562306a36Sopenharmony_ci	struct nlattr *nest;
132662306a36Sopenharmony_ci
132762306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
132862306a36Sopenharmony_ci	if (obj->_present.id)
132962306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_STRINGSET_ID, obj->id);
133062306a36Sopenharmony_ci	if (obj->_present.count)
133162306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_STRINGSET_COUNT, obj->count);
133262306a36Sopenharmony_ci	for (unsigned int i = 0; i < obj->n_strings; i++)
133362306a36Sopenharmony_ci		ethtool_strings_put(nlh, ETHTOOL_A_STRINGSET_STRINGS, &obj->strings[i]);
133462306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
133562306a36Sopenharmony_ci
133662306a36Sopenharmony_ci	return 0;
133762306a36Sopenharmony_ci}
133862306a36Sopenharmony_ci
133962306a36Sopenharmony_ciint ethtool_stringset_parse(struct ynl_parse_arg *yarg,
134062306a36Sopenharmony_ci			    const struct nlattr *nested)
134162306a36Sopenharmony_ci{
134262306a36Sopenharmony_ci	struct ethtool_stringset_ *dst = yarg->data;
134362306a36Sopenharmony_ci	unsigned int n_strings = 0;
134462306a36Sopenharmony_ci	const struct nlattr *attr;
134562306a36Sopenharmony_ci	struct ynl_parse_arg parg;
134662306a36Sopenharmony_ci	int i;
134762306a36Sopenharmony_ci
134862306a36Sopenharmony_ci	parg.ys = yarg->ys;
134962306a36Sopenharmony_ci
135062306a36Sopenharmony_ci	if (dst->strings)
135162306a36Sopenharmony_ci		return ynl_error_parse(yarg, "attribute already present (stringset.strings)");
135262306a36Sopenharmony_ci
135362306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
135462306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
135562306a36Sopenharmony_ci
135662306a36Sopenharmony_ci		if (type == ETHTOOL_A_STRINGSET_ID) {
135762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
135862306a36Sopenharmony_ci				return MNL_CB_ERROR;
135962306a36Sopenharmony_ci			dst->_present.id = 1;
136062306a36Sopenharmony_ci			dst->id = mnl_attr_get_u32(attr);
136162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_STRINGSET_COUNT) {
136262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
136362306a36Sopenharmony_ci				return MNL_CB_ERROR;
136462306a36Sopenharmony_ci			dst->_present.count = 1;
136562306a36Sopenharmony_ci			dst->count = mnl_attr_get_u32(attr);
136662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_STRINGSET_STRINGS) {
136762306a36Sopenharmony_ci			n_strings++;
136862306a36Sopenharmony_ci		}
136962306a36Sopenharmony_ci	}
137062306a36Sopenharmony_ci
137162306a36Sopenharmony_ci	if (n_strings) {
137262306a36Sopenharmony_ci		dst->strings = calloc(n_strings, sizeof(*dst->strings));
137362306a36Sopenharmony_ci		dst->n_strings = n_strings;
137462306a36Sopenharmony_ci		i = 0;
137562306a36Sopenharmony_ci		parg.rsp_policy = &ethtool_strings_nest;
137662306a36Sopenharmony_ci		mnl_attr_for_each_nested(attr, nested) {
137762306a36Sopenharmony_ci			if (mnl_attr_get_type(attr) == ETHTOOL_A_STRINGSET_STRINGS) {
137862306a36Sopenharmony_ci				parg.data = &dst->strings[i];
137962306a36Sopenharmony_ci				if (ethtool_strings_parse(&parg, attr))
138062306a36Sopenharmony_ci					return MNL_CB_ERROR;
138162306a36Sopenharmony_ci				i++;
138262306a36Sopenharmony_ci			}
138362306a36Sopenharmony_ci		}
138462306a36Sopenharmony_ci	}
138562306a36Sopenharmony_ci
138662306a36Sopenharmony_ci	return 0;
138762306a36Sopenharmony_ci}
138862306a36Sopenharmony_ci
138962306a36Sopenharmony_civoid ethtool_tunnel_udp_table_free(struct ethtool_tunnel_udp_table *obj)
139062306a36Sopenharmony_ci{
139162306a36Sopenharmony_ci	unsigned int i;
139262306a36Sopenharmony_ci
139362306a36Sopenharmony_ci	ethtool_bitset_free(&obj->types);
139462306a36Sopenharmony_ci	for (i = 0; i < obj->n_entry; i++)
139562306a36Sopenharmony_ci		ethtool_tunnel_udp_entry_free(&obj->entry[i]);
139662306a36Sopenharmony_ci	free(obj->entry);
139762306a36Sopenharmony_ci}
139862306a36Sopenharmony_ci
139962306a36Sopenharmony_ciint ethtool_tunnel_udp_table_parse(struct ynl_parse_arg *yarg,
140062306a36Sopenharmony_ci				   const struct nlattr *nested)
140162306a36Sopenharmony_ci{
140262306a36Sopenharmony_ci	struct ethtool_tunnel_udp_table *dst = yarg->data;
140362306a36Sopenharmony_ci	const struct nlattr *attr;
140462306a36Sopenharmony_ci	struct ynl_parse_arg parg;
140562306a36Sopenharmony_ci	unsigned int n_entry = 0;
140662306a36Sopenharmony_ci	int i;
140762306a36Sopenharmony_ci
140862306a36Sopenharmony_ci	parg.ys = yarg->ys;
140962306a36Sopenharmony_ci
141062306a36Sopenharmony_ci	if (dst->entry)
141162306a36Sopenharmony_ci		return ynl_error_parse(yarg, "attribute already present (tunnel-udp-table.entry)");
141262306a36Sopenharmony_ci
141362306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
141462306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
141562306a36Sopenharmony_ci
141662306a36Sopenharmony_ci		if (type == ETHTOOL_A_TUNNEL_UDP_TABLE_SIZE) {
141762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
141862306a36Sopenharmony_ci				return MNL_CB_ERROR;
141962306a36Sopenharmony_ci			dst->_present.size = 1;
142062306a36Sopenharmony_ci			dst->size = mnl_attr_get_u32(attr);
142162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES) {
142262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
142362306a36Sopenharmony_ci				return MNL_CB_ERROR;
142462306a36Sopenharmony_ci			dst->_present.types = 1;
142562306a36Sopenharmony_ci
142662306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
142762306a36Sopenharmony_ci			parg.data = &dst->types;
142862306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
142962306a36Sopenharmony_ci				return MNL_CB_ERROR;
143062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY) {
143162306a36Sopenharmony_ci			n_entry++;
143262306a36Sopenharmony_ci		}
143362306a36Sopenharmony_ci	}
143462306a36Sopenharmony_ci
143562306a36Sopenharmony_ci	if (n_entry) {
143662306a36Sopenharmony_ci		dst->entry = calloc(n_entry, sizeof(*dst->entry));
143762306a36Sopenharmony_ci		dst->n_entry = n_entry;
143862306a36Sopenharmony_ci		i = 0;
143962306a36Sopenharmony_ci		parg.rsp_policy = &ethtool_tunnel_udp_entry_nest;
144062306a36Sopenharmony_ci		mnl_attr_for_each_nested(attr, nested) {
144162306a36Sopenharmony_ci			if (mnl_attr_get_type(attr) == ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY) {
144262306a36Sopenharmony_ci				parg.data = &dst->entry[i];
144362306a36Sopenharmony_ci				if (ethtool_tunnel_udp_entry_parse(&parg, attr))
144462306a36Sopenharmony_ci					return MNL_CB_ERROR;
144562306a36Sopenharmony_ci				i++;
144662306a36Sopenharmony_ci			}
144762306a36Sopenharmony_ci		}
144862306a36Sopenharmony_ci	}
144962306a36Sopenharmony_ci
145062306a36Sopenharmony_ci	return 0;
145162306a36Sopenharmony_ci}
145262306a36Sopenharmony_ci
145362306a36Sopenharmony_civoid ethtool_stringsets_free(struct ethtool_stringsets *obj)
145462306a36Sopenharmony_ci{
145562306a36Sopenharmony_ci	unsigned int i;
145662306a36Sopenharmony_ci
145762306a36Sopenharmony_ci	for (i = 0; i < obj->n_stringset; i++)
145862306a36Sopenharmony_ci		ethtool_stringset_free(&obj->stringset[i]);
145962306a36Sopenharmony_ci	free(obj->stringset);
146062306a36Sopenharmony_ci}
146162306a36Sopenharmony_ci
146262306a36Sopenharmony_ciint ethtool_stringsets_put(struct nlmsghdr *nlh, unsigned int attr_type,
146362306a36Sopenharmony_ci			   struct ethtool_stringsets *obj)
146462306a36Sopenharmony_ci{
146562306a36Sopenharmony_ci	struct nlattr *nest;
146662306a36Sopenharmony_ci
146762306a36Sopenharmony_ci	nest = mnl_attr_nest_start(nlh, attr_type);
146862306a36Sopenharmony_ci	for (unsigned int i = 0; i < obj->n_stringset; i++)
146962306a36Sopenharmony_ci		ethtool_stringset_put(nlh, ETHTOOL_A_STRINGSETS_STRINGSET, &obj->stringset[i]);
147062306a36Sopenharmony_ci	mnl_attr_nest_end(nlh, nest);
147162306a36Sopenharmony_ci
147262306a36Sopenharmony_ci	return 0;
147362306a36Sopenharmony_ci}
147462306a36Sopenharmony_ci
147562306a36Sopenharmony_ciint ethtool_stringsets_parse(struct ynl_parse_arg *yarg,
147662306a36Sopenharmony_ci			     const struct nlattr *nested)
147762306a36Sopenharmony_ci{
147862306a36Sopenharmony_ci	struct ethtool_stringsets *dst = yarg->data;
147962306a36Sopenharmony_ci	unsigned int n_stringset = 0;
148062306a36Sopenharmony_ci	const struct nlattr *attr;
148162306a36Sopenharmony_ci	struct ynl_parse_arg parg;
148262306a36Sopenharmony_ci	int i;
148362306a36Sopenharmony_ci
148462306a36Sopenharmony_ci	parg.ys = yarg->ys;
148562306a36Sopenharmony_ci
148662306a36Sopenharmony_ci	if (dst->stringset)
148762306a36Sopenharmony_ci		return ynl_error_parse(yarg, "attribute already present (stringsets.stringset)");
148862306a36Sopenharmony_ci
148962306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
149062306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
149162306a36Sopenharmony_ci
149262306a36Sopenharmony_ci		if (type == ETHTOOL_A_STRINGSETS_STRINGSET) {
149362306a36Sopenharmony_ci			n_stringset++;
149462306a36Sopenharmony_ci		}
149562306a36Sopenharmony_ci	}
149662306a36Sopenharmony_ci
149762306a36Sopenharmony_ci	if (n_stringset) {
149862306a36Sopenharmony_ci		dst->stringset = calloc(n_stringset, sizeof(*dst->stringset));
149962306a36Sopenharmony_ci		dst->n_stringset = n_stringset;
150062306a36Sopenharmony_ci		i = 0;
150162306a36Sopenharmony_ci		parg.rsp_policy = &ethtool_stringset_nest;
150262306a36Sopenharmony_ci		mnl_attr_for_each_nested(attr, nested) {
150362306a36Sopenharmony_ci			if (mnl_attr_get_type(attr) == ETHTOOL_A_STRINGSETS_STRINGSET) {
150462306a36Sopenharmony_ci				parg.data = &dst->stringset[i];
150562306a36Sopenharmony_ci				if (ethtool_stringset_parse(&parg, attr))
150662306a36Sopenharmony_ci					return MNL_CB_ERROR;
150762306a36Sopenharmony_ci				i++;
150862306a36Sopenharmony_ci			}
150962306a36Sopenharmony_ci		}
151062306a36Sopenharmony_ci	}
151162306a36Sopenharmony_ci
151262306a36Sopenharmony_ci	return 0;
151362306a36Sopenharmony_ci}
151462306a36Sopenharmony_ci
151562306a36Sopenharmony_civoid ethtool_tunnel_udp_free(struct ethtool_tunnel_udp *obj)
151662306a36Sopenharmony_ci{
151762306a36Sopenharmony_ci	ethtool_tunnel_udp_table_free(&obj->table);
151862306a36Sopenharmony_ci}
151962306a36Sopenharmony_ci
152062306a36Sopenharmony_ciint ethtool_tunnel_udp_parse(struct ynl_parse_arg *yarg,
152162306a36Sopenharmony_ci			     const struct nlattr *nested)
152262306a36Sopenharmony_ci{
152362306a36Sopenharmony_ci	struct ethtool_tunnel_udp *dst = yarg->data;
152462306a36Sopenharmony_ci	const struct nlattr *attr;
152562306a36Sopenharmony_ci	struct ynl_parse_arg parg;
152662306a36Sopenharmony_ci
152762306a36Sopenharmony_ci	parg.ys = yarg->ys;
152862306a36Sopenharmony_ci
152962306a36Sopenharmony_ci	mnl_attr_for_each_nested(attr, nested) {
153062306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
153162306a36Sopenharmony_ci
153262306a36Sopenharmony_ci		if (type == ETHTOOL_A_TUNNEL_UDP_TABLE) {
153362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
153462306a36Sopenharmony_ci				return MNL_CB_ERROR;
153562306a36Sopenharmony_ci			dst->_present.table = 1;
153662306a36Sopenharmony_ci
153762306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_tunnel_udp_table_nest;
153862306a36Sopenharmony_ci			parg.data = &dst->table;
153962306a36Sopenharmony_ci			if (ethtool_tunnel_udp_table_parse(&parg, attr))
154062306a36Sopenharmony_ci				return MNL_CB_ERROR;
154162306a36Sopenharmony_ci		}
154262306a36Sopenharmony_ci	}
154362306a36Sopenharmony_ci
154462306a36Sopenharmony_ci	return 0;
154562306a36Sopenharmony_ci}
154662306a36Sopenharmony_ci
154762306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_STRSET_GET ============== */
154862306a36Sopenharmony_ci/* ETHTOOL_MSG_STRSET_GET - do */
154962306a36Sopenharmony_civoid ethtool_strset_get_req_free(struct ethtool_strset_get_req *req)
155062306a36Sopenharmony_ci{
155162306a36Sopenharmony_ci	ethtool_header_free(&req->header);
155262306a36Sopenharmony_ci	ethtool_stringsets_free(&req->stringsets);
155362306a36Sopenharmony_ci	free(req);
155462306a36Sopenharmony_ci}
155562306a36Sopenharmony_ci
155662306a36Sopenharmony_civoid ethtool_strset_get_rsp_free(struct ethtool_strset_get_rsp *rsp)
155762306a36Sopenharmony_ci{
155862306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
155962306a36Sopenharmony_ci	ethtool_stringsets_free(&rsp->stringsets);
156062306a36Sopenharmony_ci	free(rsp);
156162306a36Sopenharmony_ci}
156262306a36Sopenharmony_ci
156362306a36Sopenharmony_ciint ethtool_strset_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
156462306a36Sopenharmony_ci{
156562306a36Sopenharmony_ci	struct ethtool_strset_get_rsp *dst;
156662306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
156762306a36Sopenharmony_ci	const struct nlattr *attr;
156862306a36Sopenharmony_ci	struct ynl_parse_arg parg;
156962306a36Sopenharmony_ci
157062306a36Sopenharmony_ci	dst = yarg->data;
157162306a36Sopenharmony_ci	parg.ys = yarg->ys;
157262306a36Sopenharmony_ci
157362306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
157462306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
157562306a36Sopenharmony_ci
157662306a36Sopenharmony_ci		if (type == ETHTOOL_A_STRSET_HEADER) {
157762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
157862306a36Sopenharmony_ci				return MNL_CB_ERROR;
157962306a36Sopenharmony_ci			dst->_present.header = 1;
158062306a36Sopenharmony_ci
158162306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
158262306a36Sopenharmony_ci			parg.data = &dst->header;
158362306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
158462306a36Sopenharmony_ci				return MNL_CB_ERROR;
158562306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_STRSET_STRINGSETS) {
158662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
158762306a36Sopenharmony_ci				return MNL_CB_ERROR;
158862306a36Sopenharmony_ci			dst->_present.stringsets = 1;
158962306a36Sopenharmony_ci
159062306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_stringsets_nest;
159162306a36Sopenharmony_ci			parg.data = &dst->stringsets;
159262306a36Sopenharmony_ci			if (ethtool_stringsets_parse(&parg, attr))
159362306a36Sopenharmony_ci				return MNL_CB_ERROR;
159462306a36Sopenharmony_ci		}
159562306a36Sopenharmony_ci	}
159662306a36Sopenharmony_ci
159762306a36Sopenharmony_ci	return MNL_CB_OK;
159862306a36Sopenharmony_ci}
159962306a36Sopenharmony_ci
160062306a36Sopenharmony_cistruct ethtool_strset_get_rsp *
160162306a36Sopenharmony_ciethtool_strset_get(struct ynl_sock *ys, struct ethtool_strset_get_req *req)
160262306a36Sopenharmony_ci{
160362306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
160462306a36Sopenharmony_ci	struct ethtool_strset_get_rsp *rsp;
160562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
160662306a36Sopenharmony_ci	int err;
160762306a36Sopenharmony_ci
160862306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_STRSET_GET, 1);
160962306a36Sopenharmony_ci	ys->req_policy = &ethtool_strset_nest;
161062306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_strset_nest;
161162306a36Sopenharmony_ci
161262306a36Sopenharmony_ci	if (req->_present.header)
161362306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_STRSET_HEADER, &req->header);
161462306a36Sopenharmony_ci	if (req->_present.stringsets)
161562306a36Sopenharmony_ci		ethtool_stringsets_put(nlh, ETHTOOL_A_STRSET_STRINGSETS, &req->stringsets);
161662306a36Sopenharmony_ci	if (req->_present.counts_only)
161762306a36Sopenharmony_ci		mnl_attr_put(nlh, ETHTOOL_A_STRSET_COUNTS_ONLY, 0, NULL);
161862306a36Sopenharmony_ci
161962306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
162062306a36Sopenharmony_ci	yrs.yarg.data = rsp;
162162306a36Sopenharmony_ci	yrs.cb = ethtool_strset_get_rsp_parse;
162262306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_STRSET_GET;
162362306a36Sopenharmony_ci
162462306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
162562306a36Sopenharmony_ci	if (err < 0)
162662306a36Sopenharmony_ci		goto err_free;
162762306a36Sopenharmony_ci
162862306a36Sopenharmony_ci	return rsp;
162962306a36Sopenharmony_ci
163062306a36Sopenharmony_cierr_free:
163162306a36Sopenharmony_ci	ethtool_strset_get_rsp_free(rsp);
163262306a36Sopenharmony_ci	return NULL;
163362306a36Sopenharmony_ci}
163462306a36Sopenharmony_ci
163562306a36Sopenharmony_ci/* ETHTOOL_MSG_STRSET_GET - dump */
163662306a36Sopenharmony_civoid ethtool_strset_get_list_free(struct ethtool_strset_get_list *rsp)
163762306a36Sopenharmony_ci{
163862306a36Sopenharmony_ci	struct ethtool_strset_get_list *next = rsp;
163962306a36Sopenharmony_ci
164062306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
164162306a36Sopenharmony_ci		rsp = next;
164262306a36Sopenharmony_ci		next = rsp->next;
164362306a36Sopenharmony_ci
164462306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
164562306a36Sopenharmony_ci		ethtool_stringsets_free(&rsp->obj.stringsets);
164662306a36Sopenharmony_ci		free(rsp);
164762306a36Sopenharmony_ci	}
164862306a36Sopenharmony_ci}
164962306a36Sopenharmony_ci
165062306a36Sopenharmony_cistruct ethtool_strset_get_list *
165162306a36Sopenharmony_ciethtool_strset_get_dump(struct ynl_sock *ys,
165262306a36Sopenharmony_ci			struct ethtool_strset_get_req_dump *req)
165362306a36Sopenharmony_ci{
165462306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
165562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
165662306a36Sopenharmony_ci	int err;
165762306a36Sopenharmony_ci
165862306a36Sopenharmony_ci	yds.ys = ys;
165962306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_strset_get_list);
166062306a36Sopenharmony_ci	yds.cb = ethtool_strset_get_rsp_parse;
166162306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_STRSET_GET;
166262306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_strset_nest;
166362306a36Sopenharmony_ci
166462306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_STRSET_GET, 1);
166562306a36Sopenharmony_ci	ys->req_policy = &ethtool_strset_nest;
166662306a36Sopenharmony_ci
166762306a36Sopenharmony_ci	if (req->_present.header)
166862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_STRSET_HEADER, &req->header);
166962306a36Sopenharmony_ci	if (req->_present.stringsets)
167062306a36Sopenharmony_ci		ethtool_stringsets_put(nlh, ETHTOOL_A_STRSET_STRINGSETS, &req->stringsets);
167162306a36Sopenharmony_ci	if (req->_present.counts_only)
167262306a36Sopenharmony_ci		mnl_attr_put(nlh, ETHTOOL_A_STRSET_COUNTS_ONLY, 0, NULL);
167362306a36Sopenharmony_ci
167462306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
167562306a36Sopenharmony_ci	if (err < 0)
167662306a36Sopenharmony_ci		goto free_list;
167762306a36Sopenharmony_ci
167862306a36Sopenharmony_ci	return yds.first;
167962306a36Sopenharmony_ci
168062306a36Sopenharmony_cifree_list:
168162306a36Sopenharmony_ci	ethtool_strset_get_list_free(yds.first);
168262306a36Sopenharmony_ci	return NULL;
168362306a36Sopenharmony_ci}
168462306a36Sopenharmony_ci
168562306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_LINKINFO_GET ============== */
168662306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKINFO_GET - do */
168762306a36Sopenharmony_civoid ethtool_linkinfo_get_req_free(struct ethtool_linkinfo_get_req *req)
168862306a36Sopenharmony_ci{
168962306a36Sopenharmony_ci	ethtool_header_free(&req->header);
169062306a36Sopenharmony_ci	free(req);
169162306a36Sopenharmony_ci}
169262306a36Sopenharmony_ci
169362306a36Sopenharmony_civoid ethtool_linkinfo_get_rsp_free(struct ethtool_linkinfo_get_rsp *rsp)
169462306a36Sopenharmony_ci{
169562306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
169662306a36Sopenharmony_ci	free(rsp);
169762306a36Sopenharmony_ci}
169862306a36Sopenharmony_ci
169962306a36Sopenharmony_ciint ethtool_linkinfo_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
170062306a36Sopenharmony_ci{
170162306a36Sopenharmony_ci	struct ethtool_linkinfo_get_rsp *dst;
170262306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
170362306a36Sopenharmony_ci	const struct nlattr *attr;
170462306a36Sopenharmony_ci	struct ynl_parse_arg parg;
170562306a36Sopenharmony_ci
170662306a36Sopenharmony_ci	dst = yarg->data;
170762306a36Sopenharmony_ci	parg.ys = yarg->ys;
170862306a36Sopenharmony_ci
170962306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
171062306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
171162306a36Sopenharmony_ci
171262306a36Sopenharmony_ci		if (type == ETHTOOL_A_LINKINFO_HEADER) {
171362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
171462306a36Sopenharmony_ci				return MNL_CB_ERROR;
171562306a36Sopenharmony_ci			dst->_present.header = 1;
171662306a36Sopenharmony_ci
171762306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
171862306a36Sopenharmony_ci			parg.data = &dst->header;
171962306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
172062306a36Sopenharmony_ci				return MNL_CB_ERROR;
172162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKINFO_PORT) {
172262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
172362306a36Sopenharmony_ci				return MNL_CB_ERROR;
172462306a36Sopenharmony_ci			dst->_present.port = 1;
172562306a36Sopenharmony_ci			dst->port = mnl_attr_get_u8(attr);
172662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKINFO_PHYADDR) {
172762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
172862306a36Sopenharmony_ci				return MNL_CB_ERROR;
172962306a36Sopenharmony_ci			dst->_present.phyaddr = 1;
173062306a36Sopenharmony_ci			dst->phyaddr = mnl_attr_get_u8(attr);
173162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKINFO_TP_MDIX) {
173262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
173362306a36Sopenharmony_ci				return MNL_CB_ERROR;
173462306a36Sopenharmony_ci			dst->_present.tp_mdix = 1;
173562306a36Sopenharmony_ci			dst->tp_mdix = mnl_attr_get_u8(attr);
173662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKINFO_TP_MDIX_CTRL) {
173762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
173862306a36Sopenharmony_ci				return MNL_CB_ERROR;
173962306a36Sopenharmony_ci			dst->_present.tp_mdix_ctrl = 1;
174062306a36Sopenharmony_ci			dst->tp_mdix_ctrl = mnl_attr_get_u8(attr);
174162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKINFO_TRANSCEIVER) {
174262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
174362306a36Sopenharmony_ci				return MNL_CB_ERROR;
174462306a36Sopenharmony_ci			dst->_present.transceiver = 1;
174562306a36Sopenharmony_ci			dst->transceiver = mnl_attr_get_u8(attr);
174662306a36Sopenharmony_ci		}
174762306a36Sopenharmony_ci	}
174862306a36Sopenharmony_ci
174962306a36Sopenharmony_ci	return MNL_CB_OK;
175062306a36Sopenharmony_ci}
175162306a36Sopenharmony_ci
175262306a36Sopenharmony_cistruct ethtool_linkinfo_get_rsp *
175362306a36Sopenharmony_ciethtool_linkinfo_get(struct ynl_sock *ys, struct ethtool_linkinfo_get_req *req)
175462306a36Sopenharmony_ci{
175562306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
175662306a36Sopenharmony_ci	struct ethtool_linkinfo_get_rsp *rsp;
175762306a36Sopenharmony_ci	struct nlmsghdr *nlh;
175862306a36Sopenharmony_ci	int err;
175962306a36Sopenharmony_ci
176062306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKINFO_GET, 1);
176162306a36Sopenharmony_ci	ys->req_policy = &ethtool_linkinfo_nest;
176262306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_linkinfo_nest;
176362306a36Sopenharmony_ci
176462306a36Sopenharmony_ci	if (req->_present.header)
176562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_LINKINFO_HEADER, &req->header);
176662306a36Sopenharmony_ci
176762306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
176862306a36Sopenharmony_ci	yrs.yarg.data = rsp;
176962306a36Sopenharmony_ci	yrs.cb = ethtool_linkinfo_get_rsp_parse;
177062306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_LINKINFO_GET;
177162306a36Sopenharmony_ci
177262306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
177362306a36Sopenharmony_ci	if (err < 0)
177462306a36Sopenharmony_ci		goto err_free;
177562306a36Sopenharmony_ci
177662306a36Sopenharmony_ci	return rsp;
177762306a36Sopenharmony_ci
177862306a36Sopenharmony_cierr_free:
177962306a36Sopenharmony_ci	ethtool_linkinfo_get_rsp_free(rsp);
178062306a36Sopenharmony_ci	return NULL;
178162306a36Sopenharmony_ci}
178262306a36Sopenharmony_ci
178362306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKINFO_GET - dump */
178462306a36Sopenharmony_civoid ethtool_linkinfo_get_list_free(struct ethtool_linkinfo_get_list *rsp)
178562306a36Sopenharmony_ci{
178662306a36Sopenharmony_ci	struct ethtool_linkinfo_get_list *next = rsp;
178762306a36Sopenharmony_ci
178862306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
178962306a36Sopenharmony_ci		rsp = next;
179062306a36Sopenharmony_ci		next = rsp->next;
179162306a36Sopenharmony_ci
179262306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
179362306a36Sopenharmony_ci		free(rsp);
179462306a36Sopenharmony_ci	}
179562306a36Sopenharmony_ci}
179662306a36Sopenharmony_ci
179762306a36Sopenharmony_cistruct ethtool_linkinfo_get_list *
179862306a36Sopenharmony_ciethtool_linkinfo_get_dump(struct ynl_sock *ys,
179962306a36Sopenharmony_ci			  struct ethtool_linkinfo_get_req_dump *req)
180062306a36Sopenharmony_ci{
180162306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
180262306a36Sopenharmony_ci	struct nlmsghdr *nlh;
180362306a36Sopenharmony_ci	int err;
180462306a36Sopenharmony_ci
180562306a36Sopenharmony_ci	yds.ys = ys;
180662306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_linkinfo_get_list);
180762306a36Sopenharmony_ci	yds.cb = ethtool_linkinfo_get_rsp_parse;
180862306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_LINKINFO_GET;
180962306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_linkinfo_nest;
181062306a36Sopenharmony_ci
181162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_LINKINFO_GET, 1);
181262306a36Sopenharmony_ci	ys->req_policy = &ethtool_linkinfo_nest;
181362306a36Sopenharmony_ci
181462306a36Sopenharmony_ci	if (req->_present.header)
181562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_LINKINFO_HEADER, &req->header);
181662306a36Sopenharmony_ci
181762306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
181862306a36Sopenharmony_ci	if (err < 0)
181962306a36Sopenharmony_ci		goto free_list;
182062306a36Sopenharmony_ci
182162306a36Sopenharmony_ci	return yds.first;
182262306a36Sopenharmony_ci
182362306a36Sopenharmony_cifree_list:
182462306a36Sopenharmony_ci	ethtool_linkinfo_get_list_free(yds.first);
182562306a36Sopenharmony_ci	return NULL;
182662306a36Sopenharmony_ci}
182762306a36Sopenharmony_ci
182862306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKINFO_GET - notify */
182962306a36Sopenharmony_civoid ethtool_linkinfo_get_ntf_free(struct ethtool_linkinfo_get_ntf *rsp)
183062306a36Sopenharmony_ci{
183162306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
183262306a36Sopenharmony_ci	free(rsp);
183362306a36Sopenharmony_ci}
183462306a36Sopenharmony_ci
183562306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_LINKINFO_SET ============== */
183662306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKINFO_SET - do */
183762306a36Sopenharmony_civoid ethtool_linkinfo_set_req_free(struct ethtool_linkinfo_set_req *req)
183862306a36Sopenharmony_ci{
183962306a36Sopenharmony_ci	ethtool_header_free(&req->header);
184062306a36Sopenharmony_ci	free(req);
184162306a36Sopenharmony_ci}
184262306a36Sopenharmony_ci
184362306a36Sopenharmony_ciint ethtool_linkinfo_set(struct ynl_sock *ys,
184462306a36Sopenharmony_ci			 struct ethtool_linkinfo_set_req *req)
184562306a36Sopenharmony_ci{
184662306a36Sopenharmony_ci	struct nlmsghdr *nlh;
184762306a36Sopenharmony_ci	int err;
184862306a36Sopenharmony_ci
184962306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKINFO_SET, 1);
185062306a36Sopenharmony_ci	ys->req_policy = &ethtool_linkinfo_nest;
185162306a36Sopenharmony_ci
185262306a36Sopenharmony_ci	if (req->_present.header)
185362306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_LINKINFO_HEADER, &req->header);
185462306a36Sopenharmony_ci	if (req->_present.port)
185562306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_PORT, req->port);
185662306a36Sopenharmony_ci	if (req->_present.phyaddr)
185762306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_PHYADDR, req->phyaddr);
185862306a36Sopenharmony_ci	if (req->_present.tp_mdix)
185962306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_TP_MDIX, req->tp_mdix);
186062306a36Sopenharmony_ci	if (req->_present.tp_mdix_ctrl)
186162306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_TP_MDIX_CTRL, req->tp_mdix_ctrl);
186262306a36Sopenharmony_ci	if (req->_present.transceiver)
186362306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_TRANSCEIVER, req->transceiver);
186462306a36Sopenharmony_ci
186562306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
186662306a36Sopenharmony_ci	if (err < 0)
186762306a36Sopenharmony_ci		return -1;
186862306a36Sopenharmony_ci
186962306a36Sopenharmony_ci	return 0;
187062306a36Sopenharmony_ci}
187162306a36Sopenharmony_ci
187262306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_LINKMODES_GET ============== */
187362306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKMODES_GET - do */
187462306a36Sopenharmony_civoid ethtool_linkmodes_get_req_free(struct ethtool_linkmodes_get_req *req)
187562306a36Sopenharmony_ci{
187662306a36Sopenharmony_ci	ethtool_header_free(&req->header);
187762306a36Sopenharmony_ci	free(req);
187862306a36Sopenharmony_ci}
187962306a36Sopenharmony_ci
188062306a36Sopenharmony_civoid ethtool_linkmodes_get_rsp_free(struct ethtool_linkmodes_get_rsp *rsp)
188162306a36Sopenharmony_ci{
188262306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
188362306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->ours);
188462306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->peer);
188562306a36Sopenharmony_ci	free(rsp);
188662306a36Sopenharmony_ci}
188762306a36Sopenharmony_ci
188862306a36Sopenharmony_ciint ethtool_linkmodes_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
188962306a36Sopenharmony_ci{
189062306a36Sopenharmony_ci	struct ethtool_linkmodes_get_rsp *dst;
189162306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
189262306a36Sopenharmony_ci	const struct nlattr *attr;
189362306a36Sopenharmony_ci	struct ynl_parse_arg parg;
189462306a36Sopenharmony_ci
189562306a36Sopenharmony_ci	dst = yarg->data;
189662306a36Sopenharmony_ci	parg.ys = yarg->ys;
189762306a36Sopenharmony_ci
189862306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
189962306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
190062306a36Sopenharmony_ci
190162306a36Sopenharmony_ci		if (type == ETHTOOL_A_LINKMODES_HEADER) {
190262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
190362306a36Sopenharmony_ci				return MNL_CB_ERROR;
190462306a36Sopenharmony_ci			dst->_present.header = 1;
190562306a36Sopenharmony_ci
190662306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
190762306a36Sopenharmony_ci			parg.data = &dst->header;
190862306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
190962306a36Sopenharmony_ci				return MNL_CB_ERROR;
191062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKMODES_AUTONEG) {
191162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
191262306a36Sopenharmony_ci				return MNL_CB_ERROR;
191362306a36Sopenharmony_ci			dst->_present.autoneg = 1;
191462306a36Sopenharmony_ci			dst->autoneg = mnl_attr_get_u8(attr);
191562306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKMODES_OURS) {
191662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
191762306a36Sopenharmony_ci				return MNL_CB_ERROR;
191862306a36Sopenharmony_ci			dst->_present.ours = 1;
191962306a36Sopenharmony_ci
192062306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
192162306a36Sopenharmony_ci			parg.data = &dst->ours;
192262306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
192362306a36Sopenharmony_ci				return MNL_CB_ERROR;
192462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKMODES_PEER) {
192562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
192662306a36Sopenharmony_ci				return MNL_CB_ERROR;
192762306a36Sopenharmony_ci			dst->_present.peer = 1;
192862306a36Sopenharmony_ci
192962306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
193062306a36Sopenharmony_ci			parg.data = &dst->peer;
193162306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
193262306a36Sopenharmony_ci				return MNL_CB_ERROR;
193362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKMODES_SPEED) {
193462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
193562306a36Sopenharmony_ci				return MNL_CB_ERROR;
193662306a36Sopenharmony_ci			dst->_present.speed = 1;
193762306a36Sopenharmony_ci			dst->speed = mnl_attr_get_u32(attr);
193862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKMODES_DUPLEX) {
193962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
194062306a36Sopenharmony_ci				return MNL_CB_ERROR;
194162306a36Sopenharmony_ci			dst->_present.duplex = 1;
194262306a36Sopenharmony_ci			dst->duplex = mnl_attr_get_u8(attr);
194362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG) {
194462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
194562306a36Sopenharmony_ci				return MNL_CB_ERROR;
194662306a36Sopenharmony_ci			dst->_present.master_slave_cfg = 1;
194762306a36Sopenharmony_ci			dst->master_slave_cfg = mnl_attr_get_u8(attr);
194862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE) {
194962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
195062306a36Sopenharmony_ci				return MNL_CB_ERROR;
195162306a36Sopenharmony_ci			dst->_present.master_slave_state = 1;
195262306a36Sopenharmony_ci			dst->master_slave_state = mnl_attr_get_u8(attr);
195362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKMODES_LANES) {
195462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
195562306a36Sopenharmony_ci				return MNL_CB_ERROR;
195662306a36Sopenharmony_ci			dst->_present.lanes = 1;
195762306a36Sopenharmony_ci			dst->lanes = mnl_attr_get_u32(attr);
195862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKMODES_RATE_MATCHING) {
195962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
196062306a36Sopenharmony_ci				return MNL_CB_ERROR;
196162306a36Sopenharmony_ci			dst->_present.rate_matching = 1;
196262306a36Sopenharmony_ci			dst->rate_matching = mnl_attr_get_u8(attr);
196362306a36Sopenharmony_ci		}
196462306a36Sopenharmony_ci	}
196562306a36Sopenharmony_ci
196662306a36Sopenharmony_ci	return MNL_CB_OK;
196762306a36Sopenharmony_ci}
196862306a36Sopenharmony_ci
196962306a36Sopenharmony_cistruct ethtool_linkmodes_get_rsp *
197062306a36Sopenharmony_ciethtool_linkmodes_get(struct ynl_sock *ys,
197162306a36Sopenharmony_ci		      struct ethtool_linkmodes_get_req *req)
197262306a36Sopenharmony_ci{
197362306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
197462306a36Sopenharmony_ci	struct ethtool_linkmodes_get_rsp *rsp;
197562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
197662306a36Sopenharmony_ci	int err;
197762306a36Sopenharmony_ci
197862306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKMODES_GET, 1);
197962306a36Sopenharmony_ci	ys->req_policy = &ethtool_linkmodes_nest;
198062306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_linkmodes_nest;
198162306a36Sopenharmony_ci
198262306a36Sopenharmony_ci	if (req->_present.header)
198362306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_LINKMODES_HEADER, &req->header);
198462306a36Sopenharmony_ci
198562306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
198662306a36Sopenharmony_ci	yrs.yarg.data = rsp;
198762306a36Sopenharmony_ci	yrs.cb = ethtool_linkmodes_get_rsp_parse;
198862306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_LINKMODES_GET;
198962306a36Sopenharmony_ci
199062306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
199162306a36Sopenharmony_ci	if (err < 0)
199262306a36Sopenharmony_ci		goto err_free;
199362306a36Sopenharmony_ci
199462306a36Sopenharmony_ci	return rsp;
199562306a36Sopenharmony_ci
199662306a36Sopenharmony_cierr_free:
199762306a36Sopenharmony_ci	ethtool_linkmodes_get_rsp_free(rsp);
199862306a36Sopenharmony_ci	return NULL;
199962306a36Sopenharmony_ci}
200062306a36Sopenharmony_ci
200162306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKMODES_GET - dump */
200262306a36Sopenharmony_civoid ethtool_linkmodes_get_list_free(struct ethtool_linkmodes_get_list *rsp)
200362306a36Sopenharmony_ci{
200462306a36Sopenharmony_ci	struct ethtool_linkmodes_get_list *next = rsp;
200562306a36Sopenharmony_ci
200662306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
200762306a36Sopenharmony_ci		rsp = next;
200862306a36Sopenharmony_ci		next = rsp->next;
200962306a36Sopenharmony_ci
201062306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
201162306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.ours);
201262306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.peer);
201362306a36Sopenharmony_ci		free(rsp);
201462306a36Sopenharmony_ci	}
201562306a36Sopenharmony_ci}
201662306a36Sopenharmony_ci
201762306a36Sopenharmony_cistruct ethtool_linkmodes_get_list *
201862306a36Sopenharmony_ciethtool_linkmodes_get_dump(struct ynl_sock *ys,
201962306a36Sopenharmony_ci			   struct ethtool_linkmodes_get_req_dump *req)
202062306a36Sopenharmony_ci{
202162306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
202262306a36Sopenharmony_ci	struct nlmsghdr *nlh;
202362306a36Sopenharmony_ci	int err;
202462306a36Sopenharmony_ci
202562306a36Sopenharmony_ci	yds.ys = ys;
202662306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_linkmodes_get_list);
202762306a36Sopenharmony_ci	yds.cb = ethtool_linkmodes_get_rsp_parse;
202862306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_LINKMODES_GET;
202962306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_linkmodes_nest;
203062306a36Sopenharmony_ci
203162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_LINKMODES_GET, 1);
203262306a36Sopenharmony_ci	ys->req_policy = &ethtool_linkmodes_nest;
203362306a36Sopenharmony_ci
203462306a36Sopenharmony_ci	if (req->_present.header)
203562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_LINKMODES_HEADER, &req->header);
203662306a36Sopenharmony_ci
203762306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
203862306a36Sopenharmony_ci	if (err < 0)
203962306a36Sopenharmony_ci		goto free_list;
204062306a36Sopenharmony_ci
204162306a36Sopenharmony_ci	return yds.first;
204262306a36Sopenharmony_ci
204362306a36Sopenharmony_cifree_list:
204462306a36Sopenharmony_ci	ethtool_linkmodes_get_list_free(yds.first);
204562306a36Sopenharmony_ci	return NULL;
204662306a36Sopenharmony_ci}
204762306a36Sopenharmony_ci
204862306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKMODES_GET - notify */
204962306a36Sopenharmony_civoid ethtool_linkmodes_get_ntf_free(struct ethtool_linkmodes_get_ntf *rsp)
205062306a36Sopenharmony_ci{
205162306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
205262306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.ours);
205362306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.peer);
205462306a36Sopenharmony_ci	free(rsp);
205562306a36Sopenharmony_ci}
205662306a36Sopenharmony_ci
205762306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_LINKMODES_SET ============== */
205862306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKMODES_SET - do */
205962306a36Sopenharmony_civoid ethtool_linkmodes_set_req_free(struct ethtool_linkmodes_set_req *req)
206062306a36Sopenharmony_ci{
206162306a36Sopenharmony_ci	ethtool_header_free(&req->header);
206262306a36Sopenharmony_ci	ethtool_bitset_free(&req->ours);
206362306a36Sopenharmony_ci	ethtool_bitset_free(&req->peer);
206462306a36Sopenharmony_ci	free(req);
206562306a36Sopenharmony_ci}
206662306a36Sopenharmony_ci
206762306a36Sopenharmony_ciint ethtool_linkmodes_set(struct ynl_sock *ys,
206862306a36Sopenharmony_ci			  struct ethtool_linkmodes_set_req *req)
206962306a36Sopenharmony_ci{
207062306a36Sopenharmony_ci	struct nlmsghdr *nlh;
207162306a36Sopenharmony_ci	int err;
207262306a36Sopenharmony_ci
207362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKMODES_SET, 1);
207462306a36Sopenharmony_ci	ys->req_policy = &ethtool_linkmodes_nest;
207562306a36Sopenharmony_ci
207662306a36Sopenharmony_ci	if (req->_present.header)
207762306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_LINKMODES_HEADER, &req->header);
207862306a36Sopenharmony_ci	if (req->_present.autoneg)
207962306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_AUTONEG, req->autoneg);
208062306a36Sopenharmony_ci	if (req->_present.ours)
208162306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_LINKMODES_OURS, &req->ours);
208262306a36Sopenharmony_ci	if (req->_present.peer)
208362306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_LINKMODES_PEER, &req->peer);
208462306a36Sopenharmony_ci	if (req->_present.speed)
208562306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_LINKMODES_SPEED, req->speed);
208662306a36Sopenharmony_ci	if (req->_present.duplex)
208762306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_DUPLEX, req->duplex);
208862306a36Sopenharmony_ci	if (req->_present.master_slave_cfg)
208962306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG, req->master_slave_cfg);
209062306a36Sopenharmony_ci	if (req->_present.master_slave_state)
209162306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE, req->master_slave_state);
209262306a36Sopenharmony_ci	if (req->_present.lanes)
209362306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_LINKMODES_LANES, req->lanes);
209462306a36Sopenharmony_ci	if (req->_present.rate_matching)
209562306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_RATE_MATCHING, req->rate_matching);
209662306a36Sopenharmony_ci
209762306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
209862306a36Sopenharmony_ci	if (err < 0)
209962306a36Sopenharmony_ci		return -1;
210062306a36Sopenharmony_ci
210162306a36Sopenharmony_ci	return 0;
210262306a36Sopenharmony_ci}
210362306a36Sopenharmony_ci
210462306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_LINKSTATE_GET ============== */
210562306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKSTATE_GET - do */
210662306a36Sopenharmony_civoid ethtool_linkstate_get_req_free(struct ethtool_linkstate_get_req *req)
210762306a36Sopenharmony_ci{
210862306a36Sopenharmony_ci	ethtool_header_free(&req->header);
210962306a36Sopenharmony_ci	free(req);
211062306a36Sopenharmony_ci}
211162306a36Sopenharmony_ci
211262306a36Sopenharmony_civoid ethtool_linkstate_get_rsp_free(struct ethtool_linkstate_get_rsp *rsp)
211362306a36Sopenharmony_ci{
211462306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
211562306a36Sopenharmony_ci	free(rsp);
211662306a36Sopenharmony_ci}
211762306a36Sopenharmony_ci
211862306a36Sopenharmony_ciint ethtool_linkstate_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
211962306a36Sopenharmony_ci{
212062306a36Sopenharmony_ci	struct ethtool_linkstate_get_rsp *dst;
212162306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
212262306a36Sopenharmony_ci	const struct nlattr *attr;
212362306a36Sopenharmony_ci	struct ynl_parse_arg parg;
212462306a36Sopenharmony_ci
212562306a36Sopenharmony_ci	dst = yarg->data;
212662306a36Sopenharmony_ci	parg.ys = yarg->ys;
212762306a36Sopenharmony_ci
212862306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
212962306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
213062306a36Sopenharmony_ci
213162306a36Sopenharmony_ci		if (type == ETHTOOL_A_LINKSTATE_HEADER) {
213262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
213362306a36Sopenharmony_ci				return MNL_CB_ERROR;
213462306a36Sopenharmony_ci			dst->_present.header = 1;
213562306a36Sopenharmony_ci
213662306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
213762306a36Sopenharmony_ci			parg.data = &dst->header;
213862306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
213962306a36Sopenharmony_ci				return MNL_CB_ERROR;
214062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKSTATE_LINK) {
214162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
214262306a36Sopenharmony_ci				return MNL_CB_ERROR;
214362306a36Sopenharmony_ci			dst->_present.link = 1;
214462306a36Sopenharmony_ci			dst->link = mnl_attr_get_u8(attr);
214562306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKSTATE_SQI) {
214662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
214762306a36Sopenharmony_ci				return MNL_CB_ERROR;
214862306a36Sopenharmony_ci			dst->_present.sqi = 1;
214962306a36Sopenharmony_ci			dst->sqi = mnl_attr_get_u32(attr);
215062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKSTATE_SQI_MAX) {
215162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
215262306a36Sopenharmony_ci				return MNL_CB_ERROR;
215362306a36Sopenharmony_ci			dst->_present.sqi_max = 1;
215462306a36Sopenharmony_ci			dst->sqi_max = mnl_attr_get_u32(attr);
215562306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKSTATE_EXT_STATE) {
215662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
215762306a36Sopenharmony_ci				return MNL_CB_ERROR;
215862306a36Sopenharmony_ci			dst->_present.ext_state = 1;
215962306a36Sopenharmony_ci			dst->ext_state = mnl_attr_get_u8(attr);
216062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKSTATE_EXT_SUBSTATE) {
216162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
216262306a36Sopenharmony_ci				return MNL_CB_ERROR;
216362306a36Sopenharmony_ci			dst->_present.ext_substate = 1;
216462306a36Sopenharmony_ci			dst->ext_substate = mnl_attr_get_u8(attr);
216562306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT) {
216662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
216762306a36Sopenharmony_ci				return MNL_CB_ERROR;
216862306a36Sopenharmony_ci			dst->_present.ext_down_cnt = 1;
216962306a36Sopenharmony_ci			dst->ext_down_cnt = mnl_attr_get_u32(attr);
217062306a36Sopenharmony_ci		}
217162306a36Sopenharmony_ci	}
217262306a36Sopenharmony_ci
217362306a36Sopenharmony_ci	return MNL_CB_OK;
217462306a36Sopenharmony_ci}
217562306a36Sopenharmony_ci
217662306a36Sopenharmony_cistruct ethtool_linkstate_get_rsp *
217762306a36Sopenharmony_ciethtool_linkstate_get(struct ynl_sock *ys,
217862306a36Sopenharmony_ci		      struct ethtool_linkstate_get_req *req)
217962306a36Sopenharmony_ci{
218062306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
218162306a36Sopenharmony_ci	struct ethtool_linkstate_get_rsp *rsp;
218262306a36Sopenharmony_ci	struct nlmsghdr *nlh;
218362306a36Sopenharmony_ci	int err;
218462306a36Sopenharmony_ci
218562306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKSTATE_GET, 1);
218662306a36Sopenharmony_ci	ys->req_policy = &ethtool_linkstate_nest;
218762306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_linkstate_nest;
218862306a36Sopenharmony_ci
218962306a36Sopenharmony_ci	if (req->_present.header)
219062306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_LINKSTATE_HEADER, &req->header);
219162306a36Sopenharmony_ci
219262306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
219362306a36Sopenharmony_ci	yrs.yarg.data = rsp;
219462306a36Sopenharmony_ci	yrs.cb = ethtool_linkstate_get_rsp_parse;
219562306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_LINKSTATE_GET;
219662306a36Sopenharmony_ci
219762306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
219862306a36Sopenharmony_ci	if (err < 0)
219962306a36Sopenharmony_ci		goto err_free;
220062306a36Sopenharmony_ci
220162306a36Sopenharmony_ci	return rsp;
220262306a36Sopenharmony_ci
220362306a36Sopenharmony_cierr_free:
220462306a36Sopenharmony_ci	ethtool_linkstate_get_rsp_free(rsp);
220562306a36Sopenharmony_ci	return NULL;
220662306a36Sopenharmony_ci}
220762306a36Sopenharmony_ci
220862306a36Sopenharmony_ci/* ETHTOOL_MSG_LINKSTATE_GET - dump */
220962306a36Sopenharmony_civoid ethtool_linkstate_get_list_free(struct ethtool_linkstate_get_list *rsp)
221062306a36Sopenharmony_ci{
221162306a36Sopenharmony_ci	struct ethtool_linkstate_get_list *next = rsp;
221262306a36Sopenharmony_ci
221362306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
221462306a36Sopenharmony_ci		rsp = next;
221562306a36Sopenharmony_ci		next = rsp->next;
221662306a36Sopenharmony_ci
221762306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
221862306a36Sopenharmony_ci		free(rsp);
221962306a36Sopenharmony_ci	}
222062306a36Sopenharmony_ci}
222162306a36Sopenharmony_ci
222262306a36Sopenharmony_cistruct ethtool_linkstate_get_list *
222362306a36Sopenharmony_ciethtool_linkstate_get_dump(struct ynl_sock *ys,
222462306a36Sopenharmony_ci			   struct ethtool_linkstate_get_req_dump *req)
222562306a36Sopenharmony_ci{
222662306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
222762306a36Sopenharmony_ci	struct nlmsghdr *nlh;
222862306a36Sopenharmony_ci	int err;
222962306a36Sopenharmony_ci
223062306a36Sopenharmony_ci	yds.ys = ys;
223162306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_linkstate_get_list);
223262306a36Sopenharmony_ci	yds.cb = ethtool_linkstate_get_rsp_parse;
223362306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_LINKSTATE_GET;
223462306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_linkstate_nest;
223562306a36Sopenharmony_ci
223662306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_LINKSTATE_GET, 1);
223762306a36Sopenharmony_ci	ys->req_policy = &ethtool_linkstate_nest;
223862306a36Sopenharmony_ci
223962306a36Sopenharmony_ci	if (req->_present.header)
224062306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_LINKSTATE_HEADER, &req->header);
224162306a36Sopenharmony_ci
224262306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
224362306a36Sopenharmony_ci	if (err < 0)
224462306a36Sopenharmony_ci		goto free_list;
224562306a36Sopenharmony_ci
224662306a36Sopenharmony_ci	return yds.first;
224762306a36Sopenharmony_ci
224862306a36Sopenharmony_cifree_list:
224962306a36Sopenharmony_ci	ethtool_linkstate_get_list_free(yds.first);
225062306a36Sopenharmony_ci	return NULL;
225162306a36Sopenharmony_ci}
225262306a36Sopenharmony_ci
225362306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_DEBUG_GET ============== */
225462306a36Sopenharmony_ci/* ETHTOOL_MSG_DEBUG_GET - do */
225562306a36Sopenharmony_civoid ethtool_debug_get_req_free(struct ethtool_debug_get_req *req)
225662306a36Sopenharmony_ci{
225762306a36Sopenharmony_ci	ethtool_header_free(&req->header);
225862306a36Sopenharmony_ci	free(req);
225962306a36Sopenharmony_ci}
226062306a36Sopenharmony_ci
226162306a36Sopenharmony_civoid ethtool_debug_get_rsp_free(struct ethtool_debug_get_rsp *rsp)
226262306a36Sopenharmony_ci{
226362306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
226462306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->msgmask);
226562306a36Sopenharmony_ci	free(rsp);
226662306a36Sopenharmony_ci}
226762306a36Sopenharmony_ci
226862306a36Sopenharmony_ciint ethtool_debug_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
226962306a36Sopenharmony_ci{
227062306a36Sopenharmony_ci	struct ethtool_debug_get_rsp *dst;
227162306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
227262306a36Sopenharmony_ci	const struct nlattr *attr;
227362306a36Sopenharmony_ci	struct ynl_parse_arg parg;
227462306a36Sopenharmony_ci
227562306a36Sopenharmony_ci	dst = yarg->data;
227662306a36Sopenharmony_ci	parg.ys = yarg->ys;
227762306a36Sopenharmony_ci
227862306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
227962306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
228062306a36Sopenharmony_ci
228162306a36Sopenharmony_ci		if (type == ETHTOOL_A_DEBUG_HEADER) {
228262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
228362306a36Sopenharmony_ci				return MNL_CB_ERROR;
228462306a36Sopenharmony_ci			dst->_present.header = 1;
228562306a36Sopenharmony_ci
228662306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
228762306a36Sopenharmony_ci			parg.data = &dst->header;
228862306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
228962306a36Sopenharmony_ci				return MNL_CB_ERROR;
229062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_DEBUG_MSGMASK) {
229162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
229262306a36Sopenharmony_ci				return MNL_CB_ERROR;
229362306a36Sopenharmony_ci			dst->_present.msgmask = 1;
229462306a36Sopenharmony_ci
229562306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
229662306a36Sopenharmony_ci			parg.data = &dst->msgmask;
229762306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
229862306a36Sopenharmony_ci				return MNL_CB_ERROR;
229962306a36Sopenharmony_ci		}
230062306a36Sopenharmony_ci	}
230162306a36Sopenharmony_ci
230262306a36Sopenharmony_ci	return MNL_CB_OK;
230362306a36Sopenharmony_ci}
230462306a36Sopenharmony_ci
230562306a36Sopenharmony_cistruct ethtool_debug_get_rsp *
230662306a36Sopenharmony_ciethtool_debug_get(struct ynl_sock *ys, struct ethtool_debug_get_req *req)
230762306a36Sopenharmony_ci{
230862306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
230962306a36Sopenharmony_ci	struct ethtool_debug_get_rsp *rsp;
231062306a36Sopenharmony_ci	struct nlmsghdr *nlh;
231162306a36Sopenharmony_ci	int err;
231262306a36Sopenharmony_ci
231362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_DEBUG_GET, 1);
231462306a36Sopenharmony_ci	ys->req_policy = &ethtool_debug_nest;
231562306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_debug_nest;
231662306a36Sopenharmony_ci
231762306a36Sopenharmony_ci	if (req->_present.header)
231862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_DEBUG_HEADER, &req->header);
231962306a36Sopenharmony_ci
232062306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
232162306a36Sopenharmony_ci	yrs.yarg.data = rsp;
232262306a36Sopenharmony_ci	yrs.cb = ethtool_debug_get_rsp_parse;
232362306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_DEBUG_GET;
232462306a36Sopenharmony_ci
232562306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
232662306a36Sopenharmony_ci	if (err < 0)
232762306a36Sopenharmony_ci		goto err_free;
232862306a36Sopenharmony_ci
232962306a36Sopenharmony_ci	return rsp;
233062306a36Sopenharmony_ci
233162306a36Sopenharmony_cierr_free:
233262306a36Sopenharmony_ci	ethtool_debug_get_rsp_free(rsp);
233362306a36Sopenharmony_ci	return NULL;
233462306a36Sopenharmony_ci}
233562306a36Sopenharmony_ci
233662306a36Sopenharmony_ci/* ETHTOOL_MSG_DEBUG_GET - dump */
233762306a36Sopenharmony_civoid ethtool_debug_get_list_free(struct ethtool_debug_get_list *rsp)
233862306a36Sopenharmony_ci{
233962306a36Sopenharmony_ci	struct ethtool_debug_get_list *next = rsp;
234062306a36Sopenharmony_ci
234162306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
234262306a36Sopenharmony_ci		rsp = next;
234362306a36Sopenharmony_ci		next = rsp->next;
234462306a36Sopenharmony_ci
234562306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
234662306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.msgmask);
234762306a36Sopenharmony_ci		free(rsp);
234862306a36Sopenharmony_ci	}
234962306a36Sopenharmony_ci}
235062306a36Sopenharmony_ci
235162306a36Sopenharmony_cistruct ethtool_debug_get_list *
235262306a36Sopenharmony_ciethtool_debug_get_dump(struct ynl_sock *ys,
235362306a36Sopenharmony_ci		       struct ethtool_debug_get_req_dump *req)
235462306a36Sopenharmony_ci{
235562306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
235662306a36Sopenharmony_ci	struct nlmsghdr *nlh;
235762306a36Sopenharmony_ci	int err;
235862306a36Sopenharmony_ci
235962306a36Sopenharmony_ci	yds.ys = ys;
236062306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_debug_get_list);
236162306a36Sopenharmony_ci	yds.cb = ethtool_debug_get_rsp_parse;
236262306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_DEBUG_GET;
236362306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_debug_nest;
236462306a36Sopenharmony_ci
236562306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_DEBUG_GET, 1);
236662306a36Sopenharmony_ci	ys->req_policy = &ethtool_debug_nest;
236762306a36Sopenharmony_ci
236862306a36Sopenharmony_ci	if (req->_present.header)
236962306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_DEBUG_HEADER, &req->header);
237062306a36Sopenharmony_ci
237162306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
237262306a36Sopenharmony_ci	if (err < 0)
237362306a36Sopenharmony_ci		goto free_list;
237462306a36Sopenharmony_ci
237562306a36Sopenharmony_ci	return yds.first;
237662306a36Sopenharmony_ci
237762306a36Sopenharmony_cifree_list:
237862306a36Sopenharmony_ci	ethtool_debug_get_list_free(yds.first);
237962306a36Sopenharmony_ci	return NULL;
238062306a36Sopenharmony_ci}
238162306a36Sopenharmony_ci
238262306a36Sopenharmony_ci/* ETHTOOL_MSG_DEBUG_GET - notify */
238362306a36Sopenharmony_civoid ethtool_debug_get_ntf_free(struct ethtool_debug_get_ntf *rsp)
238462306a36Sopenharmony_ci{
238562306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
238662306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.msgmask);
238762306a36Sopenharmony_ci	free(rsp);
238862306a36Sopenharmony_ci}
238962306a36Sopenharmony_ci
239062306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_DEBUG_SET ============== */
239162306a36Sopenharmony_ci/* ETHTOOL_MSG_DEBUG_SET - do */
239262306a36Sopenharmony_civoid ethtool_debug_set_req_free(struct ethtool_debug_set_req *req)
239362306a36Sopenharmony_ci{
239462306a36Sopenharmony_ci	ethtool_header_free(&req->header);
239562306a36Sopenharmony_ci	ethtool_bitset_free(&req->msgmask);
239662306a36Sopenharmony_ci	free(req);
239762306a36Sopenharmony_ci}
239862306a36Sopenharmony_ci
239962306a36Sopenharmony_ciint ethtool_debug_set(struct ynl_sock *ys, struct ethtool_debug_set_req *req)
240062306a36Sopenharmony_ci{
240162306a36Sopenharmony_ci	struct nlmsghdr *nlh;
240262306a36Sopenharmony_ci	int err;
240362306a36Sopenharmony_ci
240462306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_DEBUG_SET, 1);
240562306a36Sopenharmony_ci	ys->req_policy = &ethtool_debug_nest;
240662306a36Sopenharmony_ci
240762306a36Sopenharmony_ci	if (req->_present.header)
240862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_DEBUG_HEADER, &req->header);
240962306a36Sopenharmony_ci	if (req->_present.msgmask)
241062306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_DEBUG_MSGMASK, &req->msgmask);
241162306a36Sopenharmony_ci
241262306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
241362306a36Sopenharmony_ci	if (err < 0)
241462306a36Sopenharmony_ci		return -1;
241562306a36Sopenharmony_ci
241662306a36Sopenharmony_ci	return 0;
241762306a36Sopenharmony_ci}
241862306a36Sopenharmony_ci
241962306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_WOL_GET ============== */
242062306a36Sopenharmony_ci/* ETHTOOL_MSG_WOL_GET - do */
242162306a36Sopenharmony_civoid ethtool_wol_get_req_free(struct ethtool_wol_get_req *req)
242262306a36Sopenharmony_ci{
242362306a36Sopenharmony_ci	ethtool_header_free(&req->header);
242462306a36Sopenharmony_ci	free(req);
242562306a36Sopenharmony_ci}
242662306a36Sopenharmony_ci
242762306a36Sopenharmony_civoid ethtool_wol_get_rsp_free(struct ethtool_wol_get_rsp *rsp)
242862306a36Sopenharmony_ci{
242962306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
243062306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->modes);
243162306a36Sopenharmony_ci	free(rsp->sopass);
243262306a36Sopenharmony_ci	free(rsp);
243362306a36Sopenharmony_ci}
243462306a36Sopenharmony_ci
243562306a36Sopenharmony_ciint ethtool_wol_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
243662306a36Sopenharmony_ci{
243762306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
243862306a36Sopenharmony_ci	struct ethtool_wol_get_rsp *dst;
243962306a36Sopenharmony_ci	const struct nlattr *attr;
244062306a36Sopenharmony_ci	struct ynl_parse_arg parg;
244162306a36Sopenharmony_ci
244262306a36Sopenharmony_ci	dst = yarg->data;
244362306a36Sopenharmony_ci	parg.ys = yarg->ys;
244462306a36Sopenharmony_ci
244562306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
244662306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
244762306a36Sopenharmony_ci
244862306a36Sopenharmony_ci		if (type == ETHTOOL_A_WOL_HEADER) {
244962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
245062306a36Sopenharmony_ci				return MNL_CB_ERROR;
245162306a36Sopenharmony_ci			dst->_present.header = 1;
245262306a36Sopenharmony_ci
245362306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
245462306a36Sopenharmony_ci			parg.data = &dst->header;
245562306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
245662306a36Sopenharmony_ci				return MNL_CB_ERROR;
245762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_WOL_MODES) {
245862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
245962306a36Sopenharmony_ci				return MNL_CB_ERROR;
246062306a36Sopenharmony_ci			dst->_present.modes = 1;
246162306a36Sopenharmony_ci
246262306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
246362306a36Sopenharmony_ci			parg.data = &dst->modes;
246462306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
246562306a36Sopenharmony_ci				return MNL_CB_ERROR;
246662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_WOL_SOPASS) {
246762306a36Sopenharmony_ci			unsigned int len;
246862306a36Sopenharmony_ci
246962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
247062306a36Sopenharmony_ci				return MNL_CB_ERROR;
247162306a36Sopenharmony_ci
247262306a36Sopenharmony_ci			len = mnl_attr_get_payload_len(attr);
247362306a36Sopenharmony_ci			dst->_present.sopass_len = len;
247462306a36Sopenharmony_ci			dst->sopass = malloc(len);
247562306a36Sopenharmony_ci			memcpy(dst->sopass, mnl_attr_get_payload(attr), len);
247662306a36Sopenharmony_ci		}
247762306a36Sopenharmony_ci	}
247862306a36Sopenharmony_ci
247962306a36Sopenharmony_ci	return MNL_CB_OK;
248062306a36Sopenharmony_ci}
248162306a36Sopenharmony_ci
248262306a36Sopenharmony_cistruct ethtool_wol_get_rsp *
248362306a36Sopenharmony_ciethtool_wol_get(struct ynl_sock *ys, struct ethtool_wol_get_req *req)
248462306a36Sopenharmony_ci{
248562306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
248662306a36Sopenharmony_ci	struct ethtool_wol_get_rsp *rsp;
248762306a36Sopenharmony_ci	struct nlmsghdr *nlh;
248862306a36Sopenharmony_ci	int err;
248962306a36Sopenharmony_ci
249062306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_WOL_GET, 1);
249162306a36Sopenharmony_ci	ys->req_policy = &ethtool_wol_nest;
249262306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_wol_nest;
249362306a36Sopenharmony_ci
249462306a36Sopenharmony_ci	if (req->_present.header)
249562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_WOL_HEADER, &req->header);
249662306a36Sopenharmony_ci
249762306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
249862306a36Sopenharmony_ci	yrs.yarg.data = rsp;
249962306a36Sopenharmony_ci	yrs.cb = ethtool_wol_get_rsp_parse;
250062306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_WOL_GET;
250162306a36Sopenharmony_ci
250262306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
250362306a36Sopenharmony_ci	if (err < 0)
250462306a36Sopenharmony_ci		goto err_free;
250562306a36Sopenharmony_ci
250662306a36Sopenharmony_ci	return rsp;
250762306a36Sopenharmony_ci
250862306a36Sopenharmony_cierr_free:
250962306a36Sopenharmony_ci	ethtool_wol_get_rsp_free(rsp);
251062306a36Sopenharmony_ci	return NULL;
251162306a36Sopenharmony_ci}
251262306a36Sopenharmony_ci
251362306a36Sopenharmony_ci/* ETHTOOL_MSG_WOL_GET - dump */
251462306a36Sopenharmony_civoid ethtool_wol_get_list_free(struct ethtool_wol_get_list *rsp)
251562306a36Sopenharmony_ci{
251662306a36Sopenharmony_ci	struct ethtool_wol_get_list *next = rsp;
251762306a36Sopenharmony_ci
251862306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
251962306a36Sopenharmony_ci		rsp = next;
252062306a36Sopenharmony_ci		next = rsp->next;
252162306a36Sopenharmony_ci
252262306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
252362306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.modes);
252462306a36Sopenharmony_ci		free(rsp->obj.sopass);
252562306a36Sopenharmony_ci		free(rsp);
252662306a36Sopenharmony_ci	}
252762306a36Sopenharmony_ci}
252862306a36Sopenharmony_ci
252962306a36Sopenharmony_cistruct ethtool_wol_get_list *
253062306a36Sopenharmony_ciethtool_wol_get_dump(struct ynl_sock *ys, struct ethtool_wol_get_req_dump *req)
253162306a36Sopenharmony_ci{
253262306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
253362306a36Sopenharmony_ci	struct nlmsghdr *nlh;
253462306a36Sopenharmony_ci	int err;
253562306a36Sopenharmony_ci
253662306a36Sopenharmony_ci	yds.ys = ys;
253762306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_wol_get_list);
253862306a36Sopenharmony_ci	yds.cb = ethtool_wol_get_rsp_parse;
253962306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_WOL_GET;
254062306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_wol_nest;
254162306a36Sopenharmony_ci
254262306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_WOL_GET, 1);
254362306a36Sopenharmony_ci	ys->req_policy = &ethtool_wol_nest;
254462306a36Sopenharmony_ci
254562306a36Sopenharmony_ci	if (req->_present.header)
254662306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_WOL_HEADER, &req->header);
254762306a36Sopenharmony_ci
254862306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
254962306a36Sopenharmony_ci	if (err < 0)
255062306a36Sopenharmony_ci		goto free_list;
255162306a36Sopenharmony_ci
255262306a36Sopenharmony_ci	return yds.first;
255362306a36Sopenharmony_ci
255462306a36Sopenharmony_cifree_list:
255562306a36Sopenharmony_ci	ethtool_wol_get_list_free(yds.first);
255662306a36Sopenharmony_ci	return NULL;
255762306a36Sopenharmony_ci}
255862306a36Sopenharmony_ci
255962306a36Sopenharmony_ci/* ETHTOOL_MSG_WOL_GET - notify */
256062306a36Sopenharmony_civoid ethtool_wol_get_ntf_free(struct ethtool_wol_get_ntf *rsp)
256162306a36Sopenharmony_ci{
256262306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
256362306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.modes);
256462306a36Sopenharmony_ci	free(rsp->obj.sopass);
256562306a36Sopenharmony_ci	free(rsp);
256662306a36Sopenharmony_ci}
256762306a36Sopenharmony_ci
256862306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_WOL_SET ============== */
256962306a36Sopenharmony_ci/* ETHTOOL_MSG_WOL_SET - do */
257062306a36Sopenharmony_civoid ethtool_wol_set_req_free(struct ethtool_wol_set_req *req)
257162306a36Sopenharmony_ci{
257262306a36Sopenharmony_ci	ethtool_header_free(&req->header);
257362306a36Sopenharmony_ci	ethtool_bitset_free(&req->modes);
257462306a36Sopenharmony_ci	free(req->sopass);
257562306a36Sopenharmony_ci	free(req);
257662306a36Sopenharmony_ci}
257762306a36Sopenharmony_ci
257862306a36Sopenharmony_ciint ethtool_wol_set(struct ynl_sock *ys, struct ethtool_wol_set_req *req)
257962306a36Sopenharmony_ci{
258062306a36Sopenharmony_ci	struct nlmsghdr *nlh;
258162306a36Sopenharmony_ci	int err;
258262306a36Sopenharmony_ci
258362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_WOL_SET, 1);
258462306a36Sopenharmony_ci	ys->req_policy = &ethtool_wol_nest;
258562306a36Sopenharmony_ci
258662306a36Sopenharmony_ci	if (req->_present.header)
258762306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_WOL_HEADER, &req->header);
258862306a36Sopenharmony_ci	if (req->_present.modes)
258962306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_WOL_MODES, &req->modes);
259062306a36Sopenharmony_ci	if (req->_present.sopass_len)
259162306a36Sopenharmony_ci		mnl_attr_put(nlh, ETHTOOL_A_WOL_SOPASS, req->_present.sopass_len, req->sopass);
259262306a36Sopenharmony_ci
259362306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
259462306a36Sopenharmony_ci	if (err < 0)
259562306a36Sopenharmony_ci		return -1;
259662306a36Sopenharmony_ci
259762306a36Sopenharmony_ci	return 0;
259862306a36Sopenharmony_ci}
259962306a36Sopenharmony_ci
260062306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_FEATURES_GET ============== */
260162306a36Sopenharmony_ci/* ETHTOOL_MSG_FEATURES_GET - do */
260262306a36Sopenharmony_civoid ethtool_features_get_req_free(struct ethtool_features_get_req *req)
260362306a36Sopenharmony_ci{
260462306a36Sopenharmony_ci	ethtool_header_free(&req->header);
260562306a36Sopenharmony_ci	free(req);
260662306a36Sopenharmony_ci}
260762306a36Sopenharmony_ci
260862306a36Sopenharmony_civoid ethtool_features_get_rsp_free(struct ethtool_features_get_rsp *rsp)
260962306a36Sopenharmony_ci{
261062306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
261162306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->hw);
261262306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->wanted);
261362306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->active);
261462306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->nochange);
261562306a36Sopenharmony_ci	free(rsp);
261662306a36Sopenharmony_ci}
261762306a36Sopenharmony_ci
261862306a36Sopenharmony_ciint ethtool_features_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
261962306a36Sopenharmony_ci{
262062306a36Sopenharmony_ci	struct ethtool_features_get_rsp *dst;
262162306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
262262306a36Sopenharmony_ci	const struct nlattr *attr;
262362306a36Sopenharmony_ci	struct ynl_parse_arg parg;
262462306a36Sopenharmony_ci
262562306a36Sopenharmony_ci	dst = yarg->data;
262662306a36Sopenharmony_ci	parg.ys = yarg->ys;
262762306a36Sopenharmony_ci
262862306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
262962306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
263062306a36Sopenharmony_ci
263162306a36Sopenharmony_ci		if (type == ETHTOOL_A_FEATURES_HEADER) {
263262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
263362306a36Sopenharmony_ci				return MNL_CB_ERROR;
263462306a36Sopenharmony_ci			dst->_present.header = 1;
263562306a36Sopenharmony_ci
263662306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
263762306a36Sopenharmony_ci			parg.data = &dst->header;
263862306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
263962306a36Sopenharmony_ci				return MNL_CB_ERROR;
264062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEATURES_HW) {
264162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
264262306a36Sopenharmony_ci				return MNL_CB_ERROR;
264362306a36Sopenharmony_ci			dst->_present.hw = 1;
264462306a36Sopenharmony_ci
264562306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
264662306a36Sopenharmony_ci			parg.data = &dst->hw;
264762306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
264862306a36Sopenharmony_ci				return MNL_CB_ERROR;
264962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEATURES_WANTED) {
265062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
265162306a36Sopenharmony_ci				return MNL_CB_ERROR;
265262306a36Sopenharmony_ci			dst->_present.wanted = 1;
265362306a36Sopenharmony_ci
265462306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
265562306a36Sopenharmony_ci			parg.data = &dst->wanted;
265662306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
265762306a36Sopenharmony_ci				return MNL_CB_ERROR;
265862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEATURES_ACTIVE) {
265962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
266062306a36Sopenharmony_ci				return MNL_CB_ERROR;
266162306a36Sopenharmony_ci			dst->_present.active = 1;
266262306a36Sopenharmony_ci
266362306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
266462306a36Sopenharmony_ci			parg.data = &dst->active;
266562306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
266662306a36Sopenharmony_ci				return MNL_CB_ERROR;
266762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEATURES_NOCHANGE) {
266862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
266962306a36Sopenharmony_ci				return MNL_CB_ERROR;
267062306a36Sopenharmony_ci			dst->_present.nochange = 1;
267162306a36Sopenharmony_ci
267262306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
267362306a36Sopenharmony_ci			parg.data = &dst->nochange;
267462306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
267562306a36Sopenharmony_ci				return MNL_CB_ERROR;
267662306a36Sopenharmony_ci		}
267762306a36Sopenharmony_ci	}
267862306a36Sopenharmony_ci
267962306a36Sopenharmony_ci	return MNL_CB_OK;
268062306a36Sopenharmony_ci}
268162306a36Sopenharmony_ci
268262306a36Sopenharmony_cistruct ethtool_features_get_rsp *
268362306a36Sopenharmony_ciethtool_features_get(struct ynl_sock *ys, struct ethtool_features_get_req *req)
268462306a36Sopenharmony_ci{
268562306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
268662306a36Sopenharmony_ci	struct ethtool_features_get_rsp *rsp;
268762306a36Sopenharmony_ci	struct nlmsghdr *nlh;
268862306a36Sopenharmony_ci	int err;
268962306a36Sopenharmony_ci
269062306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_FEATURES_GET, 1);
269162306a36Sopenharmony_ci	ys->req_policy = &ethtool_features_nest;
269262306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_features_nest;
269362306a36Sopenharmony_ci
269462306a36Sopenharmony_ci	if (req->_present.header)
269562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_FEATURES_HEADER, &req->header);
269662306a36Sopenharmony_ci
269762306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
269862306a36Sopenharmony_ci	yrs.yarg.data = rsp;
269962306a36Sopenharmony_ci	yrs.cb = ethtool_features_get_rsp_parse;
270062306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_FEATURES_GET;
270162306a36Sopenharmony_ci
270262306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
270362306a36Sopenharmony_ci	if (err < 0)
270462306a36Sopenharmony_ci		goto err_free;
270562306a36Sopenharmony_ci
270662306a36Sopenharmony_ci	return rsp;
270762306a36Sopenharmony_ci
270862306a36Sopenharmony_cierr_free:
270962306a36Sopenharmony_ci	ethtool_features_get_rsp_free(rsp);
271062306a36Sopenharmony_ci	return NULL;
271162306a36Sopenharmony_ci}
271262306a36Sopenharmony_ci
271362306a36Sopenharmony_ci/* ETHTOOL_MSG_FEATURES_GET - dump */
271462306a36Sopenharmony_civoid ethtool_features_get_list_free(struct ethtool_features_get_list *rsp)
271562306a36Sopenharmony_ci{
271662306a36Sopenharmony_ci	struct ethtool_features_get_list *next = rsp;
271762306a36Sopenharmony_ci
271862306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
271962306a36Sopenharmony_ci		rsp = next;
272062306a36Sopenharmony_ci		next = rsp->next;
272162306a36Sopenharmony_ci
272262306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
272362306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.hw);
272462306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.wanted);
272562306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.active);
272662306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.nochange);
272762306a36Sopenharmony_ci		free(rsp);
272862306a36Sopenharmony_ci	}
272962306a36Sopenharmony_ci}
273062306a36Sopenharmony_ci
273162306a36Sopenharmony_cistruct ethtool_features_get_list *
273262306a36Sopenharmony_ciethtool_features_get_dump(struct ynl_sock *ys,
273362306a36Sopenharmony_ci			  struct ethtool_features_get_req_dump *req)
273462306a36Sopenharmony_ci{
273562306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
273662306a36Sopenharmony_ci	struct nlmsghdr *nlh;
273762306a36Sopenharmony_ci	int err;
273862306a36Sopenharmony_ci
273962306a36Sopenharmony_ci	yds.ys = ys;
274062306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_features_get_list);
274162306a36Sopenharmony_ci	yds.cb = ethtool_features_get_rsp_parse;
274262306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_FEATURES_GET;
274362306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_features_nest;
274462306a36Sopenharmony_ci
274562306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_FEATURES_GET, 1);
274662306a36Sopenharmony_ci	ys->req_policy = &ethtool_features_nest;
274762306a36Sopenharmony_ci
274862306a36Sopenharmony_ci	if (req->_present.header)
274962306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_FEATURES_HEADER, &req->header);
275062306a36Sopenharmony_ci
275162306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
275262306a36Sopenharmony_ci	if (err < 0)
275362306a36Sopenharmony_ci		goto free_list;
275462306a36Sopenharmony_ci
275562306a36Sopenharmony_ci	return yds.first;
275662306a36Sopenharmony_ci
275762306a36Sopenharmony_cifree_list:
275862306a36Sopenharmony_ci	ethtool_features_get_list_free(yds.first);
275962306a36Sopenharmony_ci	return NULL;
276062306a36Sopenharmony_ci}
276162306a36Sopenharmony_ci
276262306a36Sopenharmony_ci/* ETHTOOL_MSG_FEATURES_GET - notify */
276362306a36Sopenharmony_civoid ethtool_features_get_ntf_free(struct ethtool_features_get_ntf *rsp)
276462306a36Sopenharmony_ci{
276562306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
276662306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.hw);
276762306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.wanted);
276862306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.active);
276962306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.nochange);
277062306a36Sopenharmony_ci	free(rsp);
277162306a36Sopenharmony_ci}
277262306a36Sopenharmony_ci
277362306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_FEATURES_SET ============== */
277462306a36Sopenharmony_ci/* ETHTOOL_MSG_FEATURES_SET - do */
277562306a36Sopenharmony_civoid ethtool_features_set_req_free(struct ethtool_features_set_req *req)
277662306a36Sopenharmony_ci{
277762306a36Sopenharmony_ci	ethtool_header_free(&req->header);
277862306a36Sopenharmony_ci	ethtool_bitset_free(&req->hw);
277962306a36Sopenharmony_ci	ethtool_bitset_free(&req->wanted);
278062306a36Sopenharmony_ci	ethtool_bitset_free(&req->active);
278162306a36Sopenharmony_ci	ethtool_bitset_free(&req->nochange);
278262306a36Sopenharmony_ci	free(req);
278362306a36Sopenharmony_ci}
278462306a36Sopenharmony_ci
278562306a36Sopenharmony_civoid ethtool_features_set_rsp_free(struct ethtool_features_set_rsp *rsp)
278662306a36Sopenharmony_ci{
278762306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
278862306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->hw);
278962306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->wanted);
279062306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->active);
279162306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->nochange);
279262306a36Sopenharmony_ci	free(rsp);
279362306a36Sopenharmony_ci}
279462306a36Sopenharmony_ci
279562306a36Sopenharmony_ciint ethtool_features_set_rsp_parse(const struct nlmsghdr *nlh, void *data)
279662306a36Sopenharmony_ci{
279762306a36Sopenharmony_ci	struct ethtool_features_set_rsp *dst;
279862306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
279962306a36Sopenharmony_ci	const struct nlattr *attr;
280062306a36Sopenharmony_ci	struct ynl_parse_arg parg;
280162306a36Sopenharmony_ci
280262306a36Sopenharmony_ci	dst = yarg->data;
280362306a36Sopenharmony_ci	parg.ys = yarg->ys;
280462306a36Sopenharmony_ci
280562306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
280662306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
280762306a36Sopenharmony_ci
280862306a36Sopenharmony_ci		if (type == ETHTOOL_A_FEATURES_HEADER) {
280962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
281062306a36Sopenharmony_ci				return MNL_CB_ERROR;
281162306a36Sopenharmony_ci			dst->_present.header = 1;
281262306a36Sopenharmony_ci
281362306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
281462306a36Sopenharmony_ci			parg.data = &dst->header;
281562306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
281662306a36Sopenharmony_ci				return MNL_CB_ERROR;
281762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEATURES_HW) {
281862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
281962306a36Sopenharmony_ci				return MNL_CB_ERROR;
282062306a36Sopenharmony_ci			dst->_present.hw = 1;
282162306a36Sopenharmony_ci
282262306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
282362306a36Sopenharmony_ci			parg.data = &dst->hw;
282462306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
282562306a36Sopenharmony_ci				return MNL_CB_ERROR;
282662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEATURES_WANTED) {
282762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
282862306a36Sopenharmony_ci				return MNL_CB_ERROR;
282962306a36Sopenharmony_ci			dst->_present.wanted = 1;
283062306a36Sopenharmony_ci
283162306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
283262306a36Sopenharmony_ci			parg.data = &dst->wanted;
283362306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
283462306a36Sopenharmony_ci				return MNL_CB_ERROR;
283562306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEATURES_ACTIVE) {
283662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
283762306a36Sopenharmony_ci				return MNL_CB_ERROR;
283862306a36Sopenharmony_ci			dst->_present.active = 1;
283962306a36Sopenharmony_ci
284062306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
284162306a36Sopenharmony_ci			parg.data = &dst->active;
284262306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
284362306a36Sopenharmony_ci				return MNL_CB_ERROR;
284462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEATURES_NOCHANGE) {
284562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
284662306a36Sopenharmony_ci				return MNL_CB_ERROR;
284762306a36Sopenharmony_ci			dst->_present.nochange = 1;
284862306a36Sopenharmony_ci
284962306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
285062306a36Sopenharmony_ci			parg.data = &dst->nochange;
285162306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
285262306a36Sopenharmony_ci				return MNL_CB_ERROR;
285362306a36Sopenharmony_ci		}
285462306a36Sopenharmony_ci	}
285562306a36Sopenharmony_ci
285662306a36Sopenharmony_ci	return MNL_CB_OK;
285762306a36Sopenharmony_ci}
285862306a36Sopenharmony_ci
285962306a36Sopenharmony_cistruct ethtool_features_set_rsp *
286062306a36Sopenharmony_ciethtool_features_set(struct ynl_sock *ys, struct ethtool_features_set_req *req)
286162306a36Sopenharmony_ci{
286262306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
286362306a36Sopenharmony_ci	struct ethtool_features_set_rsp *rsp;
286462306a36Sopenharmony_ci	struct nlmsghdr *nlh;
286562306a36Sopenharmony_ci	int err;
286662306a36Sopenharmony_ci
286762306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_FEATURES_SET, 1);
286862306a36Sopenharmony_ci	ys->req_policy = &ethtool_features_nest;
286962306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_features_nest;
287062306a36Sopenharmony_ci
287162306a36Sopenharmony_ci	if (req->_present.header)
287262306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_FEATURES_HEADER, &req->header);
287362306a36Sopenharmony_ci	if (req->_present.hw)
287462306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_FEATURES_HW, &req->hw);
287562306a36Sopenharmony_ci	if (req->_present.wanted)
287662306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_FEATURES_WANTED, &req->wanted);
287762306a36Sopenharmony_ci	if (req->_present.active)
287862306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_FEATURES_ACTIVE, &req->active);
287962306a36Sopenharmony_ci	if (req->_present.nochange)
288062306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_FEATURES_NOCHANGE, &req->nochange);
288162306a36Sopenharmony_ci
288262306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
288362306a36Sopenharmony_ci	yrs.yarg.data = rsp;
288462306a36Sopenharmony_ci	yrs.cb = ethtool_features_set_rsp_parse;
288562306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_FEATURES_SET;
288662306a36Sopenharmony_ci
288762306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
288862306a36Sopenharmony_ci	if (err < 0)
288962306a36Sopenharmony_ci		goto err_free;
289062306a36Sopenharmony_ci
289162306a36Sopenharmony_ci	return rsp;
289262306a36Sopenharmony_ci
289362306a36Sopenharmony_cierr_free:
289462306a36Sopenharmony_ci	ethtool_features_set_rsp_free(rsp);
289562306a36Sopenharmony_ci	return NULL;
289662306a36Sopenharmony_ci}
289762306a36Sopenharmony_ci
289862306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PRIVFLAGS_GET ============== */
289962306a36Sopenharmony_ci/* ETHTOOL_MSG_PRIVFLAGS_GET - do */
290062306a36Sopenharmony_civoid ethtool_privflags_get_req_free(struct ethtool_privflags_get_req *req)
290162306a36Sopenharmony_ci{
290262306a36Sopenharmony_ci	ethtool_header_free(&req->header);
290362306a36Sopenharmony_ci	free(req);
290462306a36Sopenharmony_ci}
290562306a36Sopenharmony_ci
290662306a36Sopenharmony_civoid ethtool_privflags_get_rsp_free(struct ethtool_privflags_get_rsp *rsp)
290762306a36Sopenharmony_ci{
290862306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
290962306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->flags);
291062306a36Sopenharmony_ci	free(rsp);
291162306a36Sopenharmony_ci}
291262306a36Sopenharmony_ci
291362306a36Sopenharmony_ciint ethtool_privflags_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
291462306a36Sopenharmony_ci{
291562306a36Sopenharmony_ci	struct ethtool_privflags_get_rsp *dst;
291662306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
291762306a36Sopenharmony_ci	const struct nlattr *attr;
291862306a36Sopenharmony_ci	struct ynl_parse_arg parg;
291962306a36Sopenharmony_ci
292062306a36Sopenharmony_ci	dst = yarg->data;
292162306a36Sopenharmony_ci	parg.ys = yarg->ys;
292262306a36Sopenharmony_ci
292362306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
292462306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
292562306a36Sopenharmony_ci
292662306a36Sopenharmony_ci		if (type == ETHTOOL_A_PRIVFLAGS_HEADER) {
292762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
292862306a36Sopenharmony_ci				return MNL_CB_ERROR;
292962306a36Sopenharmony_ci			dst->_present.header = 1;
293062306a36Sopenharmony_ci
293162306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
293262306a36Sopenharmony_ci			parg.data = &dst->header;
293362306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
293462306a36Sopenharmony_ci				return MNL_CB_ERROR;
293562306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PRIVFLAGS_FLAGS) {
293662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
293762306a36Sopenharmony_ci				return MNL_CB_ERROR;
293862306a36Sopenharmony_ci			dst->_present.flags = 1;
293962306a36Sopenharmony_ci
294062306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
294162306a36Sopenharmony_ci			parg.data = &dst->flags;
294262306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
294362306a36Sopenharmony_ci				return MNL_CB_ERROR;
294462306a36Sopenharmony_ci		}
294562306a36Sopenharmony_ci	}
294662306a36Sopenharmony_ci
294762306a36Sopenharmony_ci	return MNL_CB_OK;
294862306a36Sopenharmony_ci}
294962306a36Sopenharmony_ci
295062306a36Sopenharmony_cistruct ethtool_privflags_get_rsp *
295162306a36Sopenharmony_ciethtool_privflags_get(struct ynl_sock *ys,
295262306a36Sopenharmony_ci		      struct ethtool_privflags_get_req *req)
295362306a36Sopenharmony_ci{
295462306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
295562306a36Sopenharmony_ci	struct ethtool_privflags_get_rsp *rsp;
295662306a36Sopenharmony_ci	struct nlmsghdr *nlh;
295762306a36Sopenharmony_ci	int err;
295862306a36Sopenharmony_ci
295962306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PRIVFLAGS_GET, 1);
296062306a36Sopenharmony_ci	ys->req_policy = &ethtool_privflags_nest;
296162306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_privflags_nest;
296262306a36Sopenharmony_ci
296362306a36Sopenharmony_ci	if (req->_present.header)
296462306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PRIVFLAGS_HEADER, &req->header);
296562306a36Sopenharmony_ci
296662306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
296762306a36Sopenharmony_ci	yrs.yarg.data = rsp;
296862306a36Sopenharmony_ci	yrs.cb = ethtool_privflags_get_rsp_parse;
296962306a36Sopenharmony_ci	yrs.rsp_cmd = 14;
297062306a36Sopenharmony_ci
297162306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
297262306a36Sopenharmony_ci	if (err < 0)
297362306a36Sopenharmony_ci		goto err_free;
297462306a36Sopenharmony_ci
297562306a36Sopenharmony_ci	return rsp;
297662306a36Sopenharmony_ci
297762306a36Sopenharmony_cierr_free:
297862306a36Sopenharmony_ci	ethtool_privflags_get_rsp_free(rsp);
297962306a36Sopenharmony_ci	return NULL;
298062306a36Sopenharmony_ci}
298162306a36Sopenharmony_ci
298262306a36Sopenharmony_ci/* ETHTOOL_MSG_PRIVFLAGS_GET - dump */
298362306a36Sopenharmony_civoid ethtool_privflags_get_list_free(struct ethtool_privflags_get_list *rsp)
298462306a36Sopenharmony_ci{
298562306a36Sopenharmony_ci	struct ethtool_privflags_get_list *next = rsp;
298662306a36Sopenharmony_ci
298762306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
298862306a36Sopenharmony_ci		rsp = next;
298962306a36Sopenharmony_ci		next = rsp->next;
299062306a36Sopenharmony_ci
299162306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
299262306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.flags);
299362306a36Sopenharmony_ci		free(rsp);
299462306a36Sopenharmony_ci	}
299562306a36Sopenharmony_ci}
299662306a36Sopenharmony_ci
299762306a36Sopenharmony_cistruct ethtool_privflags_get_list *
299862306a36Sopenharmony_ciethtool_privflags_get_dump(struct ynl_sock *ys,
299962306a36Sopenharmony_ci			   struct ethtool_privflags_get_req_dump *req)
300062306a36Sopenharmony_ci{
300162306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
300262306a36Sopenharmony_ci	struct nlmsghdr *nlh;
300362306a36Sopenharmony_ci	int err;
300462306a36Sopenharmony_ci
300562306a36Sopenharmony_ci	yds.ys = ys;
300662306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_privflags_get_list);
300762306a36Sopenharmony_ci	yds.cb = ethtool_privflags_get_rsp_parse;
300862306a36Sopenharmony_ci	yds.rsp_cmd = 14;
300962306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_privflags_nest;
301062306a36Sopenharmony_ci
301162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PRIVFLAGS_GET, 1);
301262306a36Sopenharmony_ci	ys->req_policy = &ethtool_privflags_nest;
301362306a36Sopenharmony_ci
301462306a36Sopenharmony_ci	if (req->_present.header)
301562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PRIVFLAGS_HEADER, &req->header);
301662306a36Sopenharmony_ci
301762306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
301862306a36Sopenharmony_ci	if (err < 0)
301962306a36Sopenharmony_ci		goto free_list;
302062306a36Sopenharmony_ci
302162306a36Sopenharmony_ci	return yds.first;
302262306a36Sopenharmony_ci
302362306a36Sopenharmony_cifree_list:
302462306a36Sopenharmony_ci	ethtool_privflags_get_list_free(yds.first);
302562306a36Sopenharmony_ci	return NULL;
302662306a36Sopenharmony_ci}
302762306a36Sopenharmony_ci
302862306a36Sopenharmony_ci/* ETHTOOL_MSG_PRIVFLAGS_GET - notify */
302962306a36Sopenharmony_civoid ethtool_privflags_get_ntf_free(struct ethtool_privflags_get_ntf *rsp)
303062306a36Sopenharmony_ci{
303162306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
303262306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.flags);
303362306a36Sopenharmony_ci	free(rsp);
303462306a36Sopenharmony_ci}
303562306a36Sopenharmony_ci
303662306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PRIVFLAGS_SET ============== */
303762306a36Sopenharmony_ci/* ETHTOOL_MSG_PRIVFLAGS_SET - do */
303862306a36Sopenharmony_civoid ethtool_privflags_set_req_free(struct ethtool_privflags_set_req *req)
303962306a36Sopenharmony_ci{
304062306a36Sopenharmony_ci	ethtool_header_free(&req->header);
304162306a36Sopenharmony_ci	ethtool_bitset_free(&req->flags);
304262306a36Sopenharmony_ci	free(req);
304362306a36Sopenharmony_ci}
304462306a36Sopenharmony_ci
304562306a36Sopenharmony_ciint ethtool_privflags_set(struct ynl_sock *ys,
304662306a36Sopenharmony_ci			  struct ethtool_privflags_set_req *req)
304762306a36Sopenharmony_ci{
304862306a36Sopenharmony_ci	struct nlmsghdr *nlh;
304962306a36Sopenharmony_ci	int err;
305062306a36Sopenharmony_ci
305162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PRIVFLAGS_SET, 1);
305262306a36Sopenharmony_ci	ys->req_policy = &ethtool_privflags_nest;
305362306a36Sopenharmony_ci
305462306a36Sopenharmony_ci	if (req->_present.header)
305562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PRIVFLAGS_HEADER, &req->header);
305662306a36Sopenharmony_ci	if (req->_present.flags)
305762306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_PRIVFLAGS_FLAGS, &req->flags);
305862306a36Sopenharmony_ci
305962306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
306062306a36Sopenharmony_ci	if (err < 0)
306162306a36Sopenharmony_ci		return -1;
306262306a36Sopenharmony_ci
306362306a36Sopenharmony_ci	return 0;
306462306a36Sopenharmony_ci}
306562306a36Sopenharmony_ci
306662306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_RINGS_GET ============== */
306762306a36Sopenharmony_ci/* ETHTOOL_MSG_RINGS_GET - do */
306862306a36Sopenharmony_civoid ethtool_rings_get_req_free(struct ethtool_rings_get_req *req)
306962306a36Sopenharmony_ci{
307062306a36Sopenharmony_ci	ethtool_header_free(&req->header);
307162306a36Sopenharmony_ci	free(req);
307262306a36Sopenharmony_ci}
307362306a36Sopenharmony_ci
307462306a36Sopenharmony_civoid ethtool_rings_get_rsp_free(struct ethtool_rings_get_rsp *rsp)
307562306a36Sopenharmony_ci{
307662306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
307762306a36Sopenharmony_ci	free(rsp);
307862306a36Sopenharmony_ci}
307962306a36Sopenharmony_ci
308062306a36Sopenharmony_ciint ethtool_rings_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
308162306a36Sopenharmony_ci{
308262306a36Sopenharmony_ci	struct ethtool_rings_get_rsp *dst;
308362306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
308462306a36Sopenharmony_ci	const struct nlattr *attr;
308562306a36Sopenharmony_ci	struct ynl_parse_arg parg;
308662306a36Sopenharmony_ci
308762306a36Sopenharmony_ci	dst = yarg->data;
308862306a36Sopenharmony_ci	parg.ys = yarg->ys;
308962306a36Sopenharmony_ci
309062306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
309162306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
309262306a36Sopenharmony_ci
309362306a36Sopenharmony_ci		if (type == ETHTOOL_A_RINGS_HEADER) {
309462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
309562306a36Sopenharmony_ci				return MNL_CB_ERROR;
309662306a36Sopenharmony_ci			dst->_present.header = 1;
309762306a36Sopenharmony_ci
309862306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
309962306a36Sopenharmony_ci			parg.data = &dst->header;
310062306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
310162306a36Sopenharmony_ci				return MNL_CB_ERROR;
310262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_RX_MAX) {
310362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
310462306a36Sopenharmony_ci				return MNL_CB_ERROR;
310562306a36Sopenharmony_ci			dst->_present.rx_max = 1;
310662306a36Sopenharmony_ci			dst->rx_max = mnl_attr_get_u32(attr);
310762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_RX_MINI_MAX) {
310862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
310962306a36Sopenharmony_ci				return MNL_CB_ERROR;
311062306a36Sopenharmony_ci			dst->_present.rx_mini_max = 1;
311162306a36Sopenharmony_ci			dst->rx_mini_max = mnl_attr_get_u32(attr);
311262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_RX_JUMBO_MAX) {
311362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
311462306a36Sopenharmony_ci				return MNL_CB_ERROR;
311562306a36Sopenharmony_ci			dst->_present.rx_jumbo_max = 1;
311662306a36Sopenharmony_ci			dst->rx_jumbo_max = mnl_attr_get_u32(attr);
311762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_TX_MAX) {
311862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
311962306a36Sopenharmony_ci				return MNL_CB_ERROR;
312062306a36Sopenharmony_ci			dst->_present.tx_max = 1;
312162306a36Sopenharmony_ci			dst->tx_max = mnl_attr_get_u32(attr);
312262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_RX) {
312362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
312462306a36Sopenharmony_ci				return MNL_CB_ERROR;
312562306a36Sopenharmony_ci			dst->_present.rx = 1;
312662306a36Sopenharmony_ci			dst->rx = mnl_attr_get_u32(attr);
312762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_RX_MINI) {
312862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
312962306a36Sopenharmony_ci				return MNL_CB_ERROR;
313062306a36Sopenharmony_ci			dst->_present.rx_mini = 1;
313162306a36Sopenharmony_ci			dst->rx_mini = mnl_attr_get_u32(attr);
313262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_RX_JUMBO) {
313362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
313462306a36Sopenharmony_ci				return MNL_CB_ERROR;
313562306a36Sopenharmony_ci			dst->_present.rx_jumbo = 1;
313662306a36Sopenharmony_ci			dst->rx_jumbo = mnl_attr_get_u32(attr);
313762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_TX) {
313862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
313962306a36Sopenharmony_ci				return MNL_CB_ERROR;
314062306a36Sopenharmony_ci			dst->_present.tx = 1;
314162306a36Sopenharmony_ci			dst->tx = mnl_attr_get_u32(attr);
314262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_RX_BUF_LEN) {
314362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
314462306a36Sopenharmony_ci				return MNL_CB_ERROR;
314562306a36Sopenharmony_ci			dst->_present.rx_buf_len = 1;
314662306a36Sopenharmony_ci			dst->rx_buf_len = mnl_attr_get_u32(attr);
314762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_TCP_DATA_SPLIT) {
314862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
314962306a36Sopenharmony_ci				return MNL_CB_ERROR;
315062306a36Sopenharmony_ci			dst->_present.tcp_data_split = 1;
315162306a36Sopenharmony_ci			dst->tcp_data_split = mnl_attr_get_u8(attr);
315262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_CQE_SIZE) {
315362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
315462306a36Sopenharmony_ci				return MNL_CB_ERROR;
315562306a36Sopenharmony_ci			dst->_present.cqe_size = 1;
315662306a36Sopenharmony_ci			dst->cqe_size = mnl_attr_get_u32(attr);
315762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_TX_PUSH) {
315862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
315962306a36Sopenharmony_ci				return MNL_CB_ERROR;
316062306a36Sopenharmony_ci			dst->_present.tx_push = 1;
316162306a36Sopenharmony_ci			dst->tx_push = mnl_attr_get_u8(attr);
316262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_RX_PUSH) {
316362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
316462306a36Sopenharmony_ci				return MNL_CB_ERROR;
316562306a36Sopenharmony_ci			dst->_present.rx_push = 1;
316662306a36Sopenharmony_ci			dst->rx_push = mnl_attr_get_u8(attr);
316762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN) {
316862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
316962306a36Sopenharmony_ci				return MNL_CB_ERROR;
317062306a36Sopenharmony_ci			dst->_present.tx_push_buf_len = 1;
317162306a36Sopenharmony_ci			dst->tx_push_buf_len = mnl_attr_get_u32(attr);
317262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX) {
317362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
317462306a36Sopenharmony_ci				return MNL_CB_ERROR;
317562306a36Sopenharmony_ci			dst->_present.tx_push_buf_len_max = 1;
317662306a36Sopenharmony_ci			dst->tx_push_buf_len_max = mnl_attr_get_u32(attr);
317762306a36Sopenharmony_ci		}
317862306a36Sopenharmony_ci	}
317962306a36Sopenharmony_ci
318062306a36Sopenharmony_ci	return MNL_CB_OK;
318162306a36Sopenharmony_ci}
318262306a36Sopenharmony_ci
318362306a36Sopenharmony_cistruct ethtool_rings_get_rsp *
318462306a36Sopenharmony_ciethtool_rings_get(struct ynl_sock *ys, struct ethtool_rings_get_req *req)
318562306a36Sopenharmony_ci{
318662306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
318762306a36Sopenharmony_ci	struct ethtool_rings_get_rsp *rsp;
318862306a36Sopenharmony_ci	struct nlmsghdr *nlh;
318962306a36Sopenharmony_ci	int err;
319062306a36Sopenharmony_ci
319162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_RINGS_GET, 1);
319262306a36Sopenharmony_ci	ys->req_policy = &ethtool_rings_nest;
319362306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_rings_nest;
319462306a36Sopenharmony_ci
319562306a36Sopenharmony_ci	if (req->_present.header)
319662306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_RINGS_HEADER, &req->header);
319762306a36Sopenharmony_ci
319862306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
319962306a36Sopenharmony_ci	yrs.yarg.data = rsp;
320062306a36Sopenharmony_ci	yrs.cb = ethtool_rings_get_rsp_parse;
320162306a36Sopenharmony_ci	yrs.rsp_cmd = 16;
320262306a36Sopenharmony_ci
320362306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
320462306a36Sopenharmony_ci	if (err < 0)
320562306a36Sopenharmony_ci		goto err_free;
320662306a36Sopenharmony_ci
320762306a36Sopenharmony_ci	return rsp;
320862306a36Sopenharmony_ci
320962306a36Sopenharmony_cierr_free:
321062306a36Sopenharmony_ci	ethtool_rings_get_rsp_free(rsp);
321162306a36Sopenharmony_ci	return NULL;
321262306a36Sopenharmony_ci}
321362306a36Sopenharmony_ci
321462306a36Sopenharmony_ci/* ETHTOOL_MSG_RINGS_GET - dump */
321562306a36Sopenharmony_civoid ethtool_rings_get_list_free(struct ethtool_rings_get_list *rsp)
321662306a36Sopenharmony_ci{
321762306a36Sopenharmony_ci	struct ethtool_rings_get_list *next = rsp;
321862306a36Sopenharmony_ci
321962306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
322062306a36Sopenharmony_ci		rsp = next;
322162306a36Sopenharmony_ci		next = rsp->next;
322262306a36Sopenharmony_ci
322362306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
322462306a36Sopenharmony_ci		free(rsp);
322562306a36Sopenharmony_ci	}
322662306a36Sopenharmony_ci}
322762306a36Sopenharmony_ci
322862306a36Sopenharmony_cistruct ethtool_rings_get_list *
322962306a36Sopenharmony_ciethtool_rings_get_dump(struct ynl_sock *ys,
323062306a36Sopenharmony_ci		       struct ethtool_rings_get_req_dump *req)
323162306a36Sopenharmony_ci{
323262306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
323362306a36Sopenharmony_ci	struct nlmsghdr *nlh;
323462306a36Sopenharmony_ci	int err;
323562306a36Sopenharmony_ci
323662306a36Sopenharmony_ci	yds.ys = ys;
323762306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_rings_get_list);
323862306a36Sopenharmony_ci	yds.cb = ethtool_rings_get_rsp_parse;
323962306a36Sopenharmony_ci	yds.rsp_cmd = 16;
324062306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_rings_nest;
324162306a36Sopenharmony_ci
324262306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_RINGS_GET, 1);
324362306a36Sopenharmony_ci	ys->req_policy = &ethtool_rings_nest;
324462306a36Sopenharmony_ci
324562306a36Sopenharmony_ci	if (req->_present.header)
324662306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_RINGS_HEADER, &req->header);
324762306a36Sopenharmony_ci
324862306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
324962306a36Sopenharmony_ci	if (err < 0)
325062306a36Sopenharmony_ci		goto free_list;
325162306a36Sopenharmony_ci
325262306a36Sopenharmony_ci	return yds.first;
325362306a36Sopenharmony_ci
325462306a36Sopenharmony_cifree_list:
325562306a36Sopenharmony_ci	ethtool_rings_get_list_free(yds.first);
325662306a36Sopenharmony_ci	return NULL;
325762306a36Sopenharmony_ci}
325862306a36Sopenharmony_ci
325962306a36Sopenharmony_ci/* ETHTOOL_MSG_RINGS_GET - notify */
326062306a36Sopenharmony_civoid ethtool_rings_get_ntf_free(struct ethtool_rings_get_ntf *rsp)
326162306a36Sopenharmony_ci{
326262306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
326362306a36Sopenharmony_ci	free(rsp);
326462306a36Sopenharmony_ci}
326562306a36Sopenharmony_ci
326662306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_RINGS_SET ============== */
326762306a36Sopenharmony_ci/* ETHTOOL_MSG_RINGS_SET - do */
326862306a36Sopenharmony_civoid ethtool_rings_set_req_free(struct ethtool_rings_set_req *req)
326962306a36Sopenharmony_ci{
327062306a36Sopenharmony_ci	ethtool_header_free(&req->header);
327162306a36Sopenharmony_ci	free(req);
327262306a36Sopenharmony_ci}
327362306a36Sopenharmony_ci
327462306a36Sopenharmony_ciint ethtool_rings_set(struct ynl_sock *ys, struct ethtool_rings_set_req *req)
327562306a36Sopenharmony_ci{
327662306a36Sopenharmony_ci	struct nlmsghdr *nlh;
327762306a36Sopenharmony_ci	int err;
327862306a36Sopenharmony_ci
327962306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_RINGS_SET, 1);
328062306a36Sopenharmony_ci	ys->req_policy = &ethtool_rings_nest;
328162306a36Sopenharmony_ci
328262306a36Sopenharmony_ci	if (req->_present.header)
328362306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_RINGS_HEADER, &req->header);
328462306a36Sopenharmony_ci	if (req->_present.rx_max)
328562306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_MAX, req->rx_max);
328662306a36Sopenharmony_ci	if (req->_present.rx_mini_max)
328762306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_MINI_MAX, req->rx_mini_max);
328862306a36Sopenharmony_ci	if (req->_present.rx_jumbo_max)
328962306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_JUMBO_MAX, req->rx_jumbo_max);
329062306a36Sopenharmony_ci	if (req->_present.tx_max)
329162306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX_MAX, req->tx_max);
329262306a36Sopenharmony_ci	if (req->_present.rx)
329362306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX, req->rx);
329462306a36Sopenharmony_ci	if (req->_present.rx_mini)
329562306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_MINI, req->rx_mini);
329662306a36Sopenharmony_ci	if (req->_present.rx_jumbo)
329762306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_JUMBO, req->rx_jumbo);
329862306a36Sopenharmony_ci	if (req->_present.tx)
329962306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX, req->tx);
330062306a36Sopenharmony_ci	if (req->_present.rx_buf_len)
330162306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_BUF_LEN, req->rx_buf_len);
330262306a36Sopenharmony_ci	if (req->_present.tcp_data_split)
330362306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_RINGS_TCP_DATA_SPLIT, req->tcp_data_split);
330462306a36Sopenharmony_ci	if (req->_present.cqe_size)
330562306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_CQE_SIZE, req->cqe_size);
330662306a36Sopenharmony_ci	if (req->_present.tx_push)
330762306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_RINGS_TX_PUSH, req->tx_push);
330862306a36Sopenharmony_ci	if (req->_present.rx_push)
330962306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_RINGS_RX_PUSH, req->rx_push);
331062306a36Sopenharmony_ci	if (req->_present.tx_push_buf_len)
331162306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN, req->tx_push_buf_len);
331262306a36Sopenharmony_ci	if (req->_present.tx_push_buf_len_max)
331362306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX, req->tx_push_buf_len_max);
331462306a36Sopenharmony_ci
331562306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
331662306a36Sopenharmony_ci	if (err < 0)
331762306a36Sopenharmony_ci		return -1;
331862306a36Sopenharmony_ci
331962306a36Sopenharmony_ci	return 0;
332062306a36Sopenharmony_ci}
332162306a36Sopenharmony_ci
332262306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_CHANNELS_GET ============== */
332362306a36Sopenharmony_ci/* ETHTOOL_MSG_CHANNELS_GET - do */
332462306a36Sopenharmony_civoid ethtool_channels_get_req_free(struct ethtool_channels_get_req *req)
332562306a36Sopenharmony_ci{
332662306a36Sopenharmony_ci	ethtool_header_free(&req->header);
332762306a36Sopenharmony_ci	free(req);
332862306a36Sopenharmony_ci}
332962306a36Sopenharmony_ci
333062306a36Sopenharmony_civoid ethtool_channels_get_rsp_free(struct ethtool_channels_get_rsp *rsp)
333162306a36Sopenharmony_ci{
333262306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
333362306a36Sopenharmony_ci	free(rsp);
333462306a36Sopenharmony_ci}
333562306a36Sopenharmony_ci
333662306a36Sopenharmony_ciint ethtool_channels_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
333762306a36Sopenharmony_ci{
333862306a36Sopenharmony_ci	struct ethtool_channels_get_rsp *dst;
333962306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
334062306a36Sopenharmony_ci	const struct nlattr *attr;
334162306a36Sopenharmony_ci	struct ynl_parse_arg parg;
334262306a36Sopenharmony_ci
334362306a36Sopenharmony_ci	dst = yarg->data;
334462306a36Sopenharmony_ci	parg.ys = yarg->ys;
334562306a36Sopenharmony_ci
334662306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
334762306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
334862306a36Sopenharmony_ci
334962306a36Sopenharmony_ci		if (type == ETHTOOL_A_CHANNELS_HEADER) {
335062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
335162306a36Sopenharmony_ci				return MNL_CB_ERROR;
335262306a36Sopenharmony_ci			dst->_present.header = 1;
335362306a36Sopenharmony_ci
335462306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
335562306a36Sopenharmony_ci			parg.data = &dst->header;
335662306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
335762306a36Sopenharmony_ci				return MNL_CB_ERROR;
335862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CHANNELS_RX_MAX) {
335962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
336062306a36Sopenharmony_ci				return MNL_CB_ERROR;
336162306a36Sopenharmony_ci			dst->_present.rx_max = 1;
336262306a36Sopenharmony_ci			dst->rx_max = mnl_attr_get_u32(attr);
336362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CHANNELS_TX_MAX) {
336462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
336562306a36Sopenharmony_ci				return MNL_CB_ERROR;
336662306a36Sopenharmony_ci			dst->_present.tx_max = 1;
336762306a36Sopenharmony_ci			dst->tx_max = mnl_attr_get_u32(attr);
336862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CHANNELS_OTHER_MAX) {
336962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
337062306a36Sopenharmony_ci				return MNL_CB_ERROR;
337162306a36Sopenharmony_ci			dst->_present.other_max = 1;
337262306a36Sopenharmony_ci			dst->other_max = mnl_attr_get_u32(attr);
337362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CHANNELS_COMBINED_MAX) {
337462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
337562306a36Sopenharmony_ci				return MNL_CB_ERROR;
337662306a36Sopenharmony_ci			dst->_present.combined_max = 1;
337762306a36Sopenharmony_ci			dst->combined_max = mnl_attr_get_u32(attr);
337862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CHANNELS_RX_COUNT) {
337962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
338062306a36Sopenharmony_ci				return MNL_CB_ERROR;
338162306a36Sopenharmony_ci			dst->_present.rx_count = 1;
338262306a36Sopenharmony_ci			dst->rx_count = mnl_attr_get_u32(attr);
338362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CHANNELS_TX_COUNT) {
338462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
338562306a36Sopenharmony_ci				return MNL_CB_ERROR;
338662306a36Sopenharmony_ci			dst->_present.tx_count = 1;
338762306a36Sopenharmony_ci			dst->tx_count = mnl_attr_get_u32(attr);
338862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CHANNELS_OTHER_COUNT) {
338962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
339062306a36Sopenharmony_ci				return MNL_CB_ERROR;
339162306a36Sopenharmony_ci			dst->_present.other_count = 1;
339262306a36Sopenharmony_ci			dst->other_count = mnl_attr_get_u32(attr);
339362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CHANNELS_COMBINED_COUNT) {
339462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
339562306a36Sopenharmony_ci				return MNL_CB_ERROR;
339662306a36Sopenharmony_ci			dst->_present.combined_count = 1;
339762306a36Sopenharmony_ci			dst->combined_count = mnl_attr_get_u32(attr);
339862306a36Sopenharmony_ci		}
339962306a36Sopenharmony_ci	}
340062306a36Sopenharmony_ci
340162306a36Sopenharmony_ci	return MNL_CB_OK;
340262306a36Sopenharmony_ci}
340362306a36Sopenharmony_ci
340462306a36Sopenharmony_cistruct ethtool_channels_get_rsp *
340562306a36Sopenharmony_ciethtool_channels_get(struct ynl_sock *ys, struct ethtool_channels_get_req *req)
340662306a36Sopenharmony_ci{
340762306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
340862306a36Sopenharmony_ci	struct ethtool_channels_get_rsp *rsp;
340962306a36Sopenharmony_ci	struct nlmsghdr *nlh;
341062306a36Sopenharmony_ci	int err;
341162306a36Sopenharmony_ci
341262306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_CHANNELS_GET, 1);
341362306a36Sopenharmony_ci	ys->req_policy = &ethtool_channels_nest;
341462306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_channels_nest;
341562306a36Sopenharmony_ci
341662306a36Sopenharmony_ci	if (req->_present.header)
341762306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_CHANNELS_HEADER, &req->header);
341862306a36Sopenharmony_ci
341962306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
342062306a36Sopenharmony_ci	yrs.yarg.data = rsp;
342162306a36Sopenharmony_ci	yrs.cb = ethtool_channels_get_rsp_parse;
342262306a36Sopenharmony_ci	yrs.rsp_cmd = 18;
342362306a36Sopenharmony_ci
342462306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
342562306a36Sopenharmony_ci	if (err < 0)
342662306a36Sopenharmony_ci		goto err_free;
342762306a36Sopenharmony_ci
342862306a36Sopenharmony_ci	return rsp;
342962306a36Sopenharmony_ci
343062306a36Sopenharmony_cierr_free:
343162306a36Sopenharmony_ci	ethtool_channels_get_rsp_free(rsp);
343262306a36Sopenharmony_ci	return NULL;
343362306a36Sopenharmony_ci}
343462306a36Sopenharmony_ci
343562306a36Sopenharmony_ci/* ETHTOOL_MSG_CHANNELS_GET - dump */
343662306a36Sopenharmony_civoid ethtool_channels_get_list_free(struct ethtool_channels_get_list *rsp)
343762306a36Sopenharmony_ci{
343862306a36Sopenharmony_ci	struct ethtool_channels_get_list *next = rsp;
343962306a36Sopenharmony_ci
344062306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
344162306a36Sopenharmony_ci		rsp = next;
344262306a36Sopenharmony_ci		next = rsp->next;
344362306a36Sopenharmony_ci
344462306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
344562306a36Sopenharmony_ci		free(rsp);
344662306a36Sopenharmony_ci	}
344762306a36Sopenharmony_ci}
344862306a36Sopenharmony_ci
344962306a36Sopenharmony_cistruct ethtool_channels_get_list *
345062306a36Sopenharmony_ciethtool_channels_get_dump(struct ynl_sock *ys,
345162306a36Sopenharmony_ci			  struct ethtool_channels_get_req_dump *req)
345262306a36Sopenharmony_ci{
345362306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
345462306a36Sopenharmony_ci	struct nlmsghdr *nlh;
345562306a36Sopenharmony_ci	int err;
345662306a36Sopenharmony_ci
345762306a36Sopenharmony_ci	yds.ys = ys;
345862306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_channels_get_list);
345962306a36Sopenharmony_ci	yds.cb = ethtool_channels_get_rsp_parse;
346062306a36Sopenharmony_ci	yds.rsp_cmd = 18;
346162306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_channels_nest;
346262306a36Sopenharmony_ci
346362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_CHANNELS_GET, 1);
346462306a36Sopenharmony_ci	ys->req_policy = &ethtool_channels_nest;
346562306a36Sopenharmony_ci
346662306a36Sopenharmony_ci	if (req->_present.header)
346762306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_CHANNELS_HEADER, &req->header);
346862306a36Sopenharmony_ci
346962306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
347062306a36Sopenharmony_ci	if (err < 0)
347162306a36Sopenharmony_ci		goto free_list;
347262306a36Sopenharmony_ci
347362306a36Sopenharmony_ci	return yds.first;
347462306a36Sopenharmony_ci
347562306a36Sopenharmony_cifree_list:
347662306a36Sopenharmony_ci	ethtool_channels_get_list_free(yds.first);
347762306a36Sopenharmony_ci	return NULL;
347862306a36Sopenharmony_ci}
347962306a36Sopenharmony_ci
348062306a36Sopenharmony_ci/* ETHTOOL_MSG_CHANNELS_GET - notify */
348162306a36Sopenharmony_civoid ethtool_channels_get_ntf_free(struct ethtool_channels_get_ntf *rsp)
348262306a36Sopenharmony_ci{
348362306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
348462306a36Sopenharmony_ci	free(rsp);
348562306a36Sopenharmony_ci}
348662306a36Sopenharmony_ci
348762306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_CHANNELS_SET ============== */
348862306a36Sopenharmony_ci/* ETHTOOL_MSG_CHANNELS_SET - do */
348962306a36Sopenharmony_civoid ethtool_channels_set_req_free(struct ethtool_channels_set_req *req)
349062306a36Sopenharmony_ci{
349162306a36Sopenharmony_ci	ethtool_header_free(&req->header);
349262306a36Sopenharmony_ci	free(req);
349362306a36Sopenharmony_ci}
349462306a36Sopenharmony_ci
349562306a36Sopenharmony_ciint ethtool_channels_set(struct ynl_sock *ys,
349662306a36Sopenharmony_ci			 struct ethtool_channels_set_req *req)
349762306a36Sopenharmony_ci{
349862306a36Sopenharmony_ci	struct nlmsghdr *nlh;
349962306a36Sopenharmony_ci	int err;
350062306a36Sopenharmony_ci
350162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_CHANNELS_SET, 1);
350262306a36Sopenharmony_ci	ys->req_policy = &ethtool_channels_nest;
350362306a36Sopenharmony_ci
350462306a36Sopenharmony_ci	if (req->_present.header)
350562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_CHANNELS_HEADER, &req->header);
350662306a36Sopenharmony_ci	if (req->_present.rx_max)
350762306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_RX_MAX, req->rx_max);
350862306a36Sopenharmony_ci	if (req->_present.tx_max)
350962306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_TX_MAX, req->tx_max);
351062306a36Sopenharmony_ci	if (req->_present.other_max)
351162306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_OTHER_MAX, req->other_max);
351262306a36Sopenharmony_ci	if (req->_present.combined_max)
351362306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_COMBINED_MAX, req->combined_max);
351462306a36Sopenharmony_ci	if (req->_present.rx_count)
351562306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_RX_COUNT, req->rx_count);
351662306a36Sopenharmony_ci	if (req->_present.tx_count)
351762306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_TX_COUNT, req->tx_count);
351862306a36Sopenharmony_ci	if (req->_present.other_count)
351962306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_OTHER_COUNT, req->other_count);
352062306a36Sopenharmony_ci	if (req->_present.combined_count)
352162306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_COMBINED_COUNT, req->combined_count);
352262306a36Sopenharmony_ci
352362306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
352462306a36Sopenharmony_ci	if (err < 0)
352562306a36Sopenharmony_ci		return -1;
352662306a36Sopenharmony_ci
352762306a36Sopenharmony_ci	return 0;
352862306a36Sopenharmony_ci}
352962306a36Sopenharmony_ci
353062306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_COALESCE_GET ============== */
353162306a36Sopenharmony_ci/* ETHTOOL_MSG_COALESCE_GET - do */
353262306a36Sopenharmony_civoid ethtool_coalesce_get_req_free(struct ethtool_coalesce_get_req *req)
353362306a36Sopenharmony_ci{
353462306a36Sopenharmony_ci	ethtool_header_free(&req->header);
353562306a36Sopenharmony_ci	free(req);
353662306a36Sopenharmony_ci}
353762306a36Sopenharmony_ci
353862306a36Sopenharmony_civoid ethtool_coalesce_get_rsp_free(struct ethtool_coalesce_get_rsp *rsp)
353962306a36Sopenharmony_ci{
354062306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
354162306a36Sopenharmony_ci	free(rsp);
354262306a36Sopenharmony_ci}
354362306a36Sopenharmony_ci
354462306a36Sopenharmony_ciint ethtool_coalesce_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
354562306a36Sopenharmony_ci{
354662306a36Sopenharmony_ci	struct ethtool_coalesce_get_rsp *dst;
354762306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
354862306a36Sopenharmony_ci	const struct nlattr *attr;
354962306a36Sopenharmony_ci	struct ynl_parse_arg parg;
355062306a36Sopenharmony_ci
355162306a36Sopenharmony_ci	dst = yarg->data;
355262306a36Sopenharmony_ci	parg.ys = yarg->ys;
355362306a36Sopenharmony_ci
355462306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
355562306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
355662306a36Sopenharmony_ci
355762306a36Sopenharmony_ci		if (type == ETHTOOL_A_COALESCE_HEADER) {
355862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
355962306a36Sopenharmony_ci				return MNL_CB_ERROR;
356062306a36Sopenharmony_ci			dst->_present.header = 1;
356162306a36Sopenharmony_ci
356262306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
356362306a36Sopenharmony_ci			parg.data = &dst->header;
356462306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
356562306a36Sopenharmony_ci				return MNL_CB_ERROR;
356662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_RX_USECS) {
356762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
356862306a36Sopenharmony_ci				return MNL_CB_ERROR;
356962306a36Sopenharmony_ci			dst->_present.rx_usecs = 1;
357062306a36Sopenharmony_ci			dst->rx_usecs = mnl_attr_get_u32(attr);
357162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_RX_MAX_FRAMES) {
357262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
357362306a36Sopenharmony_ci				return MNL_CB_ERROR;
357462306a36Sopenharmony_ci			dst->_present.rx_max_frames = 1;
357562306a36Sopenharmony_ci			dst->rx_max_frames = mnl_attr_get_u32(attr);
357662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_RX_USECS_IRQ) {
357762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
357862306a36Sopenharmony_ci				return MNL_CB_ERROR;
357962306a36Sopenharmony_ci			dst->_present.rx_usecs_irq = 1;
358062306a36Sopenharmony_ci			dst->rx_usecs_irq = mnl_attr_get_u32(attr);
358162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ) {
358262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
358362306a36Sopenharmony_ci				return MNL_CB_ERROR;
358462306a36Sopenharmony_ci			dst->_present.rx_max_frames_irq = 1;
358562306a36Sopenharmony_ci			dst->rx_max_frames_irq = mnl_attr_get_u32(attr);
358662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_USECS) {
358762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
358862306a36Sopenharmony_ci				return MNL_CB_ERROR;
358962306a36Sopenharmony_ci			dst->_present.tx_usecs = 1;
359062306a36Sopenharmony_ci			dst->tx_usecs = mnl_attr_get_u32(attr);
359162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_MAX_FRAMES) {
359262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
359362306a36Sopenharmony_ci				return MNL_CB_ERROR;
359462306a36Sopenharmony_ci			dst->_present.tx_max_frames = 1;
359562306a36Sopenharmony_ci			dst->tx_max_frames = mnl_attr_get_u32(attr);
359662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_USECS_IRQ) {
359762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
359862306a36Sopenharmony_ci				return MNL_CB_ERROR;
359962306a36Sopenharmony_ci			dst->_present.tx_usecs_irq = 1;
360062306a36Sopenharmony_ci			dst->tx_usecs_irq = mnl_attr_get_u32(attr);
360162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ) {
360262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
360362306a36Sopenharmony_ci				return MNL_CB_ERROR;
360462306a36Sopenharmony_ci			dst->_present.tx_max_frames_irq = 1;
360562306a36Sopenharmony_ci			dst->tx_max_frames_irq = mnl_attr_get_u32(attr);
360662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_STATS_BLOCK_USECS) {
360762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
360862306a36Sopenharmony_ci				return MNL_CB_ERROR;
360962306a36Sopenharmony_ci			dst->_present.stats_block_usecs = 1;
361062306a36Sopenharmony_ci			dst->stats_block_usecs = mnl_attr_get_u32(attr);
361162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX) {
361262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
361362306a36Sopenharmony_ci				return MNL_CB_ERROR;
361462306a36Sopenharmony_ci			dst->_present.use_adaptive_rx = 1;
361562306a36Sopenharmony_ci			dst->use_adaptive_rx = mnl_attr_get_u8(attr);
361662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX) {
361762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
361862306a36Sopenharmony_ci				return MNL_CB_ERROR;
361962306a36Sopenharmony_ci			dst->_present.use_adaptive_tx = 1;
362062306a36Sopenharmony_ci			dst->use_adaptive_tx = mnl_attr_get_u8(attr);
362162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_PKT_RATE_LOW) {
362262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
362362306a36Sopenharmony_ci				return MNL_CB_ERROR;
362462306a36Sopenharmony_ci			dst->_present.pkt_rate_low = 1;
362562306a36Sopenharmony_ci			dst->pkt_rate_low = mnl_attr_get_u32(attr);
362662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_RX_USECS_LOW) {
362762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
362862306a36Sopenharmony_ci				return MNL_CB_ERROR;
362962306a36Sopenharmony_ci			dst->_present.rx_usecs_low = 1;
363062306a36Sopenharmony_ci			dst->rx_usecs_low = mnl_attr_get_u32(attr);
363162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW) {
363262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
363362306a36Sopenharmony_ci				return MNL_CB_ERROR;
363462306a36Sopenharmony_ci			dst->_present.rx_max_frames_low = 1;
363562306a36Sopenharmony_ci			dst->rx_max_frames_low = mnl_attr_get_u32(attr);
363662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_USECS_LOW) {
363762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
363862306a36Sopenharmony_ci				return MNL_CB_ERROR;
363962306a36Sopenharmony_ci			dst->_present.tx_usecs_low = 1;
364062306a36Sopenharmony_ci			dst->tx_usecs_low = mnl_attr_get_u32(attr);
364162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW) {
364262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
364362306a36Sopenharmony_ci				return MNL_CB_ERROR;
364462306a36Sopenharmony_ci			dst->_present.tx_max_frames_low = 1;
364562306a36Sopenharmony_ci			dst->tx_max_frames_low = mnl_attr_get_u32(attr);
364662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_PKT_RATE_HIGH) {
364762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
364862306a36Sopenharmony_ci				return MNL_CB_ERROR;
364962306a36Sopenharmony_ci			dst->_present.pkt_rate_high = 1;
365062306a36Sopenharmony_ci			dst->pkt_rate_high = mnl_attr_get_u32(attr);
365162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_RX_USECS_HIGH) {
365262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
365362306a36Sopenharmony_ci				return MNL_CB_ERROR;
365462306a36Sopenharmony_ci			dst->_present.rx_usecs_high = 1;
365562306a36Sopenharmony_ci			dst->rx_usecs_high = mnl_attr_get_u32(attr);
365662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH) {
365762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
365862306a36Sopenharmony_ci				return MNL_CB_ERROR;
365962306a36Sopenharmony_ci			dst->_present.rx_max_frames_high = 1;
366062306a36Sopenharmony_ci			dst->rx_max_frames_high = mnl_attr_get_u32(attr);
366162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_USECS_HIGH) {
366262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
366362306a36Sopenharmony_ci				return MNL_CB_ERROR;
366462306a36Sopenharmony_ci			dst->_present.tx_usecs_high = 1;
366562306a36Sopenharmony_ci			dst->tx_usecs_high = mnl_attr_get_u32(attr);
366662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH) {
366762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
366862306a36Sopenharmony_ci				return MNL_CB_ERROR;
366962306a36Sopenharmony_ci			dst->_present.tx_max_frames_high = 1;
367062306a36Sopenharmony_ci			dst->tx_max_frames_high = mnl_attr_get_u32(attr);
367162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL) {
367262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
367362306a36Sopenharmony_ci				return MNL_CB_ERROR;
367462306a36Sopenharmony_ci			dst->_present.rate_sample_interval = 1;
367562306a36Sopenharmony_ci			dst->rate_sample_interval = mnl_attr_get_u32(attr);
367662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_USE_CQE_MODE_TX) {
367762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
367862306a36Sopenharmony_ci				return MNL_CB_ERROR;
367962306a36Sopenharmony_ci			dst->_present.use_cqe_mode_tx = 1;
368062306a36Sopenharmony_ci			dst->use_cqe_mode_tx = mnl_attr_get_u8(attr);
368162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_USE_CQE_MODE_RX) {
368262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
368362306a36Sopenharmony_ci				return MNL_CB_ERROR;
368462306a36Sopenharmony_ci			dst->_present.use_cqe_mode_rx = 1;
368562306a36Sopenharmony_ci			dst->use_cqe_mode_rx = mnl_attr_get_u8(attr);
368662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES) {
368762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
368862306a36Sopenharmony_ci				return MNL_CB_ERROR;
368962306a36Sopenharmony_ci			dst->_present.tx_aggr_max_bytes = 1;
369062306a36Sopenharmony_ci			dst->tx_aggr_max_bytes = mnl_attr_get_u32(attr);
369162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES) {
369262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
369362306a36Sopenharmony_ci				return MNL_CB_ERROR;
369462306a36Sopenharmony_ci			dst->_present.tx_aggr_max_frames = 1;
369562306a36Sopenharmony_ci			dst->tx_aggr_max_frames = mnl_attr_get_u32(attr);
369662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS) {
369762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
369862306a36Sopenharmony_ci				return MNL_CB_ERROR;
369962306a36Sopenharmony_ci			dst->_present.tx_aggr_time_usecs = 1;
370062306a36Sopenharmony_ci			dst->tx_aggr_time_usecs = mnl_attr_get_u32(attr);
370162306a36Sopenharmony_ci		}
370262306a36Sopenharmony_ci	}
370362306a36Sopenharmony_ci
370462306a36Sopenharmony_ci	return MNL_CB_OK;
370562306a36Sopenharmony_ci}
370662306a36Sopenharmony_ci
370762306a36Sopenharmony_cistruct ethtool_coalesce_get_rsp *
370862306a36Sopenharmony_ciethtool_coalesce_get(struct ynl_sock *ys, struct ethtool_coalesce_get_req *req)
370962306a36Sopenharmony_ci{
371062306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
371162306a36Sopenharmony_ci	struct ethtool_coalesce_get_rsp *rsp;
371262306a36Sopenharmony_ci	struct nlmsghdr *nlh;
371362306a36Sopenharmony_ci	int err;
371462306a36Sopenharmony_ci
371562306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_COALESCE_GET, 1);
371662306a36Sopenharmony_ci	ys->req_policy = &ethtool_coalesce_nest;
371762306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_coalesce_nest;
371862306a36Sopenharmony_ci
371962306a36Sopenharmony_ci	if (req->_present.header)
372062306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_COALESCE_HEADER, &req->header);
372162306a36Sopenharmony_ci
372262306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
372362306a36Sopenharmony_ci	yrs.yarg.data = rsp;
372462306a36Sopenharmony_ci	yrs.cb = ethtool_coalesce_get_rsp_parse;
372562306a36Sopenharmony_ci	yrs.rsp_cmd = 20;
372662306a36Sopenharmony_ci
372762306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
372862306a36Sopenharmony_ci	if (err < 0)
372962306a36Sopenharmony_ci		goto err_free;
373062306a36Sopenharmony_ci
373162306a36Sopenharmony_ci	return rsp;
373262306a36Sopenharmony_ci
373362306a36Sopenharmony_cierr_free:
373462306a36Sopenharmony_ci	ethtool_coalesce_get_rsp_free(rsp);
373562306a36Sopenharmony_ci	return NULL;
373662306a36Sopenharmony_ci}
373762306a36Sopenharmony_ci
373862306a36Sopenharmony_ci/* ETHTOOL_MSG_COALESCE_GET - dump */
373962306a36Sopenharmony_civoid ethtool_coalesce_get_list_free(struct ethtool_coalesce_get_list *rsp)
374062306a36Sopenharmony_ci{
374162306a36Sopenharmony_ci	struct ethtool_coalesce_get_list *next = rsp;
374262306a36Sopenharmony_ci
374362306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
374462306a36Sopenharmony_ci		rsp = next;
374562306a36Sopenharmony_ci		next = rsp->next;
374662306a36Sopenharmony_ci
374762306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
374862306a36Sopenharmony_ci		free(rsp);
374962306a36Sopenharmony_ci	}
375062306a36Sopenharmony_ci}
375162306a36Sopenharmony_ci
375262306a36Sopenharmony_cistruct ethtool_coalesce_get_list *
375362306a36Sopenharmony_ciethtool_coalesce_get_dump(struct ynl_sock *ys,
375462306a36Sopenharmony_ci			  struct ethtool_coalesce_get_req_dump *req)
375562306a36Sopenharmony_ci{
375662306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
375762306a36Sopenharmony_ci	struct nlmsghdr *nlh;
375862306a36Sopenharmony_ci	int err;
375962306a36Sopenharmony_ci
376062306a36Sopenharmony_ci	yds.ys = ys;
376162306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_coalesce_get_list);
376262306a36Sopenharmony_ci	yds.cb = ethtool_coalesce_get_rsp_parse;
376362306a36Sopenharmony_ci	yds.rsp_cmd = 20;
376462306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_coalesce_nest;
376562306a36Sopenharmony_ci
376662306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_COALESCE_GET, 1);
376762306a36Sopenharmony_ci	ys->req_policy = &ethtool_coalesce_nest;
376862306a36Sopenharmony_ci
376962306a36Sopenharmony_ci	if (req->_present.header)
377062306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_COALESCE_HEADER, &req->header);
377162306a36Sopenharmony_ci
377262306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
377362306a36Sopenharmony_ci	if (err < 0)
377462306a36Sopenharmony_ci		goto free_list;
377562306a36Sopenharmony_ci
377662306a36Sopenharmony_ci	return yds.first;
377762306a36Sopenharmony_ci
377862306a36Sopenharmony_cifree_list:
377962306a36Sopenharmony_ci	ethtool_coalesce_get_list_free(yds.first);
378062306a36Sopenharmony_ci	return NULL;
378162306a36Sopenharmony_ci}
378262306a36Sopenharmony_ci
378362306a36Sopenharmony_ci/* ETHTOOL_MSG_COALESCE_GET - notify */
378462306a36Sopenharmony_civoid ethtool_coalesce_get_ntf_free(struct ethtool_coalesce_get_ntf *rsp)
378562306a36Sopenharmony_ci{
378662306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
378762306a36Sopenharmony_ci	free(rsp);
378862306a36Sopenharmony_ci}
378962306a36Sopenharmony_ci
379062306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_COALESCE_SET ============== */
379162306a36Sopenharmony_ci/* ETHTOOL_MSG_COALESCE_SET - do */
379262306a36Sopenharmony_civoid ethtool_coalesce_set_req_free(struct ethtool_coalesce_set_req *req)
379362306a36Sopenharmony_ci{
379462306a36Sopenharmony_ci	ethtool_header_free(&req->header);
379562306a36Sopenharmony_ci	free(req);
379662306a36Sopenharmony_ci}
379762306a36Sopenharmony_ci
379862306a36Sopenharmony_ciint ethtool_coalesce_set(struct ynl_sock *ys,
379962306a36Sopenharmony_ci			 struct ethtool_coalesce_set_req *req)
380062306a36Sopenharmony_ci{
380162306a36Sopenharmony_ci	struct nlmsghdr *nlh;
380262306a36Sopenharmony_ci	int err;
380362306a36Sopenharmony_ci
380462306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_COALESCE_SET, 1);
380562306a36Sopenharmony_ci	ys->req_policy = &ethtool_coalesce_nest;
380662306a36Sopenharmony_ci
380762306a36Sopenharmony_ci	if (req->_present.header)
380862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_COALESCE_HEADER, &req->header);
380962306a36Sopenharmony_ci	if (req->_present.rx_usecs)
381062306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_USECS, req->rx_usecs);
381162306a36Sopenharmony_ci	if (req->_present.rx_max_frames)
381262306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_MAX_FRAMES, req->rx_max_frames);
381362306a36Sopenharmony_ci	if (req->_present.rx_usecs_irq)
381462306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_USECS_IRQ, req->rx_usecs_irq);
381562306a36Sopenharmony_ci	if (req->_present.rx_max_frames_irq)
381662306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ, req->rx_max_frames_irq);
381762306a36Sopenharmony_ci	if (req->_present.tx_usecs)
381862306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_USECS, req->tx_usecs);
381962306a36Sopenharmony_ci	if (req->_present.tx_max_frames)
382062306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_MAX_FRAMES, req->tx_max_frames);
382162306a36Sopenharmony_ci	if (req->_present.tx_usecs_irq)
382262306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_USECS_IRQ, req->tx_usecs_irq);
382362306a36Sopenharmony_ci	if (req->_present.tx_max_frames_irq)
382462306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ, req->tx_max_frames_irq);
382562306a36Sopenharmony_ci	if (req->_present.stats_block_usecs)
382662306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_STATS_BLOCK_USECS, req->stats_block_usecs);
382762306a36Sopenharmony_ci	if (req->_present.use_adaptive_rx)
382862306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX, req->use_adaptive_rx);
382962306a36Sopenharmony_ci	if (req->_present.use_adaptive_tx)
383062306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX, req->use_adaptive_tx);
383162306a36Sopenharmony_ci	if (req->_present.pkt_rate_low)
383262306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_PKT_RATE_LOW, req->pkt_rate_low);
383362306a36Sopenharmony_ci	if (req->_present.rx_usecs_low)
383462306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_USECS_LOW, req->rx_usecs_low);
383562306a36Sopenharmony_ci	if (req->_present.rx_max_frames_low)
383662306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW, req->rx_max_frames_low);
383762306a36Sopenharmony_ci	if (req->_present.tx_usecs_low)
383862306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_USECS_LOW, req->tx_usecs_low);
383962306a36Sopenharmony_ci	if (req->_present.tx_max_frames_low)
384062306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW, req->tx_max_frames_low);
384162306a36Sopenharmony_ci	if (req->_present.pkt_rate_high)
384262306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_PKT_RATE_HIGH, req->pkt_rate_high);
384362306a36Sopenharmony_ci	if (req->_present.rx_usecs_high)
384462306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_USECS_HIGH, req->rx_usecs_high);
384562306a36Sopenharmony_ci	if (req->_present.rx_max_frames_high)
384662306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH, req->rx_max_frames_high);
384762306a36Sopenharmony_ci	if (req->_present.tx_usecs_high)
384862306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_USECS_HIGH, req->tx_usecs_high);
384962306a36Sopenharmony_ci	if (req->_present.tx_max_frames_high)
385062306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH, req->tx_max_frames_high);
385162306a36Sopenharmony_ci	if (req->_present.rate_sample_interval)
385262306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL, req->rate_sample_interval);
385362306a36Sopenharmony_ci	if (req->_present.use_cqe_mode_tx)
385462306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_COALESCE_USE_CQE_MODE_TX, req->use_cqe_mode_tx);
385562306a36Sopenharmony_ci	if (req->_present.use_cqe_mode_rx)
385662306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_COALESCE_USE_CQE_MODE_RX, req->use_cqe_mode_rx);
385762306a36Sopenharmony_ci	if (req->_present.tx_aggr_max_bytes)
385862306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES, req->tx_aggr_max_bytes);
385962306a36Sopenharmony_ci	if (req->_present.tx_aggr_max_frames)
386062306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES, req->tx_aggr_max_frames);
386162306a36Sopenharmony_ci	if (req->_present.tx_aggr_time_usecs)
386262306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS, req->tx_aggr_time_usecs);
386362306a36Sopenharmony_ci
386462306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
386562306a36Sopenharmony_ci	if (err < 0)
386662306a36Sopenharmony_ci		return -1;
386762306a36Sopenharmony_ci
386862306a36Sopenharmony_ci	return 0;
386962306a36Sopenharmony_ci}
387062306a36Sopenharmony_ci
387162306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PAUSE_GET ============== */
387262306a36Sopenharmony_ci/* ETHTOOL_MSG_PAUSE_GET - do */
387362306a36Sopenharmony_civoid ethtool_pause_get_req_free(struct ethtool_pause_get_req *req)
387462306a36Sopenharmony_ci{
387562306a36Sopenharmony_ci	ethtool_header_free(&req->header);
387662306a36Sopenharmony_ci	free(req);
387762306a36Sopenharmony_ci}
387862306a36Sopenharmony_ci
387962306a36Sopenharmony_civoid ethtool_pause_get_rsp_free(struct ethtool_pause_get_rsp *rsp)
388062306a36Sopenharmony_ci{
388162306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
388262306a36Sopenharmony_ci	ethtool_pause_stat_free(&rsp->stats);
388362306a36Sopenharmony_ci	free(rsp);
388462306a36Sopenharmony_ci}
388562306a36Sopenharmony_ci
388662306a36Sopenharmony_ciint ethtool_pause_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
388762306a36Sopenharmony_ci{
388862306a36Sopenharmony_ci	struct ethtool_pause_get_rsp *dst;
388962306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
389062306a36Sopenharmony_ci	const struct nlattr *attr;
389162306a36Sopenharmony_ci	struct ynl_parse_arg parg;
389262306a36Sopenharmony_ci
389362306a36Sopenharmony_ci	dst = yarg->data;
389462306a36Sopenharmony_ci	parg.ys = yarg->ys;
389562306a36Sopenharmony_ci
389662306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
389762306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
389862306a36Sopenharmony_ci
389962306a36Sopenharmony_ci		if (type == ETHTOOL_A_PAUSE_HEADER) {
390062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
390162306a36Sopenharmony_ci				return MNL_CB_ERROR;
390262306a36Sopenharmony_ci			dst->_present.header = 1;
390362306a36Sopenharmony_ci
390462306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
390562306a36Sopenharmony_ci			parg.data = &dst->header;
390662306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
390762306a36Sopenharmony_ci				return MNL_CB_ERROR;
390862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PAUSE_AUTONEG) {
390962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
391062306a36Sopenharmony_ci				return MNL_CB_ERROR;
391162306a36Sopenharmony_ci			dst->_present.autoneg = 1;
391262306a36Sopenharmony_ci			dst->autoneg = mnl_attr_get_u8(attr);
391362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PAUSE_RX) {
391462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
391562306a36Sopenharmony_ci				return MNL_CB_ERROR;
391662306a36Sopenharmony_ci			dst->_present.rx = 1;
391762306a36Sopenharmony_ci			dst->rx = mnl_attr_get_u8(attr);
391862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PAUSE_TX) {
391962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
392062306a36Sopenharmony_ci				return MNL_CB_ERROR;
392162306a36Sopenharmony_ci			dst->_present.tx = 1;
392262306a36Sopenharmony_ci			dst->tx = mnl_attr_get_u8(attr);
392362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PAUSE_STATS) {
392462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
392562306a36Sopenharmony_ci				return MNL_CB_ERROR;
392662306a36Sopenharmony_ci			dst->_present.stats = 1;
392762306a36Sopenharmony_ci
392862306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_pause_stat_nest;
392962306a36Sopenharmony_ci			parg.data = &dst->stats;
393062306a36Sopenharmony_ci			if (ethtool_pause_stat_parse(&parg, attr))
393162306a36Sopenharmony_ci				return MNL_CB_ERROR;
393262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PAUSE_STATS_SRC) {
393362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
393462306a36Sopenharmony_ci				return MNL_CB_ERROR;
393562306a36Sopenharmony_ci			dst->_present.stats_src = 1;
393662306a36Sopenharmony_ci			dst->stats_src = mnl_attr_get_u32(attr);
393762306a36Sopenharmony_ci		}
393862306a36Sopenharmony_ci	}
393962306a36Sopenharmony_ci
394062306a36Sopenharmony_ci	return MNL_CB_OK;
394162306a36Sopenharmony_ci}
394262306a36Sopenharmony_ci
394362306a36Sopenharmony_cistruct ethtool_pause_get_rsp *
394462306a36Sopenharmony_ciethtool_pause_get(struct ynl_sock *ys, struct ethtool_pause_get_req *req)
394562306a36Sopenharmony_ci{
394662306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
394762306a36Sopenharmony_ci	struct ethtool_pause_get_rsp *rsp;
394862306a36Sopenharmony_ci	struct nlmsghdr *nlh;
394962306a36Sopenharmony_ci	int err;
395062306a36Sopenharmony_ci
395162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PAUSE_GET, 1);
395262306a36Sopenharmony_ci	ys->req_policy = &ethtool_pause_nest;
395362306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_pause_nest;
395462306a36Sopenharmony_ci
395562306a36Sopenharmony_ci	if (req->_present.header)
395662306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PAUSE_HEADER, &req->header);
395762306a36Sopenharmony_ci
395862306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
395962306a36Sopenharmony_ci	yrs.yarg.data = rsp;
396062306a36Sopenharmony_ci	yrs.cb = ethtool_pause_get_rsp_parse;
396162306a36Sopenharmony_ci	yrs.rsp_cmd = 22;
396262306a36Sopenharmony_ci
396362306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
396462306a36Sopenharmony_ci	if (err < 0)
396562306a36Sopenharmony_ci		goto err_free;
396662306a36Sopenharmony_ci
396762306a36Sopenharmony_ci	return rsp;
396862306a36Sopenharmony_ci
396962306a36Sopenharmony_cierr_free:
397062306a36Sopenharmony_ci	ethtool_pause_get_rsp_free(rsp);
397162306a36Sopenharmony_ci	return NULL;
397262306a36Sopenharmony_ci}
397362306a36Sopenharmony_ci
397462306a36Sopenharmony_ci/* ETHTOOL_MSG_PAUSE_GET - dump */
397562306a36Sopenharmony_civoid ethtool_pause_get_list_free(struct ethtool_pause_get_list *rsp)
397662306a36Sopenharmony_ci{
397762306a36Sopenharmony_ci	struct ethtool_pause_get_list *next = rsp;
397862306a36Sopenharmony_ci
397962306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
398062306a36Sopenharmony_ci		rsp = next;
398162306a36Sopenharmony_ci		next = rsp->next;
398262306a36Sopenharmony_ci
398362306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
398462306a36Sopenharmony_ci		ethtool_pause_stat_free(&rsp->obj.stats);
398562306a36Sopenharmony_ci		free(rsp);
398662306a36Sopenharmony_ci	}
398762306a36Sopenharmony_ci}
398862306a36Sopenharmony_ci
398962306a36Sopenharmony_cistruct ethtool_pause_get_list *
399062306a36Sopenharmony_ciethtool_pause_get_dump(struct ynl_sock *ys,
399162306a36Sopenharmony_ci		       struct ethtool_pause_get_req_dump *req)
399262306a36Sopenharmony_ci{
399362306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
399462306a36Sopenharmony_ci	struct nlmsghdr *nlh;
399562306a36Sopenharmony_ci	int err;
399662306a36Sopenharmony_ci
399762306a36Sopenharmony_ci	yds.ys = ys;
399862306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_pause_get_list);
399962306a36Sopenharmony_ci	yds.cb = ethtool_pause_get_rsp_parse;
400062306a36Sopenharmony_ci	yds.rsp_cmd = 22;
400162306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_pause_nest;
400262306a36Sopenharmony_ci
400362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PAUSE_GET, 1);
400462306a36Sopenharmony_ci	ys->req_policy = &ethtool_pause_nest;
400562306a36Sopenharmony_ci
400662306a36Sopenharmony_ci	if (req->_present.header)
400762306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PAUSE_HEADER, &req->header);
400862306a36Sopenharmony_ci
400962306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
401062306a36Sopenharmony_ci	if (err < 0)
401162306a36Sopenharmony_ci		goto free_list;
401262306a36Sopenharmony_ci
401362306a36Sopenharmony_ci	return yds.first;
401462306a36Sopenharmony_ci
401562306a36Sopenharmony_cifree_list:
401662306a36Sopenharmony_ci	ethtool_pause_get_list_free(yds.first);
401762306a36Sopenharmony_ci	return NULL;
401862306a36Sopenharmony_ci}
401962306a36Sopenharmony_ci
402062306a36Sopenharmony_ci/* ETHTOOL_MSG_PAUSE_GET - notify */
402162306a36Sopenharmony_civoid ethtool_pause_get_ntf_free(struct ethtool_pause_get_ntf *rsp)
402262306a36Sopenharmony_ci{
402362306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
402462306a36Sopenharmony_ci	ethtool_pause_stat_free(&rsp->obj.stats);
402562306a36Sopenharmony_ci	free(rsp);
402662306a36Sopenharmony_ci}
402762306a36Sopenharmony_ci
402862306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PAUSE_SET ============== */
402962306a36Sopenharmony_ci/* ETHTOOL_MSG_PAUSE_SET - do */
403062306a36Sopenharmony_civoid ethtool_pause_set_req_free(struct ethtool_pause_set_req *req)
403162306a36Sopenharmony_ci{
403262306a36Sopenharmony_ci	ethtool_header_free(&req->header);
403362306a36Sopenharmony_ci	ethtool_pause_stat_free(&req->stats);
403462306a36Sopenharmony_ci	free(req);
403562306a36Sopenharmony_ci}
403662306a36Sopenharmony_ci
403762306a36Sopenharmony_ciint ethtool_pause_set(struct ynl_sock *ys, struct ethtool_pause_set_req *req)
403862306a36Sopenharmony_ci{
403962306a36Sopenharmony_ci	struct nlmsghdr *nlh;
404062306a36Sopenharmony_ci	int err;
404162306a36Sopenharmony_ci
404262306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PAUSE_SET, 1);
404362306a36Sopenharmony_ci	ys->req_policy = &ethtool_pause_nest;
404462306a36Sopenharmony_ci
404562306a36Sopenharmony_ci	if (req->_present.header)
404662306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PAUSE_HEADER, &req->header);
404762306a36Sopenharmony_ci	if (req->_present.autoneg)
404862306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_PAUSE_AUTONEG, req->autoneg);
404962306a36Sopenharmony_ci	if (req->_present.rx)
405062306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_PAUSE_RX, req->rx);
405162306a36Sopenharmony_ci	if (req->_present.tx)
405262306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_PAUSE_TX, req->tx);
405362306a36Sopenharmony_ci	if (req->_present.stats)
405462306a36Sopenharmony_ci		ethtool_pause_stat_put(nlh, ETHTOOL_A_PAUSE_STATS, &req->stats);
405562306a36Sopenharmony_ci	if (req->_present.stats_src)
405662306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_PAUSE_STATS_SRC, req->stats_src);
405762306a36Sopenharmony_ci
405862306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
405962306a36Sopenharmony_ci	if (err < 0)
406062306a36Sopenharmony_ci		return -1;
406162306a36Sopenharmony_ci
406262306a36Sopenharmony_ci	return 0;
406362306a36Sopenharmony_ci}
406462306a36Sopenharmony_ci
406562306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_EEE_GET ============== */
406662306a36Sopenharmony_ci/* ETHTOOL_MSG_EEE_GET - do */
406762306a36Sopenharmony_civoid ethtool_eee_get_req_free(struct ethtool_eee_get_req *req)
406862306a36Sopenharmony_ci{
406962306a36Sopenharmony_ci	ethtool_header_free(&req->header);
407062306a36Sopenharmony_ci	free(req);
407162306a36Sopenharmony_ci}
407262306a36Sopenharmony_ci
407362306a36Sopenharmony_civoid ethtool_eee_get_rsp_free(struct ethtool_eee_get_rsp *rsp)
407462306a36Sopenharmony_ci{
407562306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
407662306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->modes_ours);
407762306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->modes_peer);
407862306a36Sopenharmony_ci	free(rsp);
407962306a36Sopenharmony_ci}
408062306a36Sopenharmony_ci
408162306a36Sopenharmony_ciint ethtool_eee_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
408262306a36Sopenharmony_ci{
408362306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
408462306a36Sopenharmony_ci	struct ethtool_eee_get_rsp *dst;
408562306a36Sopenharmony_ci	const struct nlattr *attr;
408662306a36Sopenharmony_ci	struct ynl_parse_arg parg;
408762306a36Sopenharmony_ci
408862306a36Sopenharmony_ci	dst = yarg->data;
408962306a36Sopenharmony_ci	parg.ys = yarg->ys;
409062306a36Sopenharmony_ci
409162306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
409262306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
409362306a36Sopenharmony_ci
409462306a36Sopenharmony_ci		if (type == ETHTOOL_A_EEE_HEADER) {
409562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
409662306a36Sopenharmony_ci				return MNL_CB_ERROR;
409762306a36Sopenharmony_ci			dst->_present.header = 1;
409862306a36Sopenharmony_ci
409962306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
410062306a36Sopenharmony_ci			parg.data = &dst->header;
410162306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
410262306a36Sopenharmony_ci				return MNL_CB_ERROR;
410362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_EEE_MODES_OURS) {
410462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
410562306a36Sopenharmony_ci				return MNL_CB_ERROR;
410662306a36Sopenharmony_ci			dst->_present.modes_ours = 1;
410762306a36Sopenharmony_ci
410862306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
410962306a36Sopenharmony_ci			parg.data = &dst->modes_ours;
411062306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
411162306a36Sopenharmony_ci				return MNL_CB_ERROR;
411262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_EEE_MODES_PEER) {
411362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
411462306a36Sopenharmony_ci				return MNL_CB_ERROR;
411562306a36Sopenharmony_ci			dst->_present.modes_peer = 1;
411662306a36Sopenharmony_ci
411762306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
411862306a36Sopenharmony_ci			parg.data = &dst->modes_peer;
411962306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
412062306a36Sopenharmony_ci				return MNL_CB_ERROR;
412162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_EEE_ACTIVE) {
412262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
412362306a36Sopenharmony_ci				return MNL_CB_ERROR;
412462306a36Sopenharmony_ci			dst->_present.active = 1;
412562306a36Sopenharmony_ci			dst->active = mnl_attr_get_u8(attr);
412662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_EEE_ENABLED) {
412762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
412862306a36Sopenharmony_ci				return MNL_CB_ERROR;
412962306a36Sopenharmony_ci			dst->_present.enabled = 1;
413062306a36Sopenharmony_ci			dst->enabled = mnl_attr_get_u8(attr);
413162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_EEE_TX_LPI_ENABLED) {
413262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
413362306a36Sopenharmony_ci				return MNL_CB_ERROR;
413462306a36Sopenharmony_ci			dst->_present.tx_lpi_enabled = 1;
413562306a36Sopenharmony_ci			dst->tx_lpi_enabled = mnl_attr_get_u8(attr);
413662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_EEE_TX_LPI_TIMER) {
413762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
413862306a36Sopenharmony_ci				return MNL_CB_ERROR;
413962306a36Sopenharmony_ci			dst->_present.tx_lpi_timer = 1;
414062306a36Sopenharmony_ci			dst->tx_lpi_timer = mnl_attr_get_u32(attr);
414162306a36Sopenharmony_ci		}
414262306a36Sopenharmony_ci	}
414362306a36Sopenharmony_ci
414462306a36Sopenharmony_ci	return MNL_CB_OK;
414562306a36Sopenharmony_ci}
414662306a36Sopenharmony_ci
414762306a36Sopenharmony_cistruct ethtool_eee_get_rsp *
414862306a36Sopenharmony_ciethtool_eee_get(struct ynl_sock *ys, struct ethtool_eee_get_req *req)
414962306a36Sopenharmony_ci{
415062306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
415162306a36Sopenharmony_ci	struct ethtool_eee_get_rsp *rsp;
415262306a36Sopenharmony_ci	struct nlmsghdr *nlh;
415362306a36Sopenharmony_ci	int err;
415462306a36Sopenharmony_ci
415562306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_EEE_GET, 1);
415662306a36Sopenharmony_ci	ys->req_policy = &ethtool_eee_nest;
415762306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_eee_nest;
415862306a36Sopenharmony_ci
415962306a36Sopenharmony_ci	if (req->_present.header)
416062306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_EEE_HEADER, &req->header);
416162306a36Sopenharmony_ci
416262306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
416362306a36Sopenharmony_ci	yrs.yarg.data = rsp;
416462306a36Sopenharmony_ci	yrs.cb = ethtool_eee_get_rsp_parse;
416562306a36Sopenharmony_ci	yrs.rsp_cmd = 24;
416662306a36Sopenharmony_ci
416762306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
416862306a36Sopenharmony_ci	if (err < 0)
416962306a36Sopenharmony_ci		goto err_free;
417062306a36Sopenharmony_ci
417162306a36Sopenharmony_ci	return rsp;
417262306a36Sopenharmony_ci
417362306a36Sopenharmony_cierr_free:
417462306a36Sopenharmony_ci	ethtool_eee_get_rsp_free(rsp);
417562306a36Sopenharmony_ci	return NULL;
417662306a36Sopenharmony_ci}
417762306a36Sopenharmony_ci
417862306a36Sopenharmony_ci/* ETHTOOL_MSG_EEE_GET - dump */
417962306a36Sopenharmony_civoid ethtool_eee_get_list_free(struct ethtool_eee_get_list *rsp)
418062306a36Sopenharmony_ci{
418162306a36Sopenharmony_ci	struct ethtool_eee_get_list *next = rsp;
418262306a36Sopenharmony_ci
418362306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
418462306a36Sopenharmony_ci		rsp = next;
418562306a36Sopenharmony_ci		next = rsp->next;
418662306a36Sopenharmony_ci
418762306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
418862306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.modes_ours);
418962306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.modes_peer);
419062306a36Sopenharmony_ci		free(rsp);
419162306a36Sopenharmony_ci	}
419262306a36Sopenharmony_ci}
419362306a36Sopenharmony_ci
419462306a36Sopenharmony_cistruct ethtool_eee_get_list *
419562306a36Sopenharmony_ciethtool_eee_get_dump(struct ynl_sock *ys, struct ethtool_eee_get_req_dump *req)
419662306a36Sopenharmony_ci{
419762306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
419862306a36Sopenharmony_ci	struct nlmsghdr *nlh;
419962306a36Sopenharmony_ci	int err;
420062306a36Sopenharmony_ci
420162306a36Sopenharmony_ci	yds.ys = ys;
420262306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_eee_get_list);
420362306a36Sopenharmony_ci	yds.cb = ethtool_eee_get_rsp_parse;
420462306a36Sopenharmony_ci	yds.rsp_cmd = 24;
420562306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_eee_nest;
420662306a36Sopenharmony_ci
420762306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_EEE_GET, 1);
420862306a36Sopenharmony_ci	ys->req_policy = &ethtool_eee_nest;
420962306a36Sopenharmony_ci
421062306a36Sopenharmony_ci	if (req->_present.header)
421162306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_EEE_HEADER, &req->header);
421262306a36Sopenharmony_ci
421362306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
421462306a36Sopenharmony_ci	if (err < 0)
421562306a36Sopenharmony_ci		goto free_list;
421662306a36Sopenharmony_ci
421762306a36Sopenharmony_ci	return yds.first;
421862306a36Sopenharmony_ci
421962306a36Sopenharmony_cifree_list:
422062306a36Sopenharmony_ci	ethtool_eee_get_list_free(yds.first);
422162306a36Sopenharmony_ci	return NULL;
422262306a36Sopenharmony_ci}
422362306a36Sopenharmony_ci
422462306a36Sopenharmony_ci/* ETHTOOL_MSG_EEE_GET - notify */
422562306a36Sopenharmony_civoid ethtool_eee_get_ntf_free(struct ethtool_eee_get_ntf *rsp)
422662306a36Sopenharmony_ci{
422762306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
422862306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.modes_ours);
422962306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.modes_peer);
423062306a36Sopenharmony_ci	free(rsp);
423162306a36Sopenharmony_ci}
423262306a36Sopenharmony_ci
423362306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_EEE_SET ============== */
423462306a36Sopenharmony_ci/* ETHTOOL_MSG_EEE_SET - do */
423562306a36Sopenharmony_civoid ethtool_eee_set_req_free(struct ethtool_eee_set_req *req)
423662306a36Sopenharmony_ci{
423762306a36Sopenharmony_ci	ethtool_header_free(&req->header);
423862306a36Sopenharmony_ci	ethtool_bitset_free(&req->modes_ours);
423962306a36Sopenharmony_ci	ethtool_bitset_free(&req->modes_peer);
424062306a36Sopenharmony_ci	free(req);
424162306a36Sopenharmony_ci}
424262306a36Sopenharmony_ci
424362306a36Sopenharmony_ciint ethtool_eee_set(struct ynl_sock *ys, struct ethtool_eee_set_req *req)
424462306a36Sopenharmony_ci{
424562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
424662306a36Sopenharmony_ci	int err;
424762306a36Sopenharmony_ci
424862306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_EEE_SET, 1);
424962306a36Sopenharmony_ci	ys->req_policy = &ethtool_eee_nest;
425062306a36Sopenharmony_ci
425162306a36Sopenharmony_ci	if (req->_present.header)
425262306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_EEE_HEADER, &req->header);
425362306a36Sopenharmony_ci	if (req->_present.modes_ours)
425462306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_EEE_MODES_OURS, &req->modes_ours);
425562306a36Sopenharmony_ci	if (req->_present.modes_peer)
425662306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_EEE_MODES_PEER, &req->modes_peer);
425762306a36Sopenharmony_ci	if (req->_present.active)
425862306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_EEE_ACTIVE, req->active);
425962306a36Sopenharmony_ci	if (req->_present.enabled)
426062306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_EEE_ENABLED, req->enabled);
426162306a36Sopenharmony_ci	if (req->_present.tx_lpi_enabled)
426262306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_EEE_TX_LPI_ENABLED, req->tx_lpi_enabled);
426362306a36Sopenharmony_ci	if (req->_present.tx_lpi_timer)
426462306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_EEE_TX_LPI_TIMER, req->tx_lpi_timer);
426562306a36Sopenharmony_ci
426662306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
426762306a36Sopenharmony_ci	if (err < 0)
426862306a36Sopenharmony_ci		return -1;
426962306a36Sopenharmony_ci
427062306a36Sopenharmony_ci	return 0;
427162306a36Sopenharmony_ci}
427262306a36Sopenharmony_ci
427362306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_TSINFO_GET ============== */
427462306a36Sopenharmony_ci/* ETHTOOL_MSG_TSINFO_GET - do */
427562306a36Sopenharmony_civoid ethtool_tsinfo_get_req_free(struct ethtool_tsinfo_get_req *req)
427662306a36Sopenharmony_ci{
427762306a36Sopenharmony_ci	ethtool_header_free(&req->header);
427862306a36Sopenharmony_ci	free(req);
427962306a36Sopenharmony_ci}
428062306a36Sopenharmony_ci
428162306a36Sopenharmony_civoid ethtool_tsinfo_get_rsp_free(struct ethtool_tsinfo_get_rsp *rsp)
428262306a36Sopenharmony_ci{
428362306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
428462306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->timestamping);
428562306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->tx_types);
428662306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->rx_filters);
428762306a36Sopenharmony_ci	free(rsp);
428862306a36Sopenharmony_ci}
428962306a36Sopenharmony_ci
429062306a36Sopenharmony_ciint ethtool_tsinfo_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
429162306a36Sopenharmony_ci{
429262306a36Sopenharmony_ci	struct ethtool_tsinfo_get_rsp *dst;
429362306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
429462306a36Sopenharmony_ci	const struct nlattr *attr;
429562306a36Sopenharmony_ci	struct ynl_parse_arg parg;
429662306a36Sopenharmony_ci
429762306a36Sopenharmony_ci	dst = yarg->data;
429862306a36Sopenharmony_ci	parg.ys = yarg->ys;
429962306a36Sopenharmony_ci
430062306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
430162306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
430262306a36Sopenharmony_ci
430362306a36Sopenharmony_ci		if (type == ETHTOOL_A_TSINFO_HEADER) {
430462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
430562306a36Sopenharmony_ci				return MNL_CB_ERROR;
430662306a36Sopenharmony_ci			dst->_present.header = 1;
430762306a36Sopenharmony_ci
430862306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
430962306a36Sopenharmony_ci			parg.data = &dst->header;
431062306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
431162306a36Sopenharmony_ci				return MNL_CB_ERROR;
431262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_TSINFO_TIMESTAMPING) {
431362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
431462306a36Sopenharmony_ci				return MNL_CB_ERROR;
431562306a36Sopenharmony_ci			dst->_present.timestamping = 1;
431662306a36Sopenharmony_ci
431762306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
431862306a36Sopenharmony_ci			parg.data = &dst->timestamping;
431962306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
432062306a36Sopenharmony_ci				return MNL_CB_ERROR;
432162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_TSINFO_TX_TYPES) {
432262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
432362306a36Sopenharmony_ci				return MNL_CB_ERROR;
432462306a36Sopenharmony_ci			dst->_present.tx_types = 1;
432562306a36Sopenharmony_ci
432662306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
432762306a36Sopenharmony_ci			parg.data = &dst->tx_types;
432862306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
432962306a36Sopenharmony_ci				return MNL_CB_ERROR;
433062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_TSINFO_RX_FILTERS) {
433162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
433262306a36Sopenharmony_ci				return MNL_CB_ERROR;
433362306a36Sopenharmony_ci			dst->_present.rx_filters = 1;
433462306a36Sopenharmony_ci
433562306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
433662306a36Sopenharmony_ci			parg.data = &dst->rx_filters;
433762306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
433862306a36Sopenharmony_ci				return MNL_CB_ERROR;
433962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_TSINFO_PHC_INDEX) {
434062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
434162306a36Sopenharmony_ci				return MNL_CB_ERROR;
434262306a36Sopenharmony_ci			dst->_present.phc_index = 1;
434362306a36Sopenharmony_ci			dst->phc_index = mnl_attr_get_u32(attr);
434462306a36Sopenharmony_ci		}
434562306a36Sopenharmony_ci	}
434662306a36Sopenharmony_ci
434762306a36Sopenharmony_ci	return MNL_CB_OK;
434862306a36Sopenharmony_ci}
434962306a36Sopenharmony_ci
435062306a36Sopenharmony_cistruct ethtool_tsinfo_get_rsp *
435162306a36Sopenharmony_ciethtool_tsinfo_get(struct ynl_sock *ys, struct ethtool_tsinfo_get_req *req)
435262306a36Sopenharmony_ci{
435362306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
435462306a36Sopenharmony_ci	struct ethtool_tsinfo_get_rsp *rsp;
435562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
435662306a36Sopenharmony_ci	int err;
435762306a36Sopenharmony_ci
435862306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_TSINFO_GET, 1);
435962306a36Sopenharmony_ci	ys->req_policy = &ethtool_tsinfo_nest;
436062306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_tsinfo_nest;
436162306a36Sopenharmony_ci
436262306a36Sopenharmony_ci	if (req->_present.header)
436362306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_TSINFO_HEADER, &req->header);
436462306a36Sopenharmony_ci
436562306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
436662306a36Sopenharmony_ci	yrs.yarg.data = rsp;
436762306a36Sopenharmony_ci	yrs.cb = ethtool_tsinfo_get_rsp_parse;
436862306a36Sopenharmony_ci	yrs.rsp_cmd = 26;
436962306a36Sopenharmony_ci
437062306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
437162306a36Sopenharmony_ci	if (err < 0)
437262306a36Sopenharmony_ci		goto err_free;
437362306a36Sopenharmony_ci
437462306a36Sopenharmony_ci	return rsp;
437562306a36Sopenharmony_ci
437662306a36Sopenharmony_cierr_free:
437762306a36Sopenharmony_ci	ethtool_tsinfo_get_rsp_free(rsp);
437862306a36Sopenharmony_ci	return NULL;
437962306a36Sopenharmony_ci}
438062306a36Sopenharmony_ci
438162306a36Sopenharmony_ci/* ETHTOOL_MSG_TSINFO_GET - dump */
438262306a36Sopenharmony_civoid ethtool_tsinfo_get_list_free(struct ethtool_tsinfo_get_list *rsp)
438362306a36Sopenharmony_ci{
438462306a36Sopenharmony_ci	struct ethtool_tsinfo_get_list *next = rsp;
438562306a36Sopenharmony_ci
438662306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
438762306a36Sopenharmony_ci		rsp = next;
438862306a36Sopenharmony_ci		next = rsp->next;
438962306a36Sopenharmony_ci
439062306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
439162306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.timestamping);
439262306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.tx_types);
439362306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.rx_filters);
439462306a36Sopenharmony_ci		free(rsp);
439562306a36Sopenharmony_ci	}
439662306a36Sopenharmony_ci}
439762306a36Sopenharmony_ci
439862306a36Sopenharmony_cistruct ethtool_tsinfo_get_list *
439962306a36Sopenharmony_ciethtool_tsinfo_get_dump(struct ynl_sock *ys,
440062306a36Sopenharmony_ci			struct ethtool_tsinfo_get_req_dump *req)
440162306a36Sopenharmony_ci{
440262306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
440362306a36Sopenharmony_ci	struct nlmsghdr *nlh;
440462306a36Sopenharmony_ci	int err;
440562306a36Sopenharmony_ci
440662306a36Sopenharmony_ci	yds.ys = ys;
440762306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_tsinfo_get_list);
440862306a36Sopenharmony_ci	yds.cb = ethtool_tsinfo_get_rsp_parse;
440962306a36Sopenharmony_ci	yds.rsp_cmd = 26;
441062306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_tsinfo_nest;
441162306a36Sopenharmony_ci
441262306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_TSINFO_GET, 1);
441362306a36Sopenharmony_ci	ys->req_policy = &ethtool_tsinfo_nest;
441462306a36Sopenharmony_ci
441562306a36Sopenharmony_ci	if (req->_present.header)
441662306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_TSINFO_HEADER, &req->header);
441762306a36Sopenharmony_ci
441862306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
441962306a36Sopenharmony_ci	if (err < 0)
442062306a36Sopenharmony_ci		goto free_list;
442162306a36Sopenharmony_ci
442262306a36Sopenharmony_ci	return yds.first;
442362306a36Sopenharmony_ci
442462306a36Sopenharmony_cifree_list:
442562306a36Sopenharmony_ci	ethtool_tsinfo_get_list_free(yds.first);
442662306a36Sopenharmony_ci	return NULL;
442762306a36Sopenharmony_ci}
442862306a36Sopenharmony_ci
442962306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_CABLE_TEST_ACT ============== */
443062306a36Sopenharmony_ci/* ETHTOOL_MSG_CABLE_TEST_ACT - do */
443162306a36Sopenharmony_civoid ethtool_cable_test_act_req_free(struct ethtool_cable_test_act_req *req)
443262306a36Sopenharmony_ci{
443362306a36Sopenharmony_ci	ethtool_header_free(&req->header);
443462306a36Sopenharmony_ci	free(req);
443562306a36Sopenharmony_ci}
443662306a36Sopenharmony_ci
443762306a36Sopenharmony_ciint ethtool_cable_test_act(struct ynl_sock *ys,
443862306a36Sopenharmony_ci			   struct ethtool_cable_test_act_req *req)
443962306a36Sopenharmony_ci{
444062306a36Sopenharmony_ci	struct nlmsghdr *nlh;
444162306a36Sopenharmony_ci	int err;
444262306a36Sopenharmony_ci
444362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_CABLE_TEST_ACT, 1);
444462306a36Sopenharmony_ci	ys->req_policy = &ethtool_cable_test_nest;
444562306a36Sopenharmony_ci
444662306a36Sopenharmony_ci	if (req->_present.header)
444762306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_CABLE_TEST_HEADER, &req->header);
444862306a36Sopenharmony_ci
444962306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
445062306a36Sopenharmony_ci	if (err < 0)
445162306a36Sopenharmony_ci		return -1;
445262306a36Sopenharmony_ci
445362306a36Sopenharmony_ci	return 0;
445462306a36Sopenharmony_ci}
445562306a36Sopenharmony_ci
445662306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_CABLE_TEST_TDR_ACT ============== */
445762306a36Sopenharmony_ci/* ETHTOOL_MSG_CABLE_TEST_TDR_ACT - do */
445862306a36Sopenharmony_civoid
445962306a36Sopenharmony_ciethtool_cable_test_tdr_act_req_free(struct ethtool_cable_test_tdr_act_req *req)
446062306a36Sopenharmony_ci{
446162306a36Sopenharmony_ci	ethtool_header_free(&req->header);
446262306a36Sopenharmony_ci	free(req);
446362306a36Sopenharmony_ci}
446462306a36Sopenharmony_ci
446562306a36Sopenharmony_ciint ethtool_cable_test_tdr_act(struct ynl_sock *ys,
446662306a36Sopenharmony_ci			       struct ethtool_cable_test_tdr_act_req *req)
446762306a36Sopenharmony_ci{
446862306a36Sopenharmony_ci	struct nlmsghdr *nlh;
446962306a36Sopenharmony_ci	int err;
447062306a36Sopenharmony_ci
447162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_CABLE_TEST_TDR_ACT, 1);
447262306a36Sopenharmony_ci	ys->req_policy = &ethtool_cable_test_tdr_nest;
447362306a36Sopenharmony_ci
447462306a36Sopenharmony_ci	if (req->_present.header)
447562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_CABLE_TEST_TDR_HEADER, &req->header);
447662306a36Sopenharmony_ci
447762306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
447862306a36Sopenharmony_ci	if (err < 0)
447962306a36Sopenharmony_ci		return -1;
448062306a36Sopenharmony_ci
448162306a36Sopenharmony_ci	return 0;
448262306a36Sopenharmony_ci}
448362306a36Sopenharmony_ci
448462306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_TUNNEL_INFO_GET ============== */
448562306a36Sopenharmony_ci/* ETHTOOL_MSG_TUNNEL_INFO_GET - do */
448662306a36Sopenharmony_civoid ethtool_tunnel_info_get_req_free(struct ethtool_tunnel_info_get_req *req)
448762306a36Sopenharmony_ci{
448862306a36Sopenharmony_ci	ethtool_header_free(&req->header);
448962306a36Sopenharmony_ci	free(req);
449062306a36Sopenharmony_ci}
449162306a36Sopenharmony_ci
449262306a36Sopenharmony_civoid ethtool_tunnel_info_get_rsp_free(struct ethtool_tunnel_info_get_rsp *rsp)
449362306a36Sopenharmony_ci{
449462306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
449562306a36Sopenharmony_ci	ethtool_tunnel_udp_free(&rsp->udp_ports);
449662306a36Sopenharmony_ci	free(rsp);
449762306a36Sopenharmony_ci}
449862306a36Sopenharmony_ci
449962306a36Sopenharmony_ciint ethtool_tunnel_info_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
450062306a36Sopenharmony_ci{
450162306a36Sopenharmony_ci	struct ethtool_tunnel_info_get_rsp *dst;
450262306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
450362306a36Sopenharmony_ci	const struct nlattr *attr;
450462306a36Sopenharmony_ci	struct ynl_parse_arg parg;
450562306a36Sopenharmony_ci
450662306a36Sopenharmony_ci	dst = yarg->data;
450762306a36Sopenharmony_ci	parg.ys = yarg->ys;
450862306a36Sopenharmony_ci
450962306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
451062306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
451162306a36Sopenharmony_ci
451262306a36Sopenharmony_ci		if (type == ETHTOOL_A_TUNNEL_INFO_HEADER) {
451362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
451462306a36Sopenharmony_ci				return MNL_CB_ERROR;
451562306a36Sopenharmony_ci			dst->_present.header = 1;
451662306a36Sopenharmony_ci
451762306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
451862306a36Sopenharmony_ci			parg.data = &dst->header;
451962306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
452062306a36Sopenharmony_ci				return MNL_CB_ERROR;
452162306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_TUNNEL_INFO_UDP_PORTS) {
452262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
452362306a36Sopenharmony_ci				return MNL_CB_ERROR;
452462306a36Sopenharmony_ci			dst->_present.udp_ports = 1;
452562306a36Sopenharmony_ci
452662306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_tunnel_udp_nest;
452762306a36Sopenharmony_ci			parg.data = &dst->udp_ports;
452862306a36Sopenharmony_ci			if (ethtool_tunnel_udp_parse(&parg, attr))
452962306a36Sopenharmony_ci				return MNL_CB_ERROR;
453062306a36Sopenharmony_ci		}
453162306a36Sopenharmony_ci	}
453262306a36Sopenharmony_ci
453362306a36Sopenharmony_ci	return MNL_CB_OK;
453462306a36Sopenharmony_ci}
453562306a36Sopenharmony_ci
453662306a36Sopenharmony_cistruct ethtool_tunnel_info_get_rsp *
453762306a36Sopenharmony_ciethtool_tunnel_info_get(struct ynl_sock *ys,
453862306a36Sopenharmony_ci			struct ethtool_tunnel_info_get_req *req)
453962306a36Sopenharmony_ci{
454062306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
454162306a36Sopenharmony_ci	struct ethtool_tunnel_info_get_rsp *rsp;
454262306a36Sopenharmony_ci	struct nlmsghdr *nlh;
454362306a36Sopenharmony_ci	int err;
454462306a36Sopenharmony_ci
454562306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_TUNNEL_INFO_GET, 1);
454662306a36Sopenharmony_ci	ys->req_policy = &ethtool_tunnel_info_nest;
454762306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_tunnel_info_nest;
454862306a36Sopenharmony_ci
454962306a36Sopenharmony_ci	if (req->_present.header)
455062306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_TUNNEL_INFO_HEADER, &req->header);
455162306a36Sopenharmony_ci
455262306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
455362306a36Sopenharmony_ci	yrs.yarg.data = rsp;
455462306a36Sopenharmony_ci	yrs.cb = ethtool_tunnel_info_get_rsp_parse;
455562306a36Sopenharmony_ci	yrs.rsp_cmd = 29;
455662306a36Sopenharmony_ci
455762306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
455862306a36Sopenharmony_ci	if (err < 0)
455962306a36Sopenharmony_ci		goto err_free;
456062306a36Sopenharmony_ci
456162306a36Sopenharmony_ci	return rsp;
456262306a36Sopenharmony_ci
456362306a36Sopenharmony_cierr_free:
456462306a36Sopenharmony_ci	ethtool_tunnel_info_get_rsp_free(rsp);
456562306a36Sopenharmony_ci	return NULL;
456662306a36Sopenharmony_ci}
456762306a36Sopenharmony_ci
456862306a36Sopenharmony_ci/* ETHTOOL_MSG_TUNNEL_INFO_GET - dump */
456962306a36Sopenharmony_civoid
457062306a36Sopenharmony_ciethtool_tunnel_info_get_list_free(struct ethtool_tunnel_info_get_list *rsp)
457162306a36Sopenharmony_ci{
457262306a36Sopenharmony_ci	struct ethtool_tunnel_info_get_list *next = rsp;
457362306a36Sopenharmony_ci
457462306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
457562306a36Sopenharmony_ci		rsp = next;
457662306a36Sopenharmony_ci		next = rsp->next;
457762306a36Sopenharmony_ci
457862306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
457962306a36Sopenharmony_ci		ethtool_tunnel_udp_free(&rsp->obj.udp_ports);
458062306a36Sopenharmony_ci		free(rsp);
458162306a36Sopenharmony_ci	}
458262306a36Sopenharmony_ci}
458362306a36Sopenharmony_ci
458462306a36Sopenharmony_cistruct ethtool_tunnel_info_get_list *
458562306a36Sopenharmony_ciethtool_tunnel_info_get_dump(struct ynl_sock *ys,
458662306a36Sopenharmony_ci			     struct ethtool_tunnel_info_get_req_dump *req)
458762306a36Sopenharmony_ci{
458862306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
458962306a36Sopenharmony_ci	struct nlmsghdr *nlh;
459062306a36Sopenharmony_ci	int err;
459162306a36Sopenharmony_ci
459262306a36Sopenharmony_ci	yds.ys = ys;
459362306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_tunnel_info_get_list);
459462306a36Sopenharmony_ci	yds.cb = ethtool_tunnel_info_get_rsp_parse;
459562306a36Sopenharmony_ci	yds.rsp_cmd = 29;
459662306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_tunnel_info_nest;
459762306a36Sopenharmony_ci
459862306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_TUNNEL_INFO_GET, 1);
459962306a36Sopenharmony_ci	ys->req_policy = &ethtool_tunnel_info_nest;
460062306a36Sopenharmony_ci
460162306a36Sopenharmony_ci	if (req->_present.header)
460262306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_TUNNEL_INFO_HEADER, &req->header);
460362306a36Sopenharmony_ci
460462306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
460562306a36Sopenharmony_ci	if (err < 0)
460662306a36Sopenharmony_ci		goto free_list;
460762306a36Sopenharmony_ci
460862306a36Sopenharmony_ci	return yds.first;
460962306a36Sopenharmony_ci
461062306a36Sopenharmony_cifree_list:
461162306a36Sopenharmony_ci	ethtool_tunnel_info_get_list_free(yds.first);
461262306a36Sopenharmony_ci	return NULL;
461362306a36Sopenharmony_ci}
461462306a36Sopenharmony_ci
461562306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_FEC_GET ============== */
461662306a36Sopenharmony_ci/* ETHTOOL_MSG_FEC_GET - do */
461762306a36Sopenharmony_civoid ethtool_fec_get_req_free(struct ethtool_fec_get_req *req)
461862306a36Sopenharmony_ci{
461962306a36Sopenharmony_ci	ethtool_header_free(&req->header);
462062306a36Sopenharmony_ci	free(req);
462162306a36Sopenharmony_ci}
462262306a36Sopenharmony_ci
462362306a36Sopenharmony_civoid ethtool_fec_get_rsp_free(struct ethtool_fec_get_rsp *rsp)
462462306a36Sopenharmony_ci{
462562306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
462662306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->modes);
462762306a36Sopenharmony_ci	ethtool_fec_stat_free(&rsp->stats);
462862306a36Sopenharmony_ci	free(rsp);
462962306a36Sopenharmony_ci}
463062306a36Sopenharmony_ci
463162306a36Sopenharmony_ciint ethtool_fec_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
463262306a36Sopenharmony_ci{
463362306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
463462306a36Sopenharmony_ci	struct ethtool_fec_get_rsp *dst;
463562306a36Sopenharmony_ci	const struct nlattr *attr;
463662306a36Sopenharmony_ci	struct ynl_parse_arg parg;
463762306a36Sopenharmony_ci
463862306a36Sopenharmony_ci	dst = yarg->data;
463962306a36Sopenharmony_ci	parg.ys = yarg->ys;
464062306a36Sopenharmony_ci
464162306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
464262306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
464362306a36Sopenharmony_ci
464462306a36Sopenharmony_ci		if (type == ETHTOOL_A_FEC_HEADER) {
464562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
464662306a36Sopenharmony_ci				return MNL_CB_ERROR;
464762306a36Sopenharmony_ci			dst->_present.header = 1;
464862306a36Sopenharmony_ci
464962306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
465062306a36Sopenharmony_ci			parg.data = &dst->header;
465162306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
465262306a36Sopenharmony_ci				return MNL_CB_ERROR;
465362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEC_MODES) {
465462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
465562306a36Sopenharmony_ci				return MNL_CB_ERROR;
465662306a36Sopenharmony_ci			dst->_present.modes = 1;
465762306a36Sopenharmony_ci
465862306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_bitset_nest;
465962306a36Sopenharmony_ci			parg.data = &dst->modes;
466062306a36Sopenharmony_ci			if (ethtool_bitset_parse(&parg, attr))
466162306a36Sopenharmony_ci				return MNL_CB_ERROR;
466262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEC_AUTO) {
466362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
466462306a36Sopenharmony_ci				return MNL_CB_ERROR;
466562306a36Sopenharmony_ci			dst->_present.auto_ = 1;
466662306a36Sopenharmony_ci			dst->auto_ = mnl_attr_get_u8(attr);
466762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEC_ACTIVE) {
466862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
466962306a36Sopenharmony_ci				return MNL_CB_ERROR;
467062306a36Sopenharmony_ci			dst->_present.active = 1;
467162306a36Sopenharmony_ci			dst->active = mnl_attr_get_u32(attr);
467262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_FEC_STATS) {
467362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
467462306a36Sopenharmony_ci				return MNL_CB_ERROR;
467562306a36Sopenharmony_ci			dst->_present.stats = 1;
467662306a36Sopenharmony_ci
467762306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_fec_stat_nest;
467862306a36Sopenharmony_ci			parg.data = &dst->stats;
467962306a36Sopenharmony_ci			if (ethtool_fec_stat_parse(&parg, attr))
468062306a36Sopenharmony_ci				return MNL_CB_ERROR;
468162306a36Sopenharmony_ci		}
468262306a36Sopenharmony_ci	}
468362306a36Sopenharmony_ci
468462306a36Sopenharmony_ci	return MNL_CB_OK;
468562306a36Sopenharmony_ci}
468662306a36Sopenharmony_ci
468762306a36Sopenharmony_cistruct ethtool_fec_get_rsp *
468862306a36Sopenharmony_ciethtool_fec_get(struct ynl_sock *ys, struct ethtool_fec_get_req *req)
468962306a36Sopenharmony_ci{
469062306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
469162306a36Sopenharmony_ci	struct ethtool_fec_get_rsp *rsp;
469262306a36Sopenharmony_ci	struct nlmsghdr *nlh;
469362306a36Sopenharmony_ci	int err;
469462306a36Sopenharmony_ci
469562306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_FEC_GET, 1);
469662306a36Sopenharmony_ci	ys->req_policy = &ethtool_fec_nest;
469762306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_fec_nest;
469862306a36Sopenharmony_ci
469962306a36Sopenharmony_ci	if (req->_present.header)
470062306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_FEC_HEADER, &req->header);
470162306a36Sopenharmony_ci
470262306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
470362306a36Sopenharmony_ci	yrs.yarg.data = rsp;
470462306a36Sopenharmony_ci	yrs.cb = ethtool_fec_get_rsp_parse;
470562306a36Sopenharmony_ci	yrs.rsp_cmd = 30;
470662306a36Sopenharmony_ci
470762306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
470862306a36Sopenharmony_ci	if (err < 0)
470962306a36Sopenharmony_ci		goto err_free;
471062306a36Sopenharmony_ci
471162306a36Sopenharmony_ci	return rsp;
471262306a36Sopenharmony_ci
471362306a36Sopenharmony_cierr_free:
471462306a36Sopenharmony_ci	ethtool_fec_get_rsp_free(rsp);
471562306a36Sopenharmony_ci	return NULL;
471662306a36Sopenharmony_ci}
471762306a36Sopenharmony_ci
471862306a36Sopenharmony_ci/* ETHTOOL_MSG_FEC_GET - dump */
471962306a36Sopenharmony_civoid ethtool_fec_get_list_free(struct ethtool_fec_get_list *rsp)
472062306a36Sopenharmony_ci{
472162306a36Sopenharmony_ci	struct ethtool_fec_get_list *next = rsp;
472262306a36Sopenharmony_ci
472362306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
472462306a36Sopenharmony_ci		rsp = next;
472562306a36Sopenharmony_ci		next = rsp->next;
472662306a36Sopenharmony_ci
472762306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
472862306a36Sopenharmony_ci		ethtool_bitset_free(&rsp->obj.modes);
472962306a36Sopenharmony_ci		ethtool_fec_stat_free(&rsp->obj.stats);
473062306a36Sopenharmony_ci		free(rsp);
473162306a36Sopenharmony_ci	}
473262306a36Sopenharmony_ci}
473362306a36Sopenharmony_ci
473462306a36Sopenharmony_cistruct ethtool_fec_get_list *
473562306a36Sopenharmony_ciethtool_fec_get_dump(struct ynl_sock *ys, struct ethtool_fec_get_req_dump *req)
473662306a36Sopenharmony_ci{
473762306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
473862306a36Sopenharmony_ci	struct nlmsghdr *nlh;
473962306a36Sopenharmony_ci	int err;
474062306a36Sopenharmony_ci
474162306a36Sopenharmony_ci	yds.ys = ys;
474262306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_fec_get_list);
474362306a36Sopenharmony_ci	yds.cb = ethtool_fec_get_rsp_parse;
474462306a36Sopenharmony_ci	yds.rsp_cmd = 30;
474562306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_fec_nest;
474662306a36Sopenharmony_ci
474762306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_FEC_GET, 1);
474862306a36Sopenharmony_ci	ys->req_policy = &ethtool_fec_nest;
474962306a36Sopenharmony_ci
475062306a36Sopenharmony_ci	if (req->_present.header)
475162306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_FEC_HEADER, &req->header);
475262306a36Sopenharmony_ci
475362306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
475462306a36Sopenharmony_ci	if (err < 0)
475562306a36Sopenharmony_ci		goto free_list;
475662306a36Sopenharmony_ci
475762306a36Sopenharmony_ci	return yds.first;
475862306a36Sopenharmony_ci
475962306a36Sopenharmony_cifree_list:
476062306a36Sopenharmony_ci	ethtool_fec_get_list_free(yds.first);
476162306a36Sopenharmony_ci	return NULL;
476262306a36Sopenharmony_ci}
476362306a36Sopenharmony_ci
476462306a36Sopenharmony_ci/* ETHTOOL_MSG_FEC_GET - notify */
476562306a36Sopenharmony_civoid ethtool_fec_get_ntf_free(struct ethtool_fec_get_ntf *rsp)
476662306a36Sopenharmony_ci{
476762306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
476862306a36Sopenharmony_ci	ethtool_bitset_free(&rsp->obj.modes);
476962306a36Sopenharmony_ci	ethtool_fec_stat_free(&rsp->obj.stats);
477062306a36Sopenharmony_ci	free(rsp);
477162306a36Sopenharmony_ci}
477262306a36Sopenharmony_ci
477362306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_FEC_SET ============== */
477462306a36Sopenharmony_ci/* ETHTOOL_MSG_FEC_SET - do */
477562306a36Sopenharmony_civoid ethtool_fec_set_req_free(struct ethtool_fec_set_req *req)
477662306a36Sopenharmony_ci{
477762306a36Sopenharmony_ci	ethtool_header_free(&req->header);
477862306a36Sopenharmony_ci	ethtool_bitset_free(&req->modes);
477962306a36Sopenharmony_ci	ethtool_fec_stat_free(&req->stats);
478062306a36Sopenharmony_ci	free(req);
478162306a36Sopenharmony_ci}
478262306a36Sopenharmony_ci
478362306a36Sopenharmony_ciint ethtool_fec_set(struct ynl_sock *ys, struct ethtool_fec_set_req *req)
478462306a36Sopenharmony_ci{
478562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
478662306a36Sopenharmony_ci	int err;
478762306a36Sopenharmony_ci
478862306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_FEC_SET, 1);
478962306a36Sopenharmony_ci	ys->req_policy = &ethtool_fec_nest;
479062306a36Sopenharmony_ci
479162306a36Sopenharmony_ci	if (req->_present.header)
479262306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_FEC_HEADER, &req->header);
479362306a36Sopenharmony_ci	if (req->_present.modes)
479462306a36Sopenharmony_ci		ethtool_bitset_put(nlh, ETHTOOL_A_FEC_MODES, &req->modes);
479562306a36Sopenharmony_ci	if (req->_present.auto_)
479662306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_FEC_AUTO, req->auto_);
479762306a36Sopenharmony_ci	if (req->_present.active)
479862306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_FEC_ACTIVE, req->active);
479962306a36Sopenharmony_ci	if (req->_present.stats)
480062306a36Sopenharmony_ci		ethtool_fec_stat_put(nlh, ETHTOOL_A_FEC_STATS, &req->stats);
480162306a36Sopenharmony_ci
480262306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
480362306a36Sopenharmony_ci	if (err < 0)
480462306a36Sopenharmony_ci		return -1;
480562306a36Sopenharmony_ci
480662306a36Sopenharmony_ci	return 0;
480762306a36Sopenharmony_ci}
480862306a36Sopenharmony_ci
480962306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_MODULE_EEPROM_GET ============== */
481062306a36Sopenharmony_ci/* ETHTOOL_MSG_MODULE_EEPROM_GET - do */
481162306a36Sopenharmony_civoid
481262306a36Sopenharmony_ciethtool_module_eeprom_get_req_free(struct ethtool_module_eeprom_get_req *req)
481362306a36Sopenharmony_ci{
481462306a36Sopenharmony_ci	ethtool_header_free(&req->header);
481562306a36Sopenharmony_ci	free(req);
481662306a36Sopenharmony_ci}
481762306a36Sopenharmony_ci
481862306a36Sopenharmony_civoid
481962306a36Sopenharmony_ciethtool_module_eeprom_get_rsp_free(struct ethtool_module_eeprom_get_rsp *rsp)
482062306a36Sopenharmony_ci{
482162306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
482262306a36Sopenharmony_ci	free(rsp->data);
482362306a36Sopenharmony_ci	free(rsp);
482462306a36Sopenharmony_ci}
482562306a36Sopenharmony_ci
482662306a36Sopenharmony_ciint ethtool_module_eeprom_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
482762306a36Sopenharmony_ci{
482862306a36Sopenharmony_ci	struct ethtool_module_eeprom_get_rsp *dst;
482962306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
483062306a36Sopenharmony_ci	const struct nlattr *attr;
483162306a36Sopenharmony_ci	struct ynl_parse_arg parg;
483262306a36Sopenharmony_ci
483362306a36Sopenharmony_ci	dst = yarg->data;
483462306a36Sopenharmony_ci	parg.ys = yarg->ys;
483562306a36Sopenharmony_ci
483662306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
483762306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
483862306a36Sopenharmony_ci
483962306a36Sopenharmony_ci		if (type == ETHTOOL_A_MODULE_EEPROM_HEADER) {
484062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
484162306a36Sopenharmony_ci				return MNL_CB_ERROR;
484262306a36Sopenharmony_ci			dst->_present.header = 1;
484362306a36Sopenharmony_ci
484462306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
484562306a36Sopenharmony_ci			parg.data = &dst->header;
484662306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
484762306a36Sopenharmony_ci				return MNL_CB_ERROR;
484862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MODULE_EEPROM_OFFSET) {
484962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
485062306a36Sopenharmony_ci				return MNL_CB_ERROR;
485162306a36Sopenharmony_ci			dst->_present.offset = 1;
485262306a36Sopenharmony_ci			dst->offset = mnl_attr_get_u32(attr);
485362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MODULE_EEPROM_LENGTH) {
485462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
485562306a36Sopenharmony_ci				return MNL_CB_ERROR;
485662306a36Sopenharmony_ci			dst->_present.length = 1;
485762306a36Sopenharmony_ci			dst->length = mnl_attr_get_u32(attr);
485862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MODULE_EEPROM_PAGE) {
485962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
486062306a36Sopenharmony_ci				return MNL_CB_ERROR;
486162306a36Sopenharmony_ci			dst->_present.page = 1;
486262306a36Sopenharmony_ci			dst->page = mnl_attr_get_u8(attr);
486362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MODULE_EEPROM_BANK) {
486462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
486562306a36Sopenharmony_ci				return MNL_CB_ERROR;
486662306a36Sopenharmony_ci			dst->_present.bank = 1;
486762306a36Sopenharmony_ci			dst->bank = mnl_attr_get_u8(attr);
486862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS) {
486962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
487062306a36Sopenharmony_ci				return MNL_CB_ERROR;
487162306a36Sopenharmony_ci			dst->_present.i2c_address = 1;
487262306a36Sopenharmony_ci			dst->i2c_address = mnl_attr_get_u8(attr);
487362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MODULE_EEPROM_DATA) {
487462306a36Sopenharmony_ci			unsigned int len;
487562306a36Sopenharmony_ci
487662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
487762306a36Sopenharmony_ci				return MNL_CB_ERROR;
487862306a36Sopenharmony_ci
487962306a36Sopenharmony_ci			len = mnl_attr_get_payload_len(attr);
488062306a36Sopenharmony_ci			dst->_present.data_len = len;
488162306a36Sopenharmony_ci			dst->data = malloc(len);
488262306a36Sopenharmony_ci			memcpy(dst->data, mnl_attr_get_payload(attr), len);
488362306a36Sopenharmony_ci		}
488462306a36Sopenharmony_ci	}
488562306a36Sopenharmony_ci
488662306a36Sopenharmony_ci	return MNL_CB_OK;
488762306a36Sopenharmony_ci}
488862306a36Sopenharmony_ci
488962306a36Sopenharmony_cistruct ethtool_module_eeprom_get_rsp *
489062306a36Sopenharmony_ciethtool_module_eeprom_get(struct ynl_sock *ys,
489162306a36Sopenharmony_ci			  struct ethtool_module_eeprom_get_req *req)
489262306a36Sopenharmony_ci{
489362306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
489462306a36Sopenharmony_ci	struct ethtool_module_eeprom_get_rsp *rsp;
489562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
489662306a36Sopenharmony_ci	int err;
489762306a36Sopenharmony_ci
489862306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MODULE_EEPROM_GET, 1);
489962306a36Sopenharmony_ci	ys->req_policy = &ethtool_module_eeprom_nest;
490062306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_module_eeprom_nest;
490162306a36Sopenharmony_ci
490262306a36Sopenharmony_ci	if (req->_present.header)
490362306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_MODULE_EEPROM_HEADER, &req->header);
490462306a36Sopenharmony_ci
490562306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
490662306a36Sopenharmony_ci	yrs.yarg.data = rsp;
490762306a36Sopenharmony_ci	yrs.cb = ethtool_module_eeprom_get_rsp_parse;
490862306a36Sopenharmony_ci	yrs.rsp_cmd = 32;
490962306a36Sopenharmony_ci
491062306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
491162306a36Sopenharmony_ci	if (err < 0)
491262306a36Sopenharmony_ci		goto err_free;
491362306a36Sopenharmony_ci
491462306a36Sopenharmony_ci	return rsp;
491562306a36Sopenharmony_ci
491662306a36Sopenharmony_cierr_free:
491762306a36Sopenharmony_ci	ethtool_module_eeprom_get_rsp_free(rsp);
491862306a36Sopenharmony_ci	return NULL;
491962306a36Sopenharmony_ci}
492062306a36Sopenharmony_ci
492162306a36Sopenharmony_ci/* ETHTOOL_MSG_MODULE_EEPROM_GET - dump */
492262306a36Sopenharmony_civoid
492362306a36Sopenharmony_ciethtool_module_eeprom_get_list_free(struct ethtool_module_eeprom_get_list *rsp)
492462306a36Sopenharmony_ci{
492562306a36Sopenharmony_ci	struct ethtool_module_eeprom_get_list *next = rsp;
492662306a36Sopenharmony_ci
492762306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
492862306a36Sopenharmony_ci		rsp = next;
492962306a36Sopenharmony_ci		next = rsp->next;
493062306a36Sopenharmony_ci
493162306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
493262306a36Sopenharmony_ci		free(rsp->obj.data);
493362306a36Sopenharmony_ci		free(rsp);
493462306a36Sopenharmony_ci	}
493562306a36Sopenharmony_ci}
493662306a36Sopenharmony_ci
493762306a36Sopenharmony_cistruct ethtool_module_eeprom_get_list *
493862306a36Sopenharmony_ciethtool_module_eeprom_get_dump(struct ynl_sock *ys,
493962306a36Sopenharmony_ci			       struct ethtool_module_eeprom_get_req_dump *req)
494062306a36Sopenharmony_ci{
494162306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
494262306a36Sopenharmony_ci	struct nlmsghdr *nlh;
494362306a36Sopenharmony_ci	int err;
494462306a36Sopenharmony_ci
494562306a36Sopenharmony_ci	yds.ys = ys;
494662306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_module_eeprom_get_list);
494762306a36Sopenharmony_ci	yds.cb = ethtool_module_eeprom_get_rsp_parse;
494862306a36Sopenharmony_ci	yds.rsp_cmd = 32;
494962306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_module_eeprom_nest;
495062306a36Sopenharmony_ci
495162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_MODULE_EEPROM_GET, 1);
495262306a36Sopenharmony_ci	ys->req_policy = &ethtool_module_eeprom_nest;
495362306a36Sopenharmony_ci
495462306a36Sopenharmony_ci	if (req->_present.header)
495562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_MODULE_EEPROM_HEADER, &req->header);
495662306a36Sopenharmony_ci
495762306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
495862306a36Sopenharmony_ci	if (err < 0)
495962306a36Sopenharmony_ci		goto free_list;
496062306a36Sopenharmony_ci
496162306a36Sopenharmony_ci	return yds.first;
496262306a36Sopenharmony_ci
496362306a36Sopenharmony_cifree_list:
496462306a36Sopenharmony_ci	ethtool_module_eeprom_get_list_free(yds.first);
496562306a36Sopenharmony_ci	return NULL;
496662306a36Sopenharmony_ci}
496762306a36Sopenharmony_ci
496862306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PHC_VCLOCKS_GET ============== */
496962306a36Sopenharmony_ci/* ETHTOOL_MSG_PHC_VCLOCKS_GET - do */
497062306a36Sopenharmony_civoid ethtool_phc_vclocks_get_req_free(struct ethtool_phc_vclocks_get_req *req)
497162306a36Sopenharmony_ci{
497262306a36Sopenharmony_ci	ethtool_header_free(&req->header);
497362306a36Sopenharmony_ci	free(req);
497462306a36Sopenharmony_ci}
497562306a36Sopenharmony_ci
497662306a36Sopenharmony_civoid ethtool_phc_vclocks_get_rsp_free(struct ethtool_phc_vclocks_get_rsp *rsp)
497762306a36Sopenharmony_ci{
497862306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
497962306a36Sopenharmony_ci	free(rsp);
498062306a36Sopenharmony_ci}
498162306a36Sopenharmony_ci
498262306a36Sopenharmony_ciint ethtool_phc_vclocks_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
498362306a36Sopenharmony_ci{
498462306a36Sopenharmony_ci	struct ethtool_phc_vclocks_get_rsp *dst;
498562306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
498662306a36Sopenharmony_ci	const struct nlattr *attr;
498762306a36Sopenharmony_ci	struct ynl_parse_arg parg;
498862306a36Sopenharmony_ci
498962306a36Sopenharmony_ci	dst = yarg->data;
499062306a36Sopenharmony_ci	parg.ys = yarg->ys;
499162306a36Sopenharmony_ci
499262306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
499362306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
499462306a36Sopenharmony_ci
499562306a36Sopenharmony_ci		if (type == ETHTOOL_A_PHC_VCLOCKS_HEADER) {
499662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
499762306a36Sopenharmony_ci				return MNL_CB_ERROR;
499862306a36Sopenharmony_ci			dst->_present.header = 1;
499962306a36Sopenharmony_ci
500062306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
500162306a36Sopenharmony_ci			parg.data = &dst->header;
500262306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
500362306a36Sopenharmony_ci				return MNL_CB_ERROR;
500462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PHC_VCLOCKS_NUM) {
500562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
500662306a36Sopenharmony_ci				return MNL_CB_ERROR;
500762306a36Sopenharmony_ci			dst->_present.num = 1;
500862306a36Sopenharmony_ci			dst->num = mnl_attr_get_u32(attr);
500962306a36Sopenharmony_ci		}
501062306a36Sopenharmony_ci	}
501162306a36Sopenharmony_ci
501262306a36Sopenharmony_ci	return MNL_CB_OK;
501362306a36Sopenharmony_ci}
501462306a36Sopenharmony_ci
501562306a36Sopenharmony_cistruct ethtool_phc_vclocks_get_rsp *
501662306a36Sopenharmony_ciethtool_phc_vclocks_get(struct ynl_sock *ys,
501762306a36Sopenharmony_ci			struct ethtool_phc_vclocks_get_req *req)
501862306a36Sopenharmony_ci{
501962306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
502062306a36Sopenharmony_ci	struct ethtool_phc_vclocks_get_rsp *rsp;
502162306a36Sopenharmony_ci	struct nlmsghdr *nlh;
502262306a36Sopenharmony_ci	int err;
502362306a36Sopenharmony_ci
502462306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PHC_VCLOCKS_GET, 1);
502562306a36Sopenharmony_ci	ys->req_policy = &ethtool_phc_vclocks_nest;
502662306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_phc_vclocks_nest;
502762306a36Sopenharmony_ci
502862306a36Sopenharmony_ci	if (req->_present.header)
502962306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PHC_VCLOCKS_HEADER, &req->header);
503062306a36Sopenharmony_ci
503162306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
503262306a36Sopenharmony_ci	yrs.yarg.data = rsp;
503362306a36Sopenharmony_ci	yrs.cb = ethtool_phc_vclocks_get_rsp_parse;
503462306a36Sopenharmony_ci	yrs.rsp_cmd = 34;
503562306a36Sopenharmony_ci
503662306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
503762306a36Sopenharmony_ci	if (err < 0)
503862306a36Sopenharmony_ci		goto err_free;
503962306a36Sopenharmony_ci
504062306a36Sopenharmony_ci	return rsp;
504162306a36Sopenharmony_ci
504262306a36Sopenharmony_cierr_free:
504362306a36Sopenharmony_ci	ethtool_phc_vclocks_get_rsp_free(rsp);
504462306a36Sopenharmony_ci	return NULL;
504562306a36Sopenharmony_ci}
504662306a36Sopenharmony_ci
504762306a36Sopenharmony_ci/* ETHTOOL_MSG_PHC_VCLOCKS_GET - dump */
504862306a36Sopenharmony_civoid
504962306a36Sopenharmony_ciethtool_phc_vclocks_get_list_free(struct ethtool_phc_vclocks_get_list *rsp)
505062306a36Sopenharmony_ci{
505162306a36Sopenharmony_ci	struct ethtool_phc_vclocks_get_list *next = rsp;
505262306a36Sopenharmony_ci
505362306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
505462306a36Sopenharmony_ci		rsp = next;
505562306a36Sopenharmony_ci		next = rsp->next;
505662306a36Sopenharmony_ci
505762306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
505862306a36Sopenharmony_ci		free(rsp);
505962306a36Sopenharmony_ci	}
506062306a36Sopenharmony_ci}
506162306a36Sopenharmony_ci
506262306a36Sopenharmony_cistruct ethtool_phc_vclocks_get_list *
506362306a36Sopenharmony_ciethtool_phc_vclocks_get_dump(struct ynl_sock *ys,
506462306a36Sopenharmony_ci			     struct ethtool_phc_vclocks_get_req_dump *req)
506562306a36Sopenharmony_ci{
506662306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
506762306a36Sopenharmony_ci	struct nlmsghdr *nlh;
506862306a36Sopenharmony_ci	int err;
506962306a36Sopenharmony_ci
507062306a36Sopenharmony_ci	yds.ys = ys;
507162306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_phc_vclocks_get_list);
507262306a36Sopenharmony_ci	yds.cb = ethtool_phc_vclocks_get_rsp_parse;
507362306a36Sopenharmony_ci	yds.rsp_cmd = 34;
507462306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_phc_vclocks_nest;
507562306a36Sopenharmony_ci
507662306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PHC_VCLOCKS_GET, 1);
507762306a36Sopenharmony_ci	ys->req_policy = &ethtool_phc_vclocks_nest;
507862306a36Sopenharmony_ci
507962306a36Sopenharmony_ci	if (req->_present.header)
508062306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PHC_VCLOCKS_HEADER, &req->header);
508162306a36Sopenharmony_ci
508262306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
508362306a36Sopenharmony_ci	if (err < 0)
508462306a36Sopenharmony_ci		goto free_list;
508562306a36Sopenharmony_ci
508662306a36Sopenharmony_ci	return yds.first;
508762306a36Sopenharmony_ci
508862306a36Sopenharmony_cifree_list:
508962306a36Sopenharmony_ci	ethtool_phc_vclocks_get_list_free(yds.first);
509062306a36Sopenharmony_ci	return NULL;
509162306a36Sopenharmony_ci}
509262306a36Sopenharmony_ci
509362306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_MODULE_GET ============== */
509462306a36Sopenharmony_ci/* ETHTOOL_MSG_MODULE_GET - do */
509562306a36Sopenharmony_civoid ethtool_module_get_req_free(struct ethtool_module_get_req *req)
509662306a36Sopenharmony_ci{
509762306a36Sopenharmony_ci	ethtool_header_free(&req->header);
509862306a36Sopenharmony_ci	free(req);
509962306a36Sopenharmony_ci}
510062306a36Sopenharmony_ci
510162306a36Sopenharmony_civoid ethtool_module_get_rsp_free(struct ethtool_module_get_rsp *rsp)
510262306a36Sopenharmony_ci{
510362306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
510462306a36Sopenharmony_ci	free(rsp);
510562306a36Sopenharmony_ci}
510662306a36Sopenharmony_ci
510762306a36Sopenharmony_ciint ethtool_module_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
510862306a36Sopenharmony_ci{
510962306a36Sopenharmony_ci	struct ethtool_module_get_rsp *dst;
511062306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
511162306a36Sopenharmony_ci	const struct nlattr *attr;
511262306a36Sopenharmony_ci	struct ynl_parse_arg parg;
511362306a36Sopenharmony_ci
511462306a36Sopenharmony_ci	dst = yarg->data;
511562306a36Sopenharmony_ci	parg.ys = yarg->ys;
511662306a36Sopenharmony_ci
511762306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
511862306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
511962306a36Sopenharmony_ci
512062306a36Sopenharmony_ci		if (type == ETHTOOL_A_MODULE_HEADER) {
512162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
512262306a36Sopenharmony_ci				return MNL_CB_ERROR;
512362306a36Sopenharmony_ci			dst->_present.header = 1;
512462306a36Sopenharmony_ci
512562306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
512662306a36Sopenharmony_ci			parg.data = &dst->header;
512762306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
512862306a36Sopenharmony_ci				return MNL_CB_ERROR;
512962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MODULE_POWER_MODE_POLICY) {
513062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
513162306a36Sopenharmony_ci				return MNL_CB_ERROR;
513262306a36Sopenharmony_ci			dst->_present.power_mode_policy = 1;
513362306a36Sopenharmony_ci			dst->power_mode_policy = mnl_attr_get_u8(attr);
513462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MODULE_POWER_MODE) {
513562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
513662306a36Sopenharmony_ci				return MNL_CB_ERROR;
513762306a36Sopenharmony_ci			dst->_present.power_mode = 1;
513862306a36Sopenharmony_ci			dst->power_mode = mnl_attr_get_u8(attr);
513962306a36Sopenharmony_ci		}
514062306a36Sopenharmony_ci	}
514162306a36Sopenharmony_ci
514262306a36Sopenharmony_ci	return MNL_CB_OK;
514362306a36Sopenharmony_ci}
514462306a36Sopenharmony_ci
514562306a36Sopenharmony_cistruct ethtool_module_get_rsp *
514662306a36Sopenharmony_ciethtool_module_get(struct ynl_sock *ys, struct ethtool_module_get_req *req)
514762306a36Sopenharmony_ci{
514862306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
514962306a36Sopenharmony_ci	struct ethtool_module_get_rsp *rsp;
515062306a36Sopenharmony_ci	struct nlmsghdr *nlh;
515162306a36Sopenharmony_ci	int err;
515262306a36Sopenharmony_ci
515362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MODULE_GET, 1);
515462306a36Sopenharmony_ci	ys->req_policy = &ethtool_module_nest;
515562306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_module_nest;
515662306a36Sopenharmony_ci
515762306a36Sopenharmony_ci	if (req->_present.header)
515862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_MODULE_HEADER, &req->header);
515962306a36Sopenharmony_ci
516062306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
516162306a36Sopenharmony_ci	yrs.yarg.data = rsp;
516262306a36Sopenharmony_ci	yrs.cb = ethtool_module_get_rsp_parse;
516362306a36Sopenharmony_ci	yrs.rsp_cmd = 35;
516462306a36Sopenharmony_ci
516562306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
516662306a36Sopenharmony_ci	if (err < 0)
516762306a36Sopenharmony_ci		goto err_free;
516862306a36Sopenharmony_ci
516962306a36Sopenharmony_ci	return rsp;
517062306a36Sopenharmony_ci
517162306a36Sopenharmony_cierr_free:
517262306a36Sopenharmony_ci	ethtool_module_get_rsp_free(rsp);
517362306a36Sopenharmony_ci	return NULL;
517462306a36Sopenharmony_ci}
517562306a36Sopenharmony_ci
517662306a36Sopenharmony_ci/* ETHTOOL_MSG_MODULE_GET - dump */
517762306a36Sopenharmony_civoid ethtool_module_get_list_free(struct ethtool_module_get_list *rsp)
517862306a36Sopenharmony_ci{
517962306a36Sopenharmony_ci	struct ethtool_module_get_list *next = rsp;
518062306a36Sopenharmony_ci
518162306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
518262306a36Sopenharmony_ci		rsp = next;
518362306a36Sopenharmony_ci		next = rsp->next;
518462306a36Sopenharmony_ci
518562306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
518662306a36Sopenharmony_ci		free(rsp);
518762306a36Sopenharmony_ci	}
518862306a36Sopenharmony_ci}
518962306a36Sopenharmony_ci
519062306a36Sopenharmony_cistruct ethtool_module_get_list *
519162306a36Sopenharmony_ciethtool_module_get_dump(struct ynl_sock *ys,
519262306a36Sopenharmony_ci			struct ethtool_module_get_req_dump *req)
519362306a36Sopenharmony_ci{
519462306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
519562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
519662306a36Sopenharmony_ci	int err;
519762306a36Sopenharmony_ci
519862306a36Sopenharmony_ci	yds.ys = ys;
519962306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_module_get_list);
520062306a36Sopenharmony_ci	yds.cb = ethtool_module_get_rsp_parse;
520162306a36Sopenharmony_ci	yds.rsp_cmd = 35;
520262306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_module_nest;
520362306a36Sopenharmony_ci
520462306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_MODULE_GET, 1);
520562306a36Sopenharmony_ci	ys->req_policy = &ethtool_module_nest;
520662306a36Sopenharmony_ci
520762306a36Sopenharmony_ci	if (req->_present.header)
520862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_MODULE_HEADER, &req->header);
520962306a36Sopenharmony_ci
521062306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
521162306a36Sopenharmony_ci	if (err < 0)
521262306a36Sopenharmony_ci		goto free_list;
521362306a36Sopenharmony_ci
521462306a36Sopenharmony_ci	return yds.first;
521562306a36Sopenharmony_ci
521662306a36Sopenharmony_cifree_list:
521762306a36Sopenharmony_ci	ethtool_module_get_list_free(yds.first);
521862306a36Sopenharmony_ci	return NULL;
521962306a36Sopenharmony_ci}
522062306a36Sopenharmony_ci
522162306a36Sopenharmony_ci/* ETHTOOL_MSG_MODULE_GET - notify */
522262306a36Sopenharmony_civoid ethtool_module_get_ntf_free(struct ethtool_module_get_ntf *rsp)
522362306a36Sopenharmony_ci{
522462306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
522562306a36Sopenharmony_ci	free(rsp);
522662306a36Sopenharmony_ci}
522762306a36Sopenharmony_ci
522862306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_MODULE_SET ============== */
522962306a36Sopenharmony_ci/* ETHTOOL_MSG_MODULE_SET - do */
523062306a36Sopenharmony_civoid ethtool_module_set_req_free(struct ethtool_module_set_req *req)
523162306a36Sopenharmony_ci{
523262306a36Sopenharmony_ci	ethtool_header_free(&req->header);
523362306a36Sopenharmony_ci	free(req);
523462306a36Sopenharmony_ci}
523562306a36Sopenharmony_ci
523662306a36Sopenharmony_ciint ethtool_module_set(struct ynl_sock *ys, struct ethtool_module_set_req *req)
523762306a36Sopenharmony_ci{
523862306a36Sopenharmony_ci	struct nlmsghdr *nlh;
523962306a36Sopenharmony_ci	int err;
524062306a36Sopenharmony_ci
524162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MODULE_SET, 1);
524262306a36Sopenharmony_ci	ys->req_policy = &ethtool_module_nest;
524362306a36Sopenharmony_ci
524462306a36Sopenharmony_ci	if (req->_present.header)
524562306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_MODULE_HEADER, &req->header);
524662306a36Sopenharmony_ci	if (req->_present.power_mode_policy)
524762306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_MODULE_POWER_MODE_POLICY, req->power_mode_policy);
524862306a36Sopenharmony_ci	if (req->_present.power_mode)
524962306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_MODULE_POWER_MODE, req->power_mode);
525062306a36Sopenharmony_ci
525162306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
525262306a36Sopenharmony_ci	if (err < 0)
525362306a36Sopenharmony_ci		return -1;
525462306a36Sopenharmony_ci
525562306a36Sopenharmony_ci	return 0;
525662306a36Sopenharmony_ci}
525762306a36Sopenharmony_ci
525862306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PSE_GET ============== */
525962306a36Sopenharmony_ci/* ETHTOOL_MSG_PSE_GET - do */
526062306a36Sopenharmony_civoid ethtool_pse_get_req_free(struct ethtool_pse_get_req *req)
526162306a36Sopenharmony_ci{
526262306a36Sopenharmony_ci	ethtool_header_free(&req->header);
526362306a36Sopenharmony_ci	free(req);
526462306a36Sopenharmony_ci}
526562306a36Sopenharmony_ci
526662306a36Sopenharmony_civoid ethtool_pse_get_rsp_free(struct ethtool_pse_get_rsp *rsp)
526762306a36Sopenharmony_ci{
526862306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
526962306a36Sopenharmony_ci	free(rsp);
527062306a36Sopenharmony_ci}
527162306a36Sopenharmony_ci
527262306a36Sopenharmony_ciint ethtool_pse_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
527362306a36Sopenharmony_ci{
527462306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
527562306a36Sopenharmony_ci	struct ethtool_pse_get_rsp *dst;
527662306a36Sopenharmony_ci	const struct nlattr *attr;
527762306a36Sopenharmony_ci	struct ynl_parse_arg parg;
527862306a36Sopenharmony_ci
527962306a36Sopenharmony_ci	dst = yarg->data;
528062306a36Sopenharmony_ci	parg.ys = yarg->ys;
528162306a36Sopenharmony_ci
528262306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
528362306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
528462306a36Sopenharmony_ci
528562306a36Sopenharmony_ci		if (type == ETHTOOL_A_PSE_HEADER) {
528662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
528762306a36Sopenharmony_ci				return MNL_CB_ERROR;
528862306a36Sopenharmony_ci			dst->_present.header = 1;
528962306a36Sopenharmony_ci
529062306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
529162306a36Sopenharmony_ci			parg.data = &dst->header;
529262306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
529362306a36Sopenharmony_ci				return MNL_CB_ERROR;
529462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PODL_PSE_ADMIN_STATE) {
529562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
529662306a36Sopenharmony_ci				return MNL_CB_ERROR;
529762306a36Sopenharmony_ci			dst->_present.admin_state = 1;
529862306a36Sopenharmony_ci			dst->admin_state = mnl_attr_get_u32(attr);
529962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PODL_PSE_ADMIN_CONTROL) {
530062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
530162306a36Sopenharmony_ci				return MNL_CB_ERROR;
530262306a36Sopenharmony_ci			dst->_present.admin_control = 1;
530362306a36Sopenharmony_ci			dst->admin_control = mnl_attr_get_u32(attr);
530462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PODL_PSE_PW_D_STATUS) {
530562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
530662306a36Sopenharmony_ci				return MNL_CB_ERROR;
530762306a36Sopenharmony_ci			dst->_present.pw_d_status = 1;
530862306a36Sopenharmony_ci			dst->pw_d_status = mnl_attr_get_u32(attr);
530962306a36Sopenharmony_ci		}
531062306a36Sopenharmony_ci	}
531162306a36Sopenharmony_ci
531262306a36Sopenharmony_ci	return MNL_CB_OK;
531362306a36Sopenharmony_ci}
531462306a36Sopenharmony_ci
531562306a36Sopenharmony_cistruct ethtool_pse_get_rsp *
531662306a36Sopenharmony_ciethtool_pse_get(struct ynl_sock *ys, struct ethtool_pse_get_req *req)
531762306a36Sopenharmony_ci{
531862306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
531962306a36Sopenharmony_ci	struct ethtool_pse_get_rsp *rsp;
532062306a36Sopenharmony_ci	struct nlmsghdr *nlh;
532162306a36Sopenharmony_ci	int err;
532262306a36Sopenharmony_ci
532362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PSE_GET, 1);
532462306a36Sopenharmony_ci	ys->req_policy = &ethtool_pse_nest;
532562306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_pse_nest;
532662306a36Sopenharmony_ci
532762306a36Sopenharmony_ci	if (req->_present.header)
532862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PSE_HEADER, &req->header);
532962306a36Sopenharmony_ci
533062306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
533162306a36Sopenharmony_ci	yrs.yarg.data = rsp;
533262306a36Sopenharmony_ci	yrs.cb = ethtool_pse_get_rsp_parse;
533362306a36Sopenharmony_ci	yrs.rsp_cmd = 37;
533462306a36Sopenharmony_ci
533562306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
533662306a36Sopenharmony_ci	if (err < 0)
533762306a36Sopenharmony_ci		goto err_free;
533862306a36Sopenharmony_ci
533962306a36Sopenharmony_ci	return rsp;
534062306a36Sopenharmony_ci
534162306a36Sopenharmony_cierr_free:
534262306a36Sopenharmony_ci	ethtool_pse_get_rsp_free(rsp);
534362306a36Sopenharmony_ci	return NULL;
534462306a36Sopenharmony_ci}
534562306a36Sopenharmony_ci
534662306a36Sopenharmony_ci/* ETHTOOL_MSG_PSE_GET - dump */
534762306a36Sopenharmony_civoid ethtool_pse_get_list_free(struct ethtool_pse_get_list *rsp)
534862306a36Sopenharmony_ci{
534962306a36Sopenharmony_ci	struct ethtool_pse_get_list *next = rsp;
535062306a36Sopenharmony_ci
535162306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
535262306a36Sopenharmony_ci		rsp = next;
535362306a36Sopenharmony_ci		next = rsp->next;
535462306a36Sopenharmony_ci
535562306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
535662306a36Sopenharmony_ci		free(rsp);
535762306a36Sopenharmony_ci	}
535862306a36Sopenharmony_ci}
535962306a36Sopenharmony_ci
536062306a36Sopenharmony_cistruct ethtool_pse_get_list *
536162306a36Sopenharmony_ciethtool_pse_get_dump(struct ynl_sock *ys, struct ethtool_pse_get_req_dump *req)
536262306a36Sopenharmony_ci{
536362306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
536462306a36Sopenharmony_ci	struct nlmsghdr *nlh;
536562306a36Sopenharmony_ci	int err;
536662306a36Sopenharmony_ci
536762306a36Sopenharmony_ci	yds.ys = ys;
536862306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_pse_get_list);
536962306a36Sopenharmony_ci	yds.cb = ethtool_pse_get_rsp_parse;
537062306a36Sopenharmony_ci	yds.rsp_cmd = 37;
537162306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_pse_nest;
537262306a36Sopenharmony_ci
537362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PSE_GET, 1);
537462306a36Sopenharmony_ci	ys->req_policy = &ethtool_pse_nest;
537562306a36Sopenharmony_ci
537662306a36Sopenharmony_ci	if (req->_present.header)
537762306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PSE_HEADER, &req->header);
537862306a36Sopenharmony_ci
537962306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
538062306a36Sopenharmony_ci	if (err < 0)
538162306a36Sopenharmony_ci		goto free_list;
538262306a36Sopenharmony_ci
538362306a36Sopenharmony_ci	return yds.first;
538462306a36Sopenharmony_ci
538562306a36Sopenharmony_cifree_list:
538662306a36Sopenharmony_ci	ethtool_pse_get_list_free(yds.first);
538762306a36Sopenharmony_ci	return NULL;
538862306a36Sopenharmony_ci}
538962306a36Sopenharmony_ci
539062306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PSE_SET ============== */
539162306a36Sopenharmony_ci/* ETHTOOL_MSG_PSE_SET - do */
539262306a36Sopenharmony_civoid ethtool_pse_set_req_free(struct ethtool_pse_set_req *req)
539362306a36Sopenharmony_ci{
539462306a36Sopenharmony_ci	ethtool_header_free(&req->header);
539562306a36Sopenharmony_ci	free(req);
539662306a36Sopenharmony_ci}
539762306a36Sopenharmony_ci
539862306a36Sopenharmony_ciint ethtool_pse_set(struct ynl_sock *ys, struct ethtool_pse_set_req *req)
539962306a36Sopenharmony_ci{
540062306a36Sopenharmony_ci	struct nlmsghdr *nlh;
540162306a36Sopenharmony_ci	int err;
540262306a36Sopenharmony_ci
540362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PSE_SET, 1);
540462306a36Sopenharmony_ci	ys->req_policy = &ethtool_pse_nest;
540562306a36Sopenharmony_ci
540662306a36Sopenharmony_ci	if (req->_present.header)
540762306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PSE_HEADER, &req->header);
540862306a36Sopenharmony_ci	if (req->_present.admin_state)
540962306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_PODL_PSE_ADMIN_STATE, req->admin_state);
541062306a36Sopenharmony_ci	if (req->_present.admin_control)
541162306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_PODL_PSE_ADMIN_CONTROL, req->admin_control);
541262306a36Sopenharmony_ci	if (req->_present.pw_d_status)
541362306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_PODL_PSE_PW_D_STATUS, req->pw_d_status);
541462306a36Sopenharmony_ci
541562306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
541662306a36Sopenharmony_ci	if (err < 0)
541762306a36Sopenharmony_ci		return -1;
541862306a36Sopenharmony_ci
541962306a36Sopenharmony_ci	return 0;
542062306a36Sopenharmony_ci}
542162306a36Sopenharmony_ci
542262306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_RSS_GET ============== */
542362306a36Sopenharmony_ci/* ETHTOOL_MSG_RSS_GET - do */
542462306a36Sopenharmony_civoid ethtool_rss_get_req_free(struct ethtool_rss_get_req *req)
542562306a36Sopenharmony_ci{
542662306a36Sopenharmony_ci	ethtool_header_free(&req->header);
542762306a36Sopenharmony_ci	free(req);
542862306a36Sopenharmony_ci}
542962306a36Sopenharmony_ci
543062306a36Sopenharmony_civoid ethtool_rss_get_rsp_free(struct ethtool_rss_get_rsp *rsp)
543162306a36Sopenharmony_ci{
543262306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
543362306a36Sopenharmony_ci	free(rsp->indir);
543462306a36Sopenharmony_ci	free(rsp->hkey);
543562306a36Sopenharmony_ci	free(rsp);
543662306a36Sopenharmony_ci}
543762306a36Sopenharmony_ci
543862306a36Sopenharmony_ciint ethtool_rss_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
543962306a36Sopenharmony_ci{
544062306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
544162306a36Sopenharmony_ci	struct ethtool_rss_get_rsp *dst;
544262306a36Sopenharmony_ci	const struct nlattr *attr;
544362306a36Sopenharmony_ci	struct ynl_parse_arg parg;
544462306a36Sopenharmony_ci
544562306a36Sopenharmony_ci	dst = yarg->data;
544662306a36Sopenharmony_ci	parg.ys = yarg->ys;
544762306a36Sopenharmony_ci
544862306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
544962306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
545062306a36Sopenharmony_ci
545162306a36Sopenharmony_ci		if (type == ETHTOOL_A_RSS_HEADER) {
545262306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
545362306a36Sopenharmony_ci				return MNL_CB_ERROR;
545462306a36Sopenharmony_ci			dst->_present.header = 1;
545562306a36Sopenharmony_ci
545662306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
545762306a36Sopenharmony_ci			parg.data = &dst->header;
545862306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
545962306a36Sopenharmony_ci				return MNL_CB_ERROR;
546062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RSS_CONTEXT) {
546162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
546262306a36Sopenharmony_ci				return MNL_CB_ERROR;
546362306a36Sopenharmony_ci			dst->_present.context = 1;
546462306a36Sopenharmony_ci			dst->context = mnl_attr_get_u32(attr);
546562306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RSS_HFUNC) {
546662306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
546762306a36Sopenharmony_ci				return MNL_CB_ERROR;
546862306a36Sopenharmony_ci			dst->_present.hfunc = 1;
546962306a36Sopenharmony_ci			dst->hfunc = mnl_attr_get_u32(attr);
547062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RSS_INDIR) {
547162306a36Sopenharmony_ci			unsigned int len;
547262306a36Sopenharmony_ci
547362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
547462306a36Sopenharmony_ci				return MNL_CB_ERROR;
547562306a36Sopenharmony_ci
547662306a36Sopenharmony_ci			len = mnl_attr_get_payload_len(attr);
547762306a36Sopenharmony_ci			dst->_present.indir_len = len;
547862306a36Sopenharmony_ci			dst->indir = malloc(len);
547962306a36Sopenharmony_ci			memcpy(dst->indir, mnl_attr_get_payload(attr), len);
548062306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_RSS_HKEY) {
548162306a36Sopenharmony_ci			unsigned int len;
548262306a36Sopenharmony_ci
548362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
548462306a36Sopenharmony_ci				return MNL_CB_ERROR;
548562306a36Sopenharmony_ci
548662306a36Sopenharmony_ci			len = mnl_attr_get_payload_len(attr);
548762306a36Sopenharmony_ci			dst->_present.hkey_len = len;
548862306a36Sopenharmony_ci			dst->hkey = malloc(len);
548962306a36Sopenharmony_ci			memcpy(dst->hkey, mnl_attr_get_payload(attr), len);
549062306a36Sopenharmony_ci		}
549162306a36Sopenharmony_ci	}
549262306a36Sopenharmony_ci
549362306a36Sopenharmony_ci	return MNL_CB_OK;
549462306a36Sopenharmony_ci}
549562306a36Sopenharmony_ci
549662306a36Sopenharmony_cistruct ethtool_rss_get_rsp *
549762306a36Sopenharmony_ciethtool_rss_get(struct ynl_sock *ys, struct ethtool_rss_get_req *req)
549862306a36Sopenharmony_ci{
549962306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
550062306a36Sopenharmony_ci	struct ethtool_rss_get_rsp *rsp;
550162306a36Sopenharmony_ci	struct nlmsghdr *nlh;
550262306a36Sopenharmony_ci	int err;
550362306a36Sopenharmony_ci
550462306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_RSS_GET, 1);
550562306a36Sopenharmony_ci	ys->req_policy = &ethtool_rss_nest;
550662306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_rss_nest;
550762306a36Sopenharmony_ci
550862306a36Sopenharmony_ci	if (req->_present.header)
550962306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_RSS_HEADER, &req->header);
551062306a36Sopenharmony_ci
551162306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
551262306a36Sopenharmony_ci	yrs.yarg.data = rsp;
551362306a36Sopenharmony_ci	yrs.cb = ethtool_rss_get_rsp_parse;
551462306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_RSS_GET;
551562306a36Sopenharmony_ci
551662306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
551762306a36Sopenharmony_ci	if (err < 0)
551862306a36Sopenharmony_ci		goto err_free;
551962306a36Sopenharmony_ci
552062306a36Sopenharmony_ci	return rsp;
552162306a36Sopenharmony_ci
552262306a36Sopenharmony_cierr_free:
552362306a36Sopenharmony_ci	ethtool_rss_get_rsp_free(rsp);
552462306a36Sopenharmony_ci	return NULL;
552562306a36Sopenharmony_ci}
552662306a36Sopenharmony_ci
552762306a36Sopenharmony_ci/* ETHTOOL_MSG_RSS_GET - dump */
552862306a36Sopenharmony_civoid ethtool_rss_get_list_free(struct ethtool_rss_get_list *rsp)
552962306a36Sopenharmony_ci{
553062306a36Sopenharmony_ci	struct ethtool_rss_get_list *next = rsp;
553162306a36Sopenharmony_ci
553262306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
553362306a36Sopenharmony_ci		rsp = next;
553462306a36Sopenharmony_ci		next = rsp->next;
553562306a36Sopenharmony_ci
553662306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
553762306a36Sopenharmony_ci		free(rsp->obj.indir);
553862306a36Sopenharmony_ci		free(rsp->obj.hkey);
553962306a36Sopenharmony_ci		free(rsp);
554062306a36Sopenharmony_ci	}
554162306a36Sopenharmony_ci}
554262306a36Sopenharmony_ci
554362306a36Sopenharmony_cistruct ethtool_rss_get_list *
554462306a36Sopenharmony_ciethtool_rss_get_dump(struct ynl_sock *ys, struct ethtool_rss_get_req_dump *req)
554562306a36Sopenharmony_ci{
554662306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
554762306a36Sopenharmony_ci	struct nlmsghdr *nlh;
554862306a36Sopenharmony_ci	int err;
554962306a36Sopenharmony_ci
555062306a36Sopenharmony_ci	yds.ys = ys;
555162306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_rss_get_list);
555262306a36Sopenharmony_ci	yds.cb = ethtool_rss_get_rsp_parse;
555362306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_RSS_GET;
555462306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_rss_nest;
555562306a36Sopenharmony_ci
555662306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_RSS_GET, 1);
555762306a36Sopenharmony_ci	ys->req_policy = &ethtool_rss_nest;
555862306a36Sopenharmony_ci
555962306a36Sopenharmony_ci	if (req->_present.header)
556062306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_RSS_HEADER, &req->header);
556162306a36Sopenharmony_ci
556262306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
556362306a36Sopenharmony_ci	if (err < 0)
556462306a36Sopenharmony_ci		goto free_list;
556562306a36Sopenharmony_ci
556662306a36Sopenharmony_ci	return yds.first;
556762306a36Sopenharmony_ci
556862306a36Sopenharmony_cifree_list:
556962306a36Sopenharmony_ci	ethtool_rss_get_list_free(yds.first);
557062306a36Sopenharmony_ci	return NULL;
557162306a36Sopenharmony_ci}
557262306a36Sopenharmony_ci
557362306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PLCA_GET_CFG ============== */
557462306a36Sopenharmony_ci/* ETHTOOL_MSG_PLCA_GET_CFG - do */
557562306a36Sopenharmony_civoid ethtool_plca_get_cfg_req_free(struct ethtool_plca_get_cfg_req *req)
557662306a36Sopenharmony_ci{
557762306a36Sopenharmony_ci	ethtool_header_free(&req->header);
557862306a36Sopenharmony_ci	free(req);
557962306a36Sopenharmony_ci}
558062306a36Sopenharmony_ci
558162306a36Sopenharmony_civoid ethtool_plca_get_cfg_rsp_free(struct ethtool_plca_get_cfg_rsp *rsp)
558262306a36Sopenharmony_ci{
558362306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
558462306a36Sopenharmony_ci	free(rsp);
558562306a36Sopenharmony_ci}
558662306a36Sopenharmony_ci
558762306a36Sopenharmony_ciint ethtool_plca_get_cfg_rsp_parse(const struct nlmsghdr *nlh, void *data)
558862306a36Sopenharmony_ci{
558962306a36Sopenharmony_ci	struct ethtool_plca_get_cfg_rsp *dst;
559062306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
559162306a36Sopenharmony_ci	const struct nlattr *attr;
559262306a36Sopenharmony_ci	struct ynl_parse_arg parg;
559362306a36Sopenharmony_ci
559462306a36Sopenharmony_ci	dst = yarg->data;
559562306a36Sopenharmony_ci	parg.ys = yarg->ys;
559662306a36Sopenharmony_ci
559762306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
559862306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
559962306a36Sopenharmony_ci
560062306a36Sopenharmony_ci		if (type == ETHTOOL_A_PLCA_HEADER) {
560162306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
560262306a36Sopenharmony_ci				return MNL_CB_ERROR;
560362306a36Sopenharmony_ci			dst->_present.header = 1;
560462306a36Sopenharmony_ci
560562306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
560662306a36Sopenharmony_ci			parg.data = &dst->header;
560762306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
560862306a36Sopenharmony_ci				return MNL_CB_ERROR;
560962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_VERSION) {
561062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
561162306a36Sopenharmony_ci				return MNL_CB_ERROR;
561262306a36Sopenharmony_ci			dst->_present.version = 1;
561362306a36Sopenharmony_ci			dst->version = mnl_attr_get_u16(attr);
561462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_ENABLED) {
561562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
561662306a36Sopenharmony_ci				return MNL_CB_ERROR;
561762306a36Sopenharmony_ci			dst->_present.enabled = 1;
561862306a36Sopenharmony_ci			dst->enabled = mnl_attr_get_u8(attr);
561962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_STATUS) {
562062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
562162306a36Sopenharmony_ci				return MNL_CB_ERROR;
562262306a36Sopenharmony_ci			dst->_present.status = 1;
562362306a36Sopenharmony_ci			dst->status = mnl_attr_get_u8(attr);
562462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_NODE_CNT) {
562562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
562662306a36Sopenharmony_ci				return MNL_CB_ERROR;
562762306a36Sopenharmony_ci			dst->_present.node_cnt = 1;
562862306a36Sopenharmony_ci			dst->node_cnt = mnl_attr_get_u32(attr);
562962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_NODE_ID) {
563062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
563162306a36Sopenharmony_ci				return MNL_CB_ERROR;
563262306a36Sopenharmony_ci			dst->_present.node_id = 1;
563362306a36Sopenharmony_ci			dst->node_id = mnl_attr_get_u32(attr);
563462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_TO_TMR) {
563562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
563662306a36Sopenharmony_ci				return MNL_CB_ERROR;
563762306a36Sopenharmony_ci			dst->_present.to_tmr = 1;
563862306a36Sopenharmony_ci			dst->to_tmr = mnl_attr_get_u32(attr);
563962306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_BURST_CNT) {
564062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
564162306a36Sopenharmony_ci				return MNL_CB_ERROR;
564262306a36Sopenharmony_ci			dst->_present.burst_cnt = 1;
564362306a36Sopenharmony_ci			dst->burst_cnt = mnl_attr_get_u32(attr);
564462306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_BURST_TMR) {
564562306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
564662306a36Sopenharmony_ci				return MNL_CB_ERROR;
564762306a36Sopenharmony_ci			dst->_present.burst_tmr = 1;
564862306a36Sopenharmony_ci			dst->burst_tmr = mnl_attr_get_u32(attr);
564962306a36Sopenharmony_ci		}
565062306a36Sopenharmony_ci	}
565162306a36Sopenharmony_ci
565262306a36Sopenharmony_ci	return MNL_CB_OK;
565362306a36Sopenharmony_ci}
565462306a36Sopenharmony_ci
565562306a36Sopenharmony_cistruct ethtool_plca_get_cfg_rsp *
565662306a36Sopenharmony_ciethtool_plca_get_cfg(struct ynl_sock *ys, struct ethtool_plca_get_cfg_req *req)
565762306a36Sopenharmony_ci{
565862306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
565962306a36Sopenharmony_ci	struct ethtool_plca_get_cfg_rsp *rsp;
566062306a36Sopenharmony_ci	struct nlmsghdr *nlh;
566162306a36Sopenharmony_ci	int err;
566262306a36Sopenharmony_ci
566362306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PLCA_GET_CFG, 1);
566462306a36Sopenharmony_ci	ys->req_policy = &ethtool_plca_nest;
566562306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_plca_nest;
566662306a36Sopenharmony_ci
566762306a36Sopenharmony_ci	if (req->_present.header)
566862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header);
566962306a36Sopenharmony_ci
567062306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
567162306a36Sopenharmony_ci	yrs.yarg.data = rsp;
567262306a36Sopenharmony_ci	yrs.cb = ethtool_plca_get_cfg_rsp_parse;
567362306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_PLCA_GET_CFG;
567462306a36Sopenharmony_ci
567562306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
567662306a36Sopenharmony_ci	if (err < 0)
567762306a36Sopenharmony_ci		goto err_free;
567862306a36Sopenharmony_ci
567962306a36Sopenharmony_ci	return rsp;
568062306a36Sopenharmony_ci
568162306a36Sopenharmony_cierr_free:
568262306a36Sopenharmony_ci	ethtool_plca_get_cfg_rsp_free(rsp);
568362306a36Sopenharmony_ci	return NULL;
568462306a36Sopenharmony_ci}
568562306a36Sopenharmony_ci
568662306a36Sopenharmony_ci/* ETHTOOL_MSG_PLCA_GET_CFG - dump */
568762306a36Sopenharmony_civoid ethtool_plca_get_cfg_list_free(struct ethtool_plca_get_cfg_list *rsp)
568862306a36Sopenharmony_ci{
568962306a36Sopenharmony_ci	struct ethtool_plca_get_cfg_list *next = rsp;
569062306a36Sopenharmony_ci
569162306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
569262306a36Sopenharmony_ci		rsp = next;
569362306a36Sopenharmony_ci		next = rsp->next;
569462306a36Sopenharmony_ci
569562306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
569662306a36Sopenharmony_ci		free(rsp);
569762306a36Sopenharmony_ci	}
569862306a36Sopenharmony_ci}
569962306a36Sopenharmony_ci
570062306a36Sopenharmony_cistruct ethtool_plca_get_cfg_list *
570162306a36Sopenharmony_ciethtool_plca_get_cfg_dump(struct ynl_sock *ys,
570262306a36Sopenharmony_ci			  struct ethtool_plca_get_cfg_req_dump *req)
570362306a36Sopenharmony_ci{
570462306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
570562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
570662306a36Sopenharmony_ci	int err;
570762306a36Sopenharmony_ci
570862306a36Sopenharmony_ci	yds.ys = ys;
570962306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_plca_get_cfg_list);
571062306a36Sopenharmony_ci	yds.cb = ethtool_plca_get_cfg_rsp_parse;
571162306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_PLCA_GET_CFG;
571262306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_plca_nest;
571362306a36Sopenharmony_ci
571462306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PLCA_GET_CFG, 1);
571562306a36Sopenharmony_ci	ys->req_policy = &ethtool_plca_nest;
571662306a36Sopenharmony_ci
571762306a36Sopenharmony_ci	if (req->_present.header)
571862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header);
571962306a36Sopenharmony_ci
572062306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
572162306a36Sopenharmony_ci	if (err < 0)
572262306a36Sopenharmony_ci		goto free_list;
572362306a36Sopenharmony_ci
572462306a36Sopenharmony_ci	return yds.first;
572562306a36Sopenharmony_ci
572662306a36Sopenharmony_cifree_list:
572762306a36Sopenharmony_ci	ethtool_plca_get_cfg_list_free(yds.first);
572862306a36Sopenharmony_ci	return NULL;
572962306a36Sopenharmony_ci}
573062306a36Sopenharmony_ci
573162306a36Sopenharmony_ci/* ETHTOOL_MSG_PLCA_GET_CFG - notify */
573262306a36Sopenharmony_civoid ethtool_plca_get_cfg_ntf_free(struct ethtool_plca_get_cfg_ntf *rsp)
573362306a36Sopenharmony_ci{
573462306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
573562306a36Sopenharmony_ci	free(rsp);
573662306a36Sopenharmony_ci}
573762306a36Sopenharmony_ci
573862306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PLCA_SET_CFG ============== */
573962306a36Sopenharmony_ci/* ETHTOOL_MSG_PLCA_SET_CFG - do */
574062306a36Sopenharmony_civoid ethtool_plca_set_cfg_req_free(struct ethtool_plca_set_cfg_req *req)
574162306a36Sopenharmony_ci{
574262306a36Sopenharmony_ci	ethtool_header_free(&req->header);
574362306a36Sopenharmony_ci	free(req);
574462306a36Sopenharmony_ci}
574562306a36Sopenharmony_ci
574662306a36Sopenharmony_ciint ethtool_plca_set_cfg(struct ynl_sock *ys,
574762306a36Sopenharmony_ci			 struct ethtool_plca_set_cfg_req *req)
574862306a36Sopenharmony_ci{
574962306a36Sopenharmony_ci	struct nlmsghdr *nlh;
575062306a36Sopenharmony_ci	int err;
575162306a36Sopenharmony_ci
575262306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PLCA_SET_CFG, 1);
575362306a36Sopenharmony_ci	ys->req_policy = &ethtool_plca_nest;
575462306a36Sopenharmony_ci
575562306a36Sopenharmony_ci	if (req->_present.header)
575662306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header);
575762306a36Sopenharmony_ci	if (req->_present.version)
575862306a36Sopenharmony_ci		mnl_attr_put_u16(nlh, ETHTOOL_A_PLCA_VERSION, req->version);
575962306a36Sopenharmony_ci	if (req->_present.enabled)
576062306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_PLCA_ENABLED, req->enabled);
576162306a36Sopenharmony_ci	if (req->_present.status)
576262306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_PLCA_STATUS, req->status);
576362306a36Sopenharmony_ci	if (req->_present.node_cnt)
576462306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_NODE_CNT, req->node_cnt);
576562306a36Sopenharmony_ci	if (req->_present.node_id)
576662306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_NODE_ID, req->node_id);
576762306a36Sopenharmony_ci	if (req->_present.to_tmr)
576862306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_TO_TMR, req->to_tmr);
576962306a36Sopenharmony_ci	if (req->_present.burst_cnt)
577062306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_BURST_CNT, req->burst_cnt);
577162306a36Sopenharmony_ci	if (req->_present.burst_tmr)
577262306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_BURST_TMR, req->burst_tmr);
577362306a36Sopenharmony_ci
577462306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
577562306a36Sopenharmony_ci	if (err < 0)
577662306a36Sopenharmony_ci		return -1;
577762306a36Sopenharmony_ci
577862306a36Sopenharmony_ci	return 0;
577962306a36Sopenharmony_ci}
578062306a36Sopenharmony_ci
578162306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_PLCA_GET_STATUS ============== */
578262306a36Sopenharmony_ci/* ETHTOOL_MSG_PLCA_GET_STATUS - do */
578362306a36Sopenharmony_civoid ethtool_plca_get_status_req_free(struct ethtool_plca_get_status_req *req)
578462306a36Sopenharmony_ci{
578562306a36Sopenharmony_ci	ethtool_header_free(&req->header);
578662306a36Sopenharmony_ci	free(req);
578762306a36Sopenharmony_ci}
578862306a36Sopenharmony_ci
578962306a36Sopenharmony_civoid ethtool_plca_get_status_rsp_free(struct ethtool_plca_get_status_rsp *rsp)
579062306a36Sopenharmony_ci{
579162306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
579262306a36Sopenharmony_ci	free(rsp);
579362306a36Sopenharmony_ci}
579462306a36Sopenharmony_ci
579562306a36Sopenharmony_ciint ethtool_plca_get_status_rsp_parse(const struct nlmsghdr *nlh, void *data)
579662306a36Sopenharmony_ci{
579762306a36Sopenharmony_ci	struct ethtool_plca_get_status_rsp *dst;
579862306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
579962306a36Sopenharmony_ci	const struct nlattr *attr;
580062306a36Sopenharmony_ci	struct ynl_parse_arg parg;
580162306a36Sopenharmony_ci
580262306a36Sopenharmony_ci	dst = yarg->data;
580362306a36Sopenharmony_ci	parg.ys = yarg->ys;
580462306a36Sopenharmony_ci
580562306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
580662306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
580762306a36Sopenharmony_ci
580862306a36Sopenharmony_ci		if (type == ETHTOOL_A_PLCA_HEADER) {
580962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
581062306a36Sopenharmony_ci				return MNL_CB_ERROR;
581162306a36Sopenharmony_ci			dst->_present.header = 1;
581262306a36Sopenharmony_ci
581362306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
581462306a36Sopenharmony_ci			parg.data = &dst->header;
581562306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
581662306a36Sopenharmony_ci				return MNL_CB_ERROR;
581762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_VERSION) {
581862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
581962306a36Sopenharmony_ci				return MNL_CB_ERROR;
582062306a36Sopenharmony_ci			dst->_present.version = 1;
582162306a36Sopenharmony_ci			dst->version = mnl_attr_get_u16(attr);
582262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_ENABLED) {
582362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
582462306a36Sopenharmony_ci				return MNL_CB_ERROR;
582562306a36Sopenharmony_ci			dst->_present.enabled = 1;
582662306a36Sopenharmony_ci			dst->enabled = mnl_attr_get_u8(attr);
582762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_STATUS) {
582862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
582962306a36Sopenharmony_ci				return MNL_CB_ERROR;
583062306a36Sopenharmony_ci			dst->_present.status = 1;
583162306a36Sopenharmony_ci			dst->status = mnl_attr_get_u8(attr);
583262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_NODE_CNT) {
583362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
583462306a36Sopenharmony_ci				return MNL_CB_ERROR;
583562306a36Sopenharmony_ci			dst->_present.node_cnt = 1;
583662306a36Sopenharmony_ci			dst->node_cnt = mnl_attr_get_u32(attr);
583762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_NODE_ID) {
583862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
583962306a36Sopenharmony_ci				return MNL_CB_ERROR;
584062306a36Sopenharmony_ci			dst->_present.node_id = 1;
584162306a36Sopenharmony_ci			dst->node_id = mnl_attr_get_u32(attr);
584262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_TO_TMR) {
584362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
584462306a36Sopenharmony_ci				return MNL_CB_ERROR;
584562306a36Sopenharmony_ci			dst->_present.to_tmr = 1;
584662306a36Sopenharmony_ci			dst->to_tmr = mnl_attr_get_u32(attr);
584762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_BURST_CNT) {
584862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
584962306a36Sopenharmony_ci				return MNL_CB_ERROR;
585062306a36Sopenharmony_ci			dst->_present.burst_cnt = 1;
585162306a36Sopenharmony_ci			dst->burst_cnt = mnl_attr_get_u32(attr);
585262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_PLCA_BURST_TMR) {
585362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
585462306a36Sopenharmony_ci				return MNL_CB_ERROR;
585562306a36Sopenharmony_ci			dst->_present.burst_tmr = 1;
585662306a36Sopenharmony_ci			dst->burst_tmr = mnl_attr_get_u32(attr);
585762306a36Sopenharmony_ci		}
585862306a36Sopenharmony_ci	}
585962306a36Sopenharmony_ci
586062306a36Sopenharmony_ci	return MNL_CB_OK;
586162306a36Sopenharmony_ci}
586262306a36Sopenharmony_ci
586362306a36Sopenharmony_cistruct ethtool_plca_get_status_rsp *
586462306a36Sopenharmony_ciethtool_plca_get_status(struct ynl_sock *ys,
586562306a36Sopenharmony_ci			struct ethtool_plca_get_status_req *req)
586662306a36Sopenharmony_ci{
586762306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
586862306a36Sopenharmony_ci	struct ethtool_plca_get_status_rsp *rsp;
586962306a36Sopenharmony_ci	struct nlmsghdr *nlh;
587062306a36Sopenharmony_ci	int err;
587162306a36Sopenharmony_ci
587262306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PLCA_GET_STATUS, 1);
587362306a36Sopenharmony_ci	ys->req_policy = &ethtool_plca_nest;
587462306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_plca_nest;
587562306a36Sopenharmony_ci
587662306a36Sopenharmony_ci	if (req->_present.header)
587762306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header);
587862306a36Sopenharmony_ci
587962306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
588062306a36Sopenharmony_ci	yrs.yarg.data = rsp;
588162306a36Sopenharmony_ci	yrs.cb = ethtool_plca_get_status_rsp_parse;
588262306a36Sopenharmony_ci	yrs.rsp_cmd = 40;
588362306a36Sopenharmony_ci
588462306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
588562306a36Sopenharmony_ci	if (err < 0)
588662306a36Sopenharmony_ci		goto err_free;
588762306a36Sopenharmony_ci
588862306a36Sopenharmony_ci	return rsp;
588962306a36Sopenharmony_ci
589062306a36Sopenharmony_cierr_free:
589162306a36Sopenharmony_ci	ethtool_plca_get_status_rsp_free(rsp);
589262306a36Sopenharmony_ci	return NULL;
589362306a36Sopenharmony_ci}
589462306a36Sopenharmony_ci
589562306a36Sopenharmony_ci/* ETHTOOL_MSG_PLCA_GET_STATUS - dump */
589662306a36Sopenharmony_civoid
589762306a36Sopenharmony_ciethtool_plca_get_status_list_free(struct ethtool_plca_get_status_list *rsp)
589862306a36Sopenharmony_ci{
589962306a36Sopenharmony_ci	struct ethtool_plca_get_status_list *next = rsp;
590062306a36Sopenharmony_ci
590162306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
590262306a36Sopenharmony_ci		rsp = next;
590362306a36Sopenharmony_ci		next = rsp->next;
590462306a36Sopenharmony_ci
590562306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
590662306a36Sopenharmony_ci		free(rsp);
590762306a36Sopenharmony_ci	}
590862306a36Sopenharmony_ci}
590962306a36Sopenharmony_ci
591062306a36Sopenharmony_cistruct ethtool_plca_get_status_list *
591162306a36Sopenharmony_ciethtool_plca_get_status_dump(struct ynl_sock *ys,
591262306a36Sopenharmony_ci			     struct ethtool_plca_get_status_req_dump *req)
591362306a36Sopenharmony_ci{
591462306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
591562306a36Sopenharmony_ci	struct nlmsghdr *nlh;
591662306a36Sopenharmony_ci	int err;
591762306a36Sopenharmony_ci
591862306a36Sopenharmony_ci	yds.ys = ys;
591962306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_plca_get_status_list);
592062306a36Sopenharmony_ci	yds.cb = ethtool_plca_get_status_rsp_parse;
592162306a36Sopenharmony_ci	yds.rsp_cmd = 40;
592262306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_plca_nest;
592362306a36Sopenharmony_ci
592462306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PLCA_GET_STATUS, 1);
592562306a36Sopenharmony_ci	ys->req_policy = &ethtool_plca_nest;
592662306a36Sopenharmony_ci
592762306a36Sopenharmony_ci	if (req->_present.header)
592862306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header);
592962306a36Sopenharmony_ci
593062306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
593162306a36Sopenharmony_ci	if (err < 0)
593262306a36Sopenharmony_ci		goto free_list;
593362306a36Sopenharmony_ci
593462306a36Sopenharmony_ci	return yds.first;
593562306a36Sopenharmony_ci
593662306a36Sopenharmony_cifree_list:
593762306a36Sopenharmony_ci	ethtool_plca_get_status_list_free(yds.first);
593862306a36Sopenharmony_ci	return NULL;
593962306a36Sopenharmony_ci}
594062306a36Sopenharmony_ci
594162306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_MM_GET ============== */
594262306a36Sopenharmony_ci/* ETHTOOL_MSG_MM_GET - do */
594362306a36Sopenharmony_civoid ethtool_mm_get_req_free(struct ethtool_mm_get_req *req)
594462306a36Sopenharmony_ci{
594562306a36Sopenharmony_ci	ethtool_header_free(&req->header);
594662306a36Sopenharmony_ci	free(req);
594762306a36Sopenharmony_ci}
594862306a36Sopenharmony_ci
594962306a36Sopenharmony_civoid ethtool_mm_get_rsp_free(struct ethtool_mm_get_rsp *rsp)
595062306a36Sopenharmony_ci{
595162306a36Sopenharmony_ci	ethtool_header_free(&rsp->header);
595262306a36Sopenharmony_ci	ethtool_mm_stat_free(&rsp->stats);
595362306a36Sopenharmony_ci	free(rsp);
595462306a36Sopenharmony_ci}
595562306a36Sopenharmony_ci
595662306a36Sopenharmony_ciint ethtool_mm_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
595762306a36Sopenharmony_ci{
595862306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
595962306a36Sopenharmony_ci	struct ethtool_mm_get_rsp *dst;
596062306a36Sopenharmony_ci	const struct nlattr *attr;
596162306a36Sopenharmony_ci	struct ynl_parse_arg parg;
596262306a36Sopenharmony_ci
596362306a36Sopenharmony_ci	dst = yarg->data;
596462306a36Sopenharmony_ci	parg.ys = yarg->ys;
596562306a36Sopenharmony_ci
596662306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
596762306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
596862306a36Sopenharmony_ci
596962306a36Sopenharmony_ci		if (type == ETHTOOL_A_MM_HEADER) {
597062306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
597162306a36Sopenharmony_ci				return MNL_CB_ERROR;
597262306a36Sopenharmony_ci			dst->_present.header = 1;
597362306a36Sopenharmony_ci
597462306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
597562306a36Sopenharmony_ci			parg.data = &dst->header;
597662306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
597762306a36Sopenharmony_ci				return MNL_CB_ERROR;
597862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_PMAC_ENABLED) {
597962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
598062306a36Sopenharmony_ci				return MNL_CB_ERROR;
598162306a36Sopenharmony_ci			dst->_present.pmac_enabled = 1;
598262306a36Sopenharmony_ci			dst->pmac_enabled = mnl_attr_get_u8(attr);
598362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_TX_ENABLED) {
598462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
598562306a36Sopenharmony_ci				return MNL_CB_ERROR;
598662306a36Sopenharmony_ci			dst->_present.tx_enabled = 1;
598762306a36Sopenharmony_ci			dst->tx_enabled = mnl_attr_get_u8(attr);
598862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_TX_ACTIVE) {
598962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
599062306a36Sopenharmony_ci				return MNL_CB_ERROR;
599162306a36Sopenharmony_ci			dst->_present.tx_active = 1;
599262306a36Sopenharmony_ci			dst->tx_active = mnl_attr_get_u8(attr);
599362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_TX_MIN_FRAG_SIZE) {
599462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
599562306a36Sopenharmony_ci				return MNL_CB_ERROR;
599662306a36Sopenharmony_ci			dst->_present.tx_min_frag_size = 1;
599762306a36Sopenharmony_ci			dst->tx_min_frag_size = mnl_attr_get_u32(attr);
599862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_RX_MIN_FRAG_SIZE) {
599962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
600062306a36Sopenharmony_ci				return MNL_CB_ERROR;
600162306a36Sopenharmony_ci			dst->_present.rx_min_frag_size = 1;
600262306a36Sopenharmony_ci			dst->rx_min_frag_size = mnl_attr_get_u32(attr);
600362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_VERIFY_ENABLED) {
600462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
600562306a36Sopenharmony_ci				return MNL_CB_ERROR;
600662306a36Sopenharmony_ci			dst->_present.verify_enabled = 1;
600762306a36Sopenharmony_ci			dst->verify_enabled = mnl_attr_get_u8(attr);
600862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_VERIFY_TIME) {
600962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
601062306a36Sopenharmony_ci				return MNL_CB_ERROR;
601162306a36Sopenharmony_ci			dst->_present.verify_time = 1;
601262306a36Sopenharmony_ci			dst->verify_time = mnl_attr_get_u32(attr);
601362306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_MAX_VERIFY_TIME) {
601462306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
601562306a36Sopenharmony_ci				return MNL_CB_ERROR;
601662306a36Sopenharmony_ci			dst->_present.max_verify_time = 1;
601762306a36Sopenharmony_ci			dst->max_verify_time = mnl_attr_get_u32(attr);
601862306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_MM_STATS) {
601962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
602062306a36Sopenharmony_ci				return MNL_CB_ERROR;
602162306a36Sopenharmony_ci			dst->_present.stats = 1;
602262306a36Sopenharmony_ci
602362306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_mm_stat_nest;
602462306a36Sopenharmony_ci			parg.data = &dst->stats;
602562306a36Sopenharmony_ci			if (ethtool_mm_stat_parse(&parg, attr))
602662306a36Sopenharmony_ci				return MNL_CB_ERROR;
602762306a36Sopenharmony_ci		}
602862306a36Sopenharmony_ci	}
602962306a36Sopenharmony_ci
603062306a36Sopenharmony_ci	return MNL_CB_OK;
603162306a36Sopenharmony_ci}
603262306a36Sopenharmony_ci
603362306a36Sopenharmony_cistruct ethtool_mm_get_rsp *
603462306a36Sopenharmony_ciethtool_mm_get(struct ynl_sock *ys, struct ethtool_mm_get_req *req)
603562306a36Sopenharmony_ci{
603662306a36Sopenharmony_ci	struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
603762306a36Sopenharmony_ci	struct ethtool_mm_get_rsp *rsp;
603862306a36Sopenharmony_ci	struct nlmsghdr *nlh;
603962306a36Sopenharmony_ci	int err;
604062306a36Sopenharmony_ci
604162306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MM_GET, 1);
604262306a36Sopenharmony_ci	ys->req_policy = &ethtool_mm_nest;
604362306a36Sopenharmony_ci	yrs.yarg.rsp_policy = &ethtool_mm_nest;
604462306a36Sopenharmony_ci
604562306a36Sopenharmony_ci	if (req->_present.header)
604662306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_MM_HEADER, &req->header);
604762306a36Sopenharmony_ci
604862306a36Sopenharmony_ci	rsp = calloc(1, sizeof(*rsp));
604962306a36Sopenharmony_ci	yrs.yarg.data = rsp;
605062306a36Sopenharmony_ci	yrs.cb = ethtool_mm_get_rsp_parse;
605162306a36Sopenharmony_ci	yrs.rsp_cmd = ETHTOOL_MSG_MM_GET;
605262306a36Sopenharmony_ci
605362306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, &yrs);
605462306a36Sopenharmony_ci	if (err < 0)
605562306a36Sopenharmony_ci		goto err_free;
605662306a36Sopenharmony_ci
605762306a36Sopenharmony_ci	return rsp;
605862306a36Sopenharmony_ci
605962306a36Sopenharmony_cierr_free:
606062306a36Sopenharmony_ci	ethtool_mm_get_rsp_free(rsp);
606162306a36Sopenharmony_ci	return NULL;
606262306a36Sopenharmony_ci}
606362306a36Sopenharmony_ci
606462306a36Sopenharmony_ci/* ETHTOOL_MSG_MM_GET - dump */
606562306a36Sopenharmony_civoid ethtool_mm_get_list_free(struct ethtool_mm_get_list *rsp)
606662306a36Sopenharmony_ci{
606762306a36Sopenharmony_ci	struct ethtool_mm_get_list *next = rsp;
606862306a36Sopenharmony_ci
606962306a36Sopenharmony_ci	while ((void *)next != YNL_LIST_END) {
607062306a36Sopenharmony_ci		rsp = next;
607162306a36Sopenharmony_ci		next = rsp->next;
607262306a36Sopenharmony_ci
607362306a36Sopenharmony_ci		ethtool_header_free(&rsp->obj.header);
607462306a36Sopenharmony_ci		ethtool_mm_stat_free(&rsp->obj.stats);
607562306a36Sopenharmony_ci		free(rsp);
607662306a36Sopenharmony_ci	}
607762306a36Sopenharmony_ci}
607862306a36Sopenharmony_ci
607962306a36Sopenharmony_cistruct ethtool_mm_get_list *
608062306a36Sopenharmony_ciethtool_mm_get_dump(struct ynl_sock *ys, struct ethtool_mm_get_req_dump *req)
608162306a36Sopenharmony_ci{
608262306a36Sopenharmony_ci	struct ynl_dump_state yds = {};
608362306a36Sopenharmony_ci	struct nlmsghdr *nlh;
608462306a36Sopenharmony_ci	int err;
608562306a36Sopenharmony_ci
608662306a36Sopenharmony_ci	yds.ys = ys;
608762306a36Sopenharmony_ci	yds.alloc_sz = sizeof(struct ethtool_mm_get_list);
608862306a36Sopenharmony_ci	yds.cb = ethtool_mm_get_rsp_parse;
608962306a36Sopenharmony_ci	yds.rsp_cmd = ETHTOOL_MSG_MM_GET;
609062306a36Sopenharmony_ci	yds.rsp_policy = &ethtool_mm_nest;
609162306a36Sopenharmony_ci
609262306a36Sopenharmony_ci	nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_MM_GET, 1);
609362306a36Sopenharmony_ci	ys->req_policy = &ethtool_mm_nest;
609462306a36Sopenharmony_ci
609562306a36Sopenharmony_ci	if (req->_present.header)
609662306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_MM_HEADER, &req->header);
609762306a36Sopenharmony_ci
609862306a36Sopenharmony_ci	err = ynl_exec_dump(ys, nlh, &yds);
609962306a36Sopenharmony_ci	if (err < 0)
610062306a36Sopenharmony_ci		goto free_list;
610162306a36Sopenharmony_ci
610262306a36Sopenharmony_ci	return yds.first;
610362306a36Sopenharmony_ci
610462306a36Sopenharmony_cifree_list:
610562306a36Sopenharmony_ci	ethtool_mm_get_list_free(yds.first);
610662306a36Sopenharmony_ci	return NULL;
610762306a36Sopenharmony_ci}
610862306a36Sopenharmony_ci
610962306a36Sopenharmony_ci/* ETHTOOL_MSG_MM_GET - notify */
611062306a36Sopenharmony_civoid ethtool_mm_get_ntf_free(struct ethtool_mm_get_ntf *rsp)
611162306a36Sopenharmony_ci{
611262306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
611362306a36Sopenharmony_ci	ethtool_mm_stat_free(&rsp->obj.stats);
611462306a36Sopenharmony_ci	free(rsp);
611562306a36Sopenharmony_ci}
611662306a36Sopenharmony_ci
611762306a36Sopenharmony_ci/* ============== ETHTOOL_MSG_MM_SET ============== */
611862306a36Sopenharmony_ci/* ETHTOOL_MSG_MM_SET - do */
611962306a36Sopenharmony_civoid ethtool_mm_set_req_free(struct ethtool_mm_set_req *req)
612062306a36Sopenharmony_ci{
612162306a36Sopenharmony_ci	ethtool_header_free(&req->header);
612262306a36Sopenharmony_ci	free(req);
612362306a36Sopenharmony_ci}
612462306a36Sopenharmony_ci
612562306a36Sopenharmony_ciint ethtool_mm_set(struct ynl_sock *ys, struct ethtool_mm_set_req *req)
612662306a36Sopenharmony_ci{
612762306a36Sopenharmony_ci	struct nlmsghdr *nlh;
612862306a36Sopenharmony_ci	int err;
612962306a36Sopenharmony_ci
613062306a36Sopenharmony_ci	nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MM_SET, 1);
613162306a36Sopenharmony_ci	ys->req_policy = &ethtool_mm_nest;
613262306a36Sopenharmony_ci
613362306a36Sopenharmony_ci	if (req->_present.header)
613462306a36Sopenharmony_ci		ethtool_header_put(nlh, ETHTOOL_A_MM_HEADER, &req->header);
613562306a36Sopenharmony_ci	if (req->_present.verify_enabled)
613662306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_MM_VERIFY_ENABLED, req->verify_enabled);
613762306a36Sopenharmony_ci	if (req->_present.verify_time)
613862306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_MM_VERIFY_TIME, req->verify_time);
613962306a36Sopenharmony_ci	if (req->_present.tx_enabled)
614062306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_MM_TX_ENABLED, req->tx_enabled);
614162306a36Sopenharmony_ci	if (req->_present.pmac_enabled)
614262306a36Sopenharmony_ci		mnl_attr_put_u8(nlh, ETHTOOL_A_MM_PMAC_ENABLED, req->pmac_enabled);
614362306a36Sopenharmony_ci	if (req->_present.tx_min_frag_size)
614462306a36Sopenharmony_ci		mnl_attr_put_u32(nlh, ETHTOOL_A_MM_TX_MIN_FRAG_SIZE, req->tx_min_frag_size);
614562306a36Sopenharmony_ci
614662306a36Sopenharmony_ci	err = ynl_exec(ys, nlh, NULL);
614762306a36Sopenharmony_ci	if (err < 0)
614862306a36Sopenharmony_ci		return -1;
614962306a36Sopenharmony_ci
615062306a36Sopenharmony_ci	return 0;
615162306a36Sopenharmony_ci}
615262306a36Sopenharmony_ci
615362306a36Sopenharmony_ci/* ETHTOOL_MSG_CABLE_TEST_NTF - event */
615462306a36Sopenharmony_ciint ethtool_cable_test_ntf_rsp_parse(const struct nlmsghdr *nlh, void *data)
615562306a36Sopenharmony_ci{
615662306a36Sopenharmony_ci	struct ethtool_cable_test_ntf_rsp *dst;
615762306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
615862306a36Sopenharmony_ci	const struct nlattr *attr;
615962306a36Sopenharmony_ci	struct ynl_parse_arg parg;
616062306a36Sopenharmony_ci
616162306a36Sopenharmony_ci	dst = yarg->data;
616262306a36Sopenharmony_ci	parg.ys = yarg->ys;
616362306a36Sopenharmony_ci
616462306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
616562306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
616662306a36Sopenharmony_ci
616762306a36Sopenharmony_ci		if (type == ETHTOOL_A_CABLE_TEST_NTF_HEADER) {
616862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
616962306a36Sopenharmony_ci				return MNL_CB_ERROR;
617062306a36Sopenharmony_ci			dst->_present.header = 1;
617162306a36Sopenharmony_ci
617262306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
617362306a36Sopenharmony_ci			parg.data = &dst->header;
617462306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
617562306a36Sopenharmony_ci				return MNL_CB_ERROR;
617662306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CABLE_TEST_NTF_STATUS) {
617762306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
617862306a36Sopenharmony_ci				return MNL_CB_ERROR;
617962306a36Sopenharmony_ci			dst->_present.status = 1;
618062306a36Sopenharmony_ci			dst->status = mnl_attr_get_u8(attr);
618162306a36Sopenharmony_ci		}
618262306a36Sopenharmony_ci	}
618362306a36Sopenharmony_ci
618462306a36Sopenharmony_ci	return MNL_CB_OK;
618562306a36Sopenharmony_ci}
618662306a36Sopenharmony_ci
618762306a36Sopenharmony_civoid ethtool_cable_test_ntf_free(struct ethtool_cable_test_ntf *rsp)
618862306a36Sopenharmony_ci{
618962306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
619062306a36Sopenharmony_ci	free(rsp);
619162306a36Sopenharmony_ci}
619262306a36Sopenharmony_ci
619362306a36Sopenharmony_ci/* ETHTOOL_MSG_CABLE_TEST_TDR_NTF - event */
619462306a36Sopenharmony_ciint ethtool_cable_test_tdr_ntf_rsp_parse(const struct nlmsghdr *nlh,
619562306a36Sopenharmony_ci					 void *data)
619662306a36Sopenharmony_ci{
619762306a36Sopenharmony_ci	struct ethtool_cable_test_tdr_ntf_rsp *dst;
619862306a36Sopenharmony_ci	struct ynl_parse_arg *yarg = data;
619962306a36Sopenharmony_ci	const struct nlattr *attr;
620062306a36Sopenharmony_ci	struct ynl_parse_arg parg;
620162306a36Sopenharmony_ci
620262306a36Sopenharmony_ci	dst = yarg->data;
620362306a36Sopenharmony_ci	parg.ys = yarg->ys;
620462306a36Sopenharmony_ci
620562306a36Sopenharmony_ci	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
620662306a36Sopenharmony_ci		unsigned int type = mnl_attr_get_type(attr);
620762306a36Sopenharmony_ci
620862306a36Sopenharmony_ci		if (type == ETHTOOL_A_CABLE_TEST_TDR_NTF_HEADER) {
620962306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
621062306a36Sopenharmony_ci				return MNL_CB_ERROR;
621162306a36Sopenharmony_ci			dst->_present.header = 1;
621262306a36Sopenharmony_ci
621362306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_header_nest;
621462306a36Sopenharmony_ci			parg.data = &dst->header;
621562306a36Sopenharmony_ci			if (ethtool_header_parse(&parg, attr))
621662306a36Sopenharmony_ci				return MNL_CB_ERROR;
621762306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CABLE_TEST_TDR_NTF_STATUS) {
621862306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
621962306a36Sopenharmony_ci				return MNL_CB_ERROR;
622062306a36Sopenharmony_ci			dst->_present.status = 1;
622162306a36Sopenharmony_ci			dst->status = mnl_attr_get_u8(attr);
622262306a36Sopenharmony_ci		} else if (type == ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST) {
622362306a36Sopenharmony_ci			if (ynl_attr_validate(yarg, attr))
622462306a36Sopenharmony_ci				return MNL_CB_ERROR;
622562306a36Sopenharmony_ci			dst->_present.nest = 1;
622662306a36Sopenharmony_ci
622762306a36Sopenharmony_ci			parg.rsp_policy = &ethtool_cable_nest_nest;
622862306a36Sopenharmony_ci			parg.data = &dst->nest;
622962306a36Sopenharmony_ci			if (ethtool_cable_nest_parse(&parg, attr))
623062306a36Sopenharmony_ci				return MNL_CB_ERROR;
623162306a36Sopenharmony_ci		}
623262306a36Sopenharmony_ci	}
623362306a36Sopenharmony_ci
623462306a36Sopenharmony_ci	return MNL_CB_OK;
623562306a36Sopenharmony_ci}
623662306a36Sopenharmony_ci
623762306a36Sopenharmony_civoid ethtool_cable_test_tdr_ntf_free(struct ethtool_cable_test_tdr_ntf *rsp)
623862306a36Sopenharmony_ci{
623962306a36Sopenharmony_ci	ethtool_header_free(&rsp->obj.header);
624062306a36Sopenharmony_ci	ethtool_cable_nest_free(&rsp->obj.nest);
624162306a36Sopenharmony_ci	free(rsp);
624262306a36Sopenharmony_ci}
624362306a36Sopenharmony_ci
624462306a36Sopenharmony_cistatic const struct ynl_ntf_info ethtool_ntf_info[] =  {
624562306a36Sopenharmony_ci	[ETHTOOL_MSG_LINKINFO_NTF] =  {
624662306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_linkinfo_get_ntf),
624762306a36Sopenharmony_ci		.cb		= ethtool_linkinfo_get_rsp_parse,
624862306a36Sopenharmony_ci		.policy		= &ethtool_linkinfo_nest,
624962306a36Sopenharmony_ci		.free		= (void *)ethtool_linkinfo_get_ntf_free,
625062306a36Sopenharmony_ci	},
625162306a36Sopenharmony_ci	[ETHTOOL_MSG_LINKMODES_NTF] =  {
625262306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_linkmodes_get_ntf),
625362306a36Sopenharmony_ci		.cb		= ethtool_linkmodes_get_rsp_parse,
625462306a36Sopenharmony_ci		.policy		= &ethtool_linkmodes_nest,
625562306a36Sopenharmony_ci		.free		= (void *)ethtool_linkmodes_get_ntf_free,
625662306a36Sopenharmony_ci	},
625762306a36Sopenharmony_ci	[ETHTOOL_MSG_DEBUG_NTF] =  {
625862306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_debug_get_ntf),
625962306a36Sopenharmony_ci		.cb		= ethtool_debug_get_rsp_parse,
626062306a36Sopenharmony_ci		.policy		= &ethtool_debug_nest,
626162306a36Sopenharmony_ci		.free		= (void *)ethtool_debug_get_ntf_free,
626262306a36Sopenharmony_ci	},
626362306a36Sopenharmony_ci	[ETHTOOL_MSG_WOL_NTF] =  {
626462306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_wol_get_ntf),
626562306a36Sopenharmony_ci		.cb		= ethtool_wol_get_rsp_parse,
626662306a36Sopenharmony_ci		.policy		= &ethtool_wol_nest,
626762306a36Sopenharmony_ci		.free		= (void *)ethtool_wol_get_ntf_free,
626862306a36Sopenharmony_ci	},
626962306a36Sopenharmony_ci	[ETHTOOL_MSG_FEATURES_NTF] =  {
627062306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_features_get_ntf),
627162306a36Sopenharmony_ci		.cb		= ethtool_features_get_rsp_parse,
627262306a36Sopenharmony_ci		.policy		= &ethtool_features_nest,
627362306a36Sopenharmony_ci		.free		= (void *)ethtool_features_get_ntf_free,
627462306a36Sopenharmony_ci	},
627562306a36Sopenharmony_ci	[ETHTOOL_MSG_PRIVFLAGS_NTF] =  {
627662306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_privflags_get_ntf),
627762306a36Sopenharmony_ci		.cb		= ethtool_privflags_get_rsp_parse,
627862306a36Sopenharmony_ci		.policy		= &ethtool_privflags_nest,
627962306a36Sopenharmony_ci		.free		= (void *)ethtool_privflags_get_ntf_free,
628062306a36Sopenharmony_ci	},
628162306a36Sopenharmony_ci	[ETHTOOL_MSG_RINGS_NTF] =  {
628262306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_rings_get_ntf),
628362306a36Sopenharmony_ci		.cb		= ethtool_rings_get_rsp_parse,
628462306a36Sopenharmony_ci		.policy		= &ethtool_rings_nest,
628562306a36Sopenharmony_ci		.free		= (void *)ethtool_rings_get_ntf_free,
628662306a36Sopenharmony_ci	},
628762306a36Sopenharmony_ci	[ETHTOOL_MSG_CHANNELS_NTF] =  {
628862306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_channels_get_ntf),
628962306a36Sopenharmony_ci		.cb		= ethtool_channels_get_rsp_parse,
629062306a36Sopenharmony_ci		.policy		= &ethtool_channels_nest,
629162306a36Sopenharmony_ci		.free		= (void *)ethtool_channels_get_ntf_free,
629262306a36Sopenharmony_ci	},
629362306a36Sopenharmony_ci	[ETHTOOL_MSG_COALESCE_NTF] =  {
629462306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_coalesce_get_ntf),
629562306a36Sopenharmony_ci		.cb		= ethtool_coalesce_get_rsp_parse,
629662306a36Sopenharmony_ci		.policy		= &ethtool_coalesce_nest,
629762306a36Sopenharmony_ci		.free		= (void *)ethtool_coalesce_get_ntf_free,
629862306a36Sopenharmony_ci	},
629962306a36Sopenharmony_ci	[ETHTOOL_MSG_PAUSE_NTF] =  {
630062306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_pause_get_ntf),
630162306a36Sopenharmony_ci		.cb		= ethtool_pause_get_rsp_parse,
630262306a36Sopenharmony_ci		.policy		= &ethtool_pause_nest,
630362306a36Sopenharmony_ci		.free		= (void *)ethtool_pause_get_ntf_free,
630462306a36Sopenharmony_ci	},
630562306a36Sopenharmony_ci	[ETHTOOL_MSG_EEE_NTF] =  {
630662306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_eee_get_ntf),
630762306a36Sopenharmony_ci		.cb		= ethtool_eee_get_rsp_parse,
630862306a36Sopenharmony_ci		.policy		= &ethtool_eee_nest,
630962306a36Sopenharmony_ci		.free		= (void *)ethtool_eee_get_ntf_free,
631062306a36Sopenharmony_ci	},
631162306a36Sopenharmony_ci	[ETHTOOL_MSG_CABLE_TEST_NTF] =  {
631262306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_cable_test_ntf),
631362306a36Sopenharmony_ci		.cb		= ethtool_cable_test_ntf_rsp_parse,
631462306a36Sopenharmony_ci		.policy		= &ethtool_cable_test_ntf_nest,
631562306a36Sopenharmony_ci		.free		= (void *)ethtool_cable_test_ntf_free,
631662306a36Sopenharmony_ci	},
631762306a36Sopenharmony_ci	[ETHTOOL_MSG_CABLE_TEST_TDR_NTF] =  {
631862306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_cable_test_tdr_ntf),
631962306a36Sopenharmony_ci		.cb		= ethtool_cable_test_tdr_ntf_rsp_parse,
632062306a36Sopenharmony_ci		.policy		= &ethtool_cable_test_tdr_ntf_nest,
632162306a36Sopenharmony_ci		.free		= (void *)ethtool_cable_test_tdr_ntf_free,
632262306a36Sopenharmony_ci	},
632362306a36Sopenharmony_ci	[ETHTOOL_MSG_FEC_NTF] =  {
632462306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_fec_get_ntf),
632562306a36Sopenharmony_ci		.cb		= ethtool_fec_get_rsp_parse,
632662306a36Sopenharmony_ci		.policy		= &ethtool_fec_nest,
632762306a36Sopenharmony_ci		.free		= (void *)ethtool_fec_get_ntf_free,
632862306a36Sopenharmony_ci	},
632962306a36Sopenharmony_ci	[ETHTOOL_MSG_MODULE_NTF] =  {
633062306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_module_get_ntf),
633162306a36Sopenharmony_ci		.cb		= ethtool_module_get_rsp_parse,
633262306a36Sopenharmony_ci		.policy		= &ethtool_module_nest,
633362306a36Sopenharmony_ci		.free		= (void *)ethtool_module_get_ntf_free,
633462306a36Sopenharmony_ci	},
633562306a36Sopenharmony_ci	[ETHTOOL_MSG_PLCA_NTF] =  {
633662306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_plca_get_cfg_ntf),
633762306a36Sopenharmony_ci		.cb		= ethtool_plca_get_cfg_rsp_parse,
633862306a36Sopenharmony_ci		.policy		= &ethtool_plca_nest,
633962306a36Sopenharmony_ci		.free		= (void *)ethtool_plca_get_cfg_ntf_free,
634062306a36Sopenharmony_ci	},
634162306a36Sopenharmony_ci	[ETHTOOL_MSG_MM_NTF] =  {
634262306a36Sopenharmony_ci		.alloc_sz	= sizeof(struct ethtool_mm_get_ntf),
634362306a36Sopenharmony_ci		.cb		= ethtool_mm_get_rsp_parse,
634462306a36Sopenharmony_ci		.policy		= &ethtool_mm_nest,
634562306a36Sopenharmony_ci		.free		= (void *)ethtool_mm_get_ntf_free,
634662306a36Sopenharmony_ci	},
634762306a36Sopenharmony_ci};
634862306a36Sopenharmony_ci
634962306a36Sopenharmony_ciconst struct ynl_family ynl_ethtool_family =  {
635062306a36Sopenharmony_ci	.name		= "ethtool",
635162306a36Sopenharmony_ci	.ntf_info	= ethtool_ntf_info,
635262306a36Sopenharmony_ci	.ntf_info_size	= MNL_ARRAY_SIZE(ethtool_ntf_info),
635362306a36Sopenharmony_ci};
6354