37
37
* Switch the data path from the synthetic interface to the VF
38
38
* interface.
39
39
*/
40
- void netvsc_switch_datapath (struct netvsc_device * nv_dev , bool vf )
40
+ void netvsc_switch_datapath (struct net_device * ndev , bool vf )
41
41
{
42
- struct nvsp_message * init_pkt = & nv_dev -> channel_init_pkt ;
43
- struct net_device * ndev = nv_dev -> ndev ;
44
42
struct net_device_context * net_device_ctx = netdev_priv (ndev );
45
43
struct hv_device * dev = net_device_ctx -> device_ctx ;
44
+ struct netvsc_device * nv_dev = net_device_ctx -> nvdev ;
45
+ struct nvsp_message * init_pkt = & nv_dev -> channel_init_pkt ;
46
46
47
47
memset (init_pkt , 0 , sizeof (struct nvsp_message ));
48
48
init_pkt -> hdr .msg_type = NVSP_MSG4_TYPE_SWITCH_DATA_PATH ;
@@ -80,7 +80,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
80
80
net_device -> destroy = false;
81
81
atomic_set (& net_device -> open_cnt , 0 );
82
82
atomic_set (& net_device -> vf_use_cnt , 0 );
83
- net_device -> ndev = ndev ;
84
83
net_device -> max_pkt = RNDIS_MAX_PKT_DEFAULT ;
85
84
net_device -> pkt_align = RNDIS_PKT_ALIGN_DEFAULT ;
86
85
@@ -263,7 +262,7 @@ static int netvsc_init_buf(struct hv_device *device)
263
262
net_device = get_outbound_net_device (device );
264
263
if (!net_device )
265
264
return - ENODEV ;
266
- ndev = net_device -> ndev ;
265
+ ndev = hv_get_drvdata ( device ) ;
267
266
268
267
node = cpu_to_node (device -> channel -> target_cpu );
269
268
net_device -> recv_buf = vzalloc_node (net_device -> recv_buf_size , node );
@@ -453,6 +452,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
453
452
struct nvsp_message * init_packet ,
454
453
u32 nvsp_ver )
455
454
{
455
+ struct net_device * ndev = hv_get_drvdata (device );
456
456
int ret ;
457
457
unsigned long t ;
458
458
@@ -486,8 +486,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
486
486
/* NVSPv2 or later: Send NDIS config */
487
487
memset (init_packet , 0 , sizeof (struct nvsp_message ));
488
488
init_packet -> hdr .msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG ;
489
- init_packet -> msg .v2_msg .send_ndis_config .mtu = net_device -> ndev -> mtu +
490
- ETH_HLEN ;
489
+ init_packet -> msg .v2_msg .send_ndis_config .mtu = ndev -> mtu + ETH_HLEN ;
491
490
init_packet -> msg .v2_msg .send_ndis_config .capability .ieee8021q = 1 ;
492
491
493
492
if (nvsp_ver >= NVSP_PROTOCOL_VERSION_5 )
@@ -507,15 +506,13 @@ static int netvsc_connect_vsp(struct hv_device *device)
507
506
struct netvsc_device * net_device ;
508
507
struct nvsp_message * init_packet ;
509
508
int ndis_version ;
510
- struct net_device * ndev ;
511
509
u32 ver_list [] = { NVSP_PROTOCOL_VERSION_1 , NVSP_PROTOCOL_VERSION_2 ,
512
510
NVSP_PROTOCOL_VERSION_4 , NVSP_PROTOCOL_VERSION_5 };
513
511
int i , num_ver = 4 ; /* number of different NVSP versions */
514
512
515
513
net_device = get_outbound_net_device (device );
516
514
if (!net_device )
517
515
return - ENODEV ;
518
- ndev = net_device -> ndev ;
519
516
520
517
init_packet = & net_device -> channel_init_pkt ;
521
518
@@ -768,6 +765,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
768
765
}
769
766
770
767
static inline int netvsc_send_pkt (
768
+ struct hv_device * device ,
771
769
struct hv_netvsc_packet * packet ,
772
770
struct netvsc_device * net_device ,
773
771
struct hv_page_buffer * * pb ,
@@ -776,7 +774,7 @@ static inline int netvsc_send_pkt(
776
774
struct nvsp_message nvmsg ;
777
775
u16 q_idx = packet -> q_idx ;
778
776
struct vmbus_channel * out_channel = net_device -> chn_table [q_idx ];
779
- struct net_device * ndev = net_device -> ndev ;
777
+ struct net_device * ndev = hv_get_drvdata ( device ) ;
780
778
u64 req_id ;
781
779
int ret ;
782
780
struct hv_page_buffer * pgbuf ;
@@ -971,7 +969,8 @@ int netvsc_send(struct hv_device *device,
971
969
}
972
970
973
971
if (msd_send ) {
974
- m_ret = netvsc_send_pkt (msd_send , net_device , NULL , msd_skb );
972
+ m_ret = netvsc_send_pkt (device , msd_send , net_device ,
973
+ NULL , msd_skb );
975
974
976
975
if (m_ret != 0 ) {
977
976
netvsc_free_send_slot (net_device ,
@@ -982,7 +981,7 @@ int netvsc_send(struct hv_device *device,
982
981
983
982
send_now :
984
983
if (cur_send )
985
- ret = netvsc_send_pkt (cur_send , net_device , pb , skb );
984
+ ret = netvsc_send_pkt (device , cur_send , net_device , pb , skb );
986
985
987
986
if (ret != 0 && section_index != NETVSC_INVALID_INDEX )
988
987
netvsc_free_send_slot (net_device , section_index );
@@ -998,9 +997,7 @@ static void netvsc_send_recv_completion(struct hv_device *device,
998
997
struct nvsp_message recvcompMessage ;
999
998
int retries = 0 ;
1000
999
int ret ;
1001
- struct net_device * ndev ;
1002
-
1003
- ndev = net_device -> ndev ;
1000
+ struct net_device * ndev = hv_get_drvdata (device );
1004
1001
1005
1002
recvcompMessage .hdr .msg_type =
1006
1003
NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE ;
@@ -1047,11 +1044,9 @@ static void netvsc_receive(struct netvsc_device *net_device,
1047
1044
u32 status = NVSP_STAT_SUCCESS ;
1048
1045
int i ;
1049
1046
int count = 0 ;
1050
- struct net_device * ndev ;
1047
+ struct net_device * ndev = hv_get_drvdata ( device ) ;
1051
1048
void * data ;
1052
1049
1053
- ndev = net_device -> ndev ;
1054
-
1055
1050
/*
1056
1051
* All inbound packets other than send completion should be xfer page
1057
1052
* packet
@@ -1107,14 +1102,13 @@ static void netvsc_send_table(struct hv_device *hdev,
1107
1102
struct nvsp_message * nvmsg )
1108
1103
{
1109
1104
struct netvsc_device * nvscdev ;
1110
- struct net_device * ndev ;
1105
+ struct net_device * ndev = hv_get_drvdata ( hdev ) ;
1111
1106
int i ;
1112
1107
u32 count , * tab ;
1113
1108
1114
1109
nvscdev = get_outbound_net_device (hdev );
1115
1110
if (!nvscdev )
1116
1111
return ;
1117
- ndev = nvscdev -> ndev ;
1118
1112
1119
1113
count = nvmsg -> msg .v5_msg .send_table .count ;
1120
1114
if (count != VRSS_SEND_TAB_SIZE ) {
@@ -1173,7 +1167,7 @@ void netvsc_channel_cb(void *context)
1173
1167
net_device = get_inbound_net_device (device );
1174
1168
if (!net_device )
1175
1169
return ;
1176
- ndev = net_device -> ndev ;
1170
+ ndev = hv_get_drvdata ( device ) ;
1177
1171
buffer = get_per_channel_state (channel );
1178
1172
1179
1173
do {
0 commit comments