netdevice.h 114 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3 4 5 6 7 8 9
/*
 * INET		An implementation of the TCP/IP protocol suite for the LINUX
 *		operating system.  INET is implemented using the  BSD Socket
 *		interface as the means of communication with the user level.
 *
 *		Definitions for the Interfaces handler.
 *
 * Version:	@(#)dev.h	1.0.10	08/12/93
 *
10
 * Authors:	Ross Biro
Linus Torvalds's avatar
Linus Torvalds committed
11 12 13
 *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
 *		Corey Minyard <wf-rch!minyard@relay.EU.net>
 *		Donald J. Becker, <becker@cesdis.gsfc.nasa.gov>
14
 *		Alan Cox, <alan@lxorguk.ukuu.org.uk>
Linus Torvalds's avatar
Linus Torvalds committed
15 16 17 18 19 20 21 22 23 24 25 26 27
 *		Bjorn Ekwall. <bj0rn@blox.se>
 *              Pekka Riikonen <priikone@poseidon.pspt.fi>
 *
 *		This program is free software; you can redistribute it and/or
 *		modify it under the terms of the GNU General Public License
 *		as published by the Free Software Foundation; either version
 *		2 of the License, or (at your option) any later version.
 *
 *		Moved to /usr/include/linux for NET3
 */
#ifndef _LINUX_NETDEVICE_H
#define _LINUX_NETDEVICE_H

28
#include <linux/pm_qos.h>
Al Viro's avatar
Al Viro committed
29
#include <linux/timer.h>
30
#include <linux/bug.h>
31
#include <linux/delay.h>
Arun Sharma's avatar
Arun Sharma committed
32
#include <linux/atomic.h>
Linus Torvalds's avatar
Linus Torvalds committed
33 34 35 36
#include <asm/cache.h>
#include <asm/byteorder.h>

#include <linux/percpu.h>
37
#include <linux/rculist.h>
38
#include <linux/dmaengine.h>
39
#include <linux/workqueue.h>
Tom Herbert's avatar
Tom Herbert committed
40
#include <linux/dynamic_queue_limits.h>
Linus Torvalds's avatar
Linus Torvalds committed
41

42
#include <linux/ethtool.h>
43
#include <net/net_namespace.h>
44
#include <net/dsa.h>
Jeff Kirsher's avatar
Jeff Kirsher committed
45
#ifdef CONFIG_DCB
46 47
#include <net/dcbnl.h>
#endif
48
#include <net/netprio_cgroup.h>
49

50
#include <linux/netdev_features.h>
51
#include <linux/neighbour.h>
52
#include <uapi/linux/netdevice.h>
53

54
struct netpoll_info;
55
struct device;
56
struct phy_device;
57 58
/* 802.11 specific */
struct wireless_dev;
Linus Torvalds's avatar
Linus Torvalds committed
59

60 61
void netdev_set_default_ethtool_ops(struct net_device *dev,
				    const struct ethtool_ops *ops);
62

63 64 65 66
/* Backlog congestion levels */
#define NET_RX_SUCCESS		0	/* keep 'em coming, baby */
#define NET_RX_DROP		1	/* packet dropped */

67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
/*
 * Transmit return codes: transmit return codes originate from three different
 * namespaces:
 *
 * - qdisc return codes
 * - driver transmit return codes
 * - errno values
 *
 * Drivers are allowed to return any one of those in their hard_start_xmit()
 * function. Real network devices commonly used with qdiscs should only return
 * the driver transmit return codes though - when qdiscs are used, the actual
 * transmission happens asynchronously, so the value is not propagated to
 * higher layers. Virtual network devices transmit synchronously, in this case
 * the driver transmit return codes are consumed by dev_queue_xmit(), all
 * others are propagated to higher layers.
 */

/* qdisc ->enqueue() return codes. */
#define NET_XMIT_SUCCESS	0x00
86 87 88 89
#define NET_XMIT_DROP		0x01	/* skb dropped			*/
#define NET_XMIT_CN		0x02	/* congestion notification	*/
#define NET_XMIT_POLICED	0x03	/* skb is shot by police	*/
#define NET_XMIT_MASK		0x0f	/* qdisc flags in net/sch_generic.h */
Linus Torvalds's avatar
Linus Torvalds committed
90

91 92 93
/* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It
 * indicates that the device will soon be dropping packets, or already drops
 * some packets of the same priority; prompting us to send less aggressively. */
94
#define net_xmit_eval(e)	((e) == NET_XMIT_CN ? 0 : (e))
Linus Torvalds's avatar
Linus Torvalds committed
95 96
#define net_xmit_errno(e)	((e) != NET_XMIT_CN ? -ENOBUFS : 0)

97
/* Driver transmit return codes */
98
#define NETDEV_TX_MASK		0xf0
99

100
enum netdev_tx {
101
	__NETDEV_TX_MIN	 = INT_MIN,	/* make sure enum is signed */
102 103 104
	NETDEV_TX_OK	 = 0x00,	/* driver took care of packet */
	NETDEV_TX_BUSY	 = 0x10,	/* driver tx path was busy*/
	NETDEV_TX_LOCKED = 0x20,	/* driver tx lock was already taken */
105 106 107
};
typedef enum netdev_tx netdev_tx_t;

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
/*
 * Current order: NETDEV_TX_MASK > NET_XMIT_MASK >= 0 is significant;
 * hard_start_xmit() return < NET_XMIT_MASK means skb was consumed.
 */
static inline bool dev_xmit_complete(int rc)
{
	/*
	 * Positive cases with an skb consumed by a driver:
	 * - successful transmission (rc == NETDEV_TX_OK)
	 * - error while transmitting (rc < 0)
	 * - error while queueing to a different device (rc & NET_XMIT_MASK)
	 */
	if (likely(rc < NET_XMIT_MASK))
		return true;

	return false;
}

Linus Torvalds's avatar
Linus Torvalds committed
126 127 128 129
/*
 *	Compute the worst case header length according to the protocols
 *	used.
 */
Graf Yang's avatar
Graf Yang committed
130

131
#if defined(CONFIG_WLAN) || IS_ENABLED(CONFIG_AX25)
132 133 134 135 136
# if defined(CONFIG_MAC80211_MESH)
#  define LL_MAX_HEADER 128
# else
#  define LL_MAX_HEADER 96
# endif
Linus Torvalds's avatar
Linus Torvalds committed
137
#else
138
# define LL_MAX_HEADER 32
Linus Torvalds's avatar
Linus Torvalds committed
139 140
#endif

