1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2017 Oracle and/or its affiliates. All rights reserved. */
3 
4 #ifndef _IXGBE_IPSEC_H_
5 #define _IXGBE_IPSEC_H_
6 
7 #define IXGBE_IPSEC_MAX_SA_COUNT	1024
8 #define IXGBE_IPSEC_MAX_RX_IP_COUNT	128
9 #define IXGBE_IPSEC_BASE_RX_INDEX	0
10 #define IXGBE_IPSEC_BASE_TX_INDEX	IXGBE_IPSEC_MAX_SA_COUNT
11 #define IXGBE_IPSEC_AUTH_BITS		128
12 
13 #define IXGBE_RXTXIDX_IPS_EN		0x00000001
14 #define IXGBE_RXIDX_TBL_SHIFT		1
15 enum ixgbe_ipsec_tbl_sel {
16 	ips_rx_ip_tbl	=	0x01,
17 	ips_rx_spi_tbl	=	0x02,
18 	ips_rx_key_tbl	=	0x03,
19 };
20 
21 #define IXGBE_RXTXIDX_IDX_SHIFT		3
22 #define IXGBE_RXTXIDX_READ		0x40000000
23 #define IXGBE_RXTXIDX_WRITE		0x80000000
24 
25 #define IXGBE_RXMOD_VALID		0x00000001
26 #define IXGBE_RXMOD_PROTO_ESP		0x00000004
27 #define IXGBE_RXMOD_DECRYPT		0x00000008
28 #define IXGBE_RXMOD_IPV6		0x00000010
29 
30 struct rx_sa {
31 	struct hlist_node hlist;
32 	struct xfrm_state *xs;
33 	__be32 ipaddr[4];
34 	u32 key[4];
35 	u32 salt;
36 	u32 mode;
37 	u8  iptbl_ind;
38 	bool used;
39 	bool decrypt;
40 };
41 
42 struct rx_ip_sa {
43 	__be32 ipaddr[4];
44 	u32 ref_cnt;
45 	bool used;
46 };
47 
48 struct tx_sa {
49 	struct xfrm_state *xs;
50 	u32 key[4];
51 	u32 salt;
52 	bool encrypt;
53 	bool used;
54 };
55 
56 struct ixgbe_ipsec_tx_data {
57 	u32 flags;
58 	u16 trailer_len;
59 	u16 sa_idx;
60 };
61 
62 struct ixgbe_ipsec {
63 	u16 num_rx_sa;
64 	u16 num_tx_sa;
65 	struct rx_ip_sa *ip_tbl;
66 	struct rx_sa *rx_tbl;
67 	struct tx_sa *tx_tbl;
68 	DECLARE_HASHTABLE(rx_sa_list, 10);
69 };
70 #endif /* _IXGBE_IPSEC_H_ */
71