All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vadim Rozenfeld <vrozenfe@redhat.com>
To: kvm@vger.kernel.org
Subject: [PATCH] viostor driver. add support for serial number.
Date: Sun, 25 Oct 2009 13:15:55 +0200	[thread overview]
Message-ID: <4AE4336B.6070104@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3613 bytes --]



repository: /home/vadimr/shares/kvm-guest-drivers-windows
branch: master
commit 394ae1879c5818fd0dce4b68b207c8ef6bf5e115
Author: Vadim Rozenfeld<vrozenfe@redhat.com>
Date:   Fri Sep 25 21:15:37 2009 +0300

     [PATCH] viostor driver. add support for serial number feature.

     Signed-off-by: Vadim Rozenfeld<vrozenfe@redhat.com>

diff --git a/viostor/virtio_stor.c b/viostor/virtio_stor.c
index 375021b..b972dd2 100644
--- a/viostor/virtio_stor.c
+++ b/viostor/virtio_stor.c
@@ -416,6 +416,14 @@ VirtIoHwInitialize(
          RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("VIRTIO_BLK_F_GEOMETRY. cylinders = %d  heads = %d  sectors = %d\n", adaptExt->info.geometry.cylinders, adaptExt->info.geometry.heads, adaptExt->info.geometry.sectors));
      }

+    if (VirtIODeviceGetHostFeature(DeviceExtension, VIRTIO_BLK_F_IDENTIFY)) {
+        VirtIODeviceGet(DeviceExtension, FIELD_OFFSET(blk_config, identify),
+&adaptExt->info.identify, VIRTIO_BLK_ID_LEN);
+        adaptExt->has_sn = TRUE;
+        RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("VIRTIO_BLK_F_IDENTIFY. \n"));
+    }
+
+
      VirtIODeviceGet( DeviceExtension, FIELD_OFFSET(blk_config, capacity),
                        &cap, sizeof(cap));
      adaptExt->info.capacity = cap;
@@ -801,8 +809,13 @@ RhelScsiGetInquiryData(
          PVPD_SERIAL_NUMBER_PAGE SerialPage;
          SerialPage = (PVPD_SERIAL_NUMBER_PAGE)Srb->DataBuffer;
          SerialPage->PageCode = VPD_SERIAL_NUMBER;
-        SerialPage->PageLength = 1;
-        SerialPage->SerialNumber[0] = '0';
+        if(adaptExt->has_sn) {
+           SerialPage->PageLength = VIRTIO_BLK_ID_SN_BYTES;
+           ScsiPortMoveMemory(&SerialPage->SerialNumber[0],&adaptExt->info.identify[VIRTIO_BLK_ID_SN], VIRTIO_BLK_ID_SN_BYTES);
+        } else {
+           SerialPage->PageLength = 1;
+           SerialPage->SerialNumber[0] = '0';
+        }
          Srb->DataTransferLength = sizeof(VPD_SERIAL_NUMBER_PAGE) + SerialPage->PageLength;
      }
      else if ((cdb->CDB6INQUIRY3.PageCode == VPD_DEVICE_IDENTIFIERS)&&
diff --git a/viostor/virtio_stor.h b/viostor/virtio_stor.h
index 2533148..dd4728e 100644
--- a/viostor/virtio_stor.h
+++ b/viostor/virtio_stor.h
@@ -36,6 +36,12 @@ typedef struct VirtIOBufferDescriptor VIO_SG, *PVIO_SG;
  #define VIRTIO_BLK_F_GEOMETRY	4	/* Legacy geometry available  */
  #define VIRTIO_BLK_F_RO		5	/* Disk is read-only */
  #define VIRTIO_BLK_F_BLK_SIZE	6	/* Block size of disk is available*/
+#define VIRTIO_BLK_F_SCSI       7       /* Supports scsi command passthru */
+#define VIRTIO_BLK_F_IDENTIFY   8       /* ATA IDENTIFY supported */
+
+#define VIRTIO_BLK_ID_LEN       256     /* length of identify u16 array */
+#define VIRTIO_BLK_ID_SN        10      /* start of char * serial# */
+#define VIRTIO_BLK_ID_SN_BYTES  20      /* length in bytes of serial# */

  /* These two define direction. */
  #define VIRTIO_BLK_T_IN		0
@@ -66,6 +72,7 @@ typedef struct virtio_blk_config {
      } geometry;
      /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
      u32 blk_size;
+    u16 identify[VIRTIO_BLK_ID_LEN];
  }blk_config, *pblk_config;
  #pragma pack()

