25 #include <linux/slab.h>
34 #define WL1271_TM_MAX_DATA_LENGTH 1024
48 #define WL1271_TM_CMD_MAX (__WL1271_TM_CMD_AFTER_LAST - 1)
60 #define WL1271_TM_ATTR_MAX (__WL1271_TM_ATTR_AFTER_LAST - 1)
72 static int wl1271_tm_cmd_test(
struct wl1271 *wl,
struct nlattr *
tb[])
84 buf = nla_data(tb[WL1271_TM_ATTR_DATA]);
85 buf_len = nla_len(tb[WL1271_TM_ATTR_DATA]);
88 answer = nla_get_u8(tb[WL1271_TM_ATTR_ANSWER]);
125 len = nla_total_size(buf_len);
126 skb = cfg80211_testmode_alloc_reply_skb(wl->
hw->wiphy, len);
132 if (
nla_put(skb, WL1271_TM_ATTR_DATA, buf_len, buf)) {
138 ret = cfg80211_testmode_reply(skb);
151 static int wl1271_tm_cmd_interrogate(
struct wl1271 *wl,
struct nlattr *tb[])
163 ie_id = nla_get_u8(tb[WL1271_TM_ATTR_IE_ID]);
188 skb = cfg80211_testmode_alloc_reply_skb(wl->
hw->wiphy,
sizeof(*cmd));
194 if (
nla_put(skb, WL1271_TM_ATTR_DATA,
sizeof(*cmd), cmd)) {
200 ret = cfg80211_testmode_reply(skb);
214 static int wl1271_tm_cmd_configure(
struct wl1271 *wl,
struct nlattr *tb[])
222 if (!tb[WL1271_TM_ATTR_DATA])
224 if (!tb[WL1271_TM_ATTR_IE_ID])
227 ie_id = nla_get_u8(tb[WL1271_TM_ATTR_IE_ID]);
228 buf = nla_data(tb[WL1271_TM_ATTR_DATA]);
229 buf_len = nla_len(tb[WL1271_TM_ATTR_DATA]);
246 static int wl1271_tm_detect_fem(
struct wl1271 *wl,
struct nlattr *tb[])
258 len = nla_total_size(
sizeof(wl->
fem_manuf));
259 skb = cfg80211_testmode_alloc_reply_skb(wl->
hw->wiphy, len);
272 ret = cfg80211_testmode_reply(skb);
283 static int wl1271_tm_cmd_set_plt_mode(
struct wl1271 *wl,
struct nlattr *tb[])
293 val = nla_get_u32(tb[WL1271_TM_ATTR_PLT_MODE]);
303 ret = wl1271_tm_detect_fem(wl, tb);
313 static int wl12xx_tm_cmd_get_mac(
struct wl1271 *wl,
struct nlattr *tb[])
338 skb = cfg80211_testmode_alloc_reply_skb(wl->
hw->wiphy,
ETH_ALEN);
350 ret = cfg80211_testmode_reply(skb);
372 switch (nla_get_u32(tb[WL1271_TM_ATTR_CMD_ID])) {
374 return wl1271_tm_cmd_test(wl, tb);
376 return wl1271_tm_cmd_interrogate(wl, tb);
378 return wl1271_tm_cmd_configure(wl, tb);
380 return wl1271_tm_cmd_set_plt_mode(wl, tb);
382 return wl12xx_tm_cmd_get_mac(wl, tb);