@@ -453,13 +453,16 @@ static int negotiate_nvsp_ver(struct hv_device *device,
453453 if (nvsp_ver == NVSP_PROTOCOL_VERSION_1 )
454454 return 0 ;
455455
456- /* NVSPv2 only : Send NDIS config */
456+ /* NVSPv2 or later : Send NDIS config */
457457 memset (init_packet , 0 , sizeof (struct nvsp_message ));
458458 init_packet -> hdr .msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG ;
459459 init_packet -> msg .v2_msg .send_ndis_config .mtu = net_device -> ndev -> mtu +
460460 ETH_HLEN ;
461461 init_packet -> msg .v2_msg .send_ndis_config .capability .ieee8021q = 1 ;
462462
463+ if (nvsp_ver >= NVSP_PROTOCOL_VERSION_5 )
464+ init_packet -> msg .v2_msg .send_ndis_config .capability .sriov = 1 ;
465+
463466 ret = vmbus_sendpacket (device -> channel , init_packet ,
464467 sizeof (struct nvsp_message ),
465468 (unsigned long )init_packet ,
@@ -1064,11 +1067,10 @@ static void netvsc_receive(struct netvsc_device *net_device,
10641067
10651068
10661069static void netvsc_send_table (struct hv_device * hdev ,
1067- struct vmpacket_descriptor * vmpkt )
1070+ struct nvsp_message * nvmsg )
10681071{
10691072 struct netvsc_device * nvscdev ;
10701073 struct net_device * ndev ;
1071- struct nvsp_message * nvmsg ;
10721074 int i ;
10731075 u32 count , * tab ;
10741076
@@ -1077,12 +1079,6 @@ static void netvsc_send_table(struct hv_device *hdev,
10771079 return ;
10781080 ndev = nvscdev -> ndev ;
10791081
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-
10861082 count = nvmsg -> msg .v5_msg .send_table .count ;
10871083 if (count != VRSS_SEND_TAB_SIZE ) {
10881084 netdev_err (ndev , "Received wrong send-table size:%u\n" , count );
@@ -1096,6 +1092,28 @@ static void netvsc_send_table(struct hv_device *hdev,
10961092 nvscdev -> send_table [i ] = tab [i ];
10971093}
10981094
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+
10991117void netvsc_channel_cb (void * context )
11001118{
11011119 int ret ;
@@ -1108,6 +1126,7 @@ void netvsc_channel_cb(void *context)
11081126 unsigned char * buffer ;
11091127 int bufferlen = NETVSC_PACKET_SIZE ;
11101128 struct net_device * ndev ;
1129+ struct nvsp_message * nvmsg ;
11111130
11121131 if (channel -> primary_channel != NULL )
11131132 device = channel -> primary_channel -> device_obj ;
@@ -1126,6 +1145,8 @@ void netvsc_channel_cb(void *context)
11261145 if (ret == 0 ) {
11271146 if (bytes_recvd > 0 ) {
11281147 desc = (struct vmpacket_descriptor * )buffer ;
1148+ nvmsg = (struct nvsp_message * )((unsigned long )
1149+ desc + (desc -> offset8 << 3 ));
11291150 switch (desc -> type ) {
11301151 case VM_PKT_COMP :
11311152 netvsc_send_completion (net_device ,
@@ -1138,7 +1159,9 @@ void netvsc_channel_cb(void *context)
11381159 break ;
11391160
11401161 case VM_PKT_DATA_INBAND :
1141- netvsc_send_table (device , desc );
1162+ netvsc_receive_inband (device ,
1163+ net_device ,
1164+ nvmsg );
11421165 break ;
11431166
11441167 default :
0 commit comments