Commit e70cf22b authored by Igor Mitsyanko's avatar Igor Mitsyanko Committed by Kalle Valo

qtnfmac: merge PHY_PARAMS_GET into MAC_INFO

QLINK_CMD_PHY_PARAMS_GET command does not need to be separate,
it can be included into GET_MAC_INFO command. Merge these two
commands adding all the missing wiphy data.
Signed-off-by: default avatarIgor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 310cd5dd
......@@ -1291,7 +1291,12 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac,
mac_info->radar_detect_widths =
qlink_chan_width_mask_to_nl(le16_to_cpu(
resp_info->radar_detect_widths));
mac_info->max_acl_mac_addrs = le32_to_cpu(resp_info->max_acl_mac_addrs);
mac_info->max_acl_mac_addrs = le16_to_cpu(resp_info->max_acl_mac_addrs);
mac_info->frag_thr = le32_to_cpu(resp_info->frag_threshold);
mac_info->rts_thr = le32_to_cpu(resp_info->rts_threshold);
mac_info->sretry_limit = resp_info->retry_short;
mac_info->lretry_limit = resp_info->retry_long;
mac_info->coverage_class = resp_info->coverage_class;
memcpy(&mac_info->ht_cap_mod_mask, &resp_info->ht_cap_mod_mask,
sizeof(mac_info->ht_cap_mod_mask));
......@@ -1576,72 +1581,6 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band,
return ret;
}
static int qtnf_cmd_resp_proc_phy_params(struct qtnf_wmac *mac,
const u8 *payload, size_t payload_len)
{
struct qtnf_mac_info *mac_info;
struct qlink_tlv_frag_rts_thr *phy_thr;
struct qlink_tlv_rlimit *limit;
struct qlink_tlv_cclass *class;
u16 tlv_type;
u16 tlv_value_len;
size_t tlv_full_len;
const struct qlink_tlv_hdr *tlv;
mac_info = &mac->macinfo;
tlv = (struct qlink_tlv_hdr *)payload;
while (payload_len >= sizeof(struct qlink_tlv_hdr)) {
tlv_type = le16_to_cpu(tlv->type);
tlv_value_len = le16_to_cpu(tlv->len);
tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr);
if (tlv_full_len > payload_len) {
pr_warn("MAC%u: malformed TLV 0x%.2X; LEN: %u\n",
mac->macid, tlv_type, tlv_value_len);
return -EINVAL;
}
switch (tlv_type) {
case QTN_TLV_ID_FRAG_THRESH:
phy_thr = (void *)tlv;
mac_info->frag_thr = le32_to_cpu(phy_thr->thr);
break;
case QTN_TLV_ID_RTS_THRESH:
phy_thr = (void *)tlv;
mac_info->rts_thr = le32_to_cpu(phy_thr->thr);
break;
case QTN_TLV_ID_SRETRY_LIMIT:
limit = (void *)tlv;
mac_info->sretry_limit = limit->rlimit;
break;
case QTN_TLV_ID_LRETRY_LIMIT:
limit = (void *)tlv;
mac_info->lretry_limit = limit->rlimit;
break;
case QTN_TLV_ID_COVERAGE_CLASS:
class = (void *)tlv;
mac_info->coverage_class = class->cclass;
break;
default:
pr_err("MAC%u: Unknown TLV type: %#x\n", mac->macid,
le16_to_cpu(tlv->type));
break;
}
payload_len -= tlv_full_len;
tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len);
}
if (payload_len) {
pr_warn("MAC%u: malformed TLV buf; bytes left: %zu\n",
mac->macid, payload_len);
return -EINVAL;
}
return 0;
}
static int
qtnf_cmd_resp_proc_chan_stat_info(struct qtnf_chan_stats *stats,
const u8 *payload, size_t payload_len)
......@@ -1799,35 +1738,6 @@ int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
return ret;
}
int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac)
{
struct sk_buff *cmd_skb, *resp_skb = NULL;
struct qlink_resp_phy_params *resp;
size_t response_size = 0;
int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
QLINK_CMD_PHY_PARAMS_GET,
sizeof(struct qlink_cmd));
if (!cmd_skb)
return -ENOMEM;
qtnf_bus_lock(mac->bus);
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb,
sizeof(*resp), &response_size);
if (ret)
goto out;
resp = (struct qlink_resp_phy_params *)resp_skb->data;
ret = qtnf_cmd_resp_proc_phy_params(mac, resp->info, response_size);
out:
qtnf_bus_unlock(mac->bus);
consume_skb(resp_skb);
return ret;
}
int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed)
{
struct wiphy *wiphy = priv_to_wiphy(mac);
......
......@@ -585,16 +585,6 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)
return PTR_ERR(mac);
}
ret = qtnf_cmd_get_mac_info(mac);
if (ret) {
pr_err("MAC%u: failed to get info\n", macid);
goto error;
}
/* Use MAC address of the first active radio as a unique device ID */
if (is_zero_ether_addr(mac->bus->hw_id))
ether_addr_copy(mac->bus->hw_id, mac->macaddr);
vif = qtnf_mac_get_base_vif(mac);
if (!vif) {
pr_err("MAC%u: primary VIF is not ready\n", macid);
......@@ -609,12 +599,16 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)
goto error;
}
ret = qtnf_cmd_send_get_phy_params(mac);
ret = qtnf_cmd_get_mac_info(mac);
if (ret) {
pr_err("MAC%u: failed to get PHY settings\n", macid);
pr_err("MAC%u: failed to get MAC info\n", macid);
goto error_del_vif;
}
/* Use MAC address of the first active radio as a unique device ID */
if (is_zero_ether_addr(mac->bus->hw_id))
ether_addr_copy(mac->bus->hw_id, mac->macaddr);
ret = qtnf_mac_init_bands(mac);
if (ret) {
pr_err("MAC%u: failed to init bands\n", macid);
......
......@@ -84,7 +84,7 @@ struct qtnf_mac_info {
u8 sretry_limit;
u8 coverage_class;
u8 radar_detect_widths;
u32 max_acl_mac_addrs;
u16 max_acl_mac_addrs;
struct ieee80211_ht_cap ht_cap_mod_mask;
struct ieee80211_vht_cap vht_cap_mod_mask;
struct ieee80211_iface_combination *if_comb;
......@@ -141,7 +141,6 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv,
const char *name, unsigned char name_assign_type);
void qtnf_main_work_queue(struct work_struct *work);
int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac);
struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
......
......@@ -289,7 +289,6 @@ enum qlink_cmd_type {
QLINK_CMD_REGISTER_MGMT = 0x0003,
QLINK_CMD_SEND_FRAME = 0x0004,
QLINK_CMD_MGMT_SET_APPIE = 0x0005,
QLINK_CMD_PHY_PARAMS_GET = 0x0011,
QLINK_CMD_PHY_PARAMS_SET = 0x0012,
QLINK_CMD_GET_HW_INFO = 0x0013,
QLINK_CMD_MAC_INFO = 0x0014,
......@@ -982,14 +981,48 @@ struct qlink_resp_get_mac_info {
u8 num_rx_chain;
struct ieee80211_vht_cap vht_cap_mod_mask;
struct ieee80211_ht_cap ht_cap_mod_mask;
__le16 max_ap_assoc_sta;
__le32 hw_version;
__le32 probe_resp_offload;
__le32 bss_select_support;
__le16 n_addresses;
__le16 radar_detect_widths;
__le32 max_acl_mac_addrs;
__le16 max_remain_on_channel_duration;
__le16 max_acl_mac_addrs;
__le32 frag_threshold;
__le32 rts_threshold;
u8 retry_short;
u8 retry_long;
u8 coverage_class;
u8 max_scan_ssids;
u8 max_sched_scan_reqs;
u8 max_sched_scan_ssids;
u8 max_match_sets;
u8 max_adj_channel_rssi_comp;
__le16 max_scan_ie_len;
__le16 max_sched_scan_ie_len;
__le32 max_sched_scan_plans;
__le32 max_sched_scan_plan_interval;
__le32 max_sched_scan_plan_iterations;
u8 n_cipher_suites;
u8 n_akm_suites;
u8 max_num_pmkids;
u8 num_iftype_ext_capab;
u8 extended_capabilities_len;
u8 max_data_retry_count;
u8 n_iface_combinations;
u8 max_num_csa_counters;
u8 bands_cap;
u8 alpha2[2];
u8 n_reg_rules;
u8 dfs_region;
u8 rsvd[1];
u8 rsvd[3];
u8 var_info[0];
} __packed;
......@@ -1073,16 +1106,6 @@ struct qlink_resp_band_info_get {
u8 info[0];
} __packed;
/**
* struct qlink_resp_phy_params - response for QLINK_CMD_PHY_PARAMS_GET command
*
* @info: variable-length array of PHY params.
*/
struct qlink_resp_phy_params {
struct qlink_resp rhdr;
u8 info[0];
} __packed;
/**
* struct qlink_resp_get_chan_stats - response for QLINK_CMD_CHAN_STATS cmd
*
......@@ -1425,21 +1448,6 @@ struct qlink_iface_limit_record {
#define QLINK_RSSI_OFFSET 120
struct qlink_tlv_frag_rts_thr {
struct qlink_tlv_hdr hdr;
__le32 thr;
} __packed;
struct qlink_tlv_rlimit {
struct qlink_tlv_hdr hdr;
u8 rlimit;
} __packed;
struct qlink_tlv_cclass {
struct qlink_tlv_hdr hdr;
u8 cclass;
} __packed;
/**
* enum qlink_reg_rule_flags - regulatory rule flags
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment