Lines Matching +full:combined +full:- +full:power +full:- +full:req

1 // SPDX-License-Identifier: GPL-2.0-only
3 * mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211
6 * Copyright (c) 2016 - 2017 Intel Deutschland GmbH
7 * Copyright (C) 2018 - 2020 Intel Corporation
12 * - Add TSF sync and fix IBSS beacon transmission by adding
14 * - RX filtering based on filter configuration (data->rx_filter)
66 MODULE_PARM_DESC(support_p2p_device, "Support P2P-Device interface type");
69 * enum hwsim_regtest - the type of regulatory tests we offer
93 * this by using a custom beacon-capable regulatory domain for the first
108 * domain settings, combined with secondary driver regulatory domain
111 * non-strict settings using the second driver regulatory request. All
116 * 1 - driver custom world regulatory domain
117 * 2 - second custom world regulatory domain
118 * 3 - first driver regulatory domain request
119 * 4 - second driver regulatory domain request
120 * 5 - strict regulatory domain settings using the third driver regulatory
122 * 6 and on - should follow the intersection of the 3rd, 4rth and 5th radio
157 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0),
158 REG_RULE(2484-10, 2484+10, 40, 0, 20, 0),
159 REG_RULE(5150-10, 5240+10, 40, 0, 30, 0),
160 REG_RULE(5745-10, 5825+10, 40, 0, 30, 0),
161 REG_RULE(5855-10, 5925+10, 40, 0, 33, 0),
169 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0),
170 REG_RULE(5725-10, 5850+10, 40, 0, 30,
172 REG_RULE(5855-10, 5925+10, 40, 0, 33, 0),
193 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_check_magic()
194 WARN(vp->magic != HWSIM_VIF_MAGIC, in hwsim_check_magic()
196 vif, vp->magic, vif->addr, vif->type, vif->p2p); in hwsim_check_magic()
201 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_set_magic()
202 vp->magic = HWSIM_VIF_MAGIC; in hwsim_set_magic()
207 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_clear_magic()
208 vp->magic = 0; in hwsim_clear_magic()
219 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in hwsim_check_sta_magic()
220 WARN_ON(sp->magic != HWSIM_STA_MAGIC); in hwsim_check_sta_magic()
225 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in hwsim_set_sta_magic()
226 sp->magic = HWSIM_STA_MAGIC; in hwsim_set_sta_magic()
231 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in hwsim_clear_sta_magic()
232 sp->magic = 0; in hwsim_clear_sta_magic()
243 struct hwsim_chanctx_priv *cp = (void *)c->drv_priv; in hwsim_check_chanctx_magic()
244 WARN_ON(cp->magic != HWSIM_CHANCTX_MAGIC); in hwsim_check_chanctx_magic()
249 struct hwsim_chanctx_priv *cp = (void *)c->drv_priv; in hwsim_set_chanctx_magic()
250 cp->magic = HWSIM_CHANCTX_MAGIC; in hwsim_set_chanctx_magic()
255 struct hwsim_chanctx_priv *cp = (void *)c->drv_priv; in hwsim_clear_chanctx_magic()
256 cp->magic = 0; in hwsim_clear_chanctx_magic()
272 return hwsim_net->netgroup; in hwsim_net_get_netgroup()
279 hwsim_net->netgroup = ida_simple_get(&hwsim_netgroup_ida, in hwsim_net_set_netgroup()
281 return hwsim_net->netgroup >= 0 ? 0 : -ENOMEM; in hwsim_net_set_netgroup()
288 return hwsim_net->wmediumd; in hwsim_net_get_wmediumd()
295 hwsim_net->wmediumd = portid; in hwsim_net_set_wmediumd()
473 /* Rx Single spatial stream and S1G-MCS Map for 1MHz */
474 /* Tx Single spatial stream and S1G-MCS Map for 1MHz */
546 return -EINVAL; in mac80211_hwsim_vendor_cmd_test()
566 /* Send the event - this will call nla_nest_end() */ in mac80211_hwsim_vendor_cmd_test()
573 return -ENOMEM; in mac80211_hwsim_vendor_cmd_test()
781 err = -ENODEV; in hwsim_tx_virtio()
785 sg_init_one(sg, skb->head, skb_end_offset(skb)); in hwsim_tx_virtio()
814 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_send_ps_poll()
818 if (!vp->assoc) in hwsim_send_ps_poll()
821 wiphy_dbg(data->hw->wiphy, in hwsim_send_ps_poll()
822 "%s: send PS-Poll to %pM for aid %d\n", in hwsim_send_ps_poll()
823 __func__, vp->bssid, vp->aid); in hwsim_send_ps_poll()
829 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in hwsim_send_ps_poll()
832 pspoll->aid = cpu_to_le16(0xc000 | vp->aid); in hwsim_send_ps_poll()
833 memcpy(pspoll->bssid, vp->bssid, ETH_ALEN); in hwsim_send_ps_poll()
834 memcpy(pspoll->ta, mac, ETH_ALEN); in hwsim_send_ps_poll()
837 mac80211_hwsim_tx_frame(data->hw, skb, in hwsim_send_ps_poll()
838 rcu_dereference(vif->chanctx_conf)->def.chan); in hwsim_send_ps_poll()
845 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_send_nullfunc()
849 if (!vp->assoc) in hwsim_send_nullfunc()
852 wiphy_dbg(data->hw->wiphy, in hwsim_send_nullfunc()
854 __func__, vp->bssid, ps); in hwsim_send_nullfunc()
859 hdr = skb_put(skb, sizeof(*hdr) - ETH_ALEN); in hwsim_send_nullfunc()
860 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in hwsim_send_nullfunc()
864 hdr->duration_id = cpu_to_le16(0); in hwsim_send_nullfunc()
865 memcpy(hdr->addr1, vp->bssid, ETH_ALEN); in hwsim_send_nullfunc()
866 memcpy(hdr->addr2, mac, ETH_ALEN); in hwsim_send_nullfunc()
867 memcpy(hdr->addr3, vp->bssid, ETH_ALEN); in hwsim_send_nullfunc()
870 mac80211_hwsim_tx_frame(data->hw, skb, in hwsim_send_nullfunc()
871 rcu_dereference(vif->chanctx_conf)->def.chan); in hwsim_send_nullfunc()
893 *val = data->ps; in hwsim_fops_ps_read()
904 return -EINVAL; in hwsim_fops_ps_write()
907 if (data->ps != PS_ENABLED) in hwsim_fops_ps_write()
908 return -EINVAL; in hwsim_fops_ps_write()
911 data->hw, IEEE80211_IFACE_ITER_NORMAL, in hwsim_fops_ps_write()
916 old_ps = data->ps; in hwsim_fops_ps_write()
917 data->ps = val; in hwsim_fops_ps_write()
922 data->hw, IEEE80211_IFACE_ITER_NORMAL, in hwsim_fops_ps_write()
926 data->hw, IEEE80211_IFACE_ITER_NORMAL, in hwsim_fops_ps_write()
941 ieee80211_radar_detected(data->hw); in hwsim_write_simulate_radar()
952 *val = data->group; in hwsim_fops_group_read()
959 data->group = val; in hwsim_fops_group_write()
983 return cpu_to_le64(now + data->tsf_offset); in __mac80211_hwsim_get_tsf()
989 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_get_tsf()
996 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_set_tsf()
998 u32 bcn_int = data->beacon_int; in mac80211_hwsim_set_tsf()
999 u64 delta = abs(tsf - now); in mac80211_hwsim_set_tsf()
1003 data->tsf_offset += delta; in mac80211_hwsim_set_tsf()
1004 data->bcn_delta = do_div(delta, bcn_int); in mac80211_hwsim_set_tsf()
1006 data->tsf_offset -= delta; in mac80211_hwsim_set_tsf()
1007 data->bcn_delta = -(s64)do_div(delta, bcn_int); in mac80211_hwsim_set_tsf()
1015 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_monitor_rx()
1025 bitrate = txrate->bitrate; in mac80211_hwsim_monitor_rx()
1035 hdr->hdr.it_version = PKTHDR_RADIOTAP_VERSION; in mac80211_hwsim_monitor_rx()
1036 hdr->hdr.it_pad = 0; in mac80211_hwsim_monitor_rx()
1037 hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); in mac80211_hwsim_monitor_rx()
1038 hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | in mac80211_hwsim_monitor_rx()
1042 hdr->rt_tsft = __mac80211_hwsim_get_tsf(data); in mac80211_hwsim_monitor_rx()
1043 hdr->rt_flags = 0; in mac80211_hwsim_monitor_rx()
1044 hdr->rt_rate = bitrate / 5; in mac80211_hwsim_monitor_rx()
1045 hdr->rt_channel = cpu_to_le16(chan->center_freq); in mac80211_hwsim_monitor_rx()
1047 if (txrate && txrate->flags & IEEE80211_RATE_ERP_G) in mac80211_hwsim_monitor_rx()
1051 hdr->rt_chbitmask = cpu_to_le16(flags); in mac80211_hwsim_monitor_rx()
1053 skb->dev = hwsim_mon; in mac80211_hwsim_monitor_rx()
1055 skb->ip_summed = CHECKSUM_UNNECESSARY; in mac80211_hwsim_monitor_rx()
1056 skb->pkt_type = PACKET_OTHERHOST; in mac80211_hwsim_monitor_rx()
1057 skb->protocol = htons(ETH_P_802_2); in mac80211_hwsim_monitor_rx()
1058 memset(skb->cb, 0, sizeof(skb->cb)); in mac80211_hwsim_monitor_rx()
1079 hdr->hdr.it_version = PKTHDR_RADIOTAP_VERSION; in mac80211_hwsim_monitor_ack()
1080 hdr->hdr.it_pad = 0; in mac80211_hwsim_monitor_ack()
1081 hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); in mac80211_hwsim_monitor_ack()
1082 hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | in mac80211_hwsim_monitor_ack()
1084 hdr->rt_flags = 0; in mac80211_hwsim_monitor_ack()
1085 hdr->pad = 0; in mac80211_hwsim_monitor_ack()
1086 hdr->rt_channel = cpu_to_le16(chan->center_freq); in mac80211_hwsim_monitor_ack()
1088 hdr->rt_chbitmask = cpu_to_le16(flags); in mac80211_hwsim_monitor_ack()
1091 hdr11->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in mac80211_hwsim_monitor_ack()
1093 hdr11->duration_id = cpu_to_le16(0); in mac80211_hwsim_monitor_ack()
1094 memcpy(hdr11->addr1, addr, ETH_ALEN); in mac80211_hwsim_monitor_ack()
1096 skb->dev = hwsim_mon; in mac80211_hwsim_monitor_ack()
1098 skb->ip_summed = CHECKSUM_UNNECESSARY; in mac80211_hwsim_monitor_ack()
1099 skb->pkt_type = PACKET_OTHERHOST; in mac80211_hwsim_monitor_ack()
1100 skb->protocol = htons(ETH_P_802_2); in mac80211_hwsim_monitor_ack()
1101 memset(skb->cb, 0, sizeof(skb->cb)); in mac80211_hwsim_monitor_ack()
1115 if (memcmp(mac, md->addr, ETH_ALEN) == 0) in mac80211_hwsim_addr_iter()
1116 md->ret = true; in mac80211_hwsim_addr_iter()
1126 if (data->scanning && memcmp(addr, data->scan_addr, ETH_ALEN) == 0) in mac80211_hwsim_addr_match()
1131 ieee80211_iterate_active_interfaces_atomic(data->hw, in mac80211_hwsim_addr_match()
1142 switch (data->ps) { in hwsim_ps_rx_ok()
1149 * if pending PS-Poll has been sent */ in hwsim_ps_rx_ok()
1153 * PS-Poll */ in hwsim_ps_rx_ok()
1154 if (data->ps_poll_pending && in hwsim_ps_rx_ok()
1155 mac80211_hwsim_addr_match(data, skb->data + 4)) { in hwsim_ps_rx_ok()
1156 data->ps_poll_pending = false; in hwsim_ps_rx_ok()
1170 int res = -ENOENT; in hwsim_unicast_netgroup()
1174 if (data->netgroup == hwsim_net_get_netgroup(net)) { in hwsim_unicast_netgroup()
1191 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_config_mac_nl()
1192 u32 _portid = READ_ONCE(data->wmediumd); in mac80211_hwsim_config_mac_nl()
1212 ETH_ALEN, data->addresses[1].addr)) in mac80211_hwsim_config_mac_nl()
1233 if (rate->flags & IEEE80211_TX_RC_USE_RTS_CTS) in trans_tx_rate_flags_ieee2hwsim()
1235 if (rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT) in trans_tx_rate_flags_ieee2hwsim()
1237 if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) in trans_tx_rate_flags_ieee2hwsim()
1239 if (rate->flags & IEEE80211_TX_RC_MCS) in trans_tx_rate_flags_ieee2hwsim()
1241 if (rate->flags & IEEE80211_TX_RC_GREEN_FIELD) in trans_tx_rate_flags_ieee2hwsim()
1243 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in trans_tx_rate_flags_ieee2hwsim()
1245 if (rate->flags & IEEE80211_TX_RC_DUP_DATA) in trans_tx_rate_flags_ieee2hwsim()
1247 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) in trans_tx_rate_flags_ieee2hwsim()
1249 if (rate->flags & IEEE80211_TX_RC_VHT_MCS) in trans_tx_rate_flags_ieee2hwsim()
1251 if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) in trans_tx_rate_flags_ieee2hwsim()
1253 if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) in trans_tx_rate_flags_ieee2hwsim()
1265 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_tx_frame_nl()
1266 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) my_skb->data; in mac80211_hwsim_tx_frame_nl()
1275 if (data->ps != PS_DISABLED) in mac80211_hwsim_tx_frame_nl()
1276 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in mac80211_hwsim_tx_frame_nl()
1278 if (skb_queue_len(&data->pending) >= MAX_QUEUE) { in mac80211_hwsim_tx_frame_nl()
1280 while (skb_queue_len(&data->pending) >= WARN_QUEUE) { in mac80211_hwsim_tx_frame_nl()
1281 ieee80211_free_txskb(hw, skb_dequeue(&data->pending)); in mac80211_hwsim_tx_frame_nl()
1282 data->tx_dropped++; in mac80211_hwsim_tx_frame_nl()
1298 ETH_ALEN, data->addresses[1].addr)) in mac80211_hwsim_tx_frame_nl()
1301 /* We get the skb->data */ in mac80211_hwsim_tx_frame_nl()
1302 if (nla_put(skb, HWSIM_ATTR_FRAME, my_skb->len, my_skb->data)) in mac80211_hwsim_tx_frame_nl()
1308 if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) in mac80211_hwsim_tx_frame_nl()
1311 if (info->flags & IEEE80211_TX_CTL_NO_ACK) in mac80211_hwsim_tx_frame_nl()
1317 if (nla_put_u32(skb, HWSIM_ATTR_FREQ, channel->center_freq)) in mac80211_hwsim_tx_frame_nl()
1323 tx_attempts[i].idx = info->status.rates[i].idx; in mac80211_hwsim_tx_frame_nl()
1324 tx_attempts_flags[i].idx = info->status.rates[i].idx; in mac80211_hwsim_tx_frame_nl()
1325 tx_attempts[i].count = info->status.rates[i].count; in mac80211_hwsim_tx_frame_nl()
1328 &info->status.rates[i]); in mac80211_hwsim_tx_frame_nl()
1342 data->pending_cookie++; in mac80211_hwsim_tx_frame_nl()
1343 cookie = data->pending_cookie; in mac80211_hwsim_tx_frame_nl()
1344 info->rate_driver_data[0] = (void *)cookie; in mac80211_hwsim_tx_frame_nl()
1359 skb_queue_tail(&data->pending, my_skb); in mac80211_hwsim_tx_frame_nl()
1360 data->tx_pkts++; in mac80211_hwsim_tx_frame_nl()
1361 data->tx_bytes += my_skb->len; in mac80211_hwsim_tx_frame_nl()
1369 data->tx_failed++; in mac80211_hwsim_tx_frame_nl()
1378 return c1->center_freq == c2->center_freq; in hwsim_chans_compat()
1391 if (!vif->chanctx_conf) in mac80211_hwsim_tx_iter()
1394 if (!hwsim_chans_compat(data->channel, in mac80211_hwsim_tx_iter()
1395 rcu_dereference(vif->chanctx_conf)->def.chan)) in mac80211_hwsim_tx_iter()
1398 data->receive = true; in mac80211_hwsim_tx_iter()
1421 rtap->oui[0] = HWSIM_RADIOTAP_OUI[0]; in mac80211_hwsim_add_vendor_rtap()
1422 rtap->oui[1] = HWSIM_RADIOTAP_OUI[1]; in mac80211_hwsim_add_vendor_rtap()
1423 rtap->oui[2] = HWSIM_RADIOTAP_OUI[2]; in mac80211_hwsim_add_vendor_rtap()
1424 rtap->subns = 127; in mac80211_hwsim_add_vendor_rtap()
1432 rtap->present = BIT(0); in mac80211_hwsim_add_vendor_rtap()
1434 rtap->len = 8; in mac80211_hwsim_add_vendor_rtap()
1436 rtap->align = 8; in mac80211_hwsim_add_vendor_rtap()
1438 rtap->pad = 4; in mac80211_hwsim_add_vendor_rtap()
1440 memcpy(rtap->data, "ABCDEFGH", 8); in mac80211_hwsim_add_vendor_rtap()
1442 memset(rtap->data + 8, 0, 4); in mac80211_hwsim_add_vendor_rtap()
1444 IEEE80211_SKB_RXCB(skb)->flag |= RX_FLAG_RADIOTAP_VENDOR_DATA; in mac80211_hwsim_add_vendor_rtap()
1452 struct mac80211_hwsim_data *data = hw->priv, *data2; in mac80211_hwsim_tx_frame_no_nl()
1454 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in mac80211_hwsim_tx_frame_no_nl()
1461 rx_status.freq = chan->center_freq; in mac80211_hwsim_tx_frame_no_nl()
1462 rx_status.freq_offset = chan->freq_offset ? 1 : 0; in mac80211_hwsim_tx_frame_no_nl()
1463 rx_status.band = chan->band; in mac80211_hwsim_tx_frame_no_nl()
1464 if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) { in mac80211_hwsim_tx_frame_no_nl()
1466 ieee80211_rate_get_vht_mcs(&info->control.rates[0]); in mac80211_hwsim_tx_frame_no_nl()
1468 ieee80211_rate_get_vht_nss(&info->control.rates[0]); in mac80211_hwsim_tx_frame_no_nl()
1471 rx_status.rate_idx = info->control.rates[0].idx; in mac80211_hwsim_tx_frame_no_nl()
1472 if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS) in mac80211_hwsim_tx_frame_no_nl()
1475 if (info->control.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in mac80211_hwsim_tx_frame_no_nl()
1477 else if (info->control.rates[0].flags & IEEE80211_TX_RC_80_MHZ_WIDTH) in mac80211_hwsim_tx_frame_no_nl()
1479 else if (info->control.rates[0].flags & IEEE80211_TX_RC_160_MHZ_WIDTH) in mac80211_hwsim_tx_frame_no_nl()
1483 if (info->control.rates[0].flags & IEEE80211_TX_RC_SHORT_GI) in mac80211_hwsim_tx_frame_no_nl()
1486 rx_status.signal = -50; in mac80211_hwsim_tx_frame_no_nl()
1487 if (info->control.vif) in mac80211_hwsim_tx_frame_no_nl()
1488 rx_status.signal += info->control.vif->bss_conf.txpower; in mac80211_hwsim_tx_frame_no_nl()
1490 if (data->ps != PS_DISABLED) in mac80211_hwsim_tx_frame_no_nl()
1491 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in mac80211_hwsim_tx_frame_no_nl()
1496 skb->mark = 0; in mac80211_hwsim_tx_frame_no_nl()
1503 * Giving beacons a different mactime than non-beacons looks messy, but in mac80211_hwsim_tx_frame_no_nl()
1507 if (ieee80211_is_beacon(hdr->frame_control) || in mac80211_hwsim_tx_frame_no_nl()
1508 ieee80211_is_probe_resp(hdr->frame_control)) { in mac80211_hwsim_tx_frame_no_nl()
1510 now = data->abs_bcn_ts; in mac80211_hwsim_tx_frame_no_nl()
1527 if (!data2->started || (data2->idle && !data2->tmp_chan) || in mac80211_hwsim_tx_frame_no_nl()
1531 if (!(data->group & data2->group)) in mac80211_hwsim_tx_frame_no_nl()
1534 if (data->netgroup != data2->netgroup) in mac80211_hwsim_tx_frame_no_nl()
1537 if (!hwsim_chans_compat(chan, data2->tmp_chan) && in mac80211_hwsim_tx_frame_no_nl()
1538 !hwsim_chans_compat(chan, data2->channel)) { in mac80211_hwsim_tx_frame_no_nl()
1540 data2->hw, IEEE80211_IFACE_ITER_NORMAL, in mac80211_hwsim_tx_frame_no_nl()
1550 if (skb->len < PAGE_SIZE && paged_rx) { in mac80211_hwsim_tx_frame_no_nl()
1562 memcpy(page_address(page), skb->data, skb->len); in mac80211_hwsim_tx_frame_no_nl()
1563 skb_add_rx_frag(nskb, 0, page, 0, skb->len, skb->len); in mac80211_hwsim_tx_frame_no_nl()
1570 if (mac80211_hwsim_addr_match(data2, hdr->addr1)) in mac80211_hwsim_tx_frame_no_nl()
1573 rx_status.mactime = now + data2->tsf_offset; in mac80211_hwsim_tx_frame_no_nl()
1579 data2->rx_pkts++; in mac80211_hwsim_tx_frame_no_nl()
1580 data2->rx_bytes += nskb->len; in mac80211_hwsim_tx_frame_no_nl()
1581 ieee80211_rx_irqsafe(data2->hw, nskb); in mac80211_hwsim_tx_frame_no_nl()
1592 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_tx()
1594 struct ieee80211_hdr *hdr = (void *)skb->data; in mac80211_hwsim_tx()
1600 if (WARN_ON(skb->len < 10)) { in mac80211_hwsim_tx()
1606 if (!data->use_chanctx) { in mac80211_hwsim_tx()
1607 channel = data->channel; in mac80211_hwsim_tx()
1608 } else if (txi->hw_queue == 4) { in mac80211_hwsim_tx()
1609 channel = data->tmp_chan; in mac80211_hwsim_tx()
1611 chanctx_conf = rcu_dereference(txi->control.vif->chanctx_conf); in mac80211_hwsim_tx()
1613 channel = chanctx_conf->def.chan; in mac80211_hwsim_tx()
1618 if (WARN(!channel, "TX w/o channel - queue = %d\n", txi->hw_queue)) { in mac80211_hwsim_tx()
1623 if (data->idle && !data->tmp_chan) { in mac80211_hwsim_tx()
1624 wiphy_dbg(hw->wiphy, "Trying to TX when idle - reject\n"); in mac80211_hwsim_tx()
1629 if (txi->control.vif) in mac80211_hwsim_tx()
1630 hwsim_check_magic(txi->control.vif); in mac80211_hwsim_tx()
1631 if (control->sta) in mac80211_hwsim_tx()
1632 hwsim_check_sta_magic(control->sta); in mac80211_hwsim_tx()
1635 ieee80211_get_tx_rates(txi->control.vif, control->sta, skb, in mac80211_hwsim_tx()
1636 txi->control.rates, in mac80211_hwsim_tx()
1637 ARRAY_SIZE(txi->control.rates)); in mac80211_hwsim_tx()
1639 if (skb->len >= 24 + 8 && in mac80211_hwsim_tx()
1640 ieee80211_is_probe_resp(hdr->frame_control)) { in mac80211_hwsim_tx()
1648 mgmt = (struct ieee80211_mgmt *)skb->data; in mac80211_hwsim_tx()
1651 bitrate = txrate->bitrate; in mac80211_hwsim_tx()
1653 mgmt->u.probe_resp.timestamp = in mac80211_hwsim_tx()
1654 cpu_to_le64(ts + data->tsf_offset + in mac80211_hwsim_tx()
1661 _portid = READ_ONCE(data->wmediumd); in mac80211_hwsim_tx()
1667 data->tx_pkts++; in mac80211_hwsim_tx()
1668 data->tx_bytes += skb->len; in mac80211_hwsim_tx()
1671 if (ack && skb->len >= 16) in mac80211_hwsim_tx()
1672 mac80211_hwsim_monitor_ack(channel, hdr->addr2); in mac80211_hwsim_tx()
1677 txi->control.rates[0].count = 1; in mac80211_hwsim_tx()
1678 txi->control.rates[1].idx = -1; in mac80211_hwsim_tx()
1680 if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) && ack) in mac80211_hwsim_tx()
1681 txi->flags |= IEEE80211_TX_STAT_ACK; in mac80211_hwsim_tx()
1688 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_start()
1689 wiphy_dbg(hw->wiphy, "%s\n", __func__); in mac80211_hwsim_start()
1690 data->started = true; in mac80211_hwsim_start()
1697 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_stop()
1699 data->started = false; in mac80211_hwsim_stop()
1700 hrtimer_cancel(&data->beacon_timer); in mac80211_hwsim_stop()
1702 while (!skb_queue_empty(&data->pending)) in mac80211_hwsim_stop()
1703 ieee80211_free_txskb(hw, skb_dequeue(&data->pending)); in mac80211_hwsim_stop()
1705 wiphy_dbg(hw->wiphy, "%s\n", __func__); in mac80211_hwsim_stop()
1712 wiphy_dbg(hw->wiphy, "%s (type=%d mac_addr=%pM)\n", in mac80211_hwsim_add_interface()
1714 vif->addr); in mac80211_hwsim_add_interface()
1717 if (vif->type != NL80211_IFTYPE_MONITOR) in mac80211_hwsim_add_interface()
1718 mac80211_hwsim_config_mac_nl(hw, vif->addr, true); in mac80211_hwsim_add_interface()
1720 vif->cab_queue = 0; in mac80211_hwsim_add_interface()
1721 vif->hw_queue[IEEE80211_AC_VO] = 0; in mac80211_hwsim_add_interface()
1722 vif->hw_queue[IEEE80211_AC_VI] = 1; in mac80211_hwsim_add_interface()
1723 vif->hw_queue[IEEE80211_AC_BE] = 2; in mac80211_hwsim_add_interface()
1724 vif->hw_queue[IEEE80211_AC_BK] = 3; in mac80211_hwsim_add_interface()
1736 wiphy_dbg(hw->wiphy, in mac80211_hwsim_change_interface()
1739 newtype, vif->addr); in mac80211_hwsim_change_interface()
1743 * interface may change from non-AP to AP in in mac80211_hwsim_change_interface()
1746 vif->cab_queue = 0; in mac80211_hwsim_change_interface()
1754 wiphy_dbg(hw->wiphy, "%s (type=%d mac_addr=%pM)\n", in mac80211_hwsim_remove_interface()
1756 vif->addr); in mac80211_hwsim_remove_interface()
1759 if (vif->type != NL80211_IFTYPE_MONITOR) in mac80211_hwsim_remove_interface()
1760 mac80211_hwsim_config_mac_nl(hw, vif->addr, false); in mac80211_hwsim_remove_interface()
1767 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_tx_frame()
1768 u32 _pid = READ_ONCE(data->wmediumd); in mac80211_hwsim_tx_frame()
1772 ieee80211_get_tx_rates(txi->control.vif, NULL, skb, in mac80211_hwsim_tx_frame()
1773 txi->control.rates, in mac80211_hwsim_tx_frame()
1774 ARRAY_SIZE(txi->control.rates)); in mac80211_hwsim_tx_frame()
1782 data->tx_pkts++; in mac80211_hwsim_tx_frame()
1783 data->tx_bytes += skb->len; in mac80211_hwsim_tx_frame()
1792 struct ieee80211_hw *hw = data->hw; in mac80211_hwsim_beacon_tx()
1802 if (vif->type != NL80211_IFTYPE_AP && in mac80211_hwsim_beacon_tx()
1803 vif->type != NL80211_IFTYPE_MESH_POINT && in mac80211_hwsim_beacon_tx()
1804 vif->type != NL80211_IFTYPE_ADHOC && in mac80211_hwsim_beacon_tx()
1805 vif->type != NL80211_IFTYPE_OCB) in mac80211_hwsim_beacon_tx()
1814 info->control.rates, in mac80211_hwsim_beacon_tx()
1815 ARRAY_SIZE(info->control.rates)); in mac80211_hwsim_beacon_tx()
1819 bitrate = txrate->bitrate; in mac80211_hwsim_beacon_tx()
1821 mgmt = (struct ieee80211_mgmt *) skb->data; in mac80211_hwsim_beacon_tx()
1823 data->abs_bcn_ts = mac80211_hwsim_get_tsf_raw(); in mac80211_hwsim_beacon_tx()
1824 if (ieee80211_is_s1g_beacon(mgmt->frame_control)) { in mac80211_hwsim_beacon_tx()
1827 ext->u.s1g_beacon.timestamp = cpu_to_le32(data->abs_bcn_ts + in mac80211_hwsim_beacon_tx()
1828 data->tsf_offset + in mac80211_hwsim_beacon_tx()
1832 mgmt->u.beacon.timestamp = cpu_to_le64(data->abs_bcn_ts + in mac80211_hwsim_beacon_tx()
1833 data->tsf_offset + in mac80211_hwsim_beacon_tx()
1839 rcu_dereference(vif->chanctx_conf)->def.chan); in mac80211_hwsim_beacon_tx()
1843 rcu_dereference(vif->chanctx_conf)->def.chan); in mac80211_hwsim_beacon_tx()
1846 if (vif->csa_active && ieee80211_beacon_cntdwn_is_complete(vif)) in mac80211_hwsim_beacon_tx()
1855 struct ieee80211_hw *hw = data->hw; in mac80211_hwsim_beacon()
1856 u64 bcn_int = data->beacon_int; in mac80211_hwsim_beacon()
1858 if (!data->started) in mac80211_hwsim_beacon()
1866 if (data->bcn_delta) { in mac80211_hwsim_beacon()
1867 bcn_int -= data->bcn_delta; in mac80211_hwsim_beacon()
1868 data->bcn_delta = 0; in mac80211_hwsim_beacon()
1870 hrtimer_forward_now(&data->beacon_timer, in mac80211_hwsim_beacon()
1893 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_config()
1894 struct ieee80211_conf *conf = &hw->conf; in mac80211_hwsim_config()
1903 if (conf->chandef.chan) in mac80211_hwsim_config()
1904 wiphy_dbg(hw->wiphy, in mac80211_hwsim_config()
1905 "%s (freq=%d(%d - %d)/%s idle=%d ps=%d smps=%s)\n", in mac80211_hwsim_config()
1907 conf->chandef.chan->center_freq, in mac80211_hwsim_config()
1908 conf->chandef.center_freq1, in mac80211_hwsim_config()
1909 conf->chandef.center_freq2, in mac80211_hwsim_config()
1910 hwsim_chanwidths[conf->chandef.width], in mac80211_hwsim_config()
1911 !!(conf->flags & IEEE80211_CONF_IDLE), in mac80211_hwsim_config()
1912 !!(conf->flags & IEEE80211_CONF_PS), in mac80211_hwsim_config()
1913 smps_modes[conf->smps_mode]); in mac80211_hwsim_config()
1915 wiphy_dbg(hw->wiphy, in mac80211_hwsim_config()
1918 !!(conf->flags & IEEE80211_CONF_IDLE), in mac80211_hwsim_config()
1919 !!(conf->flags & IEEE80211_CONF_PS), in mac80211_hwsim_config()
1920 smps_modes[conf->smps_mode]); in mac80211_hwsim_config()
1922 data->idle = !!(conf->flags & IEEE80211_CONF_IDLE); in mac80211_hwsim_config()
1924 WARN_ON(conf->chandef.chan && data->use_chanctx); in mac80211_hwsim_config()
1926 mutex_lock(&data->mutex); in mac80211_hwsim_config()
1927 if (data->scanning && conf->chandef.chan) { in mac80211_hwsim_config()
1928 for (idx = 0; idx < ARRAY_SIZE(data->survey_data); idx++) { in mac80211_hwsim_config()
1929 if (data->survey_data[idx].channel == data->channel) { in mac80211_hwsim_config()
1930 data->survey_data[idx].start = in mac80211_hwsim_config()
1931 data->survey_data[idx].next_start; in mac80211_hwsim_config()
1932 data->survey_data[idx].end = jiffies; in mac80211_hwsim_config()
1937 data->channel = conf->chandef.chan; in mac80211_hwsim_config()
1939 for (idx = 0; idx < ARRAY_SIZE(data->survey_data); idx++) { in mac80211_hwsim_config()
1940 if (data->survey_data[idx].channel && in mac80211_hwsim_config()
1941 data->survey_data[idx].channel != data->channel) in mac80211_hwsim_config()
1943 data->survey_data[idx].channel = data->channel; in mac80211_hwsim_config()
1944 data->survey_data[idx].next_start = jiffies; in mac80211_hwsim_config()
1948 data->channel = conf->chandef.chan; in mac80211_hwsim_config()
1950 mutex_unlock(&data->mutex); in mac80211_hwsim_config()
1952 if (!data->started || !data->beacon_int) in mac80211_hwsim_config()
1953 hrtimer_cancel(&data->beacon_timer); in mac80211_hwsim_config()
1954 else if (!hrtimer_is_queued(&data->beacon_timer)) { in mac80211_hwsim_config()
1956 u32 bcn_int = data->beacon_int; in mac80211_hwsim_config()
1957 u64 until_tbtt = bcn_int - do_div(tsf, bcn_int); in mac80211_hwsim_config()
1959 hrtimer_start(&data->beacon_timer, in mac80211_hwsim_config()
1972 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_configure_filter()
1974 wiphy_dbg(hw->wiphy, "%s\n", __func__); in mac80211_hwsim_configure_filter()
1976 data->rx_filter = 0; in mac80211_hwsim_configure_filter()
1978 data->rx_filter |= FIF_ALLMULTI; in mac80211_hwsim_configure_filter()
1980 data->rx_filter |= FIF_MCAST_ACTION; in mac80211_hwsim_configure_filter()
1982 *total_flags = data->rx_filter; in mac80211_hwsim_configure_filter()
1989 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in mac80211_hwsim_bcn_en_iter()
1991 if (vp->bcn_en) in mac80211_hwsim_bcn_en_iter()
2000 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in mac80211_hwsim_bss_info_changed()
2001 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_bss_info_changed()
2005 wiphy_dbg(hw->wiphy, "%s(changed=0x%x vif->addr=%pM)\n", in mac80211_hwsim_bss_info_changed()
2006 __func__, changed, vif->addr); in mac80211_hwsim_bss_info_changed()
2009 wiphy_dbg(hw->wiphy, "%s: BSSID changed: %pM\n", in mac80211_hwsim_bss_info_changed()
2010 __func__, info->bssid); in mac80211_hwsim_bss_info_changed()
2011 memcpy(vp->bssid, info->bssid, ETH_ALEN); in mac80211_hwsim_bss_info_changed()
2015 wiphy_dbg(hw->wiphy, " ASSOC: assoc=%d aid=%d\n", in mac80211_hwsim_bss_info_changed()
2016 info->assoc, info->aid); in mac80211_hwsim_bss_info_changed()
2017 vp->assoc = info->assoc; in mac80211_hwsim_bss_info_changed()
2018 vp->aid = info->aid; in mac80211_hwsim_bss_info_changed()
2022 wiphy_dbg(hw->wiphy, " BCN EN: %d (BI=%u)\n", in mac80211_hwsim_bss_info_changed()
2023 info->enable_beacon, info->beacon_int); in mac80211_hwsim_bss_info_changed()
2024 vp->bcn_en = info->enable_beacon; in mac80211_hwsim_bss_info_changed()
2025 if (data->started && in mac80211_hwsim_bss_info_changed()
2026 !hrtimer_is_queued(&data->beacon_timer) && in mac80211_hwsim_bss_info_changed()
2027 info->enable_beacon) { in mac80211_hwsim_bss_info_changed()
2030 data->beacon_int = info->beacon_int * 1024; in mac80211_hwsim_bss_info_changed()
2032 bcn_int = data->beacon_int; in mac80211_hwsim_bss_info_changed()
2033 until_tbtt = bcn_int - do_div(tsf, bcn_int); in mac80211_hwsim_bss_info_changed()
2035 hrtimer_start(&data->beacon_timer, in mac80211_hwsim_bss_info_changed()
2038 } else if (!info->enable_beacon) { in mac80211_hwsim_bss_info_changed()
2041 data->hw, IEEE80211_IFACE_ITER_NORMAL, in mac80211_hwsim_bss_info_changed()
2043 wiphy_dbg(hw->wiphy, " beaconing vifs remaining: %u", in mac80211_hwsim_bss_info_changed()
2046 hrtimer_cancel(&data->beacon_timer); in mac80211_hwsim_bss_info_changed()
2047 data->beacon_int = 0; in mac80211_hwsim_bss_info_changed()
2053 wiphy_dbg(hw->wiphy, " ERP_CTS_PROT: %d\n", in mac80211_hwsim_bss_info_changed()
2054 info->use_cts_prot); in mac80211_hwsim_bss_info_changed()
2058 wiphy_dbg(hw->wiphy, " ERP_PREAMBLE: %d\n", in mac80211_hwsim_bss_info_changed()
2059 info->use_short_preamble); in mac80211_hwsim_bss_info_changed()
2063 wiphy_dbg(hw->wiphy, " ERP_SLOT: %d\n", info->use_short_slot); in mac80211_hwsim_bss_info_changed()
2067 wiphy_dbg(hw->wiphy, " HT: op_mode=0x%x\n", in mac80211_hwsim_bss_info_changed()
2068 info->ht_operation_mode); in mac80211_hwsim_bss_info_changed()
2072 wiphy_dbg(hw->wiphy, " BASIC_RATES: 0x%llx\n", in mac80211_hwsim_bss_info_changed()
2073 (unsigned long long) info->basic_rates); in mac80211_hwsim_bss_info_changed()
2077 wiphy_dbg(hw->wiphy, " TX Power: %d dBm\n", info->txpower); in mac80211_hwsim_bss_info_changed()
2131 wiphy_dbg(hw->wiphy, in mac80211_hwsim_conf_tx()
2134 params->txop, params->cw_min, in mac80211_hwsim_conf_tx()
2135 params->cw_max, params->aifs); in mac80211_hwsim_conf_tx()
2142 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_get_survey()
2144 if (idx < 0 || idx >= ARRAY_SIZE(hwsim->survey_data)) in mac80211_hwsim_get_survey()
2145 return -ENOENT; in mac80211_hwsim_get_survey()
2147 mutex_lock(&hwsim->mutex); in mac80211_hwsim_get_survey()
2148 survey->channel = hwsim->survey_data[idx].channel; in mac80211_hwsim_get_survey()
2149 if (!survey->channel) { in mac80211_hwsim_get_survey()
2150 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_get_survey()
2151 return -ENOENT; in mac80211_hwsim_get_survey()
2155 * Magically conjured dummy values --- this is only ok for simulated hardware. in mac80211_hwsim_get_survey()
2158 * report any, especially not a magically conjured ones :-) in mac80211_hwsim_get_survey()
2160 survey->filled = SURVEY_INFO_NOISE_DBM | in mac80211_hwsim_get_survey()
2163 survey->noise = -92; in mac80211_hwsim_get_survey()
2164 survey->time = in mac80211_hwsim_get_survey()
2165 jiffies_to_msecs(hwsim->survey_data[idx].end - in mac80211_hwsim_get_survey()
2166 hwsim->survey_data[idx].start); in mac80211_hwsim_get_survey()
2168 survey->time_busy = survey->time/8; in mac80211_hwsim_get_survey()
2169 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_get_survey()
2188 HWSIM_TM_ATTR_MAX = __HWSIM_TM_ATTR_AFTER_LAST - 1
2207 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_testmode_cmd()
2218 return -EINVAL; in mac80211_hwsim_testmode_cmd()
2223 return -EINVAL; in mac80211_hwsim_testmode_cmd()
2227 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, in mac80211_hwsim_testmode_cmd()
2230 return -ENOMEM; in mac80211_hwsim_testmode_cmd()
2231 if (nla_put_u32(skb, HWSIM_TM_ATTR_PS, hwsim->ps)) in mac80211_hwsim_testmode_cmd()
2241 return -EOPNOTSUPP; in mac80211_hwsim_testmode_cmd()
2246 return -ENOBUFS; in mac80211_hwsim_testmode_cmd()
2254 struct ieee80211_sta *sta = params->sta; in mac80211_hwsim_ampdu_action()
2255 enum ieee80211_ampdu_mlme_action action = params->action; in mac80211_hwsim_ampdu_action()
2256 u16 tid = params->tid; in mac80211_hwsim_ampdu_action()
2264 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in mac80211_hwsim_ampdu_action()
2272 return -EOPNOTSUPP; in mac80211_hwsim_ampdu_action()
2289 struct cfg80211_scan_request *req = hwsim->hw_scan_request; in hw_scan_work() local
2292 mutex_lock(&hwsim->mutex); in hw_scan_work()
2293 if (hwsim->scan_chan_idx >= req->n_channels) { in hw_scan_work()
2298 wiphy_dbg(hwsim->hw->wiphy, "hw scan complete\n"); in hw_scan_work()
2299 ieee80211_scan_completed(hwsim->hw, &info); in hw_scan_work()
2300 hwsim->hw_scan_request = NULL; in hw_scan_work()
2301 hwsim->hw_scan_vif = NULL; in hw_scan_work()
2302 hwsim->tmp_chan = NULL; in hw_scan_work()
2303 mutex_unlock(&hwsim->mutex); in hw_scan_work()
2304 mac80211_hwsim_config_mac_nl(hwsim->hw, hwsim->scan_addr, in hw_scan_work()
2309 wiphy_dbg(hwsim->hw->wiphy, "hw scan %d MHz\n", in hw_scan_work()
2310 req->channels[hwsim->scan_chan_idx]->center_freq); in hw_scan_work()
2312 hwsim->tmp_chan = req->channels[hwsim->scan_chan_idx]; in hw_scan_work()
2313 if (hwsim->tmp_chan->flags & (IEEE80211_CHAN_NO_IR | in hw_scan_work()
2315 !req->n_ssids) { in hw_scan_work()
2320 for (i = 0; i < req->n_ssids; i++) { in hw_scan_work()
2324 probe = ieee80211_probereq_get(hwsim->hw, in hw_scan_work()
2325 hwsim->scan_addr, in hw_scan_work()
2326 req->ssids[i].ssid, in hw_scan_work()
2327 req->ssids[i].ssid_len, in hw_scan_work()
2328 req->ie_len); in hw_scan_work()
2332 mgmt = (struct ieee80211_mgmt *) probe->data; in hw_scan_work()
2333 memcpy(mgmt->da, req->bssid, ETH_ALEN); in hw_scan_work()
2334 memcpy(mgmt->bssid, req->bssid, ETH_ALEN); in hw_scan_work()
2336 if (req->ie_len) in hw_scan_work()
2337 skb_put_data(probe, req->ie, req->ie_len); in hw_scan_work()
2340 mac80211_hwsim_tx_frame(hwsim->hw, probe, in hw_scan_work()
2341 hwsim->tmp_chan); in hw_scan_work()
2345 ieee80211_queue_delayed_work(hwsim->hw, &hwsim->hw_scan, in hw_scan_work()
2347 hwsim->survey_data[hwsim->scan_chan_idx].channel = hwsim->tmp_chan; in hw_scan_work()
2348 hwsim->survey_data[hwsim->scan_chan_idx].start = jiffies; in hw_scan_work()
2349 hwsim->survey_data[hwsim->scan_chan_idx].end = in hw_scan_work()
2351 hwsim->scan_chan_idx++; in hw_scan_work()
2352 mutex_unlock(&hwsim->mutex); in hw_scan_work()
2359 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_hw_scan()
2360 struct cfg80211_scan_request *req = &hw_req->req; in mac80211_hwsim_hw_scan() local
2362 mutex_lock(&hwsim->mutex); in mac80211_hwsim_hw_scan()
2363 if (WARN_ON(hwsim->tmp_chan || hwsim->hw_scan_request)) { in mac80211_hwsim_hw_scan()
2364 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_hw_scan()
2365 return -EBUSY; in mac80211_hwsim_hw_scan()
2367 hwsim->hw_scan_request = req; in mac80211_hwsim_hw_scan()
2368 hwsim->hw_scan_vif = vif; in mac80211_hwsim_hw_scan()
2369 hwsim->scan_chan_idx = 0; in mac80211_hwsim_hw_scan()
2370 if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) in mac80211_hwsim_hw_scan()
2371 get_random_mask_addr(hwsim->scan_addr, in mac80211_hwsim_hw_scan()
2372 hw_req->req.mac_addr, in mac80211_hwsim_hw_scan()
2373 hw_req->req.mac_addr_mask); in mac80211_hwsim_hw_scan()
2375 memcpy(hwsim->scan_addr, vif->addr, ETH_ALEN); in mac80211_hwsim_hw_scan()
2376 memset(hwsim->survey_data, 0, sizeof(hwsim->survey_data)); in mac80211_hwsim_hw_scan()
2377 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_hw_scan()
2379 mac80211_hwsim_config_mac_nl(hw, hwsim->scan_addr, true); in mac80211_hwsim_hw_scan()
2380 wiphy_dbg(hw->wiphy, "hwsim hw_scan request\n"); in mac80211_hwsim_hw_scan()
2382 ieee80211_queue_delayed_work(hwsim->hw, &hwsim->hw_scan, 0); in mac80211_hwsim_hw_scan()
2390 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_cancel_hw_scan()
2395 wiphy_dbg(hw->wiphy, "hwsim cancel_hw_scan\n"); in mac80211_hwsim_cancel_hw_scan()
2397 cancel_delayed_work_sync(&hwsim->hw_scan); in mac80211_hwsim_cancel_hw_scan()
2399 mutex_lock(&hwsim->mutex); in mac80211_hwsim_cancel_hw_scan()
2400 ieee80211_scan_completed(hwsim->hw, &info); in mac80211_hwsim_cancel_hw_scan()
2401 hwsim->tmp_chan = NULL; in mac80211_hwsim_cancel_hw_scan()
2402 hwsim->hw_scan_request = NULL; in mac80211_hwsim_cancel_hw_scan()
2403 hwsim->hw_scan_vif = NULL; in mac80211_hwsim_cancel_hw_scan()
2404 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_cancel_hw_scan()
2411 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_sw_scan()
2413 mutex_lock(&hwsim->mutex); in mac80211_hwsim_sw_scan()
2415 if (hwsim->scanning) { in mac80211_hwsim_sw_scan()
2422 memcpy(hwsim->scan_addr, mac_addr, ETH_ALEN); in mac80211_hwsim_sw_scan()
2423 mac80211_hwsim_config_mac_nl(hw, hwsim->scan_addr, true); in mac80211_hwsim_sw_scan()
2424 hwsim->scanning = true; in mac80211_hwsim_sw_scan()
2425 memset(hwsim->survey_data, 0, sizeof(hwsim->survey_data)); in mac80211_hwsim_sw_scan()
2428 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_sw_scan()
2434 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_sw_scan_complete()
2436 mutex_lock(&hwsim->mutex); in mac80211_hwsim_sw_scan_complete()
2439 hwsim->scanning = false; in mac80211_hwsim_sw_scan_complete()
2440 mac80211_hwsim_config_mac_nl(hw, hwsim->scan_addr, false); in mac80211_hwsim_sw_scan_complete()
2441 eth_zero_addr(hwsim->scan_addr); in mac80211_hwsim_sw_scan_complete()
2443 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_sw_scan_complete()
2451 mutex_lock(&hwsim->mutex); in hw_roc_start()
2453 wiphy_dbg(hwsim->hw->wiphy, "hwsim ROC begins\n"); in hw_roc_start()
2454 hwsim->tmp_chan = hwsim->roc_chan; in hw_roc_start()
2455 ieee80211_ready_on_channel(hwsim->hw); in hw_roc_start()
2457 ieee80211_queue_delayed_work(hwsim->hw, &hwsim->roc_done, in hw_roc_start()
2458 msecs_to_jiffies(hwsim->roc_duration)); in hw_roc_start()
2460 mutex_unlock(&hwsim->mutex); in hw_roc_start()
2468 mutex_lock(&hwsim->mutex); in hw_roc_done()
2469 ieee80211_remain_on_channel_expired(hwsim->hw); in hw_roc_done()
2470 hwsim->tmp_chan = NULL; in hw_roc_done()
2471 mutex_unlock(&hwsim->mutex); in hw_roc_done()
2473 wiphy_dbg(hwsim->hw->wiphy, "hwsim ROC expired\n"); in hw_roc_done()
2482 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_roc()
2484 mutex_lock(&hwsim->mutex); in mac80211_hwsim_roc()
2485 if (WARN_ON(hwsim->tmp_chan || hwsim->hw_scan_request)) { in mac80211_hwsim_roc()
2486 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_roc()
2487 return -EBUSY; in mac80211_hwsim_roc()
2490 hwsim->roc_chan = chan; in mac80211_hwsim_roc()
2491 hwsim->roc_duration = duration; in mac80211_hwsim_roc()
2492 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_roc()
2494 wiphy_dbg(hw->wiphy, "hwsim ROC (%d MHz, %d ms)\n", in mac80211_hwsim_roc()
2495 chan->center_freq, duration); in mac80211_hwsim_roc()
2496 ieee80211_queue_delayed_work(hw, &hwsim->roc_start, HZ/50); in mac80211_hwsim_roc()
2504 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_croc()
2506 cancel_delayed_work_sync(&hwsim->roc_start); in mac80211_hwsim_croc()
2507 cancel_delayed_work_sync(&hwsim->roc_done); in mac80211_hwsim_croc()
2509 mutex_lock(&hwsim->mutex); in mac80211_hwsim_croc()
2510 hwsim->tmp_chan = NULL; in mac80211_hwsim_croc()
2511 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_croc()
2513 wiphy_dbg(hw->wiphy, "hwsim ROC canceled\n"); in mac80211_hwsim_croc()
2521 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_add_chanctx()
2523 mutex_lock(&hwsim->mutex); in mac80211_hwsim_add_chanctx()
2524 hwsim->chanctx = ctx; in mac80211_hwsim_add_chanctx()
2525 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_add_chanctx()
2527 wiphy_dbg(hw->wiphy, in mac80211_hwsim_add_chanctx()
2529 ctx->def.chan->center_freq, ctx->def.width, in mac80211_hwsim_add_chanctx()
2530 ctx->def.center_freq1, ctx->def.center_freq2); in mac80211_hwsim_add_chanctx()
2537 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_remove_chanctx()
2539 mutex_lock(&hwsim->mutex); in mac80211_hwsim_remove_chanctx()
2540 hwsim->chanctx = NULL; in mac80211_hwsim_remove_chanctx()
2541 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_remove_chanctx()
2542 wiphy_dbg(hw->wiphy, in mac80211_hwsim_remove_chanctx()
2544 ctx->def.chan->center_freq, ctx->def.width, in mac80211_hwsim_remove_chanctx()
2545 ctx->def.center_freq1, ctx->def.center_freq2); in mac80211_hwsim_remove_chanctx()
2554 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_change_chanctx()
2556 mutex_lock(&hwsim->mutex); in mac80211_hwsim_change_chanctx()
2557 hwsim->chanctx = ctx; in mac80211_hwsim_change_chanctx()
2558 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_change_chanctx()
2560 wiphy_dbg(hw->wiphy, in mac80211_hwsim_change_chanctx()
2562 ctx->def.chan->center_freq, ctx->def.width, in mac80211_hwsim_change_chanctx()
2563 ctx->def.center_freq1, ctx->def.center_freq2); in mac80211_hwsim_change_chanctx()
2618 struct mac80211_hwsim_data *ar = hw->priv; in mac80211_hwsim_get_et_stats()
2621 data[i++] = ar->tx_pkts; in mac80211_hwsim_get_et_stats()
2622 data[i++] = ar->tx_bytes; in mac80211_hwsim_get_et_stats()
2623 data[i++] = ar->rx_pkts; in mac80211_hwsim_get_et_stats()
2624 data[i++] = ar->rx_bytes; in mac80211_hwsim_get_et_stats()
2625 data[i++] = ar->tx_dropped; in mac80211_hwsim_get_et_stats()
2626 data[i++] = ar->tx_failed; in mac80211_hwsim_get_et_stats()
2627 data[i++] = ar->ps; in mac80211_hwsim_get_et_stats()
2628 data[i++] = ar->group; in mac80211_hwsim_get_et_stats()
2721 if (param->channels) { in append_radio_msg()
2722 ret = nla_put_u32(skb, HWSIM_ATTR_CHANNELS, param->channels); in append_radio_msg()
2727 if (param->reg_alpha2) { in append_radio_msg()
2729 param->reg_alpha2); in append_radio_msg()
2734 if (param->regd) { in append_radio_msg()
2738 if (hwsim_world_regdom_custom[i] != param->regd) in append_radio_msg()
2748 if (param->reg_strict) { in append_radio_msg()
2754 if (param->p2p_device) { in append_radio_msg()
2760 if (param->use_chanctx) { in append_radio_msg()
2766 if (param->hwname) { in append_radio_msg()
2768 strlen(param->hwname), param->hwname); in append_radio_msg()
2995 if (sband->band == NL80211_BAND_2GHZ) { in mac80211_hwsim_he_capab()
2997 sband->iftype_data = in mac80211_hwsim_he_capab()
2999 } else if (sband->band == NL80211_BAND_5GHZ) { in mac80211_hwsim_he_capab()
3001 sband->iftype_data = in mac80211_hwsim_he_capab()
3007 sband->n_iftype_data = n_iftype_data; in mac80211_hwsim_he_capab()
3045 if (WARN_ON(param->channels > 1 && !param->use_chanctx)) in mac80211_hwsim_new_radio()
3046 return -EINVAL; in mac80211_hwsim_new_radio()
3052 if (param->use_chanctx) in mac80211_hwsim_new_radio()
3054 hw = ieee80211_alloc_hw_nm(sizeof(*data), ops, param->hwname); in mac80211_hwsim_new_radio()
3057 err = -ENOMEM; in mac80211_hwsim_new_radio()
3062 param->hwname = wiphy_name(hw->wiphy); in mac80211_hwsim_new_radio()
3068 wiphy_net_set(hw->wiphy, net); in mac80211_hwsim_new_radio()
3070 data = hw->priv; in mac80211_hwsim_new_radio()
3071 data->hw = hw; in mac80211_hwsim_new_radio()
3073 data->dev = device_create(hwsim_class, NULL, 0, hw, "hwsim%d", idx); in mac80211_hwsim_new_radio()
3074 if (IS_ERR(data->dev)) { in mac80211_hwsim_new_radio()
3077 PTR_ERR(data->dev)); in mac80211_hwsim_new_radio()
3078 err = -ENOMEM; in mac80211_hwsim_new_radio()
3081 data->dev->driver = &mac80211_hwsim_driver.driver; in mac80211_hwsim_new_radio()
3082 err = device_bind_driver(data->dev); in mac80211_hwsim_new_radio()
3089 skb_queue_head_init(&data->pending); in mac80211_hwsim_new_radio()
3091 SET_IEEE80211_DEV(hw, data->dev); in mac80211_hwsim_new_radio()
3092 if (!param->perm_addr) { in mac80211_hwsim_new_radio()
3097 memcpy(data->addresses[0].addr, addr, ETH_ALEN); in mac80211_hwsim_new_radio()
3099 memcpy(data->addresses[1].addr, addr, ETH_ALEN); in mac80211_hwsim_new_radio()
3100 data->addresses[1].addr[0] |= 0x40; in mac80211_hwsim_new_radio()
3101 hw->wiphy->n_addresses = 2; in mac80211_hwsim_new_radio()
3102 hw->wiphy->addresses = data->addresses; in mac80211_hwsim_new_radio()
3105 memcpy(data->addresses[0].addr, param->perm_addr, ETH_ALEN); in mac80211_hwsim_new_radio()
3107 memcpy(data->addresses[1].addr, param->perm_addr, ETH_ALEN); in mac80211_hwsim_new_radio()
3108 hw->wiphy->n_addresses = 2; in mac80211_hwsim_new_radio()
3109 hw->wiphy->addresses = data->addresses; in mac80211_hwsim_new_radio()
3112 data->channels = param->channels; in mac80211_hwsim_new_radio()
3113 data->use_chanctx = param->use_chanctx; in mac80211_hwsim_new_radio()
3114 data->idx = idx; in mac80211_hwsim_new_radio()
3115 data->destroy_on_close = param->destroy_on_close; in mac80211_hwsim_new_radio()
3117 data->portid = info->snd_portid; in mac80211_hwsim_new_radio()
3120 if (param->iftypes & BIT(NL80211_IFTYPE_ADHOC)) { in mac80211_hwsim_new_radio()
3121 data->if_limits[n_limits].max = 1; in mac80211_hwsim_new_radio()
3122 data->if_limits[n_limits].types = BIT(NL80211_IFTYPE_ADHOC); in mac80211_hwsim_new_radio()
3126 if (param->iftypes & HWSIM_DEFAULT_IF_LIMIT) { in mac80211_hwsim_new_radio()
3127 data->if_limits[n_limits].max = 2048; in mac80211_hwsim_new_radio()
3131 * bits that both param->iftype & HWSIM_DEFAULT_IF_LIMIT have. in mac80211_hwsim_new_radio()
3133 data->if_limits[n_limits].types = in mac80211_hwsim_new_radio()
3134 HWSIM_DEFAULT_IF_LIMIT & param->iftypes; in mac80211_hwsim_new_radio()
3138 if (param->iftypes & BIT(NL80211_IFTYPE_P2P_DEVICE)) { in mac80211_hwsim_new_radio()
3139 data->if_limits[n_limits].max = 1; in mac80211_hwsim_new_radio()
3140 data->if_limits[n_limits].types = in mac80211_hwsim_new_radio()
3145 if (data->use_chanctx) { in mac80211_hwsim_new_radio()
3146 hw->wiphy->max_scan_ssids = 255; in mac80211_hwsim_new_radio()
3147 hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; in mac80211_hwsim_new_radio()
3148 hw->wiphy->max_remain_on_channel_duration = 1000; in mac80211_hwsim_new_radio()
3149 data->if_combination.radar_detect_widths = 0; in mac80211_hwsim_new_radio()
3150 data->if_combination.num_different_channels = data->channels; in mac80211_hwsim_new_radio()
3151 data->chanctx = NULL; in mac80211_hwsim_new_radio()
3153 data->if_combination.num_different_channels = 1; in mac80211_hwsim_new_radio()
3154 data->if_combination.radar_detect_widths = in mac80211_hwsim_new_radio()
3165 err = -EINVAL; in mac80211_hwsim_new_radio()
3169 data->if_combination.max_interfaces = 0; in mac80211_hwsim_new_radio()
3171 data->if_combination.max_interfaces += in mac80211_hwsim_new_radio()
3172 data->if_limits[i].max; in mac80211_hwsim_new_radio()
3174 data->if_combination.n_limits = n_limits; in mac80211_hwsim_new_radio()
3175 data->if_combination.limits = data->if_limits; in mac80211_hwsim_new_radio()
3179 * advertise them - if there's only a single thing like in mac80211_hwsim_new_radio()
3182 if (data->if_combination.max_interfaces > 1) { in mac80211_hwsim_new_radio()
3183 hw->wiphy->iface_combinations = &data->if_combination; in mac80211_hwsim_new_radio()
3184 hw->wiphy->n_iface_combinations = 1; in mac80211_hwsim_new_radio()
3187 if (param->ciphers) { in mac80211_hwsim_new_radio()
3188 memcpy(data->ciphers, param->ciphers, in mac80211_hwsim_new_radio()
3189 param->n_ciphers * sizeof(u32)); in mac80211_hwsim_new_radio()
3190 hw->wiphy->cipher_suites = data->ciphers; in mac80211_hwsim_new_radio()
3191 hw->wiphy->n_cipher_suites = param->n_ciphers; in mac80211_hwsim_new_radio()
3194 INIT_DELAYED_WORK(&data->roc_start, hw_roc_start); in mac80211_hwsim_new_radio()
3195 INIT_DELAYED_WORK(&data->roc_done, hw_roc_done); in mac80211_hwsim_new_radio()
3196 INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work); in mac80211_hwsim_new_radio()
3198 hw->queues = 5; in mac80211_hwsim_new_radio()
3199 hw->offchannel_tx_hw_queue = 4; in mac80211_hwsim_new_radio()
3218 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; in mac80211_hwsim_new_radio()
3219 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS | in mac80211_hwsim_new_radio()
3224 hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR | in mac80211_hwsim_new_radio()
3229 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS); in mac80211_hwsim_new_radio()
3230 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_BEACON_PROTECTION); in mac80211_hwsim_new_radio()
3231 wiphy_ext_feature_set(hw->wiphy, in mac80211_hwsim_new_radio()
3233 wiphy_ext_feature_set(hw->wiphy, in mac80211_hwsim_new_radio()
3236 hw->wiphy->interface_modes = param->iftypes; in mac80211_hwsim_new_radio()
3239 hw->vif_data_size = sizeof(struct hwsim_vif_priv); in mac80211_hwsim_new_radio()
3240 hw->sta_data_size = sizeof(struct hwsim_sta_priv); in mac80211_hwsim_new_radio()
3241 hw->chanctx_data_size = sizeof(struct hwsim_chanctx_priv); in mac80211_hwsim_new_radio()
3243 memcpy(data->channels_2ghz, hwsim_channels_2ghz, in mac80211_hwsim_new_radio()
3245 memcpy(data->channels_5ghz, hwsim_channels_5ghz, in mac80211_hwsim_new_radio()
3247 memcpy(data->channels_6ghz, hwsim_channels_6ghz, in mac80211_hwsim_new_radio()
3249 memcpy(data->channels_s1g, hwsim_channels_s1g, in mac80211_hwsim_new_radio()
3251 memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); in mac80211_hwsim_new_radio()
3254 struct ieee80211_supported_band *sband = &data->bands[band]; in mac80211_hwsim_new_radio()
3256 sband->band = band; in mac80211_hwsim_new_radio()
3260 sband->channels = data->channels_2ghz; in mac80211_hwsim_new_radio()
3261 sband->n_channels = ARRAY_SIZE(hwsim_channels_2ghz); in mac80211_hwsim_new_radio()
3262 sband->bitrates = data->rates; in mac80211_hwsim_new_radio()
3263 sband->n_bitrates = ARRAY_SIZE(hwsim_rates); in mac80211_hwsim_new_radio()
3266 sband->channels = data->channels_5ghz; in mac80211_hwsim_new_radio()
3267 sband->n_channels = ARRAY_SIZE(hwsim_channels_5ghz); in mac80211_hwsim_new_radio()
3268 sband->bitrates = data->rates + 4; in mac80211_hwsim_new_radio()
3269 sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4; in mac80211_hwsim_new_radio()
3271 sband->vht_cap.vht_supported = true; in mac80211_hwsim_new_radio()
3272 sband->vht_cap.cap = in mac80211_hwsim_new_radio()
3281 sband->vht_cap.vht_mcs.rx_mcs_map = in mac80211_hwsim_new_radio()
3290 sband->vht_cap.vht_mcs.tx_mcs_map = in mac80211_hwsim_new_radio()
3291 sband->vht_cap.vht_mcs.rx_mcs_map; in mac80211_hwsim_new_radio()
3294 memcpy(&sband->s1g_cap, &hwsim_s1g_cap, in mac80211_hwsim_new_radio()
3295 sizeof(sband->s1g_cap)); in mac80211_hwsim_new_radio()
3296 sband->channels = data->channels_s1g; in mac80211_hwsim_new_radio()
3297 sband->n_channels = ARRAY_SIZE(hwsim_channels_s1g); in mac80211_hwsim_new_radio()
3303 sband->ht_cap.ht_supported = true; in mac80211_hwsim_new_radio()
3304 sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | in mac80211_hwsim_new_radio()
3309 sband->ht_cap.ampdu_factor = 0x3; in mac80211_hwsim_new_radio()
3310 sband->ht_cap.ampdu_density = 0x6; in mac80211_hwsim_new_radio()
3311 memset(&sband->ht_cap.mcs, 0, in mac80211_hwsim_new_radio()
3312 sizeof(sband->ht_cap.mcs)); in mac80211_hwsim_new_radio()
3313 sband->ht_cap.mcs.rx_mask[0] = 0xff; in mac80211_hwsim_new_radio()
3314 sband->ht_cap.mcs.rx_mask[1] = 0xff; in mac80211_hwsim_new_radio()
3315 sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in mac80211_hwsim_new_radio()
3319 hw->wiphy->bands[band] = sband; in mac80211_hwsim_new_radio()
3323 data->group = 1; in mac80211_hwsim_new_radio()
3324 mutex_init(&data->mutex); in mac80211_hwsim_new_radio()
3326 data->netgroup = hwsim_net_get_netgroup(net); in mac80211_hwsim_new_radio()
3327 data->wmediumd = hwsim_net_get_wmediumd(net); in mac80211_hwsim_new_radio()
3330 hw->max_rates = 4; in mac80211_hwsim_new_radio()
3331 hw->max_rate_tries = 11; in mac80211_hwsim_new_radio()
3333 hw->wiphy->vendor_commands = mac80211_hwsim_vendor_commands; in mac80211_hwsim_new_radio()
3334 hw->wiphy->n_vendor_commands = in mac80211_hwsim_new_radio()
3336 hw->wiphy->vendor_events = mac80211_hwsim_vendor_events; in mac80211_hwsim_new_radio()
3337 hw->wiphy->n_vendor_events = ARRAY_SIZE(mac80211_hwsim_vendor_events); in mac80211_hwsim_new_radio()
3339 if (param->reg_strict) in mac80211_hwsim_new_radio()
3340 hw->wiphy->regulatory_flags |= REGULATORY_STRICT_REG; in mac80211_hwsim_new_radio()
3341 if (param->regd) { in mac80211_hwsim_new_radio()
3342 data->regd = param->regd; in mac80211_hwsim_new_radio()
3343 hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; in mac80211_hwsim_new_radio()
3344 wiphy_apply_custom_regulatory(hw->wiphy, param->regd); in mac80211_hwsim_new_radio()
3349 if (param->no_vif) in mac80211_hwsim_new_radio()
3352 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in mac80211_hwsim_new_radio()
3354 hrtimer_init(&data->beacon_timer, CLOCK_MONOTONIC, in mac80211_hwsim_new_radio()
3356 data->beacon_timer.function = mac80211_hwsim_beacon; in mac80211_hwsim_new_radio()
3365 wiphy_dbg(hw->wiphy, "hwaddr %pM registered\n", hw->wiphy->perm_addr); in mac80211_hwsim_new_radio()
3367 if (param->reg_alpha2) { in mac80211_hwsim_new_radio()
3368 data->alpha2[0] = param->reg_alpha2[0]; in mac80211_hwsim_new_radio()
3369 data->alpha2[1] = param->reg_alpha2[1]; in mac80211_hwsim_new_radio()
3370 regulatory_hint(hw->wiphy, param->reg_alpha2); in mac80211_hwsim_new_radio()
3373 data->debugfs = debugfs_create_dir("hwsim", hw->wiphy->debugfsdir); in mac80211_hwsim_new_radio()
3374 debugfs_create_file("ps", 0666, data->debugfs, data, &hwsim_fops_ps); in mac80211_hwsim_new_radio()
3375 debugfs_create_file("group", 0666, data->debugfs, data, in mac80211_hwsim_new_radio()
3377 if (!data->use_chanctx) in mac80211_hwsim_new_radio()
3379 data->debugfs, in mac80211_hwsim_new_radio()
3383 err = rhashtable_insert_fast(&hwsim_radios_rht, &data->rht, in mac80211_hwsim_new_radio()
3388 NL_SET_BAD_ATTR(info->extack, in mac80211_hwsim_new_radio()
3389 info->attrs[HWSIM_ATTR_PERM_ADDR]); in mac80211_hwsim_new_radio()
3395 list_add_tail(&data->list, &hwsim_radios); in mac80211_hwsim_new_radio()
3404 debugfs_remove_recursive(data->debugfs); in mac80211_hwsim_new_radio()
3405 ieee80211_unregister_hw(data->hw); in mac80211_hwsim_new_radio()
3407 device_release_driver(data->dev); in mac80211_hwsim_new_radio()
3409 device_unregister(data->dev); in mac80211_hwsim_new_radio()
3455 hwsim_mcast_del_radio(data->idx, hwname, info); in mac80211_hwsim_del_radio()
3456 debugfs_remove_recursive(data->debugfs); in mac80211_hwsim_del_radio()
3457 ieee80211_unregister_hw(data->hw); in mac80211_hwsim_del_radio()
3458 device_release_driver(data->dev); in mac80211_hwsim_del_radio()
3459 device_unregister(data->dev); in mac80211_hwsim_del_radio()
3460 ieee80211_free_hw(data->hw); in mac80211_hwsim_del_radio()
3470 int res = -EMSGSIZE; in mac80211_hwsim_get_radio()
3475 return -EMSGSIZE; in mac80211_hwsim_get_radio()
3480 if (data->alpha2[0] && data->alpha2[1]) in mac80211_hwsim_get_radio()
3481 param.reg_alpha2 = data->alpha2; in mac80211_hwsim_get_radio()
3483 param.reg_strict = !!(data->hw->wiphy->regulatory_flags & in mac80211_hwsim_get_radio()
3485 param.p2p_device = !!(data->hw->wiphy->interface_modes & in mac80211_hwsim_get_radio()
3487 param.use_chanctx = data->use_chanctx; in mac80211_hwsim_get_radio()
3488 param.regd = data->regd; in mac80211_hwsim_get_radio()
3489 param.channels = data->channels; in mac80211_hwsim_get_radio()
3490 param.hwname = wiphy_name(data->hw->wiphy); in mac80211_hwsim_get_radio()
3492 res = append_radio_msg(skb, data->idx, &param); in mac80211_hwsim_get_radio()
3512 list_del(&data->list); in mac80211_hwsim_free()
3514 mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy), in mac80211_hwsim_free()
3530 dev->netdev_ops = &hwsim_netdev_ops; in hwsim_mon_setup()
3531 dev->needs_free_netdev = true; in hwsim_mon_setup()
3533 dev->priv_flags |= IFF_NO_QUEUE; in hwsim_mon_setup()
3534 dev->type = ARPHRD_IEEE80211_RADIOTAP; in hwsim_mon_setup()
3535 eth_zero_addr(dev->dev_addr); in hwsim_mon_setup()
3536 dev->dev_addr[0] = 0x12; in hwsim_mon_setup()
3554 if (data->netgroup == hwsim_net_get_netgroup(net)) in hwsim_register_wmediumd()
3555 data->wmediumd = portid; in hwsim_register_wmediumd()
3575 if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] || in hwsim_tx_info_frame_received_nl()
3576 !info->attrs[HWSIM_ATTR_FLAGS] || in hwsim_tx_info_frame_received_nl()
3577 !info->attrs[HWSIM_ATTR_COOKIE] || in hwsim_tx_info_frame_received_nl()
3578 !info->attrs[HWSIM_ATTR_SIGNAL] || in hwsim_tx_info_frame_received_nl()
3579 !info->attrs[HWSIM_ATTR_TX_INFO]) in hwsim_tx_info_frame_received_nl()
3582 src = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]); in hwsim_tx_info_frame_received_nl()
3583 hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]); in hwsim_tx_info_frame_received_nl()
3584 ret_skb_cookie = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]); in hwsim_tx_info_frame_received_nl()
3592 data2->netgroup) in hwsim_tx_info_frame_received_nl()
3595 if (info->snd_portid != data2->wmediumd) in hwsim_tx_info_frame_received_nl()
3600 skb_queue_walk_safe(&data2->pending, skb, tmp) { in hwsim_tx_info_frame_received_nl()
3604 skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0]; in hwsim_tx_info_frame_received_nl()
3607 skb_unlink(skb, &data2->pending); in hwsim_tx_info_frame_received_nl()
3621 info->attrs[HWSIM_ATTR_TX_INFO]); in hwsim_tx_info_frame_received_nl()
3629 txi->status.rates[i].idx = tx_attempts[i].idx; in hwsim_tx_info_frame_received_nl()
3630 txi->status.rates[i].count = tx_attempts[i].count; in hwsim_tx_info_frame_received_nl()
3633 txi->status.ack_signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]); in hwsim_tx_info_frame_received_nl()
3637 if (skb->len >= 16) { in hwsim_tx_info_frame_received_nl()
3638 hdr = (struct ieee80211_hdr *) skb->data; in hwsim_tx_info_frame_received_nl()
3639 mac80211_hwsim_monitor_ack(data2->channel, in hwsim_tx_info_frame_received_nl()
3640 hdr->addr2); in hwsim_tx_info_frame_received_nl()
3642 txi->flags |= IEEE80211_TX_STAT_ACK; in hwsim_tx_info_frame_received_nl()
3644 ieee80211_tx_status_irqsafe(data2->hw, skb); in hwsim_tx_info_frame_received_nl()
3647 return -EINVAL; in hwsim_tx_info_frame_received_nl()
3663 if (!info->attrs[HWSIM_ATTR_ADDR_RECEIVER] || in hwsim_cloned_frame_received_nl()
3664 !info->attrs[HWSIM_ATTR_FRAME] || in hwsim_cloned_frame_received_nl()
3665 !info->attrs[HWSIM_ATTR_RX_RATE] || in hwsim_cloned_frame_received_nl()
3666 !info->attrs[HWSIM_ATTR_SIGNAL]) in hwsim_cloned_frame_received_nl()
3669 dst = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_RECEIVER]); in hwsim_cloned_frame_received_nl()
3670 frame_data_len = nla_len(info->attrs[HWSIM_ATTR_FRAME]); in hwsim_cloned_frame_received_nl()
3671 frame_data = (void *)nla_data(info->attrs[HWSIM_ATTR_FRAME]); in hwsim_cloned_frame_received_nl()
3688 if (data2->use_chanctx) { in hwsim_cloned_frame_received_nl()
3689 if (data2->tmp_chan) in hwsim_cloned_frame_received_nl()
3690 channel = data2->tmp_chan; in hwsim_cloned_frame_received_nl()
3691 else if (data2->chanctx) in hwsim_cloned_frame_received_nl()
3692 channel = data2->chanctx->def.chan; in hwsim_cloned_frame_received_nl()
3694 channel = data2->channel; in hwsim_cloned_frame_received_nl()
3701 data2->netgroup) in hwsim_cloned_frame_received_nl()
3704 if (info->snd_portid != data2->wmediumd) in hwsim_cloned_frame_received_nl()
3710 if ((data2->idle && !data2->tmp_chan) || !data2->started) in hwsim_cloned_frame_received_nl()
3715 if (info->attrs[HWSIM_ATTR_FREQ]) { in hwsim_cloned_frame_received_nl()
3716 /* throw away off-channel packets, but allow both the temporary in hwsim_cloned_frame_received_nl()
3717 * ("hw" scan/remain-on-channel) and regular channel, since the in hwsim_cloned_frame_received_nl()
3720 mutex_lock(&data2->mutex); in hwsim_cloned_frame_received_nl()
3721 rx_status.freq = nla_get_u32(info->attrs[HWSIM_ATTR_FREQ]); in hwsim_cloned_frame_received_nl()
3723 if (rx_status.freq != channel->center_freq) { in hwsim_cloned_frame_received_nl()
3724 mutex_unlock(&data2->mutex); in hwsim_cloned_frame_received_nl()
3727 mutex_unlock(&data2->mutex); in hwsim_cloned_frame_received_nl()
3729 rx_status.freq = channel->center_freq; in hwsim_cloned_frame_received_nl()
3732 rx_status.band = channel->band; in hwsim_cloned_frame_received_nl()
3733 rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]); in hwsim_cloned_frame_received_nl()
3734 rx_status.signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]); in hwsim_cloned_frame_received_nl()
3736 hdr = (void *)skb->data; in hwsim_cloned_frame_received_nl()
3738 if (ieee80211_is_beacon(hdr->frame_control) || in hwsim_cloned_frame_received_nl()
3739 ieee80211_is_probe_resp(hdr->frame_control)) in hwsim_cloned_frame_received_nl()
3743 data2->rx_pkts++; in hwsim_cloned_frame_received_nl()
3744 data2->rx_bytes += skb->len; in hwsim_cloned_frame_received_nl()
3745 ieee80211_rx_irqsafe(data2->hw, skb); in hwsim_cloned_frame_received_nl()
3752 return -EINVAL; in hwsim_cloned_frame_received_nl()
3764 chans = max(chans, data->channels); in hwsim_register_received_nl()
3768 * to set a flag that it does support multi-channel, then we can in hwsim_register_received_nl()
3773 return -EOPNOTSUPP; in hwsim_register_received_nl()
3776 return -EBUSY; in hwsim_register_received_nl()
3778 hwsim_register_wmediumd(net, info->snd_portid); in hwsim_register_received_nl()
3781 "switching to wmediumd mode with pid %d\n", info->snd_portid); in hwsim_register_received_nl()
3815 param.reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG]; in hwsim_new_radio_nl()
3816 param.p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE]; in hwsim_new_radio_nl()
3819 info->attrs[HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE]; in hwsim_new_radio_nl()
3821 if (info->attrs[HWSIM_ATTR_CHANNELS]) in hwsim_new_radio_nl()
3822 param.channels = nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]); in hwsim_new_radio_nl()
3826 return -EINVAL; in hwsim_new_radio_nl()
3829 if (info->attrs[HWSIM_ATTR_NO_VIF]) in hwsim_new_radio_nl()
3832 if (info->attrs[HWSIM_ATTR_USE_CHANCTX]) in hwsim_new_radio_nl()
3837 if (info->attrs[HWSIM_ATTR_REG_HINT_ALPHA2]) in hwsim_new_radio_nl()
3839 nla_data(info->attrs[HWSIM_ATTR_REG_HINT_ALPHA2]); in hwsim_new_radio_nl()
3841 if (info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]) { in hwsim_new_radio_nl()
3842 u32 idx = nla_get_u32(info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]); in hwsim_new_radio_nl()
3845 return -EINVAL; in hwsim_new_radio_nl()
3852 if (info->attrs[HWSIM_ATTR_PERM_ADDR]) { in hwsim_new_radio_nl()
3854 nla_data(info->attrs[HWSIM_ATTR_PERM_ADDR]))) { in hwsim_new_radio_nl()
3856 NL_SET_BAD_ATTR(info->extack, in hwsim_new_radio_nl()
3857 info->attrs[HWSIM_ATTR_PERM_ADDR]); in hwsim_new_radio_nl()
3858 return -EINVAL; in hwsim_new_radio_nl()
3861 param.perm_addr = nla_data(info->attrs[HWSIM_ATTR_PERM_ADDR]); in hwsim_new_radio_nl()
3864 if (info->attrs[HWSIM_ATTR_IFTYPE_SUPPORT]) { in hwsim_new_radio_nl()
3866 nla_get_u32(info->attrs[HWSIM_ATTR_IFTYPE_SUPPORT]); in hwsim_new_radio_nl()
3869 NL_SET_ERR_MSG_ATTR(info->extack, in hwsim_new_radio_nl()
3870 info->attrs[HWSIM_ATTR_IFTYPE_SUPPORT], in hwsim_new_radio_nl()
3872 return -EINVAL; in hwsim_new_radio_nl()
3885 if (info->attrs[HWSIM_ATTR_CIPHER_SUPPORT]) { in hwsim_new_radio_nl()
3886 u32 len = nla_len(info->attrs[HWSIM_ATTR_CIPHER_SUPPORT]); in hwsim_new_radio_nl()
3889 nla_data(info->attrs[HWSIM_ATTR_CIPHER_SUPPORT]); in hwsim_new_radio_nl()
3892 NL_SET_ERR_MSG_ATTR(info->extack, in hwsim_new_radio_nl()
3893 info->attrs[HWSIM_ATTR_CIPHER_SUPPORT], in hwsim_new_radio_nl()
3895 return -EINVAL; in hwsim_new_radio_nl()
3901 NL_SET_ERR_MSG_ATTR(info->extack, in hwsim_new_radio_nl()
3902 info->attrs[HWSIM_ATTR_CIPHER_SUPPORT], in hwsim_new_radio_nl()
3904 return -EINVAL; in hwsim_new_radio_nl()
3908 NL_SET_ERR_MSG_ATTR(info->extack, in hwsim_new_radio_nl()
3909 info->attrs[HWSIM_ATTR_CIPHER_SUPPORT], in hwsim_new_radio_nl()
3911 return -EINVAL; in hwsim_new_radio_nl()
3915 if (info->attrs[HWSIM_ATTR_RADIO_NAME]) { in hwsim_new_radio_nl()
3916 hwname = kstrndup((char *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]), in hwsim_new_radio_nl()
3917 nla_len(info->attrs[HWSIM_ATTR_RADIO_NAME]), in hwsim_new_radio_nl()
3920 return -ENOMEM; in hwsim_new_radio_nl()
3932 s64 idx = -1; in hwsim_del_radio_nl()
3935 if (info->attrs[HWSIM_ATTR_RADIO_ID]) { in hwsim_del_radio_nl()
3936 idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]); in hwsim_del_radio_nl()
3937 } else if (info->attrs[HWSIM_ATTR_RADIO_NAME]) { in hwsim_del_radio_nl()
3938 hwname = kstrndup((char *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]), in hwsim_del_radio_nl()
3939 nla_len(info->attrs[HWSIM_ATTR_RADIO_NAME]), in hwsim_del_radio_nl()
3942 return -ENOMEM; in hwsim_del_radio_nl()
3944 return -EINVAL; in hwsim_del_radio_nl()
3949 if (data->idx != idx) in hwsim_del_radio_nl()
3953 strcmp(hwname, wiphy_name(data->hw->wiphy))) in hwsim_del_radio_nl()
3957 if (!net_eq(wiphy_net(data->hw->wiphy), genl_info_net(info))) in hwsim_del_radio_nl()
3960 list_del(&data->list); in hwsim_del_radio_nl()
3961 rhashtable_remove_fast(&hwsim_radios_rht, &data->rht, in hwsim_del_radio_nl()
3965 mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy), in hwsim_del_radio_nl()
3973 return -ENODEV; in hwsim_del_radio_nl()
3980 int idx, res = -ENODEV; in hwsim_get_radio_nl()
3982 if (!info->attrs[HWSIM_ATTR_RADIO_ID]) in hwsim_get_radio_nl()
3983 return -EINVAL; in hwsim_get_radio_nl()
3984 idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]); in hwsim_get_radio_nl()
3988 if (data->idx != idx) in hwsim_get_radio_nl()
3991 if (!net_eq(wiphy_net(data->hw->wiphy), genl_info_net(info))) in hwsim_get_radio_nl()
3996 res = -ENOMEM; in hwsim_get_radio_nl()
4000 res = mac80211_hwsim_get_radio(skb, data, info->snd_portid, in hwsim_get_radio_nl()
4001 info->snd_seq, NULL, 0); in hwsim_get_radio_nl()
4020 int last_idx = cb->args[0] - 1; in hwsim_dump_radio_nl()
4026 cb->seq = hwsim_radios_generation; in hwsim_dump_radio_nl()
4028 if (last_idx >= hwsim_radio_idx-1) in hwsim_dump_radio_nl()
4032 if (data->idx <= last_idx) in hwsim_dump_radio_nl()
4035 if (!net_eq(wiphy_net(data->hw->wiphy), sock_net(skb->sk))) in hwsim_dump_radio_nl()
4039 NETLINK_CB(cb->skb).portid, in hwsim_dump_radio_nl()
4040 cb->nlh->nlmsg_seq, cb, in hwsim_dump_radio_nl()
4045 last_idx = data->idx; in hwsim_dump_radio_nl()
4048 cb->args[0] = last_idx + 1; in hwsim_dump_radio_nl()
4051 if (skb->len == 0 && cb->prev_seq && cb->seq != cb->prev_seq) { in hwsim_dump_radio_nl()
4052 hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, in hwsim_dump_radio_nl()
4053 cb->nlh->nlmsg_seq, &hwsim_genl_family, in hwsim_dump_radio_nl()
4059 res = -EMSGSIZE; in hwsim_dump_radio_nl()
4065 return res ?: skb->len; in hwsim_dump_radio_nl()
4126 if (entry->destroy_on_close && entry->portid == portid) { in remove_user_radios()
4127 list_move(&entry->list, &list); in remove_user_radios()
4128 rhashtable_remove_fast(&hwsim_radios_rht, &entry->rht, in remove_user_radios()
4136 list_del(&entry->list); in remove_user_radios()
4137 mac80211_hwsim_del_radio(entry, wiphy_name(entry->hw->wiphy), in remove_user_radios()
4151 remove_user_radios(notify->portid); in mac80211_hwsim_netlink_notify()
4153 if (notify->portid == hwsim_net_get_wmediumd(notify->net)) { in mac80211_hwsim_netlink_notify()
4156 hwsim_register_wmediumd(notify->net, 0); in mac80211_hwsim_netlink_notify()
4186 return -EINVAL; in hwsim_init_netlink()
4201 if (!net_eq(wiphy_net(data->hw->wiphy), net)) in hwsim_exit_net()
4205 if (data->netgroup == hwsim_net_get_netgroup(&init_net)) in hwsim_exit_net()
4208 list_move(&data->list, &list); in hwsim_exit_net()
4209 rhashtable_remove_fast(&hwsim_radios_rht, &data->rht, in hwsim_exit_net()
4216 list_del(&data->list); in hwsim_exit_net()
4218 wiphy_name(data->hw->wiphy), in hwsim_exit_net()
4272 switch (gnlh->cmd) { in hwsim_virtio_handle_cmd()
4280 pr_err_ratelimited("hwsim: invalid cmd: %d\n", gnlh->cmd); in hwsim_virtio_handle_cmd()
4281 return -EPROTO; in hwsim_virtio_handle_cmd()
4304 skb->data = skb->head; in hwsim_virtio_rx_work()
4314 sg_init_one(sg, skb->head, skb_end_offset(skb)); in hwsim_virtio_rx_work()
4355 return -ENOMEM; in fill_vq()
4357 sg_init_one(sg, skb->head, skb_end_offset(skb)); in fill_vq()
4372 vdev->config->reset(vdev); in remove_vqs()
4382 vdev->config->del_vqs(vdev); in remove_vqs()
4393 return -EEXIST; in hwsim_virtio_probe()
4466 return -EINVAL; in init_mac80211_hwsim()
4469 return -EINVAL; in init_mac80211_hwsim()
4584 err = -ENOMEM; in init_mac80211_hwsim()
4589 err = dev_alloc_name(hwsim_mon, hwsim_mon->name); in init_mac80211_hwsim()