Staging: hv: Hyper-V driver cleanup
Subsystems (2)
PATCH 1/1 Staging: hv: Hyper-V driver cleanup
This patch cleans up (a lot of the) naming issues that various reviewers have noted. It also gets rid of some unnecessary layering in the code. At the lowest level, we have one abstraction for representing a hyperv device (struct hyperv_device) and one abstraction for representing a hyperv driver (struct hyperv_driver). This collapses an unnecessary layering that existed in the code for historical reasons. While the patch is large, it was generated by a very mechanical process (global search and replace). The code compiles cleanly and I have tested this code on a 2.6.38 kernel.
--- drivers/staging/hv/blkvsc.c | 19 +- drivers/staging/hv/blkvsc_drv.c | 76 ++++---- drivers/staging/hv/channel_mgmt.c | 1 + drivers/staging/hv/channel_mgmt.h | 2 +- drivers/staging/hv/netvsc.c | 65 ++++--- drivers/staging/hv/netvsc.h | 2 +- drivers/staging/hv/netvsc_api.h | 16 +- drivers/staging/hv/netvsc_drv.c | 108 +++++------ drivers/staging/hv/rndis_filter.c | 23 ++- drivers/staging/hv/storvsc.c | 43 +++-- drivers/staging/hv/storvsc_api.h | 10 +- drivers/staging/hv/storvsc_drv.c | 106 +++++------ drivers/staging/hv/vmbus.h | 38 +++-- drivers/staging/hv/vmbus_api.h | 37 +---- drivers/staging/hv/vmbus_drv.c | 364 +++++++++++++++++------------------- drivers/staging/hv/vmbus_private.h | 13 +- 16 files changed, 439 insertions(+), 484 deletions(-)
drivers/staging/hv/blkvsc.c +10 -9
@@ -35,7 +35,8 @@ static const struct hv_guid g_blk_device_type = { } }; -static int blk_vsc_on_device_add (struct hv_device *device,void *additional_info) +static int blk_vsc_on_device_add (struct hyperv_device *device, +void *additional_info) {struct storvsc_device_info *device_info;int ret =0 ;
@@ -51,18 +52,18 @@ static int blk_vsc_on_device_add(struct hv_device *device, void *additional_info* id. For IDE devices, the device instance id is formatted as * <bus id> * - <device id> - 8899 - 000000000000. */ - device_info->path_id = device->dev_instance.data[3 ] <<24 | - device->dev_instance.data[2 ] <<16 | - device->dev_instance.data[1 ] <<8 | - device->dev_instance.data[0 ]; + device_info->path_id = device->device_id.data[3 ] <<24 | + device->device_id.data[2 ] <<16 | + device->device_id.data[1 ] <<8 | + device->device_id.data[0 ]; - device_info->target_id = device->dev_instance.data[5 ] <<8 | - device->dev_instance.data[4 ]; + device_info->target_id = device->device_id.data[5 ] <<8 | + device->device_id.data[4 ];return ret; } -int blk_vsc_initialize (struct hv_driver *driver) +int blk_vsc_initialize (struct hyperv_driver *driver) {struct storvsc_driver_object *stor_driver;int ret =0 ;
@@ -73,7 +74,7 @@ int blk_vsc_initialize(struct hv_driver *driver)/* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */ driver->name = g_blk_driver_name; -memcpy (&driver->dev_type, &g_blk_device_type,sizeof (struct hv_guid )); +memcpy (&driver->class_id, &g_blk_device_type,sizeof (struct hv_guid )); stor_driver->request_ext_size =sizeof (struct storvsc_request_extension );
drivers/staging/hv/blkvsc_drv.c +37 -39
177 lines not on this page · raw message
drivers/staging/hv/channel_mgmt.c +1 -0
@@ -28,6 +28,7 @@#include <linux/completion.h> #include "hv_api.h" #include "logging.h" +#include "vmbus.h" #include "vmbus_private.h" #include "utils.h"
drivers/staging/hv/channel_mgmt.h +1 -1
@@ -228,7 +228,7 @@ enum vmbus_channel_state {struct vmbus_channel {struct list_head listentry; -struct hv_device *device_obj; +struct hyperv_device *device_obj;struct timer_list poll_timer;/* SA-111 workaround */ struct work_struct work;
drivers/staging/hv/netvsc.c +35 -30
211 lines not on this page · raw message
drivers/staging/hv/netvsc.h +1 -1
@@ -293,7 +293,7 @@ struct nvsp_message {/* Per netvsc channel-specific */ struct netvsc_device { -struct hv_device *dev; +struct hyperv_device *dev;atomic_t refcnt;atomic_t num_outstanding_sends;
drivers/staging/hv/netvsc_api.h +8 -8
@@ -49,7 +49,7 @@ struct hv_netvsc_packet {/* Bookkeeping stuff */ struct list_head list_ent; -struct hv_device *device; +struct hyperv_device *device;bool is_data_pkt;/*
@@ -84,7 +84,7 @@ struct hv_netvsc_packet {struct netvsc_driver {/* Must be the first field */ /* Which is a bug FIXME! */ -struct hv_driver base; +struct hyperv_driver base;u32 ring_buf_size;u32 req_ext_size;
@@ -93,12 +93,12 @@ struct netvsc_driver {* This is set by the caller to allow us to callback when we * receive a packet from the "wire" */ -int (*recv_cb)(struct hv_device *dev, +int (*recv_cb)(struct hyperv_device *dev,struct hv_netvsc_packet *packet); -void (*link_status_change)(struct hv_device *dev,u32 status); +void (*link_status_change)(struct hyperv_device *dev,u32 status);/* Specific to this driver */ -int (*send)(struct hv_device *dev,struct hv_netvsc_packet *packet); +int (*send)(struct hyperv_device *dev,struct hv_netvsc_packet *packet);void *ctx; };
@@ -109,8 +109,8 @@ struct netvsc_device_info { };/* Interface */ -int netvsc_initialize (struct hv_driver *drv); -int rndis_filter_open (struct hv_device *dev); -int rndis_filter_close (struct hv_device *dev); +int netvsc_initialize (struct hyperv_driver *drv); +int rndis_filter_open (struct hyperv_device *dev); +int rndis_filter_close (struct hyperv_device *dev);#endif /* _NETVSC_API_H_ */
drivers/staging/hv/netvsc_drv.c +52 -56
240 lines not on this page · raw message
drivers/staging/hv/rndis_filter.c +12 -11
@@ -28,6 +28,7 @@#include "logging.h" #include "hv_api.h" +#include "vmbus.h" #include "netvsc_api.h" #include "rndis_filter.h"
@@ -84,14 +85,14 @@ struct rndis_filter_packet { }; -static int rndis_filte_device_add (struct hv_device *dev, +static int rndis_filte_device_add (struct hyperv_device *dev,void *additional_info); -static int rndis_filter_device_remove (struct hv_device *dev); +static int rndis_filter_device_remove (struct hyperv_device *dev); -static void rndis_filter_cleanup (struct hv_driver *drv); +static void rndis_filter_cleanup (struct hyperv_driver *drv); -static int rndis_filter_send (struct hv_device *dev, +static int rndis_filter_send (struct hyperv_device *dev,struct hv_netvsc_packet *pkt);static void rndis_filter_send_completion (void *ctx);
@@ -375,7 +376,7 @@ static void rndis_filter_receive_data(struct rndis_device *dev, pkt); } -static int rndis_filter_receive (struct hv_device *dev, +static int rndis_filter_receive (struct hyperv_device *dev,struct hv_netvsc_packet *pkt) {struct netvsc_device *net_dev = dev->ext;
@@ -753,7 +754,7 @@ static int rndis_filter_close_device(struct rndis_device *dev)return ret; } -static int rndis_filte_device_add (struct hv_device *dev, +static int rndis_filte_device_add (struct hyperv_device *dev,void *additional_info) {int ret;
@@ -816,7 +817,7 @@ static int rndis_filte_device_add(struct hv_device *dev,return ret; } -static int rndis_filter_device_remove (struct hv_device *dev) +static int rndis_filter_device_remove (struct hyperv_device *dev) {struct netvsc_device *net_dev = dev->ext;struct rndis_device *rndis_dev = net_dev->extension;
@@ -833,11 +834,11 @@ static int rndis_filter_device_remove(struct hv_device *dev)return 0 ; } -static void rndis_filter_cleanup (struct hv_driver *drv) +static void rndis_filter_cleanup (struct hyperv_driver *drv) { } -int rndis_filter_open (struct hv_device *dev) +int rndis_filter_open (struct hyperv_device *dev) {struct netvsc_device *netDevice = dev->ext;
@@ -847,7 +848,7 @@ int rndis_filter_open(struct hv_device *dev)return rndis_filter_open_device (netDevice->extension); } -int rndis_filter_close (struct hv_device *dev) +int rndis_filter_close (struct hyperv_device *dev) {struct netvsc_device *netDevice = dev->ext;
@@ -857,7 +858,7 @@ int rndis_filter_close(struct hv_device *dev)return rndis_filter_close_device (netDevice->extension); } -static int rndis_filter_send (struct hv_device *dev, +static int rndis_filter_send (struct hyperv_device *dev,struct hv_netvsc_packet *pkt) {int ret;
drivers/staging/hv/storvsc.c +23 -20
169 lines not on this page · raw message
drivers/staging/hv/storvsc_api.h +5 -5
@@ -80,7 +80,7 @@ struct hv_storvsc_request {struct storvsc_driver_object {/* Must be the first field */ /* Which is a bug FIXME! */ -struct hv_driver base; +struct hyperv_driver base;/* Set by caller (in bytes) */ u32 ring_buffer_size;
@@ -92,7 +92,7 @@ struct storvsc_driver_object {u32 max_outstanding_req_per_channel;/* Specific to this driver */ -int (*on_io_request)(struct hv_device *device, +int (*on_io_request)(struct hyperv_device *device,struct hv_storvsc_request *request); };
@@ -103,8 +103,8 @@ struct storvsc_device_info { };/* Interface */ -int stor_vsc_initialize (struct hv_driver *driver); -int stor_vsc_on_host_reset (struct hv_device *device); -int blk_vsc_initialize (struct hv_driver *driver); +int stor_vsc_initialize (struct hyperv_driver *driver); +int stor_vsc_on_host_reset (struct hyperv_device *device); +int blk_vsc_initialize (struct hyperv_driver *driver);#endif /* _STORVSC_API_H_ */
drivers/staging/hv/storvsc_drv.c +52 -54
263 lines not on this page · raw message
drivers/staging/hv/vmbus.h +23 -15
@@ -28,9 +28,17 @@#include <linux/device.h> #include "vmbus_api.h" -struct driver_context { +struct hyperv_driver { +const char *name; +struct hv_guid class_id; +int (*dev_add)(struct hyperv_device *device,void *data); + +int (*dev_rm)(struct hyperv_device *device); + +void (*cleanup)(struct hyperv_driver *driver); +struct device_driver driver;/*
@@ -43,34 +51,34 @@ struct driver_context {void (*shutdown)(struct device *); }; -struct vm_device { +struct hyperv_device { +char name[64 ];struct work_struct probe_failed_work_item; -struct hv_guid class_id; -struct hv_guid device_id; +struct hv_guid class_id;/* device type id */ +struct hv_guid device_id;/* device class id */ +struct hyperv_driver *drv;int probe_error; -struct hv_device device_obj; +struct vmbus_channel *channel;/* associated channel to host*/ +void *ext;struct device device; }; -static inline struct vm_device *to_vm_device (struct hv_device *d) -{ - return container_of(d, struct vm_device, device_obj); -} -static inline struct vm_device *device_to_vm_device (struct device *d) +static inline struct hyperv_device *device_to_hyperv_device (struct device *d) { - return container_of(d, struct vm_device, device); + return container_of(d, struct hyperv_device, device); } -static inline struct driver_context *driver_to_driver_context (struct device_driver *d) +static inline struct hyperv_driver * +driver_to_hyperv_driver (struct device_driver *d) { - return container_of(d, struct driver_context, driver); + return container_of(d, struct hyperv_driver, driver); }/* Vmbus interface */ -int vmbus_child_driver_register (struct driver_context *driver_ctx); -void vmbus_child_driver_unregister (struct driver_context *driver_ctx); +int vmbus_child_driver_register (struct hyperv_driver *drv); +void vmbus_child_driver_unregister (struct hyperv_driver *drv);extern struct completion hv_channel_ready;
drivers/staging/hv/vmbus_api.h +3 -34
@@ -55,8 +55,8 @@ struct hv_multipage_buffer {#pragma pack(pop) -struct hv_driver ; -struct hv_device ; +struct hyperv_driver ; +struct hyperv_device ;struct hv_dev_port_info {u32 int_mask;
@@ -66,7 +66,7 @@ struct hv_dev_port_info {u32 bytes_avail_towrite; }; -struct hv_device_info { +struct hyperv_device_info {u32 chn_id;u32 chn_state;struct hv_guid chn_type;
@@ -84,35 +84,4 @@ struct hv_device_info { struct hv_dev_port_info outbound; }; -/* Base driver object */ -struct hv_driver { -const char *name; - -/* the device type supported by this driver */ -struct hv_guid dev_type; - -int (*dev_add)(struct hv_device *device,void *data); -int (*dev_rm)(struct hv_device *device); -void (*cleanup)(struct hv_driver *driver); -}; - -/* Base device object */ -struct hv_device { -/* the driver for this device */ -struct hv_driver *drv; - -char name[64 ]; - -/* the device type id of this device */ -struct hv_guid dev_type; - -/* the device instance id of this device */ -struct hv_guid dev_instance; - -struct vmbus_channel *channel; - -/* Device extension; */ -void *ext; -}; -#endif /* _VMBUS_API_H_ */
drivers/staging/hv/vmbus_drv.c +171 -193
752 lines not on this page · raw message
drivers/staging/hv/vmbus_private.h +5 -8
@@ -103,18 +103,15 @@ extern struct vmbus_connection vmbus_connection;/* General vmbus interface */ -struct hv_device *vmbus_child_device_create (struct hv_guid *type, +struct hyperv_device *vmbus_child_device_create (struct hv_guid *type,struct hv_guid *instance,struct vmbus_channel *channel); -int vmbus_child_dev_add (struct hv_device *device); -int vmbus_child_device_register (struct hv_device *root_device_obj, -struct hv_device *child_device_obj); -void vmbus_child_device_unregister (struct hv_device *device_obj); +int vmbus_child_dev_add (struct hyperv_device *device); +int vmbus_child_device_register (struct hyperv_device *root_device_obj, +struct hyperv_device *child_device_obj); +void vmbus_child_device_unregister (struct hyperv_device *device_obj); -/* static void */ -/* VmbusChildDeviceDestroy( */ -/* struct hv_device *); */ struct vmbus_channel *relid2channel (u32 relid);
Signature · 1 line
1.5.5.6
Quoted 3 lines · K. Y. Srinivasan
This patch cleans up (a lot of the) naming issues that various reviewers have noted. It also gets rid of some unnecessary layering in the code.
Whenever you have a patch description that says "It also..." you know you need to break this up into smaller, logical pieces.
As it is, I can not take this patch.
Please break it up into logical patches, each doing only one thing, so we can properly review it.
Quoted 10 lines
At the lowest
level, we have one abstraction for representing a hyperv device (structhyperv_device) and one abstraction for representing a hyperv driver (structhyperv_driver). This collapses an unnecessary layering that existed in the code for historical reasons. While the patch is large, it was generated by a very mechanical process (global search and replace). The code compiles cleanly and I have tested this code on a 2.6.38 kernel.
There is no 2.6.38 kernel yet, so I find this very hard to believe :)
thanks,
greg k-h
Quoted 10 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, February 24, 2011 6:46 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; Haiyang Zhang; Hank Janssen
Subject: Re: [PATCH ] Staging: hv: Hyper-V driver cleanup
Quoted 7 lines
Quoted 3 lines · K. Y. Srinivasan
This patch cleans up (a lot of the) naming issues that various reviewers have noted. It also gets rid of some unnecessary layering in the code.
Whenever you have a patch description that says "It also..." you know you need to break this up into smaller, logical pieces.
The name change was related to the layering issue. For instance I combined the Vm_device and hv_device abstractions to build the hyperv_device abstraction. Likewise, I combined the driver_context and the hv_driver abstractions to build the the hyperv_driver abstraction. Would breaking this patch up into two patches, one dealing with the device abstraction consolidation and the other dealing with the consolidation of driver abstractions satisfy your concern. Even if I partition this patch along these lines, it will still be a large set of patches; since these changes are pervasive.
Quoted 17 lines
As it is, I can not take this patch.
Please break it up into logical patches, each doing only one thing, so we can properly review it.
Quoted 10 lines
At the lowest
level, we have one abstraction for representing a hyperv device (structhyperv_device) and one abstraction for representing a hyperv driver (structhyperv_driver). This collapses an unnecessary layering that existed in the code for historical reasons. While the patch is large, it was generated by a very mechanical process (global search and replace). The code compiles cleanly and I have tested this code on a 2.6.38 kernel.
Quoted 1 line
There is no 2.6.38 kernel yet, so I find this very hard to believe :)
My mistake; I did not specify the full output of uname -a on the box that I tested this code. This box is running the LINUX-NEXT kernel :
2.6.38-rc1-0.2-default.
Regards,
K. Y
Quoted 4 lines
thanks,
greg k-h
Quoted 18 lines · KY Srinivasan
Quoted 10 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, February 24, 2011 6:46 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; Haiyang Zhang; Hank Janssen
Subject: Re: [PATCH ] Staging: hv: Hyper-V driver cleanupQuoted 7 lines
Quoted 3 lines · K. Y. Srinivasan
This patch cleans up (a lot of the) naming issues that various reviewers have noted. It also gets rid of some unnecessary layering in the code.
Whenever you have a patch description that says "It also..." you know you need to break this up into smaller, logical pieces.
Quoted 8 lines
The name change was related to the layering issue. For instance I combined the
Vm_deviceandhv_deviceabstractions to build thehyperv_deviceabstraction. Likewise, I combined thedriver_contextand thehv_driverabstractions to build the thehyperv_driverabstraction. Would breaking this patch up into two patches, one dealing with the device abstraction consolidation and the other dealing with the consolidation of driver abstractions satisfy your concern. Even if I partition this patch along these lines, it will still be a large set of patches; since these changes are pervasive.
pervasive patches are fine, just remember, "each patch can only do one thing". It sounds like you want to do at least 2 patches here, if not a lot more. Look at my past patches when I combined things and removed a whole layer for how to do this in a very incremental, piece-by-piece fashion (i.e, move one field over at a time until the structure is gone, and then remove it entirely.)
Quoted 5 lines
Quoted 1 line
There is no 2.6.38 kernel yet, so I find this very hard to believe :)
My mistake; I did not specify the full output of uname -a on the box that I tested this code. This box is running the LINUX-NEXT kernel :
2.6.38-rc1-0.2-default.
linux-next should be farther along than -rc1 as -rc6 is currently out.
confused,
greg k-h
Quoted 41 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, February 24, 2011 7:32 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; Haiyang Zhang; Hank Janssen
Subject: Re: [PATCH ] Staging: hv: Hyper-V driver cleanupQuoted 15 lines · KY Srinivasan
Quoted 15 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, February 24, 2011 6:46 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; Haiyang Zhang; Hank Janssen
Subject: Re: [PATCH ] Staging: hv: Hyper-V driver cleanupQuoted 3 lines · K. Y. Srinivasan
This patch cleans up (a lot of the) naming issues that various reviewers have noted. It also gets rid of some unnecessary layering in the code.
Quoted 6 lines
Quoted 2 lines
Whenever you have a patch description that says "It also..." you know you need to break this up into smaller, logical pieces.
The name change was related to the layering issue. For instance I combined the
Vm_deviceandhv_deviceabstractions to build thehyperv_deviceabstraction. Likewise, I combined thedriver_contextand thehv_driverabstractions to buildthe
Quoted 2 lines
the
hyperv_driverabstraction. Would breaking this patch up into two patches, one dealing with the device abstraction consolidation and the other dealingwith
Quoted 1 line
the consolidation of driver abstractions satisfy your concern. Even if I partition
this
Quoted 2 lines
patch along these lines, it will still be a large set of patches; since these changes are pervasive.
Quoted 6 lines
pervasive patches are fine, just remember, "each patch can only do one thing". It sounds like you want to do at least 2 patches here, if not a lot more. Look at my past patches when I combined things and removed a whole layer for how to do this in a very incremental, piece-by-piece fashion (i.e, move one field over at a time until the structure is gone, and then remove it entirely.)
If it is ok with you, I will do two patches - one for dealing with consolidating device structure and the other for consolidating the driver abstractions.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
There is no 2.6.38 kernel yet, so I find this very hard to believe :)
My mistake; I did not specify the full output of uname -a on the box that I tested this code. This box is running the LINUX-NEXT kernel :
2.6.38-rc1-0.2-default.linux-next should be farther along than -rc1 as -rc6 is currently out.
While the hv code is from the tip of the tree; the kernel I am running is a little dated.
Regards,
K. Y
Quoted 4 lines
confused,
greg k-h