xref: /freebsd/sys/dev/rtwn/rtl8192c/r92c_fw_cmd.h (revision 2ff63af9b88c7413b7d71715b5532625752a248e)
1 /*-
2  * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
3  * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  *
17  * $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
18  */
19 
20 #ifndef R92C_FW_CMD_H
21 #define R92C_FW_CMD_H
22 
23 /*
24  * Host to firmware commands.
25  */
26 struct r92c_fw_cmd {
27 	uint8_t	id;
28 #define R92C_CMD_SET_PWRMODE		1
29 #define R92C_CMD_JOINBSS_RPT		2
30 #define R92C_CMD_RSVD_PAGE		3
31 #define R92C_CMD_RSSI_SETTING		5
32 #define R92C_CMD_MACID_CONFIG		6
33 
34 #define R92C_CMD_FLAG_EXT		0x80
35 
36 	uint8_t	msg[5];
37 } __packed __attribute__((aligned(4)));
38 
39 /* Structure for R92C_CMD_JOINBSS_RPT. */
40 struct r92c_fw_cmd_joinbss_rpt {
41 	uint8_t	mstatus;
42 #define R92C_MSTATUS_DISASSOC		0x00
43 #define R92C_MSTATUS_ASSOC		0x01
44 } __packed;
45 
46 /* Structure for R92C_CMD_SET_PWRMODE. */
47 struct r92c_fw_cmd_pwrmode {
48 	uint8_t	mode;
49 #define R92C_PWRMODE_CAM	0
50 #define R92C_PWRMODE_MIN	1
51 #define R92C_PWRMODE_MAX	2
52 #define R92C_PWRMODE_DTIM	3
53 #define R92C_PWRMODE_UAPSD_WMM	5
54 #define R92C_PWRMODE_UAPSD	6
55 #define R92C_PWRMODE_IBSS	7
56 
57 	uint8_t	smart_ps;
58 /* XXX undocumented */
59 #define R92C_PWRMODE_SMARTPS_NULLDATA	2
60 
61 	uint8_t	bcn_pass;	/* unit: beacon interval */
62 } __packed;
63 
64 /* Structure for R92C_CMD_RSVD_PAGE. */
65 struct r92c_fw_cmd_rsvdpage {
66 	uint8_t probe_resp;
67 	uint8_t ps_poll;
68 	uint8_t null_data;
69 } __packed;
70 
71 /* Structure for R92C_CMD_RSSI_SETTING. */
72 struct r92c_fw_cmd_rssi {
73 	uint8_t	macid;
74 	uint8_t	reserved;
75 	uint8_t	pwdb;
76 } __packed;
77 
78 /* Structure for R92C_CMD_MACID_CONFIG. */
79 struct r92c_fw_cmd_macid_cfg {
80 	uint32_t	mask;
81 	uint8_t		macid;
82 #define R92C_CMD_MACID_VALID	0x80
83 } __packed;
84 
85 /*
86  * C2H event structure.
87  */
88 /* Bigger value is used to prevent buffer overrun. */
89 #define R92C_C2H_MSG_MAX_LEN		16
90 
91 struct r92c_c2h_evt {
92 	uint8_t		evtb0;
93 #define R92C_C2H_EVTB0_ID_M		0x0f
94 #define R92C_C2H_EVTB0_ID_S		0
95 #define R92C_C2H_EVTB0_LEN_M		0xf0
96 #define R92C_C2H_EVTB0_LEN_S		4
97 
98 	uint8_t		seq;
99 
100 	/* Followed by payload (see below). */
101 } __packed;
102 
103 /*
104  * C2H event types.
105  */
106 #define R92C_C2H_EVT_DEBUG		0
107 #define R92C_C2H_EVT_TX_REPORT		3
108 #define R92C_C2H_EVT_EXT_RA_RPT		6
109 
110 /* Structure for R92C_C2H_EVT_TX_REPORT event. */
111 struct r92c_c2h_tx_rpt {
112 	uint8_t		rptb0;
113 #define R92C_RPTB0_RETRY_CNT_M		0x3f
114 #define R92C_RPTB0_RETRY_CNT_S		0
115 
116 	uint8_t		rptb1;		/* XXX junk */
117 #define R92C_RPTB1_RTS_RETRY_CNT_M	0x3f
118 #define R92C_RPTB1_RTS_RETRY_CNT_S	0
119 
120 	uint8_t		queue_time_low;
121 	uint8_t		queue_time_high;
122 	uint8_t		rptb4;
123 #define R92C_RPTB4_MISSED_PKT_NUM_M	0x1f
124 #define R92C_RPTB4_MISSED_PKT_NUM_S	0
125 
126 	uint8_t		rptb5;
127 #define R92C_RPTB5_MACID_M		0x1f
128 #define R92C_RPTB5_MACID_S		0
129 #define R92C_RPTB5_DES1_FRAGSSN_M	0xe0
130 #define R92C_RPTB5_DES1_FRAGSSN_S	5
131 
132 	uint8_t		rptb6;
133 #define R92C_RPTB6_RPT_PKT_NUM_M	0x1f
134 #define R92C_RPTB6_RPT_PKT_NUM_S	0
135 #define R92C_RPTB6_PKT_DROP		0x20
136 #define R92C_RPTB6_LIFE_EXPIRE		0x40
137 #define R92C_RPTB6_RETRY_OVER		0x80
138 
139 	uint8_t		rptb7;
140 #define R92C_RPTB7_EDCA_M		0x0f
141 #define R92C_RPTB7_EDCA_S		0
142 #define R92C_RPTB7_BMC			0x20
143 #define R92C_RPTB7_PKT_OK		0x40
144 #define R92C_RPTB7_INT_CCX		0x80
145 } __packed;
146 
147 #endif	/* R92C_FW_CMD_H */
148