Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

linux - What is ethtool and is it important for usable ethernet NIC. Can I remove it from device driver and still able to use network

I am studying realtek device driver and came across ethtool operations like ethtool_ops there are many operation included in the operations object. Following is the code

        static const struct ethtool_ops rtl8169_ethtool_ops = {
                .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
                                 ETHTOOL_COALESCE_MAX_FRAMES,
                .get_drvinfo        = rtl8169_get_drvinfo,
                .get_regs_len       = rtl8169_get_regs_len,
                .get_link       = ethtool_op_get_link,
                .get_coalesce       = rtl_get_coalesce,
                .set_coalesce       = rtl_set_coalesce,
                .get_regs       = rtl8169_get_regs,
                .get_wol        = rtl8169_get_wol,
                .set_wol        = rtl8169_set_wol,
                .get_strings        = rtl8169_get_strings,
                .get_sset_count     = rtl8169_get_sset_count,
                .get_ethtool_stats  = rtl8169_get_ethtool_stats,
                .get_ts_info        = ethtool_op_get_ts_info,
                .nway_reset     = phy_ethtool_nway_reset,
                .get_eee        = rtl8169_get_eee,
                .set_eee        = rtl8169_set_eee,
                .get_link_ksettings = phy_ethtool_get_link_ksettings,
                .set_link_ksettings = phy_ethtool_set_link_ksettings,
                };

What are these operations

for example there is eee mentioned so I am interested in what its matching functionality with higher level layers like ip or tcp.

What are these: coalesce, wol, stats, ksettings, ts_info and eee from list above. I believe they have something to do with physical layer of OSI model, But if u can give me what higher level functions they achieve. For each these functions matching high level brief info will be great

For example wol is something like

Wake-on-LAN is an Ethernet or Token Ring computer networking standard that allows a computer to be turned on or awakened by a network message. > The message is usually sent to the target computer by a program executed > on a device connected to the same local area network, such as a smartphone. Wikipedia

And Coalese is

Packet coalescing is the grouping of packets as a way of limiting the number of receive interrupts and, as a result, lowering the amount of processing required.

Just give me some technical info on kernel api about these functions. Thanks

question from:https://stackoverflow.com/questions/66063229/what-is-ethtool-and-is-it-important-for-usable-ethernet-nic-can-i-remove-it-fro

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Long story short, ethtool is a means to display and adjust generic NIC/driver parameters (identification, the number of receive and transmit queues, receive and transmit offloads, you name it) in a userspace application. On the one side, there's kernel API which a NIC driver is connected to (in particular, by means of struct ethtool_ops). On the other side, there's an ioctl command named SIOCETHTOOL which a userspace application can use to send requests to the kernel side and get responses.

Sub-identifiers enumerating specific commands for SIOCETHTOOL exist, and they correspond to the methods of struct ethtool_ops. From the question of yours it follows that it's struct ethtool_ops that should be explained.

I suggest that you take a look at include/linux/ethtool.h. There's a comment section right before the definition of struct ethtool_ops. In particular:

 * @get_wol: Report whether Wake-on-Lan is enabled
 * @set_wol: Turn Wake-on-Lan on or off.  Returns a negative error code
 * @get_coalesce: Get interrupt coalescing parameters.  Returns a negative
 *  error code or zero.
 * @set_coalesce: Set interrupt coalescing parameters.  Supported coalescing
 *  types should be set in @supported_coalesce_params.
 *  Returns a negative error code or zero.
 * @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
 *  Drivers supporting transmit time stamps in software should set this to
 *  ethtool_op_get_ts_info().
 * @get_eee: Get Energy-Efficient (EEE) supported and status.
 * @set_eee: Set EEE status (enable/disable) as well as LPI timers.

For WoL feature and interrupt coalescing, these brief comments mostly match the explanations in the question of yours. The rest of the comments in the header file are also of great use. You may refer to them to get the gist.

It may also come in handy to take a look at ethtool mechanism from the userspace perspective. The most commonly used userspace application to use ethtool mechanism is also named ethtool; it's available as a package in popular distributions (Debian, Ubuntu, you name it). It's the man page of the package which contains useful information. In example:

ethtool -c|--show-coalesce devname

ethtool -C|--coalesce devname [adaptive-rx on|off]
      [adaptive-tx on|off] [rx-usecs N] [rx-frames N]
      [rx-usecs-irq N] [rx-frames-irq N] [tx-usecs N]
      [tx-frames N] [tx-usecs-irq N] [tx-frames-irq N]
      [stats-block-usecs N] [pkt-rate-low N] [rx-usecs-low N]
      [rx-frames-low N] [tx-usecs-low N] [tx-frames-low N]
      [pkt-rate-high N] [rx-usecs-high N] [rx-frames-high N]
      [tx-usecs-high N] [tx-frames-high N] [sample-interval N]
-c --show-coalesce
      Queries the specified network device for coalescing
      information.

-C --coalesce
      Changes the coalescing settings of the specified network
      device.

All in all, there might be quite a few places which you may take a look at to clarify the meaning of ethtool commands/methods. These commands (as well as the features they serve) do not necessarily have something to do with the physical layer of OSI model. Some may be out of scope of the OSI model (like device identification); some may correspond to higher levels of the OSI model, in example, controls for packet offloads like TCP segmentation offload, RSS (Receive Side Scaling), etc. A particular feature can be discussed separately should the need arise.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...