Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.7-rc6 6370 lines 187 kB view raw
1// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 2/* Do not edit directly, auto-generated from: */ 3/* Documentation/netlink/specs/ethtool.yaml */ 4/* YNL-GEN user source */ 5/* YNL-ARG --user-header linux/ethtool_netlink.h --exclude-op stats-get */ 6 7#include <stdlib.h> 8#include <string.h> 9#include "ethtool-user.h" 10#include "ynl.h" 11#include <linux/ethtool.h> 12 13#include <libmnl/libmnl.h> 14#include <linux/genetlink.h> 15 16#include "linux/ethtool_netlink.h" 17 18/* Enums */ 19static const char * const ethtool_op_strmap[] = { 20 [ETHTOOL_MSG_STRSET_GET] = "strset-get", 21 [ETHTOOL_MSG_LINKINFO_GET] = "linkinfo-get", 22 [3] = "linkinfo-ntf", 23 [ETHTOOL_MSG_LINKMODES_GET] = "linkmodes-get", 24 [5] = "linkmodes-ntf", 25 [ETHTOOL_MSG_LINKSTATE_GET] = "linkstate-get", 26 [ETHTOOL_MSG_DEBUG_GET] = "debug-get", 27 [8] = "debug-ntf", 28 [ETHTOOL_MSG_WOL_GET] = "wol-get", 29 [10] = "wol-ntf", 30 [ETHTOOL_MSG_FEATURES_GET] = "features-get", 31 [ETHTOOL_MSG_FEATURES_SET] = "features-set", 32 [13] = "features-ntf", 33 [14] = "privflags-get", 34 [15] = "privflags-ntf", 35 [16] = "rings-get", 36 [17] = "rings-ntf", 37 [18] = "channels-get", 38 [19] = "channels-ntf", 39 [20] = "coalesce-get", 40 [21] = "coalesce-ntf", 41 [22] = "pause-get", 42 [23] = "pause-ntf", 43 [24] = "eee-get", 44 [25] = "eee-ntf", 45 [26] = "tsinfo-get", 46 [27] = "cable-test-ntf", 47 [28] = "cable-test-tdr-ntf", 48 [29] = "tunnel-info-get", 49 [30] = "fec-get", 50 [31] = "fec-ntf", 51 [32] = "module-eeprom-get", 52 [34] = "phc-vclocks-get", 53 [35] = "module-get", 54 [36] = "module-ntf", 55 [37] = "pse-get", 56 [ETHTOOL_MSG_RSS_GET] = "rss-get", 57 [ETHTOOL_MSG_PLCA_GET_CFG] = "plca-get-cfg", 58 [40] = "plca-get-status", 59 [41] = "plca-ntf", 60 [ETHTOOL_MSG_MM_GET] = "mm-get", 61 [43] = "mm-ntf", 62}; 63 64const char *ethtool_op_str(int op) 65{ 66 if (op < 0 || op >= (int)MNL_ARRAY_SIZE(ethtool_op_strmap)) 67 return NULL; 68 return ethtool_op_strmap[op]; 69} 70 71static const char * const ethtool_udp_tunnel_type_strmap[] = { 72 [0] = "vxlan", 73 [1] = "geneve", 74 [2] = "vxlan-gpe", 75}; 76 77const char *ethtool_udp_tunnel_type_str(int value) 78{ 79 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(ethtool_udp_tunnel_type_strmap)) 80 return NULL; 81 return ethtool_udp_tunnel_type_strmap[value]; 82} 83 84static const char * const ethtool_stringset_strmap[] = { 85}; 86 87const char *ethtool_stringset_str(enum ethtool_stringset value) 88{ 89 if (value < 0 || value >= (int)MNL_ARRAY_SIZE(ethtool_stringset_strmap)) 90 return NULL; 91 return ethtool_stringset_strmap[value]; 92} 93 94/* Policies */ 95struct ynl_policy_attr ethtool_header_policy[ETHTOOL_A_HEADER_MAX + 1] = { 96 [ETHTOOL_A_HEADER_DEV_INDEX] = { .name = "dev-index", .type = YNL_PT_U32, }, 97 [ETHTOOL_A_HEADER_DEV_NAME] = { .name = "dev-name", .type = YNL_PT_NUL_STR, }, 98 [ETHTOOL_A_HEADER_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, 99}; 100 101struct ynl_policy_nest ethtool_header_nest = { 102 .max_attr = ETHTOOL_A_HEADER_MAX, 103 .table = ethtool_header_policy, 104}; 105 106struct ynl_policy_attr ethtool_pause_stat_policy[ETHTOOL_A_PAUSE_STAT_MAX + 1] = { 107 [ETHTOOL_A_PAUSE_STAT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, 108 [ETHTOOL_A_PAUSE_STAT_TX_FRAMES] = { .name = "tx-frames", .type = YNL_PT_U64, }, 109 [ETHTOOL_A_PAUSE_STAT_RX_FRAMES] = { .name = "rx-frames", .type = YNL_PT_U64, }, 110}; 111 112struct ynl_policy_nest ethtool_pause_stat_nest = { 113 .max_attr = ETHTOOL_A_PAUSE_STAT_MAX, 114 .table = ethtool_pause_stat_policy, 115}; 116 117struct ynl_policy_attr ethtool_cable_test_tdr_cfg_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX + 1] = { 118 [ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST] = { .name = "first", .type = YNL_PT_U32, }, 119 [ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST] = { .name = "last", .type = YNL_PT_U32, }, 120 [ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP] = { .name = "step", .type = YNL_PT_U32, }, 121 [ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR] = { .name = "pair", .type = YNL_PT_U8, }, 122}; 123 124struct ynl_policy_nest ethtool_cable_test_tdr_cfg_nest = { 125 .max_attr = ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX, 126 .table = ethtool_cable_test_tdr_cfg_policy, 127}; 128 129struct ynl_policy_attr ethtool_fec_stat_policy[ETHTOOL_A_FEC_STAT_MAX + 1] = { 130 [ETHTOOL_A_FEC_STAT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, 131 [ETHTOOL_A_FEC_STAT_CORRECTED] = { .name = "corrected", .type = YNL_PT_BINARY,}, 132 [ETHTOOL_A_FEC_STAT_UNCORR] = { .name = "uncorr", .type = YNL_PT_BINARY,}, 133 [ETHTOOL_A_FEC_STAT_CORR_BITS] = { .name = "corr-bits", .type = YNL_PT_BINARY,}, 134}; 135 136struct ynl_policy_nest ethtool_fec_stat_nest = { 137 .max_attr = ETHTOOL_A_FEC_STAT_MAX, 138 .table = ethtool_fec_stat_policy, 139}; 140 141struct ynl_policy_attr ethtool_mm_stat_policy[ETHTOOL_A_MM_STAT_MAX + 1] = { 142 [ETHTOOL_A_MM_STAT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, 143 [ETHTOOL_A_MM_STAT_REASSEMBLY_ERRORS] = { .name = "reassembly-errors", .type = YNL_PT_U64, }, 144 [ETHTOOL_A_MM_STAT_SMD_ERRORS] = { .name = "smd-errors", .type = YNL_PT_U64, }, 145 [ETHTOOL_A_MM_STAT_REASSEMBLY_OK] = { .name = "reassembly-ok", .type = YNL_PT_U64, }, 146 [ETHTOOL_A_MM_STAT_RX_FRAG_COUNT] = { .name = "rx-frag-count", .type = YNL_PT_U64, }, 147 [ETHTOOL_A_MM_STAT_TX_FRAG_COUNT] = { .name = "tx-frag-count", .type = YNL_PT_U64, }, 148 [ETHTOOL_A_MM_STAT_HOLD_COUNT] = { .name = "hold-count", .type = YNL_PT_U64, }, 149}; 150 151struct ynl_policy_nest ethtool_mm_stat_nest = { 152 .max_attr = ETHTOOL_A_MM_STAT_MAX, 153 .table = ethtool_mm_stat_policy, 154}; 155 156struct ynl_policy_attr ethtool_cable_result_policy[ETHTOOL_A_CABLE_RESULT_MAX + 1] = { 157 [ETHTOOL_A_CABLE_RESULT_PAIR] = { .name = "pair", .type = YNL_PT_U8, }, 158 [ETHTOOL_A_CABLE_RESULT_CODE] = { .name = "code", .type = YNL_PT_U8, }, 159}; 160 161struct ynl_policy_nest ethtool_cable_result_nest = { 162 .max_attr = ETHTOOL_A_CABLE_RESULT_MAX, 163 .table = ethtool_cable_result_policy, 164}; 165 166struct ynl_policy_attr ethtool_cable_fault_length_policy[ETHTOOL_A_CABLE_FAULT_LENGTH_MAX + 1] = { 167 [ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR] = { .name = "pair", .type = YNL_PT_U8, }, 168 [ETHTOOL_A_CABLE_FAULT_LENGTH_CM] = { .name = "cm", .type = YNL_PT_U32, }, 169}; 170 171struct ynl_policy_nest ethtool_cable_fault_length_nest = { 172 .max_attr = ETHTOOL_A_CABLE_FAULT_LENGTH_MAX, 173 .table = ethtool_cable_fault_length_policy, 174}; 175 176struct ynl_policy_attr ethtool_bitset_bit_policy[ETHTOOL_A_BITSET_BIT_MAX + 1] = { 177 [ETHTOOL_A_BITSET_BIT_INDEX] = { .name = "index", .type = YNL_PT_U32, }, 178 [ETHTOOL_A_BITSET_BIT_NAME] = { .name = "name", .type = YNL_PT_NUL_STR, }, 179 [ETHTOOL_A_BITSET_BIT_VALUE] = { .name = "value", .type = YNL_PT_FLAG, }, 180}; 181 182struct ynl_policy_nest ethtool_bitset_bit_nest = { 183 .max_attr = ETHTOOL_A_BITSET_BIT_MAX, 184 .table = ethtool_bitset_bit_policy, 185}; 186 187struct ynl_policy_attr ethtool_tunnel_udp_entry_policy[ETHTOOL_A_TUNNEL_UDP_ENTRY_MAX + 1] = { 188 [ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT] = { .name = "port", .type = YNL_PT_U16, }, 189 [ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE] = { .name = "type", .type = YNL_PT_U32, }, 190}; 191 192struct ynl_policy_nest ethtool_tunnel_udp_entry_nest = { 193 .max_attr = ETHTOOL_A_TUNNEL_UDP_ENTRY_MAX, 194 .table = ethtool_tunnel_udp_entry_policy, 195}; 196 197struct ynl_policy_attr ethtool_string_policy[ETHTOOL_A_STRING_MAX + 1] = { 198 [ETHTOOL_A_STRING_INDEX] = { .name = "index", .type = YNL_PT_U32, }, 199 [ETHTOOL_A_STRING_VALUE] = { .name = "value", .type = YNL_PT_NUL_STR, }, 200}; 201 202struct ynl_policy_nest ethtool_string_nest = { 203 .max_attr = ETHTOOL_A_STRING_MAX, 204 .table = ethtool_string_policy, 205}; 206 207struct ynl_policy_attr ethtool_cable_nest_policy[ETHTOOL_A_CABLE_NEST_MAX + 1] = { 208 [ETHTOOL_A_CABLE_NEST_RESULT] = { .name = "result", .type = YNL_PT_NEST, .nest = &ethtool_cable_result_nest, }, 209 [ETHTOOL_A_CABLE_NEST_FAULT_LENGTH] = { .name = "fault-length", .type = YNL_PT_NEST, .nest = &ethtool_cable_fault_length_nest, }, 210}; 211 212struct ynl_policy_nest ethtool_cable_nest_nest = { 213 .max_attr = ETHTOOL_A_CABLE_NEST_MAX, 214 .table = ethtool_cable_nest_policy, 215}; 216 217struct ynl_policy_attr ethtool_bitset_bits_policy[ETHTOOL_A_BITSET_BITS_MAX + 1] = { 218 [ETHTOOL_A_BITSET_BITS_BIT] = { .name = "bit", .type = YNL_PT_NEST, .nest = &ethtool_bitset_bit_nest, }, 219}; 220 221struct ynl_policy_nest ethtool_bitset_bits_nest = { 222 .max_attr = ETHTOOL_A_BITSET_BITS_MAX, 223 .table = ethtool_bitset_bits_policy, 224}; 225 226struct ynl_policy_attr ethtool_strings_policy[ETHTOOL_A_STRINGS_MAX + 1] = { 227 [ETHTOOL_A_STRINGS_STRING] = { .name = "string", .type = YNL_PT_NEST, .nest = &ethtool_string_nest, }, 228}; 229 230struct ynl_policy_nest ethtool_strings_nest = { 231 .max_attr = ETHTOOL_A_STRINGS_MAX, 232 .table = ethtool_strings_policy, 233}; 234 235struct ynl_policy_attr ethtool_bitset_policy[ETHTOOL_A_BITSET_MAX + 1] = { 236 [ETHTOOL_A_BITSET_NOMASK] = { .name = "nomask", .type = YNL_PT_FLAG, }, 237 [ETHTOOL_A_BITSET_SIZE] = { .name = "size", .type = YNL_PT_U32, }, 238 [ETHTOOL_A_BITSET_BITS] = { .name = "bits", .type = YNL_PT_NEST, .nest = &ethtool_bitset_bits_nest, }, 239}; 240 241struct ynl_policy_nest ethtool_bitset_nest = { 242 .max_attr = ETHTOOL_A_BITSET_MAX, 243 .table = ethtool_bitset_policy, 244}; 245 246struct ynl_policy_attr ethtool_stringset_policy[ETHTOOL_A_STRINGSET_MAX + 1] = { 247 [ETHTOOL_A_STRINGSET_ID] = { .name = "id", .type = YNL_PT_U32, }, 248 [ETHTOOL_A_STRINGSET_COUNT] = { .name = "count", .type = YNL_PT_U32, }, 249 [ETHTOOL_A_STRINGSET_STRINGS] = { .name = "strings", .type = YNL_PT_NEST, .nest = &ethtool_strings_nest, }, 250}; 251 252struct ynl_policy_nest ethtool_stringset_nest = { 253 .max_attr = ETHTOOL_A_STRINGSET_MAX, 254 .table = ethtool_stringset_policy, 255}; 256 257struct ynl_policy_attr ethtool_tunnel_udp_table_policy[ETHTOOL_A_TUNNEL_UDP_TABLE_MAX + 1] = { 258 [ETHTOOL_A_TUNNEL_UDP_TABLE_SIZE] = { .name = "size", .type = YNL_PT_U32, }, 259 [ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES] = { .name = "types", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 260 [ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY] = { .name = "entry", .type = YNL_PT_NEST, .nest = &ethtool_tunnel_udp_entry_nest, }, 261}; 262 263struct ynl_policy_nest ethtool_tunnel_udp_table_nest = { 264 .max_attr = ETHTOOL_A_TUNNEL_UDP_TABLE_MAX, 265 .table = ethtool_tunnel_udp_table_policy, 266}; 267 268struct ynl_policy_attr ethtool_stringsets_policy[ETHTOOL_A_STRINGSETS_MAX + 1] = { 269 [ETHTOOL_A_STRINGSETS_STRINGSET] = { .name = "stringset", .type = YNL_PT_NEST, .nest = &ethtool_stringset_nest, }, 270}; 271 272struct ynl_policy_nest ethtool_stringsets_nest = { 273 .max_attr = ETHTOOL_A_STRINGSETS_MAX, 274 .table = ethtool_stringsets_policy, 275}; 276 277struct ynl_policy_attr ethtool_tunnel_udp_policy[ETHTOOL_A_TUNNEL_UDP_MAX + 1] = { 278 [ETHTOOL_A_TUNNEL_UDP_TABLE] = { .name = "table", .type = YNL_PT_NEST, .nest = &ethtool_tunnel_udp_table_nest, }, 279}; 280 281struct ynl_policy_nest ethtool_tunnel_udp_nest = { 282 .max_attr = ETHTOOL_A_TUNNEL_UDP_MAX, 283 .table = ethtool_tunnel_udp_policy, 284}; 285 286struct ynl_policy_attr ethtool_strset_policy[ETHTOOL_A_STRSET_MAX + 1] = { 287 [ETHTOOL_A_STRSET_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 288 [ETHTOOL_A_STRSET_STRINGSETS] = { .name = "stringsets", .type = YNL_PT_NEST, .nest = &ethtool_stringsets_nest, }, 289 [ETHTOOL_A_STRSET_COUNTS_ONLY] = { .name = "counts-only", .type = YNL_PT_FLAG, }, 290}; 291 292struct ynl_policy_nest ethtool_strset_nest = { 293 .max_attr = ETHTOOL_A_STRSET_MAX, 294 .table = ethtool_strset_policy, 295}; 296 297struct ynl_policy_attr ethtool_linkinfo_policy[ETHTOOL_A_LINKINFO_MAX + 1] = { 298 [ETHTOOL_A_LINKINFO_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 299 [ETHTOOL_A_LINKINFO_PORT] = { .name = "port", .type = YNL_PT_U8, }, 300 [ETHTOOL_A_LINKINFO_PHYADDR] = { .name = "phyaddr", .type = YNL_PT_U8, }, 301 [ETHTOOL_A_LINKINFO_TP_MDIX] = { .name = "tp-mdix", .type = YNL_PT_U8, }, 302 [ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] = { .name = "tp-mdix-ctrl", .type = YNL_PT_U8, }, 303 [ETHTOOL_A_LINKINFO_TRANSCEIVER] = { .name = "transceiver", .type = YNL_PT_U8, }, 304}; 305 306struct ynl_policy_nest ethtool_linkinfo_nest = { 307 .max_attr = ETHTOOL_A_LINKINFO_MAX, 308 .table = ethtool_linkinfo_policy, 309}; 310 311struct ynl_policy_attr ethtool_linkmodes_policy[ETHTOOL_A_LINKMODES_MAX + 1] = { 312 [ETHTOOL_A_LINKMODES_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 313 [ETHTOOL_A_LINKMODES_AUTONEG] = { .name = "autoneg", .type = YNL_PT_U8, }, 314 [ETHTOOL_A_LINKMODES_OURS] = { .name = "ours", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 315 [ETHTOOL_A_LINKMODES_PEER] = { .name = "peer", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 316 [ETHTOOL_A_LINKMODES_SPEED] = { .name = "speed", .type = YNL_PT_U32, }, 317 [ETHTOOL_A_LINKMODES_DUPLEX] = { .name = "duplex", .type = YNL_PT_U8, }, 318 [ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG] = { .name = "master-slave-cfg", .type = YNL_PT_U8, }, 319 [ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE] = { .name = "master-slave-state", .type = YNL_PT_U8, }, 320 [ETHTOOL_A_LINKMODES_LANES] = { .name = "lanes", .type = YNL_PT_U32, }, 321 [ETHTOOL_A_LINKMODES_RATE_MATCHING] = { .name = "rate-matching", .type = YNL_PT_U8, }, 322}; 323 324struct ynl_policy_nest ethtool_linkmodes_nest = { 325 .max_attr = ETHTOOL_A_LINKMODES_MAX, 326 .table = ethtool_linkmodes_policy, 327}; 328 329struct ynl_policy_attr ethtool_linkstate_policy[ETHTOOL_A_LINKSTATE_MAX + 1] = { 330 [ETHTOOL_A_LINKSTATE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 331 [ETHTOOL_A_LINKSTATE_LINK] = { .name = "link", .type = YNL_PT_U8, }, 332 [ETHTOOL_A_LINKSTATE_SQI] = { .name = "sqi", .type = YNL_PT_U32, }, 333 [ETHTOOL_A_LINKSTATE_SQI_MAX] = { .name = "sqi-max", .type = YNL_PT_U32, }, 334 [ETHTOOL_A_LINKSTATE_EXT_STATE] = { .name = "ext-state", .type = YNL_PT_U8, }, 335 [ETHTOOL_A_LINKSTATE_EXT_SUBSTATE] = { .name = "ext-substate", .type = YNL_PT_U8, }, 336 [ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT] = { .name = "ext-down-cnt", .type = YNL_PT_U32, }, 337}; 338 339struct ynl_policy_nest ethtool_linkstate_nest = { 340 .max_attr = ETHTOOL_A_LINKSTATE_MAX, 341 .table = ethtool_linkstate_policy, 342}; 343 344struct ynl_policy_attr ethtool_debug_policy[ETHTOOL_A_DEBUG_MAX + 1] = { 345 [ETHTOOL_A_DEBUG_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 346 [ETHTOOL_A_DEBUG_MSGMASK] = { .name = "msgmask", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 347}; 348 349struct ynl_policy_nest ethtool_debug_nest = { 350 .max_attr = ETHTOOL_A_DEBUG_MAX, 351 .table = ethtool_debug_policy, 352}; 353 354struct ynl_policy_attr ethtool_wol_policy[ETHTOOL_A_WOL_MAX + 1] = { 355 [ETHTOOL_A_WOL_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 356 [ETHTOOL_A_WOL_MODES] = { .name = "modes", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 357 [ETHTOOL_A_WOL_SOPASS] = { .name = "sopass", .type = YNL_PT_BINARY,}, 358}; 359 360struct ynl_policy_nest ethtool_wol_nest = { 361 .max_attr = ETHTOOL_A_WOL_MAX, 362 .table = ethtool_wol_policy, 363}; 364 365struct ynl_policy_attr ethtool_features_policy[ETHTOOL_A_FEATURES_MAX + 1] = { 366 [ETHTOOL_A_FEATURES_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 367 [ETHTOOL_A_FEATURES_HW] = { .name = "hw", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 368 [ETHTOOL_A_FEATURES_WANTED] = { .name = "wanted", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 369 [ETHTOOL_A_FEATURES_ACTIVE] = { .name = "active", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 370 [ETHTOOL_A_FEATURES_NOCHANGE] = { .name = "nochange", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 371}; 372 373struct ynl_policy_nest ethtool_features_nest = { 374 .max_attr = ETHTOOL_A_FEATURES_MAX, 375 .table = ethtool_features_policy, 376}; 377 378struct ynl_policy_attr ethtool_privflags_policy[ETHTOOL_A_PRIVFLAGS_MAX + 1] = { 379 [ETHTOOL_A_PRIVFLAGS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 380 [ETHTOOL_A_PRIVFLAGS_FLAGS] = { .name = "flags", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 381}; 382 383struct ynl_policy_nest ethtool_privflags_nest = { 384 .max_attr = ETHTOOL_A_PRIVFLAGS_MAX, 385 .table = ethtool_privflags_policy, 386}; 387 388struct ynl_policy_attr ethtool_rings_policy[ETHTOOL_A_RINGS_MAX + 1] = { 389 [ETHTOOL_A_RINGS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 390 [ETHTOOL_A_RINGS_RX_MAX] = { .name = "rx-max", .type = YNL_PT_U32, }, 391 [ETHTOOL_A_RINGS_RX_MINI_MAX] = { .name = "rx-mini-max", .type = YNL_PT_U32, }, 392 [ETHTOOL_A_RINGS_RX_JUMBO_MAX] = { .name = "rx-jumbo-max", .type = YNL_PT_U32, }, 393 [ETHTOOL_A_RINGS_TX_MAX] = { .name = "tx-max", .type = YNL_PT_U32, }, 394 [ETHTOOL_A_RINGS_RX] = { .name = "rx", .type = YNL_PT_U32, }, 395 [ETHTOOL_A_RINGS_RX_MINI] = { .name = "rx-mini", .type = YNL_PT_U32, }, 396 [ETHTOOL_A_RINGS_RX_JUMBO] = { .name = "rx-jumbo", .type = YNL_PT_U32, }, 397 [ETHTOOL_A_RINGS_TX] = { .name = "tx", .type = YNL_PT_U32, }, 398 [ETHTOOL_A_RINGS_RX_BUF_LEN] = { .name = "rx-buf-len", .type = YNL_PT_U32, }, 399 [ETHTOOL_A_RINGS_TCP_DATA_SPLIT] = { .name = "tcp-data-split", .type = YNL_PT_U8, }, 400 [ETHTOOL_A_RINGS_CQE_SIZE] = { .name = "cqe-size", .type = YNL_PT_U32, }, 401 [ETHTOOL_A_RINGS_TX_PUSH] = { .name = "tx-push", .type = YNL_PT_U8, }, 402 [ETHTOOL_A_RINGS_RX_PUSH] = { .name = "rx-push", .type = YNL_PT_U8, }, 403 [ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN] = { .name = "tx-push-buf-len", .type = YNL_PT_U32, }, 404 [ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX] = { .name = "tx-push-buf-len-max", .type = YNL_PT_U32, }, 405}; 406 407struct ynl_policy_nest ethtool_rings_nest = { 408 .max_attr = ETHTOOL_A_RINGS_MAX, 409 .table = ethtool_rings_policy, 410}; 411 412struct ynl_policy_attr ethtool_channels_policy[ETHTOOL_A_CHANNELS_MAX + 1] = { 413 [ETHTOOL_A_CHANNELS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 414 [ETHTOOL_A_CHANNELS_RX_MAX] = { .name = "rx-max", .type = YNL_PT_U32, }, 415 [ETHTOOL_A_CHANNELS_TX_MAX] = { .name = "tx-max", .type = YNL_PT_U32, }, 416 [ETHTOOL_A_CHANNELS_OTHER_MAX] = { .name = "other-max", .type = YNL_PT_U32, }, 417 [ETHTOOL_A_CHANNELS_COMBINED_MAX] = { .name = "combined-max", .type = YNL_PT_U32, }, 418 [ETHTOOL_A_CHANNELS_RX_COUNT] = { .name = "rx-count", .type = YNL_PT_U32, }, 419 [ETHTOOL_A_CHANNELS_TX_COUNT] = { .name = "tx-count", .type = YNL_PT_U32, }, 420 [ETHTOOL_A_CHANNELS_OTHER_COUNT] = { .name = "other-count", .type = YNL_PT_U32, }, 421 [ETHTOOL_A_CHANNELS_COMBINED_COUNT] = { .name = "combined-count", .type = YNL_PT_U32, }, 422}; 423 424struct ynl_policy_nest ethtool_channels_nest = { 425 .max_attr = ETHTOOL_A_CHANNELS_MAX, 426 .table = ethtool_channels_policy, 427}; 428 429struct ynl_policy_attr ethtool_coalesce_policy[ETHTOOL_A_COALESCE_MAX + 1] = { 430 [ETHTOOL_A_COALESCE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 431 [ETHTOOL_A_COALESCE_RX_USECS] = { .name = "rx-usecs", .type = YNL_PT_U32, }, 432 [ETHTOOL_A_COALESCE_RX_MAX_FRAMES] = { .name = "rx-max-frames", .type = YNL_PT_U32, }, 433 [ETHTOOL_A_COALESCE_RX_USECS_IRQ] = { .name = "rx-usecs-irq", .type = YNL_PT_U32, }, 434 [ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ] = { .name = "rx-max-frames-irq", .type = YNL_PT_U32, }, 435 [ETHTOOL_A_COALESCE_TX_USECS] = { .name = "tx-usecs", .type = YNL_PT_U32, }, 436 [ETHTOOL_A_COALESCE_TX_MAX_FRAMES] = { .name = "tx-max-frames", .type = YNL_PT_U32, }, 437 [ETHTOOL_A_COALESCE_TX_USECS_IRQ] = { .name = "tx-usecs-irq", .type = YNL_PT_U32, }, 438 [ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ] = { .name = "tx-max-frames-irq", .type = YNL_PT_U32, }, 439 [ETHTOOL_A_COALESCE_STATS_BLOCK_USECS] = { .name = "stats-block-usecs", .type = YNL_PT_U32, }, 440 [ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX] = { .name = "use-adaptive-rx", .type = YNL_PT_U8, }, 441 [ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX] = { .name = "use-adaptive-tx", .type = YNL_PT_U8, }, 442 [ETHTOOL_A_COALESCE_PKT_RATE_LOW] = { .name = "pkt-rate-low", .type = YNL_PT_U32, }, 443 [ETHTOOL_A_COALESCE_RX_USECS_LOW] = { .name = "rx-usecs-low", .type = YNL_PT_U32, }, 444 [ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW] = { .name = "rx-max-frames-low", .type = YNL_PT_U32, }, 445 [ETHTOOL_A_COALESCE_TX_USECS_LOW] = { .name = "tx-usecs-low", .type = YNL_PT_U32, }, 446 [ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW] = { .name = "tx-max-frames-low", .type = YNL_PT_U32, }, 447 [ETHTOOL_A_COALESCE_PKT_RATE_HIGH] = { .name = "pkt-rate-high", .type = YNL_PT_U32, }, 448 [ETHTOOL_A_COALESCE_RX_USECS_HIGH] = { .name = "rx-usecs-high", .type = YNL_PT_U32, }, 449 [ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH] = { .name = "rx-max-frames-high", .type = YNL_PT_U32, }, 450 [ETHTOOL_A_COALESCE_TX_USECS_HIGH] = { .name = "tx-usecs-high", .type = YNL_PT_U32, }, 451 [ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH] = { .name = "tx-max-frames-high", .type = YNL_PT_U32, }, 452 [ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL] = { .name = "rate-sample-interval", .type = YNL_PT_U32, }, 453 [ETHTOOL_A_COALESCE_USE_CQE_MODE_TX] = { .name = "use-cqe-mode-tx", .type = YNL_PT_U8, }, 454 [ETHTOOL_A_COALESCE_USE_CQE_MODE_RX] = { .name = "use-cqe-mode-rx", .type = YNL_PT_U8, }, 455 [ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES] = { .name = "tx-aggr-max-bytes", .type = YNL_PT_U32, }, 456 [ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES] = { .name = "tx-aggr-max-frames", .type = YNL_PT_U32, }, 457 [ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS] = { .name = "tx-aggr-time-usecs", .type = YNL_PT_U32, }, 458}; 459 460struct ynl_policy_nest ethtool_coalesce_nest = { 461 .max_attr = ETHTOOL_A_COALESCE_MAX, 462 .table = ethtool_coalesce_policy, 463}; 464 465struct ynl_policy_attr ethtool_pause_policy[ETHTOOL_A_PAUSE_MAX + 1] = { 466 [ETHTOOL_A_PAUSE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 467 [ETHTOOL_A_PAUSE_AUTONEG] = { .name = "autoneg", .type = YNL_PT_U8, }, 468 [ETHTOOL_A_PAUSE_RX] = { .name = "rx", .type = YNL_PT_U8, }, 469 [ETHTOOL_A_PAUSE_TX] = { .name = "tx", .type = YNL_PT_U8, }, 470 [ETHTOOL_A_PAUSE_STATS] = { .name = "stats", .type = YNL_PT_NEST, .nest = &ethtool_pause_stat_nest, }, 471 [ETHTOOL_A_PAUSE_STATS_SRC] = { .name = "stats-src", .type = YNL_PT_U32, }, 472}; 473 474struct ynl_policy_nest ethtool_pause_nest = { 475 .max_attr = ETHTOOL_A_PAUSE_MAX, 476 .table = ethtool_pause_policy, 477}; 478 479struct ynl_policy_attr ethtool_eee_policy[ETHTOOL_A_EEE_MAX + 1] = { 480 [ETHTOOL_A_EEE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 481 [ETHTOOL_A_EEE_MODES_OURS] = { .name = "modes-ours", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 482 [ETHTOOL_A_EEE_MODES_PEER] = { .name = "modes-peer", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 483 [ETHTOOL_A_EEE_ACTIVE] = { .name = "active", .type = YNL_PT_U8, }, 484 [ETHTOOL_A_EEE_ENABLED] = { .name = "enabled", .type = YNL_PT_U8, }, 485 [ETHTOOL_A_EEE_TX_LPI_ENABLED] = { .name = "tx-lpi-enabled", .type = YNL_PT_U8, }, 486 [ETHTOOL_A_EEE_TX_LPI_TIMER] = { .name = "tx-lpi-timer", .type = YNL_PT_U32, }, 487}; 488 489struct ynl_policy_nest ethtool_eee_nest = { 490 .max_attr = ETHTOOL_A_EEE_MAX, 491 .table = ethtool_eee_policy, 492}; 493 494struct ynl_policy_attr ethtool_tsinfo_policy[ETHTOOL_A_TSINFO_MAX + 1] = { 495 [ETHTOOL_A_TSINFO_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 496 [ETHTOOL_A_TSINFO_TIMESTAMPING] = { .name = "timestamping", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 497 [ETHTOOL_A_TSINFO_TX_TYPES] = { .name = "tx-types", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 498 [ETHTOOL_A_TSINFO_RX_FILTERS] = { .name = "rx-filters", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 499 [ETHTOOL_A_TSINFO_PHC_INDEX] = { .name = "phc-index", .type = YNL_PT_U32, }, 500}; 501 502struct ynl_policy_nest ethtool_tsinfo_nest = { 503 .max_attr = ETHTOOL_A_TSINFO_MAX, 504 .table = ethtool_tsinfo_policy, 505}; 506 507struct ynl_policy_attr ethtool_cable_test_policy[ETHTOOL_A_CABLE_TEST_MAX + 1] = { 508 [ETHTOOL_A_CABLE_TEST_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 509}; 510 511struct ynl_policy_nest ethtool_cable_test_nest = { 512 .max_attr = ETHTOOL_A_CABLE_TEST_MAX, 513 .table = ethtool_cable_test_policy, 514}; 515 516struct ynl_policy_attr ethtool_cable_test_ntf_policy[ETHTOOL_A_CABLE_TEST_NTF_MAX + 1] = { 517 [ETHTOOL_A_CABLE_TEST_NTF_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 518 [ETHTOOL_A_CABLE_TEST_NTF_STATUS] = { .name = "status", .type = YNL_PT_U8, }, 519 [ETHTOOL_A_CABLE_TEST_NTF_NEST] = { .name = "nest", .type = YNL_PT_NEST, .nest = &ethtool_cable_nest_nest, }, 520}; 521 522struct ynl_policy_nest ethtool_cable_test_ntf_nest = { 523 .max_attr = ETHTOOL_A_CABLE_TEST_NTF_MAX, 524 .table = ethtool_cable_test_ntf_policy, 525}; 526 527struct ynl_policy_attr ethtool_cable_test_tdr_policy[ETHTOOL_A_CABLE_TEST_TDR_MAX + 1] = { 528 [ETHTOOL_A_CABLE_TEST_TDR_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 529 [ETHTOOL_A_CABLE_TEST_TDR_CFG] = { .name = "cfg", .type = YNL_PT_NEST, .nest = &ethtool_cable_test_tdr_cfg_nest, }, 530}; 531 532struct ynl_policy_nest ethtool_cable_test_tdr_nest = { 533 .max_attr = ETHTOOL_A_CABLE_TEST_TDR_MAX, 534 .table = ethtool_cable_test_tdr_policy, 535}; 536 537struct ynl_policy_attr ethtool_cable_test_tdr_ntf_policy[ETHTOOL_A_CABLE_TEST_TDR_NTF_MAX + 1] = { 538 [ETHTOOL_A_CABLE_TEST_TDR_NTF_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 539 [ETHTOOL_A_CABLE_TEST_TDR_NTF_STATUS] = { .name = "status", .type = YNL_PT_U8, }, 540 [ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST] = { .name = "nest", .type = YNL_PT_NEST, .nest = &ethtool_cable_nest_nest, }, 541}; 542 543struct ynl_policy_nest ethtool_cable_test_tdr_ntf_nest = { 544 .max_attr = ETHTOOL_A_CABLE_TEST_TDR_NTF_MAX, 545 .table = ethtool_cable_test_tdr_ntf_policy, 546}; 547 548struct ynl_policy_attr ethtool_tunnel_info_policy[ETHTOOL_A_TUNNEL_INFO_MAX + 1] = { 549 [ETHTOOL_A_TUNNEL_INFO_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 550 [ETHTOOL_A_TUNNEL_INFO_UDP_PORTS] = { .name = "udp-ports", .type = YNL_PT_NEST, .nest = &ethtool_tunnel_udp_nest, }, 551}; 552 553struct ynl_policy_nest ethtool_tunnel_info_nest = { 554 .max_attr = ETHTOOL_A_TUNNEL_INFO_MAX, 555 .table = ethtool_tunnel_info_policy, 556}; 557 558struct ynl_policy_attr ethtool_fec_policy[ETHTOOL_A_FEC_MAX + 1] = { 559 [ETHTOOL_A_FEC_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 560 [ETHTOOL_A_FEC_MODES] = { .name = "modes", .type = YNL_PT_NEST, .nest = &ethtool_bitset_nest, }, 561 [ETHTOOL_A_FEC_AUTO] = { .name = "auto", .type = YNL_PT_U8, }, 562 [ETHTOOL_A_FEC_ACTIVE] = { .name = "active", .type = YNL_PT_U32, }, 563 [ETHTOOL_A_FEC_STATS] = { .name = "stats", .type = YNL_PT_NEST, .nest = &ethtool_fec_stat_nest, }, 564}; 565 566struct ynl_policy_nest ethtool_fec_nest = { 567 .max_attr = ETHTOOL_A_FEC_MAX, 568 .table = ethtool_fec_policy, 569}; 570 571struct ynl_policy_attr ethtool_module_eeprom_policy[ETHTOOL_A_MODULE_EEPROM_MAX + 1] = { 572 [ETHTOOL_A_MODULE_EEPROM_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 573 [ETHTOOL_A_MODULE_EEPROM_OFFSET] = { .name = "offset", .type = YNL_PT_U32, }, 574 [ETHTOOL_A_MODULE_EEPROM_LENGTH] = { .name = "length", .type = YNL_PT_U32, }, 575 [ETHTOOL_A_MODULE_EEPROM_PAGE] = { .name = "page", .type = YNL_PT_U8, }, 576 [ETHTOOL_A_MODULE_EEPROM_BANK] = { .name = "bank", .type = YNL_PT_U8, }, 577 [ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS] = { .name = "i2c-address", .type = YNL_PT_U8, }, 578 [ETHTOOL_A_MODULE_EEPROM_DATA] = { .name = "data", .type = YNL_PT_BINARY,}, 579}; 580 581struct ynl_policy_nest ethtool_module_eeprom_nest = { 582 .max_attr = ETHTOOL_A_MODULE_EEPROM_MAX, 583 .table = ethtool_module_eeprom_policy, 584}; 585 586struct ynl_policy_attr ethtool_phc_vclocks_policy[ETHTOOL_A_PHC_VCLOCKS_MAX + 1] = { 587 [ETHTOOL_A_PHC_VCLOCKS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 588 [ETHTOOL_A_PHC_VCLOCKS_NUM] = { .name = "num", .type = YNL_PT_U32, }, 589 [ETHTOOL_A_PHC_VCLOCKS_INDEX] = { .name = "index", .type = YNL_PT_BINARY,}, 590}; 591 592struct ynl_policy_nest ethtool_phc_vclocks_nest = { 593 .max_attr = ETHTOOL_A_PHC_VCLOCKS_MAX, 594 .table = ethtool_phc_vclocks_policy, 595}; 596 597struct ynl_policy_attr ethtool_module_policy[ETHTOOL_A_MODULE_MAX + 1] = { 598 [ETHTOOL_A_MODULE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 599 [ETHTOOL_A_MODULE_POWER_MODE_POLICY] = { .name = "power-mode-policy", .type = YNL_PT_U8, }, 600 [ETHTOOL_A_MODULE_POWER_MODE] = { .name = "power-mode", .type = YNL_PT_U8, }, 601}; 602 603struct ynl_policy_nest ethtool_module_nest = { 604 .max_attr = ETHTOOL_A_MODULE_MAX, 605 .table = ethtool_module_policy, 606}; 607 608struct ynl_policy_attr ethtool_pse_policy[ETHTOOL_A_PSE_MAX + 1] = { 609 [ETHTOOL_A_PSE_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 610 [ETHTOOL_A_PODL_PSE_ADMIN_STATE] = { .name = "admin-state", .type = YNL_PT_U32, }, 611 [ETHTOOL_A_PODL_PSE_ADMIN_CONTROL] = { .name = "admin-control", .type = YNL_PT_U32, }, 612 [ETHTOOL_A_PODL_PSE_PW_D_STATUS] = { .name = "pw-d-status", .type = YNL_PT_U32, }, 613}; 614 615struct ynl_policy_nest ethtool_pse_nest = { 616 .max_attr = ETHTOOL_A_PSE_MAX, 617 .table = ethtool_pse_policy, 618}; 619 620struct ynl_policy_attr ethtool_rss_policy[ETHTOOL_A_RSS_MAX + 1] = { 621 [ETHTOOL_A_RSS_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 622 [ETHTOOL_A_RSS_CONTEXT] = { .name = "context", .type = YNL_PT_U32, }, 623 [ETHTOOL_A_RSS_HFUNC] = { .name = "hfunc", .type = YNL_PT_U32, }, 624 [ETHTOOL_A_RSS_INDIR] = { .name = "indir", .type = YNL_PT_BINARY,}, 625 [ETHTOOL_A_RSS_HKEY] = { .name = "hkey", .type = YNL_PT_BINARY,}, 626}; 627 628struct ynl_policy_nest ethtool_rss_nest = { 629 .max_attr = ETHTOOL_A_RSS_MAX, 630 .table = ethtool_rss_policy, 631}; 632 633struct ynl_policy_attr ethtool_plca_policy[ETHTOOL_A_PLCA_MAX + 1] = { 634 [ETHTOOL_A_PLCA_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 635 [ETHTOOL_A_PLCA_VERSION] = { .name = "version", .type = YNL_PT_U16, }, 636 [ETHTOOL_A_PLCA_ENABLED] = { .name = "enabled", .type = YNL_PT_U8, }, 637 [ETHTOOL_A_PLCA_STATUS] = { .name = "status", .type = YNL_PT_U8, }, 638 [ETHTOOL_A_PLCA_NODE_CNT] = { .name = "node-cnt", .type = YNL_PT_U32, }, 639 [ETHTOOL_A_PLCA_NODE_ID] = { .name = "node-id", .type = YNL_PT_U32, }, 640 [ETHTOOL_A_PLCA_TO_TMR] = { .name = "to-tmr", .type = YNL_PT_U32, }, 641 [ETHTOOL_A_PLCA_BURST_CNT] = { .name = "burst-cnt", .type = YNL_PT_U32, }, 642 [ETHTOOL_A_PLCA_BURST_TMR] = { .name = "burst-tmr", .type = YNL_PT_U32, }, 643}; 644 645struct ynl_policy_nest ethtool_plca_nest = { 646 .max_attr = ETHTOOL_A_PLCA_MAX, 647 .table = ethtool_plca_policy, 648}; 649 650struct ynl_policy_attr ethtool_mm_policy[ETHTOOL_A_MM_MAX + 1] = { 651 [ETHTOOL_A_MM_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = &ethtool_header_nest, }, 652 [ETHTOOL_A_MM_PMAC_ENABLED] = { .name = "pmac-enabled", .type = YNL_PT_U8, }, 653 [ETHTOOL_A_MM_TX_ENABLED] = { .name = "tx-enabled", .type = YNL_PT_U8, }, 654 [ETHTOOL_A_MM_TX_ACTIVE] = { .name = "tx-active", .type = YNL_PT_U8, }, 655 [ETHTOOL_A_MM_TX_MIN_FRAG_SIZE] = { .name = "tx-min-frag-size", .type = YNL_PT_U32, }, 656 [ETHTOOL_A_MM_RX_MIN_FRAG_SIZE] = { .name = "rx-min-frag-size", .type = YNL_PT_U32, }, 657 [ETHTOOL_A_MM_VERIFY_ENABLED] = { .name = "verify-enabled", .type = YNL_PT_U8, }, 658 [ETHTOOL_A_MM_VERIFY_STATUS] = { .name = "verify-status", .type = YNL_PT_U8, }, 659 [ETHTOOL_A_MM_VERIFY_TIME] = { .name = "verify-time", .type = YNL_PT_U32, }, 660 [ETHTOOL_A_MM_MAX_VERIFY_TIME] = { .name = "max-verify-time", .type = YNL_PT_U32, }, 661 [ETHTOOL_A_MM_STATS] = { .name = "stats", .type = YNL_PT_NEST, .nest = &ethtool_mm_stat_nest, }, 662}; 663 664struct ynl_policy_nest ethtool_mm_nest = { 665 .max_attr = ETHTOOL_A_MM_MAX, 666 .table = ethtool_mm_policy, 667}; 668 669/* Common nested types */ 670void ethtool_header_free(struct ethtool_header *obj) 671{ 672 free(obj->dev_name); 673} 674 675int ethtool_header_put(struct nlmsghdr *nlh, unsigned int attr_type, 676 struct ethtool_header *obj) 677{ 678 struct nlattr *nest; 679 680 nest = mnl_attr_nest_start(nlh, attr_type); 681 if (obj->_present.dev_index) 682 mnl_attr_put_u32(nlh, ETHTOOL_A_HEADER_DEV_INDEX, obj->dev_index); 683 if (obj->_present.dev_name_len) 684 mnl_attr_put_strz(nlh, ETHTOOL_A_HEADER_DEV_NAME, obj->dev_name); 685 if (obj->_present.flags) 686 mnl_attr_put_u32(nlh, ETHTOOL_A_HEADER_FLAGS, obj->flags); 687 mnl_attr_nest_end(nlh, nest); 688 689 return 0; 690} 691 692int ethtool_header_parse(struct ynl_parse_arg *yarg, 693 const struct nlattr *nested) 694{ 695 struct ethtool_header *dst = yarg->data; 696 const struct nlattr *attr; 697 698 mnl_attr_for_each_nested(attr, nested) { 699 unsigned int type = mnl_attr_get_type(attr); 700 701 if (type == ETHTOOL_A_HEADER_DEV_INDEX) { 702 if (ynl_attr_validate(yarg, attr)) 703 return MNL_CB_ERROR; 704 dst->_present.dev_index = 1; 705 dst->dev_index = mnl_attr_get_u32(attr); 706 } else if (type == ETHTOOL_A_HEADER_DEV_NAME) { 707 unsigned int len; 708 709 if (ynl_attr_validate(yarg, attr)) 710 return MNL_CB_ERROR; 711 712 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr)); 713 dst->_present.dev_name_len = len; 714 dst->dev_name = malloc(len + 1); 715 memcpy(dst->dev_name, mnl_attr_get_str(attr), len); 716 dst->dev_name[len] = 0; 717 } else if (type == ETHTOOL_A_HEADER_FLAGS) { 718 if (ynl_attr_validate(yarg, attr)) 719 return MNL_CB_ERROR; 720 dst->_present.flags = 1; 721 dst->flags = mnl_attr_get_u32(attr); 722 } 723 } 724 725 return 0; 726} 727 728void ethtool_pause_stat_free(struct ethtool_pause_stat *obj) 729{ 730} 731 732int ethtool_pause_stat_put(struct nlmsghdr *nlh, unsigned int attr_type, 733 struct ethtool_pause_stat *obj) 734{ 735 struct nlattr *nest; 736 737 nest = mnl_attr_nest_start(nlh, attr_type); 738 if (obj->_present.tx_frames) 739 mnl_attr_put_u64(nlh, ETHTOOL_A_PAUSE_STAT_TX_FRAMES, obj->tx_frames); 740 if (obj->_present.rx_frames) 741 mnl_attr_put_u64(nlh, ETHTOOL_A_PAUSE_STAT_RX_FRAMES, obj->rx_frames); 742 mnl_attr_nest_end(nlh, nest); 743 744 return 0; 745} 746 747int ethtool_pause_stat_parse(struct ynl_parse_arg *yarg, 748 const struct nlattr *nested) 749{ 750 struct ethtool_pause_stat *dst = yarg->data; 751 const struct nlattr *attr; 752 753 mnl_attr_for_each_nested(attr, nested) { 754 unsigned int type = mnl_attr_get_type(attr); 755 756 if (type == ETHTOOL_A_PAUSE_STAT_TX_FRAMES) { 757 if (ynl_attr_validate(yarg, attr)) 758 return MNL_CB_ERROR; 759 dst->_present.tx_frames = 1; 760 dst->tx_frames = mnl_attr_get_u64(attr); 761 } else if (type == ETHTOOL_A_PAUSE_STAT_RX_FRAMES) { 762 if (ynl_attr_validate(yarg, attr)) 763 return MNL_CB_ERROR; 764 dst->_present.rx_frames = 1; 765 dst->rx_frames = mnl_attr_get_u64(attr); 766 } 767 } 768 769 return 0; 770} 771 772void ethtool_cable_test_tdr_cfg_free(struct ethtool_cable_test_tdr_cfg *obj) 773{ 774} 775 776void ethtool_fec_stat_free(struct ethtool_fec_stat *obj) 777{ 778 free(obj->corrected); 779 free(obj->uncorr); 780 free(obj->corr_bits); 781} 782 783int ethtool_fec_stat_put(struct nlmsghdr *nlh, unsigned int attr_type, 784 struct ethtool_fec_stat *obj) 785{ 786 struct nlattr *nest; 787 788 nest = mnl_attr_nest_start(nlh, attr_type); 789 if (obj->_present.corrected_len) 790 mnl_attr_put(nlh, ETHTOOL_A_FEC_STAT_CORRECTED, obj->_present.corrected_len, obj->corrected); 791 if (obj->_present.uncorr_len) 792 mnl_attr_put(nlh, ETHTOOL_A_FEC_STAT_UNCORR, obj->_present.uncorr_len, obj->uncorr); 793 if (obj->_present.corr_bits_len) 794 mnl_attr_put(nlh, ETHTOOL_A_FEC_STAT_CORR_BITS, obj->_present.corr_bits_len, obj->corr_bits); 795 mnl_attr_nest_end(nlh, nest); 796 797 return 0; 798} 799 800int ethtool_fec_stat_parse(struct ynl_parse_arg *yarg, 801 const struct nlattr *nested) 802{ 803 struct ethtool_fec_stat *dst = yarg->data; 804 const struct nlattr *attr; 805 806 mnl_attr_for_each_nested(attr, nested) { 807 unsigned int type = mnl_attr_get_type(attr); 808 809 if (type == ETHTOOL_A_FEC_STAT_CORRECTED) { 810 unsigned int len; 811 812 if (ynl_attr_validate(yarg, attr)) 813 return MNL_CB_ERROR; 814 815 len = mnl_attr_get_payload_len(attr); 816 dst->_present.corrected_len = len; 817 dst->corrected = malloc(len); 818 memcpy(dst->corrected, mnl_attr_get_payload(attr), len); 819 } else if (type == ETHTOOL_A_FEC_STAT_UNCORR) { 820 unsigned int len; 821 822 if (ynl_attr_validate(yarg, attr)) 823 return MNL_CB_ERROR; 824 825 len = mnl_attr_get_payload_len(attr); 826 dst->_present.uncorr_len = len; 827 dst->uncorr = malloc(len); 828 memcpy(dst->uncorr, mnl_attr_get_payload(attr), len); 829 } else if (type == ETHTOOL_A_FEC_STAT_CORR_BITS) { 830 unsigned int len; 831 832 if (ynl_attr_validate(yarg, attr)) 833 return MNL_CB_ERROR; 834 835 len = mnl_attr_get_payload_len(attr); 836 dst->_present.corr_bits_len = len; 837 dst->corr_bits = malloc(len); 838 memcpy(dst->corr_bits, mnl_attr_get_payload(attr), len); 839 } 840 } 841 842 return 0; 843} 844 845void ethtool_mm_stat_free(struct ethtool_mm_stat *obj) 846{ 847} 848 849int ethtool_mm_stat_parse(struct ynl_parse_arg *yarg, 850 const struct nlattr *nested) 851{ 852 struct ethtool_mm_stat *dst = yarg->data; 853 const struct nlattr *attr; 854 855 mnl_attr_for_each_nested(attr, nested) { 856 unsigned int type = mnl_attr_get_type(attr); 857 858 if (type == ETHTOOL_A_MM_STAT_REASSEMBLY_ERRORS) { 859 if (ynl_attr_validate(yarg, attr)) 860 return MNL_CB_ERROR; 861 dst->_present.reassembly_errors = 1; 862 dst->reassembly_errors = mnl_attr_get_u64(attr); 863 } else if (type == ETHTOOL_A_MM_STAT_SMD_ERRORS) { 864 if (ynl_attr_validate(yarg, attr)) 865 return MNL_CB_ERROR; 866 dst->_present.smd_errors = 1; 867 dst->smd_errors = mnl_attr_get_u64(attr); 868 } else if (type == ETHTOOL_A_MM_STAT_REASSEMBLY_OK) { 869 if (ynl_attr_validate(yarg, attr)) 870 return MNL_CB_ERROR; 871 dst->_present.reassembly_ok = 1; 872 dst->reassembly_ok = mnl_attr_get_u64(attr); 873 } else if (type == ETHTOOL_A_MM_STAT_RX_FRAG_COUNT) { 874 if (ynl_attr_validate(yarg, attr)) 875 return MNL_CB_ERROR; 876 dst->_present.rx_frag_count = 1; 877 dst->rx_frag_count = mnl_attr_get_u64(attr); 878 } else if (type == ETHTOOL_A_MM_STAT_TX_FRAG_COUNT) { 879 if (ynl_attr_validate(yarg, attr)) 880 return MNL_CB_ERROR; 881 dst->_present.tx_frag_count = 1; 882 dst->tx_frag_count = mnl_attr_get_u64(attr); 883 } else if (type == ETHTOOL_A_MM_STAT_HOLD_COUNT) { 884 if (ynl_attr_validate(yarg, attr)) 885 return MNL_CB_ERROR; 886 dst->_present.hold_count = 1; 887 dst->hold_count = mnl_attr_get_u64(attr); 888 } 889 } 890 891 return 0; 892} 893 894void ethtool_cable_result_free(struct ethtool_cable_result *obj) 895{ 896} 897 898int ethtool_cable_result_parse(struct ynl_parse_arg *yarg, 899 const struct nlattr *nested) 900{ 901 struct ethtool_cable_result *dst = yarg->data; 902 const struct nlattr *attr; 903 904 mnl_attr_for_each_nested(attr, nested) { 905 unsigned int type = mnl_attr_get_type(attr); 906 907 if (type == ETHTOOL_A_CABLE_RESULT_PAIR) { 908 if (ynl_attr_validate(yarg, attr)) 909 return MNL_CB_ERROR; 910 dst->_present.pair = 1; 911 dst->pair = mnl_attr_get_u8(attr); 912 } else if (type == ETHTOOL_A_CABLE_RESULT_CODE) { 913 if (ynl_attr_validate(yarg, attr)) 914 return MNL_CB_ERROR; 915 dst->_present.code = 1; 916 dst->code = mnl_attr_get_u8(attr); 917 } 918 } 919 920 return 0; 921} 922 923void ethtool_cable_fault_length_free(struct ethtool_cable_fault_length *obj) 924{ 925} 926 927int ethtool_cable_fault_length_parse(struct ynl_parse_arg *yarg, 928 const struct nlattr *nested) 929{ 930 struct ethtool_cable_fault_length *dst = yarg->data; 931 const struct nlattr *attr; 932 933 mnl_attr_for_each_nested(attr, nested) { 934 unsigned int type = mnl_attr_get_type(attr); 935 936 if (type == ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR) { 937 if (ynl_attr_validate(yarg, attr)) 938 return MNL_CB_ERROR; 939 dst->_present.pair = 1; 940 dst->pair = mnl_attr_get_u8(attr); 941 } else if (type == ETHTOOL_A_CABLE_FAULT_LENGTH_CM) { 942 if (ynl_attr_validate(yarg, attr)) 943 return MNL_CB_ERROR; 944 dst->_present.cm = 1; 945 dst->cm = mnl_attr_get_u32(attr); 946 } 947 } 948 949 return 0; 950} 951 952void ethtool_bitset_bit_free(struct ethtool_bitset_bit *obj) 953{ 954 free(obj->name); 955} 956 957int ethtool_bitset_bit_put(struct nlmsghdr *nlh, unsigned int attr_type, 958 struct ethtool_bitset_bit *obj) 959{ 960 struct nlattr *nest; 961 962 nest = mnl_attr_nest_start(nlh, attr_type); 963 if (obj->_present.index) 964 mnl_attr_put_u32(nlh, ETHTOOL_A_BITSET_BIT_INDEX, obj->index); 965 if (obj->_present.name_len) 966 mnl_attr_put_strz(nlh, ETHTOOL_A_BITSET_BIT_NAME, obj->name); 967 if (obj->_present.value) 968 mnl_attr_put(nlh, ETHTOOL_A_BITSET_BIT_VALUE, 0, NULL); 969 mnl_attr_nest_end(nlh, nest); 970 971 return 0; 972} 973 974int ethtool_bitset_bit_parse(struct ynl_parse_arg *yarg, 975 const struct nlattr *nested) 976{ 977 struct ethtool_bitset_bit *dst = yarg->data; 978 const struct nlattr *attr; 979 980 mnl_attr_for_each_nested(attr, nested) { 981 unsigned int type = mnl_attr_get_type(attr); 982 983 if (type == ETHTOOL_A_BITSET_BIT_INDEX) { 984 if (ynl_attr_validate(yarg, attr)) 985 return MNL_CB_ERROR; 986 dst->_present.index = 1; 987 dst->index = mnl_attr_get_u32(attr); 988 } else if (type == ETHTOOL_A_BITSET_BIT_NAME) { 989 unsigned int len; 990 991 if (ynl_attr_validate(yarg, attr)) 992 return MNL_CB_ERROR; 993 994 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr)); 995 dst->_present.name_len = len; 996 dst->name = malloc(len + 1); 997 memcpy(dst->name, mnl_attr_get_str(attr), len); 998 dst->name[len] = 0; 999 } else if (type == ETHTOOL_A_BITSET_BIT_VALUE) { 1000 if (ynl_attr_validate(yarg, attr)) 1001 return MNL_CB_ERROR; 1002 dst->_present.value = 1; 1003 } 1004 } 1005 1006 return 0; 1007} 1008 1009void ethtool_tunnel_udp_entry_free(struct ethtool_tunnel_udp_entry *obj) 1010{ 1011} 1012 1013int ethtool_tunnel_udp_entry_parse(struct ynl_parse_arg *yarg, 1014 const struct nlattr *nested) 1015{ 1016 struct ethtool_tunnel_udp_entry *dst = yarg->data; 1017 const struct nlattr *attr; 1018 1019 mnl_attr_for_each_nested(attr, nested) { 1020 unsigned int type = mnl_attr_get_type(attr); 1021 1022 if (type == ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT) { 1023 if (ynl_attr_validate(yarg, attr)) 1024 return MNL_CB_ERROR; 1025 dst->_present.port = 1; 1026 dst->port = mnl_attr_get_u16(attr); 1027 } else if (type == ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE) { 1028 if (ynl_attr_validate(yarg, attr)) 1029 return MNL_CB_ERROR; 1030 dst->_present.type = 1; 1031 dst->type = mnl_attr_get_u32(attr); 1032 } 1033 } 1034 1035 return 0; 1036} 1037 1038void ethtool_string_free(struct ethtool_string *obj) 1039{ 1040 free(obj->value); 1041} 1042 1043int ethtool_string_put(struct nlmsghdr *nlh, unsigned int attr_type, 1044 struct ethtool_string *obj) 1045{ 1046 struct nlattr *nest; 1047 1048 nest = mnl_attr_nest_start(nlh, attr_type); 1049 if (obj->_present.index) 1050 mnl_attr_put_u32(nlh, ETHTOOL_A_STRING_INDEX, obj->index); 1051 if (obj->_present.value_len) 1052 mnl_attr_put_strz(nlh, ETHTOOL_A_STRING_VALUE, obj->value); 1053 mnl_attr_nest_end(nlh, nest); 1054 1055 return 0; 1056} 1057 1058int ethtool_string_parse(struct ynl_parse_arg *yarg, 1059 const struct nlattr *nested) 1060{ 1061 struct ethtool_string *dst = yarg->data; 1062 const struct nlattr *attr; 1063 1064 mnl_attr_for_each_nested(attr, nested) { 1065 unsigned int type = mnl_attr_get_type(attr); 1066 1067 if (type == ETHTOOL_A_STRING_INDEX) { 1068 if (ynl_attr_validate(yarg, attr)) 1069 return MNL_CB_ERROR; 1070 dst->_present.index = 1; 1071 dst->index = mnl_attr_get_u32(attr); 1072 } else if (type == ETHTOOL_A_STRING_VALUE) { 1073 unsigned int len; 1074 1075 if (ynl_attr_validate(yarg, attr)) 1076 return MNL_CB_ERROR; 1077 1078 len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr)); 1079 dst->_present.value_len = len; 1080 dst->value = malloc(len + 1); 1081 memcpy(dst->value, mnl_attr_get_str(attr), len); 1082 dst->value[len] = 0; 1083 } 1084 } 1085 1086 return 0; 1087} 1088 1089void ethtool_cable_nest_free(struct ethtool_cable_nest *obj) 1090{ 1091 ethtool_cable_result_free(&obj->result); 1092 ethtool_cable_fault_length_free(&obj->fault_length); 1093} 1094 1095int ethtool_cable_nest_parse(struct ynl_parse_arg *yarg, 1096 const struct nlattr *nested) 1097{ 1098 struct ethtool_cable_nest *dst = yarg->data; 1099 const struct nlattr *attr; 1100 struct ynl_parse_arg parg; 1101 1102 parg.ys = yarg->ys; 1103 1104 mnl_attr_for_each_nested(attr, nested) { 1105 unsigned int type = mnl_attr_get_type(attr); 1106 1107 if (type == ETHTOOL_A_CABLE_NEST_RESULT) { 1108 if (ynl_attr_validate(yarg, attr)) 1109 return MNL_CB_ERROR; 1110 dst->_present.result = 1; 1111 1112 parg.rsp_policy = &ethtool_cable_result_nest; 1113 parg.data = &dst->result; 1114 if (ethtool_cable_result_parse(&parg, attr)) 1115 return MNL_CB_ERROR; 1116 } else if (type == ETHTOOL_A_CABLE_NEST_FAULT_LENGTH) { 1117 if (ynl_attr_validate(yarg, attr)) 1118 return MNL_CB_ERROR; 1119 dst->_present.fault_length = 1; 1120 1121 parg.rsp_policy = &ethtool_cable_fault_length_nest; 1122 parg.data = &dst->fault_length; 1123 if (ethtool_cable_fault_length_parse(&parg, attr)) 1124 return MNL_CB_ERROR; 1125 } 1126 } 1127 1128 return 0; 1129} 1130 1131void ethtool_bitset_bits_free(struct ethtool_bitset_bits *obj) 1132{ 1133 unsigned int i; 1134 1135 for (i = 0; i < obj->n_bit; i++) 1136 ethtool_bitset_bit_free(&obj->bit[i]); 1137 free(obj->bit); 1138} 1139 1140int ethtool_bitset_bits_put(struct nlmsghdr *nlh, unsigned int attr_type, 1141 struct ethtool_bitset_bits *obj) 1142{ 1143 struct nlattr *nest; 1144 1145 nest = mnl_attr_nest_start(nlh, attr_type); 1146 for (unsigned int i = 0; i < obj->n_bit; i++) 1147 ethtool_bitset_bit_put(nlh, ETHTOOL_A_BITSET_BITS_BIT, &obj->bit[i]); 1148 mnl_attr_nest_end(nlh, nest); 1149 1150 return 0; 1151} 1152 1153int ethtool_bitset_bits_parse(struct ynl_parse_arg *yarg, 1154 const struct nlattr *nested) 1155{ 1156 struct ethtool_bitset_bits *dst = yarg->data; 1157 const struct nlattr *attr; 1158 struct ynl_parse_arg parg; 1159 unsigned int n_bit = 0; 1160 int i; 1161 1162 parg.ys = yarg->ys; 1163 1164 if (dst->bit) 1165 return ynl_error_parse(yarg, "attribute already present (bitset-bits.bit)"); 1166 1167 mnl_attr_for_each_nested(attr, nested) { 1168 unsigned int type = mnl_attr_get_type(attr); 1169 1170 if (type == ETHTOOL_A_BITSET_BITS_BIT) { 1171 n_bit++; 1172 } 1173 } 1174 1175 if (n_bit) { 1176 dst->bit = calloc(n_bit, sizeof(*dst->bit)); 1177 dst->n_bit = n_bit; 1178 i = 0; 1179 parg.rsp_policy = &ethtool_bitset_bit_nest; 1180 mnl_attr_for_each_nested(attr, nested) { 1181 if (mnl_attr_get_type(attr) == ETHTOOL_A_BITSET_BITS_BIT) { 1182 parg.data = &dst->bit[i]; 1183 if (ethtool_bitset_bit_parse(&parg, attr)) 1184 return MNL_CB_ERROR; 1185 i++; 1186 } 1187 } 1188 } 1189 1190 return 0; 1191} 1192 1193void ethtool_strings_free(struct ethtool_strings *obj) 1194{ 1195 unsigned int i; 1196 1197 for (i = 0; i < obj->n_string; i++) 1198 ethtool_string_free(&obj->string[i]); 1199 free(obj->string); 1200} 1201 1202int ethtool_strings_put(struct nlmsghdr *nlh, unsigned int attr_type, 1203 struct ethtool_strings *obj) 1204{ 1205 struct nlattr *nest; 1206 1207 nest = mnl_attr_nest_start(nlh, attr_type); 1208 for (unsigned int i = 0; i < obj->n_string; i++) 1209 ethtool_string_put(nlh, ETHTOOL_A_STRINGS_STRING, &obj->string[i]); 1210 mnl_attr_nest_end(nlh, nest); 1211 1212 return 0; 1213} 1214 1215int ethtool_strings_parse(struct ynl_parse_arg *yarg, 1216 const struct nlattr *nested) 1217{ 1218 struct ethtool_strings *dst = yarg->data; 1219 const struct nlattr *attr; 1220 struct ynl_parse_arg parg; 1221 unsigned int n_string = 0; 1222 int i; 1223 1224 parg.ys = yarg->ys; 1225 1226 if (dst->string) 1227 return ynl_error_parse(yarg, "attribute already present (strings.string)"); 1228 1229 mnl_attr_for_each_nested(attr, nested) { 1230 unsigned int type = mnl_attr_get_type(attr); 1231 1232 if (type == ETHTOOL_A_STRINGS_STRING) { 1233 n_string++; 1234 } 1235 } 1236 1237 if (n_string) { 1238 dst->string = calloc(n_string, sizeof(*dst->string)); 1239 dst->n_string = n_string; 1240 i = 0; 1241 parg.rsp_policy = &ethtool_string_nest; 1242 mnl_attr_for_each_nested(attr, nested) { 1243 if (mnl_attr_get_type(attr) == ETHTOOL_A_STRINGS_STRING) { 1244 parg.data = &dst->string[i]; 1245 if (ethtool_string_parse(&parg, attr)) 1246 return MNL_CB_ERROR; 1247 i++; 1248 } 1249 } 1250 } 1251 1252 return 0; 1253} 1254 1255void ethtool_bitset_free(struct ethtool_bitset *obj) 1256{ 1257 ethtool_bitset_bits_free(&obj->bits); 1258} 1259 1260int ethtool_bitset_put(struct nlmsghdr *nlh, unsigned int attr_type, 1261 struct ethtool_bitset *obj) 1262{ 1263 struct nlattr *nest; 1264 1265 nest = mnl_attr_nest_start(nlh, attr_type); 1266 if (obj->_present.nomask) 1267 mnl_attr_put(nlh, ETHTOOL_A_BITSET_NOMASK, 0, NULL); 1268 if (obj->_present.size) 1269 mnl_attr_put_u32(nlh, ETHTOOL_A_BITSET_SIZE, obj->size); 1270 if (obj->_present.bits) 1271 ethtool_bitset_bits_put(nlh, ETHTOOL_A_BITSET_BITS, &obj->bits); 1272 mnl_attr_nest_end(nlh, nest); 1273 1274 return 0; 1275} 1276 1277int ethtool_bitset_parse(struct ynl_parse_arg *yarg, 1278 const struct nlattr *nested) 1279{ 1280 struct ethtool_bitset *dst = yarg->data; 1281 const struct nlattr *attr; 1282 struct ynl_parse_arg parg; 1283 1284 parg.ys = yarg->ys; 1285 1286 mnl_attr_for_each_nested(attr, nested) { 1287 unsigned int type = mnl_attr_get_type(attr); 1288 1289 if (type == ETHTOOL_A_BITSET_NOMASK) { 1290 if (ynl_attr_validate(yarg, attr)) 1291 return MNL_CB_ERROR; 1292 dst->_present.nomask = 1; 1293 } else if (type == ETHTOOL_A_BITSET_SIZE) { 1294 if (ynl_attr_validate(yarg, attr)) 1295 return MNL_CB_ERROR; 1296 dst->_present.size = 1; 1297 dst->size = mnl_attr_get_u32(attr); 1298 } else if (type == ETHTOOL_A_BITSET_BITS) { 1299 if (ynl_attr_validate(yarg, attr)) 1300 return MNL_CB_ERROR; 1301 dst->_present.bits = 1; 1302 1303 parg.rsp_policy = &ethtool_bitset_bits_nest; 1304 parg.data = &dst->bits; 1305 if (ethtool_bitset_bits_parse(&parg, attr)) 1306 return MNL_CB_ERROR; 1307 } 1308 } 1309 1310 return 0; 1311} 1312 1313void ethtool_stringset_free(struct ethtool_stringset_ *obj) 1314{ 1315 unsigned int i; 1316 1317 for (i = 0; i < obj->n_strings; i++) 1318 ethtool_strings_free(&obj->strings[i]); 1319 free(obj->strings); 1320} 1321 1322int ethtool_stringset_put(struct nlmsghdr *nlh, unsigned int attr_type, 1323 struct ethtool_stringset_ *obj) 1324{ 1325 struct nlattr *nest; 1326 1327 nest = mnl_attr_nest_start(nlh, attr_type); 1328 if (obj->_present.id) 1329 mnl_attr_put_u32(nlh, ETHTOOL_A_STRINGSET_ID, obj->id); 1330 if (obj->_present.count) 1331 mnl_attr_put_u32(nlh, ETHTOOL_A_STRINGSET_COUNT, obj->count); 1332 for (unsigned int i = 0; i < obj->n_strings; i++) 1333 ethtool_strings_put(nlh, ETHTOOL_A_STRINGSET_STRINGS, &obj->strings[i]); 1334 mnl_attr_nest_end(nlh, nest); 1335 1336 return 0; 1337} 1338 1339int ethtool_stringset_parse(struct ynl_parse_arg *yarg, 1340 const struct nlattr *nested) 1341{ 1342 struct ethtool_stringset_ *dst = yarg->data; 1343 unsigned int n_strings = 0; 1344 const struct nlattr *attr; 1345 struct ynl_parse_arg parg; 1346 int i; 1347 1348 parg.ys = yarg->ys; 1349 1350 if (dst->strings) 1351 return ynl_error_parse(yarg, "attribute already present (stringset.strings)"); 1352 1353 mnl_attr_for_each_nested(attr, nested) { 1354 unsigned int type = mnl_attr_get_type(attr); 1355 1356 if (type == ETHTOOL_A_STRINGSET_ID) { 1357 if (ynl_attr_validate(yarg, attr)) 1358 return MNL_CB_ERROR; 1359 dst->_present.id = 1; 1360 dst->id = mnl_attr_get_u32(attr); 1361 } else if (type == ETHTOOL_A_STRINGSET_COUNT) { 1362 if (ynl_attr_validate(yarg, attr)) 1363 return MNL_CB_ERROR; 1364 dst->_present.count = 1; 1365 dst->count = mnl_attr_get_u32(attr); 1366 } else if (type == ETHTOOL_A_STRINGSET_STRINGS) { 1367 n_strings++; 1368 } 1369 } 1370 1371 if (n_strings) { 1372 dst->strings = calloc(n_strings, sizeof(*dst->strings)); 1373 dst->n_strings = n_strings; 1374 i = 0; 1375 parg.rsp_policy = &ethtool_strings_nest; 1376 mnl_attr_for_each_nested(attr, nested) { 1377 if (mnl_attr_get_type(attr) == ETHTOOL_A_STRINGSET_STRINGS) { 1378 parg.data = &dst->strings[i]; 1379 if (ethtool_strings_parse(&parg, attr)) 1380 return MNL_CB_ERROR; 1381 i++; 1382 } 1383 } 1384 } 1385 1386 return 0; 1387} 1388 1389void ethtool_tunnel_udp_table_free(struct ethtool_tunnel_udp_table *obj) 1390{ 1391 unsigned int i; 1392 1393 ethtool_bitset_free(&obj->types); 1394 for (i = 0; i < obj->n_entry; i++) 1395 ethtool_tunnel_udp_entry_free(&obj->entry[i]); 1396 free(obj->entry); 1397} 1398 1399int ethtool_tunnel_udp_table_parse(struct ynl_parse_arg *yarg, 1400 const struct nlattr *nested) 1401{ 1402 struct ethtool_tunnel_udp_table *dst = yarg->data; 1403 const struct nlattr *attr; 1404 struct ynl_parse_arg parg; 1405 unsigned int n_entry = 0; 1406 int i; 1407 1408 parg.ys = yarg->ys; 1409 1410 if (dst->entry) 1411 return ynl_error_parse(yarg, "attribute already present (tunnel-udp-table.entry)"); 1412 1413 mnl_attr_for_each_nested(attr, nested) { 1414 unsigned int type = mnl_attr_get_type(attr); 1415 1416 if (type == ETHTOOL_A_TUNNEL_UDP_TABLE_SIZE) { 1417 if (ynl_attr_validate(yarg, attr)) 1418 return MNL_CB_ERROR; 1419 dst->_present.size = 1; 1420 dst->size = mnl_attr_get_u32(attr); 1421 } else if (type == ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES) { 1422 if (ynl_attr_validate(yarg, attr)) 1423 return MNL_CB_ERROR; 1424 dst->_present.types = 1; 1425 1426 parg.rsp_policy = &ethtool_bitset_nest; 1427 parg.data = &dst->types; 1428 if (ethtool_bitset_parse(&parg, attr)) 1429 return MNL_CB_ERROR; 1430 } else if (type == ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY) { 1431 n_entry++; 1432 } 1433 } 1434 1435 if (n_entry) { 1436 dst->entry = calloc(n_entry, sizeof(*dst->entry)); 1437 dst->n_entry = n_entry; 1438 i = 0; 1439 parg.rsp_policy = &ethtool_tunnel_udp_entry_nest; 1440 mnl_attr_for_each_nested(attr, nested) { 1441 if (mnl_attr_get_type(attr) == ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY) { 1442 parg.data = &dst->entry[i]; 1443 if (ethtool_tunnel_udp_entry_parse(&parg, attr)) 1444 return MNL_CB_ERROR; 1445 i++; 1446 } 1447 } 1448 } 1449 1450 return 0; 1451} 1452 1453void ethtool_stringsets_free(struct ethtool_stringsets *obj) 1454{ 1455 unsigned int i; 1456 1457 for (i = 0; i < obj->n_stringset; i++) 1458 ethtool_stringset_free(&obj->stringset[i]); 1459 free(obj->stringset); 1460} 1461 1462int ethtool_stringsets_put(struct nlmsghdr *nlh, unsigned int attr_type, 1463 struct ethtool_stringsets *obj) 1464{ 1465 struct nlattr *nest; 1466 1467 nest = mnl_attr_nest_start(nlh, attr_type); 1468 for (unsigned int i = 0; i < obj->n_stringset; i++) 1469 ethtool_stringset_put(nlh, ETHTOOL_A_STRINGSETS_STRINGSET, &obj->stringset[i]); 1470 mnl_attr_nest_end(nlh, nest); 1471 1472 return 0; 1473} 1474 1475int ethtool_stringsets_parse(struct ynl_parse_arg *yarg, 1476 const struct nlattr *nested) 1477{ 1478 struct ethtool_stringsets *dst = yarg->data; 1479 unsigned int n_stringset = 0; 1480 const struct nlattr *attr; 1481 struct ynl_parse_arg parg; 1482 int i; 1483 1484 parg.ys = yarg->ys; 1485 1486 if (dst->stringset) 1487 return ynl_error_parse(yarg, "attribute already present (stringsets.stringset)"); 1488 1489 mnl_attr_for_each_nested(attr, nested) { 1490 unsigned int type = mnl_attr_get_type(attr); 1491 1492 if (type == ETHTOOL_A_STRINGSETS_STRINGSET) { 1493 n_stringset++; 1494 } 1495 } 1496 1497 if (n_stringset) { 1498 dst->stringset = calloc(n_stringset, sizeof(*dst->stringset)); 1499 dst->n_stringset = n_stringset; 1500 i = 0; 1501 parg.rsp_policy = &ethtool_stringset_nest; 1502 mnl_attr_for_each_nested(attr, nested) { 1503 if (mnl_attr_get_type(attr) == ETHTOOL_A_STRINGSETS_STRINGSET) { 1504 parg.data = &dst->stringset[i]; 1505 if (ethtool_stringset_parse(&parg, attr)) 1506 return MNL_CB_ERROR; 1507 i++; 1508 } 1509 } 1510 } 1511 1512 return 0; 1513} 1514 1515void ethtool_tunnel_udp_free(struct ethtool_tunnel_udp *obj) 1516{ 1517 ethtool_tunnel_udp_table_free(&obj->table); 1518} 1519 1520int ethtool_tunnel_udp_parse(struct ynl_parse_arg *yarg, 1521 const struct nlattr *nested) 1522{ 1523 struct ethtool_tunnel_udp *dst = yarg->data; 1524 const struct nlattr *attr; 1525 struct ynl_parse_arg parg; 1526 1527 parg.ys = yarg->ys; 1528 1529 mnl_attr_for_each_nested(attr, nested) { 1530 unsigned int type = mnl_attr_get_type(attr); 1531 1532 if (type == ETHTOOL_A_TUNNEL_UDP_TABLE) { 1533 if (ynl_attr_validate(yarg, attr)) 1534 return MNL_CB_ERROR; 1535 dst->_present.table = 1; 1536 1537 parg.rsp_policy = &ethtool_tunnel_udp_table_nest; 1538 parg.data = &dst->table; 1539 if (ethtool_tunnel_udp_table_parse(&parg, attr)) 1540 return MNL_CB_ERROR; 1541 } 1542 } 1543 1544 return 0; 1545} 1546 1547/* ============== ETHTOOL_MSG_STRSET_GET ============== */ 1548/* ETHTOOL_MSG_STRSET_GET - do */ 1549void ethtool_strset_get_req_free(struct ethtool_strset_get_req *req) 1550{ 1551 ethtool_header_free(&req->header); 1552 ethtool_stringsets_free(&req->stringsets); 1553 free(req); 1554} 1555 1556void ethtool_strset_get_rsp_free(struct ethtool_strset_get_rsp *rsp) 1557{ 1558 ethtool_header_free(&rsp->header); 1559 ethtool_stringsets_free(&rsp->stringsets); 1560 free(rsp); 1561} 1562 1563int ethtool_strset_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 1564{ 1565 struct ethtool_strset_get_rsp *dst; 1566 struct ynl_parse_arg *yarg = data; 1567 const struct nlattr *attr; 1568 struct ynl_parse_arg parg; 1569 1570 dst = yarg->data; 1571 parg.ys = yarg->ys; 1572 1573 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 1574 unsigned int type = mnl_attr_get_type(attr); 1575 1576 if (type == ETHTOOL_A_STRSET_HEADER) { 1577 if (ynl_attr_validate(yarg, attr)) 1578 return MNL_CB_ERROR; 1579 dst->_present.header = 1; 1580 1581 parg.rsp_policy = &ethtool_header_nest; 1582 parg.data = &dst->header; 1583 if (ethtool_header_parse(&parg, attr)) 1584 return MNL_CB_ERROR; 1585 } else if (type == ETHTOOL_A_STRSET_STRINGSETS) { 1586 if (ynl_attr_validate(yarg, attr)) 1587 return MNL_CB_ERROR; 1588 dst->_present.stringsets = 1; 1589 1590 parg.rsp_policy = &ethtool_stringsets_nest; 1591 parg.data = &dst->stringsets; 1592 if (ethtool_stringsets_parse(&parg, attr)) 1593 return MNL_CB_ERROR; 1594 } 1595 } 1596 1597 return MNL_CB_OK; 1598} 1599 1600struct ethtool_strset_get_rsp * 1601ethtool_strset_get(struct ynl_sock *ys, struct ethtool_strset_get_req *req) 1602{ 1603 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 1604 struct ethtool_strset_get_rsp *rsp; 1605 struct nlmsghdr *nlh; 1606 int err; 1607 1608 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_STRSET_GET, 1); 1609 ys->req_policy = &ethtool_strset_nest; 1610 yrs.yarg.rsp_policy = &ethtool_strset_nest; 1611 1612 if (req->_present.header) 1613 ethtool_header_put(nlh, ETHTOOL_A_STRSET_HEADER, &req->header); 1614 if (req->_present.stringsets) 1615 ethtool_stringsets_put(nlh, ETHTOOL_A_STRSET_STRINGSETS, &req->stringsets); 1616 if (req->_present.counts_only) 1617 mnl_attr_put(nlh, ETHTOOL_A_STRSET_COUNTS_ONLY, 0, NULL); 1618 1619 rsp = calloc(1, sizeof(*rsp)); 1620 yrs.yarg.data = rsp; 1621 yrs.cb = ethtool_strset_get_rsp_parse; 1622 yrs.rsp_cmd = ETHTOOL_MSG_STRSET_GET; 1623 1624 err = ynl_exec(ys, nlh, &yrs); 1625 if (err < 0) 1626 goto err_free; 1627 1628 return rsp; 1629 1630err_free: 1631 ethtool_strset_get_rsp_free(rsp); 1632 return NULL; 1633} 1634 1635/* ETHTOOL_MSG_STRSET_GET - dump */ 1636void ethtool_strset_get_list_free(struct ethtool_strset_get_list *rsp) 1637{ 1638 struct ethtool_strset_get_list *next = rsp; 1639 1640 while ((void *)next != YNL_LIST_END) { 1641 rsp = next; 1642 next = rsp->next; 1643 1644 ethtool_header_free(&rsp->obj.header); 1645 ethtool_stringsets_free(&rsp->obj.stringsets); 1646 free(rsp); 1647 } 1648} 1649 1650struct ethtool_strset_get_list * 1651ethtool_strset_get_dump(struct ynl_sock *ys, 1652 struct ethtool_strset_get_req_dump *req) 1653{ 1654 struct ynl_dump_state yds = {}; 1655 struct nlmsghdr *nlh; 1656 int err; 1657 1658 yds.ys = ys; 1659 yds.alloc_sz = sizeof(struct ethtool_strset_get_list); 1660 yds.cb = ethtool_strset_get_rsp_parse; 1661 yds.rsp_cmd = ETHTOOL_MSG_STRSET_GET; 1662 yds.rsp_policy = &ethtool_strset_nest; 1663 1664 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_STRSET_GET, 1); 1665 ys->req_policy = &ethtool_strset_nest; 1666 1667 if (req->_present.header) 1668 ethtool_header_put(nlh, ETHTOOL_A_STRSET_HEADER, &req->header); 1669 if (req->_present.stringsets) 1670 ethtool_stringsets_put(nlh, ETHTOOL_A_STRSET_STRINGSETS, &req->stringsets); 1671 if (req->_present.counts_only) 1672 mnl_attr_put(nlh, ETHTOOL_A_STRSET_COUNTS_ONLY, 0, NULL); 1673 1674 err = ynl_exec_dump(ys, nlh, &yds); 1675 if (err < 0) 1676 goto free_list; 1677 1678 return yds.first; 1679 1680free_list: 1681 ethtool_strset_get_list_free(yds.first); 1682 return NULL; 1683} 1684 1685/* ============== ETHTOOL_MSG_LINKINFO_GET ============== */ 1686/* ETHTOOL_MSG_LINKINFO_GET - do */ 1687void ethtool_linkinfo_get_req_free(struct ethtool_linkinfo_get_req *req) 1688{ 1689 ethtool_header_free(&req->header); 1690 free(req); 1691} 1692 1693void ethtool_linkinfo_get_rsp_free(struct ethtool_linkinfo_get_rsp *rsp) 1694{ 1695 ethtool_header_free(&rsp->header); 1696 free(rsp); 1697} 1698 1699int ethtool_linkinfo_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 1700{ 1701 struct ethtool_linkinfo_get_rsp *dst; 1702 struct ynl_parse_arg *yarg = data; 1703 const struct nlattr *attr; 1704 struct ynl_parse_arg parg; 1705 1706 dst = yarg->data; 1707 parg.ys = yarg->ys; 1708 1709 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 1710 unsigned int type = mnl_attr_get_type(attr); 1711 1712 if (type == ETHTOOL_A_LINKINFO_HEADER) { 1713 if (ynl_attr_validate(yarg, attr)) 1714 return MNL_CB_ERROR; 1715 dst->_present.header = 1; 1716 1717 parg.rsp_policy = &ethtool_header_nest; 1718 parg.data = &dst->header; 1719 if (ethtool_header_parse(&parg, attr)) 1720 return MNL_CB_ERROR; 1721 } else if (type == ETHTOOL_A_LINKINFO_PORT) { 1722 if (ynl_attr_validate(yarg, attr)) 1723 return MNL_CB_ERROR; 1724 dst->_present.port = 1; 1725 dst->port = mnl_attr_get_u8(attr); 1726 } else if (type == ETHTOOL_A_LINKINFO_PHYADDR) { 1727 if (ynl_attr_validate(yarg, attr)) 1728 return MNL_CB_ERROR; 1729 dst->_present.phyaddr = 1; 1730 dst->phyaddr = mnl_attr_get_u8(attr); 1731 } else if (type == ETHTOOL_A_LINKINFO_TP_MDIX) { 1732 if (ynl_attr_validate(yarg, attr)) 1733 return MNL_CB_ERROR; 1734 dst->_present.tp_mdix = 1; 1735 dst->tp_mdix = mnl_attr_get_u8(attr); 1736 } else if (type == ETHTOOL_A_LINKINFO_TP_MDIX_CTRL) { 1737 if (ynl_attr_validate(yarg, attr)) 1738 return MNL_CB_ERROR; 1739 dst->_present.tp_mdix_ctrl = 1; 1740 dst->tp_mdix_ctrl = mnl_attr_get_u8(attr); 1741 } else if (type == ETHTOOL_A_LINKINFO_TRANSCEIVER) { 1742 if (ynl_attr_validate(yarg, attr)) 1743 return MNL_CB_ERROR; 1744 dst->_present.transceiver = 1; 1745 dst->transceiver = mnl_attr_get_u8(attr); 1746 } 1747 } 1748 1749 return MNL_CB_OK; 1750} 1751 1752struct ethtool_linkinfo_get_rsp * 1753ethtool_linkinfo_get(struct ynl_sock *ys, struct ethtool_linkinfo_get_req *req) 1754{ 1755 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 1756 struct ethtool_linkinfo_get_rsp *rsp; 1757 struct nlmsghdr *nlh; 1758 int err; 1759 1760 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKINFO_GET, 1); 1761 ys->req_policy = &ethtool_linkinfo_nest; 1762 yrs.yarg.rsp_policy = &ethtool_linkinfo_nest; 1763 1764 if (req->_present.header) 1765 ethtool_header_put(nlh, ETHTOOL_A_LINKINFO_HEADER, &req->header); 1766 1767 rsp = calloc(1, sizeof(*rsp)); 1768 yrs.yarg.data = rsp; 1769 yrs.cb = ethtool_linkinfo_get_rsp_parse; 1770 yrs.rsp_cmd = ETHTOOL_MSG_LINKINFO_GET; 1771 1772 err = ynl_exec(ys, nlh, &yrs); 1773 if (err < 0) 1774 goto err_free; 1775 1776 return rsp; 1777 1778err_free: 1779 ethtool_linkinfo_get_rsp_free(rsp); 1780 return NULL; 1781} 1782 1783/* ETHTOOL_MSG_LINKINFO_GET - dump */ 1784void ethtool_linkinfo_get_list_free(struct ethtool_linkinfo_get_list *rsp) 1785{ 1786 struct ethtool_linkinfo_get_list *next = rsp; 1787 1788 while ((void *)next != YNL_LIST_END) { 1789 rsp = next; 1790 next = rsp->next; 1791 1792 ethtool_header_free(&rsp->obj.header); 1793 free(rsp); 1794 } 1795} 1796 1797struct ethtool_linkinfo_get_list * 1798ethtool_linkinfo_get_dump(struct ynl_sock *ys, 1799 struct ethtool_linkinfo_get_req_dump *req) 1800{ 1801 struct ynl_dump_state yds = {}; 1802 struct nlmsghdr *nlh; 1803 int err; 1804 1805 yds.ys = ys; 1806 yds.alloc_sz = sizeof(struct ethtool_linkinfo_get_list); 1807 yds.cb = ethtool_linkinfo_get_rsp_parse; 1808 yds.rsp_cmd = ETHTOOL_MSG_LINKINFO_GET; 1809 yds.rsp_policy = &ethtool_linkinfo_nest; 1810 1811 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_LINKINFO_GET, 1); 1812 ys->req_policy = &ethtool_linkinfo_nest; 1813 1814 if (req->_present.header) 1815 ethtool_header_put(nlh, ETHTOOL_A_LINKINFO_HEADER, &req->header); 1816 1817 err = ynl_exec_dump(ys, nlh, &yds); 1818 if (err < 0) 1819 goto free_list; 1820 1821 return yds.first; 1822 1823free_list: 1824 ethtool_linkinfo_get_list_free(yds.first); 1825 return NULL; 1826} 1827 1828/* ETHTOOL_MSG_LINKINFO_GET - notify */ 1829void ethtool_linkinfo_get_ntf_free(struct ethtool_linkinfo_get_ntf *rsp) 1830{ 1831 ethtool_header_free(&rsp->obj.header); 1832 free(rsp); 1833} 1834 1835/* ============== ETHTOOL_MSG_LINKINFO_SET ============== */ 1836/* ETHTOOL_MSG_LINKINFO_SET - do */ 1837void ethtool_linkinfo_set_req_free(struct ethtool_linkinfo_set_req *req) 1838{ 1839 ethtool_header_free(&req->header); 1840 free(req); 1841} 1842 1843int ethtool_linkinfo_set(struct ynl_sock *ys, 1844 struct ethtool_linkinfo_set_req *req) 1845{ 1846 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 1847 struct nlmsghdr *nlh; 1848 int err; 1849 1850 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKINFO_SET, 1); 1851 ys->req_policy = &ethtool_linkinfo_nest; 1852 1853 if (req->_present.header) 1854 ethtool_header_put(nlh, ETHTOOL_A_LINKINFO_HEADER, &req->header); 1855 if (req->_present.port) 1856 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_PORT, req->port); 1857 if (req->_present.phyaddr) 1858 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_PHYADDR, req->phyaddr); 1859 if (req->_present.tp_mdix) 1860 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_TP_MDIX, req->tp_mdix); 1861 if (req->_present.tp_mdix_ctrl) 1862 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_TP_MDIX_CTRL, req->tp_mdix_ctrl); 1863 if (req->_present.transceiver) 1864 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_TRANSCEIVER, req->transceiver); 1865 1866 err = ynl_exec(ys, nlh, &yrs); 1867 if (err < 0) 1868 return -1; 1869 1870 return 0; 1871} 1872 1873/* ============== ETHTOOL_MSG_LINKMODES_GET ============== */ 1874/* ETHTOOL_MSG_LINKMODES_GET - do */ 1875void ethtool_linkmodes_get_req_free(struct ethtool_linkmodes_get_req *req) 1876{ 1877 ethtool_header_free(&req->header); 1878 free(req); 1879} 1880 1881void ethtool_linkmodes_get_rsp_free(struct ethtool_linkmodes_get_rsp *rsp) 1882{ 1883 ethtool_header_free(&rsp->header); 1884 ethtool_bitset_free(&rsp->ours); 1885 ethtool_bitset_free(&rsp->peer); 1886 free(rsp); 1887} 1888 1889int ethtool_linkmodes_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 1890{ 1891 struct ethtool_linkmodes_get_rsp *dst; 1892 struct ynl_parse_arg *yarg = data; 1893 const struct nlattr *attr; 1894 struct ynl_parse_arg parg; 1895 1896 dst = yarg->data; 1897 parg.ys = yarg->ys; 1898 1899 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 1900 unsigned int type = mnl_attr_get_type(attr); 1901 1902 if (type == ETHTOOL_A_LINKMODES_HEADER) { 1903 if (ynl_attr_validate(yarg, attr)) 1904 return MNL_CB_ERROR; 1905 dst->_present.header = 1; 1906 1907 parg.rsp_policy = &ethtool_header_nest; 1908 parg.data = &dst->header; 1909 if (ethtool_header_parse(&parg, attr)) 1910 return MNL_CB_ERROR; 1911 } else if (type == ETHTOOL_A_LINKMODES_AUTONEG) { 1912 if (ynl_attr_validate(yarg, attr)) 1913 return MNL_CB_ERROR; 1914 dst->_present.autoneg = 1; 1915 dst->autoneg = mnl_attr_get_u8(attr); 1916 } else if (type == ETHTOOL_A_LINKMODES_OURS) { 1917 if (ynl_attr_validate(yarg, attr)) 1918 return MNL_CB_ERROR; 1919 dst->_present.ours = 1; 1920 1921 parg.rsp_policy = &ethtool_bitset_nest; 1922 parg.data = &dst->ours; 1923 if (ethtool_bitset_parse(&parg, attr)) 1924 return MNL_CB_ERROR; 1925 } else if (type == ETHTOOL_A_LINKMODES_PEER) { 1926 if (ynl_attr_validate(yarg, attr)) 1927 return MNL_CB_ERROR; 1928 dst->_present.peer = 1; 1929 1930 parg.rsp_policy = &ethtool_bitset_nest; 1931 parg.data = &dst->peer; 1932 if (ethtool_bitset_parse(&parg, attr)) 1933 return MNL_CB_ERROR; 1934 } else if (type == ETHTOOL_A_LINKMODES_SPEED) { 1935 if (ynl_attr_validate(yarg, attr)) 1936 return MNL_CB_ERROR; 1937 dst->_present.speed = 1; 1938 dst->speed = mnl_attr_get_u32(attr); 1939 } else if (type == ETHTOOL_A_LINKMODES_DUPLEX) { 1940 if (ynl_attr_validate(yarg, attr)) 1941 return MNL_CB_ERROR; 1942 dst->_present.duplex = 1; 1943 dst->duplex = mnl_attr_get_u8(attr); 1944 } else if (type == ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG) { 1945 if (ynl_attr_validate(yarg, attr)) 1946 return MNL_CB_ERROR; 1947 dst->_present.master_slave_cfg = 1; 1948 dst->master_slave_cfg = mnl_attr_get_u8(attr); 1949 } else if (type == ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE) { 1950 if (ynl_attr_validate(yarg, attr)) 1951 return MNL_CB_ERROR; 1952 dst->_present.master_slave_state = 1; 1953 dst->master_slave_state = mnl_attr_get_u8(attr); 1954 } else if (type == ETHTOOL_A_LINKMODES_LANES) { 1955 if (ynl_attr_validate(yarg, attr)) 1956 return MNL_CB_ERROR; 1957 dst->_present.lanes = 1; 1958 dst->lanes = mnl_attr_get_u32(attr); 1959 } else if (type == ETHTOOL_A_LINKMODES_RATE_MATCHING) { 1960 if (ynl_attr_validate(yarg, attr)) 1961 return MNL_CB_ERROR; 1962 dst->_present.rate_matching = 1; 1963 dst->rate_matching = mnl_attr_get_u8(attr); 1964 } 1965 } 1966 1967 return MNL_CB_OK; 1968} 1969 1970struct ethtool_linkmodes_get_rsp * 1971ethtool_linkmodes_get(struct ynl_sock *ys, 1972 struct ethtool_linkmodes_get_req *req) 1973{ 1974 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 1975 struct ethtool_linkmodes_get_rsp *rsp; 1976 struct nlmsghdr *nlh; 1977 int err; 1978 1979 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKMODES_GET, 1); 1980 ys->req_policy = &ethtool_linkmodes_nest; 1981 yrs.yarg.rsp_policy = &ethtool_linkmodes_nest; 1982 1983 if (req->_present.header) 1984 ethtool_header_put(nlh, ETHTOOL_A_LINKMODES_HEADER, &req->header); 1985 1986 rsp = calloc(1, sizeof(*rsp)); 1987 yrs.yarg.data = rsp; 1988 yrs.cb = ethtool_linkmodes_get_rsp_parse; 1989 yrs.rsp_cmd = ETHTOOL_MSG_LINKMODES_GET; 1990 1991 err = ynl_exec(ys, nlh, &yrs); 1992 if (err < 0) 1993 goto err_free; 1994 1995 return rsp; 1996 1997err_free: 1998 ethtool_linkmodes_get_rsp_free(rsp); 1999 return NULL; 2000} 2001 2002/* ETHTOOL_MSG_LINKMODES_GET - dump */ 2003void ethtool_linkmodes_get_list_free(struct ethtool_linkmodes_get_list *rsp) 2004{ 2005 struct ethtool_linkmodes_get_list *next = rsp; 2006 2007 while ((void *)next != YNL_LIST_END) { 2008 rsp = next; 2009 next = rsp->next; 2010 2011 ethtool_header_free(&rsp->obj.header); 2012 ethtool_bitset_free(&rsp->obj.ours); 2013 ethtool_bitset_free(&rsp->obj.peer); 2014 free(rsp); 2015 } 2016} 2017 2018struct ethtool_linkmodes_get_list * 2019ethtool_linkmodes_get_dump(struct ynl_sock *ys, 2020 struct ethtool_linkmodes_get_req_dump *req) 2021{ 2022 struct ynl_dump_state yds = {}; 2023 struct nlmsghdr *nlh; 2024 int err; 2025 2026 yds.ys = ys; 2027 yds.alloc_sz = sizeof(struct ethtool_linkmodes_get_list); 2028 yds.cb = ethtool_linkmodes_get_rsp_parse; 2029 yds.rsp_cmd = ETHTOOL_MSG_LINKMODES_GET; 2030 yds.rsp_policy = &ethtool_linkmodes_nest; 2031 2032 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_LINKMODES_GET, 1); 2033 ys->req_policy = &ethtool_linkmodes_nest; 2034 2035 if (req->_present.header) 2036 ethtool_header_put(nlh, ETHTOOL_A_LINKMODES_HEADER, &req->header); 2037 2038 err = ynl_exec_dump(ys, nlh, &yds); 2039 if (err < 0) 2040 goto free_list; 2041 2042 return yds.first; 2043 2044free_list: 2045 ethtool_linkmodes_get_list_free(yds.first); 2046 return NULL; 2047} 2048 2049/* ETHTOOL_MSG_LINKMODES_GET - notify */ 2050void ethtool_linkmodes_get_ntf_free(struct ethtool_linkmodes_get_ntf *rsp) 2051{ 2052 ethtool_header_free(&rsp->obj.header); 2053 ethtool_bitset_free(&rsp->obj.ours); 2054 ethtool_bitset_free(&rsp->obj.peer); 2055 free(rsp); 2056} 2057 2058/* ============== ETHTOOL_MSG_LINKMODES_SET ============== */ 2059/* ETHTOOL_MSG_LINKMODES_SET - do */ 2060void ethtool_linkmodes_set_req_free(struct ethtool_linkmodes_set_req *req) 2061{ 2062 ethtool_header_free(&req->header); 2063 ethtool_bitset_free(&req->ours); 2064 ethtool_bitset_free(&req->peer); 2065 free(req); 2066} 2067 2068int ethtool_linkmodes_set(struct ynl_sock *ys, 2069 struct ethtool_linkmodes_set_req *req) 2070{ 2071 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2072 struct nlmsghdr *nlh; 2073 int err; 2074 2075 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKMODES_SET, 1); 2076 ys->req_policy = &ethtool_linkmodes_nest; 2077 2078 if (req->_present.header) 2079 ethtool_header_put(nlh, ETHTOOL_A_LINKMODES_HEADER, &req->header); 2080 if (req->_present.autoneg) 2081 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_AUTONEG, req->autoneg); 2082 if (req->_present.ours) 2083 ethtool_bitset_put(nlh, ETHTOOL_A_LINKMODES_OURS, &req->ours); 2084 if (req->_present.peer) 2085 ethtool_bitset_put(nlh, ETHTOOL_A_LINKMODES_PEER, &req->peer); 2086 if (req->_present.speed) 2087 mnl_attr_put_u32(nlh, ETHTOOL_A_LINKMODES_SPEED, req->speed); 2088 if (req->_present.duplex) 2089 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_DUPLEX, req->duplex); 2090 if (req->_present.master_slave_cfg) 2091 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG, req->master_slave_cfg); 2092 if (req->_present.master_slave_state) 2093 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE, req->master_slave_state); 2094 if (req->_present.lanes) 2095 mnl_attr_put_u32(nlh, ETHTOOL_A_LINKMODES_LANES, req->lanes); 2096 if (req->_present.rate_matching) 2097 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_RATE_MATCHING, req->rate_matching); 2098 2099 err = ynl_exec(ys, nlh, &yrs); 2100 if (err < 0) 2101 return -1; 2102 2103 return 0; 2104} 2105 2106/* ============== ETHTOOL_MSG_LINKSTATE_GET ============== */ 2107/* ETHTOOL_MSG_LINKSTATE_GET - do */ 2108void ethtool_linkstate_get_req_free(struct ethtool_linkstate_get_req *req) 2109{ 2110 ethtool_header_free(&req->header); 2111 free(req); 2112} 2113 2114void ethtool_linkstate_get_rsp_free(struct ethtool_linkstate_get_rsp *rsp) 2115{ 2116 ethtool_header_free(&rsp->header); 2117 free(rsp); 2118} 2119 2120int ethtool_linkstate_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 2121{ 2122 struct ethtool_linkstate_get_rsp *dst; 2123 struct ynl_parse_arg *yarg = data; 2124 const struct nlattr *attr; 2125 struct ynl_parse_arg parg; 2126 2127 dst = yarg->data; 2128 parg.ys = yarg->ys; 2129 2130 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 2131 unsigned int type = mnl_attr_get_type(attr); 2132 2133 if (type == ETHTOOL_A_LINKSTATE_HEADER) { 2134 if (ynl_attr_validate(yarg, attr)) 2135 return MNL_CB_ERROR; 2136 dst->_present.header = 1; 2137 2138 parg.rsp_policy = &ethtool_header_nest; 2139 parg.data = &dst->header; 2140 if (ethtool_header_parse(&parg, attr)) 2141 return MNL_CB_ERROR; 2142 } else if (type == ETHTOOL_A_LINKSTATE_LINK) { 2143 if (ynl_attr_validate(yarg, attr)) 2144 return MNL_CB_ERROR; 2145 dst->_present.link = 1; 2146 dst->link = mnl_attr_get_u8(attr); 2147 } else if (type == ETHTOOL_A_LINKSTATE_SQI) { 2148 if (ynl_attr_validate(yarg, attr)) 2149 return MNL_CB_ERROR; 2150 dst->_present.sqi = 1; 2151 dst->sqi = mnl_attr_get_u32(attr); 2152 } else if (type == ETHTOOL_A_LINKSTATE_SQI_MAX) { 2153 if (ynl_attr_validate(yarg, attr)) 2154 return MNL_CB_ERROR; 2155 dst->_present.sqi_max = 1; 2156 dst->sqi_max = mnl_attr_get_u32(attr); 2157 } else if (type == ETHTOOL_A_LINKSTATE_EXT_STATE) { 2158 if (ynl_attr_validate(yarg, attr)) 2159 return MNL_CB_ERROR; 2160 dst->_present.ext_state = 1; 2161 dst->ext_state = mnl_attr_get_u8(attr); 2162 } else if (type == ETHTOOL_A_LINKSTATE_EXT_SUBSTATE) { 2163 if (ynl_attr_validate(yarg, attr)) 2164 return MNL_CB_ERROR; 2165 dst->_present.ext_substate = 1; 2166 dst->ext_substate = mnl_attr_get_u8(attr); 2167 } else if (type == ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT) { 2168 if (ynl_attr_validate(yarg, attr)) 2169 return MNL_CB_ERROR; 2170 dst->_present.ext_down_cnt = 1; 2171 dst->ext_down_cnt = mnl_attr_get_u32(attr); 2172 } 2173 } 2174 2175 return MNL_CB_OK; 2176} 2177 2178struct ethtool_linkstate_get_rsp * 2179ethtool_linkstate_get(struct ynl_sock *ys, 2180 struct ethtool_linkstate_get_req *req) 2181{ 2182 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2183 struct ethtool_linkstate_get_rsp *rsp; 2184 struct nlmsghdr *nlh; 2185 int err; 2186 2187 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_LINKSTATE_GET, 1); 2188 ys->req_policy = &ethtool_linkstate_nest; 2189 yrs.yarg.rsp_policy = &ethtool_linkstate_nest; 2190 2191 if (req->_present.header) 2192 ethtool_header_put(nlh, ETHTOOL_A_LINKSTATE_HEADER, &req->header); 2193 2194 rsp = calloc(1, sizeof(*rsp)); 2195 yrs.yarg.data = rsp; 2196 yrs.cb = ethtool_linkstate_get_rsp_parse; 2197 yrs.rsp_cmd = ETHTOOL_MSG_LINKSTATE_GET; 2198 2199 err = ynl_exec(ys, nlh, &yrs); 2200 if (err < 0) 2201 goto err_free; 2202 2203 return rsp; 2204 2205err_free: 2206 ethtool_linkstate_get_rsp_free(rsp); 2207 return NULL; 2208} 2209 2210/* ETHTOOL_MSG_LINKSTATE_GET - dump */ 2211void ethtool_linkstate_get_list_free(struct ethtool_linkstate_get_list *rsp) 2212{ 2213 struct ethtool_linkstate_get_list *next = rsp; 2214 2215 while ((void *)next != YNL_LIST_END) { 2216 rsp = next; 2217 next = rsp->next; 2218 2219 ethtool_header_free(&rsp->obj.header); 2220 free(rsp); 2221 } 2222} 2223 2224struct ethtool_linkstate_get_list * 2225ethtool_linkstate_get_dump(struct ynl_sock *ys, 2226 struct ethtool_linkstate_get_req_dump *req) 2227{ 2228 struct ynl_dump_state yds = {}; 2229 struct nlmsghdr *nlh; 2230 int err; 2231 2232 yds.ys = ys; 2233 yds.alloc_sz = sizeof(struct ethtool_linkstate_get_list); 2234 yds.cb = ethtool_linkstate_get_rsp_parse; 2235 yds.rsp_cmd = ETHTOOL_MSG_LINKSTATE_GET; 2236 yds.rsp_policy = &ethtool_linkstate_nest; 2237 2238 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_LINKSTATE_GET, 1); 2239 ys->req_policy = &ethtool_linkstate_nest; 2240 2241 if (req->_present.header) 2242 ethtool_header_put(nlh, ETHTOOL_A_LINKSTATE_HEADER, &req->header); 2243 2244 err = ynl_exec_dump(ys, nlh, &yds); 2245 if (err < 0) 2246 goto free_list; 2247 2248 return yds.first; 2249 2250free_list: 2251 ethtool_linkstate_get_list_free(yds.first); 2252 return NULL; 2253} 2254 2255/* ============== ETHTOOL_MSG_DEBUG_GET ============== */ 2256/* ETHTOOL_MSG_DEBUG_GET - do */ 2257void ethtool_debug_get_req_free(struct ethtool_debug_get_req *req) 2258{ 2259 ethtool_header_free(&req->header); 2260 free(req); 2261} 2262 2263void ethtool_debug_get_rsp_free(struct ethtool_debug_get_rsp *rsp) 2264{ 2265 ethtool_header_free(&rsp->header); 2266 ethtool_bitset_free(&rsp->msgmask); 2267 free(rsp); 2268} 2269 2270int ethtool_debug_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 2271{ 2272 struct ethtool_debug_get_rsp *dst; 2273 struct ynl_parse_arg *yarg = data; 2274 const struct nlattr *attr; 2275 struct ynl_parse_arg parg; 2276 2277 dst = yarg->data; 2278 parg.ys = yarg->ys; 2279 2280 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 2281 unsigned int type = mnl_attr_get_type(attr); 2282 2283 if (type == ETHTOOL_A_DEBUG_HEADER) { 2284 if (ynl_attr_validate(yarg, attr)) 2285 return MNL_CB_ERROR; 2286 dst->_present.header = 1; 2287 2288 parg.rsp_policy = &ethtool_header_nest; 2289 parg.data = &dst->header; 2290 if (ethtool_header_parse(&parg, attr)) 2291 return MNL_CB_ERROR; 2292 } else if (type == ETHTOOL_A_DEBUG_MSGMASK) { 2293 if (ynl_attr_validate(yarg, attr)) 2294 return MNL_CB_ERROR; 2295 dst->_present.msgmask = 1; 2296 2297 parg.rsp_policy = &ethtool_bitset_nest; 2298 parg.data = &dst->msgmask; 2299 if (ethtool_bitset_parse(&parg, attr)) 2300 return MNL_CB_ERROR; 2301 } 2302 } 2303 2304 return MNL_CB_OK; 2305} 2306 2307struct ethtool_debug_get_rsp * 2308ethtool_debug_get(struct ynl_sock *ys, struct ethtool_debug_get_req *req) 2309{ 2310 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2311 struct ethtool_debug_get_rsp *rsp; 2312 struct nlmsghdr *nlh; 2313 int err; 2314 2315 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_DEBUG_GET, 1); 2316 ys->req_policy = &ethtool_debug_nest; 2317 yrs.yarg.rsp_policy = &ethtool_debug_nest; 2318 2319 if (req->_present.header) 2320 ethtool_header_put(nlh, ETHTOOL_A_DEBUG_HEADER, &req->header); 2321 2322 rsp = calloc(1, sizeof(*rsp)); 2323 yrs.yarg.data = rsp; 2324 yrs.cb = ethtool_debug_get_rsp_parse; 2325 yrs.rsp_cmd = ETHTOOL_MSG_DEBUG_GET; 2326 2327 err = ynl_exec(ys, nlh, &yrs); 2328 if (err < 0) 2329 goto err_free; 2330 2331 return rsp; 2332 2333err_free: 2334 ethtool_debug_get_rsp_free(rsp); 2335 return NULL; 2336} 2337 2338/* ETHTOOL_MSG_DEBUG_GET - dump */ 2339void ethtool_debug_get_list_free(struct ethtool_debug_get_list *rsp) 2340{ 2341 struct ethtool_debug_get_list *next = rsp; 2342 2343 while ((void *)next != YNL_LIST_END) { 2344 rsp = next; 2345 next = rsp->next; 2346 2347 ethtool_header_free(&rsp->obj.header); 2348 ethtool_bitset_free(&rsp->obj.msgmask); 2349 free(rsp); 2350 } 2351} 2352 2353struct ethtool_debug_get_list * 2354ethtool_debug_get_dump(struct ynl_sock *ys, 2355 struct ethtool_debug_get_req_dump *req) 2356{ 2357 struct ynl_dump_state yds = {}; 2358 struct nlmsghdr *nlh; 2359 int err; 2360 2361 yds.ys = ys; 2362 yds.alloc_sz = sizeof(struct ethtool_debug_get_list); 2363 yds.cb = ethtool_debug_get_rsp_parse; 2364 yds.rsp_cmd = ETHTOOL_MSG_DEBUG_GET; 2365 yds.rsp_policy = &ethtool_debug_nest; 2366 2367 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_DEBUG_GET, 1); 2368 ys->req_policy = &ethtool_debug_nest; 2369 2370 if (req->_present.header) 2371 ethtool_header_put(nlh, ETHTOOL_A_DEBUG_HEADER, &req->header); 2372 2373 err = ynl_exec_dump(ys, nlh, &yds); 2374 if (err < 0) 2375 goto free_list; 2376 2377 return yds.first; 2378 2379free_list: 2380 ethtool_debug_get_list_free(yds.first); 2381 return NULL; 2382} 2383 2384/* ETHTOOL_MSG_DEBUG_GET - notify */ 2385void ethtool_debug_get_ntf_free(struct ethtool_debug_get_ntf *rsp) 2386{ 2387 ethtool_header_free(&rsp->obj.header); 2388 ethtool_bitset_free(&rsp->obj.msgmask); 2389 free(rsp); 2390} 2391 2392/* ============== ETHTOOL_MSG_DEBUG_SET ============== */ 2393/* ETHTOOL_MSG_DEBUG_SET - do */ 2394void ethtool_debug_set_req_free(struct ethtool_debug_set_req *req) 2395{ 2396 ethtool_header_free(&req->header); 2397 ethtool_bitset_free(&req->msgmask); 2398 free(req); 2399} 2400 2401int ethtool_debug_set(struct ynl_sock *ys, struct ethtool_debug_set_req *req) 2402{ 2403 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2404 struct nlmsghdr *nlh; 2405 int err; 2406 2407 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_DEBUG_SET, 1); 2408 ys->req_policy = &ethtool_debug_nest; 2409 2410 if (req->_present.header) 2411 ethtool_header_put(nlh, ETHTOOL_A_DEBUG_HEADER, &req->header); 2412 if (req->_present.msgmask) 2413 ethtool_bitset_put(nlh, ETHTOOL_A_DEBUG_MSGMASK, &req->msgmask); 2414 2415 err = ynl_exec(ys, nlh, &yrs); 2416 if (err < 0) 2417 return -1; 2418 2419 return 0; 2420} 2421 2422/* ============== ETHTOOL_MSG_WOL_GET ============== */ 2423/* ETHTOOL_MSG_WOL_GET - do */ 2424void ethtool_wol_get_req_free(struct ethtool_wol_get_req *req) 2425{ 2426 ethtool_header_free(&req->header); 2427 free(req); 2428} 2429 2430void ethtool_wol_get_rsp_free(struct ethtool_wol_get_rsp *rsp) 2431{ 2432 ethtool_header_free(&rsp->header); 2433 ethtool_bitset_free(&rsp->modes); 2434 free(rsp->sopass); 2435 free(rsp); 2436} 2437 2438int ethtool_wol_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 2439{ 2440 struct ynl_parse_arg *yarg = data; 2441 struct ethtool_wol_get_rsp *dst; 2442 const struct nlattr *attr; 2443 struct ynl_parse_arg parg; 2444 2445 dst = yarg->data; 2446 parg.ys = yarg->ys; 2447 2448 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 2449 unsigned int type = mnl_attr_get_type(attr); 2450 2451 if (type == ETHTOOL_A_WOL_HEADER) { 2452 if (ynl_attr_validate(yarg, attr)) 2453 return MNL_CB_ERROR; 2454 dst->_present.header = 1; 2455 2456 parg.rsp_policy = &ethtool_header_nest; 2457 parg.data = &dst->header; 2458 if (ethtool_header_parse(&parg, attr)) 2459 return MNL_CB_ERROR; 2460 } else if (type == ETHTOOL_A_WOL_MODES) { 2461 if (ynl_attr_validate(yarg, attr)) 2462 return MNL_CB_ERROR; 2463 dst->_present.modes = 1; 2464 2465 parg.rsp_policy = &ethtool_bitset_nest; 2466 parg.data = &dst->modes; 2467 if (ethtool_bitset_parse(&parg, attr)) 2468 return MNL_CB_ERROR; 2469 } else if (type == ETHTOOL_A_WOL_SOPASS) { 2470 unsigned int len; 2471 2472 if (ynl_attr_validate(yarg, attr)) 2473 return MNL_CB_ERROR; 2474 2475 len = mnl_attr_get_payload_len(attr); 2476 dst->_present.sopass_len = len; 2477 dst->sopass = malloc(len); 2478 memcpy(dst->sopass, mnl_attr_get_payload(attr), len); 2479 } 2480 } 2481 2482 return MNL_CB_OK; 2483} 2484 2485struct ethtool_wol_get_rsp * 2486ethtool_wol_get(struct ynl_sock *ys, struct ethtool_wol_get_req *req) 2487{ 2488 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2489 struct ethtool_wol_get_rsp *rsp; 2490 struct nlmsghdr *nlh; 2491 int err; 2492 2493 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_WOL_GET, 1); 2494 ys->req_policy = &ethtool_wol_nest; 2495 yrs.yarg.rsp_policy = &ethtool_wol_nest; 2496 2497 if (req->_present.header) 2498 ethtool_header_put(nlh, ETHTOOL_A_WOL_HEADER, &req->header); 2499 2500 rsp = calloc(1, sizeof(*rsp)); 2501 yrs.yarg.data = rsp; 2502 yrs.cb = ethtool_wol_get_rsp_parse; 2503 yrs.rsp_cmd = ETHTOOL_MSG_WOL_GET; 2504 2505 err = ynl_exec(ys, nlh, &yrs); 2506 if (err < 0) 2507 goto err_free; 2508 2509 return rsp; 2510 2511err_free: 2512 ethtool_wol_get_rsp_free(rsp); 2513 return NULL; 2514} 2515 2516/* ETHTOOL_MSG_WOL_GET - dump */ 2517void ethtool_wol_get_list_free(struct ethtool_wol_get_list *rsp) 2518{ 2519 struct ethtool_wol_get_list *next = rsp; 2520 2521 while ((void *)next != YNL_LIST_END) { 2522 rsp = next; 2523 next = rsp->next; 2524 2525 ethtool_header_free(&rsp->obj.header); 2526 ethtool_bitset_free(&rsp->obj.modes); 2527 free(rsp->obj.sopass); 2528 free(rsp); 2529 } 2530} 2531 2532struct ethtool_wol_get_list * 2533ethtool_wol_get_dump(struct ynl_sock *ys, struct ethtool_wol_get_req_dump *req) 2534{ 2535 struct ynl_dump_state yds = {}; 2536 struct nlmsghdr *nlh; 2537 int err; 2538 2539 yds.ys = ys; 2540 yds.alloc_sz = sizeof(struct ethtool_wol_get_list); 2541 yds.cb = ethtool_wol_get_rsp_parse; 2542 yds.rsp_cmd = ETHTOOL_MSG_WOL_GET; 2543 yds.rsp_policy = &ethtool_wol_nest; 2544 2545 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_WOL_GET, 1); 2546 ys->req_policy = &ethtool_wol_nest; 2547 2548 if (req->_present.header) 2549 ethtool_header_put(nlh, ETHTOOL_A_WOL_HEADER, &req->header); 2550 2551 err = ynl_exec_dump(ys, nlh, &yds); 2552 if (err < 0) 2553 goto free_list; 2554 2555 return yds.first; 2556 2557free_list: 2558 ethtool_wol_get_list_free(yds.first); 2559 return NULL; 2560} 2561 2562/* ETHTOOL_MSG_WOL_GET - notify */ 2563void ethtool_wol_get_ntf_free(struct ethtool_wol_get_ntf *rsp) 2564{ 2565 ethtool_header_free(&rsp->obj.header); 2566 ethtool_bitset_free(&rsp->obj.modes); 2567 free(rsp->obj.sopass); 2568 free(rsp); 2569} 2570 2571/* ============== ETHTOOL_MSG_WOL_SET ============== */ 2572/* ETHTOOL_MSG_WOL_SET - do */ 2573void ethtool_wol_set_req_free(struct ethtool_wol_set_req *req) 2574{ 2575 ethtool_header_free(&req->header); 2576 ethtool_bitset_free(&req->modes); 2577 free(req->sopass); 2578 free(req); 2579} 2580 2581int ethtool_wol_set(struct ynl_sock *ys, struct ethtool_wol_set_req *req) 2582{ 2583 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2584 struct nlmsghdr *nlh; 2585 int err; 2586 2587 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_WOL_SET, 1); 2588 ys->req_policy = &ethtool_wol_nest; 2589 2590 if (req->_present.header) 2591 ethtool_header_put(nlh, ETHTOOL_A_WOL_HEADER, &req->header); 2592 if (req->_present.modes) 2593 ethtool_bitset_put(nlh, ETHTOOL_A_WOL_MODES, &req->modes); 2594 if (req->_present.sopass_len) 2595 mnl_attr_put(nlh, ETHTOOL_A_WOL_SOPASS, req->_present.sopass_len, req->sopass); 2596 2597 err = ynl_exec(ys, nlh, &yrs); 2598 if (err < 0) 2599 return -1; 2600 2601 return 0; 2602} 2603 2604/* ============== ETHTOOL_MSG_FEATURES_GET ============== */ 2605/* ETHTOOL_MSG_FEATURES_GET - do */ 2606void ethtool_features_get_req_free(struct ethtool_features_get_req *req) 2607{ 2608 ethtool_header_free(&req->header); 2609 free(req); 2610} 2611 2612void ethtool_features_get_rsp_free(struct ethtool_features_get_rsp *rsp) 2613{ 2614 ethtool_header_free(&rsp->header); 2615 ethtool_bitset_free(&rsp->hw); 2616 ethtool_bitset_free(&rsp->wanted); 2617 ethtool_bitset_free(&rsp->active); 2618 ethtool_bitset_free(&rsp->nochange); 2619 free(rsp); 2620} 2621 2622int ethtool_features_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 2623{ 2624 struct ethtool_features_get_rsp *dst; 2625 struct ynl_parse_arg *yarg = data; 2626 const struct nlattr *attr; 2627 struct ynl_parse_arg parg; 2628 2629 dst = yarg->data; 2630 parg.ys = yarg->ys; 2631 2632 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 2633 unsigned int type = mnl_attr_get_type(attr); 2634 2635 if (type == ETHTOOL_A_FEATURES_HEADER) { 2636 if (ynl_attr_validate(yarg, attr)) 2637 return MNL_CB_ERROR; 2638 dst->_present.header = 1; 2639 2640 parg.rsp_policy = &ethtool_header_nest; 2641 parg.data = &dst->header; 2642 if (ethtool_header_parse(&parg, attr)) 2643 return MNL_CB_ERROR; 2644 } else if (type == ETHTOOL_A_FEATURES_HW) { 2645 if (ynl_attr_validate(yarg, attr)) 2646 return MNL_CB_ERROR; 2647 dst->_present.hw = 1; 2648 2649 parg.rsp_policy = &ethtool_bitset_nest; 2650 parg.data = &dst->hw; 2651 if (ethtool_bitset_parse(&parg, attr)) 2652 return MNL_CB_ERROR; 2653 } else if (type == ETHTOOL_A_FEATURES_WANTED) { 2654 if (ynl_attr_validate(yarg, attr)) 2655 return MNL_CB_ERROR; 2656 dst->_present.wanted = 1; 2657 2658 parg.rsp_policy = &ethtool_bitset_nest; 2659 parg.data = &dst->wanted; 2660 if (ethtool_bitset_parse(&parg, attr)) 2661 return MNL_CB_ERROR; 2662 } else if (type == ETHTOOL_A_FEATURES_ACTIVE) { 2663 if (ynl_attr_validate(yarg, attr)) 2664 return MNL_CB_ERROR; 2665 dst->_present.active = 1; 2666 2667 parg.rsp_policy = &ethtool_bitset_nest; 2668 parg.data = &dst->active; 2669 if (ethtool_bitset_parse(&parg, attr)) 2670 return MNL_CB_ERROR; 2671 } else if (type == ETHTOOL_A_FEATURES_NOCHANGE) { 2672 if (ynl_attr_validate(yarg, attr)) 2673 return MNL_CB_ERROR; 2674 dst->_present.nochange = 1; 2675 2676 parg.rsp_policy = &ethtool_bitset_nest; 2677 parg.data = &dst->nochange; 2678 if (ethtool_bitset_parse(&parg, attr)) 2679 return MNL_CB_ERROR; 2680 } 2681 } 2682 2683 return MNL_CB_OK; 2684} 2685 2686struct ethtool_features_get_rsp * 2687ethtool_features_get(struct ynl_sock *ys, struct ethtool_features_get_req *req) 2688{ 2689 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2690 struct ethtool_features_get_rsp *rsp; 2691 struct nlmsghdr *nlh; 2692 int err; 2693 2694 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_FEATURES_GET, 1); 2695 ys->req_policy = &ethtool_features_nest; 2696 yrs.yarg.rsp_policy = &ethtool_features_nest; 2697 2698 if (req->_present.header) 2699 ethtool_header_put(nlh, ETHTOOL_A_FEATURES_HEADER, &req->header); 2700 2701 rsp = calloc(1, sizeof(*rsp)); 2702 yrs.yarg.data = rsp; 2703 yrs.cb = ethtool_features_get_rsp_parse; 2704 yrs.rsp_cmd = ETHTOOL_MSG_FEATURES_GET; 2705 2706 err = ynl_exec(ys, nlh, &yrs); 2707 if (err < 0) 2708 goto err_free; 2709 2710 return rsp; 2711 2712err_free: 2713 ethtool_features_get_rsp_free(rsp); 2714 return NULL; 2715} 2716 2717/* ETHTOOL_MSG_FEATURES_GET - dump */ 2718void ethtool_features_get_list_free(struct ethtool_features_get_list *rsp) 2719{ 2720 struct ethtool_features_get_list *next = rsp; 2721 2722 while ((void *)next != YNL_LIST_END) { 2723 rsp = next; 2724 next = rsp->next; 2725 2726 ethtool_header_free(&rsp->obj.header); 2727 ethtool_bitset_free(&rsp->obj.hw); 2728 ethtool_bitset_free(&rsp->obj.wanted); 2729 ethtool_bitset_free(&rsp->obj.active); 2730 ethtool_bitset_free(&rsp->obj.nochange); 2731 free(rsp); 2732 } 2733} 2734 2735struct ethtool_features_get_list * 2736ethtool_features_get_dump(struct ynl_sock *ys, 2737 struct ethtool_features_get_req_dump *req) 2738{ 2739 struct ynl_dump_state yds = {}; 2740 struct nlmsghdr *nlh; 2741 int err; 2742 2743 yds.ys = ys; 2744 yds.alloc_sz = sizeof(struct ethtool_features_get_list); 2745 yds.cb = ethtool_features_get_rsp_parse; 2746 yds.rsp_cmd = ETHTOOL_MSG_FEATURES_GET; 2747 yds.rsp_policy = &ethtool_features_nest; 2748 2749 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_FEATURES_GET, 1); 2750 ys->req_policy = &ethtool_features_nest; 2751 2752 if (req->_present.header) 2753 ethtool_header_put(nlh, ETHTOOL_A_FEATURES_HEADER, &req->header); 2754 2755 err = ynl_exec_dump(ys, nlh, &yds); 2756 if (err < 0) 2757 goto free_list; 2758 2759 return yds.first; 2760 2761free_list: 2762 ethtool_features_get_list_free(yds.first); 2763 return NULL; 2764} 2765 2766/* ETHTOOL_MSG_FEATURES_GET - notify */ 2767void ethtool_features_get_ntf_free(struct ethtool_features_get_ntf *rsp) 2768{ 2769 ethtool_header_free(&rsp->obj.header); 2770 ethtool_bitset_free(&rsp->obj.hw); 2771 ethtool_bitset_free(&rsp->obj.wanted); 2772 ethtool_bitset_free(&rsp->obj.active); 2773 ethtool_bitset_free(&rsp->obj.nochange); 2774 free(rsp); 2775} 2776 2777/* ============== ETHTOOL_MSG_FEATURES_SET ============== */ 2778/* ETHTOOL_MSG_FEATURES_SET - do */ 2779void ethtool_features_set_req_free(struct ethtool_features_set_req *req) 2780{ 2781 ethtool_header_free(&req->header); 2782 ethtool_bitset_free(&req->hw); 2783 ethtool_bitset_free(&req->wanted); 2784 ethtool_bitset_free(&req->active); 2785 ethtool_bitset_free(&req->nochange); 2786 free(req); 2787} 2788 2789void ethtool_features_set_rsp_free(struct ethtool_features_set_rsp *rsp) 2790{ 2791 ethtool_header_free(&rsp->header); 2792 ethtool_bitset_free(&rsp->hw); 2793 ethtool_bitset_free(&rsp->wanted); 2794 ethtool_bitset_free(&rsp->active); 2795 ethtool_bitset_free(&rsp->nochange); 2796 free(rsp); 2797} 2798 2799int ethtool_features_set_rsp_parse(const struct nlmsghdr *nlh, void *data) 2800{ 2801 struct ethtool_features_set_rsp *dst; 2802 struct ynl_parse_arg *yarg = data; 2803 const struct nlattr *attr; 2804 struct ynl_parse_arg parg; 2805 2806 dst = yarg->data; 2807 parg.ys = yarg->ys; 2808 2809 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 2810 unsigned int type = mnl_attr_get_type(attr); 2811 2812 if (type == ETHTOOL_A_FEATURES_HEADER) { 2813 if (ynl_attr_validate(yarg, attr)) 2814 return MNL_CB_ERROR; 2815 dst->_present.header = 1; 2816 2817 parg.rsp_policy = &ethtool_header_nest; 2818 parg.data = &dst->header; 2819 if (ethtool_header_parse(&parg, attr)) 2820 return MNL_CB_ERROR; 2821 } else if (type == ETHTOOL_A_FEATURES_HW) { 2822 if (ynl_attr_validate(yarg, attr)) 2823 return MNL_CB_ERROR; 2824 dst->_present.hw = 1; 2825 2826 parg.rsp_policy = &ethtool_bitset_nest; 2827 parg.data = &dst->hw; 2828 if (ethtool_bitset_parse(&parg, attr)) 2829 return MNL_CB_ERROR; 2830 } else if (type == ETHTOOL_A_FEATURES_WANTED) { 2831 if (ynl_attr_validate(yarg, attr)) 2832 return MNL_CB_ERROR; 2833 dst->_present.wanted = 1; 2834 2835 parg.rsp_policy = &ethtool_bitset_nest; 2836 parg.data = &dst->wanted; 2837 if (ethtool_bitset_parse(&parg, attr)) 2838 return MNL_CB_ERROR; 2839 } else if (type == ETHTOOL_A_FEATURES_ACTIVE) { 2840 if (ynl_attr_validate(yarg, attr)) 2841 return MNL_CB_ERROR; 2842 dst->_present.active = 1; 2843 2844 parg.rsp_policy = &ethtool_bitset_nest; 2845 parg.data = &dst->active; 2846 if (ethtool_bitset_parse(&parg, attr)) 2847 return MNL_CB_ERROR; 2848 } else if (type == ETHTOOL_A_FEATURES_NOCHANGE) { 2849 if (ynl_attr_validate(yarg, attr)) 2850 return MNL_CB_ERROR; 2851 dst->_present.nochange = 1; 2852 2853 parg.rsp_policy = &ethtool_bitset_nest; 2854 parg.data = &dst->nochange; 2855 if (ethtool_bitset_parse(&parg, attr)) 2856 return MNL_CB_ERROR; 2857 } 2858 } 2859 2860 return MNL_CB_OK; 2861} 2862 2863struct ethtool_features_set_rsp * 2864ethtool_features_set(struct ynl_sock *ys, struct ethtool_features_set_req *req) 2865{ 2866 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2867 struct ethtool_features_set_rsp *rsp; 2868 struct nlmsghdr *nlh; 2869 int err; 2870 2871 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_FEATURES_SET, 1); 2872 ys->req_policy = &ethtool_features_nest; 2873 yrs.yarg.rsp_policy = &ethtool_features_nest; 2874 2875 if (req->_present.header) 2876 ethtool_header_put(nlh, ETHTOOL_A_FEATURES_HEADER, &req->header); 2877 if (req->_present.hw) 2878 ethtool_bitset_put(nlh, ETHTOOL_A_FEATURES_HW, &req->hw); 2879 if (req->_present.wanted) 2880 ethtool_bitset_put(nlh, ETHTOOL_A_FEATURES_WANTED, &req->wanted); 2881 if (req->_present.active) 2882 ethtool_bitset_put(nlh, ETHTOOL_A_FEATURES_ACTIVE, &req->active); 2883 if (req->_present.nochange) 2884 ethtool_bitset_put(nlh, ETHTOOL_A_FEATURES_NOCHANGE, &req->nochange); 2885 2886 rsp = calloc(1, sizeof(*rsp)); 2887 yrs.yarg.data = rsp; 2888 yrs.cb = ethtool_features_set_rsp_parse; 2889 yrs.rsp_cmd = ETHTOOL_MSG_FEATURES_SET; 2890 2891 err = ynl_exec(ys, nlh, &yrs); 2892 if (err < 0) 2893 goto err_free; 2894 2895 return rsp; 2896 2897err_free: 2898 ethtool_features_set_rsp_free(rsp); 2899 return NULL; 2900} 2901 2902/* ============== ETHTOOL_MSG_PRIVFLAGS_GET ============== */ 2903/* ETHTOOL_MSG_PRIVFLAGS_GET - do */ 2904void ethtool_privflags_get_req_free(struct ethtool_privflags_get_req *req) 2905{ 2906 ethtool_header_free(&req->header); 2907 free(req); 2908} 2909 2910void ethtool_privflags_get_rsp_free(struct ethtool_privflags_get_rsp *rsp) 2911{ 2912 ethtool_header_free(&rsp->header); 2913 ethtool_bitset_free(&rsp->flags); 2914 free(rsp); 2915} 2916 2917int ethtool_privflags_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 2918{ 2919 struct ethtool_privflags_get_rsp *dst; 2920 struct ynl_parse_arg *yarg = data; 2921 const struct nlattr *attr; 2922 struct ynl_parse_arg parg; 2923 2924 dst = yarg->data; 2925 parg.ys = yarg->ys; 2926 2927 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 2928 unsigned int type = mnl_attr_get_type(attr); 2929 2930 if (type == ETHTOOL_A_PRIVFLAGS_HEADER) { 2931 if (ynl_attr_validate(yarg, attr)) 2932 return MNL_CB_ERROR; 2933 dst->_present.header = 1; 2934 2935 parg.rsp_policy = &ethtool_header_nest; 2936 parg.data = &dst->header; 2937 if (ethtool_header_parse(&parg, attr)) 2938 return MNL_CB_ERROR; 2939 } else if (type == ETHTOOL_A_PRIVFLAGS_FLAGS) { 2940 if (ynl_attr_validate(yarg, attr)) 2941 return MNL_CB_ERROR; 2942 dst->_present.flags = 1; 2943 2944 parg.rsp_policy = &ethtool_bitset_nest; 2945 parg.data = &dst->flags; 2946 if (ethtool_bitset_parse(&parg, attr)) 2947 return MNL_CB_ERROR; 2948 } 2949 } 2950 2951 return MNL_CB_OK; 2952} 2953 2954struct ethtool_privflags_get_rsp * 2955ethtool_privflags_get(struct ynl_sock *ys, 2956 struct ethtool_privflags_get_req *req) 2957{ 2958 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2959 struct ethtool_privflags_get_rsp *rsp; 2960 struct nlmsghdr *nlh; 2961 int err; 2962 2963 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PRIVFLAGS_GET, 1); 2964 ys->req_policy = &ethtool_privflags_nest; 2965 yrs.yarg.rsp_policy = &ethtool_privflags_nest; 2966 2967 if (req->_present.header) 2968 ethtool_header_put(nlh, ETHTOOL_A_PRIVFLAGS_HEADER, &req->header); 2969 2970 rsp = calloc(1, sizeof(*rsp)); 2971 yrs.yarg.data = rsp; 2972 yrs.cb = ethtool_privflags_get_rsp_parse; 2973 yrs.rsp_cmd = 14; 2974 2975 err = ynl_exec(ys, nlh, &yrs); 2976 if (err < 0) 2977 goto err_free; 2978 2979 return rsp; 2980 2981err_free: 2982 ethtool_privflags_get_rsp_free(rsp); 2983 return NULL; 2984} 2985 2986/* ETHTOOL_MSG_PRIVFLAGS_GET - dump */ 2987void ethtool_privflags_get_list_free(struct ethtool_privflags_get_list *rsp) 2988{ 2989 struct ethtool_privflags_get_list *next = rsp; 2990 2991 while ((void *)next != YNL_LIST_END) { 2992 rsp = next; 2993 next = rsp->next; 2994 2995 ethtool_header_free(&rsp->obj.header); 2996 ethtool_bitset_free(&rsp->obj.flags); 2997 free(rsp); 2998 } 2999} 3000 3001struct ethtool_privflags_get_list * 3002ethtool_privflags_get_dump(struct ynl_sock *ys, 3003 struct ethtool_privflags_get_req_dump *req) 3004{ 3005 struct ynl_dump_state yds = {}; 3006 struct nlmsghdr *nlh; 3007 int err; 3008 3009 yds.ys = ys; 3010 yds.alloc_sz = sizeof(struct ethtool_privflags_get_list); 3011 yds.cb = ethtool_privflags_get_rsp_parse; 3012 yds.rsp_cmd = 14; 3013 yds.rsp_policy = &ethtool_privflags_nest; 3014 3015 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PRIVFLAGS_GET, 1); 3016 ys->req_policy = &ethtool_privflags_nest; 3017 3018 if (req->_present.header) 3019 ethtool_header_put(nlh, ETHTOOL_A_PRIVFLAGS_HEADER, &req->header); 3020 3021 err = ynl_exec_dump(ys, nlh, &yds); 3022 if (err < 0) 3023 goto free_list; 3024 3025 return yds.first; 3026 3027free_list: 3028 ethtool_privflags_get_list_free(yds.first); 3029 return NULL; 3030} 3031 3032/* ETHTOOL_MSG_PRIVFLAGS_GET - notify */ 3033void ethtool_privflags_get_ntf_free(struct ethtool_privflags_get_ntf *rsp) 3034{ 3035 ethtool_header_free(&rsp->obj.header); 3036 ethtool_bitset_free(&rsp->obj.flags); 3037 free(rsp); 3038} 3039 3040/* ============== ETHTOOL_MSG_PRIVFLAGS_SET ============== */ 3041/* ETHTOOL_MSG_PRIVFLAGS_SET - do */ 3042void ethtool_privflags_set_req_free(struct ethtool_privflags_set_req *req) 3043{ 3044 ethtool_header_free(&req->header); 3045 ethtool_bitset_free(&req->flags); 3046 free(req); 3047} 3048 3049int ethtool_privflags_set(struct ynl_sock *ys, 3050 struct ethtool_privflags_set_req *req) 3051{ 3052 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3053 struct nlmsghdr *nlh; 3054 int err; 3055 3056 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PRIVFLAGS_SET, 1); 3057 ys->req_policy = &ethtool_privflags_nest; 3058 3059 if (req->_present.header) 3060 ethtool_header_put(nlh, ETHTOOL_A_PRIVFLAGS_HEADER, &req->header); 3061 if (req->_present.flags) 3062 ethtool_bitset_put(nlh, ETHTOOL_A_PRIVFLAGS_FLAGS, &req->flags); 3063 3064 err = ynl_exec(ys, nlh, &yrs); 3065 if (err < 0) 3066 return -1; 3067 3068 return 0; 3069} 3070 3071/* ============== ETHTOOL_MSG_RINGS_GET ============== */ 3072/* ETHTOOL_MSG_RINGS_GET - do */ 3073void ethtool_rings_get_req_free(struct ethtool_rings_get_req *req) 3074{ 3075 ethtool_header_free(&req->header); 3076 free(req); 3077} 3078 3079void ethtool_rings_get_rsp_free(struct ethtool_rings_get_rsp *rsp) 3080{ 3081 ethtool_header_free(&rsp->header); 3082 free(rsp); 3083} 3084 3085int ethtool_rings_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 3086{ 3087 struct ethtool_rings_get_rsp *dst; 3088 struct ynl_parse_arg *yarg = data; 3089 const struct nlattr *attr; 3090 struct ynl_parse_arg parg; 3091 3092 dst = yarg->data; 3093 parg.ys = yarg->ys; 3094 3095 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 3096 unsigned int type = mnl_attr_get_type(attr); 3097 3098 if (type == ETHTOOL_A_RINGS_HEADER) { 3099 if (ynl_attr_validate(yarg, attr)) 3100 return MNL_CB_ERROR; 3101 dst->_present.header = 1; 3102 3103 parg.rsp_policy = &ethtool_header_nest; 3104 parg.data = &dst->header; 3105 if (ethtool_header_parse(&parg, attr)) 3106 return MNL_CB_ERROR; 3107 } else if (type == ETHTOOL_A_RINGS_RX_MAX) { 3108 if (ynl_attr_validate(yarg, attr)) 3109 return MNL_CB_ERROR; 3110 dst->_present.rx_max = 1; 3111 dst->rx_max = mnl_attr_get_u32(attr); 3112 } else if (type == ETHTOOL_A_RINGS_RX_MINI_MAX) { 3113 if (ynl_attr_validate(yarg, attr)) 3114 return MNL_CB_ERROR; 3115 dst->_present.rx_mini_max = 1; 3116 dst->rx_mini_max = mnl_attr_get_u32(attr); 3117 } else if (type == ETHTOOL_A_RINGS_RX_JUMBO_MAX) { 3118 if (ynl_attr_validate(yarg, attr)) 3119 return MNL_CB_ERROR; 3120 dst->_present.rx_jumbo_max = 1; 3121 dst->rx_jumbo_max = mnl_attr_get_u32(attr); 3122 } else if (type == ETHTOOL_A_RINGS_TX_MAX) { 3123 if (ynl_attr_validate(yarg, attr)) 3124 return MNL_CB_ERROR; 3125 dst->_present.tx_max = 1; 3126 dst->tx_max = mnl_attr_get_u32(attr); 3127 } else if (type == ETHTOOL_A_RINGS_RX) { 3128 if (ynl_attr_validate(yarg, attr)) 3129 return MNL_CB_ERROR; 3130 dst->_present.rx = 1; 3131 dst->rx = mnl_attr_get_u32(attr); 3132 } else if (type == ETHTOOL_A_RINGS_RX_MINI) { 3133 if (ynl_attr_validate(yarg, attr)) 3134 return MNL_CB_ERROR; 3135 dst->_present.rx_mini = 1; 3136 dst->rx_mini = mnl_attr_get_u32(attr); 3137 } else if (type == ETHTOOL_A_RINGS_RX_JUMBO) { 3138 if (ynl_attr_validate(yarg, attr)) 3139 return MNL_CB_ERROR; 3140 dst->_present.rx_jumbo = 1; 3141 dst->rx_jumbo = mnl_attr_get_u32(attr); 3142 } else if (type == ETHTOOL_A_RINGS_TX) { 3143 if (ynl_attr_validate(yarg, attr)) 3144 return MNL_CB_ERROR; 3145 dst->_present.tx = 1; 3146 dst->tx = mnl_attr_get_u32(attr); 3147 } else if (type == ETHTOOL_A_RINGS_RX_BUF_LEN) { 3148 if (ynl_attr_validate(yarg, attr)) 3149 return MNL_CB_ERROR; 3150 dst->_present.rx_buf_len = 1; 3151 dst->rx_buf_len = mnl_attr_get_u32(attr); 3152 } else if (type == ETHTOOL_A_RINGS_TCP_DATA_SPLIT) { 3153 if (ynl_attr_validate(yarg, attr)) 3154 return MNL_CB_ERROR; 3155 dst->_present.tcp_data_split = 1; 3156 dst->tcp_data_split = mnl_attr_get_u8(attr); 3157 } else if (type == ETHTOOL_A_RINGS_CQE_SIZE) { 3158 if (ynl_attr_validate(yarg, attr)) 3159 return MNL_CB_ERROR; 3160 dst->_present.cqe_size = 1; 3161 dst->cqe_size = mnl_attr_get_u32(attr); 3162 } else if (type == ETHTOOL_A_RINGS_TX_PUSH) { 3163 if (ynl_attr_validate(yarg, attr)) 3164 return MNL_CB_ERROR; 3165 dst->_present.tx_push = 1; 3166 dst->tx_push = mnl_attr_get_u8(attr); 3167 } else if (type == ETHTOOL_A_RINGS_RX_PUSH) { 3168 if (ynl_attr_validate(yarg, attr)) 3169 return MNL_CB_ERROR; 3170 dst->_present.rx_push = 1; 3171 dst->rx_push = mnl_attr_get_u8(attr); 3172 } else if (type == ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN) { 3173 if (ynl_attr_validate(yarg, attr)) 3174 return MNL_CB_ERROR; 3175 dst->_present.tx_push_buf_len = 1; 3176 dst->tx_push_buf_len = mnl_attr_get_u32(attr); 3177 } else if (type == ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX) { 3178 if (ynl_attr_validate(yarg, attr)) 3179 return MNL_CB_ERROR; 3180 dst->_present.tx_push_buf_len_max = 1; 3181 dst->tx_push_buf_len_max = mnl_attr_get_u32(attr); 3182 } 3183 } 3184 3185 return MNL_CB_OK; 3186} 3187 3188struct ethtool_rings_get_rsp * 3189ethtool_rings_get(struct ynl_sock *ys, struct ethtool_rings_get_req *req) 3190{ 3191 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3192 struct ethtool_rings_get_rsp *rsp; 3193 struct nlmsghdr *nlh; 3194 int err; 3195 3196 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_RINGS_GET, 1); 3197 ys->req_policy = &ethtool_rings_nest; 3198 yrs.yarg.rsp_policy = &ethtool_rings_nest; 3199 3200 if (req->_present.header) 3201 ethtool_header_put(nlh, ETHTOOL_A_RINGS_HEADER, &req->header); 3202 3203 rsp = calloc(1, sizeof(*rsp)); 3204 yrs.yarg.data = rsp; 3205 yrs.cb = ethtool_rings_get_rsp_parse; 3206 yrs.rsp_cmd = 16; 3207 3208 err = ynl_exec(ys, nlh, &yrs); 3209 if (err < 0) 3210 goto err_free; 3211 3212 return rsp; 3213 3214err_free: 3215 ethtool_rings_get_rsp_free(rsp); 3216 return NULL; 3217} 3218 3219/* ETHTOOL_MSG_RINGS_GET - dump */ 3220void ethtool_rings_get_list_free(struct ethtool_rings_get_list *rsp) 3221{ 3222 struct ethtool_rings_get_list *next = rsp; 3223 3224 while ((void *)next != YNL_LIST_END) { 3225 rsp = next; 3226 next = rsp->next; 3227 3228 ethtool_header_free(&rsp->obj.header); 3229 free(rsp); 3230 } 3231} 3232 3233struct ethtool_rings_get_list * 3234ethtool_rings_get_dump(struct ynl_sock *ys, 3235 struct ethtool_rings_get_req_dump *req) 3236{ 3237 struct ynl_dump_state yds = {}; 3238 struct nlmsghdr *nlh; 3239 int err; 3240 3241 yds.ys = ys; 3242 yds.alloc_sz = sizeof(struct ethtool_rings_get_list); 3243 yds.cb = ethtool_rings_get_rsp_parse; 3244 yds.rsp_cmd = 16; 3245 yds.rsp_policy = &ethtool_rings_nest; 3246 3247 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_RINGS_GET, 1); 3248 ys->req_policy = &ethtool_rings_nest; 3249 3250 if (req->_present.header) 3251 ethtool_header_put(nlh, ETHTOOL_A_RINGS_HEADER, &req->header); 3252 3253 err = ynl_exec_dump(ys, nlh, &yds); 3254 if (err < 0) 3255 goto free_list; 3256 3257 return yds.first; 3258 3259free_list: 3260 ethtool_rings_get_list_free(yds.first); 3261 return NULL; 3262} 3263 3264/* ETHTOOL_MSG_RINGS_GET - notify */ 3265void ethtool_rings_get_ntf_free(struct ethtool_rings_get_ntf *rsp) 3266{ 3267 ethtool_header_free(&rsp->obj.header); 3268 free(rsp); 3269} 3270 3271/* ============== ETHTOOL_MSG_RINGS_SET ============== */ 3272/* ETHTOOL_MSG_RINGS_SET - do */ 3273void ethtool_rings_set_req_free(struct ethtool_rings_set_req *req) 3274{ 3275 ethtool_header_free(&req->header); 3276 free(req); 3277} 3278 3279int ethtool_rings_set(struct ynl_sock *ys, struct ethtool_rings_set_req *req) 3280{ 3281 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3282 struct nlmsghdr *nlh; 3283 int err; 3284 3285 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_RINGS_SET, 1); 3286 ys->req_policy = &ethtool_rings_nest; 3287 3288 if (req->_present.header) 3289 ethtool_header_put(nlh, ETHTOOL_A_RINGS_HEADER, &req->header); 3290 if (req->_present.rx_max) 3291 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_MAX, req->rx_max); 3292 if (req->_present.rx_mini_max) 3293 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_MINI_MAX, req->rx_mini_max); 3294 if (req->_present.rx_jumbo_max) 3295 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_JUMBO_MAX, req->rx_jumbo_max); 3296 if (req->_present.tx_max) 3297 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX_MAX, req->tx_max); 3298 if (req->_present.rx) 3299 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX, req->rx); 3300 if (req->_present.rx_mini) 3301 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_MINI, req->rx_mini); 3302 if (req->_present.rx_jumbo) 3303 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_JUMBO, req->rx_jumbo); 3304 if (req->_present.tx) 3305 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX, req->tx); 3306 if (req->_present.rx_buf_len) 3307 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_RX_BUF_LEN, req->rx_buf_len); 3308 if (req->_present.tcp_data_split) 3309 mnl_attr_put_u8(nlh, ETHTOOL_A_RINGS_TCP_DATA_SPLIT, req->tcp_data_split); 3310 if (req->_present.cqe_size) 3311 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_CQE_SIZE, req->cqe_size); 3312 if (req->_present.tx_push) 3313 mnl_attr_put_u8(nlh, ETHTOOL_A_RINGS_TX_PUSH, req->tx_push); 3314 if (req->_present.rx_push) 3315 mnl_attr_put_u8(nlh, ETHTOOL_A_RINGS_RX_PUSH, req->rx_push); 3316 if (req->_present.tx_push_buf_len) 3317 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN, req->tx_push_buf_len); 3318 if (req->_present.tx_push_buf_len_max) 3319 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX, req->tx_push_buf_len_max); 3320 3321 err = ynl_exec(ys, nlh, &yrs); 3322 if (err < 0) 3323 return -1; 3324 3325 return 0; 3326} 3327 3328/* ============== ETHTOOL_MSG_CHANNELS_GET ============== */ 3329/* ETHTOOL_MSG_CHANNELS_GET - do */ 3330void ethtool_channels_get_req_free(struct ethtool_channels_get_req *req) 3331{ 3332 ethtool_header_free(&req->header); 3333 free(req); 3334} 3335 3336void ethtool_channels_get_rsp_free(struct ethtool_channels_get_rsp *rsp) 3337{ 3338 ethtool_header_free(&rsp->header); 3339 free(rsp); 3340} 3341 3342int ethtool_channels_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 3343{ 3344 struct ethtool_channels_get_rsp *dst; 3345 struct ynl_parse_arg *yarg = data; 3346 const struct nlattr *attr; 3347 struct ynl_parse_arg parg; 3348 3349 dst = yarg->data; 3350 parg.ys = yarg->ys; 3351 3352 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 3353 unsigned int type = mnl_attr_get_type(attr); 3354 3355 if (type == ETHTOOL_A_CHANNELS_HEADER) { 3356 if (ynl_attr_validate(yarg, attr)) 3357 return MNL_CB_ERROR; 3358 dst->_present.header = 1; 3359 3360 parg.rsp_policy = &ethtool_header_nest; 3361 parg.data = &dst->header; 3362 if (ethtool_header_parse(&parg, attr)) 3363 return MNL_CB_ERROR; 3364 } else if (type == ETHTOOL_A_CHANNELS_RX_MAX) { 3365 if (ynl_attr_validate(yarg, attr)) 3366 return MNL_CB_ERROR; 3367 dst->_present.rx_max = 1; 3368 dst->rx_max = mnl_attr_get_u32(attr); 3369 } else if (type == ETHTOOL_A_CHANNELS_TX_MAX) { 3370 if (ynl_attr_validate(yarg, attr)) 3371 return MNL_CB_ERROR; 3372 dst->_present.tx_max = 1; 3373 dst->tx_max = mnl_attr_get_u32(attr); 3374 } else if (type == ETHTOOL_A_CHANNELS_OTHER_MAX) { 3375 if (ynl_attr_validate(yarg, attr)) 3376 return MNL_CB_ERROR; 3377 dst->_present.other_max = 1; 3378 dst->other_max = mnl_attr_get_u32(attr); 3379 } else if (type == ETHTOOL_A_CHANNELS_COMBINED_MAX) { 3380 if (ynl_attr_validate(yarg, attr)) 3381 return MNL_CB_ERROR; 3382 dst->_present.combined_max = 1; 3383 dst->combined_max = mnl_attr_get_u32(attr); 3384 } else if (type == ETHTOOL_A_CHANNELS_RX_COUNT) { 3385 if (ynl_attr_validate(yarg, attr)) 3386 return MNL_CB_ERROR; 3387 dst->_present.rx_count = 1; 3388 dst->rx_count = mnl_attr_get_u32(attr); 3389 } else if (type == ETHTOOL_A_CHANNELS_TX_COUNT) { 3390 if (ynl_attr_validate(yarg, attr)) 3391 return MNL_CB_ERROR; 3392 dst->_present.tx_count = 1; 3393 dst->tx_count = mnl_attr_get_u32(attr); 3394 } else if (type == ETHTOOL_A_CHANNELS_OTHER_COUNT) { 3395 if (ynl_attr_validate(yarg, attr)) 3396 return MNL_CB_ERROR; 3397 dst->_present.other_count = 1; 3398 dst->other_count = mnl_attr_get_u32(attr); 3399 } else if (type == ETHTOOL_A_CHANNELS_COMBINED_COUNT) { 3400 if (ynl_attr_validate(yarg, attr)) 3401 return MNL_CB_ERROR; 3402 dst->_present.combined_count = 1; 3403 dst->combined_count = mnl_attr_get_u32(attr); 3404 } 3405 } 3406 3407 return MNL_CB_OK; 3408} 3409 3410struct ethtool_channels_get_rsp * 3411ethtool_channels_get(struct ynl_sock *ys, struct ethtool_channels_get_req *req) 3412{ 3413 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3414 struct ethtool_channels_get_rsp *rsp; 3415 struct nlmsghdr *nlh; 3416 int err; 3417 3418 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_CHANNELS_GET, 1); 3419 ys->req_policy = &ethtool_channels_nest; 3420 yrs.yarg.rsp_policy = &ethtool_channels_nest; 3421 3422 if (req->_present.header) 3423 ethtool_header_put(nlh, ETHTOOL_A_CHANNELS_HEADER, &req->header); 3424 3425 rsp = calloc(1, sizeof(*rsp)); 3426 yrs.yarg.data = rsp; 3427 yrs.cb = ethtool_channels_get_rsp_parse; 3428 yrs.rsp_cmd = 18; 3429 3430 err = ynl_exec(ys, nlh, &yrs); 3431 if (err < 0) 3432 goto err_free; 3433 3434 return rsp; 3435 3436err_free: 3437 ethtool_channels_get_rsp_free(rsp); 3438 return NULL; 3439} 3440 3441/* ETHTOOL_MSG_CHANNELS_GET - dump */ 3442void ethtool_channels_get_list_free(struct ethtool_channels_get_list *rsp) 3443{ 3444 struct ethtool_channels_get_list *next = rsp; 3445 3446 while ((void *)next != YNL_LIST_END) { 3447 rsp = next; 3448 next = rsp->next; 3449 3450 ethtool_header_free(&rsp->obj.header); 3451 free(rsp); 3452 } 3453} 3454 3455struct ethtool_channels_get_list * 3456ethtool_channels_get_dump(struct ynl_sock *ys, 3457 struct ethtool_channels_get_req_dump *req) 3458{ 3459 struct ynl_dump_state yds = {}; 3460 struct nlmsghdr *nlh; 3461 int err; 3462 3463 yds.ys = ys; 3464 yds.alloc_sz = sizeof(struct ethtool_channels_get_list); 3465 yds.cb = ethtool_channels_get_rsp_parse; 3466 yds.rsp_cmd = 18; 3467 yds.rsp_policy = &ethtool_channels_nest; 3468 3469 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_CHANNELS_GET, 1); 3470 ys->req_policy = &ethtool_channels_nest; 3471 3472 if (req->_present.header) 3473 ethtool_header_put(nlh, ETHTOOL_A_CHANNELS_HEADER, &req->header); 3474 3475 err = ynl_exec_dump(ys, nlh, &yds); 3476 if (err < 0) 3477 goto free_list; 3478 3479 return yds.first; 3480 3481free_list: 3482 ethtool_channels_get_list_free(yds.first); 3483 return NULL; 3484} 3485 3486/* ETHTOOL_MSG_CHANNELS_GET - notify */ 3487void ethtool_channels_get_ntf_free(struct ethtool_channels_get_ntf *rsp) 3488{ 3489 ethtool_header_free(&rsp->obj.header); 3490 free(rsp); 3491} 3492 3493/* ============== ETHTOOL_MSG_CHANNELS_SET ============== */ 3494/* ETHTOOL_MSG_CHANNELS_SET - do */ 3495void ethtool_channels_set_req_free(struct ethtool_channels_set_req *req) 3496{ 3497 ethtool_header_free(&req->header); 3498 free(req); 3499} 3500 3501int ethtool_channels_set(struct ynl_sock *ys, 3502 struct ethtool_channels_set_req *req) 3503{ 3504 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3505 struct nlmsghdr *nlh; 3506 int err; 3507 3508 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_CHANNELS_SET, 1); 3509 ys->req_policy = &ethtool_channels_nest; 3510 3511 if (req->_present.header) 3512 ethtool_header_put(nlh, ETHTOOL_A_CHANNELS_HEADER, &req->header); 3513 if (req->_present.rx_max) 3514 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_RX_MAX, req->rx_max); 3515 if (req->_present.tx_max) 3516 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_TX_MAX, req->tx_max); 3517 if (req->_present.other_max) 3518 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_OTHER_MAX, req->other_max); 3519 if (req->_present.combined_max) 3520 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_COMBINED_MAX, req->combined_max); 3521 if (req->_present.rx_count) 3522 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_RX_COUNT, req->rx_count); 3523 if (req->_present.tx_count) 3524 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_TX_COUNT, req->tx_count); 3525 if (req->_present.other_count) 3526 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_OTHER_COUNT, req->other_count); 3527 if (req->_present.combined_count) 3528 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_COMBINED_COUNT, req->combined_count); 3529 3530 err = ynl_exec(ys, nlh, &yrs); 3531 if (err < 0) 3532 return -1; 3533 3534 return 0; 3535} 3536 3537/* ============== ETHTOOL_MSG_COALESCE_GET ============== */ 3538/* ETHTOOL_MSG_COALESCE_GET - do */ 3539void ethtool_coalesce_get_req_free(struct ethtool_coalesce_get_req *req) 3540{ 3541 ethtool_header_free(&req->header); 3542 free(req); 3543} 3544 3545void ethtool_coalesce_get_rsp_free(struct ethtool_coalesce_get_rsp *rsp) 3546{ 3547 ethtool_header_free(&rsp->header); 3548 free(rsp); 3549} 3550 3551int ethtool_coalesce_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 3552{ 3553 struct ethtool_coalesce_get_rsp *dst; 3554 struct ynl_parse_arg *yarg = data; 3555 const struct nlattr *attr; 3556 struct ynl_parse_arg parg; 3557 3558 dst = yarg->data; 3559 parg.ys = yarg->ys; 3560 3561 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 3562 unsigned int type = mnl_attr_get_type(attr); 3563 3564 if (type == ETHTOOL_A_COALESCE_HEADER) { 3565 if (ynl_attr_validate(yarg, attr)) 3566 return MNL_CB_ERROR; 3567 dst->_present.header = 1; 3568 3569 parg.rsp_policy = &ethtool_header_nest; 3570 parg.data = &dst->header; 3571 if (ethtool_header_parse(&parg, attr)) 3572 return MNL_CB_ERROR; 3573 } else if (type == ETHTOOL_A_COALESCE_RX_USECS) { 3574 if (ynl_attr_validate(yarg, attr)) 3575 return MNL_CB_ERROR; 3576 dst->_present.rx_usecs = 1; 3577 dst->rx_usecs = mnl_attr_get_u32(attr); 3578 } else if (type == ETHTOOL_A_COALESCE_RX_MAX_FRAMES) { 3579 if (ynl_attr_validate(yarg, attr)) 3580 return MNL_CB_ERROR; 3581 dst->_present.rx_max_frames = 1; 3582 dst->rx_max_frames = mnl_attr_get_u32(attr); 3583 } else if (type == ETHTOOL_A_COALESCE_RX_USECS_IRQ) { 3584 if (ynl_attr_validate(yarg, attr)) 3585 return MNL_CB_ERROR; 3586 dst->_present.rx_usecs_irq = 1; 3587 dst->rx_usecs_irq = mnl_attr_get_u32(attr); 3588 } else if (type == ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ) { 3589 if (ynl_attr_validate(yarg, attr)) 3590 return MNL_CB_ERROR; 3591 dst->_present.rx_max_frames_irq = 1; 3592 dst->rx_max_frames_irq = mnl_attr_get_u32(attr); 3593 } else if (type == ETHTOOL_A_COALESCE_TX_USECS) { 3594 if (ynl_attr_validate(yarg, attr)) 3595 return MNL_CB_ERROR; 3596 dst->_present.tx_usecs = 1; 3597 dst->tx_usecs = mnl_attr_get_u32(attr); 3598 } else if (type == ETHTOOL_A_COALESCE_TX_MAX_FRAMES) { 3599 if (ynl_attr_validate(yarg, attr)) 3600 return MNL_CB_ERROR; 3601 dst->_present.tx_max_frames = 1; 3602 dst->tx_max_frames = mnl_attr_get_u32(attr); 3603 } else if (type == ETHTOOL_A_COALESCE_TX_USECS_IRQ) { 3604 if (ynl_attr_validate(yarg, attr)) 3605 return MNL_CB_ERROR; 3606 dst->_present.tx_usecs_irq = 1; 3607 dst->tx_usecs_irq = mnl_attr_get_u32(attr); 3608 } else if (type == ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ) { 3609 if (ynl_attr_validate(yarg, attr)) 3610 return MNL_CB_ERROR; 3611 dst->_present.tx_max_frames_irq = 1; 3612 dst->tx_max_frames_irq = mnl_attr_get_u32(attr); 3613 } else if (type == ETHTOOL_A_COALESCE_STATS_BLOCK_USECS) { 3614 if (ynl_attr_validate(yarg, attr)) 3615 return MNL_CB_ERROR; 3616 dst->_present.stats_block_usecs = 1; 3617 dst->stats_block_usecs = mnl_attr_get_u32(attr); 3618 } else if (type == ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX) { 3619 if (ynl_attr_validate(yarg, attr)) 3620 return MNL_CB_ERROR; 3621 dst->_present.use_adaptive_rx = 1; 3622 dst->use_adaptive_rx = mnl_attr_get_u8(attr); 3623 } else if (type == ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX) { 3624 if (ynl_attr_validate(yarg, attr)) 3625 return MNL_CB_ERROR; 3626 dst->_present.use_adaptive_tx = 1; 3627 dst->use_adaptive_tx = mnl_attr_get_u8(attr); 3628 } else if (type == ETHTOOL_A_COALESCE_PKT_RATE_LOW) { 3629 if (ynl_attr_validate(yarg, attr)) 3630 return MNL_CB_ERROR; 3631 dst->_present.pkt_rate_low = 1; 3632 dst->pkt_rate_low = mnl_attr_get_u32(attr); 3633 } else if (type == ETHTOOL_A_COALESCE_RX_USECS_LOW) { 3634 if (ynl_attr_validate(yarg, attr)) 3635 return MNL_CB_ERROR; 3636 dst->_present.rx_usecs_low = 1; 3637 dst->rx_usecs_low = mnl_attr_get_u32(attr); 3638 } else if (type == ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW) { 3639 if (ynl_attr_validate(yarg, attr)) 3640 return MNL_CB_ERROR; 3641 dst->_present.rx_max_frames_low = 1; 3642 dst->rx_max_frames_low = mnl_attr_get_u32(attr); 3643 } else if (type == ETHTOOL_A_COALESCE_TX_USECS_LOW) { 3644 if (ynl_attr_validate(yarg, attr)) 3645 return MNL_CB_ERROR; 3646 dst->_present.tx_usecs_low = 1; 3647 dst->tx_usecs_low = mnl_attr_get_u32(attr); 3648 } else if (type == ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW) { 3649 if (ynl_attr_validate(yarg, attr)) 3650 return MNL_CB_ERROR; 3651 dst->_present.tx_max_frames_low = 1; 3652 dst->tx_max_frames_low = mnl_attr_get_u32(attr); 3653 } else if (type == ETHTOOL_A_COALESCE_PKT_RATE_HIGH) { 3654 if (ynl_attr_validate(yarg, attr)) 3655 return MNL_CB_ERROR; 3656 dst->_present.pkt_rate_high = 1; 3657 dst->pkt_rate_high = mnl_attr_get_u32(attr); 3658 } else if (type == ETHTOOL_A_COALESCE_RX_USECS_HIGH) { 3659 if (ynl_attr_validate(yarg, attr)) 3660 return MNL_CB_ERROR; 3661 dst->_present.rx_usecs_high = 1; 3662 dst->rx_usecs_high = mnl_attr_get_u32(attr); 3663 } else if (type == ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH) { 3664 if (ynl_attr_validate(yarg, attr)) 3665 return MNL_CB_ERROR; 3666 dst->_present.rx_max_frames_high = 1; 3667 dst->rx_max_frames_high = mnl_attr_get_u32(attr); 3668 } else if (type == ETHTOOL_A_COALESCE_TX_USECS_HIGH) { 3669 if (ynl_attr_validate(yarg, attr)) 3670 return MNL_CB_ERROR; 3671 dst->_present.tx_usecs_high = 1; 3672 dst->tx_usecs_high = mnl_attr_get_u32(attr); 3673 } else if (type == ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH) { 3674 if (ynl_attr_validate(yarg, attr)) 3675 return MNL_CB_ERROR; 3676 dst->_present.tx_max_frames_high = 1; 3677 dst->tx_max_frames_high = mnl_attr_get_u32(attr); 3678 } else if (type == ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL) { 3679 if (ynl_attr_validate(yarg, attr)) 3680 return MNL_CB_ERROR; 3681 dst->_present.rate_sample_interval = 1; 3682 dst->rate_sample_interval = mnl_attr_get_u32(attr); 3683 } else if (type == ETHTOOL_A_COALESCE_USE_CQE_MODE_TX) { 3684 if (ynl_attr_validate(yarg, attr)) 3685 return MNL_CB_ERROR; 3686 dst->_present.use_cqe_mode_tx = 1; 3687 dst->use_cqe_mode_tx = mnl_attr_get_u8(attr); 3688 } else if (type == ETHTOOL_A_COALESCE_USE_CQE_MODE_RX) { 3689 if (ynl_attr_validate(yarg, attr)) 3690 return MNL_CB_ERROR; 3691 dst->_present.use_cqe_mode_rx = 1; 3692 dst->use_cqe_mode_rx = mnl_attr_get_u8(attr); 3693 } else if (type == ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES) { 3694 if (ynl_attr_validate(yarg, attr)) 3695 return MNL_CB_ERROR; 3696 dst->_present.tx_aggr_max_bytes = 1; 3697 dst->tx_aggr_max_bytes = mnl_attr_get_u32(attr); 3698 } else if (type == ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES) { 3699 if (ynl_attr_validate(yarg, attr)) 3700 return MNL_CB_ERROR; 3701 dst->_present.tx_aggr_max_frames = 1; 3702 dst->tx_aggr_max_frames = mnl_attr_get_u32(attr); 3703 } else if (type == ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS) { 3704 if (ynl_attr_validate(yarg, attr)) 3705 return MNL_CB_ERROR; 3706 dst->_present.tx_aggr_time_usecs = 1; 3707 dst->tx_aggr_time_usecs = mnl_attr_get_u32(attr); 3708 } 3709 } 3710 3711 return MNL_CB_OK; 3712} 3713 3714struct ethtool_coalesce_get_rsp * 3715ethtool_coalesce_get(struct ynl_sock *ys, struct ethtool_coalesce_get_req *req) 3716{ 3717 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3718 struct ethtool_coalesce_get_rsp *rsp; 3719 struct nlmsghdr *nlh; 3720 int err; 3721 3722 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_COALESCE_GET, 1); 3723 ys->req_policy = &ethtool_coalesce_nest; 3724 yrs.yarg.rsp_policy = &ethtool_coalesce_nest; 3725 3726 if (req->_present.header) 3727 ethtool_header_put(nlh, ETHTOOL_A_COALESCE_HEADER, &req->header); 3728 3729 rsp = calloc(1, sizeof(*rsp)); 3730 yrs.yarg.data = rsp; 3731 yrs.cb = ethtool_coalesce_get_rsp_parse; 3732 yrs.rsp_cmd = 20; 3733 3734 err = ynl_exec(ys, nlh, &yrs); 3735 if (err < 0) 3736 goto err_free; 3737 3738 return rsp; 3739 3740err_free: 3741 ethtool_coalesce_get_rsp_free(rsp); 3742 return NULL; 3743} 3744 3745/* ETHTOOL_MSG_COALESCE_GET - dump */ 3746void ethtool_coalesce_get_list_free(struct ethtool_coalesce_get_list *rsp) 3747{ 3748 struct ethtool_coalesce_get_list *next = rsp; 3749 3750 while ((void *)next != YNL_LIST_END) { 3751 rsp = next; 3752 next = rsp->next; 3753 3754 ethtool_header_free(&rsp->obj.header); 3755 free(rsp); 3756 } 3757} 3758 3759struct ethtool_coalesce_get_list * 3760ethtool_coalesce_get_dump(struct ynl_sock *ys, 3761 struct ethtool_coalesce_get_req_dump *req) 3762{ 3763 struct ynl_dump_state yds = {}; 3764 struct nlmsghdr *nlh; 3765 int err; 3766 3767 yds.ys = ys; 3768 yds.alloc_sz = sizeof(struct ethtool_coalesce_get_list); 3769 yds.cb = ethtool_coalesce_get_rsp_parse; 3770 yds.rsp_cmd = 20; 3771 yds.rsp_policy = &ethtool_coalesce_nest; 3772 3773 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_COALESCE_GET, 1); 3774 ys->req_policy = &ethtool_coalesce_nest; 3775 3776 if (req->_present.header) 3777 ethtool_header_put(nlh, ETHTOOL_A_COALESCE_HEADER, &req->header); 3778 3779 err = ynl_exec_dump(ys, nlh, &yds); 3780 if (err < 0) 3781 goto free_list; 3782 3783 return yds.first; 3784 3785free_list: 3786 ethtool_coalesce_get_list_free(yds.first); 3787 return NULL; 3788} 3789 3790/* ETHTOOL_MSG_COALESCE_GET - notify */ 3791void ethtool_coalesce_get_ntf_free(struct ethtool_coalesce_get_ntf *rsp) 3792{ 3793 ethtool_header_free(&rsp->obj.header); 3794 free(rsp); 3795} 3796 3797/* ============== ETHTOOL_MSG_COALESCE_SET ============== */ 3798/* ETHTOOL_MSG_COALESCE_SET - do */ 3799void ethtool_coalesce_set_req_free(struct ethtool_coalesce_set_req *req) 3800{ 3801 ethtool_header_free(&req->header); 3802 free(req); 3803} 3804 3805int ethtool_coalesce_set(struct ynl_sock *ys, 3806 struct ethtool_coalesce_set_req *req) 3807{ 3808 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3809 struct nlmsghdr *nlh; 3810 int err; 3811 3812 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_COALESCE_SET, 1); 3813 ys->req_policy = &ethtool_coalesce_nest; 3814 3815 if (req->_present.header) 3816 ethtool_header_put(nlh, ETHTOOL_A_COALESCE_HEADER, &req->header); 3817 if (req->_present.rx_usecs) 3818 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_USECS, req->rx_usecs); 3819 if (req->_present.rx_max_frames) 3820 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_MAX_FRAMES, req->rx_max_frames); 3821 if (req->_present.rx_usecs_irq) 3822 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_USECS_IRQ, req->rx_usecs_irq); 3823 if (req->_present.rx_max_frames_irq) 3824 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ, req->rx_max_frames_irq); 3825 if (req->_present.tx_usecs) 3826 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_USECS, req->tx_usecs); 3827 if (req->_present.tx_max_frames) 3828 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_MAX_FRAMES, req->tx_max_frames); 3829 if (req->_present.tx_usecs_irq) 3830 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_USECS_IRQ, req->tx_usecs_irq); 3831 if (req->_present.tx_max_frames_irq) 3832 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ, req->tx_max_frames_irq); 3833 if (req->_present.stats_block_usecs) 3834 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_STATS_BLOCK_USECS, req->stats_block_usecs); 3835 if (req->_present.use_adaptive_rx) 3836 mnl_attr_put_u8(nlh, ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX, req->use_adaptive_rx); 3837 if (req->_present.use_adaptive_tx) 3838 mnl_attr_put_u8(nlh, ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX, req->use_adaptive_tx); 3839 if (req->_present.pkt_rate_low) 3840 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_PKT_RATE_LOW, req->pkt_rate_low); 3841 if (req->_present.rx_usecs_low) 3842 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_USECS_LOW, req->rx_usecs_low); 3843 if (req->_present.rx_max_frames_low) 3844 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW, req->rx_max_frames_low); 3845 if (req->_present.tx_usecs_low) 3846 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_USECS_LOW, req->tx_usecs_low); 3847 if (req->_present.tx_max_frames_low) 3848 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW, req->tx_max_frames_low); 3849 if (req->_present.pkt_rate_high) 3850 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_PKT_RATE_HIGH, req->pkt_rate_high); 3851 if (req->_present.rx_usecs_high) 3852 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_USECS_HIGH, req->rx_usecs_high); 3853 if (req->_present.rx_max_frames_high) 3854 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH, req->rx_max_frames_high); 3855 if (req->_present.tx_usecs_high) 3856 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_USECS_HIGH, req->tx_usecs_high); 3857 if (req->_present.tx_max_frames_high) 3858 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH, req->tx_max_frames_high); 3859 if (req->_present.rate_sample_interval) 3860 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL, req->rate_sample_interval); 3861 if (req->_present.use_cqe_mode_tx) 3862 mnl_attr_put_u8(nlh, ETHTOOL_A_COALESCE_USE_CQE_MODE_TX, req->use_cqe_mode_tx); 3863 if (req->_present.use_cqe_mode_rx) 3864 mnl_attr_put_u8(nlh, ETHTOOL_A_COALESCE_USE_CQE_MODE_RX, req->use_cqe_mode_rx); 3865 if (req->_present.tx_aggr_max_bytes) 3866 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES, req->tx_aggr_max_bytes); 3867 if (req->_present.tx_aggr_max_frames) 3868 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES, req->tx_aggr_max_frames); 3869 if (req->_present.tx_aggr_time_usecs) 3870 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS, req->tx_aggr_time_usecs); 3871 3872 err = ynl_exec(ys, nlh, &yrs); 3873 if (err < 0) 3874 return -1; 3875 3876 return 0; 3877} 3878 3879/* ============== ETHTOOL_MSG_PAUSE_GET ============== */ 3880/* ETHTOOL_MSG_PAUSE_GET - do */ 3881void ethtool_pause_get_req_free(struct ethtool_pause_get_req *req) 3882{ 3883 ethtool_header_free(&req->header); 3884 free(req); 3885} 3886 3887void ethtool_pause_get_rsp_free(struct ethtool_pause_get_rsp *rsp) 3888{ 3889 ethtool_header_free(&rsp->header); 3890 ethtool_pause_stat_free(&rsp->stats); 3891 free(rsp); 3892} 3893 3894int ethtool_pause_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 3895{ 3896 struct ethtool_pause_get_rsp *dst; 3897 struct ynl_parse_arg *yarg = data; 3898 const struct nlattr *attr; 3899 struct ynl_parse_arg parg; 3900 3901 dst = yarg->data; 3902 parg.ys = yarg->ys; 3903 3904 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 3905 unsigned int type = mnl_attr_get_type(attr); 3906 3907 if (type == ETHTOOL_A_PAUSE_HEADER) { 3908 if (ynl_attr_validate(yarg, attr)) 3909 return MNL_CB_ERROR; 3910 dst->_present.header = 1; 3911 3912 parg.rsp_policy = &ethtool_header_nest; 3913 parg.data = &dst->header; 3914 if (ethtool_header_parse(&parg, attr)) 3915 return MNL_CB_ERROR; 3916 } else if (type == ETHTOOL_A_PAUSE_AUTONEG) { 3917 if (ynl_attr_validate(yarg, attr)) 3918 return MNL_CB_ERROR; 3919 dst->_present.autoneg = 1; 3920 dst->autoneg = mnl_attr_get_u8(attr); 3921 } else if (type == ETHTOOL_A_PAUSE_RX) { 3922 if (ynl_attr_validate(yarg, attr)) 3923 return MNL_CB_ERROR; 3924 dst->_present.rx = 1; 3925 dst->rx = mnl_attr_get_u8(attr); 3926 } else if (type == ETHTOOL_A_PAUSE_TX) { 3927 if (ynl_attr_validate(yarg, attr)) 3928 return MNL_CB_ERROR; 3929 dst->_present.tx = 1; 3930 dst->tx = mnl_attr_get_u8(attr); 3931 } else if (type == ETHTOOL_A_PAUSE_STATS) { 3932 if (ynl_attr_validate(yarg, attr)) 3933 return MNL_CB_ERROR; 3934 dst->_present.stats = 1; 3935 3936 parg.rsp_policy = &ethtool_pause_stat_nest; 3937 parg.data = &dst->stats; 3938 if (ethtool_pause_stat_parse(&parg, attr)) 3939 return MNL_CB_ERROR; 3940 } else if (type == ETHTOOL_A_PAUSE_STATS_SRC) { 3941 if (ynl_attr_validate(yarg, attr)) 3942 return MNL_CB_ERROR; 3943 dst->_present.stats_src = 1; 3944 dst->stats_src = mnl_attr_get_u32(attr); 3945 } 3946 } 3947 3948 return MNL_CB_OK; 3949} 3950 3951struct ethtool_pause_get_rsp * 3952ethtool_pause_get(struct ynl_sock *ys, struct ethtool_pause_get_req *req) 3953{ 3954 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3955 struct ethtool_pause_get_rsp *rsp; 3956 struct nlmsghdr *nlh; 3957 int err; 3958 3959 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PAUSE_GET, 1); 3960 ys->req_policy = &ethtool_pause_nest; 3961 yrs.yarg.rsp_policy = &ethtool_pause_nest; 3962 3963 if (req->_present.header) 3964 ethtool_header_put(nlh, ETHTOOL_A_PAUSE_HEADER, &req->header); 3965 3966 rsp = calloc(1, sizeof(*rsp)); 3967 yrs.yarg.data = rsp; 3968 yrs.cb = ethtool_pause_get_rsp_parse; 3969 yrs.rsp_cmd = 22; 3970 3971 err = ynl_exec(ys, nlh, &yrs); 3972 if (err < 0) 3973 goto err_free; 3974 3975 return rsp; 3976 3977err_free: 3978 ethtool_pause_get_rsp_free(rsp); 3979 return NULL; 3980} 3981 3982/* ETHTOOL_MSG_PAUSE_GET - dump */ 3983void ethtool_pause_get_list_free(struct ethtool_pause_get_list *rsp) 3984{ 3985 struct ethtool_pause_get_list *next = rsp; 3986 3987 while ((void *)next != YNL_LIST_END) { 3988 rsp = next; 3989 next = rsp->next; 3990 3991 ethtool_header_free(&rsp->obj.header); 3992 ethtool_pause_stat_free(&rsp->obj.stats); 3993 free(rsp); 3994 } 3995} 3996 3997struct ethtool_pause_get_list * 3998ethtool_pause_get_dump(struct ynl_sock *ys, 3999 struct ethtool_pause_get_req_dump *req) 4000{ 4001 struct ynl_dump_state yds = {}; 4002 struct nlmsghdr *nlh; 4003 int err; 4004 4005 yds.ys = ys; 4006 yds.alloc_sz = sizeof(struct ethtool_pause_get_list); 4007 yds.cb = ethtool_pause_get_rsp_parse; 4008 yds.rsp_cmd = 22; 4009 yds.rsp_policy = &ethtool_pause_nest; 4010 4011 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PAUSE_GET, 1); 4012 ys->req_policy = &ethtool_pause_nest; 4013 4014 if (req->_present.header) 4015 ethtool_header_put(nlh, ETHTOOL_A_PAUSE_HEADER, &req->header); 4016 4017 err = ynl_exec_dump(ys, nlh, &yds); 4018 if (err < 0) 4019 goto free_list; 4020 4021 return yds.first; 4022 4023free_list: 4024 ethtool_pause_get_list_free(yds.first); 4025 return NULL; 4026} 4027 4028/* ETHTOOL_MSG_PAUSE_GET - notify */ 4029void ethtool_pause_get_ntf_free(struct ethtool_pause_get_ntf *rsp) 4030{ 4031 ethtool_header_free(&rsp->obj.header); 4032 ethtool_pause_stat_free(&rsp->obj.stats); 4033 free(rsp); 4034} 4035 4036/* ============== ETHTOOL_MSG_PAUSE_SET ============== */ 4037/* ETHTOOL_MSG_PAUSE_SET - do */ 4038void ethtool_pause_set_req_free(struct ethtool_pause_set_req *req) 4039{ 4040 ethtool_header_free(&req->header); 4041 ethtool_pause_stat_free(&req->stats); 4042 free(req); 4043} 4044 4045int ethtool_pause_set(struct ynl_sock *ys, struct ethtool_pause_set_req *req) 4046{ 4047 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4048 struct nlmsghdr *nlh; 4049 int err; 4050 4051 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PAUSE_SET, 1); 4052 ys->req_policy = &ethtool_pause_nest; 4053 4054 if (req->_present.header) 4055 ethtool_header_put(nlh, ETHTOOL_A_PAUSE_HEADER, &req->header); 4056 if (req->_present.autoneg) 4057 mnl_attr_put_u8(nlh, ETHTOOL_A_PAUSE_AUTONEG, req->autoneg); 4058 if (req->_present.rx) 4059 mnl_attr_put_u8(nlh, ETHTOOL_A_PAUSE_RX, req->rx); 4060 if (req->_present.tx) 4061 mnl_attr_put_u8(nlh, ETHTOOL_A_PAUSE_TX, req->tx); 4062 if (req->_present.stats) 4063 ethtool_pause_stat_put(nlh, ETHTOOL_A_PAUSE_STATS, &req->stats); 4064 if (req->_present.stats_src) 4065 mnl_attr_put_u32(nlh, ETHTOOL_A_PAUSE_STATS_SRC, req->stats_src); 4066 4067 err = ynl_exec(ys, nlh, &yrs); 4068 if (err < 0) 4069 return -1; 4070 4071 return 0; 4072} 4073 4074/* ============== ETHTOOL_MSG_EEE_GET ============== */ 4075/* ETHTOOL_MSG_EEE_GET - do */ 4076void ethtool_eee_get_req_free(struct ethtool_eee_get_req *req) 4077{ 4078 ethtool_header_free(&req->header); 4079 free(req); 4080} 4081 4082void ethtool_eee_get_rsp_free(struct ethtool_eee_get_rsp *rsp) 4083{ 4084 ethtool_header_free(&rsp->header); 4085 ethtool_bitset_free(&rsp->modes_ours); 4086 ethtool_bitset_free(&rsp->modes_peer); 4087 free(rsp); 4088} 4089 4090int ethtool_eee_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 4091{ 4092 struct ynl_parse_arg *yarg = data; 4093 struct ethtool_eee_get_rsp *dst; 4094 const struct nlattr *attr; 4095 struct ynl_parse_arg parg; 4096 4097 dst = yarg->data; 4098 parg.ys = yarg->ys; 4099 4100 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 4101 unsigned int type = mnl_attr_get_type(attr); 4102 4103 if (type == ETHTOOL_A_EEE_HEADER) { 4104 if (ynl_attr_validate(yarg, attr)) 4105 return MNL_CB_ERROR; 4106 dst->_present.header = 1; 4107 4108 parg.rsp_policy = &ethtool_header_nest; 4109 parg.data = &dst->header; 4110 if (ethtool_header_parse(&parg, attr)) 4111 return MNL_CB_ERROR; 4112 } else if (type == ETHTOOL_A_EEE_MODES_OURS) { 4113 if (ynl_attr_validate(yarg, attr)) 4114 return MNL_CB_ERROR; 4115 dst->_present.modes_ours = 1; 4116 4117 parg.rsp_policy = &ethtool_bitset_nest; 4118 parg.data = &dst->modes_ours; 4119 if (ethtool_bitset_parse(&parg, attr)) 4120 return MNL_CB_ERROR; 4121 } else if (type == ETHTOOL_A_EEE_MODES_PEER) { 4122 if (ynl_attr_validate(yarg, attr)) 4123 return MNL_CB_ERROR; 4124 dst->_present.modes_peer = 1; 4125 4126 parg.rsp_policy = &ethtool_bitset_nest; 4127 parg.data = &dst->modes_peer; 4128 if (ethtool_bitset_parse(&parg, attr)) 4129 return MNL_CB_ERROR; 4130 } else if (type == ETHTOOL_A_EEE_ACTIVE) { 4131 if (ynl_attr_validate(yarg, attr)) 4132 return MNL_CB_ERROR; 4133 dst->_present.active = 1; 4134 dst->active = mnl_attr_get_u8(attr); 4135 } else if (type == ETHTOOL_A_EEE_ENABLED) { 4136 if (ynl_attr_validate(yarg, attr)) 4137 return MNL_CB_ERROR; 4138 dst->_present.enabled = 1; 4139 dst->enabled = mnl_attr_get_u8(attr); 4140 } else if (type == ETHTOOL_A_EEE_TX_LPI_ENABLED) { 4141 if (ynl_attr_validate(yarg, attr)) 4142 return MNL_CB_ERROR; 4143 dst->_present.tx_lpi_enabled = 1; 4144 dst->tx_lpi_enabled = mnl_attr_get_u8(attr); 4145 } else if (type == ETHTOOL_A_EEE_TX_LPI_TIMER) { 4146 if (ynl_attr_validate(yarg, attr)) 4147 return MNL_CB_ERROR; 4148 dst->_present.tx_lpi_timer = 1; 4149 dst->tx_lpi_timer = mnl_attr_get_u32(attr); 4150 } 4151 } 4152 4153 return MNL_CB_OK; 4154} 4155 4156struct ethtool_eee_get_rsp * 4157ethtool_eee_get(struct ynl_sock *ys, struct ethtool_eee_get_req *req) 4158{ 4159 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4160 struct ethtool_eee_get_rsp *rsp; 4161 struct nlmsghdr *nlh; 4162 int err; 4163 4164 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_EEE_GET, 1); 4165 ys->req_policy = &ethtool_eee_nest; 4166 yrs.yarg.rsp_policy = &ethtool_eee_nest; 4167 4168 if (req->_present.header) 4169 ethtool_header_put(nlh, ETHTOOL_A_EEE_HEADER, &req->header); 4170 4171 rsp = calloc(1, sizeof(*rsp)); 4172 yrs.yarg.data = rsp; 4173 yrs.cb = ethtool_eee_get_rsp_parse; 4174 yrs.rsp_cmd = 24; 4175 4176 err = ynl_exec(ys, nlh, &yrs); 4177 if (err < 0) 4178 goto err_free; 4179 4180 return rsp; 4181 4182err_free: 4183 ethtool_eee_get_rsp_free(rsp); 4184 return NULL; 4185} 4186 4187/* ETHTOOL_MSG_EEE_GET - dump */ 4188void ethtool_eee_get_list_free(struct ethtool_eee_get_list *rsp) 4189{ 4190 struct ethtool_eee_get_list *next = rsp; 4191 4192 while ((void *)next != YNL_LIST_END) { 4193 rsp = next; 4194 next = rsp->next; 4195 4196 ethtool_header_free(&rsp->obj.header); 4197 ethtool_bitset_free(&rsp->obj.modes_ours); 4198 ethtool_bitset_free(&rsp->obj.modes_peer); 4199 free(rsp); 4200 } 4201} 4202 4203struct ethtool_eee_get_list * 4204ethtool_eee_get_dump(struct ynl_sock *ys, struct ethtool_eee_get_req_dump *req) 4205{ 4206 struct ynl_dump_state yds = {}; 4207 struct nlmsghdr *nlh; 4208 int err; 4209 4210 yds.ys = ys; 4211 yds.alloc_sz = sizeof(struct ethtool_eee_get_list); 4212 yds.cb = ethtool_eee_get_rsp_parse; 4213 yds.rsp_cmd = 24; 4214 yds.rsp_policy = &ethtool_eee_nest; 4215 4216 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_EEE_GET, 1); 4217 ys->req_policy = &ethtool_eee_nest; 4218 4219 if (req->_present.header) 4220 ethtool_header_put(nlh, ETHTOOL_A_EEE_HEADER, &req->header); 4221 4222 err = ynl_exec_dump(ys, nlh, &yds); 4223 if (err < 0) 4224 goto free_list; 4225 4226 return yds.first; 4227 4228free_list: 4229 ethtool_eee_get_list_free(yds.first); 4230 return NULL; 4231} 4232 4233/* ETHTOOL_MSG_EEE_GET - notify */ 4234void ethtool_eee_get_ntf_free(struct ethtool_eee_get_ntf *rsp) 4235{ 4236 ethtool_header_free(&rsp->obj.header); 4237 ethtool_bitset_free(&rsp->obj.modes_ours); 4238 ethtool_bitset_free(&rsp->obj.modes_peer); 4239 free(rsp); 4240} 4241 4242/* ============== ETHTOOL_MSG_EEE_SET ============== */ 4243/* ETHTOOL_MSG_EEE_SET - do */ 4244void ethtool_eee_set_req_free(struct ethtool_eee_set_req *req) 4245{ 4246 ethtool_header_free(&req->header); 4247 ethtool_bitset_free(&req->modes_ours); 4248 ethtool_bitset_free(&req->modes_peer); 4249 free(req); 4250} 4251 4252int ethtool_eee_set(struct ynl_sock *ys, struct ethtool_eee_set_req *req) 4253{ 4254 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4255 struct nlmsghdr *nlh; 4256 int err; 4257 4258 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_EEE_SET, 1); 4259 ys->req_policy = &ethtool_eee_nest; 4260 4261 if (req->_present.header) 4262 ethtool_header_put(nlh, ETHTOOL_A_EEE_HEADER, &req->header); 4263 if (req->_present.modes_ours) 4264 ethtool_bitset_put(nlh, ETHTOOL_A_EEE_MODES_OURS, &req->modes_ours); 4265 if (req->_present.modes_peer) 4266 ethtool_bitset_put(nlh, ETHTOOL_A_EEE_MODES_PEER, &req->modes_peer); 4267 if (req->_present.active) 4268 mnl_attr_put_u8(nlh, ETHTOOL_A_EEE_ACTIVE, req->active); 4269 if (req->_present.enabled) 4270 mnl_attr_put_u8(nlh, ETHTOOL_A_EEE_ENABLED, req->enabled); 4271 if (req->_present.tx_lpi_enabled) 4272 mnl_attr_put_u8(nlh, ETHTOOL_A_EEE_TX_LPI_ENABLED, req->tx_lpi_enabled); 4273 if (req->_present.tx_lpi_timer) 4274 mnl_attr_put_u32(nlh, ETHTOOL_A_EEE_TX_LPI_TIMER, req->tx_lpi_timer); 4275 4276 err = ynl_exec(ys, nlh, &yrs); 4277 if (err < 0) 4278 return -1; 4279 4280 return 0; 4281} 4282 4283/* ============== ETHTOOL_MSG_TSINFO_GET ============== */ 4284/* ETHTOOL_MSG_TSINFO_GET - do */ 4285void ethtool_tsinfo_get_req_free(struct ethtool_tsinfo_get_req *req) 4286{ 4287 ethtool_header_free(&req->header); 4288 free(req); 4289} 4290 4291void ethtool_tsinfo_get_rsp_free(struct ethtool_tsinfo_get_rsp *rsp) 4292{ 4293 ethtool_header_free(&rsp->header); 4294 ethtool_bitset_free(&rsp->timestamping); 4295 ethtool_bitset_free(&rsp->tx_types); 4296 ethtool_bitset_free(&rsp->rx_filters); 4297 free(rsp); 4298} 4299 4300int ethtool_tsinfo_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 4301{ 4302 struct ethtool_tsinfo_get_rsp *dst; 4303 struct ynl_parse_arg *yarg = data; 4304 const struct nlattr *attr; 4305 struct ynl_parse_arg parg; 4306 4307 dst = yarg->data; 4308 parg.ys = yarg->ys; 4309 4310 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 4311 unsigned int type = mnl_attr_get_type(attr); 4312 4313 if (type == ETHTOOL_A_TSINFO_HEADER) { 4314 if (ynl_attr_validate(yarg, attr)) 4315 return MNL_CB_ERROR; 4316 dst->_present.header = 1; 4317 4318 parg.rsp_policy = &ethtool_header_nest; 4319 parg.data = &dst->header; 4320 if (ethtool_header_parse(&parg, attr)) 4321 return MNL_CB_ERROR; 4322 } else if (type == ETHTOOL_A_TSINFO_TIMESTAMPING) { 4323 if (ynl_attr_validate(yarg, attr)) 4324 return MNL_CB_ERROR; 4325 dst->_present.timestamping = 1; 4326 4327 parg.rsp_policy = &ethtool_bitset_nest; 4328 parg.data = &dst->timestamping; 4329 if (ethtool_bitset_parse(&parg, attr)) 4330 return MNL_CB_ERROR; 4331 } else if (type == ETHTOOL_A_TSINFO_TX_TYPES) { 4332 if (ynl_attr_validate(yarg, attr)) 4333 return MNL_CB_ERROR; 4334 dst->_present.tx_types = 1; 4335 4336 parg.rsp_policy = &ethtool_bitset_nest; 4337 parg.data = &dst->tx_types; 4338 if (ethtool_bitset_parse(&parg, attr)) 4339 return MNL_CB_ERROR; 4340 } else if (type == ETHTOOL_A_TSINFO_RX_FILTERS) { 4341 if (ynl_attr_validate(yarg, attr)) 4342 return MNL_CB_ERROR; 4343 dst->_present.rx_filters = 1; 4344 4345 parg.rsp_policy = &ethtool_bitset_nest; 4346 parg.data = &dst->rx_filters; 4347 if (ethtool_bitset_parse(&parg, attr)) 4348 return MNL_CB_ERROR; 4349 } else if (type == ETHTOOL_A_TSINFO_PHC_INDEX) { 4350 if (ynl_attr_validate(yarg, attr)) 4351 return MNL_CB_ERROR; 4352 dst->_present.phc_index = 1; 4353 dst->phc_index = mnl_attr_get_u32(attr); 4354 } 4355 } 4356 4357 return MNL_CB_OK; 4358} 4359 4360struct ethtool_tsinfo_get_rsp * 4361ethtool_tsinfo_get(struct ynl_sock *ys, struct ethtool_tsinfo_get_req *req) 4362{ 4363 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4364 struct ethtool_tsinfo_get_rsp *rsp; 4365 struct nlmsghdr *nlh; 4366 int err; 4367 4368 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_TSINFO_GET, 1); 4369 ys->req_policy = &ethtool_tsinfo_nest; 4370 yrs.yarg.rsp_policy = &ethtool_tsinfo_nest; 4371 4372 if (req->_present.header) 4373 ethtool_header_put(nlh, ETHTOOL_A_TSINFO_HEADER, &req->header); 4374 4375 rsp = calloc(1, sizeof(*rsp)); 4376 yrs.yarg.data = rsp; 4377 yrs.cb = ethtool_tsinfo_get_rsp_parse; 4378 yrs.rsp_cmd = 26; 4379 4380 err = ynl_exec(ys, nlh, &yrs); 4381 if (err < 0) 4382 goto err_free; 4383 4384 return rsp; 4385 4386err_free: 4387 ethtool_tsinfo_get_rsp_free(rsp); 4388 return NULL; 4389} 4390 4391/* ETHTOOL_MSG_TSINFO_GET - dump */ 4392void ethtool_tsinfo_get_list_free(struct ethtool_tsinfo_get_list *rsp) 4393{ 4394 struct ethtool_tsinfo_get_list *next = rsp; 4395 4396 while ((void *)next != YNL_LIST_END) { 4397 rsp = next; 4398 next = rsp->next; 4399 4400 ethtool_header_free(&rsp->obj.header); 4401 ethtool_bitset_free(&rsp->obj.timestamping); 4402 ethtool_bitset_free(&rsp->obj.tx_types); 4403 ethtool_bitset_free(&rsp->obj.rx_filters); 4404 free(rsp); 4405 } 4406} 4407 4408struct ethtool_tsinfo_get_list * 4409ethtool_tsinfo_get_dump(struct ynl_sock *ys, 4410 struct ethtool_tsinfo_get_req_dump *req) 4411{ 4412 struct ynl_dump_state yds = {}; 4413 struct nlmsghdr *nlh; 4414 int err; 4415 4416 yds.ys = ys; 4417 yds.alloc_sz = sizeof(struct ethtool_tsinfo_get_list); 4418 yds.cb = ethtool_tsinfo_get_rsp_parse; 4419 yds.rsp_cmd = 26; 4420 yds.rsp_policy = &ethtool_tsinfo_nest; 4421 4422 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_TSINFO_GET, 1); 4423 ys->req_policy = &ethtool_tsinfo_nest; 4424 4425 if (req->_present.header) 4426 ethtool_header_put(nlh, ETHTOOL_A_TSINFO_HEADER, &req->header); 4427 4428 err = ynl_exec_dump(ys, nlh, &yds); 4429 if (err < 0) 4430 goto free_list; 4431 4432 return yds.first; 4433 4434free_list: 4435 ethtool_tsinfo_get_list_free(yds.first); 4436 return NULL; 4437} 4438 4439/* ============== ETHTOOL_MSG_CABLE_TEST_ACT ============== */ 4440/* ETHTOOL_MSG_CABLE_TEST_ACT - do */ 4441void ethtool_cable_test_act_req_free(struct ethtool_cable_test_act_req *req) 4442{ 4443 ethtool_header_free(&req->header); 4444 free(req); 4445} 4446 4447int ethtool_cable_test_act(struct ynl_sock *ys, 4448 struct ethtool_cable_test_act_req *req) 4449{ 4450 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4451 struct nlmsghdr *nlh; 4452 int err; 4453 4454 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_CABLE_TEST_ACT, 1); 4455 ys->req_policy = &ethtool_cable_test_nest; 4456 4457 if (req->_present.header) 4458 ethtool_header_put(nlh, ETHTOOL_A_CABLE_TEST_HEADER, &req->header); 4459 4460 err = ynl_exec(ys, nlh, &yrs); 4461 if (err < 0) 4462 return -1; 4463 4464 return 0; 4465} 4466 4467/* ============== ETHTOOL_MSG_CABLE_TEST_TDR_ACT ============== */ 4468/* ETHTOOL_MSG_CABLE_TEST_TDR_ACT - do */ 4469void 4470ethtool_cable_test_tdr_act_req_free(struct ethtool_cable_test_tdr_act_req *req) 4471{ 4472 ethtool_header_free(&req->header); 4473 free(req); 4474} 4475 4476int ethtool_cable_test_tdr_act(struct ynl_sock *ys, 4477 struct ethtool_cable_test_tdr_act_req *req) 4478{ 4479 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4480 struct nlmsghdr *nlh; 4481 int err; 4482 4483 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_CABLE_TEST_TDR_ACT, 1); 4484 ys->req_policy = &ethtool_cable_test_tdr_nest; 4485 4486 if (req->_present.header) 4487 ethtool_header_put(nlh, ETHTOOL_A_CABLE_TEST_TDR_HEADER, &req->header); 4488 4489 err = ynl_exec(ys, nlh, &yrs); 4490 if (err < 0) 4491 return -1; 4492 4493 return 0; 4494} 4495 4496/* ============== ETHTOOL_MSG_TUNNEL_INFO_GET ============== */ 4497/* ETHTOOL_MSG_TUNNEL_INFO_GET - do */ 4498void ethtool_tunnel_info_get_req_free(struct ethtool_tunnel_info_get_req *req) 4499{ 4500 ethtool_header_free(&req->header); 4501 free(req); 4502} 4503 4504void ethtool_tunnel_info_get_rsp_free(struct ethtool_tunnel_info_get_rsp *rsp) 4505{ 4506 ethtool_header_free(&rsp->header); 4507 ethtool_tunnel_udp_free(&rsp->udp_ports); 4508 free(rsp); 4509} 4510 4511int ethtool_tunnel_info_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 4512{ 4513 struct ethtool_tunnel_info_get_rsp *dst; 4514 struct ynl_parse_arg *yarg = data; 4515 const struct nlattr *attr; 4516 struct ynl_parse_arg parg; 4517 4518 dst = yarg->data; 4519 parg.ys = yarg->ys; 4520 4521 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 4522 unsigned int type = mnl_attr_get_type(attr); 4523 4524 if (type == ETHTOOL_A_TUNNEL_INFO_HEADER) { 4525 if (ynl_attr_validate(yarg, attr)) 4526 return MNL_CB_ERROR; 4527 dst->_present.header = 1; 4528 4529 parg.rsp_policy = &ethtool_header_nest; 4530 parg.data = &dst->header; 4531 if (ethtool_header_parse(&parg, attr)) 4532 return MNL_CB_ERROR; 4533 } else if (type == ETHTOOL_A_TUNNEL_INFO_UDP_PORTS) { 4534 if (ynl_attr_validate(yarg, attr)) 4535 return MNL_CB_ERROR; 4536 dst->_present.udp_ports = 1; 4537 4538 parg.rsp_policy = &ethtool_tunnel_udp_nest; 4539 parg.data = &dst->udp_ports; 4540 if (ethtool_tunnel_udp_parse(&parg, attr)) 4541 return MNL_CB_ERROR; 4542 } 4543 } 4544 4545 return MNL_CB_OK; 4546} 4547 4548struct ethtool_tunnel_info_get_rsp * 4549ethtool_tunnel_info_get(struct ynl_sock *ys, 4550 struct ethtool_tunnel_info_get_req *req) 4551{ 4552 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4553 struct ethtool_tunnel_info_get_rsp *rsp; 4554 struct nlmsghdr *nlh; 4555 int err; 4556 4557 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_TUNNEL_INFO_GET, 1); 4558 ys->req_policy = &ethtool_tunnel_info_nest; 4559 yrs.yarg.rsp_policy = &ethtool_tunnel_info_nest; 4560 4561 if (req->_present.header) 4562 ethtool_header_put(nlh, ETHTOOL_A_TUNNEL_INFO_HEADER, &req->header); 4563 4564 rsp = calloc(1, sizeof(*rsp)); 4565 yrs.yarg.data = rsp; 4566 yrs.cb = ethtool_tunnel_info_get_rsp_parse; 4567 yrs.rsp_cmd = 29; 4568 4569 err = ynl_exec(ys, nlh, &yrs); 4570 if (err < 0) 4571 goto err_free; 4572 4573 return rsp; 4574 4575err_free: 4576 ethtool_tunnel_info_get_rsp_free(rsp); 4577 return NULL; 4578} 4579 4580/* ETHTOOL_MSG_TUNNEL_INFO_GET - dump */ 4581void 4582ethtool_tunnel_info_get_list_free(struct ethtool_tunnel_info_get_list *rsp) 4583{ 4584 struct ethtool_tunnel_info_get_list *next = rsp; 4585 4586 while ((void *)next != YNL_LIST_END) { 4587 rsp = next; 4588 next = rsp->next; 4589 4590 ethtool_header_free(&rsp->obj.header); 4591 ethtool_tunnel_udp_free(&rsp->obj.udp_ports); 4592 free(rsp); 4593 } 4594} 4595 4596struct ethtool_tunnel_info_get_list * 4597ethtool_tunnel_info_get_dump(struct ynl_sock *ys, 4598 struct ethtool_tunnel_info_get_req_dump *req) 4599{ 4600 struct ynl_dump_state yds = {}; 4601 struct nlmsghdr *nlh; 4602 int err; 4603 4604 yds.ys = ys; 4605 yds.alloc_sz = sizeof(struct ethtool_tunnel_info_get_list); 4606 yds.cb = ethtool_tunnel_info_get_rsp_parse; 4607 yds.rsp_cmd = 29; 4608 yds.rsp_policy = &ethtool_tunnel_info_nest; 4609 4610 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_TUNNEL_INFO_GET, 1); 4611 ys->req_policy = &ethtool_tunnel_info_nest; 4612 4613 if (req->_present.header) 4614 ethtool_header_put(nlh, ETHTOOL_A_TUNNEL_INFO_HEADER, &req->header); 4615 4616 err = ynl_exec_dump(ys, nlh, &yds); 4617 if (err < 0) 4618 goto free_list; 4619 4620 return yds.first; 4621 4622free_list: 4623 ethtool_tunnel_info_get_list_free(yds.first); 4624 return NULL; 4625} 4626 4627/* ============== ETHTOOL_MSG_FEC_GET ============== */ 4628/* ETHTOOL_MSG_FEC_GET - do */ 4629void ethtool_fec_get_req_free(struct ethtool_fec_get_req *req) 4630{ 4631 ethtool_header_free(&req->header); 4632 free(req); 4633} 4634 4635void ethtool_fec_get_rsp_free(struct ethtool_fec_get_rsp *rsp) 4636{ 4637 ethtool_header_free(&rsp->header); 4638 ethtool_bitset_free(&rsp->modes); 4639 ethtool_fec_stat_free(&rsp->stats); 4640 free(rsp); 4641} 4642 4643int ethtool_fec_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 4644{ 4645 struct ynl_parse_arg *yarg = data; 4646 struct ethtool_fec_get_rsp *dst; 4647 const struct nlattr *attr; 4648 struct ynl_parse_arg parg; 4649 4650 dst = yarg->data; 4651 parg.ys = yarg->ys; 4652 4653 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 4654 unsigned int type = mnl_attr_get_type(attr); 4655 4656 if (type == ETHTOOL_A_FEC_HEADER) { 4657 if (ynl_attr_validate(yarg, attr)) 4658 return MNL_CB_ERROR; 4659 dst->_present.header = 1; 4660 4661 parg.rsp_policy = &ethtool_header_nest; 4662 parg.data = &dst->header; 4663 if (ethtool_header_parse(&parg, attr)) 4664 return MNL_CB_ERROR; 4665 } else if (type == ETHTOOL_A_FEC_MODES) { 4666 if (ynl_attr_validate(yarg, attr)) 4667 return MNL_CB_ERROR; 4668 dst->_present.modes = 1; 4669 4670 parg.rsp_policy = &ethtool_bitset_nest; 4671 parg.data = &dst->modes; 4672 if (ethtool_bitset_parse(&parg, attr)) 4673 return MNL_CB_ERROR; 4674 } else if (type == ETHTOOL_A_FEC_AUTO) { 4675 if (ynl_attr_validate(yarg, attr)) 4676 return MNL_CB_ERROR; 4677 dst->_present.auto_ = 1; 4678 dst->auto_ = mnl_attr_get_u8(attr); 4679 } else if (type == ETHTOOL_A_FEC_ACTIVE) { 4680 if (ynl_attr_validate(yarg, attr)) 4681 return MNL_CB_ERROR; 4682 dst->_present.active = 1; 4683 dst->active = mnl_attr_get_u32(attr); 4684 } else if (type == ETHTOOL_A_FEC_STATS) { 4685 if (ynl_attr_validate(yarg, attr)) 4686 return MNL_CB_ERROR; 4687 dst->_present.stats = 1; 4688 4689 parg.rsp_policy = &ethtool_fec_stat_nest; 4690 parg.data = &dst->stats; 4691 if (ethtool_fec_stat_parse(&parg, attr)) 4692 return MNL_CB_ERROR; 4693 } 4694 } 4695 4696 return MNL_CB_OK; 4697} 4698 4699struct ethtool_fec_get_rsp * 4700ethtool_fec_get(struct ynl_sock *ys, struct ethtool_fec_get_req *req) 4701{ 4702 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4703 struct ethtool_fec_get_rsp *rsp; 4704 struct nlmsghdr *nlh; 4705 int err; 4706 4707 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_FEC_GET, 1); 4708 ys->req_policy = &ethtool_fec_nest; 4709 yrs.yarg.rsp_policy = &ethtool_fec_nest; 4710 4711 if (req->_present.header) 4712 ethtool_header_put(nlh, ETHTOOL_A_FEC_HEADER, &req->header); 4713 4714 rsp = calloc(1, sizeof(*rsp)); 4715 yrs.yarg.data = rsp; 4716 yrs.cb = ethtool_fec_get_rsp_parse; 4717 yrs.rsp_cmd = 30; 4718 4719 err = ynl_exec(ys, nlh, &yrs); 4720 if (err < 0) 4721 goto err_free; 4722 4723 return rsp; 4724 4725err_free: 4726 ethtool_fec_get_rsp_free(rsp); 4727 return NULL; 4728} 4729 4730/* ETHTOOL_MSG_FEC_GET - dump */ 4731void ethtool_fec_get_list_free(struct ethtool_fec_get_list *rsp) 4732{ 4733 struct ethtool_fec_get_list *next = rsp; 4734 4735 while ((void *)next != YNL_LIST_END) { 4736 rsp = next; 4737 next = rsp->next; 4738 4739 ethtool_header_free(&rsp->obj.header); 4740 ethtool_bitset_free(&rsp->obj.modes); 4741 ethtool_fec_stat_free(&rsp->obj.stats); 4742 free(rsp); 4743 } 4744} 4745 4746struct ethtool_fec_get_list * 4747ethtool_fec_get_dump(struct ynl_sock *ys, struct ethtool_fec_get_req_dump *req) 4748{ 4749 struct ynl_dump_state yds = {}; 4750 struct nlmsghdr *nlh; 4751 int err; 4752 4753 yds.ys = ys; 4754 yds.alloc_sz = sizeof(struct ethtool_fec_get_list); 4755 yds.cb = ethtool_fec_get_rsp_parse; 4756 yds.rsp_cmd = 30; 4757 yds.rsp_policy = &ethtool_fec_nest; 4758 4759 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_FEC_GET, 1); 4760 ys->req_policy = &ethtool_fec_nest; 4761 4762 if (req->_present.header) 4763 ethtool_header_put(nlh, ETHTOOL_A_FEC_HEADER, &req->header); 4764 4765 err = ynl_exec_dump(ys, nlh, &yds); 4766 if (err < 0) 4767 goto free_list; 4768 4769 return yds.first; 4770 4771free_list: 4772 ethtool_fec_get_list_free(yds.first); 4773 return NULL; 4774} 4775 4776/* ETHTOOL_MSG_FEC_GET - notify */ 4777void ethtool_fec_get_ntf_free(struct ethtool_fec_get_ntf *rsp) 4778{ 4779 ethtool_header_free(&rsp->obj.header); 4780 ethtool_bitset_free(&rsp->obj.modes); 4781 ethtool_fec_stat_free(&rsp->obj.stats); 4782 free(rsp); 4783} 4784 4785/* ============== ETHTOOL_MSG_FEC_SET ============== */ 4786/* ETHTOOL_MSG_FEC_SET - do */ 4787void ethtool_fec_set_req_free(struct ethtool_fec_set_req *req) 4788{ 4789 ethtool_header_free(&req->header); 4790 ethtool_bitset_free(&req->modes); 4791 ethtool_fec_stat_free(&req->stats); 4792 free(req); 4793} 4794 4795int ethtool_fec_set(struct ynl_sock *ys, struct ethtool_fec_set_req *req) 4796{ 4797 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4798 struct nlmsghdr *nlh; 4799 int err; 4800 4801 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_FEC_SET, 1); 4802 ys->req_policy = &ethtool_fec_nest; 4803 4804 if (req->_present.header) 4805 ethtool_header_put(nlh, ETHTOOL_A_FEC_HEADER, &req->header); 4806 if (req->_present.modes) 4807 ethtool_bitset_put(nlh, ETHTOOL_A_FEC_MODES, &req->modes); 4808 if (req->_present.auto_) 4809 mnl_attr_put_u8(nlh, ETHTOOL_A_FEC_AUTO, req->auto_); 4810 if (req->_present.active) 4811 mnl_attr_put_u32(nlh, ETHTOOL_A_FEC_ACTIVE, req->active); 4812 if (req->_present.stats) 4813 ethtool_fec_stat_put(nlh, ETHTOOL_A_FEC_STATS, &req->stats); 4814 4815 err = ynl_exec(ys, nlh, &yrs); 4816 if (err < 0) 4817 return -1; 4818 4819 return 0; 4820} 4821 4822/* ============== ETHTOOL_MSG_MODULE_EEPROM_GET ============== */ 4823/* ETHTOOL_MSG_MODULE_EEPROM_GET - do */ 4824void 4825ethtool_module_eeprom_get_req_free(struct ethtool_module_eeprom_get_req *req) 4826{ 4827 ethtool_header_free(&req->header); 4828 free(req); 4829} 4830 4831void 4832ethtool_module_eeprom_get_rsp_free(struct ethtool_module_eeprom_get_rsp *rsp) 4833{ 4834 ethtool_header_free(&rsp->header); 4835 free(rsp->data); 4836 free(rsp); 4837} 4838 4839int ethtool_module_eeprom_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 4840{ 4841 struct ethtool_module_eeprom_get_rsp *dst; 4842 struct ynl_parse_arg *yarg = data; 4843 const struct nlattr *attr; 4844 struct ynl_parse_arg parg; 4845 4846 dst = yarg->data; 4847 parg.ys = yarg->ys; 4848 4849 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 4850 unsigned int type = mnl_attr_get_type(attr); 4851 4852 if (type == ETHTOOL_A_MODULE_EEPROM_HEADER) { 4853 if (ynl_attr_validate(yarg, attr)) 4854 return MNL_CB_ERROR; 4855 dst->_present.header = 1; 4856 4857 parg.rsp_policy = &ethtool_header_nest; 4858 parg.data = &dst->header; 4859 if (ethtool_header_parse(&parg, attr)) 4860 return MNL_CB_ERROR; 4861 } else if (type == ETHTOOL_A_MODULE_EEPROM_OFFSET) { 4862 if (ynl_attr_validate(yarg, attr)) 4863 return MNL_CB_ERROR; 4864 dst->_present.offset = 1; 4865 dst->offset = mnl_attr_get_u32(attr); 4866 } else if (type == ETHTOOL_A_MODULE_EEPROM_LENGTH) { 4867 if (ynl_attr_validate(yarg, attr)) 4868 return MNL_CB_ERROR; 4869 dst->_present.length = 1; 4870 dst->length = mnl_attr_get_u32(attr); 4871 } else if (type == ETHTOOL_A_MODULE_EEPROM_PAGE) { 4872 if (ynl_attr_validate(yarg, attr)) 4873 return MNL_CB_ERROR; 4874 dst->_present.page = 1; 4875 dst->page = mnl_attr_get_u8(attr); 4876 } else if (type == ETHTOOL_A_MODULE_EEPROM_BANK) { 4877 if (ynl_attr_validate(yarg, attr)) 4878 return MNL_CB_ERROR; 4879 dst->_present.bank = 1; 4880 dst->bank = mnl_attr_get_u8(attr); 4881 } else if (type == ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS) { 4882 if (ynl_attr_validate(yarg, attr)) 4883 return MNL_CB_ERROR; 4884 dst->_present.i2c_address = 1; 4885 dst->i2c_address = mnl_attr_get_u8(attr); 4886 } else if (type == ETHTOOL_A_MODULE_EEPROM_DATA) { 4887 unsigned int len; 4888 4889 if (ynl_attr_validate(yarg, attr)) 4890 return MNL_CB_ERROR; 4891 4892 len = mnl_attr_get_payload_len(attr); 4893 dst->_present.data_len = len; 4894 dst->data = malloc(len); 4895 memcpy(dst->data, mnl_attr_get_payload(attr), len); 4896 } 4897 } 4898 4899 return MNL_CB_OK; 4900} 4901 4902struct ethtool_module_eeprom_get_rsp * 4903ethtool_module_eeprom_get(struct ynl_sock *ys, 4904 struct ethtool_module_eeprom_get_req *req) 4905{ 4906 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4907 struct ethtool_module_eeprom_get_rsp *rsp; 4908 struct nlmsghdr *nlh; 4909 int err; 4910 4911 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MODULE_EEPROM_GET, 1); 4912 ys->req_policy = &ethtool_module_eeprom_nest; 4913 yrs.yarg.rsp_policy = &ethtool_module_eeprom_nest; 4914 4915 if (req->_present.header) 4916 ethtool_header_put(nlh, ETHTOOL_A_MODULE_EEPROM_HEADER, &req->header); 4917 4918 rsp = calloc(1, sizeof(*rsp)); 4919 yrs.yarg.data = rsp; 4920 yrs.cb = ethtool_module_eeprom_get_rsp_parse; 4921 yrs.rsp_cmd = 32; 4922 4923 err = ynl_exec(ys, nlh, &yrs); 4924 if (err < 0) 4925 goto err_free; 4926 4927 return rsp; 4928 4929err_free: 4930 ethtool_module_eeprom_get_rsp_free(rsp); 4931 return NULL; 4932} 4933 4934/* ETHTOOL_MSG_MODULE_EEPROM_GET - dump */ 4935void 4936ethtool_module_eeprom_get_list_free(struct ethtool_module_eeprom_get_list *rsp) 4937{ 4938 struct ethtool_module_eeprom_get_list *next = rsp; 4939 4940 while ((void *)next != YNL_LIST_END) { 4941 rsp = next; 4942 next = rsp->next; 4943 4944 ethtool_header_free(&rsp->obj.header); 4945 free(rsp->obj.data); 4946 free(rsp); 4947 } 4948} 4949 4950struct ethtool_module_eeprom_get_list * 4951ethtool_module_eeprom_get_dump(struct ynl_sock *ys, 4952 struct ethtool_module_eeprom_get_req_dump *req) 4953{ 4954 struct ynl_dump_state yds = {}; 4955 struct nlmsghdr *nlh; 4956 int err; 4957 4958 yds.ys = ys; 4959 yds.alloc_sz = sizeof(struct ethtool_module_eeprom_get_list); 4960 yds.cb = ethtool_module_eeprom_get_rsp_parse; 4961 yds.rsp_cmd = 32; 4962 yds.rsp_policy = &ethtool_module_eeprom_nest; 4963 4964 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_MODULE_EEPROM_GET, 1); 4965 ys->req_policy = &ethtool_module_eeprom_nest; 4966 4967 if (req->_present.header) 4968 ethtool_header_put(nlh, ETHTOOL_A_MODULE_EEPROM_HEADER, &req->header); 4969 4970 err = ynl_exec_dump(ys, nlh, &yds); 4971 if (err < 0) 4972 goto free_list; 4973 4974 return yds.first; 4975 4976free_list: 4977 ethtool_module_eeprom_get_list_free(yds.first); 4978 return NULL; 4979} 4980 4981/* ============== ETHTOOL_MSG_PHC_VCLOCKS_GET ============== */ 4982/* ETHTOOL_MSG_PHC_VCLOCKS_GET - do */ 4983void ethtool_phc_vclocks_get_req_free(struct ethtool_phc_vclocks_get_req *req) 4984{ 4985 ethtool_header_free(&req->header); 4986 free(req); 4987} 4988 4989void ethtool_phc_vclocks_get_rsp_free(struct ethtool_phc_vclocks_get_rsp *rsp) 4990{ 4991 ethtool_header_free(&rsp->header); 4992 free(rsp); 4993} 4994 4995int ethtool_phc_vclocks_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 4996{ 4997 struct ethtool_phc_vclocks_get_rsp *dst; 4998 struct ynl_parse_arg *yarg = data; 4999 const struct nlattr *attr; 5000 struct ynl_parse_arg parg; 5001 5002 dst = yarg->data; 5003 parg.ys = yarg->ys; 5004 5005 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 5006 unsigned int type = mnl_attr_get_type(attr); 5007 5008 if (type == ETHTOOL_A_PHC_VCLOCKS_HEADER) { 5009 if (ynl_attr_validate(yarg, attr)) 5010 return MNL_CB_ERROR; 5011 dst->_present.header = 1; 5012 5013 parg.rsp_policy = &ethtool_header_nest; 5014 parg.data = &dst->header; 5015 if (ethtool_header_parse(&parg, attr)) 5016 return MNL_CB_ERROR; 5017 } else if (type == ETHTOOL_A_PHC_VCLOCKS_NUM) { 5018 if (ynl_attr_validate(yarg, attr)) 5019 return MNL_CB_ERROR; 5020 dst->_present.num = 1; 5021 dst->num = mnl_attr_get_u32(attr); 5022 } 5023 } 5024 5025 return MNL_CB_OK; 5026} 5027 5028struct ethtool_phc_vclocks_get_rsp * 5029ethtool_phc_vclocks_get(struct ynl_sock *ys, 5030 struct ethtool_phc_vclocks_get_req *req) 5031{ 5032 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5033 struct ethtool_phc_vclocks_get_rsp *rsp; 5034 struct nlmsghdr *nlh; 5035 int err; 5036 5037 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PHC_VCLOCKS_GET, 1); 5038 ys->req_policy = &ethtool_phc_vclocks_nest; 5039 yrs.yarg.rsp_policy = &ethtool_phc_vclocks_nest; 5040 5041 if (req->_present.header) 5042 ethtool_header_put(nlh, ETHTOOL_A_PHC_VCLOCKS_HEADER, &req->header); 5043 5044 rsp = calloc(1, sizeof(*rsp)); 5045 yrs.yarg.data = rsp; 5046 yrs.cb = ethtool_phc_vclocks_get_rsp_parse; 5047 yrs.rsp_cmd = 34; 5048 5049 err = ynl_exec(ys, nlh, &yrs); 5050 if (err < 0) 5051 goto err_free; 5052 5053 return rsp; 5054 5055err_free: 5056 ethtool_phc_vclocks_get_rsp_free(rsp); 5057 return NULL; 5058} 5059 5060/* ETHTOOL_MSG_PHC_VCLOCKS_GET - dump */ 5061void 5062ethtool_phc_vclocks_get_list_free(struct ethtool_phc_vclocks_get_list *rsp) 5063{ 5064 struct ethtool_phc_vclocks_get_list *next = rsp; 5065 5066 while ((void *)next != YNL_LIST_END) { 5067 rsp = next; 5068 next = rsp->next; 5069 5070 ethtool_header_free(&rsp->obj.header); 5071 free(rsp); 5072 } 5073} 5074 5075struct ethtool_phc_vclocks_get_list * 5076ethtool_phc_vclocks_get_dump(struct ynl_sock *ys, 5077 struct ethtool_phc_vclocks_get_req_dump *req) 5078{ 5079 struct ynl_dump_state yds = {}; 5080 struct nlmsghdr *nlh; 5081 int err; 5082 5083 yds.ys = ys; 5084 yds.alloc_sz = sizeof(struct ethtool_phc_vclocks_get_list); 5085 yds.cb = ethtool_phc_vclocks_get_rsp_parse; 5086 yds.rsp_cmd = 34; 5087 yds.rsp_policy = &ethtool_phc_vclocks_nest; 5088 5089 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PHC_VCLOCKS_GET, 1); 5090 ys->req_policy = &ethtool_phc_vclocks_nest; 5091 5092 if (req->_present.header) 5093 ethtool_header_put(nlh, ETHTOOL_A_PHC_VCLOCKS_HEADER, &req->header); 5094 5095 err = ynl_exec_dump(ys, nlh, &yds); 5096 if (err < 0) 5097 goto free_list; 5098 5099 return yds.first; 5100 5101free_list: 5102 ethtool_phc_vclocks_get_list_free(yds.first); 5103 return NULL; 5104} 5105 5106/* ============== ETHTOOL_MSG_MODULE_GET ============== */ 5107/* ETHTOOL_MSG_MODULE_GET - do */ 5108void ethtool_module_get_req_free(struct ethtool_module_get_req *req) 5109{ 5110 ethtool_header_free(&req->header); 5111 free(req); 5112} 5113 5114void ethtool_module_get_rsp_free(struct ethtool_module_get_rsp *rsp) 5115{ 5116 ethtool_header_free(&rsp->header); 5117 free(rsp); 5118} 5119 5120int ethtool_module_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 5121{ 5122 struct ethtool_module_get_rsp *dst; 5123 struct ynl_parse_arg *yarg = data; 5124 const struct nlattr *attr; 5125 struct ynl_parse_arg parg; 5126 5127 dst = yarg->data; 5128 parg.ys = yarg->ys; 5129 5130 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 5131 unsigned int type = mnl_attr_get_type(attr); 5132 5133 if (type == ETHTOOL_A_MODULE_HEADER) { 5134 if (ynl_attr_validate(yarg, attr)) 5135 return MNL_CB_ERROR; 5136 dst->_present.header = 1; 5137 5138 parg.rsp_policy = &ethtool_header_nest; 5139 parg.data = &dst->header; 5140 if (ethtool_header_parse(&parg, attr)) 5141 return MNL_CB_ERROR; 5142 } else if (type == ETHTOOL_A_MODULE_POWER_MODE_POLICY) { 5143 if (ynl_attr_validate(yarg, attr)) 5144 return MNL_CB_ERROR; 5145 dst->_present.power_mode_policy = 1; 5146 dst->power_mode_policy = mnl_attr_get_u8(attr); 5147 } else if (type == ETHTOOL_A_MODULE_POWER_MODE) { 5148 if (ynl_attr_validate(yarg, attr)) 5149 return MNL_CB_ERROR; 5150 dst->_present.power_mode = 1; 5151 dst->power_mode = mnl_attr_get_u8(attr); 5152 } 5153 } 5154 5155 return MNL_CB_OK; 5156} 5157 5158struct ethtool_module_get_rsp * 5159ethtool_module_get(struct ynl_sock *ys, struct ethtool_module_get_req *req) 5160{ 5161 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5162 struct ethtool_module_get_rsp *rsp; 5163 struct nlmsghdr *nlh; 5164 int err; 5165 5166 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MODULE_GET, 1); 5167 ys->req_policy = &ethtool_module_nest; 5168 yrs.yarg.rsp_policy = &ethtool_module_nest; 5169 5170 if (req->_present.header) 5171 ethtool_header_put(nlh, ETHTOOL_A_MODULE_HEADER, &req->header); 5172 5173 rsp = calloc(1, sizeof(*rsp)); 5174 yrs.yarg.data = rsp; 5175 yrs.cb = ethtool_module_get_rsp_parse; 5176 yrs.rsp_cmd = 35; 5177 5178 err = ynl_exec(ys, nlh, &yrs); 5179 if (err < 0) 5180 goto err_free; 5181 5182 return rsp; 5183 5184err_free: 5185 ethtool_module_get_rsp_free(rsp); 5186 return NULL; 5187} 5188 5189/* ETHTOOL_MSG_MODULE_GET - dump */ 5190void ethtool_module_get_list_free(struct ethtool_module_get_list *rsp) 5191{ 5192 struct ethtool_module_get_list *next = rsp; 5193 5194 while ((void *)next != YNL_LIST_END) { 5195 rsp = next; 5196 next = rsp->next; 5197 5198 ethtool_header_free(&rsp->obj.header); 5199 free(rsp); 5200 } 5201} 5202 5203struct ethtool_module_get_list * 5204ethtool_module_get_dump(struct ynl_sock *ys, 5205 struct ethtool_module_get_req_dump *req) 5206{ 5207 struct ynl_dump_state yds = {}; 5208 struct nlmsghdr *nlh; 5209 int err; 5210 5211 yds.ys = ys; 5212 yds.alloc_sz = sizeof(struct ethtool_module_get_list); 5213 yds.cb = ethtool_module_get_rsp_parse; 5214 yds.rsp_cmd = 35; 5215 yds.rsp_policy = &ethtool_module_nest; 5216 5217 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_MODULE_GET, 1); 5218 ys->req_policy = &ethtool_module_nest; 5219 5220 if (req->_present.header) 5221 ethtool_header_put(nlh, ETHTOOL_A_MODULE_HEADER, &req->header); 5222 5223 err = ynl_exec_dump(ys, nlh, &yds); 5224 if (err < 0) 5225 goto free_list; 5226 5227 return yds.first; 5228 5229free_list: 5230 ethtool_module_get_list_free(yds.first); 5231 return NULL; 5232} 5233 5234/* ETHTOOL_MSG_MODULE_GET - notify */ 5235void ethtool_module_get_ntf_free(struct ethtool_module_get_ntf *rsp) 5236{ 5237 ethtool_header_free(&rsp->obj.header); 5238 free(rsp); 5239} 5240 5241/* ============== ETHTOOL_MSG_MODULE_SET ============== */ 5242/* ETHTOOL_MSG_MODULE_SET - do */ 5243void ethtool_module_set_req_free(struct ethtool_module_set_req *req) 5244{ 5245 ethtool_header_free(&req->header); 5246 free(req); 5247} 5248 5249int ethtool_module_set(struct ynl_sock *ys, struct ethtool_module_set_req *req) 5250{ 5251 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5252 struct nlmsghdr *nlh; 5253 int err; 5254 5255 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MODULE_SET, 1); 5256 ys->req_policy = &ethtool_module_nest; 5257 5258 if (req->_present.header) 5259 ethtool_header_put(nlh, ETHTOOL_A_MODULE_HEADER, &req->header); 5260 if (req->_present.power_mode_policy) 5261 mnl_attr_put_u8(nlh, ETHTOOL_A_MODULE_POWER_MODE_POLICY, req->power_mode_policy); 5262 if (req->_present.power_mode) 5263 mnl_attr_put_u8(nlh, ETHTOOL_A_MODULE_POWER_MODE, req->power_mode); 5264 5265 err = ynl_exec(ys, nlh, &yrs); 5266 if (err < 0) 5267 return -1; 5268 5269 return 0; 5270} 5271 5272/* ============== ETHTOOL_MSG_PSE_GET ============== */ 5273/* ETHTOOL_MSG_PSE_GET - do */ 5274void ethtool_pse_get_req_free(struct ethtool_pse_get_req *req) 5275{ 5276 ethtool_header_free(&req->header); 5277 free(req); 5278} 5279 5280void ethtool_pse_get_rsp_free(struct ethtool_pse_get_rsp *rsp) 5281{ 5282 ethtool_header_free(&rsp->header); 5283 free(rsp); 5284} 5285 5286int ethtool_pse_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 5287{ 5288 struct ynl_parse_arg *yarg = data; 5289 struct ethtool_pse_get_rsp *dst; 5290 const struct nlattr *attr; 5291 struct ynl_parse_arg parg; 5292 5293 dst = yarg->data; 5294 parg.ys = yarg->ys; 5295 5296 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 5297 unsigned int type = mnl_attr_get_type(attr); 5298 5299 if (type == ETHTOOL_A_PSE_HEADER) { 5300 if (ynl_attr_validate(yarg, attr)) 5301 return MNL_CB_ERROR; 5302 dst->_present.header = 1; 5303 5304 parg.rsp_policy = &ethtool_header_nest; 5305 parg.data = &dst->header; 5306 if (ethtool_header_parse(&parg, attr)) 5307 return MNL_CB_ERROR; 5308 } else if (type == ETHTOOL_A_PODL_PSE_ADMIN_STATE) { 5309 if (ynl_attr_validate(yarg, attr)) 5310 return MNL_CB_ERROR; 5311 dst->_present.admin_state = 1; 5312 dst->admin_state = mnl_attr_get_u32(attr); 5313 } else if (type == ETHTOOL_A_PODL_PSE_ADMIN_CONTROL) { 5314 if (ynl_attr_validate(yarg, attr)) 5315 return MNL_CB_ERROR; 5316 dst->_present.admin_control = 1; 5317 dst->admin_control = mnl_attr_get_u32(attr); 5318 } else if (type == ETHTOOL_A_PODL_PSE_PW_D_STATUS) { 5319 if (ynl_attr_validate(yarg, attr)) 5320 return MNL_CB_ERROR; 5321 dst->_present.pw_d_status = 1; 5322 dst->pw_d_status = mnl_attr_get_u32(attr); 5323 } 5324 } 5325 5326 return MNL_CB_OK; 5327} 5328 5329struct ethtool_pse_get_rsp * 5330ethtool_pse_get(struct ynl_sock *ys, struct ethtool_pse_get_req *req) 5331{ 5332 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5333 struct ethtool_pse_get_rsp *rsp; 5334 struct nlmsghdr *nlh; 5335 int err; 5336 5337 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PSE_GET, 1); 5338 ys->req_policy = &ethtool_pse_nest; 5339 yrs.yarg.rsp_policy = &ethtool_pse_nest; 5340 5341 if (req->_present.header) 5342 ethtool_header_put(nlh, ETHTOOL_A_PSE_HEADER, &req->header); 5343 5344 rsp = calloc(1, sizeof(*rsp)); 5345 yrs.yarg.data = rsp; 5346 yrs.cb = ethtool_pse_get_rsp_parse; 5347 yrs.rsp_cmd = 37; 5348 5349 err = ynl_exec(ys, nlh, &yrs); 5350 if (err < 0) 5351 goto err_free; 5352 5353 return rsp; 5354 5355err_free: 5356 ethtool_pse_get_rsp_free(rsp); 5357 return NULL; 5358} 5359 5360/* ETHTOOL_MSG_PSE_GET - dump */ 5361void ethtool_pse_get_list_free(struct ethtool_pse_get_list *rsp) 5362{ 5363 struct ethtool_pse_get_list *next = rsp; 5364 5365 while ((void *)next != YNL_LIST_END) { 5366 rsp = next; 5367 next = rsp->next; 5368 5369 ethtool_header_free(&rsp->obj.header); 5370 free(rsp); 5371 } 5372} 5373 5374struct ethtool_pse_get_list * 5375ethtool_pse_get_dump(struct ynl_sock *ys, struct ethtool_pse_get_req_dump *req) 5376{ 5377 struct ynl_dump_state yds = {}; 5378 struct nlmsghdr *nlh; 5379 int err; 5380 5381 yds.ys = ys; 5382 yds.alloc_sz = sizeof(struct ethtool_pse_get_list); 5383 yds.cb = ethtool_pse_get_rsp_parse; 5384 yds.rsp_cmd = 37; 5385 yds.rsp_policy = &ethtool_pse_nest; 5386 5387 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PSE_GET, 1); 5388 ys->req_policy = &ethtool_pse_nest; 5389 5390 if (req->_present.header) 5391 ethtool_header_put(nlh, ETHTOOL_A_PSE_HEADER, &req->header); 5392 5393 err = ynl_exec_dump(ys, nlh, &yds); 5394 if (err < 0) 5395 goto free_list; 5396 5397 return yds.first; 5398 5399free_list: 5400 ethtool_pse_get_list_free(yds.first); 5401 return NULL; 5402} 5403 5404/* ============== ETHTOOL_MSG_PSE_SET ============== */ 5405/* ETHTOOL_MSG_PSE_SET - do */ 5406void ethtool_pse_set_req_free(struct ethtool_pse_set_req *req) 5407{ 5408 ethtool_header_free(&req->header); 5409 free(req); 5410} 5411 5412int ethtool_pse_set(struct ynl_sock *ys, struct ethtool_pse_set_req *req) 5413{ 5414 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5415 struct nlmsghdr *nlh; 5416 int err; 5417 5418 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PSE_SET, 1); 5419 ys->req_policy = &ethtool_pse_nest; 5420 5421 if (req->_present.header) 5422 ethtool_header_put(nlh, ETHTOOL_A_PSE_HEADER, &req->header); 5423 if (req->_present.admin_state) 5424 mnl_attr_put_u32(nlh, ETHTOOL_A_PODL_PSE_ADMIN_STATE, req->admin_state); 5425 if (req->_present.admin_control) 5426 mnl_attr_put_u32(nlh, ETHTOOL_A_PODL_PSE_ADMIN_CONTROL, req->admin_control); 5427 if (req->_present.pw_d_status) 5428 mnl_attr_put_u32(nlh, ETHTOOL_A_PODL_PSE_PW_D_STATUS, req->pw_d_status); 5429 5430 err = ynl_exec(ys, nlh, &yrs); 5431 if (err < 0) 5432 return -1; 5433 5434 return 0; 5435} 5436 5437/* ============== ETHTOOL_MSG_RSS_GET ============== */ 5438/* ETHTOOL_MSG_RSS_GET - do */ 5439void ethtool_rss_get_req_free(struct ethtool_rss_get_req *req) 5440{ 5441 ethtool_header_free(&req->header); 5442 free(req); 5443} 5444 5445void ethtool_rss_get_rsp_free(struct ethtool_rss_get_rsp *rsp) 5446{ 5447 ethtool_header_free(&rsp->header); 5448 free(rsp->indir); 5449 free(rsp->hkey); 5450 free(rsp); 5451} 5452 5453int ethtool_rss_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 5454{ 5455 struct ynl_parse_arg *yarg = data; 5456 struct ethtool_rss_get_rsp *dst; 5457 const struct nlattr *attr; 5458 struct ynl_parse_arg parg; 5459 5460 dst = yarg->data; 5461 parg.ys = yarg->ys; 5462 5463 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 5464 unsigned int type = mnl_attr_get_type(attr); 5465 5466 if (type == ETHTOOL_A_RSS_HEADER) { 5467 if (ynl_attr_validate(yarg, attr)) 5468 return MNL_CB_ERROR; 5469 dst->_present.header = 1; 5470 5471 parg.rsp_policy = &ethtool_header_nest; 5472 parg.data = &dst->header; 5473 if (ethtool_header_parse(&parg, attr)) 5474 return MNL_CB_ERROR; 5475 } else if (type == ETHTOOL_A_RSS_CONTEXT) { 5476 if (ynl_attr_validate(yarg, attr)) 5477 return MNL_CB_ERROR; 5478 dst->_present.context = 1; 5479 dst->context = mnl_attr_get_u32(attr); 5480 } else if (type == ETHTOOL_A_RSS_HFUNC) { 5481 if (ynl_attr_validate(yarg, attr)) 5482 return MNL_CB_ERROR; 5483 dst->_present.hfunc = 1; 5484 dst->hfunc = mnl_attr_get_u32(attr); 5485 } else if (type == ETHTOOL_A_RSS_INDIR) { 5486 unsigned int len; 5487 5488 if (ynl_attr_validate(yarg, attr)) 5489 return MNL_CB_ERROR; 5490 5491 len = mnl_attr_get_payload_len(attr); 5492 dst->_present.indir_len = len; 5493 dst->indir = malloc(len); 5494 memcpy(dst->indir, mnl_attr_get_payload(attr), len); 5495 } else if (type == ETHTOOL_A_RSS_HKEY) { 5496 unsigned int len; 5497 5498 if (ynl_attr_validate(yarg, attr)) 5499 return MNL_CB_ERROR; 5500 5501 len = mnl_attr_get_payload_len(attr); 5502 dst->_present.hkey_len = len; 5503 dst->hkey = malloc(len); 5504 memcpy(dst->hkey, mnl_attr_get_payload(attr), len); 5505 } 5506 } 5507 5508 return MNL_CB_OK; 5509} 5510 5511struct ethtool_rss_get_rsp * 5512ethtool_rss_get(struct ynl_sock *ys, struct ethtool_rss_get_req *req) 5513{ 5514 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5515 struct ethtool_rss_get_rsp *rsp; 5516 struct nlmsghdr *nlh; 5517 int err; 5518 5519 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_RSS_GET, 1); 5520 ys->req_policy = &ethtool_rss_nest; 5521 yrs.yarg.rsp_policy = &ethtool_rss_nest; 5522 5523 if (req->_present.header) 5524 ethtool_header_put(nlh, ETHTOOL_A_RSS_HEADER, &req->header); 5525 5526 rsp = calloc(1, sizeof(*rsp)); 5527 yrs.yarg.data = rsp; 5528 yrs.cb = ethtool_rss_get_rsp_parse; 5529 yrs.rsp_cmd = ETHTOOL_MSG_RSS_GET; 5530 5531 err = ynl_exec(ys, nlh, &yrs); 5532 if (err < 0) 5533 goto err_free; 5534 5535 return rsp; 5536 5537err_free: 5538 ethtool_rss_get_rsp_free(rsp); 5539 return NULL; 5540} 5541 5542/* ETHTOOL_MSG_RSS_GET - dump */ 5543void ethtool_rss_get_list_free(struct ethtool_rss_get_list *rsp) 5544{ 5545 struct ethtool_rss_get_list *next = rsp; 5546 5547 while ((void *)next != YNL_LIST_END) { 5548 rsp = next; 5549 next = rsp->next; 5550 5551 ethtool_header_free(&rsp->obj.header); 5552 free(rsp->obj.indir); 5553 free(rsp->obj.hkey); 5554 free(rsp); 5555 } 5556} 5557 5558struct ethtool_rss_get_list * 5559ethtool_rss_get_dump(struct ynl_sock *ys, struct ethtool_rss_get_req_dump *req) 5560{ 5561 struct ynl_dump_state yds = {}; 5562 struct nlmsghdr *nlh; 5563 int err; 5564 5565 yds.ys = ys; 5566 yds.alloc_sz = sizeof(struct ethtool_rss_get_list); 5567 yds.cb = ethtool_rss_get_rsp_parse; 5568 yds.rsp_cmd = ETHTOOL_MSG_RSS_GET; 5569 yds.rsp_policy = &ethtool_rss_nest; 5570 5571 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_RSS_GET, 1); 5572 ys->req_policy = &ethtool_rss_nest; 5573 5574 if (req->_present.header) 5575 ethtool_header_put(nlh, ETHTOOL_A_RSS_HEADER, &req->header); 5576 5577 err = ynl_exec_dump(ys, nlh, &yds); 5578 if (err < 0) 5579 goto free_list; 5580 5581 return yds.first; 5582 5583free_list: 5584 ethtool_rss_get_list_free(yds.first); 5585 return NULL; 5586} 5587 5588/* ============== ETHTOOL_MSG_PLCA_GET_CFG ============== */ 5589/* ETHTOOL_MSG_PLCA_GET_CFG - do */ 5590void ethtool_plca_get_cfg_req_free(struct ethtool_plca_get_cfg_req *req) 5591{ 5592 ethtool_header_free(&req->header); 5593 free(req); 5594} 5595 5596void ethtool_plca_get_cfg_rsp_free(struct ethtool_plca_get_cfg_rsp *rsp) 5597{ 5598 ethtool_header_free(&rsp->header); 5599 free(rsp); 5600} 5601 5602int ethtool_plca_get_cfg_rsp_parse(const struct nlmsghdr *nlh, void *data) 5603{ 5604 struct ethtool_plca_get_cfg_rsp *dst; 5605 struct ynl_parse_arg *yarg = data; 5606 const struct nlattr *attr; 5607 struct ynl_parse_arg parg; 5608 5609 dst = yarg->data; 5610 parg.ys = yarg->ys; 5611 5612 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 5613 unsigned int type = mnl_attr_get_type(attr); 5614 5615 if (type == ETHTOOL_A_PLCA_HEADER) { 5616 if (ynl_attr_validate(yarg, attr)) 5617 return MNL_CB_ERROR; 5618 dst->_present.header = 1; 5619 5620 parg.rsp_policy = &ethtool_header_nest; 5621 parg.data = &dst->header; 5622 if (ethtool_header_parse(&parg, attr)) 5623 return MNL_CB_ERROR; 5624 } else if (type == ETHTOOL_A_PLCA_VERSION) { 5625 if (ynl_attr_validate(yarg, attr)) 5626 return MNL_CB_ERROR; 5627 dst->_present.version = 1; 5628 dst->version = mnl_attr_get_u16(attr); 5629 } else if (type == ETHTOOL_A_PLCA_ENABLED) { 5630 if (ynl_attr_validate(yarg, attr)) 5631 return MNL_CB_ERROR; 5632 dst->_present.enabled = 1; 5633 dst->enabled = mnl_attr_get_u8(attr); 5634 } else if (type == ETHTOOL_A_PLCA_STATUS) { 5635 if (ynl_attr_validate(yarg, attr)) 5636 return MNL_CB_ERROR; 5637 dst->_present.status = 1; 5638 dst->status = mnl_attr_get_u8(attr); 5639 } else if (type == ETHTOOL_A_PLCA_NODE_CNT) { 5640 if (ynl_attr_validate(yarg, attr)) 5641 return MNL_CB_ERROR; 5642 dst->_present.node_cnt = 1; 5643 dst->node_cnt = mnl_attr_get_u32(attr); 5644 } else if (type == ETHTOOL_A_PLCA_NODE_ID) { 5645 if (ynl_attr_validate(yarg, attr)) 5646 return MNL_CB_ERROR; 5647 dst->_present.node_id = 1; 5648 dst->node_id = mnl_attr_get_u32(attr); 5649 } else if (type == ETHTOOL_A_PLCA_TO_TMR) { 5650 if (ynl_attr_validate(yarg, attr)) 5651 return MNL_CB_ERROR; 5652 dst->_present.to_tmr = 1; 5653 dst->to_tmr = mnl_attr_get_u32(attr); 5654 } else if (type == ETHTOOL_A_PLCA_BURST_CNT) { 5655 if (ynl_attr_validate(yarg, attr)) 5656 return MNL_CB_ERROR; 5657 dst->_present.burst_cnt = 1; 5658 dst->burst_cnt = mnl_attr_get_u32(attr); 5659 } else if (type == ETHTOOL_A_PLCA_BURST_TMR) { 5660 if (ynl_attr_validate(yarg, attr)) 5661 return MNL_CB_ERROR; 5662 dst->_present.burst_tmr = 1; 5663 dst->burst_tmr = mnl_attr_get_u32(attr); 5664 } 5665 } 5666 5667 return MNL_CB_OK; 5668} 5669 5670struct ethtool_plca_get_cfg_rsp * 5671ethtool_plca_get_cfg(struct ynl_sock *ys, struct ethtool_plca_get_cfg_req *req) 5672{ 5673 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5674 struct ethtool_plca_get_cfg_rsp *rsp; 5675 struct nlmsghdr *nlh; 5676 int err; 5677 5678 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PLCA_GET_CFG, 1); 5679 ys->req_policy = &ethtool_plca_nest; 5680 yrs.yarg.rsp_policy = &ethtool_plca_nest; 5681 5682 if (req->_present.header) 5683 ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header); 5684 5685 rsp = calloc(1, sizeof(*rsp)); 5686 yrs.yarg.data = rsp; 5687 yrs.cb = ethtool_plca_get_cfg_rsp_parse; 5688 yrs.rsp_cmd = ETHTOOL_MSG_PLCA_GET_CFG; 5689 5690 err = ynl_exec(ys, nlh, &yrs); 5691 if (err < 0) 5692 goto err_free; 5693 5694 return rsp; 5695 5696err_free: 5697 ethtool_plca_get_cfg_rsp_free(rsp); 5698 return NULL; 5699} 5700 5701/* ETHTOOL_MSG_PLCA_GET_CFG - dump */ 5702void ethtool_plca_get_cfg_list_free(struct ethtool_plca_get_cfg_list *rsp) 5703{ 5704 struct ethtool_plca_get_cfg_list *next = rsp; 5705 5706 while ((void *)next != YNL_LIST_END) { 5707 rsp = next; 5708 next = rsp->next; 5709 5710 ethtool_header_free(&rsp->obj.header); 5711 free(rsp); 5712 } 5713} 5714 5715struct ethtool_plca_get_cfg_list * 5716ethtool_plca_get_cfg_dump(struct ynl_sock *ys, 5717 struct ethtool_plca_get_cfg_req_dump *req) 5718{ 5719 struct ynl_dump_state yds = {}; 5720 struct nlmsghdr *nlh; 5721 int err; 5722 5723 yds.ys = ys; 5724 yds.alloc_sz = sizeof(struct ethtool_plca_get_cfg_list); 5725 yds.cb = ethtool_plca_get_cfg_rsp_parse; 5726 yds.rsp_cmd = ETHTOOL_MSG_PLCA_GET_CFG; 5727 yds.rsp_policy = &ethtool_plca_nest; 5728 5729 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PLCA_GET_CFG, 1); 5730 ys->req_policy = &ethtool_plca_nest; 5731 5732 if (req->_present.header) 5733 ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header); 5734 5735 err = ynl_exec_dump(ys, nlh, &yds); 5736 if (err < 0) 5737 goto free_list; 5738 5739 return yds.first; 5740 5741free_list: 5742 ethtool_plca_get_cfg_list_free(yds.first); 5743 return NULL; 5744} 5745 5746/* ETHTOOL_MSG_PLCA_GET_CFG - notify */ 5747void ethtool_plca_get_cfg_ntf_free(struct ethtool_plca_get_cfg_ntf *rsp) 5748{ 5749 ethtool_header_free(&rsp->obj.header); 5750 free(rsp); 5751} 5752 5753/* ============== ETHTOOL_MSG_PLCA_SET_CFG ============== */ 5754/* ETHTOOL_MSG_PLCA_SET_CFG - do */ 5755void ethtool_plca_set_cfg_req_free(struct ethtool_plca_set_cfg_req *req) 5756{ 5757 ethtool_header_free(&req->header); 5758 free(req); 5759} 5760 5761int ethtool_plca_set_cfg(struct ynl_sock *ys, 5762 struct ethtool_plca_set_cfg_req *req) 5763{ 5764 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5765 struct nlmsghdr *nlh; 5766 int err; 5767 5768 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PLCA_SET_CFG, 1); 5769 ys->req_policy = &ethtool_plca_nest; 5770 5771 if (req->_present.header) 5772 ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header); 5773 if (req->_present.version) 5774 mnl_attr_put_u16(nlh, ETHTOOL_A_PLCA_VERSION, req->version); 5775 if (req->_present.enabled) 5776 mnl_attr_put_u8(nlh, ETHTOOL_A_PLCA_ENABLED, req->enabled); 5777 if (req->_present.status) 5778 mnl_attr_put_u8(nlh, ETHTOOL_A_PLCA_STATUS, req->status); 5779 if (req->_present.node_cnt) 5780 mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_NODE_CNT, req->node_cnt); 5781 if (req->_present.node_id) 5782 mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_NODE_ID, req->node_id); 5783 if (req->_present.to_tmr) 5784 mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_TO_TMR, req->to_tmr); 5785 if (req->_present.burst_cnt) 5786 mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_BURST_CNT, req->burst_cnt); 5787 if (req->_present.burst_tmr) 5788 mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_BURST_TMR, req->burst_tmr); 5789 5790 err = ynl_exec(ys, nlh, &yrs); 5791 if (err < 0) 5792 return -1; 5793 5794 return 0; 5795} 5796 5797/* ============== ETHTOOL_MSG_PLCA_GET_STATUS ============== */ 5798/* ETHTOOL_MSG_PLCA_GET_STATUS - do */ 5799void ethtool_plca_get_status_req_free(struct ethtool_plca_get_status_req *req) 5800{ 5801 ethtool_header_free(&req->header); 5802 free(req); 5803} 5804 5805void ethtool_plca_get_status_rsp_free(struct ethtool_plca_get_status_rsp *rsp) 5806{ 5807 ethtool_header_free(&rsp->header); 5808 free(rsp); 5809} 5810 5811int ethtool_plca_get_status_rsp_parse(const struct nlmsghdr *nlh, void *data) 5812{ 5813 struct ethtool_plca_get_status_rsp *dst; 5814 struct ynl_parse_arg *yarg = data; 5815 const struct nlattr *attr; 5816 struct ynl_parse_arg parg; 5817 5818 dst = yarg->data; 5819 parg.ys = yarg->ys; 5820 5821 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 5822 unsigned int type = mnl_attr_get_type(attr); 5823 5824 if (type == ETHTOOL_A_PLCA_HEADER) { 5825 if (ynl_attr_validate(yarg, attr)) 5826 return MNL_CB_ERROR; 5827 dst->_present.header = 1; 5828 5829 parg.rsp_policy = &ethtool_header_nest; 5830 parg.data = &dst->header; 5831 if (ethtool_header_parse(&parg, attr)) 5832 return MNL_CB_ERROR; 5833 } else if (type == ETHTOOL_A_PLCA_VERSION) { 5834 if (ynl_attr_validate(yarg, attr)) 5835 return MNL_CB_ERROR; 5836 dst->_present.version = 1; 5837 dst->version = mnl_attr_get_u16(attr); 5838 } else if (type == ETHTOOL_A_PLCA_ENABLED) { 5839 if (ynl_attr_validate(yarg, attr)) 5840 return MNL_CB_ERROR; 5841 dst->_present.enabled = 1; 5842 dst->enabled = mnl_attr_get_u8(attr); 5843 } else if (type == ETHTOOL_A_PLCA_STATUS) { 5844 if (ynl_attr_validate(yarg, attr)) 5845 return MNL_CB_ERROR; 5846 dst->_present.status = 1; 5847 dst->status = mnl_attr_get_u8(attr); 5848 } else if (type == ETHTOOL_A_PLCA_NODE_CNT) { 5849 if (ynl_attr_validate(yarg, attr)) 5850 return MNL_CB_ERROR; 5851 dst->_present.node_cnt = 1; 5852 dst->node_cnt = mnl_attr_get_u32(attr); 5853 } else if (type == ETHTOOL_A_PLCA_NODE_ID) { 5854 if (ynl_attr_validate(yarg, attr)) 5855 return MNL_CB_ERROR; 5856 dst->_present.node_id = 1; 5857 dst->node_id = mnl_attr_get_u32(attr); 5858 } else if (type == ETHTOOL_A_PLCA_TO_TMR) { 5859 if (ynl_attr_validate(yarg, attr)) 5860 return MNL_CB_ERROR; 5861 dst->_present.to_tmr = 1; 5862 dst->to_tmr = mnl_attr_get_u32(attr); 5863 } else if (type == ETHTOOL_A_PLCA_BURST_CNT) { 5864 if (ynl_attr_validate(yarg, attr)) 5865 return MNL_CB_ERROR; 5866 dst->_present.burst_cnt = 1; 5867 dst->burst_cnt = mnl_attr_get_u32(attr); 5868 } else if (type == ETHTOOL_A_PLCA_BURST_TMR) { 5869 if (ynl_attr_validate(yarg, attr)) 5870 return MNL_CB_ERROR; 5871 dst->_present.burst_tmr = 1; 5872 dst->burst_tmr = mnl_attr_get_u32(attr); 5873 } 5874 } 5875 5876 return MNL_CB_OK; 5877} 5878 5879struct ethtool_plca_get_status_rsp * 5880ethtool_plca_get_status(struct ynl_sock *ys, 5881 struct ethtool_plca_get_status_req *req) 5882{ 5883 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5884 struct ethtool_plca_get_status_rsp *rsp; 5885 struct nlmsghdr *nlh; 5886 int err; 5887 5888 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_PLCA_GET_STATUS, 1); 5889 ys->req_policy = &ethtool_plca_nest; 5890 yrs.yarg.rsp_policy = &ethtool_plca_nest; 5891 5892 if (req->_present.header) 5893 ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header); 5894 5895 rsp = calloc(1, sizeof(*rsp)); 5896 yrs.yarg.data = rsp; 5897 yrs.cb = ethtool_plca_get_status_rsp_parse; 5898 yrs.rsp_cmd = 40; 5899 5900 err = ynl_exec(ys, nlh, &yrs); 5901 if (err < 0) 5902 goto err_free; 5903 5904 return rsp; 5905 5906err_free: 5907 ethtool_plca_get_status_rsp_free(rsp); 5908 return NULL; 5909} 5910 5911/* ETHTOOL_MSG_PLCA_GET_STATUS - dump */ 5912void 5913ethtool_plca_get_status_list_free(struct ethtool_plca_get_status_list *rsp) 5914{ 5915 struct ethtool_plca_get_status_list *next = rsp; 5916 5917 while ((void *)next != YNL_LIST_END) { 5918 rsp = next; 5919 next = rsp->next; 5920 5921 ethtool_header_free(&rsp->obj.header); 5922 free(rsp); 5923 } 5924} 5925 5926struct ethtool_plca_get_status_list * 5927ethtool_plca_get_status_dump(struct ynl_sock *ys, 5928 struct ethtool_plca_get_status_req_dump *req) 5929{ 5930 struct ynl_dump_state yds = {}; 5931 struct nlmsghdr *nlh; 5932 int err; 5933 5934 yds.ys = ys; 5935 yds.alloc_sz = sizeof(struct ethtool_plca_get_status_list); 5936 yds.cb = ethtool_plca_get_status_rsp_parse; 5937 yds.rsp_cmd = 40; 5938 yds.rsp_policy = &ethtool_plca_nest; 5939 5940 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_PLCA_GET_STATUS, 1); 5941 ys->req_policy = &ethtool_plca_nest; 5942 5943 if (req->_present.header) 5944 ethtool_header_put(nlh, ETHTOOL_A_PLCA_HEADER, &req->header); 5945 5946 err = ynl_exec_dump(ys, nlh, &yds); 5947 if (err < 0) 5948 goto free_list; 5949 5950 return yds.first; 5951 5952free_list: 5953 ethtool_plca_get_status_list_free(yds.first); 5954 return NULL; 5955} 5956 5957/* ============== ETHTOOL_MSG_MM_GET ============== */ 5958/* ETHTOOL_MSG_MM_GET - do */ 5959void ethtool_mm_get_req_free(struct ethtool_mm_get_req *req) 5960{ 5961 ethtool_header_free(&req->header); 5962 free(req); 5963} 5964 5965void ethtool_mm_get_rsp_free(struct ethtool_mm_get_rsp *rsp) 5966{ 5967 ethtool_header_free(&rsp->header); 5968 ethtool_mm_stat_free(&rsp->stats); 5969 free(rsp); 5970} 5971 5972int ethtool_mm_get_rsp_parse(const struct nlmsghdr *nlh, void *data) 5973{ 5974 struct ynl_parse_arg *yarg = data; 5975 struct ethtool_mm_get_rsp *dst; 5976 const struct nlattr *attr; 5977 struct ynl_parse_arg parg; 5978 5979 dst = yarg->data; 5980 parg.ys = yarg->ys; 5981 5982 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 5983 unsigned int type = mnl_attr_get_type(attr); 5984 5985 if (type == ETHTOOL_A_MM_HEADER) { 5986 if (ynl_attr_validate(yarg, attr)) 5987 return MNL_CB_ERROR; 5988 dst->_present.header = 1; 5989 5990 parg.rsp_policy = &ethtool_header_nest; 5991 parg.data = &dst->header; 5992 if (ethtool_header_parse(&parg, attr)) 5993 return MNL_CB_ERROR; 5994 } else if (type == ETHTOOL_A_MM_PMAC_ENABLED) { 5995 if (ynl_attr_validate(yarg, attr)) 5996 return MNL_CB_ERROR; 5997 dst->_present.pmac_enabled = 1; 5998 dst->pmac_enabled = mnl_attr_get_u8(attr); 5999 } else if (type == ETHTOOL_A_MM_TX_ENABLED) { 6000 if (ynl_attr_validate(yarg, attr)) 6001 return MNL_CB_ERROR; 6002 dst->_present.tx_enabled = 1; 6003 dst->tx_enabled = mnl_attr_get_u8(attr); 6004 } else if (type == ETHTOOL_A_MM_TX_ACTIVE) { 6005 if (ynl_attr_validate(yarg, attr)) 6006 return MNL_CB_ERROR; 6007 dst->_present.tx_active = 1; 6008 dst->tx_active = mnl_attr_get_u8(attr); 6009 } else if (type == ETHTOOL_A_MM_TX_MIN_FRAG_SIZE) { 6010 if (ynl_attr_validate(yarg, attr)) 6011 return MNL_CB_ERROR; 6012 dst->_present.tx_min_frag_size = 1; 6013 dst->tx_min_frag_size = mnl_attr_get_u32(attr); 6014 } else if (type == ETHTOOL_A_MM_RX_MIN_FRAG_SIZE) { 6015 if (ynl_attr_validate(yarg, attr)) 6016 return MNL_CB_ERROR; 6017 dst->_present.rx_min_frag_size = 1; 6018 dst->rx_min_frag_size = mnl_attr_get_u32(attr); 6019 } else if (type == ETHTOOL_A_MM_VERIFY_ENABLED) { 6020 if (ynl_attr_validate(yarg, attr)) 6021 return MNL_CB_ERROR; 6022 dst->_present.verify_enabled = 1; 6023 dst->verify_enabled = mnl_attr_get_u8(attr); 6024 } else if (type == ETHTOOL_A_MM_VERIFY_TIME) { 6025 if (ynl_attr_validate(yarg, attr)) 6026 return MNL_CB_ERROR; 6027 dst->_present.verify_time = 1; 6028 dst->verify_time = mnl_attr_get_u32(attr); 6029 } else if (type == ETHTOOL_A_MM_MAX_VERIFY_TIME) { 6030 if (ynl_attr_validate(yarg, attr)) 6031 return MNL_CB_ERROR; 6032 dst->_present.max_verify_time = 1; 6033 dst->max_verify_time = mnl_attr_get_u32(attr); 6034 } else if (type == ETHTOOL_A_MM_STATS) { 6035 if (ynl_attr_validate(yarg, attr)) 6036 return MNL_CB_ERROR; 6037 dst->_present.stats = 1; 6038 6039 parg.rsp_policy = &ethtool_mm_stat_nest; 6040 parg.data = &dst->stats; 6041 if (ethtool_mm_stat_parse(&parg, attr)) 6042 return MNL_CB_ERROR; 6043 } 6044 } 6045 6046 return MNL_CB_OK; 6047} 6048 6049struct ethtool_mm_get_rsp * 6050ethtool_mm_get(struct ynl_sock *ys, struct ethtool_mm_get_req *req) 6051{ 6052 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 6053 struct ethtool_mm_get_rsp *rsp; 6054 struct nlmsghdr *nlh; 6055 int err; 6056 6057 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MM_GET, 1); 6058 ys->req_policy = &ethtool_mm_nest; 6059 yrs.yarg.rsp_policy = &ethtool_mm_nest; 6060 6061 if (req->_present.header) 6062 ethtool_header_put(nlh, ETHTOOL_A_MM_HEADER, &req->header); 6063 6064 rsp = calloc(1, sizeof(*rsp)); 6065 yrs.yarg.data = rsp; 6066 yrs.cb = ethtool_mm_get_rsp_parse; 6067 yrs.rsp_cmd = ETHTOOL_MSG_MM_GET; 6068 6069 err = ynl_exec(ys, nlh, &yrs); 6070 if (err < 0) 6071 goto err_free; 6072 6073 return rsp; 6074 6075err_free: 6076 ethtool_mm_get_rsp_free(rsp); 6077 return NULL; 6078} 6079 6080/* ETHTOOL_MSG_MM_GET - dump */ 6081void ethtool_mm_get_list_free(struct ethtool_mm_get_list *rsp) 6082{ 6083 struct ethtool_mm_get_list *next = rsp; 6084 6085 while ((void *)next != YNL_LIST_END) { 6086 rsp = next; 6087 next = rsp->next; 6088 6089 ethtool_header_free(&rsp->obj.header); 6090 ethtool_mm_stat_free(&rsp->obj.stats); 6091 free(rsp); 6092 } 6093} 6094 6095struct ethtool_mm_get_list * 6096ethtool_mm_get_dump(struct ynl_sock *ys, struct ethtool_mm_get_req_dump *req) 6097{ 6098 struct ynl_dump_state yds = {}; 6099 struct nlmsghdr *nlh; 6100 int err; 6101 6102 yds.ys = ys; 6103 yds.alloc_sz = sizeof(struct ethtool_mm_get_list); 6104 yds.cb = ethtool_mm_get_rsp_parse; 6105 yds.rsp_cmd = ETHTOOL_MSG_MM_GET; 6106 yds.rsp_policy = &ethtool_mm_nest; 6107 6108 nlh = ynl_gemsg_start_dump(ys, ys->family_id, ETHTOOL_MSG_MM_GET, 1); 6109 ys->req_policy = &ethtool_mm_nest; 6110 6111 if (req->_present.header) 6112 ethtool_header_put(nlh, ETHTOOL_A_MM_HEADER, &req->header); 6113 6114 err = ynl_exec_dump(ys, nlh, &yds); 6115 if (err < 0) 6116 goto free_list; 6117 6118 return yds.first; 6119 6120free_list: 6121 ethtool_mm_get_list_free(yds.first); 6122 return NULL; 6123} 6124 6125/* ETHTOOL_MSG_MM_GET - notify */ 6126void ethtool_mm_get_ntf_free(struct ethtool_mm_get_ntf *rsp) 6127{ 6128 ethtool_header_free(&rsp->obj.header); 6129 ethtool_mm_stat_free(&rsp->obj.stats); 6130 free(rsp); 6131} 6132 6133/* ============== ETHTOOL_MSG_MM_SET ============== */ 6134/* ETHTOOL_MSG_MM_SET - do */ 6135void ethtool_mm_set_req_free(struct ethtool_mm_set_req *req) 6136{ 6137 ethtool_header_free(&req->header); 6138 free(req); 6139} 6140 6141int ethtool_mm_set(struct ynl_sock *ys, struct ethtool_mm_set_req *req) 6142{ 6143 struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 6144 struct nlmsghdr *nlh; 6145 int err; 6146 6147 nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_MM_SET, 1); 6148 ys->req_policy = &ethtool_mm_nest; 6149 6150 if (req->_present.header) 6151 ethtool_header_put(nlh, ETHTOOL_A_MM_HEADER, &req->header); 6152 if (req->_present.verify_enabled) 6153 mnl_attr_put_u8(nlh, ETHTOOL_A_MM_VERIFY_ENABLED, req->verify_enabled); 6154 if (req->_present.verify_time) 6155 mnl_attr_put_u32(nlh, ETHTOOL_A_MM_VERIFY_TIME, req->verify_time); 6156 if (req->_present.tx_enabled) 6157 mnl_attr_put_u8(nlh, ETHTOOL_A_MM_TX_ENABLED, req->tx_enabled); 6158 if (req->_present.pmac_enabled) 6159 mnl_attr_put_u8(nlh, ETHTOOL_A_MM_PMAC_ENABLED, req->pmac_enabled); 6160 if (req->_present.tx_min_frag_size) 6161 mnl_attr_put_u32(nlh, ETHTOOL_A_MM_TX_MIN_FRAG_SIZE, req->tx_min_frag_size); 6162 6163 err = ynl_exec(ys, nlh, &yrs); 6164 if (err < 0) 6165 return -1; 6166 6167 return 0; 6168} 6169 6170/* ETHTOOL_MSG_CABLE_TEST_NTF - event */ 6171int ethtool_cable_test_ntf_rsp_parse(const struct nlmsghdr *nlh, void *data) 6172{ 6173 struct ethtool_cable_test_ntf_rsp *dst; 6174 struct ynl_parse_arg *yarg = data; 6175 const struct nlattr *attr; 6176 struct ynl_parse_arg parg; 6177 6178 dst = yarg->data; 6179 parg.ys = yarg->ys; 6180 6181 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 6182 unsigned int type = mnl_attr_get_type(attr); 6183 6184 if (type == ETHTOOL_A_CABLE_TEST_NTF_HEADER) { 6185 if (ynl_attr_validate(yarg, attr)) 6186 return MNL_CB_ERROR; 6187 dst->_present.header = 1; 6188 6189 parg.rsp_policy = &ethtool_header_nest; 6190 parg.data = &dst->header; 6191 if (ethtool_header_parse(&parg, attr)) 6192 return MNL_CB_ERROR; 6193 } else if (type == ETHTOOL_A_CABLE_TEST_NTF_STATUS) { 6194 if (ynl_attr_validate(yarg, attr)) 6195 return MNL_CB_ERROR; 6196 dst->_present.status = 1; 6197 dst->status = mnl_attr_get_u8(attr); 6198 } 6199 } 6200 6201 return MNL_CB_OK; 6202} 6203 6204void ethtool_cable_test_ntf_free(struct ethtool_cable_test_ntf *rsp) 6205{ 6206 ethtool_header_free(&rsp->obj.header); 6207 free(rsp); 6208} 6209 6210/* ETHTOOL_MSG_CABLE_TEST_TDR_NTF - event */ 6211int ethtool_cable_test_tdr_ntf_rsp_parse(const struct nlmsghdr *nlh, 6212 void *data) 6213{ 6214 struct ethtool_cable_test_tdr_ntf_rsp *dst; 6215 struct ynl_parse_arg *yarg = data; 6216 const struct nlattr *attr; 6217 struct ynl_parse_arg parg; 6218 6219 dst = yarg->data; 6220 parg.ys = yarg->ys; 6221 6222 mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) { 6223 unsigned int type = mnl_attr_get_type(attr); 6224 6225 if (type == ETHTOOL_A_CABLE_TEST_TDR_NTF_HEADER) { 6226 if (ynl_attr_validate(yarg, attr)) 6227 return MNL_CB_ERROR; 6228 dst->_present.header = 1; 6229 6230 parg.rsp_policy = &ethtool_header_nest; 6231 parg.data = &dst->header; 6232 if (ethtool_header_parse(&parg, attr)) 6233 return MNL_CB_ERROR; 6234 } else if (type == ETHTOOL_A_CABLE_TEST_TDR_NTF_STATUS) { 6235 if (ynl_attr_validate(yarg, attr)) 6236 return MNL_CB_ERROR; 6237 dst->_present.status = 1; 6238 dst->status = mnl_attr_get_u8(attr); 6239 } else if (type == ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST) { 6240 if (ynl_attr_validate(yarg, attr)) 6241 return MNL_CB_ERROR; 6242 dst->_present.nest = 1; 6243 6244 parg.rsp_policy = &ethtool_cable_nest_nest; 6245 parg.data = &dst->nest; 6246 if (ethtool_cable_nest_parse(&parg, attr)) 6247 return MNL_CB_ERROR; 6248 } 6249 } 6250 6251 return MNL_CB_OK; 6252} 6253 6254void ethtool_cable_test_tdr_ntf_free(struct ethtool_cable_test_tdr_ntf *rsp) 6255{ 6256 ethtool_header_free(&rsp->obj.header); 6257 ethtool_cable_nest_free(&rsp->obj.nest); 6258 free(rsp); 6259} 6260 6261static const struct ynl_ntf_info ethtool_ntf_info[] = { 6262 [ETHTOOL_MSG_LINKINFO_NTF] = { 6263 .alloc_sz = sizeof(struct ethtool_linkinfo_get_ntf), 6264 .cb = ethtool_linkinfo_get_rsp_parse, 6265 .policy = &ethtool_linkinfo_nest, 6266 .free = (void *)ethtool_linkinfo_get_ntf_free, 6267 }, 6268 [ETHTOOL_MSG_LINKMODES_NTF] = { 6269 .alloc_sz = sizeof(struct ethtool_linkmodes_get_ntf), 6270 .cb = ethtool_linkmodes_get_rsp_parse, 6271 .policy = &ethtool_linkmodes_nest, 6272 .free = (void *)ethtool_linkmodes_get_ntf_free, 6273 }, 6274 [ETHTOOL_MSG_DEBUG_NTF] = { 6275 .alloc_sz = sizeof(struct ethtool_debug_get_ntf), 6276 .cb = ethtool_debug_get_rsp_parse, 6277 .policy = &ethtool_debug_nest, 6278 .free = (void *)ethtool_debug_get_ntf_free, 6279 }, 6280 [ETHTOOL_MSG_WOL_NTF] = { 6281 .alloc_sz = sizeof(struct ethtool_wol_get_ntf), 6282 .cb = ethtool_wol_get_rsp_parse, 6283 .policy = &ethtool_wol_nest, 6284 .free = (void *)ethtool_wol_get_ntf_free, 6285 }, 6286 [ETHTOOL_MSG_FEATURES_NTF] = { 6287 .alloc_sz = sizeof(struct ethtool_features_get_ntf), 6288 .cb = ethtool_features_get_rsp_parse, 6289 .policy = &ethtool_features_nest, 6290 .free = (void *)ethtool_features_get_ntf_free, 6291 }, 6292 [ETHTOOL_MSG_PRIVFLAGS_NTF] = { 6293 .alloc_sz = sizeof(struct ethtool_privflags_get_ntf), 6294 .cb = ethtool_privflags_get_rsp_parse, 6295 .policy = &ethtool_privflags_nest, 6296 .free = (void *)ethtool_privflags_get_ntf_free, 6297 }, 6298 [ETHTOOL_MSG_RINGS_NTF] = { 6299 .alloc_sz = sizeof(struct ethtool_rings_get_ntf), 6300 .cb = ethtool_rings_get_rsp_parse, 6301 .policy = &ethtool_rings_nest, 6302 .free = (void *)ethtool_rings_get_ntf_free, 6303 }, 6304 [ETHTOOL_MSG_CHANNELS_NTF] = { 6305 .alloc_sz = sizeof(struct ethtool_channels_get_ntf), 6306 .cb = ethtool_channels_get_rsp_parse, 6307 .policy = &ethtool_channels_nest, 6308 .free = (void *)ethtool_channels_get_ntf_free, 6309 }, 6310 [ETHTOOL_MSG_COALESCE_NTF] = { 6311 .alloc_sz = sizeof(struct ethtool_coalesce_get_ntf), 6312 .cb = ethtool_coalesce_get_rsp_parse, 6313 .policy = &ethtool_coalesce_nest, 6314 .free = (void *)ethtool_coalesce_get_ntf_free, 6315 }, 6316 [ETHTOOL_MSG_PAUSE_NTF] = { 6317 .alloc_sz = sizeof(struct ethtool_pause_get_ntf), 6318 .cb = ethtool_pause_get_rsp_parse, 6319 .policy = &ethtool_pause_nest, 6320 .free = (void *)ethtool_pause_get_ntf_free, 6321 }, 6322 [ETHTOOL_MSG_EEE_NTF] = { 6323 .alloc_sz = sizeof(struct ethtool_eee_get_ntf), 6324 .cb = ethtool_eee_get_rsp_parse, 6325 .policy = &ethtool_eee_nest, 6326 .free = (void *)ethtool_eee_get_ntf_free, 6327 }, 6328 [ETHTOOL_MSG_CABLE_TEST_NTF] = { 6329 .alloc_sz = sizeof(struct ethtool_cable_test_ntf), 6330 .cb = ethtool_cable_test_ntf_rsp_parse, 6331 .policy = &ethtool_cable_test_ntf_nest, 6332 .free = (void *)ethtool_cable_test_ntf_free, 6333 }, 6334 [ETHTOOL_MSG_CABLE_TEST_TDR_NTF] = { 6335 .alloc_sz = sizeof(struct ethtool_cable_test_tdr_ntf), 6336 .cb = ethtool_cable_test_tdr_ntf_rsp_parse, 6337 .policy = &ethtool_cable_test_tdr_ntf_nest, 6338 .free = (void *)ethtool_cable_test_tdr_ntf_free, 6339 }, 6340 [ETHTOOL_MSG_FEC_NTF] = { 6341 .alloc_sz = sizeof(struct ethtool_fec_get_ntf), 6342 .cb = ethtool_fec_get_rsp_parse, 6343 .policy = &ethtool_fec_nest, 6344 .free = (void *)ethtool_fec_get_ntf_free, 6345 }, 6346 [ETHTOOL_MSG_MODULE_NTF] = { 6347 .alloc_sz = sizeof(struct ethtool_module_get_ntf), 6348 .cb = ethtool_module_get_rsp_parse, 6349 .policy = &ethtool_module_nest, 6350 .free = (void *)ethtool_module_get_ntf_free, 6351 }, 6352 [ETHTOOL_MSG_PLCA_NTF] = { 6353 .alloc_sz = sizeof(struct ethtool_plca_get_cfg_ntf), 6354 .cb = ethtool_plca_get_cfg_rsp_parse, 6355 .policy = &ethtool_plca_nest, 6356 .free = (void *)ethtool_plca_get_cfg_ntf_free, 6357 }, 6358 [ETHTOOL_MSG_MM_NTF] = { 6359 .alloc_sz = sizeof(struct ethtool_mm_get_ntf), 6360 .cb = ethtool_mm_get_rsp_parse, 6361 .policy = &ethtool_mm_nest, 6362 .free = (void *)ethtool_mm_get_ntf_free, 6363 }, 6364}; 6365 6366const struct ynl_family ynl_ethtool_family = { 6367 .name = "ethtool", 6368 .ntf_info = ethtool_ntf_info, 6369 .ntf_info_size = MNL_ARRAY_SIZE(ethtool_ntf_info), 6370};