diff options
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 55c2086e1f06..649a0252686e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -530,14 +530,73 @@ struct rps_map { | |||
530 | }; | 530 | }; |
531 | #define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16))) | 531 | #define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16))) |
532 | 532 | ||
533 | /* | ||
534 | * The rps_dev_flow structure contains the mapping of a flow to a CPU and the | ||
535 | * tail pointer for that CPU's input queue at the time of last enqueue. | ||
536 | */ | ||
537 | struct rps_dev_flow { | ||
538 | u16 cpu; | ||
539 | u16 fill; | ||
540 | unsigned int last_qtail; | ||
541 | }; | ||
542 | |||
543 | /* | ||
544 | * The rps_dev_flow_table structure contains a table of flow mappings. | ||
545 | */ | ||
546 | struct rps_dev_flow_table { | ||
547 | unsigned int mask; | ||
548 | struct rcu_head rcu; | ||
549 | struct work_struct free_work; | ||
550 | struct rps_dev_flow flows[0]; | ||
551 | }; | ||
552 | #define RPS_DEV_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_dev_flow_table) + \ | ||
553 | (_num * sizeof(struct rps_dev_flow))) | ||
554 | |||
555 | /* | ||
556 | * The rps_sock_flow_table contains mappings of flows to the last CPU | ||
557 | * on which they were processed by the application (set in recvmsg). | ||
558 | */ | ||
559 | struct rps_sock_flow_table { | ||
560 | unsigned int mask; | ||
561 | u16 ents[0]; | ||
562 | }; | ||
563 | #define RPS_SOCK_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_sock_flow_table) + \ | ||
564 | (_num * sizeof(u16))) | ||
565 | |||
566 | #define RPS_NO_CPU 0xffff | ||
567 | |||
568 | static inline void rps_record_sock_flow(struct rps_sock_flow_table *table, | ||
569 | u32 hash) | ||
570 | { | ||
571 | if (table && hash) { | ||
572 | unsigned int cpu, index = hash & table->mask; | ||
573 | |||
574 | /* We only give a hint, preemption can change cpu under us */ | ||
575 | cpu = raw_smp_processor_id(); | ||
576 | |||
577 | if (table->ents[index] != cpu) | ||
578 | table->ents[index] = cpu; | ||
579 | } | ||
580 | } | ||
581 | |||
582 | static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table, | ||
583 | u32 hash) | ||
584 | { | ||
585 | if (table && hash) | ||
586 | table->ents[hash & table->mask] = RPS_NO_CPU; | ||
587 | } | ||
588 | |||
589 | extern struct rps_sock_flow_table *rps_sock_flow_table; | ||
590 | |||
533 | /* This structure contains an instance of an RX queue. */ | 591 | /* This structure contains an instance of an RX queue. */ |
534 | struct netdev_rx_queue { | 592 | struct netdev_rx_queue { |
535 | struct rps_map *rps_map; | 593 | struct rps_map *rps_map; |
594 | struct rps_dev_flow_table *rps_flow_table; | ||
536 | struct kobject kobj; | 595 | struct kobject kobj; |
537 | struct netdev_rx_queue *first; | 596 | struct netdev_rx_queue *first; |
538 | atomic_t count; | 597 | atomic_t count; |
539 | } ____cacheline_aligned_in_smp; | 598 | } ____cacheline_aligned_in_smp; |
540 | #endif | 599 | #endif /* CONFIG_RPS */ |
541 | 600 | ||
542 | /* | 601 | /* |
543 | * This structure defines the management hooks for network devices. | 602 | * This structure defines the management hooks for network devices. |
@@ -1333,11 +1392,19 @@ struct softnet_data { | |||
1333 | /* Elements below can be accessed between CPUs for RPS */ | 1392 | /* Elements below can be accessed between CPUs for RPS */ |
1334 | #ifdef CONFIG_RPS | 1393 | #ifdef CONFIG_RPS |
1335 | struct call_single_data csd ____cacheline_aligned_in_smp; | 1394 | struct call_single_data csd ____cacheline_aligned_in_smp; |
1395 | unsigned int input_queue_head; | ||
1336 | #endif | 1396 | #endif |
1337 | struct sk_buff_head input_pkt_queue; | 1397 | struct sk_buff_head input_pkt_queue; |
1338 | struct napi_struct backlog; | 1398 | struct napi_struct backlog; |
1339 | }; | 1399 | }; |
1340 | 1400 | ||
1401 | static inline void incr_input_queue_head(struct softnet_data *queue) | ||
1402 | { | ||
1403 | #ifdef CONFIG_RPS | ||
1404 | queue->input_queue_head++; | ||
1405 | #endif | ||
1406 | } | ||
1407 | |||
1341 | DECLARE_PER_CPU_ALIGNED(struct softnet_data, softnet_data); | 1408 | DECLARE_PER_CPU_ALIGNED(struct softnet_data, softnet_data); |
1342 | 1409 | ||
1343 | #define HAVE_NETIF_QUEUE | 1410 | #define HAVE_NETIF_QUEUE |