Lines Matching refs:mac

125 static void housekeeping_init(struct zd_mac *mac);
126 static void housekeeping_enable(struct zd_mac *mac);
127 static void housekeeping_disable(struct zd_mac *mac);
128 static void beacon_init(struct zd_mac *mac);
129 static void beacon_enable(struct zd_mac *mac);
130 static void beacon_disable(struct zd_mac *mac);
131 static void set_rts_cts(struct zd_mac *mac, unsigned int short_preamble);
152 struct zd_mac *mac = zd_hw_mac(hw);
154 dev_dbg_f_cond(zd_mac_dev(mac), signal < 0 || signal > 100,
170 struct zd_mac *mac = zd_hw_mac(hw);
172 r = zd_chip_read_mac_addr_fw(&mac->chip, addr);
184 struct zd_mac *mac = zd_hw_mac(hw);
185 struct zd_chip *chip = &mac->chip;
201 spin_lock_irq(&mac->lock);
202 mac->regdomain = mac->default_regdomain = default_regdomain;
203 spin_unlock_irq(&mac->lock);
211 r = zd_reg2alpha2(mac->regdomain, alpha2);
222 void zd_mac_clear(struct zd_mac *mac)
225 zd_chip_clear(&mac->chip);
226 ZD_MEMCLEAR(mac, sizeof(struct zd_mac));
229 static int set_rx_filter(struct zd_mac *mac)
234 spin_lock_irqsave(&mac->lock, flags);
235 if (mac->pass_ctrl)
237 spin_unlock_irqrestore(&mac->lock, flags);
239 return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter);
242 static int set_mac_and_bssid(struct zd_mac *mac)
246 if (!mac->vif)
249 r = zd_write_mac_addr(&mac->chip, mac->vif->addr);
256 if (mac->type != NL80211_IFTYPE_AP)
257 return set_rx_filter(mac);
259 return zd_write_bssid(&mac->chip, mac->vif->addr);
262 static int set_mc_hash(struct zd_mac *mac)
266 return zd_chip_set_multicast_hash(&mac->chip, &hash);
271 struct zd_mac *mac = zd_hw_mac(hw);
272 struct zd_chip *chip = &mac->chip;
289 r = set_rx_filter(mac);
292 r = set_mc_hash(mac);
315 housekeeping_enable(mac);
316 beacon_enable(mac);
317 set_bit(ZD_DEVICE_RUNNING, &mac->flags);
331 struct zd_mac *mac = zd_hw_mac(hw);
332 struct zd_chip *chip = &mac->chip;
334 struct sk_buff_head *ack_wait_queue = &mac->ack_wait_queue;
336 clear_bit(ZD_DEVICE_RUNNING, &mac->flags);
344 beacon_disable(mac);
345 housekeeping_disable(mac);
357 int zd_restore_settings(struct zd_mac *mac)
365 dev_dbg_f(zd_mac_dev(mac), "\n");
367 spin_lock_irq(&mac->lock);
368 multicast_hash = mac->multicast_hash;
369 short_preamble = mac->short_preamble;
370 beacon_interval = mac->beacon.interval;
371 beacon_period = mac->beacon.period;
372 channel = mac->channel;
373 spin_unlock_irq(&mac->lock);
375 r = set_mac_and_bssid(mac);
377 dev_dbg_f(zd_mac_dev(mac), "set_mac_and_bssid failed, %d\n", r);
381 r = zd_chip_set_channel(&mac->chip, channel);
383 dev_dbg_f(zd_mac_dev(mac), "zd_chip_set_channel failed, %d\n",
388 set_rts_cts(mac, short_preamble);
390 r = zd_chip_set_multicast_hash(&mac->chip, &multicast_hash);
392 dev_dbg_f(zd_mac_dev(mac),
397 if (mac->type == NL80211_IFTYPE_MESH_POINT ||
398 mac->type == NL80211_IFTYPE_ADHOC ||
399 mac->type == NL80211_IFTYPE_AP) {
400 if (mac->vif != NULL) {
401 beacon = ieee80211_beacon_get(mac->hw, mac->vif, 0);
403 zd_mac_config_beacon(mac->hw, beacon, false);
406 zd_set_beacon_interval(&mac->chip, beacon_interval,
407 beacon_period, mac->type);
409 spin_lock_irq(&mac->lock);
410 mac->beacon.last_update = jiffies;
411 spin_unlock_irq(&mac->lock);
488 struct zd_mac *mac = zd_hw_mac(hw);
489 struct sk_buff_head *q = &mac->ack_wait_queue;
512 if (tx_status->failure && mac->ack_pending &&
520 if (unlikely(!ether_addr_equal(tx_hdr->addr1, tx_status->mac)))
547 mac->ack_pending ? mac->ack_signal : 0,
549 mac->ack_pending = 0;
570 struct zd_mac *mac = zd_hw_mac(hw);
582 struct sk_buff_head *q = &mac->ack_wait_queue;
587 mac->ack_pending ? mac->ack_signal : 0,
589 mac->ack_pending = 0;
641 static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
674 static bool zd_mac_match_cur_beacon(struct zd_mac *mac, struct sk_buff *beacon)
676 if (!mac->beacon.cur_beacon)
679 if (mac->beacon.cur_beacon->len != beacon->len)
682 return !memcmp(beacon->data, mac->beacon.cur_beacon->data, beacon->len);
685 static void zd_mac_free_cur_beacon_locked(struct zd_mac *mac)
687 ZD_ASSERT(mutex_is_locked(&mac->chip.mutex));
689 kfree_skb(mac->beacon.cur_beacon);
690 mac->beacon.cur_beacon = NULL;
693 static void zd_mac_free_cur_beacon(struct zd_mac *mac)
695 mutex_lock(&mac->chip.mutex);
696 zd_mac_free_cur_beacon_locked(mac);
697 mutex_unlock(&mac->chip.mutex);
703 struct zd_mac *mac = zd_hw_mac(hw);
711 mutex_lock(&mac->chip.mutex);
714 if (zd_mac_match_cur_beacon(mac, beacon)) {
720 num_cmds = 1 + zd_chip_is_zd1211b(&mac->chip) + full_len;
728 r = zd_iowrite32_locked(&mac->chip, 0, CR_BCN_FIFO_SEMAPHORE);
731 r = zd_ioread32_locked(&mac->chip, &tmp, CR_BCN_FIFO_SEMAPHORE);
742 r = zd_ioread32_locked(&mac->chip, &tmp, CR_BCN_FIFO_SEMAPHORE);
747 dev_err(zd_mac_dev(mac),
750 dev_err(zd_mac_dev(mac),
762 if (zd_chip_is_zd1211b(&mac->chip)) {
782 r = zd_iowrite32a_locked(&mac->chip, ioreqs, num_cmds);
790 ret = zd_iowrite32_locked(&mac->chip, 1, CR_BCN_FIFO_SEMAPHORE);
798 ret = zd_iowrite32_locked(&mac->chip, 1, CR_BCN_FIFO_SEMAPHORE);
802 dev_err(zd_mac_dev(mac), "Could not release "
810 zd_mac_free_cur_beacon_locked(mac);
816 zd_mac_free_cur_beacon_locked(mac);
817 mac->beacon.cur_beacon = beacon;
824 r = zd_iowrite32_locked(&mac->chip, 0x00000400 | (full_len << 19),
830 mutex_unlock(&mac->chip.mutex);
835 zd_mac_free_cur_beacon_locked(mac);
838 mutex_unlock(&mac->chip.mutex);
842 dev_warn(zd_mac_dev(mac), "CR_BCN_FIFO_SEMAPHORE stuck, "
844 usb_queue_reset_device(mac->chip.usb.intf);
849 static int fill_ctrlset(struct zd_mac *mac,
870 txrate = ieee80211_get_tx_rate(mac->hw, info);
878 cs_set_control(mac, cs, hdr, info);
885 cs->packet_length = cpu_to_le16(zd_chip_is_zd1211b(&mac->chip) ?
927 struct zd_mac *mac = zd_hw_mac(hw);
931 r = fill_ctrlset(mac, skb);
937 r = zd_usb_tx(&mac->chip.usb, skb);
963 struct zd_mac *mac = zd_hw_mac(hw);
973 q = &mac->ack_wait_queue;
980 if (mac->ack_pending && skb_queue_is_first(q, skb))
995 mac->ack_pending ? mac->ack_signal : 0,
997 mac->ack_pending = 0;
1000 mac->ack_pending = 1;
1001 mac->ack_signal = stats->signal;
1004 if (mac->type == NL80211_IFTYPE_AP) {
1006 zd_mac_tx_status(hw, skb, mac->ack_signal, NULL);
1007 mac->ack_pending = 0;
1017 struct zd_mac *mac = zd_hw_mac(hw);
1034 * mac locking intentionally omitted here, as this is the only unlocked
1046 if (mac->pass_failed_fcs &&
1055 stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq;
1062 for (i = 0; i < mac->band.n_bitrates; i++)
1063 if (rate == mac->band.bitrates[i].hw_value)
1076 && !mac->pass_ctrl)
1101 struct zd_mac *mac = zd_hw_mac(hw);
1104 if (mac->type != NL80211_IFTYPE_UNSPECIFIED)
1113 mac->type = vif->type;
1119 mac->vif = vif;
1121 return set_mac_and_bssid(mac);
1127 struct zd_mac *mac = zd_hw_mac(hw);
1128 mac->type = NL80211_IFTYPE_UNSPECIFIED;
1129 mac->vif = NULL;
1130 zd_set_beacon_interval(&mac->chip, 0, 0, NL80211_IFTYPE_UNSPECIFIED);
1131 zd_write_mac_addr(&mac->chip, NULL);
1133 zd_mac_free_cur_beacon(mac);
1138 struct zd_mac *mac = zd_hw_mac(hw);
1141 spin_lock_irq(&mac->lock);
1142 mac->channel = conf->chandef.chan->hw_value;
1143 spin_unlock_irq(&mac->lock);
1145 return zd_chip_set_channel(&mac->chip, conf->chandef.chan->hw_value);
1148 static void zd_beacon_done(struct zd_mac *mac)
1152 if (!test_bit(ZD_DEVICE_RUNNING, &mac->flags))
1154 if (!mac->vif || mac->vif->type != NL80211_IFTYPE_AP)
1160 while (!ieee80211_queue_stopped(mac->hw, 0)) {
1161 skb = ieee80211_get_buffered_bc(mac->hw, mac->vif);
1164 zd_op_tx(mac->hw, NULL, skb);
1170 beacon = ieee80211_beacon_get(mac->hw, mac->vif, 0);
1172 zd_mac_config_beacon(mac->hw, beacon, true);
1174 spin_lock_irq(&mac->lock);
1175 mac->beacon.last_update = jiffies;
1176 spin_unlock_irq(&mac->lock);
1183 struct zd_mac *mac = container_of(work, struct zd_mac, process_intr);
1185 spin_lock_irqsave(&mac->lock, flags);
1186 int_status = le16_to_cpu(*(__le16 *)(mac->intr_buffer + 4));
1187 spin_unlock_irqrestore(&mac->lock, flags);
1190 /*dev_dbg_f_limit(zd_mac_dev(mac), "INT_CFG_NEXT_BCN\n");*/
1191 zd_beacon_done(mac);
1193 dev_dbg_f(zd_mac_dev(mac), "Unsupported interrupt\n");
1196 zd_chip_enable_hwint(&mac->chip);
1203 struct zd_mac *mac = zd_hw_mac(hw);
1210 dev_dbg_f(zd_mac_dev(mac), "mc addr %pM\n", ha->addr);
1229 struct zd_mac *mac = zd_hw_mac(hw);
1247 spin_lock_irqsave(&mac->lock, flags);
1248 mac->pass_failed_fcs = !!(*new_flags & FIF_FCSFAIL);
1249 mac->pass_ctrl = !!(*new_flags & FIF_CONTROL);
1250 mac->multicast_hash = hash;
1251 spin_unlock_irqrestore(&mac->lock, flags);
1253 zd_chip_set_multicast_hash(&mac->chip, &hash);
1256 r = set_rx_filter(mac);
1258 dev_err(zd_mac_dev(mac), "set_rx_filter error %d\n", r);
1271 static void set_rts_cts(struct zd_mac *mac, unsigned int short_preamble)
1273 mutex_lock(&mac->chip.mutex);
1274 zd_chip_set_rts_cts_rate_locked(&mac->chip, short_preamble);
1275 mutex_unlock(&mac->chip.mutex);
1283 struct zd_mac *mac = zd_hw_mac(hw);
1286 dev_dbg_f(zd_mac_dev(mac), "changes: %llx\n", changes);
1288 if (mac->type == NL80211_IFTYPE_MESH_POINT ||
1289 mac->type == NL80211_IFTYPE_ADHOC ||
1290 mac->type == NL80211_IFTYPE_AP) {
1297 zd_chip_disable_hwint(&mac->chip);
1299 zd_chip_enable_hwint(&mac->chip);
1312 spin_lock_irq(&mac->lock);
1313 mac->beacon.period = period;
1314 mac->beacon.interval = interval;
1315 mac->beacon.last_update = jiffies;
1316 spin_unlock_irq(&mac->lock);
1318 zd_set_beacon_interval(&mac->chip, interval, period,
1319 mac->type);
1324 spin_lock_irq(&mac->lock);
1325 mac->associated = associated;
1326 spin_unlock_irq(&mac->lock);
1331 spin_lock_irq(&mac->lock);
1332 mac->short_preamble = bss_conf->use_short_preamble;
1333 spin_unlock_irq(&mac->lock);
1335 set_rts_cts(mac, bss_conf->use_short_preamble);
1341 struct zd_mac *mac = zd_hw_mac(hw);
1342 return zd_chip_get_tsf(&mac->chip);
1365 struct zd_mac *mac;
1374 mac = zd_hw_mac(hw);
1376 memset(mac, 0, sizeof(*mac));
1377 spin_lock_init(&mac->lock);
1378 mac->hw = hw;
1380 mac->type = NL80211_IFTYPE_UNSPECIFIED;
1382 memcpy(mac->channels, zd_channels, sizeof(zd_channels));
1383 memcpy(mac->rates, zd_rates, sizeof(zd_rates));
1384 mac->band.n_bitrates = ARRAY_SIZE(zd_rates);
1385 mac->band.bitrates = mac->rates;
1386 mac->band.n_channels = ARRAY_SIZE(zd_channels);
1387 mac->band.channels = mac->channels;
1389 hw->wiphy->bands[NL80211_BAND_2GHZ] = &mac->band;
1414 skb_queue_head_init(&mac->ack_wait_queue);
1415 mac->ack_pending = 0;
1417 zd_chip_init(&mac->chip, hw, intf);
1418 housekeeping_init(mac);
1419 beacon_init(mac);
1420 INIT_WORK(&mac->process_intr, zd_process_intr);
1430 struct zd_mac *mac =
1436 if (!test_bit(ZD_DEVICE_RUNNING, &mac->flags))
1438 if (mac->type != NL80211_IFTYPE_AP || !mac->vif)
1441 spin_lock_irq(&mac->lock);
1442 interval = mac->beacon.interval;
1443 period = mac->beacon.period;
1444 timeout = mac->beacon.last_update +
1446 spin_unlock_irq(&mac->lock);
1449 dev_dbg_f(zd_mac_dev(mac), "beacon interrupt stalled, "
1454 zd_chip_disable_hwint(&mac->chip);
1456 beacon = ieee80211_beacon_get(mac->hw, mac->vif, 0);
1458 zd_mac_free_cur_beacon(mac);
1460 zd_mac_config_beacon(mac->hw, beacon, false);
1463 zd_set_beacon_interval(&mac->chip, interval, period, mac->type);
1465 zd_chip_enable_hwint(&mac->chip);
1467 spin_lock_irq(&mac->lock);
1468 mac->beacon.last_update = jiffies;
1469 spin_unlock_irq(&mac->lock);
1473 queue_delayed_work(zd_workqueue, &mac->beacon.watchdog_work,
1477 static void beacon_init(struct zd_mac *mac)
1479 INIT_DELAYED_WORK(&mac->beacon.watchdog_work, beacon_watchdog_handler);
1482 static void beacon_enable(struct zd_mac *mac)
1484 dev_dbg_f(zd_mac_dev(mac), "\n");
1486 mac->beacon.last_update = jiffies;
1487 queue_delayed_work(zd_workqueue, &mac->beacon.watchdog_work,
1491 static void beacon_disable(struct zd_mac *mac)
1493 dev_dbg_f(zd_mac_dev(mac), "\n");
1494 cancel_delayed_work_sync(&mac->beacon.watchdog_work);
1496 zd_mac_free_cur_beacon(mac);
1503 struct zd_mac *mac =
1505 struct zd_chip *chip = &mac->chip;
1509 if (!test_bit(ZD_DEVICE_RUNNING, &mac->flags))
1512 spin_lock_irq(&mac->lock);
1513 is_associated = mac->associated;
1514 spin_unlock_irq(&mac->lock);
1519 dev_dbg_f(zd_mac_dev(mac), "zd_chip_control_leds error %d\n", r);
1522 queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work,
1526 static void housekeeping_init(struct zd_mac *mac)
1528 INIT_DELAYED_WORK(&mac->housekeeping.link_led_work, link_led_handler);
1531 static void housekeeping_enable(struct zd_mac *mac)
1533 dev_dbg_f(zd_mac_dev(mac), "\n");
1534 queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work,
1538 static void housekeeping_disable(struct zd_mac *mac)
1540 dev_dbg_f(zd_mac_dev(mac), "\n");
1541 cancel_delayed_work_sync(&mac->housekeeping.link_led_work);
1542 zd_chip_control_leds(&mac->chip, ZD_LED_OFF);