Commit ee0c4c39 authored by KY Srinivasan's avatar KY Srinivasan Committed by David S. Miller

Drivers: net: hyperv: Cleanup the netvsc receive callback functio

Get rid of the buffer allocation in the receive path for normal packets.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 97c1723a
...@@ -506,6 +506,8 @@ struct netvsc_device { ...@@ -506,6 +506,8 @@ struct netvsc_device {
/* Holds rndis device info */ /* Holds rndis device info */
void *extension; void *extension;
/* The recive buffer for this device */
unsigned char cb_buffer[NETVSC_PACKET_SIZE];
}; };
/* NdisInitialize message */ /* NdisInitialize message */
......
...@@ -795,22 +795,16 @@ static void netvsc_channel_cb(void *context) ...@@ -795,22 +795,16 @@ static void netvsc_channel_cb(void *context)
struct netvsc_device *net_device; struct netvsc_device *net_device;
u32 bytes_recvd; u32 bytes_recvd;
u64 request_id; u64 request_id;
unsigned char *packet;
struct vmpacket_descriptor *desc; struct vmpacket_descriptor *desc;
unsigned char *buffer; unsigned char *buffer;
int bufferlen = NETVSC_PACKET_SIZE; int bufferlen = NETVSC_PACKET_SIZE;
struct net_device *ndev; struct net_device *ndev;
packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char),
GFP_ATOMIC);
if (!packet)
return;
buffer = packet;
net_device = get_inbound_net_device(device); net_device = get_inbound_net_device(device);
if (!net_device) if (!net_device)
goto out; return;
ndev = net_device->ndev; ndev = net_device->ndev;
buffer = net_device->cb_buffer;
do { do {
ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen,
...@@ -838,23 +832,16 @@ static void netvsc_channel_cb(void *context) ...@@ -838,23 +832,16 @@ static void netvsc_channel_cb(void *context)
break; break;
} }
/* reset */
if (bufferlen > NETVSC_PACKET_SIZE) {
kfree(buffer);
buffer = packet;
bufferlen = NETVSC_PACKET_SIZE;
}
} else { } else {
/* reset */ /*
if (bufferlen > NETVSC_PACKET_SIZE) { * We are done for this pass.
kfree(buffer); */
buffer = packet;
bufferlen = NETVSC_PACKET_SIZE;
}
break; break;
} }
} else if (ret == -ENOBUFS) { } else if (ret == -ENOBUFS) {
if (bufferlen > NETVSC_PACKET_SIZE)
kfree(buffer);
/* Handle large packet */ /* Handle large packet */
buffer = kmalloc(bytes_recvd, GFP_ATOMIC); buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
if (buffer == NULL) { if (buffer == NULL) {
...@@ -869,7 +856,7 @@ static void netvsc_channel_cb(void *context) ...@@ -869,7 +856,7 @@ static void netvsc_channel_cb(void *context)
} }
} while (1); } while (1);
out: if (bufferlen > NETVSC_PACKET_SIZE)
kfree(buffer); kfree(buffer);
return; return;
} }
......
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