From owner-svn-src-all@freebsd.org Fri Jul 26 03:49:18 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AE9B6B5214; Fri, 26 Jul 2019 03:49:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 87F08746BA; Fri, 26 Jul 2019 03:49:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 61DD892D3; Fri, 26 Jul 2019 03:49:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x6Q3nI55052662; Fri, 26 Jul 2019 03:49:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x6Q3nHFw052657; Fri, 26 Jul 2019 03:49:17 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201907260349.x6Q3nHFw052657@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 26 Jul 2019 03:49:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r350346 - in head: sys/cam/ctl sys/cam/scsi usr.sbin/ctladm X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head: sys/cam/ctl sys/cam/scsi usr.sbin/ctladm X-SVN-Commit-Revision: 350346 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 87F08746BA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.952,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Jul 2019 03:49:18 -0000 Author: mav Date: Fri Jul 26 03:49:16 2019 New Revision: 350346 URL: https://svnweb.freebsd.org/changeset/base/350346 Log: Add device temperature reporting into CTL. The values to report can be set via LUN options. It can be useful for testing, and also required for Drive Maintenance 2016 feature set. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl.h head/sys/cam/ctl/ctl_private.h head/sys/cam/scsi/scsi_all.h head/usr.sbin/ctladm/ctladm.8 Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Fri Jul 26 02:49:34 2019 (r350345) +++ head/sys/cam/ctl/ctl.c Fri Jul 26 03:49:16 2019 (r350346) @@ -4450,12 +4450,14 @@ ctl_init_log_page_index(struct ctl_lun *lun) lun->log_pages.index[0].page_len = j; lun->log_pages.index[1].page_data = &lun->log_pages.subpages_page[0]; lun->log_pages.index[1].page_len = k * 2; - lun->log_pages.index[2].page_data = &lun->log_pages.lbp_page[0]; - lun->log_pages.index[2].page_len = 12*CTL_NUM_LBP_PARAMS; - lun->log_pages.index[3].page_data = (uint8_t *)&lun->log_pages.stat_page; - lun->log_pages.index[3].page_len = sizeof(lun->log_pages.stat_page); - lun->log_pages.index[4].page_data = (uint8_t *)&lun->log_pages.ie_page; - lun->log_pages.index[4].page_len = sizeof(lun->log_pages.ie_page); + lun->log_pages.index[2].page_data = (uint8_t *)&lun->log_pages.temp_page; + lun->log_pages.index[2].page_len = sizeof(lun->log_pages.temp_page); + lun->log_pages.index[3].page_data = &lun->log_pages.lbp_page[0]; + lun->log_pages.index[3].page_len = 12*CTL_NUM_LBP_PARAMS; + lun->log_pages.index[4].page_data = (uint8_t *)&lun->log_pages.stat_page; + lun->log_pages.index[4].page_len = sizeof(lun->log_pages.stat_page); + lun->log_pages.index[5].page_data = (uint8_t *)&lun->log_pages.ie_page; + lun->log_pages.index[5].page_len = sizeof(lun->log_pages.ie_page); return (CTL_RETVAL_COMPLETE); } @@ -6679,6 +6681,40 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) } int +ctl_temp_log_sense_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, + int pc) +{ + struct ctl_lun *lun = CTL_LUN(ctsio); + struct scsi_log_temperature *data; + const char *value; + + data = (struct scsi_log_temperature *)page_index->page_data; + + scsi_ulto2b(SLP_TEMPERATURE, data->hdr.param_code); + data->hdr.param_control = SLP_LBIN; + data->hdr.param_len = sizeof(struct scsi_log_temperature) - + sizeof(struct scsi_log_param_header); + if ((value = dnvlist_get_string(lun->be_lun->options, "temperature", + NULL)) != NULL) + data->temperature = strtol(value, NULL, 0); + else + data->temperature = 0xff; + data++; + + scsi_ulto2b(SLP_REFTEMPERATURE, data->hdr.param_code); + data->hdr.param_control = SLP_LBIN; + data->hdr.param_len = sizeof(struct scsi_log_temperature) - + sizeof(struct scsi_log_param_header); + if ((value = dnvlist_get_string(lun->be_lun->options, "reftemperature", + NULL)) != NULL) + data->temperature = strtol(value, NULL, 0); + else + data->temperature = 0xff; + return (0); +} + +int ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, int pc) @@ -6802,6 +6838,7 @@ ctl_ie_log_sense_handler(struct ctl_scsiio *ctsio, { struct ctl_lun *lun = CTL_LUN(ctsio); struct scsi_log_informational_exceptions *data; + const char *value; data = (struct scsi_log_informational_exceptions *)page_index->page_data; @@ -6811,7 +6848,11 @@ ctl_ie_log_sense_handler(struct ctl_scsiio *ctsio, sizeof(struct scsi_log_param_header); data->ie_asc = lun->ie_asc; data->ie_ascq = lun->ie_ascq; - data->temperature = 0xff; + if ((value = dnvlist_get_string(lun->be_lun->options, "temperature", + NULL)) != NULL) + data->temperature = strtol(value, NULL, 0); + else + data->temperature = 0xff; return (0); } Modified: head/sys/cam/ctl/ctl.h ============================================================================== --- head/sys/cam/ctl/ctl.h Fri Jul 26 02:49:34 2019 (r350345) +++ head/sys/cam/ctl/ctl.h Fri Jul 26 03:49:16 2019 (r350346) @@ -158,6 +158,9 @@ int ctl_default_page_handler(struct ctl_scsiio *ctsio, int ctl_ie_page_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, uint8_t *page_ptr); +int ctl_temp_log_sense_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, + int pc); int ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, int pc); Modified: head/sys/cam/ctl/ctl_private.h ============================================================================== --- head/sys/cam/ctl/ctl_private.h Fri Jul 26 02:49:34 2019 (r350345) +++ head/sys/cam/ctl/ctl_private.h Fri Jul 26 03:49:16 2019 (r350346) @@ -331,6 +331,8 @@ static const struct ctl_page_index log_page_index_temp CTL_PAGE_FLAG_ALL, NULL, NULL}, {SLS_SUPPORTED_PAGES_PAGE, SLS_SUPPORTED_SUBPAGES_SUBPAGE, 0, NULL, CTL_PAGE_FLAG_ALL, NULL, NULL}, + {SLS_TEMPERATURE, 0, 0, NULL, + CTL_PAGE_FLAG_DIRECT, ctl_temp_log_sense_handler, NULL}, {SLS_LOGICAL_BLOCK_PROVISIONING, 0, 0, NULL, CTL_PAGE_FLAG_DIRECT, ctl_lbp_log_sense_handler, NULL}, {SLS_STAT_AND_PERF, 0, 0, NULL, @@ -351,6 +353,7 @@ struct ctl_log_pages { struct scsi_log_idle_time it; struct scsi_log_time_interval ti; } stat_page; + struct scsi_log_temperature temp_page[2]; struct scsi_log_informational_exceptions ie_page; struct ctl_page_index index[CTL_NUM_LOG_PAGES]; }; Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Fri Jul 26 02:49:34 2019 (r350345) +++ head/sys/cam/scsi/scsi_all.h Fri Jul 26 03:49:16 2019 (r350346) @@ -568,6 +568,7 @@ struct scsi_log_sense #define SLS_ERROR_NONMEDIUM_PAGE 0x06 #define SLS_ERROR_LASTN_PAGE 0x07 #define SLS_LOGICAL_BLOCK_PROVISIONING 0x0c +#define SLS_TEMPERATURE 0x0d #define SLS_SELF_TEST_PAGE 0x10 #define SLS_SOLID_STATE_MEDIA 0x11 #define SLS_STAT_AND_PERF 0x19 @@ -680,6 +681,14 @@ struct scsi_log_informational_exceptions { #define SLP_IE_GEN 0x0000 uint8_t ie_asc; uint8_t ie_ascq; + uint8_t temperature; +}; + +struct scsi_log_temperature { + struct scsi_log_param_header hdr; +#define SLP_TEMPERATURE 0x0000 +#define SLP_REFTEMPERATURE 0x0001 + uint8_t reserved; uint8_t temperature; }; Modified: head/usr.sbin/ctladm/ctladm.8 ============================================================================== --- head/usr.sbin/ctladm/ctladm.8 Fri Jul 26 02:49:34 2019 (r350345) +++ head/usr.sbin/ctladm/ctladm.8 Fri Jul 26 03:49:16 2019 (r350346) @@ -36,7 +36,7 @@ .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $ .\" $FreeBSD$ .\" -.Dd May 10, 2018 +.Dd July 25, 2019 .Dt CTLADM 8 .Os .Sh NAME @@ -918,6 +918,9 @@ Specifies medium rotation rate of the device: 0 -- not .It Va formfactor Specifies nominal form factor of the device: 0 -- not reported, 1 -- 5.25", 2 -- 3.5", 3 -- 2.5", 4 -- 1.8", 5 -- less then 1.8". +.It Va temperature +.It Va reftemperature +Specify current and reference (maximum) temperatures of the device. .It Va provisioning_type When UNMAP support is enabled, this option specifies provisioning type: "resource", "thin" or "unknown".