1. 21 7月, 2020 32 次提交
  2. 20 7月, 2020 8 次提交
    • D
      Merge branch 'Fully-describe-the-waveform-for-PTP-periodic-output' · 120c7dd5
      David S. Miller 提交于
      Vladimir Oltean says:
      
      ====================
      Fully describe the waveform for PTP periodic output
      
      While using the ancillary pin functionality of PTP hardware clocks to
      synchronize multiple DSA switches on a board, a need arised to be able
      to configure the duty cycle of the master of this PPS hierarchy.
      
      Also, the PPS master is not able to emit PPS starting from arbitrary
      absolute times, so a new flag is introduced to support such hardware
      without making guesses.
      
      With these patches, struct ptp_perout_request now basically describes a
      general-purpose square wave.
      
      Changes in v2:
      Made sure this applies to net-next.
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      120c7dd5
    • V
      net: mscc: ocelot: add support for PTP waveform configuration · ecf9f9b7
      Vladimir Oltean 提交于
      For PPS output (perout period is 1.000000000), accept the new "phase"
      parameter from the periodic output request structure.
      
      For both PPS and freeform output, accept the new "on" argument for
      specifying the duty cycle of the generated signal. Preserve the old
      defaults for this "on" time: 1 us for PPS, and half the period for
      freeform output.
      
      Also preserve the old behavior that accepted the "phase" via the "start"
      argument.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NHoratiu Vultur <horatiu.vultur@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ecf9f9b7
    • V
      ptp: introduce a phase offset in the periodic output request · b6bd4136
      Vladimir Oltean 提交于
      Some PHCs like the ocelot/felix switch cannot emit generic periodic
      output, but just PPS (pulse per second) signals, which:
      - don't start from arbitrary absolute times, but are rather
        phase-aligned to the beginning of [the closest next] second.
      - have an optional phase offset relative to that beginning of the
        second.
      
      For those, it was initially established that they should reject any
      other absolute time for the PTP_PEROUT_REQUEST than 0.000000000 [1].
      
      But when it actually came to writing an application [2] that makes use
      of this functionality, we realized that we can't really deal generically
      with PHCs that support absolute start time, and with PHCs that don't,
      without an explicit interface. Namely, in an ideal world, PHC drivers
      would ensure that the "perout.start" value written to hardware will
      result in a functional output. This means that if the PTP time has
      become in the past of this PHC's current time, it should be
      automatically fast-forwarded by the driver into a close enough future
      time that is known to work (note: this is necessary only if the hardware
      doesn't do this fast-forward by itself). But we don't really know what
      is the status for PHC drivers in use today, so in the general sense,
      user space would be risking to have a non-functional periodic output if
      it simply asked for a start time of 0.000000000.
      
      So let's introduce a flag for this type of reduced-functionality
      hardware, named PTP_PEROUT_PHASE. The start time is just "soon", the
      only thing we know for sure about this signal is that its rising edge
      events, Rn, occur at:
      
      Rn = perout.phase + n * perout.period
      
      The "phase" in the periodic output structure is simply an alias to the
      "start" time, since both cannot logically be specified at the same time.
      Therefore, the binary layout of the structure is not affected.
      
      [1]: https://patchwork.ozlabs.org/project/netdev/patch/20200320103726.32559-7-yangbo.lu@nxp.com/
      [2]: https://www.mail-archive.com/linuxptp-devel@lists.sourceforge.net/msg04142.htmlSigned-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b6bd4136
    • V
      ptp: add ability to configure duty cycle for periodic output · f65b71aa
      Vladimir Oltean 提交于
      There are external event timestampers (PHCs with support for
      PTP_EXTTS_REQUEST) that timestamp both event edges.
      
      When those edges are very close (such as in the case of a short pulse),
      there is a chance that the collected timestamp might be of the rising,
      or of the falling edge, we never know.
      
      There are also PHCs capable of generating periodic output with a
      configurable duty cycle. This is good news, because we can space the
      rising and falling edge out enough in time, that the risks to overrun
      the 1-entry timestamp FIFO of the extts PHC are lower (example: the
      perout PHC can be configured for a period of 1 second, and an "on" time
      of 0.5 seconds, resulting in a duty cycle of 50%).
      
      A flag is introduced for signaling that an on time is present in the
      perout request structure, for preserving compatibility. Logically
      speaking, the duty cycle cannot exceed 100% and the PTP core checks for
      this.
      
      PHC drivers that don't support this flag emit a periodic output of an
      unspecified duty cycle, same as before.
      
      The duty cycle is encoded as an "on" time, similar to the "start" and
      "period" times, and reuses the reserved space while preserving overall
      binary layout.
      
      Pahole reported before:
      
      struct ptp_perout_request {
              struct ptp_clock_time start;                     /*     0    16 */
              struct ptp_clock_time period;                    /*    16    16 */
              unsigned int               index;                /*    32     4 */
              unsigned int               flags;                /*    36     4 */
              unsigned int               rsv[4];               /*    40    16 */
      
              /* size: 56, cachelines: 1, members: 5 */
              /* last cacheline: 56 bytes */
      };
      
      And now:
      
      struct ptp_perout_request {
              struct ptp_clock_time start;                     /*     0    16 */
              struct ptp_clock_time period;                    /*    16    16 */
              unsigned int               index;                /*    32     4 */
              unsigned int               flags;                /*    36     4 */
              union {
                      struct ptp_clock_time on;                /*    40    16 */
                      unsigned int       rsv[4];               /*    40    16 */
              };                                               /*    40    16 */
      
              /* size: 56, cachelines: 1, members: 5 */
              /* last cacheline: 56 bytes */
      };
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f65b71aa
    • W
      icmp: support rfc 4884 · eba75c58
      Willem de Bruijn 提交于
      Add setsockopt SOL_IP/IP_RECVERR_4884 to return the offset to an
      extension struct if present.
      
      ICMP messages may include an extension structure after the original
      datagram. RFC 4884 standardized this behavior. It stores the offset
      in words to the extension header in u8 icmphdr.un.reserved[1].
      
      The field is valid only for ICMP types destination unreachable, time
      exceeded and parameter problem, if length is at least 128 bytes and
      entire packet does not exceed 576 bytes.
      
      Return the offset to the start of the extension struct when reading an
      ICMP error from the error queue, if it matches the above constraints.
      
      Do not return the raw u8 field. Return the offset from the start of
      the user buffer, in bytes. The kernel does not return the network and
      transport headers, so subtract those.
      
      Also validate the headers. Return the offset regardless of validation,
      as an invalid extension must still not be misinterpreted as part of
      the original datagram. Note that !invalid does not imply valid. If
      the extension version does not match, no validation can take place,
      for instance.
      
      For backward compatibility, make this optional, set by setsockopt
      SOL_IP/IP_RECVERR_RFC4884. For API example and feature test, see
      github.com/wdebruij/kerneltools/blob/master/tests/recv_icmp_v2.c
      
      For forward compatibility, reserve only setsockopt value 1, leaving
      other bits for additional icmp extensions.
      
      Changes
        v1->v2:
        - convert word offset to byte offset from start of user buffer
          - return in ee_data as u8 may be insufficient
        - define extension struct and object header structs
        - return len only if constraints met
        - if returning len, also validate
      Signed-off-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      eba75c58
    • D
      Merge branch 'rework-mvneta-napi_poll-loop-for-XDP-multi-buffers' · 930bc4cc
      David S. Miller 提交于
      Lorenzo Bianconi says:
      
      ====================
      rework mvneta napi_poll loop for XDP multi-buffers
      
      Rework mvneta_rx_swbm routine in order to process all rx descriptors before
      building the skb or run the xdp program attached to the interface.
      Introduce xdp_get_shared_info_from_{buff,frame} utility routines to get the
      skb_shared_info pointer from xdp_buff or xdp_frame.
      This is a preliminary series to enable multi-buffers and jumbo frames for XDP
      according to [1]
      
      [1] https://github.com/xdp-project/xdp-project/blob/master/areas/core/xdp-multi-buffer01-design.org
      
      Changes since v1:
      - rely on skb_frag_* utility routines to access page/offset/len of the xdp multi-buffer
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      930bc4cc
    • L
      net: mvneta: move rxq->left_size on the stack · c7a3a8cd
      Lorenzo Bianconi 提交于
      Allocate rxq->left_size on mvneta_rx_swbm stack since it is used just
      in sw bm napi_poll
      Signed-off-by: NLorenzo Bianconi <lorenzo@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c7a3a8cd
    • L
      net: mvneta: get rid of skb in mvneta_rx_queue · 89f4a198
      Lorenzo Bianconi 提交于
      Remove skb pointer in mvneta_rx_queue data structure since it is no
      longer used
      Signed-off-by: NLorenzo Bianconi <lorenzo@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      89f4a198