All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address
@ 2023-07-31 22:23 ` Daniel Golle
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Golle @ 2023-07-31 22:23 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Kalle Valo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	linux-wireless, netdev, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek

Introduce support for setting individual per-band MAC addresses using
NVMEM cells by adding a 'bands' object with enumerated child nodes
representing the 2.4 GHz, 5 GHz and 6 GHz bands.

In case it is defined, call of_get_mac_address for the per-band child
node, otherwise try with of_get_mac_address on the main device node and
fall back to a random address like it used to be.

While at it, add MAC address related properties also for the main node.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
Changes since v2:
 * drop items list with only a single item

Changes since v1:
 * add dt-bindings

 .../bindings/net/wireless/mediatek,mt76.yaml  | 58 ++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
index 252207adbc54c..7eafed53da1de 100644
--- a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
+++ b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
@@ -37,6 +37,12 @@ properties:
     description:
       MT7986 should contain 3 regions consys, dcm, and sku, in this order.
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
   interrupts:
     maxItems: 1
 
@@ -72,13 +78,23 @@ properties:
 
   ieee80211-freq-limit: true
 
+  address: true
+
+  local-mac-address: true
+
+  mac-address: true
+
   nvmem-cells:
+    minItems: 1
     items:
       - description: NVMEM cell with EEPROM
+      - description: NVMEM cell with the MAC address
 
   nvmem-cell-names:
+    minItems: 1
     items:
       - const: eeprom
+      - const: mac-address
 
   mediatek,eeprom-data:
     $ref: /schemas/types.yaml#/definitions/uint32-array
@@ -213,6 +229,29 @@ properties:
                     description:
                       Half-dBm power delta for different numbers of antennas
 
+patternProperties:
+  '^band@[0-2]+$':
+    type: object
+    additionalProperties: false
+    properties:
+      reg:
+        maxItems: 1
+
+      address: true
+      local-mac-address: true
+      mac-address: true
+
+      nvmem-cells:
+        description: NVMEM cell with the MAC address
+
+      nvmem-cell-names:
+        const: mac-address
+
+    required:
+      - reg
+
+    unevaluatedProperties: false
+
 required:
   - compatible
   - reg
@@ -225,10 +264,13 @@ examples:
       #address-cells = <3>;
       #size-cells = <2>;
       wifi@0,0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
         compatible = "mediatek,mt76";
         reg = <0x0000 0 0 0 0>;
         ieee80211-freq-limit = <5000000 6000000>;
-        mediatek,mtd-eeprom = <&factory 0x8000>;
+        nvmem-cells = <&factory_eeprom>;
+        nvmem-cell-names = "eeprom";
         big-endian;
 
         led {
@@ -257,6 +299,20 @@ examples:
              };
           };
         };
+
+        band@0 {
+          /* 2.4 GHz */
+          reg = <0>;
+          nvmem-cells = <&macaddr 0x4>;
+          nvmem-cell-names = "mac-address";
+        };
+
+        band@1 {
+          /* 5 GHz */
+          reg = <1>;
+          nvmem-cells = <&macaddr 0xa>;
+          nvmem-cell-names = "mac-address";
+        };
       };
     };
 
-- 
2.41.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address
@ 2023-07-31 22:23 ` Daniel Golle
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Golle @ 2023-07-31 22:23 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Kalle Valo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	linux-wireless, netdev, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek

Introduce support for setting individual per-band MAC addresses using
NVMEM cells by adding a 'bands' object with enumerated child nodes
representing the 2.4 GHz, 5 GHz and 6 GHz bands.

In case it is defined, call of_get_mac_address for the per-band child
node, otherwise try with of_get_mac_address on the main device node and
fall back to a random address like it used to be.

While at it, add MAC address related properties also for the main node.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
Changes since v2:
 * drop items list with only a single item

Changes since v1:
 * add dt-bindings

 .../bindings/net/wireless/mediatek,mt76.yaml  | 58 ++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
index 252207adbc54c..7eafed53da1de 100644
--- a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
+++ b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
@@ -37,6 +37,12 @@ properties:
     description:
       MT7986 should contain 3 regions consys, dcm, and sku, in this order.
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
   interrupts:
     maxItems: 1
 
