xref: /linux/drivers/net/wireless/marvell/libertas/cmd.h (revision cea0f76a483d1270ac6f6513964e3e75193dda48)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2007, Red Hat, Inc. */
3 
4 #ifndef _LBS_CMD_H_
5 #define _LBS_CMD_H_
6 
7 #include <net/cfg80211.h>
8 
9 #include "host.h"
10 #include "dev.h"
11 
12 
13 /* Command & response transfer between host and card */
14 
15 struct cmd_ctrl_node {
16 	struct list_head list;
17 	int result;
18 	/* command response */
19 	int (*callback)(struct lbs_private *,
20 			unsigned long,
21 			struct cmd_header *);
22 	unsigned long callback_arg;
23 	/* command data */
24 	struct cmd_header *cmdbuf;
25 	/* wait queue */
26 	u16 cmdwaitqwoken;
27 	wait_queue_head_t cmdwait_q;
28 };
29 
30 
31 /* lbs_cmd() infers the size of the buffer to copy data back into, from
32    the size of the target of the pointer. Since the command to be sent
33    may often be smaller, that size is set in cmd->size by the caller.*/
34 #define lbs_cmd(priv, cmdnr, cmd, cb, cb_arg)	({		\
35 	uint16_t __sz = le16_to_cpu((cmd)->hdr.size);		\
36 	(cmd)->hdr.size = cpu_to_le16(sizeof(*(cmd)));		\
37 	__lbs_cmd(priv, cmdnr, &(cmd)->hdr, __sz, cb, cb_arg);	\
38 })
39 
40 #define lbs_cmd_with_response(priv, cmdnr, cmd)	\
41 	lbs_cmd(priv, cmdnr, cmd, lbs_cmd_copyback, (unsigned long) (cmd))
42 
43 void lbs_cmd_async(struct lbs_private *priv, uint16_t command,
44 	struct cmd_header *in_cmd, int in_cmd_size);
45 
46 int __lbs_cmd(struct lbs_private *priv, uint16_t command,
47 	      struct cmd_header *in_cmd, int in_cmd_size,
48 	      int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
49 	      unsigned long callback_arg);
50 
51 struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv,
52 	uint16_t command, struct cmd_header *in_cmd, int in_cmd_size,
53 	int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
54 	unsigned long callback_arg);
55 
56 int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
57 		     struct cmd_header *resp);
58 
59 int lbs_allocate_cmd_buffer(struct lbs_private *priv);
60 int lbs_free_cmd_buffer(struct lbs_private *priv);
61 
62 int lbs_execute_next_command(struct lbs_private *priv);
63 void __lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
64 			    int result);
65 void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
66 			  int result);
67 int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len);
68 
69 
70 /* From cmdresp.c */
71 
72 void lbs_mac_event_disconnected(struct lbs_private *priv,
73 				bool locally_generated);
74 
75 
76 
77 /* Events */
78 
79 void lbs_process_event(struct lbs_private *priv, u32 event);
80 
81 
82 /* Actual commands */
83 
84 int lbs_update_hw_spec(struct lbs_private *priv);
85 
86 int lbs_set_channel(struct lbs_private *priv, u8 channel);
87 
88 int lbs_update_channel(struct lbs_private *priv);
89 
90 int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria,
91 		struct wol_config *p_wol_config);
92 
93 int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action,
94 				struct sleep_params *sp);
95 
96 void lbs_ps_confirm_sleep(struct lbs_private *priv);
97 
98 int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on);
99 
100 void lbs_set_mac_control(struct lbs_private *priv);
101 int lbs_set_mac_control_sync(struct lbs_private *priv);
102 
103 int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel,
104 		     s16 *maxlevel);
105 
106 int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val);
107 
108 int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val);
109 
110 
111 /* Commands only used in wext.c, assoc. and scan.c */
112 
113 int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0,
114 		int8_t p1, int8_t p2);
115 
116 int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1,
117 		int8_t p2, int usesnr);
118 
119 int lbs_set_data_rate(struct lbs_private *priv, u8 rate);
120 
121 int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv,
122 				      uint16_t cmd_action);
123 
124 int lbs_set_tx_power(struct lbs_private *priv, s16 dbm);
125 
126 int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep);
127 
128 int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep);
129 
130 int lbs_set_monitor_mode(struct lbs_private *priv, int enable);
131 
132 int lbs_get_rssi(struct lbs_private *priv, s8 *snr, s8 *nf);
133 
134 int lbs_set_11d_domain_info(struct lbs_private *priv);
135 
136 int lbs_get_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 *value);
137 
138 int lbs_set_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 value);
139 
140 int lbs_set_ps_mode(struct lbs_private *priv, u16 cmd_action, bool block);
141 
142 #endif /* _LBS_CMD_H */
143