xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/ssv6xxx/smac/sec.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (c) 2015 South Silicon Valley Microelectronics Inc.
3  * Copyright (c) 2015 iComm Corporation
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef SEC_H
18 #define SEC_H
19 #include <linux/types.h>
20 #include <linux/ieee80211.h>
21 #include <net/mac80211.h>
22 #define CCMP_TK_LEN 16
23 #define TKIP_KEY_LEN 32
24 #define WEP_KEY_LEN 13
25 struct ssv_crypto_ops {
26  const char *name;
27  struct list_head list;
28  void *(*init) (int keyidx);
29  void (*deinit) (void *priv);
30  int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
31  int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
32  int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv);
33  int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len,
34         void *priv);
35  int (*set_tx_pn) (u8 * seq, void *priv);
36  int (*set_key) (void *key, int len, u8 * seq, void *priv);
37  int (*get_key) (void *key, int len, u8 * seq, void *priv);
38  char *(*print_stats) (char *p, void *priv);
39  unsigned long (*get_flags) (void *priv);
40  unsigned long (*set_flags) (unsigned long flags, void *priv);
41 #ifdef MULTI_THREAD_ENCRYPT
42  int (*encrypt_prepare) (struct sk_buff * skb, int hdr_len, void *priv);
43  int (*decrypt_prepare) (struct sk_buff * skb, int hdr_len, void *priv);
44 #endif
45  int extra_mpdu_prefix_len, extra_mpdu_postfix_len;
46  int extra_msdu_prefix_len, extra_msdu_postfix_len;
47 };
48 struct ssv_crypto_data {
49     struct ssv_crypto_ops *ops;
50     void *priv;
51     #ifdef HAS_CRYPTO_LOCK
52     rwlock_t lock;
53     #endif
54 };
55 struct ssv_crypto_ops *get_crypto_ccmp_ops(void);
56 struct ssv_crypto_ops *get_crypto_tkip_ops(void);
57 struct ssv_crypto_ops *get_crypto_wep_ops(void);
58 #ifdef CONFIG_SSV_WAPI
59 struct ssv_crypto_ops *get_crypto_wpi_ops(void);
60 #endif
61 #endif
62