diff options
author | smh <smh@FreeBSD.org> | 2013-04-26 16:11:03 +0000 |
---|---|---|
committer | smh <smh@FreeBSD.org> | 2013-04-26 16:11:03 +0000 |
commit | 2b4c1ee5e0d30d6e81f0475b0bf31a6bcddff76e (patch) | |
tree | 6251a4ff9de81161ae0008ff6b453977709315e8 /sys/cam | |
parent | 20b03102b8959f50b443a894c34031c7dd6dcf8d (diff) | |
download | FreeBSD-src-2b4c1ee5e0d30d6e81f0475b0bf31a6bcddff76e.zip FreeBSD-src-2b4c1ee5e0d30d6e81f0475b0bf31a6bcddff76e.tar.gz |
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
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/scsi/scsi_all.c | 33 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_all.h | 2 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_xpt.c | 22 |
3 files changed, 36 insertions, 21 deletions
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c index e206edf..016aef2 100644 --- a/sys/cam/scsi/scsi_all.c +++ b/sys/cam/scsi/scsi_all.c @@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/libkern.h> #include <sys/kernel.h> +#include <sys/lock.h> +#include <sys/malloc.h> +#include <sys/mutex.h> #include <sys/sysctl.h> #else #include <errno.h> @@ -55,7 +58,13 @@ __FBSDID("$FreeBSD$"); #include <cam/scsi/scsi_all.h> #include <sys/ata.h> #include <sys/sbuf.h> -#ifndef _KERNEL + +#ifdef _KERNEL +#include <cam/cam_periph.h> +#include <cam/cam_xpt_sim.h> +#include <cam/cam_xpt_periph.h> +#include <cam/cam_xpt_internal.h> +#else #include <camlib.h> #include <stddef.h> @@ -6257,6 +6266,28 @@ scsi_devid_match(uint8_t *lhs, size_t lhs_len, uint8_t *rhs, size_t rhs_len) } #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) { diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h index d2872a0..1071a56 100644 --- a/sys/cam/scsi/scsi_all.h +++ b/sys/cam/scsi/scsi_all.h @@ -2258,6 +2258,8 @@ int scsi_sense_sbuf(struct ccb_scsiio *csio, struct sbuf *sb, 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); diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index fb2f584..f94deff 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -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); |