Lines Matching +full:elm +full:- +full:id
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
123 SES_SETSTATUS_ENC_IDX = -1
133 req->result = result; in ses_terminate_control_requests()
147 ITERATOR_INDEX_INVALID = -1,
220 * This index is appropriate for indexing into enc->ses_elm_map.
393 * of the first type (ITERATOR_INDEX_INVALID == -1). This in ses_iter_reset()
396 iter->type_index = 0; in ses_iter_reset()
397 iter->type_element_index = ITERATOR_INDEX_INVALID; in ses_iter_reset()
398 iter->global_element_index = ITERATOR_INDEX_INVALID; in ses_iter_reset()
399 iter->individual_element_index = ITERATOR_INDEX_INVALID; in ses_iter_reset()
400 iter->saved_individual_element_index = ITERATOR_INDEX_INVALID; in ses_iter_reset()
415 iter->enc = enc; in ses_iter_init()
416 iter->cache = cache; in ses_iter_init()
435 ses_cache = iter->cache->private; in ses_iter_next()
442 if (iter->global_element_index >= (int)iter->cache->nelms - 1) { in ses_iter_next()
444 iter->type_index = ITERATOR_INDEX_END; in ses_iter_next()
445 iter->type_element_index = ITERATOR_INDEX_END; in ses_iter_next()
446 iter->global_element_index = ITERATOR_INDEX_END; in ses_iter_next()
447 iter->individual_element_index = ITERATOR_INDEX_END; in ses_iter_next()
448 iter->saved_individual_element_index = ITERATOR_INDEX_END; in ses_iter_next()
452 KASSERT((iter->type_index < ses_cache->ses_ntypes), in ses_iter_next()
454 iter->type_index, ses_cache->ses_ntypes)); in ses_iter_next()
456 element_type = &ses_cache->ses_types[iter->type_index]; in ses_iter_next()
457 iter->global_element_index++; in ses_iter_next()
458 iter->type_element_index++; in ses_iter_next()
463 * count is non-zero. in ses_iter_next()
465 if (iter->type_element_index > element_type->hdr->etype_maxelt) { in ses_iter_next()
470 iter->type_index++; in ses_iter_next()
471 iter->type_element_index = 0; in ses_iter_next()
472 iter->individual_element_index = ITERATOR_INDEX_INVALID; in ses_iter_next()
475 if (iter->type_element_index > 0) { in ses_iter_next()
476 iter->individual_element_index = in ses_iter_next()
477 ++iter->saved_individual_element_index; in ses_iter_next()
480 return (&iter->cache->elm_map[iter->global_element_index]); in ses_iter_next()
522 cur_index = &iter->global_element_index; in ses_iter_seek_to()
524 cur_index = &iter->individual_element_index; in ses_iter_seek_to()
528 return (&iter->cache->elm_map[iter->global_element_index]); in ses_iter_seek_to()
565 ses_cache = cache->private; in ses_cache_free_elm_addlstatus()
566 if (ses_cache->elm_addlstatus_page == NULL) in ses_cache_free_elm_addlstatus()
569 for (cur_elm = cache->elm_map, in ses_cache_free_elm_addlstatus()
570 last_elm = &cache->elm_map[cache->nelms]; in ses_cache_free_elm_addlstatus()
574 elmpriv = cur_elm->elm_private; in ses_cache_free_elm_addlstatus()
577 bzero(&elmpriv->addl, sizeof(elmpriv->addl)); in ses_cache_free_elm_addlstatus()
580 other_ses_cache = enc_other_cache(enc, cache)->private; in ses_cache_free_elm_addlstatus()
581 if (other_ses_cache->elm_addlstatus_page in ses_cache_free_elm_addlstatus()
582 != ses_cache->elm_addlstatus_page) in ses_cache_free_elm_addlstatus()
583 ENC_FREE(ses_cache->elm_addlstatus_page); in ses_cache_free_elm_addlstatus()
584 ses_cache->elm_addlstatus_page = NULL; in ses_cache_free_elm_addlstatus()
596 ses_cache = cache->private; in ses_cache_free_elm_descs()
597 if (ses_cache->elm_descs_page == NULL) in ses_cache_free_elm_descs()
600 for (cur_elm = cache->elm_map, in ses_cache_free_elm_descs()
601 last_elm = &cache->elm_map[cache->nelms]; in ses_cache_free_elm_descs()
605 elmpriv = cur_elm->elm_private; in ses_cache_free_elm_descs()
606 elmpriv->descr_len = 0; in ses_cache_free_elm_descs()
607 elmpriv->descr = NULL; in ses_cache_free_elm_descs()
610 other_ses_cache = enc_other_cache(enc, cache)->private; in ses_cache_free_elm_descs()
611 if (other_ses_cache->elm_descs_page in ses_cache_free_elm_descs()
612 != ses_cache->elm_descs_page) in ses_cache_free_elm_descs()
613 ENC_FREE(ses_cache->elm_descs_page); in ses_cache_free_elm_descs()
614 ses_cache->elm_descs_page = NULL; in ses_cache_free_elm_descs()
624 ses_cache = cache->private; in ses_cache_free_status()
625 if (ses_cache->status_page == NULL) in ses_cache_free_status()
628 other_ses_cache = enc_other_cache(enc, cache)->private; in ses_cache_free_status()
629 if (other_ses_cache->status_page != ses_cache->status_page) in ses_cache_free_status()
630 ENC_FREE(ses_cache->status_page); in ses_cache_free_status()
631 ses_cache->status_page = NULL; in ses_cache_free_status()
641 if (cache->elm_map == NULL) in ses_cache_free_elm_map()
646 for (cur_elm = cache->elm_map, in ses_cache_free_elm_map()
647 last_elm = &cache->elm_map[cache->nelms]; in ses_cache_free_elm_map()
649 ENC_FREE_AND_NULL(cur_elm->elm_private); in ses_cache_free_elm_map()
651 ENC_FREE_AND_NULL(cache->elm_map); in ses_cache_free_elm_map()
652 cache->nelms = 0; in ses_cache_free_elm_map()
667 ses_cache = cache->private; in ses_cache_free()
668 ses_cache->ses_ntypes = 0; in ses_cache_free()
670 other_ses_cache = enc_other_cache(enc, cache)->private; in ses_cache_free()
671 if (other_ses_cache->subencs != ses_cache->subencs) in ses_cache_free()
672 ENC_FREE(ses_cache->subencs); in ses_cache_free()
673 ses_cache->subencs = NULL; in ses_cache_free()
675 if (other_ses_cache->ses_types != ses_cache->ses_types) in ses_cache_free()
676 ENC_FREE(ses_cache->ses_types); in ses_cache_free()
677 ses_cache->ses_types = NULL; in ses_cache_free()
679 if (other_ses_cache->cfg_page != ses_cache->cfg_page) in ses_cache_free()
680 ENC_FREE(ses_cache->cfg_page); in ses_cache_free()
681 ses_cache->cfg_page = NULL; in ses_cache_free()
696 src_ses_cache = src->private; in ses_cache_clone()
697 dst_ses_cache = dst->private; in ses_cache_clone()
710 dst->private = dst_ses_cache; in ses_cache_clone()
716 dst->elm_map = malloc(dst->nelms * sizeof(enc_element_t), in ses_cache_clone()
718 memcpy(dst->elm_map, src->elm_map, dst->nelms * sizeof(enc_element_t)); in ses_cache_clone()
719 for (dst_elm = dst->elm_map, src_elm = src->elm_map, in ses_cache_clone()
720 last_elm = &src->elm_map[src->nelms]; in ses_cache_clone()
722 dst_elm->elm_private = malloc(sizeof(ses_element_t), in ses_cache_clone()
724 memcpy(dst_elm->elm_private, src_elm->elm_private, in ses_cache_clone()
734 return ((obj)->base_hdr.byte1 >> 6); in ses_elm_sas_descr_type()
739 return ((hdr)->byte0 & 0xf); in ses_elm_addlstatus_proto()
744 return ((hdr)->byte0 >> 4 & 0x1); in ses_elm_addlstatus_eip()
749 return ((hdr)->byte0 >> 7); in ses_elm_addlstatus_invalid()
754 return ((hdr)->type0_noneip.byte1 & 0x1); in ses_elm_sas_type0_not_all_phys()
759 return ((phy)->target_ports & 0x1); in ses_elm_sas_dev_phy_sata_dev()
764 return ((phy)->target_ports >> 7); in ses_elm_sas_dev_phy_sata_port()
769 return (((phy)->byte0 >> 4) & 0x7); in ses_elm_sas_dev_phy_dev_type()
781 * \return non-zero if true, 0 if false.
789 if (ses_cache->cfg_page == NULL) in ses_config_cache_valid()
792 cache_gc = scsi_4btoul(ses_cache->cfg_page->hdr.gen_code); in ses_config_cache_valid()
804 * \brief Iterate over and create vpd device id records from the
805 * additional element status data for elm, passing that data
808 * \param enc SES instance containing elm
809 * \param elm Element for which to extract device ID data.
811 * device id descriptor for elm.
815 ses_devids_iter(enc_softc_t *enc, enc_element_t *elm, in ses_devids_iter() argument
823 elmpriv = elm->elm_private; in ses_devids_iter()
824 addl = &(elmpriv->addl); in ses_devids_iter()
828 for (i = 0; i < addl->proto_hdr.sas->base_hdr.num_phys; i++) { in ses_devids_iter()
834 phy_addr = addl->proto_data.sasdev_phys[i].phy_addr; in ses_devids_iter()
835 devid->proto_codeset = (SCSI_PROTO_SAS << SVPD_ID_PROTO_SHIFT) in ses_devids_iter()
837 devid->id_type = SVPD_ID_PIV in ses_devids_iter()
840 devid->reserved = 0; in ses_devids_iter()
841 devid->length = sizeof(struct scsi_vpd_id_naa_ieee_reg); in ses_devids_iter()
842 memcpy(devid->identifier, phy_addr, devid->length); in ses_devids_iter()
844 callback(enc, elm, devid, callback_arg); in ses_devids_iter()
867 * \param enc SES instance containing elm
868 * \param elm Element on which device ID matching is active.
869 * \param periph A device ID corresponding to elm.
888 device_pattern->flags = DEV_MATCH_DEVID; in ses_path_iter_devid_callback()
889 device_pattern->data.devid_pat.id_len = in ses_path_iter_devid_callback()
891 + devid->length; in ses_path_iter_devid_callback()
892 memcpy(device_pattern->data.devid_pat.id, devid, in ses_path_iter_devid_callback()
893 device_pattern->data.devid_pat.id_len); in ses_path_iter_devid_callback()
895 device_pattern->flags |= DEV_MATCH_PATH; in ses_path_iter_devid_callback()
896 device_pattern->path_id = xpt_path_path_id(enc->periph->path); in ses_path_iter_devid_callback()
924 device_match->path_id, in ses_path_iter_devid_callback()
925 device_match->target_id, in ses_path_iter_devid_callback()
926 device_match->target_lun) == CAM_REQ_CMP) { in ses_path_iter_devid_callback()
927 args->callback(enc, elem, path, args->callback_arg); in ses_path_iter_devid_callback()
940 * \param enc SES instance containing elm
941 * \param elm Element for which to perform periph object matching.
947 ses_paths_iter(enc_softc_t *enc, enc_element_t *elm, in ses_paths_iter() argument
953 elmpriv = elm->elm_private; in ses_paths_iter()
954 addl = &(elmpriv->addl); in ses_paths_iter()
956 if (addl->hdr == NULL) in ses_paths_iter()
959 switch(ses_elm_addlstatus_proto(addl->hdr)) { in ses_paths_iter()
961 if (addl->proto_hdr.sas != NULL && in ses_paths_iter()
962 addl->proto_data.sasdev_phys != NULL) { in ses_paths_iter()
967 ses_devids_iter(enc, elm, ses_path_iter_devid_callback, in ses_paths_iter()
972 if (addl->proto_hdr.ata != NULL) { in ses_paths_iter()
977 scsi_4btoul(addl->proto_hdr.ata->bus), in ses_paths_iter()
978 scsi_4btoul(addl->proto_hdr.ata->target), 0) in ses_paths_iter()
987 callback(enc, elm, path, callback_arg); in ses_paths_iter()
1000 * \param enc SES instance containing elm
1001 * \param elm Element on which periph matching is active.
1002 * \param periph A periph instance that matches elm.
1028 * \param enc SES instance containing elm
1029 * \param elm Element on which periph matching is active.
1030 * \param periph A periph instance that matches elm.
1034 ses_setphyspath_callback(enc_softc_t *enc, enc_element_t *elm, in ses_setphyspath_callback() argument
1055 if (strcmp(old_physpath, sbuf_data(args->physpath)) != 0) { in ses_setphyspath_callback()
1060 cdai.bufsiz = sbuf_len(args->physpath); in ses_setphyspath_callback()
1061 cdai.buf = sbuf_data(args->physpath); in ses_setphyspath_callback()
1066 args->num_set++; in ses_setphyspath_callback()
1075 * \param enc SES instance containing elm
1076 * \param elm Element to publish physical path string for
1077 * \param iter Iterator whose state corresponds to elm
1082 ses_set_physpath(enc_softc_t *enc, enc_element_t *elm, in ses_set_physpath() argument
1097 elmpriv = elm->elm_private; in ses_set_physpath()
1098 if (elmpriv->addl.hdr == NULL) in ses_set_physpath()
1103 * the device ID of the enclosure itself. in ses_set_physpath()
1106 xpt_setup_ccb(&cdai.ccb_h, enc->periph->path, CAM_PRIORITY_NORMAL); in ses_set_physpath()
1112 cam_periph_lock(enc->periph); in ses_set_physpath()
1116 cam_periph_unlock(enc->periph); in ses_set_physpath()
1131 scsi_8btou64(idd->identifier), iter->type_index, in ses_set_physpath()
1132 iter->type_element_index); in ses_set_physpath()
1134 if (elmpriv->descr != NULL && elmpriv->descr_len > 0) { in ses_set_physpath()
1136 for (i = 0, c = elmpriv->descr; i < elmpriv->descr_len; in ses_set_physpath()
1147 * Set this physical path on any CAM devices with a device ID in ses_set_physpath()
1153 ses_paths_iter(enc, elm, ses_setphyspath_callback, &args); in ses_set_physpath()
1175 /* Ref: SPC-4 r25 Section 6.20 Table 223 */ in ses_page_cdb()
1210 periph = enc->periph; in ses_set_timed_completion()
1211 ses = enc->enc_private; in ses_set_timed_completion()
1219 scsi_mode_sense(&ccb->csio, /*retries*/4, NULL, MSG_SIMPLE_Q_TAG, in ses_set_timed_completion()
1229 if (ccb->ccb_h.status != CAM_REQ_CMP) { in ses_set_timed_completion()
1236 if ((mgmt->byte5 & SES_MGMT_TIMED_COMP_EN) == tc_en) in ses_set_timed_completion()
1241 mgmt->byte5 |= SES_MGMT_TIMED_COMP_EN; in ses_set_timed_completion()
1243 mgmt->byte5 &= ~SES_MGMT_TIMED_COMP_EN; in ses_set_timed_completion()
1245 bzero(&mgmt->max_comp_time, sizeof(mgmt->max_comp_time)); in ses_set_timed_completion()
1247 scsi_mode_select(&ccb->csio, 5, NULL, MSG_SIMPLE_Q_TAG, in ses_set_timed_completion()
1252 if (ccb->ccb_h.status != CAM_REQ_CMP) { in ses_set_timed_completion()
1258 if ((mgmt->byte5 & SES_MGMT_TIMED_COMP_EN) != 0) { in ses_set_timed_completion()
1260 ses->ses_flags |= SES_FLAG_TIMEDCOMP; in ses_set_timed_completion()
1263 ses->ses_flags &= ~SES_FLAG_TIMEDCOMP; in ses_set_timed_completion()
1269 return (ses->ses_flags & SES_FLAG_TIMEDCOMP); in ses_set_timed_completion()
1289 CAM_DEBUG(enc->periph->path, CAM_DEBUG_SUBTRACE, in ses_process_pages()
1291 ses = enc->enc_private; in ses_process_pages()
1292 err = -1; in ses_process_pages()
1304 length = scsi_2btoul(page->length); in ses_process_pages()
1314 if (page->params[i] == SesElementDescriptor) in ses_process_pages()
1315 ses->ses_flags |= SES_FLAG_DESC; in ses_process_pages()
1316 else if (page->params[i] == SesAddlElementStatus) in ses_process_pages()
1317 ses->ses_flags |= SES_FLAG_ADDLSTATUS; in ses_process_pages()
1359 CAM_DEBUG(enc->periph->path, CAM_DEBUG_SUBTRACE, in ses_process_config()
1361 enc_cache = &enc->enc_daemon_cache; in ses_process_config()
1362 ses_cache = enc_cache->private; in ses_process_config()
1364 err = -1; in ses_process_config()
1370 if (xfer_len < sizeof(cfg_page->hdr)) { in ses_process_config()
1377 length = ses_page_length(&cfg_page->hdr); in ses_process_config()
1382 last_valid_byte = &buf[length - 1]; in ses_process_config()
1388 if (ses_config_cache_valid(ses_cache, cfg_page->hdr.gen_code)) { in ses_process_config()
1396 scsi_4btoul(cfg_page->hdr.gen_code), in ses_process_config()
1400 ses_cache->cfg_page = cfg_page; in ses_process_config()
1410 * Sub-enclosure data is const after construction (i.e. when in ses_process_config()
1416 ses_cache->ses_nsubencs = ses_cfg_page_get_num_subenc(cfg_page); in ses_process_config()
1417 ses_cache->subencs = subencs; in ses_process_config()
1419 buf_subenc = cfg_page->subencs; in ses_process_config()
1421 last_subenc = &subencs[ses_cache->ses_nsubencs - 1]; in ses_process_config()
1426 "Descriptors\n", cur_subenc - subencs); in ses_process_config()
1431 ENC_VLOG(enc, " SubEnclosure ID %d, %d Types With this ID, " in ses_process_config()
1432 "Descriptor Length %d, offset %d\n", buf_subenc->subenc_id, in ses_process_config()
1433 buf_subenc->num_types, buf_subenc->length, in ses_process_config()
1434 &buf_subenc->byte0 - buf); in ses_process_config()
1436 (uintmax_t)scsi_8btou64(buf_subenc->logical_id)); in ses_process_config()
1438 ntype += buf_subenc->num_types; in ses_process_config()
1451 ses_cache->ses_ntypes = ntype; in ses_process_config()
1452 ses_cache->ses_types = ses_types; in ses_process_config()
1455 (&(*last_subenc)->length + (*last_subenc)->length + 1); in ses_process_config()
1456 last_buf_type = cur_buf_type + ntype - 1; in ses_process_config()
1461 if (&cur_buf_type->etype_txt_len > last_valid_byte) { in ses_process_config()
1463 sestype - ses_types); in ses_process_config()
1467 sestype->hdr = cur_buf_type; in ses_process_config()
1468 sestype->text = type_text; in ses_process_config()
1469 type_text += cur_buf_type->etype_txt_len; in ses_process_config()
1471 "%d, Text Length %d: %.*s\n", sestype - ses_types, in ses_process_config()
1472 sestype->hdr->etype_elm_type, sestype->hdr->etype_maxelt, in ses_process_config()
1473 sestype->hdr->etype_subenc, sestype->hdr->etype_txt_len, in ses_process_config()
1474 sestype->hdr->etype_txt_len, sestype->text); in ses_process_config()
1476 nelm += sestype->hdr->etype_maxelt in ses_process_config()
1483 enc_cache->elm_map = malloc(nelm * sizeof(enc_element_t), in ses_process_config()
1485 enc_cache->nelms = nelm; in ses_process_config()
1494 thdr = ses_cache->ses_types[iter.type_index].hdr; in ses_process_config()
1495 element->elm_idx = iter.global_element_index; in ses_process_config()
1496 element->elm_type = thdr->etype_elm_type; in ses_process_config()
1497 element->subenclosure = thdr->etype_subenc; in ses_process_config()
1498 element->type_elm_idx = iter.type_element_index; in ses_process_config()
1499 element->elm_private = malloc(sizeof(ses_element_t), in ses_process_config()
1504 thdr->etype_subenc, thdr->etype_elm_type); in ses_process_config()
1539 int err = -1; in ses_process_status()
1545 ses = enc->enc_private; in ses_process_status()
1546 enc_cache = &enc->enc_daemon_cache; in ses_process_status()
1547 ses_cache = enc_cache->private; in ses_process_status()
1552 length = ses_page_length(&page->hdr); in ses_process_status()
1571 if (length >= 4 && page->hdr.page_code == SesShortStatus) { in ses_process_status()
1573 ses->ses_flags &= ~(SES_FLAG_ADDLSTATUS | SES_FLAG_DESC); in ses_process_status()
1575 enc_cache->enc_status = page->hdr.page_specific_flags; in ses_process_status()
1582 if (length < (sizeof(*page) + sizeof(*page->elements))) { in ses_process_status()
1587 if (!ses_config_cache_valid(ses_cache, page->hdr.gen_code)) { in ses_process_status()
1595 ses_cache->status_page = page; in ses_process_status()
1598 enc_cache->enc_status = page->hdr.page_specific_flags; in ses_process_status()
1606 cur_stat = page->elements; in ses_process_status()
1608 &buf[length - sizeof(*last_stat)]; in ses_process_status()
1615 iter.type_element_index, (uint8_t *)cur_stat - buf, in ses_process_status()
1616 scsi_4btoul(cur_stat->bytes)); in ses_process_status()
1618 memcpy(&element->encstat, cur_stat, sizeof(element->encstat)); in ses_process_status()
1619 element->svalid = 1; in ses_process_status()
1679 enc_cache = &enc->enc_daemon_cache; in ses_typehasaddlstatus()
1680 ses_cache = enc_cache->private; in ses_typehasaddlstatus()
1681 switch(ses_cache->ses_types[typidx].hdr->etype_elm_type) { in ses_typehasaddlstatus()
1730 enc_cache = &enc->enc_daemon_cache; in ses_process_elm_addlstatus()
1731 ses_cache = enc_cache->private; in ses_process_elm_addlstatus()
1733 err = -1; in ses_process_elm_addlstatus()
1740 ses_cache->elm_addlstatus_page = in ses_process_elm_addlstatus()
1750 hdr = &ses_cache->elm_addlstatus_page->hdr; in ses_process_elm_addlstatus()
1763 if (!ses_config_cache_valid(ses_cache, hdr->gen_code)) { in ses_process_elm_addlstatus()
1797 if (SES_ADDL_EIP_EIIOE_EI_GLOB(eip_hdr->byte2)) { in ses_process_elm_addlstatus()
1804 if (eip_hdr->element_index < expected_index) { in ses_process_elm_addlstatus()
1808 eip_hdr->byte2) ? "global " : "", in ses_process_elm_addlstatus()
1809 eip_hdr->element_index, expected_index); in ses_process_elm_addlstatus()
1814 eip_hdr->element_index, index_type); in ses_process_elm_addlstatus()
1818 SES_ADDL_EIP_EIIOE_EI_GLOB(eip_hdr->byte2) ? in ses_process_elm_addlstatus()
1819 "global " : "", eip_hdr->element_index); in ses_process_elm_addlstatus()
1827 SES_ADDL_EIP_EIIOE_EI_GLOB(eip_hdr->byte2) ? in ses_process_elm_addlstatus()
1828 "global " : "", eip_hdr->element_index); in ses_process_elm_addlstatus()
1843 if (SES_ADDL_EIP_EIIOE_EI_GLOB(eip_hdr->byte2)) in ses_process_elm_addlstatus()
1853 eip_hdr->byte2) ? "global " : "", in ses_process_elm_addlstatus()
1857 elmpriv = element->elm_private; in ses_process_elm_addlstatus()
1862 iter.type_element_index, offset, elm_hdr->byte0, in ses_process_elm_addlstatus()
1863 elm_hdr->length); in ses_process_elm_addlstatus()
1869 if ((offset + elm_hdr->length) > length) { in ses_process_elm_addlstatus()
1878 offset += elm_hdr->length; in ses_process_elm_addlstatus()
1881 elmpriv->addl.hdr = elm_hdr; in ses_process_elm_addlstatus()
1885 proto_info_len = elm_hdr->length in ses_process_elm_addlstatus()
1886 - (eip * SES_EIP_HDR_EXTRA_LEN); in ses_process_elm_addlstatus()
1888 /* Errors in this block are ignored as they are non-fatal */ in ses_process_elm_addlstatus()
1891 if (elm_hdr->length == 0) in ses_process_elm_addlstatus()
1897 if (elm_hdr->length <= 2) in ses_process_elm_addlstatus()
1936 ses = enc->enc_private; in ses_process_control_request()
1942 ses_terminate_control_requests(&ses->ses_pending_requests, error); in ses_process_control_request()
1955 enc_cache = &enc->enc_daemon_cache; in ses_publish_physpaths()
1977 sx_xlock(&enc->enc_cache_lock); in ses_publish_cache()
1978 ses_cache_clone(enc, /*src*/&enc->enc_daemon_cache, in ses_publish_cache()
1979 /*dst*/&enc->enc_cache); in ses_publish_cache()
1980 sx_xunlock(&enc->enc_cache_lock); in ses_publish_cache()
2040 ses = enc->enc_private; in ses_process_elm_descs()
2041 enc_cache = &enc->enc_daemon_cache; in ses_process_elm_descs()
2042 ses_cache = enc_cache->private; in ses_process_elm_descs()
2044 err = -1; in ses_process_elm_descs()
2051 ses_cache->elm_descs_page = (struct ses_elem_descr_page *)buf; in ses_process_elm_descs()
2054 phdr = &ses_cache->elm_descs_page->hdr; in ses_process_elm_descs()
2065 if (!ses_config_cache_valid(ses_cache, phdr->gen_code)) { in ses_process_elm_descs()
2083 length = scsi_2btoul(hdr->length); in ses_process_elm_descs()
2095 elmpriv = element->elm_private; in ses_process_elm_descs()
2096 elmpriv->descr_len = length; in ses_process_elm_descs()
2097 elmpriv->descr = ses_sanitize_elm_desc(&buf[offset], in ses_process_elm_descs()
2098 &elmpriv->descr_len); in ses_process_elm_descs()
2108 if (ses->ses_flags & SES_FLAG_ADDLSTATUS) in ses_process_elm_descs()
2120 if (enc->enc_type == ENC_SEMB_SES) { in ses_fill_rcv_diag_io()
2121 semb_receive_diagnostic_results(&ccb->ataio, /*retries*/5, in ses_fill_rcv_diag_io()
2123 state->page_code, buf, state->buf_size, in ses_fill_rcv_diag_io()
2124 state->timeout); in ses_fill_rcv_diag_io()
2126 scsi_receive_diagnostic_results(&ccb->csio, /*retries*/5, in ses_fill_rcv_diag_io()
2128 state->page_code, buf, state->buf_size, in ses_fill_rcv_diag_io()
2129 SSD_FULL_SIZE, state->timeout); in ses_fill_rcv_diag_io()
2155 ses_iter_init(enc, &enc->enc_cache, &iter); in ses_encode()
2157 if (req->elm_idx == -1) { in ses_encode()
2161 hdr->control_flags = in ses_encode()
2162 req->elm_stat.comstatus & SES_SET_STATUS_MASK; in ses_encode()
2163 ENC_DLOG(enc, "Set EncStat %x\n", hdr->control_flags); in ses_encode()
2167 element = ses_iter_seek_to(&iter, req->elm_idx, SES_ELEM_INDEX_GLOBAL); in ses_encode()
2183 memcpy(&buf[offset], &req->elm_stat, sizeof(struct ses_comstat)); in ses_encode()
2187 req->elm_stat.comstatus, req->elm_stat.comstat[0], in ses_encode()
2188 req->elm_stat.comstat[1], req->elm_stat.comstat[2]); in ses_encode()
2205 ses = enc->enc_private; in ses_fill_control_request()
2206 enc_cache = &enc->enc_daemon_cache; in ses_fill_control_request()
2207 ses_cache = enc_cache->private; in ses_fill_control_request()
2210 if (ses_cache->status_page == NULL) { in ses_fill_control_request()
2211 ses_terminate_control_requests(&ses->ses_requests, EIO); in ses_fill_control_request()
2215 plength = ses_page_length(&ses_cache->status_page->hdr); in ses_fill_control_request()
2216 memcpy(buf, ses_cache->status_page, plength); in ses_fill_control_request()
2226 hdr->control_flags &= ~SES_ENCSTAT_INVOP; in ses_fill_control_request()
2229 while ((req = TAILQ_FIRST(&ses->ses_requests)) != NULL) { in ses_fill_control_request()
2230 TAILQ_REMOVE(&ses->ses_requests, req, links); in ses_fill_control_request()
2231 req->result = ses_encode(enc, buf, plength, req); in ses_fill_control_request()
2232 if (req->result != 0) { in ses_fill_control_request()
2236 TAILQ_INSERT_TAIL(&ses->ses_pending_requests, req, links); in ses_fill_control_request()
2239 if (TAILQ_EMPTY(&ses->ses_pending_requests) != 0) in ses_fill_control_request()
2243 if (enc->enc_type == ENC_SEMB_SES) { in ses_fill_control_request()
2244 semb_send_diagnostic(&ccb->ataio, /*retries*/5, NULL, in ses_fill_control_request()
2246 buf, ses_page_length(&ses_cache->status_page->hdr), in ses_fill_control_request()
2247 state->timeout); in ses_fill_control_request()
2249 scsi_send_diagnostic(&ccb->csio, /*retries*/5, NULL, in ses_fill_control_request()
2253 buf, ses_page_length(&ses_cache->status_page->hdr), in ses_fill_control_request()
2254 SSD_FULL_SIZE, state->timeout); in ses_fill_control_request()
2297 elmpriv = obj->elm_private; in ses_print_addl_data_sas_type0()
2298 addl = &(elmpriv->addl); in ses_print_addl_data_sas_type0()
2300 addl->proto_hdr.sas->base_hdr.num_phys, in ses_print_addl_data_sas_type0()
2301 ses_elm_sas_type0_not_all_phys(addl->proto_hdr.sas) ? "+" : ""); in ses_print_addl_data_sas_type0()
2302 if (ses_elm_addlstatus_eip(addl->hdr)) in ses_print_addl_data_sas_type0()
2304 addl->proto_hdr.sas->type0_eip.dev_slot_num); in ses_print_addl_data_sas_type0()
2306 if (addl->proto_data.sasdev_phys == NULL) in ses_print_addl_data_sas_type0()
2308 for (i = 0;i < addl->proto_hdr.sas->base_hdr.num_phys;i++) { in ses_print_addl_data_sas_type0()
2309 phy = &addl->proto_data.sasdev_phys[i]; in ses_print_addl_data_sas_type0()
2316 ses_elm_sas_dev_phy_dev_type(phy), phy->phy_id); in ses_print_addl_data_sas_type0()
2317 SES_PRINT_PORTS(phy->initiator_ports, "Initiator"); in ses_print_addl_data_sas_type0()
2318 SES_PRINT_PORTS(phy->target_ports, "Target"); in ses_print_addl_data_sas_type0()
2323 (uintmax_t)scsi_8btou64(phy->parent_addr), in ses_print_addl_data_sas_type0()
2324 (uintmax_t)scsi_8btou64(phy->phy_addr)); in ses_print_addl_data_sas_type0()
2347 elmpriv = obj->elm_private; in ses_print_addl_data_sas_type1()
2348 addl = &(elmpriv->addl); in ses_print_addl_data_sas_type1()
2350 if (obj->elm_type == ELMTYP_SAS_EXP) { in ses_print_addl_data_sas_type1()
2351 num_phys = addl->proto_hdr.sas->base_hdr.num_phys; in ses_print_addl_data_sas_type1()
2353 if (addl->proto_data.sasexp_phys == NULL) in ses_print_addl_data_sas_type1()
2356 exp_phy = &addl->proto_data.sasexp_phys[i]; in ses_print_addl_data_sas_type1()
2358 sesname, i, exp_phy->connector_index, in ses_print_addl_data_sas_type1()
2359 exp_phy->other_index); in ses_print_addl_data_sas_type1()
2362 num_phys = addl->proto_hdr.sas->base_hdr.num_phys; in ses_print_addl_data_sas_type1()
2364 if (addl->proto_data.sasport_phys == NULL) in ses_print_addl_data_sas_type1()
2367 port_phy = &addl->proto_data.sasport_phys[i]; in ses_print_addl_data_sas_type1()
2369 "%s: phy %d: id %d connector %d other %d\n", in ses_print_addl_data_sas_type1()
2370 sesname, i, port_phy->phy_id, in ses_print_addl_data_sas_type1()
2371 port_phy->connector_index, port_phy->other_index); in ses_print_addl_data_sas_type1()
2373 (uintmax_t)scsi_8btou64(port_phy->phy_addr)); in ses_print_addl_data_sas_type1()
2388 ses_element_t *elmpriv = obj->elm_private; in ses_print_addl_data_ata()
2389 struct ses_addl_status *addl = &elmpriv->addl; in ses_print_addl_data_ata()
2390 struct ses_elm_ata_hdr *ata = addl->proto_hdr.ata; in ses_print_addl_data_ata()
2393 scsi_4btoul(ata->bus), scsi_4btoul(ata->target)); in ses_print_addl_data_ata()
2409 elmpriv = obj->elm_private; in ses_print_addl_data()
2413 addl = &(elmpriv->addl); in ses_print_addl_data()
2414 if (addl->hdr == NULL) in ses_print_addl_data()
2424 sbuf_printf(&sesname, "%s%d", enc->periph->periph_name, in ses_print_addl_data()
2425 enc->periph->unit_number); in ses_print_addl_data()
2428 if (elmpriv->descr != NULL) in ses_print_addl_data()
2429 sbuf_printf(&out, "'%s'", elmpriv->descr); in ses_print_addl_data()
2431 if (obj->elm_type <= ELMTYP_LAST) in ses_print_addl_data()
2432 sbuf_cat(&out, elm_type_names[obj->elm_type]); in ses_print_addl_data()
2434 sbuf_printf(&out, "<Type 0x%02x>", obj->elm_type); in ses_print_addl_data()
2435 sbuf_printf(&out, " %d", obj->type_elm_idx); in ses_print_addl_data()
2436 if (obj->subenclosure != 0) in ses_print_addl_data()
2437 sbuf_printf(&out, " of subenc %d", obj->subenclosure); in ses_print_addl_data()
2439 switch(ses_elm_addlstatus_proto(addl->hdr)) { in ses_print_addl_data()
2443 if (addl->proto_hdr.sas == NULL) in ses_print_addl_data()
2445 switch(ses_elm_sas_descr_type(addl->proto_hdr.sas)) { in ses_print_addl_data()
2459 if (addl->proto_hdr.ata == NULL) in ses_print_addl_data()
2499 obj = &(enc_cache->elm_map[nobj]); in ses_get_elm_addlstatus_sas_type0()
2500 elmpriv = obj->elm_private; in ses_get_elm_addlstatus_sas_type0()
2501 addl = &(elmpriv->addl); in ses_get_elm_addlstatus_sas_type0()
2503 addl->proto_hdr.sas = (union ses_elm_sas_hdr *)&buf[offset]; in ses_get_elm_addlstatus_sas_type0()
2506 bzero(&addl->proto_data, sizeof(addl->proto_data)); in ses_get_elm_addlstatus_sas_type0()
2507 if (addl->proto_hdr.sas->base_hdr.num_phys == 0) in ses_get_elm_addlstatus_sas_type0()
2517 physz = addl->proto_hdr.sas->base_hdr.num_phys; in ses_get_elm_addlstatus_sas_type0()
2519 if (physz > (bufsiz - offset + 4)) { in ses_get_elm_addlstatus_sas_type0()
2527 addl->proto_data.sasdev_phys = in ses_get_elm_addlstatus_sas_type0()
2558 obj = &(enc_cache->elm_map[nobj]); in ses_get_elm_addlstatus_sas_type1()
2559 elmpriv = obj->elm_private; in ses_get_elm_addlstatus_sas_type1()
2560 addl = &(elmpriv->addl); in ses_get_elm_addlstatus_sas_type1()
2562 addl->proto_hdr.sas = (union ses_elm_sas_hdr *)&buf[offset]; in ses_get_elm_addlstatus_sas_type1()
2565 bzero(&addl->proto_data, sizeof(addl->proto_data)); in ses_get_elm_addlstatus_sas_type1()
2566 if (addl->proto_hdr.sas->base_hdr.num_phys == 0) in ses_get_elm_addlstatus_sas_type1()
2570 if (obj->elm_type == ELMTYP_SAS_EXP) { in ses_get_elm_addlstatus_sas_type1()
2572 physz = addl->proto_hdr.sas->base_hdr.num_phys * in ses_get_elm_addlstatus_sas_type1()
2574 if (physz > (bufsiz - offset)) { in ses_get_elm_addlstatus_sas_type1()
2580 addl->proto_data.sasexp_phys = in ses_get_elm_addlstatus_sas_type1()
2584 physz = addl->proto_hdr.sas->base_hdr.num_phys * in ses_get_elm_addlstatus_sas_type1()
2586 if (physz > (bufsiz - offset + 4)) { in ses_get_elm_addlstatus_sas_type1()
2592 addl->proto_data.sasport_phys = in ses_get_elm_addlstatus_sas_type1()
2628 ses_cache = enc_cache->private; in ses_get_elm_addlstatus_sas()
2634 switch(ses_cache->ses_types[tidx].hdr->etype_elm_type) { in ses_get_elm_addlstatus_sas()
2641 ses_cache->ses_types[tidx].hdr->etype_elm_type); in ses_get_elm_addlstatus_sas()
2650 switch(ses_cache->ses_types[tidx].hdr->etype_elm_type) { in ses_get_elm_addlstatus_sas()
2659 ses_cache->ses_types[tidx].hdr->etype_elm_type); in ses_get_elm_addlstatus_sas()
2669 ses_cache->ses_types[tidx].hdr->etype_elm_type, dtype); in ses_get_elm_addlstatus_sas()
2704 ses_cache = enc_cache->private; in ses_get_elm_addlstatus_ata()
2705 switch(ses_cache->ses_types[tidx].hdr->etype_elm_type) { in ses_get_elm_addlstatus_ata()
2712 ses_cache->ses_types[tidx].hdr->etype_elm_type); in ses_get_elm_addlstatus_ata()
2717 ((ses_element_t *)enc_cache->elm_map[nobj].elm_private) in ses_get_elm_addlstatus_ata()
2718 ->addl.proto_hdr.ata = (struct ses_elm_ata_hdr *)buf; in ses_get_elm_addlstatus_ata()
2730 ses = enc->enc_private; in ses_softc_invalidate()
2731 ses_terminate_control_requests(&ses->ses_requests, ENXIO); in ses_softc_invalidate()
2738 ses_cache_free(enc, &enc->enc_cache); in ses_softc_cleanup()
2739 ses_cache_free(enc, &enc->enc_daemon_cache); in ses_softc_cleanup()
2740 ENC_FREE_AND_NULL(enc->enc_private); in ses_softc_cleanup()
2741 ENC_FREE_AND_NULL(enc->enc_cache.private); in ses_softc_cleanup()
2742 ENC_FREE_AND_NULL(enc->enc_daemon_cache.private); in ses_softc_cleanup()
2757 ses = enc->enc_private; in ses_set_enc_status()
2761 TAILQ_INSERT_TAIL(&ses->ses_requests, &req, links); in ses_set_enc_status()
2763 cam_periph_sleep(enc->periph, &req, PUSER, "encstat", 0); in ses_set_enc_status()
2771 unsigned int i = elms->elm_idx; in ses_get_elm_status()
2773 memcpy(elms->cstat, &enc->enc_cache.elm_map[i].encstat, 4); in ses_get_elm_status()
2784 if ((elms->cstat[0] & SESCTL_CSEL) == 0) in ses_set_elm_status()
2787 ses = enc->enc_private; in ses_set_elm_status()
2788 req.elm_idx = elms->elm_idx; in ses_set_elm_status()
2789 memcpy(&req.elm_stat, elms->cstat, sizeof(req.elm_stat)); in ses_set_elm_status()
2791 TAILQ_INSERT_TAIL(&ses->ses_requests, &req, links); in ses_set_elm_status()
2793 cam_periph_sleep(enc->periph, &req, PUSER, "encstat", 0); in ses_set_elm_status()
2801 int i = (int)elmd->elm_idx; in ses_get_elm_desc()
2805 elmpriv = enc->enc_cache.elm_map[i].elm_private; in ses_get_elm_desc()
2807 if (elmpriv == NULL || elmpriv->descr == NULL) { in ses_get_elm_desc()
2808 elmd->elm_desc_len = 0; in ses_get_elm_desc()
2811 if (elmd->elm_desc_len > elmpriv->descr_len) in ses_get_elm_desc()
2812 elmd->elm_desc_len = elmpriv->descr_len; in ses_get_elm_desc()
2813 return (copyout(elmpriv->descr, elmd->elm_desc_str, in ses_get_elm_desc()
2814 elmd->elm_desc_len)); in ses_get_elm_desc()
2819 * given object id if one is available.
2832 len = elmdn->elm_names_size; in ses_get_elm_devnames()
2836 cam_periph_unlock(enc->periph); in ses_get_elm_devnames()
2838 ses_paths_iter(enc, &enc->enc_cache.elm_map[elmdn->elm_idx], in ses_get_elm_devnames()
2841 elmdn->elm_names_len = sbuf_len(&sb); in ses_get_elm_devnames()
2842 error = copyout(sbuf_data(&sb), elmdn->elm_devnames, in ses_get_elm_devnames()
2843 elmdn->elm_names_len + 1); in ses_get_elm_devnames()
2845 cam_periph_lock(enc->periph); in ses_get_elm_devnames()
2846 if (error == 0 && elmdn->elm_names_len == 0) in ses_get_elm_devnames()
2876 enc_cache = &enc->enc_daemon_cache; in ses_handle_string()
2877 ses_cache = enc_cache->private; in ses_handle_string()
2880 if (sstr->bufsiz > ENC_STRING_MAX) in ses_handle_string()
2885 payload = sstr->bufsiz + 4; /* header for SEND DIAGNOSTIC */ in ses_handle_string()
2886 amt = 0 - payload; in ses_handle_string()
2894 buf[2] = sstr->bufsiz >> 8; in ses_handle_string()
2895 buf[3] = sstr->bufsiz & 0xff; in ses_handle_string()
2896 ret = copyin(sstr->buf, &buf[4], sstr->bufsiz); in ses_handle_string()
2903 payload = sstr->bufsiz; in ses_handle_string()
2911 if (ses_cache->ses_nsubencs < 1) in ses_handle_string()
2913 enc_desc = ses_cache->subencs[0]; in ses_handle_string()
2914 cam_strvis(vendor, enc_desc->vendor_id, in ses_handle_string()
2915 sizeof(enc_desc->vendor_id), sizeof(vendor)); in ses_handle_string()
2916 cam_strvis(product, enc_desc->product_id, in ses_handle_string()
2917 sizeof(enc_desc->product_id), sizeof(product)); in ses_handle_string()
2918 cam_strvis(rev, enc_desc->product_rev, in ses_handle_string()
2919 sizeof(enc_desc->product_rev), sizeof(rev)); in ses_handle_string()
2925 if (size > sstr->bufsiz) in ses_handle_string()
2926 size = sstr->bufsiz; in ses_handle_string()
2927 ret = copyout(str, sstr->buf, size); in ses_handle_string()
2928 sstr->bufsiz = rsize; in ses_handle_string()
2931 if (ses_cache->ses_nsubencs < 1) in ses_handle_string()
2933 enc_desc = ses_cache->subencs[0]; in ses_handle_string()
2935 scsi_8btou64(enc_desc->logical_id)) + 1; in ses_handle_string()
2939 if (size > sstr->bufsiz) in ses_handle_string()
2940 size = sstr->bufsiz; in ses_handle_string()
2941 ret = copyout(str, sstr->buf, size); in ses_handle_string()
2942 sstr->bufsiz = rsize; in ses_handle_string()
2949 ret = copyout(buf, sstr->buf, sstr->bufsiz); in ses_handle_string()
2963 ses = enc->enc_private; in ses_poll_status()
2965 if (ses->ses_flags & SES_FLAG_DESC) in ses_poll_status()
2967 if (ses->ses_flags & SES_FLAG_ADDLSTATUS) in ses_poll_status()
3012 CAM_DEBUG(enc->periph->path, CAM_DEBUG_SUBTRACE, in ses_softc_init()
3015 enc->enc_vec = ses_enc_vec; in ses_softc_init()
3016 enc->enc_fsm_states = enc_fsm_states; in ses_softc_init()
3018 if (enc->enc_private == NULL) in ses_softc_init()
3019 enc->enc_private = ENC_MALLOCZ(sizeof(ses_softc_t)); in ses_softc_init()
3020 if (enc->enc_cache.private == NULL) in ses_softc_init()
3021 enc->enc_cache.private = ENC_MALLOCZ(sizeof(ses_cache_t)); in ses_softc_init()
3022 if (enc->enc_daemon_cache.private == NULL) in ses_softc_init()
3023 enc->enc_daemon_cache.private = in ses_softc_init()
3026 if (enc->enc_private == NULL in ses_softc_init()
3027 || enc->enc_cache.private == NULL in ses_softc_init()
3028 || enc->enc_daemon_cache.private == NULL) { in ses_softc_init()
3029 ENC_FREE_AND_NULL(enc->enc_private); in ses_softc_init()
3030 ENC_FREE_AND_NULL(enc->enc_cache.private); in ses_softc_init()
3031 ENC_FREE_AND_NULL(enc->enc_daemon_cache.private); in ses_softc_init()
3035 ses_softc = enc->enc_private; in ses_softc_init()
3036 TAILQ_INIT(&ses_softc->ses_requests); in ses_softc_init()
3037 TAILQ_INIT(&ses_softc->ses_pending_requests); in ses_softc_init()