Skip to content

Commit

Permalink
hyperv: Increase the buffer length for netvsc_channel_cb()
Browse files Browse the repository at this point in the history
When the buffer is too small for a packet from VMBus, a bigger buffer will be
allocated in netvsc_channel_cb() and retry reading the packet from VMBus.
Increasing this buffer size will reduce the retry overhead.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Haiyang Zhang authored and David S. Miller committed Aug 22, 2014
1 parent c9d2642 commit f90251c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions drivers/net/hyperv/hyperv_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ struct nvsp_message {

#define NETVSC_RECEIVE_BUFFER_ID 0xcafe

#define NETVSC_PACKET_SIZE 2048
#define NETVSC_PACKET_SIZE 4096

#define VRSS_SEND_TAB_SIZE 16

Expand Down Expand Up @@ -642,7 +642,7 @@ struct netvsc_device {
int ring_size;

/* The primary channel callback buffer */
unsigned char cb_buffer[NETVSC_PACKET_SIZE];
unsigned char *cb_buffer;
/* The sub channel callback buffer */
unsigned char *sub_cb_buf;
};
Expand Down
16 changes: 14 additions & 2 deletions drivers/net/hyperv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
if (!net_device)
return NULL;

net_device->cb_buffer = kzalloc(NETVSC_PACKET_SIZE, GFP_KERNEL);
if (!net_device->cb_buffer) {
kfree(net_device);
return NULL;
}

init_waitqueue_head(&net_device->wait_drain);
net_device->start_remove = false;
net_device->destroy = false;
Expand All @@ -52,6 +58,12 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
return net_device;
}

static void free_netvsc_device(struct netvsc_device *nvdev)
{
kfree(nvdev->cb_buffer);
kfree(nvdev);
}

static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
{
struct netvsc_device *net_device;
Expand Down Expand Up @@ -551,7 +563,7 @@ int netvsc_device_remove(struct hv_device *device)
if (net_device->sub_cb_buf)
vfree(net_device->sub_cb_buf);

kfree(net_device);
free_netvsc_device(net_device);
return 0;
}

Expand Down Expand Up @@ -1093,7 +1105,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
vmbus_close(device->channel);

cleanup:
kfree(net_device);
free_netvsc_device(net_device);

return ret;
}

0 comments on commit f90251c

Please sign in to comment.