@@ -72,13 +78,23 @@ properties:
 
   ieee80211-freq-limit: true
 
+  address: true
+
+  local-mac-address: true
+
+  mac-address: true
+
   nvmem-cells:
+    minItems: 1
     items:
       - description: NVMEM cell with EEPROM
+      - description: NVMEM cell with the MAC address
 
   nvmem-cell-names:
+    minItems: 1
     items:
       - const: eeprom
+      - const: mac-address
 
   mediatek,eeprom-data:
     $ref: /schemas/types.yaml#/definitions/uint32-array
@@ -213,6 +229,29 @@ properties:
                     description:
                       Half-dBm power delta for different numbers of antennas
 
+patternProperties:
+  '^band@[0-2]+$':
+    type: object
+    additionalProperties: false
+    properties:
+      reg:
+        maxItems: 1
+
+      address: true
+      local-mac-address: true
+      mac-address: true
+
+      nvmem-cells:
+        description: NVMEM cell with the MAC address
+
+      nvmem-cell-names:
+        const: mac-address
+
+    required:
+      - reg
+
+    unevaluatedProperties: false
+
 required:
   - compatible
   - reg
@@ -225,10 +264,13 @@ examples:
       #address-cells = <3>;
       #size-cells = <2>;
       wifi@0,0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
         compatible = "mediatek,mt76";
         reg = <0x0000 0 0 0 0>;
         ieee80211-freq-limit = <5000000 6000000>;
-        mediatek,mtd-eeprom = <&factory 0x8000>;
+        nvmem-cells = <&factory_eeprom>;
+        nvmem-cell-names = "eeprom";
         big-endian;
 
         led {
@@ -257,6 +299,20 @@ examples:
              };
           };
         };
+
+        band@0 {
+          /* 2.4 GHz */
+          reg = <0>;
+          nvmem-cells = <&macaddr 0x4>;
+          nvmem-cell-names = "mac-address";
+        };
+
+        band@1 {
+          /* 5 GHz */
+          reg = <1>;
+          nvmem-cells = <&macaddr 0xa>;
+          nvmem-cell-names = "mac-address";
+        };
       };
     };
 
-- 
2.41.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 2/2] wifi: mt76: support per-band MAC addresses from OF child nodes
  2023-07-31 22:23 ` Daniel Golle
@ 2023-07-31 22:24   ` Daniel Golle
  -1 siblings, 0 replies; 10+ messages in thread
From: Daniel Golle @ 2023-07-31 22:24 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Kalle Valo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	linux-wireless, netdev, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek

With dual-band-dual-congruent front-ends which appear as two independent
radios it is desirable to assign a per-band MAC address from device-tree,
eg. using nvmem-cells.
Support specifying MAC-address related properties in band-specific child
nodes, e.g.
        wifi@0,0 {
                reg = <0x0000 0 0 0 0>;
                #addr-cells = <1>;
                #size-cells = <0>;

                band@0 {
                        /* 2.4 GHz */
                        reg = <0>;
                        nvmem-cells = <&macaddr 2>;
                        nvmem-cell-names = "mac-address";
                };

                band@1 {
                        /* 5 GHz */
                        reg = <1>;
                        nvmem-cells = <&macaddr 3>;
                        nvmem-cell-names = "mac-address";
                };
        };

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Tested-by: Shiji Yang <yangshiji66@outlook.com>
---
Changes since v2:
 * none

Changes since v1:
 * refactor and add missing of_node_put()

 drivers/net/wireless/mediatek/mt76/eeprom.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
