1. 23 Aug, 2022 21 commits
    • Wolfram Sang's avatar
      net: move from strlcpy with unused retval to strscpy · 70986397
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Link: https://lore.kernel.org/r/20220818210215.8395-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      70986397
    • Wolfram Sang's avatar
      packet: move from strlcpy with unused retval to strscpy · 8fc9d51e
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Link: https://lore.kernel.org/r/20220818210227.8611-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8fc9d51e
    • Wolfram Sang's avatar
      l2tp: move from strlcpy with unused retval to strscpy · a5afe530
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Link: https://lore.kernel.org/r/20220818210222.8515-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      a5afe530
    • Wolfram Sang's avatar
      ipv6: move from strlcpy with unused retval to strscpy · 7574cc58
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Link: https://lore.kernel.org/r/20220818210220.8491-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      7574cc58
    • Wolfram Sang's avatar
      ipv4: move from strlcpy with unused retval to strscpy · 01e454f2
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Link: https://lore.kernel.org/r/20220818210219.8467-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      01e454f2
    • Wolfram Sang's avatar
      caif: move from strlcpy with unused retval to strscpy · df207b00
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Link: https://lore.kernel.org/r/20220818210214.8371-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      df207b00
    • Wolfram Sang's avatar
      bridge: move from strlcpy with unused retval to strscpy · 993e1634
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Acked-by: default avatarNikolay Aleksandrov <razor@blackwall.org>
      Link: https://lore.kernel.org/r/20220818210212.8347-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      993e1634
    • Wolfram Sang's avatar
      ax25: move from strlcpy with unused retval to strscpy · 6164b5e3
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Link: https://lore.kernel.org/r/20220818210206.8299-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      6164b5e3
    • Wolfram Sang's avatar
      vlan: move from strlcpy with unused retval to strscpy · bb4d15df
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Link: https://lore.kernel.org/r/20220818210204.8275-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      bb4d15df
    • Wolfram Sang's avatar
      isdn: move from strlcpy with unused retval to strscpy · cdb27b7b
      Wolfram Sang authored
      Follow the advice of the below link and prefer 'strscpy' in this
      subsystem. Conversion is 1:1 because the return value is not used.
      Generated by a coccinelle script.
      
      Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Link: https://lore.kernel.org/r/20220818210023.6889-1-wsa+renesas@sang-engineering.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      cdb27b7b
    • Jakub Kicinski's avatar
      Merge branch 'validate-of-nodes-for-dsa-shared-ports' · 706447f0
      Jakub Kicinski authored
      Vladimir Oltean says:
      
      ====================
      Validate OF nodes for DSA shared ports
      
      This is the first set of measures taken so that more drivers can be
      transitioned towards phylink on shared (CPU and DSA) ports some time in
      the future. It consists of:
      
      - expanding the DT schema for DSA and related drivers to clarify the new
        requirements.
      
      - introducing warnings for drivers that currently skip phylink due to
        incomplete DT descriptions.
      
      - introducing warning for drivers that currently skip phylink due to
        using platform data (search for struct dsa_chip_data).
      
      - closing the possibility for new(ish) drivers to skip phylink, by
        validating their DT descriptions.
      
      - making the code paths used by shared ports more evident.
      
      - preparing the code paths used by shared ports for further work to fake
        a link description where that is possible.
      
      More details in patch 10/10.
      
      DT binding (patches 1-6) and kernel (7-10) are in principle separable,
      but are submitted together since they're part of the same story.
      
      Patches 8 and 9 are DSA cleanups, and patch 7 is a dependency for patch
      10.
      
      v1 at
      https://patchwork.kernel.org/project/netdevbpf/patch/20220723164635.1621911-1-vladimir.oltean@nxp.com/
      
      v2 at
      https://patchwork.kernel.org/project/netdevbpf/patch/20220729132119.1191227-5-vladimir.oltean@nxp.com/
      
      v3 at
      https://patchwork.kernel.org/project/netdevbpf/cover/20220806141059.2498226-1-vladimir.oltean@nxp.com/
      ====================
      
      Link: https://lore.kernel.org/r/20220818115500.2592578-1-vladimir.oltean@nxp.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      706447f0
    • Vladimir Oltean's avatar
      net: dsa: make phylink-related OF properties mandatory on DSA and CPU ports · e09e9873
      Vladimir Oltean authored
      Early DSA drivers were kind of simplistic in that they assumed a fairly
      narrow hardware layout. User ports would have integrated PHYs at an
      internal MDIO address that is derivable from the port number, and shared
      (DSA and CPU) ports would have an MII-style (serial or parallel)
      connection to another MAC. Phylib and then phylink were used to drive
      the internal PHYs, and this needed little to no description through the
      platform data structures. Bringing up the shared ports at the maximum
      supported link speed was the responsibility of the drivers.
      
      As a result of this, when these early drivers were converted from
      platform data to the new DSA OF bindings, there was no link information
      translated into the first DT bindings.
      
      https://lore.kernel.org/all/YtXFtTsf++AeDm1l@lunn.ch/
      
      Later, phylink was adopted for shared ports as well, and today we have a
      workaround in place, introduced by commit a20f9970 ("net: dsa: Don't
      instantiate phylink for CPU/DSA ports unless needed"). There, DSA checks
      for the presence of phy-handle/fixed-link/managed OF properties, and if
      missing, phylink registration would be skipped. This is because phylink
      is optional for some drivers (the shared ports already work without it),
      but the process of starting to register a port with phylink is
      irreversible: if phylink_create() fails to find the fwnode properties it
      needs, it bails out and it leaves the ports inoperational (because
      phylink expects ports to be initially down, so DSA necessarily takes
      them down, and doesn't know how to put them back up again).
      
      DSA being a common framework, new drivers opt into this workaround
      willy-nilly, but the ideal behavior from the DSA core's side would have
      been to not interfere with phylink's process of failing at all. This
      isn't possible because of regression concerns with pre-phylink DT blobs,
      but at least DSA should put a stop to the proliferation of more of such
      cases that rely on the workaround to skip phylink registration, and
      sanitize the environment that new drivers work in.
      
      To that end, create a list of compatible strings for which the
      workaround is preserved, and don't apply the workaround for any drivers
      outside that list (this includes new drivers).
      
      In some cases, we make the assumption that even existing drivers don't
      rely on DSA's workaround, and we do this by looking at the device trees
      in which they appear. We can't fully know what is the situation with
      downstream DT blobs, but we can guess the overall trend by studying the
      DT blobs that were submitted upstream. If there are upstream blobs that
      have lacking descriptions, we take it as very likely that there are many
      more downstream blobs that do so too. If all upstream blobs have
      complete descriptions, we take that as a hint that the driver is a
      candidate for enforcing strict DT bindings (considering that most
      bindings are copy-pasted). If there are no upstream DT blobs, we take
      the conservative route of allowing the workaround, unless the driver
      maintainer instructs us otherwise.
      
      The driver situation is as follows:
      
      ar9331
      ~~~~~~
      
          compatible strings:
          - qca,ar9331-switch
      
          1 occurrence in mainline device trees, part of SoC dtsi
          (arch/mips/boot/dts/qca/ar9331.dtsi), description is not problematic.
      
          Verdict: opt into strict DT bindings and out of workarounds.
      
      b53
      ~~~
      
          compatible strings:
          - brcm,bcm5325
          - brcm,bcm53115
          - brcm,bcm53125
          - brcm,bcm53128
          - brcm,bcm5365
          - brcm,bcm5389
          - brcm,bcm5395
          - brcm,bcm5397
          - brcm,bcm5398
      
          - brcm,bcm53010-srab
          - brcm,bcm53011-srab
          - brcm,bcm53012-srab
          - brcm,bcm53018-srab
          - brcm,bcm53019-srab
          - brcm,bcm5301x-srab
          - brcm,bcm11360-srab
          - brcm,bcm58522-srab
          - brcm,bcm58525-srab
          - brcm,bcm58535-srab
          - brcm,bcm58622-srab
          - brcm,bcm58623-srab
          - brcm,bcm58625-srab
          - brcm,bcm88312-srab
          - brcm,cygnus-srab
          - brcm,nsp-srab
          - brcm,omega-srab
      
          - brcm,bcm3384-switch
          - brcm,bcm6328-switch
          - brcm,bcm6368-switch
          - brcm,bcm63xx-switch
      
          I've found at least these mainline DT blobs with problems:
      
          arch/arm/boot/dts/bcm47094-linksys-panamera.dts
          - lacks phy-mode
          arch/arm/boot/dts/bcm47189-tenda-ac9.dts
          - lacks phy-mode and fixed-link
          arch/arm/boot/dts/bcm47081-luxul-xap-1410.dts
          arch/arm/boot/dts/bcm47081-luxul-xwr-1200.dts
          arch/arm/boot/dts/bcm47081-buffalo-wzr-600dhp2.dts
          - lacks phy-mode and fixed-link
          arch/arm/boot/dts/bcm47094-luxul-xbr-4500.dts
          arch/arm/boot/dts/bcm4708-smartrg-sr400ac.dts
          arch/arm/boot/dts/bcm4708-luxul-xap-1510.dts
          arch/arm/boot/dts/bcm953012er.dts
          arch/arm/boot/dts/bcm4708-netgear-r6250.dts
          arch/arm/boot/dts/bcm4708-buffalo-wzr-1166dhp-common.dtsi
          arch/arm/boot/dts/bcm4708-luxul-xwc-1000.dts
          arch/arm/boot/dts/bcm47094-luxul-abr-4500.dts
          - lacks phy-mode and fixed-link
          arch/arm/boot/dts/bcm53016-meraki-mr32.dts
          - lacks phy-mode
      
          Verdict: opt into DSA workarounds.
      
      bcm_sf2
      ~~~~~~~
      
          compatible strings:
          - brcm,bcm4908-switch
          - brcm,bcm7445-switch-v4.0
          - brcm,bcm7278-switch-v4.0
          - brcm,bcm7278-switch-v4.8
      
          A single occurrence in mainline
          (arch/arm64/boot/dts/broadcom/bcm4908/bcm4908.dtsi), part of a SoC
          dtsi, valid description. Florian Fainelli explains that most of the
          bcm_sf2 device trees lack a full description for the internal IMP
          ports.
      
          Verdict: opt the BCM4908 into strict DT bindings, and opt the rest
          into the workarounds. Note that even though BCM4908 has strict DT
          bindings, it still does not register with phylink on the IMP port
          due to it implementing ->adjust_link().
      
      hellcreek
      ~~~~~~~~~
      
          compatible strings:
          - hirschmann,hellcreek-de1soc-r1
      
          No occurrence in mainline device trees. Kurt Kanzenbach explains
          that the downstream device trees lacked phy-mode and fixed link, and
          needed work, but were fixed in the meantime.
      
          Verdict: opt into strict DT bindings and out of workarounds.
      
      lan9303
      ~~~~~~~
      
          compatible strings:
          - smsc,lan9303-mdio
          - smsc,lan9303-i2c
      
          1 occurrence in mainline device trees:
          arch/arm/boot/dts/imx53-kp-hsc.dts
          - no phy-mode, no fixed-link
      
          Verdict: opt out of strict DT bindings and into workarounds.
      
      lantiq_gswip
      ~~~~~~~~~~~~
      
          compatible strings:
          - lantiq,xrx200-gswip
          - lantiq,xrx300-gswip
          - lantiq,xrx330-gswip
      
          No occurrences in mainline device trees. Martin Blumenstingl
          confirms that the downstream OpenWrt device trees lack a proper
          fixed-link and need work, and that the incomplete description can
          even be seen in the example from
          Documentation/devicetree/bindings/net/dsa/lantiq-gswip.txt.
      
          Verdict: opt out of strict DT bindings and into workarounds.
      
      microchip ksz
      ~~~~~~~~~~~~~
      
          compatible strings:
          - microchip,ksz8765
          - microchip,ksz8794
          - microchip,ksz8795
          - microchip,ksz8863
          - microchip,ksz8873
          - microchip,ksz9477
          - microchip,ksz9897
          - microchip,ksz9893
          - microchip,ksz9563
          - microchip,ksz8563
          - microchip,ksz9567
          - microchip,lan9370
          - microchip,lan9371
          - microchip,lan9372
          - microchip,lan9373
          - microchip,lan9374
      
          5 occurrences in mainline device trees, all descriptions are valid.
          But we had a snafu for the ksz8795 and ksz9477 drivers where the
          phy-mode property would be expected to be located directly under the
          'switch' node rather than under a port OF node. It was fixed by
          commit edecfa98 ("net: dsa: microchip: look for phy-mode in port
          nodes"). The driver still has compatibility with the old DT blobs.
          The lan937x support was added later than the above snafu was fixed,
          and even though it has support for the broken DT blobs by virtue of
          sharing a common probing function, I'll take it that its DT blobs
          are correct.
      
          Verdict: opt lan937x into strict DT bindings, and the others out.
      
      mt7530
      ~~~~~~
      
          compatible strings
          - mediatek,mt7621
          - mediatek,mt7530
          - mediatek,mt7531
      
          Multiple occurrences in mainline device trees, one is part of an SoC
          dtsi (arch/mips/boot/dts/ralink/mt7621.dtsi), all descriptions are fine.
      
          Verdict: opt into strict DT bindings and out of workarounds.
      
      mv88e6060
      ~~~~~~~~~
      
          compatible string:
          - marvell,mv88e6060
      
          no occurrences in mainline, nobody knows anybody who uses it.
      
          Verdict: opt out of strict DT bindings and into workarounds.
      
      mv88e6xxx
      ~~~~~~~~~
      
          compatible strings:
          - marvell,mv88e6085
          - marvell,mv88e6190
          - marvell,mv88e6250
      
          Device trees that have incomplete descriptions of CPU or DSA ports:
          arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi
          - lacks phy-mode
          arch/arm64/boot/dts/marvell/cn9130-crb.dtsi
          - lacks phy-mode and fixed-link
          arch/arm/boot/dts/vf610-zii-ssmb-spu3.dts
          - lacks phy-mode
          arch/arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts
          - lacks phy-mode
          arch/arm/boot/dts/vf610-zii-spb4.dts
          - lacks phy-mode
          arch/arm/boot/dts/vf610-zii-cfu1.dts
          - lacks phy-mode
          arch/arm/boot/dts/vf610-zii-dev-rev-c.dts
          - lacks phy-mode on CPU port, fixed-link on DSA ports
          arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
          - lacks phy-mode on CPU port
          arch/arm/boot/dts/armada-381-netgear-gs110emx.dts
          - lacks phy-mode
          arch/arm/boot/dts/vf610-zii-scu4-aib.dts
          - lacks fixed-link on xgmii DSA ports and/or in-band-status on
            2500base-x DSA ports, and phy-mode on CPU port
          arch/arm/boot/dts/imx6qdl-gw5904.dtsi
          - lacks phy-mode and fixed-link
          arch/arm/boot/dts/armada-385-clearfog-gtr-l8.dts
          - lacks phy-mode and fixed-link
          arch/arm/boot/dts/vf610-zii-ssmb-dtu.dts
          - lacks phy-mode
          arch/arm/boot/dts/kirkwood-dir665.dts
          - lacks phy-mode
          arch/arm/boot/dts/kirkwood-rd88f6281.dtsi
          - lacks phy-mode
          arch/arm/boot/dts/orion5x-netgear-wnr854t.dts
          - lacks phy-mode and fixed-link
          arch/arm/boot/dts/armada-388-clearfog.dts
          - lacks phy-mode
          arch/arm/boot/dts/armada-xp-linksys-mamba.dts
          - lacks phy-mode
          arch/arm/boot/dts/armada-385-linksys.dtsi
          - lacks phy-mode
          arch/arm/boot/dts/imx6q-b450v3.dts
          arch/arm/boot/dts/imx6q-b850v3.dts
          - has a phy-handle but not a phy-mode?
          arch/arm/boot/dts/armada-370-rd.dts
          - lacks phy-mode
          arch/arm/boot/dts/kirkwood-linksys-viper.dts
          - lacks phy-mode
          arch/arm/boot/dts/imx51-zii-rdu1.dts
          - lacks phy-mode
          arch/arm/boot/dts/imx51-zii-scu2-mezz.dts
          - lacks phy-mode
          arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
          - lacks phy-mode
          arch/arm/boot/dts/armada-385-clearfog-gtr-s4.dts
          - lacks phy-mode and fixed-link
      
          Verdict: opt out of strict DT bindings and into workarounds.
      
      ocelot
      ~~~~~~
      
          compatible strings:
          - mscc,vsc9953-switch
          - felix (arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi) is a PCI
            device, has no compatible string
      
          2 occurrences in mainline, both are part of SoC dtsi and complete.
      
          Verdict: opt into strict DT bindings and out of workarounds.
      
      qca8k
      ~~~~~
      
          compatible strings:
          - qca,qca8327
          - qca,qca8328
          - qca,qca8334
          - qca,qca8337
      
          5 occurrences in mainline device trees, none of the descriptions are
          problematic.
      
          Verdict: opt into strict DT bindings and out of workarounds.
      
      realtek
      ~~~~~~~
      
          compatible strings:
          - realtek,rtl8366rb
          - realtek,rtl8365mb
      
          2 occurrences in mainline, both descriptions are fine, additionally
          rtl8365mb.c has a comment "The device tree firmware should also
          specify the link partner of the extension port - either via a
          fixed-link or other phy-handle."
      
          Verdict: opt into strict DT bindings and out of workarounds.
      
      rzn1_a5psw
      ~~~~~~~~~~
      
          compatible strings:
          - renesas,rzn1-a5psw
      
          One single occurrence, part of SoC dtsi
          (arch/arm/boot/dts/r9a06g032.dtsi), description is fine.
      
          Verdict: opt into strict DT bindings and out of workarounds.
      
      sja1105
      ~~~~~~~
      
          Driver already validates its port OF nodes in
          sja1105_parse_ports_node().
      
          Verdict: opt into strict DT bindings and out of workarounds.
      
      vsc73xx
      ~~~~~~~
      
          compatible strings:
          - vitesse,vsc7385
          - vitesse,vsc7388
          - vitesse,vsc7395
          - vitesse,vsc7398
      
          2 occurrences in mainline device trees, both descriptions are fine.
      
          Verdict: opt into strict DT bindings and out of workarounds.
      
      xrs700x
      ~~~~~~~
      
          compatible strings:
          - arrow,xrs7003e
          - arrow,xrs7003f
          - arrow,xrs7004e
          - arrow,xrs7004f
      
          no occurrences in mainline, we don't know.
      
          Verdict: opt out of strict DT bindings and into workarounds.
      
      Because there is a pattern where newly added switches reuse existing
      drivers more often than introducing new ones, I've opted for deciding
      who gets to opt into the workaround based on an OF compatible match
      table in the DSA core. The alternative would have been to add another
      boolean property to struct dsa_switch, like configure_vlan_while_not_filtering.
      But this avoids situations where sometimes driver maintainers obfuscate
      what goes on by sharing a common probing function, and therefore making
      new switches inherit old quirks.
      
      Side note, we also warn about missing properties for drivers that rely
      on the workaround. This isn't an indication that we'll break
      compatibility with those DT blobs any time soon, but is rather done to
      raise awareness about the change, for future DT blob authors.
      
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Acked-by: Alvin Šipraga <alsi@bang-olufsen.dk> # realtek
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      e09e9873
    • Vladimir Oltean's avatar
      net: dsa: rename dsa_port_link_{,un}register_of · 770375ff
      Vladimir Oltean authored
      There is a subset of functions that applies only to shared (DSA and CPU)
      ports, yet this is difficult to comprehend by looking at their code alone.
      These are dsa_port_link_register_of(), dsa_port_link_unregister_of(),
      and the functions that only these 2 call.
      
      Rename this class of functions to dsa_shared_port_* to make this fact
      more evident, even if this goes against the apparent convention that
      function names in port.c must start with dsa_port_.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      770375ff
    • Vladimir Oltean's avatar
      net: dsa: avoid dsa_port_link_{,un}register_of() calls with platform data · da2c398e
      Vladimir Oltean authored
      dsa_port_link_register_of() and dsa_port_link_unregister_of() are not
      written with the fact in mind that they can be called with a dp->dn that
      is NULL (as evidenced even by the _of suffix in their name), but this is
      exactly what happens.
      
      How this behaves will differ depending on whether the backing driver
      implements ->adjust_link() or not.
      
      If it doesn't, the "if (of_phy_is_fixed_link(dp->dn) || phy_np)"
      condition will return false, and dsa_port_link_register_of() will do
      nothing and return 0.
      
      If the driver does implement ->adjust_link(), the
      "if (of_phy_is_fixed_link(dp->dn))" condition will return false
      (dp->dn is NULL) and we will call dsa_port_setup_phy_of(). This will
      call dsa_port_get_phy_device(), which will also return NULL, and we will
      also do nothing and return 0.
      
      It is hard to maintain this code and make future changes to it in this
      state, so just suppress calls to these 2 functions if dp->dn is NULL.
      The only functional effect is that if the driver does implement
      ->adjust_link(), we'll stop printing this to the console:
      
      Using legacy PHYLIB callbacks. Please migrate to PHYLINK!
      
      but instead we'll always print:
      
      [    8.539848] dsa-loop fixed-0:1f: skipping link registration for CPU port 5
      
      This is for the better anyway, since "using legacy phylib callbacks"
      was misleading information - we weren't issuing _any_ callbacks due to
      dsa_port_get_phy_device() returning NULL.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      da2c398e
    • Vladimir Oltean's avatar
      of: base: export of_device_compatible_match() for use in modules · df55e317
      Vladimir Oltean authored
      Modules such as net/dsa/dsa_core.ko might want to iterate through an
      array of compatible strings for things such as validation (or rather,
      skipping it for some potentially broken drivers).
      
      of_device_is_compatible() is exported, by of_device_compatible_match()
      isn't. Export the latter as well, so we don't have to open-code the
      iteration.
      
      Cc: Frank Rowand <frowand.list@gmail.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      df55e317
    • Vladimir Oltean's avatar
      dt-bindings: net: dsa: make phylink bindings required for CPU/DSA ports · 2ec2fb83
      Vladimir Oltean authored
      It is desirable that new DSA drivers are written to expect that all
      their ports register with phylink, and not rely on the DSA core's
      workarounds to skip this process.
      
      To that end, DSA is being changed to warn existing drivers when such DT
      blobs are in use, and to opt new drivers out of the workarounds.
      
      Introduce another layer of validation in the DSA DT schema, and assert
      that CPU and DSA ports must have phylink-related properties present.
      Suggested-by: default avatarRob Herring <robh+dt@kernel.org>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      2ec2fb83
    • Vladimir Oltean's avatar
      dt-bindings: net: dsa: rzn1-a5psw: add missing CPU port phy-mode to example · f3c8168f
      Vladimir Oltean authored
      To prevent warnings during "make dt_bindings_check" after dsa-port.yaml
      will make phylink properties mandatory, add phy-mode = "internal" to the
      example.
      
      This new property is taken straight out of the SoC dtsi at
      arch/arm/boot/dts/r9a06g032.dtsi, so it seems likely that only the
      example needs to be fixed, rather than DT blobs in circulation.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f3c8168f
    • Vladimir Oltean's avatar
      dt-bindings: net: dsa: microchip: add missing CPU port phy-mode to example · 2401bd95
      Vladimir Oltean authored
      The ksz_switch_chips[] element for KSZ9477 says that port 5 is an xMII
      port and it supports speeds of 10/100/1000. The device tree example does
      declare a fixed-link at 1000, and RGMII is the only one of those modes
      that supports this speed, so use this phy-mode.
      
      The microchip,ksz8565 compatible string is not supported by the
      microchip driver, however on Microchip's product page it says that there
      are 5 ports, 4 of which have internal PHYs and the 5th is an
      MII/RMII/RGMII port. It's a bit strange that this is port@6, but it is
      probably just the way it is. Select an RGMII phy-mode for this one as
      well.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      2401bd95
    • Vladimir Oltean's avatar
      dt-bindings: net: dsa: b53: add missing CPU port phy-mode to example · 526512f6
      Vladimir Oltean authored
      Looking at b53_srab_phylink_get_caps() I get no indication of what PHY
      modes does port 8 support, since it is implemented circularly based on
      the p->mode retrieved from the device tree (and in PHY_INTERFACE_MODE_NA
      it reports nothing to supported_interfaces).
      
      However if I look at the b53_switch_chips[] element for BCM58XX_DEVICE_ID,
      I see that port 8 is the IMP port, and SRAB means the IMP port is
      internal to the SoC. So use phy-mode = "internal" in the example.
      
      Note that this will make b53_srab_phylink_get_caps() go through the
      "default" case and report PHY_INTERFACE_MODE_INTERNAL to
      supported_interfaces, which is probably a good thing.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      526512f6
    • Vladimir Oltean's avatar
      dt-bindings: net: dsa: hellcreek: add missing CPU port phy-mode/fixed-link to example · b975b734
      Vladimir Oltean authored
      Looking at hellcreek_phylink_get_caps(), I see that depending on whether
      is_100_mbits is set, speeds of 1G or of 100M will be advertised. The
      de1soc_r1_pdata sets is_100_mbits to true.
      
      The PHY modes declared in the capabilities are MII, RGMII and GMII. GMII
      doesn't support 100Mbps, and as for RGMII, it would be a bit implausible
      to me to support this PHY mode but limit it to only 25 MHz. So I've
      settled on MII as a phy-mode in the example, and a fixed-link of
      100Mbps.
      
      As a side note, there exists such a thing as "rev-mii", because the MII
      protocol is asymmetric, and "mii" is the designation for the MAC side
      (expected to be connected to a PHY), and "rev-mii" is the designation
      for the PHY side (expected to be connected to a MAC). I wonder whether
      "mii" or "rev-mii" should actually be used here, since this is a CPU
      port and presumably connected to another MAC.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Reviewed-by: Kurt Kanzenbach's avatarKurt Kanzenbach <kurt@linutronix.de>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b975b734
    • Vladimir Oltean's avatar
      dt-bindings: net: dsa: xrs700x: add missing CPU port phy-mode to example · b2376760
      Vladimir Oltean authored
      Judging by xrs700x_phylink_get_caps(), I deduce that this switch
      supports the RGMII modes on port 3, so state this phy-mode in the
      example, such that users are encouraged to not rely on avoiding phylink
      for this port.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b2376760
  2. 22 Aug, 2022 19 commits