144603Sdcs/* SPDX-License-Identifier: GPL-2.0 */
244603Sdcs/* Copyright(c) 2017 Oracle and/or its affiliates. All rights reserved. */
344603Sdcs
444603Sdcs#ifndef _IXGBE_IPSEC_H_
544603Sdcs#define _IXGBE_IPSEC_H_
644603Sdcs
744603Sdcs#define IXGBE_IPSEC_MAX_SA_COUNT	1024
844603Sdcs#define IXGBE_IPSEC_MAX_RX_IP_COUNT	128
950477Speter#define IXGBE_IPSEC_BASE_RX_INDEX	0
1044603Sdcs#define IXGBE_IPSEC_BASE_TX_INDEX	IXGBE_IPSEC_MAX_SA_COUNT
1144603Sdcs#define IXGBE_IPSEC_AUTH_BITS		128
1244603Sdcs
1344603Sdcs#define IXGBE_RXTXIDX_IPS_EN		0x00000001
1444603Sdcs#define IXGBE_RXIDX_TBL_SHIFT		1
1544603Sdcsenum ixgbe_ipsec_tbl_sel {
1644603Sdcs	ips_rx_ip_tbl	=	0x01,
1765785Sdcs	ips_rx_spi_tbl	=	0x02,
1865785Sdcs	ips_rx_key_tbl	=	0x03,
19135986Sru};
2044603Sdcs
2197201Sgordon#define IXGBE_RXTXIDX_IDX_SHIFT		3
2297201Sgordon#define IXGBE_RXTXIDX_READ		0x40000000
2397201Sgordon#define IXGBE_RXTXIDX_WRITE		0x80000000
2444603Sdcs
2544603Sdcs#define IXGBE_RXMOD_VALID		0x00000001
2644603Sdcs#define IXGBE_RXMOD_PROTO_ESP		0x00000004
2744603Sdcs#define IXGBE_RXMOD_DECRYPT		0x00000008
2844603Sdcs#define IXGBE_RXMOD_IPV6		0x00000010
2944603Sdcs#define IXGBE_RXTXMOD_VF		0x00000020
3044603Sdcs
3144603Sdcsstruct rx_sa {
3247171Sdcs	struct hlist_node hlist;
3347171Sdcs	struct xfrm_state *xs;
3444603Sdcs	__be32 ipaddr[4];
3544603Sdcs	u32 key[4];
3665939Sdcs	u32 salt;
3765939Sdcs	u32 mode;
38137344Skrion	u8  iptbl_ind;
3944603Sdcs	bool used;
4044603Sdcs	bool decrypt;
4144603Sdcs	u32 vf;
4244603Sdcs};
4344603Sdcs
4444603Sdcsstruct rx_ip_sa {
45146421Ssobomax	__be32 ipaddr[4];
46146421Ssobomax	u32 ref_cnt;
47146421Ssobomax	bool used;
48146421Ssobomax};
49117090Sbrueffer
50149213Siedowsestruct tx_sa {
51148515Sbrian	struct xfrm_state *xs;
5254247Sdcs	u32 key[4];
53133217Sjmg	u32 salt;
5452749Sdcs	u32 mode;
5554247Sdcs	bool encrypt;
5654247Sdcs	bool used;
5744603Sdcs	u32 vf;
5844603Sdcs};
5944603Sdcs
6044603Sdcsstruct ixgbe_ipsec_tx_data {
6144603Sdcs	u32 flags;
6244603Sdcs	u16 trailer_len;
63148515Sbrian	u16 sa_idx;
64148515Sbrian};
65148515Sbrian
66148515Sbrianstruct ixgbe_ipsec {
67148515Sbrian	u16 num_rx_sa;
68148515Sbrian	u16 num_tx_sa;
69148515Sbrian	struct rx_ip_sa *ip_tbl;
70148515Sbrian	struct rx_sa *rx_tbl;
71148515Sbrian	struct tx_sa *tx_tbl;
72148515Sbrian	DECLARE_HASHTABLE(rx_sa_list, 10);
73148515Sbrian};
74148515Sbrian
75142009Sdesstruct sa_mbx_msg {
7654265Smsmith	__be32 spi;
7744603Sdcs	u8 dir;
7844603Sdcs	u8 proto;
7944603Sdcs	u16 family;
8044603Sdcs	__be32 addr[4];
8144603Sdcs	u32 key[5];
8244603Sdcs};
83132853Sceri#endif /* _IXGBE_IPSEC_H_ */
8499332Smini