Re: Struct net_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I am really not sure what is required here. Please see if below info.
> helps (not an expert comment, though :)).
> You can get the netdev struct of the interface by name:
>
> struct net_device *netdev = dev_get_by_name("eth0"); // when
> netdev->name is eth0.
> struct e1000_adapter *adapter = netdev_priv(netdev); // obtain the
> adapter.
>

Or possible you want the net_device_stats.  Here is how to obtain them
in the aforementioned driver once you have obtained a pointer to the
struct net_device.

/**
 * e1000_get_stats - Get System Network Statistics
 * @netdev: network interface device structure
 *
 * Returns the address of the device statistics structure.
 * The statistics are actually updated from the timer callback.
 **/
static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
{
        /* only return the current stats */
        return &netdev->stats;
}

Obviously, you also should look at the file include/linux/netdevice.h

--
John

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux