mac.c (61fe43e7216df6e9a912d831aafc7142fa20f280) mac.c (f552d6fd2f27ce9430c74482c46272838e2de688)
1// SPDX-License-Identifier: BSD-3-Clause-Clear
2/*
3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4 */
5
6#include <net/mac80211.h>
7#include <linux/etherdevice.h>
8#include "mac.h"

--- 1567 unchanged lines hidden (view full) ---

1576
1577 tx_mcs_set &= ~(0x3 << (nss * 2));
1578 tx_mcs_set |= mcs << (nss * 2);
1579 }
1580
1581 return tx_mcs_set;
1582}
1583
1// SPDX-License-Identifier: BSD-3-Clause-Clear
2/*
3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4 */
5
6#include <net/mac80211.h>
7#include <linux/etherdevice.h>
8#include "mac.h"

--- 1567 unchanged lines hidden (view full) ---

1576
1577 tx_mcs_set &= ~(0x3 << (nss * 2));
1578 tx_mcs_set |= mcs << (nss * 2);
1579 }
1580
1581 return tx_mcs_set;
1582}
1583
1584static u8 ath11k_get_nss_160mhz(struct ath11k *ar,
1585 u8 max_nss)
1586{
1587 u8 nss_ratio_info = ar->pdev->cap.nss_ratio_info;
1588 u8 max_sup_nss = 0;
1589
1590 switch (nss_ratio_info) {
1591 case WMI_NSS_RATIO_1BY2_NSS:
1592 max_sup_nss = max_nss >> 1;
1593 break;
1594 case WMI_NSS_RATIO_3BY4_NSS:
1595 ath11k_warn(ar->ab, "WMI_NSS_RATIO_3BY4_NSS not supported\n");
1596 break;
1597 case WMI_NSS_RATIO_1_NSS:
1598 max_sup_nss = max_nss;
1599 break;
1600 case WMI_NSS_RATIO_2_NSS:
1601 ath11k_warn(ar->ab, "WMI_NSS_RATIO_2_NSS not supported\n");
1602 break;
1603 default:
1604 ath11k_warn(ar->ab, "invalid nss ratio received from firmware: %d\n",
1605 nss_ratio_info);
1606 break;
1607 }
1608
1609 return max_sup_nss;
1610}
1611
1584static void ath11k_peer_assoc_h_vht(struct ath11k *ar,
1585 struct ieee80211_vif *vif,
1586 struct ieee80211_sta *sta,
1587 struct peer_assoc_params *arg)
1588{
1589 const struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
1590 struct ath11k_vif *arvif = (void *)vif->drv_priv;
1591 struct cfg80211_chan_def def;
1592 enum nl80211_band band;
1593 u16 *vht_mcs_mask;
1594 u8 ampdu_factor;
1595 u8 max_nss, vht_mcs;
1596 int i, vht_nss, nss_idx;
1597 bool user_rate_valid = true;
1612static void ath11k_peer_assoc_h_vht(struct ath11k *ar,
1613 struct ieee80211_vif *vif,
1614 struct ieee80211_sta *sta,
1615 struct peer_assoc_params *arg)
1616{
1617 const struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
1618 struct ath11k_vif *arvif = (void *)vif->drv_priv;
1619 struct cfg80211_chan_def def;
1620 enum nl80211_band band;
1621 u16 *vht_mcs_mask;
1622 u8 ampdu_factor;
1623 u8 max_nss, vht_mcs;
1624 int i, vht_nss, nss_idx;
1625 bool user_rate_valid = true;
1626 u32 rx_nss, tx_nss, nss_160;
1598
1599 if (WARN_ON(ath11k_mac_vif_chan(vif, &def)))
1600 return;
1601
1602 if (!vht_cap->vht_supported)
1603 return;
1604
1605 band = def.chan->band;

--- 76 unchanged lines hidden (view full) ---

1682
1683 if ((arg->tx_mcs_set & IEEE80211_VHT_MCS_NOT_SUPPORTED) ==
1684 IEEE80211_VHT_MCS_NOT_SUPPORTED)
1685 arg->peer_vht_caps &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
1686
1687 /* TODO: Check */
1688 arg->tx_max_mcs_nss = 0xFF;
1689
1627
1628 if (WARN_ON(ath11k_mac_vif_chan(vif, &def)))
1629 return;
1630
1631 if (!vht_cap->vht_supported)
1632 return;
1633
1634 band = def.chan->band;

--- 76 unchanged lines hidden (view full) ---

1711
1712 if ((arg->tx_mcs_set & IEEE80211_VHT_MCS_NOT_SUPPORTED) ==
1713 IEEE80211_VHT_MCS_NOT_SUPPORTED)
1714 arg->peer_vht_caps &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
1715
1716 /* TODO: Check */
1717 arg->tx_max_mcs_nss = 0xFF;
1718
1690 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x\n",
1691 sta->addr, arg->peer_max_mpdu, arg->peer_flags);
1719 if (arg->peer_phymode == MODE_11AC_VHT160 ||
1720 arg->peer_phymode == MODE_11AC_VHT80_80) {
1721 tx_nss = ath11k_get_nss_160mhz(ar, max_nss);
1722 rx_nss = min(arg->peer_nss, tx_nss);
1723 arg->peer_bw_rxnss_override = ATH11K_BW_NSS_MAP_ENABLE;
1692
1724
1693 /* TODO: rxnss_override */
1725 if (!rx_nss) {
1726 ath11k_warn(ar->ab, "invalid max_nss\n");
1727 return;
1728 }
1729
1730 if (arg->peer_phymode == MODE_11AC_VHT160)
1731 nss_160 = FIELD_PREP(ATH11K_PEER_RX_NSS_160MHZ, rx_nss - 1);
1732 else
1733 nss_160 = FIELD_PREP(ATH11K_PEER_RX_NSS_80_80MHZ, rx_nss - 1);
1734
1735 arg->peer_bw_rxnss_override |= nss_160;
1736 }
1737
1738 ath11k_dbg(ar->ab, ATH11K_DBG_MAC,
1739 "mac vht peer %pM max_mpdu %d flags 0x%x nss_override 0x%x\n",
1740 sta->addr, arg->peer_max_mpdu, arg->peer_flags,
1741 arg->peer_bw_rxnss_override);
1694}
1695
1696static int ath11k_mac_get_max_he_mcs_map(u16 mcs_map, int nss)
1697{
1698 switch ((mcs_map >> (2 * nss)) & 0x3) {
1699 case IEEE80211_HE_MCS_SUPPORT_0_7: return BIT(8) - 1;
1700 case IEEE80211_HE_MCS_SUPPORT_0_9: return BIT(10) - 1;
1701 case IEEE80211_HE_MCS_SUPPORT_0_11: return BIT(12) - 1;

--- 67 unchanged lines hidden (view full) ---

1769 const struct ieee80211_sta_he_cap *he_cap = &sta->he_cap;
1770 u8 ampdu_factor;
1771 enum nl80211_band band;
1772 u16 *he_mcs_mask;
1773 u8 max_nss, he_mcs;
1774 u16 he_tx_mcs = 0, v = 0;
1775 int i, he_nss, nss_idx;
1776 bool user_rate_valid = true;
1742}
1743
1744static int ath11k_mac_get_max_he_mcs_map(u16 mcs_map, int nss)
1745{
1746 switch ((mcs_map >> (2 * nss)) & 0x3) {
1747 case IEEE80211_HE_MCS_SUPPORT_0_7: return BIT(8) - 1;
1748 case IEEE80211_HE_MCS_SUPPORT_0_9: return BIT(10) - 1;
1749 case IEEE80211_HE_MCS_SUPPORT_0_11: return BIT(12) - 1;

--- 67 unchanged lines hidden (view full) ---

1817 const struct ieee80211_sta_he_cap *he_cap = &sta->he_cap;
1818 u8 ampdu_factor;
1819 enum nl80211_band band;
1820 u16 *he_mcs_mask;
1821 u8 max_nss, he_mcs;
1822 u16 he_tx_mcs = 0, v = 0;
1823 int i, he_nss, nss_idx;
1824 bool user_rate_valid = true;
1825 u32 rx_nss, tx_nss, nss_160;
1777
1778 if (WARN_ON(ath11k_mac_vif_chan(vif, &def)))
1779 return;
1780
1781 if (!he_cap->has_he)
1782 return;
1783
1784 band = def.chan->band;

--- 147 unchanged lines hidden (view full) ---

1932 * to find nss.
1933 */
1934 if (he_mcs != IEEE80211_HE_MCS_NOT_SUPPORTED ||
1935 he_mcs_mask[i])
1936 max_nss = i + 1;
1937 }
1938 arg->peer_nss = min(sta->rx_nss, max_nss);
1939
1826
1827 if (WARN_ON(ath11k_mac_vif_chan(vif, &def)))
1828 return;
1829
1830 if (!he_cap->has_he)
1831 return;
1832
1833 band = def.chan->band;

--- 147 unchanged lines hidden (view full) ---

1981 * to find nss.
1982 */
1983 if (he_mcs != IEEE80211_HE_MCS_NOT_SUPPORTED ||
1984 he_mcs_mask[i])
1985 max_nss = i + 1;
1986 }
1987 arg->peer_nss = min(sta->rx_nss, max_nss);
1988
1989 if (arg->peer_phymode == MODE_11AX_HE160 ||
1990 arg->peer_phymode == MODE_11AX_HE80_80) {
1991 tx_nss = ath11k_get_nss_160mhz(ar, max_nss);
1992 rx_nss = min(arg->peer_nss, tx_nss);
1993 arg->peer_bw_rxnss_override = ATH11K_BW_NSS_MAP_ENABLE;
1994
1995 if (!rx_nss) {
1996 ath11k_warn(ar->ab, "invalid max_nss\n");
1997 return;
1998 }
1999
2000 if (arg->peer_phymode == MODE_11AX_HE160)
2001 nss_160 = FIELD_PREP(ATH11K_PEER_RX_NSS_160MHZ, rx_nss - 1);
2002 else
2003 nss_160 = FIELD_PREP(ATH11K_PEER_RX_NSS_80_80MHZ, rx_nss - 1);
2004
2005 arg->peer_bw_rxnss_override |= nss_160;
2006 }
2007
1940 ath11k_dbg(ar->ab, ATH11K_DBG_MAC,
2008 ath11k_dbg(ar->ab, ATH11K_DBG_MAC,
1941 "mac he peer %pM nss %d mcs cnt %d\n",
1942 sta->addr, arg->peer_nss, arg->peer_he_mcs_count);
2009 "mac he peer %pM nss %d mcs cnt %d nss_override 0x%x\n",
2010 sta->addr, arg->peer_nss,
2011 arg->peer_he_mcs_count,
2012 arg->peer_bw_rxnss_override);
1943}
1944
1945static void ath11k_peer_assoc_h_smps(struct ieee80211_sta *sta,
1946 struct peer_assoc_params *arg)
1947{
1948 const struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
1949 int smps;
1950

--- 271 unchanged lines hidden (view full) ---

2222 memset(arg, 0, sizeof(*arg));
2223
2224 reinit_completion(&ar->peer_assoc_done);
2225
2226 arg->peer_new_assoc = !reassoc;
2227 ath11k_peer_assoc_h_basic(ar, vif, sta, arg);
2228 ath11k_peer_assoc_h_crypto(ar, vif, sta, arg);
2229 ath11k_peer_assoc_h_rates(ar, vif, sta, arg);
2013}
2014
2015static void ath11k_peer_assoc_h_smps(struct ieee80211_sta *sta,
2016 struct peer_assoc_params *arg)
2017{
2018 const struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
2019 int smps;
2020

--- 271 unchanged lines hidden (view full) ---

2292 memset(arg, 0, sizeof(*arg));
2293
2294 reinit_completion(&ar->peer_assoc_done);
2295
2296 arg->peer_new_assoc = !reassoc;
2297 ath11k_peer_assoc_h_basic(ar, vif, sta, arg);
2298 ath11k_peer_assoc_h_crypto(ar, vif, sta, arg);
2299 ath11k_peer_assoc_h_rates(ar, vif, sta, arg);
2300 ath11k_peer_assoc_h_phymode(ar, vif, sta, arg);
2230 ath11k_peer_assoc_h_ht(ar, vif, sta, arg);
2231 ath11k_peer_assoc_h_vht(ar, vif, sta, arg);
2232 ath11k_peer_assoc_h_he(ar, vif, sta, arg);
2233 ath11k_peer_assoc_h_qos(ar, vif, sta, arg);
2301 ath11k_peer_assoc_h_ht(ar, vif, sta, arg);
2302 ath11k_peer_assoc_h_vht(ar, vif, sta, arg);
2303 ath11k_peer_assoc_h_he(ar, vif, sta, arg);
2304 ath11k_peer_assoc_h_qos(ar, vif, sta, arg);
2234 ath11k_peer_assoc_h_phymode(ar, vif, sta, arg);
2235 ath11k_peer_assoc_h_smps(sta, arg);
2236
2237 /* TODO: amsdu_disable req? */
2238}
2239
2240static int ath11k_setup_peer_smps(struct ath11k *ar, struct ath11k_vif *arvif,
2241 const u8 *addr,
2242 const struct ieee80211_sta_ht_cap *ht_cap)

