Lines Matching refs:buf
28 static void spc_fill_alua_data(struct se_lun *lun, unsigned char *buf) in spc_fill_alua_data() argument
35 buf[5] = 0x80; in spc_fill_alua_data()
46 buf[5] |= tg_pt_gp->tg_pt_gp_alua_access_type; in spc_fill_alua_data()
51 spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_inquiry_std() argument
59 buf[1] = 0x80; in spc_emulate_inquiry_std()
61 buf[2] = 0x05; /* SPC-3 */ in spc_emulate_inquiry_std()
73 buf[3] = 2; in spc_emulate_inquiry_std()
78 spc_fill_alua_data(lun, buf); in spc_emulate_inquiry_std()
84 buf[5] |= 0x8; in spc_emulate_inquiry_std()
93 buf[5] |= 0x1; in spc_emulate_inquiry_std()
96 buf[7] = 0x2; /* CmdQue=1 */ in spc_emulate_inquiry_std()
103 memset(&buf[8], 0x20, in spc_emulate_inquiry_std()
105 memcpy(&buf[8], dev->t10_wwn.vendor, in spc_emulate_inquiry_std()
107 memcpy(&buf[16], dev->t10_wwn.model, in spc_emulate_inquiry_std()
109 memcpy(&buf[32], dev->t10_wwn.revision, in spc_emulate_inquiry_std()
111 buf[4] = 31; /* Set additional length to 31 */ in spc_emulate_inquiry_std()
119 spc_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_80() argument
125 len = sprintf(&buf[4], "%s", dev->t10_wwn.unit_serial); in spc_emulate_evpd_80()
127 buf[3] = len; in spc_emulate_evpd_80()
133 unsigned char *buf) in spc_parse_naa_6h_vendor_specific() argument
155 buf[cnt++] |= val; in spc_parse_naa_6h_vendor_specific()
158 buf[cnt] = val << 4; in spc_parse_naa_6h_vendor_specific()
168 spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_83() argument
194 buf[off++] = 0x1; in spc_emulate_evpd_83()
197 buf[off] = 0x00; in spc_emulate_evpd_83()
200 buf[off++] |= 0x3; in spc_emulate_evpd_83()
204 buf[off++] = 0x10; in spc_emulate_evpd_83()
209 buf[off++] = (0x6 << 4); in spc_emulate_evpd_83()
214 buf[off++] = 0x01; in spc_emulate_evpd_83()
215 buf[off++] = 0x40; in spc_emulate_evpd_83()
216 buf[off] = (0x5 << 4); in spc_emulate_evpd_83()
223 spc_parse_naa_6h_vendor_specific(dev, &buf[off]); in spc_emulate_evpd_83()
242 id_len += sprintf(&buf[off+12], "%s:%s", prod, in spc_emulate_evpd_83()
245 buf[off] = 0x2; /* ASCII */ in spc_emulate_evpd_83()
246 buf[off+1] = 0x1; /* T10 Vendor ID */ in spc_emulate_evpd_83()
247 buf[off+2] = 0x0; in spc_emulate_evpd_83()
249 memset(&buf[off+4], 0x20, INQUIRY_VENDOR_LEN); in spc_emulate_evpd_83()
250 memcpy(&buf[off+4], dev->t10_wwn.vendor, in spc_emulate_evpd_83()
255 buf[off+3] = id_len; in spc_emulate_evpd_83()
275 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
276 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
277 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
279 buf[off] |= 0x10; in spc_emulate_evpd_83()
281 buf[off++] |= 0x4; in spc_emulate_evpd_83()
283 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
287 put_unaligned_be16(lun->lun_rtpi, &buf[off]); in spc_emulate_evpd_83()
306 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
307 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
308 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
310 buf[off] |= 0x10; in spc_emulate_evpd_83()
312 buf[off++] |= 0x5; in spc_emulate_evpd_83()
314 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
316 put_unaligned_be16(tg_pt_gp_id, &buf[off]); in spc_emulate_evpd_83()
337 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
339 buf[off++] |= 0x6; in spc_emulate_evpd_83()
341 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
343 put_unaligned_be16(lu_gp_id, &buf[off]); in spc_emulate_evpd_83()
354 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
355 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
356 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
358 buf[off] |= 0x10; in spc_emulate_evpd_83()
360 buf[off++] |= 0x8; in spc_emulate_evpd_83()
369 scsi_name_len = sprintf(&buf[off], "%s,t,0x%04x", in spc_emulate_evpd_83()
386 buf[off-1] = scsi_name_len; in spc_emulate_evpd_83()
394 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
395 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
396 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
398 buf[off] |= 0x20; in spc_emulate_evpd_83()
400 buf[off++] |= 0x8; in spc_emulate_evpd_83()
408 scsi_target_len = sprintf(&buf[off], "%s", in spc_emulate_evpd_83()
425 buf[off-1] = scsi_target_len; in spc_emulate_evpd_83()
431 put_unaligned_be16(len, &buf[2]); /* Page Length for VPD 0x83 */ in spc_emulate_evpd_83()
438 spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_86() argument
443 buf[3] = 0x3c; in spc_emulate_evpd_86()
451 buf[4] = 0x5; in spc_emulate_evpd_86()
454 buf[4] = 0x4; in spc_emulate_evpd_86()
461 buf[4] |= (0x3 << 3); in spc_emulate_evpd_86()
465 buf[5] = 0x07; in spc_emulate_evpd_86()
469 buf[6] = 0x01; in spc_emulate_evpd_86()
473 buf[8] = 0x10; in spc_emulate_evpd_86()
480 spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b0() argument
494 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b0()
495 buf[3] = have_tp ? 0x3c : 0x10; in spc_emulate_evpd_b0()
498 buf[4] = 0x01; in spc_emulate_evpd_b0()
503 buf[5] = 0x01; in spc_emulate_evpd_b0()
509 put_unaligned_be16(min / dev->dev_attrib.block_size, &buf[6]); in spc_emulate_evpd_b0()
511 put_unaligned_be16(1, &buf[6]); in spc_emulate_evpd_b0()
523 put_unaligned_be32(min_not_zero(mtl, dev->dev_attrib.hw_max_sectors), &buf[8]); in spc_emulate_evpd_b0()
529 put_unaligned_be32(opt / dev->dev_attrib.block_size, &buf[12]); in spc_emulate_evpd_b0()
531 put_unaligned_be32(dev->dev_attrib.optimal_sectors, &buf[12]); in spc_emulate_evpd_b0()
542 put_unaligned_be32(dev->dev_attrib.max_unmap_lba_count, &buf[20]); in spc_emulate_evpd_b0()
548 &buf[24]); in spc_emulate_evpd_b0()
553 put_unaligned_be32(dev->dev_attrib.unmap_granularity, &buf[28]); in spc_emulate_evpd_b0()
559 &buf[32]); in spc_emulate_evpd_b0()
561 buf[32] |= 0x80; /* Set the UGAVALID bit */ in spc_emulate_evpd_b0()
567 put_unaligned_be64(dev->dev_attrib.max_write_same_len, &buf[36]); in spc_emulate_evpd_b0()
574 spc_emulate_evpd_b1(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b1() argument
578 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b1()
579 buf[3] = 0x3c; in spc_emulate_evpd_b1()
580 buf[5] = dev->dev_attrib.is_nonrot ? 1 : 0; in spc_emulate_evpd_b1()
587 spc_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b2() argument
599 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b2()
604 put_unaligned_be16(0x0004, &buf[2]); in spc_emulate_evpd_b2()
615 buf[4] = 0x00; in spc_emulate_evpd_b2()
623 buf[5] = 0x80; in spc_emulate_evpd_b2()
632 buf[5] |= 0x40 | 0x20; in spc_emulate_evpd_b2()
644 buf[5] |= 0x04; in spc_emulate_evpd_b2()
651 spc_emulate_evpd_b3(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b3() argument
655 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b3()
656 buf[3] = 0x0c; in spc_emulate_evpd_b3()
657 put_unaligned_be32(dev->t10_alua.lba_map_segment_size, &buf[8]); in spc_emulate_evpd_b3()
658 put_unaligned_be32(dev->t10_alua.lba_map_segment_multiplier, &buf[12]); in spc_emulate_evpd_b3()
664 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf);
682 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_00() argument
692 buf[3] = ARRAY_SIZE(evpd_handlers); in spc_emulate_evpd_00()
694 buf[p + 4] = evpd_handlers[p].page; in spc_emulate_evpd_00()
707 unsigned char *buf; in spc_emulate_inquiry() local
712 buf = kzalloc(SE_INQUIRY_BUF, GFP_KERNEL); in spc_emulate_inquiry()
713 if (!buf) { in spc_emulate_inquiry()
719 buf[0] = 0x3f; /* Not connected */ in spc_emulate_inquiry()
721 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_inquiry()
731 ret = spc_emulate_inquiry_std(cmd, buf); in spc_emulate_inquiry()
732 len = buf[4] + 5; in spc_emulate_inquiry()
738 buf[1] = cdb[2]; in spc_emulate_inquiry()
739 ret = evpd_handlers[p].emulate(cmd, buf); in spc_emulate_inquiry()
740 len = get_unaligned_be16(&buf[2]) + 4; in spc_emulate_inquiry()
751 memcpy(rbuf, buf, min_t(u32, SE_INQUIRY_BUF, cmd->data_length)); in spc_emulate_inquiry()
754 kfree(buf); in spc_emulate_inquiry()
940 static void spc_modesense_write_protect(unsigned char *buf, int type) in spc_modesense_write_protect() argument
950 buf[0] |= 0x80; /* WP bit */ in spc_modesense_write_protect()
955 static void spc_modesense_dpofua(unsigned char *buf, int type) in spc_modesense_dpofua() argument
959 buf[0] |= 0x10; /* DPOFUA bit */ in spc_modesense_dpofua()
966 static int spc_modesense_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_blockdesc() argument
968 *buf++ = 8; in spc_modesense_blockdesc()
969 put_unaligned_be32(min(blocks, 0xffffffffull), buf); in spc_modesense_blockdesc()
970 buf += 4; in spc_modesense_blockdesc()
971 put_unaligned_be32(block_size, buf); in spc_modesense_blockdesc()
975 static int spc_modesense_long_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_long_blockdesc() argument
978 return spc_modesense_blockdesc(buf + 3, blocks, block_size) + 3; in spc_modesense_long_blockdesc()
980 *buf++ = 1; /* LONGLBA */ in spc_modesense_long_blockdesc()
981 buf += 2; in spc_modesense_long_blockdesc()
982 *buf++ = 16; in spc_modesense_long_blockdesc()
983 put_unaligned_be64(blocks, buf); in spc_modesense_long_blockdesc()
984 buf += 12; in spc_modesense_long_blockdesc()
985 put_unaligned_be32(block_size, buf); in spc_modesense_long_blockdesc()
994 unsigned char buf[SE_MODE_PAGE_BUF], *rbuf; in spc_emulate_modesense() local
1006 memset(buf, 0, SE_MODE_PAGE_BUF); in spc_emulate_modesense()
1016 spc_modesense_write_protect(&buf[length], type); in spc_emulate_modesense()
1024 spc_modesense_dpofua(&buf[length], type); in spc_emulate_modesense()
1040 length += spc_modesense_long_blockdesc(&buf[length], in spc_emulate_modesense()
1044 length += spc_modesense_blockdesc(&buf[length], in spc_emulate_modesense()
1048 length += spc_modesense_blockdesc(&buf[length], blocks, in spc_emulate_modesense()
1072 ret = modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1085 length += modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1101 put_unaligned_be16(length - 2, buf); in spc_emulate_modesense()
1103 buf[0] = length - 1; in spc_emulate_modesense()
1107 memcpy(rbuf, buf, min_t(u32, SE_MODE_PAGE_BUF, cmd->data_length)); in spc_emulate_modesense()
1122 unsigned char *buf; in spc_emulate_modeselect() local
1136 buf = transport_kmap_data_sg(cmd); in spc_emulate_modeselect()
1137 if (!buf) in spc_emulate_modeselect()
1145 page = buf[off] & 0x3f; in spc_emulate_modeselect()
1146 subpage = buf[off] & 0x40 ? buf[off + 1] : 0; in spc_emulate_modeselect()
1165 if (memcmp(buf + off, tbuf, length)) in spc_emulate_modeselect()
1181 unsigned char buf[SE_SENSE_BUF]; in spc_emulate_request_sense() local
1184 memset(buf, 0, SE_SENSE_BUF); in spc_emulate_request_sense()
1197 scsi_build_sense_buffer(desc_format, buf, UNIT_ATTENTION, in spc_emulate_request_sense()
1200 scsi_build_sense_buffer(desc_format, buf, NO_SENSE, 0x0, 0x0); in spc_emulate_request_sense()
1202 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); in spc_emulate_request_sense()
1215 unsigned char *buf; in spc_emulate_report_luns() local
1219 buf = transport_kmap_data_sg(cmd); in spc_emulate_report_luns()
1220 if (cmd->data_length && !buf) in spc_emulate_report_luns()
1245 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1261 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1266 if (buf) { in spc_emulate_report_luns()
1268 memcpy(buf, &len, min_t(int, sizeof len, cmd->data_length)); in spc_emulate_report_luns()