Commit b865273b authored by Kalle Valo's avatar Kalle Valo
Browse files

Merge tag 'mt76-for-kvalo-2022-02-24' of https://github.com/nbd168/wireless

mt76 patches for 5.18

- bugfixes
- mt7915 thermal management improvements
- SAR support for more mt76 drivers
- mt7986 wmac support on mt7915
parents a0061be4 00a883e6
Loading
Loading
Loading
Loading
+30 −3
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ description: |
  wireless device. The node is expected to be specified as a child
  node of the PCI controller to which the wireless chip is connected.
  Alternatively, it can specify the wireless part of the MT7628/MT7688
  or MT7622 SoC.
  or MT7622/MT7986 SoC.

allOf:
  - $ref: ieee80211.yaml#
@@ -29,9 +29,13 @@ properties:
      - mediatek,mt76
      - mediatek,mt7628-wmac
      - mediatek,mt7622-wmac
      - mediatek,mt7986-wmac

  reg:
    maxItems: 1
    minItems: 1
    maxItems: 3
    description:
      MT7986 should contain 3 regions consys, dcm, and sku, in this order.

  interrupts:
    maxItems: 1
@@ -39,6 +43,17 @@ properties:
  power-domains:
    maxItems: 1

  memory-region:
    maxItems: 1

  resets:
    maxItems: 1
    description:
      Specify the consys reset for mt7986.

  reset-name:
    const: consys

  mediatek,infracfg:
    $ref: /schemas/types.yaml#/definitions/phandle
    description:
@@ -174,7 +189,7 @@ required:
  - compatible
  - reg

additionalProperties: false
unevaluatedProperties: false

examples:
  - |
@@ -240,3 +255,15 @@ examples:

      power-domains = <&scpsys 3>;
    };

  - |
    wifi@18000000 {
        compatible = "mediatek,mt7986-wmac";
        resets = <&watchdog 23>;
        reset-names = "consys";
        reg = <0x18000000 0x1000000>,
              <0x10003000 0x1000>,
              <0x11d10000 0x1000>;
        interrupts = <GIC_SPI 213 IRQ_TYPE_LEVEL_HIGH>;
        memory-region = <&wmcpu_emi>;
    };
+33 −1
Original line number Diff line number Diff line
@@ -932,6 +932,35 @@ void mt76_wcid_key_setup(struct mt76_dev *dev, struct mt76_wcid *wcid,
}
EXPORT_SYMBOL(mt76_wcid_key_setup);

static int
mt76_rx_signal(struct mt76_rx_status *status)
{
	s8 *chain_signal = status->chain_signal;
	int signal = -128;
	u8 chains;

	for (chains = status->chains; chains; chains >>= 1, chain_signal++) {
		int cur, diff;

		if (!(chains & BIT(0)))
			continue;

		cur = *chain_signal;
		if (cur > signal)
			swap(cur, signal);

		diff = signal - cur;
		if (diff == 0)
			signal += 3;
		else if (diff <= 2)
			signal += 2;
		else if (diff <= 6)
			signal += 1;
	}

	return signal;
}

static void
mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb,
		struct ieee80211_hw **hw,
@@ -960,6 +989,9 @@ mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb,
	status->ampdu_reference = mstat.ampdu_ref;
	status->device_timestamp = mstat.timestamp;
	status->mactime = mstat.timestamp;
	status->signal = mt76_rx_signal(&mstat);
	if (status->signal <= -128)
		status->flag |= RX_FLAG_NO_SIGNAL_VAL;

	if (ieee80211_is_beacon(hdr->frame_control) ||
	    ieee80211_is_probe_resp(hdr->frame_control))
@@ -1626,7 +1658,7 @@ enum mt76_dfs_state mt76_phy_dfs_state(struct mt76_phy *phy)
		return MT_DFS_STATE_DISABLED;
	}

	if (phy->chandef.chan->dfs_state != NL80211_DFS_AVAILABLE)
	if (!cfg80211_reg_can_beacon(hw->wiphy, &phy->chandef, NL80211_IFTYPE_AP))
		return MT_DFS_STATE_CAC;

	return MT_DFS_STATE_ACTIVE;
+0 −5
Original line number Diff line number Diff line
@@ -643,11 +643,6 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb)
		status->chain_signal[1] = FIELD_GET(MT_RXV4_IB_RSSI1, rxdg3) +
					  dev->rssi_offset[1];

		status->signal = status->chain_signal[0];
		if (status->chains & BIT(1))
			status->signal = max(status->signal,
					     status->chain_signal[1]);

		if (FIELD_GET(MT_RXV1_FRAME_MODE, rxdg0) == 1)
			status->bw = RATE_INFO_BW_40;

