Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/ethtool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/phy.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include "netlink.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) struct strset_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 	bool per_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 	bool free_strings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 	unsigned int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 	const char (*strings)[ETH_GSTRING_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) static const struct strset_info info_template[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	[ETH_SS_TEST] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 		.per_dev	= true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	[ETH_SS_STATS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 		.per_dev	= true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	[ETH_SS_PRIV_FLAGS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 		.per_dev	= true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	[ETH_SS_FEATURES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		.count		= ARRAY_SIZE(netdev_features_strings),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		.strings	= netdev_features_strings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	[ETH_SS_RSS_HASH_FUNCS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		.count		= ARRAY_SIZE(rss_hash_func_strings),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		.strings	= rss_hash_func_strings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	[ETH_SS_TUNABLES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		.count		= ARRAY_SIZE(tunable_strings),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		.strings	= tunable_strings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	[ETH_SS_PHY_STATS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		.per_dev	= true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	[ETH_SS_PHY_TUNABLES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		.count		= ARRAY_SIZE(phy_tunable_strings),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		.strings	= phy_tunable_strings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	[ETH_SS_LINK_MODES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		.count		= __ETHTOOL_LINK_MODE_MASK_NBITS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		.strings	= link_mode_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	[ETH_SS_MSG_CLASSES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		.count		= NETIF_MSG_CLASS_COUNT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		.strings	= netif_msg_class_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	[ETH_SS_WOL_MODES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		.count		= WOL_MODE_COUNT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		.strings	= wol_mode_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	[ETH_SS_SOF_TIMESTAMPING] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		.count		= __SOF_TIMESTAMPING_CNT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		.strings	= sof_timestamping_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	[ETH_SS_TS_TX_TYPES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		.count		= __HWTSTAMP_TX_CNT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		.strings	= ts_tx_type_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	[ETH_SS_TS_RX_FILTERS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		.count		= __HWTSTAMP_FILTER_CNT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		.strings	= ts_rx_filter_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	[ETH_SS_UDP_TUNNEL_TYPES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		.per_dev	= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		.count		= __ETHTOOL_UDP_TUNNEL_TYPE_CNT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		.strings	= udp_tunnel_type_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) struct strset_req_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct ethnl_req_info		base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	u32				req_ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	bool				counts_only;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #define STRSET_REQINFO(__req_base) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	container_of(__req_base, struct strset_req_info, base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) struct strset_reply_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	struct ethnl_reply_data		base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct strset_info		sets[ETH_SS_COUNT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define STRSET_REPDATA(__reply_base) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	container_of(__reply_base, struct strset_reply_data, base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) const struct nla_policy ethnl_strset_get_policy[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	[ETHTOOL_A_STRSET_HEADER]	=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		NLA_POLICY_NESTED(ethnl_header_policy),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	[ETHTOOL_A_STRSET_STRINGSETS]	= { .type = NLA_NESTED },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	[ETHTOOL_A_STRSET_COUNTS_ONLY]	= { .type = NLA_FLAG },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static const struct nla_policy get_stringset_policy[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	[ETHTOOL_A_STRINGSET_ID]	= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * strset_include() - test if a string set should be included in reply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * @info: parsed client request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * @data: pointer to request data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * @id:   id of string set to check (ETH_SS_* constants)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static bool strset_include(const struct strset_req_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			   const struct strset_reply_data *data, u32 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	bool per_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	BUILD_BUG_ON(ETH_SS_COUNT >= BITS_PER_BYTE * sizeof(info->req_ids));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (info->req_ids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return info->req_ids & (1U << id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	per_dev = data->sets[id].per_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	if (!per_dev && !data->sets[id].strings)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	return data->base.dev ? per_dev : !per_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static int strset_get_id(const struct nlattr *nest, u32 *val,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			 struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	struct nlattr *tb[ARRAY_SIZE(get_stringset_policy)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	ret = nla_parse_nested(tb, ARRAY_SIZE(get_stringset_policy) - 1, nest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			       get_stringset_policy, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	if (!tb[ETHTOOL_A_STRINGSET_ID])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	*val = nla_get_u32(tb[ETHTOOL_A_STRINGSET_ID]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static const struct nla_policy strset_stringsets_policy[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	[ETHTOOL_A_STRINGSETS_STRINGSET]	= { .type = NLA_NESTED },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) static int strset_parse_request(struct ethnl_req_info *req_base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 				struct nlattr **tb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 				struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	struct strset_req_info *req_info = STRSET_REQINFO(req_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	struct nlattr *nest = tb[ETHTOOL_A_STRSET_STRINGSETS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	struct nlattr *attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	int rem, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	if (!nest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	ret = nla_validate_nested(nest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 				  ARRAY_SIZE(strset_stringsets_policy) - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 				  strset_stringsets_policy, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	req_info->counts_only = tb[ETHTOOL_A_STRSET_COUNTS_ONLY];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	nla_for_each_nested(attr, nest, rem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		u32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		if (WARN_ONCE(nla_type(attr) != ETHTOOL_A_STRINGSETS_STRINGSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			      "unexpected attrtype %u in ETHTOOL_A_STRSET_STRINGSETS\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			      nla_type(attr)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		ret = strset_get_id(attr, &id, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		if (id >= ETH_SS_COUNT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			NL_SET_ERR_MSG_ATTR(extack, attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 					    "unknown string set id");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 			return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		req_info->req_ids |= (1U << id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static void strset_cleanup_data(struct ethnl_reply_data *reply_base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	struct strset_reply_data *data = STRSET_REPDATA(reply_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	for (i = 0; i < ETH_SS_COUNT; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		if (data->sets[i].free_strings) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			kfree(data->sets[i].strings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			data->sets[i].strings = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 			data->sets[i].free_strings = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static int strset_prepare_set(struct strset_info *info, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			      unsigned int id, bool counts_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	const struct ethtool_ops *ops = dev->ethtool_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	void *strings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	int count, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	if (id == ETH_SS_PHY_STATS && dev->phydev &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	    !ops->get_ethtool_phy_stats && phy_ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	    phy_ops->get_sset_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		ret = phy_ops->get_sset_count(dev->phydev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	else if (ops->get_sset_count && ops->get_strings)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		ret = ops->get_sset_count(dev, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		ret = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	if (ret <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		info->count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	count = ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	if (!counts_only) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		strings = kcalloc(count, ETH_GSTRING_LEN, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		if (!strings)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		if (id == ETH_SS_PHY_STATS && dev->phydev &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		    !ops->get_ethtool_phy_stats && phy_ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		    phy_ops->get_strings)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			phy_ops->get_strings(dev->phydev, strings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			ops->get_strings(dev, id, strings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		info->strings = strings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		info->free_strings = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	info->count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static int strset_prepare_data(const struct ethnl_req_info *req_base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			       struct ethnl_reply_data *reply_base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 			       struct genl_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	const struct strset_req_info *req_info = STRSET_REQINFO(req_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	struct strset_reply_data *data = STRSET_REPDATA(reply_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	struct net_device *dev = reply_base->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	BUILD_BUG_ON(ARRAY_SIZE(info_template) != ETH_SS_COUNT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	memcpy(&data->sets, &info_template, sizeof(data->sets));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	if (!dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		for (i = 0; i < ETH_SS_COUNT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 			if ((req_info->req_ids & (1U << i)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 			    data->sets[i].per_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 				if (info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 					GENL_SET_ERR_MSG(info, "requested per device strings without dev");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	ret = ethnl_ops_begin(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		goto err_strset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	for (i = 0; i < ETH_SS_COUNT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		if (!strset_include(req_info, data, i) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		    !data->sets[i].per_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		ret = strset_prepare_set(&data->sets[i], dev, i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 					 req_info->counts_only);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			goto err_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	ethnl_ops_complete(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) err_ops:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	ethnl_ops_complete(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) err_strset:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	strset_cleanup_data(reply_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) /* calculate size of ETHTOOL_A_STRSET_STRINGSET nest for one string set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) static int strset_set_size(const struct strset_info *info, bool counts_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	unsigned int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	if (info->count == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	if (counts_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		return nla_total_size(2 * nla_total_size(sizeof(u32)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	for (i = 0; i < info->count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		const char *str = info->strings[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		/* ETHTOOL_A_STRING_INDEX, ETHTOOL_A_STRING_VALUE, nest */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		len += nla_total_size(nla_total_size(sizeof(u32)) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 				      ethnl_strz_size(str));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	/* ETHTOOL_A_STRINGSET_ID, ETHTOOL_A_STRINGSET_COUNT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	len = 2 * nla_total_size(sizeof(u32)) + nla_total_size(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	return nla_total_size(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) static int strset_reply_size(const struct ethnl_req_info *req_base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 			     const struct ethnl_reply_data *reply_base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	const struct strset_req_info *req_info = STRSET_REQINFO(req_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	const struct strset_reply_data *data = STRSET_REPDATA(reply_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	len += nla_total_size(0); /* ETHTOOL_A_STRSET_STRINGSETS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	for (i = 0; i < ETH_SS_COUNT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		const struct strset_info *set_info = &data->sets[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		if (!strset_include(req_info, data, i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		ret = strset_set_size(set_info, req_info->counts_only);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		len += ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) /* fill one string into reply */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) static int strset_fill_string(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 			      const struct strset_info *set_info, u32 idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	struct nlattr *string_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	const char *value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	value = set_info->strings[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	string_attr = nla_nest_start(skb, ETHTOOL_A_STRINGS_STRING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	if (!string_attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	if (nla_put_u32(skb, ETHTOOL_A_STRING_INDEX, idx) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	    ethnl_put_strz(skb, ETHTOOL_A_STRING_VALUE, value))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		goto nla_put_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	nla_nest_end(skb, string_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) nla_put_failure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	nla_nest_cancel(skb, string_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) /* fill one string set into reply */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) static int strset_fill_set(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 			   const struct strset_info *set_info, u32 id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 			   bool counts_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	struct nlattr *stringset_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	struct nlattr *strings_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	if (!set_info->per_dev && !set_info->strings)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	if (set_info->count == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	stringset_attr = nla_nest_start(skb, ETHTOOL_A_STRINGSETS_STRINGSET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	if (!stringset_attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	if (nla_put_u32(skb, ETHTOOL_A_STRINGSET_ID, id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	    nla_put_u32(skb, ETHTOOL_A_STRINGSET_COUNT, set_info->count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		goto nla_put_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	if (!counts_only) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		strings_attr = nla_nest_start(skb, ETHTOOL_A_STRINGSET_STRINGS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		if (!strings_attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			goto nla_put_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		for (i = 0; i < set_info->count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			if (strset_fill_string(skb, set_info, i) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 				goto nla_put_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		nla_nest_end(skb, strings_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	nla_nest_end(skb, stringset_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) nla_put_failure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	nla_nest_cancel(skb, stringset_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) static int strset_fill_reply(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 			     const struct ethnl_req_info *req_base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 			     const struct ethnl_reply_data *reply_base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	const struct strset_req_info *req_info = STRSET_REQINFO(req_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	const struct strset_reply_data *data = STRSET_REPDATA(reply_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	struct nlattr *nest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	nest = nla_nest_start(skb, ETHTOOL_A_STRSET_STRINGSETS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	if (!nest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	for (i = 0; i < ETH_SS_COUNT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		if (strset_include(req_info, data, i)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 			ret = strset_fill_set(skb, &data->sets[i], i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 					      req_info->counts_only);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 			if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 				goto nla_put_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	nla_nest_end(skb, nest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) nla_put_failure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	nla_nest_cancel(skb, nest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) const struct ethnl_request_ops ethnl_strset_request_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	.request_cmd		= ETHTOOL_MSG_STRSET_GET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	.reply_cmd		= ETHTOOL_MSG_STRSET_GET_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	.hdr_attr		= ETHTOOL_A_STRSET_HEADER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	.req_info_size		= sizeof(struct strset_req_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	.reply_data_size	= sizeof(struct strset_reply_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	.allow_nodev_do		= true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	.parse_request		= strset_parse_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	.prepare_data		= strset_prepare_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	.reply_size		= strset_reply_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	.fill_reply		= strset_fill_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	.cleanup_data		= strset_cleanup_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) };