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

tools: ynl: generate code for the ethtool family

Generate the protocol code for ethtool. Skip the stats
for now, they are the only outlier in terms of complexity.
Stats are a sort-of semi-polymorphic (attr space of a nest
depends on value of another attr) or a type-value-scalar,
depending on how one wants to look at it...
A challenge for another time.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jakub Kicinski and committed by
David S. Miller
2d7be507 68335713

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