12b4a8990SMichal Kubecek /* SPDX-License-Identifier: GPL-2.0-only */
22b4a8990SMichal Kubecek
32b4a8990SMichal Kubecek #ifndef _NET_ETHTOOL_NETLINK_H
42b4a8990SMichal Kubecek #define _NET_ETHTOOL_NETLINK_H
52b4a8990SMichal Kubecek
62b4a8990SMichal Kubecek #include <linux/ethtool_netlink.h>
72b4a8990SMichal Kubecek #include <linux/netdevice.h>
82b4a8990SMichal Kubecek #include <net/genetlink.h>
9041b1c5dSMichal Kubecek #include <net/sock.h>
10041b1c5dSMichal Kubecek
11041b1c5dSMichal Kubecek struct ethnl_req_info;
12041b1c5dSMichal Kubecek
1398130546SMichal Kubecek int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info,
14041b1c5dSMichal Kubecek const struct nlattr *nest, struct net *net,
1598130546SMichal Kubecek struct netlink_ext_ack *extack,
1698130546SMichal Kubecek bool require_dev);
17041b1c5dSMichal Kubecek int ethnl_fill_reply_header(struct sk_buff *skb, struct net_device *dev,
18041b1c5dSMichal Kubecek u16 attrtype);
19041b1c5dSMichal Kubecek struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd,
20041b1c5dSMichal Kubecek u16 hdr_attrtype, struct genl_info *info,
21041b1c5dSMichal Kubecek void **ehdrp);
22c7d759ebSJakub Kicinski void *ethnl_dump_put(struct sk_buff *skb, struct netlink_callback *cb, u8 cmd);
230df960f1SAndrew Lunn void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd);
240df960f1SAndrew Lunn int ethnl_multicast(struct sk_buff *skb, struct net_device *dev);
25041b1c5dSMichal Kubecek
26041b1c5dSMichal Kubecek /**
27041b1c5dSMichal Kubecek * ethnl_strz_size() - calculate attribute length for fixed size string
28041b1c5dSMichal Kubecek * @s: ETH_GSTRING_LEN sized string (may not be null terminated)
29041b1c5dSMichal Kubecek *
30041b1c5dSMichal Kubecek * Return: total length of an attribute with null terminated string from @s
31041b1c5dSMichal Kubecek */
ethnl_strz_size(const char * s)32041b1c5dSMichal Kubecek static inline int ethnl_strz_size(const char *s)
33041b1c5dSMichal Kubecek {
34041b1c5dSMichal Kubecek return nla_total_size(strnlen(s, ETH_GSTRING_LEN) + 1);
35041b1c5dSMichal Kubecek }
36041b1c5dSMichal Kubecek
37041b1c5dSMichal Kubecek /**
38041b1c5dSMichal Kubecek * ethnl_put_strz() - put string attribute with fixed size string
39041b1c5dSMichal Kubecek * @skb: skb with the message
40f33b0e19SJakub Kicinski * @attrtype: attribute type
41041b1c5dSMichal Kubecek * @s: ETH_GSTRING_LEN sized string (may not be null terminated)
42041b1c5dSMichal Kubecek *
43041b1c5dSMichal Kubecek * Puts an attribute with null terminated string from @s into the message.
44041b1c5dSMichal Kubecek *
45041b1c5dSMichal Kubecek * Return: 0 on success, negative error code on failure
46041b1c5dSMichal Kubecek */
ethnl_put_strz(struct sk_buff * skb,u16 attrtype,const char * s)47041b1c5dSMichal Kubecek static inline int ethnl_put_strz(struct sk_buff *skb, u16 attrtype,
48041b1c5dSMichal Kubecek const char *s)
49041b1c5dSMichal Kubecek {
50041b1c5dSMichal Kubecek unsigned int len = strnlen(s, ETH_GSTRING_LEN);
51041b1c5dSMichal Kubecek struct nlattr *attr;
52041b1c5dSMichal Kubecek
53041b1c5dSMichal Kubecek attr = nla_reserve(skb, attrtype, len + 1);
54041b1c5dSMichal Kubecek if (!attr)
55041b1c5dSMichal Kubecek return -EMSGSIZE;
56041b1c5dSMichal Kubecek
57041b1c5dSMichal Kubecek memcpy(nla_data(attr), s, len);
58041b1c5dSMichal Kubecek ((char *)nla_data(attr))[len] = '\0';
59041b1c5dSMichal Kubecek return 0;
60041b1c5dSMichal Kubecek }
61041b1c5dSMichal Kubecek
62041b1c5dSMichal Kubecek /**
63041b1c5dSMichal Kubecek * ethnl_update_u32() - update u32 value from NLA_U32 attribute
64041b1c5dSMichal Kubecek * @dst: value to update
65041b1c5dSMichal Kubecek * @attr: netlink attribute with new value or null
66041b1c5dSMichal Kubecek * @mod: pointer to bool for modification tracking
67041b1c5dSMichal Kubecek *
68041b1c5dSMichal Kubecek * Copy the u32 value from NLA_U32 netlink attribute @attr into variable
69041b1c5dSMichal Kubecek * pointed to by @dst; do nothing if @attr is null. Bool pointed to by @mod
70041b1c5dSMichal Kubecek * is set to true if this function changed the value of *dst, otherwise it
71041b1c5dSMichal Kubecek * is left as is.
72041b1c5dSMichal Kubecek */
ethnl_update_u32(u32 * dst,const struct nlattr * attr,bool * mod)73041b1c5dSMichal Kubecek static inline void ethnl_update_u32(u32 *dst, const struct nlattr *attr,
74041b1c5dSMichal Kubecek bool *mod)
75041b1c5dSMichal Kubecek {
76041b1c5dSMichal Kubecek u32 val;
77041b1c5dSMichal Kubecek
78041b1c5dSMichal Kubecek if (!attr)
79041b1c5dSMichal Kubecek return;
80041b1c5dSMichal Kubecek val = nla_get_u32(attr);
81041b1c5dSMichal Kubecek if (*dst == val)
82041b1c5dSMichal Kubecek return;
83041b1c5dSMichal Kubecek
84041b1c5dSMichal Kubecek *dst = val;
85041b1c5dSMichal Kubecek *mod = true;
86041b1c5dSMichal Kubecek }
87041b1c5dSMichal Kubecek
88041b1c5dSMichal Kubecek /**
89041b1c5dSMichal Kubecek * ethnl_update_u8() - update u8 value from NLA_U8 attribute
90041b1c5dSMichal Kubecek * @dst: value to update
91041b1c5dSMichal Kubecek * @attr: netlink attribute with new value or null
92041b1c5dSMichal Kubecek * @mod: pointer to bool for modification tracking
93041b1c5dSMichal Kubecek *
94041b1c5dSMichal Kubecek * Copy the u8 value from NLA_U8 netlink attribute @attr into variable
95041b1c5dSMichal Kubecek * pointed to by @dst; do nothing if @attr is null. Bool pointed to by @mod
96041b1c5dSMichal Kubecek * is set to true if this function changed the value of *dst, otherwise it
97041b1c5dSMichal Kubecek * is left as is.
98041b1c5dSMichal Kubecek */
ethnl_update_u8(u8 * dst,const struct nlattr * attr,bool * mod)99041b1c5dSMichal Kubecek static inline void ethnl_update_u8(u8 *dst, const struct nlattr *attr,
100041b1c5dSMichal Kubecek bool *mod)
101041b1c5dSMichal Kubecek {
102041b1c5dSMichal Kubecek u8 val;
103041b1c5dSMichal Kubecek
104041b1c5dSMichal Kubecek if (!attr)
105041b1c5dSMichal Kubecek return;
106041b1c5dSMichal Kubecek val = nla_get_u8(attr);
107041b1c5dSMichal Kubecek if (*dst == val)
108041b1c5dSMichal Kubecek return;
109041b1c5dSMichal Kubecek
110041b1c5dSMichal Kubecek *dst = val;
111041b1c5dSMichal Kubecek *mod = true;
112041b1c5dSMichal Kubecek }
113041b1c5dSMichal Kubecek
114041b1c5dSMichal Kubecek /**
115041b1c5dSMichal Kubecek * ethnl_update_bool32() - update u32 used as bool from NLA_U8 attribute
116041b1c5dSMichal Kubecek * @dst: value to update
117041b1c5dSMichal Kubecek * @attr: netlink attribute with new value or null
118041b1c5dSMichal Kubecek * @mod: pointer to bool for modification tracking
119041b1c5dSMichal Kubecek *
120041b1c5dSMichal Kubecek * Use the u8 value from NLA_U8 netlink attribute @attr to set u32 variable
121041b1c5dSMichal Kubecek * pointed to by @dst to 0 (if zero) or 1 (if not); do nothing if @attr is
122041b1c5dSMichal Kubecek * null. Bool pointed to by @mod is set to true if this function changed the
123041b1c5dSMichal Kubecek * logical value of *dst, otherwise it is left as is.
124041b1c5dSMichal Kubecek */
ethnl_update_bool32(u32 * dst,const struct nlattr * attr,bool * mod)125041b1c5dSMichal Kubecek static inline void ethnl_update_bool32(u32 *dst, const struct nlattr *attr,
126041b1c5dSMichal Kubecek bool *mod)
127041b1c5dSMichal Kubecek {
128041b1c5dSMichal Kubecek u8 val;
129041b1c5dSMichal Kubecek
130041b1c5dSMichal Kubecek if (!attr)
131041b1c5dSMichal Kubecek return;
132041b1c5dSMichal Kubecek val = !!nla_get_u8(attr);
133041b1c5dSMichal Kubecek if (!!*dst == val)
134041b1c5dSMichal Kubecek return;
135041b1c5dSMichal Kubecek
136041b1c5dSMichal Kubecek *dst = val;
137041b1c5dSMichal Kubecek *mod = true;
138041b1c5dSMichal Kubecek }
139041b1c5dSMichal Kubecek
140041b1c5dSMichal Kubecek /**
141dc0b98a1SDavid S. Miller * ethnl_update_bool() - updateb bool used as bool from NLA_U8 attribute
142dc0b98a1SDavid S. Miller * @dst: value to update
143dc0b98a1SDavid S. Miller * @attr: netlink attribute with new value or null
144dc0b98a1SDavid S. Miller * @mod: pointer to bool for modification tracking
145dc0b98a1SDavid S. Miller *
146dc0b98a1SDavid S. Miller * Use the bool value from NLA_U8 netlink attribute @attr to set bool variable
147dc0b98a1SDavid S. Miller * pointed to by @dst to 0 (if zero) or 1 (if not); do nothing if @attr is
148dc0b98a1SDavid S. Miller * null. Bool pointed to by @mod is set to true if this function changed the
149dc0b98a1SDavid S. Miller * logical value of *dst, otherwise it is left as is.
150dc0b98a1SDavid S. Miller */
ethnl_update_bool(bool * dst,const struct nlattr * attr,bool * mod)151dc0b98a1SDavid S. Miller static inline void ethnl_update_bool(bool *dst, const struct nlattr *attr,
152dc0b98a1SDavid S. Miller bool *mod)
153dc0b98a1SDavid S. Miller {
154dc0b98a1SDavid S. Miller u8 val;
155dc0b98a1SDavid S. Miller
156dc0b98a1SDavid S. Miller if (!attr)
157dc0b98a1SDavid S. Miller return;
158dc0b98a1SDavid S. Miller val = !!nla_get_u8(attr);
159dc0b98a1SDavid S. Miller if (!!*dst == val)
160dc0b98a1SDavid S. Miller return;
161dc0b98a1SDavid S. Miller
162dc0b98a1SDavid S. Miller *dst = val;
163dc0b98a1SDavid S. Miller *mod = true;
164dc0b98a1SDavid S. Miller }
165dc0b98a1SDavid S. Miller
166dc0b98a1SDavid S. Miller /**
167b676c7f1SZheng Yongjun * ethnl_update_binary() - update binary data from NLA_BINARY attribute
168041b1c5dSMichal Kubecek * @dst: value to update
169041b1c5dSMichal Kubecek * @len: destination buffer length
170041b1c5dSMichal Kubecek * @attr: netlink attribute with new value or null
171041b1c5dSMichal Kubecek * @mod: pointer to bool for modification tracking
172041b1c5dSMichal Kubecek *
173041b1c5dSMichal Kubecek * Use the u8 value from NLA_U8 netlink attribute @attr to rewrite data block
174041b1c5dSMichal Kubecek * of length @len at @dst by attribute payload; do nothing if @attr is null.
175041b1c5dSMichal Kubecek * Bool pointed to by @mod is set to true if this function changed the logical
176041b1c5dSMichal Kubecek * value of *dst, otherwise it is left as is.
177041b1c5dSMichal Kubecek */
ethnl_update_binary(void * dst,unsigned int len,const struct nlattr * attr,bool * mod)178041b1c5dSMichal Kubecek static inline void ethnl_update_binary(void *dst, unsigned int len,
179041b1c5dSMichal Kubecek const struct nlattr *attr, bool *mod)
180041b1c5dSMichal Kubecek {
181041b1c5dSMichal Kubecek if (!attr)
182041b1c5dSMichal Kubecek return;
183041b1c5dSMichal Kubecek if (nla_len(attr) < len)
184041b1c5dSMichal Kubecek len = nla_len(attr);
185041b1c5dSMichal Kubecek if (!memcmp(dst, nla_data(attr), len))
186041b1c5dSMichal Kubecek return;
187041b1c5dSMichal Kubecek
188041b1c5dSMichal Kubecek memcpy(dst, nla_data(attr), len);
189041b1c5dSMichal Kubecek *mod = true;
190041b1c5dSMichal Kubecek }
191041b1c5dSMichal Kubecek
192041b1c5dSMichal Kubecek /**
193041b1c5dSMichal Kubecek * ethnl_update_bitfield32() - update u32 value from NLA_BITFIELD32 attribute
194041b1c5dSMichal Kubecek * @dst: value to update
195041b1c5dSMichal Kubecek * @attr: netlink attribute with new value or null
196041b1c5dSMichal Kubecek * @mod: pointer to bool for modification tracking
197041b1c5dSMichal Kubecek *
198041b1c5dSMichal Kubecek * Update bits in u32 value which are set in attribute's mask to values from
199041b1c5dSMichal Kubecek * attribute's value. Do nothing if @attr is null or the value wouldn't change;
200041b1c5dSMichal Kubecek * otherwise, set bool pointed to by @mod to true.
201041b1c5dSMichal Kubecek */
ethnl_update_bitfield32(u32 * dst,const struct nlattr * attr,bool * mod)202041b1c5dSMichal Kubecek static inline void ethnl_update_bitfield32(u32 *dst, const struct nlattr *attr,
203041b1c5dSMichal Kubecek bool *mod)
204041b1c5dSMichal Kubecek {
205041b1c5dSMichal Kubecek struct nla_bitfield32 change;
206041b1c5dSMichal Kubecek u32 newval;
207041b1c5dSMichal Kubecek
208041b1c5dSMichal Kubecek if (!attr)
209041b1c5dSMichal Kubecek return;
210041b1c5dSMichal Kubecek change = nla_get_bitfield32(attr);
211041b1c5dSMichal Kubecek newval = (*dst & ~change.selector) | (change.value & change.selector);
212041b1c5dSMichal Kubecek if (*dst == newval)
213041b1c5dSMichal Kubecek return;
214041b1c5dSMichal Kubecek
215041b1c5dSMichal Kubecek *dst = newval;
216041b1c5dSMichal Kubecek *mod = true;
217041b1c5dSMichal Kubecek }
218041b1c5dSMichal Kubecek
219041b1c5dSMichal Kubecek /**
220041b1c5dSMichal Kubecek * ethnl_reply_header_size() - total size of reply header
221041b1c5dSMichal Kubecek *
222041b1c5dSMichal Kubecek * This is an upper estimate so that we do not need to hold RTNL lock longer
223041b1c5dSMichal Kubecek * than necessary (to prevent rename between size estimate and composing the
224041b1c5dSMichal Kubecek * message). Accounts only for device ifindex and name as those are the only
225041b1c5dSMichal Kubecek * attributes ethnl_fill_reply_header() puts into the reply header.
226041b1c5dSMichal Kubecek */
ethnl_reply_header_size(void)227041b1c5dSMichal Kubecek static inline unsigned int ethnl_reply_header_size(void)
228041b1c5dSMichal Kubecek {
229041b1c5dSMichal Kubecek return nla_total_size(nla_total_size(sizeof(u32)) +
230041b1c5dSMichal Kubecek nla_total_size(IFNAMSIZ));
231041b1c5dSMichal Kubecek }
232041b1c5dSMichal Kubecek
233728480f1SMichal Kubecek /* GET request handling */
234728480f1SMichal Kubecek
235728480f1SMichal Kubecek /* Unified processing of GET requests uses two data structures: request info
236728480f1SMichal Kubecek * and reply data. Request info holds information parsed from client request
237728480f1SMichal Kubecek * and its stays constant through all request processing. Reply data holds data
238728480f1SMichal Kubecek * retrieved from ethtool_ops callbacks or other internal sources which is used
239728480f1SMichal Kubecek * to compose the reply. When processing a dump request, request info is filled
240728480f1SMichal Kubecek * only once (when the request message is parsed) but reply data is filled for
241728480f1SMichal Kubecek * each reply message.
242728480f1SMichal Kubecek *
243728480f1SMichal Kubecek * Both structures consist of part common for all request types (struct
244728480f1SMichal Kubecek * ethnl_req_info and struct ethnl_reply_data defined below) and optional
245728480f1SMichal Kubecek * parts specific for each request type. Common part always starts at offset 0.
246728480f1SMichal Kubecek */
247728480f1SMichal Kubecek
248041b1c5dSMichal Kubecek /**
249041b1c5dSMichal Kubecek * struct ethnl_req_info - base type of request information for GET requests
250041b1c5dSMichal Kubecek * @dev: network device the request is for (may be null)
251e4b89540SEric Dumazet * @dev_tracker: refcount tracker for @dev reference
252041b1c5dSMichal Kubecek * @flags: request flags common for all request types
253041b1c5dSMichal Kubecek *
254728480f1SMichal Kubecek * This is a common base for request specific structures holding data from
255728480f1SMichal Kubecek * parsed userspace request. These always embed struct ethnl_req_info at
256728480f1SMichal Kubecek * zero offset.
257041b1c5dSMichal Kubecek */
258041b1c5dSMichal Kubecek struct ethnl_req_info {
259041b1c5dSMichal Kubecek struct net_device *dev;
260e4b89540SEric Dumazet netdevice_tracker dev_tracker;
261041b1c5dSMichal Kubecek u32 flags;
262041b1c5dSMichal Kubecek };
2632b4a8990SMichal Kubecek
ethnl_parse_header_dev_put(struct ethnl_req_info * req_info)26434ac17ecSEric Dumazet static inline void ethnl_parse_header_dev_put(struct ethnl_req_info *req_info)
26534ac17ecSEric Dumazet {
266d62607c3SJakub Kicinski netdev_put(req_info->dev, &req_info->dev_tracker);
26734ac17ecSEric Dumazet }
26834ac17ecSEric Dumazet
269728480f1SMichal Kubecek /**
270728480f1SMichal Kubecek * struct ethnl_reply_data - base type of reply data for GET requests
271728480f1SMichal Kubecek * @dev: device for current reply message; in single shot requests it is
272728480f1SMichal Kubecek * equal to ðnl_req_info.dev; in dumps it's different for each
273728480f1SMichal Kubecek * reply message
274728480f1SMichal Kubecek *
275728480f1SMichal Kubecek * This is a common base for request specific structures holding data for
276728480f1SMichal Kubecek * kernel reply message. These always embed struct ethnl_reply_data at zero
277728480f1SMichal Kubecek * offset.
278728480f1SMichal Kubecek */
279728480f1SMichal Kubecek struct ethnl_reply_data {
280728480f1SMichal Kubecek struct net_device *dev;
281728480f1SMichal Kubecek };
282728480f1SMichal Kubecek
283c5ab51dfSHeiner Kallweit int ethnl_ops_begin(struct net_device *dev);
284c5ab51dfSHeiner Kallweit void ethnl_ops_complete(struct net_device *dev);
285728480f1SMichal Kubecek
286728480f1SMichal Kubecek /**
28799132b6eSJakub Kicinski * struct ethnl_request_ops - unified handling of GET and SET requests
288728480f1SMichal Kubecek * @request_cmd: command id for request (GET)
289728480f1SMichal Kubecek * @reply_cmd: command id for reply (GET_REPLY)
290728480f1SMichal Kubecek * @hdr_attr: attribute type for request header
291728480f1SMichal Kubecek * @req_info_size: size of request info
292728480f1SMichal Kubecek * @reply_data_size: size of reply data
293728480f1SMichal Kubecek * @allow_nodev_do: allow non-dump request with no device identification
29499132b6eSJakub Kicinski * @set_ntf_cmd: notification to generate on changes (SET)
295728480f1SMichal Kubecek * @parse_request:
296728480f1SMichal Kubecek * Parse request except common header (struct ethnl_req_info). Common
297728480f1SMichal Kubecek * header is already filled on entry, the rest up to @repdata_offset
298728480f1SMichal Kubecek * is zero initialized. This callback should only modify type specific
299728480f1SMichal Kubecek * request info by parsed attributes from request message.
300728480f1SMichal Kubecek * @prepare_data:
301728480f1SMichal Kubecek * Retrieve and prepare data needed to compose a reply message. Calls to
302728480f1SMichal Kubecek * ethtool_ops handlers are limited to this callback. Common reply data
303728480f1SMichal Kubecek * (struct ethnl_reply_data) is filled on entry, type specific part after
304728480f1SMichal Kubecek * it is zero initialized. This callback should only modify the type
305728480f1SMichal Kubecek * specific part of reply data. Device identification from struct
306728480f1SMichal Kubecek * ethnl_reply_data is to be used as for dump requests, it iterates
307728480f1SMichal Kubecek * through network devices while dev member of struct ethnl_req_info
308728480f1SMichal Kubecek * points to the device from client request.
309728480f1SMichal Kubecek * @reply_size:
310728480f1SMichal Kubecek * Estimate reply message size. Returned value must be sufficient for
311728480f1SMichal Kubecek * message payload without common reply header. The callback may returned
312728480f1SMichal Kubecek * estimate higher than actual message size if exact calculation would
313728480f1SMichal Kubecek * not be worth the saved memory space.
314728480f1SMichal Kubecek * @fill_reply:
315728480f1SMichal Kubecek * Fill reply message payload (except for common header) from reply data.
316728480f1SMichal Kubecek * The callback must not generate more payload than previously called
317728480f1SMichal Kubecek * ->reply_size() estimated.
318728480f1SMichal Kubecek * @cleanup_data:
319728480f1SMichal Kubecek * Optional cleanup called when reply data is no longer needed. Can be
320728480f1SMichal Kubecek * used e.g. to free any additional data structures outside the main
321728480f1SMichal Kubecek * structure which were allocated by ->prepare_data(). When processing
322728480f1SMichal Kubecek * dump requests, ->cleanup() is called for each message.
32399132b6eSJakub Kicinski * @set_validate:
32499132b6eSJakub Kicinski * Check if set operation is supported for a given device, and perform
32599132b6eSJakub Kicinski * extra input checks. Expected return values:
32699132b6eSJakub Kicinski * - 0 if the operation is a noop for the device (rare)
32799132b6eSJakub Kicinski * - 1 if operation should proceed to calling @set
32899132b6eSJakub Kicinski * - negative errno on errors
32999132b6eSJakub Kicinski * Called without any locks, just a reference on the netdev.
33099132b6eSJakub Kicinski * @set:
33199132b6eSJakub Kicinski * Execute the set operation. The implementation should return
33299132b6eSJakub Kicinski * - 0 if no configuration has changed
33399132b6eSJakub Kicinski * - 1 if configuration changed and notification should be generated
33499132b6eSJakub Kicinski * - negative errno on errors
335728480f1SMichal Kubecek *
336728480f1SMichal Kubecek * Description of variable parts of GET request handling when using the
337728480f1SMichal Kubecek * unified infrastructure. When used, a pointer to an instance of this
338728480f1SMichal Kubecek * structure is to be added to ðnl_default_requests array and generic
339728480f1SMichal Kubecek * handlers ethnl_default_doit(), ethnl_default_dumpit(),
3405cf2a548SMichal Kubecek * ethnl_default_start() and ethnl_default_done() used in @ethtool_genl_ops;
3415cf2a548SMichal Kubecek * ethnl_default_notify() can be used in @ethnl_notify_handlers to send
3425cf2a548SMichal Kubecek * notifications of the corresponding type.
343728480f1SMichal Kubecek */
344728480f1SMichal Kubecek struct ethnl_request_ops {
345728480f1SMichal Kubecek u8 request_cmd;
346728480f1SMichal Kubecek u8 reply_cmd;
347728480f1SMichal Kubecek u16 hdr_attr;
348728480f1SMichal Kubecek unsigned int req_info_size;
349728480f1SMichal Kubecek unsigned int reply_data_size;
350728480f1SMichal Kubecek bool allow_nodev_do;
35199132b6eSJakub Kicinski u8 set_ntf_cmd;
352728480f1SMichal Kubecek
353728480f1SMichal Kubecek int (*parse_request)(struct ethnl_req_info *req_info,
354728480f1SMichal Kubecek struct nlattr **tb,
355728480f1SMichal Kubecek struct netlink_ext_ack *extack);
356728480f1SMichal Kubecek int (*prepare_data)(const struct ethnl_req_info *req_info,
357728480f1SMichal Kubecek struct ethnl_reply_data *reply_data,
358*f946270dSJakub Kicinski const struct genl_info *info);
359728480f1SMichal Kubecek int (*reply_size)(const struct ethnl_req_info *req_info,
360728480f1SMichal Kubecek const struct ethnl_reply_data *reply_data);
361728480f1SMichal Kubecek int (*fill_reply)(struct sk_buff *skb,
362728480f1SMichal Kubecek const struct ethnl_req_info *req_info,
363728480f1SMichal Kubecek const struct ethnl_reply_data *reply_data);
364728480f1SMichal Kubecek void (*cleanup_data)(struct ethnl_reply_data *reply_data);
36599132b6eSJakub Kicinski
36699132b6eSJakub Kicinski int (*set_validate)(struct ethnl_req_info *req_info,
36799132b6eSJakub Kicinski struct genl_info *info);
36899132b6eSJakub Kicinski int (*set)(struct ethnl_req_info *req_info,
36999132b6eSJakub Kicinski struct genl_info *info);
370728480f1SMichal Kubecek };
371728480f1SMichal Kubecek
37271921690SMichal Kubecek /* request handlers */
37371921690SMichal Kubecek
37471921690SMichal Kubecek extern const struct ethnl_request_ops ethnl_strset_request_ops;
375459e0b81SMichal Kubecek extern const struct ethnl_request_ops ethnl_linkinfo_request_ops;
376f625aa9bSMichal Kubecek extern const struct ethnl_request_ops ethnl_linkmodes_request_ops;
3773d2b847fSMichal Kubecek extern const struct ethnl_request_ops ethnl_linkstate_request_ops;
3786a94b8ccSMichal Kubecek extern const struct ethnl_request_ops ethnl_debug_request_ops;
37951ea22b0SMichal Kubecek extern const struct ethnl_request_ops ethnl_wol_request_ops;
3800524399dSMichal Kubecek extern const struct ethnl_request_ops ethnl_features_request_ops;
381e16c3386SMichal Kubecek extern const struct ethnl_request_ops ethnl_privflags_request_ops;
382e4a1717bSMichal Kubecek extern const struct ethnl_request_ops ethnl_rings_request_ops;
3830c84979cSMichal Kubecek extern const struct ethnl_request_ops ethnl_channels_request_ops;
38421727545SMichal Kubecek extern const struct ethnl_request_ops ethnl_coalesce_request_ops;
3857f59fb32SMichal Kubecek extern const struct ethnl_request_ops ethnl_pause_request_ops;
386b7eeefe7SMichal Kubecek extern const struct ethnl_request_ops ethnl_eee_request_ops;
3875b071c59SMichal Kubecek extern const struct ethnl_request_ops ethnl_tsinfo_request_ops;
3881e5d1f69SJakub Kicinski extern const struct ethnl_request_ops ethnl_fec_request_ops;
389c781ff12SVladyslav Tarasiuk extern const struct ethnl_request_ops ethnl_module_eeprom_request_ops;
390f09ea6fbSJakub Kicinski extern const struct ethnl_request_ops ethnl_stats_request_ops;
391c156174aSYangbo Lu extern const struct ethnl_request_ops ethnl_phc_vclocks_request_ops;
392353407d9SIdo Schimmel extern const struct ethnl_request_ops ethnl_module_request_ops;
39318ff0bcdSOleksij Rempel extern const struct ethnl_request_ops ethnl_pse_request_ops;
3947112a046SSudheer Mogilappagari extern const struct ethnl_request_ops ethnl_rss_request_ops;
3958580e16cSPiergiorgio Beruto extern const struct ethnl_request_ops ethnl_plca_cfg_request_ops;
3968580e16cSPiergiorgio Beruto extern const struct ethnl_request_ops ethnl_plca_status_request_ops;
3972b30f829SVladimir Oltean extern const struct ethnl_request_ops ethnl_mm_request_ops;
39871921690SMichal Kubecek
399329d9c33SJakub Kicinski extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1];
400a0de1cd3SJakub Kicinski extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1];
401db972e53SJohannes Berg extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_COUNTS_ONLY + 1];
402ff419afaSJakub Kicinski extern const struct nla_policy ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_HEADER + 1];
403ff419afaSJakub Kicinski extern const struct nla_policy ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL + 1];
404ff419afaSJakub Kicinski extern const struct nla_policy ethnl_linkmodes_get_policy[ETHTOOL_A_LINKMODES_HEADER + 1];
405012ce4ddSDanielle Ratson extern const struct nla_policy ethnl_linkmodes_set_policy[ETHTOOL_A_LINKMODES_LANES + 1];
406ff419afaSJakub Kicinski extern const struct nla_policy ethnl_linkstate_get_policy[ETHTOOL_A_LINKSTATE_HEADER + 1];
407ff419afaSJakub Kicinski extern const struct nla_policy ethnl_debug_get_policy[ETHTOOL_A_DEBUG_HEADER + 1];
408ff419afaSJakub Kicinski extern const struct nla_policy ethnl_debug_set_policy[ETHTOOL_A_DEBUG_MSGMASK + 1];
409ff419afaSJakub Kicinski extern const struct nla_policy ethnl_wol_get_policy[ETHTOOL_A_WOL_HEADER + 1];
410ff419afaSJakub Kicinski extern const struct nla_policy ethnl_wol_set_policy[ETHTOOL_A_WOL_SOPASS + 1];
411ff419afaSJakub Kicinski extern const struct nla_policy ethnl_features_get_policy[ETHTOOL_A_FEATURES_HEADER + 1];
412ff419afaSJakub Kicinski extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_WANTED + 1];
413ff419afaSJakub Kicinski extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_HEADER + 1];
414ff419afaSJakub Kicinski extern const struct nla_policy ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_FLAGS + 1];
415ff419afaSJakub Kicinski extern const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_HEADER + 1];
416233eb4e7SShay Agroskin extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX + 1];
417ff419afaSJakub Kicinski extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEADER + 1];
418ff419afaSJakub Kicinski extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1];
419ff419afaSJakub Kicinski extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1];
420029ee6b1SYufeng Mo extern const struct nla_policy ethnl_coalesce_set_policy[ETHTOOL_A_COALESCE_MAX + 1];
42104692c90SVladimir Oltean extern const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_STATS_SRC + 1];
422ff419afaSJakub Kicinski extern const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_TX + 1];
423ff419afaSJakub Kicinski extern const struct nla_policy ethnl_eee_get_policy[ETHTOOL_A_EEE_HEADER + 1];
424ff419afaSJakub Kicinski extern const struct nla_policy ethnl_eee_set_policy[ETHTOOL_A_EEE_TX_LPI_TIMER + 1];
425ff419afaSJakub Kicinski extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER + 1];
426ff419afaSJakub Kicinski extern const struct nla_policy ethnl_cable_test_act_policy[ETHTOOL_A_CABLE_TEST_HEADER + 1];
427ff419afaSJakub Kicinski extern const struct nla_policy ethnl_cable_test_tdr_act_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG + 1];
428ff419afaSJakub Kicinski extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INFO_HEADER + 1];
4291e5d1f69SJakub Kicinski extern const struct nla_policy ethnl_fec_get_policy[ETHTOOL_A_FEC_HEADER + 1];
4301e5d1f69SJakub Kicinski extern const struct nla_policy ethnl_fec_set_policy[ETHTOOL_A_FEC_AUTO + 1];
431f5fe211dSIdo Schimmel extern const struct nla_policy ethnl_module_eeprom_get_policy[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS + 1];
43204692c90SVladimir Oltean extern const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_SRC + 1];
433c156174aSYangbo Lu extern const struct nla_policy ethnl_phc_vclocks_get_policy[ETHTOOL_A_PHC_VCLOCKS_HEADER + 1];
434353407d9SIdo Schimmel extern const struct nla_policy ethnl_module_get_policy[ETHTOOL_A_MODULE_HEADER + 1];
435353407d9SIdo Schimmel extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MODE_POLICY + 1];
43618ff0bcdSOleksij Rempel extern const struct nla_policy ethnl_pse_get_policy[ETHTOOL_A_PSE_HEADER + 1];
43718ff0bcdSOleksij Rempel extern const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX + 1];
4387112a046SSudheer Mogilappagari extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_CONTEXT + 1];
4398580e16cSPiergiorgio Beruto extern const struct nla_policy ethnl_plca_get_cfg_policy[ETHTOOL_A_PLCA_HEADER + 1];
4408580e16cSPiergiorgio Beruto extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX + 1];
4418580e16cSPiergiorgio Beruto extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER + 1];
4422b30f829SVladimir Oltean extern const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1];
4432b30f829SVladimir Oltean extern const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1];
4444f30974fSJakub Kicinski
4450980bfcdSMichal Kubecek int ethnl_set_features(struct sk_buff *skb, struct genl_info *info);
44611ca3c42SAndrew Lunn int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info);
4471a644de2SAndrew Lunn int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct genl_info *info);
448c7d759ebSJakub Kicinski int ethnl_tunnel_info_doit(struct sk_buff *skb, struct genl_info *info);
449c7d759ebSJakub Kicinski int ethnl_tunnel_info_start(struct netlink_callback *cb);
450c7d759ebSJakub Kicinski int ethnl_tunnel_info_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
451a53f3d41SMichal Kubecek
452f09ea6fbSJakub Kicinski extern const char stats_std_names[__ETHTOOL_STATS_CNT][ETH_GSTRING_LEN];
453f09ea6fbSJakub Kicinski extern const char stats_eth_phy_names[__ETHTOOL_A_STATS_ETH_PHY_CNT][ETH_GSTRING_LEN];
454ca224454SJakub Kicinski extern const char stats_eth_mac_names[__ETHTOOL_A_STATS_ETH_MAC_CNT][ETH_GSTRING_LEN];
455bfad2b97SJakub Kicinski extern const char stats_eth_ctrl_names[__ETHTOOL_A_STATS_ETH_CTRL_CNT][ETH_GSTRING_LEN];
456a8b06e9dSJakub Kicinski extern const char stats_rmon_names[__ETHTOOL_A_STATS_RMON_CNT][ETH_GSTRING_LEN];
457f09ea6fbSJakub Kicinski
4582b4a8990SMichal Kubecek #endif /* _NET_ETHTOOL_NETLINK_H */
459