]> asedeno.scripts.mit.edu Git - linux.git/blob - Documentation/networking/ethtool-netlink.rst
ethtool: provide string sets with STRSET_GET request
[linux.git] / Documentation / networking / ethtool-netlink.rst
1 =============================
2 Netlink interface for ethtool
3 =============================
4
5
6 Basic information
7 =================
8
9 Netlink interface for ethtool uses generic netlink family ``ethtool``
10 (userspace application should use macros ``ETHTOOL_GENL_NAME`` and
11 ``ETHTOOL_GENL_VERSION`` defined in ``<linux/ethtool_netlink.h>`` uapi
12 header). This family does not use a specific header, all information in
13 requests and replies is passed using netlink attributes.
14
15 The ethtool netlink interface uses extended ACK for error and warning
16 reporting, userspace application developers are encouraged to make these
17 messages available to user in a suitable way.
18
19 Requests can be divided into three categories: "get" (retrieving information),
20 "set" (setting parameters) and "action" (invoking an action).
21
22 All "set" and "action" type requests require admin privileges
23 (``CAP_NET_ADMIN`` in the namespace). Most "get" type requests are allowed for
24 anyone but there are exceptions (where the response contains sensitive
25 information). In some cases, the request as such is allowed for anyone but
26 unprivileged users have attributes with sensitive information (e.g.
27 wake-on-lan password) omitted.
28
29
30 Conventions
31 ===========
32
33 Attributes which represent a boolean value usually use NLA_U8 type so that we
34 can distinguish three states: "on", "off" and "not present" (meaning the
35 information is not available in "get" requests or value is not to be changed
36 in "set" requests). For these attributes, the "true" value should be passed as
37 number 1 but any non-zero value should be understood as "true" by recipient.
38 In the tables below, "bool" denotes NLA_U8 attributes interpreted in this way.
39
40 In the message structure descriptions below, if an attribute name is suffixed
41 with "+", parent nest can contain multiple attributes of the same type. This
42 implements an array of entries.
43
44
45 Request header
46 ==============
47
48 Each request or reply message contains a nested attribute with common header.
49 Structure of this header is
50
51   ==============================  ======  =============================
52   ``ETHTOOL_A_HEADER_DEV_INDEX``  u32     device ifindex
53   ``ETHTOOL_A_HEADER_DEV_NAME``   string  device name
54   ``ETHTOOL_A_HEADER_FLAGS``      u32     flags common for all requests
55   ==============================  ======  =============================
56
57 ``ETHTOOL_A_HEADER_DEV_INDEX`` and ``ETHTOOL_A_HEADER_DEV_NAME`` identify the
58 device message relates to. One of them is sufficient in requests, if both are
59 used, they must identify the same device. Some requests, e.g. global string
60 sets, do not require device identification. Most ``GET`` requests also allow
61 dump requests without device identification to query the same information for
62 all devices providing it (each device in a separate message).
63
64 ``ETHTOOL_A_HEADER_FLAGS`` is a bitmap of request flags common for all request
65 types. The interpretation of these flags is the same for all request types but
66 the flags may not apply to requests. Recognized flags are:
67
68   =================================  ===================================
69   ``ETHTOOL_FLAG_COMPACT_BITSETS``   use compact format bitsets in reply
70   ``ETHTOOL_FLAG_OMIT_REPLY``        omit optional reply (_SET and _ACT)
71   =================================  ===================================
72
73 New request flags should follow the general idea that if the flag is not set,
74 the behaviour is backward compatible, i.e. requests from old clients not aware
75 of the flag should be interpreted the way the client expects. A client must
76 not set flags it does not understand.
77
78
79 Bit sets
80 ========
81
82 For short bitmaps of (reasonably) fixed length, standard ``NLA_BITFIELD32``
83 type is used. For arbitrary length bitmaps, ethtool netlink uses a nested
84 attribute with contents of one of two forms: compact (two binary bitmaps
85 representing bit values and mask of affected bits) and bit-by-bit (list of
86 bits identified by either index or name).
87
88 Verbose (bit-by-bit) bitsets allow sending symbolic names for bits together
89 with their values which saves a round trip (when the bitset is passed in a
90 request) or at least a second request (when the bitset is in a reply). This is
91 useful for one shot applications like traditional ethtool command. On the
92 other hand, long running applications like ethtool monitor (displaying
93 notifications) or network management daemons may prefer fetching the names
94 only once and using compact form to save message size. Notifications from
95 ethtool netlink interface always use compact form for bitsets.
96
97 A bitset can represent either a value/mask pair (``ETHTOOL_A_BITSET_NOMASK``
98 not set) or a single bitmap (``ETHTOOL_A_BITSET_NOMASK`` set). In requests
99 modifying a bitmap, the former changes the bit set in mask to values set in
100 value and preserves the rest; the latter sets the bits set in the bitmap and
101 clears the rest.
102
103 Compact form: nested (bitset) atrribute contents:
104
105   ============================  ======  ============================
106   ``ETHTOOL_A_BITSET_NOMASK``   flag    no mask, only a list
107   ``ETHTOOL_A_BITSET_SIZE``     u32     number of significant bits
108   ``ETHTOOL_A_BITSET_VALUE``    binary  bitmap of bit values
109   ``ETHTOOL_A_BITSET_MASK``     binary  bitmap of valid bits
110   ============================  ======  ============================
111
112 Value and mask must have length at least ``ETHTOOL_A_BITSET_SIZE`` bits
113 rounded up to a multiple of 32 bits. They consist of 32-bit words in host byte
114 order, words ordered from least significant to most significant (i.e. the same
115 way as bitmaps are passed with ioctl interface).
116
117 For compact form, ``ETHTOOL_A_BITSET_SIZE`` and ``ETHTOOL_A_BITSET_VALUE`` are
118 mandatory. ``ETHTOOL_A_BITSET_MASK`` attribute is mandatory if
119 ``ETHTOOL_A_BITSET_NOMASK`` is not set (bitset represents a value/mask pair);
120 if ``ETHTOOL_A_BITSET_NOMASK`` is not set, ``ETHTOOL_A_BITSET_MASK`` is not
121 allowed (bitset represents a single bitmap.
122
123 Kernel bit set length may differ from userspace length if older application is
124 used on newer kernel or vice versa. If userspace bitmap is longer, an error is
125 issued only if the request actually tries to set values of some bits not
126 recognized by kernel.
127
128 Bit-by-bit form: nested (bitset) attribute contents:
129
130  +------------------------------------+--------+-----------------------------+
131  | ``ETHTOOL_A_BITSET_NOMASK``        | flag   | no mask, only a list        |
132  +------------------------------------+--------+-----------------------------+
133  | ``ETHTOOL_A_BITSET_SIZE``          | u32    | number of significant bits  |
134  +------------------------------------+--------+-----------------------------+
135  | ``ETHTOOL_A_BITSET_BITS``          | nested | array of bits               |
136  +-+----------------------------------+--------+-----------------------------+
137  | | ``ETHTOOL_A_BITSET_BITS_BIT+``   | nested | one bit                     |
138  +-+-+--------------------------------+--------+-----------------------------+
139  | | | ``ETHTOOL_A_BITSET_BIT_INDEX`` | u32    | bit index (0 for LSB)       |
140  +-+-+--------------------------------+--------+-----------------------------+
141  | | | ``ETHTOOL_A_BITSET_BIT_NAME``  | string | bit name                    |
142  +-+-+--------------------------------+--------+-----------------------------+
143  | | | ``ETHTOOL_A_BITSET_BIT_VALUE`` | flag   | present if bit is set       |
144  +-+-+--------------------------------+--------+-----------------------------+
145
146 Bit size is optional for bit-by-bit form. ``ETHTOOL_A_BITSET_BITS`` nest can
147 only contain ``ETHTOOL_A_BITSET_BITS_BIT`` attributes but there can be an
148 arbitrary number of them.  A bit may be identified by its index or by its
149 name. When used in requests, listed bits are set to 0 or 1 according to
150 ``ETHTOOL_A_BITSET_BIT_VALUE``, the rest is preserved. A request fails if
151 index exceeds kernel bit length or if name is not recognized.
152
153 When ``ETHTOOL_A_BITSET_NOMASK`` flag is present, bitset is interpreted as
154 a simple bitmap. ``ETHTOOL_A_BITSET_BIT_VALUE`` attributes are not used in
155 such case. Such bitset represents a bitmap with listed bits set and the rest
156 zero.
157
158 In requests, application can use either form. Form used by kernel in reply is
159 determined by ``ETHTOOL_FLAG_COMPACT_BITSETS`` flag in flags field of request
160 header. Semantics of value and mask depends on the attribute.
161
162
163 List of message types
164 =====================
165
166 All constants identifying message types use ``ETHTOOL_CMD_`` prefix and suffix
167 according to message purpose:
168
169   ==============    ======================================
170   ``_GET``          userspace request to retrieve data
171   ``_SET``          userspace request to set data
172   ``_ACT``          userspace request to perform an action
173   ``_GET_REPLY``    kernel reply to a ``GET`` request
174   ``_SET_REPLY``    kernel reply to a ``SET`` request
175   ``_ACT_REPLY``    kernel reply to an ``ACT`` request
176   ``_NTF``          kernel notification
177   ==============    ======================================
178
179 Userspace to kernel:
180
181   ===================================== ================================
182   ``ETHTOOL_MSG_STRSET_GET``            get string set
183   ===================================== ================================
184
185 Kernel to userspace:
186
187   ===================================== ================================
188   ``ETHTOOL_MSG_STRSET_GET_REPLY``      string set contents
189   ===================================== ================================
190
191 ``GET`` requests are sent by userspace applications to retrieve device
192 information. They usually do not contain any message specific attributes.
193 Kernel replies with corresponding "GET_REPLY" message. For most types, ``GET``
194 request with ``NLM_F_DUMP`` and no device identification can be used to query
195 the information for all devices supporting the request.
196
197 If the data can be also modified, corresponding ``SET`` message with the same
198 layout as corresponding ``GET_REPLY`` is used to request changes. Only
199 attributes where a change is requested are included in such request (also, not
200 all attributes may be changed). Replies to most ``SET`` request consist only
201 of error code and extack; if kernel provides additional data, it is sent in
202 the form of corresponding ``SET_REPLY`` message which can be suppressed by
203 setting ``ETHTOOL_FLAG_OMIT_REPLY`` flag in request header.
204
205 Data modification also triggers sending a ``NTF`` message with a notification.
206 These usually bear only a subset of attributes which was affected by the
207 change. The same notification is issued if the data is modified using other
208 means (mostly ioctl ethtool interface). Unlike notifications from ethtool
209 netlink code which are only sent if something actually changed, notifications
210 triggered by ioctl interface may be sent even if the request did not actually
211 change any data.
212
213 ``ACT`` messages request kernel (driver) to perform a specific action. If some
214 information is reported by kernel (which can be suppressed by setting
215 ``ETHTOOL_FLAG_OMIT_REPLY`` flag in request header), the reply takes form of
216 an ``ACT_REPLY`` message. Performing an action also triggers a notification
217 (``NTF`` message).
218
219 Later sections describe the format and semantics of these messages.
220
221
222 STRSET_GET
223 ==========
224
225 Requests contents of a string set as provided by ioctl commands
226 ``ETHTOOL_GSSET_INFO`` and ``ETHTOOL_GSTRINGS.`` String sets are not user
227 writeable so that the corresponding ``STRSET_SET`` message is only used in
228 kernel replies. There are two types of string sets: global (independent of
229 a device, e.g. device feature names) and device specific (e.g. device private
230 flags).
231
232 Request contents:
233
234  +---------------------------------------+--------+------------------------+
235  | ``ETHTOOL_A_STRSET_HEADER``           | nested | request header         |
236  +---------------------------------------+--------+------------------------+
237  | ``ETHTOOL_A_STRSET_STRINGSETS``       | nested | string set to request  |
238  +-+-------------------------------------+--------+------------------------+
239  | | ``ETHTOOL_A_STRINGSETS_STRINGSET+`` | nested | one string set         |
240  +-+-+-----------------------------------+--------+------------------------+
241  | | | ``ETHTOOL_A_STRINGSET_ID``        | u32    | set id                 |
242  +-+-+-----------------------------------+--------+------------------------+
243
244 Kernel response contents:
245
246  +---------------------------------------+--------+-----------------------+
247  | ``ETHTOOL_A_STRSET_HEADER``           | nested | reply header          |
248  +---------------------------------------+--------+-----------------------+
249  | ``ETHTOOL_A_STRSET_STRINGSETS``       | nested | array of string sets  |
250  +-+-------------------------------------+--------+-----------------------+
251  | | ``ETHTOOL_A_STRINGSETS_STRINGSET+`` | nested | one string set        |
252  +-+-+-----------------------------------+--------+-----------------------+
253  | | | ``ETHTOOL_A_STRINGSET_ID``        | u32    | set id                |
254  +-+-+-----------------------------------+--------+-----------------------+
255  | | | ``ETHTOOL_A_STRINGSET_COUNT``     | u32    | number of strings     |
256  +-+-+-----------------------------------+--------+-----------------------+
257  | | | ``ETHTOOL_A_STRINGSET_STRINGS``   | nested | array of strings      |
258  +-+-+-+---------------------------------+--------+-----------------------+
259  | | | | ``ETHTOOL_A_STRINGS_STRING+``   | nested | one string            |
260  +-+-+-+-+-------------------------------+--------+-----------------------+
261  | | | | | ``ETHTOOL_A_STRING_INDEX``    | u32    | string index          |
262  +-+-+-+-+-------------------------------+--------+-----------------------+
263  | | | | | ``ETHTOOL_A_STRING_VALUE``    | string | string value          |
264  +-+-+-+-+-------------------------------+--------+-----------------------+
265  | ``ETHTOOL_A_STRSET_COUNTS_ONLY``      | flag   | return only counts    |
266  +---------------------------------------+--------+-----------------------+
267
268 Device identification in request header is optional. Depending on its presence
269 a and ``NLM_F_DUMP`` flag, there are three type of ``STRSET_GET`` requests:
270
271  - no ``NLM_F_DUMP,`` no device: get "global" stringsets
272  - no ``NLM_F_DUMP``, with device: get string sets related to the device
273  - ``NLM_F_DUMP``, no device: get device related string sets for all devices
274
275 If there is no ``ETHTOOL_A_STRSET_STRINGSETS`` array, all string sets of
276 requested type are returned, otherwise only those specified in the request.
277 Flag ``ETHTOOL_A_STRSET_COUNTS_ONLY`` tells kernel to only return string
278 counts of the sets, not the actual strings.
279
280
281 Request translation
282 ===================
283
284 The following table maps ioctl commands to netlink commands providing their
285 functionality. Entries with "n/a" in right column are commands which do not
286 have their netlink replacement yet.
287
288   =================================== =====================================
289   ioctl command                       netlink command
290   =================================== =====================================
291   ``ETHTOOL_GSET``                    n/a
292   ``ETHTOOL_SSET``                    n/a
293   ``ETHTOOL_GDRVINFO``                n/a
294   ``ETHTOOL_GREGS``                   n/a
295   ``ETHTOOL_GWOL``                    n/a
296   ``ETHTOOL_SWOL``                    n/a
297   ``ETHTOOL_GMSGLVL``                 n/a
298   ``ETHTOOL_SMSGLVL``                 n/a
299   ``ETHTOOL_NWAY_RST``                n/a
300   ``ETHTOOL_GLINK``                   n/a
301   ``ETHTOOL_GEEPROM``                 n/a
302   ``ETHTOOL_SEEPROM``                 n/a
303   ``ETHTOOL_GCOALESCE``               n/a
304   ``ETHTOOL_SCOALESCE``               n/a
305   ``ETHTOOL_GRINGPARAM``              n/a
306   ``ETHTOOL_SRINGPARAM``              n/a
307   ``ETHTOOL_GPAUSEPARAM``             n/a
308   ``ETHTOOL_SPAUSEPARAM``             n/a
309   ``ETHTOOL_GRXCSUM``                 n/a
310   ``ETHTOOL_SRXCSUM``                 n/a
311   ``ETHTOOL_GTXCSUM``                 n/a
312   ``ETHTOOL_STXCSUM``                 n/a
313   ``ETHTOOL_GSG``                     n/a
314   ``ETHTOOL_SSG``                     n/a
315   ``ETHTOOL_TEST``                    n/a
316   ``ETHTOOL_GSTRINGS``                ``ETHTOOL_MSG_STRSET_GET``
317   ``ETHTOOL_PHYS_ID``                 n/a
318   ``ETHTOOL_GSTATS``                  n/a
319   ``ETHTOOL_GTSO``                    n/a
320   ``ETHTOOL_STSO``                    n/a
321   ``ETHTOOL_GPERMADDR``               rtnetlink ``RTM_GETLINK``
322   ``ETHTOOL_GUFO``                    n/a
323   ``ETHTOOL_SUFO``                    n/a
324   ``ETHTOOL_GGSO``                    n/a
325   ``ETHTOOL_SGSO``                    n/a
326   ``ETHTOOL_GFLAGS``                  n/a
327   ``ETHTOOL_SFLAGS``                  n/a
328   ``ETHTOOL_GPFLAGS``                 n/a
329   ``ETHTOOL_SPFLAGS``                 n/a
330   ``ETHTOOL_GRXFH``                   n/a
331   ``ETHTOOL_SRXFH``                   n/a
332   ``ETHTOOL_GGRO``                    n/a
333   ``ETHTOOL_SGRO``                    n/a
334   ``ETHTOOL_GRXRINGS``                n/a
335   ``ETHTOOL_GRXCLSRLCNT``             n/a
336   ``ETHTOOL_GRXCLSRULE``              n/a
337   ``ETHTOOL_GRXCLSRLALL``             n/a
338   ``ETHTOOL_SRXCLSRLDEL``             n/a
339   ``ETHTOOL_SRXCLSRLINS``             n/a
340   ``ETHTOOL_FLASHDEV``                n/a
341   ``ETHTOOL_RESET``                   n/a
342   ``ETHTOOL_SRXNTUPLE``               n/a
343   ``ETHTOOL_GRXNTUPLE``               n/a
344   ``ETHTOOL_GSSET_INFO``              ``ETHTOOL_MSG_STRSET_GET``
345   ``ETHTOOL_GRXFHINDIR``              n/a
346   ``ETHTOOL_SRXFHINDIR``              n/a
347   ``ETHTOOL_GFEATURES``               n/a
348   ``ETHTOOL_SFEATURES``               n/a
349   ``ETHTOOL_GCHANNELS``               n/a
350   ``ETHTOOL_SCHANNELS``               n/a
351   ``ETHTOOL_SET_DUMP``                n/a
352   ``ETHTOOL_GET_DUMP_FLAG``           n/a
353   ``ETHTOOL_GET_DUMP_DATA``           n/a
354   ``ETHTOOL_GET_TS_INFO``             n/a
355   ``ETHTOOL_GMODULEINFO``             n/a
356   ``ETHTOOL_GMODULEEEPROM``           n/a
357   ``ETHTOOL_GEEE``                    n/a
358   ``ETHTOOL_SEEE``                    n/a
359   ``ETHTOOL_GRSSH``                   n/a
360   ``ETHTOOL_SRSSH``                   n/a
361   ``ETHTOOL_GTUNABLE``                n/a
362   ``ETHTOOL_STUNABLE``                n/a
363   ``ETHTOOL_GPHYSTATS``               n/a
364   ``ETHTOOL_PERQUEUE``                n/a
365   ``ETHTOOL_GLINKSETTINGS``           n/a
366   ``ETHTOOL_SLINKSETTINGS``           n/a
367   ``ETHTOOL_PHY_GTUNABLE``            n/a
368   ``ETHTOOL_PHY_STUNABLE``            n/a
369   ``ETHTOOL_GFECPARAM``               n/a
370   ``ETHTOOL_SFECPARAM``               n/a
371   =================================== =====================================