Commit 961b27ff authored by Kalle Valo's avatar Kalle Valo
Browse files

Merge tag 'mt76-for-kvalo-2021-04-12' of https://github.com/nbd168/wireless

mt76 patches for 5.13

* code cleanup
* mt7915/mt7615 decap offload support
* driver fixes
* mt7613 eeprom support
* MCU code unification
* threaded NAPI support
* new device IDs
* mt7921 device reset support
* rx timestamp support

# gpg: Signature made Tue 13 Apr 2021 12:11:25 AM EEST using DSA key ID 02A76EF5
# gpg: Good signature from "Felix Fietkau <nbd@nbd.name>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 75D1 1A7D 91A7 710F 4900  42EF D77D 141D 02A7 6EF5
parents 3a1aa533 481fc927
Loading
Loading
Loading
Loading
+0 −24
Original line number Diff line number Diff line
Common IEEE 802.11 properties

This provides documentation of common properties that are valid for all wireless
devices.

Optional properties:
 - ieee80211-freq-limit : list of supported frequency ranges in KHz. This can be
	used for devices that in a given config support less channels than
	normally. It may happen chipset supports a wide wireless band but it is
	limited to some part of it due to used antennas or power amplifier.
	An example case for this can be tri-band wireless router with two
	identical chipsets used for two different 5 GHz subbands. Using them
	incorrectly could not work or decrease performance noticeably.

Example:

pcie@0,0 {
	reg = <0x0000 0 0 0 0>;
	wifi@0,0 {
		reg = <0x0000 0 0 0 0>;
		ieee80211-freq-limit = <2402000 2482000>,
				       <5170000 5250000>;
	};
};
+45 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
# Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.

%YAML 1.2
---
$id: http://devicetree.org/schemas/net/wireless/ieee80211.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Common IEEE 802.11 Binding

maintainers:
  - Lorenzo Bianconi <lorenzo@kernel.org>

description: |
  This provides documentation of common properties that are valid for
  all wireless devices

properties:
  ieee80211-freq-limit:
    $ref: /schemas/types.yaml#/definitions/uint32-matrix
    items:
      minItems: 2
      maxItems: 2
    description:
      List of supported frequency ranges in KHz. This can be used for devices
      that in a given config support less channels than normally. It may happen
      chipset supports a wide wireless band but it is limited to some part of
      it due to used antennas or power amplifier. An example case for this
      can be tri-band wireless router with two identical chipsets used for two
      different 5 GHz subbands. Using them incorrectly could not work or
      decrease performance noticeably

additionalProperties: true

examples:
  - |
    pcie0 {
      #address-cells = <3>;
      #size-cells = <2>;
      wifi@0,0 {
        reg = <0x0000 0 0 0 0>;
        ieee80211-freq-limit = <2402000 2482000>,
                               <5170000 5250000>;
      };
    };
+0 −78
Original line number Diff line number Diff line
* MediaTek mt76xx devices

This node provides properties for configuring the MediaTek mt76xx 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. For SoC, use the following compatible strings:

compatible:
- "mediatek,mt7628-wmac" for MT7628/MT7688
- "mediatek,mt7622-wmac" for MT7622

properties:
- reg: Address and length of the register set for the device.
- interrupts: Main device interrupt

MT7622 specific properties:
- power-domains: phandle to the power domain that the WMAC is part of
- mediatek,infracfg: phandle to the infrastructure bus fabric syscon node

Optional properties:

- ieee80211-freq-limit: See ieee80211.txt
- mediatek,mtd-eeprom: Specify a MTD partition + offset containing EEPROM data
- big-endian: if the radio eeprom partition is written in big-endian, specify
  this property
- mediatek,eeprom-merge-otp: Merge EEPROM data with OTP data. Can be used on
  boards where the flash calibration data is generic and specific calibration
  data should be pulled from the OTP ROM

The MAC address can as well be set with corresponding optional properties
defined in net/ethernet.txt.

Optional nodes:
- led: Properties for a connected LED
  Optional properties:
    - led-sources: See Documentation/devicetree/bindings/leds/common.txt

&pcie {
	pcie0 {
		wifi@0,0 {
			compatible = "mediatek,mt76";
			reg = <0x0000 0 0 0 0>;
			ieee80211-freq-limit = <5000000 6000000>;
			mediatek,mtd-eeprom = <&factory 0x8000>;
			big-endian;

			led {
				led-sources = <2>;
			};
		};
	};
};

MT7628 example:

wmac: wmac@10300000 {
	compatible = "mediatek,mt7628-wmac";
	reg = <0x10300000 0x100000>;

	interrupt-parent = <&cpuintc>;
	interrupts = <6>;

	mediatek,mtd-eeprom = <&factory 0x0000>;
};

MT7622 example:

wmac: wmac@18000000 {
	compatible = "mediatek,mt7622-wmac";
	reg = <0 0x18000000 0 0x100000>;
	interrupts = <GIC_SPI 211 IRQ_TYPE_LEVEL_LOW>;

	mediatek,infracfg = <&infracfg>;

	power-domains = <&scpsys MT7622_POWER_DOMAIN_WB>;
};
+121 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
# Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.

%YAML 1.2
---
$id: http://devicetree.org/schemas/net/wireless/mediatek,mt76.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: MediaTek mt76 wireless devices Generic Binding