141 142
#if !IS_ENABLED(CONFIG_NET_IPIP) && !IS_ENABLED(CONFIG_NET_IPGRE) && \
    !IS_ENABLED(CONFIG_IPV6_SIT) && !IS_ENABLED(CONFIG_IPV6_TUNNEL)
Linus Torvalds's avatar
Linus Torvalds committed
143 144 145 146 147 148
#define MAX_HEADER LL_MAX_HEADER
#else
#define MAX_HEADER (LL_MAX_HEADER + 48)
#endif

/*
149 150
 *	Old network device statistics. Fields are native words
 *	(unsigned long) so they can be read and written atomically.
Linus Torvalds's avatar
Linus Torvalds committed
151
 */
Graf Yang's avatar
Graf Yang committed
152

Eric Dumazet's avatar
Eric Dumazet committed
153
struct net_device_stats {
154 155 156 157 158 159 160 161 162
	unsigned long	rx_packets;
	unsigned long	tx_packets;
	unsigned long	rx_bytes;
	unsigned long	tx_bytes;
	unsigned long	rx_errors;
	unsigned long	tx_errors;
	unsigned long	rx_dropped;
	unsigned long	tx_dropped;
	unsigned long	multicast;
Linus Torvalds's avatar
Linus Torvalds committed
163 164
	unsigned long	collisions;
	unsigned long	rx_length_errors;
165 166 167 168 169
	unsigned long	rx_over_errors;
	unsigned long	rx_crc_errors;
	unsigned long	rx_frame_errors;
	unsigned long	rx_fifo_errors;
	unsigned long	rx_missed_errors;
Linus Torvalds's avatar
Linus Torvalds committed
170 171 172 173 174 175 176 177 178 179 180 181 182
	unsigned long	tx_aborted_errors;
	unsigned long	tx_carrier_errors;
	unsigned long	tx_fifo_errors;
	unsigned long	tx_heartbeat_errors;
	unsigned long	tx_window_errors;
	unsigned long	rx_compressed;
	unsigned long	tx_compressed;
};


#include <linux/cache.h>
#include <linux/skbuff.h>

183
#ifdef CONFIG_RPS
184 185
#include <linux/static_key.h>
extern struct static_key rps_needed;
186 187
#endif

Linus Torvalds's avatar
Linus Torvalds committed
188 189 190 191
struct neighbour;
struct neigh_parms;
struct sk_buff;

192 193 194 195
struct netdev_hw_addr {
	struct list_head	list;
	unsigned char		addr[MAX_ADDR_LEN];
	unsigned char		type;
Jiri Pirko's avatar
Jiri Pirko committed
196 197 198 199
#define NETDEV_HW_ADDR_T_LAN		1
#define NETDEV_HW_ADDR_T_SAN		2
#define NETDEV_HW_ADDR_T_SLAVE		3
#define NETDEV_HW_ADDR_T_UNICAST	4
200 201
#define NETDEV_HW_ADDR_T_MULTICAST	5
	bool			global_use;
202
	int			sync_cnt;
203
	int			refcount;
204
	int			synced;
205 206 207
	struct rcu_head		rcu_head;
};

208 209 210 211 212
struct netdev_hw_addr_list {
	struct list_head	list;
	int			count;
};

213 214 215 216
#define netdev_hw_addr_list_count(l) ((l)->count)
#define netdev_hw_addr_list_empty(l) (netdev_hw_addr_list_count(l) == 0)
#define netdev_hw_addr_list_for_each(ha, l) \
	list_for_each_entry(ha, &(l)->list, list)
217

218 219 220 221
#define netdev_uc_count(dev) netdev_hw_addr_list_count(&(dev)->uc)
#define netdev_uc_empty(dev) netdev_hw_addr_list_empty(&(dev)->uc)
#define netdev_for_each_uc_addr(ha, dev) \
	netdev_hw_addr_list_for_each(ha, &(dev)->uc)
222

223 224
#define netdev_mc_count(dev) netdev_hw_addr_list_count(&(dev)->mc)
#define netdev_mc_empty(dev) netdev_hw_addr_list_empty(&(dev)->mc)
225
#define netdev_for_each_mc_addr(ha, dev) \
226
	netdev_hw_addr_list_for_each(ha, &(dev)->mc)
227

Eric Dumazet's avatar
Eric Dumazet committed
228
struct hh_cache {
229
	u16		hh_len;
230
	u16		__pad;
231
	seqlock_t	hh_lock;
Linus Torvalds's avatar
Linus Torvalds committed
232 233 234 235

	/* cached hardware header; allow for machine alignment needs.        */
#define HH_DATA_MOD	16
#define HH_DATA_OFF(__len) \
Jiri Benc's avatar
Jiri Benc committed
236
	(HH_DATA_MOD - (((__len - 1) & (HH_DATA_MOD - 1)) + 1))
Linus Torvalds's avatar
Linus Torvalds committed
237 238 239 240 241 242 243 244 245 246 247 248 249 250
#define HH_DATA_ALIGN(__len) \
	(((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1))
	unsigned long	hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)];
};

/* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much.
 * Alternative is:
 *   dev->hard_header_len ? (dev->hard_header_len +
 *                           (HH_DATA_MOD - 1)) & ~(HH_DATA_MOD - 1) : 0
 *
 * We could use other alignment values, but we must maintain the
 * relationship HH alignment <= LL alignment.
 */
