netvsc bug fixes and cleanups
Subsystems (2)
cover netvsc bug fixes and cleanups
Fixed a set of bugs in netvsc module, and cleaned up some coding style issues.
Haiyang Zhang (9):
staging: hv: remove unnecessary includes in netvsc
staging: hv: add newline to log messages in netvsc
staging: hv: convert dev_<loglevel> to netdev_<loglevel> in netvsc
staging: hv: fix a kernel warning in netvsc_linkstatus_callback()
staging: hv: re-order the code in netvsc_probe()
staging: hv: fix counting of #outstanding-sends in failed sends
staging: hv: fix counting of available buffer slots when send fails
staging: hv: fix the return status of netvsc_start_xmit()
staging: hv: fix the page buffer when rndis data go across page
boundary
drivers/staging/hv/netvsc.c | 124 ++++++++++++++++++++----------------- drivers/staging/hv/netvsc_drv.c | 46 +++++++------- drivers/staging/hv/rndis_filter.c | 28 ++++++--- 3 files changed, 111 insertions(+), 87 deletions(-)
PATCH 1/9 staging: hv: remove unnecessary includes in netvsc
hyperv.h is included by hyperv_net.h already, so no need to include it again in these C files.
--- drivers/staging/hv/netvsc.c | 1 - drivers/staging/hv/netvsc_drv.c | 1 - drivers/staging/hv/rndis_filter.c | 1 - 3 files changed, 0 insertions(+), 3 deletions(-)
drivers/staging/hv/netvsc.c +0 -1
@@ -29,7 +29,6 @@#include <linux/io.h> #include <linux/slab.h> -#include "hyperv.h" #include "hyperv_net.h"
drivers/staging/hv/netvsc_drv.c +0 -1
@@ -38,7 +38,6 @@#include <net/sock.h> #include <net/pkt_sched.h> -#include "hyperv.h" #include "hyperv_net.h" static const char *driver_name ="netvsc" ;
drivers/staging/hv/rndis_filter.c +0 -1
@@ -27,7 +27,6 @@#include <linux/if_ether.h> #include <linux/netdevice.h> -#include "hyperv.h" #include "hyperv_net.h"
Signature · 1 line
1.6.3.2
PATCH 3/9 staging: hv: convert dev_<loglevel> to netdev_<loglevel> in netvsc
In reply to Haiyang Zhang--- drivers/staging/hv/netvsc.c | 68 +++++++++++++++++++++---------------- drivers/staging/hv/rndis_filter.c | 17 +++++---- 2 files changed, 49 insertions(+), 36 deletions(-)
drivers/staging/hv/netvsc.c +39 -29
@@ -28,6 +28,7 @@#include <linux/delay.h> #include <linux/io.h> #include <linux/slab.h> +#include <linux/netdevice.h> #include "hyperv_net.h"
@@ -111,6 +112,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) {struct nvsp_message *revoke_packet;int ret =0 ; +struct net_device *ndev =dev_get_drvdata (&net_device->dev->device);/* * If we got a section count, it means we received a
@@ -138,7 +140,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)* have a leak rather than continue and a bugchk */ if (ret !=0 ) { -dev_err (&net_device->dev->device,"unable to send " +netdev_err (ndev,"unable to send " "revoke receive buffer to netvsp\n" );return ret; }
@@ -153,7 +155,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)* rather than continue and a bugchk */ if (ret !=0 ) { -dev_err (&net_device->dev->device, +netdev_err (ndev,"unable to teardown receive buffer's gpadl\n" );return -ret; }
@@ -182,10 +184,11 @@ static int netvsc_init_recv_buf(struct hv_device *device)int t;struct netvsc_device *net_device;struct nvsp_message *init_packet; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =get_outbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return -ENODEV ; }
@@ -194,7 +197,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) (void *)__get_free_pages (GFP_KERNEL |__GFP_ZERO,get_order (net_device->recv_buf_size));if (!net_device->recv_buf) { -dev_err (&device->device,"unable to allocate receive " +netdev_err (ndev,"unable to allocate receive " "buffer of size %d\n" , net_device->recv_buf_size); ret = -ENOMEM ; goto cleanup;
@@ -209,7 +212,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) net_device->recv_buf_size, &net_device->recv_buf_gpadl_handle);if (ret !=0 ) { -dev_err (&device->device, +netdev_err (ndev,"unable to establish receive buffer's gpadl\n" ); goto cleanup; }
@@ -233,7 +236,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)VM_PKT_DATA_INBAND , VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);if (ret !=0 ) { -dev_err (&device->device, +netdev_err (ndev,"unable to send receive buffer's gpadl to netvsp\n" ); goto cleanup; }
@@ -245,7 +248,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)/* Check the response */ if (init_packet->msg.v1_msg. send_recv_buf_complete.status !=NVSP_STAT_SUCCESS ) { -dev_err (&device->device,"Unable to complete receive buffer " +netdev_err (ndev,"Unable to complete receive buffer " "initialzation with NetVsp - status %d\n" , init_packet->msg.v1_msg. send_recv_buf_complete.status);
@@ -298,10 +301,11 @@ static int netvsc_connect_vsp(struct hv_device *device)struct netvsc_device *net_device;struct nvsp_message *init_packet;int ndis_version; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =get_outbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return -ENODEV ; }
@@ -400,7 +404,7 @@ int netvsc_device_remove(struct hv_device *device)/* Wait for all send completions */ while (atomic_read (&net_device->num_outstanding_sends)) { -dev_err (&device->device, +dev_info (&device->device,"waiting for %d requests to complete...\n" ,atomic_read (&net_device->num_outstanding_sends));udelay (100 );
@@ -447,10 +451,11 @@ static void netvsc_send_completion(struct hv_device *device,struct netvsc_device *net_device;struct nvsp_message *nvsp_packet;struct hv_netvsc_packet *nvsc_packet; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =get_inbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return ; }
@@ -479,7 +484,7 @@ static void netvsc_send_completion(struct hv_device *device,atomic_dec (&net_device->num_outstanding_sends); }else { -dev_err (&device->device,"Unknown send completion packet type- " +netdev_err (ndev,"Unknown send completion packet type- " "%d received!!\n" , nvsp_packet->hdr.msg_type); }
@@ -491,12 +496,12 @@ int netvsc_send(struct hv_device *device, {struct netvsc_device *net_device;int ret =0 ; -struct nvsp_message sendMessage; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =get_outbound_net_device (device);if (!net_device) { -dev_err (&device->device,"net device (%p) shutting down..." +netdev_err (ndev,"net device (%p) shutting down..." "ignoring outbound packets\n" , net_device);return -ENODEV ; }
@@ -532,7 +537,7 @@ int netvsc_send(struct hv_device *device, }if (ret !=0 ) -dev_err (&device->device,"Unable to send packet %p ret %d\n" , +netdev_err (ndev,"Unable to send packet %p ret %d\n" , packet, ret);atomic_inc (&net_device->num_outstanding_sends);
@@ -546,6 +551,7 @@ static void netvsc_send_recv_completion(struct hv_device *device,struct nvsp_message recvcompMessage;int retries =0 ;int ret; +struct net_device *ndev =dev_get_drvdata (&device->device); recvcompMessage.hdr.msg_type =NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE ;
@@ -565,19 +571,19 @@ retry_send_cmplt: }else if (ret == -EAGAIN ) {/* no more room...wait a bit and attempt to retry 3 times */ retries++; -dev_err (&device->device,"unable to send receive completion pkt" +netdev_err (ndev,"unable to send receive completion pkt" " (tid %llx)...retrying %d\n" , transaction_id, retries);if (retries <4 ) {udelay (100 ); goto retry_send_cmplt; }else { -dev_err (&device->device,"unable to send receive " +netdev_err (ndev,"unable to send receive " "completion pkt (tid %llx)...give up retrying\n" , transaction_id); } }else { -dev_err (&device->device,"unable to send receive " +netdev_err (ndev,"unable to send receive " "completion pkt - %llx\n" , transaction_id); } }
@@ -591,6 +597,7 @@ static void netvsc_receive_completion(void *context)u64 transaction_id =0 ;bool fsend_receive_comp = false;unsigned long flags; +struct net_device *ndev =dev_get_drvdata (&device->device);/* * Even though it seems logical to do a GetOutboundNetDevice() here to
@@ -599,7 +606,7 @@ static void netvsc_receive_completion(void *context)*/ net_device =get_inbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return ; }
@@ -646,12 +653,13 @@ static void netvsc_receive(struct hv_device *device,int i, j;int count =0 , bytes_remain =0 ;unsigned long flags; +struct net_device *ndev =dev_get_drvdata (&device->device);LIST_HEAD (listHead); net_device =get_inbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return ; }
@@ -661,7 +669,7 @@ static void netvsc_receive(struct hv_device *device,* packet */ if (packet->type !=VM_PKT_DATA_USING_XFER_PAGES ) { -dev_err (&device->device,"Unknown packet type received - %d\n" , +netdev_err (ndev,"Unknown packet type received - %d\n" , packet->type);put_net_device (device);return ;
@@ -673,7 +681,7 @@ static void netvsc_receive(struct hv_device *device,/* Make sure this is a valid nvsp packet */ if (nvsp_packet->hdr.msg_type !=NVSP_MSG1_TYPE_SEND_RNDIS_PKT ) { -dev_err (&device->device,"Unknown nvsp packet type received-" +netdev_err (ndev,"Unknown nvsp packet type received-" " %d\n" , nvsp_packet->hdr.msg_type);put_net_device (device);return ;
@@ -682,7 +690,7 @@ static void netvsc_receive(struct hv_device *device, vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet;if (vmxferpage_packet->xfer_pageset_id !=NETVSC_RECEIVE_BUFFER_ID ) { -dev_err (&device->device,"Invalid xfer page set id - " +netdev_err (ndev,"Invalid xfer page set id - " "expecting %x got %x\n" ,NETVSC_RECEIVE_BUFFER_ID , vmxferpage_packet->xfer_pageset_id);put_net_device (device);
@@ -709,7 +717,7 @@ static void netvsc_receive(struct hv_device *device,* some of the xfer page packet ranges... */ if (count <2 ) { -dev_err (&device->device,"Got only %d netvsc pkt...needed " +netdev_err (ndev,"Got only %d netvsc pkt...needed " "%d pkts. Dropping this xfer page packet completely!\n" , count, vmxferpage_packet->range_cnt +1 );
@@ -737,7 +745,7 @@ static void netvsc_receive(struct hv_device *device, xferpage_packet->count = count -1 ;if (xferpage_packet->count != vmxferpage_packet->range_cnt) { -dev_err (&device->device,"Needed %d netvsc pkts to satisy " +netdev_err (ndev,"Needed %d netvsc pkts to satisy " "this xfer page...got %d\n" , vmxferpage_packet->range_cnt, xferpage_packet->count); }
@@ -827,6 +835,7 @@ static void netvsc_channel_cb(void *context)struct vmpacket_descriptor *desc;unsigned char *buffer;int bufferlen =NETVSC_PACKET_SIZE ; +struct net_device *ndev =dev_get_drvdata (&device->device); packet =kzalloc (NETVSC_PACKET_SIZE *sizeof (unsigned char ),GFP_ATOMIC );
@@ -836,7 +845,7 @@ static void netvsc_channel_cb(void *context) net_device =get_inbound_net_device (device);if (!net_device) { -dev_err (&device->device,"net device (%p) shutting down..." +netdev_err (ndev,"net device (%p) shutting down..." "ignoring inbound packets\n" , net_device); goto out; }
@@ -857,7 +866,7 @@ static void netvsc_channel_cb(void *context)break ;default : - dev_err(&device->device, + netdev_err(ndev, "unhandled packet type %d, " "tid %llx len %d\n", desc->type, request_id,
@@ -886,7 +895,7 @@ static void netvsc_channel_cb(void *context) buffer =kmalloc (bytes_recvd,GFP_ATOMIC );if (buffer ==NULL ) {/* Try again next time around */ -dev_err (&device->device, +netdev_err (ndev,"unable to allocate buffer of size " "(%d)!!\n" , bytes_recvd);break ;
@@ -914,6 +923,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) ((struct netvsc_device_info *)additional_info)->ring_size;struct netvsc_device *net_device;struct hv_netvsc_packet *packet, *pos; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =alloc_net_device (device);if (!net_device) {
@@ -945,7 +955,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) netvsc_channel_cb, device);if (ret !=0 ) { -dev_err (&device->device,"unable to open channel: %d\n" , ret); +netdev_err (ndev,"unable to open channel: %d\n" , ret); goto cleanup; }
@@ -955,7 +965,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)/* Connect with the NetVsp */ ret =netvsc_connect_vsp (device);if (ret !=0 ) { -dev_err (&device->device, +netdev_err (ndev,"unable to connect to NetVSP - %d\n" , ret); goto close; }
drivers/staging/hv/rndis_filter.c +10 -7
@@ -249,6 +249,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,struct rndis_request *request =NULL ;bool found = false;unsigned long flags; +struct net_device *ndev =dev_get_drvdata (&dev->net_dev->dev->device);spin_lock_irqsave (&dev->request_lock, flags);list_for_each_entry (request, &dev->req_list, list_ent) {
@@ -269,7 +270,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,memcpy (&request->response_msg, resp, resp->msg_len); }else { - dev_err(&dev->net_dev->dev->device, + netdev_err(ndev, "rndis response buffer overflow " "detected (size %u max %zu)\n", resp->msg_len,
@@ -289,7 +290,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,complete (&request->wait_event); }else { - dev_err(&dev->net_dev->dev->device, + netdev_err(ndev, "no rndis request found for this response " "(id 0x%x res type 0x%x)\n", resp->msg.init_complete.req_id,
@@ -349,20 +350,21 @@ int rndis_filter_receive(struct hv_device *dev,struct rndis_device *rndis_dev;struct rndis_message rndis_msg;struct rndis_message *rndis_hdr; +struct net_device *ndev =dev_get_drvdata (&dev->device);if (!net_dev)return -EINVAL ;/* Make sure the rndis device state is initialized */ if (!net_dev->extension) { -dev_err (&dev->device,"got rndis message but no rndis device - " +netdev_err (ndev,"got rndis message but no rndis device - " "dropping this message!\n" );return -ENODEV ; } rndis_dev = (struct rndis_device *)net_dev->extension;if (rndis_dev->state ==RNDIS_DEV_UNINITIALIZED ) { -dev_err (&dev->device,"got rndis message but rndis device " +netdev_err (ndev,"got rndis message but rndis device " "uninitialized...dropping this message!\n" );return -ENODEV ; }
@@ -376,7 +378,7 @@ int rndis_filter_receive(struct hv_device *dev,/* Make sure we got a valid rndis message */ if ((rndis_hdr->ndis_msg_type !=REMOTE_NDIS_PACKET_MSG ) && (rndis_hdr->msg_len >sizeof (struct rndis_message ))) { -dev_err (&dev->device,"incoming rndis message buffer overflow " +netdev_err (ndev,"incoming rndis message buffer overflow " "detected (got %u, max %zu)..marking it an error!\n" , rndis_hdr->msg_len,sizeof (struct rndis_message ));
@@ -409,7 +411,7 @@ int rndis_filter_receive(struct hv_device *dev,rndis_filter_receive_indicate_status (rndis_dev, &rndis_msg);break ;default : -dev_err (&dev->device, +netdev_err (ndev,"unhandled rndis message (type %u len %u)\n" , rndis_msg.ndis_msg_type, rndis_msg.msg_len);
@@ -505,6 +507,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,struct rndis_set_complete *set_complete;u32 status;int ret, t; +struct net_device *ndev =dev_get_drvdata (&dev->net_dev->dev->device); request = get_rndis_request(dev, REMOTE_NDIS_SET_MSG, RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
@@ -530,7 +533,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, t =wait_for_completion_timeout (&request->wait_event,5 *HZ );if (t ==0 ) { -dev_err (&dev->net_dev->dev->device, +netdev_err (ndev,"timeout before we got a set response...\n" );/* * We can't deallocate the request since we may still receive a
Signature · 1 line
1.6.3.2
PATCH 2/9 staging: hv: add newline to log messages in netvsc
In reply to Haiyang Zhang--- drivers/staging/hv/netvsc.c | 58 +++++++++++++++++++------------------- drivers/staging/hv/netvsc_drv.c | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-)
drivers/staging/hv/netvsc.c +29 -29
@@ -139,7 +139,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)*/ if (ret !=0 ) {dev_err (&net_device->dev->device,"unable to send " -"revoke receive buffer to netvsp" ); +"revoke receive buffer to netvsp\n" );return ret; } }
@@ -154,7 +154,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)*/ if (ret !=0 ) {dev_err (&net_device->dev->device, -"unable to teardown receive buffer's gpadl" ); +"unable to teardown receive buffer's gpadl\n" );return -ret; } net_device->recv_buf_gpadl_handle =0 ;
@@ -186,7 +186,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) net_device =get_outbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return -ENODEV ; }
@@ -195,7 +195,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) get_order(net_device->recv_buf_size));if (!net_device->recv_buf) {dev_err (&device->device,"unable to allocate receive " -"buffer of size %d" , net_device->recv_buf_size); +"buffer of size %d\n" , net_device->recv_buf_size); ret = -ENOMEM ; goto cleanup; }
@@ -210,7 +210,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) &net_device->recv_buf_gpadl_handle);if (ret !=0 ) {dev_err (&device->device, -"unable to establish receive buffer's gpadl" ); +"unable to establish receive buffer's gpadl\n" ); goto cleanup; }
@@ -234,7 +234,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);if (ret !=0 ) {dev_err (&device->device, -"unable to send receive buffer's gpadl to netvsp" ); +"unable to send receive buffer's gpadl to netvsp\n" ); goto cleanup; }
@@ -246,7 +246,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)if (init_packet->msg.v1_msg. send_recv_buf_complete.status !=NVSP_STAT_SUCCESS ) {dev_err (&device->device,"Unable to complete receive buffer " -"initialzation with NetVsp - status %d" , +"initialzation with NetVsp - status %d\n" , init_packet->msg.v1_msg. send_recv_buf_complete.status); ret = -EINVAL ;
@@ -302,7 +302,7 @@ static int netvsc_connect_vsp(struct hv_device *device) net_device =get_outbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return -ENODEV ; }
@@ -401,7 +401,7 @@ int netvsc_device_remove(struct hv_device *device)/* Wait for all send completions */ while (atomic_read (&net_device->num_outstanding_sends)) {dev_err (&device->device, -"waiting for %d requests to complete..." , +"waiting for %d requests to complete...\n" ,atomic_read (&net_device->num_outstanding_sends));udelay (100 ); }
@@ -425,7 +425,7 @@ int netvsc_device_remove(struct hv_device *device)udelay (100 );/* At this point, no one should be accessing netDevice except in here */ -dev_notice (&device->device,"net device safe to remove" ); +dev_notice (&device->device,"net device safe to remove\n" );/* Now, we can close the channel safely */ vmbus_close (device->channel);
@@ -451,7 +451,7 @@ static void netvsc_send_completion(struct hv_device *device, net_device =get_inbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return ; }
@@ -480,7 +480,7 @@ static void netvsc_send_completion(struct hv_device *device,atomic_dec (&net_device->num_outstanding_sends); }else {dev_err (&device->device,"Unknown send completion packet type- " -"%d received!!" , nvsp_packet->hdr.msg_type); +"%d received!!\n" , nvsp_packet->hdr.msg_type); }put_net_device (device);
@@ -497,7 +497,7 @@ int netvsc_send(struct hv_device *device, net_device =get_outbound_net_device (device);if (!net_device) {dev_err (&device->device,"net device (%p) shutting down..." -"ignoring outbound packets" , net_device); +"ignoring outbound packets\n" , net_device);return -ENODEV ; }
@@ -532,7 +532,7 @@ int netvsc_send(struct hv_device *device, }if (ret !=0 ) -dev_err (&device->device,"Unable to send packet %p ret %d" , +dev_err (&device->device,"Unable to send packet %p ret %d\n" , packet, ret);atomic_inc (&net_device->num_outstanding_sends);
@@ -566,19 +566,19 @@ retry_send_cmplt:/* no more room...wait a bit and attempt to retry 3 times */ retries++;dev_err (&device->device,"unable to send receive completion pkt" -" (tid %llx)...retrying %d" , transaction_id, retries); +" (tid %llx)...retrying %d\n" , transaction_id, retries);if (retries <4 ) {udelay (100 ); goto retry_send_cmplt; }else {dev_err (&device->device,"unable to send receive " -"completion pkt (tid %llx)...give up retrying" , +"completion pkt (tid %llx)...give up retrying\n" , transaction_id); } }else {dev_err (&device->device,"unable to send receive " -"completion pkt - %llx" , transaction_id); +"completion pkt - %llx\n" , transaction_id); } }
@@ -600,7 +600,7 @@ static void netvsc_receive_completion(void *context) net_device =get_inbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return ; }
@@ -652,7 +652,7 @@ static void netvsc_receive(struct hv_device *device, net_device =get_inbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return ; }
@@ -661,7 +661,7 @@ static void netvsc_receive(struct hv_device *device,* packet */ if (packet->type !=VM_PKT_DATA_USING_XFER_PAGES ) { -dev_err (&device->device,"Unknown packet type received - %d" , +dev_err (&device->device,"Unknown packet type received - %d\n" , packet->type);put_net_device (device);return ;
@@ -674,7 +674,7 @@ static void netvsc_receive(struct hv_device *device,if (nvsp_packet->hdr.msg_type !=NVSP_MSG1_TYPE_SEND_RNDIS_PKT ) {dev_err (&device->device,"Unknown nvsp packet type received-" -" %d" , nvsp_packet->hdr.msg_type); +" %d\n" , nvsp_packet->hdr.msg_type);put_net_device (device);return ; }
@@ -683,7 +683,7 @@ static void netvsc_receive(struct hv_device *device,if (vmxferpage_packet->xfer_pageset_id !=NETVSC_RECEIVE_BUFFER_ID ) {dev_err (&device->device,"Invalid xfer page set id - " -"expecting %x got %x" ,NETVSC_RECEIVE_BUFFER_ID , +"expecting %x got %x\n" ,NETVSC_RECEIVE_BUFFER_ID , vmxferpage_packet->xfer_pageset_id);put_net_device (device);return ;
@@ -710,7 +710,7 @@ static void netvsc_receive(struct hv_device *device,*/ if (count <2 ) {dev_err (&device->device,"Got only %d netvsc pkt...needed " -"%d pkts. Dropping this xfer page packet completely!" , +"%d pkts. Dropping this xfer page packet completely!\n" , count, vmxferpage_packet->range_cnt +1 );/* Return it to the freelist */
@@ -738,7 +738,7 @@ static void netvsc_receive(struct hv_device *device,if (xferpage_packet->count != vmxferpage_packet->range_cnt) {dev_err (&device->device,"Needed %d netvsc pkts to satisy " -"this xfer page...got %d" , +"this xfer page...got %d\n" , vmxferpage_packet->range_cnt, xferpage_packet->count); }
@@ -837,7 +837,7 @@ static void netvsc_channel_cb(void *context) net_device =get_inbound_net_device (device);if (!net_device) {dev_err (&device->device,"net device (%p) shutting down..." -"ignoring inbound packets" , net_device); +"ignoring inbound packets\n" , net_device); goto out; }
@@ -888,7 +888,7 @@ static void netvsc_channel_cb(void *context)/* Try again next time around */ dev_err (&device->device,"unable to allocate buffer of size " -"(%d)!!" , bytes_recvd); +"(%d)!!\n" , bytes_recvd);break ; }
@@ -945,18 +945,18 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) netvsc_channel_cb, device);if (ret !=0 ) { -dev_err (&device->device,"unable to open channel: %d" , ret); +dev_err (&device->device,"unable to open channel: %d\n" , ret); goto cleanup; }/* Channel is opened */ -pr_info ("hv_netvsc channel opened successfully" ); +pr_info ("hv_netvsc channel opened successfully\n" );/* Connect with the NetVsp */ ret =netvsc_connect_vsp (device);if (ret !=0 ) {dev_err (&device->device, -"unable to connect to NetVSP - %d" , ret); +"unable to connect to NetVSP - %d\n" , ret); goto close; }
drivers/staging/hv/netvsc_drv.c +1 -1
@@ -446,7 +446,7 @@ static int __init netvsc_drv_init(void)struct hv_driver *drv = &netvsc_drv;int ret; -pr_info ("initializing...." ); +pr_info ("initializing....\n" ); drv->driver.name = driver_name;
Signature · 1 line
1.6.3.2
PATCH 7/9 staging: hv: fix counting of available buffer slots when send fails
In reply to Haiyang ZhangBecause the number of available buffer slots doesn't decrease for failed sends, we should not call netvsc_xmit_completion(), which increase the count of available slots. In this failed case, just free the memory is enough.
--- drivers/staging/hv/netvsc_drv.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/staging/hv/netvsc_drv.c +2 -1
@@ -192,7 +192,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) }else {/* we are shutting down or bus overloaded, just drop packet */ net->stats.tx_dropped++; -netvsc_xmit_completion (packet); +kfree (packet); +dev_kfree_skb_any (skb); }return NETDEV_TX_OK ;
Signature · 1 line
1.6.3.2
PATCH 8/9 staging: hv: fix the return status of netvsc_start_xmit()
In reply to Haiyang ZhangFix the return status, so the upper layer will retry if transmission fails.
--- drivers/staging/hv/netvsc_drv.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/netvsc_drv.c +3 -3
@@ -142,12 +142,12 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) (num_pages *sizeof (struct hv_page_buffer )) + sizeof(struct rndis_filter_packet), GFP_ATOMIC);if (!packet) { -/* out of memory, silently drop packet */ +/* out of memory, drop packet */ netdev_err (net,"unable to allocate hv_netvsc_packet\n" );dev_kfree_skb (skb); net->stats.tx_dropped++; -return NETDEV_TX_OK ; +return NETDEV_TX_BUSY ; } packet->extension = (void *)(unsigned long)packet +
@@ -196,7 +196,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)dev_kfree_skb_any (skb); } -return NETDEV_TX_OK ; +return ret ?NETDEV_TX_BUSY :NETDEV_TX_OK ; }/*
Signature · 1 line
1.6.3.2
PATCH 6/9 staging: hv: fix counting of #outstanding-sends in failed sends
In reply to Haiyang ZhangIf the packet failed to be sent, we shouldn't count it as the number of outstanding sends.
--- drivers/staging/hv/netvsc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/staging/hv/netvsc.c +2 -1
@@ -539,8 +539,9 @@ int netvsc_send(struct hv_device *device,if (ret !=0 )netdev_err (ndev,"Unable to send packet %p ret %d\n" , packet, ret); +else +atomic_inc (&net_device->num_outstanding_sends); -atomic_inc (&net_device->num_outstanding_sends);put_net_device (device);return ret; }
Signature · 1 line
1.6.3.2
PATCH 4/9 staging: hv: fix a kernel warning in netvsc_linkstatus_callback()
In reply to Haiyang Zhangnetif_notify_peers() caused a kernel warning in netvsc_linkstatus_callback(), because netvsc_linkstatus_callback() is within IRQ context. So we move the first call to netif_notify_peers() into queued work as well, but with zero delay.
In addition to "staging-next", this should also be back-ported to stable kernels 2.6.32 and later.
--- drivers/staging/hv/netvsc_drv.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/netvsc_drv.c +1 -1
@@ -216,8 +216,8 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,if (status ==1 ) {netif_carrier_on (net);netif_wake_queue (net); -netif_notify_peers (net); ndev_ctx =netdev_priv (net); +schedule_delayed_work (&ndev_ctx->dwork,0 );schedule_delayed_work (&ndev_ctx->dwork,msecs_to_jiffies (20 )); }else {netif_carrier_off (net);
Signature · 1 line
1.6.3.2
PATCH 9/9 staging: hv: fix the page buffer when rndis data go across page boundary
In reply to Haiyang ZhangIn rndis_filter_receive_data(), we need to drop the 0th page and move the rest of pages forward if the rndis data go across page boundary, otherwise the page offset will overflow.
--- drivers/staging/hv/rndis_filter.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/staging/hv/rndis_filter.c +10 -0
@@ -323,6 +323,7 @@ static void rndis_filter_receive_data(struct rndis_device *dev, {struct rndis_packet *rndis_pkt;u32 data_offset; +int i; rndis_pkt = &msg->msg.pkt;
@@ -338,6 +339,15 @@ static void rndis_filter_receive_data(struct rndis_device *dev, pkt->page_buf[0 ].offset += data_offset; pkt->page_buf[0 ].len -= data_offset; +/* Drop the 0th page, if rndis data go beyond page boundary */ +if (pkt->page_buf[0 ].offset >=PAGE_SIZE ) { + pkt->page_buf[1 ].offset = pkt->page_buf[0 ].offset -PAGE_SIZE ; + pkt->page_buf[1 ].len -= pkt->page_buf[1 ].offset; + pkt->page_buf_cnt--; +for (i =0 ; i < pkt->page_buf_cnt; i++) + pkt->page_buf[i] = pkt->page_buf[i+1 ]; + } + pkt->is_data_pkt = true;netvsc_recv_callback (dev->net_dev->dev, pkt);
Signature · 1 line
1.6.3.2
PATCH 1/9 staging: hv: remove unnecessary includes in netvsc
In reply to Haiyang Zhanghyperv.h is included by hyperv_net.h already, so no need to include it again in these C files.
--- drivers/staging/hv/netvsc.c | 1 - drivers/staging/hv/netvsc_drv.c | 1 - drivers/staging/hv/rndis_filter.c | 1 - 3 files changed, 0 insertions(+), 3 deletions(-)
drivers/staging/hv/netvsc.c +0 -1
@@ -29,7 +29,6 @@#include <linux/io.h> #include <linux/slab.h> -#include "hyperv.h" #include "hyperv_net.h"
drivers/staging/hv/netvsc_drv.c +0 -1
@@ -38,7 +38,6 @@#include <net/sock.h> #include <net/pkt_sched.h> -#include "hyperv.h" #include "hyperv_net.h" static const char *driver_name ="netvsc" ;
drivers/staging/hv/rndis_filter.c +0 -1
@@ -27,7 +27,6 @@#include <linux/if_ether.h> #include <linux/netdevice.h> -#include "hyperv.h" #include "hyperv_net.h"
Signature · 1 line
1.6.3.2
PATCH 2/9 staging: hv: add newline to log messages in netvsc
In reply to Haiyang Zhang--- drivers/staging/hv/netvsc.c | 58 +++++++++++++++++++------------------- drivers/staging/hv/netvsc_drv.c | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-)
drivers/staging/hv/netvsc.c +29 -29
@@ -139,7 +139,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)*/ if (ret !=0 ) {dev_err (&net_device->dev->device,"unable to send " -"revoke receive buffer to netvsp" ); +"revoke receive buffer to netvsp\n" );return ret; } }
@@ -154,7 +154,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)*/ if (ret !=0 ) {dev_err (&net_device->dev->device, -"unable to teardown receive buffer's gpadl" ); +"unable to teardown receive buffer's gpadl\n" );return -ret; } net_device->recv_buf_gpadl_handle =0 ;
@@ -186,7 +186,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) net_device =get_outbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return -ENODEV ; }
@@ -195,7 +195,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) get_order(net_device->recv_buf_size));if (!net_device->recv_buf) {dev_err (&device->device,"unable to allocate receive " -"buffer of size %d" , net_device->recv_buf_size); +"buffer of size %d\n" , net_device->recv_buf_size); ret = -ENOMEM ; goto cleanup; }
@@ -210,7 +210,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) &net_device->recv_buf_gpadl_handle);if (ret !=0 ) {dev_err (&device->device, -"unable to establish receive buffer's gpadl" ); +"unable to establish receive buffer's gpadl\n" ); goto cleanup; }
@@ -234,7 +234,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);if (ret !=0 ) {dev_err (&device->device, -"unable to send receive buffer's gpadl to netvsp" ); +"unable to send receive buffer's gpadl to netvsp\n" ); goto cleanup; }
@@ -246,7 +246,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)if (init_packet->msg.v1_msg. send_recv_buf_complete.status !=NVSP_STAT_SUCCESS ) {dev_err (&device->device,"Unable to complete receive buffer " -"initialzation with NetVsp - status %d" , +"initialzation with NetVsp - status %d\n" , init_packet->msg.v1_msg. send_recv_buf_complete.status); ret = -EINVAL ;
@@ -302,7 +302,7 @@ static int netvsc_connect_vsp(struct hv_device *device) net_device =get_outbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return -ENODEV ; }
@@ -401,7 +401,7 @@ int netvsc_device_remove(struct hv_device *device)/* Wait for all send completions */ while (atomic_read (&net_device->num_outstanding_sends)) {dev_err (&device->device, -"waiting for %d requests to complete..." , +"waiting for %d requests to complete...\n" ,atomic_read (&net_device->num_outstanding_sends));udelay (100 ); }
@@ -425,7 +425,7 @@ int netvsc_device_remove(struct hv_device *device)udelay (100 );/* At this point, no one should be accessing netDevice except in here */ -dev_notice (&device->device,"net device safe to remove" ); +dev_notice (&device->device,"net device safe to remove\n" );/* Now, we can close the channel safely */ vmbus_close (device->channel);
@@ -451,7 +451,7 @@ static void netvsc_send_completion(struct hv_device *device, net_device =get_inbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return ; }
@@ -480,7 +480,7 @@ static void netvsc_send_completion(struct hv_device *device,atomic_dec (&net_device->num_outstanding_sends); }else {dev_err (&device->device,"Unknown send completion packet type- " -"%d received!!" , nvsp_packet->hdr.msg_type); +"%d received!!\n" , nvsp_packet->hdr.msg_type); }put_net_device (device);
@@ -497,7 +497,7 @@ int netvsc_send(struct hv_device *device, net_device =get_outbound_net_device (device);if (!net_device) {dev_err (&device->device,"net device (%p) shutting down..." -"ignoring outbound packets" , net_device); +"ignoring outbound packets\n" , net_device);return -ENODEV ; }
@@ -532,7 +532,7 @@ int netvsc_send(struct hv_device *device, }if (ret !=0 ) -dev_err (&device->device,"Unable to send packet %p ret %d" , +dev_err (&device->device,"Unable to send packet %p ret %d\n" , packet, ret);atomic_inc (&net_device->num_outstanding_sends);
@@ -566,19 +566,19 @@ retry_send_cmplt:/* no more room...wait a bit and attempt to retry 3 times */ retries++;dev_err (&device->device,"unable to send receive completion pkt" -" (tid %llx)...retrying %d" , transaction_id, retries); +" (tid %llx)...retrying %d\n" , transaction_id, retries);if (retries <4 ) {udelay (100 ); goto retry_send_cmplt; }else {dev_err (&device->device,"unable to send receive " -"completion pkt (tid %llx)...give up retrying" , +"completion pkt (tid %llx)...give up retrying\n" , transaction_id); } }else {dev_err (&device->device,"unable to send receive " -"completion pkt - %llx" , transaction_id); +"completion pkt - %llx\n" , transaction_id); } }
@@ -600,7 +600,7 @@ static void netvsc_receive_completion(void *context) net_device =get_inbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return ; }
@@ -652,7 +652,7 @@ static void netvsc_receive(struct hv_device *device, net_device =get_inbound_net_device (device);if (!net_device) {dev_err (&device->device,"unable to get net device..." -"device being destroyed?" ); +"device being destroyed?\n" );return ; }
@@ -661,7 +661,7 @@ static void netvsc_receive(struct hv_device *device,* packet */ if (packet->type !=VM_PKT_DATA_USING_XFER_PAGES ) { -dev_err (&device->device,"Unknown packet type received - %d" , +dev_err (&device->device,"Unknown packet type received - %d\n" , packet->type);put_net_device (device);return ;
@@ -674,7 +674,7 @@ static void netvsc_receive(struct hv_device *device,if (nvsp_packet->hdr.msg_type !=NVSP_MSG1_TYPE_SEND_RNDIS_PKT ) {dev_err (&device->device,"Unknown nvsp packet type received-" -" %d" , nvsp_packet->hdr.msg_type); +" %d\n" , nvsp_packet->hdr.msg_type);put_net_device (device);return ; }
@@ -683,7 +683,7 @@ static void netvsc_receive(struct hv_device *device,if (vmxferpage_packet->xfer_pageset_id !=NETVSC_RECEIVE_BUFFER_ID ) {dev_err (&device->device,"Invalid xfer page set id - " -"expecting %x got %x" ,NETVSC_RECEIVE_BUFFER_ID , +"expecting %x got %x\n" ,NETVSC_RECEIVE_BUFFER_ID , vmxferpage_packet->xfer_pageset_id);put_net_device (device);return ;
@@ -710,7 +710,7 @@ static void netvsc_receive(struct hv_device *device,*/ if (count <2 ) {dev_err (&device->device,"Got only %d netvsc pkt...needed " -"%d pkts. Dropping this xfer page packet completely!" , +"%d pkts. Dropping this xfer page packet completely!\n" , count, vmxferpage_packet->range_cnt +1 );/* Return it to the freelist */
@@ -738,7 +738,7 @@ static void netvsc_receive(struct hv_device *device,if (xferpage_packet->count != vmxferpage_packet->range_cnt) {dev_err (&device->device,"Needed %d netvsc pkts to satisy " -"this xfer page...got %d" , +"this xfer page...got %d\n" , vmxferpage_packet->range_cnt, xferpage_packet->count); }
@@ -837,7 +837,7 @@ static void netvsc_channel_cb(void *context) net_device =get_inbound_net_device (device);if (!net_device) {dev_err (&device->device,"net device (%p) shutting down..." -"ignoring inbound packets" , net_device); +"ignoring inbound packets\n" , net_device); goto out; }
@@ -888,7 +888,7 @@ static void netvsc_channel_cb(void *context)/* Try again next time around */ dev_err (&device->device,"unable to allocate buffer of size " -"(%d)!!" , bytes_recvd); +"(%d)!!\n" , bytes_recvd);break ; }
@@ -945,18 +945,18 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) netvsc_channel_cb, device);if (ret !=0 ) { -dev_err (&device->device,"unable to open channel: %d" , ret); +dev_err (&device->device,"unable to open channel: %d\n" , ret); goto cleanup; }/* Channel is opened */ -pr_info ("hv_netvsc channel opened successfully" ); +pr_info ("hv_netvsc channel opened successfully\n" );/* Connect with the NetVsp */ ret =netvsc_connect_vsp (device);if (ret !=0 ) {dev_err (&device->device, -"unable to connect to NetVSP - %d" , ret); +"unable to connect to NetVSP - %d\n" , ret); goto close; }
drivers/staging/hv/netvsc_drv.c +1 -1
@@ -446,7 +446,7 @@ static int __init netvsc_drv_init(void)struct hv_driver *drv = &netvsc_drv;int ret; -pr_info ("initializing...." ); +pr_info ("initializing....\n" ); drv->driver.name = driver_name;
Signature · 1 line
1.6.3.2
PATCH 3/9 staging: hv: convert dev_<loglevel> to netdev_<loglevel> in netvsc
In reply to Haiyang Zhang--- drivers/staging/hv/netvsc.c | 68 +++++++++++++++++++++---------------- drivers/staging/hv/rndis_filter.c | 17 +++++---- 2 files changed, 49 insertions(+), 36 deletions(-)
drivers/staging/hv/netvsc.c +39 -29
@@ -28,6 +28,7 @@#include <linux/delay.h> #include <linux/io.h> #include <linux/slab.h> +#include <linux/netdevice.h> #include "hyperv_net.h"
@@ -111,6 +112,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) {struct nvsp_message *revoke_packet;int ret =0 ; +struct net_device *ndev =dev_get_drvdata (&net_device->dev->device);/* * If we got a section count, it means we received a
@@ -138,7 +140,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)* have a leak rather than continue and a bugchk */ if (ret !=0 ) { -dev_err (&net_device->dev->device,"unable to send " +netdev_err (ndev,"unable to send " "revoke receive buffer to netvsp\n" );return ret; }
@@ -153,7 +155,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)* rather than continue and a bugchk */ if (ret !=0 ) { -dev_err (&net_device->dev->device, +netdev_err (ndev,"unable to teardown receive buffer's gpadl\n" );return -ret; }
@@ -182,10 +184,11 @@ static int netvsc_init_recv_buf(struct hv_device *device)int t;struct netvsc_device *net_device;struct nvsp_message *init_packet; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =get_outbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return -ENODEV ; }
@@ -194,7 +197,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) (void *)__get_free_pages (GFP_KERNEL |__GFP_ZERO,get_order (net_device->recv_buf_size));if (!net_device->recv_buf) { -dev_err (&device->device,"unable to allocate receive " +netdev_err (ndev,"unable to allocate receive " "buffer of size %d\n" , net_device->recv_buf_size); ret = -ENOMEM ; goto cleanup;
@@ -209,7 +212,7 @@ static int netvsc_init_recv_buf(struct hv_device *device) net_device->recv_buf_size, &net_device->recv_buf_gpadl_handle);if (ret !=0 ) { -dev_err (&device->device, +netdev_err (ndev,"unable to establish receive buffer's gpadl\n" ); goto cleanup; }
@@ -233,7 +236,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)VM_PKT_DATA_INBAND , VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);if (ret !=0 ) { -dev_err (&device->device, +netdev_err (ndev,"unable to send receive buffer's gpadl to netvsp\n" ); goto cleanup; }
@@ -245,7 +248,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)/* Check the response */ if (init_packet->msg.v1_msg. send_recv_buf_complete.status !=NVSP_STAT_SUCCESS ) { -dev_err (&device->device,"Unable to complete receive buffer " +netdev_err (ndev,"Unable to complete receive buffer " "initialzation with NetVsp - status %d\n" , init_packet->msg.v1_msg. send_recv_buf_complete.status);
@@ -298,10 +301,11 @@ static int netvsc_connect_vsp(struct hv_device *device)struct netvsc_device *net_device;struct nvsp_message *init_packet;int ndis_version; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =get_outbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return -ENODEV ; }
@@ -400,7 +404,7 @@ int netvsc_device_remove(struct hv_device *device)/* Wait for all send completions */ while (atomic_read (&net_device->num_outstanding_sends)) { -dev_err (&device->device, +dev_info (&device->device,"waiting for %d requests to complete...\n" ,atomic_read (&net_device->num_outstanding_sends));udelay (100 );
@@ -447,10 +451,11 @@ static void netvsc_send_completion(struct hv_device *device,struct netvsc_device *net_device;struct nvsp_message *nvsp_packet;struct hv_netvsc_packet *nvsc_packet; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =get_inbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return ; }
@@ -479,7 +484,7 @@ static void netvsc_send_completion(struct hv_device *device,atomic_dec (&net_device->num_outstanding_sends); }else { -dev_err (&device->device,"Unknown send completion packet type- " +netdev_err (ndev,"Unknown send completion packet type- " "%d received!!\n" , nvsp_packet->hdr.msg_type); }
@@ -491,12 +496,12 @@ int netvsc_send(struct hv_device *device, {struct netvsc_device *net_device;int ret =0 ; -struct nvsp_message sendMessage; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =get_outbound_net_device (device);if (!net_device) { -dev_err (&device->device,"net device (%p) shutting down..." +netdev_err (ndev,"net device (%p) shutting down..." "ignoring outbound packets\n" , net_device);return -ENODEV ; }
@@ -532,7 +537,7 @@ int netvsc_send(struct hv_device *device, }if (ret !=0 ) -dev_err (&device->device,"Unable to send packet %p ret %d\n" , +netdev_err (ndev,"Unable to send packet %p ret %d\n" , packet, ret);atomic_inc (&net_device->num_outstanding_sends);
@@ -546,6 +551,7 @@ static void netvsc_send_recv_completion(struct hv_device *device,struct nvsp_message recvcompMessage;int retries =0 ;int ret; +struct net_device *ndev =dev_get_drvdata (&device->device); recvcompMessage.hdr.msg_type =NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE ;
@@ -565,19 +571,19 @@ retry_send_cmplt: }else if (ret == -EAGAIN ) {/* no more room...wait a bit and attempt to retry 3 times */ retries++; -dev_err (&device->device,"unable to send receive completion pkt" +netdev_err (ndev,"unable to send receive completion pkt" " (tid %llx)...retrying %d\n" , transaction_id, retries);if (retries <4 ) {udelay (100 ); goto retry_send_cmplt; }else { -dev_err (&device->device,"unable to send receive " +netdev_err (ndev,"unable to send receive " "completion pkt (tid %llx)...give up retrying\n" , transaction_id); } }else { -dev_err (&device->device,"unable to send receive " +netdev_err (ndev,"unable to send receive " "completion pkt - %llx\n" , transaction_id); } }
@@ -591,6 +597,7 @@ static void netvsc_receive_completion(void *context)u64 transaction_id =0 ;bool fsend_receive_comp = false;unsigned long flags; +struct net_device *ndev =dev_get_drvdata (&device->device);/* * Even though it seems logical to do a GetOutboundNetDevice() here to
@@ -599,7 +606,7 @@ static void netvsc_receive_completion(void *context)*/ net_device =get_inbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return ; }
@@ -646,12 +653,13 @@ static void netvsc_receive(struct hv_device *device,int i, j;int count =0 , bytes_remain =0 ;unsigned long flags; +struct net_device *ndev =dev_get_drvdata (&device->device);LIST_HEAD (listHead); net_device =get_inbound_net_device (device);if (!net_device) { -dev_err (&device->device,"unable to get net device..." +netdev_err (ndev,"unable to get net device..." "device being destroyed?\n" );return ; }
@@ -661,7 +669,7 @@ static void netvsc_receive(struct hv_device *device,* packet */ if (packet->type !=VM_PKT_DATA_USING_XFER_PAGES ) { -dev_err (&device->device,"Unknown packet type received - %d\n" , +netdev_err (ndev,"Unknown packet type received - %d\n" , packet->type);put_net_device (device);return ;
@@ -673,7 +681,7 @@ static void netvsc_receive(struct hv_device *device,/* Make sure this is a valid nvsp packet */ if (nvsp_packet->hdr.msg_type !=NVSP_MSG1_TYPE_SEND_RNDIS_PKT ) { -dev_err (&device->device,"Unknown nvsp packet type received-" +netdev_err (ndev,"Unknown nvsp packet type received-" " %d\n" , nvsp_packet->hdr.msg_type);put_net_device (device);return ;
@@ -682,7 +690,7 @@ static void netvsc_receive(struct hv_device *device, vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet;if (vmxferpage_packet->xfer_pageset_id !=NETVSC_RECEIVE_BUFFER_ID ) { -dev_err (&device->device,"Invalid xfer page set id - " +netdev_err (ndev,"Invalid xfer page set id - " "expecting %x got %x\n" ,NETVSC_RECEIVE_BUFFER_ID , vmxferpage_packet->xfer_pageset_id);put_net_device (device);
@@ -709,7 +717,7 @@ static void netvsc_receive(struct hv_device *device,* some of the xfer page packet ranges... */ if (count <2 ) { -dev_err (&device->device,"Got only %d netvsc pkt...needed " +netdev_err (ndev,"Got only %d netvsc pkt...needed " "%d pkts. Dropping this xfer page packet completely!\n" , count, vmxferpage_packet->range_cnt +1 );
@@ -737,7 +745,7 @@ static void netvsc_receive(struct hv_device *device, xferpage_packet->count = count -1 ;if (xferpage_packet->count != vmxferpage_packet->range_cnt) { -dev_err (&device->device,"Needed %d netvsc pkts to satisy " +netdev_err (ndev,"Needed %d netvsc pkts to satisy " "this xfer page...got %d\n" , vmxferpage_packet->range_cnt, xferpage_packet->count); }
@@ -827,6 +835,7 @@ static void netvsc_channel_cb(void *context)struct vmpacket_descriptor *desc;unsigned char *buffer;int bufferlen =NETVSC_PACKET_SIZE ; +struct net_device *ndev =dev_get_drvdata (&device->device); packet =kzalloc (NETVSC_PACKET_SIZE *sizeof (unsigned char ),GFP_ATOMIC );
@@ -836,7 +845,7 @@ static void netvsc_channel_cb(void *context) net_device =get_inbound_net_device (device);if (!net_device) { -dev_err (&device->device,"net device (%p) shutting down..." +netdev_err (ndev,"net device (%p) shutting down..." "ignoring inbound packets\n" , net_device); goto out; }
@@ -857,7 +866,7 @@ static void netvsc_channel_cb(void *context)break ;default : - dev_err(&device->device, + netdev_err(ndev, "unhandled packet type %d, " "tid %llx len %d\n", desc->type, request_id,
@@ -886,7 +895,7 @@ static void netvsc_channel_cb(void *context) buffer =kmalloc (bytes_recvd,GFP_ATOMIC );if (buffer ==NULL ) {/* Try again next time around */ -dev_err (&device->device, +netdev_err (ndev,"unable to allocate buffer of size " "(%d)!!\n" , bytes_recvd);break ;
@@ -914,6 +923,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) ((struct netvsc_device_info *)additional_info)->ring_size;struct netvsc_device *net_device;struct hv_netvsc_packet *packet, *pos; +struct net_device *ndev =dev_get_drvdata (&device->device); net_device =alloc_net_device (device);if (!net_device) {
@@ -945,7 +955,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) netvsc_channel_cb, device);if (ret !=0 ) { -dev_err (&device->device,"unable to open channel: %d\n" , ret); +netdev_err (ndev,"unable to open channel: %d\n" , ret); goto cleanup; }
@@ -955,7 +965,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)/* Connect with the NetVsp */ ret =netvsc_connect_vsp (device);if (ret !=0 ) { -dev_err (&device->device, +netdev_err (ndev,"unable to connect to NetVSP - %d\n" , ret); goto close; }
drivers/staging/hv/rndis_filter.c +10 -7
@@ -249,6 +249,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,struct rndis_request *request =NULL ;bool found = false;unsigned long flags; +struct net_device *ndev =dev_get_drvdata (&dev->net_dev->dev->device);spin_lock_irqsave (&dev->request_lock, flags);list_for_each_entry (request, &dev->req_list, list_ent) {
@@ -269,7 +270,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,memcpy (&request->response_msg, resp, resp->msg_len); }else { - dev_err(&dev->net_dev->dev->device, + netdev_err(ndev, "rndis response buffer overflow " "detected (size %u max %zu)\n", resp->msg_len,
@@ -289,7 +290,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,complete (&request->wait_event); }else { - dev_err(&dev->net_dev->dev->device, + netdev_err(ndev, "no rndis request found for this response " "(id 0x%x res type 0x%x)\n", resp->msg.init_complete.req_id,
@@ -349,20 +350,21 @@ int rndis_filter_receive(struct hv_device *dev,struct rndis_device *rndis_dev;struct rndis_message rndis_msg;struct rndis_message *rndis_hdr; +struct net_device *ndev =dev_get_drvdata (&dev->device);if (!net_dev)return -EINVAL ;/* Make sure the rndis device state is initialized */ if (!net_dev->extension) { -dev_err (&dev->device,"got rndis message but no rndis device - " +netdev_err (ndev,"got rndis message but no rndis device - " "dropping this message!\n" );return -ENODEV ; } rndis_dev = (struct rndis_device *)net_dev->extension;if (rndis_dev->state ==RNDIS_DEV_UNINITIALIZED ) { -dev_err (&dev->device,"got rndis message but rndis device " +netdev_err (ndev,"got rndis message but rndis device " "uninitialized...dropping this message!\n" );return -ENODEV ; }
@@ -376,7 +378,7 @@ int rndis_filter_receive(struct hv_device *dev,/* Make sure we got a valid rndis message */ if ((rndis_hdr->ndis_msg_type !=REMOTE_NDIS_PACKET_MSG ) && (rndis_hdr->msg_len >sizeof (struct rndis_message ))) { -dev_err (&dev->device,"incoming rndis message buffer overflow " +netdev_err (ndev,"incoming rndis message buffer overflow " "detected (got %u, max %zu)..marking it an error!\n" , rndis_hdr->msg_len,sizeof (struct rndis_message ));
@@ -409,7 +411,7 @@ int rndis_filter_receive(struct hv_device *dev,rndis_filter_receive_indicate_status (rndis_dev, &rndis_msg);break ;default : -dev_err (&dev->device, +netdev_err (ndev,"unhandled rndis message (type %u len %u)\n" , rndis_msg.ndis_msg_type, rndis_msg.msg_len);
@@ -505,6 +507,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,struct rndis_set_complete *set_complete;u32 status;int ret, t; +struct net_device *ndev =dev_get_drvdata (&dev->net_dev->dev->device); request = get_rndis_request(dev, REMOTE_NDIS_SET_MSG, RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
@@ -530,7 +533,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, t =wait_for_completion_timeout (&request->wait_event,5 *HZ );if (t ==0 ) { -dev_err (&dev->net_dev->dev->device, +netdev_err (ndev,"timeout before we got a set response...\n" );/* * We can't deallocate the request since we may still receive a
Signature · 1 line
1.6.3.2
PATCH 4/9 staging: hv: fix a kernel warning in netvsc_linkstatus_callback()
In reply to Haiyang Zhangnetif_notify_peers() caused a kernel warning in netvsc_linkstatus_callback(), because netvsc_linkstatus_callback() is within IRQ context. So we move the first call to netif_notify_peers() into queued work as well, but with zero delay.
In addition to "staging-next", this should also be back-ported to stable kernels 2.6.32 and later.
--- drivers/staging/hv/netvsc_drv.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/netvsc_drv.c +1 -1
@@ -216,8 +216,8 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,if (status ==1 ) {netif_carrier_on (net);netif_wake_queue (net); -netif_notify_peers (net); ndev_ctx =netdev_priv (net); +schedule_delayed_work (&ndev_ctx->dwork,0 );schedule_delayed_work (&ndev_ctx->dwork,msecs_to_jiffies (20 )); }else {netif_carrier_off (net);
Signature · 1 line
1.6.3.2
PATCH 5/9 staging: hv: re-order the code in netvsc_probe()
In reply to Haiyang ZhangRe-order the code in netvsc_probe() to prevent a guest crash caused by packets possibly received from NetVSP before call to register_netdev().
--- drivers/staging/hv/netvsc_drv.c | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-)
drivers/staging/hv/netvsc_drv.c +17 -15
@@ -350,19 +350,6 @@ static int netvsc_probe(struct hv_device *dev)dev_set_drvdata (&dev->device, net);INIT_DELAYED_WORK (&net_device_ctx->dwork, netvsc_send_garp); -/* Notify the netvsc driver of the new device */ - device_info.ring_size = ring_size; - ret =rndis_filter_device_add (dev, &device_info); -if (ret !=0 ) { -free_netdev (net); -dev_set_drvdata (&dev->device,NULL ); -return ret; - } - -netif_carrier_on (net); - -memcpy (net->dev_addr, device_info.mac_adr,ETH_ALEN ); - net->netdev_ops = &device_ops;/* TODO: Add GSO and Checksum offload */
@@ -374,11 +361,26 @@ static int netvsc_probe(struct hv_device *dev) ret =register_netdev (net);if (ret !=0 ) { -/* Remove the device and release the resource */ -rndis_filter_device_remove (dev); +pr_err ("Unable to register netdev.\n" );free_netdev (net); + goto out; } +/* Notify the netvsc driver of the new device */ + device_info.ring_size = ring_size; + ret =rndis_filter_device_add (dev, &device_info); +if (ret !=0 ) { +netdev_err (net,"unable to add netvsc device (ret %d)\n" , ret); +unregister_netdev (net); +free_netdev (net); +dev_set_drvdata (&dev->device,NULL ); +return ret; + } +memcpy (net->dev_addr, device_info.mac_adr,ETH_ALEN ); + +netif_carrier_on (net); + +out:return ret; }
Signature · 1 line
1.6.3.2
PATCH 6/9 staging: hv: fix counting of #outstanding-sends in failed sends
In reply to Haiyang ZhangIf the packet failed to be sent, we shouldn't count it as the number of outstanding sends.
--- drivers/staging/hv/netvsc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/staging/hv/netvsc.c +2 -1
@@ -539,8 +539,9 @@ int netvsc_send(struct hv_device *device,if (ret !=0 )netdev_err (ndev,"Unable to send packet %p ret %d\n" , packet, ret); +else +atomic_inc (&net_device->num_outstanding_sends); -atomic_inc (&net_device->num_outstanding_sends);put_net_device (device);return ret; }
Signature · 1 line
1.6.3.2
PATCH 7/9 staging: hv: fix counting of available buffer slots when send fails
In reply to Haiyang ZhangBecause the number of available buffer slots doesn't decrease for failed sends, we should not call netvsc_xmit_completion(), which increase the count of available slots. In this failed case, just free the memory is enough.
--- drivers/staging/hv/netvsc_drv.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/staging/hv/netvsc_drv.c +2 -1
@@ -192,7 +192,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) }else {/* we are shutting down or bus overloaded, just drop packet */ net->stats.tx_dropped++; -netvsc_xmit_completion (packet); +kfree (packet); +dev_kfree_skb_any (skb); }return NETDEV_TX_OK ;
Signature · 1 line
1.6.3.2
PATCH 8/9 staging: hv: fix the return status of netvsc_start_xmit()
In reply to Haiyang ZhangFix the return status, so the upper layer will retry if transmission fails.
--- drivers/staging/hv/netvsc_drv.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/netvsc_drv.c +3 -3
@@ -142,12 +142,12 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) (num_pages *sizeof (struct hv_page_buffer )) + sizeof(struct rndis_filter_packet), GFP_ATOMIC);if (!packet) { -/* out of memory, silently drop packet */ +/* out of memory, drop packet */ netdev_err (net,"unable to allocate hv_netvsc_packet\n" );dev_kfree_skb (skb); net->stats.tx_dropped++; -return NETDEV_TX_OK ; +return NETDEV_TX_BUSY ; } packet->extension = (void *)(unsigned long)packet +
@@ -196,7 +196,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)dev_kfree_skb_any (skb); } -return NETDEV_TX_OK ; +return ret ?NETDEV_TX_BUSY :NETDEV_TX_OK ; }/*
Signature · 1 line
1.6.3.2
PATCH 9/9 staging: hv: fix the page buffer when rndis data go across page boundary
In reply to Haiyang ZhangIn rndis_filter_receive_data(), we need to drop the 0th page and move the rest of pages forward if the rndis data go across page boundary, otherwise the page offset will overflow.
--- drivers/staging/hv/rndis_filter.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/staging/hv/rndis_filter.c +10 -0
@@ -323,6 +323,7 @@ static void rndis_filter_receive_data(struct rndis_device *dev, {struct rndis_packet *rndis_pkt;u32 data_offset; +int i; rndis_pkt = &msg->msg.pkt;
@@ -338,6 +339,15 @@ static void rndis_filter_receive_data(struct rndis_device *dev, pkt->page_buf[0 ].offset += data_offset; pkt->page_buf[0 ].len -= data_offset; +/* Drop the 0th page, if rndis data go beyond page boundary */ +if (pkt->page_buf[0 ].offset >=PAGE_SIZE ) { + pkt->page_buf[1 ].offset = pkt->page_buf[0 ].offset -PAGE_SIZE ; + pkt->page_buf[1 ].len -= pkt->page_buf[1 ].offset; + pkt->page_buf_cnt--; +for (i =0 ; i < pkt->page_buf_cnt; i++) + pkt->page_buf[i] = pkt->page_buf[i+1 ]; + } + pkt->is_data_pkt = true;netvsc_recv_callback (dev->net_dev->dev, pkt);
Signature · 1 line
1.6.3.2
PATCH 5/9 staging: hv: re-order the code in netvsc_probe()
In reply to Haiyang ZhangRe-order the code in netvsc_probe() to prevent a guest crash caused by packets possibly received from NetVSP before call to register_netdev().
--- drivers/staging/hv/netvsc_drv.c | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-)
drivers/staging/hv/netvsc_drv.c +17 -15
@@ -350,19 +350,6 @@ static int netvsc_probe(struct hv_device *dev)dev_set_drvdata (&dev->device, net);INIT_DELAYED_WORK (&net_device_ctx->dwork, netvsc_send_garp); -/* Notify the netvsc driver of the new device */ - device_info.ring_size = ring_size; - ret =rndis_filter_device_add (dev, &device_info); -if (ret !=0 ) { -free_netdev (net); -dev_set_drvdata (&dev->device,NULL ); -return ret; - } - -netif_carrier_on (net); - -memcpy (net->dev_addr, device_info.mac_adr,ETH_ALEN ); - net->netdev_ops = &device_ops;/* TODO: Add GSO and Checksum offload */
@@ -374,11 +361,26 @@ static int netvsc_probe(struct hv_device *dev) ret =register_netdev (net);if (ret !=0 ) { -/* Remove the device and release the resource */ -rndis_filter_device_remove (dev); +pr_err ("Unable to register netdev.\n" );free_netdev (net); + goto out; } +/* Notify the netvsc driver of the new device */ + device_info.ring_size = ring_size; + ret =rndis_filter_device_add (dev, &device_info); +if (ret !=0 ) { +netdev_err (net,"unable to add netvsc device (ret %d)\n" , ret); +unregister_netdev (net); +free_netdev (net); +dev_set_drvdata (&dev->device,NULL ); +return ret; + } +memcpy (net->dev_addr, device_info.mac_adr,ETH_ALEN ); + +netif_carrier_on (net); + +out:return ret; }
Signature · 1 line
1.6.3.2
Re: [PATCH 2/9] staging: hv: add newline to log messages in netvsc
In reply to Haiyang ZhangQuoted 2 lines · Haiyang Zhang
Signed-off-by Haiyang Zhang <[email protected]>Signed-off-by K. Y. Srinivasan <[email protected]>
Just noticing some trivial typos...
drivers/staging/hv/netvsc.c
Quoted 1 line
drivers/staging/hv/netvsc.c +0
-0
[]
drivers/staging/hv/netvsc.c static int netvsc_init_recv_buf(struct hv_device *device) · line 249
Quoted 6 lines
drivers/staging/hv/netvsc.c +1
-1@@ -246,7 +246,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)if (init_packet->msg.v1_msg. send_recv_buf_complete.status !=NVSP_STAT_SUCCESS ) { dev_err(&device->device, "Unable to complete receive buffer " - "initialzation with NetVsp - status %d", + "initialzation with NetVsp - status %d\n",
initialization
[]
drivers/staging/hv/netvsc.c static void netvsc_receive(struct hv_device *device, · line 741
Quoted 6 lines
drivers/staging/hv/netvsc.c +1
-1@@ -738,7 +738,7 @@ static void netvsc_receive(struct hv_device *device,if (xferpage_packet->count != vmxferpage_packet->range_cnt) { dev_err(&device->device, "Needed %d netvsc pkts to satisy " - "this xfer page...got %d", + "this xfer page...got %d\n",
satisfy
RE: [PATCH 2/9] staging: hv: add newline to log messages in netvsc
Quoted 23 lines
-----Original Message-----
From: Joe Perches [mailto:[email protected]]
Sent: Thursday, July 21, 2011 9:36 PM
Just noticing some trivial typos...Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/staging/hv/netvsc.c
[]Review static int netvsc_init_recv_buf(struct hv_device
Quoted 1 line
(quoted diff) +0
-0@@ -246,7 +246,7 @@ static int netvsc_init_recv_buf(struct hv_device*device)
drivers/staging/hv/netvsc.c static int netvsc_init_recv_buf(struct hv_device *device)
Quoted 3 lines
drivers/staging/hv/netvsc.c +0
-0if (init_packet->msg.v1_msg. send_recv_buf_complete.status !=NVSP_STAT_SUCCESS ) { dev_err(&device->device, "Unable to complete receive buffer"
drivers/staging/hv/netvsc.c static int netvsc_init_recv_buf(struct hv_device *device) · line 249
Quoted 2 lines
drivers/staging/hv/netvsc.c +1
-1- "initialzation with NetVsp - status %d", + "initialzation with NetVsp - status %d\n",initialization
[]
Review static void netvsc_receive(struct hv_device
Quoted 1 line
(quoted diff) +0
-0@@ -738,7 +738,7 @@ static void netvsc_receive(struct hv_device*device,
Quoted 1 line
Quoted 6 lines
drivers/staging/hv/netvsc.c static void netvsc_receive(struct hv_device *device, · line 741
Quoted 4 lines
drivers/staging/hv/netvsc.c +1
-1if (xferpage_packet->count != vmxferpage_packet->range_cnt) { dev_err(&device->device, "Needed %d netvsc pkts to satisy " - "this xfer page...got %d", + "this xfer page...got %d\n",satisfy
Good catch! I will make a new patch to correct them.
Thanks,
- Haiyang