index 36564930aef12..c2b3386cada1c 100644
--- a/drivers/net/wireless/mediatek/mt76/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
@@ -161,9 +161,25 @@ void
 mt76_eeprom_override(struct mt76_phy *phy)
 {
 	struct mt76_dev *dev = phy->dev;
-	struct device_node *np = dev->dev->of_node;
+	struct device_node *np = dev->dev->of_node, *band_np;
+	bool found_mac = false;
+	u32 reg;
+	int ret;
+
+	for_each_child_of_node(np, band_np) {
+		ret = of_property_read_u32(band_np, "reg", &reg);
+		if (ret)
+			continue;
+
+		if (reg == phy->band_idx) {
+			found_mac = !of_get_mac_address(band_np, phy->macaddr);
+			of_node_put(band_np);
+			break;
+		}
+	}
 
-	of_get_mac_address(np, phy->macaddr);
+	if (!found_mac)
+		of_get_mac_address(np, phy->macaddr);
 
 	if (!is_valid_ether_addr(phy->macaddr)) {
 		eth_random_addr(phy->macaddr);
-- 
2.41.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 2/2] wifi: mt76: support per-band MAC addresses from OF child nodes
@ 2023-07-31 22:24   ` Daniel Golle
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Golle @ 2023-07-31 22:24 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Kalle Valo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	linux-wireless, netdev, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek

With dual-band-dual-congruent front-ends which appear as two independent
radios it is desirable to assign a per-band MAC address from device-tree,
eg. using nvmem-cells.
Support specifying MAC-address related properties in band-specific child
nodes, e.g.
        wifi@0,0 {
                reg = <0x0000 0 0 0 0>;
                #addr-cells = <1>;
                #size-cells = <0>;

                band@0 {
                        /* 2.4 GHz */
                        reg = <0>;
                        nvmem-cells = <&macaddr 2>;
                        nvmem-cell-names = "mac-address";
                };

                band@1 {
                        /* 5 GHz */
                        reg = <1>;
                        nvmem-cells = <&macaddr 3>;
                        nvmem-cell-names = "mac-address";
                };
        };

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Tested-by: Shiji Yang <yangshiji66@outlook.com>
---
Changes since v2:
 * none

Changes since v1:
 * refactor and add missing of_node_put()

 drivers/net/wireless/mediatek/mt76/eeprom.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
index 36564930aef12..c2b3386cada1c 100644
--- a/drivers/net/wireless/mediatek/mt76/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
@@ -161,9 +161,25 @@ void
 mt76_eeprom_override(struct mt76_phy *phy)
 {
 	struct mt76_dev *dev = phy->dev;
-	struct device_node *np = dev->dev->of_node;
+	struct device_node *np = dev->dev->of_node, *band_np;
+	bool found_mac = false;
+	u32 reg;
+	int ret;
+
+	for_each_child_of_node(np, band_np) {
+		ret = of_property_read_u32(band_np, "reg", &reg);
+		if (ret)
+			continue;
+
+		if (reg == phy->band_idx) {
+			found_mac = !of_get_mac_address(band_np, phy->macaddr);
+			of_node_put(band_np);
+			break;
+		}
+	}
 
-	of_get_mac_address(np, phy->macaddr);
+	if (!found_mac)
+		of_get_mac_address(np, phy->macaddr);
 
 	if (!is_valid_ether_addr(phy->macaddr)) {
 		eth_random_addr(phy->macaddr);
-- 
2.41.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address
  2023-07-31 22:23 ` Daniel Golle
@ 2023-08-01  8:04   ` Kalle Valo
  -1 siblings, 0 replies; 10+ messages in thread
From: Kalle Valo @ 2023-08-01  8:04 UTC (permalink / raw)
  To: Daniel Golle
  Cc: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-wireless,
	netdev, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek

Daniel Golle <daniel@makrotopia.org> writes:

> Introduce support for setting individual per-band MAC addresses using
> NVMEM cells by adding a 'bands' object with enumerated child nodes
> representing the 2.4 GHz, 5 GHz and 6 GHz bands.
>
> In case it is defined, call of_get_mac_address for the per-band child
> node, otherwise try with of_get_mac_address on the main device node and
> fall back to a random address like it used to be.
>
> While at it, add MAC address related properties also for the main node.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>

mt76 patches go to Felix's tree, not net-next. No need to resend because
of this.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address
@ 2023-08-01  8:04   ` Kalle Valo
  0 siblings, 0 replies; 10+ messages in thread
From: Kalle Valo @ 2023-08-01  8:04 UTC (permalink / raw)
  To: Daniel Golle
  Cc: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-wireless,
	netdev, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek

Daniel Golle <daniel@makrotopia.org> writes:

> Introduce support for setting individual per-band MAC addresses using
> NVMEM cells by adding a 'bands' object with enumerated child nodes
> representing the 2.4 GHz, 5 GHz and 6 GHz bands.
>
> In case it is defined, call of_get_mac_address for the per-band child
> node, otherwise try with of_get_mac_address on the main device node and
> fall back to a random address like it used to be.
>
> While at it, add MAC address related properties also for the main node.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>

mt76 patches go to Felix's tree, not net-next. No need to resend because
of this.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address
  2023-07-31 22:23 ` Daniel Golle
@ 2023-08-11 19:09   ` Rob Herring
  -1 siblings, 0 replies; 10+ messages in thread
From: Rob Herring @ 2023-08-11 19:09 UTC (permalink / raw)
  To: Daniel Golle
  Cc: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Kalle Valo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-wireless,
	netdev, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek

On Mon, Jul 31, 2023 at 11:23:16PM +0100, Daniel Golle wrote:
> Introduce support for setting individual per-band MAC addresses using
> NVMEM cells by adding a 'bands' object with enumerated child nodes
> representing the 2.4 GHz, 5 GHz and 6 GHz bands.
> 
> In case it is defined, call of_get_mac_address for the per-band child
> node, otherwise try with of_get_mac_address on the main device node and
> fall back to a random address like it used to be.
> 
> While at it, add MAC address related properties also for the main node.
> 
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> Changes since v2:
>  * drop items list with only a single item
> 
> Changes since v1:
>  * add dt-bindings
> 
>  .../bindings/net/wireless/mediatek,mt76.yaml  | 58 ++++++++++++++++++-
>  1 file changed, 57 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> index 252207adbc54c..7eafed53da1de 100644
> --- a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> +++ b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> @@ -37,6 +37,12 @@ properties:
>      description:
>        MT7986 should contain 3 regions consys, dcm, and sku, in this order.
>  
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
>    interrupts:
>      maxItems: 1
>  
> @@ -72,13 +78,23 @@ properties:
>  
>    ieee80211-freq-limit: true
>  
> +  address: true

What's this? Not a documented property.


> +
> +  local-mac-address: true
> +
> +  mac-address: true

You really need a ref to the schema defining these. But first we need to 
split them out from ethernet-controller.yaml. Which I think there were 
patches for, but it stalled out.

Anyways, it's fine for now if you're not up for that.

> +
>    nvmem-cells:
> +    minItems: 1
>      items:
>        - description: NVMEM cell with EEPROM
> +      - description: NVMEM cell with the MAC address
>  
>    nvmem-cell-names:
> +    minItems: 1
>      items:
>        - const: eeprom
> +      - const: mac-address
>  
>    mediatek,eeprom-data:
>      $ref: /schemas/types.yaml#/definitions/uint32-array
> @@ -213,6 +229,29 @@ properties:
>                      description:
>                        Half-dBm power delta for different numbers of antennas
>  
> +patternProperties:
> +  '^band@[0-2]+$':
> +    type: object
> +    additionalProperties: false
> +    properties:
> +      reg:
> +        maxItems: 1
> +
> +      address: true
> +      local-mac-address: true
> +      mac-address: true
> +
> +      nvmem-cells:
> +        description: NVMEM cell with the MAC address
> +
> +      nvmem-cell-names:
> +        const: mac-address
> +
> +    required:
> +      - reg
> +
> +    unevaluatedProperties: false
> +
>  required:
>    - compatible
>    - reg
> @@ -225,10 +264,13 @@ examples:
>        #address-cells = <3>;
>        #size-cells = <2>;
>        wifi@0,0 {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
>          compatible = "mediatek,mt76";
>          reg = <0x0000 0 0 0 0>;
>          ieee80211-freq-limit = <5000000 6000000>;
> -        mediatek,mtd-eeprom = <&factory 0x8000>;
> +        nvmem-cells = <&factory_eeprom>;
> +        nvmem-cell-names = "eeprom";
>          big-endian;
>  
>          led {
> @@ -257,6 +299,20 @@ examples:
>               };
>            };
>          };
> +
> +        band@0 {
> +          /* 2.4 GHz */
> +          reg = <0>;
> +          nvmem-cells = <&macaddr 0x4>;
> +          nvmem-cell-names = "mac-address";
> +        };
> +
> +        band@1 {
> +          /* 5 GHz */
> +          reg = <1>;
> +          nvmem-cells = <&macaddr 0xa>;
> +          nvmem-cell-names = "mac-address";
> +        };
>        };
>      };
>  
> -- 
> 2.41.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address
@ 2023-08-11 19:09   ` Rob Herring
  0 siblings, 0 replies; 10+ messages in thread
From: Rob Herring @ 2023-08-11 19:09 UTC (permalink / raw)
  To: Daniel Golle
  Cc: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Kalle Valo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-wireless,
	netdev, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek

On Mon, Jul 31, 2023 at 11:23:16PM +0100, Daniel Golle wrote:
> Introduce support for setting individual per-band MAC addresses using
> NVMEM cells by adding a 'bands' object with enumerated child nodes
> representing the 2.4 GHz, 5 GHz and 6 GHz bands.
> 
> In case it is defined, call of_get_mac_address for the per-band child
> node, otherwise try with of_get_mac_address on the main device node and
> fall back to a random address like it used to be.
> 
> While at it, add MAC address related properties also for the main node.
> 
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> Changes since v2:
>  * drop items list with only a single item
> 
> Changes since v1:
>  * add dt-bindings
> 
>  .../bindings/net/wireless/mediatek,mt76.yaml  | 58 ++++++++++++++++++-
>  1 file changed, 57 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> index 252207adbc54c..7eafed53da1de 100644
> --- a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> +++ b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> @@ -37,6 +37,12 @@ properties:
>      description:
>        MT7986 should contain 3 regions consys, dcm, and sku, in this order.
>  
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
>    interrupts:
>      maxItems: 1
>  
> @@ -72,13 +78,23 @@ properties:
>  
>    ieee80211-freq-limit: true
>  
> +  address: true

What's this? Not a documented property.


> +
> +  local-mac-address: true
> +
> +  mac-address: true

You really need a ref to the schema defining these. But first we need to 
split them out from ethernet-controller.yaml. Which I think there were 
patches for, but it stalled out.

Anyways, it's fine for now if you're not up for that.

> +
>    nvmem-cells:
> +    minItems: 1
>      items:
>        - description: NVMEM cell with EEPROM
> +      - description: NVMEM cell with the MAC address
>  
>    nvmem-cell-names:
> +    minItems: 1
>      items:
>        - const: eeprom
> +      - const: mac-address
>  
>    mediatek,eeprom-data:
>      $ref: /schemas/types.yaml#/definitions/uint32-array
> @@ -213,6 +229,29 @@ properties:
>                      description:
>                        Half-dBm power delta for different numbers of antennas
>  
> +patternProperties:
> +  '^band@[0-2]+$':
> +    type: object
> +    additionalProperties: false
> +    properties:
> +      reg:
> +        maxItems: 1
> +
> +      address: true
> +      local-mac-address: true
> +      mac-address: true
> +
> +      nvmem-cells:
> +        description: NVMEM cell with the MAC address
> +
> +      nvmem-cell-names:
> +        const: mac-address
> +
> +    required:
> +      - reg
> +
> +    unevaluatedProperties: false
> +
>  required:
>    - compatible
>    - reg
> @@ -225,10 +264,13 @@ examples:
>        #address-cells = <3>;
>        #size-cells = <2>;
>        wifi@0,0 {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
>          compatible = "mediatek,mt76";
>          reg = <0x0000 0 0 0 0>;
>          ieee80211-freq-limit = <5000000 6000000>;
> -        mediatek,mtd-eeprom = <&factory 0x8000>;
> +        nvmem-cells = <&factory_eeprom>;
> +        nvmem-cell-names = "eeprom";
>          big-endian;
>  
>          led {
> @@ -257,6 +299,20 @@ examples:
>               };
>            };
>          };
> +
> +        band@0 {
> +          /* 2.4 GHz */
> +          reg = <0>;
> +          nvmem-cells = <&macaddr 0x4>;
> +          nvmem-cell-names = "mac-address";
> +        };
> +
> +        band@1 {
> +          /* 5 GHz */
> +          reg = <1>;
> +          nvmem-cells = <&macaddr 0xa>;
> +          nvmem-cell-names = "mac-address";
> +        };
>        };
>      };
>  
> -- 
> 2.41.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address
  2023-08-11 19:09   ` Rob Herring