--- 2179 unchanged lines hidden (view full) ---

4422 u16 txmcs_map, rxmcs_map;
4423 int i;
4424
4425 vht_cap.vht_supported = 1;
4426 vht_cap.cap = ar->pdev->cap.vht_cap;
4427
4428 ath11k_set_vht_txbf_cap(ar, &vht_cap.cap);
4429
2305 ath11k_peer_assoc_h_smps(sta, arg);
2306
2307 /* TODO: amsdu_disable req? */
2308}
2309
2310static int ath11k_setup_peer_smps(struct ath11k *ar, struct ath11k_vif *arvif,
2311 const u8 *addr,
2312 const struct ieee80211_sta_ht_cap *ht_cap)

--- 2179 unchanged lines hidden (view full) ---

4492 u16 txmcs_map, rxmcs_map;
4493 int i;
4494
4495 vht_cap.vht_supported = 1;
4496 vht_cap.cap = ar->pdev->cap.vht_cap;
4497
4498 ath11k_set_vht_txbf_cap(ar, &vht_cap.cap);
4499
4430 /* TODO: Enable back VHT160 mode once association issues are fixed */
4431 /* Disabling VHT160 and VHT80+80 modes */
4432 vht_cap.cap &= ~IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
4433 vht_cap.cap &= ~IEEE80211_VHT_CAP_SHORT_GI_160;
4434
4435 rxmcs_map = 0;
4436 txmcs_map = 0;
4437 for (i = 0; i < 8; i++) {
4438 if (i < ar->num_tx_chains && rate_cap_tx_chainmask & BIT(i))
4439 txmcs_map |= IEEE80211_VHT_MCS_SUPPORT_0_9 << (i * 2);
4440 else
4441 txmcs_map |= IEEE80211_VHT_MCS_NOT_SUPPORTED << (i * 2);
4442

--- 2897 unchanged lines hidden (view full) ---

7340 combinations[0].n_limits = n_limits;
7341 combinations[0].max_interfaces = 16;
7342 combinations[0].num_different_channels = 1;
7343 combinations[0].beacon_int_infra_match = true;
7344 combinations[0].beacon_int_min_gcd = 100;
7345 combinations[0].radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
7346 BIT(NL80211_CHAN_WIDTH_20) |
7347 BIT(NL80211_CHAN_WIDTH_40) |
4500 rxmcs_map = 0;
4501 txmcs_map = 0;
4502 for (i = 0; i < 8; i++) {
4503 if (i < ar->num_tx_chains && rate_cap_tx_chainmask & BIT(i))
4504 txmcs_map |= IEEE80211_VHT_MCS_SUPPORT_0_9 << (i * 2);
4505 else
4506 txmcs_map |= IEEE80211_VHT_MCS_NOT_SUPPORTED << (i * 2);
4507

--- 2897 unchanged lines hidden (view full) ---

7405 combinations[0].n_limits = n_limits;
7406 combinations[0].max_interfaces = 16;
7407 combinations[0].num_different_channels = 1;
7408 combinations[0].beacon_int_infra_match = true;
7409 combinations[0].beacon_int_min_gcd = 100;
7410 combinations[0].radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
7411 BIT(NL80211_CHAN_WIDTH_20) |
7412 BIT(NL80211_CHAN_WIDTH_40) |
7348 BIT(NL80211_CHAN_WIDTH_80);
7413 BIT(NL80211_CHAN_WIDTH_80) |
7414 BIT(NL80211_CHAN_WIDTH_80P80) |
7415 BIT(NL80211_CHAN_WIDTH_160);
7349
7350 ar->hw->wiphy->iface_combinations = combinations;
7351 ar->hw->wiphy->n_iface_combinations = 1;
7352
7353 return 0;
7354}
7355
7356static const u8 ath11k_if_types_ext_capa[] = {

--- 122 unchanged lines hidden (view full) ---

7479 ieee80211_hw_set(ar->hw, CONNECTION_MONITOR);
7480 ieee80211_hw_set(ar->hw, SUPPORTS_PER_STA_GTK);
7481 ieee80211_hw_set(ar->hw, WANT_MONITOR_VIF);
7482 ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA);
7483 ieee80211_hw_set(ar->hw, QUEUE_CONTROL);
7484 ieee80211_hw_set(ar->hw, SUPPORTS_TX_FRAG);
7485 ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK);
7486 ieee80211_hw_set(ar->hw, SUPPORTS_TX_ENCAP_OFFLOAD);
7416
7417 ar->hw->wiphy->iface_combinations = combinations;
7418 ar->hw->wiphy->n_iface_combinations = 1;
7419
7420 return 0;
7421}
7422
7423static const u8 ath11k_if_types_ext_capa[] = {

--- 122 unchanged lines hidden (view full) ---

7546 ieee80211_hw_set(ar->hw, CONNECTION_MONITOR);
7547 ieee80211_hw_set(ar->hw, SUPPORTS_PER_STA_GTK);
7548 ieee80211_hw_set(ar->hw, WANT_MONITOR_VIF);
7549 ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA);
7550 ieee80211_hw_set(ar->hw, QUEUE_CONTROL);
7551 ieee80211_hw_set(ar->hw, SUPPORTS_TX_FRAG);
7552 ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK);
7553 ieee80211_hw_set(ar->hw, SUPPORTS_TX_ENCAP_OFFLOAD);
7554
7555 if (cap->nss_ratio_enabled)
7556 ieee80211_hw_set(ar->hw, SUPPORTS_VHT_EXT_NSS_BW);
7557
7487 if (ht_cap & WMI_HT_CAP_ENABLED) {
7488 ieee80211_hw_set(ar->hw, AMPDU_AGGREGATION);
7489 ieee80211_hw_set(ar->hw, TX_AMPDU_SETUP_IN_HW);
7490 ieee80211_hw_set(ar->hw, SUPPORTS_REORDERING_BUFFER);
7491 ieee80211_hw_set(ar->hw, SUPPORTS_AMSDU_IN_AMPDU);
7492 ieee80211_hw_set(ar->hw, USES_RSS);
7493 }
7494

--- 240 unchanged lines hidden ---
7558 if (ht_cap & WMI_HT_CAP_ENABLED) {
7559 ieee80211_hw_set(ar->hw, AMPDU_AGGREGATION);
7560 ieee80211_hw_set(ar->hw, TX_AMPDU_SETUP_IN_HW);
7561 ieee80211_hw_set(ar->hw, SUPPORTS_REORDERING_BUFFER);
7562 ieee80211_hw_set(ar->hw, SUPPORTS_AMSDU_IN_AMPDU);
7563 ieee80211_hw_set(ar->hw, USES_RSS);
7564 }
7565

--- 240 unchanged lines hidden ---