summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/freescale/dpa/capwap/dpaa_capwap_desc.h
blob: dd76acdea6d42021f82731aeaaabb08c9524c183 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* Copyright 2014 Freescale Semiconductor, Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Freescale Semiconductor nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 *
 * ALTERNATIVELY, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") as published by the Free Software
 * Foundation, either version 2 of that License or (at your option) any
 * later version.
 *
 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __DPAA_CAPWAP_DESC_H__
#define __DPAA_CAPWAP_DESC_H__

#include "pdb.h"
#include "desc_constr.h"

/* DPA CAPWAP Cipher Parameters */
struct cipher_params {
	uint16_t cipher_type;	 /* Algorithm type as defined by SEC driver   */
	uint8_t *cipher_key;	 /* Address to the encryption key	      */
	uint32_t cipher_key_len; /* Length in bytes of the normal key         */
};

/* DPA CAPWAP Authentication Parameters */
struct auth_params {
	uint32_t auth_type;	/* Algorithm type as defined by SEC driver    */
	uint8_t *auth_key;	/* Address to the normal key		      */
	uint32_t auth_key_len;	/* Length in bytes of the normal key          */
	uint8_t *split_key;	/* Address to the generated split key         */
	uint32_t split_key_len;	/* Length in bytes of the split key           */
	uint32_t split_key_pad_len;/* Length in bytes of the padded split key */
};

struct dpaa_capwap_sec_info {
	int sec_era; /* SEC ERA information */
	int sec_ver; /* SEC version information */
	struct device *jrdev; /* Job ring device */
};

/* DPA CAPWAP cipher & authentication algorithm identifiers */
struct capwap_alg_suite {
	uint32_t        auth_alg;
	uint32_t        cipher_alg;
};

#define CAPWAP_ALGS_ENTRY(auth, cipher)	{\
	.auth_alg = OP_ALG_ALGSEL_ ## auth,\
	.cipher_alg = OP_PCL_DTLS_ ## cipher\
}

#define CAPWAP_ALGS	{\
	CAPWAP_ALGS_ENTRY(SHA1, DES_CBC_SHA_2),		\
	CAPWAP_ALGS_ENTRY(MD5, DES_CBC_MD5),		\
	CAPWAP_ALGS_ENTRY(MD5, 3DES_EDE_CBC_MD5),	\
	CAPWAP_ALGS_ENTRY(SHA1, 3DES_EDE_CBC_SHA160),	\
	CAPWAP_ALGS_ENTRY(SHA384, 3DES_EDE_CBC_SHA384),	\
	CAPWAP_ALGS_ENTRY(SHA224, 3DES_EDE_CBC_SHA224),	\
	CAPWAP_ALGS_ENTRY(SHA512, 3DES_EDE_CBC_SHA512),	\
	CAPWAP_ALGS_ENTRY(SHA256, 3DES_EDE_CBC_SHA256),	\
	CAPWAP_ALGS_ENTRY(SHA1, AES_256_CBC_SHA160),	\
	CAPWAP_ALGS_ENTRY(SHA384, AES_256_CBC_SHA384),	\
	CAPWAP_ALGS_ENTRY(SHA224, AES_256_CBC_SHA224),	\
	CAPWAP_ALGS_ENTRY(SHA512, AES_256_CBC_SHA512),	\
	CAPWAP_ALGS_ENTRY(SHA256, AES_256_CBC_SHA256),	\
	CAPWAP_ALGS_ENTRY(SHA1, AES_128_CBC_SHA160),	\
	CAPWAP_ALGS_ENTRY(SHA384, AES_128_CBC_SHA384),	\
	CAPWAP_ALGS_ENTRY(SHA224, AES_128_CBC_SHA224),	\
	CAPWAP_ALGS_ENTRY(SHA512, AES_128_CBC_SHA512),	\
	CAPWAP_ALGS_ENTRY(SHA256, AES_128_CBC_SHA256),	\
	CAPWAP_ALGS_ENTRY(SHA1, AES_192_CBC_SHA160),	\
	CAPWAP_ALGS_ENTRY(SHA384, AES_192_CBC_SHA384),	\
	CAPWAP_ALGS_ENTRY(SHA224, AES_192_CBC_SHA224),	\
	CAPWAP_ALGS_ENTRY(SHA512, AES_192_CBC_SHA512),	\
	CAPWAP_ALGS_ENTRY(SHA256, AES_192_CBC_SHA256)	\
}

struct preheader_t {
	union {
		uint32_t word;
		struct {
			unsigned int rsls:1;
			unsigned int rsvd1_15:15;
			unsigned int rsvd16_24:9;
			unsigned int idlen:7;
		} field;
	} __packed hi;

	union {
		uint32_t word;
		struct {
			unsigned int rsvd32_33:2;
			unsigned int fsgt:1;
			unsigned int lng:1;
			unsigned int offset:2;
			unsigned int abs:1;
			unsigned int add_buf:1;
			uint8_t pool_id;
			uint16_t pool_buffer_size;
		} field;
	} __packed lo;
} __packed;

struct init_descriptor_header_t {
	union {
		uint32_t word;
		struct {
			unsigned int ctype:5;
			unsigned int rsvd5_6:2;
			unsigned int dnr:1;
			unsigned int one:1;
			unsigned int rsvd9:1;
			unsigned int start_idx:6;
			unsigned int zro:1;
			unsigned int rsvd17_18:2;
			unsigned int sc:1;
			unsigned int propogate_dnr:1;
			unsigned int rsvd21:1;
			unsigned int share:2;
			unsigned int rsvd24_25:2;
			unsigned int desc_len:6;
		} field;
	} __packed command;
} __packed;

struct dtls_encap_descriptor_t {
	struct preheader_t prehdr;
	struct init_descriptor_header_t deschdr;
	struct dtls_block_encap_pdb pdb;
	/* DCL library will fill following info */
	uint32_t data_move_cmd[3];	/* For Storing Data Move Cmd */
	uint32_t jump_cmd;		/* For Storing Jump Command */
	uint32_t auth_key[13];		/* Max Space for storing auth Key */
	uint32_t enc_key[7];		/* Max Space for storing enc Key */
	uint32_t operation_cmd;		/* For operation Command */
} __packed;

struct dtls_decap_descriptor_t {
	struct preheader_t prehdr;
	struct init_descriptor_header_t deschdr;
	struct dtls_block_decap_pdb pdb;
	/* DCL library will fill following info */
	uint32_t data_move_cmd[3];	/* For Storing Data Move Cmd */
	uint32_t jump_cmd;		/* For Storing Jump Command */
	uint32_t auth_key[13];		/* Max Space for storing auth Key */
	uint32_t dec_key[7];		/* Max Space for storing dec Key */
	uint32_t operation_cmd;		/* For operation Command */
} __packed;

#define SEC_DEF_VER 40 /* like in P4080 */
#define SEC_VER_5_3 53

int get_sec_info(struct dpaa_capwap_sec_info *secinfo);

int generate_split_key(struct auth_params *auth_param,
			struct dpaa_capwap_sec_info *secinfo);

void cnstr_shdsc_dtls_decap(uint32_t *desc,
					   uint16_t *bufsize,
					   struct cipher_params *cipherdata,
					   struct auth_params *authdata,
					   uint32_t data_move_size);

void cnstr_shdsc_dtls_encap(uint32_t *desc,
					   uint16_t *bufsize,
					   struct cipher_params *cipherdata,
					   struct auth_params *authdata,
					   uint32_t data_move_size);

#endif /* __DPAA_CAPWAP_DESC_H__ */