@ 2023-08-22 11:35     ` Daniel Golle
  -1 siblings, 0 replies; 10+ messages in thread
From: Daniel Golle @ 2023-08-22 11:35 UTC (permalink / raw)
  To: Rob Herring
  Cc: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Kalle Valo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-wireless,
	netdev, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek

On Fri, Aug 11, 2023 at 01:09:44PM -0600, Rob Herring wrote:
> On Mon, Jul 31, 2023 at 11:23:16PM +0100, Daniel Golle wrote:
> > Introduce support for setting individual per-band MAC addresses using
> > NVMEM cells by adding a 'bands' object with enumerated child nodes
> > representing the 2.4 GHz, 5 GHz and 6 GHz bands.
> > 
> > In case it is defined, call of_get_mac_address for the per-band child
> > node, otherwise try with of_get_mac_address on the main device node and
> > fall back to a random address like it used to be.
> > 
> > While at it, add MAC address related properties also for the main node.
> > 
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> > ---
> > Changes since v2:
> >  * drop items list with only a single item
> > 
> > Changes since v1:
> >  * add dt-bindings
> > 
> >  .../bindings/net/wireless/mediatek,mt76.yaml  | 58 ++++++++++++++++++-
> >  1 file changed, 57 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> > index 252207adbc54c..7eafed53da1de 100644
> > --- a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> > +++ b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> > @@ -37,6 +37,12 @@ properties:
> >      description:
> >        MT7986 should contain 3 regions consys, dcm, and sku, in this order.
> >  
> > +  '#address-cells':
> > +    const: 1
> > +
> > +  '#size-cells':
> > +    const: 0
> > +
> >    interrupts:
> >      maxItems: 1
> >  
> > @@ -72,13 +78,23 @@ properties:
> >  
> >    ieee80211-freq-limit: true
> >  
> > +  address: true
> 
> What's this? Not a documented property.

Maybe it should be documented then...?
See
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/core/of_net.c#n140

```
int of_get_mac_address(struct device_node *np, u8 *addr)
{
	int ret;

	if (!np)
		return -ENODEV;

	ret = of_get_mac_addr(np, "mac-address", addr);
	if (!ret)
		return 0;

	ret = of_get_mac_addr(np, "local-mac-address", addr);
	if (!ret)
		return 0;

	ret = of_get_mac_addr(np, "address", addr);
	if (!ret)
		return 0;

	return of_get_mac_address_nvmem(np, addr);
}
EXPORT_SYMBOL(of_get_mac_address);
```

> 
> 
> > +
> > +  local-mac-address: true
> > +
> > +  mac-address: true
> 
> You really need a ref to the schema defining these. But first we need to 
> split them out from ethernet-controller.yaml. Which I think there were 
> patches for, but it stalled out.
> 

I understand, so have a schema to include whenever of_net.c is used to
assign a MAC address, and then use that for ethernet-controller.yaml and
in places such as here.

If you point me to the existing patches I can pick them up and address
whatever needs to be addressed to get them merged.

> Anyways, it's fine for now if you're not up for that.

So just remove the (supposedly deprecated) "address: true" for now and
then create an of_net MAC-address related schema and move things there
after that?

> 
> > +
> >    nvmem-cells:
> > +    minItems: 1
> >      items:
> >        - description: NVMEM cell with EEPROM
> > +      - description: NVMEM cell with the MAC address
> >  
> >    nvmem-cell-names:
> > +    minItems: 1
> >      items:
> >        - const: eeprom
> > +      - const: mac-address
> >  
> >    mediatek,eeprom-data:
> >      $ref: /schemas/types.yaml#/definitions/uint32-array
> > @@ -213,6 +229,29 @@ properties:
> >                      description:
> >                        Half-dBm power delta for different numbers of antennas
> >  
> > +patternProperties:
> > +  '^band@[0-2]+$':
> > +    type: object
> > +    additionalProperties: false
> > +    properties:
> > +      reg:
> > +        maxItems: 1
> > +
> > +      address: true
> > +      local-mac-address: true
> > +      mac-address: true
> > +
> > +      nvmem-cells:
> > +        description: NVMEM cell with the MAC address
> > +
> > +      nvmem-cell-names:
> > +        const: mac-address
> > +
> > +    required:
> > +      - reg
> > +
> > +    unevaluatedProperties: false
> > +
> >  required:
> >    - compatible
> >    - reg
> > @@ -225,10 +264,13 @@ examples:
> >        #address-cells = <3>;
> >        #size-cells = <2>;
> >        wifi@0,0 {
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> >          compatible = "mediatek,mt76";
> >          reg = <0x0000 0 0 0 0>;
> >          ieee80211-freq-limit = <5000000 6000000>;
> > -        mediatek,mtd-eeprom = <&factory 0x8000>;
> > +        nvmem-cells = <&factory_eeprom>;
> > +        nvmem-cell-names = "eeprom";
> >          big-endian;
> >  
> >          led {
> > @@ -257,6 +299,20 @@ examples:
> >               };
> >            };
> >          };
> > +
> > +        band@0 {
> > +          /* 2.4 GHz */
> > +          reg = <0>;
> > +          nvmem-cells = <&macaddr 0x4>;
> > +          nvmem-cell-names = "mac-address";
> > +        };
> > +
> > +        band@1 {
> > +          /* 5 GHz */
> > +          reg = <1>;
> > +          nvmem-cells = <&macaddr 0xa>;
> > +          nvmem-cell-names = "mac-address";
> > +        };
> >        };
> >      };
> >  
> > -- 
> > 2.41.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address
@ 2023-08-22 11:35     ` Daniel Golle
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Golle @ 2023-08-22 11:35 UTC (permalink / raw)
  To: Rob Herring
  Cc: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Kalle Valo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-wireless,
	netdev, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek

