diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2011-01-19 06:03:53 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-24 17:53:01 -0500 |
commit | c445477d74ab3779d1386ab797fbb9b628eb9f64 (patch) | |
tree | 3ee70b7748c6c63a688f367e5ffd83fde21b87e3 /include | |
parent | c39649c331c70952700f99832b03f87e9d7f5b4b (diff) |
net: RPS: Enable hardware acceleration of RFS
Allow drivers for multiqueue hardware with flow filter tables to
accelerate RFS. The driver must:
1. Set net_device::rx_cpu_rmap to a cpu_rmap of the RX completion
IRQs (in queue order). This will provide a mapping from CPUs to the
queues for which completions are handled nearest to them.
2. Implement net_device_ops::ndo_rx_flow_steer. This operation adds
or replaces a filter steering the given flow to the given RX queue, if
possible.
3. Periodically remove filters for which rps_may_expire_flow() returns
true.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netdevice.h | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 371fa8839d51..a335f2022690 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -554,14 +554,16 @@ struct rps_map { | |||
554 | #define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16))) | 554 | #define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16))) |
555 | 555 | ||
556 | /* | 556 | /* |
557 | * The rps_dev_flow structure contains the mapping of a flow to a CPU and the | 557 | * The rps_dev_flow structure contains the mapping of a flow to a CPU, the |
558 | * tail pointer for that CPU's input queue at the time of last enqueue. | 558 | * tail pointer for that CPU's input queue at the time of last enqueue, and |
559 | * a hardware filter index. | ||
559 | */ | 560 | */ |
560 | struct rps_dev_flow { | 561 | struct rps_dev_flow { |
561 | u16 cpu; | 562 | u16 cpu; |
562 | u16 fill; | 563 | u16 filter; |
563 | unsigned int last_qtail; | 564 | unsigned int last_qtail; |
564 | }; | 565 | }; |
566 | #define RPS_NO_FILTER 0xffff | ||
565 | 567 | ||
566 | /* | 568 | /* |
567 | * The rps_dev_flow_table structure contains a table of flow mappings. | 569 | * The rps_dev_flow_table structure contains a table of flow mappings. |
@@ -611,6 +613,11 @@ static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table, | |||
611 | 613 | ||
612 | extern struct rps_sock_flow_table __rcu *rps_sock_flow_table; | 614 | extern struct rps_sock_flow_table __rcu *rps_sock_flow_table; |
613 | 615 | ||
616 | #ifdef CONFIG_RFS_ACCEL | ||
617 | extern bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, | ||
618 | u32 flow_id, u16 filter_id); | ||
619 | #endif | ||
620 | |||
614 | /* This structure contains an instance of an RX queue. */ | 621 | /* This structure contains an instance of an RX queue. */ |
615 | struct netdev_rx_queue { | 622 | struct netdev_rx_queue { |
616 | struct rps_map __rcu *rps_map; | 623 | struct rps_map __rcu *rps_map; |
@@ -769,6 +776,13 @@ struct netdev_tc_txq { | |||
769 | * is always called from the stack with the rtnl lock held and netif tx | 776 | * is always called from the stack with the rtnl lock held and netif tx |
770 | * queues stopped. This allows the netdevice to perform queue management | 777 | * queues stopped. This allows the netdevice to perform queue management |
771 | * safely. | 778 | * safely. |
779 | * | ||
780 | * RFS acceleration. | ||
781 | * int (*ndo_rx_flow_steer)(struct net_device *dev, const struct sk_buff *skb, | ||
782 | * u16 rxq_index, u32 flow_id); | ||
783 | * Set hardware filter for RFS. rxq_index is the target queue index; | ||
784 | * flow_id is a flow ID to be passed to rps_may_expire_flow() later. | ||
785 | * Return the filter ID on success, or a negative error code. | ||
772 | */ | 786 | */ |
773 | #define HAVE_NET_DEVICE_OPS | 787 | #define HAVE_NET_DEVICE_OPS |
774 | struct net_device_ops { | 788 | struct net_device_ops { |
@@ -842,6 +856,12 @@ struct net_device_ops { | |||
842 | int (*ndo_fcoe_get_wwn)(struct net_device *dev, | 856 | int (*ndo_fcoe_get_wwn)(struct net_device *dev, |
843 | u64 *wwn, int type); | 857 | u64 *wwn, int type); |
844 | #endif | 858 | #endif |
859 | #ifdef CONFIG_RFS_ACCEL | ||
860 | int (*ndo_rx_flow_steer)(struct net_device *dev, | ||
861 | const struct sk_buff *skb, | ||
862 | u16 rxq_index, | ||
863 | u32 flow_id); | ||
864 | #endif | ||
845 | }; | 865 | }; |
846 | 866 | ||
847 | /* | 867 | /* |
@@ -1056,6 +1076,13 @@ struct net_device { | |||
1056 | 1076 | ||
1057 | /* Number of RX queues currently active in device */ | 1077 | /* Number of RX queues currently active in device */ |
1058 | unsigned int real_num_rx_queues; | 1078 | unsigned int real_num_rx_queues; |
1079 | |||
1080 | #ifdef CONFIG_RFS_ACCEL | ||
1081 | /* CPU reverse-mapping for RX completion interrupts, indexed | ||
1082 | * by RX queue number. Assigned by driver. This must only be | ||
1083 | * set if the ndo_rx_flow_steer operation is defined. */ | ||
1084 | struct cpu_rmap *rx_cpu_rmap; | ||
1085 | #endif | ||
1059 | #endif | 1086 | #endif |
1060 | 1087 | ||
1061 | rx_handler_func_t __rcu *rx_handler; | 1088 | rx_handler_func_t __rcu *rx_handler; |