Skip to content

Commit cf1ea88

Browse files
committed
Merge tag 'mmc-v6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull mmc cleanup from Ulf Hansson: "Move rpmb_frame struct and constants to rpmb common header This helps us to avoid sharing an immutable branch between our git trees. I was planning to send it before rc1, but I didn't make it" * tag 'mmc-v6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: rpmb: move rpmb_frame struct and constants to common header
2 parents 1422424 + 7e82424 commit cf1ea88

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

drivers/mmc/core/block.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -79,48 +79,6 @@ MODULE_ALIAS("mmc:block");
7979
#define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16)
8080
#define MMC_EXTRACT_VALUE_FROM_ARG(x) ((x & 0x0000FF00) >> 8)
8181

82-
/**
83-
* struct rpmb_frame - rpmb frame as defined by eMMC 5.1 (JESD84-B51)
84-
*
85-
* @stuff : stuff bytes
86-
* @key_mac : The authentication key or the message authentication
87-
* code (MAC) depending on the request/response type.
88-
* The MAC will be delivered in the last (or the only)
89-
* block of data.
90-
* @data : Data to be written or read by signed access.
91-
* @nonce : Random number generated by the host for the requests
92-
* and copied to the response by the RPMB engine.
93-
* @write_counter: Counter value for the total amount of the successful
94-
* authenticated data write requests made by the host.
95-
* @addr : Address of the data to be programmed to or read
96-
* from the RPMB. Address is the serial number of
97-
* the accessed block (half sector 256B).
98-
* @block_count : Number of blocks (half sectors, 256B) requested to be
99-
* read/programmed.
100-
* @result : Includes information about the status of the write counter
101-
* (valid, expired) and result of the access made to the RPMB.
102-
* @req_resp : Defines the type of request and response to/from the memory.
103-
*
104-
* The stuff bytes and big-endian properties are modeled to fit to the spec.
105-
*/
106-
struct rpmb_frame {
107-
u8 stuff[196];
108-
u8 key_mac[32];
109-
u8 data[256];
110-
u8 nonce[16];
111-
__be32 write_counter;
112-
__be16 addr;
113-
__be16 block_count;
114-
__be16 result;
115-
__be16 req_resp;
116-
} __packed;
117-
118-
#define RPMB_PROGRAM_KEY 0x1 /* Program RPMB Authentication Key */
119-
#define RPMB_GET_WRITE_COUNTER 0x2 /* Read RPMB write counter */
120-
#define RPMB_WRITE_DATA 0x3 /* Write data to RPMB partition */
121-
#define RPMB_READ_DATA 0x4 /* Read data from RPMB partition */
122-
#define RPMB_RESULT_READ 0x5 /* Read result request (Internal) */
123-
12482
#define RPMB_FRAME_SIZE sizeof(struct rpmb_frame)
12583
#define CHECK_SIZE_NEQ(val) ((val) != sizeof(struct rpmb_frame))
12684
#define CHECK_SIZE_ALIGNED(val) IS_ALIGNED((val), sizeof(struct rpmb_frame))

include/linux/rpmb.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,50 @@ struct rpmb_dev {
6161

6262
#define to_rpmb_dev(x) container_of((x), struct rpmb_dev, dev)
6363

64+
/**
65+
* struct rpmb_frame - RPMB frame structure for authenticated access
66+
*
67+
* @stuff : stuff bytes, a padding/reserved area of 196 bytes at the
68+
* beginning of the RPMB frame. They don’t carry meaningful
69+
* data but are required to make the frame exactly 512 bytes.
70+
* @key_mac : The authentication key or the message authentication
71+
* code (MAC) depending on the request/response type.
72+
* The MAC will be delivered in the last (or the only)
73+
* block of data.
74+
* @data : Data to be written or read by signed access.
75+
* @nonce : Random number generated by the host for the requests
76+
* and copied to the response by the RPMB engine.
77+
* @write_counter: Counter value for the total amount of the successful
78+
* authenticated data write requests made by the host.
79+
* @addr : Address of the data to be programmed to or read
80+
* from the RPMB. Address is the serial number of
81+
* the accessed block (half sector 256B).
82+
* @block_count : Number of blocks (half sectors, 256B) requested to be
83+
* read/programmed.
84+
* @result : Includes information about the status of the write counter
85+
* (valid, expired) and result of the access made to the RPMB.
86+
* @req_resp : Defines the type of request and response to/from the memory.
87+
*
88+
* The stuff bytes and big-endian properties are modeled to fit to the spec.
89+
*/
90+
struct rpmb_frame {
91+
u8 stuff[196];
92+
u8 key_mac[32];
93+
u8 data[256];
94+
u8 nonce[16];
95+
__be32 write_counter;
96+
__be16 addr;
97+
__be16 block_count;
98+
__be16 result;
99+
__be16 req_resp;
100+
};
101+
102+
#define RPMB_PROGRAM_KEY 0x1 /* Program RPMB Authentication Key */
103+
#define RPMB_GET_WRITE_COUNTER 0x2 /* Read RPMB write counter */
104+
#define RPMB_WRITE_DATA 0x3 /* Write data to RPMB partition */
105+
#define RPMB_READ_DATA 0x4 /* Read data from RPMB partition */
106+
#define RPMB_RESULT_READ 0x5 /* Read result request (Internal) */
107+
64108
#if IS_ENABLED(CONFIG_RPMB)
65109
struct rpmb_dev *rpmb_dev_get(struct rpmb_dev *rdev);
66110
void rpmb_dev_put(struct rpmb_dev *rdev);

0 commit comments

Comments
 (0)