net/txgbe: destroy security session
[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 #define ESP_ICV_SIZE 16
21 #define ESP_TRAILER_SIZE 2
22
23 enum txgbe_operation {
24         TXGBE_OP_AUTHENTICATED_ENCRYPTION,
25         TXGBE_OP_AUTHENTICATED_DECRYPTION
26 };
27
28 /**
29  * Generic IP address structure
30  * TODO: Find better location for this rte_net.h possibly.
31  **/
32 struct ipaddr {
33         enum ipaddr_type {
34                 IPv4,
35                 IPv6
36         } type;
37         /**< IP Address Type - IPv4/IPv6 */
38
39         union {
40                 uint32_t ipv4;
41                 uint32_t ipv6[4];
42         };
43 };
44
45 /** inline crypto private session structure */
46 struct txgbe_crypto_session {
47         enum txgbe_operation op;
48         const uint8_t *key;
49         uint32_t key_len;
50         uint32_t salt;
51         uint32_t sa_index;
52         uint32_t spi;
53         struct ipaddr src_ip;
54         struct ipaddr dst_ip;
55         struct rte_eth_dev *dev;
56 } __rte_cache_aligned;
57
58 struct txgbe_crypto_rx_ip_table {
59         struct ipaddr ip;
60         uint16_t ref_count;
61 };
62 struct txgbe_crypto_rx_sa_table {
63         uint32_t spi;
64         uint32_t ip_index;
65         uint8_t  mode;
66         uint8_t  used;
67 };
68
69 struct txgbe_crypto_tx_sa_table {
70         uint32_t spi;
71         uint8_t  used;
72 };
73
74 union txgbe_crypto_tx_desc_md {
75         uint64_t data;
76         struct {
77                 /**< SA table index */
78                 uint32_t sa_idx;
79                 /**< ICV and ESP trailer length */
80                 uint8_t pad_len;
81                 /**< enable encryption */
82                 uint8_t enc;
83         };
84 };
85
86 struct txgbe_ipsec {
87         struct txgbe_crypto_rx_ip_table rx_ip_tbl[IPSEC_MAX_RX_IP_COUNT];
88         struct txgbe_crypto_rx_sa_table rx_sa_tbl[IPSEC_MAX_SA_COUNT];
89         struct txgbe_crypto_tx_sa_table tx_sa_tbl[IPSEC_MAX_SA_COUNT];
90 };
91
92 #endif /*TXGBE_IPSEC_H_*/