hyperv: Add support for virtual Receive Side Scaling (vRSS)
Subsystems (3)
Haiyang Zhang
maintainerPATCH v4 1/1 hyperv: Add support for virtual Receive Side Scaling (vRSS)
This feature allows multiple channels to be used by each virtual NIC. It is available on Hyper-V host 2012 R2.
--- drivers/net/hyperv/hyperv_net.h | 110 +++++++++++++++++++++- drivers/net/hyperv/netvsc.c | 136 +++++++++++++++++++++----- drivers/net/hyperv/netvsc_drv.c | 103 +++++++++++++++++++- drivers/net/hyperv/rndis_filter.c | 189 ++++++++++++++++++++++++++++++++++++- 4 files changed, 504 insertions(+), 34 deletions(-)
drivers/net/hyperv/hyperv_net.h +109 -1
@@ -28,6 +28,96 @@#include <linux/hyperv.h> #include <linux/rndis.h> +/* RSS related */ +#define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203/* query only */ +#define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204/* query and set */ + +#define NDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88 +#define NDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89 + +#define NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2 +#define NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2 + +struct ndis_obj_header { +u8 type; +u8 rev; +u16 size; +} __packed; + +/* ndis_recv_scale_cap/cap_flag */ +#define NDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x01000000 +#define NDIS_RSS_CAPS_CLASSIFICATION_AT_ISR 0x02000000 +#define NDIS_RSS_CAPS_CLASSIFICATION_AT_DPC 0x04000000 +#define NDIS_RSS_CAPS_USING_MSI_X 0x08000000 +#define NDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS 0x10000000 +#define NDIS_RSS_CAPS_SUPPORTS_MSI_X 0x20000000 +#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4 0x00000100 +#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6 0x00000200 +#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX 0x00000400 + +struct ndis_recv_scale_cap {/* NDIS_RECEIVE_SCALE_CAPABILITIES */ +struct ndis_obj_header hdr; +u32 cap_flag; +u32 num_int_msg; +u32 num_recv_que; +u16 num_indirect_tabent; +} __packed; + + +/* ndis_recv_scale_param flags */ +#define NDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001 +#define NDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED 0x0002 +#define NDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED 0x0004 +#define NDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008 +#define NDIS_RSS_PARAM_FLAG_DISABLE_RSS 0x0010 + +/* Hash info bits */ +#define NDIS_HASH_FUNC_TOEPLITZ 0x00000001 +#define NDIS_HASH_IPV4 0x00000100 +#define NDIS_HASH_TCP_IPV4 0x00000200 +#define NDIS_HASH_IPV6 0x00000400 +#define NDIS_HASH_IPV6_EX 0x00000800 +#define NDIS_HASH_TCP_IPV6 0x00001000 +#define NDIS_HASH_TCP_IPV6_EX 0x00002000 + +#define NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4) +#define NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 40 + +#define ITAB_NUM 128 +#define HASH_KEYLEN NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 +extern u8 netvsc_hash_key[]; + +struct ndis_recv_scale_param {/* NDIS_RECEIVE_SCALE_PARAMETERS */ +struct ndis_obj_header hdr; + +/* Qualifies the rest of the information */ +u16 flag; + +/* The base CPU number to do receive processing. not used */ +u16 base_cpu_number; + +/* This describes the hash function and type being enabled */ +u32 hashinfo; + +/* The size of indirection table array */ +u16 indirect_tabsize; + +/* The offset of the indirection table from the beginning of this +* structure +*/ +u32 indirect_taboffset; + +/* The size of the hash secret key */ +u16 hashkey_size; + +/* The offset of the secret key from the beginning of this structure */ +u32 kashkey_offset; + +u32 processor_masks_offset; +u32 num_processor_masks; +u32 processor_masks_entry_size; +}; +/* Fwd declaration */ struct hv_netvsc_packet ;struct ndis_tcp_ip_checksum_info ;
@@ -39,6 +129,8 @@ struct xferpage_packet {/* # of netvsc packets this xfer packet contains */ u32 count; + +struct vmbus_channel *channel; };/*
@@ -54,6 +146,9 @@ struct hv_netvsc_packet {bool is_data_pkt;u16 vlan_tci; +u16 q_idx; +struct vmbus_channel *channel; +/* * Valid only for receives when we break a xfer page packet * into multiple netvsc packets
@@ -120,6 +215,7 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,int netvsc_recv_callback (struct hv_device *device_obj,struct hv_netvsc_packet *packet,struct ndis_tcp_ip_checksum_info *csum_info); +void netvsc_channel_cb (void *context);int rndis_filter_open (struct hv_device *dev);int rndis_filter_close (struct hv_device *dev); int rndis_filter_device_add(struct hv_device *dev,
@@ -522,6 +618,8 @@ struct nvsp_message {#define NETVSC_PACKET_SIZE 2048 +#define VRSS_SEND_TAB_SIZE 16 +/* Per netvsc channel-specific */ struct netvsc_device {struct hv_device *dev;
@@ -555,10 +653,20 @@ struct netvsc_device {struct net_device *ndev; +struct vmbus_channel *chn_table[NR_CPUS ]; +u32 send_table[VRSS_SEND_TAB_SIZE ]; +u32 num_chn; +atomic_t queue_sends[NR_CPUS ]; +/* Holds rndis device info */ void *extension; -/* The recive buffer for this device */ + +int ring_size; + +/* The primary channel callback buffer */ unsigned char cb_buffer[NETVSC_PACKET_SIZE ]; +/* The sub channel callback buffer */ +unsigned char *sub_cb_buf; };/* NdisInitialize message */
drivers/net/hyperv/netvsc.c +109 -27
292 lines not on this page · raw message
drivers/net/hyperv/netvsc_drv.c +100 -3
153 lines not on this page · raw message
drivers/net/hyperv/rndis_filter.c +186 -3
243 lines not on this page · raw message
Signature · 1 line
1.7.4.1
From: Haiyang Zhang <[email protected]>
Date: Thu, 20 Mar 2014 15:28:41 -0700
Quoted 5 lines
This feature allows multiple channels to be used by each virtual NIC. It is available on Hyper-V host 2012 R2.
Signed-off-by Haiyang Zhang <[email protected]>Reviewed-by K. Y. Srinivasan <[email protected]>
Applied, thanks.
David Miller
maintainerFrom: David Miller <[email protected]>
Date: Fri, 21 Mar 2014 14:49:57 -0400 (EDT)
Quoted 10 lines
From: Haiyang Zhang <[email protected]>
Date: Thu, 20 Mar 2014 15:28:41 -0700Quoted 5 lines
This feature allows multiple channels to be used by each virtual NIC. It is available on Hyper-V host 2012 R2.
Signed-off-by Haiyang Zhang <[email protected]>Reviewed-by K. Y. Srinivasan <[email protected]>Applied, thanks.
Actually I had to revert, this doesn't even compile.
drivers/net/hyperv/netvsc.c: In function ‘netvsc_channel_cb’:drivers/net/hyperv/netvsc.c:891:2: error: implicit declaration of function ‘get_per_channel_state’ [-Werror=implicit-function-declaration] drivers/net/hyperv/netvsc.c:891:9: warning: assignment makes pointer from integer without a cast [enabled by default] drivers/net/hyperv/netvsc.c: In function ‘netvsc_device_add’:drivers/net/hyperv/netvsc.c:998:2: error: implicit declaration of function ‘set_per_channel_state’ [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[3]: *** [drivers/net/hyperv/netvsc.o] Error 1
make[3]: *** Waiting for unfinished jobs....drivers/net/hyperv/rndis_filter.c: In function ‘netvsc_sc_open’:drivers/net/hyperv/rndis_filter.c:988:2: error: implicit declaration of function ‘set_per_channel_state’ [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[3]: *** [drivers/net/hyperv/rndis_filter.o] Error 1
make[2]: *** [drivers/net/hyperv] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [drivers/net] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [drivers] Error 2
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Haiyang Zhang
maintainerQuoted 41 lines
-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Friday, March 21, 2014 2:55 PM
To: Haiyang Zhang
Cc: [email protected]; KY Srinivasan; [email protected]; [email protected]; [email protected]; driverdev- [email protected]
Subject: Re: [PATCH net-next,v4] hyperv: Add support for virtual Receive Side Scaling (vRSS)From: David Miller <[email protected]>
Date: Fri, 21 Mar 2014 14:49:57 -0400 (EDT)Quoted 10 lines
From: Haiyang Zhang <[email protected]>
Date: Thu, 20 Mar 2014 15:28:41 -0700Quoted 5 lines
This feature allows multiple channels to be used by each virtual NIC. It is available on Hyper-V host 2012 R2.
Signed-off-by Haiyang Zhang <[email protected]>Reviewed-by K. Y. Srinivasan <[email protected]>Applied, thanks.
Actually I had to revert, this doesn't even compile.
drivers/net/hyperv/netvsc.c: In function ‘netvsc_channel_cb’:drivers/net/hyperv/netvsc.c:891:2: error: implicit declaration of function ‘get_per_channel_state’ [-Werror=implicit-function-declaration]drivers/net/hyperv/netvsc.c:891:9: warning: assignment makes pointer from integer without a cast [enabled by default]drivers/net/hyperv/netvsc.c: In function ‘netvsc_device_add’:drivers/net/hyperv/netvsc.c:998:2: error: implicit declaration of function ‘set_per_channel_state’ [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[3]: *** [drivers/net/hyperv/netvsc.o] Error 1
make[3]: *** Waiting for unfinished jobs....drivers/net/hyperv/rndis_filter.c: In function ‘netvsc_sc_open’:drivers/net/hyperv/rndis_filter.c:988:2: error: implicit declaration of
Quoted 8 lines
function ‘set_per_channel_state’ [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[3]: *** [drivers/net/hyperv/rndis_filter.o] Error 1 make[2]: *** [drivers/net/hyperv] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [drivers/net] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [drivers] Error 2
The per channel state variable and functions are defined by this patch, which has been applied on 2/07:
Drivers: hv: vmbus: Support per-channel driver state
http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=8a7206a89f85c8439561b0eff85bb9440a2e97a9
Could it be merged into net-next tree?
Thanks,
- Haiyang
David Miller
maintainerFrom: Haiyang Zhang <[email protected]>
Date: Fri, 21 Mar 2014 19:12:43 +0000
Quoted 1 line
Could it be merged into net-next tree?
You submitted a patch against net-next, that means you are implicitly stating that all dependencies are in place in _that_ tree and that you tested it in _that_ tree.
If the situation is otherwise you must explicitly state this in your patch submission.
Haiyang Zhang
maintainerQuoted 15 lines
-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Friday, March 21, 2014 3:33 PM
To: Haiyang Zhang
Cc: [email protected]; KY Srinivasan; [email protected]; [email protected]; [email protected]; driverdev- [email protected]
Subject: Re: [PATCH net-next,v4] hyperv: Add support for virtual Receive Side Scaling (vRSS)From: Haiyang Zhang <[email protected]>
Date: Fri, 21 Mar 2014 19:12:43 +0000
Quoted 8 lines
Quoted 1 line
Could it be merged into net-next tree?
You submitted a patch against net-next, that means you are implicitly stating that all dependencies are in place in _that_ tree and that you tested it in _that_ tree.
If the situation is otherwise you must explicitly state this in your patch submission.
I will re-submit the vRSS patch with the dependency specified. Thanks,
- Haiyang