diff options
author | Amritha Nambiar <amritha.nambiar@intel.com> | 2018-06-30 00:26:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-07-01 20:06:23 -0400 |
commit | 80d19669ecd34423e85ca04f2210b0e42a47cb16 (patch) | |
tree | db6eb66398a8ff0c5befd17f2d1056d83776b241 /include/linux/netdevice.h | |
parent | 1a84d7fdb5fc07b903678756f6f169d36de542b8 (diff) |
net: Refactor XPS for CPUs and Rx queues
Refactor XPS code to support Tx queue selection based on
CPU(s) map or Rx queue(s) map.
Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 98 |
1 files changed, 95 insertions, 3 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index c6b377a15869..8bf8d6149f79 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -731,10 +731,15 @@ struct xps_map { | |||
731 | */ | 731 | */ |
732 | struct xps_dev_maps { | 732 | struct xps_dev_maps { |
733 | struct rcu_head rcu; | 733 | struct rcu_head rcu; |
734 | struct xps_map __rcu *cpu_map[0]; | 734 | struct xps_map __rcu *attr_map[0]; /* Either CPUs map or RXQs map */ |
735 | }; | 735 | }; |
736 | #define XPS_DEV_MAPS_SIZE(_tcs) (sizeof(struct xps_dev_maps) + \ | 736 | |
737 | #define XPS_CPU_DEV_MAPS_SIZE(_tcs) (sizeof(struct xps_dev_maps) + \ | ||
737 | (nr_cpu_ids * (_tcs) * sizeof(struct xps_map *))) | 738 | (nr_cpu_ids * (_tcs) * sizeof(struct xps_map *))) |
739 | |||
740 | #define XPS_RXQ_DEV_MAPS_SIZE(_tcs, _rxqs) (sizeof(struct xps_dev_maps) +\ | ||
741 | (_rxqs * (_tcs) * sizeof(struct xps_map *))) | ||
742 | |||
738 | #endif /* CONFIG_XPS */ | 743 | #endif /* CONFIG_XPS */ |
739 | 744 | ||
740 | #define TC_MAX_QUEUE 16 | 745 | #define TC_MAX_QUEUE 16 |
@@ -1910,7 +1915,8 @@ struct net_device { | |||
1910 | int watchdog_timeo; | 1915 | int watchdog_timeo; |
1911 | 1916 | ||
1912 | #ifdef CONFIG_XPS | 1917 | #ifdef CONFIG_XPS |
1913 | struct xps_dev_maps __rcu *xps_maps; | 1918 | struct xps_dev_maps __rcu *xps_cpus_map; |
1919 | struct xps_dev_maps __rcu *xps_rxqs_map; | ||
1914 | #endif | 1920 | #endif |
1915 | #ifdef CONFIG_NET_CLS_ACT | 1921 | #ifdef CONFIG_NET_CLS_ACT |
1916 | struct mini_Qdisc __rcu *miniq_egress; | 1922 | struct mini_Qdisc __rcu *miniq_egress; |
@@ -3259,6 +3265,92 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index) | |||
3259 | #ifdef CONFIG_XPS | 3265 | #ifdef CONFIG_XPS |
3260 | int netif_set_xps_queue(struct net_device *dev, const struct cpumask *mask, | 3266 | int netif_set_xps_queue(struct net_device *dev, const struct cpumask *mask, |
3261 | u16 index); | 3267 | u16 index); |
3268 | int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, | ||
3269 | u16 index, bool is_rxqs_map); | ||
3270 | |||
3271 | /** | ||
3272 | * netif_attr_test_mask - Test a CPU or Rx queue set in a mask | ||
3273 | * @j: CPU/Rx queue index | ||
3274 | * @mask: bitmask of all cpus/rx queues | ||
3275 | * @nr_bits: number of bits in the bitmask | ||
3276 | * | ||
3277 | * Test if a CPU or Rx queue index is set in a mask of all CPU/Rx queues. | ||
3278 | */ | ||
3279 | static inline bool netif_attr_test_mask(unsigned long j, | ||
3280 | const unsigned long *mask, | ||
3281 | unsigned int nr_bits) | ||
3282 | { | ||
3283 | cpu_max_bits_warn(j, nr_bits); | ||
3284 | return test_bit(j, mask); | ||
3285 | } | ||
3286 | |||
3287 | /** | ||
3288 | * netif_attr_test_online - Test for online CPU/Rx queue | ||
3289 | * @j: CPU/Rx queue index | ||
3290 | * @online_mask: bitmask for CPUs/Rx queues that are online | ||
3291 | * @nr_bits: number of bits in the bitmask | ||
3292 | * | ||
3293 | * Returns true if a CPU/Rx queue is online. | ||
3294 | */ | ||
3295 | static inline bool netif_attr_test_online(unsigned long j, | ||
3296 | const unsigned long *online_mask, | ||
3297 | unsigned int nr_bits) | ||
3298 | { | ||
3299 | cpu_max_bits_warn(j, nr_bits); | ||
3300 | |||
3301 | if (online_mask) | ||
3302 | return test_bit(j, online_mask); | ||
3303 | |||
3304 | return (j < nr_bits); | ||
3305 | } | ||
3306 | |||
3307 | /** | ||
3308 | * netif_attrmask_next - get the next CPU/Rx queue in a cpu/Rx queues mask | ||
3309 | * @n: CPU/Rx queue index | ||
3310 | * @srcp: the cpumask/Rx queue mask pointer | ||
3311 | * @nr_bits: number of bits in the bitmask | ||
3312 | * | ||
3313 | * Returns >= nr_bits if no further CPUs/Rx queues set. | ||
3314 | */ | ||
3315 | static inline unsigned int netif_attrmask_next(int n, const unsigned long *srcp, | ||
3316 | unsigned int nr_bits) | ||
3317 | { | ||
3318 | /* -1 is a legal arg here. */ | ||
3319 | if (n != -1) | ||
3320 | cpu_max_bits_warn(n, nr_bits); | ||
3321 | |||
3322 | if (srcp) | ||
3323 | return find_next_bit(srcp, nr_bits, n + 1); | ||
3324 | |||
3325 | return n + 1; | ||
3326 | } | ||
3327 | |||
3328 | /** | ||
3329 | * netif_attrmask_next_and - get the next CPU/Rx queue in *src1p & *src2p | ||
3330 | * @n: CPU/Rx queue index | ||
3331 | * @src1p: the first CPUs/Rx queues mask pointer | ||
3332 | * @src2p: the second CPUs/Rx queues mask pointer | ||
3333 | * @nr_bits: number of bits in the bitmask | ||
3334 | * | ||
3335 | * Returns >= nr_bits if no further CPUs/Rx queues set in both. | ||
3336 | */ | ||
3337 | static inline int netif_attrmask_next_and(int n, const unsigned long *src1p, | ||
3338 | const unsigned long *src2p, | ||
3339 | unsigned int nr_bits) | ||
3340 | { | ||
3341 | /* -1 is a legal arg here. */ | ||
3342 | if (n != -1) | ||
3343 | cpu_max_bits_warn(n, nr_bits); | ||
3344 | |||
3345 | if (src1p && src2p) | ||
3346 | return find_next_and_bit(src1p, src2p, nr_bits, n + 1); | ||
3347 | else if (src1p) | ||
3348 | return find_next_bit(src1p, nr_bits, n + 1); | ||
3349 | else if (src2p) | ||
3350 | return find_next_bit(src2p, nr_bits, n + 1); | ||
3351 | |||
3352 | return n + 1; | ||
3353 | } | ||
3262 | #else | 3354 | #else |
3263 | static inline int netif_set_xps_queue(struct net_device *dev, | 3355 | static inline int netif_set_xps_queue(struct net_device *dev, |
3264 | const struct cpumask *mask, | 3356 | const struct cpumask *mask, |