diff options
author | Haiyang Zhang <haiyangz@microsoft.com> | 2016-03-23 12:43:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-03-23 14:38:55 -0400 |
commit | 9efc2f7dcd06e04d7b6a3032ae65bfd628b1aebe (patch) | |
tree | b1177296ef91d34aadc8307915de09240e76eaf9 | |
parent | d212b4633c3a99561939f2d423eacf3263850bcd (diff) |
hv_netvsc: Fix the array sizes to be max supported channels
The VRSS_CHANNEL_MAX is the max number of channels supported by Hyper-V
hosts. We use it for the related array sizes instead of using NR_CPUS,
which may be set to several thousands.
This patch reduces possible memory allocation failures.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/hyperv/hyperv_net.h | 7 | ||||
-rw-r--r-- | drivers/net/hyperv/rndis_filter.c | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index b4c68783dfc3..8b3bd8ecd1c4 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h | |||
@@ -619,6 +619,7 @@ struct nvsp_message { | |||
619 | #define NETVSC_PACKET_SIZE 4096 | 619 | #define NETVSC_PACKET_SIZE 4096 |
620 | 620 | ||
621 | #define VRSS_SEND_TAB_SIZE 16 | 621 | #define VRSS_SEND_TAB_SIZE 16 |
622 | #define VRSS_CHANNEL_MAX 64 | ||
622 | 623 | ||
623 | #define RNDIS_MAX_PKT_DEFAULT 8 | 624 | #define RNDIS_MAX_PKT_DEFAULT 8 |
624 | #define RNDIS_PKT_ALIGN_DEFAULT 8 | 625 | #define RNDIS_PKT_ALIGN_DEFAULT 8 |
@@ -700,13 +701,13 @@ struct netvsc_device { | |||
700 | 701 | ||
701 | struct net_device *ndev; | 702 | struct net_device *ndev; |
702 | 703 | ||
703 | struct vmbus_channel *chn_table[NR_CPUS]; | 704 | struct vmbus_channel *chn_table[VRSS_CHANNEL_MAX]; |
704 | u32 send_table[VRSS_SEND_TAB_SIZE]; | 705 | u32 send_table[VRSS_SEND_TAB_SIZE]; |
705 | u32 max_chn; | 706 | u32 max_chn; |
706 | u32 num_chn; | 707 | u32 num_chn; |
707 | spinlock_t sc_lock; /* Protects num_sc_offered variable */ | 708 | spinlock_t sc_lock; /* Protects num_sc_offered variable */ |
708 | u32 num_sc_offered; | 709 | u32 num_sc_offered; |
709 | atomic_t queue_sends[NR_CPUS]; | 710 | atomic_t queue_sends[VRSS_CHANNEL_MAX]; |
710 | 711 | ||
711 | /* Holds rndis device info */ | 712 | /* Holds rndis device info */ |
712 | void *extension; | 713 | void *extension; |
@@ -718,7 +719,7 @@ struct netvsc_device { | |||
718 | /* The sub channel callback buffer */ | 719 | /* The sub channel callback buffer */ |
719 | unsigned char *sub_cb_buf; | 720 | unsigned char *sub_cb_buf; |
720 | 721 | ||
721 | struct multi_send_data msd[NR_CPUS]; | 722 | struct multi_send_data msd[VRSS_CHANNEL_MAX]; |
722 | u32 max_pkt; /* max number of pkt in one send, e.g. 8 */ | 723 | u32 max_pkt; /* max number of pkt in one send, e.g. 8 */ |
723 | u32 pkt_align; /* alignment bytes, e.g. 8 */ | 724 | u32 pkt_align; /* alignment bytes, e.g. 8 */ |
724 | 725 | ||
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 47d07c576a34..d5a54da5d9c8 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c | |||
@@ -1113,9 +1113,9 @@ int rndis_filter_device_add(struct hv_device *dev, | |||
1113 | if (ret || rsscap.num_recv_que < 2) | 1113 | if (ret || rsscap.num_recv_que < 2) |
1114 | goto out; | 1114 | goto out; |
1115 | 1115 | ||
1116 | num_rss_qs = min(device_info->max_num_vrss_chns, rsscap.num_recv_que); | 1116 | net_device->max_chn = min_t(u32, VRSS_CHANNEL_MAX, rsscap.num_recv_que); |
1117 | 1117 | ||
1118 | net_device->max_chn = rsscap.num_recv_que; | 1118 | num_rss_qs = min(device_info->max_num_vrss_chns, net_device->max_chn); |
1119 | 1119 | ||
1120 | /* | 1120 | /* |
1121 | * We will limit the VRSS channels to the number CPUs in the NUMA node | 1121 | * We will limit the VRSS channels to the number CPUs in the NUMA node |