@@ -453,13 +453,16 @@ static int negotiate_nvsp_ver(struct hv_device *device,
453
453
if (nvsp_ver == NVSP_PROTOCOL_VERSION_1 )
454
454
return 0 ;
455
455
456
- /* NVSPv2 only : Send NDIS config */
456
+ /* NVSPv2 or later : Send NDIS config */
457
457
memset (init_packet , 0 , sizeof (struct nvsp_message ));
458
458
init_packet -> hdr .msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG ;
459
459
init_packet -> msg .v2_msg .send_ndis_config .mtu = net_device -> ndev -> mtu +
460
460
ETH_HLEN ;
461
461
init_packet -> msg .v2_msg .send_ndis_config .capability .ieee8021q = 1 ;
462
462
463
+ if (nvsp_ver >= NVSP_PROTOCOL_VERSION_5 )
464
+ init_packet -> msg .v2_msg .send_ndis_config .capability .sriov = 1 ;
465
+
463
466
ret = vmbus_sendpacket (device -> channel , init_packet ,
464
467
sizeof (struct nvsp_message ),
465
468
(unsigned long )init_packet ,
@@ -1064,11 +1067,10 @@ static void netvsc_receive(struct netvsc_device *net_device,
1064
1067
1065
1068
1066
1069
static void netvsc_send_table (struct hv_device * hdev ,
1067
- struct vmpacket_descriptor * vmpkt )
1070
+ struct nvsp_message * nvmsg )
1068
1071
{
1069
1072
struct netvsc_device * nvscdev ;
1070
1073
struct net_device * ndev ;
1071
- struct nvsp_message * nvmsg ;
1072
1074
int i ;
1073
1075
u32 count , * tab ;
1074
1076
@@ -1077,12 +1079,6 @@ static void netvsc_send_table(struct hv_device *hdev,
1077
1079
return ;
1078
1080
ndev = nvscdev -> ndev ;
1079
1081
1080
- nvmsg = (struct nvsp_message * )((unsigned long )vmpkt +
1081
- (vmpkt -> offset8 << 3 ));
1082
-
1083
- if (nvmsg -> hdr .msg_type != NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE )
1084
- return ;
1085
-
1086
1082
count = nvmsg -> msg .v5_msg .send_table .count ;
1087
1083
if (count != VRSS_SEND_TAB_SIZE ) {
1088
1084
netdev_err (ndev , "Received wrong send-table size:%u\n" , count );
@@ -1096,6 +1092,28 @@ static void netvsc_send_table(struct hv_device *hdev,
1096
1092
nvscdev -> send_table [i ] = tab [i ];
1097
1093
}
1098
1094
1095
+ static void netvsc_send_vf (struct netvsc_device * nvdev ,
1096
+ struct nvsp_message * nvmsg )
1097
+ {
1098
+ nvdev -> vf_alloc = nvmsg -> msg .v4_msg .vf_assoc .allocated ;
1099
+ nvdev -> vf_serial = nvmsg -> msg .v4_msg .vf_assoc .serial ;
1100
+ }
1101
+
1102
+ static inline void netvsc_receive_inband (struct hv_device * hdev ,
1103
+ struct netvsc_device * nvdev ,
1104
+ struct nvsp_message * nvmsg )
1105
+ {
1106
+ switch (nvmsg -> hdr .msg_type ) {
1107
+ case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE :
1108
+ netvsc_send_table (hdev , nvmsg );
1109
+ break ;
1110
+
1111
+ case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION :
1112
+ netvsc_send_vf (nvdev , nvmsg );
1113
+ break ;
1114
+ }
1115
+ }
1116
+
1099
1117
void netvsc_channel_cb (void * context )
1100
1118
{
1101
1119
int ret ;
@@ -1108,6 +1126,7 @@ void netvsc_channel_cb(void *context)
1108
1126
unsigned char * buffer ;
1109
1127
int bufferlen = NETVSC_PACKET_SIZE ;
1110
1128
struct net_device * ndev ;
1129
+ struct nvsp_message * nvmsg ;
1111
1130
1112
1131
if (channel -> primary_channel != NULL )
1113
1132
device = channel -> primary_channel -> device_obj ;
@@ -1126,6 +1145,8 @@ void netvsc_channel_cb(void *context)
1126
1145
if (ret == 0 ) {
1127
1146
if (bytes_recvd > 0 ) {
1128
1147
desc = (struct vmpacket_descriptor * )buffer ;
1148
+ nvmsg = (struct nvsp_message * )((unsigned long )
1149
+ desc + (desc -> offset8 << 3 ));
1129
1150
switch (desc -> type ) {
1130
1151
case VM_PKT_COMP :
1131
1152
netvsc_send_completion (net_device ,
@@ -1138,7 +1159,9 @@ void netvsc_channel_cb(void *context)
1138
1159
break ;
1139
1160
1140
1161
case VM_PKT_DATA_INBAND :
1141
- netvsc_send_table (device , desc );
1162
+ netvsc_receive_inband (device ,
1163
+ net_device ,
1164
+ nvmsg );
1142
1165
break ;
1143
1166
1144
1167
default :
0 commit comments