static void init_3592_inquiry(struct lu_phy_attr *lu) { int pg; uint8_t worm; uint8_t local_TapeAlert[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; worm = ((struct priv_lu_ssc *)lu->lu_private)->pm->drive_supports_WORM; lu->inquiry[2] = ((struct priv_lu_ssc *)lu->lu_private)->pm->drive_ANSI_VERSION; /* Sequential Access device capabilities - Ref: 8.4.2 */ pg = PCODE_OFFSET(0xb0); lu->lu_vpd[pg] = alloc_vpd(VPD_B0_SZ); if (!lu->lu_vpd[pg]) { MHVTL_ERR("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b0(lu, &worm); /* Manufacture-assigned serial number - Ref: 8.4.3 */ pg = PCODE_OFFSET(0xb1); lu->lu_vpd[pg] = alloc_vpd(VPD_B1_SZ); if (!lu->lu_vpd[pg]) { MHVTL_ERR("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b1(lu, lu->lu_serial_no); /* TapeAlert supported flags - Ref: 8.4.4 */ pg = PCODE_OFFSET(0xb2); lu->lu_vpd[pg] = alloc_vpd(VPD_B2_SZ); if (!lu->lu_vpd[pg]) { MHVTL_ERR("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b2(lu, &local_TapeAlert); /* VPD page 0xC0 */ pg = PCODE_OFFSET(0xc0); lu->lu_vpd[pg] = alloc_vpd(VPD_C0_SZ); if (!lu->lu_vpd[pg]) { MHVTL_ERR("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_c0(lu, "10-03-2008 19:38:00"); /* VPD page 0xC1 */ pg = PCODE_OFFSET(0xc1); lu->lu_vpd[pg] = alloc_vpd(strlen("Security")); if (!lu->lu_vpd[pg]) { MHVTL_ERR("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_c1(lu, "Security"); }
static void update_stk_l_vpd_83(struct lu_phy_attr *lu) { struct vpd *lu_vpd; lu_vpd = lu->lu_vpd[PCODE_OFFSET(0x83)]; /* STK L series do not have this VPD page - remove */ if (lu_vpd) { /* Free any earlier allocation */ dealloc_vpd(lu_vpd); lu->lu_vpd[PCODE_OFFSET(0x83)] = NULL; } }
static void update_scalar_vpd_83(struct lu_phy_attr *lu) { struct vpd *lu_vpd; struct smc_priv *smc_p; uint8_t *d; lu_vpd = lu->lu_vpd[PCODE_OFFSET(0x83)]; smc_p = lu->lu_private; /* Unit Serial Number */ if (lu_vpd) /* Free any earlier allocation */ dealloc_vpd(lu_vpd); lu_vpd = alloc_vpd(36); if (lu_vpd) { d = lu_vpd->data; d[0] = 0xf2; d[1] = 0x01; d[3] = 0x20; snprintf((char *)&d[4], 9, "%-8s", lu->vendor_id); snprintf((char *)&d[12], 25, "%-24s", lu->lu_serial_no); } else { MHVTL_ERR("Could not malloc(36) bytes, line %d", __LINE__); } }
static void update_stk_l_vpd_80(struct lu_phy_attr *lu) { struct vpd **lu_vpd = lu->lu_vpd; struct smc_priv *smc_p = lu->lu_private; uint8_t *d; int pg; smc_p = lu->lu_private; /* Unit Serial Number */ pg = PCODE_OFFSET(0x80); if (lu_vpd[pg]) /* Free any earlier allocation */ dealloc_vpd(lu_vpd[pg]); lu_vpd[pg] = alloc_vpd(0x12); if (lu_vpd[pg]) { d = lu_vpd[pg]->data; d[0] = lu->ptype; d[1] = 0x80; /* Page code */ d[3] = 0x0b; /* Page length */ /* d[4 - 15] Serial number of device */ snprintf((char *)&d[4], 10, "%-10s", lu->lu_serial_no); /* Unique Logical Library Identifier */ } else { MHVTL_DBG(1, "Could not malloc(0x12) bytes, line %d", __LINE__); } }
static void update_eml_vpd_83(struct lu_phy_attr *lu) { struct vpd *vpd_pg = lu->lu_vpd[PCODE_OFFSET(0x83)]; uint8_t *d; int num; char *ptr; int len, j; d = vpd_pg->data; d[0] = 2; d[1] = 1; d[2] = 0; num = VENDOR_ID_LEN + PRODUCT_ID_LEN + 10; d[3] = num; memcpy(&d[4], &lu->vendor_id, VENDOR_ID_LEN); memcpy(&d[12], &lu->product_id, PRODUCT_ID_LEN); memcpy(&d[28], &lu->lu_serial_no, 10); len = (int)strlen(lu->lu_serial_no); ptr = &lu->lu_serial_no[len]; num += 4; /* NAA IEEE registered identifier (faked) */ d[num] = 0x1; /* Binary */ d[num + 1] = 0x3; d[num + 2] = 0x0; d[num + 3] = 0x8; d[num + 4] = 0x51; d[num + 5] = 0x23; d[num + 6] = 0x45; d[num + 7] = 0x60; d[num + 8] = 0x3; d[num + 9] = 0x3; d[num + 10] = 0x3; d[num + 11] = 0x3; if (lu->naa) { /* If defined in config file */ sscanf((const char *)lu->naa, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &d[num + 4], &d[num + 5], &d[num + 6], &d[num + 7], &d[num + 8], &d[num + 9], &d[num + 10], &d[num + 11]); } else { /* Else munge the serial number */ ptr--; for (j = 11; j > 3; ptr--, j--) d[num + j] = *ptr; } d[num + 4] &= 0x0f; d[num + 4] |= 0x50; }
static void update_vpd_ult_c1(struct lu_phy_attr *lu, char *sn) { uint8_t *data; struct vpd *vpd_p; vpd_p = lu->lu_vpd[PCODE_OFFSET(0xc1)]; data = vpd_p->data; data[1] = 0xc1; data[3] = 0x18; snprintf((char *)&data[4], 12, "%-12s", sn); snprintf((char *)&data[16], 12, "%-12s", sn); }
/* DLT7000 & DLT8000 */ static void init_dlt_inquiry(struct lu_phy_attr *lu) { int pg; char b[32]; int x, y, z; lu->inquiry[2] = ((struct priv_lu_ssc *)lu->lu_private)->pm->drive_ANSI_VERSION; lu->inquiry[36] = get_product_family(lu); sprintf(b, "%s", MHVTL_VERSION); sscanf(b, "%d.%d.%d", &x, &y, &z); if (x) { lu->inquiry[37] = x; lu->inquiry[38] = y; } else { lu->inquiry[37] = y; lu->inquiry[38] = z; } /* VPD page 0xC0 */ pg = PCODE_OFFSET(0xc0); lu->lu_vpd[pg] = alloc_vpd(44); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_dlt_c0(lu); /* VPD page 0xC1 */ pg = PCODE_OFFSET(0xc1); lu->lu_vpd[pg] = alloc_vpd(44); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_dlt_c1(lu, lu->lu_serial_no); }
static void update_vpd_dlt_c1(struct lu_phy_attr *lu, char *sn) { uint8_t *data; struct vpd *vpd_p; vpd_p = lu->lu_vpd[PCODE_OFFSET(0xc1)]; data = vpd_p->data; data[1] = 0xc1; data[3] = 0x39; data[4] = get_product_family(lu); snprintf((char *)&data[4], 12, "%-12s", sn); snprintf((char *)&data[24], 12, "%-12s", sn); }
static void update_hp_vpd_cx(struct lu_phy_attr *lu, uint8_t pg, char *comp, char *vers, char *date, char *variant) { struct vpd *vpd_p; char *data; vpd_p = lu->lu_vpd[PCODE_OFFSET(pg)]; if (!vpd_p) { MHVTL_LOG("Arrhhh... vpd pg %d not defined...", pg); } data = (char *)vpd_p->data; data[3] = 0x5c; snprintf(&data[4], 24, "%-24s", comp); snprintf(&data[30], 18, "%-18s", vers); snprintf(&data[49], 24, "%-24s", date); snprintf(&data[73], 22, "%-22s", variant); }
/* As per IBM LTO5 SCSI Programmers Guide.. * Filling in compile time/date & dummy 'platform' string */ static void update_vpd_dlt_c0(struct lu_phy_attr *lu) { uint8_t *data; struct vpd *vpd_p; int h, m, s; int day, month, year; vpd_p = lu->lu_vpd[PCODE_OFFSET(0xc0)]; data = vpd_p->data; month = 0; sscanf(__TIME__, "%d:%d:%d", &h, &m, &s); if (sscanf(__DATE__, "Jan %d %d", &day, &year) == 2) month = 1; if (sscanf(__DATE__, "Feb %d %d", &day, &year) == 2) month = 2; if (sscanf(__DATE__, "Mar %d %d", &day, &year) == 2) month = 3; if (sscanf(__DATE__, "Apr %d %d", &day, &year) == 2) month = 4; if (sscanf(__DATE__, "May %d %d", &day, &year) == 2) month = 5; if (sscanf(__DATE__, "Jun %d %d", &day, &year) == 2) month = 6; if (sscanf(__DATE__, "Jul %d %d", &day, &year) == 2) month = 7; if (sscanf(__DATE__, "Aug %d %d", &day, &year) == 2) month = 8; if (sscanf(__DATE__, "Sep %d %d", &day, &year) == 2) month = 9; if (sscanf(__DATE__, "Oct %d %d", &day, &year) == 2) month = 10; if (sscanf(__DATE__, "Nov %d %d", &day, &year) == 2) month = 11; if (sscanf(__DATE__, "Dec %d %d", &day, &year) == 2) month = 12; data[1] = 0xc0; data[3] = 0x28; /* Controller firmware build date */ sprintf((char *)&data[20], "%02d-%02d-%04d %02d:%02d:%02d", day, month, year, h, m, s); }
static void init_t10k_inquiry(struct lu_phy_attr *lu) { int pg; uint8_t worm = 1; /* Supports WORM */ lu->inquiry[3] = 0x42; lu->inquiry[4] = INQUIRY_LEN - 5; /* Additional Length */ lu->inquiry[54] = 0x04; /* Key Management */ lu->inquiry[55] = 0x12; /* Support Encryption & Compression */ /* Sequential Access device capabilities - Ref: 8.4.2 */ pg = PCODE_OFFSET(0xb0); lu->lu_vpd[pg] = alloc_vpd(VPD_B0_SZ); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b0(lu, &worm); }
/* As per IBM LTO5 SCSI Programmers Guide.. * Filling in compile time/date & dummy 'platform' string */ static void update_vpd_ult_c0(struct lu_phy_attr *lu) { uint8_t *data; struct vpd *vpd_p; int h, m, s; int day, month, year; vpd_p = lu->lu_vpd[PCODE_OFFSET(0xc0)]; data = vpd_p->data; ymd(&year, &month, &day, &h, &m, &s); data[1] = 0xc0; data[3] = 0x27; sprintf((char *)&data[16], "%02d%02d%02d", h, m, s); sprintf((char *)&data[23], "%04d%02d%02d", year, month, day); sprintf((char *)&data[31], "mhvtl_fl_f"); }
static void update_eml_vpd_80(struct lu_phy_attr *lu) { struct vpd **lu_vpd = lu->lu_vpd; uint8_t *d; int pg; /* Unit Serial Number */ pg = PCODE_OFFSET(0x80); if (lu_vpd[pg]) /* Free any earlier allocation */ dealloc_vpd(lu_vpd[pg]); lu_vpd[pg] = alloc_vpd(0x12); if (lu_vpd[pg]) { d = lu_vpd[pg]->data; snprintf((char *)&d[0], 11, "%-10.10s", lu->lu_serial_no); /* Unique Logical Library Identifier */ } else { MHVTL_ERR("Could not malloc(0x12) bytes, line %d", __LINE__); } }
/* As per IBM LTO5 SCSI Programmers Guide.. * Filling in compile time/date & dummy 'platform' string */ static void update_vpd_dlt_c0(struct lu_phy_attr *lu) { uint8_t *data; struct vpd *vpd_p; int h, m, s; int day, month, year; vpd_p = lu->lu_vpd[PCODE_OFFSET(0xc0)]; data = vpd_p->data; month = 0; ymd(&year, &month, &day, &h, &m, &s); data[1] = 0xc0; data[3] = 0x28; /* Controller firmware build date */ sprintf((char *)&data[20], "%02d-%02d-%04d %02d:%02d:%02d", day, month, year, h, m, s); }
static void update_stk_l_vpd_80(struct lu_phy_attr *lu) { struct vpd *lu_vpd; uint8_t *d; lu_vpd = lu->lu_vpd[PCODE_OFFSET(0x80)]; /* Unit Serial Number */ if (lu_vpd) /* Free any earlier allocation */ dealloc_vpd(lu_vpd); lu_vpd = alloc_vpd(0x12); if (lu_vpd) { d = lu_vpd->data; /* d[4 - 15] Serial number of device */ snprintf((char *)&d[0], 13, "%-12s", lu->lu_serial_no); /* Unique Logical Library Identifier */ } else { MHVTL_ERR("Could not malloc(0x12) bytes, line %d", __LINE__); } }
static void update_scalar_vpd_80(struct lu_phy_attr *lu) { struct vpd *lu_vpd; struct smc_priv *smc_p; uint8_t *d; lu_vpd = lu->lu_vpd[PCODE_OFFSET(0x80)]; smc_p = lu->lu_private; /* Unit Serial Number */ if (lu_vpd) /* Free any earlier allocation */ dealloc_vpd(lu_vpd); lu_vpd = alloc_vpd(24); if (lu_vpd) { d = lu_vpd->data; /* d[4 - 27] Serial number prefixed by Vendor ID */ snprintf((char *)&d[0], 25, "%-s%-17s", lu->vendor_id, lu->lu_serial_no); } else { MHVTL_ERR("Could not malloc(24) bytes, line %d", __LINE__); } }
static void init_9840_inquiry(struct lu_phy_attr *lu) { int pg; uint8_t worm; worm = ((struct priv_lu_ssc *)lu->lu_private)->pm->drive_supports_WORM; lu->inquiry[2] = ((struct priv_lu_ssc *)lu->lu_private)->pm->drive_ANSI_VERSION; lu->inquiry[3] = 0x42; lu->inquiry[4] = INQUIRY_LEN - 5; /* Additional Length */ lu->inquiry[54] = 0x04; /* Key Management */ lu->inquiry[55] = 0x12; /* Support Encryption & Compression */ /* Sequential Access device capabilities - Ref: 8.4.2 */ pg = PCODE_OFFSET(0xb0); lu->lu_vpd[pg] = alloc_vpd(VPD_B0_SZ); if (!lu->lu_vpd[pg]) { MHVTL_ERR("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b0(lu, &worm); }
static void init_ult_inquiry(struct lu_phy_attr *lu) { int pg; uint8_t worm = 1; /* Supports WORM */ uint8_t local_TapeAlert[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; pg = PCODE_OFFSET(0x86); lu->lu_vpd[pg] = alloc_vpd(VPD_86_SZ); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } /* Sequential Access device capabilities - Ref: 8.4.2 */ pg = PCODE_OFFSET(0xb0); lu->lu_vpd[pg] = alloc_vpd(VPD_B0_SZ); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b0(lu, &worm); /* Manufacture-assigned serial number - Ref: 8.4.3 */ pg = PCODE_OFFSET(0xb1); lu->lu_vpd[pg] = alloc_vpd(VPD_B1_SZ); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b1(lu, lu->lu_serial_no); /* TapeAlert supported flags - Ref: 8.4.4 */ pg = PCODE_OFFSET(0xb2); lu->lu_vpd[pg] = alloc_vpd(VPD_B2_SZ); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b2(lu, &local_TapeAlert); /* VPD page 0xC0 - Firmware revision page */ pg = PCODE_OFFSET(0xc0); lu->lu_vpd[pg] = alloc_vpd(0x60); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_hp_vpd_cx(lu, pg, "Firmware", MHVTL_VERSION, "2012/04/18 19:38", "6"); /* VPD page 0xC1 - Hardware */ pg = PCODE_OFFSET(0xc1); lu->lu_vpd[pg] = alloc_vpd(0x60); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_hp_vpd_cx(lu, pg, "Hardware", MHVTL_VERSION, "2012/04/18 06:53", "5"); /* VPD page 0xC2 - PCA */ pg = PCODE_OFFSET(0xc2); lu->lu_vpd[pg] = alloc_vpd(0x60); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_hp_vpd_cx(lu, pg, "PCA", MHVTL_VERSION, "1996/11/29 10:00", "4"); /* VPD page 0xC3 - Mechanism */ pg = PCODE_OFFSET(0xc3); lu->lu_vpd[pg] = alloc_vpd(0x60); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_hp_vpd_cx(lu, pg, "Mechanism", MHVTL_VERSION, "1992/08/11 10:00", "3"); /* VPD page 0xC4 - Head Assembly */ pg = PCODE_OFFSET(0xc4); lu->lu_vpd[pg] = alloc_vpd(0x60); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_hp_vpd_cx(lu, pg, "Head Assy", MHVTL_VERSION, "1966/07/28 10:00", "2"); /* VPD page 0xC5 - ACI */ pg = PCODE_OFFSET(0xc5); lu->lu_vpd[pg] = alloc_vpd(0x60); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_hp_vpd_cx(lu, pg, "ACI", MHVTL_VERSION, "1960/03/10 10:00", "1"); }
/* SuperDLT range */ static void init_sdlt_inquiry(struct lu_phy_attr *lu) { int pg; uint8_t worm; uint8_t ta[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; char b[32]; int x, y, z; worm = ((struct priv_lu_ssc *)lu->lu_private)->pm->drive_supports_WORM; lu->inquiry[2] = ((struct priv_lu_ssc *)lu->lu_private)->pm->drive_ANSI_VERSION; lu->inquiry[36] = get_product_family(lu); sprintf(b, "%s", MHVTL_VERSION); sscanf(b, "%d.%d.%d", &x, &y, &z); if (x) { lu->inquiry[37] = x; lu->inquiry[38] = y; } else { lu->inquiry[37] = y; lu->inquiry[38] = z; } /* Sequential Access device capabilities - Ref: 8.4.2 */ pg = PCODE_OFFSET(0xb0); lu->lu_vpd[pg] = alloc_vpd(VPD_B0_SZ); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b0(lu, &worm); /* Manufacture-assigned serial number - Ref: 8.4.3 */ pg = PCODE_OFFSET(0xb1); lu->lu_vpd[pg] = alloc_vpd(VPD_B1_SZ); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b1(lu, lu->lu_serial_no); /* TapeAlert supported flags - Ref: 8.4.4 */ pg = PCODE_OFFSET(0xb2); lu->lu_vpd[pg] = alloc_vpd(VPD_B2_SZ); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_b2(lu, &ta); /* VPD page 0xC0 */ pg = PCODE_OFFSET(0xc0); lu->lu_vpd[pg] = alloc_vpd(44); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_dlt_c0(lu); /* VPD page 0xC1 */ pg = PCODE_OFFSET(0xc1); lu->lu_vpd[pg] = alloc_vpd(44); if (!lu->lu_vpd[pg]) { MHVTL_LOG("Failed to malloc(): Line %d", __LINE__); exit(-ENOMEM); } update_vpd_dlt_c1(lu, lu->lu_serial_no); }
static void update_eml_vpd_83(struct lu_phy_attr *lu) { struct vpd **lu_vpd = lu->lu_vpd; uint8_t *d; int num; char *ptr; int pg; int len, j; num = VENDOR_ID_LEN + PRODUCT_ID_LEN + 10; pg = PCODE_OFFSET(0x83); if (lu_vpd[pg]) /* Free any earlier allocation */ dealloc_vpd(lu_vpd[pg]); lu_vpd[pg] = alloc_vpd(num + 12); if (!lu_vpd[pg]) { MHVTL_ERR("Can't malloc() to setup for vpd_83"); return; } d = lu_vpd[pg]->data; d[0] = 2; d[1] = 1; d[2] = 0; d[3] = num; memcpy(&d[4], &lu->vendor_id, VENDOR_ID_LEN); memcpy(&d[12], &lu->product_id, PRODUCT_ID_LEN); memcpy(&d[28], &lu->lu_serial_no, 10); len = (int)strlen(lu->lu_serial_no); ptr = &lu->lu_serial_no[len]; num += 4; /* NAA IEEE registered identifier (faked) */ d[num] = 0x1; /* Binary */ d[num + 1] = 0x3; d[num + 2] = 0x0; d[num + 3] = 0x8; d[num + 4] = 0x51; d[num + 5] = 0x23; d[num + 6] = 0x45; d[num + 7] = 0x60; d[num + 8] = 0x3; d[num + 9] = 0x3; d[num + 10] = 0x3; d[num + 11] = 0x3; if (lu->naa) { /* If defined in config file */ sscanf((const char *)lu->naa, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &d[num + 4], &d[num + 5], &d[num + 6], &d[num + 7], &d[num + 8], &d[num + 9], &d[num + 10], &d[num + 11]); } else { /* Else munge the serial number */ ptr--; for (j = 11; j > 3; ptr--, j--) d[num + j] = *ptr; } d[num + 4] &= 0x0f; d[num + 4] |= 0x50; }