From f3abc6eaf55f109abea4d244459376e5a3e3568b Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Thu, 21 Apr 2011 12:30:44 -0700 Subject: [PATCH] --- yaml --- r: 249103 b: refs/heads/master c: 0021e71e9fde72a65a5f4bedd51964af9ab4fb4a h: refs/heads/master i: 249101: d36f55f3777d5f0674fcedf8b6cf95b77e430912 249099: e3d95412fe51ada30168fa60dfc17d5ad220958f 249095: a23543d9c33df5965a46217c4ee68b157af2a2ef 249087: c9f126e41a2f2ff25a74cc65594f37964bb00510 v: v3 --- [refs] | 2 +- trunk/drivers/staging/hv/netvsc.c | 130 +++++++++++++++--------------- 2 files changed, 65 insertions(+), 67 deletions(-) diff --git a/[refs] b/[refs] index 80651e4ef318..53ea22f6246b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ec91cd09b153d896d14bb2882d6128a97f00ff41 +refs/heads/master: 0021e71e9fde72a65a5f4bedd51964af9ab4fb4a diff --git a/trunk/drivers/staging/hv/netvsc.c b/trunk/drivers/staging/hv/netvsc.c index 8b2defd86969..75640eab94fd 100644 --- a/trunk/drivers/staging/hv/netvsc.c +++ b/trunk/drivers/staging/hv/netvsc.c @@ -51,8 +51,6 @@ static int netvsc_init_send_buf(struct hv_device *device); static int netvsc_init_recv_buf(struct hv_device *device); -static int netvsc_destroy_send_buf(struct netvsc_device *net_device); - static int netvsc_connect_vsp(struct hv_device *device); static void netvsc_send_completion(struct hv_device *device, @@ -343,6 +341,70 @@ static int netvsc_init_recv_buf(struct hv_device *device) return ret; } +static int netvsc_destroy_send_buf(struct netvsc_device *net_device) +{ + struct nvsp_message *revoke_packet; + int ret = 0; + + /* + * If we got a section count, it means we received a + * SendReceiveBufferComplete msg (ie sent + * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need + * to send a revoke msg here + */ + if (net_device->send_section_size) { + /* Send the revoke send buffer */ + revoke_packet = &net_device->revoke_packet; + memset(revoke_packet, 0, sizeof(struct nvsp_message)); + + revoke_packet->hdr.msg_type = + NVSP_MSG1_TYPE_REVOKE_SEND_BUF; + revoke_packet->msg.v1_msg. + revoke_send_buf.id = NETVSC_SEND_BUFFER_ID; + + ret = vmbus_sendpacket(net_device->dev->channel, + revoke_packet, + sizeof(struct nvsp_message), + (unsigned long)revoke_packet, + VM_PKT_DATA_INBAND, 0); + /* + * If we failed here, we might as well return and have a leak + * rather than continue and a bugchk + */ + if (ret != 0) { + dev_err(&net_device->dev->device, "unable to send " + "revoke send buffer to netvsp"); + return -1; + } + } + + /* Teardown the gpadl on the vsp end */ + if (net_device->send_buf_gpadl_handle) { + ret = vmbus_teardown_gpadl(net_device->dev->channel, + net_device->send_buf_gpadl_handle); + + /* + * If we failed here, we might as well return and have a leak + * rather than continue and a bugchk + */ + if (ret != 0) { + dev_err(&net_device->dev->device, + "unable to teardown send buffer's gpadl"); + return -1; + } + net_device->send_buf_gpadl_handle = 0; + } + + if (net_device->send_buf) { + /* Free up the receive buffer */ + free_pages((unsigned long)net_device->send_buf, + get_order(net_device->send_buf_size)); + net_device->send_buf = NULL; + } + + return ret; +} + static int netvsc_init_send_buf(struct hv_device *device) { int ret = 0; @@ -436,70 +498,6 @@ static int netvsc_init_send_buf(struct hv_device *device) return ret; } -static int netvsc_destroy_send_buf(struct netvsc_device *net_device) -{ - struct nvsp_message *revoke_packet; - int ret = 0; - - /* - * If we got a section count, it means we received a - * SendReceiveBufferComplete msg (ie sent - * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need - * to send a revoke msg here - */ - if (net_device->send_section_size) { - /* Send the revoke send buffer */ - revoke_packet = &net_device->revoke_packet; - memset(revoke_packet, 0, sizeof(struct nvsp_message)); - - revoke_packet->hdr.msg_type = - NVSP_MSG1_TYPE_REVOKE_SEND_BUF; - revoke_packet->msg.v1_msg. - revoke_send_buf.id = NETVSC_SEND_BUFFER_ID; - - ret = vmbus_sendpacket(net_device->dev->channel, - revoke_packet, - sizeof(struct nvsp_message), - (unsigned long)revoke_packet, - VM_PKT_DATA_INBAND, 0); - /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk - */ - if (ret != 0) { - dev_err(&net_device->dev->device, "unable to send " - "revoke send buffer to netvsp"); - return -1; - } - } - - /* Teardown the gpadl on the vsp end */ - if (net_device->send_buf_gpadl_handle) { - ret = vmbus_teardown_gpadl(net_device->dev->channel, - net_device->send_buf_gpadl_handle); - - /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk - */ - if (ret != 0) { - dev_err(&net_device->dev->device, - "unable to teardown send buffer's gpadl"); - return -1; - } - net_device->send_buf_gpadl_handle = 0; - } - - if (net_device->send_buf) { - /* Free up the receive buffer */ - free_pages((unsigned long)net_device->send_buf, - get_order(net_device->send_buf_size)); - net_device->send_buf = NULL; - } - - return ret; -} - static int netvsc_connect_vsp(struct hv_device *device) {