#define LL_RESERVED_SPACE(dev) \
251
	((((dev)->hard_header_len+(dev)->needed_headroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
Linus Torvalds's avatar
Linus Torvalds committed
252
#define LL_RESERVED_SPACE_EXTRA(dev,extra) \
253
	((((dev)->hard_header_len+(dev)->needed_headroom+(extra))&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
Linus Torvalds's avatar
Linus Torvalds committed
254

255 256 257
struct header_ops {
	int	(*create) (struct sk_buff *skb, struct net_device *dev,
			   unsigned short type, const void *daddr,
258
			   const void *saddr, unsigned int len);
259 260
	int	(*parse)(const struct sk_buff *skb, unsigned char *haddr);
	int	(*rebuild)(struct sk_buff *skb);
261
	int	(*cache)(const struct neighbour *neigh, struct hh_cache *hh, __be16 type);
262 263 264 265 266
	void	(*cache_update)(struct hh_cache *hh,
				const struct net_device *dev,
				const unsigned char *haddr);
};

Linus Torvalds's avatar
Linus Torvalds committed
267 268 269 270 271
/* These flag bits are private to the generic network queueing
 * layer, they may not be explicitly referenced by any other
 * code.
 */

Eric Dumazet's avatar
Eric Dumazet committed
272
enum netdev_state_t {
Linus Torvalds's avatar
Linus Torvalds committed
273 274 275
	__LINK_STATE_START,
	__LINK_STATE_PRESENT,
	__LINK_STATE_NOCARRIER,
276 277
	__LINK_STATE_LINKWATCH_PENDING,
	__LINK_STATE_DORMANT,
Linus Torvalds's avatar
Linus Torvalds committed
278 279 280 281 282
};


/*
 * This structure holds at boot time configured netdevice settings. They
Graf Yang's avatar
Graf Yang committed
283
 * are then used in the device probing.
Linus Torvalds's avatar
Linus Torvalds committed
284 285 286 287 288 289 290
 */
struct netdev_boot_setup {
	char name[IFNAMSIZ];
	struct ifmap map;
};
#define NETDEV_BOOT_SETUP_MAX 8

291
int __init netdev_boot_setup(char *str);
Linus Torvalds's avatar
Linus Torvalds committed
292

293 294 295 296 297 298 299 300 301 302 303 304 305 306
/*
 * Structure for NAPI scheduling similar to tasklet but with weighting
 */
struct napi_struct {
	/* The poll_list must only be managed by the entity which
	 * changes the state of the NAPI_STATE_SCHED bit.  This means
	 * whoever atomically sets that bit can add this napi_struct
	 * to the per-cpu poll_list, and whoever clears that bit
	 * can remove from the list right before clearing the bit.
	 */
	struct list_head	poll_list;

	unsigned long		state;
	int			weight;
307
	unsigned int		gro_count;
308 309 310 311 312
	int			(*poll)(struct napi_struct *, int);
#ifdef CONFIG_NETPOLL
	spinlock_t		poll_lock;
	int			poll_owner;
#endif
Herbert Xu's avatar
Herbert Xu committed
313
	struct net_device	*dev;
314
	struct sk_buff		*gro_list;
Herbert Xu's avatar
Herbert Xu committed
315
	struct sk_buff		*skb;
316
	struct list_head	dev_list;
Eliezer Tamir's avatar
Eliezer Tamir committed
317 318
	struct hlist_node	napi_hash_node;
	unsigned int		napi_id;
319 320
};

Eric Dumazet's avatar
Eric Dumazet committed
321
enum {
322
	NAPI_STATE_SCHED,	/* Poll is scheduled */
323
	NAPI_STATE_DISABLE,	/* Disable pending */
324
	NAPI_STATE_NPSVC,	/* Netpoll - don't dequeue from poll_list */
Eliezer Tamir's avatar
Eliezer Tamir committed
325
	NAPI_STATE_HASHED,	/* In NAPI hash */
326 327
};

328
enum gro_result {
329 330 331 332 333 334
	GRO_MERGED,
	GRO_MERGED_FREE,
	GRO_HELD,
	GRO_NORMAL,
	GRO_DROP,
};
335
typedef enum gro_result gro_result_t;
336

337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
/*
 * enum rx_handler_result - Possible return values for rx_handlers.
 * @RX_HANDLER_CONSUMED: skb was consumed by rx_handler, do not process it
 * further.
 * @RX_HANDLER_ANOTHER: Do another round in receive path. This is indicated in
 * case skb->dev was changed by rx_handler.
 * @RX_HANDLER_EXACT: Force exact delivery, no wildcard.
 * @RX_HANDLER_PASS: Do nothing, passe the skb as if no rx_handler was called.
 *
 * rx_handlers are functions called from inside __netif_receive_skb(), to do
 * special processing of the skb, prior to delivery to protocol handlers.
 *
 * Currently, a net_device can only have a single rx_handler registered. Trying
 * to register a second rx_handler will return -EBUSY.
 *
 * To register a rx_handler on a net_device, use netdev_rx_handler_register().
 * To unregister a rx_handler on a net_device, use
 * netdev_rx_handler_unregister().
 *
 * Upon return, rx_handler is expected to tell __netif_receive_skb() what to
 * do with the skb.
 *
 * If the rx_handler consumed to skb in some way, it should return
 * RX_HANDLER_CONSUMED. This is appropriate when the rx_handler arranged for
 * the skb to be delivered in some other ways.
 *
 * If the rx_handler changed skb->dev, to divert the skb to another
 * net_device, it should return RX_HANDLER_ANOTHER. The rx_handler for the
 * new device will be called if it exists.
 *
 * If the rx_handler consider the skb should be ignored, it should return
 * RX_HANDLER_EXACT. The skb will only be delivered to protocol handlers that
369
 * are registered on exact device (ptype->dev == skb->dev).
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
 *
 * If the rx_handler didn't changed skb->dev, but want the skb to be normally
 * delivered, it should return RX_HANDLER_PASS.
 *
 * A device without a registered rx_handler will behave as if rx_handler
 * returned RX_HANDLER_PASS.
 */

enum rx_handler_result {
	RX_HANDLER_CONSUMED,
	RX_HANDLER_ANOTHER,
	RX_HANDLER_EXACT,
	RX_HANDLER_PASS,
};
typedef enum rx_handler_result rx_handler_result_t;
typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb);
386

387
void __napi_schedule(struct napi_struct *n);
388

389
static inline bool napi_disable_pending(struct napi_struct *n)
390 391 392 393
{
	return test_bit(NAPI_STATE_DISABLE, &n->state);
}

394 395 396 397 398 399
/**
 *	napi_schedule_prep - check if napi can be scheduled
 *	@n: napi context
 *
 * Test if NAPI routine is already running, and if not mark
 * it as running.  This is used as a condition variable
400 401
 * insure only one NAPI poll instance runs.  We also make
 * sure there is no pending NAPI disable.
402
 */
403
static inline bool napi_schedule_prep(struct napi_struct *n)
404
{
405 406
	return !napi_disable_pending(n) &&
		!test_and_set_bit(NAPI_STATE_SCHED, &n->state);
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
}

/**
 *	napi_schedule - schedule NAPI poll
 *	@n: napi context
 *
 * Schedule NAPI poll routine to be called if it is not already
 * running.
 */
static inline void napi_schedule(struct napi_struct *n)
{
	if (napi_schedule_prep(n))
		__napi_schedule(n);
}

422
/* Try to reschedule poll. Called by dev->poll() after napi_complete().  */
423
static inline bool napi_reschedule(struct napi_struct *napi)
424 425 426
{
	if (napi_schedule_prep(napi)) {
		__napi_schedule(napi);
427
		return true;
428
	}
429
	return false;
430 431
}

432 433 434 435 436 437
/**
 *	napi_complete - NAPI processing complete
 *	@n: napi context
 *
 * Mark NAPI processing as complete.
 */
438 439
void __napi_complete(struct napi_struct *n);
void napi_complete(struct napi_struct *n);
440

Eliezer Tamir's avatar
Eliezer Tamir committed
441 442 443 444 445 446 447
/**
 *	napi_by_id - lookup a NAPI by napi_id
 *	@napi_id: hashed napi_id
 *
 * lookup @napi_id in napi_hash table
 * must be called under rcu_read_lock()
 */
448
struct napi_struct *napi_by_id(unsigned int napi_id);
Eliezer Tamir's avatar
Eliezer Tamir committed
449 450 451 452 453 454 455

/**
 *	napi_hash_add - add a NAPI to global hashtable
 *	@napi: napi context
 *
 * generate a new napi_id and store a @napi under it in napi_hash
 */
456
void napi_hash_add(struct napi_struct *napi);
Eliezer Tamir's avatar
Eliezer Tamir committed
457 458 459 460 461 462 463 464

/**
 *	napi_hash_del - remove a NAPI from global table
 *	@napi: napi context
 *
 * Warning: caller must observe rcu grace period
 * before freeing memory containing @napi
 */
465
void napi_hash_del(struct napi_struct *napi);
Eliezer Tamir's avatar
Eliezer Tamir committed
466

467 468 469 470 471 472 473 474 475
/**
 *	napi_disable - prevent NAPI from scheduling
 *	@n: napi context
 *
 * Stop NAPI from being scheduled on this context.
 * Waits till any outstanding processing completes.
 */
static inline void napi_disable(struct napi_struct *n)
{
476
	might_sleep();
477
	set_bit(NAPI_STATE_DISABLE, &n->state);
478
	while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
479
		msleep(1);
480
	clear_bit(NAPI_STATE_DISABLE, &n->state);
481 482 483 484 485 486 487 488 489 490 491 492
}

/**
 *	napi_enable - enable NAPI scheduling
 *	@n: napi context
 *
 * Resume NAPI from being scheduled on this context.
 * Must be paired with napi_disable.
 */
static inline void napi_enable(struct napi_struct *n)
{
	BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state));
493
	smp_mb__before_atomic();
494 495 496
	clear_bit(NAPI_STATE_SCHED, &n->state);
}

497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
#ifdef CONFIG_SMP
/**
 *	napi_synchronize - wait until NAPI is not running
 *	@n: napi context
 *
 * Wait until NAPI is done being scheduled on this context.
 * Waits till any outstanding processing completes but
 * does not disable future activations.
 */
static inline void napi_synchronize(const struct napi_struct *n)
{
	while (test_bit(NAPI_STATE_SCHED, &n->state))
		msleep(1);
}
#else
# define napi_synchronize(n)	barrier()
#endif

Eric Dumazet's avatar
Eric Dumazet committed
515
enum netdev_queue_state_t {
516 517
	__QUEUE_STATE_DRV_XOFF,
	__QUEUE_STATE_STACK_XOFF,
518
	__QUEUE_STATE_FROZEN,
519
};
520 521 522 523 524 525 526 527 528 529 530

#define QUEUE_STATE_DRV_XOFF	(1 << __QUEUE_STATE_DRV_XOFF)
#define QUEUE_STATE_STACK_XOFF	(1 << __QUEUE_STATE_STACK_XOFF)
#define QUEUE_STATE_FROZEN	(1 << __QUEUE_STATE_FROZEN)

#define QUEUE_STATE_ANY_XOFF	(QUEUE_STATE_DRV_XOFF | QUEUE_STATE_STACK_XOFF)
#define QUEUE_STATE_ANY_XOFF_OR_FROZEN (QUEUE_STATE_ANY_XOFF | \
					QUEUE_STATE_FROZEN)
#define QUEUE_STATE_DRV_XOFF_OR_FROZEN (QUEUE_STATE_DRV_XOFF | \
					QUEUE_STATE_FROZEN)

