mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
mt76: testmode: add support to set MAC
Add support to set SA/DA/BSSID in testmode. During mass production stage, some test scripts or test equipments need to set fixed addresses to detect or parse if a test is passed. Also, MAC setting is necessary for some tx/rx tests with rx filter, to make sure rx site only receives expected packets. Signed-off-by: Shayne Chen <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
committed by
Felix Fietkau
parent
f1520c9bb3
commit
0c489ea286
+33
-3
@@ -126,9 +126,9 @@ int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len)
|
||||
|
||||
hdr = __skb_put_zero(head, head_len);
|
||||
hdr->frame_control = cpu_to_le16(fc);
|
||||
memcpy(hdr->addr1, phy->macaddr, sizeof(phy->macaddr));
|
||||
memcpy(hdr->addr2, phy->macaddr, sizeof(phy->macaddr));
|
||||
memcpy(hdr->addr3, phy->macaddr, sizeof(phy->macaddr));
|
||||
memcpy(hdr->addr1, td->addr[0], ETH_ALEN);
|
||||
memcpy(hdr->addr2, td->addr[1], ETH_ALEN);
|
||||
memcpy(hdr->addr3, td->addr[2], ETH_ALEN);
|
||||
skb_set_queue_mapping(head, IEEE80211_AC_BE);
|
||||
|
||||
info = IEEE80211_SKB_CB(head);
|
||||
@@ -318,6 +318,10 @@ mt76_testmode_init_defaults(struct mt76_phy *phy)
|
||||
td->tx_count = 1;
|
||||
td->tx_rate_mode = MT76_TM_TX_MODE_OFDM;
|
||||
td->tx_rate_nss = 1;
|
||||
|
||||
memcpy(td->addr[0], phy->macaddr, ETH_ALEN);
|
||||
memcpy(td->addr[1], phy->macaddr, ETH_ALEN);
|
||||
memcpy(td->addr[2], phy->macaddr, ETH_ALEN);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -493,6 +497,20 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||
}
|
||||
}
|
||||
|
||||
if (tb[MT76_TM_ATTR_MAC_ADDRS]) {
|
||||
struct nlattr *cur;
|
||||
int idx = 0;
|
||||
int rem;
|
||||
|
||||
nla_for_each_nested(cur, tb[MT76_TM_ATTR_MAC_ADDRS], rem) {
|
||||
if (nla_len(cur) != ETH_ALEN || idx >= 3)
|
||||
goto out;
|
||||
|
||||
memcpy(td->addr[idx], nla_data(cur), ETH_ALEN);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
if (dev->test_ops->set_params) {
|
||||
err = dev->test_ops->set_params(phy, tb, state);
|
||||
if (err)
|
||||
@@ -635,6 +653,18 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg,
|
||||
nla_nest_end(msg, a);
|
||||
}
|
||||
|
||||
if (mt76_testmode_param_present(td, MT76_TM_ATTR_MAC_ADDRS)) {
|
||||
a = nla_nest_start(msg, MT76_TM_ATTR_MAC_ADDRS);
|
||||
if (!a)
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (nla_put(msg, i, ETH_ALEN, td->addr[i]))
|
||||
goto out;
|
||||
|
||||
nla_nest_end(msg, a);
|
||||
}
|
||||
|
||||
err = 0;
|
||||
|
||||
out:
|
||||
|
||||
Reference in New Issue
Block a user