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 put_unaligned_be16(lun->lun_rtpi, &buf[off]); 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 put_unaligned_be16(tg_pt_gp_id, &buf[off]); 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 put_unaligned_be16(lu_gp_id, &buf[off]); 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 put_unaligned_be16(len, &buf[2]); /* Page Length for VPD 0x83 */ in spc_emulate_evpd_83()
441 spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_86() argument
446 buf[3] = 0x3c; in spc_emulate_evpd_86()
454 buf[4] = 0x5; in spc_emulate_evpd_86()
457 buf[4] = 0x4; in spc_emulate_evpd_86()
464 buf[4] |= (0x3 << 3); in spc_emulate_evpd_86()
468 buf[5] = 0x07; in spc_emulate_evpd_86()
472 buf[6] = 0x01; in spc_emulate_evpd_86()
476 buf[8] = 0x10; in spc_emulate_evpd_86()
483 spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b0() argument
497 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b0()
498 buf[3] = have_tp ? 0x3c : 0x10; in spc_emulate_evpd_b0()
501 buf[4] = 0x01; in spc_emulate_evpd_b0()
506 buf[5] = 0x01; in spc_emulate_evpd_b0()
512 put_unaligned_be16(min / dev->dev_attrib.block_size, &buf[6]); in spc_emulate_evpd_b0()
514 put_unaligned_be16(1, &buf[6]); in spc_emulate_evpd_b0()
526 put_unaligned_be32(min_not_zero(mtl, dev->dev_attrib.hw_max_sectors), &buf[8]); in spc_emulate_evpd_b0()
532 put_unaligned_be32(opt / dev->dev_attrib.block_size, &buf[12]); in spc_emulate_evpd_b0()
534 put_unaligned_be32(dev->dev_attrib.optimal_sectors, &buf[12]); in spc_emulate_evpd_b0()
545 put_unaligned_be32(dev->dev_attrib.max_unmap_lba_count, &buf[20]); in spc_emulate_evpd_b0()
551 &buf[24]); in spc_emulate_evpd_b0()
556 put_unaligned_be32(dev->dev_attrib.unmap_granularity, &buf[28]); in spc_emulate_evpd_b0()
562 &buf[32]); in spc_emulate_evpd_b0()
564 buf[32] |= 0x80; /* Set the UGAVALID bit */ in spc_emulate_evpd_b0()
570 put_unaligned_be64(dev->dev_attrib.max_write_same_len, &buf[36]); in spc_emulate_evpd_b0()
577 spc_emulate_evpd_b1(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b1() argument
581 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b1()
582 buf[3] = 0x3c; in spc_emulate_evpd_b1()
583 buf[5] = dev->dev_attrib.is_nonrot ? 1 : 0; in spc_emulate_evpd_b1()
590 spc_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b2() argument
602 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b2()
607 put_unaligned_be16(0x0004, &buf[2]); in spc_emulate_evpd_b2()
618 buf[4] = 0x00; in spc_emulate_evpd_b2()
626 buf[5] = 0x80; in spc_emulate_evpd_b2()
635 buf[5] |= 0x40 | 0x20; in spc_emulate_evpd_b2()
647 buf[5] |= 0x04; in spc_emulate_evpd_b2()
654 spc_emulate_evpd_b3(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b3() argument
658 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b3()
659 buf[3] = 0x0c; in spc_emulate_evpd_b3()
660 put_unaligned_be32(dev->t10_alua.lba_map_segment_size, &buf[8]); in spc_emulate_evpd_b3()
661 put_unaligned_be32(dev->t10_alua.lba_map_segment_multiplier, &buf[12]); in spc_emulate_evpd_b3()
667 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf);
685 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_00() argument
695 buf[3] = ARRAY_SIZE(evpd_handlers); in spc_emulate_evpd_00()
697 buf[p + 4] = evpd_handlers[p].page; in spc_emulate_evpd_00()
710 unsigned char *buf; in spc_emulate_inquiry() local
715 buf = kzalloc(SE_INQUIRY_BUF, GFP_KERNEL); in spc_emulate_inquiry()
716 if (!buf) { in spc_emulate_inquiry()
722 buf[0] = 0x3f; /* Not connected */ in spc_emulate_inquiry()
724 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_inquiry()
734 ret = spc_emulate_inquiry_std(cmd, buf); in spc_emulate_inquiry()
735 len = buf[4] + 5; in spc_emulate_inquiry()
741 buf[1] = cdb[2]; in spc_emulate_inquiry()
742 ret = evpd_handlers[p].emulate(cmd, buf); in spc_emulate_inquiry()
743 len = get_unaligned_be16(&buf[2]) + 4; in spc_emulate_inquiry()
754 memcpy(rbuf, buf, min_t(u32, SE_INQUIRY_BUF, cmd->data_length)); in spc_emulate_inquiry()
757 kfree(buf); in spc_emulate_inquiry()
934 static void spc_modesense_write_protect(unsigned char *buf, int type) in spc_modesense_write_protect() argument
944 buf[0] |= 0x80; /* WP bit */ in spc_modesense_write_protect()
949 static void spc_modesense_dpofua(unsigned char *buf, int type) in spc_modesense_dpofua() argument
953 buf[0] |= 0x10; /* DPOFUA bit */ in spc_modesense_dpofua()
960 static int spc_modesense_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_blockdesc() argument
962 *buf++ = 8; in spc_modesense_blockdesc()
963 put_unaligned_be32(min(blocks, 0xffffffffull), buf); in spc_modesense_blockdesc()
964 buf += 4; in spc_modesense_blockdesc()
965 put_unaligned_be32(block_size, buf); in spc_modesense_blockdesc()
969 static int spc_modesense_long_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_long_blockdesc() argument
972 return spc_modesense_blockdesc(buf + 3, blocks, block_size) + 3; in spc_modesense_long_blockdesc()
974 *buf++ = 1; /* LONGLBA */ in spc_modesense_long_blockdesc()
975 buf += 2; in spc_modesense_long_blockdesc()
976 *buf++ = 16; in spc_modesense_long_blockdesc()
977 put_unaligned_be64(blocks, buf); in spc_modesense_long_blockdesc()
978 buf += 12; in spc_modesense_long_blockdesc()
979 put_unaligned_be32(block_size, buf); in spc_modesense_long_blockdesc()
988 unsigned char buf[SE_MODE_PAGE_BUF], *rbuf; in spc_emulate_modesense() local
1000 memset(buf, 0, SE_MODE_PAGE_BUF); in spc_emulate_modesense()
1010 spc_modesense_write_protect(&buf[length], type); in spc_emulate_modesense()
1018 spc_modesense_dpofua(&buf[length], type); in spc_emulate_modesense()
1034 length += spc_modesense_long_blockdesc(&buf[length], in spc_emulate_modesense()
1038 length += spc_modesense_blockdesc(&buf[length], in spc_emulate_modesense()
1042 length += spc_modesense_blockdesc(&buf[length], blocks, in spc_emulate_modesense()
1066 ret = modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1079 length += modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1095 put_unaligned_be16(length - 2, buf); in spc_emulate_modesense()
1097 buf[0] = length - 1; in spc_emulate_modesense()
1101 memcpy(rbuf, buf, min_t(u32, SE_MODE_PAGE_BUF, cmd->data_length)); in spc_emulate_modesense()
1116 unsigned char *buf; in spc_emulate_modeselect() local
1130 buf = transport_kmap_data_sg(cmd); in spc_emulate_modeselect()
1131 if (!buf) in spc_emulate_modeselect()
1139 page = buf[off] & 0x3f; in spc_emulate_modeselect()
1140 subpage = buf[off] & 0x40 ? buf[off + 1] : 0; in spc_emulate_modeselect()
1159 if (memcmp(buf + off, tbuf, length)) in spc_emulate_modeselect()
1175 unsigned char buf[SE_SENSE_BUF]; in spc_emulate_request_sense() local
1178 memset(buf, 0, SE_SENSE_BUF); in spc_emulate_request_sense()
1191 scsi_build_sense_buffer(desc_format, buf, UNIT_ATTENTION, in spc_emulate_request_sense()
1194 scsi_build_sense_buffer(desc_format, buf, NO_SENSE, 0x0, 0x0); in spc_emulate_request_sense()
1196 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); in spc_emulate_request_sense()
1209 unsigned char *buf; in spc_emulate_report_luns() local
1213 buf = transport_kmap_data_sg(cmd); in spc_emulate_report_luns()
1214 if (cmd->data_length && !buf) in spc_emulate_report_luns()
1239 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1255 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1260 if (buf) { in spc_emulate_report_luns()
1262 memcpy(buf, &len, min_t(int, sizeof len, cmd->data_length)); in spc_emulate_report_luns()