Lines Matching refs:buf
41 static void spc_fill_alua_data(struct se_lun *lun, unsigned char *buf) in spc_fill_alua_data() argument
48 buf[5] = 0x80; in spc_fill_alua_data()
59 buf[5] |= tg_pt_gp->tg_pt_gp_alua_access_type; in spc_fill_alua_data()
64 spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_inquiry_std() argument
72 buf[1] = 0x80; in spc_emulate_inquiry_std()
74 buf[2] = 0x05; /* SPC-3 */ in spc_emulate_inquiry_std()
86 buf[3] = 2; in spc_emulate_inquiry_std()
91 spc_fill_alua_data(lun, buf); in spc_emulate_inquiry_std()
97 buf[5] |= 0x8; in spc_emulate_inquiry_std()
106 buf[5] |= 0x1; in spc_emulate_inquiry_std()
109 buf[7] = 0x2; /* CmdQue=1 */ in spc_emulate_inquiry_std()
111 memcpy(&buf[8], "LIO-ORG ", 8); in spc_emulate_inquiry_std()
112 memset(&buf[16], 0x20, 16); in spc_emulate_inquiry_std()
113 memcpy(&buf[16], dev->t10_wwn.model, in spc_emulate_inquiry_std()
115 memcpy(&buf[32], dev->t10_wwn.revision, in spc_emulate_inquiry_std()
117 buf[4] = 31; /* Set additional length to 31 */ in spc_emulate_inquiry_std()
125 spc_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_80() argument
131 len = sprintf(&buf[4], "%s", dev->t10_wwn.unit_serial); in spc_emulate_evpd_80()
133 buf[3] = len; in spc_emulate_evpd_80()
139 unsigned char *buf) in spc_parse_naa_6h_vendor_specific() argument
161 buf[cnt++] |= val; in spc_parse_naa_6h_vendor_specific()
164 buf[cnt] = val << 4; in spc_parse_naa_6h_vendor_specific()
174 spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_83() argument
200 buf[off++] = 0x1; in spc_emulate_evpd_83()
203 buf[off] = 0x00; in spc_emulate_evpd_83()
206 buf[off++] |= 0x3; in spc_emulate_evpd_83()
210 buf[off++] = 0x10; in spc_emulate_evpd_83()
215 buf[off++] = (0x6 << 4); in spc_emulate_evpd_83()
220 buf[off++] = 0x01; in spc_emulate_evpd_83()
221 buf[off++] = 0x40; in spc_emulate_evpd_83()
222 buf[off] = (0x5 << 4); in spc_emulate_evpd_83()
229 spc_parse_naa_6h_vendor_specific(dev, &buf[off]); in spc_emulate_evpd_83()
248 id_len += sprintf(&buf[off+12], "%s:%s", prod, in spc_emulate_evpd_83()
251 buf[off] = 0x2; /* ASCII */ in spc_emulate_evpd_83()
252 buf[off+1] = 0x1; /* T10 Vendor ID */ in spc_emulate_evpd_83()
253 buf[off+2] = 0x0; in spc_emulate_evpd_83()
254 memcpy(&buf[off+4], "LIO-ORG", 8); in spc_emulate_evpd_83()
258 buf[off+3] = id_len; in spc_emulate_evpd_83()
278 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
279 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
280 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
282 buf[off] |= 0x10; in spc_emulate_evpd_83()
284 buf[off++] |= 0x4; in spc_emulate_evpd_83()
286 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
290 buf[off++] = ((lun->lun_rtpi >> 8) & 0xff); in spc_emulate_evpd_83()
291 buf[off++] = (lun->lun_rtpi & 0xff); in spc_emulate_evpd_83()
309 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
310 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
311 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
313 buf[off] |= 0x10; in spc_emulate_evpd_83()
315 buf[off++] |= 0x5; in spc_emulate_evpd_83()
317 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
319 buf[off++] = ((tg_pt_gp_id >> 8) & 0xff); in spc_emulate_evpd_83()
320 buf[off++] = (tg_pt_gp_id & 0xff); in spc_emulate_evpd_83()
340 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
342 buf[off++] |= 0x6; in spc_emulate_evpd_83()
344 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
346 buf[off++] = ((lu_gp_id >> 8) & 0xff); in spc_emulate_evpd_83()
347 buf[off++] = (lu_gp_id & 0xff); in spc_emulate_evpd_83()
357 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
358 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
359 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
361 buf[off] |= 0x10; in spc_emulate_evpd_83()
363 buf[off++] |= 0x8; in spc_emulate_evpd_83()
372 scsi_name_len = sprintf(&buf[off], "%s,t,0x%04x", in spc_emulate_evpd_83()
389 buf[off-1] = scsi_name_len; in spc_emulate_evpd_83()
397 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
398 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
399 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
401 buf[off] |= 0x20; in spc_emulate_evpd_83()
403 buf[off++] |= 0x8; in spc_emulate_evpd_83()
411 scsi_target_len = sprintf(&buf[off], "%s", in spc_emulate_evpd_83()
428 buf[off-1] = scsi_target_len; in spc_emulate_evpd_83()
434 buf[2] = ((len >> 8) & 0xff); in spc_emulate_evpd_83()
435 buf[3] = (len & 0xff); /* Page Length for VPD 0x83 */ in spc_emulate_evpd_83()
442 spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_86() argument
447 buf[3] = 0x3c; in spc_emulate_evpd_86()
455 buf[4] = 0x5; in spc_emulate_evpd_86()
458 buf[4] = 0x4; in spc_emulate_evpd_86()
465 buf[4] |= (0x3 << 3); in spc_emulate_evpd_86()
469 buf[5] = 0x07; in spc_emulate_evpd_86()
473 buf[6] = 0x01; in spc_emulate_evpd_86()
477 buf[8] = 0x10; in spc_emulate_evpd_86()
484 spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b0() argument
498 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b0()
499 buf[3] = have_tp ? 0x3c : 0x10; in spc_emulate_evpd_b0()
502 buf[4] = 0x01; in spc_emulate_evpd_b0()
507 buf[5] = 0x01; in spc_emulate_evpd_b0()
513 put_unaligned_be16(min / dev->dev_attrib.block_size, &buf[6]); in spc_emulate_evpd_b0()
515 put_unaligned_be16(1, &buf[6]); in spc_emulate_evpd_b0()
527 put_unaligned_be32(min_not_zero(mtl, dev->dev_attrib.hw_max_sectors), &buf[8]); in spc_emulate_evpd_b0()
533 put_unaligned_be32(opt / dev->dev_attrib.block_size, &buf[12]); in spc_emulate_evpd_b0()
535 put_unaligned_be32(dev->dev_attrib.optimal_sectors, &buf[12]); in spc_emulate_evpd_b0()
546 put_unaligned_be32(dev->dev_attrib.max_unmap_lba_count, &buf[20]); in spc_emulate_evpd_b0()
552 &buf[24]); in spc_emulate_evpd_b0()
557 put_unaligned_be32(dev->dev_attrib.unmap_granularity, &buf[28]); in spc_emulate_evpd_b0()
563 &buf[32]); in spc_emulate_evpd_b0()
565 buf[32] |= 0x80; /* Set the UGAVALID bit */ in spc_emulate_evpd_b0()
571 put_unaligned_be64(dev->dev_attrib.max_write_same_len, &buf[36]); in spc_emulate_evpd_b0()
578 spc_emulate_evpd_b1(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b1() argument
582 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b1()
583 buf[3] = 0x3c; in spc_emulate_evpd_b1()
584 buf[5] = dev->dev_attrib.is_nonrot ? 1 : 0; in spc_emulate_evpd_b1()
591 spc_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b2() argument
603 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b2()
608 put_unaligned_be16(0x0004, &buf[2]); in spc_emulate_evpd_b2()
619 buf[4] = 0x00; in spc_emulate_evpd_b2()
627 buf[5] = 0x80; in spc_emulate_evpd_b2()
636 buf[5] |= 0x40 | 0x20; in spc_emulate_evpd_b2()
648 buf[5] |= 0x04; in spc_emulate_evpd_b2()
655 spc_emulate_evpd_b3(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b3() argument
659 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b3()
660 buf[3] = 0x0c; in spc_emulate_evpd_b3()
661 put_unaligned_be32(dev->t10_alua.lba_map_segment_size, &buf[8]); in spc_emulate_evpd_b3()
662 put_unaligned_be32(dev->t10_alua.lba_map_segment_multiplier, &buf[12]); in spc_emulate_evpd_b3()
668 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf);
686 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_00() argument
696 buf[3] = ARRAY_SIZE(evpd_handlers); in spc_emulate_evpd_00()
698 buf[p + 4] = evpd_handlers[p].page; in spc_emulate_evpd_00()
711 unsigned char *buf; in spc_emulate_inquiry() local
716 buf = kzalloc(SE_INQUIRY_BUF, GFP_KERNEL); in spc_emulate_inquiry()
717 if (!buf) { in spc_emulate_inquiry()
723 buf[0] = 0x3f; /* Not connected */ in spc_emulate_inquiry()
725 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_inquiry()
735 ret = spc_emulate_inquiry_std(cmd, buf); in spc_emulate_inquiry()
736 len = buf[4] + 5; in spc_emulate_inquiry()
742 buf[1] = cdb[2]; in spc_emulate_inquiry()
743 ret = evpd_handlers[p].emulate(cmd, buf); in spc_emulate_inquiry()
744 len = get_unaligned_be16(&buf[2]) + 4; in spc_emulate_inquiry()
755 memcpy(rbuf, buf, min_t(u32, SE_INQUIRY_BUF, cmd->data_length)); in spc_emulate_inquiry()
758 kfree(buf); in spc_emulate_inquiry()
935 static void spc_modesense_write_protect(unsigned char *buf, int type) in spc_modesense_write_protect() argument
945 buf[0] |= 0x80; /* WP bit */ in spc_modesense_write_protect()
950 static void spc_modesense_dpofua(unsigned char *buf, int type) in spc_modesense_dpofua() argument
954 buf[0] |= 0x10; /* DPOFUA bit */ in spc_modesense_dpofua()
961 static int spc_modesense_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_blockdesc() argument
963 *buf++ = 8; in spc_modesense_blockdesc()
964 put_unaligned_be32(min(blocks, 0xffffffffull), buf); in spc_modesense_blockdesc()
965 buf += 4; in spc_modesense_blockdesc()
966 put_unaligned_be32(block_size, buf); in spc_modesense_blockdesc()
970 static int spc_modesense_long_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_long_blockdesc() argument
973 return spc_modesense_blockdesc(buf + 3, blocks, block_size) + 3; in spc_modesense_long_blockdesc()
975 *buf++ = 1; /* LONGLBA */ in spc_modesense_long_blockdesc()
976 buf += 2; in spc_modesense_long_blockdesc()
977 *buf++ = 16; in spc_modesense_long_blockdesc()
978 put_unaligned_be64(blocks, buf); in spc_modesense_long_blockdesc()
979 buf += 12; in spc_modesense_long_blockdesc()
980 put_unaligned_be32(block_size, buf); in spc_modesense_long_blockdesc()
989 unsigned char buf[SE_MODE_PAGE_BUF], *rbuf; in spc_emulate_modesense() local
1001 memset(buf, 0, SE_MODE_PAGE_BUF); in spc_emulate_modesense()
1011 spc_modesense_write_protect(&buf[length], type); in spc_emulate_modesense()
1019 spc_modesense_dpofua(&buf[length], type); in spc_emulate_modesense()
1035 length += spc_modesense_long_blockdesc(&buf[length], in spc_emulate_modesense()
1039 length += spc_modesense_blockdesc(&buf[length], in spc_emulate_modesense()
1043 length += spc_modesense_blockdesc(&buf[length], blocks, in spc_emulate_modesense()
1067 ret = modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1080 length += modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1096 put_unaligned_be16(length - 2, buf); in spc_emulate_modesense()
1098 buf[0] = length - 1; in spc_emulate_modesense()
1102 memcpy(rbuf, buf, min_t(u32, SE_MODE_PAGE_BUF, cmd->data_length)); in spc_emulate_modesense()
1117 unsigned char *buf; in spc_emulate_modeselect() local
1131 buf = transport_kmap_data_sg(cmd); in spc_emulate_modeselect()
1132 if (!buf) in spc_emulate_modeselect()
1140 page = buf[off] & 0x3f; in spc_emulate_modeselect()
1141 subpage = buf[off] & 0x40 ? buf[off + 1] : 0; in spc_emulate_modeselect()
1160 if (memcmp(buf + off, tbuf, length)) in spc_emulate_modeselect()
1176 unsigned char buf[SE_SENSE_BUF]; in spc_emulate_request_sense() local
1179 memset(buf, 0, SE_SENSE_BUF); in spc_emulate_request_sense()
1192 scsi_build_sense_buffer(desc_format, buf, UNIT_ATTENTION, in spc_emulate_request_sense()
1195 scsi_build_sense_buffer(desc_format, buf, NO_SENSE, 0x0, 0x0); in spc_emulate_request_sense()
1197 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); in spc_emulate_request_sense()
1210 unsigned char *buf; in spc_emulate_report_luns() local
1214 buf = transport_kmap_data_sg(cmd); in spc_emulate_report_luns()
1215 if (cmd->data_length && !buf) in spc_emulate_report_luns()
1240 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1256 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1261 if (buf) { in spc_emulate_report_luns()
1263 memcpy(buf, &len, min_t(int, sizeof len, cmd->data_length)); in spc_emulate_report_luns()