Lines Matching +full:mac +full:- +full:only
1 // SPDX-License-Identifier: GPL-2.0-only
14 #include "mac.h"
87 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_mac_init_hw() local
88 struct plfxlc_chip *chip = &mac->chip; in plfxlc_mac_init_hw()
93 dev_warn(plfxlc_mac_dev(mac), "init hw failed (%d)\n", r); in plfxlc_mac_init_hw()
97 dev_dbg(plfxlc_mac_dev(mac), "irq_disabled (%d)\n", irqs_disabled()); in plfxlc_mac_init_hw()
98 regulatory_hint(hw->wiphy, "00"); in plfxlc_mac_init_hw()
102 void plfxlc_mac_release(struct plfxlc_mac *mac) in plfxlc_mac_release() argument
104 plfxlc_chip_release(&mac->chip); in plfxlc_mac_release()
105 lockdep_assert_held(&mac->lock); in plfxlc_mac_release()
110 plfxlc_hw_mac(hw)->chip.usb.initialized = 1; in plfxlc_op_start()
116 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_op_stop() local
118 clear_bit(PURELIFI_DEVICE_RUNNING, &mac->flags); in plfxlc_op_stop()
121 int plfxlc_restore_settings(struct plfxlc_mac *mac) in plfxlc_restore_settings() argument
126 spin_lock_irq(&mac->lock); in plfxlc_restore_settings()
127 beacon_interval = mac->beacon.interval; in plfxlc_restore_settings()
128 beacon_period = mac->beacon.period; in plfxlc_restore_settings()
129 spin_unlock_irq(&mac->lock); in plfxlc_restore_settings()
131 if (mac->type != NL80211_IFTYPE_ADHOC) in plfxlc_restore_settings()
134 if (mac->vif) { in plfxlc_restore_settings()
135 beacon = ieee80211_beacon_get(mac->hw, mac->vif, 0); in plfxlc_restore_settings()
139 /* Returned skb is used only once and lowlevel in plfxlc_restore_settings()
145 plfxlc_set_beacon_interval(&mac->chip, beacon_interval, in plfxlc_restore_settings()
146 beacon_period, mac->type); in plfxlc_restore_settings()
148 spin_lock_irq(&mac->lock); in plfxlc_restore_settings()
149 mac->beacon.last_update = jiffies; in plfxlc_restore_settings()
150 spin_unlock_irq(&mac->lock); in plfxlc_restore_settings()
165 success = !tx_status->failure; in plfxlc_mac_tx_status()
168 info->flags |= IEEE80211_TX_STAT_ACK; in plfxlc_mac_tx_status()
170 info->flags &= ~IEEE80211_TX_STAT_ACK; in plfxlc_mac_tx_status()
172 info->status.ack_signal = 50; in plfxlc_mac_tx_status()
179 struct ieee80211_hw *hw = info->rate_driver_data[0]; in plfxlc_mac_tx_to_dev()
180 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_mac_tx_to_dev() local
187 (info->flags & IEEE80211_TX_CTL_NO_ACK))) { in plfxlc_mac_tx_to_dev()
192 q = &mac->ack_wait_queue; in plfxlc_mac_tx_to_dev()
197 mac->ack_pending ? in plfxlc_mac_tx_to_dev()
198 mac->ack_signal : 0, in plfxlc_mac_tx_to_dev()
200 mac->ack_pending = 0; in plfxlc_mac_tx_to_dev()
204 static int plfxlc_fill_ctrlset(struct plfxlc_mac *mac, struct sk_buff *skb) in plfxlc_fill_ctrlset() argument
206 unsigned int frag_len = skb->len; in plfxlc_fill_ctrlset()
213 dev_dbg(plfxlc_mac_dev(mac), "Not enough hroom(1)\n"); in plfxlc_fill_ctrlset()
220 sizeof(struct plfxlc_ctrlset) - in plfxlc_fill_ctrlset()
221 sizeof(cs->id) - sizeof(cs->len); in plfxlc_fill_ctrlset()
234 tmp = skb->len & 3; in plfxlc_fill_ctrlset()
236 if (skb_tailroom(skb) < (3 - tmp)) { in plfxlc_fill_ctrlset()
237 if (skb_headroom(skb) >= 4 - tmp) { in plfxlc_fill_ctrlset()
242 len = skb->len; in plfxlc_fill_ctrlset()
243 src_pt = skb->data; in plfxlc_fill_ctrlset()
244 dest_pt = skb_push(skb, 4 - tmp); in plfxlc_fill_ctrlset()
247 return -ENOBUFS; in plfxlc_fill_ctrlset()
250 skb_put(skb, 4 - tmp); in plfxlc_fill_ctrlset()
252 temp_len += 4 - tmp; in plfxlc_fill_ctrlset()
256 tmp = skb->len & 0x1ff; in plfxlc_fill_ctrlset()
260 u8 len = skb->len; in plfxlc_fill_ctrlset()
261 u8 *src_pt = skb->data; in plfxlc_fill_ctrlset()
269 return -ENOBUFS; in plfxlc_fill_ctrlset()
277 cs->id = cpu_to_be32(USB_REQ_DATA_TX); in plfxlc_fill_ctrlset()
278 cs->len = cpu_to_be32(temp_len); in plfxlc_fill_ctrlset()
279 cs->payload_len_nw = cpu_to_be32(temp_payload_len); in plfxlc_fill_ctrlset()
289 struct plfxlc_header *plhdr = (void *)skb->data; in plfxlc_op_tx()
290 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_op_tx() local
291 struct plfxlc_usb *usb = &mac->chip.usb; in plfxlc_op_tx()
295 r = plfxlc_fill_ctrlset(mac, skb); in plfxlc_op_tx()
299 info->rate_driver_data[0] = hw; in plfxlc_op_tx()
301 if (plhdr->frametype == IEEE80211_FTYPE_DATA) { in plfxlc_op_tx()
302 u8 *dst_mac = plhdr->dmac; in plfxlc_op_tx()
305 struct plfxlc_usb_tx *tx = &usb->tx; in plfxlc_op_tx()
308 if (!(tx->station[sidx].flag & STATION_CONNECTED_FLAG)) in plfxlc_op_tx()
310 if (memcmp(tx->station[sidx].mac, dst_mac, ETH_ALEN)) in plfxlc_op_tx()
321 if (skb_queue_len(&tx->station[sidx].data_list) > 60) in plfxlc_op_tx()
325 if (skb_queue_len(&tx->station[sidx].data_list) > 256) in plfxlc_op_tx()
327 skb_queue_tail(&tx->station[sidx].data_list, skb); in plfxlc_op_tx()
331 spin_lock_irqsave(&usb->tx.lock, flags); in plfxlc_op_tx()
332 r = plfxlc_usb_wreq_async(&mac->chip.usb, skb->data, skb->len, in plfxlc_op_tx()
334 spin_unlock_irqrestore(&usb->tx.lock, flags); in plfxlc_op_tx()
347 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_filter_ack() local
354 if (!ieee80211_is_ack(rx_hdr->frame_control)) in plfxlc_filter_ack()
357 dev_dbg(plfxlc_mac_dev(mac), "ACK Received\n"); in plfxlc_filter_ack()
360 q = &mac->ack_wait_queue; in plfxlc_filter_ack()
361 spin_lock_irqsave(&q->lock, flags); in plfxlc_filter_ack()
368 if (mac->ack_pending && skb_queue_is_first(q, skb)) in plfxlc_filter_ack()
370 if (mac->ack_pending == 0) in plfxlc_filter_ack()
373 tx_hdr = (struct ieee80211_hdr *)skb->data; in plfxlc_filter_ack()
374 if (likely(ether_addr_equal(tx_hdr->addr2, rx_hdr->addr1))) { in plfxlc_filter_ack()
385 mac->ack_pending ? in plfxlc_filter_ack()
386 mac->ack_signal : 0, in plfxlc_filter_ack()
388 mac->ack_pending = 0; in plfxlc_filter_ack()
391 mac->ack_pending = skb_queue_len(q) ? 1 : 0; in plfxlc_filter_ack()
392 mac->ack_signal = stats->signal; in plfxlc_filter_ack()
395 spin_unlock_irqrestore(&q->lock, flags); in plfxlc_filter_ack()
402 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_mac_rx() local
413 if (!mac->vif) in plfxlc_mac_rx()
423 mac->rssi = -15 * be16_to_cpu(status->rssi) / 10; in plfxlc_mac_rx()
425 stats.signal = mac->rssi; in plfxlc_mac_rx()
427 if (status->rate_idx > 7) in plfxlc_mac_rx()
430 stats.rate_idx = status->rate_idx; in plfxlc_mac_rx()
432 mac->crc_errors = be64_to_cpu(status->crc_error_count); in plfxlc_mac_rx()
436 !mac->pass_ctrl) in plfxlc_mac_rx()
443 dev_err(plfxlc_mac_dev(mac), " > MTU %u\n", payload_length); in plfxlc_mac_rx()
451 tx = &mac->chip.usb.tx; in plfxlc_mac_rx()
453 for (sidx = 0; sidx < MAX_STA_NUM - 1; sidx++) { in plfxlc_mac_rx()
454 if (memcmp(&buffer[10], tx->station[sidx].mac, ETH_ALEN)) in plfxlc_mac_rx()
456 if (tx->station[sidx].flag & STATION_CONNECTED_FLAG) { in plfxlc_mac_rx()
457 tx->station[sidx].flag |= STATION_HEARTBEAT_FLAG; in plfxlc_mac_rx()
462 if (sidx == MAX_STA_NUM - 1) { in plfxlc_mac_rx()
463 for (sidx = 0; sidx < MAX_STA_NUM - 1; sidx++) { in plfxlc_mac_rx()
464 if (tx->station[sidx].flag & STATION_CONNECTED_FLAG) in plfxlc_mac_rx()
466 memcpy(tx->station[sidx].mac, &buffer[10], ETH_ALEN); in plfxlc_mac_rx()
467 tx->station[sidx].flag |= STATION_CONNECTED_FLAG; in plfxlc_mac_rx()
468 tx->station[sidx].flag |= STATION_HEARTBEAT_FLAG; in plfxlc_mac_rx()
475 dev_dbg(plfxlc_mac_dev(mac), "Probe request\n"); in plfxlc_mac_rx()
478 dev_dbg(plfxlc_mac_dev(mac), "Association request\n"); in plfxlc_mac_rx()
481 dev_dbg(plfxlc_mac_dev(mac), "Authentication req\n"); in plfxlc_mac_rx()
484 dev_dbg(plfxlc_mac_dev(mac), "802.11 data frame\n"); in plfxlc_mac_rx()
490 return -ENOMEM; in plfxlc_mac_rx()
505 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_op_add_interface() local
511 if (mac->type != NL80211_IFTYPE_UNSPECIFIED) in plfxlc_op_add_interface()
512 return -EOPNOTSUPP; in plfxlc_op_add_interface()
514 if (vif->type == NL80211_IFTYPE_ADHOC || in plfxlc_op_add_interface()
515 vif->type == NL80211_IFTYPE_STATION) { in plfxlc_op_add_interface()
516 dev_dbg(plfxlc_mac_dev(mac), "%s %s\n", __func__, in plfxlc_op_add_interface()
517 iftype80211[vif->type]); in plfxlc_op_add_interface()
518 mac->type = vif->type; in plfxlc_op_add_interface()
519 mac->vif = vif; in plfxlc_op_add_interface()
522 dev_dbg(plfxlc_mac_dev(mac), "unsupported iftype\n"); in plfxlc_op_add_interface()
523 return -EOPNOTSUPP; in plfxlc_op_add_interface()
529 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_op_remove_interface() local
531 mac->type = NL80211_IFTYPE_UNSPECIFIED; in plfxlc_op_remove_interface()
532 mac->vif = NULL; in plfxlc_op_remove_interface()
552 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_op_configure_filter() local
555 /* Only deal with supported flags */ in plfxlc_op_configure_filter()
568 spin_lock_irqsave(&mac->lock, flags); in plfxlc_op_configure_filter()
569 mac->pass_failed_fcs = !!(*new_flags & FIF_FCSFAIL); in plfxlc_op_configure_filter()
570 mac->pass_ctrl = !!(*new_flags & FIF_CONTROL); in plfxlc_op_configure_filter()
571 mac->multicast_hash = hash; in plfxlc_op_configure_filter()
572 spin_unlock_irqrestore(&mac->lock, flags); in plfxlc_op_configure_filter()
591 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_op_bss_info_changed() local
594 dev_dbg(plfxlc_mac_dev(mac), "changes: %llx\n", changes); in plfxlc_op_bss_info_changed()
596 if (mac->type != NL80211_IFTYPE_ADHOC) { /* for STATION */ in plfxlc_op_bss_info_changed()
597 associated = is_valid_ether_addr(bss_conf->bssid); in plfxlc_op_bss_info_changed()
608 /*Returned skb is used only once and in plfxlc_op_bss_info_changed()
609 * low-level driver is in plfxlc_op_bss_info_changed()
619 if (bss_conf->enable_beacon) { in plfxlc_op_bss_info_changed()
620 period = bss_conf->dtim_period; in plfxlc_op_bss_info_changed()
621 interval = bss_conf->beacon_int; in plfxlc_op_bss_info_changed()
624 spin_lock_irq(&mac->lock); in plfxlc_op_bss_info_changed()
625 mac->beacon.period = period; in plfxlc_op_bss_info_changed()
626 mac->beacon.interval = interval; in plfxlc_op_bss_info_changed()
627 mac->beacon.last_update = jiffies; in plfxlc_op_bss_info_changed()
628 spin_unlock_irq(&mac->lock); in plfxlc_op_bss_info_changed()
630 plfxlc_set_beacon_interval(&mac->chip, interval, in plfxlc_op_bss_info_changed()
631 period, mac->type); in plfxlc_op_bss_info_changed()
634 spin_lock_irq(&mac->lock); in plfxlc_op_bss_info_changed()
635 mac->associated = associated; in plfxlc_op_bss_info_changed()
636 spin_unlock_irq(&mac->lock); in plfxlc_op_bss_info_changed()
642 stats->dot11ACKFailureCount = 0; in plfxlc_get_stats()
643 stats->dot11RTSFailureCount = 0; in plfxlc_get_stats()
644 stats->dot11FCSErrorCount = 0; in plfxlc_get_stats()
645 stats->dot11RTSSuccessCount = 0; in plfxlc_get_stats()
675 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); in plfxlc_get_et_stats() local
677 data[0] = mac->rssi; in plfxlc_get_et_stats()
678 data[1] = mac->crc_errors; in plfxlc_get_et_stats()
710 struct plfxlc_mac *mac; in plfxlc_mac_alloc_hw() local
714 dev_dbg(&intf->dev, "out of memory\n"); in plfxlc_mac_alloc_hw()
717 set_wiphy_dev(hw->wiphy, &intf->dev); in plfxlc_mac_alloc_hw()
719 mac = plfxlc_hw_mac(hw); in plfxlc_mac_alloc_hw()
720 memset(mac, 0, sizeof(*mac)); in plfxlc_mac_alloc_hw()
721 spin_lock_init(&mac->lock); in plfxlc_mac_alloc_hw()
722 mac->hw = hw; in plfxlc_mac_alloc_hw()
724 mac->type = NL80211_IFTYPE_UNSPECIFIED; in plfxlc_mac_alloc_hw()
726 memcpy(mac->channels, plfxlc_channels, sizeof(plfxlc_channels)); in plfxlc_mac_alloc_hw()
727 memcpy(mac->rates, plfxlc_rates, sizeof(plfxlc_rates)); in plfxlc_mac_alloc_hw()
728 mac->band.n_bitrates = ARRAY_SIZE(plfxlc_rates); in plfxlc_mac_alloc_hw()
729 mac->band.bitrates = mac->rates; in plfxlc_mac_alloc_hw()
730 mac->band.n_channels = ARRAY_SIZE(plfxlc_channels); in plfxlc_mac_alloc_hw()
731 mac->band.channels = mac->channels; in plfxlc_mac_alloc_hw()
732 hw->wiphy->bands[NL80211_BAND_LC] = &mac->band; in plfxlc_mac_alloc_hw()
733 hw->conf.chandef.width = NL80211_CHAN_WIDTH_20; in plfxlc_mac_alloc_hw()
740 hw->wiphy->interface_modes = in plfxlc_mac_alloc_hw()
743 hw->max_signal = 100; in plfxlc_mac_alloc_hw()
744 hw->queues = 1; in plfxlc_mac_alloc_hw()
746 hw->extra_tx_headroom = sizeof(struct plfxlc_ctrlset) + 4; in plfxlc_mac_alloc_hw()
748 hw->max_rates = IEEE80211_TX_MAX_RATES; in plfxlc_mac_alloc_hw()
749 hw->max_rate_tries = 18; /* 9 rates * 2 retries/rate */ in plfxlc_mac_alloc_hw()
751 skb_queue_head_init(&mac->ack_wait_queue); in plfxlc_mac_alloc_hw()
752 mac->ack_pending = 0; in plfxlc_mac_alloc_hw()
754 plfxlc_chip_init(&mac->chip, hw, intf); in plfxlc_mac_alloc_hw()
756 SET_IEEE80211_DEV(hw, &intf->dev); in plfxlc_mac_alloc_hw()