net:wireless:Support eswin usb wifi ECR6600U
[platform/kernel/linux-starfive.git] / drivers / net / wireless / eswin / fullmac / ecrnx_rx.h
1 /**
2  ******************************************************************************
3  *
4  * @file ecrnx_rx.h
5  *
6  * Copyright (C) ESWIN 2015-2020
7  *
8  ******************************************************************************
9  */
10 #ifndef _ECRNX_RX_H_
11 #define _ECRNX_RX_H_
12
13 #include <linux/workqueue.h>
14 #include "hal_desc.h"
15 enum rx_status_bits
16 {
17     /// The buffer can be forwarded to the networking stack
18     RX_STAT_FORWARD = 1 << 0,
19     /// A new buffer has to be allocated
20     RX_STAT_ALLOC = 1 << 1,
21     /// The buffer has to be deleted
22     RX_STAT_DELETE = 1 << 2,
23     /// The length of the buffer has to be updated
24     RX_STAT_LEN_UPDATE = 1 << 3,
25     /// The length in the Ethernet header has to be updated
26     RX_STAT_ETH_LEN_UPDATE = 1 << 4,
27     /// Simple copy
28     RX_STAT_COPY = 1 << 5,
29     /// Spurious frame (inform upper layer and discard)
30     RX_STAT_SPURIOUS = 1 << 6,
31     /// packet for monitor interface
32     RX_STAT_MONITOR = 1 << 7,
33 };
34
35 #if defined(CONFIG_ECRNX_ESWIN_USB)
36 typedef enum
37 {
38     MSG_TYPE_DATA = 1,
39     MSG_TYPE_CTRL
40 }MSG_TYPE_E;
41 #endif
42
43 /*
44  * Decryption status subfields.
45  * {
46  */
47 // @}
48
49 #define _ASOCREQ_IE_OFFSET_     4   /* excluding wlan_hdr */
50 #define _REASOCREQ_IE_OFFSET_   10
51 #define STATION_INFO_ASSOC_REQ_IES 0
52 #define WLAN_HDR_A3_LEN            24
53 #define get_addr2_ptr(pbuf)     ((unsigned char *)((unsigned int)(pbuf) + 10))
54
55 /* keep it same with the FW */
56 #define RX_CNTRL_REORD_WIN_SIZE 42
57 #ifdef CONFIG_ECRNX_MON_DATA
58 #define RX_MACHDR_BACKUP_LEN    64
59 /// MAC header backup descriptor
60 struct mon_machdrdesc
61 {
62     /// Length of the buffer
63     u32 buf_len;
64     /// Buffer containing mac header, LLC and SNAP
65     u8 buffer[RX_MACHDR_BACKUP_LEN];
66 };
67 #endif
68
69 struct hw_rxhdr {
70     /** RX vector */
71     struct hw_vect hwvect;
72
73     /** PHY channel information */
74     struct phy_channel_info_desc phy_info;
75
76     /** RX flags */
77     u32    flags_is_amsdu     : 1;
78     u32    flags_is_80211_mpdu: 1;
79     u32    flags_is_4addr     : 1;
80     u32    flags_new_peer     : 1;
81     u32    flags_user_prio    : 3;
82     u32    flags_rsvd0        : 1;
83     u32    flags_vif_idx      : 8;    // 0xFF if invalid VIF index
84     u32    flags_sta_idx      : 8;    // 0xFF if invalid STA index
85     u32    flags_dst_idx      : 8;    // 0xFF if unknown destination STA
86 #ifdef CONFIG_ECRNX_MON_DATA
87     /// MAC header backup descriptor (used only for MSDU when there is a monitor and a data interface)
88     struct mon_machdrdesc mac_hdr_backup;
89 #endif
90     /** Pattern indicating if the buffer is available for the driver */
91     u32    pattern;
92 };
93
94 struct ecrnx_defer_rx {
95     struct sk_buff_head sk_list;
96     struct work_struct work;
97 };
98
99 /**
100  * struct ecrnx_defer_rx_cb - Control buffer for deferred buffers
101  *
102  * @vif: VIF that received the buffer
103  */
104 struct ecrnx_defer_rx_cb {
105     struct ecrnx_vif *vif;
106 };
107
108 u8 ecrnx_unsup_rx_vec_ind(void *pthis, void *hostid);
109 u8 ecrnx_rxdataind(void *pthis, void *hostid);
110 void ecrnx_rx_deferred(struct work_struct *ws);
111 void ecrnx_rx_defer_skb(struct ecrnx_hw *ecrnx_hw, struct ecrnx_vif *ecrnx_vif,
112                        struct sk_buff *skb);
113 #ifdef CONFIG_ECRNX_ESWIN_SDIO
114 int ecrnx_rx_callback(void *priv, struct sk_buff *skb);
115 #elif defined(CONFIG_ECRNX_ESWIN_USB)
116 int ecrnx_rx_callback(void *priv, struct sk_buff *skb, uint8_t endpoint);
117 #endif
118
119 void ecrnx_rx_reord_deinit(struct ecrnx_hw *ecrnx_hw);
120 void ecrnx_rx_reord_init(struct ecrnx_hw *ecrnx_hw);
121 void ecrnx_rx_reord_sta_init(struct ecrnx_hw* ecrnx_hw, struct ecrnx_vif *ecrnx_vif, u8 sta_idx);
122 void ecrnx_rx_reord_sta_deinit(struct ecrnx_hw* ecrnx_hw, u8 sta_idx, bool is_del);
123
124
125 #endif /* _ECRNX_RX_H_ */