diff options
author | KY Srinivasan <kys@microsoft.com> | 2014-02-16 19:38:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-02-17 16:32:32 -0500 |
commit | ee0c4c39c577d07c05749a5f5b960b4c0fdd8097 (patch) | |
tree | 42a97ee254d656633279282567286397652bc935 /drivers/net/hyperv | |
parent | 97c1723a6177790a3a5b8c1173ed0b03571d4e06 (diff) |
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: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/hyperv')
-rw-r--r-- | drivers/net/hyperv/hyperv_net.h | 2 | ||||
-rw-r--r-- | drivers/net/hyperv/netvsc.c | 33 |
2 files changed, 12 insertions, 23 deletions
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 7645ba38bde8..01a16ea77a5a 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h | |||
@@ -506,6 +506,8 @@ struct netvsc_device { | |||
506 | 506 | ||
507 | /* Holds rndis device info */ | 507 | /* Holds rndis device info */ |
508 | void *extension; | 508 | void *extension; |
509 | /* The recive buffer for this device */ | ||
510 | unsigned char cb_buffer[NETVSC_PACKET_SIZE]; | ||
509 | }; | 511 | }; |
510 | 512 | ||
511 | /* NdisInitialize message */ | 513 | /* NdisInitialize message */ |
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 7fa2bbade327..9a0e9c6f1414 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c | |||
@@ -795,22 +795,16 @@ static void netvsc_channel_cb(void *context) | |||
795 | struct netvsc_device *net_device; | 795 | struct netvsc_device *net_device; |
796 | u32 bytes_recvd; | 796 | u32 bytes_recvd; |
797 | u64 request_id; | 797 | u64 request_id; |
798 | unsigned char *packet; | ||
799 | struct vmpacket_descriptor *desc; | 798 | struct vmpacket_descriptor *desc; |
800 | unsigned char *buffer; | 799 | unsigned char *buffer; |
801 | int bufferlen = NETVSC_PACKET_SIZE; | 800 | int bufferlen = NETVSC_PACKET_SIZE; |
802 | struct net_device *ndev; | 801 | struct net_device *ndev; |
803 | 802 | ||
804 | packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char), | ||
805 | GFP_ATOMIC); | ||
806 | if (!packet) | ||
807 | return; | ||
808 | buffer = packet; | ||
809 | |||
810 | net_device = get_inbound_net_device(device); | 803 | net_device = get_inbound_net_device(device); |
811 | if (!net_device) | 804 | if (!net_device) |
812 | goto out; | 805 | return; |
813 | ndev = net_device->ndev; | 806 | ndev = net_device->ndev; |
807 | buffer = net_device->cb_buffer; | ||
814 | 808 | ||
815 | do { | 809 | do { |
816 | ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, | 810 | ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, |
@@ -838,23 +832,16 @@ static void netvsc_channel_cb(void *context) | |||
838 | break; | 832 | break; |
839 | } | 833 | } |
840 | 834 | ||
841 | /* reset */ | ||
842 | if (bufferlen > NETVSC_PACKET_SIZE) { | ||
843 | kfree(buffer); | ||
844 | buffer = packet; | ||
845 | bufferlen = NETVSC_PACKET_SIZE; | ||
846 | } | ||
847 | } else { | 835 | } else { |
848 | /* reset */ | 836 | /* |
849 | if (bufferlen > NETVSC_PACKET_SIZE) { | 837 | * We are done for this pass. |
850 | kfree(buffer); | 838 | */ |
851 | buffer = packet; | ||
852 | bufferlen = NETVSC_PACKET_SIZE; | ||
853 | } | ||
854 | |||
855 | break; | 839 | break; |
856 | } | 840 | } |
841 | |||
857 | } else if (ret == -ENOBUFS) { | 842 | } else if (ret == -ENOBUFS) { |
843 | if (bufferlen > NETVSC_PACKET_SIZE) | ||
844 | kfree(buffer); | ||
858 | /* Handle large packet */ | 845 | /* Handle large packet */ |
859 | buffer = kmalloc(bytes_recvd, GFP_ATOMIC); | 846 | buffer = kmalloc(bytes_recvd, GFP_ATOMIC); |
860 | if (buffer == NULL) { | 847 | if (buffer == NULL) { |
@@ -869,8 +856,8 @@ static void netvsc_channel_cb(void *context) | |||
869 | } | 856 | } |
870 | } while (1); | 857 | } while (1); |
871 | 858 | ||
872 | out: | 859 | if (bufferlen > NETVSC_PACKET_SIZE) |
873 | kfree(buffer); | 860 | kfree(buffer); |
874 | return; | 861 | return; |
875 | } | 862 | } |
876 | 863 | ||