487 */
488 static int
489 ql_set_feature_bits(ql_adapter_state_t *ha, uint16_t features)
490 {
491 int rval;
492 uint32_t count;
493 nvram_t *nv;
494 uint16_t *wptr;
495 uint8_t *bptr;
496 uint8_t csum;
497 uint32_t start_addr;
498
499 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
500
501 if (CFG_IST(ha, CFG_CTRL_24258081)) {
502 EL(ha, "Not supported for 24xx\n");
503 return (EINVAL);
504 }
505
506 nv = kmem_zalloc(sizeof (*nv), KM_SLEEP);
507 if (nv == NULL) {
508 EL(ha, "failed, kmem_zalloc\n");
509 return (ENOMEM);
510 }
511
512 rval = ql_lock_nvram(ha, &start_addr, LNF_NVRAM_DATA);
513 if (rval != QL_SUCCESS) {
514 EL(ha, "failed, ql_lock_nvram=%xh\n", rval);
515 kmem_free(nv, sizeof (*nv));
516 return (EIO);
517 }
518 rval = 0;
519
520 /*
521 * Read off the whole NVRAM
522 */
523 wptr = (uint16_t *)nv;
524 csum = 0;
525 for (count = 0; count < sizeof (nvram_t) / 2; count++) {
526 *wptr = (uint16_t)ql_get_nvram_word(ha, count + start_addr);
527 csum = (uint8_t)(csum + (uint8_t)*wptr);
528 csum = (uint8_t)(csum + (uint8_t)(*wptr >> 8));
529 wptr++;
530 }
594 {
595 int rval;
596 uint32_t count;
597 uint32_t start_addr;
598
599 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
600
601 rval = ql_lock_nvram(ha, &start_addr, LNF_NVRAM_DATA);
602 if (rval != QL_SUCCESS) {
603 EL(ha, "failed, ql_lock_nvram=%xh\n", rval);
604 return (EIO);
605 }
606 rval = 0;
607
608 if (CFG_IST(ha, CFG_CTRL_24258081)) {
609 nvram_24xx_t *nv;
610 uint32_t *longptr;
611 uint32_t csum = 0;
612
613 nv = kmem_zalloc(sizeof (*nv), KM_SLEEP);
614 if (nv == NULL) {
615 EL(ha, "failed, kmem_zalloc\n");
616 return (ENOMEM);
617 }
618
619 nv->nvram_version[0] = LSB(ICB_24XX_VERSION);
620 nv->nvram_version[1] = MSB(ICB_24XX_VERSION);
621
622 nv->version[0] = 1;
623 nv->max_frame_length[1] = 8;
624 nv->execution_throttle[0] = 16;
625 nv->login_retry_count[0] = 8;
626
627 nv->firmware_options_1[0] = BIT_2 | BIT_1;
628 nv->firmware_options_1[1] = BIT_5;
629 nv->firmware_options_2[0] = BIT_5;
630 nv->firmware_options_2[1] = BIT_4;
631 nv->firmware_options_3[1] = BIT_6;
632
633 /*
634 * Set default host adapter parameters
635 */
636 nv->host_p[0] = BIT_4 | BIT_1;
637 nv->host_p[1] = BIT_3 | BIT_2;
671 rval = ql_24xx_read_flash(ha, count + start_addr,
672 longptr);
673 if (rval != QL_SUCCESS) {
674 EL(ha, "24xx_read_flash failed=%xh\n", rval);
675 break;
676 }
677 csum += *longptr;
678 }
679
680 if (csum) {
681 rval = EINVAL;
682 }
683 kmem_free(nv, sizeof (nvram_24xx_t));
684 } else {
685 nvram_t *nv;
686 uint16_t *wptr;
687 uint8_t *bptr;
688 uint8_t csum;
689
690 nv = kmem_zalloc(sizeof (*nv), KM_SLEEP);
691 if (nv == NULL) {
692 EL(ha, "failed, kmem_zalloc\n");
693 return (ENOMEM);
694 }
695 /*
696 * Set default initialization control block.
697 */
698 nv->parameter_block_version = ICB_VERSION;
699 nv->firmware_options[0] = BIT_4 | BIT_3 | BIT_2 | BIT_1;
700 nv->firmware_options[1] = BIT_7 | BIT_5 | BIT_2;
701
702 nv->max_frame_length[1] = 4;
703 nv->max_iocb_allocation[1] = 1;
704 nv->execution_throttle[0] = 16;
705 nv->login_retry_count = 8;
706 nv->port_name[0] = 33;
707 nv->port_name[3] = 224;
708 nv->port_name[4] = 139;
709 nv->login_timeout = 4;
710
711 /*
712 * Set default host adapter parameters
713 */
714 nv->host_p[0] = BIT_1;
923 * bp = user buffer address.
924 *
925 * Returns:
926 *
927 * Context:
928 * Kernel context.
929 */
930 int
931 ql_nv_util_load(ql_adapter_state_t *ha, void *bp, int mode)
932 {
933 uint8_t cnt;
934 void *nv;
935 uint16_t *wptr;
936 uint16_t data;
937 uint32_t start_addr, *lptr, data32;
938 nvram_t *nptr;
939 int rval;
940
941 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
942
943 if ((nv = kmem_zalloc(ha->nvram_cache->size, KM_SLEEP)) == NULL) {
944 EL(ha, "failed, kmem_zalloc\n");
945 return (ENOMEM);
946 }
947
948 if (ddi_copyin(bp, nv, ha->nvram_cache->size, mode) != 0) {
949 EL(ha, "Buffer copy failed\n");
950 kmem_free(nv, ha->nvram_cache->size);
951 return (EFAULT);
952 }
953
954 /* See if the buffer passed to us looks sane */
955 nptr = (nvram_t *)nv;
956 if (nptr->id[0] != 'I' || nptr->id[1] != 'S' || nptr->id[2] != 'P' ||
957 nptr->id[3] != ' ') {
958 EL(ha, "failed, buffer sanity check\n");
959 kmem_free(nv, ha->nvram_cache->size);
960 return (EINVAL);
961 }
962
963 /* Quiesce I/O */
964 if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
965 EL(ha, "ql_stall_driver failed\n");
966 kmem_free(nv, ha->nvram_cache->size);
1145 * Context:
1146 * Kernel context.
1147 */
1148 int
1149 ql_vpd_load(ql_adapter_state_t *ha, void *bp, int mode)
1150 {
1151 uint8_t cnt;
1152 uint8_t *vpd, *vpdptr, *vbuf;
1153 uint32_t start_addr, vpd_size, *lptr, data32;
1154 int rval;
1155
1156 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
1157
1158 if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
1159 EL(ha, "unsupported adapter feature\n");
1160 return (ENOTSUP);
1161 }
1162
1163 vpd_size = QL_24XX_VPD_SIZE;
1164
1165 if ((vpd = kmem_zalloc(vpd_size, KM_SLEEP)) == NULL) {
1166 EL(ha, "failed, kmem_zalloc\n");
1167 return (ENOMEM);
1168 }
1169
1170 if (ddi_copyin(bp, vpd, vpd_size, mode) != 0) {
1171 EL(ha, "Buffer copy failed\n");
1172 kmem_free(vpd, vpd_size);
1173 return (EFAULT);
1174 }
1175
1176 /* Sanity check the user supplied data via checksum */
1177 if ((vpdptr = ql_vpd_findtag(ha, vpd, "RV")) == NULL) {
1178 EL(ha, "vpd RV tag missing\n");
1179 kmem_free(vpd, vpd_size);
1180 return (EINVAL);
1181 }
1182
1183 vpdptr += 3;
1184 cnt = 0;
1185 vbuf = vpd;
1186 while (vbuf <= vpdptr) {
1187 cnt += *vbuf++;
1188 }
1287
1288 if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
1289 EL(ha, "unsupported adapter feature\n");
1290 return (EACCES);
1291 }
1292
1293 vpd_size = QL_24XX_VPD_SIZE;
1294
1295 CACHE_LOCK(ha);
1296
1297 if (ha->vcache != NULL) {
1298 /* copy back the vpd cache data */
1299 if (ddi_copyout(ha->vcache, bp, vpd_size, mode) != 0) {
1300 EL(ha, "Buffer copy failed\n");
1301 rval = EFAULT;
1302 }
1303 CACHE_UNLOCK(ha);
1304 return (rval);
1305 }
1306
1307 if ((vpd = kmem_zalloc(vpd_size, KM_SLEEP)) == NULL) {
1308 CACHE_UNLOCK(ha);
1309 EL(ha, "failed, kmem_zalloc\n");
1310 return (ENOMEM);
1311 }
1312
1313 /* Quiesce I/O */
1314 if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
1315 CACHE_UNLOCK(ha);
1316 EL(ha, "ql_stall_driver failed\n");
1317 kmem_free(vpd, vpd_size);
1318 return (EBUSY);
1319 }
1320
1321 rval = ql_lock_nvram(ha, &start_addr, LNF_VPD_DATA);
1322 if (rval != QL_SUCCESS) {
1323 CACHE_UNLOCK(ha);
1324 EL(ha, "failed, ql_lock_nvram=%xh\n", rval);
1325 kmem_free(vpd, vpd_size);
1326 ql_restart_driver(ha);
1327 return (EIO);
1328 }
1329
1330 /* Dump VPD. */
1331 lptr = (uint32_t *)vpd;
1559 * ql local function return status code.
1560 *
1561 * Context:
1562 * Kernel context.
1563 */
1564 int
1565 ql_r_m_w_flash(ql_adapter_state_t *ha, caddr_t dp, uint32_t bc, uint32_t faddr,
1566 int mode)
1567 {
1568 uint8_t *bp;
1569 uint32_t xfer, bsize, saddr, ofst;
1570 int rval = 0;
1571
1572 QL_PRINT_9(CE_CONT, "(%d): started, dp=%ph, faddr=%xh, bc=%xh\n",
1573 ha->instance, (void *)dp, faddr, bc);
1574
1575 bsize = ha->xioctl->fdesc.block_size;
1576 saddr = faddr & ~(bsize - 1);
1577 ofst = faddr & (bsize - 1);
1578
1579 if ((bp = kmem_zalloc(bsize, KM_SLEEP)) == NULL) {
1580 EL(ha, "kmem_zalloc=null\n");
1581 return (QL_MEMORY_ALLOC_FAILED);
1582 }
1583
1584 while (bc) {
1585 xfer = bc > bsize ? bsize : bc;
1586 if (ofst + xfer > bsize) {
1587 xfer = bsize - ofst;
1588 }
1589 QL_PRINT_9(CE_CONT, "(%d): dp=%ph, saddr=%xh, bc=%xh, "
1590 "ofst=%xh, xfer=%xh\n", ha->instance, (void *)dp, saddr,
1591 bc, ofst, xfer);
1592
1593 if (ofst || xfer < bsize) {
1594 /* Dump Flash sector. */
1595 if ((rval = ql_dump_fcode(ha, bp, bsize, saddr)) !=
1596 QL_SUCCESS) {
1597 EL(ha, "dump_flash status=%x\n", rval);
1598 break;
1599 }
1600 }
1601
1602 /* Set new data. */
2018 *
2019 * Input:
2020 * ha: adapter state pointer.
2021 * dop: ql_adm_op_t structure pointer.
2022 * mode: flags.
2023 *
2024 * Returns:
2025 *
2026 * Context:
2027 * Kernel context.
2028 */
2029 static int
2030 ql_adm_prop_update_int(ql_adapter_state_t *ha, ql_adm_op_t *dop, int mode)
2031 {
2032 char *prop_name;
2033 int rval;
2034
2035 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
2036
2037 prop_name = kmem_zalloc(dop->length, KM_SLEEP);
2038 if (prop_name == NULL) {
2039 EL(ha, "failed, kmem_zalloc\n");
2040 return (ENOMEM);
2041 }
2042
2043 if (ddi_copyin((void *)(uintptr_t)dop->buffer, prop_name, dop->length,
2044 mode) != 0) {
2045 EL(ha, "failed, prop_name ddi_copyin\n");
2046 kmem_free(prop_name, dop->length);
2047 return (EFAULT);
2048 }
2049
2050 /*LINTED [Solaris DDI_DEV_T_ANY Lint warning]*/
2051 if ((rval = ddi_prop_update_int(DDI_DEV_T_NONE, ha->dip, prop_name,
2052 (int)dop->option)) != DDI_PROP_SUCCESS) {
2053 EL(ha, "failed, prop_update=%xh\n", rval);
2054 kmem_free(prop_name, dop->length);
2055 return (EINVAL);
2056 }
2057
2058 kmem_free(prop_name, dop->length);
2059
2060 QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
2061
2075 * Returns:
2076 *
2077 * Context:
2078 * Kernel context.
2079 */
2080 static int
2081 ql_adm_fw_dump(ql_adapter_state_t *ha, ql_adm_op_t *dop, void *udop, int mode)
2082 {
2083 caddr_t dmp;
2084
2085 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
2086
2087 if (dop->length < ha->risc_dump_size) {
2088 EL(ha, "failed, incorrect length=%xh, size=%xh\n",
2089 dop->length, ha->risc_dump_size);
2090 return (EINVAL);
2091 }
2092
2093 if (ha->ql_dump_state & QL_DUMP_VALID) {
2094 dmp = kmem_zalloc(ha->risc_dump_size, KM_SLEEP);
2095 if (dmp == NULL) {
2096 EL(ha, "failed, kmem_zalloc\n");
2097 return (ENOMEM);
2098 }
2099
2100 dop->length = (uint32_t)ql_ascii_fw_dump(ha, dmp);
2101 if (ddi_copyout((void *)dmp, (void *)(uintptr_t)dop->buffer,
2102 dop->length, mode) != 0) {
2103 EL(ha, "failed, ddi_copyout\n");
2104 kmem_free(dmp, ha->risc_dump_size);
2105 return (EFAULT);
2106 }
2107
2108 kmem_free(dmp, ha->risc_dump_size);
2109 ha->ql_dump_state |= QL_DUMP_UPLOADED;
2110
2111 } else {
2112 EL(ha, "failed, no dump file\n");
2113 dop->length = 0;
2114 }
2115
2116 if (ddi_copyout(dop, udop, sizeof (ql_adm_op_t), mode) != 0) {
2117 EL(ha, "failed, driver_op_t ddi_copyout\n");
2118 return (EFAULT);
2204 * Performs qladm QL_FLASH_LOAD command
2205 *
2206 * Input:
2207 * ha: adapter state pointer.
2208 * dop: ql_adm_op_t structure pointer.
2209 * mode: flags.
2210 *
2211 * Returns:
2212 *
2213 * Context:
2214 * Kernel context.
2215 */
2216 static int
2217 ql_adm_flash_load(ql_adapter_state_t *ha, ql_adm_op_t *dop, int mode)
2218 {
2219 uint8_t *dp;
2220 int rval;
2221
2222 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
2223
2224 if ((dp = kmem_zalloc(dop->length, KM_SLEEP)) == NULL) {
2225 EL(ha, "failed, kmem_zalloc\n");
2226 return (ENOMEM);
2227 }
2228
2229 if (ddi_copyin((void *)(uintptr_t)dop->buffer, dp, dop->length,
2230 mode) != 0) {
2231 EL(ha, "ddi_copyin failed\n");
2232 kmem_free(dp, dop->length);
2233 return (EFAULT);
2234 }
2235
2236 if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
2237 EL(ha, "ql_stall_driver failed\n");
2238 kmem_free(dp, dop->length);
2239 return (EBUSY);
2240 }
2241
2242 rval = (CFG_IST(ha, CFG_CTRL_24258081) ?
2243 ql_24xx_load_flash(ha, dp, dop->length, dop->option) :
2244 ql_load_flash(ha, dp, dop->length));
2245
2246 ql_restart_driver(ha);
2247
|
487 */
488 static int
489 ql_set_feature_bits(ql_adapter_state_t *ha, uint16_t features)
490 {
491 int rval;
492 uint32_t count;
493 nvram_t *nv;
494 uint16_t *wptr;
495 uint8_t *bptr;
496 uint8_t csum;
497 uint32_t start_addr;
498
499 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
500
501 if (CFG_IST(ha, CFG_CTRL_24258081)) {
502 EL(ha, "Not supported for 24xx\n");
503 return (EINVAL);
504 }
505
506 nv = kmem_zalloc(sizeof (*nv), KM_SLEEP);
507
508 rval = ql_lock_nvram(ha, &start_addr, LNF_NVRAM_DATA);
509 if (rval != QL_SUCCESS) {
510 EL(ha, "failed, ql_lock_nvram=%xh\n", rval);
511 kmem_free(nv, sizeof (*nv));
512 return (EIO);
513 }
514 rval = 0;
515
516 /*
517 * Read off the whole NVRAM
518 */
519 wptr = (uint16_t *)nv;
520 csum = 0;
521 for (count = 0; count < sizeof (nvram_t) / 2; count++) {
522 *wptr = (uint16_t)ql_get_nvram_word(ha, count + start_addr);
523 csum = (uint8_t)(csum + (uint8_t)*wptr);
524 csum = (uint8_t)(csum + (uint8_t)(*wptr >> 8));
525 wptr++;
526 }
590 {
591 int rval;
592 uint32_t count;
593 uint32_t start_addr;
594
595 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
596
597 rval = ql_lock_nvram(ha, &start_addr, LNF_NVRAM_DATA);
598 if (rval != QL_SUCCESS) {
599 EL(ha, "failed, ql_lock_nvram=%xh\n", rval);
600 return (EIO);
601 }
602 rval = 0;
603
604 if (CFG_IST(ha, CFG_CTRL_24258081)) {
605 nvram_24xx_t *nv;
606 uint32_t *longptr;
607 uint32_t csum = 0;
608
609 nv = kmem_zalloc(sizeof (*nv), KM_SLEEP);
610
611 nv->nvram_version[0] = LSB(ICB_24XX_VERSION);
612 nv->nvram_version[1] = MSB(ICB_24XX_VERSION);
613
614 nv->version[0] = 1;
615 nv->max_frame_length[1] = 8;
616 nv->execution_throttle[0] = 16;
617 nv->login_retry_count[0] = 8;
618
619 nv->firmware_options_1[0] = BIT_2 | BIT_1;
620 nv->firmware_options_1[1] = BIT_5;
621 nv->firmware_options_2[0] = BIT_5;
622 nv->firmware_options_2[1] = BIT_4;
623 nv->firmware_options_3[1] = BIT_6;
624
625 /*
626 * Set default host adapter parameters
627 */
628 nv->host_p[0] = BIT_4 | BIT_1;
629 nv->host_p[1] = BIT_3 | BIT_2;
663 rval = ql_24xx_read_flash(ha, count + start_addr,
664 longptr);
665 if (rval != QL_SUCCESS) {
666 EL(ha, "24xx_read_flash failed=%xh\n", rval);
667 break;
668 }
669 csum += *longptr;
670 }
671
672 if (csum) {
673 rval = EINVAL;
674 }
675 kmem_free(nv, sizeof (nvram_24xx_t));
676 } else {
677 nvram_t *nv;
678 uint16_t *wptr;
679 uint8_t *bptr;
680 uint8_t csum;
681
682 nv = kmem_zalloc(sizeof (*nv), KM_SLEEP);
683 /*
684 * Set default initialization control block.
685 */
686 nv->parameter_block_version = ICB_VERSION;
687 nv->firmware_options[0] = BIT_4 | BIT_3 | BIT_2 | BIT_1;
688 nv->firmware_options[1] = BIT_7 | BIT_5 | BIT_2;
689
690 nv->max_frame_length[1] = 4;
691 nv->max_iocb_allocation[1] = 1;
692 nv->execution_throttle[0] = 16;
693 nv->login_retry_count = 8;
694 nv->port_name[0] = 33;
695 nv->port_name[3] = 224;
696 nv->port_name[4] = 139;
697 nv->login_timeout = 4;
698
699 /*
700 * Set default host adapter parameters
701 */
702 nv->host_p[0] = BIT_1;
911 * bp = user buffer address.
912 *
913 * Returns:
914 *
915 * Context:
916 * Kernel context.
917 */
918 int
919 ql_nv_util_load(ql_adapter_state_t *ha, void *bp, int mode)
920 {
921 uint8_t cnt;
922 void *nv;
923 uint16_t *wptr;
924 uint16_t data;
925 uint32_t start_addr, *lptr, data32;
926 nvram_t *nptr;
927 int rval;
928
929 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
930
931 nv = kmem_zalloc(ha->nvram_cache->size, KM_SLEEP);
932
933 if (ddi_copyin(bp, nv, ha->nvram_cache->size, mode) != 0) {
934 EL(ha, "Buffer copy failed\n");
935 kmem_free(nv, ha->nvram_cache->size);
936 return (EFAULT);
937 }
938
939 /* See if the buffer passed to us looks sane */
940 nptr = (nvram_t *)nv;
941 if (nptr->id[0] != 'I' || nptr->id[1] != 'S' || nptr->id[2] != 'P' ||
942 nptr->id[3] != ' ') {
943 EL(ha, "failed, buffer sanity check\n");
944 kmem_free(nv, ha->nvram_cache->size);
945 return (EINVAL);
946 }
947
948 /* Quiesce I/O */
949 if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
950 EL(ha, "ql_stall_driver failed\n");
951 kmem_free(nv, ha->nvram_cache->size);
1130 * Context:
1131 * Kernel context.
1132 */
1133 int
1134 ql_vpd_load(ql_adapter_state_t *ha, void *bp, int mode)
1135 {
1136 uint8_t cnt;
1137 uint8_t *vpd, *vpdptr, *vbuf;
1138 uint32_t start_addr, vpd_size, *lptr, data32;
1139 int rval;
1140
1141 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
1142
1143 if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
1144 EL(ha, "unsupported adapter feature\n");
1145 return (ENOTSUP);
1146 }
1147
1148 vpd_size = QL_24XX_VPD_SIZE;
1149
1150 vpd = kmem_zalloc(vpd_size, KM_SLEEP);
1151
1152 if (ddi_copyin(bp, vpd, vpd_size, mode) != 0) {
1153 EL(ha, "Buffer copy failed\n");
1154 kmem_free(vpd, vpd_size);
1155 return (EFAULT);
1156 }
1157
1158 /* Sanity check the user supplied data via checksum */
1159 if ((vpdptr = ql_vpd_findtag(ha, vpd, "RV")) == NULL) {
1160 EL(ha, "vpd RV tag missing\n");
1161 kmem_free(vpd, vpd_size);
1162 return (EINVAL);
1163 }
1164
1165 vpdptr += 3;
1166 cnt = 0;
1167 vbuf = vpd;
1168 while (vbuf <= vpdptr) {
1169 cnt += *vbuf++;
1170 }
1269
1270 if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
1271 EL(ha, "unsupported adapter feature\n");
1272 return (EACCES);
1273 }
1274
1275 vpd_size = QL_24XX_VPD_SIZE;
1276
1277 CACHE_LOCK(ha);
1278
1279 if (ha->vcache != NULL) {
1280 /* copy back the vpd cache data */
1281 if (ddi_copyout(ha->vcache, bp, vpd_size, mode) != 0) {
1282 EL(ha, "Buffer copy failed\n");
1283 rval = EFAULT;
1284 }
1285 CACHE_UNLOCK(ha);
1286 return (rval);
1287 }
1288
1289 vpd = kmem_zalloc(vpd_size, KM_SLEEP);
1290
1291 /* Quiesce I/O */
1292 if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
1293 CACHE_UNLOCK(ha);
1294 EL(ha, "ql_stall_driver failed\n");
1295 kmem_free(vpd, vpd_size);
1296 return (EBUSY);
1297 }
1298
1299 rval = ql_lock_nvram(ha, &start_addr, LNF_VPD_DATA);
1300 if (rval != QL_SUCCESS) {
1301 CACHE_UNLOCK(ha);
1302 EL(ha, "failed, ql_lock_nvram=%xh\n", rval);
1303 kmem_free(vpd, vpd_size);
1304 ql_restart_driver(ha);
1305 return (EIO);
1306 }
1307
1308 /* Dump VPD. */
1309 lptr = (uint32_t *)vpd;
1537 * ql local function return status code.
1538 *
1539 * Context:
1540 * Kernel context.
1541 */
1542 int
1543 ql_r_m_w_flash(ql_adapter_state_t *ha, caddr_t dp, uint32_t bc, uint32_t faddr,
1544 int mode)
1545 {
1546 uint8_t *bp;
1547 uint32_t xfer, bsize, saddr, ofst;
1548 int rval = 0;
1549
1550 QL_PRINT_9(CE_CONT, "(%d): started, dp=%ph, faddr=%xh, bc=%xh\n",
1551 ha->instance, (void *)dp, faddr, bc);
1552
1553 bsize = ha->xioctl->fdesc.block_size;
1554 saddr = faddr & ~(bsize - 1);
1555 ofst = faddr & (bsize - 1);
1556
1557 bp = kmem_zalloc(bsize, KM_SLEEP);
1558
1559 while (bc) {
1560 xfer = bc > bsize ? bsize : bc;
1561 if (ofst + xfer > bsize) {
1562 xfer = bsize - ofst;
1563 }
1564 QL_PRINT_9(CE_CONT, "(%d): dp=%ph, saddr=%xh, bc=%xh, "
1565 "ofst=%xh, xfer=%xh\n", ha->instance, (void *)dp, saddr,
1566 bc, ofst, xfer);
1567
1568 if (ofst || xfer < bsize) {
1569 /* Dump Flash sector. */
1570 if ((rval = ql_dump_fcode(ha, bp, bsize, saddr)) !=
1571 QL_SUCCESS) {
1572 EL(ha, "dump_flash status=%x\n", rval);
1573 break;
1574 }
1575 }
1576
1577 /* Set new data. */
1993 *
1994 * Input:
1995 * ha: adapter state pointer.
1996 * dop: ql_adm_op_t structure pointer.
1997 * mode: flags.
1998 *
1999 * Returns:
2000 *
2001 * Context:
2002 * Kernel context.
2003 */
2004 static int
2005 ql_adm_prop_update_int(ql_adapter_state_t *ha, ql_adm_op_t *dop, int mode)
2006 {
2007 char *prop_name;
2008 int rval;
2009
2010 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
2011
2012 prop_name = kmem_zalloc(dop->length, KM_SLEEP);
2013
2014 if (ddi_copyin((void *)(uintptr_t)dop->buffer, prop_name, dop->length,
2015 mode) != 0) {
2016 EL(ha, "failed, prop_name ddi_copyin\n");
2017 kmem_free(prop_name, dop->length);
2018 return (EFAULT);
2019 }
2020
2021 /*LINTED [Solaris DDI_DEV_T_ANY Lint warning]*/
2022 if ((rval = ddi_prop_update_int(DDI_DEV_T_NONE, ha->dip, prop_name,
2023 (int)dop->option)) != DDI_PROP_SUCCESS) {
2024 EL(ha, "failed, prop_update=%xh\n", rval);
2025 kmem_free(prop_name, dop->length);
2026 return (EINVAL);
2027 }
2028
2029 kmem_free(prop_name, dop->length);
2030
2031 QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
2032
2046 * Returns:
2047 *
2048 * Context:
2049 * Kernel context.
2050 */
2051 static int
2052 ql_adm_fw_dump(ql_adapter_state_t *ha, ql_adm_op_t *dop, void *udop, int mode)
2053 {
2054 caddr_t dmp;
2055
2056 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
2057
2058 if (dop->length < ha->risc_dump_size) {
2059 EL(ha, "failed, incorrect length=%xh, size=%xh\n",
2060 dop->length, ha->risc_dump_size);
2061 return (EINVAL);
2062 }
2063
2064 if (ha->ql_dump_state & QL_DUMP_VALID) {
2065 dmp = kmem_zalloc(ha->risc_dump_size, KM_SLEEP);
2066
2067 dop->length = (uint32_t)ql_ascii_fw_dump(ha, dmp);
2068 if (ddi_copyout((void *)dmp, (void *)(uintptr_t)dop->buffer,
2069 dop->length, mode) != 0) {
2070 EL(ha, "failed, ddi_copyout\n");
2071 kmem_free(dmp, ha->risc_dump_size);
2072 return (EFAULT);
2073 }
2074
2075 kmem_free(dmp, ha->risc_dump_size);
2076 ha->ql_dump_state |= QL_DUMP_UPLOADED;
2077
2078 } else {
2079 EL(ha, "failed, no dump file\n");
2080 dop->length = 0;
2081 }
2082
2083 if (ddi_copyout(dop, udop, sizeof (ql_adm_op_t), mode) != 0) {
2084 EL(ha, "failed, driver_op_t ddi_copyout\n");
2085 return (EFAULT);
2171 * Performs qladm QL_FLASH_LOAD command
2172 *
2173 * Input:
2174 * ha: adapter state pointer.
2175 * dop: ql_adm_op_t structure pointer.
2176 * mode: flags.
2177 *
2178 * Returns:
2179 *
2180 * Context:
2181 * Kernel context.
2182 */
2183 static int
2184 ql_adm_flash_load(ql_adapter_state_t *ha, ql_adm_op_t *dop, int mode)
2185 {
2186 uint8_t *dp;
2187 int rval;
2188
2189 QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
2190
2191 dp = kmem_zalloc(dop->length, KM_SLEEP);
2192
2193 if (ddi_copyin((void *)(uintptr_t)dop->buffer, dp, dop->length,
2194 mode) != 0) {
2195 EL(ha, "ddi_copyin failed\n");
2196 kmem_free(dp, dop->length);
2197 return (EFAULT);
2198 }
2199
2200 if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
2201 EL(ha, "ql_stall_driver failed\n");
2202 kmem_free(dp, dop->length);
2203 return (EBUSY);
2204 }
2205
2206 rval = (CFG_IST(ha, CFG_CTRL_24258081) ?
2207 ql_24xx_load_flash(ha, dp, dop->length, dop->option) :
2208 ql_load_flash(ha, dp, dop->length));
2209
2210 ql_restart_driver(ha);
2211
|