1. 14 Dec, 2021 10 commits
    • David S. Miller's avatar
      Merge branch 'dsa-fixups' · 256f8d72
      David S. Miller authored
      Vladimir Oltean says:
      
      ====================
      DSA tagger-owned storage fixups
      
      It seems that the DSA tagger-owned storage changes were insufficiently
      tested and do not work in all cases. Specifically, the NXP Bluebox 3
      (arch/arm64/boot/dts/freescale/fsl-lx2160a-bluebox3.dts) got broken by
      these changes, because
      (a) I forgot that DSA_TAG_PROTO_SJA1110 exists and differs from
          DSA_TAG_PROTO_SJA1105
      (b) the Bluebox 3 uses a DSA switch tree with 2 switches, and the
          tagger-owned storage patches don't cover that use case well, it
          seems
      
      Therefore, I'm sorry to say that there needs to be an API fixup: tagging
      protocol drivers will from now on connect to individual switches from a
      tree, rather than to the tree as a whole. This is more robust against
      various ordering constraints in the DSA probe and teardown paths, and is
      also symmetrical with the connection API exposed to the switch drivers
      themselves, which is also per switch.
      
      With these changes, the Bluebox 3 also works fine.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      256f8d72
    • Vladimir Oltean's avatar
      net: dsa: make tagging protocols connect to individual switches from a tree · 7f297314
      Vladimir Oltean authored
      On the NXP Bluebox 3 board which uses a multi-switch setup with sja1105,
      the mechanism through which the tagger connects to the switch tree is
      broken, due to improper DSA code design. At the time when tag_ops->connect()
      is called in dsa_port_parse_cpu(), DSA hasn't finished "touching" all
      the ports, so it doesn't know how large the tree is and how many ports
      it has. It has just seen the first CPU port by this time. As a result,
      this function will call the tagger's ->connect method too early, and the
      tagger will connect only to the first switch from the tree.
      
      This could be perhaps addressed a bit more simply by just moving the
      tag_ops->connect(dst) call a bit later (for example in dsa_tree_setup),
      but there is already a design inconsistency at present: on the switch
      side, the notification is on a per-switch basis, but on the tagger side,
      it is on a per-tree basis. Furthermore, the persistent storage itself is
      per switch (ds->tagger_data). And the tagger connect and disconnect
      procedures (at least the ones that exist currently) could see a fair bit
      of simplification if they didn't have to iterate through the switches of
      a tree.
      
      To fix the issue, this change transforms tag_ops->connect(dst) into
      tag_ops->connect(ds) and moves it somewhere where we already iterate
      over all switches of a tree. That is in dsa_switch_setup_tag_protocol(),
      which is a good placement because we already have there the connection
      call to the switch side of things.
      
      As for the dsa_tree_bind_tag_proto() method (called from the code path
      that changes the tag protocol), things are a bit more complicated
      because we receive the tree as argument, yet when we unwind on errors,
      it would be nice to not call tag_ops->disconnect(ds) where we didn't
      previously call tag_ops->connect(ds). We didn't have this problem before
      because the tag_ops connection operations passed the entire dst before,
      and this is more fine grained now. To solve the error rewind case using
      the new API, we have to create yet one more cross-chip notifier for
      disconnection, and stay connected with the old tag protocol to all the
      switches in the tree until we've succeeded to connect with the new one
      as well. So if something fails half way, the whole tree is still
      connected to the old tagger. But there may still be leaks if the tagger
      fails to connect to the 2nd out of 3 switches in a tree: somebody needs
      to tell the tagger to disconnect from the first switch. Nothing comes
      for free, and this was previously handled privately by the tagging
      protocol driver before, but now we need to emit a disconnect cross-chip
      notifier for that, because DSA has to take care of the unwind path. We
      assume that the tagging protocol has connected to a switch if it has set
      ds->tagger_data to something, otherwise we avoid calling its
      disconnection method in the error rewind path.
      
      The rest of the changes are in the tagging protocol drivers, and have to
      do with the replacement of dst with ds. The iteration is removed and the
      error unwind path is simplified, as mentioned above.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7f297314
    • Vladimir Oltean's avatar
      net: dsa: sja1105: fix broken connection with the sja1110 tagger · c8a2a011
      Vladimir Oltean authored
      The driver was incorrectly converted assuming that "sja1105" is the only
      tagger supported by this driver. This results in SJA1110 switches
      failing to probe:
      
      sja1105 spi1.0: Unable to connect to tag protocol "sja1110": -EPROTONOSUPPORT
      sja1105: probe of spi1.2 failed with error -93
      
      Add DSA_TAG_PROTO_SJA1110 to the list of supported taggers by the
      sja1105 driver. The sja1105_tagger_data structure format is common for
      the two tagging protocols.
      
      Fixes: c79e8486 ("net: dsa: tag_sja1105: convert to tagger-owned data")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c8a2a011
    • Vladimir Oltean's avatar
      net: dsa: tag_sja1105: fix zeroization of ds->priv on tag proto disconnect · e2f01bfe
      Vladimir Oltean authored
      The method was meant to zeroize ds->tagger_data but got the wrong
      pointer. Fix this.
      
      Fixes: c79e8486 ("net: dsa: tag_sja1105: convert to tagger-owned data")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e2f01bfe
    • Guillaume Nault's avatar
      bareudp: Add extack support to bareudp_configure() · b4bffa4c
      Guillaume Nault authored
      Add missing extacks for common configuration errors.
      Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b4bffa4c
    • Jakub Kicinski's avatar
      ethtool: fix null-ptr-deref on ref tracker · 0976b888
      Jakub Kicinski authored
      dev can be a NULL here, not all requests set require_dev.
      
      Fixes: e4b89540 ("netlink: add net device refcount tracker to struct ethnl_req_info")
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0976b888
    • Sebastian Andrzej Siewior's avatar
      net: dev: Change the order of the arguments for the contended condition. · a9aa5e33
      Sebastian Andrzej Siewior authored
      Change the order of arguments and make qdisc_is_running() appear first.
      This is more readable for the general case.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a9aa5e33
    • David S. Miller's avatar
      Merge branch 'hwtstamp_bonding' · d0c3e464
      David S. Miller authored
      Hangbin Liu says:
      
      ====================
      net: add new hwtstamp flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
      
      This patchset add a new hwtstamp_config flag HWTSTAMP_FLAG_BONDED_PHC_INDEX.
      When user want to get bond active interface's PHC, they need to add this flag
      and aware the PHC index may changed.
      
      v3: Use bitwise test to check the flags validation
      v2: rename the flag to HWTSTAMP_FLAG_BONDED_PHC_INDEX
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d0c3e464
    • Hangbin Liu's avatar
      Bonding: force user to add HWTSTAMP_FLAG_BONDED_PHC_INDEX when get/set HWTSTAMP · 085d6100
      Hangbin Liu authored
      When there is a failover, the PHC index of bond active interface will be
      changed. This may break the user space program if the author didn't aware.
      
      By setting this flag, the user should aware that the PHC index get/set
      by syscall is not stable. And the user space is able to deal with it.
      Without this flag, the kernel will reject the request forwarding to
      bonding.
      Reported-by: default avatarJakub Kicinski <kuba@kernel.org>
      Fixes: 94dd016a ("bond: pass get_ts_info and SIOC[SG]HWTSTAMP ioctl to active device")
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      085d6100
    • Hangbin Liu's avatar
      net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX · 9c9211a3
      Hangbin Liu authored
      Since commit 94dd016a ("bond: pass get_ts_info and SIOC[SG]HWTSTAMP
      ioctl to active device") the user could get bond active interface's
      PHC index directly. But when there is a failover, the bond active
      interface will change, thus the PHC index is also changed. This may
      break the user's program if they did not update the PHC timely.
      
      This patch adds a new hwtstamp_config flag HWTSTAMP_FLAG_BONDED_PHC_INDEX.
      When the user wants to get the bond active interface's PHC, they need to
      add this flag and be aware the PHC index may be changed.
      
      With the new flag. All flag checks in current drivers are removed. Only
      the checking in net_hwtstamp_validate() is kept.
      Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9c9211a3
  2. 13 Dec, 2021 23 commits
  3. 12 Dec, 2021 7 commits
    • David S. Miller's avatar
      Merge branch 'dsa-tagger-storage' · 9b5bcb19
      David S. Miller authored
      Vladimir Oltean says:
      
      ====================
      Replace DSA dp->priv with tagger-owned storage
      
      Ansuel's recent work on qca8k register access over Ethernet:
      https://patchwork.kernel.org/project/netdevbpf/cover/20211207145942.7444-1-ansuelsmth@gmail.com/
      has triggered me to do something which I should've done for a longer
      time:
      https://patchwork.kernel.org/project/netdevbpf/patch/20211109095013.27829-7-martin.kaistra@linutronix.de/#24585521
      which is to replace dp->priv with something that has less caveats.
      
      The dp->priv was introduced when sja1105 needed to hold stateful
      information in the tagging protocol driver. In that design, dp->priv
      held memory allocated by the switch driver, because the tagging protocol
      driver design was 100% stateless.
      
      Some years have passed and others have started to feel the need for
      stateful information kept by the tagger, as well as passing data back
      and forth between the tagging protocol driver and the switch driver.
      This isn't possible cleanly in DSA due to a circular dependency which
      leads to broken module autoloading:
      https://lore.kernel.org/netdev/20210908220834.d7gmtnwrorhharna@skbuf/
      
      This patchset introduces a framework that resembles something normal,
      which allows data to be passed from the tagging protocol driver (things
      like switch management packets, which aren't intended for the network
      stack) to the switch driver, while the tagging protocol still remains
      more or less stateless. The overall design of the framework was
      discussed with Ansuel too and it appears to be flexible enough to cover
      the "register access over Ethernet" use case. Additionally, the existing
      uses of dp->priv, which have mainly to do with PTP timestamping, have
      also been migrated.
      
      Changes in v2:
      Fix transient build breakage in patch 5/11 due to a missing parenthesis,
      https://patchwork.hopto.org/static/nipa/592567/12665213/build_clang/
      and another transient build warning in patch 4/11 that for some reason
      doesn't appear in my W=1 C=1 build.
      https://patchwork.hopto.org/static/nipa/592567/12665209/build_clang/stderr
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9b5bcb19
    • Vladimir Oltean's avatar
      net: dsa: remove dp->priv · 4f3cb343
      Vladimir Oltean authored
      All current in-tree uses of dp->priv have been replaced with
      ds->tagger_data, which provides for a safer API especially when the
      connection isn't the regular 1:1 link between one switch driver and one
      tagging protocol driver, but could be either one switch to many taggers,
      or many switches to one tagger.
      
      Therefore, we can remove this unused pointer.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4f3cb343
    • Vladimir Oltean's avatar
      net: dsa: tag_sja1105: split sja1105_tagger_data into private and public sections · 950a419d
      Vladimir Oltean authored
      The sja1105 driver messes with the tagging protocol's state when PTP RX
      timestamping is enabled/disabled. This is fundamentally necessary
      because the tagger needs to know what to do when it receives a PTP
      packet. If RX timestamping is enabled, then a metadata follow-up frame
      is expected, and this holds the (partial) timestamp. So the tagger plays
      hide-and-seek with the network stack until it also gets the metadata
      frame, and then presents a single packet, the timestamped PTP packet.
      But when RX timestamping isn't enabled, there is no metadata frame
      expected, so the hide-and-seek game must be turned off and the packet
      must be delivered right away to the network stack.
      
      Considering this, we create a pseudo isolation by devising two tagger
      methods callable by the switch: one to get the RX timestamping state,
      and one to set it. Since we can't export symbols between the tagger and
      the switch driver, these methods are exposed through function pointers.
      
      After this change, the public portion of the sja1105_tagger_data
      contains only function pointers.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      950a419d
    • Vladimir Oltean's avatar
      Revert "net: dsa: move sja1110_process_meta_tstamp inside the tagging protocol driver" · fcbf979a
      Vladimir Oltean authored
      This reverts commit 6d709cad.
      
      The above change was done to avoid calling symbols exported by the
      switch driver from the tagging protocol driver.
      
      With the tagger-owned storage model, we have a new option on our hands,
      and that is for the switch driver to provide a data consumer handler in
      the form of a function pointer inside the ->connect_tag_protocol()
      method. Having a function pointer avoids the problems of the exported
      symbols approach.
      
      By creating a handler for metadata frames holding TX timestamps on
      SJA1110, we are able to eliminate an skb queue from the tagger data, and
      replace it with a simple, and stateless, function pointer. This skb
      queue is now handled exclusively by sja1105_ptp.c, which makes the code
      easier to follow, as it used to be before the reverted patch.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fcbf979a
    • Vladimir Oltean's avatar
      net: dsa: tag_sja1105: convert to tagger-owned data · c79e8486
      Vladimir Oltean authored
      Currently, struct sja1105_tagger_data is a part of struct
      sja1105_private, and is used by the sja1105 driver to populate dp->priv.
      
      With the movement towards tagger-owned storage, the sja1105 driver
      should not be the owner of this memory.
      
      This change implements the connection between the sja1105 switch driver
      and its tagging protocol, which means that sja1105_tagger_data no longer
      stays in dp->priv but in ds->tagger_data, and that the sja1105 driver
      now only populates the sja1105_port_deferred_xmit callback pointer.
      The kthread worker is now the responsibility of the tagger.
      
      The sja1105 driver also alters the tagger's state some more, especially
      with regard to the PTP RX timestamping state. This will be fixed up a
      bit in further changes.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c79e8486
    • Vladimir Oltean's avatar
      net: dsa: sja1105: move ts_id from sja1105_tagger_data · 22ee9f8e
      Vladimir Oltean authored
      The TX timestamp ID is incremented by the SJA1110 PTP timestamping
      callback (->port_tx_timestamp) for every packet, when cloning it.
      It isn't used by the tagger at all, even though it sits inside the
      struct sja1105_tagger_data.
      
      Also, serialization to this structure is currently done through
      tagger_data->meta_lock, which is a cheap hack because the meta_lock
      isn't used for anything else on SJA1110 (sja1105_rcv_meta_state_machine
      isn't called).
      
      This change moves ts_id from sja1105_tagger_data to sja1105_private and
      introduces a dedicated spinlock for it, also in sja1105_private.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      22ee9f8e
    • Vladimir Oltean's avatar
      net: dsa: sja1105: make dp->priv point directly to sja1105_tagger_data · bfcf1425
      Vladimir Oltean authored
      The design of the sja1105 tagger dp->priv is that each port has a
      separate struct sja1105_port, and the sp->data pointer points to a
      common struct sja1105_tagger_data.
      
      We have removed all per-port members accessible by the tagger, and now
      only struct sja1105_tagger_data remains. Make dp->priv point directly to
      this.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bfcf1425