how can I determine a network device speed from a linux kernel module -


I have a Linux kernel module, which can get the speed of a given network interface (i.e. "eth0"). How do I get speed (configure / conversations) for Linux 2.6.31?

Each network driver has an "aththol" implementation for such features but you probably need a generic function Which can give you speed for the normal genetic neteve straight. You can see and see how it implements the / sys / class / net interface. For example:

  static ssize_t show_speed (straight device * dev, struct device_attribute * attr, char * buf) {struct net_device * netdev = to_net_dev (dev); Int ret = -EINVAL; If (! Rtnl_trylock ()) return restart_syscall (); If (netif_ring (netdiv) and net dave-> athlete_ops and net dav-> gtc- gt; gt; gt; & gt; gate_settings) {struct ethtool_cmd cmd = {ETHTOOL_GSET}; If (! Netdev-> Estholeopes-> Get_settings (netdev, & CMD)) ret = sprintf (buf, fmt_dec, ethtool_cmd_speed (& amp; cmd)); } Rtnl_unlock (); Return writ; }  

Comments