1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * UFS Transport SGIO v4 BSG Message Support 4 * 5 * Copyright (C) 2011-2013 Samsung India Software Operations 6 * Copyright (C) 2018 Western Digital Corporation 7 */ 8 #ifndef SCSI_BSG_UFS_H 9 #define SCSI_BSG_UFS_H 10 11 #include <linux/types.h> 12 /* 13 * This file intended to be included by both kernel and user space 14 */ 15 16 #define UFS_CDB_SIZE 16 17 #define UPIU_TRANSACTION_UIC_CMD 0x1F 18 /* uic commands are 4DW long, per UFSHCI V2.1 paragraph 5.6.1 */ 19 #define UIC_CMD_SIZE (sizeof(__u32) * 4) 20 21 /** 22 * struct utp_upiu_header - UPIU header structure 23 * @dword_0: UPIU header DW-0 24 * @dword_1: UPIU header DW-1 25 * @dword_2: UPIU header DW-2 26 */ 27 struct utp_upiu_header { 28 __be32 dword_0; 29 __be32 dword_1; 30 __be32 dword_2; 31 }; 32 33 /** 34 * struct utp_upiu_query - upiu request buffer structure for 35 * query request. 36 * @opcode: command to perform B-0 37 * @idn: a value that indicates the particular type of data B-1 38 * @index: Index to further identify data B-2 39 * @selector: Index to further identify data B-3 40 * @reserved_osf: spec reserved field B-4,5 41 * @length: number of descriptor bytes to read/write B-6,7 42 * @value: Attribute value to be written DW-5 43 * @reserved: spec reserved DW-6,7 44 */ 45 struct utp_upiu_query { 46 __u8 opcode; 47 __u8 idn; 48 __u8 index; 49 __u8 selector; 50 __be16 reserved_osf; 51 __be16 length; 52 __be32 value; 53 __be32 reserved[2]; 54 }; 55 56 /** 57 * struct utp_upiu_cmd - Command UPIU structure 58 * @data_transfer_len: Data Transfer Length DW-3 59 * @cdb: Command Descriptor Block CDB DW-4 to DW-7 60 */ 61 struct utp_upiu_cmd { 62 __be32 exp_data_transfer_len; 63 __u8 cdb[UFS_CDB_SIZE]; 64 }; 65 66 /** 67 * struct utp_upiu_req - general upiu request structure 68 * @header:UPIU header structure DW-0 to DW-2 69 * @sc: fields structure for scsi command DW-3 to DW-7 70 * @qr: fields structure for query request DW-3 to DW-7 71 */ 72 struct utp_upiu_req { 73 struct utp_upiu_header header; 74 union { 75 struct utp_upiu_cmd sc; 76 struct utp_upiu_query qr; 77 struct utp_upiu_query tr; 78 /* use utp_upiu_query to host the 4 dwords of uic command */ 79 struct utp_upiu_query uc; 80 }; 81 }; 82 83 /* request (CDB) structure of the sg_io_v4 */ 84 struct ufs_bsg_request { 85 __u32 msgcode; 86 struct utp_upiu_req upiu_req; 87 }; 88 89 /* response (request sense data) structure of the sg_io_v4 */ 90 struct ufs_bsg_reply { 91 /* 92 * The completion result. Result exists in two forms: 93 * if negative, it is an -Exxx system errno value. There will 94 * be no further reply information supplied. 95 * else, it's the 4-byte scsi error result, with driver, host, 96 * msg and status fields. The per-msgcode reply structure 97 * will contain valid data. 98 */ 99 __u32 result; 100 101 /* If there was reply_payload, how much was received? */ 102 __u32 reply_payload_rcv_len; 103 104 struct utp_upiu_req upiu_rsp; 105 }; 106 #endif /* UFS_BSG_H */ 107