531 532 533 534 535 536 537 538 539
/*
 * __QUEUE_STATE_DRV_XOFF is used by drivers to stop the transmit queue.  The
 * netif_tx_* functions below are used to manipulate this flag.  The
 * __QUEUE_STATE_STACK_XOFF flag is used by the stack to stop the transmit
 * queue independently.  The netif_xmit_*stopped functions below are called
 * to check if the queue has been stopped by the driver or stack (either
 * of the XOFF bits are set in the state).  Drivers should not need to call
 * netif_xmit*stopped functions, they should only be using netif_tx_*.
 */
540

541
struct netdev_queue {
542 543 544
/*
 * read mostly part
 */
545
	struct net_device	*dev;
546 547
	struct Qdisc		*qdisc;
	struct Qdisc		*qdisc_sleeping;
548
#ifdef CONFIG_SYSFS
Tom Herbert's avatar
Tom Herbert committed
549 550
	struct kobject		kobj;
#endif
551 552 553
#if defined(CONFIG_XPS) && defined(CONFIG_NUMA)
	int			numa_node;
#endif
554 555 556 557 558
/*
 * write mostly part
 */
	spinlock_t		_xmit_lock ____cacheline_aligned_in_smp;
	int			xmit_lock_owner;
559 560 561 562
	/*
	 * please use this field instead of dev->trans_start
	 */
	unsigned long		trans_start;
563 564 565 566 567 568

	/*
	 * Number of TX timeouts for this queue
	 * (/sys/class/net/DEV/Q/trans_timeout)
	 */
	unsigned long		trans_timeout;
Tom Herbert's avatar
Tom Herbert committed
569 570 571 572 573 574

	unsigned long		state;

#ifdef CONFIG_BQL
	struct dql		dql;
#endif
575
} ____cacheline_aligned_in_smp;
576

577 578 579 580 581
static inline int netdev_queue_numa_node_read(const struct netdev_queue *q)
{
#if defined(CONFIG_XPS) && defined(CONFIG_NUMA)
	return q->numa_node;
#else
582
	return NUMA_NO_NODE;
583 584 585 586 587 588 589 590 591 592
#endif
}

static inline void netdev_queue_numa_node_write(struct netdev_queue *q, int node)
{
#if defined(CONFIG_XPS) && defined(CONFIG_NUMA)
	q->numa_node = node;
#endif
}

Eric Dumazet's avatar
Eric Dumazet committed
593
#ifdef CONFIG_RPS
Tom Herbert's avatar
Tom Herbert committed
594 595 596 597 598 599 600 601 602
/*
 * This structure holds an RPS map which can be of variable length.  The
 * map is an array of CPUs.
 */