@@ -97,6 +104,7 @@ typedef struct _ADAPTER_EXTENSION {
      LIST_ENTRY            list_head;
      LIST_ENTRY            complete_list;
      STOR_DPC              completion_dpc;
+    BOOLEAN               has_sn;
  }ADAPTER_EXTENSION, *PADAPTER_EXTENSION;

  typedef struct _RHEL_SRB_EXTENSION {
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[-- Attachment #2: add_support_for_serial_number_feature.patch --]
[-- Type: text/plain, Size: 3091 bytes --]

diff --git a/viostor/virtio_stor.c b/viostor/virtio_stor.c
index 375021b..b972dd2 100644
--- a/viostor/virtio_stor.c
+++ b/viostor/virtio_stor.c
@@ -416,6 +416,14 @@ VirtIoHwInitialize(
         RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("VIRTIO_BLK_F_GEOMETRY. cylinders = %d  heads = %d  sectors = %d\n", adaptExt->info.geometry.cylinders, adaptExt->info.geometry.heads, adaptExt->info.geometry.sectors));
     }
 
+    if (VirtIODeviceGetHostFeature(DeviceExtension, VIRTIO_BLK_F_IDENTIFY)) {
+        VirtIODeviceGet(DeviceExtension, FIELD_OFFSET(blk_config, identify),
+                      &adaptExt->info.identify, VIRTIO_BLK_ID_LEN);
+        adaptExt->has_sn = TRUE; 
+        RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("VIRTIO_BLK_F_IDENTIFY. \n"));
+    }
+
+
     VirtIODeviceGet( DeviceExtension, FIELD_OFFSET(blk_config, capacity),
                       &cap, sizeof(cap));
     adaptExt->info.capacity = cap;   
@@ -801,8 +809,13 @@ RhelScsiGetInquiryData(
         PVPD_SERIAL_NUMBER_PAGE SerialPage;
         SerialPage = (PVPD_SERIAL_NUMBER_PAGE)Srb->DataBuffer;
         SerialPage->PageCode = VPD_SERIAL_NUMBER;  
-        SerialPage->PageLength = 1;
-        SerialPage->SerialNumber[0] = '0';
+        if(adaptExt->has_sn) {
+           SerialPage->PageLength = VIRTIO_BLK_ID_SN_BYTES;
+           ScsiPortMoveMemory(&SerialPage->SerialNumber[0], &adaptExt->info.identify[VIRTIO_BLK_ID_SN], VIRTIO_BLK_ID_SN_BYTES);
+        } else {
+           SerialPage->PageLength = 1;
+           SerialPage->SerialNumber[0] = '0';
+        }
         Srb->DataTransferLength = sizeof(VPD_SERIAL_NUMBER_PAGE) + SerialPage->PageLength;
     }
     else if ((cdb->CDB6INQUIRY3.PageCode == VPD_DEVICE_IDENTIFIERS) && 
diff --git a/viostor/virtio_stor.h b/viostor/virtio_stor.h
index 2533148..dd4728e 100644
--- a/viostor/virtio_stor.h
+++ b/viostor/virtio_stor.h
@@ -36,6 +36,12 @@ typedef struct VirtIOBufferDescriptor VIO_SG, *PVIO_SG;
 #define VIRTIO_BLK_F_GEOMETRY	4	/* Legacy geometry available  */
 #define VIRTIO_BLK_F_RO		5	/* Disk is read-only */
 #define VIRTIO_BLK_F_BLK_SIZE	6	/* Block size of disk is available*/
+#define VIRTIO_BLK_F_SCSI       7       /* Supports scsi command passthru */
+#define VIRTIO_BLK_F_IDENTIFY   8       /* ATA IDENTIFY supported */
+
+#define VIRTIO_BLK_ID_LEN       256     /* length of identify u16 array */
+#define VIRTIO_BLK_ID_SN        10      /* start of char * serial# */
+#define VIRTIO_BLK_ID_SN_BYTES  20      /* length in bytes of serial# */
 
 /* These two define direction. */
 #define VIRTIO_BLK_T_IN		0
@@ -66,6 +72,7 @@ typedef struct virtio_blk_config {
     } geometry;
     /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
     u32 blk_size;
+    u16 identify[VIRTIO_BLK_ID_LEN];
 }blk_config, *pblk_config;
 #pragma pack()
 
@@ -97,6 +104,7 @@ typedef struct _ADAPTER_EXTENSION {
     LIST_ENTRY            list_head;
     LIST_ENTRY            complete_list;
     STOR_DPC              completion_dpc;
+    BOOLEAN               has_sn;
 }ADAPTER_EXTENSION, *PADAPTER_EXTENSION;
 
 typedef struct _RHEL_SRB_EXTENSION {

                 reply	other threads:[~2009-10-25 11:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AE4336B.6070104@redhat.com \
    --to=vrozenfe@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.