On Fri, Aug 11, 2023 at 01:09:44PM -0600, Rob Herring wrote:
> On Mon, Jul 31, 2023 at 11:23:16PM +0100, Daniel Golle wrote:
> > Introduce support for setting individual per-band MAC addresses using
> > NVMEM cells by adding a 'bands' object with enumerated child nodes
> > representing the 2.4 GHz, 5 GHz and 6 GHz bands.
> > 
> > In case it is defined, call of_get_mac_address for the per-band child
> > node, otherwise try with of_get_mac_address on the main device node and
> > fall back to a random address like it used to be.
> > 
> > While at it, add MAC address related properties also for the main node.
> > 
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> > ---
> > Changes since v2:
> >  * drop items list with only a single item
> > 
> > Changes since v1:
> >  * add dt-bindings
> > 
> >  .../bindings/net/wireless/mediatek,mt76.yaml  | 58 ++++++++++++++++++-
> >  1 file changed, 57 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> > index 252207adbc54c..7eafed53da1de 100644
> > --- a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> > +++ b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml
> > @@ -37,6 +37,12 @@ properties:
> >      description:
> >        MT7986 should contain 3 regions consys, dcm, and sku, in this order.
> >  
> > +  '#address-cells':
> > +    const: 1
> > +
> > +  '#size-cells':
> > +    const: 0
> > +
> >    interrupts:
> >      maxItems: 1
> >  
> > @@ -72,13 +78,23 @@ properties:
> >  
> >    ieee80211-freq-limit: true
> >  
> > +  address: true
> 
> What's this? Not a documented property.

