ethtool.h 11.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9
/*
 * ethtool.h: Defines for Linux ethtool.
 *
 * Copyright (C) 1998 David S. Miller (davem@redhat.com)
 * Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
 * Portions Copyright 2001 Sun Microsystems (thockin@sun.com)
 * Portions Copyright 2002 Intel (eli.kupermann@intel.com,
 *                                christopher.leech@intel.com,
 *                                scott.feldman@intel.com)
10
 * Portions Copyright (C) Sun Microsystems 2008
L
Linus Torvalds 已提交
11 12 13 14
 */
#ifndef _LINUX_ETHTOOL_H
#define _LINUX_ETHTOOL_H

15
#include <linux/compat.h>
16
#include <uapi/linux/ethtool.h>
17

18 19 20 21
#ifdef CONFIG_COMPAT

struct compat_ethtool_rx_flow_spec {
	u32		flow_type;
22 23 24 25
	union ethtool_flow_union h_u;
	struct ethtool_flow_ext h_ext;
	union ethtool_flow_union m_u;
	struct ethtool_flow_ext m_ext;
26 27 28 29 30 31 32 33 34 35 36 37 38 39
	compat_u64	ring_cookie;
	u32		location;
};

struct compat_ethtool_rxnfc {
	u32				cmd;
	u32				flow_type;
	compat_u64			data;
	struct compat_ethtool_rx_flow_spec fs;
	u32				rule_cnt;
	u32				rule_locs[0];
};

#endif /* CONFIG_COMPAT */
40

41 42
#include <linux/rculist.h>

43 44 45
extern int __ethtool_get_settings(struct net_device *dev,
				  struct ethtool_cmd *cmd);

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
/**
 * enum ethtool_phys_id_state - indicator state for physical identification
 * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
 * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
 * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
 *	is not supported)
 * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
 *	is not supported)
 */
enum ethtool_phys_id_state {
	ETHTOOL_ID_INACTIVE,
	ETHTOOL_ID_ACTIVE,
	ETHTOOL_ID_ON,
	ETHTOOL_ID_OFF
};

L
Linus Torvalds 已提交
62 63 64 65
struct net_device;

/* Some generic methods drivers may use in their ethtool_ops */
u32 ethtool_op_get_link(struct net_device *dev);
66
int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
L
Linus Torvalds 已提交
67

68 69 70 71 72 73 74 75 76 77 78 79
/**
 * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
 * @index: Index in RX flow hash indirection table
 * @n_rx_rings: Number of RX rings to use
 *
 * This function provides the default policy for RX flow hash indirection.
 */
static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
{
	return index % n_rx_rings;
}