struct rps_map {
	unsigned int len;
	struct rcu_head rcu;
	u16 cpus[0];
};
603
#define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + ((_num) * sizeof(u16)))
Tom Herbert's avatar
Tom Herbert committed
604

Tom Herbert's avatar
Tom Herbert committed
605
/*
606 607 608
 * The rps_dev_flow structure contains the mapping of a flow to a CPU, the
 * tail pointer for that CPU's input queue at the time of last enqueue, and
 * a hardware filter index.
Tom Herbert's avatar
Tom Herbert committed
609 610 611
 */
struct rps_dev_flow {
	u16 cpu;
612
	u16 filter;
Tom Herbert's avatar
Tom Herbert committed
613 614
	unsigned int last_qtail;
};
615
#define RPS_NO_FILTER 0xffff
Tom Herbert's avatar
Tom Herbert committed
616 617 618 619 620 621 622 623 624 625

/*
 * The rps_dev_flow_table structure contains a table of flow mappings.
 */
struct rps_dev_flow_table {
	unsigned int mask;
	struct rcu_head rcu;
	struct rps_dev_flow flows[0];
};
#define RPS_DEV_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_dev_flow_table) + \
626
    ((_num) * sizeof(struct rps_dev_flow)))
Tom Herbert's avatar
Tom Herbert committed
627 628 629 630 631 632 633 634 635 636

/*
 * The rps_sock_flow_table contains mappings of flows to the last CPU
 * on which they were processed by the application (set in recvmsg).
 */
struct rps_sock_flow_table {
	unsigned int mask;
	u16 ents[0];
};
#define	RPS_SOCK_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_sock_flow_table) + \
637
    ((_num) * sizeof(u16)))
Tom Herbert's avatar
Tom Herbert committed
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661

#define RPS_NO_CPU 0xffff

static inline void rps_record_sock_flow(struct rps_sock_flow_table *table,
					u32 hash)
{
	if (table && hash) {
		unsigned int cpu, index = hash & table->mask;

		/* We only give a hint, preemption can change cpu under us */
		cpu = raw_smp_processor_id();

		if (table->ents[index] != cpu)
			table->ents[index] = cpu;
	}
}

static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table,
				       u32 hash)
{
	if (table && hash)
		table->ents[hash & table->mask] = RPS_NO_CPU;
}

Eric Dumazet's avatar
Eric Dumazet committed
662
extern struct rps_sock_flow_table __rcu *rps_sock_flow_table;
Tom Herbert's avatar
Tom Herbert committed
663

664
#ifdef CONFIG_RFS_ACCEL
665 666
bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, u32 flow_id,
			 u16 filter_id);
667
#endif
668
#endif /* CONFIG_RPS */
669

Tom Herbert's avatar
Tom Herbert committed
670 671
/* This structure contains an instance of an RX queue. */
struct netdev_rx_queue {
672
#ifdef CONFIG_RPS
Eric Dumazet's avatar
Eric Dumazet committed
673 674
	struct rps_map __rcu		*rps_map;
	struct rps_dev_flow_table __rcu	*rps_flow_table;
675
#endif
Eric Dumazet's avatar
Eric Dumazet committed
676
	struct kobject			kobj;
677
	struct net_device		*dev;
Tom Herbert's avatar
Tom Herbert committed
678
} ____cacheline_aligned_in_smp;
679 680 681 682 683 684 685 686 687 688 689

/*
 * RX queue sysfs structures and functions.
 */
struct rx_queue_attribute {
	struct attribute attr;
	ssize_t (*show)(struct netdev_rx_queue *queue,
	    struct rx_queue_attribute *attr, char *buf);
	ssize_t (*store)(struct netdev_rx_queue *queue,
	    struct rx_queue_attribute *attr, const char *buf, size_t len);
};
690

Tom Herbert's avatar
Tom Herbert committed
691 692 693 694 695 696 697 698 699 700 701
#ifdef CONFIG_XPS
/*
 * This structure holds an XPS map which can be of variable length.  The
 * map is an array of queues.
 */
struct xps_map {
	unsigned int len;
	unsigned int alloc_len;
	struct rcu_head rcu;
	u16 queues[0];
};
702
#define XPS_MAP_SIZE(_num) (sizeof(struct xps_map) + ((_num) * sizeof(u16)))
Tom Herbert's avatar
Tom Herbert committed
703 704 705 706 707 708 709 710
#define XPS_MIN_MAP_ALLOC ((L1_CACHE_BYTES - sizeof(struct xps_map))	\
    / sizeof(u16))

/*
 * This structure holds all XPS maps for device.  Maps are indexed by CPU.
 */
struct xps_dev_maps {
	struct rcu_head rcu;
Eric Dumazet's avatar
Eric Dumazet committed
711
	struct xps_map __rcu *cpu_map[0];
Tom Herbert's avatar
Tom Herbert committed
712 713 714 715 716
};
#define XPS_DEV_MAPS_SIZE (sizeof(struct xps_dev_maps) +		\
    (nr_cpu_ids * sizeof(struct xps_map *)))
#endif /* CONFIG_XPS */

717 718 719 720 721 722 723 724
#define TC_MAX_QUEUE	16
#define TC_BITMASK	15
/* HW offloaded queuing disciplines txq count and offset maps */
struct netdev_tc_txq {
	u16 count;
	u16 offset;
};

725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
/*
 * This structure is to hold information about the device
 * configured to run FCoE protocol stack.
 */
struct netdev_fcoe_hbainfo {
	char	manufacturer[64];
	char	serial_number[64];
	char	hardware_version[64];
	char	driver_version[64];
	char	optionrom_version[64];
	char	firmware_version[64];
	char	model[256];
	char	model_description[256];
};
#endif

742 743 744 745 746 747 748 749 750 751
#define MAX_PHYS_PORT_ID_LEN 32

/* This structure holds a unique identifier to identify the
 * physical port used by a netdevice.
 */
struct netdev_phys_port_id {
	unsigned char id[MAX_PHYS_PORT_ID_LEN];
	unsigned char id_len;
};

752 753 754
typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
				       struct sk_buff *skb);

