summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/freescale/dpa/capwap/dpaa_capwap_domain.h
blob: 8fd8122d7d44526698c4cbbe86126a2e33a93064 (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
/* Copyright (c) 2014 Freescale Semiconductor, Inc.
 * All rights reserved.
 *
 * 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_DOMAIN_H
#define __DPAA_CAPWAP_DOMAIN_H

#include "fm_port_ext.h"
#include "fm_pcd_ext.h"
#include "dpaa_capwap_domain_ext.h"
#include "dpaa_capwap_desc.h"

#define OUTER_HEADER_MAX_SIZE 100
#define DTLS_KEY_MAX_SIZE 256
#define TABLE_KEY_MAX_SIZE FM_PCD_MAX_SIZE_OF_KEY

#define UDP_HDR_SIZE 8

enum e_PortType {
	e_CAPWAP_DOM_PORT_RXTX = 0,
	e_CAPWAP_DOM_PORT_SEC_DEC,
	e_CAPWAP_DOM_PORT_SEC_ENC,
	e_CAPWAP_DOM_PORT_OP_POST_DEC,
	e_CAPWAP_DOM_PORT_OP_OUT
};

struct qman_fq_chain {
	struct qman_fq *fq;
	struct list_head list;
};

struct dpaa_capwap_tunnel {
	enum dpaa_capwap_domain_direction tunnel_dir;
	uint32_t tunnel_id;
	uint16_t key_index;
	t_Handle dpaa_capwap_domain;
	t_Handle sec_desc;

	struct cipher_params cipher_data;
	struct auth_params auth_data;

	/* Tx internal info */
	t_Handle h_hm_capwap;
	t_Handle h_ccNode;
	t_Handle h_hm_l2;
	t_Handle h_hm_l3;
	t_Handle h_hm_l4;
	t_Handle h_capwap_frag;
	t_Handle h_capwap_manip;

	/* Rx Pre SEC internal info */
	uint8_t *p_key;
	uint8_t *p_mask;
	t_Handle h_hm_till_manip;

	struct list_head node;
	struct list_head fq_chain_head;
};

struct t_FmPcdInfo {
	t_Handle h_NetEnv;
	t_Handle h_CcTree;
	uint8_t numOfCcNodes;
	t_Handle h_CcNodes[5];
	t_Handle h_CcNodesOrder[5];
};

struct t_Port {
	enum e_PortType type;
	t_Handle h_DpaPort;
	t_Handle h_Domain;
	uint32_t rxPcdQsBase;
	uint32_t numOfTxQs;
	struct t_FmPcdInfo fmPcdInfo;
	uint8_t	fm_id;
	uint8_t	port_id;
	uint16_t tx_ch;
};

struct dpaa_capwap_domain {
	struct t_Port rx_tx_port;
	struct t_Port post_dec_op_port;
	struct t_Port out_op_port;

	t_Handle h_fm_pcd;

	uint32_t max_num_of_tunnels;
	bool support_ipv6;

	/* Tx internal info */
	t_Handle h_op_port;
	t_Handle h_flow_id_table;

	/* Rx Pre SEC internal info */
	uint8_t key_size;
	uint32_t key_fields;
	uint32_t mask_fields;
	t_Handle h_em_table;

	struct list_head in_tunnel_list;
	struct list_head out_tunnel_list;
	struct dpaa_capwap_sec_info secinfo;
	struct dpaa_capwap_domain_fqs *fqs;
	struct net_device *net_dev; /* Device for CAPWAP Ethernet */
	uint8_t bpid;
};

static inline struct dpaa_capwap_tunnel *dequeue_tunnel_obj(
		struct list_head *p_list)
{
	struct dpaa_capwap_tunnel *p_tunnel = NULL;
	struct list_head *p_next;

	if (!list_empty(p_list)) {
		p_next = p_list->next;
		p_tunnel = list_entry(p_next, struct dpaa_capwap_tunnel, node);
		list_del(p_next);
	}

	return p_tunnel;
}

static inline void enqueue_tunnel_obj(struct list_head *p_List,
				struct dpaa_capwap_tunnel *p_Tunnel)
{
	list_add_tail(&p_Tunnel->node, p_List);
}

int add_in_tunnel(struct dpaa_capwap_domain *capwap_domain,
		struct dpaa_capwap_tunnel *p_tunnel,
		struct dpaa_capwap_domain_tunnel_in_params *in_tunnel_params);

int add_out_tunnel(struct dpaa_capwap_domain *capwap_domain,
		struct dpaa_capwap_tunnel *p_tunnel,
		struct dpaa_capwap_domain_tunnel_out_params *out_tunnel_params);

struct dpaa_capwap_domain_fqs *get_domain_fqs(void);

int op_init(struct t_Port *port, struct net_device *net_dev);
int capwap_fq_pre_init(struct dpaa_capwap_domain *capwap_domain);
int capwap_tunnel_drv_init(struct dpaa_capwap_domain *domain);
uint8_t get_capwap_bpid(struct net_device *net_dev);
int capwap_br_init(struct dpaa_capwap_domain *domain);
uint16_t get_flow_index(bool is_dtls, bool is_control_tunnel);
int capwap_kernel_rx_ctl(struct capwap_domain_kernel_rx_ctl *rx_ctl);
struct dpaa_capwap_domain *dpaa_capwap_domain_config(
		struct dpaa_capwap_domain_params *new_capwap_domain);
int dpaa_capwap_domain_init(struct dpaa_capwap_domain *capwap_domain);
int dpaa_capwap_domain_remove_tunnel(struct dpaa_capwap_tunnel *p_tunnel);

#endif /* __DPAA_CAPWAP_DOMAIN_H */