2019-07-25 07:58:31 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
2018-10-07 14:30:34 +00:00
|
|
|
/*
|
|
|
|
* UFS Transport SGIO v4 BSG Message Support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011-2013 Samsung India Software Operations
|
scsi: ufs: Add a bsg endpoint that supports UPIUs
For now, just provide an API to allocate and remove ufs-bsg node. We
will use this framework to manage ufs devices by sending UPIU
transactions.
For the time being, implements an empty bsg_request() - will add some
more functionality in coming patches.
Nonetheless, we reveal here the protocol we are planning to use: UFS
Transport Protocol Transactions. UFS transactions consist of packets
called UFS Protocol Information Units (UPIU).
There are UPIU’s defined for UFS SCSI commands, responses, data in and
data out, task management, utility functions, vendor functions,
transaction synchronization and control, and more.
By using UPIUs, we get access to the most fine-grained internals of this
protocol, and able to communicate with the device in ways, that are
sometimes beyond the capacity of the ufs driver.
Moreover and as a result, our core structure - ufs_bsg_node has a pretty
lean structure: using upiu transactions that contains the outmost
detailed info, so we don't really need complex constructs to support it.
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2018-10-07 14:30:35 +00:00
|
|
|
* Copyright (C) 2018 Western Digital Corporation
|
2018-10-07 14:30:34 +00:00
|
|
|
*/
|
|
|
|
#ifndef SCSI_BSG_UFS_H
|
|
|
|
#define SCSI_BSG_UFS_H
|
|
|
|
|
2018-10-12 10:41:28 +00:00
|
|
|
#include <linux/types.h>
|
2018-10-07 14:30:34 +00:00
|
|
|
/*
|
|
|
|
* This file intended to be included by both kernel and user space
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define UFS_CDB_SIZE 16
|
2018-10-07 14:30:39 +00:00
|
|
|
/* uic commands are 4DW long, per UFSHCI V2.1 paragraph 5.6.1 */
|
2018-10-12 10:41:28 +00:00
|
|
|
#define UIC_CMD_SIZE (sizeof(__u32) * 4)
|
2018-10-07 14:30:34 +00:00
|
|
|
|
2022-12-01 14:04:37 +00:00
|
|
|
enum ufs_bsg_msg_code {
|
|
|
|
UPIU_TRANSACTION_UIC_CMD = 0x1F,
|
|
|
|
UPIU_TRANSACTION_ARPMB_CMD,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* UFS RPMB Request Message Types */
|
|
|
|
enum ufs_rpmb_op_type {
|
|
|
|
UFS_RPMB_WRITE_KEY = 0x01,
|
|
|
|
UFS_RPMB_READ_CNT = 0x02,
|
|
|
|
UFS_RPMB_WRITE = 0x03,
|
|
|
|
UFS_RPMB_READ = 0x04,
|
|
|
|
UFS_RPMB_READ_RESP = 0x05,
|
|
|
|
UFS_RPMB_SEC_CONF_WRITE = 0x06,
|
|
|
|
UFS_RPMB_SEC_CONF_READ = 0x07,
|
|
|
|
UFS_RPMB_PURGE_ENABLE = 0x08,
|
|
|
|
UFS_RPMB_PURGE_STATUS_READ = 0x09,
|
|
|
|
};
|
|
|
|
|
2018-10-07 14:30:34 +00:00
|
|
|
/**
|
|
|
|
* struct utp_upiu_header - UPIU header structure
|
|
|
|
* @dword_0: UPIU header DW-0
|
|
|
|
* @dword_1: UPIU header DW-1
|
|
|
|
* @dword_2: UPIU header DW-2
|
|
|
|
*/
|
|
|
|
struct utp_upiu_header {
|
|
|
|
__be32 dword_0;
|
|
|
|
__be32 dword_1;
|
|
|
|
__be32 dword_2;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct utp_upiu_query - upiu request buffer structure for
|
|
|
|
* query request.
|
|
|
|
* @opcode: command to perform B-0
|
|
|
|
* @idn: a value that indicates the particular type of data B-1
|
|
|
|
* @index: Index to further identify data B-2
|
|
|
|
* @selector: Index to further identify data B-3
|
|
|
|
* @reserved_osf: spec reserved field B-4,5
|
|
|
|
* @length: number of descriptor bytes to read/write B-6,7
|
|
|
|
* @value: Attribute value to be written DW-5
|
|
|
|
* @reserved: spec reserved DW-6,7
|
|
|
|
*/
|
|
|
|
struct utp_upiu_query {
|
|
|
|
__u8 opcode;
|
|
|
|
__u8 idn;
|
|
|
|
__u8 index;
|
|
|
|
__u8 selector;
|
|
|
|
__be16 reserved_osf;
|
|
|
|
__be16 length;
|
|
|
|
__be32 value;
|
|
|
|
__be32 reserved[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct utp_upiu_cmd - Command UPIU structure
|
|
|
|
* @data_transfer_len: Data Transfer Length DW-3
|
|
|
|
* @cdb: Command Descriptor Block CDB DW-4 to DW-7
|
|
|
|
*/
|
|
|
|
struct utp_upiu_cmd {
|
|
|
|
__be32 exp_data_transfer_len;
|
2018-10-12 10:41:28 +00:00
|
|
|
__u8 cdb[UFS_CDB_SIZE];
|
2018-10-07 14:30:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct utp_upiu_req - general upiu request structure
|
|
|
|
* @header:UPIU header structure DW-0 to DW-2
|
|
|
|
* @sc: fields structure for scsi command DW-3 to DW-7
|
|
|
|
* @qr: fields structure for query request DW-3 to DW-7
|
2019-12-05 22:09:12 +00:00
|
|
|
* @uc: use utp_upiu_query to host the 4 dwords of uic command
|
2018-10-07 14:30:34 +00:00
|
|
|
*/
|
|
|
|
struct utp_upiu_req {
|
|
|
|
struct utp_upiu_header header;
|
|
|
|
union {
|
|
|
|
struct utp_upiu_cmd sc;
|
|
|
|
struct utp_upiu_query qr;
|
scsi: ufs: Add a bsg endpoint that supports UPIUs
For now, just provide an API to allocate and remove ufs-bsg node. We
will use this framework to manage ufs devices by sending UPIU
transactions.
For the time being, implements an empty bsg_request() - will add some
more functionality in coming patches.
Nonetheless, we reveal here the protocol we are planning to use: UFS
Transport Protocol Transactions. UFS transactions consist of packets
called UFS Protocol Information Units (UPIU).
There are UPIU’s defined for UFS SCSI commands, responses, data in and
data out, task management, utility functions, vendor functions,
transaction synchronization and control, and more.
By using UPIUs, we get access to the most fine-grained internals of this
protocol, and able to communicate with the device in ways, that are
sometimes beyond the capacity of the ufs driver.
Moreover and as a result, our core structure - ufs_bsg_node has a pretty
lean structure: using upiu transactions that contains the outmost
detailed info, so we don't really need complex constructs to support it.
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2018-10-07 14:30:35 +00:00
|
|
|
struct utp_upiu_query uc;
|
2018-10-07 14:30:34 +00:00
|
|
|
};
|
|
|
|
};
|
scsi: ufs: Add a bsg endpoint that supports UPIUs
For now, just provide an API to allocate and remove ufs-bsg node. We
will use this framework to manage ufs devices by sending UPIU
transactions.
For the time being, implements an empty bsg_request() - will add some
more functionality in coming patches.
Nonetheless, we reveal here the protocol we are planning to use: UFS
Transport Protocol Transactions. UFS transactions consist of packets
called UFS Protocol Information Units (UPIU).
There are UPIU’s defined for UFS SCSI commands, responses, data in and
data out, task management, utility functions, vendor functions,
transaction synchronization and control, and more.
By using UPIUs, we get access to the most fine-grained internals of this
protocol, and able to communicate with the device in ways, that are
sometimes beyond the capacity of the ufs driver.
Moreover and as a result, our core structure - ufs_bsg_node has a pretty
lean structure: using upiu transactions that contains the outmost
detailed info, so we don't really need complex constructs to support it.
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2018-10-07 14:30:35 +00:00
|
|
|
|
2022-12-01 14:04:37 +00:00
|
|
|
struct ufs_arpmb_meta {
|
|
|
|
__u16 req_resp_type;
|
|
|
|
__u8 nonce[16];
|
|
|
|
__u32 write_counter;
|
|
|
|
__u16 addr_lun;
|
|
|
|
__u16 block_count;
|
|
|
|
__u16 result;
|
|
|
|
} __attribute__((__packed__));
|
|
|
|
|
|
|
|
struct ufs_ehs {
|
|
|
|
__u8 length;
|
|
|
|
__u8 ehs_type;
|
|
|
|
__u16 ehssub_type;
|
|
|
|
struct ufs_arpmb_meta meta;
|
|
|
|
__u8 mac_key[32];
|
|
|
|
} __attribute__((__packed__));
|
|
|
|
|
scsi: ufs: Add a bsg endpoint that supports UPIUs
For now, just provide an API to allocate and remove ufs-bsg node. We
will use this framework to manage ufs devices by sending UPIU
transactions.
For the time being, implements an empty bsg_request() - will add some
more functionality in coming patches.
Nonetheless, we reveal here the protocol we are planning to use: UFS
Transport Protocol Transactions. UFS transactions consist of packets
called UFS Protocol Information Units (UPIU).
There are UPIU’s defined for UFS SCSI commands, responses, data in and
data out, task management, utility functions, vendor functions,
transaction synchronization and control, and more.
By using UPIUs, we get access to the most fine-grained internals of this
protocol, and able to communicate with the device in ways, that are
sometimes beyond the capacity of the ufs driver.
Moreover and as a result, our core structure - ufs_bsg_node has a pretty
lean structure: using upiu transactions that contains the outmost
detailed info, so we don't really need complex constructs to support it.
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2018-10-07 14:30:35 +00:00
|
|
|
/* request (CDB) structure of the sg_io_v4 */
|
|
|
|
struct ufs_bsg_request {
|
2018-10-12 10:41:28 +00:00
|
|
|
__u32 msgcode;
|
scsi: ufs: Add a bsg endpoint that supports UPIUs
For now, just provide an API to allocate and remove ufs-bsg node. We
will use this framework to manage ufs devices by sending UPIU
transactions.
For the time being, implements an empty bsg_request() - will add some
more functionality in coming patches.
Nonetheless, we reveal here the protocol we are planning to use: UFS
Transport Protocol Transactions. UFS transactions consist of packets
called UFS Protocol Information Units (UPIU).
There are UPIU’s defined for UFS SCSI commands, responses, data in and
data out, task management, utility functions, vendor functions,
transaction synchronization and control, and more.
By using UPIUs, we get access to the most fine-grained internals of this
protocol, and able to communicate with the device in ways, that are
sometimes beyond the capacity of the ufs driver.
Moreover and as a result, our core structure - ufs_bsg_node has a pretty
lean structure: using upiu transactions that contains the outmost
detailed info, so we don't really need complex constructs to support it.
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2018-10-07 14:30:35 +00:00
|
|
|
struct utp_upiu_req upiu_req;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* response (request sense data) structure of the sg_io_v4 */
|
|
|
|
struct ufs_bsg_reply {
|
|
|
|
/*
|
|
|
|
* The completion result. Result exists in two forms:
|
|
|
|
* if negative, it is an -Exxx system errno value. There will
|
|
|
|
* be no further reply information supplied.
|
|
|
|
* else, it's the 4-byte scsi error result, with driver, host,
|
|
|
|
* msg and status fields. The per-msgcode reply structure
|
|
|
|
* will contain valid data.
|
|
|
|
*/
|
2022-12-01 14:04:31 +00:00
|
|
|
int result;
|
scsi: ufs: Add a bsg endpoint that supports UPIUs
For now, just provide an API to allocate and remove ufs-bsg node. We
will use this framework to manage ufs devices by sending UPIU
transactions.
For the time being, implements an empty bsg_request() - will add some
more functionality in coming patches.
Nonetheless, we reveal here the protocol we are planning to use: UFS
Transport Protocol Transactions. UFS transactions consist of packets
called UFS Protocol Information Units (UPIU).
There are UPIU’s defined for UFS SCSI commands, responses, data in and
data out, task management, utility functions, vendor functions,
transaction synchronization and control, and more.
By using UPIUs, we get access to the most fine-grained internals of this
protocol, and able to communicate with the device in ways, that are
sometimes beyond the capacity of the ufs driver.
Moreover and as a result, our core structure - ufs_bsg_node has a pretty
lean structure: using upiu transactions that contains the outmost
detailed info, so we don't really need complex constructs to support it.
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2018-10-07 14:30:35 +00:00
|
|
|
|
|
|
|
/* If there was reply_payload, how much was received? */
|
2018-10-12 10:41:28 +00:00
|
|
|
__u32 reply_payload_rcv_len;
|
scsi: ufs: Add a bsg endpoint that supports UPIUs
For now, just provide an API to allocate and remove ufs-bsg node. We
will use this framework to manage ufs devices by sending UPIU
transactions.
For the time being, implements an empty bsg_request() - will add some
more functionality in coming patches.
Nonetheless, we reveal here the protocol we are planning to use: UFS
Transport Protocol Transactions. UFS transactions consist of packets
called UFS Protocol Information Units (UPIU).
There are UPIU’s defined for UFS SCSI commands, responses, data in and
data out, task management, utility functions, vendor functions,
transaction synchronization and control, and more.
By using UPIUs, we get access to the most fine-grained internals of this
protocol, and able to communicate with the device in ways, that are
sometimes beyond the capacity of the ufs driver.
Moreover and as a result, our core structure - ufs_bsg_node has a pretty
lean structure: using upiu transactions that contains the outmost
detailed info, so we don't really need complex constructs to support it.
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2018-10-07 14:30:35 +00:00
|
|
|
|
|
|
|
struct utp_upiu_req upiu_rsp;
|
|
|
|
};
|
2022-12-01 14:04:37 +00:00
|
|
|
|
|
|
|
struct ufs_rpmb_request {
|
|
|
|
struct ufs_bsg_request bsg_request;
|
|
|
|
struct ufs_ehs ehs_req;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ufs_rpmb_reply {
|
|
|
|
struct ufs_bsg_reply bsg_reply;
|
|
|
|
struct ufs_ehs ehs_rsp;
|
|
|
|
};
|
2018-10-07 14:30:34 +00:00
|
|
|
#endif /* UFS_BSG_H */
|