Maybe it should be documented then...?
See
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/core/of_net.c#n140

```
int of_get_mac_address(struct device_node *np, u8 *addr)
{
	int ret;

	if (!np)
		return -ENODEV;

	ret = of_get_mac_addr(np, "mac-address", addr);
	if (!ret)
		return 0;

	ret = of_get_mac_addr(np, "local-mac-address", addr);
	if (!ret)
		return 0;

	ret = of_get_mac_addr(np, "address", addr);
	if (!ret)
		return 0;

	return of_get_mac_address_nvmem(np, addr);
}
EXPORT_SYMBOL(of_get_mac_address);
```

> 
> 
> > +
> > +  local-mac-address: true
> > +
> > +  mac-address: true
> 
> You really need a ref to the schema defining these. But first we need to 
> split them out from ethernet-controller.yaml. Which I think there were 
> patches for, but it stalled out.
> 

I understand, so have a schema to include whenever of_net.c is used to
assign a MAC address, and then use that for ethernet-controller.yaml and
in places such as here.

If you point me to the existing patches I can pick them up and address
whatever needs to be addressed to get them merged.

> Anyways, it's fine for now if you're not up for that.

So just remove the (supposedly deprecated) "address: true" for now and
then create an of_net MAC-address related schema and move things there
after that?

