18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright(c) 2017 Oracle and/or its affiliates. All rights reserved. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _IXGBE_IPSEC_H_
58c2ecf20Sopenharmony_ci#define _IXGBE_IPSEC_H_
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#define IXGBE_IPSEC_MAX_SA_COUNT	1024
88c2ecf20Sopenharmony_ci#define IXGBE_IPSEC_MAX_RX_IP_COUNT	128
98c2ecf20Sopenharmony_ci#define IXGBE_IPSEC_BASE_RX_INDEX	0
108c2ecf20Sopenharmony_ci#define IXGBE_IPSEC_BASE_TX_INDEX	IXGBE_IPSEC_MAX_SA_COUNT
118c2ecf20Sopenharmony_ci#define IXGBE_IPSEC_AUTH_BITS		128
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define IXGBE_RXTXIDX_IPS_EN		0x00000001
148c2ecf20Sopenharmony_ci#define IXGBE_RXIDX_TBL_SHIFT		1
158c2ecf20Sopenharmony_cienum ixgbe_ipsec_tbl_sel {
168c2ecf20Sopenharmony_ci	ips_rx_ip_tbl	=	0x01,
178c2ecf20Sopenharmony_ci	ips_rx_spi_tbl	=	0x02,
188c2ecf20Sopenharmony_ci	ips_rx_key_tbl	=	0x03,
198c2ecf20Sopenharmony_ci};
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define IXGBE_RXTXIDX_IDX_SHIFT		3
228c2ecf20Sopenharmony_ci#define IXGBE_RXTXIDX_READ		0x40000000
238c2ecf20Sopenharmony_ci#define IXGBE_RXTXIDX_WRITE		0x80000000
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define IXGBE_RXMOD_VALID		0x00000001
268c2ecf20Sopenharmony_ci#define IXGBE_RXMOD_PROTO_ESP		0x00000004
278c2ecf20Sopenharmony_ci#define IXGBE_RXMOD_DECRYPT		0x00000008
288c2ecf20Sopenharmony_ci#define IXGBE_RXMOD_IPV6		0x00000010
298c2ecf20Sopenharmony_ci#define IXGBE_RXTXMOD_VF		0x00000020
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistruct rx_sa {
328c2ecf20Sopenharmony_ci	struct hlist_node hlist;
338c2ecf20Sopenharmony_ci	struct xfrm_state *xs;
348c2ecf20Sopenharmony_ci	__be32 ipaddr[4];
358c2ecf20Sopenharmony_ci	u32 key[4];
368c2ecf20Sopenharmony_ci	u32 salt;
378c2ecf20Sopenharmony_ci	u32 mode;
388c2ecf20Sopenharmony_ci	u8  iptbl_ind;
398c2ecf20Sopenharmony_ci	bool used;
408c2ecf20Sopenharmony_ci	bool decrypt;
418c2ecf20Sopenharmony_ci	u32 vf;
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistruct rx_ip_sa {
458c2ecf20Sopenharmony_ci	__be32 ipaddr[4];
468c2ecf20Sopenharmony_ci	u32 ref_cnt;
478c2ecf20Sopenharmony_ci	bool used;
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_cistruct tx_sa {
518c2ecf20Sopenharmony_ci	struct xfrm_state *xs;
528c2ecf20Sopenharmony_ci	u32 key[4];
538c2ecf20Sopenharmony_ci	u32 salt;
548c2ecf20Sopenharmony_ci	u32 mode;
558c2ecf20Sopenharmony_ci	bool encrypt;
568c2ecf20Sopenharmony_ci	bool used;
578c2ecf20Sopenharmony_ci	u32 vf;
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cistruct ixgbe_ipsec_tx_data {
618c2ecf20Sopenharmony_ci	u32 flags;
628c2ecf20Sopenharmony_ci	u16 trailer_len;
638c2ecf20Sopenharmony_ci	u16 sa_idx;
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistruct ixgbe_ipsec {
678c2ecf20Sopenharmony_ci	u16 num_rx_sa;
688c2ecf20Sopenharmony_ci	u16 num_tx_sa;
698c2ecf20Sopenharmony_ci	struct rx_ip_sa *ip_tbl;
708c2ecf20Sopenharmony_ci	struct rx_sa *rx_tbl;
718c2ecf20Sopenharmony_ci	struct tx_sa *tx_tbl;
728c2ecf20Sopenharmony_ci	DECLARE_HASHTABLE(rx_sa_list, 10);
738c2ecf20Sopenharmony_ci};
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistruct sa_mbx_msg {
768c2ecf20Sopenharmony_ci	__be32 spi;
778c2ecf20Sopenharmony_ci	u8 flags;
788c2ecf20Sopenharmony_ci	u8 proto;
798c2ecf20Sopenharmony_ci	u16 family;
808c2ecf20Sopenharmony_ci	__be32 addr[4];
818c2ecf20Sopenharmony_ci	u32 key[5];
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci#endif /* _IXGBE_IPSEC_H_ */
84