1. Oct 17, 2023
  2. Oct 16, 2023
    • Daniel Borkmann's avatar
      Merge branch 'bpf-log-improvements' · 99c9991f
      Daniel Borkmann authored
      
      
      Andrii Nakryiko says:
      
      ====================
      This patch set fixes ambiguity in BPF verifier log output of SCALAR register
      in the parts that emit umin/umax, smin/smax, etc ranges. See patch #4 for
      details.
      
      Also, patch #5 fixes an issue with verifier log missing instruction context
      (state) output for conditionals that trigger precision marking. See details in
      the patch.
      
      First two patches are just improvements to two selftests that are very flaky
      locally when run in parallel mode.
      
      Patch #3 changes 'align' selftest to be less strict about exact verifier log
      output (which patch #4 changes, breaking lots of align tests as written). Now
      test does more of a register substate checks, mostly around expected var_off()
      values. This 'align' selftests is one of the more brittle ones and requires
      constant adjustment when verifier log output changes, without really catching
      any new issues. So hopefully these changes can minimize future support efforts
      for this specific set of tests.
      ====================
      
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      99c9991f
    • Andrii Nakryiko's avatar
      bpf: Ensure proper register state printing for cond jumps · 1a8a315f
      Andrii Nakryiko authored
      
      
      Verifier emits relevant register state involved in any given instruction
      next to it after `;` to the right, if possible. Or, worst case, on the
      separate line repeating instruction index.
      
      E.g., a nice and simple case would be:
      
        2: (d5) if r0 s<= 0x0 goto pc+1       ; R0_w=0
      
      But if there is some intervening extra output (e.g., precision
      backtracking log) involved, we are supposed to see the state after the
      precision backtrack log:
      
        4: (75) if r0 s>= 0x0 goto pc+1
        mark_precise: frame0: last_idx 4 first_idx 0 subseq_idx -1
        mark_precise: frame0: regs=r0 stack= before 2: (d5) if r0 s<= 0x0 goto pc+1
        mark_precise: frame0: regs=r0 stack= before 1: (b7) r0 = 0
        6: R0_w=0
      
      First off, note that in `6: R0_w=0` instruction index corresponds to the
      next instruction, not to the conditional jump instruction itself, which
      is wrong and we'll get to that.
      
      But besides that, the above is a happy case that does work today. Yet,
      if it so happens that precision backtracking had to traverse some of the
      parent states, this `6: R0_w=0` state output would be missing.
      
      This is due to a quirk of print_verifier_state() routine, which performs
      mark_verifier_state_clean(env) at the end. This marks all registers as
      "non-scratched", which means that subsequent logic to print *relevant*
      registers (that is, "scratched ones") fails and doesn't see anything
      relevant to print and skips the output altogether.
      
      print_verifier_state() is used both to print instruction context, but
      also to print an **entire** verifier state indiscriminately, e.g.,
      during precision backtracking (and in a few other situations, like
      during entering or exiting subprogram).  Which means if we have to print
      entire parent state before getting to printing instruction context
      state, instruction context is marked as clean and is omitted.
      
      Long story short, this is definitely not intentional. So we fix this
      behavior in this patch by teaching print_verifier_state() to clear
      scratch state only if it was used to print instruction state, not the
      parent/callback state. This is determined by print_all option, so if
      it's not set, we don't clear scratch state. This fixes missing
      instruction state for these cases.
      
      As for the mismatched instruction index, we fix that by making sure we
      call print_insn_state() early inside check_cond_jmp_op() before we
      adjusted insn_idx based on jump branch taken logic. And with that we get
      desired correct information:
      
        9: (16) if w4 == 0x1 goto pc+9
        mark_precise: frame0: last_idx 9 first_idx 9 subseq_idx -1
        mark_precise: frame0: parent state regs=r4 stack=: R2_w=1944 R4_rw=P1 R10=fp0
        mark_precise: frame0: last_idx 8 first_idx 0 subseq_idx 9
        mark_precise: frame0: regs=r4 stack= before 8: (66) if w4 s> 0x3 goto pc+5
        mark_precise: frame0: regs=r4 stack= before 7: (b7) r4 = 1
        9: R4=1
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/bpf/20231011223728.3188086-6-andrii@kernel.org
      1a8a315f
    • Andrii Nakryiko's avatar
      bpf: Disambiguate SCALAR register state output in verifier logs · 72f8a1de
      Andrii Nakryiko authored
      
      
      Currently the way that verifier prints SCALAR_VALUE register state (and
      PTR_TO_PACKET, which can have var_off and ranges info as well) is very
      ambiguous.
      
      In the name of brevity we are trying to eliminate "unnecessary" output
      of umin/umax, smin/smax, u32_min/u32_max, and s32_min/s32_max values, if
      possible. Current rules are that if any of those have their default
      value (which for mins is the minimal value of its respective types: 0,
      S32_MIN, or S64_MIN, while for maxs it's U32_MAX, S32_MAX, S64_MAX, or
      U64_MAX) *OR* if there is another min/max value that as matching value.
      E.g., if smin=100 and umin=100, we'll emit only umin=10, omitting smin
      altogether. This approach has a few problems, being both ambiguous and
      sort-of incorrect in some cases.
      
      Ambiguity is due to missing value could be either default value or value
      of umin/umax or smin/smax. This is especially confusing when we mix
      signed and unsigned ranges. Quite often, umin=0 and smin=0, and so we'll
      have only `umin=0` leaving anyone reading verifier log to guess whether
      smin is actually 0 or it's actually -9223372036854775808 (S64_MIN). And
      often times it's important to know, especially when debugging tricky
      issues.
      
      "Sort-of incorrectness" comes from mixing negative and positive values.
      E.g., if umin is some large positive number, it can be equal to smin
      which is, interpreted as signed value, is actually some negative value.
      Currently, that smin will be omitted and only umin will be emitted with
      a large positive value, giving an impression that smin is also positive.
      
      Anyway, ambiguity is the biggest issue making it impossible to have an
      exact understanding of register state, preventing any sort of automated
      testing of verifier state based on verifier log. This patch is
      attempting to rectify the situation by removing ambiguity, while
      minimizing the verboseness of register state output.
      
      The rules are straightforward:
        - if some of the values are missing, then it definitely has a default
        value. I.e., `umin=0` means that umin is zero, but smin is actually
        S64_MIN;
        - all the various boundaries that happen to have the same value are
        emitted in one equality separated sequence. E.g., if umin and smin are
        both 100, we'll emit `smin=umin=100`, making this explicit;
        - we do not mix negative and positive values together, and even if
        they happen to have the same bit-level value, they will be emitted
        separately with proper sign. I.e., if both umax and smax happen to be
        0xffffffffffffffff, we'll emit them both separately as
        `smax=-1,umax=18446744073709551615`;
        - in the name of a bit more uniformity and consistency,
        {u32,s32}_{min,max} are renamed to {s,u}{min,max}32, which seems to
        improve readability.
      
      The above means that in case of all 4 ranges being, say, [50, 100] range,
      we'd previously see hugely ambiguous:
      
          R1=scalar(umin=50,umax=100)
      
      Now, we'll be more explicit:
      
          R1=scalar(smin=umin=smin32=umin32=50,smax=umax=smax32=umax32=100)
      
      This is slightly more verbose, but distinct from the case when we don't
      know anything about signed boundaries and 32-bit boundaries, which under
      new rules will match the old case:
      
          R1=scalar(umin=50,umax=100)
      
      Also, in the name of simplicity of implementation and consistency, order
      for {s,u}32_{min,max} are emitted *before* var_off. Previously they were
      emitted afterwards, for unclear reasons.
      
      This patch also includes a few fixes to selftests that expect exact
      register state to accommodate slight changes to verifier format. You can
      see that the changes are pretty minimal in common cases.
      
      Note, the special case when SCALAR_VALUE register is a known constant
      isn't changed, we'll emit constant value once, interpreted as signed
      value.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/bpf/20231011223728.3188086-5-andrii@kernel.org
      72f8a1de
    • Andrii Nakryiko's avatar
      selftests/bpf: Make align selftests more robust · cde78514
      Andrii Nakryiko authored
      
      
      Align subtest is very specific and finicky about expected verifier log
      output and format. This is often completely unnecessary as in a bunch of
      situations test actually cares about var_off part of register state. But
      given how exact it is right now, any tiny verifier log changes can lead
      to align tests failures, requiring constant adjustment.
      
      This patch tries to make this a bit more robust by making logic first
      search for specified register and then allowing to match only portion of
      register state, not everything exactly. This will come handly with
      follow up changes to SCALAR register output disambiguation.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/bpf/20231011223728.3188086-4-andrii@kernel.org
      cde78514
    • Andrii Nakryiko's avatar
      selftests/bpf: Improve missed_kprobe_recursion test robustness · 08a7078f
      Andrii Nakryiko authored
      
      
      Given missed_kprobe_recursion is non-serial and uses common testing
      kfuncs to count number of recursion misses it's possible that some other
      parallel test can trigger extraneous recursion misses. So we can't
      expect exactly 1 miss. Relax conditions and expect at least one.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/bpf/20231011223728.3188086-3-andrii@kernel.org
      08a7078f
    • Andrii Nakryiko's avatar
      selftests/bpf: Improve percpu_alloc test robustness · 2d78928c
      Andrii Nakryiko authored
      
      
      Make these non-serial tests filter BPF programs by intended PID of
      a test runner process. This makes it isolated from other parallel tests
      that might interfere accidentally.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/bpf/20231011223728.3188086-2-andrii@kernel.org
      2d78928c
    • Gerhard Engleder's avatar
      tsnep: Inline small fragments within TX descriptor · dccce1d7
      Gerhard Engleder authored
      
      
      The tsnep network controller is able to extend the descriptor directly
      with data to be transmitted. In this case no TX data DMA address is
      necessary. Instead of the TX data DMA address the TX data buffer is
      placed at the end of the descriptor.
      
      The descriptor is read with a 64 bytes DMA read by the tsnep network
      controller. If the sum of descriptor data and TX data is less than or
      equal to 64 bytes, then no additional DMA read is necessary to read the
      TX data. Therefore, it makes sense to inline small fragments up to this
      limit within the descriptor ring.
      
      Inlined fragments need to be copied to the descriptor ring. On the other
      hand DMA mapping is not necessary. At most 40 bytes are copied, so
      copying should be faster than DMA mapping.
      
      For A53 1.2 GHz copying takes <100ns and DMA mapping takes >200ns. So
      inlining small fragments should result in lower CPU load. Performance
      improvement is small. Thus, comparision of CPU load with and without
      inlining of small fragments did not show any significant difference.
      With this optimization less DMA reads will be done, which decreases the
      load of the interconnect.
      
      Signed-off-by: default avatarGerhard Engleder <gerhard@engleder-embedded.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dccce1d7
    • David S. Miller's avatar
      Merge branch 'udp-tunnel-route-lookups' · d8118b94
      David S. Miller authored
      
      
      Beniamino Galvani says:
      
      ====================
      net: consolidate IPv4 route lookup for UDP tunnels
      
      At the moment different UDP tunnels rely on different functions for
      IPv4 route lookup, and those functions all implement the same
      logic. Only bareudp uses the generic ip_route_output_tunnel(), while
      geneve and vxlan basically duplicate it slightly differently.
      
      This series first extends the generic lookup function so that it is
      suitable for all UDP tunnel implementations. Then, bareudp, geneve and
      vxlan are adapted to use them.
      
      This results in code with less duplication and hopefully better
      maintainability.
      
      After this series is merged, IPv6 will be converted in a similar way.
      
      Changelog:
      v2
       - fix compilation with IPv6 disabled
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d8118b94
    • Beniamino Galvani's avatar
      vxlan: use generic function for tunnel IPv4 route lookup · 6f19b2c1
      Beniamino Galvani authored
      
      
      The route lookup can be done now via generic function
      udp_tunnel_dst_lookup() to replace the custom implementations in
      vxlan_get_route().
      
      Note that this patch only touches IPv4, while IPv6 still uses
      vxlan6_get_route(). After IPv6 route lookup gets converted as well,
      vxlan_xmit_one() can be simplified by removing local variables that
      will be passed via "struct ip_tunnel_key", such as remote_ip,
      local_ip, flow_flags, label.
      
      Suggested-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarBeniamino Galvani <b.galvani@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6f19b2c1
    • Beniamino Galvani's avatar
      geneve: use generic function for tunnel IPv4 route lookup · daa2ba7e
      Beniamino Galvani authored
      
      
      The route lookup can be done now via generic function
      udp_tunnel_dst_lookup() to replace the custom implementation in
      geneve_get_v4_rt().
      
      Suggested-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarBeniamino Galvani <b.galvani@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      daa2ba7e
    • Beniamino Galvani's avatar
      geneve: add dsfield helper function · 60a77d11
      Beniamino Galvani authored
      
      
      Add a helper function to compute the tos/dsfield. In this way, we can
      factor out some duplicate code. Also, the helper will be called from
      more places in the next commit.
      
      Suggested-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarBeniamino Galvani <b.galvani@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      60a77d11
    • Beniamino Galvani's avatar
      ipv4: use tunnel flow flags for tunnel route lookups · 3ae983a6
      Beniamino Galvani authored
      Commit 451ef36b
      
       ("ip_tunnels: Add new flow flags field to
      ip_tunnel_key") added a new field to struct ip_tunnel_key to control
      route lookups. Currently the flag is used by vxlan and geneve tunnels;
      use it also in udp_tunnel_dst_lookup() so that it affects all tunnel
      types relying on this function.
      
      Signed-off-by: default avatarBeniamino Galvani <b.galvani@gmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3ae983a6
    • Beniamino Galvani's avatar
      ipv4: add new arguments to udp_tunnel_dst_lookup() · 72fc68c6
      Beniamino Galvani authored
      
      
      We want to make the function more generic so that it can be used by
      other UDP tunnel implementations such as geneve and vxlan. To do that,
      add the following arguments:
      
       - source and destination UDP port;
       - ifindex of the output interface, needed by vxlan;
       - the tos, because in some cases it is not taken from struct
         ip_tunnel_info (for example, when it's inherited from the inner
         packet);
       - the dst cache, because not all tunnel types (e.g. vxlan) want to
         use the one from struct ip_tunnel_info.
      
      With these parameters, the function no longer needs the full struct
      ip_tunnel_info as argument and we can pass only the relevant part of
      it (struct ip_tunnel_key).
      
      Suggested-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarBeniamino Galvani <b.galvani@gmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      72fc68c6
    • Beniamino Galvani's avatar
      ipv4: remove "proto" argument from udp_tunnel_dst_lookup() · 78f3655a
      Beniamino Galvani authored
      
      
      The function is now UDP-specific, the protocol is always IPPROTO_UDP.
      
      Suggested-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarBeniamino Galvani <b.galvani@gmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      78f3655a
    • Beniamino Galvani's avatar
      ipv4: rename and move ip_route_output_tunnel() · bf3fcbf7
      Beniamino Galvani authored
      
      
      At the moment ip_route_output_tunnel() is used only by bareudp.
      Ideally, other UDP tunnel implementations should use it, but to do so
      the function needs to accept new parameters that are specific for UDP
      tunnels, such as the ports.
      
      Prepare for these changes by renaming the function to
      udp_tunnel_dst_lookup() and move it to file
      net/ipv4/udp_tunnel_core.c.
      
      Suggested-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarBeniamino Galvani <b.galvani@gmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bf3fcbf7
    • zhujun2's avatar
      selftests: net: remove unused variables · 3c4fe898
      zhujun2 authored
      
      
      These variables are never referenced in the code, just remove them
      
      Signed-off-by: default avatarzhujun2 <zhujun2@cmss.chinamobile.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3c4fe898
    • Christian Marangi's avatar
      net: cxgb3: simplify logic for rspq_check_napi · 101c6032
      Christian Marangi authored
      
      
      Simplify logic for rspq_check_napi.
      Drop redundant and wrong napi_is_scheduled call as it's not race free
      and directly use the output of napi_schedule to understand if a napi is
      pending or not.
      
      rspq_check_napi main logic is to check if is_new_response is true and
      check if a napi is not scheduled. The result of this function is then
      used to detect if we are missing some interrupt and act on top of
      this... With this knowing, we can rework and simplify the logic and make
      it less problematic with testing an internal bit for napi.
      
      Suggested-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      101c6032
    • David S. Miller's avatar
      Merge branch 'ptp-multiple-readers' · c49bba01
      David S. Miller authored
      Xabier Marquiegui says:
      
      ====================
      ptp: Support for multiple filtered timestamp event queue readers
      
      On systems with multiple timestamp event channels, there can be scenarios
      where multiple userspace readers want to access the timestamping data for
      various purposes.
      
      One such example is wanting to use a pps out for time synchronization, and
      wanting to timestamp external events with the synchronized time base
      simultaneously.
      
      Timestmp event consumers on the other hand, are often interested in a
      subset of the available timestamp channels. linuxptp ts2phc, for example,
      is not happy if more than one timestamping channel is active on the device
      it is reading from.
      
      Linked lists are introduced to support multiple timestamp event queue
      consumers, and timestamp event channel filters through IOCTLs, as well as
      a debugfs interface to do some simple verifications.
      
      Xabier Marquiegui (6):
        posix-clock: introduce posix_clock_context concept
        ptp: Replace timestamp event queue with linked list
        ptp: support multiple timestamp event readers
        ptp: support event queue reader channel masks
        ptp: add debugfs interface to see applied channel masks
        ptp: add testptp mask test
      
       drivers/ptp/ptp_chardev.c                   | 129 ++++++++++++++++----
       drivers/ptp/ptp_clock.c                     |  45 ++++++-
       drivers/ptp/ptp_private.h                   |  28 +++--
       drivers/ptp/ptp_sysfs.c                     |  13 +-
       include/linux/posix-clock.h                 |  35 ++++--
       include/uapi/linux/ptp_clock.h              |   2 +
       kernel/time/posix-clock.c                   |  36 ++++--
       tools/testing/selftests/ptp/ptpchmaskfmt.sh |  14 +++
       tools/testing/selftests/ptp/testptp.c       |  19 ++-
       9 files changed, 261 insertions(+), 60 deletions(-)
       create mode 100644 tools/testing/selftests/ptp/ptpchmaskfmt.sh
      
      ---
      v6:
        - correct commit message
        - correct coding style
      v5: https://lore.kernel.org/netdev/cover.1696804243.git.reibax@gmail.com/
        - fix spelling on commit message
        - fix memory leak on ptp_open
      v4: https://lore.kernel.org/netdev/cover.1696511486.git.reibax@gmail.com/
        - split modifications in different patches for improved organization
        - rename posix_clock_user to posix_clock_context
        - remove unnecessary flush_users clock operation
        - remove unnecessary tests
        - simpler queue clean procedure
        - fix/clean comment lines
        - simplified release procedures
        - filter modifications exclusive to currently open instance for
          simplicity and security
        - expand mask to 2048 channels
        - make more secure and simple: mask is only applied to the testptp
          instance. Use debugfs to verify effects.
      v3: https://lore.kernel.org/netdev/20230928133544.3642650-1-reibax@gmail.com/
        - add this patchset overview file
        - fix use of safe and non safe linked lists for loops
        - introduce new posix_clock private_data and ida object ids for better
          dicrimination of timestamp consumers
        - safer resource release procedures
        - filter application by object id, aided by process id
        - friendlier testptp implementation of event queue channel filters
      v2: https://lore.kernel.org/netdev/20230912220217.2008895-1-reibax@gmail.com/
        - fix ptp_poll() return value
        - Style changes to comform to checkpatch strict suggestions
        - more coherent ptp_read error exit routines
        - fix testptp compilation error: unknown type name 'pid_t'
        - rename mask variable for easier code traceability
        - more detailed commit message with two examples
      v1: https://lore.kernel.org/netdev/20230906104754.1324412-2-reibax@gmail.com/
      
      
      ====================
      
      Signed-off-by: default avatarXabier Marquiegui <reibax@gmail.com>
      Suggested-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Suggested-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c49bba01
    • Xabier Marquiegui's avatar
      ptp: add testptp mask test · 26285e68
      Xabier Marquiegui authored
      
      
      Add option to test timestamp event queue mask manipulation in testptp.
      
      Option -F allows the user to specify a single channel that will be
      applied on the mask filter via IOCTL.
      
      The test program will maintain the file open until user input is
      received.
      
      This allows checking the effect of the IOCTL in debugfs.
      
      eg:
      
      Console 1:
      ```
      Channel 12 exclusively enabled. Check on debugfs.
      Press any key to continue
      ```
      
      Console 2:
      ```
      0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
      0x00000000 0x00000000 0x00000000 0x00000000
      ```
      
      Signed-off-by: default avatarXabier Marquiegui <reibax@gmail.com>
      Suggested-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Suggested-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      26285e68
    • Xabier Marquiegui's avatar
      ptp: add debugfs interface to see applied channel masks · 403376dd
      Xabier Marquiegui authored
      
      
      Use debugfs to be able to view channel mask applied to every timestamp
      event queue.
      
      Every time the device is opened, a new entry is created in
      `$DEBUGFS_MOUNTPOINT/ptpN/$INSTANCE_ADDRESS/mask`.
      
      The mask value can be viewed grouped in 32bit decimal values using cat,
      or converted to hexadecimal with the included `ptpchmaskfmt.sh` script.
      32 bit values are listed from least significant to most significant.
      
      Signed-off-by: default avatarXabier Marquiegui <reibax@gmail.com>
      Suggested-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      403376dd
    • Xabier Marquiegui's avatar
      ptp: support event queue reader channel masks · c5a445b1
      Xabier Marquiegui authored
      
      
      On systems with multiple timestamp event channels, some readers might
      want to receive only a subset of those channels.
      
      Add the necessary modifications to support timestamp event channel
      filtering, including two IOCTL operations:
      
      - Clear all channels
      - Enable one channel
      
      The mask modification operations will be applied exclusively on the
      event queue assigned to the file descriptor used on the IOCTL operation,
      so the typical procedure to have a reader receiving only a subset of the
      enabled channels would be:
      
      - Open device file
      - ioctl: clear all channels
      - ioctl: enable one channel
      - start reading
      
      Calling the enable one channel ioctl more than once will result in
      multiple enabled channels.
      
      Signed-off-by: default avatarXabier Marquiegui <reibax@gmail.com>
      Suggested-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Suggested-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c5a445b1
    • Xabier Marquiegui's avatar
      ptp: support multiple timestamp event readers · 8f5de6fb
      Xabier Marquiegui authored
      
      
      Use linked lists to create one event queue per open file. This enables
      simultaneous readers for timestamp event queues.
      
      Signed-off-by: default avatarXabier Marquiegui <reibax@gmail.com>
      Suggested-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8f5de6fb