755 756
/*
 * This structure defines the management hooks for network devices.
757 758
 * The following hooks can be defined; unless noted otherwise, they are
 * optional and can be filled with a null pointer.
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777
 *
 * int (*ndo_init)(struct net_device *dev);
 *     This function is called once when network device is registered.
 *     The network device can use this to any late stage initializaton
 *     or semantic validattion. It can fail with an error code which will
 *     be propogated back to register_netdev
 *
 * void (*ndo_uninit)(struct net_device *dev);
 *     This function is called when device is unregistered or when registration
 *     fails. It is not called if init fails.
 *
 * int (*ndo_open)(struct net_device *dev);
 *     This function is called when network device transistions to the up
 *     state.
 *
 * int (*ndo_stop)(struct net_device *dev);
 *     This function is called when network device transistions to the down
 *     state.
 *
778 779
 * netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb,
 *                               struct net_device *dev);
780
 *	Called when a packet needs to be transmitted.
781 782
 *	Must return NETDEV_TX_OK , NETDEV_TX_BUSY.
 *        (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX)
783 784
 *	Required can not be NULL.
 *
785
 * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb,
786
 *                         void *accel_priv, select_queue_fallback_t fallback);
787 788 789
 *	Called to decide which queue to when device supports multiple
 *	transmit queues.
 *
790 791 792 793 794 795
 * void (*ndo_change_rx_flags)(struct net_device *dev, int flags);
 *	This function is called to allow device receiver to make
 *	changes to configuration when multicast or promiscious is enabled.
 *
 * void (*ndo_set_rx_mode)(struct net_device *dev);
 *	This function is called device changes address list filtering.
796 797
 *	If driver handles unicast address filtering, it should set
 *	IFF_UNICAST_FLT to its priv_flags.
798 799 800
 *
 * int (*ndo_set_mac_address)(struct net_device *dev, void *addr);
 *	This function  is called when the Media Access Control address
801
 *	needs to be changed. If this interface is not defined, the
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
 *	mac address can not be changed.
 *
 * int (*ndo_validate_addr)(struct net_device *dev);
 *	Test if Media Access Control address is valid for the device.
 *
 * int (*ndo_do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);
 *	Called when a user request an ioctl which can't be handled by
 *	the generic interface code. If not defined ioctl's return
 *	not supported error code.
 *
 * int (*ndo_set_config)(struct net_device *dev, struct ifmap *map);
 *	Used to set network devices bus interface parameters. This interface
 *	is retained for legacy reason, new devices should use the bus
 *	interface (PCI) for low level management.
 *
 * int (*ndo_change_mtu)(struct net_device *dev, int new_mtu);
 *	Called when a user wants to change the Maximum Transfer Unit
 *	of a device. If not defined, any request to change MTU will
 *	will return an error.
 *
822
 * void (*ndo_tx_timeout)(struct net_device *dev);
823 824 825
 *	Callback uses when the transmitter has not made any progress
 *	for dev->watchdog ticks.
 *
826
 * struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev,
827
 *                      struct rtnl_link_stats64 *storage);
828
 * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
829
 *	Called when a user wants to get the network device usage
830
 *	statistics. Drivers must do one of the following:
831 832
 *	1. Define @ndo_get_stats64 to fill in a zero-initialised
 *	   rtnl_link_stats64 structure passed by the caller.
833
 *	2. Define @ndo_get_stats to update a net_device_stats structure
834 835 836 837 838
 *	   (which should normally be dev->stats) and return a pointer to
 *	   it. The structure may be changed asynchronously only if each
 *	   field is written atomically.
 *	3. Update dev->stats asynchronously and atomically, and define
 *	   neither operation.
839
 *
840 841 842
 * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16t vid);
 *	If device support VLAN filtering this function is called when a
 *	VLAN id is registered.
843
 *
844
 * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid);
845 846
 *	If device support VLAN filtering this function is called when a
 *	VLAN id is unregistered.
847 848
 *
 * void (*ndo_poll_controller)(struct net_device *dev);
849 850 851 852
 *
 *	SR-IOV management functions.
 * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac);
 * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos);
853 854
 * int (*ndo_set_vf_rate)(struct net_device *dev, int vf, int min_tx_rate,
 *			  int max_tx_rate);
855
 * int (*ndo_set_vf_spoofchk)(struct net_device *dev, int vf, bool setting);
856 857
 * int (*ndo_get_vf_config)(struct net_device *dev,
 *			    int vf, struct ifla_vf_info *ivf);
858
 * int (*ndo_set_vf_link_state)(struct net_device *dev, int vf, int link_state);
859 860 861
 * int (*ndo_set_vf_port)(struct net_device *dev, int vf,
 *			  struct nlattr *port[]);
 * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb);
862 863 864 865 866
 * int (*ndo_setup_tc)(struct net_device *dev, u8 tc)
 * 	Called to setup 'tc' number of traffic classes in the net device. This
 * 	is always called from the stack with the rtnl lock held and netif tx
 * 	queues stopped. This allows the netdevice to perform queue management
 * 	safely.
867
 *
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
 *	Fiber Channel over Ethernet (FCoE) offload functions.
 * int (*ndo_fcoe_enable)(struct net_device *dev);
 *	Called when the FCoE protocol stack wants to start using LLD for FCoE
 *	so the underlying device can perform whatever needed configuration or
 *	initialization to support acceleration of FCoE traffic.
 *
 * int (*ndo_fcoe_disable)(struct net_device *dev);
 *	Called when the FCoE protocol stack wants to stop using LLD for FCoE
 *	so the underlying device can perform whatever needed clean-ups to
 *	stop supporting acceleration of FCoE traffic.
 *
 * int (*ndo_fcoe_ddp_setup)(struct net_device *dev, u16 xid,
 *			     struct scatterlist *sgl, unsigned int sgc);
 *	Called when the FCoE Initiator wants to initialize an I/O that
 *	is a possible candidate for Direct Data Placement (DDP). The LLD can
 *	perform necessary setup and returns 1 to indicate the device is set up
 *	successfully to perform DDP on this I/O, otherwise this returns 0.
 *
 * int (*ndo_fcoe_ddp_done)(struct net_device *dev,  u16 xid);
 *	Called when the FCoE Initiator/Target is done with the DDPed I/O as
 *	indicated by the FC exchange id 'xid', so the underlying device can
 *	clean up and reuse resources for later DDP requests.
 *
 * int (*ndo_fcoe_ddp_target)(struct net_device *dev, u16 xid,
 *			      struct scatterlist *sgl, unsigned int sgc);
 *	Called when the FCoE Target wants to initialize an I/O that
 *	is a possible candidate for Direct Data Placement (DDP). The LLD can
 *	perform necessary setup and returns 1 to indicate the device is set up
 *	successfully to perform DDP on this I/O, otherwise this returns 0.
 *
898 899 900 901 902 903 904
 * int (*ndo_fcoe_get_hbainfo)(struct net_device *dev,
 *			       struct netdev_fcoe_hbainfo *hbainfo);
 *	Called when the FCoE Protocol stack wants information on the underlying
 *	device. This information is utilized by the FCoE protocol stack to
 *	register attributes with Fiber Channel management service as per the
 *	FC-GS Fabric Device Management Information(FDMI) specification.
 *
905 906 907 908 909 910
 * int (*ndo_fcoe_get_wwn)(struct net_device *dev, u64 *wwn, int type);
 *	Called when the underlying device wants to override default World Wide
 *	Name (WWN) generation mechanism in FCoE protocol stack to pass its own
 *	World Wide Port Name (WWPN) or World Wide Node Name (WWNN) to the FCoE
 *	protocol stack to use.
 *
911 912 913 914 915 916
 *	RFS acceleration.
 * int (*ndo_rx_flow_steer)(struct net_device *dev, const struct sk_buff *skb,
 *			    u16 rxq_index, u32 flow_id);
 *	Set hardware filter for RFS.  rxq_index is the target queue index;
 *	flow_id is a flow ID to be passed to rps_may_expire_flow() later.
 *	Return the filter ID on success, or a negative error code.
917
 *
918
 *	Slave management functions (for bridge, bonding, etc).
919 920 921 922 923
 * int (*ndo_add_slave)(struct net_device *dev, struct net_device *slave_dev);
 *	Called to make another netdev an underling.
 *
 * int (*ndo_del_slave)(struct net_device *dev, struct net_device *slave_dev);
 *	Called to release previously enslaved netdev.
924 925
 *
 *      Feature/offload setting functions.
926 927
 * netdev_features_t (*ndo_fix_features)(struct net_device *dev,
 *		netdev_features_t features);
928 929 930 931
 *	Adjusts the requested feature flags according to device-specific
 *	constraints, and returns the resulting flags. Must not modify
 *	the device state.
 *
932
 * int (*ndo_set_features)(struct net_device *dev, netdev_features_t features);
933 934 935 936
 *	Called to update device configuration to new features. Passed
 *	feature set might be less than what was returned by ndo_fix_features()).
 *	Must return >0 or -errno if it changed dev->features itself.
 *
937 938
 * int (*ndo_fdb_add)(struct ndmsg *ndm, struct nlattr *tb[],
 *		      struct net_device *dev,
939
 *		      const unsigned char *addr, u16 flags)
940
 *	Adds an FDB entry to dev for addr.
941 942
 * int (*ndo_fdb_del)(struct ndmsg *ndm, struct nlattr *tb[],
 *		      struct net_device *dev,
943
 *		      const unsigned char *addr)
944 945
 *	Deletes the FDB entry from dev coresponding to addr.
 * int (*ndo_fdb_dump)(struct sk_buff *skb, struct netlink_callback *cb,
946 947
 *		       struct net_device *dev, struct net_device *filter_dev,
 *		       int idx)
948 949
 *	Used to add FDB entries to dump requests. Implementers should add
 *	entries to skb and update idx with the number of entries.
950 951 952
 *
 * int (*ndo_bridge_setlink)(struct net_device *dev, struct nlmsghdr *nlh)
 * int (*ndo_bridge_getlink)(struct sk_buff *skb, u32 pid, u32 seq,
953
 *			     struct net_device *dev, u32 filter_mask)
Jiri Pirko's avatar
Jiri Pirko committed
954 955 956 957 958 959 960 961
 *
 * int (*ndo_change_carrier)(struct net_device *dev, bool new_carrier);
 *	Called to change device carrier. Soft-devices (like dummy, team, etc)
 *	which do not represent real hardware may define this to allow their
 *	userspace components to manage their virtual carrier state. Devices
 *	that determine carrier state from physical hardware properties (eg
 *	network cables) or protocol-dependent mechanisms (eg
 *	USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function.
962 963 964 965 966 967
 *
 * int (*ndo_get_phys_port_id)(struct net_device *dev,
 *			       struct netdev_phys_port_id *ppid);
 *	Called to get ID of physical port of this device. If driver does
 *	not implement this, it is assumed that the hw is not able to have
 *	multiple net devices on single physical port.
968 969
 *
 * void (*ndo_add_vxlan_port)(struct  net_device *dev,
Joseph Gasparakis's avatar
Joseph Gasparakis committed
970
 *			      sa_family_t sa_family, __be16 port);
971 972 973 974 975 976
 *	Called by vxlan to notiy a driver about the UDP port and socket
 *	address family that vxlan is listnening to. It is called only when
 *	a new port starts listening. The operation is protected by the
 *	vxlan_net->sock_lock.
 *
 * void (*ndo_del_vxlan_port)(struct  net_device *dev,
Joseph Gasparakis's avatar
Joseph Gasparakis committed
977
 *			      sa_family_t sa_family, __be16 port);
978 979 980
 *	Called by vxlan to notify the driver about a UDP port and socket
 *	address family that vxlan is not listening to anymore. The operation
 *	is protected by the vxlan_net->sock_lock.
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999
 *
 * void* (*ndo_dfwd_add_station)(struct net_device *pdev,
 *				 struct net_device *dev)
 *	Called by upper layer devices to accelerate switching or other
 *	station functionality into hardware. 'pdev is the lowerdev
 *	to use for the offload and 'dev' is the net device that will
 *	back the offload. Returns a pointer to the private structure
 *	the upper layer will maintain.
 * void (*ndo_dfwd_del_station)(struct net_device *pdev, void *priv)
 *	Called by upper layer device to delete the station created
 *	by 'ndo_dfwd_add_station'. 'pdev' is the net device backing
 *	the station and priv is the structure returned by the add
 *	operation.
 * netdev_tx_t (*ndo_dfwd_start_xmit)(struct sk_buff *skb,
 *				      struct net_device *dev,
 *				      void *priv);
 *	Callback to use for xmit over the accelerated station. This
 *	is used in place of ndo_start_xmit on accelerated net
 *	devices.
1000 1001 1002 1003 1004 1005
 */
