Bean Huo <beanhuo@iokpp.de> says: This series of changes is to add support for UFS advanced RPMB in ufs_bsg. The advanced RPMB application of user space is ufs_utils, the reference code is at: https://github.com/beanhuo/ufs-utils-Micron/blob/ufs_arpmb/ufs_arpmb.c. Changes to ufs_utils will be pushed to: https://github.com/westerndigitalcorporation/ufs-utils
Showing the changes to include/uapi (1 of 6 files). Show all
Unified · Split
| @@ -14,10 +14,27 @@ · 13 unmodified lines | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #define UFS_CDB_SIZE 16 | 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 */ | 17 | /* uic commands are 4DW long, per UFSHCI V2.1 paragraph 5.6.1 */ |
| 19 | #define UIC_CMD_SIZE (sizeof(__u32) * 4) | 18 | #define UIC_CMD_SIZE (sizeof(__u32) * 4) |
| 20 | 19 | ||
| 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 | |||
| 21 | /** | 38 | /** |
| 22 | * struct utp_upiu_header - UPIU header structure | 39 | * struct utp_upiu_header - UPIU header structure |
| 23 | * @dword_0: UPIU header DW-0 | 40 | * @dword_0: UPIU header DW-0 |
| @@ -79,6 +96,23 @@ struct utp_upiu_req { · 55 unmodified lines | |||
| 79 | }; | 96 | }; |
| 80 | }; | 97 | }; |
| 81 | 98 | ||
| 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 | |||
| 82 | /* request (CDB) structure of the sg_io_v4 */ | 116 | /* request (CDB) structure of the sg_io_v4 */ |
| 83 | struct ufs_bsg_request { | 117 | struct ufs_bsg_request { |
| 84 | __u32 msgcode; | 118 | __u32 msgcode; |
| @@ -95,11 +129,21 @@ struct ufs_bsg_reply { · 10 unmodified lines | |||
| 95 | * msg and status fields. The per-msgcode reply structure | 129 | * msg and status fields. The per-msgcode reply structure |
| 96 | * will contain valid data. | 130 | * will contain valid data. |
| 97 | */ | 131 | */ |
| 98 | __u32 result; | 132 | int result; |
| 99 | 133 | ||
| 100 | /* If there was reply_payload, how much was received? */ | 134 | /* If there was reply_payload, how much was received? */ |
| 101 | __u32 reply_payload_rcv_len; | 135 | __u32 reply_payload_rcv_len; |
| 102 | 136 | ||
| 103 | struct utp_upiu_req upiu_rsp; | 137 | struct utp_upiu_req upiu_rsp; |
| 104 | }; | 138 | }; |
| 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 | }; | ||
| 105 | #endif /* UFS_BSG_H */ | 149 | #endif /* UFS_BSG_H */ |