1. 29 6月, 2019 3 次提交
  2. 28 6月, 2019 6 次提交
    • V
      net: dsa: sja1105: Implement is_static for FDB entries on E/T · d7637782
      Vladimir Oltean 提交于
      The first generation switches don't tell us through the dynamic config
      interface whether the dumped FDB entries are static or not (the LOCKEDS
      bit from P/Q/R/S).
      
      However, now that we're keeping a mirror of all 'bridge fdb' commands in
      the static config, this is an opportunity to compare a dumped FDB entry
      to the driver's private database.  After all, what makes an entry static
      is that *we* added it.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d7637782
    • V
      net: dsa: sja1105: Use correct dsa_8021q VIDs for FDB commands · b3ee526a
      Vladimir Oltean 提交于
      A FDB entry means that "frames that match this VID and DMAC must be
      forwarded to this port".
      
      In the case of dsa_8021q however, the VID is not a single one (and
      neither two, as my previous patch assumed). The VID can be set either by
      the CPU port (1 tx_vid), or by any of the other front-panel port (n-1
      rx_vid's).
      
      Fixes: 93647594 ("net: dsa: sja1105: Hide the dsa_8021q VLANs from the bridge fdb command")
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b3ee526a
    • V
      net: dsa: sja1105: Populate is_static for FDB entries on P/Q/R/S · 17ae6555
      Vladimir Oltean 提交于
      The reason why this wasn't tackled earlier is that I had hoped I
      understood the user manual wrong.  But unfortunately hacks are required
      in order to retrieve the static/dynamic nature of FDB entries on SJA1105
      P/Q/R/S, since this info is stored in the writeback buffer of the
      dynamic config command.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      17ae6555
    • V
      net: dsa: sja1105: Back up static FDB entries in kernel memory · 60f6053f
      Vladimir Oltean 提交于
      After commit 8456721d ("net: dsa: sja1105: Add support for
      configuring address ageing time"), we started to reset the switch rather
      often (each time the bridge core changes the ageing time on a switch
      port).
      
      The unfortunate reality is that SJA1105 doesn't have any {cold, warm,
      whatever} reset mode in which it accepts a new configuration stream
      without flushing the FDB.  Instead, in its world, the FDB *is* an
      optional part of the static configuration.
      
      So we play its game, and do what we also do for VLANs: for each 'bridge
      fdb' command, we add the FDB entry through the dynamic interface, and we
      append the in-kernel static config memory with info that we're going to
      use later, when the next reset command is going to be issued.
      
      The result is that 'bridge fdb' commands are now persistent (dynamically
      learned entries are lost, but that's ok).
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      60f6053f
    • V
      net: dsa: sja1105: Make P/Q/R/S learn MAC addresses · 6c56e167
      Vladimir Oltean 提交于
      At the end of the commit 1da73821 ("net: dsa: sja1105: Add FDB
      operations for P/Q/R/S series") message, I said that:
      
          At the moment only FDB entries installed statically through 'bridge fdb'
          are visible in the dump callback - the dynamically learned ones are
          still under investigation.
      
      It looks like the reason why they were not visible in 'bridge fdb' was
      that they were never learned - always flooded.
      
      SJA1105 P/Q/R/S manual says about the MAXADDRP[port] field:
      
          Specify the maximum number of MAC address dynamically learned from
          the respective port. It is used to limit the number of learned MAC
          addresses per port.
      
      It looks like not providing a value in the static config (aka providing
      zeroes) is enough for it to not store the learned addresses in the FDB.
      
      For now we divide the 1024 entry FDB "equally" amongst the 5 ports. This
      may be revisited if the situation calls for that - for now I'm happy
      that learning works.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6c56e167
    • V
      net: dsa: sja1105: Make vid 1 the default pvid · e3502b82
      Vladimir Oltean 提交于
      In SJA1105 there is no concept of 'default values' per se, everything
      needs to be driver-supplied through the static configuration tables.
      
      The issue is that the hardware manual says that 'at least the default
      untagging VLAN' is mandatory to be provided through the static config.
      But VLAN 0 isn't a very good initial pvid - its use is reserved for
      priority-tagged frames, and the layers of the stack that care about
      those already make sure that this VLAN is installed, as can be seen in
      the message below:
      
        8021q: adding VLAN 0 to HW filter on device swp2
      
      So change the pvid provided through the static configuration to 1, which
      matches the bridge core's defaults.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e3502b82
  3. 14 6月, 2019 1 次提交
  4. 10 6月, 2019 3 次提交
  5. 09 6月, 2019 10 次提交
    • V
      net: dsa: sja1105: Expose PTP timestamping ioctls to userspace · a602afd2
      Vladimir Oltean 提交于
      This enables the PTP support towards userspace applications such as
      linuxptp.
      
      The switches can timestamp only trapped multicast MAC frames, and
      therefore only the profiles of 1588 over L2 are supported.
      
      TX timestamping can be enabled per port, but RX timestamping is enabled
      globally. As long as RX timestamping is enabled, the switch will emit
      metadata follow-up frames that will be processed by the tagger. It may
      be a problem that linuxptp does not restore the RX timestamping settings
      when exiting.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a602afd2
    • V
      net: dsa: sja1105: Add a state machine for RX timestamping · f3097be2
      Vladimir Oltean 提交于
      Meta frame reception relies on the hardware keeping its promise that it
      will send no other traffic towards the CPU port between a link-local
      frame and a meta frame.  Otherwise there is no other way to associate
      the meta frame with the link-local frame it's holding a timestamp of.
      The receive function is made stateful, and buffers a timestampable frame
      until its meta frame arrives, then merges the two, drops the meta and
      releases the link-local frame up the stack.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f3097be2
    • V
      net: dsa: sja1105: Increase priority of CPU-trapped frames · 08fde09a
      Vladimir Oltean 提交于
      Without noticing any particular issue, this patch ensures that
      management traffic is treated with the maximum priority on RX by the
      switch.  This is generally desirable, as the driver keeps a state
      machine that waits for metadata follow-up frames as soon as a management
      frame is received.  Increasing the priority helps expedite the reception
      (and further reconstruction) of the RX timestamp to the driver after the
      MAC has generated it.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      08fde09a
    • V
      net: dsa: sja1105: Add a global sja1105_tagger_data structure · 844d7edc
      Vladimir Oltean 提交于
      This will be used to keep state for RX timestamping. It is global
      because the switch serializes timestampable and meta frames when
      trapping them towards the CPU port (lower port indices have higher
      priority) and therefore having one state machine per port would create
      unnecessary complications.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      844d7edc
    • V
      net: dsa: sja1105: Add support for the AVB Parameters Table · 24c01949
      Vladimir Oltean 提交于
      This table is used to program the switch to emit "meta" follow-up
      Ethernet frames (which contain partial RX timestamps) after each
      link-local frame that was trapped to the CPU port through MAC filtering.
      This includes PTP frames.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      24c01949
    • V
      net: dsa: sja1105: Add logic for TX timestamping · 47ed985e
      Vladimir Oltean 提交于
      On TX, timestamping is performed synchronously from the
      port_deferred_xmit worker thread.
      In management routes, the switch is requested to take egress timestamps
      (again partial), which are reconstructed and appended to a clone of the
      skb that was just sent.  The cloning is done by DSA and we retrieve the
      pointer from the structure that DSA keeps in skb->cb.
      Then these clones are enqueued to the socket's error queue for
      application-level processing.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      47ed985e
    • V
      net: dsa: sja1105: Add support for the PTP clock · bb77f36a
      Vladimir Oltean 提交于
      The design of this PHC driver is influenced by the switch's behavior
      w.r.t. timestamping.  It exposes two PTP counters, one free-running
      (PTPTSCLK) and the other offset- and frequency-corrected in hardware
      through PTPCLKVAL, PTPCLKADD and PTPCLKRATE.  The MACs can sample either
      of these for frame timestamps.
      
      However, the user manual warns that taking timestamps based on the
      corrected clock is less than useful, as the switch can deliver corrupted
      timestamps in a variety of circumstances.
      
      Therefore, this PHC uses the free-running PTPTSCLK together with a
      timecounter/cyclecounter structure that translates it into a software
      time domain.  Thus, the settime/adjtime and adjfine callbacks are
      hardware no-ops.
      
      The timestamps (introduced in a further patch) will also be translated
      to the correct time domain before being handed over to the userspace PTP
      stack.
      
      The introduction of a second set of PHC operations that operate on the
      hardware PTPCLKVAL/PTPCLKADD/PTPCLKRATE in the future is somewhat
      unavoidable, as the TTEthernet core uses the corrected PTP time domain.
      However, the free-running counter + timecounter structure combination
      will suffice for now, as the resulting timestamps yield a sub-50 ns
      synchronization offset in steady state using linuxptp.
      
      For this patch, in absence of frame timestamping, the operations of the
      switch PHC were tested by syncing it to the system time as a local slave
      clock with:
      
      phc2sys -s CLOCK_REALTIME -c swp2 -O 0 -m -S 0.01
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bb77f36a
    • V
      net: dsa: sja1105: Limit use of incl_srcpt to bridge+vlan mode · 42824463
      Vladimir Oltean 提交于
      The incl_srcpt setting makes the switch mangle the destination MACs of
      multicast frames trapped to the CPU - a primitive tagging mechanism that
      works even when we cannot use the 802.1Q software features.
      
      The downside is that the two multicast MAC addresses that the switch
      traps for L2 PTP (01-80-C2-00-00-0E and 01-1B-19-00-00-00) quickly turn
      into a lot more, as the switch encodes the source port and switch id
      into bytes 3 and 4 of the MAC. The resulting range of MAC addresses
      would need to be installed manually into the DSA master port's multicast
      MAC filter, and even then, most devices might not have a large enough
      MAC filtering table.
      
      As a result, only limit use of incl_srcpt to when it's strictly
      necessary: when under a VLAN filtering bridge.  This fixes PTP in
      non-bridged mode (standalone ports). Otherwise, PTP frames, as well as
      metadata follow-up frames holding RX timestamps won't be received
      because they will be blocked by the master port's MAC filter.
      Linuxptp doesn't help, because it only requests the addition of the
      unmodified PTP MACs to the multicast filter.
      This issue is not seen in bridged mode because the master port is put in
      promiscuous mode when the slave ports are enslaved to a bridge.
      Therefore, there is no downside to having the incl_srcpt mechanism
      active there.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      42824463
    • V
      net: dsa: sja1105: Reverse TPID and TPID2 · f9a1a764
      Vladimir Oltean 提交于
      >From reading the P/Q/R/S user manual, it appears that TPID is used by
      the switch for detecting S-tags and TPID2 for C-tags.  Their meaning is
      not clear from the E/T manual.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f9a1a764
    • V
      net: dsa: sja1105: Move sja1105_change_tpid into sja1105_vlan_filtering · 070ca3bb
      Vladimir Oltean 提交于
      This is a cosmetic patch, pre-cursor to making another change to the
      General Parameters Table (incl_srcpt) which does not logically pertain
      to the sja1105_change_tpid function name, but not putting it there would
      otherwise create a need of resetting the switch twice.
      
      So simply move the existing code into the .port_vlan_filtering callback,
      where the incl_srcpt change will be added as well.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      070ca3bb
  6. 05 6月, 2019 7 次提交
  7. 30 5月, 2019 1 次提交
    • V
      net: dsa: sja1105: Fix broken fixed-link interfaces on user ports · af7cd036
      Vladimir Oltean 提交于
      PHYLIB and PHYLINK handle fixed-link interfaces differently. PHYLIB
      wraps them in a software PHY ("pseudo fixed link") phydev construct such
      that .adjust_link driver callbacks see an unified API. Whereas PHYLINK
      simply creates a phylink_link_state structure and passes it to
      .mac_config.
      
      At the time the driver was introduced, DSA was using PHYLIB for the
      CPU/cascade ports (the ones with no net devices) and PHYLINK for
      everything else.
      
      As explained below:
      
      commit aab9c406
      Author: Florian Fainelli <f.fainelli@gmail.com>
      Date:   Thu May 10 13:17:36 2018 -0700
      
        net: dsa: Plug in PHYLINK support
      
        Drivers that utilize fixed links for user-facing ports (e.g: bcm_sf2)
        will need to implement phylink_mac_ops from now on to preserve
        functionality, since PHYLINK *does not* create a phy_device instance
        for fixed links.
      
      In the above patch, DSA guards the .phylink_mac_config callback against
      a NULL phydev pointer.  Therefore, .adjust_link is not called in case of
      a fixed-link user port.
      
      This patch fixes the situation by converting the driver from using
      .adjust_link to .phylink_mac_config.  This can be done now in a unified
      fashion for both slave and CPU/cascade ports because DSA now uses
      PHYLINK for all ports.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      af7cd036
  8. 09 5月, 2019 1 次提交
  9. 06 5月, 2019 2 次提交
    • V
      net: dsa: sja1105: Add support for Spanning Tree Protocol · 640f763f
      Vladimir Oltean 提交于
      While not explicitly documented as supported in UM10944, compliance with
      the STP states can be obtained by manipulating 3 settings at the
      (per-port) MAC config level: dynamic learning, inhibiting reception of
      regular traffic, and inhibiting transmission of regular traffic.
      
      In all these modes, transmission and reception of special BPDU frames
      from the stack is still enabled (not inhibited by the MAC-level
      settings).
      
      On ingress, BPDUs are classified by the MAC filter as link-local
      (01-80-C2-00-00-00) and forwarded to the CPU port.  This mechanism works
      under all conditions (even without the custom 802.1Q tagging) because
      the switch hardware inserts the source port and switch ID into bytes 4
      and 5 of the MAC-filtered frames. Then the DSA .rcv handler needs to put
      back zeroes into the MAC address after decoding the source port
      information.
      
      On egress, BPDUs are transmitted using management routes from the xmit
      worker thread. Again this does not require switch tagging, as the switch
      port is programmed through SPI to hold a temporary (single-fire) route
      for a frame with the programmed destination MAC (01-80-C2-00-00-00).
      
      STP is activated using the following commands and was tested by
      connecting two front-panel ports together and noticing that switching
      loops were prevented (one port remains in the blocking state):
      
      $ ip link add name br0 type bridge stp_state 1 && ip link set br0 up
      $ for eth in $(ls /sys/devices/platform/soc/2100000.spi/spi_master/spi0/spi0.1/net/);
        do ip link set ${eth} master br0 && ip link set ${eth} up; done
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      640f763f
    • V
      net: dsa: sja1105: Add support for traffic through standalone ports · 227d07a0
      Vladimir Oltean 提交于
      In order to support this, we are creating a make-shift switch tag out of
      a VLAN trunk configured on the CPU port. Termination of normal traffic
      on switch ports only works when not under a vlan_filtering bridge.
      Termination of management (PTP, BPDU) traffic works under all
      circumstances because it uses a different tagging mechanism
      (incl_srcpt). We are making use of the generic CONFIG_NET_DSA_TAG_8021Q
      code and leveraging it from our own CONFIG_NET_DSA_TAG_SJA1105.
      
      There are two types of traffic: regular and link-local.
      
      The link-local traffic received on the CPU port is trapped from the
      switch's regular forwarding decisions because it matched one of the two
      DMAC filters for management traffic.
      
      On transmission, the switch requires special massaging for these
      link-local frames. Due to a weird implementation of the switching IP, by
      default it drops link-local frames that originate on the CPU port.
      It needs to be told where to forward them to, through an SPI command
      ("management route") that is valid for only a single frame.
      So when we're sending link-local traffic, we are using the
      dsa_defer_xmit mechanism.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      227d07a0
  10. 03 5月, 2019 6 次提交
    • V
      net: dsa: sja1105: Reject unsupported link modes for AN · ad9f299a
      Vladimir Oltean 提交于
      Ethernet flow control:
      
      The switch MAC does not consume, nor does it emit pause frames. It
      simply forwards them as any other Ethernet frame (and since the DMAC is,
      per IEEE spec, 01-80-C2-00-00-01, it means they are filtered as
      link-local traffic and forwarded to the CPU, which can't do anything
      useful with them).
      
      Duplex:
      
      There is no duplex setting in the SJA1105 MAC. It is known to forward
      traffic at line rate on the same port in both directions. Therefore it
      must be that it only supports full duplex.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ad9f299a
    • V
      net: dsa: sja1105: Add support for configuring address ageing time · 8456721d
      Vladimir Oltean 提交于
      If STP is active, this setting is applied on bridged ports each time an
      Ethernet link is established (topology changes).
      
      Since the setting is global to the switch and a reset is required to
      change it, resets are prevented if the new callback does not change the
      value that the hardware already is programmed for.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8456721d
    • V
    • V
      net: dsa: sja1105: Add support for VLAN operations · 6666cebc
      Vladimir Oltean 提交于
      VLAN filtering cannot be properly disabled in SJA1105. So in order to
      emulate the "no VLAN awareness" behavior (not dropping traffic that is
      tagged with a VID that isn't configured on the port), we need to hack
      another switch feature: programmable TPID (which is 0x8100 for 802.1Q).
      We are reprogramming the TPID to a bogus value which leaves the switch
      thinking that all traffic is untagged, and therefore accepts it.
      
      Under a vlan_filtering bridge, the proper TPID of ETH_P_8021Q is
      installed again, and the switch starts identifying 802.1Q-tagged
      traffic.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6666cebc
    • V
      net: dsa: sja1105: Error out if RGMII delays are requested in DT · f5b8631c
      Vladimir Oltean 提交于
      Documentation/devicetree/bindings/net/ethernet.txt is confusing because
      it says what the MAC should not do, but not what it *should* do:
      
        * "rgmii-rxid" (RGMII with internal RX delay provided by the PHY, the MAC
           should not add an RX delay in this case)
      
      The gap in semantics is threefold:
      1. Is it illegal for the MAC to apply the Rx internal delay by itself,
         and simplify the phy_mode (mask off "rgmii-rxid" into "rgmii") before
         passing it to of_phy_connect? The documentation would suggest yes.
      1. For "rgmii-rxid", while the situation with the Rx clock skew is more
         or less clear (needs to be added by the PHY), what should the MAC
         driver do about the Tx delays? Is it an implicit wild card for the
         MAC to apply delays in the Tx direction if it can? What if those were
         already added as serpentine PCB traces, how could that be made more
         obvious through DT bindings so that the MAC doesn't attempt to add
         them twice and again potentially break the link?
      3. If the interface is a fixed-link and therefore the PHY object is
         fixed (a purely software entity that obviously cannot add clock
         skew), what is the meaning of the above property?
      
      So an interpretation of the RGMII bindings was chosen that hopefully
      does not contradict their intention but also makes them more applied.
      The SJA1105 driver understands to act upon "rgmii-*id" phy-mode bindings
      if the port is in the PHY role (either explicitly, or if it is a
      fixed-link). Otherwise it always passes the duty of setting up delays to
      the PHY driver.
      
      The error behavior that this patch adds is required on SJA1105E/T where
      the MAC really cannot apply internal delays. If the other end of the
      fixed-link cannot apply RGMII delays either (this would be specified
      through its own DT bindings), then the situation requires PCB delays.
      
      For SJA1105P/Q/R/S, this is however hardware supported and the error is
      thus only temporary. I created a stub function pointer for configuring
      delays per-port on RXC and TXC, and will implement it when I have access
      to a board with this hardware setup.
      
      Meanwhile do not allow the user to select an invalid configuration.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f5b8631c
    • V
      net: dsa: sja1105: Add support for FDB and MDB management · 291d1e72
      Vladimir Oltean 提交于
      Currently only the (more difficult) first generation E/T series is
      supported. Here the TCAM is only 4-way associative, and to know where
      the hardware will search for a FDB entry, we need to perform the same
      hash algorithm in order to install the entry in the correct bin.
      
      On P/Q/R/S, the TCAM should be fully associative. However the SPI
      command interface is different, and because I don't have access to a
      new-generation device at the moment, support for it is TODO.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      291d1e72