struct net_device_ops {
	int			(*ndo_init)(struct net_device *dev);
	void			(*ndo_uninit)(struct net_device *dev);
	int			(*ndo_open)(struct net_device *dev);
	int			(*ndo_stop)(struct net_device *dev);
1006
	netdev_tx_t		(*ndo_start_xmit) (struct sk_buff *skb,
1007 1008
						   struct net_device *dev);
	u16			(*ndo_select_queue)(struct net_device *dev,
1009
						    struct sk_buff *skb,
1010 1011
						    void *accel_priv,
						    select_queue_fallback_t fallback);
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
	void			(*ndo_change_rx_flags)(struct net_device *dev,
						       int flags);
	void			(*ndo_set_rx_mode)(struct net_device *dev);
	int			(*ndo_set_mac_address)(struct net_device *dev,
						       void *addr);
	int			(*ndo_validate_addr)(struct net_device *dev);
	int			(*ndo_do_ioctl)(struct net_device *dev,
					        struct ifreq *ifr, int cmd);
	int			(*ndo_set_config)(struct net_device *dev,
					          struct ifmap *map);
1022 1023 1024 1025
	int			(*ndo_change_mtu)(struct net_device *dev,
						  int new_mtu);
	int			(*ndo_neigh_setup)(struct net_device *dev,
						   struct neigh_parms *);
1026 1027
	void			(*ndo_tx_timeout) (struct net_device *dev);

1028 1029
	struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev,
						     struct rtnl_link_stats64 *storage);
