s390/chsc: implement store SCM information
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Tue, 28 Aug 2012 14:45:42 +0000 (16:45 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Wed, 26 Sep 2012 13:44:58 +0000 (15:44 +0200)
chsc_scm_info will be used to detect all available increments of
storage class memory.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/cio/chsc.c
drivers/s390/cio/chsc.h

index cfe0c087fe5cc915859265bb59016076e120d84c..121865385c057b3df143e1e8061d347347019993 100644 (file)
@@ -52,6 +52,11 @@ int chsc_error_from_response(int response)
                return -EINVAL;
        case 0x0004:
                return -EOPNOTSUPP;
+       case 0x000b:
+               return -EBUSY;
+       case 0x0100:
+       case 0x0102:
+               return -ENOMEM;
        default:
                return -EIO;
        }
@@ -1047,3 +1052,33 @@ out:
        return rc;
 }
 EXPORT_SYMBOL_GPL(chsc_siosl);
+
+/**
+ * chsc_scm_info() - store SCM information (SSI)
+ * @scm_area: request and response block for SSI
+ * @token: continuation token
+ *
+ * Returns 0 on success.
+ */
+int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token)
+{
+       int ccode, ret;
+
+       memset(scm_area, 0, sizeof(*scm_area));
+       scm_area->request.length = 0x0020;
+       scm_area->request.code = 0x004C;
+       scm_area->reqtok = token;
+
+       ccode = chsc(scm_area);
+       if (ccode > 0) {
+               ret = (ccode == 3) ? -ENODEV : -EBUSY;
+               goto out;
+       }
+       ret = chsc_error_from_response(scm_area->response.code);
+       if (ret != 0)
+               CIO_MSG_EVENT(2, "chsc: scm info failed (rc=%04x)\n",
+                             scm_area->response.code);
+out:
+       return ret;
+}
+EXPORT_SYMBOL_GPL(chsc_scm_info);
index b5261f318fe880125f985e4f916373137449c5ac..3aa94fe7a676f7f85cf43658cc7e9e5095f4f237 100644 (file)
@@ -119,4 +119,39 @@ int chsc_error_from_response(int response);
 
 int chsc_siosl(struct subchannel_id schid);
 
+/* Functions and definitions to query storage-class memory. */
+struct sale {
+       u64 sa;
+       u32 p:4;
+       u32 op_state:4;
+       u32 data_state:4;
+       u32 rank:4;
+       u32 r:1;
+       u32:7;
+       u32 rid:8;
+       u32:32;
+} __packed;
+
+struct chsc_scm_info {
+       struct chsc_header request;
+       u32:32;
+       u64 reqtok;
+       u32 reserved1[4];
+       struct chsc_header response;
+       u64:56;
+       u8 rq;
+       u32 mbc;
+       u64 msa;
+       u16 is;
+       u16 mmc;
+       u32 mci;
+       u64 nr_scm_ini;
+       u64 nr_scm_unini;
+       u32 reserved2[10];
+       u64 restok;
+       struct sale scmal[248];
+} __packed;
+
+int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token);
+
 #endif