1 From 70eb620ed6d38e171e5619313e99d31688d25010 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Horia=20Geant=C4=83?= <horia.geanta@nxp.com>
3 Date: Wed, 10 Oct 2018 16:07:50 +0300
4 Subject: [PATCH] crypto: caam/qi2 - add OPR (Order Preservation) support
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 During driver upstreaming OPR was removed due to lacking users.
10 Add OPR back, since in LSDK / LSDK-based ADKs there is at least
11 one user (ASF / VortiQa IPsec).
13 Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
15 drivers/crypto/caam/dpseci.c | 85 ++++++++++++++++++++++++++++++++++++++++
16 drivers/crypto/caam/dpseci.h | 26 +++++++++++-
17 drivers/crypto/caam/dpseci_cmd.h | 51 ++++++++++++++++++++++++
18 3 files changed, 160 insertions(+), 2 deletions(-)
20 --- a/drivers/crypto/caam/dpseci.c
21 +++ b/drivers/crypto/caam/dpseci.c
25 #include <linux/fsl/mc.h>
26 +#include <soc/fsl/dpaa2-io.h>
28 #include "dpseci_cmd.h"
30 @@ -675,6 +676,90 @@ int dpseci_get_api_version(struct fsl_mc
36 + * dpseci_set_opr() - Set Order Restoration configuration
37 + * @mc_io: Pointer to MC portal's I/O object
38 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
39 + * @token: Token of DPSECI object
40 + * @index: The queue index
41 + * @options: Configuration mode options; can be OPR_OPT_CREATE or
43 + * @cfg: Configuration options for the OPR
45 + * Return: '0' on success, error code otherwise
47 +int dpseci_set_opr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u8 index,
48 + u8 options, struct opr_cfg *cfg)
50 + struct fsl_mc_command cmd = { 0 };
51 + struct dpseci_cmd_opr *cmd_params;
53 + cmd.header = mc_encode_cmd_header(
54 + DPSECI_CMDID_SET_OPR,
57 + cmd_params = (struct dpseci_cmd_opr *)cmd.params;
58 + cmd_params->index = index;
59 + cmd_params->options = options;
60 + cmd_params->oloe = cfg->oloe;
61 + cmd_params->oeane = cfg->oeane;
62 + cmd_params->olws = cfg->olws;
63 + cmd_params->oa = cfg->oa;
64 + cmd_params->oprrws = cfg->oprrws;
66 + return mc_send_command(mc_io, &cmd);
70 + * dpseci_get_opr() - Retrieve Order Restoration config and query
71 + * @mc_io: Pointer to MC portal's I/O object
72 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
73 + * @token: Token of DPSECI object
74 + * @index: The queue index
75 + * @cfg: Returned OPR configuration
76 + * @qry: Returned OPR query
78 + * Return: '0' on success, error code otherwise
80 +int dpseci_get_opr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u8 index,
81 + struct opr_cfg *cfg, struct opr_qry *qry)
83 + struct fsl_mc_command cmd = { 0 };
84 + struct dpseci_cmd_opr *cmd_params;
85 + struct dpseci_rsp_get_opr *rsp_params;
88 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_OPR,
91 + cmd_params = (struct dpseci_cmd_opr *)cmd.params;
92 + cmd_params->index = index;
93 + err = mc_send_command(mc_io, &cmd);
97 + rsp_params = (struct dpseci_rsp_get_opr *)cmd.params;
98 + qry->rip = dpseci_get_field(rsp_params->flags, OPR_RIP);
99 + qry->enable = dpseci_get_field(rsp_params->flags, OPR_ENABLE);
100 + cfg->oloe = rsp_params->oloe;
101 + cfg->oeane = rsp_params->oeane;
102 + cfg->olws = rsp_params->olws;
103 + cfg->oa = rsp_params->oa;
104 + cfg->oprrws = rsp_params->oprrws;
105 + qry->nesn = le16_to_cpu(rsp_params->nesn);
106 + qry->ndsn = le16_to_cpu(rsp_params->ndsn);
107 + qry->ea_tseq = le16_to_cpu(rsp_params->ea_tseq);
108 + qry->tseq_nlis = dpseci_get_field(rsp_params->tseq_nlis, OPR_TSEQ_NLIS);
109 + qry->ea_hseq = le16_to_cpu(rsp_params->ea_hseq);
110 + qry->hseq_nlis = dpseci_get_field(rsp_params->hseq_nlis, OPR_HSEQ_NLIS);
111 + qry->ea_hptr = le16_to_cpu(rsp_params->ea_hptr);
112 + qry->ea_tptr = le16_to_cpu(rsp_params->ea_tptr);
113 + qry->opr_vid = le16_to_cpu(rsp_params->opr_vid);
114 + qry->opr_id = le16_to_cpu(rsp_params->opr_id);
120 * dpseci_set_congestion_notification() - Set congestion group
121 --- a/drivers/crypto/caam/dpseci.h
122 +++ b/drivers/crypto/caam/dpseci.h
131 * General DPSECI macros
132 @@ -38,9 +40,21 @@ int dpseci_close(struct fsl_mc_io *mc_io
133 #define DPSECI_OPT_HAS_CG 0x000020
136 + * Enable the Order Restoration support
138 +#define DPSECI_OPT_HAS_OPR 0x000040
141 + * Order Point Records are shared for the entire DPSECI
143 +#define DPSECI_OPT_OPR_SHARED 0x000080
146 * struct dpseci_cfg - Structure representing DPSECI configuration
147 - * @options: Any combination of the following flags:
148 + * @options: Any combination of the following options:
150 + * DPSECI_OPT_HAS_OPR
151 + * DPSECI_OPT_OPR_SHARED
152 * @num_tx_queues: num of queues towards the SEC
153 * @num_rx_queues: num of queues back from the SEC
154 * @priorities: Priorities for the SEC hardware processing;
155 @@ -93,8 +107,10 @@ int dpseci_clear_irq_status(struct fsl_m
156 * @id: DPSECI object ID
157 * @num_tx_queues: number of queues towards the SEC
158 * @num_rx_queues: number of queues back from the SEC
159 - * @options: any combination of the following flags:
160 + * @options: any combination of the following options:
162 + * DPSECI_OPT_HAS_OPR
163 + * DPSECI_OPT_OPR_SHARED
167 @@ -301,6 +317,12 @@ int dpseci_get_sec_counters(struct fsl_m
168 int dpseci_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
169 u16 *major_ver, u16 *minor_ver);
171 +int dpseci_set_opr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u8 index,
172 + u8 options, struct opr_cfg *cfg);
174 +int dpseci_get_opr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u8 index,
175 + struct opr_cfg *cfg, struct opr_qry *qry);
178 * enum dpseci_congestion_unit - DPSECI congestion units
179 * @DPSECI_CONGESTION_UNIT_BYTES: bytes units
180 --- a/drivers/crypto/caam/dpseci_cmd.h
181 +++ b/drivers/crypto/caam/dpseci_cmd.h
183 #define DPSECI_CMDID_GET_TX_QUEUE DPSECI_CMD_V1(0x197)
184 #define DPSECI_CMDID_GET_SEC_ATTR DPSECI_CMD_V2(0x198)
185 #define DPSECI_CMDID_GET_SEC_COUNTERS DPSECI_CMD_V1(0x199)
186 +#define DPSECI_CMDID_SET_OPR DPSECI_CMD_V1(0x19A)
187 +#define DPSECI_CMDID_GET_OPR DPSECI_CMD_V1(0x19B)
188 #define DPSECI_CMDID_SET_CONGESTION_NOTIFICATION DPSECI_CMD_V1(0x170)
189 #define DPSECI_CMDID_GET_CONGESTION_NOTIFICATION DPSECI_CMD_V1(0x171)
191 @@ -189,6 +191,55 @@ struct dpseci_rsp_get_api_version {
195 +struct dpseci_cmd_opr {
207 +#define DPSECI_OPR_RIP_SHIFT 0
208 +#define DPSECI_OPR_RIP_SIZE 1
209 +#define DPSECI_OPR_ENABLE_SHIFT 1
210 +#define DPSECI_OPR_ENABLE_SIZE 1
211 +#define DPSECI_OPR_TSEQ_NLIS_SHIFT 0
212 +#define DPSECI_OPR_TSEQ_NLIS_SIZE 1
213 +#define DPSECI_OPR_HSEQ_NLIS_SHIFT 0
214 +#define DPSECI_OPR_HSEQ_NLIS_SIZE 1
216 +struct dpseci_rsp_get_opr {
244 #define DPSECI_CGN_DEST_TYPE_SHIFT 0
245 #define DPSECI_CGN_DEST_TYPE_SIZE 4
246 #define DPSECI_CGN_UNITS_SHIFT 4