> 
> > +
> >    nvmem-cells:
> > +    minItems: 1
> >      items:
> >        - description: NVMEM cell with EEPROM
> > +      - description: NVMEM cell with the MAC address
> >  
> >    nvmem-cell-names:
> > +    minItems: 1
> >      items:
> >        - const: eeprom
> > +      - const: mac-address
> >  
> >    mediatek,eeprom-data:
> >      $ref: /schemas/types.yaml#/definitions/uint32-array
> > @@ -213,6 +229,29 @@ properties:
> >                      description:
> >                        Half-dBm power delta for different numbers of antennas
> >  
> > +patternProperties:
> > +  '^band@[0-2]+$':
> > +    type: object
> > +    additionalProperties: false
> > +    properties:
> > +      reg:
> > +        maxItems: 1
> > +
> > +      address: true
> > +      local-mac-address: true
> > +      mac-address: true
> > +
> > +      nvmem-cells:
> > +        description: NVMEM cell with the MAC address
> > +
> > +      nvmem-cell-names:
> > +        const: mac-address
> > +
> > +    required:
> > +      - reg
> > +
> > +    unevaluatedProperties: false
> > +
> >  required:
> >    - compatible
> >    - reg
> > @@ -225,10 +264,13 @@ examples:
> >        #address-cells = <3>;
> >        #size-cells = <2>;
> >        wifi@0,0 {
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> >          compatible = "mediatek,mt76";
> >          reg = <0x0000 0 0 0 0>;
> >          ieee80211-freq-limit = <5000000 6000000>;
> > -        mediatek,mtd-eeprom = <&factory 0x8000>;
> > +        nvmem-cells = <&factory_eeprom>;
> > +        nvmem-cell-names = "eeprom";
> >          big-endian;
> >  
> >          led {
> > @@ -257,6 +299,20 @@ examples:
> >               };
> >            };
> >          };
> > +
> > +        band@0 {
> > +          /* 2.4 GHz */
> > +          reg = <0>;
> > +          nvmem-cells = <&macaddr 0x4>;
> > +          nvmem-cell-names = "mac-address";
> > +        };
> > +
> > +        band@1 {
> > +          /* 5 GHz */
> > +          reg = <1>;
> > +          nvmem-cells = <&macaddr 0xa>;
> > +          nvmem-cell-names = "mac-address";
> > +        };
> >        };
> >      };
> >  
> > -- 
> > 2.41.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-08-22 11:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-31 22:23 [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address Daniel Golle
2023-07-31 22:23 ` Daniel Golle
2023-07-31 22:24 ` [PATCH v3 2/2] wifi: mt76: support per-band MAC addresses from OF child nodes Daniel Golle
2023-07-31 22:24   ` Daniel Golle
2023-08-01  8:04 ` [PATCH net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address Kalle Valo
2023-08-01  8:04   ` Kalle Valo
2023-08-11 19:09 ` Rob Herring
2023-08-11 19:09   ` Rob Herring
2023-08-22 11:35   ` Daniel Golle
2023-08-22 11:35     ` Daniel Golle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.