net/txgbe: add security session create operation
[dpdk.git] / drivers / net / txgbe / txgbe_ipsec.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020
3  */
4
5 #ifndef TXGBE_IPSEC_H_
6 #define TXGBE_IPSEC_H_
7
8 #include <rte_ethdev.h>
9 #include <rte_ethdev_core.h>
10 #include <rte_security.h>
11
12 #define IPSRXMOD_VALID                                    0x00000001
13 #define IPSRXMOD_PROTO                                    0x00000004
14 #define IPSRXMOD_DECRYPT                                  0x00000008
15 #define IPSRXMOD_IPV6                                     0x00000010
16
17 #define IPSEC_MAX_RX_IP_COUNT           128
18 #define IPSEC_MAX_SA_COUNT              1024
19
20 enum txgbe_operation {
21         TXGBE_OP_AUTHENTICATED_ENCRYPTION,
22         TXGBE_OP_AUTHENTICATED_DECRYPTION
23 };
24
25 /**
26  * Generic IP address structure
27  * TODO: Find better location for this rte_net.h possibly.
28  **/
29 struct ipaddr {
30         enum ipaddr_type {
31                 IPv4,
32                 IPv6
33         } type;
34         /**< IP Address Type - IPv4/IPv6 */
35
36         union {
37                 uint32_t ipv4;
38                 uint32_t ipv6[4];
39         };
40 };
41
42 /** inline crypto private session structure */
43 struct txgbe_crypto_session {
44         enum txgbe_operation op;
45         const uint8_t *key;
46         uint32_t key_len;
47         uint32_t salt;
48         uint32_t sa_index;
49         uint32_t spi;
50         struct ipaddr src_ip;
51         struct ipaddr dst_ip;
52         struct rte_eth_dev *dev;
53 } __rte_cache_aligned;
54
55 struct txgbe_crypto_rx_ip_table {
56         struct ipaddr ip;
57         uint16_t ref_count;
58 };
59 struct txgbe_crypto_rx_sa_table {
60         uint32_t spi;
61         uint32_t ip_index;
62         uint8_t  mode;
63         uint8_t  used;
64 };
65
66 struct txgbe_crypto_tx_sa_table {
67         uint32_t spi;
68         uint8_t  used;
69 };
70
71 struct txgbe_ipsec {
72         struct txgbe_crypto_rx_ip_table rx_ip_tbl[IPSEC_MAX_RX_IP_COUNT];
73         struct txgbe_crypto_rx_sa_table rx_sa_tbl[IPSEC_MAX_SA_COUNT];
74         struct txgbe_crypto_tx_sa_table tx_sa_tbl[IPSEC_MAX_SA_COUNT];
75 };
76
77 #endif /*TXGBE_IPSEC_H_*/