65 #include <linux/kernel.h>
66 #include <linux/module.h>
69 #include <linux/netdevice.h>
81 static int iwl_testmode_send_cmd(
struct iwl_op_mode *op_mode,
88 static bool iwl_testmode_valid_hw_addr(
u32 addr)
103 return priv->
fw->ucode_ver;
110 return cfg80211_testmode_alloc_reply_skb(priv->
hw->wiphy, len);
115 return cfg80211_testmode_reply(skb);
122 return cfg80211_testmode_alloc_event_skb(priv->
hw->wiphy, len,
128 return cfg80211_testmode_event(skb,
GFP_ATOMIC);
132 .send_cmd = iwl_testmode_send_cmd,
133 .valid_hw_addr = iwl_testmode_valid_hw_addr,
134 .get_fw_ver = iwl_testmode_get_fw_ver,
135 .alloc_reply = iwl_testmode_alloc_reply,
136 .reply = iwl_testmode_reply,
137 .alloc_event = iwl_testmode_alloc_event,
138 .event = iwl_testmode_event,
151 static int iwl_testmode_cfg_init_calib(
struct iwl_priv *
priv)
154 static const u8 calib_complete[] = {
164 IWL_ERR(priv,
"Fail init calibration: %d\n", ret);
165 goto cfg_init_calib_error;
170 IWL_ERR(priv,
"Error detecting"
171 " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret);
174 cfg_init_calib_error:
200 unsigned char *rsp_data_ptr =
NULL;
201 int status = 0, rsp_data_len = 0;
207 rsp_data_ptr = (
unsigned char *)priv->
cfg->name;
209 skb = cfg80211_testmode_alloc_reply_skb(hw->
wiphy,
212 IWL_ERR(priv,
"Memory allocation fail\n");
215 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
218 rsp_data_len, rsp_data_ptr))
219 goto nla_put_failure;
220 status = cfg80211_testmode_reply(skb);
222 IWL_ERR(priv,
"Error sending msg : %d\n", status);
228 IWL_ERR(priv,
"Error loading init ucode: %d\n", status);
232 iwl_testmode_cfg_init_calib(priv);
234 iwl_trans_stop_device(trans);
241 "Error loading runtime ucode: %d\n", status);
247 "Error starting the device: %d\n", status);
253 iwl_trans_stop_device(trans);
257 "Error loading WOWLAN ucode: %d\n", status);
263 "Error starting the device: %d\n", status);
268 skb = cfg80211_testmode_alloc_reply_skb(hw->
wiphy,
271 IWL_ERR(priv,
"Memory allocation fail\n");
274 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
279 goto nla_put_failure;
280 status = cfg80211_testmode_reply(skb);
282 IWL_ERR(priv,
"Error sending msg : %d\n",
290 IWL_ERR(priv,
"Missing fixrate setting\n");
293 priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]);
297 skb = cfg80211_testmode_alloc_reply_skb(hw->
wiphy, 20 + 8);
299 IWL_ERR(priv,
"Memory allocation fail\n");
303 IWL_ERR(priv,
"No uCode has not been loaded\n");
313 goto nla_put_failure;
314 status = cfg80211_testmode_reply(skb);
316 IWL_ERR(priv,
"Error sending msg : %d\n", status);
320 IWL_ERR(priv,
"Unknown testmode driver command ID\n");
351 IWL_ERR(priv,
"Missing ucode owner\n");
355 owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]);
358 iwl_test_enable_notifications(&priv->tst,
false);
361 iwl_test_enable_notifications(&priv->tst,
true);
363 IWL_ERR(priv,
"Invalid owner\n");
400 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
424 result = iwl_testmode_driver(hw, tb);
429 result = iwl_testmode_ownership(hw, tb);
433 IWL_ERR(priv,
"Unknown testmode command\n");
440 IWL_ERR(priv,
"Test cmd failed result=%d\n", result);
454 cmd = cb->
args[3] - 1;
462 cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]);
463 cb->
args[3] = cmd + 1;