Skip to content

Commit f90251c

Browse files
haiyangzdavem330
authored andcommitted
hyperv: Increase the buffer length for netvsc_channel_cb()
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>
1 parent c9d2642 commit f90251c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

drivers/net/hyperv/hyperv_net.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ struct nvsp_message {
591591

592592
#define NETVSC_RECEIVE_BUFFER_ID 0xcafe
593593

594-
#define NETVSC_PACKET_SIZE 2048
594+
#define NETVSC_PACKET_SIZE 4096
595595

596596
#define VRSS_SEND_TAB_SIZE 16
597597

@@ -642,7 +642,7 @@ struct netvsc_device {
642642
int ring_size;
643643

644644
/* The primary channel callback buffer */
645-
unsigned char cb_buffer[NETVSC_PACKET_SIZE];
645+
unsigned char *cb_buffer;
646646
/* The sub channel callback buffer */
647647
unsigned char *sub_cb_buf;
648648
};

drivers/net/hyperv/netvsc.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
4242
if (!net_device)
4343
return NULL;
4444

45+
net_device->cb_buffer = kzalloc(NETVSC_PACKET_SIZE, GFP_KERNEL);
46+
if (!net_device->cb_buffer) {
47+
kfree(net_device);
48+
return NULL;
49+
}
50+
4551
init_waitqueue_head(&net_device->wait_drain);
4652
net_device->start_remove = false;
4753
net_device->destroy = false;
@@ -52,6 +58,12 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
5258
return net_device;
5359
}
5460

61+
static void free_netvsc_device(struct netvsc_device *nvdev)
62+
{
63+
kfree(nvdev->cb_buffer);
64+
kfree(nvdev);
65+
}
66+
5567
static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
5668
{
5769
struct netvsc_device *net_device;
@@ -551,7 +563,7 @@ int netvsc_device_remove(struct hv_device *device)
551563
if (net_device->sub_cb_buf)
552564
vfree(net_device->sub_cb_buf);
553565

554-
kfree(net_device);
566+
free_netvsc_device(net_device);
555567
return 0;
556568
}
557569

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

10951107
cleanup:
1096-
kfree(net_device);
1108+
free_netvsc_device(net_device);
10971109

10981110
return ret;
10991111
}

0 commit comments

Comments
 (0)