maintainers:
  - Felix Fietkau <nbd@nbd.name>
  - Lorenzo Bianconi <lorenzo@kernel.org>
  - Ryder Lee <ryder.lee@mediatek.com>

description: |
  This node provides properties for configuring the MediaTek mt76xx
  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.

allOf:
  - $ref: ieee80211.yaml#

properties:
  compatible:
    enum:
      - mediatek,mt76
      - mediatek,mt7628-wmac
      - mediatek,mt7622-wmac

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  power-domains:
    maxItems: 1

  mediatek,infracfg:
    $ref: /schemas/types.yaml#/definitions/phandle
    description:
      Phandle to the infrastructure bus fabric syscon node.
      This property is MT7622 specific

  ieee80211-freq-limit: true

  mediatek,mtd-eeprom:
    $ref: /schemas/types.yaml#/definitions/phandle-array
    description:
      Phandle to a MTD partition + offset containing EEPROM data

  big-endian:
    $ref: /schemas/types.yaml#/definitions/flag
    description:
      Specify if the radio eeprom partition is written in big-endian

  mediatek,eeprom-merge-otp:
    type: boolean
    description:
      Merge EEPROM data with OTP data. Can be used on boards where the flash
      calibration data is generic and specific calibration data should be
      pulled from the OTP ROM

  led:
    type: object
    $ref: /schemas/leds/common.yaml#
    additionalProperties: false
    properties:
      led-sources:
        maxItems: 1

required:
  - compatible
  - reg

additionalProperties: false

examples:
  - |
    pcie0 {
      #address-cells = <3>;
      #size-cells = <2>;
      wifi@0,0 {
        compatible = "mediatek,mt76";
        reg = <0x0000 0 0 0 0>;
        ieee80211-freq-limit = <5000000 6000000>;
        mediatek,mtd-eeprom = <&factory 0x8000>;
        big-endian;

        led {
          led-sources = <2>;
        };
      };
    };

  - |
    wifi@10300000 {
      compatible = "mediatek,mt7628-wmac";
      reg = <0x10300000 0x100000>;

      interrupt-parent = <&cpuintc>;
      interrupts = <6>;

      mediatek,mtd-eeprom = <&factory 0x0>;
    };

  - |
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/interrupt-controller/irq.h>
    wifi@18000000 {
      compatible = "mediatek,mt7622-wmac";
      reg = <0x10300000 0x100000>;
      interrupts = <GIC_SPI 211 IRQ_TYPE_LEVEL_LOW>;

      mediatek,infracfg = <&infracfg>;

      power-domains = <&scpsys 3>;
    };
+10 −9
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ mt76_rx_aggr_check_release(struct mt76_rx_tid *tid, struct sk_buff_head *frames)

		nframes--;
		status = (struct mt76_rx_status *)skb->cb;
		if (!time_after(jiffies,
		if (!time_after32(jiffies,
				  status->reorder_time +
				  mt76_aggr_tid_to_timeo(tid->num)))
			continue;
@@ -122,6 +122,7 @@ mt76_rx_aggr_check_ctl(struct sk_buff *skb, struct sk_buff_head *frames)
	struct ieee80211_bar *bar = mt76_skb_get_hdr(skb);
	struct mt76_wcid *wcid = status->wcid;
	struct mt76_rx_tid *tid;
	u8 tidno = status->qos_ctl & IEEE80211_QOS_CTL_TID_MASK;
	u16 seqno;

	if (!ieee80211_is_ctl(bar->frame_control))
@@ -130,9 +131,9 @@ mt76_rx_aggr_check_ctl(struct sk_buff *skb, struct sk_buff_head *frames)
	if (!ieee80211_is_back_req(bar->frame_control))
		return;

	status->tid = le16_to_cpu(bar->control) >> 12;
	status->qos_ctl = tidno = le16_to_cpu(bar->control) >> 12;
	seqno = IEEE80211_SEQ_TO_SN(le16_to_cpu(bar->start_seq_num));
	tid = rcu_dereference(wcid->aggr[status->tid]);
	tid = rcu_dereference(wcid->aggr[tidno]);
	if (!tid)
		return;

@@ -147,12 +148,12 @@ mt76_rx_aggr_check_ctl(struct sk_buff *skb, struct sk_buff_head *frames)
void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames)
{
	struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
	struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
	struct mt76_wcid *wcid = status->wcid;
	struct ieee80211_sta *sta;
	struct mt76_rx_tid *tid;
	bool sn_less;
	u16 seqno, head, size, idx;
	u8 tidno = status->qos_ctl & IEEE80211_QOS_CTL_TID_MASK;
	u8 ackp;

	__skb_queue_tail(frames, skb);
@@ -161,18 +162,18 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames)
	if (!sta)
		return;

	if (!status->aggr) {
	if (!status->aggr && !(status->flag & RX_FLAG_8023)) {
		mt76_rx_aggr_check_ctl(skb, frames);
		return;
	}

	/* not part of a BA session */
	ackp = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_ACK_POLICY_MASK;
	ackp = status->qos_ctl & IEEE80211_QOS_CTL_ACK_POLICY_MASK;
	if (ackp != IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK &&
	    ackp != IEEE80211_QOS_CTL_ACK_POLICY_NORMAL)
		return;

	tid = rcu_dereference(wcid->aggr[status->tid]);
	tid = rcu_dereference(wcid->aggr[tidno]);
	if (!tid)
		return;

Loading