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()
118 buf[7] = 0x2; /* CmdQue=1 */ in spc_emulate_inquiry_std()
125 memset(&buf[8], 0x20, in spc_emulate_inquiry_std()
127 memcpy(&buf[8], dev->t10_wwn.vendor, in spc_emulate_inquiry_std()
129 memcpy(&buf[16], dev->t10_wwn.model, in spc_emulate_inquiry_std()
131 memcpy(&buf[32], dev->t10_wwn.revision, in spc_emulate_inquiry_std()
137 put_unaligned_be16(SCSI_VERSION_DESCRIPTOR_SAM5, &buf[58]); in spc_emulate_inquiry_std()
138 put_unaligned_be16(spc_find_scsi_transport_vd(tpg->proto_id), &buf[60]); in spc_emulate_inquiry_std()
139 put_unaligned_be16(SCSI_VERSION_DESCRIPTOR_SPC4, &buf[62]); in spc_emulate_inquiry_std()
141 put_unaligned_be16(SCSI_VERSION_DESCRIPTOR_SBC3, &buf[64]); in spc_emulate_inquiry_std()
143 buf[4] = 91; /* Set additional length to 91 */ in spc_emulate_inquiry_std()
151 spc_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_80() argument
157 len = sprintf(&buf[4], "%s", dev->t10_wwn.unit_serial); in spc_emulate_evpd_80()
159 buf[3] = len; in spc_emulate_evpd_80()
168 unsigned char *buf) in spc_gen_naa_6h_vendor_specific() argument
178 buf[off] = 0x6 << 4; in spc_gen_naa_6h_vendor_specific()
181 buf[off++] |= (company_id >> 20) & 0xf; in spc_gen_naa_6h_vendor_specific()
182 buf[off++] = (company_id >> 12) & 0xff; in spc_gen_naa_6h_vendor_specific()
183 buf[off++] = (company_id >> 4) & 0xff; in spc_gen_naa_6h_vendor_specific()
184 buf[off] = (company_id & 0xf) << 4; in spc_gen_naa_6h_vendor_specific()
202 buf[off++] |= val; in spc_gen_naa_6h_vendor_specific()
205 buf[off] = val << 4; in spc_gen_naa_6h_vendor_specific()
215 spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_83() argument
241 buf[off++] = 0x1; in spc_emulate_evpd_83()
244 buf[off] = 0x00; in spc_emulate_evpd_83()
247 buf[off++] |= 0x3; in spc_emulate_evpd_83()
251 buf[off++] = 0x10; in spc_emulate_evpd_83()
254 spc_gen_naa_6h_vendor_specific(dev, &buf[off]); in spc_emulate_evpd_83()
273 id_len += sprintf(&buf[off+12], "%s:%s", prod, in spc_emulate_evpd_83()
276 buf[off] = 0x2; /* ASCII */ in spc_emulate_evpd_83()
277 buf[off+1] = 0x1; /* T10 Vendor ID */ in spc_emulate_evpd_83()
278 buf[off+2] = 0x0; in spc_emulate_evpd_83()
280 memset(&buf[off+4], 0x20, INQUIRY_VENDOR_LEN); in spc_emulate_evpd_83()
281 memcpy(&buf[off+4], dev->t10_wwn.vendor, in spc_emulate_evpd_83()
286 buf[off+3] = id_len; 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++] |= 0x4; in spc_emulate_evpd_83()
314 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
318 put_unaligned_be16(lun->lun_rtpi, &buf[off]); in spc_emulate_evpd_83()
337 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
338 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
339 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
341 buf[off] |= 0x10; in spc_emulate_evpd_83()
343 buf[off++] |= 0x5; in spc_emulate_evpd_83()
345 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
347 put_unaligned_be16(tg_pt_gp_id, &buf[off]); in spc_emulate_evpd_83()
368 buf[off++] |= 0x1; /* CODE SET == Binary */ in spc_emulate_evpd_83()
370 buf[off++] |= 0x6; in spc_emulate_evpd_83()
372 buf[off++] = 4; /* DESIGNATOR LENGTH */ in spc_emulate_evpd_83()
374 put_unaligned_be16(lu_gp_id, &buf[off]); in spc_emulate_evpd_83()
385 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
386 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
387 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
389 buf[off] |= 0x10; in spc_emulate_evpd_83()
391 buf[off++] |= 0x8; in spc_emulate_evpd_83()
400 scsi_name_len = sprintf(&buf[off], "%s,t,0x%04x", in spc_emulate_evpd_83()
417 buf[off-1] = scsi_name_len; in spc_emulate_evpd_83()
425 buf[off] = tpg->proto_id << 4; in spc_emulate_evpd_83()
426 buf[off++] |= 0x3; /* CODE SET == UTF-8 */ in spc_emulate_evpd_83()
427 buf[off] = 0x80; /* Set PIV=1 */ in spc_emulate_evpd_83()
429 buf[off] |= 0x20; in spc_emulate_evpd_83()
431 buf[off++] |= 0x8; in spc_emulate_evpd_83()
439 scsi_target_len = sprintf(&buf[off], "%s", in spc_emulate_evpd_83()
456 buf[off-1] = scsi_target_len; in spc_emulate_evpd_83()
462 put_unaligned_be16(len, &buf[2]); /* Page Length for VPD 0x83 */ in spc_emulate_evpd_83()
469 spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_86() argument
474 buf[3] = 0x3c; in spc_emulate_evpd_86()
482 buf[4] = 0x5; in spc_emulate_evpd_86()
485 buf[4] = 0x4; in spc_emulate_evpd_86()
492 buf[4] |= (0x3 << 3); in spc_emulate_evpd_86()
496 buf[5] = 0x07; in spc_emulate_evpd_86()
500 buf[6] = 0x01; in spc_emulate_evpd_86()
504 buf[8] = 0x10; in spc_emulate_evpd_86()
511 spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b0() argument
525 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b0()
526 buf[3] = have_tp ? 0x3c : 0x10; in spc_emulate_evpd_b0()
529 buf[4] = 0x01; in spc_emulate_evpd_b0()
534 buf[5] = 0x01; in spc_emulate_evpd_b0()
540 put_unaligned_be16(min / dev->dev_attrib.block_size, &buf[6]); in spc_emulate_evpd_b0()
542 put_unaligned_be16(1, &buf[6]); in spc_emulate_evpd_b0()
554 put_unaligned_be32(min_not_zero(mtl, dev->dev_attrib.hw_max_sectors), &buf[8]); in spc_emulate_evpd_b0()
560 put_unaligned_be32(opt / dev->dev_attrib.block_size, &buf[12]); in spc_emulate_evpd_b0()
562 put_unaligned_be32(dev->dev_attrib.optimal_sectors, &buf[12]); in spc_emulate_evpd_b0()
573 put_unaligned_be32(dev->dev_attrib.max_unmap_lba_count, &buf[20]); in spc_emulate_evpd_b0()
579 &buf[24]); in spc_emulate_evpd_b0()
584 put_unaligned_be32(dev->dev_attrib.unmap_granularity, &buf[28]); in spc_emulate_evpd_b0()
590 &buf[32]); in spc_emulate_evpd_b0()
592 buf[32] |= 0x80; /* Set the UGAVALID bit */ in spc_emulate_evpd_b0()
598 put_unaligned_be64(dev->dev_attrib.max_write_same_len, &buf[36]); in spc_emulate_evpd_b0()
605 spc_emulate_evpd_b1(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b1() argument
609 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b1()
610 buf[3] = 0x3c; in spc_emulate_evpd_b1()
611 buf[5] = dev->dev_attrib.is_nonrot ? 1 : 0; in spc_emulate_evpd_b1()
618 spc_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b2() argument
630 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b2()
635 put_unaligned_be16(0x0004, &buf[2]); in spc_emulate_evpd_b2()
646 buf[4] = 0x00; in spc_emulate_evpd_b2()
654 buf[5] = 0x80; in spc_emulate_evpd_b2()
663 buf[5] |= 0x40 | 0x20; in spc_emulate_evpd_b2()
675 buf[5] |= 0x04; in spc_emulate_evpd_b2()
682 spc_emulate_evpd_b3(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_b3() argument
686 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_evpd_b3()
687 buf[3] = 0x0c; in spc_emulate_evpd_b3()
688 put_unaligned_be32(dev->t10_alua.lba_map_segment_size, &buf[8]); in spc_emulate_evpd_b3()
689 put_unaligned_be32(dev->t10_alua.lba_map_segment_multiplier, &buf[12]); in spc_emulate_evpd_b3()
695 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf);
713 spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) in spc_emulate_evpd_00() argument
723 buf[3] = ARRAY_SIZE(evpd_handlers); in spc_emulate_evpd_00()
725 buf[p + 4] = evpd_handlers[p].page; in spc_emulate_evpd_00()
737 unsigned char *buf; in spc_emulate_inquiry() local
742 buf = kzalloc(SE_INQUIRY_BUF, GFP_KERNEL); in spc_emulate_inquiry()
743 if (!buf) { in spc_emulate_inquiry()
748 buf[0] = dev->transport->get_device_type(dev); in spc_emulate_inquiry()
758 ret = spc_emulate_inquiry_std(cmd, buf); in spc_emulate_inquiry()
759 len = buf[4] + 5; in spc_emulate_inquiry()
765 buf[1] = cdb[2]; in spc_emulate_inquiry()
766 ret = evpd_handlers[p].emulate(cmd, buf); in spc_emulate_inquiry()
767 len = get_unaligned_be16(&buf[2]) + 4; in spc_emulate_inquiry()
778 memcpy(rbuf, buf, min_t(u32, SE_INQUIRY_BUF, cmd->data_length)); in spc_emulate_inquiry()
781 kfree(buf); in spc_emulate_inquiry()
967 static void spc_modesense_write_protect(unsigned char *buf, int type) in spc_modesense_write_protect() argument
977 buf[0] |= 0x80; /* WP bit */ in spc_modesense_write_protect()
982 static void spc_modesense_dpofua(unsigned char *buf, int type) in spc_modesense_dpofua() argument
986 buf[0] |= 0x10; /* DPOFUA bit */ in spc_modesense_dpofua()
993 static int spc_modesense_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_blockdesc() argument
995 *buf++ = 8; in spc_modesense_blockdesc()
996 put_unaligned_be32(min(blocks, 0xffffffffull), buf); in spc_modesense_blockdesc()
997 buf += 4; in spc_modesense_blockdesc()
998 put_unaligned_be32(block_size, buf); in spc_modesense_blockdesc()
1002 static int spc_modesense_long_blockdesc(unsigned char *buf, u64 blocks, u32 block_size) in spc_modesense_long_blockdesc() argument
1005 return spc_modesense_blockdesc(buf + 3, blocks, block_size) + 3; in spc_modesense_long_blockdesc()
1007 *buf++ = 1; /* LONGLBA */ in spc_modesense_long_blockdesc()
1008 buf += 2; in spc_modesense_long_blockdesc()
1009 *buf++ = 16; in spc_modesense_long_blockdesc()
1010 put_unaligned_be64(blocks, buf); in spc_modesense_long_blockdesc()
1011 buf += 12; in spc_modesense_long_blockdesc()
1012 put_unaligned_be32(block_size, buf); in spc_modesense_long_blockdesc()
1021 unsigned char buf[SE_MODE_PAGE_BUF], *rbuf; in spc_emulate_modesense() local
1033 memset(buf, 0, SE_MODE_PAGE_BUF); in spc_emulate_modesense()
1043 spc_modesense_write_protect(&buf[length], type); in spc_emulate_modesense()
1051 spc_modesense_dpofua(&buf[length], type); in spc_emulate_modesense()
1067 length += spc_modesense_long_blockdesc(&buf[length], in spc_emulate_modesense()
1071 length += spc_modesense_blockdesc(&buf[length], in spc_emulate_modesense()
1075 length += spc_modesense_blockdesc(&buf[length], blocks, in spc_emulate_modesense()
1099 ret = modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1112 length += modesense_handlers[i].emulate(cmd, pc, &buf[length]); in spc_emulate_modesense()
1128 put_unaligned_be16(length - 2, buf); in spc_emulate_modesense()
1130 buf[0] = length - 1; in spc_emulate_modesense()
1134 memcpy(rbuf, buf, min_t(u32, SE_MODE_PAGE_BUF, cmd->data_length)); in spc_emulate_modesense()
1149 unsigned char *buf; in spc_emulate_modeselect() local
1163 buf = transport_kmap_data_sg(cmd); in spc_emulate_modeselect()
1164 if (!buf) in spc_emulate_modeselect()
1172 page = buf[off] & 0x3f; in spc_emulate_modeselect()
1173 subpage = buf[off] & 0x40 ? buf[off + 1] : 0; in spc_emulate_modeselect()
1192 if (memcmp(buf + off, tbuf, length)) in spc_emulate_modeselect()
1208 unsigned char buf[SE_SENSE_BUF]; in spc_emulate_request_sense() local
1211 memset(buf, 0, SE_SENSE_BUF); in spc_emulate_request_sense()
1224 scsi_build_sense_buffer(desc_format, buf, UNIT_ATTENTION, in spc_emulate_request_sense()
1227 scsi_build_sense_buffer(desc_format, buf, NO_SENSE, 0x0, 0x0); in spc_emulate_request_sense()
1229 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); in spc_emulate_request_sense()
1242 unsigned char *buf; in spc_emulate_report_luns() local
1246 buf = transport_kmap_data_sg(cmd); in spc_emulate_report_luns()
1247 if (cmd->data_length && !buf) in spc_emulate_report_luns()
1272 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1288 memcpy(buf + offset, &slun, in spc_emulate_report_luns()
1293 if (buf) { in spc_emulate_report_luns()
1295 memcpy(buf, &len, min_t(int, sizeof len, cmd->data_length)); in spc_emulate_report_luns()