Commit 95790837 authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

netvsc: pass net_device to netvsc_init_buf and netvsc_connect_vsp

Don't need to find netvsc_device structure, caller already had it.
Also rearrange declarations.
Signed-off-by: default avatarStephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2d694d2a
...@@ -243,18 +243,15 @@ static void netvsc_destroy_buf(struct hv_device *device) ...@@ -243,18 +243,15 @@ static void netvsc_destroy_buf(struct hv_device *device)
kfree(net_device->send_section_map); kfree(net_device->send_section_map);
} }
static int netvsc_init_buf(struct hv_device *device) static int netvsc_init_buf(struct hv_device *device,
struct netvsc_device *net_device)
{ {
int ret = 0; int ret = 0;
struct netvsc_device *net_device;
struct nvsp_message *init_packet; struct nvsp_message *init_packet;
struct net_device *ndev; struct net_device *ndev;
size_t map_words; size_t map_words;
int node; int node;
net_device = get_outbound_net_device(device);
if (!net_device)
return -ENODEV;
ndev = hv_get_drvdata(device); ndev = hv_get_drvdata(device);
node = cpu_to_node(device->channel->target_cpu); node = cpu_to_node(device->channel->target_cpu);
...@@ -285,9 +282,7 @@ static int netvsc_init_buf(struct hv_device *device) ...@@ -285,9 +282,7 @@ static int netvsc_init_buf(struct hv_device *device)
/* Notify the NetVsp of the gpadl handle */ /* Notify the NetVsp of the gpadl handle */
init_packet = &net_device->channel_init_pkt; init_packet = &net_device->channel_init_pkt;
memset(init_packet, 0, sizeof(struct nvsp_message)); memset(init_packet, 0, sizeof(struct nvsp_message));
init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_RECV_BUF; init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_RECV_BUF;
init_packet->msg.v1_msg.send_recv_buf. init_packet->msg.v1_msg.send_recv_buf.
gpadl_handle = net_device->recv_buf_gpadl_handle; gpadl_handle = net_device->recv_buf_gpadl_handle;
...@@ -486,20 +481,15 @@ static int negotiate_nvsp_ver(struct hv_device *device, ...@@ -486,20 +481,15 @@ static int negotiate_nvsp_ver(struct hv_device *device,
return ret; return ret;
} }
static int netvsc_connect_vsp(struct hv_device *device) static int netvsc_connect_vsp(struct hv_device *device,
struct netvsc_device *net_device)
{ {
int ret;
struct netvsc_device *net_device;
struct nvsp_message *init_packet;
int ndis_version;
const u32 ver_list[] = { const u32 ver_list[] = {
NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2, NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5 }; NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5
int i; };
struct nvsp_message *init_packet;
net_device = get_outbound_net_device(device); int ndis_version, i, ret;
if (!net_device)
return -ENODEV;
init_packet = &net_device->channel_init_pkt; init_packet = &net_device->channel_init_pkt;
...@@ -549,7 +539,7 @@ static int netvsc_connect_vsp(struct hv_device *device) ...@@ -549,7 +539,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE; net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
net_device->send_buf_size = NETVSC_SEND_BUFFER_SIZE; net_device->send_buf_size = NETVSC_SEND_BUFFER_SIZE;
ret = netvsc_init_buf(device); ret = netvsc_init_buf(device, net_device);
cleanup: cleanup:
return ret; return ret;
...@@ -1349,7 +1339,7 @@ int netvsc_device_add(struct hv_device *device, ...@@ -1349,7 +1339,7 @@ int netvsc_device_add(struct hv_device *device,
rcu_assign_pointer(net_device_ctx->nvdev, net_device); rcu_assign_pointer(net_device_ctx->nvdev, net_device);
/* Connect with the NetVsp */ /* Connect with the NetVsp */
ret = netvsc_connect_vsp(device); ret = netvsc_connect_vsp(device, net_device);
if (ret != 0) { if (ret != 0) {
netdev_err(ndev, netdev_err(ndev,
"unable to connect to NetVSP - %d\n", ret); "unable to connect to NetVSP - %d\n", ret);
...@@ -1368,4 +1358,5 @@ int netvsc_device_add(struct hv_device *device, ...@@ -1368,4 +1358,5 @@ int netvsc_device_add(struct hv_device *device,
free_netvsc_device(&net_device->rcu); free_netvsc_device(&net_device->rcu);
return ret; return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment