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()
72 spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_inquiry_std() argument
81 buf[1] = 0x80; in spc_emulate_inquiry_std()
83 buf[2] = 0x06; /* SPC-4 */ in spc_emulate_inquiry_std()
95 buf[3] = 2; in spc_emulate_inquiry_std()
100 spc_fill_alua_data(lun, buf); in spc_emulate_inquiry_std()
106 buf[5] |= 0x8; in spc_emulate_inquiry_std()
115 buf[5] |= 0x1; in spc_emulate_inquiry_std()
122 buf[6] |= 0x10; in spc_emulate_inquiry_std()
124 buf[7] = 0x2; /* CmdQue=1 */ in spc_emulate_inquiry_std()
131 memset(&buf[8], 0x20, in spc_emulate_inquiry_std()
133 memcpy(&buf[8], dev->t10_wwn.vendor, in spc_emulate_inquiry_std()
135 memcpy(&buf[16], dev->t10_wwn.model, in spc_emulate_inquiry_std()
137 memcpy(&buf[32], dev->t10_wwn.revision, in spc_emulate_inquiry_std()
143 put_unaligned_be16(SCSI_VERSION_DESCRIPTOR_SAM5, &buf[58]); in spc_emulate_inquiry_std()
144 put_unaligned_be16(spc_find_scsi_transport_vd(tpg->proto_id), &buf[60]); in spc_emulate_inquiry_std()
145 put_unaligned_be16(SCSI_VERSION_DESCRIPTOR_SPC4, &buf[62]); in spc_emulate_inquiry_std()
147 put_unaligned_be16(SCSI_VERSION_DESCRIPTOR_SBC3, &buf[64]); in spc_emulate_inquiry_std()
149 buf[4] = 91; /* Set additional length to 91 */ in spc_emulate_inquiry_std()
157 spc_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_80() argument
163 len = sprintf(&buf[4], "%s", dev->t10_wwn.unit_serial); in spc_emulate_evpd_80()
165 buf[3] = len; in spc_emulate_evpd_80()
174 unsigned char *buf) in spc_gen_naa_6h_vendor_specific() argument
184 buf[off] = 0x6 << 4; in spc_gen_naa_6h_vendor_specific()
187 buf[off++] |= (company_id >> 20) & 0xf; in spc_gen_naa_6h_vendor_specific()
188 buf[off++] = (company_id >> 12) & 0xff; in spc_gen_naa_6h_vendor_specific()
189 buf[off++] = (company_id >> 4) & 0xff; in spc_gen_naa_6h_vendor_specific()
190 buf[off] = (company_id & 0xf) << 4; in spc_gen_naa_6h_vendor_specific()
208 buf[off++] |= val; in spc_gen_naa_6h_vendor_specific()
211 buf[off] = val << 4; in spc_gen_naa_6h_vendor_specific()
221 spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_83() argument
247 buf[off++] = 0x1; in spc_emulate_evpd_83()
250 buf[off] = 0x00; in spc_emulate_evpd_83()
253 buf[off++] |= 0x3; in spc_emulate_evpd_83()
257 buf[off++] = 0x10; in spc_emulate_evpd_83()
260 spc_gen_naa_6h_vendor_specific(dev, &buf[off]); in spc_emulate_evpd_83()
279 id_len += sprintf(&buf[off+12], "%s:%s", prod, in spc_emulate_evpd_83()
282 buf[off] = 0x2; /* ASCII */ in spc_emulate_evpd_83()
283 buf[off+1] = 0x1; /* T10 Vendor ID */ in spc_emulate_evpd_83()
284 buf[off+2] = 0x0; in spc_emulate_evpd_83()
286 memset(&buf[off+4], 0x20, INQUIRY_VENDOR_LEN); in spc_emulate_evpd_83()
287 memcpy(&buf[off+4], dev->t10_wwn.vendor, in spc_emulate_evpd_83()
292 buf[off+3] = id_len; in spc_emulate_evpd_83()
312 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
313 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
314 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
316 buf[off] |= 0x10; in spc_emulate_evpd_83()
318 buf[off++] |= 0x4; in spc_emulate_evpd_83()
320 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
324 put_unaligned_be16(lun->lun_rtpi, &buf[off]); in spc_emulate_evpd_83()
343 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
344 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
345 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
347 buf[off] |= 0x10; in spc_emulate_evpd_83()
349 buf[off++] |= 0x5; in spc_emulate_evpd_83()
351 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
353 put_unaligned_be16(tg_pt_gp_id, &buf[off]); in spc_emulate_evpd_83()
374 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
376 buf[off++] |= 0x6; in spc_emulate_evpd_83()
378 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
380 put_unaligned_be16(lu_gp_id, &buf[off]); in spc_emulate_evpd_83()
391 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
392 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
393 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
395 buf[off] |= 0x10; in spc_emulate_evpd_83()
397 buf[off++] |= 0x8; in spc_emulate_evpd_83()
406 scsi_name_len = sprintf(&buf[off], "%s,t,0x%04x", in spc_emulate_evpd_83()
423 buf[off-1] = scsi_name_len; in spc_emulate_evpd_83()
431 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
432 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
433 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
435 buf[off] |= 0x20; in spc_emulate_evpd_83()
437 buf[off++] |= 0x8; in spc_emulate_evpd_83()
445 scsi_target_len = sprintf(&buf[off], "%s", in spc_emulate_evpd_83()
462 buf[off-1] = scsi_target_len; in spc_emulate_evpd_83()
468 put_unaligned_be16(len, &buf[2]); /* Page Length for VPD 0x83 */ in spc_emulate_evpd_83()
475 spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_86() argument
480 buf[3] = 0x3c; in spc_emulate_evpd_86()
488 buf[4] = 0x5; in spc_emulate_evpd_86()
491 buf[4] = 0x4; in spc_emulate_evpd_86()
498 buf[4] |= (0x3 << 3); in spc_emulate_evpd_86()
502 buf[5] = 0x07; in spc_emulate_evpd_86()
506 buf[6] = 0x01; in spc_emulate_evpd_86()
510 buf[8] = 0x10; in spc_emulate_evpd_86()
517 spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b0() argument
531 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b0()
532 buf[3] = have_tp ? 0x3c : 0x10; in spc_emulate_evpd_b0()
535 buf[4] = 0x01; in spc_emulate_evpd_b0()
540 buf[5] = 0x01; in spc_emulate_evpd_b0()
546 put_unaligned_be16(min / dev->dev_attrib.block_size, &buf[6]); in spc_emulate_evpd_b0()
548 put_unaligned_be16(1, &buf[6]); in spc_emulate_evpd_b0()
560 put_unaligned_be32(min_not_zero(mtl, dev->dev_attrib.hw_max_sectors), &buf[8]); in spc_emulate_evpd_b0()
566 put_unaligned_be32(opt / dev->dev_attrib.block_size, &buf[12]); in spc_emulate_evpd_b0()
568 put_unaligned_be32(dev->dev_attrib.optimal_sectors, &buf[12]); in spc_emulate_evpd_b0()
579 put_unaligned_be32(dev->dev_attrib.max_unmap_lba_count, &buf[20]); in spc_emulate_evpd_b0()
585 &buf[24]); in spc_emulate_evpd_b0()
590 put_unaligned_be32(dev->dev_attrib.unmap_granularity, &buf[28]); in spc_emulate_evpd_b0()
596 &buf[32]); in spc_emulate_evpd_b0()
598 buf[32] |= 0x80; /* Set the UGAVALID bit */ in spc_emulate_evpd_b0()
604 put_unaligned_be64(dev->dev_attrib.max_write_same_len, &buf[36]); in spc_emulate_evpd_b0()
611 spc_emulate_evpd_b1(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b1() argument
615 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b1()
616 buf[3] = 0x3c; in spc_emulate_evpd_b1()
617 buf[5] = dev->dev_attrib.is_nonrot ? 1 : 0; in spc_emulate_evpd_b1()
624 spc_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b2() argument
636 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b2()
641 put_unaligned_be16(0x0004, &buf[2]); in spc_emulate_evpd_b2()
652 buf[4] = 0x00; in spc_emulate_evpd_b2()
660 buf[5] = 0x80; in spc_emulate_evpd_b2()
669 buf[5] |= 0x40 | 0x20; in spc_emulate_evpd_b2()
681 buf[5] |= 0x04; in spc_emulate_evpd_b2()
688 spc_emulate_evpd_b3(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b3() argument
692 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b3()
693 buf[3] = 0x0c; in spc_emulate_evpd_b3()
694 put_unaligned_be32(dev->t10_alua.lba_map_segment_size, &buf[8]); in spc_emulate_evpd_b3()
695 put_unaligned_be32(dev->t10_alua.lba_map_segment_multiplier, &buf[12]); in spc_emulate_evpd_b3()
701 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf);
719 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_00() argument
729 buf[3] = ARRAY_SIZE(evpd_handlers); in spc_emulate_evpd_00()
731 buf[p + 4] = evpd_handlers[p].page; in spc_emulate_evpd_00()
743 unsigned char *buf; in spc_emulate_inquiry() local
748 buf = kzalloc(SE_INQUIRY_BUF, GFP_KERNEL); in spc_emulate_inquiry()
749 if (!buf) { in spc_emulate_inquiry()
754 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_inquiry()
764 ret = spc_emulate_inquiry_std(cmd, buf); in spc_emulate_inquiry()
765 len = buf[4] + 5; in spc_emulate_inquiry()
771 buf[1] = cdb[2]; in spc_emulate_inquiry()
772 ret = evpd_handlers[p].emulate(cmd, buf); in spc_emulate_inquiry()
773 len = get_unaligned_be16(&buf[2]) + 4; in spc_emulate_inquiry()
784 memcpy(rbuf, buf, min_t(u32, SE_INQUIRY_BUF, cmd->data_length)); in spc_emulate_inquiry()
787 kfree(buf); in spc_emulate_inquiry()
973 static void spc_modesense_write_protect(unsigned char *buf, int type) in spc_modesense_write_protect() argument
983 buf[0] |= 0x80; /* WP bit */ in spc_modesense_write_protect()
988 static void spc_modesense_dpofua(unsigned char *buf, int type) in spc_modesense_dpofua() argument
992 buf[0] |= 0x10; /* DPOFUA bit */ in spc_modesense_dpofua()
999 static int spc_modesense_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_blockdesc() argument
1001 *buf++ = 8; in spc_modesense_blockdesc()
1002 put_unaligned_be32(min(blocks, 0xffffffffull), buf); in spc_modesense_blockdesc()
1003 buf += 4; in spc_modesense_blockdesc()
1004 put_unaligned_be32(block_size, buf); in spc_modesense_blockdesc()
1008 static int spc_modesense_long_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_long_blockdesc() argument
1011 return spc_modesense_blockdesc(buf + 3, blocks, block_size) + 3; in spc_modesense_long_blockdesc()
1013 *buf++ = 1; /* LONGLBA */ in spc_modesense_long_blockdesc()
1014 buf += 2; in spc_modesense_long_blockdesc()
1015 *buf++ = 16; in spc_modesense_long_blockdesc()
1016 put_unaligned_be64(blocks, buf); in spc_modesense_long_blockdesc()
1017 buf += 12; in spc_modesense_long_blockdesc()
1018 put_unaligned_be32(block_size, buf); in spc_modesense_long_blockdesc()
1027 unsigned char buf[SE_MODE_PAGE_BUF], *rbuf; in spc_emulate_modesense() local
1039 memset(buf, 0, SE_MODE_PAGE_BUF); in spc_emulate_modesense()
1049 spc_modesense_write_protect(&buf[length], type); in spc_emulate_modesense()
1057 spc_modesense_dpofua(&buf[length], type); in spc_emulate_modesense()
1073 length += spc_modesense_long_blockdesc(&buf[length], in spc_emulate_modesense()
1077 length += spc_modesense_blockdesc(&buf[length], in spc_emulate_modesense()
1081 length += spc_modesense_blockdesc(&buf[length], blocks, in spc_emulate_modesense()
1105 ret = modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1118 length += modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1134 put_unaligned_be16(length - 2, buf); in spc_emulate_modesense()
1136 buf[0] = length - 1; in spc_emulate_modesense()
1140 memcpy(rbuf, buf, min_t(u32, SE_MODE_PAGE_BUF, cmd->data_length)); in spc_emulate_modesense()
1155 unsigned char *buf; in spc_emulate_modeselect() local
1169 buf = transport_kmap_data_sg(cmd); in spc_emulate_modeselect()
1170 if (!buf) in spc_emulate_modeselect()
1178 page = buf[off] & 0x3f; in spc_emulate_modeselect()
1179 subpage = buf[off] & 0x40 ? buf[off + 1] : 0; in spc_emulate_modeselect()
1198 if (memcmp(buf + off, tbuf, length)) in spc_emulate_modeselect()
1214 unsigned char buf[SE_SENSE_BUF]; in spc_emulate_request_sense() local
1217 memset(buf, 0, SE_SENSE_BUF); in spc_emulate_request_sense()
1230 scsi_build_sense_buffer(desc_format, buf, UNIT_ATTENTION, in spc_emulate_request_sense()
1233 scsi_build_sense_buffer(desc_format, buf, NO_SENSE, 0x0, 0x0); in spc_emulate_request_sense()
1235 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); in spc_emulate_request_sense()
1248 unsigned char *buf; in spc_emulate_report_luns() local
1252 buf = transport_kmap_data_sg(cmd); in spc_emulate_report_luns()
1253 if (cmd->data_length && !buf) in spc_emulate_report_luns()
1278 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1294 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1299 if (buf) { in spc_emulate_report_luns()
1301 memcpy(buf, &len, min_t(int, sizeof len, cmd->data_length)); in spc_emulate_report_luns()