Lines Matching refs:buf

40 static void spc_fill_alua_data(struct se_port *port, unsigned char *buf)  in spc_fill_alua_data()  argument
48 buf[5] = 0x80; in spc_fill_alua_data()
65 buf[5] |= tg_pt_gp->tg_pt_gp_alua_access_type; in spc_fill_alua_data()
70 spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_inquiry_std() argument
78 buf[1] = 0x80; in spc_emulate_inquiry_std()
80 buf[2] = 0x05; /* SPC-3 */ in spc_emulate_inquiry_std()
92 buf[3] = 2; in spc_emulate_inquiry_std()
97 spc_fill_alua_data(lun->lun_sep, buf); in spc_emulate_inquiry_std()
103 buf[5] |= 0x8; in spc_emulate_inquiry_std()
112 buf[5] |= 0x1; in spc_emulate_inquiry_std()
115 buf[7] = 0x2; /* CmdQue=1 */ in spc_emulate_inquiry_std()
117 memcpy(&buf[8], "LIO-ORG ", 8); in spc_emulate_inquiry_std()
118 memset(&buf[16], 0x20, 16); in spc_emulate_inquiry_std()
119 memcpy(&buf[16], dev->t10_wwn.model, in spc_emulate_inquiry_std()
121 memcpy(&buf[32], dev->t10_wwn.revision, in spc_emulate_inquiry_std()
123 buf[4] = 31; /* Set additional length to 31 */ in spc_emulate_inquiry_std()
131 spc_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_80() argument
137 len = sprintf(&buf[4], "%s", dev->t10_wwn.unit_serial); in spc_emulate_evpd_80()
139 buf[3] = len; in spc_emulate_evpd_80()
145 unsigned char *buf) in spc_parse_naa_6h_vendor_specific() argument
167 buf[cnt++] |= val; in spc_parse_naa_6h_vendor_specific()
170 buf[cnt] = val << 4; in spc_parse_naa_6h_vendor_specific()
180 spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_83() argument
208 buf[off++] = 0x1; in spc_emulate_evpd_83()
211 buf[off] = 0x00; in spc_emulate_evpd_83()
214 buf[off++] |= 0x3; in spc_emulate_evpd_83()
218 buf[off++] = 0x10; in spc_emulate_evpd_83()
223 buf[off++] = (0x6 << 4); in spc_emulate_evpd_83()
228 buf[off++] = 0x01; in spc_emulate_evpd_83()
229 buf[off++] = 0x40; in spc_emulate_evpd_83()
230 buf[off] = (0x5 << 4); in spc_emulate_evpd_83()
237 spc_parse_naa_6h_vendor_specific(dev, &buf[off]); in spc_emulate_evpd_83()
256 id_len += sprintf(&buf[off+12], "%s:%s", prod, in spc_emulate_evpd_83()
259 buf[off] = 0x2; /* ASCII */ in spc_emulate_evpd_83()
260 buf[off+1] = 0x1; /* T10 Vendor ID */ in spc_emulate_evpd_83()
261 buf[off+2] = 0x0; in spc_emulate_evpd_83()
262 memcpy(&buf[off+4], "LIO-ORG", 8); in spc_emulate_evpd_83()
266 buf[off+3] = id_len; in spc_emulate_evpd_83()
289 buf[off] = in spc_emulate_evpd_83()
291 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
292 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
294 buf[off] |= 0x10; in spc_emulate_evpd_83()
296 buf[off++] |= 0x4; in spc_emulate_evpd_83()
298 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
302 buf[off++] = ((port->sep_rtpi >> 8) & 0xff); in spc_emulate_evpd_83()
303 buf[off++] = (port->sep_rtpi & 0xff); in spc_emulate_evpd_83()
325 buf[off] = in spc_emulate_evpd_83()
327 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
328 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
330 buf[off] |= 0x10; in spc_emulate_evpd_83()
332 buf[off++] |= 0x5; in spc_emulate_evpd_83()
334 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
336 buf[off++] = ((tg_pt_gp_id >> 8) & 0xff); in spc_emulate_evpd_83()
337 buf[off++] = (tg_pt_gp_id & 0xff); in spc_emulate_evpd_83()
357 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
359 buf[off++] |= 0x6; in spc_emulate_evpd_83()
361 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
363 buf[off++] = ((lu_gp_id >> 8) & 0xff); in spc_emulate_evpd_83()
364 buf[off++] = (lu_gp_id & 0xff); in spc_emulate_evpd_83()
374 buf[off] = in spc_emulate_evpd_83()
376 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
377 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
379 buf[off] |= 0x10; in spc_emulate_evpd_83()
381 buf[off++] |= 0x8; in spc_emulate_evpd_83()
390 scsi_name_len = sprintf(&buf[off], "%s,t,0x%04x", in spc_emulate_evpd_83()
407 buf[off-1] = scsi_name_len; in spc_emulate_evpd_83()
415 buf[off] = in spc_emulate_evpd_83()
417 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
418 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
420 buf[off] |= 0x20; in spc_emulate_evpd_83()
422 buf[off++] |= 0x8; in spc_emulate_evpd_83()
430 scsi_target_len = sprintf(&buf[off], "%s", in spc_emulate_evpd_83()
447 buf[off-1] = scsi_target_len; in spc_emulate_evpd_83()
453 buf[2] = ((len >> 8) & 0xff); in spc_emulate_evpd_83()
454 buf[3] = (len & 0xff); /* Page Length for VPD 0x83 */ in spc_emulate_evpd_83()
461 spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_86() argument
466 buf[3] = 0x3c; in spc_emulate_evpd_86()
474 buf[4] = 0x5; in spc_emulate_evpd_86()
477 buf[4] = 0x4; in spc_emulate_evpd_86()
481 buf[5] = 0x07; in spc_emulate_evpd_86()
485 buf[6] = 0x01; in spc_emulate_evpd_86()
489 buf[8] = 0x10; in spc_emulate_evpd_86()
496 spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b0() argument
510 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b0()
511 buf[3] = have_tp ? 0x3c : 0x10; in spc_emulate_evpd_b0()
514 buf[4] = 0x01; in spc_emulate_evpd_b0()
519 buf[5] = 0x01; in spc_emulate_evpd_b0()
525 put_unaligned_be16(min / dev->dev_attrib.block_size, &buf[6]); in spc_emulate_evpd_b0()
527 put_unaligned_be16(1, &buf[6]); in spc_emulate_evpd_b0()
532 put_unaligned_be32(dev->dev_attrib.hw_max_sectors, &buf[8]); in spc_emulate_evpd_b0()
538 put_unaligned_be32(opt / dev->dev_attrib.block_size, &buf[12]); in spc_emulate_evpd_b0()
540 put_unaligned_be32(dev->dev_attrib.optimal_sectors, &buf[12]); in spc_emulate_evpd_b0()
551 put_unaligned_be32(dev->dev_attrib.max_unmap_lba_count, &buf[20]); in spc_emulate_evpd_b0()
557 &buf[24]); in spc_emulate_evpd_b0()
562 put_unaligned_be32(dev->dev_attrib.unmap_granularity, &buf[28]); in spc_emulate_evpd_b0()
568 &buf[32]); in spc_emulate_evpd_b0()
570 buf[32] |= 0x80; /* Set the UGAVALID bit */ in spc_emulate_evpd_b0()
576 put_unaligned_be64(dev->dev_attrib.max_write_same_len, &buf[36]); in spc_emulate_evpd_b0()
583 spc_emulate_evpd_b1(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b1() argument
587 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b1()
588 buf[3] = 0x3c; in spc_emulate_evpd_b1()
589 buf[5] = dev->dev_attrib.is_nonrot ? 1 : 0; in spc_emulate_evpd_b1()
596 spc_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b2() argument
608 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b2()
613 put_unaligned_be16(0x0004, &buf[2]); in spc_emulate_evpd_b2()
624 buf[4] = 0x00; in spc_emulate_evpd_b2()
632 buf[5] = 0x80; in spc_emulate_evpd_b2()
641 buf[5] |= 0x40 | 0x20; in spc_emulate_evpd_b2()
648 spc_emulate_evpd_b3(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b3() argument
652 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b3()
653 buf[3] = 0x0c; in spc_emulate_evpd_b3()
654 put_unaligned_be32(dev->t10_alua.lba_map_segment_size, &buf[8]); in spc_emulate_evpd_b3()
655 put_unaligned_be32(dev->t10_alua.lba_map_segment_multiplier, &buf[12]); in spc_emulate_evpd_b3()
661 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf);
679 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_00() argument
689 buf[3] = ARRAY_SIZE(evpd_handlers); in spc_emulate_evpd_00()
691 buf[p + 4] = evpd_handlers[p].page; in spc_emulate_evpd_00()
704 unsigned char *buf; in spc_emulate_inquiry() local
709 buf = kzalloc(SE_INQUIRY_BUF, GFP_KERNEL); in spc_emulate_inquiry()
710 if (!buf) { in spc_emulate_inquiry()
716 buf[0] = 0x3f; /* Not connected */ in spc_emulate_inquiry()
718 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_inquiry()
728 ret = spc_emulate_inquiry_std(cmd, buf); in spc_emulate_inquiry()
729 len = buf[4] + 5; in spc_emulate_inquiry()
735 buf[1] = cdb[2]; in spc_emulate_inquiry()
736 ret = evpd_handlers[p].emulate(cmd, buf); in spc_emulate_inquiry()
737 len = get_unaligned_be16(&buf[2]) + 4; in spc_emulate_inquiry()
748 memcpy(rbuf, buf, min_t(u32, SE_INQUIRY_BUF, cmd->data_length)); in spc_emulate_inquiry()
751 kfree(buf); in spc_emulate_inquiry()
923 static void spc_modesense_write_protect(unsigned char *buf, int type) in spc_modesense_write_protect() argument
933 buf[0] |= 0x80; /* WP bit */ in spc_modesense_write_protect()
938 static void spc_modesense_dpofua(unsigned char *buf, int type) in spc_modesense_dpofua() argument
942 buf[0] |= 0x10; /* DPOFUA bit */ in spc_modesense_dpofua()
949 static int spc_modesense_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_blockdesc() argument
951 *buf++ = 8; in spc_modesense_blockdesc()
952 put_unaligned_be32(min(blocks, 0xffffffffull), buf); in spc_modesense_blockdesc()
953 buf += 4; in spc_modesense_blockdesc()
954 put_unaligned_be32(block_size, buf); in spc_modesense_blockdesc()
958 static int spc_modesense_long_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_long_blockdesc() argument
961 return spc_modesense_blockdesc(buf + 3, blocks, block_size) + 3; in spc_modesense_long_blockdesc()
963 *buf++ = 1; /* LONGLBA */ in spc_modesense_long_blockdesc()
964 buf += 2; in spc_modesense_long_blockdesc()
965 *buf++ = 16; in spc_modesense_long_blockdesc()
966 put_unaligned_be64(blocks, buf); in spc_modesense_long_blockdesc()
967 buf += 12; in spc_modesense_long_blockdesc()
968 put_unaligned_be32(block_size, buf); in spc_modesense_long_blockdesc()
977 unsigned char buf[SE_MODE_PAGE_BUF], *rbuf; in spc_emulate_modesense() local
989 memset(buf, 0, SE_MODE_PAGE_BUF); in spc_emulate_modesense()
1001 spc_modesense_write_protect(&buf[length], type); in spc_emulate_modesense()
1005 spc_modesense_dpofua(&buf[length], type); in spc_emulate_modesense()
1021 length += spc_modesense_long_blockdesc(&buf[length], in spc_emulate_modesense()
1025 length += spc_modesense_blockdesc(&buf[length], in spc_emulate_modesense()
1029 length += spc_modesense_blockdesc(&buf[length], blocks, in spc_emulate_modesense()
1053 ret = modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1066 length += modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1082 put_unaligned_be16(length - 2, buf); in spc_emulate_modesense()
1084 buf[0] = length - 1; in spc_emulate_modesense()
1088 memcpy(rbuf, buf, min_t(u32, SE_MODE_PAGE_BUF, cmd->data_length)); in spc_emulate_modesense()
1103 unsigned char *buf; in spc_emulate_modeselect() local
1117 buf = transport_kmap_data_sg(cmd); in spc_emulate_modeselect()
1118 if (!buf) in spc_emulate_modeselect()
1126 page = buf[off] & 0x3f; in spc_emulate_modeselect()
1127 subpage = buf[off] & 0x40 ? buf[off + 1] : 0; in spc_emulate_modeselect()
1146 if (memcmp(buf + off, tbuf, length)) in spc_emulate_modeselect()
1162 unsigned char buf[SE_SENSE_BUF]; in spc_emulate_request_sense() local
1164 memset(buf, 0, SE_SENSE_BUF); in spc_emulate_request_sense()
1180 buf[0] = 0x70; in spc_emulate_request_sense()
1181 buf[SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; in spc_emulate_request_sense()
1186 buf[SPC_ASC_KEY_OFFSET] = ua_asc; in spc_emulate_request_sense()
1187 buf[SPC_ASCQ_KEY_OFFSET] = ua_ascq; in spc_emulate_request_sense()
1188 buf[7] = 0x0A; in spc_emulate_request_sense()
1193 buf[0] = 0x70; in spc_emulate_request_sense()
1194 buf[SPC_SENSE_KEY_OFFSET] = NO_SENSE; in spc_emulate_request_sense()
1199 buf[SPC_ASC_KEY_OFFSET] = 0x00; in spc_emulate_request_sense()
1200 buf[7] = 0x0A; in spc_emulate_request_sense()
1203 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); in spc_emulate_request_sense()
1214 unsigned char *buf; in spc_emulate_report_luns() local
1223 buf = transport_kmap_data_sg(cmd); in spc_emulate_report_luns()
1224 if (!buf) in spc_emulate_report_luns()
1233 int_to_scsilun(0, (struct scsi_lun *)&buf[offset]); in spc_emulate_report_luns()
1252 int_to_scsilun(deve->mapped_lun, (struct scsi_lun *)&buf[offset]); in spc_emulate_report_luns()
1262 buf[0] = ((lun_count >> 24) & 0xff); in spc_emulate_report_luns()
1263 buf[1] = ((lun_count >> 16) & 0xff); in spc_emulate_report_luns()
1264 buf[2] = ((lun_count >> 8) & 0xff); in spc_emulate_report_luns()
1265 buf[3] = (lun_count & 0xff); in spc_emulate_report_luns()