L
Linus Torvalds 已提交
80
/**
81 82
 * struct ethtool_ops - optional netdev operations
 * @get_settings: Get various device settings including Ethernet link
83 84 85
 *	settings. The @cmd parameter is expected to have been cleared
 *	before get_settings is called. Returns a negative error code or
 *	zero.
86 87 88 89 90 91 92
 * @set_settings: Set various device settings including Ethernet link
 *	settings.  Returns a negative error code or zero.
 * @get_drvinfo: Report driver/device information.  Should only set the
 *	@driver, @version, @fw_version and @bus_info fields.  If not
 *	implemented, the @driver and @bus_info fields will be filled in
 *	according to the netdev's parent device.
 * @get_regs_len: Get buffer length required for @get_regs
93 94
 * @get_regs: Get device registers
 * @get_wol: Report whether Wake-on-Lan is enabled
95 96 97 98
 * @set_wol: Turn Wake-on-Lan on or off.  Returns a negative error code
 *	or zero.
 * @get_msglevel: Report driver message level.  This should be the value
 *	of the @msg_enable field used by netif logging functions.
99
 * @set_msglevel: Set driver message level
100 101 102 103 104
 * @nway_reset: Restart autonegotiation.  Returns a negative error code
 *	or zero.
 * @get_link: Report whether physical link is up.  Will only be called if
 *	the netdev is up.  Should usually be set to ethtool_op_get_link(),
 *	which uses netif_carrier_ok().
105
 * @get_eeprom: Read data from the device EEPROM.
L
Linus Torvalds 已提交
106 107 108 109
 *	Should fill in the magic field.  Don't need to check len for zero
 *	or wraparound.  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.
110
 * @set_eeprom: Write data to the device EEPROM.
L
Linus Torvalds 已提交
111 112 113
 *	Should validate the magic field.  Don't need to check len for zero
 *	or wraparound.  Update len to the amount written.  Returns an error
 *	or zero.
114 115 116 117
 * @get_coalesce: Get interrupt coalescing parameters.  Returns a negative
 *	error code or zero.
 * @set_coalesce: Set interrupt coalescing parameters.  Returns a negative
 *	error code or zero.
118
 * @get_ringparam: Report ring sizes
119
 * @set_ringparam: Set ring sizes.  Returns a negative error code or zero.
120
 * @get_pauseparam: Report pause parameters
121 122
 * @set_pauseparam: Set pause parameters.  Returns a negative error code
 *	or zero.
123 124
 * @self_test: Run specified self-tests
 * @get_strings: Return a set of strings that describe the requested objects
125 126 127 128
 * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
 *	attached to it.  The implementation may update the indicator
 *	asynchronously or synchronously, but in either case it must return
 *	quickly.  It is initially called with the argument %ETHTOOL_ID_ACTIVE,
129 130 131 132
 *	and must either activate asynchronous updates and return zero, return
 *	a negative error or return a positive frequency for synchronous
 *	indication (e.g. 1 for one on/off cycle per second).  If it returns
 *	a frequency then it will be called again at intervals with the
133 134 135 136
 *	argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
 *	the indicator accordingly.  Finally, it is called with the argument
 *	%ETHTOOL_ID_INACTIVE and must deactivate the indicator.  Returns a
 *	negative error code or zero.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
 * @get_ethtool_stats: Return extended statistics about the device.
 *	This is only useful if the device maintains statistics not
 *	included in &struct rtnl_link_stats64.
 * @begin: Function to be called before any other operation.  Returns a
 *	negative error code or zero.
 * @complete: Function to be called after any other operation except
 *	@begin.  Will be called even if the other operation failed.
 * @get_priv_flags: Report driver-specific feature flags.
 * @set_priv_flags: Set driver-specific feature flags.  Returns a negative
 *	error code or zero.
 * @get_sset_count: Get number of strings that @get_strings will write.
 * @get_rxnfc: Get RX flow classification rules.  Returns a negative
 *	error code or zero.
 * @set_rxnfc: Set RX flow classification rules.  Returns a negative
 *	error code or zero.
 * @flash_device: Write a firmware image to device's flash memory.
 *	Returns a negative error code or zero.
 * @reset: Reset (part of) the device, as specified by a bitmask of
 *	flags from &enum ethtool_reset_flags.  Returns a negative
 *	error code or zero.
157 158
 * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
 *	Returns zero if not supported for this specific device.
159
 * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
160
 *	Will not be called if @get_rxfh_indir_size returns zero.
161 162
 *	Returns a negative error code or zero.
 * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
163
 *	Will not be called if @get_rxfh_indir_size returns zero.
164
 *	Returns a negative error code or zero.
165 166 167
 * @get_channels: Get number of channels.
 * @set_channels: Set number of channels.  Returns a negative error code or
 *	zero.
168 169 170 171
 * @get_dump_flag: Get dump flag indicating current dump length, version,
 * 		   and flag of the device.
 * @get_dump_data: Get dump data.
 * @set_dump: Set dump specific flags to the device.
172 173 174
 * @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
 *	Drivers supporting transmit time stamps in software should set this to
 *	ethtool_op_get_ts_info().
175 176 177
 * @get_module_info: Get the size and type of the eeprom contained within
 *	a plug-in module.
 * @get_module_eeprom: Get the eeprom information from the plug-in module
178 179
 * @get_eee: Get Energy-Efficient (EEE) supported and status.
 * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
180 181 182
 *
 * All operations are optional (i.e. the function pointer may be set
 * to %NULL) and callers must take this into account.  Callers must
183
 * hold the RTNL lock.
184 185
 *
 * See the structures used by these operations for further documentation.
186 187 188
 * Note that for all operations using a structure ending with a zero-
 * length array, the array is allocated separately in the kernel and
 * is passed to the driver as an additional parameter.
189 190 191
 *
 * See &struct net_device and &struct net_device_ops for documentation
 * of the generic netdev features interface.
L
Linus Torvalds 已提交
192 193 194 195 196 197 198 199 200 201 202 203 204 205
 */
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_len)(struct net_device *);
206 207 208 209
	int	(*get_eeprom)(struct net_device *,
			      struct ethtool_eeprom *, u8 *);
	int	(*set_eeprom)(struct net_device *,
			      struct ethtool_eeprom *, u8 *);
L
Linus Torvalds 已提交
210 211
	int	(*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
	int	(*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
212 213 214 215 216 217 218 219
	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*);
L
Linus Torvalds 已提交
220 221
	void	(*self_test)(struct net_device *, struct ethtool_test *, u64 *);
	void	(*get_strings)(struct net_device *, u32 stringset, u8 *);
222
	int	(*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
223 224
	void	(*get_ethtool_stats)(struct net_device *,
				     struct ethtool_stats *, u64 *);
L
Linus Torvalds 已提交
225 226
	int	(*begin)(struct net_device *);
	void	(*complete)(struct net_device *);
227 228
	u32	(*get_priv_flags)(struct net_device *);
	int	(*set_priv_flags)(struct net_device *, u32);
229
	int	(*get_sset_count)(struct net_device *, int);
230
	int	(*get_rxnfc)(struct net_device *,
231
			     struct ethtool_rxnfc *, u32 *rule_locs);
232
	int	(*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
233
	int	(*flash_device)(struct net_device *, struct ethtool_flash *);
B
Ben Hutchings 已提交
234
	int	(*reset)(struct net_device *, u32 *);
235 236 237
	u32	(*get_rxfh_indir_size)(struct net_device *);
	int	(*get_rxfh_indir)(struct net_device *, u32 *);
	int	(*set_rxfh_indir)(struct net_device *, const u32 *);
238 239
	void	(*get_channels)(struct net_device *, struct ethtool_channels *);
	int	(*set_channels)(struct net_device *, struct ethtool_channels *);
240 241 242 243
	int	(*get_dump_flag)(struct net_device *, struct ethtool_dump *);
	int	(*get_dump_data)(struct net_device *,
				 struct ethtool_dump *, void *);
	int	(*set_dump)(struct net_device *, struct ethtool_dump *);
244
	int	(*get_ts_info)(struct net_device *, struct ethtool_ts_info *);
245 246 247 248
	int     (*get_module_info)(struct net_device *,
				   struct ethtool_modinfo *);
	int     (*get_module_eeprom)(struct net_device *,
				     struct ethtool_eeprom *, u8 *);
249 250
	int	(*get_eee)(struct net_device *, struct ethtool_eee *);
	int	(*set_eee)(struct net_device *, struct ethtool_eee *);
251

252

L
Linus Torvalds 已提交
253 254
};
#endif /* _LINUX_ETHTOOL_H */