Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * UFS Transport SGIO v4 BSG Message Support
0004  *
0005  * Copyright (C) 2011-2013 Samsung India Software Operations
0006  * Copyright (C) 2018 Western Digital Corporation
0007  */
0008 #ifndef SCSI_BSG_UFS_H
0009 #define SCSI_BSG_UFS_H
0010 
0011 #include <linux/types.h>
0012 /*
0013  * This file intended to be included by both kernel and user space
0014  */
0015 
0016 #define UFS_CDB_SIZE    16
0017 #define UPIU_TRANSACTION_UIC_CMD 0x1F
0018 /* uic commands are 4DW long, per UFSHCI V2.1 paragraph 5.6.1 */
0019 #define UIC_CMD_SIZE (sizeof(__u32) * 4)
0020 
0021 /**
0022  * struct utp_upiu_header - UPIU header structure
0023  * @dword_0: UPIU header DW-0
0024  * @dword_1: UPIU header DW-1
0025  * @dword_2: UPIU header DW-2
0026  */
0027 struct utp_upiu_header {
0028     __be32 dword_0;
0029     __be32 dword_1;
0030     __be32 dword_2;
0031 };
0032 
0033 /**
0034  * struct utp_upiu_query - upiu request buffer structure for
0035  * query request.
0036  * @opcode: command to perform B-0
0037  * @idn: a value that indicates the particular type of data B-1
0038  * @index: Index to further identify data B-2
0039  * @selector: Index to further identify data B-3
0040  * @reserved_osf: spec reserved field B-4,5
0041  * @length: number of descriptor bytes to read/write B-6,7
0042  * @value: Attribute value to be written DW-5
0043  * @reserved: spec reserved DW-6,7
0044  */
0045 struct utp_upiu_query {
0046     __u8 opcode;
0047     __u8 idn;
0048     __u8 index;
0049     __u8 selector;
0050     __be16 reserved_osf;
0051     __be16 length;
0052     __be32 value;
0053     __be32 reserved[2];
0054 };
0055 
0056 /**
0057  * struct utp_upiu_cmd - Command UPIU structure
0058  * @data_transfer_len: Data Transfer Length DW-3
0059  * @cdb: Command Descriptor Block CDB DW-4 to DW-7
0060  */
0061 struct utp_upiu_cmd {
0062     __be32 exp_data_transfer_len;
0063     __u8 cdb[UFS_CDB_SIZE];
0064 };
0065 
0066 /**
0067  * struct utp_upiu_req - general upiu request structure
0068  * @header:UPIU header structure DW-0 to DW-2
0069  * @sc: fields structure for scsi command DW-3 to DW-7
0070  * @qr: fields structure for query request DW-3 to DW-7
0071  * @uc: use utp_upiu_query to host the 4 dwords of uic command
0072  */
0073 struct utp_upiu_req {
0074     struct utp_upiu_header header;
0075     union {
0076         struct utp_upiu_cmd     sc;
0077         struct utp_upiu_query       qr;
0078         struct utp_upiu_query       uc;
0079     };
0080 };
0081 
0082 /* request (CDB) structure of the sg_io_v4 */
0083 struct ufs_bsg_request {
0084     __u32 msgcode;
0085     struct utp_upiu_req upiu_req;
0086 };
0087 
0088 /* response (request sense data) structure of the sg_io_v4 */
0089 struct ufs_bsg_reply {
0090     /*
0091      * The completion result. Result exists in two forms:
0092      * if negative, it is an -Exxx system errno value. There will
0093      * be no further reply information supplied.
0094      * else, it's the 4-byte scsi error result, with driver, host,
0095      * msg and status fields. The per-msgcode reply structure
0096      * will contain valid data.
0097      */
0098     __u32 result;
0099 
0100     /* If there was reply_payload, how much was received? */
0101     __u32 reply_payload_rcv_len;
0102 
0103     struct utp_upiu_req upiu_rsp;
0104 };
0105 #endif /* UFS_BSG_H */