Commit 4abb08c2 authored by Stefan Weinhuber's avatar Stefan Weinhuber Committed by Martin Schwidefsky

[S390] dasd: Add support for enhanced VM UID

When z/VM provides two virtual devices (minidisks) that reside on the
same real device, both will receive the configuration data from the
real device and thus get the same uid. To fix this problem, z/VM
provides an additional configuration data record that allows to
distinguish between minidisks.
z/VM APAR VM64273 needs be installed so this fix has an effect.
Signed-off-by: default avatarStefan Weinhuber <wein@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent c2bb4e5d
...@@ -91,7 +91,8 @@ static struct alias_pav_group *_find_group(struct alias_lcu *lcu, ...@@ -91,7 +91,8 @@ static struct alias_pav_group *_find_group(struct alias_lcu *lcu,
else else
search_unit_addr = uid->base_unit_addr; search_unit_addr = uid->base_unit_addr;
list_for_each_entry(pos, &lcu->grouplist, group) { list_for_each_entry(pos, &lcu->grouplist, group) {
if (pos->uid.base_unit_addr == search_unit_addr) if (pos->uid.base_unit_addr == search_unit_addr &&
!strncmp(pos->uid.vduit, uid->vduit, sizeof(uid->vduit)))
return pos; return pos;
}; };
return NULL; return NULL;
...@@ -332,6 +333,7 @@ static int _add_device_to_lcu(struct alias_lcu *lcu, ...@@ -332,6 +333,7 @@ static int _add_device_to_lcu(struct alias_lcu *lcu,
group->uid.base_unit_addr = uid->real_unit_addr; group->uid.base_unit_addr = uid->real_unit_addr;
else else
group->uid.base_unit_addr = uid->base_unit_addr; group->uid.base_unit_addr = uid->base_unit_addr;
memcpy(group->uid.vduit, uid->vduit, sizeof(uid->vduit));
INIT_LIST_HEAD(&group->group); INIT_LIST_HEAD(&group->group);
INIT_LIST_HEAD(&group->baselist); INIT_LIST_HEAD(&group->baselist);
INIT_LIST_HEAD(&group->aliaslist); INIT_LIST_HEAD(&group->aliaslist);
......
...@@ -913,7 +913,8 @@ dasd_vendor_show(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -913,7 +913,8 @@ dasd_vendor_show(struct device *dev, struct device_attribute *attr, char *buf)
static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL); static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL);
#define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\ #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\
/* SSID */ 4 + 1 + /* unit addr */ 2 + 1) /* SSID */ 4 + 1 + /* unit addr */ 2 + 1 +\
/* vduit */ 32 + 1)
static ssize_t static ssize_t
dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf) dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
...@@ -945,8 +946,17 @@ dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -945,8 +946,17 @@ dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
sprintf(ua_string, "%02x", uid->real_unit_addr); sprintf(ua_string, "%02x", uid->real_unit_addr);
break; break;
} }
snprintf(uid_string, sizeof(uid_string), "%s.%s.%04x.%s", if (strlen(uid->vduit) > 0)
uid->vendor, uid->serial, uid->ssid, ua_string); snprintf(uid_string, sizeof(uid_string),
"%s.%s.%04x.%s.%s",
uid->vendor, uid->serial,
uid->ssid, ua_string,
uid->vduit);
else
snprintf(uid_string, sizeof(uid_string),
"%s.%s.%04x.%s",
uid->vendor, uid->serial,
uid->ssid, ua_string);
spin_unlock(&dasd_devmap_lock); spin_unlock(&dasd_devmap_lock);
return snprintf(buf, PAGE_SIZE, "%s\n", uid_string); return snprintf(buf, PAGE_SIZE, "%s\n", uid_string);
} }
......
...@@ -313,8 +313,8 @@ static int prefix(struct ccw1 *ccw, struct PFX_eckd_data *pfxdata, int trk, ...@@ -313,8 +313,8 @@ static int prefix(struct ccw1 *ccw, struct PFX_eckd_data *pfxdata, int trk,
memset(pfxdata, 0, sizeof(*pfxdata)); memset(pfxdata, 0, sizeof(*pfxdata));
/* prefix data */ /* prefix data */
pfxdata->format = 0; pfxdata->format = 0;
pfxdata->base_address = basepriv->conf_data.ned1.unit_addr; pfxdata->base_address = basepriv->ned->unit_addr;
pfxdata->base_lss = basepriv->conf_data.ned1.ID; pfxdata->base_lss = basepriv->ned->ID;
pfxdata->validity.define_extend = 1; pfxdata->validity.define_extend = 1;
/* private uid is kept up to date, conf_data may be outdated */ /* private uid is kept up to date, conf_data may be outdated */
...@@ -536,36 +536,40 @@ dasd_eckd_cdl_reclen(int recid) ...@@ -536,36 +536,40 @@ dasd_eckd_cdl_reclen(int recid)
/* /*
* Generate device unique id that specifies the physical device. * Generate device unique id that specifies the physical device.
*/ */
static int static int dasd_eckd_generate_uid(struct dasd_device *device,
dasd_eckd_generate_uid(struct dasd_device *device, struct dasd_uid *uid) struct dasd_uid *uid)
{ {
struct dasd_eckd_private *private; struct dasd_eckd_private *private;
struct dasd_eckd_confdata *confdata; int count;
private = (struct dasd_eckd_private *) device->private; private = (struct dasd_eckd_private *) device->private;
if (!private) if (!private)
return -ENODEV; return -ENODEV;
confdata = &private->conf_data; if (!private->ned || !private->gneq)
if (!confdata)
return -ENODEV; return -ENODEV;
memset(uid, 0, sizeof(struct dasd_uid)); memset(uid, 0, sizeof(struct dasd_uid));
memcpy(uid->vendor, confdata->ned1.HDA_manufacturer, memcpy(uid->vendor, private->ned->HDA_manufacturer,
sizeof(uid->vendor) - 1); sizeof(uid->vendor) - 1);
EBCASC(uid->vendor, sizeof(uid->vendor) - 1); EBCASC(uid->vendor, sizeof(uid->vendor) - 1);
memcpy(uid->serial, confdata->ned1.HDA_location, memcpy(uid->serial, private->ned->HDA_location,
sizeof(uid->serial) - 1); sizeof(uid->serial) - 1);
EBCASC(uid->serial, sizeof(uid->serial) - 1); EBCASC(uid->serial, sizeof(uid->serial) - 1);
uid->ssid = confdata->neq.subsystemID; uid->ssid = private->gneq->subsystemID;
uid->real_unit_addr = confdata->ned1.unit_addr; uid->real_unit_addr = private->ned->unit_addr;;
if (confdata->ned2.sneq.flags == 0x40 && if (private->sneq) {
confdata->ned2.sneq.format == 0x0001) { uid->type = private->sneq->sua_flags;
uid->type = confdata->ned2.sneq.sua_flags;
if (uid->type == UA_BASE_PAV_ALIAS) if (uid->type == UA_BASE_PAV_ALIAS)
uid->base_unit_addr = confdata->ned2.sneq.base_unit_addr; uid->base_unit_addr = private->sneq->base_unit_addr;
} else { } else {
uid->type = UA_BASE_DEVICE; uid->type = UA_BASE_DEVICE;
} }
if (private->vdsneq) {
for (count = 0; count < 16; count++) {
sprintf(uid->vduit+2*count, "%02x",
private->vdsneq->uit[count]);
}
}
return 0; return 0;
} }
...@@ -623,6 +627,15 @@ static int dasd_eckd_read_conf_lpm(struct dasd_device *device, ...@@ -623,6 +627,15 @@ static int dasd_eckd_read_conf_lpm(struct dasd_device *device,
ret = -ENOMEM; ret = -ENOMEM;
goto out_error; goto out_error;
} }
/*
* buffer has to start with EBCDIC "V1.0" to show
* support for virtual device SNEQ
*/
rcd_buf[0] = 0xE5;
rcd_buf[1] = 0xF1;
rcd_buf[2] = 0x4B;
rcd_buf[3] = 0xF0;
cqr = dasd_eckd_build_rcd_lpm(device, rcd_buf, ciw, lpm); cqr = dasd_eckd_build_rcd_lpm(device, rcd_buf, ciw, lpm);
if (IS_ERR(cqr)) { if (IS_ERR(cqr)) {
ret = PTR_ERR(cqr); ret = PTR_ERR(cqr);
...@@ -646,8 +659,62 @@ out_error: ...@@ -646,8 +659,62 @@ out_error:
return ret; return ret;
} }
static int static int dasd_eckd_identify_conf_parts(struct dasd_eckd_private *private)
dasd_eckd_read_conf(struct dasd_device *device) {
struct dasd_sneq *sneq;
int i, count;
private->ned = NULL;
private->sneq = NULL;
private->vdsneq = NULL;
private->gneq = NULL;
count = private->conf_len / sizeof(struct dasd_sneq);
sneq = (struct dasd_sneq *)private->conf_data;
for (i = 0; i < count; ++i) {
if (sneq->flags.identifier == 1 && sneq->format == 1)
private->sneq = sneq;
else if (sneq->flags.identifier == 1 && sneq->format == 4)
private->vdsneq = (struct vd_sneq *)sneq;
else if (sneq->flags.identifier == 2)
private->gneq = (struct dasd_gneq *)sneq;
else if (sneq->flags.identifier == 3 && sneq->res1 == 1)
private->ned = (struct dasd_ned *)sneq;
sneq++;
}
if (!private->ned || !private->gneq) {
private->ned = NULL;
private->sneq = NULL;
private->vdsneq = NULL;
private->gneq = NULL;
return -EINVAL;
}
return 0;
};
static unsigned char dasd_eckd_path_access(void *conf_data, int conf_len)
{
struct dasd_gneq *gneq;
int i, count, found;
count = conf_len / sizeof(*gneq);
gneq = (struct dasd_gneq *)conf_data;
found = 0;
for (i = 0; i < count; ++i) {
if (gneq->flags.identifier == 2) {
found = 1;
break;
}
gneq++;
}
if (found)
return ((char *)gneq)[18] & 0x07;
else
return 0;
}
static int dasd_eckd_read_conf(struct dasd_device *device)
{ {
void *conf_data; void *conf_data;
int conf_len, conf_data_saved; int conf_len, conf_data_saved;
...@@ -661,7 +728,6 @@ dasd_eckd_read_conf(struct dasd_device *device) ...@@ -661,7 +728,6 @@ dasd_eckd_read_conf(struct dasd_device *device)
path_data->opm = ccw_device_get_path_mask(device->cdev); path_data->opm = ccw_device_get_path_mask(device->cdev);
lpm = 0x80; lpm = 0x80;
conf_data_saved = 0; conf_data_saved = 0;
/* get configuration data per operational path */ /* get configuration data per operational path */
for (lpm = 0x80; lpm; lpm>>= 1) { for (lpm = 0x80; lpm; lpm>>= 1) {
if (lpm & path_data->opm){ if (lpm & path_data->opm){
...@@ -678,22 +744,20 @@ dasd_eckd_read_conf(struct dasd_device *device) ...@@ -678,22 +744,20 @@ dasd_eckd_read_conf(struct dasd_device *device)
"data retrieved"); "data retrieved");
continue; /* no error */ continue; /* no error */
} }
if (conf_len != sizeof(struct dasd_eckd_confdata)) { /* save first valid configuration data */
MESSAGE(KERN_WARNING, if (!conf_data_saved) {
"sizes of configuration data mismatch" kfree(private->conf_data);
"%d (read) vs %ld (expected)", private->conf_data = conf_data;
conf_len, private->conf_len = conf_len;
sizeof(struct dasd_eckd_confdata)); if (dasd_eckd_identify_conf_parts(private)) {
private->conf_data = NULL;
private->conf_len = 0;
kfree(conf_data); kfree(conf_data);
continue; /* no error */ continue;
} }
/* save first valid configuration data */
if (!conf_data_saved){
memcpy(&private->conf_data, conf_data,
sizeof(struct dasd_eckd_confdata));
conf_data_saved++; conf_data_saved++;
} }
switch (((char *)conf_data)[242] & 0x07){ switch (dasd_eckd_path_access(conf_data, conf_len)) {
case 0x02: case 0x02:
path_data->npm |= lpm; path_data->npm |= lpm;
break; break;
...@@ -701,6 +765,7 @@ dasd_eckd_read_conf(struct dasd_device *device) ...@@ -701,6 +765,7 @@ dasd_eckd_read_conf(struct dasd_device *device)
path_data->ppm |= lpm; path_data->ppm |= lpm;
break; break;
} }
if (conf_data != private->conf_data)
kfree(conf_data); kfree(conf_data);
} }
} }
...@@ -952,6 +1017,7 @@ out_err2: ...@@ -952,6 +1017,7 @@ out_err2:
dasd_free_block(device->block); dasd_free_block(device->block);
device->block = NULL; device->block = NULL;
out_err1: out_err1:
kfree(private->conf_data);
kfree(device->private); kfree(device->private);
device->private = NULL; device->private = NULL;
return rc; return rc;
...@@ -959,7 +1025,17 @@ out_err1: ...@@ -959,7 +1025,17 @@ out_err1:
static void dasd_eckd_uncheck_device(struct dasd_device *device) static void dasd_eckd_uncheck_device(struct dasd_device *device)
{ {
struct dasd_eckd_private *private;
private = (struct dasd_eckd_private *) device->private;
dasd_alias_disconnect_device_from_lcu(device); dasd_alias_disconnect_device_from_lcu(device);
private->ned = NULL;
private->sneq = NULL;
private->vdsneq = NULL;
private->gneq = NULL;
private->conf_len = 0;
kfree(private->conf_data);
private->conf_data = NULL;
} }
static struct dasd_ccw_req * static struct dasd_ccw_req *
...@@ -1746,9 +1822,10 @@ dasd_eckd_fill_info(struct dasd_device * device, ...@@ -1746,9 +1822,10 @@ dasd_eckd_fill_info(struct dasd_device * device,
info->characteristics_size = sizeof(struct dasd_eckd_characteristics); info->characteristics_size = sizeof(struct dasd_eckd_characteristics);
memcpy(info->characteristics, &private->rdc_data, memcpy(info->characteristics, &private->rdc_data,
sizeof(struct dasd_eckd_characteristics)); sizeof(struct dasd_eckd_characteristics));
info->confdata_size = sizeof(struct dasd_eckd_confdata); info->confdata_size = min((unsigned long)private->conf_len,
memcpy(info->configuration_data, &private->conf_data, sizeof(info->configuration_data));
sizeof(struct dasd_eckd_confdata)); memcpy(info->configuration_data, private->conf_data,
info->confdata_size);
return 0; return 0;
} }
......
...@@ -231,133 +231,62 @@ struct dasd_eckd_characteristics { ...@@ -231,133 +231,62 @@ struct dasd_eckd_characteristics {
__u8 reserved3[10]; __u8 reserved3[10];
} __attribute__ ((packed)); } __attribute__ ((packed));
struct dasd_eckd_confdata { /* elements of the configuration data */
struct dasd_ned {
struct { struct {
struct { __u8 identifier:2;
unsigned char identifier:2; __u8 token_id:1;
unsigned char token_id:1; __u8 sno_valid:1;
unsigned char sno_valid:1; __u8 subst_sno:1;
unsigned char subst_sno:1; __u8 recNED:1;
unsigned char recNED:1; __u8 emuNED:1;
unsigned char emuNED:1; __u8 reserved:1;
unsigned char reserved:1;
} __attribute__ ((packed)) flags; } __attribute__ ((packed)) flags;
__u8 descriptor; __u8 descriptor;
__u8 dev_class; __u8 dev_class;
__u8 reserved; __u8 reserved;
unsigned char dev_type[6]; __u8 dev_type[6];
unsigned char dev_model[3]; __u8 dev_model[3];
unsigned char HDA_manufacturer[3]; __u8 HDA_manufacturer[3];
unsigned char HDA_location[2]; __u8 HDA_location[2];
unsigned char HDA_seqno[12]; __u8 HDA_seqno[12];
__u8 ID; __u8 ID;
__u8 unit_addr; __u8 unit_addr;
} __attribute__ ((packed)) ned1; } __attribute__ ((packed));
union {
struct { struct dasd_sneq {
struct { struct {
unsigned char identifier:2; __u8 identifier:2;
unsigned char token_id:1; __u8 reserved:6;
unsigned char sno_valid:1;
unsigned char subst_sno:1;
unsigned char recNED:1;
unsigned char emuNED:1;
unsigned char reserved:1;
} __attribute__ ((packed)) flags; } __attribute__ ((packed)) flags;
__u8 descriptor; __u8 res1;
__u8 reserved[2]; __u16 format;
unsigned char dev_type[6]; __u8 res2[4]; /* byte 4- 7 */
unsigned char dev_model[3]; __u8 sua_flags; /* byte 8 */
unsigned char DASD_manufacturer[3];
unsigned char DASD_location[2];
unsigned char DASD_seqno[12];
__u16 ID;
} __attribute__ ((packed)) ned;
struct {
unsigned char flags; /* byte 0 */
unsigned char res1; /* byte 1 */
__u16 format; /* byte 2-3 */
unsigned char res2[4]; /* byte 4-7 */
unsigned char sua_flags; /* byte 8 */
__u8 base_unit_addr; /* byte 9 */ __u8 base_unit_addr; /* byte 9 */
unsigned char res3[22]; /* byte 10-31 */ __u8 res3[22]; /* byte 10-31 */
} __attribute__ ((packed)) sneq; } __attribute__ ((packed));
} __attribute__ ((packed)) ned2;
struct { struct vd_sneq {
struct {
unsigned char identifier:2;
unsigned char token_id:1;
unsigned char sno_valid:1;
unsigned char subst_sno:1;
unsigned char recNED:1;
unsigned char emuNED:1;
unsigned char reserved:1;
} __attribute__ ((packed)) flags;
__u8 descriptor;
__u8 reserved[2];
unsigned char cont_type[6];
unsigned char cont_model[3];
unsigned char cont_manufacturer[3];
unsigned char cont_location[2];
unsigned char cont_seqno[12];
__u16 ID;
} __attribute__ ((packed)) ned3;
struct {
struct { struct {
unsigned char identifier:2; __u8 identifier:2;
unsigned char token_id:1; __u8 reserved:6;
unsigned char sno_valid:1;
unsigned char subst_sno:1;
unsigned char recNED:1;
unsigned char emuNED:1;
unsigned char reserved:1;
} __attribute__ ((packed)) flags; } __attribute__ ((packed)) flags;
__u8 descriptor; __u8 res1;
__u8 reserved[2]; __u16 format;
unsigned char cont_type[6]; __u8 res2[4]; /* byte 4- 7 */
unsigned char empty[3]; __u8 uit[16]; /* byte 8-23 */
unsigned char cont_manufacturer[3]; __u8 res3[8]; /* byte 24-31 */
unsigned char cont_location[2]; } __attribute__ ((packed));
unsigned char cont_seqno[12];
__u16 ID; struct dasd_gneq {
} __attribute__ ((packed)) ned4;
unsigned char ned5[32];
unsigned char ned6[32];
unsigned char ned7[32];
struct {
struct { struct {
unsigned char identifier:2; __u8 identifier:2;
unsigned char reserved:6; __u8 reserved:6;
} __attribute__ ((packed)) flags; } __attribute__ ((packed)) flags;
__u8 selector; __u8 reserved[7];
__u16 interfaceID;
__u32 reserved;
__u16 subsystemID; __u16 subsystemID;
struct { __u8 reserved2[22];
unsigned char sp0:1;
unsigned char sp1:1;
unsigned char reserved:5;
unsigned char scluster:1;
} __attribute__ ((packed)) spathID;
__u8 unit_address;
__u8 dev_ID;
__u8 dev_address;
__u8 adapterID;
__u16 link_address;
struct {
unsigned char parallel:1;
unsigned char escon:1;
unsigned char reserved:1;
unsigned char ficon:1;
unsigned char reserved2:4;
} __attribute__ ((packed)) protocol_type;
struct {
unsigned char PID_in_236:1;
unsigned char reserved:7;
} __attribute__ ((packed)) format_flags;
__u8 log_dev_address;
unsigned char reserved2[12];
} __attribute__ ((packed)) neq;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct dasd_eckd_path { struct dasd_eckd_path {
...@@ -463,7 +392,14 @@ struct alias_pav_group { ...@@ -463,7 +392,14 @@ struct alias_pav_group {
struct dasd_eckd_private { struct dasd_eckd_private {
struct dasd_eckd_characteristics rdc_data; struct dasd_eckd_characteristics rdc_data;
struct dasd_eckd_confdata conf_data; u8 *conf_data;
int conf_len;
/* pointers to specific parts in the conf_data */
struct dasd_ned *ned;
struct dasd_sneq *sneq;
struct vd_sneq *vdsneq;
struct dasd_gneq *gneq;
struct dasd_eckd_path path_data; struct dasd_eckd_path path_data;
struct eckd_count count_area[5]; struct eckd_count count_area[5];
int init_cqr_status; int init_cqr_status;
......
...@@ -307,6 +307,7 @@ struct dasd_uid { ...@@ -307,6 +307,7 @@ struct dasd_uid {
__u16 ssid; __u16 ssid;
__u8 real_unit_addr; __u8 real_unit_addr;
__u8 base_unit_addr; __u8 base_unit_addr;
char vduit[33];
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment