Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / rtl8192su / r819xU_cmdpkt.h
1 #ifndef R819XUSB_CMDPKT_H
2 #define R819XUSB_CMDPKT_H
3
4 /*
5 * Different command packets have dedicated message length and definition.
6 */
7 #define CMPK_RX_TX_FB_SIZE sizeof(cmpk_txfb_t) /* 20 */
8 #define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */
9 #define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */
10 #define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t)
11 #define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t)
12 #define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t)
13
14 /* For USB constant. */
15 #define ISR_TxBcnOk BIT27 /* Transmit Beacon OK */
16 #define ISR_TxBcnErr BIT26 /* Transmit Beacon Error */
17 #define ISR_BcnTimerIntr BIT13 /* Beacon Timer Interrupt */
18
19 /*
20 * Define different command packet structures
21 *
22 * 1. RX side: TX feedback packet.
23 */
24 typedef struct tag_cmd_pkt_tx_feedback {
25 /* DWORD 0 */
26 u8 element_id; /* Command packet type. */
27 u8 length; /* Command packet length. */
28 /* TX Feedback Info Field */
29 u8 TID:4;
30 u8 fail_reason:3;
31 u8 tok:1; /* Transmit ok. */
32 u8 reserve1:4;
33 u8 pkt_type:2;
34 u8 bandwidth:1;
35 u8 qos_pkt:1;
36
37 /* DWORD 1 */
38 u8 reserve2;
39 /* TX Feedback Info Field */
40 u8 retry_cnt;
41 u16 pkt_id;
42
43 /* DWORD 3 */
44 u16 seq_num;
45 u8 s_rate; /* Start rate. */
46 u8 f_rate; /* Final rate. */
47
48 /* DWORD 4 */
49 u8 s_rts_rate;
50 u8 f_rts_rate;
51 u16 pkt_length;
52
53 /* DWORD 5 */
54 u16 reserve3;
55 u16 duration;
56 } cmpk_txfb_t;
57
58 /*
59 * 2. RX side: Interrupt status packet.
60 * It includes Beacon State, Beacon Timer Interrupt
61 * and other useful informations in MAC ISR Reg.
62 */
63 typedef struct tag_cmd_pkt_interrupt_status {
64 u8 element_id; /* Command packet type. */
65 u8 length; /* Command packet length. */
66 u16 reserve;
67 u32 interrupt_status; /* Interrupt Status. */
68 } cmpk_intr_sta_t;
69
70
71 /*
72 * 3. TX side: Set configuration packet.
73 */
74 typedef struct tag_cmd_pkt_set_configuration {
75 u8 element_id; /* Command packet type. */
76 u8 length; /* Command packet length. */
77 u16 reserve1;
78 u8 cfg_reserve1:3;
79 u8 cfg_size:2; /* Configuration info. */
80 u8 cfg_type:2; /* Configuration info. */
81 u8 cfg_action:1; /* Configuration info. */
82 u8 cfg_reserve2; /* Configuration info. */
83 u8 cfg_page:4; /* Configuration info. */
84 u8 cfg_reserve3:4; /* Configuration info. */
85 u8 cfg_offset; /* Configuration info. */
86 u32 value;
87 u32 mask;
88 } cmpk_set_cfg_t;
89
90 /*
91 * 4. Both side : TX/RX query configuraton packet.
92 * The query structure is the same as set configuration.
93 */
94 #define cmpk_query_cfg_t cmpk_set_cfg_t
95
96 /*
97 * 5. Multi packet feedback status.
98 */
99 typedef struct tag_tx_stats_feedback {
100 /*
101 * For endian transfer
102 * Driver will not the same as firmware structure.
103 */
104 /* DW 0 */
105 u16 reserve1;
106 u8 length; /* Command packet length */
107 u8 element_id; /* Command packet type */
108
109 /* DW 1 */
110 u16 txfail; /* Tx Fail count */
111 u16 txok; /* Tx ok count */
112
113 /* DW 2 */
114 u16 txmcok; /* tx multicast */
115 u16 txretry; /* Tx Retry count */
116
117 /* DW 3 */
118 u16 txucok; /* tx unicast */
119 u16 txbcok; /* tx broadcast */
120
121 /* DW 4 */
122 u16 txbcfail;
123 u16 txmcfail;
124
125 /* DW 5 */
126 u16 reserve2;
127 u16 txucfail;
128
129 /* DW 6-8 */
130 u32 txmclength;
131 u32 txbclength;
132 u32 txuclength;
133
134 /* DW 9 */
135 u16 reserve3_23;
136 u8 reserve3_1;
137 u8 rate;
138 } __attribute__((packed)) cmpk_tx_status_t;
139
140 /*
141 * 6. Debug feedback message.
142 */
143 typedef struct tag_rx_debug_message_feedback {
144 /* For endian transfer --> for driver */
145 /* DW 0 */
146 u16 reserve1;
147 u8 length; /* Command packet length */
148 u8 element_id; /* Command packet type */
149 } cmpk_rx_dbginfo_t;
150
151 /*
152 * Define transmit rate history. For big endian format.
153 */
154 typedef struct tag_tx_rate_history {
155 /* For endian transfer --> for driver */
156 /* DW 0 */
157 u8 element_id; /* Command packet type */
158 u8 length; /* Command packet length */
159 u16 reserved1;
160 /* DW 1-2 CCK rate counter */
161 u16 cck[4];
162 /* DW 3-6 */
163 u16 ofdm[8];
164 u16 ht_mcs[4][16];
165 } __attribute__((packed)) cmpk_tx_rahis_t;
166
167 typedef enum tag_command_packet_directories {
168 RX_TX_FEEDBACK = 0,
169 RX_INTERRUPT_STATUS = 1,
170 TX_SET_CONFIG = 2,
171 BOTH_QUERY_CONFIG = 3,
172 RX_TX_STATUS = 4,
173 RX_DBGINFO_FEEDBACK = 5,
174 RX_TX_PER_PKT_FEEDBACK = 6,
175 RX_TX_RATE_HISTORY = 7,
176 RX_CMD_ELE_MAX
177 } cmpk_element_e;
178
179 extern bool cmpk_message_handle_tx(struct net_device *dev,
180 u8 *codevirtualaddress,
181 u32 packettype,
182 u32 buffer_len);
183
184 extern u32 cmpk_message_handle_rx(struct net_device *dev,
185 struct ieee80211_rx_stats *pstats);
186
187 extern bool SendTxCommandPacket(struct net_device *dev,
188 void *pData,
189 u32 DataLen);
190
191 #endif