scsi_enc_ses.c (238894) | scsi_enc_ses.c (239213) |
---|---|
1/*- 2 * Copyright (c) 2000 Matthew Jacob 3 * Copyright (c) 2010 Spectra Logic Corporation 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 18 unchanged lines hidden (view full) --- 27 28/** 29 * \file scsi_enc_ses.c 30 * 31 * Structures and routines specific && private to SES only 32 */ 33 34#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000 Matthew Jacob 3 * Copyright (c) 2010 Spectra Logic Corporation 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 18 unchanged lines hidden (view full) --- 27 28/** 29 * \file scsi_enc_ses.c 30 * 31 * Structures and routines specific && private to SES only 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_enc_ses.c 238894 2012-07-30 03:00:58Z bz $"); | 35__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_enc_ses.c 239213 2012-08-12 17:01:07Z mjacob $"); |
36 37#include <sys/param.h> 38 39#include <sys/errno.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/malloc.h> 43#include <sys/mutex.h> --- 1126 unchanged lines hidden (view full) --- 1170 1171 /* 1172 * Ignore illegal request errors, as they are quite common and we 1173 * will print something out in that case anyway. 1174 */ 1175 err = cam_periph_runccb(ccb, enc_error, ENC_CFLAGS, 1176 ENC_FLAGS|SF_QUIET_IR, NULL); 1177 if (ccb->ccb_h.status != CAM_REQ_CMP) { | 36 37#include <sys/param.h> 38 39#include <sys/errno.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/malloc.h> 43#include <sys/mutex.h> --- 1126 unchanged lines hidden (view full) --- 1170 1171 /* 1172 * Ignore illegal request errors, as they are quite common and we 1173 * will print something out in that case anyway. 1174 */ 1175 err = cam_periph_runccb(ccb, enc_error, ENC_CFLAGS, 1176 ENC_FLAGS|SF_QUIET_IR, NULL); 1177 if (ccb->ccb_h.status != CAM_REQ_CMP) { |
1178 ENC_LOG(enc, "Timed Completion Unsupported\n"); | 1178 ENC_VLOG(enc, "Timed Completion Unsupported\n"); |
1179 goto release; 1180 } 1181 1182 /* Skip the mode select if the desired value is already set */ 1183 mgmt = (struct ses_mgmt_mode_page *)mode_buf; 1184 if ((mgmt->byte5 & SES_MGMT_TIMED_COMP_EN) == tc_en) 1185 goto done; 1186 --- 6 unchanged lines hidden (view full) --- 1193 bzero(&mgmt->max_comp_time, sizeof(mgmt->max_comp_time)); 1194 1195 scsi_mode_select(&ccb->csio, 5, enc_done, MSG_SIMPLE_Q_TAG, 1196 /*page_fmt*/FALSE, /*save_pages*/TRUE, mode_buf, mode_buf_len, 1197 SSD_FULL_SIZE, /*timeout*/60 * 1000); 1198 1199 err = cam_periph_runccb(ccb, enc_error, ENC_CFLAGS, ENC_FLAGS, NULL); 1200 if (ccb->ccb_h.status != CAM_REQ_CMP) { | 1179 goto release; 1180 } 1181 1182 /* Skip the mode select if the desired value is already set */ 1183 mgmt = (struct ses_mgmt_mode_page *)mode_buf; 1184 if ((mgmt->byte5 & SES_MGMT_TIMED_COMP_EN) == tc_en) 1185 goto done; 1186 --- 6 unchanged lines hidden (view full) --- 1193 bzero(&mgmt->max_comp_time, sizeof(mgmt->max_comp_time)); 1194 1195 scsi_mode_select(&ccb->csio, 5, enc_done, MSG_SIMPLE_Q_TAG, 1196 /*page_fmt*/FALSE, /*save_pages*/TRUE, mode_buf, mode_buf_len, 1197 SSD_FULL_SIZE, /*timeout*/60 * 1000); 1198 1199 err = cam_periph_runccb(ccb, enc_error, ENC_CFLAGS, ENC_FLAGS, NULL); 1200 if (ccb->ccb_h.status != CAM_REQ_CMP) { |
1201 ENC_LOG(enc, "Timed Completion Set Failed\n"); | 1201 ENC_VLOG(enc, "Timed Completion Set Failed\n"); |
1202 goto release; 1203 } 1204 1205done: 1206 if ((mgmt->byte5 & SES_MGMT_TIMED_COMP_EN) != 0) { 1207 ENC_LOG(enc, "Timed Completion Enabled\n"); 1208 ses->ses_flags |= SES_FLAG_TIMEDCOMP; 1209 } else { --- 29 unchanged lines hidden (view full) --- 1239 ses = enc->enc_private; 1240 err = -1; 1241 1242 if (error != 0) { 1243 err = error; 1244 goto out; 1245 } 1246 if (xfer_len < sizeof(*page)) { | 1202 goto release; 1203 } 1204 1205done: 1206 if ((mgmt->byte5 & SES_MGMT_TIMED_COMP_EN) != 0) { 1207 ENC_LOG(enc, "Timed Completion Enabled\n"); 1208 ses->ses_flags |= SES_FLAG_TIMEDCOMP; 1209 } else { --- 29 unchanged lines hidden (view full) --- 1239 ses = enc->enc_private; 1240 err = -1; 1241 1242 if (error != 0) { 1243 err = error; 1244 goto out; 1245 } 1246 if (xfer_len < sizeof(*page)) { |
1247 ENC_LOG(enc, "Unable to parse Diag Pages List Header\n"); | 1247 ENC_VLOG(enc, "Unable to parse Diag Pages List Header\n"); |
1248 err = EIO; 1249 goto out; 1250 } 1251 page = (struct scsi_diag_page *)*bufp; 1252 length = scsi_2btoul(page->length); 1253 if (length + offsetof(struct scsi_diag_page, params) > xfer_len) { | 1248 err = EIO; 1249 goto out; 1250 } 1251 page = (struct scsi_diag_page *)*bufp; 1252 length = scsi_2btoul(page->length); 1253 if (length + offsetof(struct scsi_diag_page, params) > xfer_len) { |
1254 ENC_LOG(enc, "Diag Pages List Too Long\n"); | 1254 ENC_VLOG(enc, "Diag Pages List Too Long\n"); |
1255 goto out; 1256 } 1257 ENC_DLOG(enc, "%s: page length %d, xfer_len %d\n", 1258 __func__, length, xfer_len); 1259 1260 err = 0; 1261 for (i = 0; i < length; i++) { 1262 if (page->params[i] == SesAddlElementStatus) { --- 50 unchanged lines hidden (view full) --- 1313 buf = *bufp; 1314 err = -1;; 1315 1316 if (error != 0) { 1317 err = error; 1318 goto out; 1319 } 1320 if (xfer_len < sizeof(cfg_page->hdr)) { | 1255 goto out; 1256 } 1257 ENC_DLOG(enc, "%s: page length %d, xfer_len %d\n", 1258 __func__, length, xfer_len); 1259 1260 err = 0; 1261 for (i = 0; i < length; i++) { 1262 if (page->params[i] == SesAddlElementStatus) { --- 50 unchanged lines hidden (view full) --- 1313 buf = *bufp; 1314 err = -1;; 1315 1316 if (error != 0) { 1317 err = error; 1318 goto out; 1319 } 1320 if (xfer_len < sizeof(cfg_page->hdr)) { |
1321 ENC_LOG(enc, "Unable to parse SES Config Header\n"); | 1321 ENC_VLOG(enc, "Unable to parse SES Config Header\n"); |
1322 err = EIO; 1323 goto out; 1324 } 1325 1326 cfg_page = (struct ses_cfg_page *)buf; 1327 length = ses_page_length(&cfg_page->hdr); 1328 if (length > xfer_len) { | 1322 err = EIO; 1323 goto out; 1324 } 1325 1326 cfg_page = (struct ses_cfg_page *)buf; 1327 length = ses_page_length(&cfg_page->hdr); 1328 if (length > xfer_len) { |
1329 ENC_LOG(enc, "Enclosure Config Page Too Long\n"); | 1329 ENC_VLOG(enc, "Enclosure Config Page Too Long\n"); |
1330 goto out; 1331 } 1332 last_valid_byte = &buf[length - 1]; 1333 1334 ENC_DLOG(enc, "%s: total page length %d, xfer_len %d\n", 1335 __func__, length, xfer_len); 1336 1337 err = 0; --- 34 unchanged lines hidden (view full) --- 1372 1373 buf_subenc = cfg_page->subencs; 1374 cur_subenc = subencs; 1375 last_subenc = &subencs[ses_cfg_page_get_num_subenc(cfg_page) - 1]; 1376 ntype = 0; 1377 while (cur_subenc <= last_subenc) { 1378 1379 if (!ses_enc_desc_is_complete(buf_subenc, last_valid_byte)) { | 1330 goto out; 1331 } 1332 last_valid_byte = &buf[length - 1]; 1333 1334 ENC_DLOG(enc, "%s: total page length %d, xfer_len %d\n", 1335 __func__, length, xfer_len); 1336 1337 err = 0; --- 34 unchanged lines hidden (view full) --- 1372 1373 buf_subenc = cfg_page->subencs; 1374 cur_subenc = subencs; 1375 last_subenc = &subencs[ses_cfg_page_get_num_subenc(cfg_page) - 1]; 1376 ntype = 0; 1377 while (cur_subenc <= last_subenc) { 1378 1379 if (!ses_enc_desc_is_complete(buf_subenc, last_valid_byte)) { |
1380 ENC_LOG(enc, "Enclosure %d Beyond End of " | 1380 ENC_VLOG(enc, "Enclosure %d Beyond End of " |
1381 "Descriptors\n", cur_subenc - subencs); 1382 err = EIO; 1383 goto out; 1384 } 1385 1386 ENC_VLOG(enc, " SubEnclosure ID %d, %d Types With this ID, " 1387 "Descriptor Length %d, offset %d\n", buf_subenc->subenc_id, 1388 buf_subenc->num_types, buf_subenc->length, --- 22 unchanged lines hidden (view full) --- 1411 cur_buf_type = (const struct ses_elm_type_desc *) 1412 (&(*last_subenc)->length + (*last_subenc)->length + 1); 1413 last_buf_type = cur_buf_type + ntype - 1; 1414 type_text = (const uint8_t *)(last_buf_type + 1); 1415 nelm = 0; 1416 sestype = ses_types; 1417 while (cur_buf_type <= last_buf_type) { 1418 if (&cur_buf_type->etype_txt_len > last_valid_byte) { | 1381 "Descriptors\n", cur_subenc - subencs); 1382 err = EIO; 1383 goto out; 1384 } 1385 1386 ENC_VLOG(enc, " SubEnclosure ID %d, %d Types With this ID, " 1387 "Descriptor Length %d, offset %d\n", buf_subenc->subenc_id, 1388 buf_subenc->num_types, buf_subenc->length, --- 22 unchanged lines hidden (view full) --- 1411 cur_buf_type = (const struct ses_elm_type_desc *) 1412 (&(*last_subenc)->length + (*last_subenc)->length + 1); 1413 last_buf_type = cur_buf_type + ntype - 1; 1414 type_text = (const uint8_t *)(last_buf_type + 1); 1415 nelm = 0; 1416 sestype = ses_types; 1417 while (cur_buf_type <= last_buf_type) { 1418 if (&cur_buf_type->etype_txt_len > last_valid_byte) { |
1419 ENC_LOG(enc, "Runt Enclosure Type Header %d\n", | 1419 ENC_VLOG(enc, "Runt Enclosure Type Header %d\n", |
1420 sestype - ses_types); 1421 err = EIO; 1422 goto out; 1423 } 1424 sestype->hdr = cur_buf_type; 1425 sestype->text = type_text; 1426 type_text += cur_buf_type->etype_txt_len; | 1420 sestype - ses_types); 1421 err = EIO; 1422 goto out; 1423 } 1424 sestype->hdr = cur_buf_type; 1425 sestype->text = type_text; 1426 type_text += cur_buf_type->etype_txt_len; |
1427 ENC_LOG(enc, " Type Desc[%d]: Type 0x%x, MaxElt %d, In Subenc " | 1427 ENC_VLOG(enc, " Type Desc[%d]: Type 0x%x, MaxElt %d, In Subenc " |
1428 "%d, Text Length %d: %.*s\n", sestype - ses_types, 1429 sestype->hdr->etype_elm_type, sestype->hdr->etype_maxelt, 1430 sestype->hdr->etype_subenc, sestype->hdr->etype_txt_len, 1431 sestype->hdr->etype_txt_len, sestype->text); 1432 1433 nelm += sestype->hdr->etype_maxelt 1434 + /*overall status element*/1; 1435 sestype++; --- 88 unchanged lines hidden (view full) --- 1524 /* 1525 * Make sure the length fits in the buffer. 1526 * 1527 * XXX all this means is that the page is larger than the space 1528 * we allocated. Since we use a statically sized buffer, this 1529 * could happen... Need to use dynamic discovery of the size. 1530 */ 1531 if (length > xfer_len) { | 1428 "%d, Text Length %d: %.*s\n", sestype - ses_types, 1429 sestype->hdr->etype_elm_type, sestype->hdr->etype_maxelt, 1430 sestype->hdr->etype_subenc, sestype->hdr->etype_txt_len, 1431 sestype->hdr->etype_txt_len, sestype->text); 1432 1433 nelm += sestype->hdr->etype_maxelt 1434 + /*overall status element*/1; 1435 sestype++; --- 88 unchanged lines hidden (view full) --- 1524 /* 1525 * Make sure the length fits in the buffer. 1526 * 1527 * XXX all this means is that the page is larger than the space 1528 * we allocated. Since we use a statically sized buffer, this 1529 * could happen... Need to use dynamic discovery of the size. 1530 */ 1531 if (length > xfer_len) { |
1532 ENC_LOG(enc, "Enclosure Status Page Too Long\n"); | 1532 ENC_VLOG(enc, "Enclosure Status Page Too Long\n"); |
1533 goto out; 1534 } 1535 /* Make sure the length contains at least one header and status */ 1536 if (length < (sizeof(*page) + sizeof(*page->elements))) { | 1533 goto out; 1534 } 1535 /* Make sure the length contains at least one header and status */ 1536 if (length < (sizeof(*page) + sizeof(*page->elements))) { |
1537 ENC_LOG(enc, "Enclosure Status Page Too Short\n"); | 1537 ENC_VLOG(enc, "Enclosure Status Page Too Short\n"); |
1538 goto out; 1539 } 1540 1541 if (!ses_config_cache_valid(ses_cache, page->hdr.gen_code)) { 1542 ENC_DLOG(enc, "%s: Generation count change detected\n", 1543 __func__); 1544 enc_update_request(enc, SES_UPDATE_GETCONFIG); 1545 goto out; --- 25 unchanged lines hidden (view full) --- 1571 scsi_4btoul(cur_stat->bytes)); 1572 1573 memcpy(&element->encstat, cur_stat, sizeof(element->encstat)); 1574 element->svalid = 1; 1575 cur_stat++; 1576 } 1577 1578 if (ses_iter_next(&iter) != NULL) { | 1538 goto out; 1539 } 1540 1541 if (!ses_config_cache_valid(ses_cache, page->hdr.gen_code)) { 1542 ENC_DLOG(enc, "%s: Generation count change detected\n", 1543 __func__); 1544 enc_update_request(enc, SES_UPDATE_GETCONFIG); 1545 goto out; --- 25 unchanged lines hidden (view full) --- 1571 scsi_4btoul(cur_stat->bytes)); 1572 1573 memcpy(&element->encstat, cur_stat, sizeof(element->encstat)); 1574 element->svalid = 1; 1575 cur_stat++; 1576 } 1577 1578 if (ses_iter_next(&iter) != NULL) { |
1579 ENC_LOG(enc, "Status page, length insufficient for " | 1579 ENC_VLOG(enc, "Status page, length insufficient for " |
1580 "expected number of objects\n"); 1581 } else { 1582 if (cur_stat <= last_stat) | 1580 "expected number of objects\n"); 1581 } else { 1582 if (cur_stat <= last_stat) |
1583 ENC_LOG(enc, "Status page, exhausted objects before " | 1583 ENC_VLOG(enc, "Status page, exhausted objects before " |
1584 "exhausing page\n"); 1585 enc_update_request(enc, SES_PUBLISH_CACHE); 1586 err = 0; 1587 } 1588out: 1589 ENC_DLOG(enc, "%s: exiting with error %d\n", __func__, err); 1590 return (err); 1591} --- 109 unchanged lines hidden (view full) --- 1701 * page. However, it is necessary to skip elements that are not 1702 * supported by this page when counting them. 1703 */ 1704 hdr = &ses_cache->elm_addlstatus_page->hdr; 1705 length = ses_page_length(hdr); 1706 ENC_DLOG(enc, "Additional Element Status Page Length 0x%x\n", length); 1707 /* Make sure the length includes at least one header. */ 1708 if (length < sizeof(*hdr)+sizeof(struct ses_elm_addlstatus_base_hdr)) { | 1584 "exhausing page\n"); 1585 enc_update_request(enc, SES_PUBLISH_CACHE); 1586 err = 0; 1587 } 1588out: 1589 ENC_DLOG(enc, "%s: exiting with error %d\n", __func__, err); 1590 return (err); 1591} --- 109 unchanged lines hidden (view full) --- 1701 * page. However, it is necessary to skip elements that are not 1702 * supported by this page when counting them. 1703 */ 1704 hdr = &ses_cache->elm_addlstatus_page->hdr; 1705 length = ses_page_length(hdr); 1706 ENC_DLOG(enc, "Additional Element Status Page Length 0x%x\n", length); 1707 /* Make sure the length includes at least one header. */ 1708 if (length < sizeof(*hdr)+sizeof(struct ses_elm_addlstatus_base_hdr)) { |
1709 ENC_LOG(enc, "Runt Additional Element Status Page\n"); | 1709 ENC_VLOG(enc, "Runt Additional Element Status Page\n"); |
1710 goto out; 1711 } 1712 if (length > xfer_len) { | 1710 goto out; 1711 } 1712 if (length > xfer_len) { |
1713 ENC_LOG(enc, "Additional Element Status Page Too Long\n"); | 1713 ENC_VLOG(enc, "Additional Element Status Page Too Long\n"); |
1714 goto out; 1715 } 1716 1717 if (!ses_config_cache_valid(ses_cache, hdr->gen_code)) { 1718 ENC_DLOG(enc, "%s: Generation count change detected\n", 1719 __func__); 1720 enc_update_request(enc, SES_UPDATE_GETCONFIG); 1721 goto out; --- 36 unchanged lines hidden (view full) --- 1758 titer.type_index > ELMTYP_SAS_CONN)) { 1759 iter = titer; 1760 element = telement; 1761 } else 1762 ignore_index = 1; 1763 1764 if (iter.individual_element_index > expected_index 1765 && status_type == TYPE_ADDLSTATUS_MANDATORY) { | 1714 goto out; 1715 } 1716 1717 if (!ses_config_cache_valid(ses_cache, hdr->gen_code)) { 1718 ENC_DLOG(enc, "%s: Generation count change detected\n", 1719 __func__); 1720 enc_update_request(enc, SES_UPDATE_GETCONFIG); 1721 goto out; --- 36 unchanged lines hidden (view full) --- 1758 titer.type_index > ELMTYP_SAS_CONN)) { 1759 iter = titer; 1760 element = telement; 1761 } else 1762 ignore_index = 1; 1763 1764 if (iter.individual_element_index > expected_index 1765 && status_type == TYPE_ADDLSTATUS_MANDATORY) { |
1766 ENC_LOG(enc, "%s: provided element " | 1766 ENC_VLOG(enc, "%s: provided element " |
1767 "index %d skips mandatory status " 1768 " element at index %d\n", 1769 __func__, eip_hdr->element_index, 1770 expected_index); 1771 } 1772 } 1773 elmpriv = element->elm_private; 1774 elmpriv->addl.hdr = elm_hdr; --- 4 unchanged lines hidden (view full) --- 1779 iter.type_element_index, offset, elmpriv->addl.hdr->byte0, 1780 elmpriv->addl.hdr->length); 1781 1782 /* Skip to after the length field */ 1783 offset += sizeof(struct ses_elm_addlstatus_base_hdr); 1784 1785 /* Make sure the descriptor is within bounds */ 1786 if ((offset + elmpriv->addl.hdr->length) > length) { | 1767 "index %d skips mandatory status " 1768 " element at index %d\n", 1769 __func__, eip_hdr->element_index, 1770 expected_index); 1771 } 1772 } 1773 elmpriv = element->elm_private; 1774 elmpriv->addl.hdr = elm_hdr; --- 4 unchanged lines hidden (view full) --- 1779 iter.type_element_index, offset, elmpriv->addl.hdr->byte0, 1780 elmpriv->addl.hdr->length); 1781 1782 /* Skip to after the length field */ 1783 offset += sizeof(struct ses_elm_addlstatus_base_hdr); 1784 1785 /* Make sure the descriptor is within bounds */ 1786 if ((offset + elmpriv->addl.hdr->length) > length) { |
1787 ENC_LOG(enc, "Element %d Beyond End " | 1787 ENC_VLOG(enc, "Element %d Beyond End " |
1788 "of Additional Element Status Descriptors\n", 1789 iter.global_element_index); 1790 err = EIO; 1791 goto out; 1792 } 1793 1794 /* Advance to the protocol data, skipping eip bytes if needed */ 1795 offset += (eip * SES_EIP_HDR_EXTRA_LEN); --- 13 unchanged lines hidden (view full) --- 1809 break; 1810 ses_get_elm_addlstatus_sas(enc, enc_cache, 1811 &buf[offset], 1812 proto_info_len, 1813 eip, iter.type_index, 1814 iter.global_element_index); 1815 break; 1816 default: | 1788 "of Additional Element Status Descriptors\n", 1789 iter.global_element_index); 1790 err = EIO; 1791 goto out; 1792 } 1793 1794 /* Advance to the protocol data, skipping eip bytes if needed */ 1795 offset += (eip * SES_EIP_HDR_EXTRA_LEN); --- 13 unchanged lines hidden (view full) --- 1809 break; 1810 ses_get_elm_addlstatus_sas(enc, enc_cache, 1811 &buf[offset], 1812 proto_info_len, 1813 eip, iter.type_index, 1814 iter.global_element_index); 1815 break; 1816 default: |
1817 ENC_LOG(enc, "Element %d: Unknown Additional Element " | 1817 ENC_VLOG(enc, "Element %d: Unknown Additional Element " |
1818 "Protocol 0x%x\n", iter.global_element_index, 1819 ses_elm_addlstatus_proto(elmpriv->addl.hdr)); 1820 goto out; 1821 } 1822 1823 offset += proto_info_len; 1824 } 1825 err = 0; --- 100 unchanged lines hidden (view full) --- 1926 } 1927 ses_cache_free_elm_descs(enc, enc_cache); 1928 ses_cache->elm_descs_page = (struct ses_elem_descr_page *)buf; 1929 *bufp = NULL; 1930 1931 phdr = &ses_cache->elm_descs_page->hdr; 1932 plength = ses_page_length(phdr); 1933 if (xfer_len < sizeof(struct ses_page_hdr)) { | 1818 "Protocol 0x%x\n", iter.global_element_index, 1819 ses_elm_addlstatus_proto(elmpriv->addl.hdr)); 1820 goto out; 1821 } 1822 1823 offset += proto_info_len; 1824 } 1825 err = 0; --- 100 unchanged lines hidden (view full) --- 1926 } 1927 ses_cache_free_elm_descs(enc, enc_cache); 1928 ses_cache->elm_descs_page = (struct ses_elem_descr_page *)buf; 1929 *bufp = NULL; 1930 1931 phdr = &ses_cache->elm_descs_page->hdr; 1932 plength = ses_page_length(phdr); 1933 if (xfer_len < sizeof(struct ses_page_hdr)) { |
1934 ENC_LOG(enc, "Runt Element Descriptor Page\n"); | 1934 ENC_VLOG(enc, "Runt Element Descriptor Page\n"); |
1935 goto out; 1936 } 1937 if (plength > xfer_len) { | 1935 goto out; 1936 } 1937 if (plength > xfer_len) { |
1938 ENC_LOG(enc, "Element Descriptor Page Too Long\n"); | 1938 ENC_VLOG(enc, "Element Descriptor Page Too Long\n"); |
1939 goto out; 1940 } 1941 1942 if (!ses_config_cache_valid(ses_cache, phdr->gen_code)) { 1943 ENC_VLOG(enc, "%s: Generation count change detected\n", 1944 __func__); 1945 enc_update_request(enc, SES_UPDATE_GETCONFIG); 1946 goto out; 1947 } 1948 1949 offset = sizeof(struct ses_page_hdr); 1950 1951 ses_iter_init(enc, enc_cache, &iter); 1952 while (offset < plength 1953 && (element = ses_iter_next(&iter)) != NULL) { 1954 1955 if ((offset + sizeof(struct ses_elm_desc_hdr)) > plength) { | 1939 goto out; 1940 } 1941 1942 if (!ses_config_cache_valid(ses_cache, phdr->gen_code)) { 1943 ENC_VLOG(enc, "%s: Generation count change detected\n", 1944 __func__); 1945 enc_update_request(enc, SES_UPDATE_GETCONFIG); 1946 goto out; 1947 } 1948 1949 offset = sizeof(struct ses_page_hdr); 1950 1951 ses_iter_init(enc, enc_cache, &iter); 1952 while (offset < plength 1953 && (element = ses_iter_next(&iter)) != NULL) { 1954 1955 if ((offset + sizeof(struct ses_elm_desc_hdr)) > plength) { |
1956 ENC_LOG(enc, "Element %d Descriptor Header Past " | 1956 ENC_VLOG(enc, "Element %d Descriptor Header Past " |
1957 "End of Buffer\n", iter.global_element_index); 1958 goto out; 1959 } 1960 hdr = (struct ses_elm_desc_hdr *)&buf[offset]; 1961 length = scsi_2btoul(hdr->length); 1962 ENC_DLOG(enc, "%s: obj %d(%d,%d) length=%d off=%d\n", __func__, 1963 iter.global_element_index, iter.type_index, 1964 iter.type_element_index, length, offset); 1965 if ((offset + sizeof(*hdr) + length) > plength) { | 1957 "End of Buffer\n", iter.global_element_index); 1958 goto out; 1959 } 1960 hdr = (struct ses_elm_desc_hdr *)&buf[offset]; 1961 length = scsi_2btoul(hdr->length); 1962 ENC_DLOG(enc, "%s: obj %d(%d,%d) length=%d off=%d\n", __func__, 1963 iter.global_element_index, iter.type_index, 1964 iter.type_element_index, length, offset); 1965 if ((offset + sizeof(*hdr) + length) > plength) { |
1966 ENC_LOG(enc, "Element%d Descriptor Past " | 1966 ENC_VLOG(enc, "Element%d Descriptor Past " |
1967 "End of Buffer\n", iter.global_element_index); 1968 goto out; 1969 } 1970 offset += sizeof(*hdr); 1971 1972 if (length > 0) { 1973 elmpriv = element->elm_private; 1974 elmpriv->descr_len = length; --- 158 unchanged lines hidden (view full) --- 2133 } 2134 return (0); 2135} 2136 2137static int 2138ses_get_elm_addlstatus_fc(enc_softc_t *enc, enc_cache_t *enc_cache, 2139 uint8_t *buf, int bufsiz) 2140{ | 1967 "End of Buffer\n", iter.global_element_index); 1968 goto out; 1969 } 1970 offset += sizeof(*hdr); 1971 1972 if (length > 0) { 1973 elmpriv = element->elm_private; 1974 elmpriv->descr_len = length; --- 158 unchanged lines hidden (view full) --- 2133 } 2134 return (0); 2135} 2136 2137static int 2138ses_get_elm_addlstatus_fc(enc_softc_t *enc, enc_cache_t *enc_cache, 2139 uint8_t *buf, int bufsiz) 2140{ |
2141 ENC_LOG(enc, "FC Device Support Stubbed in Additional Status Page\n"); | 2141 ENC_VLOG(enc, "FC Device Support Stubbed in Additional Status Page\n"); |
2142 return (ENODEV); 2143} 2144 2145#define SES_PRINT_PORTS(p, type) do { \ 2146 sbuf_printf(sbp, " %s(", type); \ 2147 if (((p) & SES_SASOBJ_DEV_PHY_PROTOMASK) == 0) \ 2148 sbuf_printf(sbp, " None"); \ 2149 else { \ --- 230 unchanged lines hidden (view full) --- 2380 offset += sizeof(struct ses_elm_sas_type0_eip_hdr); 2381 else 2382 offset += sizeof(struct ses_elm_sas_type0_base_hdr); 2383 2384 /* Make sure the phy list fits in the buffer */ 2385 physz = addl->proto_hdr.sas->base_hdr.num_phys; 2386 physz *= sizeof(struct ses_elm_sas_device_phy); 2387 if (physz > (bufsiz - offset + 4)) { | 2142 return (ENODEV); 2143} 2144 2145#define SES_PRINT_PORTS(p, type) do { \ 2146 sbuf_printf(sbp, " %s(", type); \ 2147 if (((p) & SES_SASOBJ_DEV_PHY_PROTOMASK) == 0) \ 2148 sbuf_printf(sbp, " None"); \ 2149 else { \ --- 230 unchanged lines hidden (view full) --- 2380 offset += sizeof(struct ses_elm_sas_type0_eip_hdr); 2381 else 2382 offset += sizeof(struct ses_elm_sas_type0_base_hdr); 2383 2384 /* Make sure the phy list fits in the buffer */ 2385 physz = addl->proto_hdr.sas->base_hdr.num_phys; 2386 physz *= sizeof(struct ses_elm_sas_device_phy); 2387 if (physz > (bufsiz - offset + 4)) { |
2388 ENC_LOG(enc, "Element %d Device Phy List Beyond End Of Buffer\n", | 2388 ENC_VLOG(enc, "Element %d Device Phy List Beyond End Of Buffer\n", |
2389 nobj); 2390 err = EIO; 2391 goto out; 2392 } 2393 2394 /* Point to the phy list */ 2395 addl->proto_data.sasdev_phys = 2396 (struct ses_elm_sas_device_phy *)&buf[offset]; --- 38 unchanged lines hidden (view full) --- 2435 goto out; 2436 2437 /* Process expanders differently from other type1 cases */ 2438 if (ses_obj_is_expander(enc, obj)) { 2439 offset += sizeof(struct ses_elm_sas_type1_expander_hdr); 2440 physz = addl->proto_hdr.sas->base_hdr.num_phys * 2441 sizeof(struct ses_elm_sas_expander_phy); 2442 if (physz > (bufsiz - offset)) { | 2389 nobj); 2390 err = EIO; 2391 goto out; 2392 } 2393 2394 /* Point to the phy list */ 2395 addl->proto_data.sasdev_phys = 2396 (struct ses_elm_sas_device_phy *)&buf[offset]; --- 38 unchanged lines hidden (view full) --- 2435 goto out; 2436 2437 /* Process expanders differently from other type1 cases */ 2438 if (ses_obj_is_expander(enc, obj)) { 2439 offset += sizeof(struct ses_elm_sas_type1_expander_hdr); 2440 physz = addl->proto_hdr.sas->base_hdr.num_phys * 2441 sizeof(struct ses_elm_sas_expander_phy); 2442 if (physz > (bufsiz - offset)) { |
2443 ENC_LOG(enc, "Element %d: Expander Phy List Beyond " | 2443 ENC_VLOG(enc, "Element %d: Expander Phy List Beyond " |
2444 "End Of Buffer\n", nobj); 2445 err = EIO; 2446 goto out; 2447 } 2448 addl->proto_data.sasexp_phys = 2449 (struct ses_elm_sas_expander_phy *)&buf[offset]; 2450 } else { 2451 offset += sizeof(struct ses_elm_sas_type1_nonexpander_hdr); 2452 physz = addl->proto_hdr.sas->base_hdr.num_phys * 2453 sizeof(struct ses_elm_sas_port_phy); 2454 if (physz > (bufsiz - offset + 4)) { | 2444 "End Of Buffer\n", nobj); 2445 err = EIO; 2446 goto out; 2447 } 2448 addl->proto_data.sasexp_phys = 2449 (struct ses_elm_sas_expander_phy *)&buf[offset]; 2450 } else { 2451 offset += sizeof(struct ses_elm_sas_type1_nonexpander_hdr); 2452 physz = addl->proto_hdr.sas->base_hdr.num_phys * 2453 sizeof(struct ses_elm_sas_port_phy); 2454 if (physz > (bufsiz - offset + 4)) { |
2455 ENC_LOG(enc, "Element %d: Port Phy List Beyond End " | 2455 ENC_VLOG(enc, "Element %d: Port Phy List Beyond End " |
2456 "Of Buffer\n", nobj); 2457 err = EIO; 2458 goto out; 2459 } 2460 addl->proto_data.sasport_phys = 2461 (struct ses_elm_sas_port_phy *)&buf[offset]; 2462 } 2463 --- 35 unchanged lines hidden (view full) --- 2499 dtype = ses_elm_sas_descr_type(hdr); 2500 switch(dtype) { 2501 case SES_SASOBJ_TYPE_SLOT: 2502 switch(ses_cache->ses_types[tidx].hdr->etype_elm_type) { 2503 case ELMTYP_DEVICE: 2504 case ELMTYP_ARRAY_DEV: 2505 break; 2506 default: | 2456 "Of Buffer\n", nobj); 2457 err = EIO; 2458 goto out; 2459 } 2460 addl->proto_data.sasport_phys = 2461 (struct ses_elm_sas_port_phy *)&buf[offset]; 2462 } 2463 --- 35 unchanged lines hidden (view full) --- 2499 dtype = ses_elm_sas_descr_type(hdr); 2500 switch(dtype) { 2501 case SES_SASOBJ_TYPE_SLOT: 2502 switch(ses_cache->ses_types[tidx].hdr->etype_elm_type) { 2503 case ELMTYP_DEVICE: 2504 case ELMTYP_ARRAY_DEV: 2505 break; 2506 default: |
2507 ENC_LOG(enc, "Element %d has Additional Status type 0, " | 2507 ENC_VLOG(enc, "Element %d has Additional Status type 0, " |
2508 "invalid for SES element type 0x%x\n", nobj, 2509 ses_cache->ses_types[tidx].hdr->etype_elm_type); 2510 err = ENODEV; 2511 goto out; 2512 } 2513 err = ses_get_elm_addlstatus_sas_type0(enc, enc_cache, 2514 buf, bufsiz, eip, 2515 nobj); 2516 break; 2517 case SES_SASOBJ_TYPE_OTHER: 2518 switch(ses_cache->ses_types[tidx].hdr->etype_elm_type) { 2519 case ELMTYP_SAS_EXP: 2520 case ELMTYP_SCSI_INI: 2521 case ELMTYP_SCSI_TGT: 2522 case ELMTYP_ESCC: 2523 break; 2524 default: | 2508 "invalid for SES element type 0x%x\n", nobj, 2509 ses_cache->ses_types[tidx].hdr->etype_elm_type); 2510 err = ENODEV; 2511 goto out; 2512 } 2513 err = ses_get_elm_addlstatus_sas_type0(enc, enc_cache, 2514 buf, bufsiz, eip, 2515 nobj); 2516 break; 2517 case SES_SASOBJ_TYPE_OTHER: 2518 switch(ses_cache->ses_types[tidx].hdr->etype_elm_type) { 2519 case ELMTYP_SAS_EXP: 2520 case ELMTYP_SCSI_INI: 2521 case ELMTYP_SCSI_TGT: 2522 case ELMTYP_ESCC: 2523 break; 2524 default: |
2525 ENC_LOG(enc, "Element %d has Additional Status type 1, " | 2525 ENC_VLOG(enc, "Element %d has Additional Status type 1, " |
2526 "invalid for SES element type 0x%x\n", nobj, 2527 ses_cache->ses_types[tidx].hdr->etype_elm_type); 2528 err = ENODEV; 2529 goto out; 2530 } 2531 err = ses_get_elm_addlstatus_sas_type1(enc, enc_cache, buf, 2532 bufsiz, eip, nobj); 2533 break; 2534 default: | 2526 "invalid for SES element type 0x%x\n", nobj, 2527 ses_cache->ses_types[tidx].hdr->etype_elm_type); 2528 err = ENODEV; 2529 goto out; 2530 } 2531 err = ses_get_elm_addlstatus_sas_type1(enc, enc_cache, buf, 2532 bufsiz, eip, nobj); 2533 break; 2534 default: |
2535 ENC_LOG(enc, "Element %d of type 0x%x has Additional Status " | 2535 ENC_VLOG(enc, "Element %d of type 0x%x has Additional Status " |
2536 "of unknown type 0x%x\n", nobj, 2537 ses_cache->ses_types[tidx].hdr->etype_elm_type, dtype); 2538 err = ENODEV; 2539 break; 2540 } 2541 2542out: 2543 return (err); --- 271 unchanged lines hidden --- | 2536 "of unknown type 0x%x\n", nobj, 2537 ses_cache->ses_types[tidx].hdr->etype_elm_type, dtype); 2538 err = ENODEV; 2539 break; 2540 } 2541 2542out: 2543 return (err); --- 271 unchanged lines hidden --- |