简体   繁体   中英

how to write per-channel attribute in sysfs

I am going to write a network device driver, which supports multiple channels.

Now, I am going to write the some counters (such as bytes/packets transferred) of this channel to sysfs .

For example, this device opens 8 channels, then, I would like to have sysfs like this:

/sys/devices/mynetdev/channel_0/
______________________________/bytes_egress
/sys/devices/mynetdev/channel_1/
______________________________/bytes_egress
/sys/devices/mynetdev/channel_2/
______________________________/bytes_egress
...

Questions:

  1. How to create the attribute group so that I have one folder per channel?
  2. Looks like I need to associate the attribute group before device registering. Then when do I update those attributes? Updating the attribute may impact the network performance?
  3. How does the "attribute" work? For example, when user query the sysfs from cat command, does it issue command to driver to get attribute updated? Or my driver will keep updating the attribute and cat command just query the value?

Thanks!

set .modified field of iio_chan_spec to 1. Modifiers are specified using .channel2 field of the same iio_chan_spec structure and are used to indicate a physically unique characteristic of the channel such as its direction or spectral response. For example, a light sensor can have two channels, one for infrared light and one for both infrared and visible light.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM