Michal Kubecek | 2b4a899 | 2019-12-27 15:55:18 +0100 | [diff] [blame] | 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 | List of message types |
| 80 | ===================== |
| 81 | |
| 82 | All constants identifying message types use ``ETHTOOL_CMD_`` prefix and suffix |
| 83 | according to message purpose: |
| 84 | |
| 85 | ============== ====================================== |
| 86 | ``_GET`` userspace request to retrieve data |
| 87 | ``_SET`` userspace request to set data |
| 88 | ``_ACT`` userspace request to perform an action |
| 89 | ``_GET_REPLY`` kernel reply to a ``GET`` request |
| 90 | ``_SET_REPLY`` kernel reply to a ``SET`` request |
| 91 | ``_ACT_REPLY`` kernel reply to an ``ACT`` request |
| 92 | ``_NTF`` kernel notification |
| 93 | ============== ====================================== |
| 94 | |
| 95 | ``GET`` requests are sent by userspace applications to retrieve device |
| 96 | information. They usually do not contain any message specific attributes. |
| 97 | Kernel replies with corresponding "GET_REPLY" message. For most types, ``GET`` |
| 98 | request with ``NLM_F_DUMP`` and no device identification can be used to query |
| 99 | the information for all devices supporting the request. |
| 100 | |
| 101 | If the data can be also modified, corresponding ``SET`` message with the same |
| 102 | layout as corresponding ``GET_REPLY`` is used to request changes. Only |
| 103 | attributes where a change is requested are included in such request (also, not |
| 104 | all attributes may be changed). Replies to most ``SET`` request consist only |
| 105 | of error code and extack; if kernel provides additional data, it is sent in |
| 106 | the form of corresponding ``SET_REPLY`` message which can be suppressed by |
| 107 | setting ``ETHTOOL_FLAG_OMIT_REPLY`` flag in request header. |
| 108 | |
| 109 | Data modification also triggers sending a ``NTF`` message with a notification. |
| 110 | These usually bear only a subset of attributes which was affected by the |
| 111 | change. The same notification is issued if the data is modified using other |
| 112 | means (mostly ioctl ethtool interface). Unlike notifications from ethtool |
| 113 | netlink code which are only sent if something actually changed, notifications |
| 114 | triggered by ioctl interface may be sent even if the request did not actually |
| 115 | change any data. |
| 116 | |
| 117 | ``ACT`` messages request kernel (driver) to perform a specific action. If some |
| 118 | information is reported by kernel (which can be suppressed by setting |
| 119 | ``ETHTOOL_FLAG_OMIT_REPLY`` flag in request header), the reply takes form of |
| 120 | an ``ACT_REPLY`` message. Performing an action also triggers a notification |
| 121 | (``NTF`` message). |
| 122 | |
| 123 | Later sections describe the format and semantics of these messages. |
| 124 | |
| 125 | |
| 126 | Request translation |
| 127 | =================== |
| 128 | |
| 129 | The following table maps ioctl commands to netlink commands providing their |
| 130 | functionality. Entries with "n/a" in right column are commands which do not |
| 131 | have their netlink replacement yet. |
| 132 | |
| 133 | =================================== ===================================== |
| 134 | ioctl command netlink command |
| 135 | =================================== ===================================== |
| 136 | ``ETHTOOL_GSET`` n/a |
| 137 | ``ETHTOOL_SSET`` n/a |
| 138 | ``ETHTOOL_GDRVINFO`` n/a |
| 139 | ``ETHTOOL_GREGS`` n/a |
| 140 | ``ETHTOOL_GWOL`` n/a |
| 141 | ``ETHTOOL_SWOL`` n/a |
| 142 | ``ETHTOOL_GMSGLVL`` n/a |
| 143 | ``ETHTOOL_SMSGLVL`` n/a |
| 144 | ``ETHTOOL_NWAY_RST`` n/a |
| 145 | ``ETHTOOL_GLINK`` n/a |
| 146 | ``ETHTOOL_GEEPROM`` n/a |
| 147 | ``ETHTOOL_SEEPROM`` n/a |
| 148 | ``ETHTOOL_GCOALESCE`` n/a |
| 149 | ``ETHTOOL_SCOALESCE`` n/a |
| 150 | ``ETHTOOL_GRINGPARAM`` n/a |
| 151 | ``ETHTOOL_SRINGPARAM`` n/a |
| 152 | ``ETHTOOL_GPAUSEPARAM`` n/a |
| 153 | ``ETHTOOL_SPAUSEPARAM`` n/a |
| 154 | ``ETHTOOL_GRXCSUM`` n/a |
| 155 | ``ETHTOOL_SRXCSUM`` n/a |
| 156 | ``ETHTOOL_GTXCSUM`` n/a |
| 157 | ``ETHTOOL_STXCSUM`` n/a |
| 158 | ``ETHTOOL_GSG`` n/a |
| 159 | ``ETHTOOL_SSG`` n/a |
| 160 | ``ETHTOOL_TEST`` n/a |
| 161 | ``ETHTOOL_GSTRINGS`` n/a |
| 162 | ``ETHTOOL_PHYS_ID`` n/a |
| 163 | ``ETHTOOL_GSTATS`` n/a |
| 164 | ``ETHTOOL_GTSO`` n/a |
| 165 | ``ETHTOOL_STSO`` n/a |
| 166 | ``ETHTOOL_GPERMADDR`` rtnetlink ``RTM_GETLINK`` |
| 167 | ``ETHTOOL_GUFO`` n/a |
| 168 | ``ETHTOOL_SUFO`` n/a |
| 169 | ``ETHTOOL_GGSO`` n/a |
| 170 | ``ETHTOOL_SGSO`` n/a |
| 171 | ``ETHTOOL_GFLAGS`` n/a |
| 172 | ``ETHTOOL_SFLAGS`` n/a |
| 173 | ``ETHTOOL_GPFLAGS`` n/a |
| 174 | ``ETHTOOL_SPFLAGS`` n/a |
| 175 | ``ETHTOOL_GRXFH`` n/a |
| 176 | ``ETHTOOL_SRXFH`` n/a |
| 177 | ``ETHTOOL_GGRO`` n/a |
| 178 | ``ETHTOOL_SGRO`` n/a |
| 179 | ``ETHTOOL_GRXRINGS`` n/a |
| 180 | ``ETHTOOL_GRXCLSRLCNT`` n/a |
| 181 | ``ETHTOOL_GRXCLSRULE`` n/a |
| 182 | ``ETHTOOL_GRXCLSRLALL`` n/a |
| 183 | ``ETHTOOL_SRXCLSRLDEL`` n/a |
| 184 | ``ETHTOOL_SRXCLSRLINS`` n/a |
| 185 | ``ETHTOOL_FLASHDEV`` n/a |
| 186 | ``ETHTOOL_RESET`` n/a |
| 187 | ``ETHTOOL_SRXNTUPLE`` n/a |
| 188 | ``ETHTOOL_GRXNTUPLE`` n/a |
| 189 | ``ETHTOOL_GSSET_INFO`` n/a |
| 190 | ``ETHTOOL_GRXFHINDIR`` n/a |
| 191 | ``ETHTOOL_SRXFHINDIR`` n/a |
| 192 | ``ETHTOOL_GFEATURES`` n/a |
| 193 | ``ETHTOOL_SFEATURES`` n/a |
| 194 | ``ETHTOOL_GCHANNELS`` n/a |
| 195 | ``ETHTOOL_SCHANNELS`` n/a |
| 196 | ``ETHTOOL_SET_DUMP`` n/a |
| 197 | ``ETHTOOL_GET_DUMP_FLAG`` n/a |
| 198 | ``ETHTOOL_GET_DUMP_DATA`` n/a |
| 199 | ``ETHTOOL_GET_TS_INFO`` n/a |
| 200 | ``ETHTOOL_GMODULEINFO`` n/a |
| 201 | ``ETHTOOL_GMODULEEEPROM`` n/a |
| 202 | ``ETHTOOL_GEEE`` n/a |
| 203 | ``ETHTOOL_SEEE`` n/a |
| 204 | ``ETHTOOL_GRSSH`` n/a |
| 205 | ``ETHTOOL_SRSSH`` n/a |
| 206 | ``ETHTOOL_GTUNABLE`` n/a |
| 207 | ``ETHTOOL_STUNABLE`` n/a |
| 208 | ``ETHTOOL_GPHYSTATS`` n/a |
| 209 | ``ETHTOOL_PERQUEUE`` n/a |
| 210 | ``ETHTOOL_GLINKSETTINGS`` n/a |
| 211 | ``ETHTOOL_SLINKSETTINGS`` n/a |
| 212 | ``ETHTOOL_PHY_GTUNABLE`` n/a |
| 213 | ``ETHTOOL_PHY_STUNABLE`` n/a |
| 214 | ``ETHTOOL_GFECPARAM`` n/a |
| 215 | ``ETHTOOL_SFECPARAM`` n/a |
| 216 | =================================== ===================================== |