+11 −3
Original line number Diff line number Diff line
@@ -443,11 +443,16 @@ mt7615_ext_mac_addr_read(struct file *file, char __user *userbuf,
			 size_t count, loff_t *ppos)
{
	struct mt7615_dev *dev = file->private_data;
	char buf[32 * ((ETH_ALEN * 3) + 4) + 1];
	u32 len = 32 * ((ETH_ALEN * 3) + 4) + 1;
	u8 addr[ETH_ALEN];
	char *buf;
	int ofs = 0;
	int i;

	buf = kzalloc(len, GFP_KERNEL);
	if (!buf)
		return -ENOMEM;

	for (i = 0; i < 32; i++) {
		if (!(dev->muar_mask & BIT(i)))
			continue;
@@ -458,10 +463,13 @@ mt7615_ext_mac_addr_read(struct file *file, char __user *userbuf,
		put_unaligned_le32(mt76_rr(dev, MT_WF_RMAC_MAR0), addr);
		put_unaligned_le16((mt76_rr(dev, MT_WF_RMAC_MAR1) &
				    MT_WF_RMAC_MAR1_ADDR), addr + 4);
		ofs += snprintf(buf + ofs, sizeof(buf) - ofs, "%d=%pM\n", i, addr);
		ofs += snprintf(buf + ofs, len - ofs, "%d=%pM\n", i, addr);
	}

	return simple_read_from_buffer(userbuf, count, ppos, buf, ofs);
	ofs = simple_read_from_buffer(userbuf, count, ppos, buf, ofs);

	kfree(buf);
	return ofs;
}

static ssize_t
+20 −22
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ static int mt7615_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
	struct ieee80211_sta *sta;
	struct ieee80211_vif *vif;
	struct ieee80211_hdr hdr;
	__le32 qos_ctrl, ht_ctrl;
	u16 frame_control;

	if (FIELD_GET(MT_RXD1_NORMAL_ADDR_TYPE, le32_to_cpu(rxd[1])) !=
	    MT_RXD1_NORMAL_U2M)
@@ -275,16 +275,15 @@ static int mt7615_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
	vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);

	/* store the info from RXD and ethhdr to avoid being overridden */
	hdr.frame_control = FIELD_GET(MT_RXD4_FRAME_CONTROL, rxd[4]);
	hdr.seq_ctrl = FIELD_GET(MT_RXD6_SEQ_CTRL, rxd[6]);
	qos_ctrl = FIELD_GET(MT_RXD6_QOS_CTL, rxd[6]);
	ht_ctrl = FIELD_GET(MT_RXD7_HT_CONTROL, rxd[7]);

	frame_control = le32_get_bits(rxd[4], MT_RXD4_FRAME_CONTROL);
	hdr.frame_control = cpu_to_le16(frame_control);
	hdr.seq_ctrl = cpu_to_le16(le32_get_bits(rxd[6], MT_RXD6_SEQ_CTRL));
	hdr.duration_id = 0;

	ether_addr_copy(hdr.addr1, vif->addr);
	ether_addr_copy(hdr.addr2, sta->addr);
	switch (le16_to_cpu(hdr.frame_control) &
		(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
	switch (frame_control & (IEEE80211_FCTL_TODS |
				 IEEE80211_FCTL_FROMDS)) {
	case 0:
		ether_addr_copy(hdr.addr3, vif->bss_conf.bssid);
		break;
@@ -306,15 +305,23 @@ static int mt7615_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
	if (eth_hdr->h_proto == cpu_to_be16(ETH_P_AARP) ||
	    eth_hdr->h_proto == cpu_to_be16(ETH_P_IPX))
		ether_addr_copy(skb_push(skb, ETH_ALEN), bridge_tunnel_header);
	else if (eth_hdr->h_proto >= cpu_to_be16(ETH_P_802_3_MIN))
	else if (be16_to_cpu(eth_hdr->h_proto) >= ETH_P_802_3_MIN)
		ether_addr_copy(skb_push(skb, ETH_ALEN), rfc1042_header);
	else
		skb_pull(skb, 2);

	if (ieee80211_has_order(hdr.frame_control))
		memcpy(skb_push(skb, 2), &ht_ctrl, 2);
	if (ieee80211_is_data_qos(hdr.frame_control))
		memcpy(skb_push(skb, 2), &qos_ctrl, 2);
		memcpy(skb_push(skb, IEEE80211_HT_CTL_LEN), &rxd[7],
		       IEEE80211_HT_CTL_LEN);

	if (ieee80211_is_data_qos(hdr.frame_control)) {
		__le16 qos_ctrl;

		qos_ctrl = cpu_to_le16(le32_get_bits(rxd[6], MT_RXD6_QOS_CTL));
		memcpy(skb_push(skb, IEEE80211_QOS_CTL_LEN), &qos_ctrl,
		       IEEE80211_QOS_CTL_LEN);
	}

	if (ieee80211_has_a4(hdr.frame_control))
		memcpy(skb_push(skb, sizeof(hdr)), &hdr, sizeof(hdr));
	else
@@ -569,15 +576,6 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
		status->chain_signal[1] = to_rssi(MT_RXV4_RCPI1, rxdg3);
		status->chain_signal[2] = to_rssi(MT_RXV4_RCPI2, rxdg3);
		status->chain_signal[3] = to_rssi(MT_RXV4_RCPI3, rxdg3);
		status->signal = status->chain_signal[0];

		for (i = 1; i < hweight8(mphy->antenna_mask); i++) {
			if (!(status->chains & BIT(i)))
				continue;

			status->signal = max(status->signal,
					     status->chain_signal[i]);
		}

		mt7615_mac_fill_tm_rx(mphy->priv, rxd);

@@ -1862,7 +1860,7 @@ mt7615_mac_adjust_sensitivity(struct mt7615_phy *phy,
	struct mt7615_dev *dev = phy->dev;
	int false_cca = ofdm ? phy->false_cca_ofdm : phy->false_cca_cck;
	bool ext_phy = phy != &dev->phy;
	u16 def_th = ofdm ? -98 : -110;
	s16 def_th = ofdm ? -98 : -110;
	bool update = false;
	s8 *sensitivity;
	int signal;
Loading