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 * @uc: use utp_upiu_query to host the 4 dwords of uic command 72 */ 73 struct utp_upiu_req { 74 struct utp_upiu_header header; 75 union { 76 struct utp_upiu_cmd sc; 77 struct utp_upiu_query qr; 78 struct utp_upiu_query uc; 79 }; 80 }; 81 82 /* request (CDB) structure of the sg_io_v4 */ 83 struct ufs_bsg_request { 84 __u32 msgcode; 85 struct utp_upiu_req upiu_req; 86 }; 87 88 /* response (request sense data) structure of the sg_io_v4 */ 89 struct ufs_bsg_reply { 90 /* 91 * The completion result. Result exists in two forms: 92 * if negative, it is an -Exxx system errno value. There will 93 * be no further reply information supplied. 94 * else, it's the 4-byte scsi error result, with driver, host, 95 * msg and status fields. The per-msgcode reply structure 96 * will contain valid data. 97 */ 98 __u32 result; 99 100 /* If there was reply_payload, how much was received? */ 101 __u32 reply_payload_rcv_len; 102 103 struct utp_upiu_req upiu_rsp; 104 }; 105 #endif /* UFS_BSG_H */ 106