Commit f7126cc7 authored by Jeff Garzik's avatar Jeff Garzik

[netdrvr] add ethtool_ops to struct net_device, and associated infrastructure

Contributed by Matthew Wilcox.
parent 29fa971b
......@@ -97,7 +97,7 @@ struct ethtool_coalesce {
u32 rx_max_coalesced_frames;
/* Same as above two parameters, except that these values
* apply while an IRQ is being services by the host. Not
* apply while an IRQ is being serviced by the host. Not
* all cards support this feature and the values are ignored
* in that case.
*/
......@@ -119,7 +119,7 @@ struct ethtool_coalesce {
u32 tx_max_coalesced_frames;
/* Same as above two parameters, except that these values
* apply while an IRQ is being services by the host. Not
* apply while an IRQ is being serviced by the host. Not
* all cards support this feature and the values are ignored
* in that case.
*/
......@@ -250,6 +250,101 @@ struct ethtool_stats {
u64 data[0];
};
struct net_device;
/* Some generic methods drivers may use in their ethtool_ops */
u32 ethtool_op_get_link(struct net_device *dev);
u32 ethtool_op_get_tx_csum(struct net_device *dev);
u32 ethtool_op_get_sg(struct net_device *dev);
int ethtool_op_set_sg(struct net_device *dev, u32 data);
/**
* &ethtool_ops - Alter and report network device settings
* get_settings: Get device-specific settings
* set_settings: Set device-specific settings
* get_drvinfo: Report driver information
* get_regs: Get device registers
* get_wol: Report whether Wake-on-Lan is enabled
* set_wol: Turn Wake-on-Lan on or off
* get_msglevel: Report driver message level
* set_msglevel: Set driver message level
* nway_reset: Restart autonegotiation
* get_link: Get link status
* get_eeprom: Read data from the device EEPROM
* set_eeprom: Write data to the device EEPROM
* get_coalesce: Get interrupt coalescing parameters
* set_coalesce: Set interrupt coalescing parameters
* get_ringparam: Report ring sizes
* set_ringparam: Set ring sizes
* get_pauseparam: Report pause parameters
* set_pauseparam: Set pause paramters
* get_rx_csum: Report whether receive checksums are turned on or off
* set_rx_csum: Turn receive checksum on or off
* get_tx_csum: Report whether transmit checksums are turned on or off
* set_tx_csum: Turn transmit checksums on or off
* get_sg: Report whether scatter-gather is enabled
* set_sg: Turn scatter-gather on or off
* self_test: Run specified self-tests
* get_strings: Return a set of strings that describe the requested objects
* phys_id: Identify the device
* get_stats: Return statistics about the device
*
* Description:
*
* get_settings:
* @get_settings is passed an &ethtool_cmd to fill in. It returns
* an negative errno or zero.
*
* set_settings:
* @set_settings is passed an &ethtool_cmd and should attempt to set
* all the settings this device supports. It may return an error value
* if something goes wrong (otherwise 0).
*
* get_eeprom:
* Should fill in the magic field. Don't need to check len for zero
* or wraparound but must check offset + len < size. Fill in the data
* argument with the eeprom values from offset to offset + len. Update
* len to the amount read. Returns an error or zero.
*
* set_eeprom:
* Should validate the magic field. Don't need to check len for zero
* or wraparound but must check offset + len < size. Update len to
* the amount written. Returns an error or zero.
*/
struct ethtool_ops {
int (*get_settings)(struct net_device *, struct ethtool_cmd *);
int (*set_settings)(struct net_device *, struct ethtool_cmd *);
void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
int (*get_regs_len)(struct net_device *);
void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
int (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
u32 (*get_msglevel)(struct net_device *);
void (*set_msglevel)(struct net_device *, u32);
int (*nway_reset)(struct net_device *);
u32 (*get_link)(struct net_device *);
int (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
int (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
void (*get_ringparam)(struct net_device *, struct ethtool_ringparam *);
int (*set_ringparam)(struct net_device *, struct ethtool_ringparam *);
void (*get_pauseparam)(struct net_device *, struct ethtool_pauseparam*);
int (*set_pauseparam)(struct net_device *, struct ethtool_pauseparam*);
u32 (*get_rx_csum)(struct net_device *);
int (*set_rx_csum)(struct net_device *, u32);
u32 (*get_tx_csum)(struct net_device *);
int (*set_tx_csum)(struct net_device *, u32);
u32 (*get_sg)(struct net_device *);
int (*set_sg)(struct net_device *, u32);
int (*self_test_count)(struct net_device *);
void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
void (*get_strings)(struct net_device *, u32 stringset, u8 *);
int (*phys_id)(struct net_device *, u32);
int (*get_stats_count)(struct net_device *);
void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *, u64 *);
};
/* CMDs currently supported */
#define ETHTOOL_GSET 0x00000001 /* Get settings. */
#define ETHTOOL_SSET 0x00000002 /* Set settings. */
......
......@@ -43,6 +43,7 @@
struct divert_blk;
struct vlan_group;
struct ethtool_ops;
#define HAVE_ALLOC_NETDEV /* feature macro: alloc_xxxdev
functions are available. */
......@@ -300,6 +301,8 @@ struct net_device
* See <net/iw_handler.h> for details. Jean II */
struct iw_handler_def * wireless_handlers;
struct ethtool_ops *ethtool_ops;
/*
* This marks the end of the "visible" part of the structure. All
* fields hereafter are internal to the system, and may change at
......@@ -485,7 +488,6 @@ struct packet_type
struct list_head list;
};
#include <linux/interrupt.h>
#include <linux/notifier.h>
......@@ -633,6 +635,7 @@ extern int netif_rx(struct sk_buff *skb);
#define HAVE_NETIF_RECEIVE_SKB 1
extern int netif_receive_skb(struct sk_buff *skb);
extern int dev_ioctl(unsigned int cmd, void *);
extern int dev_ethtool(struct ifreq *);
extern unsigned dev_get_flags(const struct net_device *);
extern int dev_change_flags(struct net_device *, unsigned);
extern int dev_set_mtu(struct net_device *, int);
......
......@@ -6,8 +6,8 @@ obj-y := sock.o skbuff.o iovec.o datagram.o scm.o
obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
obj-y += flow.o dev.o net-sysfs.o dev_mcast.o dst.o neighbour.o \
rtnetlink.o utils.o link_watch.o filter.o
obj-y += flow.o dev.o ethtool.o net-sysfs.o dev_mcast.o dst.o \
neighbour.o rtnetlink.o utils.o link_watch.o filter.o
obj-$(CONFIG_NETFILTER) += netfilter.o
obj-$(CONFIG_NET_DIVERT) += dv.o
......
......@@ -2365,7 +2365,6 @@ static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd)
cmd == SIOCBONDSLAVEINFOQUERY ||
cmd == SIOCBONDINFOQUERY ||
cmd == SIOCBONDCHANGEACTIVE ||
cmd == SIOCETHTOOL ||
cmd == SIOCGMIIPHY ||
cmd == SIOCGMIIREG ||
cmd == SIOCSMIIREG ||
......@@ -2462,13 +2461,26 @@ int dev_ioctl(unsigned int cmd, void *arg)
}
return ret;
case SIOCETHTOOL:
dev_load(ifr.ifr_name);
rtnl_lock();
ret = dev_ethtool(&ifr);
rtnl_unlock();
if (!ret) {
if (colon)
*colon = ':';
if (copy_to_user(arg, &ifr,
sizeof(struct ifreq)))
ret = -EFAULT;
}
return ret;
/*
* These ioctl calls:
* - require superuser power.
* - require strict serialization.
* - return a value
*/
case SIOCETHTOOL:
case SIOCGMIIPHY:
case SIOCGMIIREG:
if (!capable(CAP_NET_ADMIN))
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment