Skip to content

Commit

Permalink
Staging: hv: Move the contents of storvsc_api.h to hyperv_storage.h
Browse files Browse the repository at this point in the history
 Move the contents of storvsc_api.h  to hyperv_storage.h.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
K. Y. Srinivasan authored and Greg Kroah-Hartman committed May 17, 2011
1 parent e6572b0 commit 5041e71
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 164 deletions.
1 change: 0 additions & 1 deletion drivers/staging/hv/blkvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#include "hyperv.h"
#include "hyperv_storage.h"
#include "storvsc_api.h"


#define BLKVSC_MINORS 64
Expand Down
134 changes: 134 additions & 0 deletions drivers/staging/hv/hyperv_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,138 @@ struct vstor_packet {
/* This is the set of flags that the vsc can set in any packets it sends */
#define VSC_LEGAL_FLAGS (REQUEST_COMPLETION_FLAG)


#include <linux/kernel.h>
#include <linux/wait.h>
#include "hyperv_storage.h"
#include "hyperv.h"

/* Defines */
#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE)
#define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE)

#define STORVSC_MAX_IO_REQUESTS 128

/*
* In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
* reality, the path/target is not used (ie always set to 0) so our
* scsi host adapter essentially has 1 bus with 1 target that contains
* up to 256 luns.
*/
#define STORVSC_MAX_LUNS_PER_TARGET 64
#define STORVSC_MAX_TARGETS 1
#define STORVSC_MAX_CHANNELS 1

struct hv_storvsc_request;

/* Matches Windows-end */
enum storvsc_request_type {
WRITE_TYPE,
READ_TYPE,
UNKNOWN_TYPE,
};


struct hv_storvsc_request {
struct hv_storvsc_request *request;
struct hv_device *device;

/* Synchronize the request/response if needed */
struct completion wait_event;

unsigned char *sense_buffer;
void *context;
void (*on_io_completion)(struct hv_storvsc_request *request);
struct hv_multipage_buffer data_buffer;

struct vstor_packet vstor_packet;
};


struct storvsc_device_info {
u32 ring_buffer_size;
unsigned int port_number;
unsigned char path_id;
unsigned char target_id;
};

struct storvsc_major_info {
int major;
int index;
bool do_register;
char *devname;
char *diskname;
};

/* A storvsc device is a device object that contains a vmbus channel */
struct storvsc_device {
struct hv_device *device;

/* 0 indicates the device is being destroyed */
atomic_t ref_count;

bool drain_notify;
atomic_t num_outstanding_req;

wait_queue_head_t waiting_to_drain;

/*
* Each unique Port/Path/Target represents 1 channel ie scsi
* controller. In reality, the pathid, targetid is always 0
* and the port is set by us
*/
unsigned int port_number;
unsigned char path_id;
unsigned char target_id;

/* Used for vsc/vsp channel reset process */
struct hv_storvsc_request init_request;
struct hv_storvsc_request reset_request;
};


/* Get the stordevice object iff exists and its refcount > 1 */
static inline struct storvsc_device *get_stor_device(struct hv_device *device)
{
struct storvsc_device *stor_device;

stor_device = (struct storvsc_device *)device->ext;
if (stor_device && atomic_read(&stor_device->ref_count) > 1)
atomic_inc(&stor_device->ref_count);
else
stor_device = NULL;

return stor_device;
}


static inline void put_stor_device(struct hv_device *device)
{
struct storvsc_device *stor_device;

stor_device = (struct storvsc_device *)device->ext;

atomic_dec(&stor_device->ref_count);
}

static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
{
dev->drain_notify = true;
wait_event(dev->waiting_to_drain,
atomic_read(&dev->num_outstanding_req) == 0);
dev->drain_notify = false;
}

/* Interface */

int storvsc_dev_add(struct hv_device *device,
void *additional_info);
int storvsc_dev_remove(struct hv_device *device);

int storvsc_do_io(struct hv_device *device,
struct hv_storvsc_request *request);

int storvsc_get_major_info(struct storvsc_device_info *device_info,
struct storvsc_major_info *major_info);

#endif /* _HYPERV_STORAGE_H */
1 change: 0 additions & 1 deletion drivers/staging/hv/storvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include "hyperv.h"
#include "hyperv_storage.h"
#include "storvsc_api.h"


static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
Expand Down
161 changes: 0 additions & 161 deletions drivers/staging/hv/storvsc_api.h

This file was deleted.

1 change: 0 additions & 1 deletion drivers/staging/hv/storvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

#include "hyperv.h"
#include "hyperv_storage.h"
#include "storvsc_api.h"

static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;

Expand Down

0 comments on commit 5041e71

Please sign in to comment.