History

scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg

Add advanced RPMB support in ufs_bsg: 1. According to the UFS specification, only one RPMB operation can be performed at any time. We can ensure this by using reserved slot and its dev_cmd sync operation protection mechanism. 2. For Advanced RPMB, RPMB metadata is packaged in an EHS (Extra Header Segment) of a command UPIU, and the corresponding reply EHS (from the device) should also be returned to the user space. bsg_job->request and bsg_job->reply allow us to pass and return EHS from/back to userspace. Compared to normal/legacy RPMB, the advantages of advanced RPMB are: 1. The data length in the Advanced RPMB data read/write command can be larger than 4KB. For the legacy RPMB, the data length in a single RPMB data transfer is 256 bytes. 2. All of the advanced RPMB operations will be a single command. For legacy RPMB, take the read write-counter value as an example, you need two commands (first SECURITY PROTOCOL OUT, then second SECURITY PROTOCOL IN).

Bean Huo committed 3 years ago

Commit 6ff265f1 parent a4b1c9b6 files · +242 −12Browse files

Showing the changes to include/uapi (1 of 6 files). Show all

Unified · Split

include/uapi/scsi/scsi_bsg_ufs.h+45−1
@@ -14,10 +14,27 @@ · 13 unmodified lines
1414 */
1515
1616 #define UFS_CDB_SIZE 16
17−#define UPIU_TRANSACTION_UIC_CMD 0x1F
1817 /* uic commands are 4DW long, per UFSHCI V2.1 paragraph 5.6.1 */
1918 #define UIC_CMD_SIZE (sizeof(__u32) * 4)
2019
20+enum ufs_bsg_msg_code {
21+ UPIU_TRANSACTION_UIC_CMD = 0x1F,
22+ UPIU_TRANSACTION_ARPMB_CMD,
23+};
24+
25+/* UFS RPMB Request Message Types */
26+enum ufs_rpmb_op_type {
27+ UFS_RPMB_WRITE_KEY = 0x01,
28+ UFS_RPMB_READ_CNT = 0x02,
29+ UFS_RPMB_WRITE = 0x03,
30+ UFS_RPMB_READ = 0x04,
31+ UFS_RPMB_READ_RESP = 0x05,
32+ UFS_RPMB_SEC_CONF_WRITE = 0x06,
33+ UFS_RPMB_SEC_CONF_READ = 0x07,
34+ UFS_RPMB_PURGE_ENABLE = 0x08,
35+ UFS_RPMB_PURGE_STATUS_READ = 0x09,
36+};
37+
2138 /**
2239 * struct utp_upiu_header - UPIU header structure
2340 * @dword_0: UPIU header DW-0
@@ -79,6 +96,23 @@ struct utp_upiu_req { · 55 unmodified lines
7996 };
8097 };
8198
99+struct ufs_arpmb_meta {
100+ __u16 req_resp_type;
101+ __u8 nonce[16];
102+ __u32 write_counter;
103+ __u16 addr_lun;
104+ __u16 block_count;
105+ __u16 result;
106+} __attribute__((__packed__));
107+
108+struct ufs_ehs {
109+ __u8 length;
110+ __u8 ehs_type;
111+ __u16 ehssub_type;
112+ struct ufs_arpmb_meta meta;
113+ __u8 mac_key[32];
114+} __attribute__((__packed__));
115+
82116 /* request (CDB) structure of the sg_io_v4 */
83117 struct ufs_bsg_request {
84118 __u32 msgcode;
@@ -102,4 +136,14 @@ struct ufs_bsg_reply { · 17 unmodified lines
102136
103137 struct utp_upiu_req upiu_rsp;
104138 };
139+
140+struct ufs_rpmb_request {
141+ struct ufs_bsg_request bsg_request;
142+ struct ufs_ehs ehs_req;
143+};
144+
145+struct ufs_rpmb_reply {
146+ struct ufs_bsg_reply bsg_reply;
147+ struct ufs_ehs ehs_rsp;
148+};
105149 #endif /* UFS_BSG_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t