home | list info | list archive | date index | thread index

how to (if proper) add more sysfs attribute files for a net IF?

  if i'm writing a network driver, is there an acceptable way to
add more sysfs attribute files for it if there are some novel and
unique data values i'd like to export to userspace?

  i notice that the standard contents under /sys/class/net/<IF>/
includes the directory "statistics", which contains the following
values:

-r--r--r--. 1 root root 4096 Sep 12 10:33 collisions
-r--r--r--. 1 root root 4096 Sep 12 10:33 multicast
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_bytes
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_compressed
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_crc_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_dropped
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_fifo_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_frame_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_length_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_missed_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_nohandler
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_over_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 rx_packets
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_aborted_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_bytes
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_carrier_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_compressed
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_dropped
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_fifo_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_heartbeat_errors
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_packets
-r--r--r--. 1 root root 4096 Sep 12 10:33 tx_window_errors

which appears to be defined by this from net/core/net-sysfs:

static struct attribute *netstat_attrs[] __ro_after_init = {
        &dev_attr_rx_packets.attr,
        &dev_attr_tx_packets.attr,
        &dev_attr_rx_bytes.attr,
        &dev_attr_tx_bytes.attr,
        &dev_attr_rx_errors.attr,
        &dev_attr_tx_errors.attr,
        &dev_attr_rx_dropped.attr,
        &dev_attr_tx_dropped.attr,
        &dev_attr_multicast.attr,
        &dev_attr_collisions.attr,
        &dev_attr_rx_length_errors.attr,
        &dev_attr_rx_over_errors.attr,
        &dev_attr_rx_crc_errors.attr,
        &dev_attr_rx_frame_errors.attr,
        &dev_attr_rx_fifo_errors.attr,
        &dev_attr_rx_missed_errors.attr,
        &dev_attr_tx_aborted_errors.attr,
        &dev_attr_tx_carrier_errors.attr,
        &dev_attr_tx_fifo_errors.attr,
        &dev_attr_tx_heartbeat_errors.attr,
        &dev_attr_tx_window_errors.attr,
        &dev_attr_rx_compressed.attr,
        &dev_attr_tx_compressed.attr,
        &dev_attr_rx_nohandler.attr,
        NULL
};

which is great, but let's say this driver had some unique value
i wanted to display, say, the current temperature of the warp core.

  is there a supported way to extend the statistics attribute files
for a specific driver that would not offend the sensibilities of
accomplished kernel programmers? or is that list meant to be the
canonical list displayed under statistics?

rday


To unsubscribe send a blank message to linux+unsubscribe [ at ] linux-ottawa [ dot ] org
To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
To visit the archives: https://lists.linux-ottawa.org

message navigation