1030 1031
	struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);

1032
	int			(*ndo_vlan_rx_add_vid)(struct net_device *dev,
1033
						       __be16 proto, u16 vid);
1034
	int			(*ndo_vlan_rx_kill_vid)(struct net_device *dev,
1035
						        __be16 proto, u16 vid);
1036 1037
#ifdef CONFIG_NET_POLL_CONTROLLER
	void                    (*ndo_poll_controller)(struct net_device *dev);
Herbert Xu's avatar
Herbert Xu committed
1038
	int			(*ndo_netpoll_setup)(struct net_device *dev,
1039
						     struct netpoll_info *info);
1040
	void			(*ndo_netpoll_cleanup)(struct net_device *dev);
1041
#endif
1042
#ifdef CONFIG_NET_RX_BUSY_POLL
1043
	int			(*ndo_busy_poll)(struct napi_struct *dev);
1044
#endif
1045 1046 1047 1048
	int			(*ndo_set_vf_mac)(struct net_device *dev,
						  int queue, u8 *mac);
	int			(*ndo_set_vf_vlan)(struct net_device *dev,
						   int queue, u16 vlan, u8 qos);
1049 1050 1051
	int			(*ndo_set_vf_rate)(struct net_device *dev,
						   int vf, int min_tx_rate,
						   int max_tx_rate);
1052 1053
	int			(*ndo_set_vf_spoofchk)(struct net_device *dev,
						       int vf, bool setting);
1054 1055 1056
	int			(*ndo_get_vf_config)(struct net_device *dev,
						     int vf,
						     struct ifla_vf_info *ivf);
1057 1058
	int			(*ndo_set_vf_link_state)(struct net_device *dev,
							 int vf, int link_state);
1059 1060 1061 1062 1063
	int			(*ndo_set_vf_port)(struct net_device *dev,
						   int vf,
						   struct nlattr *port[]);
	int			(*ndo_get_vf_port)(struct net_device *dev,
						   int vf, struct sk_buff *skb);
1064
	int			(*ndo_setup_tc)(struct net_device *dev, u8 tc);
1065
#if IS_ENABLED(CONFIG_FCOE)
1066 1067
	int			(*ndo_fcoe_enable)(struct net_device *dev);
	int			(*ndo_fcoe_disable)(struct net_device *dev);
1068 1069 1070 1071 1072 1073
	int			(*ndo_fcoe_ddp_setup)(struct net_device *dev,
						      u16 xid,
						      struct scatterlist *sgl,
						      unsigned int sgc);
	int			(*ndo_fcoe_ddp_done)(struct net_device *dev,
						     u16 xid);
1074 1075 1076 1077
	int			(*ndo_fcoe_ddp_target)(struct net_device *dev,
						       u16 xid,
						       struct scatterlist *sgl,
						       unsigned int sgc);
1078 1079
	int			(*ndo_fcoe_get_hbainfo)(struct net_device *dev,
							struct netdev_fcoe_hbainfo *hbainfo);
1080 1081
#endif

1082
#if IS_ENABLED(CONFIG_LIBFCOE)
1083 1084 1085 1086
#define NETDEV_FCOE_WWNN 0
#define NETDEV_FCOE_WWPN 1
	int			(*ndo_fcoe_get_wwn)(struct net_device *dev,
						    u64 *wwn, int type);
1087
#endif
1088

1089 1090 1091 1092 1093 1094
#ifdef CONFIG_RFS_ACCEL
	int			(*ndo_rx_flow_steer)(struct net_device *dev,
						     const struct sk_buff *skb,
						     u16 rxq_index,
						     u32 flow_id);
#endif
1095 1096 1097 1098
	int			(*ndo_add_slave)(struct net_device *dev,
						 struct net_device *slave_dev);
	int			(*ndo_del_slave)(struct net_device *dev,
						 struct net_device *slave_dev);
1099 1100
	netdev_features_t	(*ndo_fix_features)(struct net_device *dev,
						    netdev_features_t features);
1101
	int			(*ndo_set_features)(struct net_device *dev,
1102
						    netdev_features_t features);
1103
	int			(*ndo_neigh_construct)(struct neighbour *n);
1104
	void			(*ndo_neigh_destroy)(struct neighbour *n);
1105 1106

	int			(*ndo_fdb_add)(struct ndmsg *ndm,
1107
					       struct nlattr *tb[],
1108
					       struct net_device *dev,
1109
					       const unsigned char *addr,
1110 1111
					       u16 flags);
	int			(*ndo_fdb_del)(struct ndmsg *ndm,
1112
					       struct nlattr *tb[],
1113
					       struct net_device *dev,
1114
					       const unsigned char *addr);
1115 1116 1117
	int			(*ndo_fdb_dump)(struct sk_buff *skb,
						struct netlink_callback *cb,
						struct net_device *dev,
1118
						struct net_device *filter_dev,
1119
						int idx);
1120 1121 1122 1123 1124

	int			(*ndo_bridge_setlink)(struct net_device *dev,
						      struct nlmsghdr *nlh);
	int			(*ndo_bridge_getlink)(struct sk_buff *skb,
						      u32 pid, u32 seq,
1125 1126
						      struct net_device *dev,
						      u32 filter_mask);
1127 1128
	int			(*ndo_bridge_dellink)(struct net_device *dev,
						      struct nlmsghdr *nlh);
Jiri Pirko's avatar
Jiri Pirko committed
1129 1130
	int			(*ndo_change_carrier)(struct net_device *dev,
						      bool new_carrier);
1131 1132
	int			(*ndo_get_phys_port_id)(struct net_device *dev,
							struct netdev_phys_port_id *ppid);
1133 1134
	void			(*ndo_add_vxlan_port)(struct  net_device *dev,
						      sa_family_t sa_family,