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 #define IXGBE_RXTXMOD_VF 0x00000020 30 31 struct rx_sa { 32 struct hlist_node hlist; 33 struct xfrm_state *xs; 34 __be32 ipaddr[4]; 35 u32 key[4]; 36 u32 salt; 37 u32 mode; 38 u8 iptbl_ind; 39 bool used; 40 bool decrypt; 41 u32 vf; 42 }; 43 44 struct rx_ip_sa { 45 __be32 ipaddr[4]; 46 u32 ref_cnt; 47 bool used; 48 }; 49 50 struct tx_sa { 51 struct xfrm_state *xs; 52 u32 key[4]; 53 u32 salt; 54 u32 mode; 55 bool encrypt; 56 bool used; 57 u32 vf; 58 }; 59 60 struct ixgbe_ipsec_tx_data { 61 u32 flags; 62 u16 trailer_len; 63 u16 sa_idx; 64 }; 65 66 struct ixgbe_ipsec { 67 u16 num_rx_sa; 68 u16 num_tx_sa; 69 struct rx_ip_sa *ip_tbl; 70 struct rx_sa *rx_tbl; 71 struct tx_sa *tx_tbl; 72 DECLARE_HASHTABLE(rx_sa_list, 10); 73 }; 74 75 struct sa_mbx_msg { 76 __be32 spi; 77 u8 flags; 78 u8 proto; 79 u16 family; 80 __be32 addr[4]; 81 u32 key[5]; 82 }; 83 #endif /* _IXGBE_IPSEC_H_ */ 84