1. 10 6月, 2019 7 次提交
  2. 09 6月, 2019 11 次提交
    • 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: Export symbols for upcoming PTP driver · 28e8fb3e
      Vladimir Oltean 提交于
      These are needed for the situation where the switch driver and the PTP
      driver are both built as modules.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      28e8fb3e
    • 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
  3. 07 6月, 2019 22 次提交