aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2005-09-27 18:23:16 -0400
committerDavid S. Miller <davem@davemloft.net>2005-09-27 18:23:16 -0400
commit9356b8fc07dc126cd91d2b12f314d760ab48996e (patch)
tree908b193442d0e2ad345c05547d227809bc162a0a /include
parent2d7ceece08ad940d0ceac98ab1b5a3b82dfc2a0a (diff)
[NET]: Reorder some hot fields of struct net_device
Place them on separate cache lines in SMP to lower memory bouncing between multiple CPU accessing the device. - One part is mostly used on receive path (including eth_type_trans()) (poll_list, poll, quota, weight, last_rx, dev_addr, broadcast) - One part is mostly used on queue transmit path (qdisc) (queue_lock, qdisc, qdisc_sleeping, qdisc_list, tx_queue_len) - One part is mostly used on xmit path (device) (xmit_lock, xmit_lock_owner, priv, hard_start_xmit, trans_start) 'features' is placed outside of these hot points, in a location that may be shared by all cpus (because mostly read) name_hlist is moved close to name[IFNAMSIZ] to speedup __dev_get_by_name() Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/netdevice.h89
1 files changed, 55 insertions, 34 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7c717907896d..368e4c825ff1 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -265,6 +265,8 @@ struct net_device
265 * the interface. 265 * the interface.
266 */ 266 */
267 char name[IFNAMSIZ]; 267 char name[IFNAMSIZ];
268 /* device name hash chain */
269 struct hlist_node name_hlist;
268 270
269 /* 271 /*
270 * I/O specific fields 272 * I/O specific fields
@@ -292,6 +294,21 @@ struct net_device
292 294
293 /* ------- Fields preinitialized in Space.c finish here ------- */ 295 /* ------- Fields preinitialized in Space.c finish here ------- */
294 296
297 /* Net device features */
298 unsigned long features;
299#define NETIF_F_SG 1 /* Scatter/gather IO. */
300#define NETIF_F_IP_CSUM 2 /* Can checksum only TCP/UDP over IPv4. */
301#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
302#define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */
303#define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */
304#define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */
305#define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */
306#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
307#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
308#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
309#define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */
310#define NETIF_F_LLTX 4096 /* LockLess TX */
311
295 struct net_device *next_sched; 312 struct net_device *next_sched;
296 313
297 /* Interface index. Unique device identifier */ 314 /* Interface index. Unique device identifier */
@@ -316,9 +333,6 @@ struct net_device
316 * will (read: may be cleaned up at will). 333 * will (read: may be cleaned up at will).
317 */ 334 */
318 335
319 /* These may be needed for future network-power-down code. */
320 unsigned long trans_start; /* Time (in jiffies) of last Tx */
321 unsigned long last_rx; /* Time of last Rx */
322 336
323 unsigned short flags; /* interface flags (a la BSD) */ 337 unsigned short flags; /* interface flags (a la BSD) */
324 unsigned short gflags; 338 unsigned short gflags;
@@ -328,15 +342,12 @@ struct net_device
328 unsigned mtu; /* interface MTU value */ 342 unsigned mtu; /* interface MTU value */
329 unsigned short type; /* interface hardware type */ 343 unsigned short type; /* interface hardware type */
330 unsigned short hard_header_len; /* hardware hdr length */ 344 unsigned short hard_header_len; /* hardware hdr length */
331 void *priv; /* pointer to private data */
332 345
333 struct net_device *master; /* Pointer to master device of a group, 346 struct net_device *master; /* Pointer to master device of a group,
334 * which this device is member of. 347 * which this device is member of.
335 */ 348 */
336 349
337 /* Interface address info. */ 350 /* Interface address info. */
338 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
339 unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address */
340 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ 351 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
341 unsigned char addr_len; /* hardware address length */ 352 unsigned char addr_len; /* hardware address length */
342 unsigned short dev_id; /* for shared network cards */ 353 unsigned short dev_id; /* for shared network cards */
@@ -346,8 +357,6 @@ struct net_device
346 int promiscuity; 357 int promiscuity;
347 int allmulti; 358 int allmulti;
348 359
349 int watchdog_timeo;
350 struct timer_list watchdog_timer;
351 360
352 /* Protocol specific pointers */ 361 /* Protocol specific pointers */
353 362
@@ -358,32 +367,62 @@ struct net_device
358 void *ec_ptr; /* Econet specific data */ 367 void *ec_ptr; /* Econet specific data */
359 void *ax25_ptr; /* AX.25 specific data */ 368 void *ax25_ptr; /* AX.25 specific data */
360 369
361 struct list_head poll_list; /* Link to poll list */ 370/*
371 * Cache line mostly used on receive path (including eth_type_trans())
372 */
373 struct list_head poll_list ____cacheline_aligned_in_smp;
374 /* Link to poll list */
375
376 int (*poll) (struct net_device *dev, int *quota);
362 int quota; 377 int quota;
363 int weight; 378 int weight;
379 unsigned long last_rx; /* Time of last Rx */
380 /* Interface address info used in eth_type_trans() */
381 unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast
382 because most packets are unicast) */
383
384 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
364 385
386/*
387 * Cache line mostly used on queue transmit path (qdisc)
388 */
389 /* device queue lock */
390 spinlock_t queue_lock ____cacheline_aligned_in_smp;
365 struct Qdisc *qdisc; 391 struct Qdisc *qdisc;
366 struct Qdisc *qdisc_sleeping; 392 struct Qdisc *qdisc_sleeping;
367 struct Qdisc *qdisc_ingress;
368 struct list_head qdisc_list; 393 struct list_head qdisc_list;
369 unsigned long tx_queue_len; /* Max frames per queue allowed */ 394 unsigned long tx_queue_len; /* Max frames per queue allowed */
370 395
371 /* ingress path synchronizer */ 396 /* ingress path synchronizer */
372 spinlock_t ingress_lock; 397 spinlock_t ingress_lock;
398 struct Qdisc *qdisc_ingress;
399
400/*
401 * One part is mostly used on xmit path (device)
402 */
373 /* hard_start_xmit synchronizer */ 403 /* hard_start_xmit synchronizer */
374 spinlock_t xmit_lock; 404 spinlock_t xmit_lock ____cacheline_aligned_in_smp;
375 /* cpu id of processor entered to hard_start_xmit or -1, 405 /* cpu id of processor entered to hard_start_xmit or -1,
376 if nobody entered there. 406 if nobody entered there.
377 */ 407 */
378 int xmit_lock_owner; 408 int xmit_lock_owner;
379 /* device queue lock */ 409 void *priv; /* pointer to private data */
380 spinlock_t queue_lock; 410 int (*hard_start_xmit) (struct sk_buff *skb,
411 struct net_device *dev);
412 /* These may be needed for future network-power-down code. */
413 unsigned long trans_start; /* Time (in jiffies) of last Tx */
414
415 int watchdog_timeo; /* used by dev_watchdog() */
416 struct timer_list watchdog_timer;
417
418/*
419 * refcnt is a very hot point, so align it on SMP
420 */
381 /* Number of references to this device */ 421 /* Number of references to this device */
382 atomic_t refcnt; 422 atomic_t refcnt ____cacheline_aligned_in_smp;
423
383 /* delayed register/unregister */ 424 /* delayed register/unregister */
384 struct list_head todo_list; 425 struct list_head todo_list;
385 /* device name hash chain */
386 struct hlist_node name_hlist;
387 /* device index hash chain */ 426 /* device index hash chain */
388 struct hlist_node index_hlist; 427 struct hlist_node index_hlist;
389 428
@@ -396,21 +435,6 @@ struct net_device
396 NETREG_RELEASED, /* called free_netdev */ 435 NETREG_RELEASED, /* called free_netdev */
397 } reg_state; 436 } reg_state;
398 437
399 /* Net device features */
400 unsigned long features;
401#define NETIF_F_SG 1 /* Scatter/gather IO. */
402#define NETIF_F_IP_CSUM 2 /* Can checksum only TCP/UDP over IPv4. */
403#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
404#define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */
405#define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */
406#define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */
407#define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */
408#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
409#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
410#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
411#define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */
412#define NETIF_F_LLTX 4096 /* LockLess TX */
413
414 /* Called after device is detached from network. */ 438 /* Called after device is detached from network. */
415 void (*uninit)(struct net_device *dev); 439 void (*uninit)(struct net_device *dev);
416 /* Called after last user reference disappears. */ 440 /* Called after last user reference disappears. */
@@ -419,10 +443,7 @@ struct net_device
419 /* Pointers to interface service routines. */ 443 /* Pointers to interface service routines. */
420 int (*open)(struct net_device *dev); 444 int (*open)(struct net_device *dev);
421 int (*stop)(struct net_device *dev); 445 int (*stop)(struct net_device *dev);
422 int (*hard_start_xmit) (struct sk_buff *skb,
423 struct net_device *dev);
424#define HAVE_NETDEV_POLL 446#define HAVE_NETDEV_POLL
425 int (*poll) (struct net_device *dev, int *quota);
426 int (*hard_header) (struct sk_buff *skb, 447 int (*hard_header) (struct sk_buff *skb,
427 struct net_device *dev, 448 struct net_device *dev,
428 unsigned short type, 449 unsigned short type,