Lines Matching refs:dev_scsi

85 static int do_scsi_page80_inquiry(struct scsi_id_device *dev_scsi, int fd,
150 static int scsi_dump_sense(struct scsi_id_device *dev_scsi, in scsi_dump_sense() argument
173 dev_scsi->kernel); in scsi_dump_sense()
186 dev_scsi->kernel, sb_len, in scsi_dump_sense()
197 dev_scsi->kernel, s); in scsi_dump_sense()
208 dev_scsi->kernel, code); in scsi_dump_sense()
211 dev_scsi->kernel, sense_key, asc, ascq); in scsi_dump_sense()
216 dev_scsi->kernel, sb_len, in scsi_dump_sense()
220 … log_debug("%s: old sense key: 0x%x", dev_scsi->kernel, sense_buffer[0] & 0x0f); in scsi_dump_sense()
223 dev_scsi->kernel, sense_buffer[0], sense_buffer[2]); in scsi_dump_sense()
225 dev_scsi->kernel, sense_class, code); in scsi_dump_sense()
232 static int scsi_dump(struct scsi_id_device *dev_scsi, struct sg_io_hdr *io) { in scsi_dump() argument
243 dev_scsi->kernel, io->driver_status, io->host_status, io->msg_status, io->status); in scsi_dump()
245 return scsi_dump_sense(dev_scsi, io->sbp, io->sb_len_wr); in scsi_dump()
250 static int scsi_dump_v4(struct scsi_id_device *dev_scsi, struct sg_io_v4 *io) { in scsi_dump_v4() argument
261 dev_scsi->kernel, io->driver_status, io->transport_status, io->device_status); in scsi_dump_v4()
263 return scsi_dump_sense(dev_scsi, (unsigned char *)(uintptr_t)io->response, in scsi_dump_v4()
269 static int scsi_inquiry(struct scsi_id_device *dev_scsi, int fd, in scsi_inquiry() argument
286 if (dev_scsi->use_sg == 4) { in scsi_inquiry()
314 if (IN_SET(errno, EINVAL, ENOSYS) && dev_scsi->use_sg == 4) { in scsi_inquiry()
315 dev_scsi->use_sg = 3; in scsi_inquiry()
318 log_debug_errno(errno, "%s: ioctl failed: %m", dev_scsi->kernel); in scsi_inquiry()
322 if (dev_scsi->use_sg == 4) in scsi_inquiry()
337 if (dev_scsi->use_sg == 4) in scsi_inquiry()
338 retval = scsi_dump_v4(dev_scsi, io_buf); in scsi_inquiry()
340 retval = scsi_dump(dev_scsi, io_buf); in scsi_inquiry()
354 dev_scsi->kernel, evpd, page); in scsi_inquiry()
360 static int do_scsi_page0_inquiry(struct scsi_id_device *dev_scsi, int fd, in do_scsi_page0_inquiry() argument
365 retval = scsi_inquiry(dev_scsi, fd, 1, 0x0, buffer, len); in do_scsi_page0_inquiry()
370 log_debug("%s: page 0 not available.", dev_scsi->kernel); in do_scsi_page0_inquiry()
374 log_debug("%s: page 0 buffer too long %d", dev_scsi->kernel, buffer[3]); in do_scsi_page0_inquiry()
390 if (strneq((char*) buffer + VENDOR_LENGTH, dev_scsi->vendor, VENDOR_LENGTH)) { in do_scsi_page0_inquiry()
391 log_debug("%s: invalid page0 data", dev_scsi->kernel); in do_scsi_page0_inquiry()
399 const struct scsi_id_device *dev_scsi, in append_vendor_model() argument
402 assert(dev_scsi); in append_vendor_model()
405 if (strnlen(dev_scsi->vendor, VENDOR_LENGTH) != VENDOR_LENGTH) in append_vendor_model()
408 dev_scsi->kernel, dev_scsi->vendor); in append_vendor_model()
409 if (strnlen(dev_scsi->model, MODEL_LENGTH) != MODEL_LENGTH) in append_vendor_model()
412 dev_scsi->kernel, dev_scsi->model); in append_vendor_model()
413 memcpy(buf, dev_scsi->vendor, VENDOR_LENGTH); in append_vendor_model()
414 memcpy(buf + VENDOR_LENGTH, dev_scsi->model, MODEL_LENGTH); in append_vendor_model()
422 static int check_fill_0x83_id(struct scsi_id_device *dev_scsi, in check_fill_0x83_id() argument
475 dev_scsi->kernel, max_len, len); in check_fill_0x83_id()
496 if (append_vendor_model(dev_scsi, serial + 1) < 0) in check_fill_0x83_id()
531 static int check_fill_0x83_prespc3(struct scsi_id_device *dev_scsi, in check_fill_0x83_prespc3() argument
551 static int do_scsi_page83_inquiry(struct scsi_id_device *dev_scsi, int fd, in do_scsi_page83_inquiry() argument
560 do_scsi_page80_inquiry(dev_scsi, fd, NULL, unit_serial_number, MAX_SERIAL_LEN); in do_scsi_page83_inquiry()
563 retval = scsi_inquiry(dev_scsi, fd, 1, PAGE_83, page_83, in do_scsi_page83_inquiry()
569 log_debug("%s: Invalid page 0x83", dev_scsi->kernel); in do_scsi_page83_inquiry()
603 return check_fill_0x83_prespc3(dev_scsi, page_83, id_search_list, in do_scsi_page83_inquiry()
618 retval = check_fill_0x83_id(dev_scsi, page_83 + j, in do_scsi_page83_inquiry()
639 static int do_scsi_page83_prespc3_inquiry(struct scsi_id_device *dev_scsi, int fd, in do_scsi_page83_prespc3_inquiry() argument
646 retval = scsi_inquiry(dev_scsi, fd, 1, PAGE_83, page_83, SCSI_INQ_BUFF_LEN); in do_scsi_page83_prespc3_inquiry()
651 log_debug("%s: Invalid page 0x83", dev_scsi->kernel); in do_scsi_page83_prespc3_inquiry()
699 static int do_scsi_page80_inquiry(struct scsi_id_device *dev_scsi, int fd, in do_scsi_page80_inquiry() argument
708 retval = scsi_inquiry(dev_scsi, fd, 1, PAGE_80, buf, SCSI_INQ_BUFF_LEN); in do_scsi_page80_inquiry()
713 log_debug("%s: Invalid page 0x80", dev_scsi->kernel); in do_scsi_page80_inquiry()
720 dev_scsi->kernel, max_len, len); in do_scsi_page80_inquiry()
730 ser_ind = append_vendor_model(dev_scsi, serial + 1); in do_scsi_page80_inquiry()
744 int scsi_std_inquiry(struct scsi_id_device *dev_scsi, const char *devname) { in scsi_std_inquiry() argument
761 sprintf(dev_scsi->kernel,"%d:%d", major(statbuf.st_rdev), in scsi_std_inquiry()
765 err = scsi_inquiry(dev_scsi, fd, 0, 0, buf, SCSI_INQ_BUFF_LEN); in scsi_std_inquiry()
770 memcpy(dev_scsi->vendor, buf + 8, 8); in scsi_std_inquiry()
771 dev_scsi->vendor[8] = '\0'; in scsi_std_inquiry()
772 memcpy(dev_scsi->model, buf + 16, 16); in scsi_std_inquiry()
773 dev_scsi->model[16] = '\0'; in scsi_std_inquiry()
774 memcpy(dev_scsi->revision, buf + 32, 4); in scsi_std_inquiry()
775 dev_scsi->revision[4] = '\0'; in scsi_std_inquiry()
776 dev_scsi->type = buf[0] & 0x1f; in scsi_std_inquiry()
783 int scsi_get_serial(struct scsi_id_device *dev_scsi, const char *devname, in scsi_get_serial() argument
791 memzero(dev_scsi->serial, len); in scsi_get_serial()
807 … if (do_scsi_page80_inquiry(dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len)) { in scsi_get_serial()
815 …ry(dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_… in scsi_get_serial()
823 …retval = do_scsi_page83_prespc3_inquiry(dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, le… in scsi_get_serial()
831 …ry(dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_… in scsi_get_serial()
848 log_debug("%s: unsupported page code 0x%d", dev_scsi->kernel, page_code); in scsi_get_serial()
857 if (do_scsi_page0_inquiry(dev_scsi, fd, page0, SCSI_INQ_BUFF_LEN)) { in scsi_get_serial()
869 if (!do_scsi_page83_inquiry(dev_scsi, fd, in scsi_get_serial()
870dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_sc… in scsi_get_serial()
880 if (!do_scsi_page80_inquiry(dev_scsi, fd, in scsi_get_serial()
881dev_scsi->serial, dev_scsi->serial_short, len)) { in scsi_get_serial()