Drivers: net: hyperv: Cleanup the hyper-V networking code
Subsystems (3)
cover Drivers: net: hyperv: Cleanup the hyper-V networking code
Get rid of some unnecessary code and some general cleanup.
K. Y. Srinivasan (3):
Drivers: net: hyperv: Get rid of the rndis_filter_packet structure
Drivers: net: hyperv: Cleanup the receive path
Drivers: net: hyperv: Cleanup the netvsc receive callback functio
drivers/net/hyperv/hyperv_net.h | 8 +--- drivers/net/hyperv/netvsc.c | 62 +++++++++++++----------------------- drivers/net/hyperv/netvsc_drv.c | 2 +- drivers/net/hyperv/rndis_filter.c | 41 ++---------------------- 4 files changed, 29 insertions(+), 84 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/3 Drivers: net: hyperv: Get rid of the rndis_filter_packet structure
This structure is redundant; get rid of it make the code little more efficient - get rid of the unnecessary indirection.
--- drivers/net/hyperv/hyperv_net.h | 6 ----- drivers/net/hyperv/netvsc_drv.c | 2 +- drivers/net/hyperv/rndis_filter.c | 41 ++---------------------------------- 3 files changed, 4 insertions(+), 45 deletions(-)
drivers/net/hyperv/hyperv_net.h +0 -6
@@ -846,12 +846,6 @@ struct rndis_message { }; -struct rndis_filter_packet { -void *completion_ctx; -void (*completion)(void *context); -struct rndis_message msg; -}; -/* Handy macros */ /* get the size of an RNDIS message. Pass in the message type, */
drivers/net/hyperv/netvsc_drv.c +1 -1
@@ -155,7 +155,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)/* Allocate a netvsc packet based on # of frags. */ packet =kzalloc (sizeof (struct hv_netvsc_packet ) + (num_pages *sizeof (struct hv_page_buffer )) + -sizeof (struct rndis_filter_packet ) + +sizeof (struct rndis_message ) +NDIS_VLAN_PPI_SIZE ,GFP_ATOMIC );if (!packet) {/* out of memory, drop packet */
drivers/net/hyperv/rndis_filter.c +3 -38
70 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 2/3 Drivers: net: hyperv: Cleanup the receive path
Make the receive path a little more efficient by parameterizing the required state rather than re-establishing that state.
--- drivers/net/hyperv/netvsc.c | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 deletions(-)
drivers/net/hyperv/netvsc.c +13 -16
@@ -432,17 +432,14 @@ static inline u32 hv_ringbuf_avail_percent(return avail_write *100 / ring_info->ring_datasize; } -static void netvsc_send_completion (struct hv_device *device, +static void netvsc_send_completion (struct netvsc_device *net_device, +struct hv_device *device,struct vmpacket_descriptor *packet) { -struct netvsc_device *net_device;struct nvsp_message *nvsp_packet;struct hv_netvsc_packet *nvsc_packet;struct net_device *ndev; - net_device =get_inbound_net_device (device); -if (!net_device) -return ; ndev = net_device->ndev; nvsp_packet = (struct nvsp_message *)((unsigned long)packet +
@@ -561,13 +558,13 @@ int netvsc_send(struct hv_device *device, }static void netvsc_send_recv_completion (struct hv_device *device, +struct netvsc_device *net_device,u64 transaction_id,u32 status) {struct nvsp_message recvcompMessage;int retries =0 ;int ret;struct net_device *ndev; -struct netvsc_device *net_device =hv_get_drvdata (device); ndev = net_device->ndev;
@@ -653,14 +650,15 @@ static void netvsc_receive_completion(void *context)/* Send a receive completion for the xfer page packet */ if (fsend_receive_comp) -netvsc_send_recv_completion (device, transaction_id, status); +netvsc_send_recv_completion (device, net_device, transaction_id, + status); } -static void netvsc_receive (struct hv_device *device, -struct vmpacket_descriptor *packet) +static void netvsc_receive (struct netvsc_device *net_device, +struct hv_device *device, +struct vmpacket_descriptor *packet) { -struct netvsc_device *net_device;struct vmtransfer_page_packet_header *vmxferpage_packet;struct nvsp_message *nvsp_packet;struct hv_netvsc_packet *netvsc_packet =NULL ;
@@ -673,9 +671,6 @@ static void netvsc_receive(struct hv_device *device,LIST_HEAD (listHead); - net_device =get_inbound_net_device (device); -if (!net_device) -return ; ndev = net_device->ndev;/*
@@ -741,7 +736,7 @@ static void netvsc_receive(struct hv_device *device,spin_unlock_irqrestore (&net_device->recv_pkt_list_lock, flags); -netvsc_send_recv_completion (device, +netvsc_send_recv_completion (device, net_device, vmxferpage_packet->d.trans_id,NVSP_STAT_FAIL );
@@ -825,11 +820,13 @@ static void netvsc_channel_cb(void *context) desc = (struct vmpacket_descriptor *)buffer;switch (desc->type) {case VM_PKT_COMP : -netvsc_send_completion (device, desc); +netvsc_send_completion (net_device, + device, desc);break ;case VM_PKT_DATA_USING_XFER_PAGES : -netvsc_receive (device, desc); +netvsc_receive (net_device, + device, desc);break ;default :
Signature · 1 line
1.7.4.1
PATCH 3/3 Drivers: net: hyperv: Cleanup the netvsc receive callback functio
In reply to K. Y. SrinivasanGet rid of the buffer allocation in the receive path for normal packets.
--- drivers/net/hyperv/hyperv_net.h | 2 ++ drivers/net/hyperv/netvsc.c | 33 ++++++++++----------------------- 2 files changed, 12 insertions(+), 23 deletions(-)
drivers/net/hyperv/hyperv_net.h +2 -0
@@ -506,6 +506,8 @@ struct netvsc_device {/* Holds rndis device info */ void *extension; +/* The recive buffer for this device */ +unsigned char cb_buffer[NETVSC_PACKET_SIZE ]; };/* NdisInitialize message */
drivers/net/hyperv/netvsc.c +10 -23
@@ -795,22 +795,16 @@ static void netvsc_channel_cb(void *context)struct netvsc_device *net_device;u32 bytes_recvd;u64 request_id; -unsigned char *packet;struct vmpacket_descriptor *desc;unsigned char *buffer;int bufferlen =NETVSC_PACKET_SIZE ;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);if (!net_device) - goto out; +return ; ndev = net_device->ndev; + buffer = net_device->cb_buffer; do { ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen,
@@ -838,23 +832,16 @@ static void netvsc_channel_cb(void *context)break ; } -/* reset */ -if (bufferlen >NETVSC_PACKET_SIZE ) { -kfree (buffer); - buffer = packet; - bufferlen =NETVSC_PACKET_SIZE ; - } }else { -/* reset */ -if (bufferlen >NETVSC_PACKET_SIZE ) { -kfree (buffer); - buffer = packet; - bufferlen =NETVSC_PACKET_SIZE ; - } - +/* +* We are done for this pass. +*/ break ; } + }else if (ret == -ENOBUFS ) { +if (bufferlen >NETVSC_PACKET_SIZE ) +kfree (buffer);/* Handle large packet */ buffer =kmalloc (bytes_recvd,GFP_ATOMIC );if (buffer ==NULL ) {
@@ -869,8 +856,8 @@ static void netvsc_channel_cb(void *context) } }while (1 ); -out: -kfree (buffer); +if (bufferlen >NETVSC_PACKET_SIZE ) +kfree (buffer);return ; }
Signature · 1 line
1.7.4.1
David Miller
maintainerFrom: "K. Y. Srinivasan" <[email protected]>
Date: Sun, 16 Feb 2014 16:38:03 -0800
Quoted 6 lines
Get rid of some unnecessary code and some general cleanup.
K. Y. Srinivasan (3):
Drivers: net: hyperv: Get rid of therndis_filter_packetstructure
Drivers: net: hyperv: Cleanup the receive path
Drivers: net: hyperv: Cleanup the netvsc receive callback functio
Series applied to net-next, thanks.