From owner-svn-src-all@FreeBSD.ORG Fri Apr 26 16:11:04 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C0113113; Fri, 26 Apr 2013 16:11:04 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B2B6C10DB; Fri, 26 Apr 2013 16:11:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3QGB4At047145; Fri, 26 Apr 2013 16:11:04 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3QGB4qj047141; Fri, 26 Apr 2013 16:11:04 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201304261611.r3QGB4qj047141@svn.freebsd.org> From: Steven Hartland Date: Fri, 26 Apr 2013 16:11:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249937 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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 Apr 2013 16:11:04 -0000 Author: smh Date: Fri Apr 26 16:11:03 2013 New Revision: 249937 URL: http://svnweb.freebsd.org/changeset/base/249937 Log: Refactored scsi_xpt use of device_has_vpd to generic scsi_vpd_supported_page so its available for use in generic scsi code. This is a pre-requirement for using VPD queries to determine available SCSI delete methods within scsi_da. Reviewed by: mav Approved by: pjd (mentor) MFC after: 2 weeks Modified: head/sys/cam/scsi/scsi_all.c head/sys/cam/scsi/scsi_all.h head/sys/cam/scsi/scsi_xpt.c Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Fri Apr 26 16:09:10 2013 (r249936) +++ head/sys/cam/scsi/scsi_all.c Fri Apr 26 16:11:03 2013 (r249937) @@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #else #include @@ -55,7 +58,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifndef _KERNEL + +#ifdef _KERNEL +#include +#include +#include +#include +#else #include #include @@ -6257,6 +6266,28 @@ scsi_devid_match(uint8_t *lhs, size_t lh } #ifdef _KERNEL +int +scsi_vpd_supported_page(struct cam_periph *periph, uint8_t page_id) +{ + struct cam_ed *device; + struct scsi_vpd_supported_pages *vpds; + int i, num_pages; + + device = periph->path->device; + vpds = (struct scsi_vpd_supported_pages *)device->supported_vpds; + + if (vpds != NULL) { + num_pages = device->supported_vpds_len - + SVPD_SUPPORTED_PAGES_HDR_LEN; + for (i = 0; i < num_pages; i++) { + if (vpds->page_list[i] == page_id) + return (1); + } + } + + return (0); +} + static void init_scsi_delay(void) { Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Fri Apr 26 16:09:10 2013 (r249936) +++ head/sys/cam/scsi/scsi_all.h Fri Apr 26 16:11:03 2013 (r249937) @@ -2258,6 +2258,8 @@ int scsi_sense_sbuf(struct ccb_scsiio * char * scsi_sense_string(struct ccb_scsiio *csio, char *str, int str_len); void scsi_sense_print(struct ccb_scsiio *csio); +int scsi_vpd_supported_page(struct cam_periph *periph, + uint8_t page_id); #else /* _KERNEL */ int scsi_command_string(struct cam_device *device, struct ccb_scsiio *csio, struct sbuf *sb); Modified: head/sys/cam/scsi/scsi_xpt.c ============================================================================== --- head/sys/cam/scsi/scsi_xpt.c Fri Apr 26 16:09:10 2013 (r249936) +++ head/sys/cam/scsi/scsi_xpt.c Fri Apr 26 16:11:03 2013 (r249937) @@ -556,7 +556,6 @@ static const int scsi_quirk_table_size = static cam_status proberegister(struct cam_periph *periph, void *arg); static void probeschedule(struct cam_periph *probe_periph); -static int device_has_vpd(struct cam_ed *device, uint8_t page_id); static void probestart(struct cam_periph *periph, union ccb *start_ccb); static void proberequestdefaultnegotiation(struct cam_periph *periph); static int proberequestbackoff(struct cam_periph *periph, @@ -703,21 +702,6 @@ probeschedule(struct cam_periph *periph) xpt_schedule(periph, CAM_PRIORITY_XPT); } -static int -device_has_vpd(struct cam_ed *device, uint8_t page_id) -{ - int i, num_pages; - struct scsi_vpd_supported_pages *vpds; - - vpds = (struct scsi_vpd_supported_pages *)device->supported_vpds; - num_pages = device->supported_vpds_len - SVPD_SUPPORTED_PAGES_HDR_LEN; - for (i = 0;i < num_pages;i++) - if (vpds->page_list[i] == page_id) - return 1; - - return 0; -} - static void probestart(struct cam_periph *periph, union ccb *start_ccb) { @@ -905,11 +889,9 @@ again: case PROBE_DEVICE_ID: { struct scsi_vpd_device_id *devid; - struct cam_ed *device; devid = NULL; - device = periph->path->device; - if (device_has_vpd(device, SVPD_DEVICE_ID)) + if (scsi_vpd_supported_page(periph, SVPD_DEVICE_ID)) devid = malloc(SVPD_DEVICE_ID_MAX_SIZE, M_CAMXPT, M_NOWAIT | M_ZERO); @@ -947,7 +929,7 @@ again: device->serial_num_len = 0; } - if (device_has_vpd(device, SVPD_UNIT_SERIAL_NUMBER)) + if (scsi_vpd_supported_page(periph, SVPD_UNIT_SERIAL_NUMBER)) serial_buf = (struct scsi_vpd_unit_serial_number *) malloc(sizeof(*serial_buf), M_CAMXPT, M_NOWAIT|M_ZERO);