int wl12xx_acx_tsf_info(struct wl1271 *wl, struct wl12xx_vif *wlvif, u64 *mactime) { struct wl12xx_acx_fw_tsf_information *tsf_info; int ret; tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL); if (!tsf_info) { ret = -ENOMEM; goto out; } tsf_info->role_id = wlvif->role_id; ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO, tsf_info, sizeof(*tsf_info)); if (ret < 0) { wl1271_warning("acx tsf info interrogate failed"); goto out; } *mactime = le32_to_cpu(tsf_info->current_tsf_low) | ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32); out: kfree(tsf_info); return ret; }
int wl12xx_acx_sta_get_rssi(struct wl1271 *wl, struct wl12xx_vif *wlvif, int *rssi) { struct wl12xx_acx_roaming_statistics *stat_info; int ret; wl1271_debug(DEBUG_ACX, "acx roaming statistics table"); stat_info = kzalloc(sizeof(*stat_info), GFP_KERNEL); if (!stat_info) return -ENOMEM; stat_info->role_id = wlvif->role_id; ret = wl1271_cmd_interrogate(wl, ACX_ROAMING_STATISTICS_TBL, stat_info, sizeof(*stat_info)); if (ret < 0) { wl1271_warning("Reading acx roaming statistics" " table failed: %d", ret); goto out; } *rssi = stat_info->rssi_beacon; out: kfree(stat_info); return ret; }
int wlcore_acx_average_rssi(struct wl1271 *wl, struct wl12xx_vif *wlvif, s8 *avg_rssi) { struct acx_roaming_stats *acx; int ret = 0; wl1271_debug(DEBUG_ACX, "acx roaming statistics"); acx = kzalloc(sizeof(*acx), GFP_KERNEL); if (!acx) { ret = -ENOMEM; goto out; } acx->role_id = wlvif->role_id; ret = wl1271_cmd_interrogate(wl, ACX_ROAMING_STATISTICS_TBL, acx, sizeof(*acx), sizeof(*acx)); if (ret < 0) { wl1271_warning("acx roaming statistics failed: %d", ret); ret = -ENOMEM; goto out; } *avg_rssi = acx->rssi_beacon; out: kfree(acx); return ret; }
int wl1271_acx_fw_version(struct wl1271 *wl, char *buf, size_t len) { struct acx_revision *rev; int ret; wl1271_debug(DEBUG_ACX, "acx fw rev"); rev = kzalloc(sizeof(*rev), GFP_KERNEL); if (!rev) { ret = -ENOMEM; goto out; } ret = wl1271_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev)); if (ret < 0) { wl1271_warning("ACX_FW_REV interrogate failed"); goto out; } /* be careful with the buffer sizes */ strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); /* * if the firmware version string is exactly * sizeof(rev->fw_version) long or fw_len is less than * sizeof(rev->fw_version) it won't be null terminated */ buf[min(len, sizeof(rev->fw_version)) - 1] = '\0'; out: kfree(rev); return ret; }
int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map, size_t len) { int ret; wl1271_debug(DEBUG_ACX, "acx mem map"); ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len); if (ret < 0) return ret; return 0; }
int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats) { int ret; wl1271_debug(DEBUG_ACX, "acx statistics"); ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats, sizeof(*stats)); if (ret < 0) { wl1271_warning("acx statistics failed: %d", ret); return -ENOMEM; } return 0; }
static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) { int ret; struct wl1271_command *cmd; struct sk_buff *skb; u8 ie_id; wl1271_debug(DEBUG_TESTMODE, "testmode cmd interrogate"); if (!tb[WL1271_TM_ATTR_IE_ID]) return -EINVAL; ie_id = nla_get_u8(tb[WL1271_TM_ATTR_IE_ID]); cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); if (!cmd) return -ENOMEM; mutex_lock(&wl->mutex); ret = wl1271_cmd_interrogate(wl, ie_id, cmd, sizeof(*cmd)); mutex_unlock(&wl->mutex); if (ret < 0) { wl1271_warning("testmode cmd interrogate failed: %d", ret); kfree(cmd); return ret; } skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, sizeof(*cmd)); if (!skb) { kfree(cmd); return -ENOMEM; } NLA_PUT(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd); return 0; nla_put_failure: kfree_skb(skb); return -EMSGSIZE; }
static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) { int ret; struct wl1271_command *cmd; struct sk_buff *skb; u8 ie_id; wl1271_debug(DEBUG_TESTMODE, "testmode cmd interrogate"); if (!tb[WL1271_TM_ATTR_IE_ID]) return -EINVAL; ie_id = nla_get_u8(tb[WL1271_TM_ATTR_IE_ID]); mutex_lock(&wl->mutex); if (unlikely(wl->state != WLCORE_STATE_ON)) { ret = -EINVAL; goto out; } ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) goto out; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); if (!cmd) { ret = -ENOMEM; goto out_sleep; } ret = wl1271_cmd_interrogate(wl, ie_id, cmd, sizeof(*cmd)); if (ret < 0) { wl1271_warning("testmode cmd interrogate failed: %d", ret); goto out_free; } skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, sizeof(*cmd)); if (!skb) { ret = -ENOMEM; goto out_free; } NLA_PUT(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd); ret = cfg80211_testmode_reply(skb); if (ret < 0) goto out_free; out_free: kfree(cmd); out_sleep: wl1271_ps_elp_sleep(wl); out: mutex_unlock(&wl->mutex); return ret; nla_put_failure: kfree_skb(skb); ret = -EMSGSIZE; goto out_free; }