10 Jul, 2015

1 commit


06 Sep, 2014

2 commits

  • The phy timestamping takes a different path than the regular timestamping
    does in that it will create a clone first so that the packets needing to be
    timestamped can be placed in a queue, or the context block could be used.

    In order to support these use cases I am pulling the core of the code out
    so it can be used in other drivers beyond just phy devices.

    In addition I have added a destructor named sock_efree which is meant to
    provide a simple way for dropping the reference to skb exceptions that
    aren't part of either the receive or send windows for the socket, and I
    have removed some duplication in spots where this destructor could be used
    in place of sock_edemux.

    Signed-off-by: Alexander Duyck
    Signed-off-by: David S. Miller

    Alexander Duyck
     
  • This change merges the shared bits that exist between skb_tx_tstamp and
    skb_complete_tx_timestamp. By doing this we can avoid the two diverging as
    there were already changes pushed into skb_tx_tstamp that hadn't made it
    into the other function.

    In addition this resolves issues with the fact that
    skb_complete_tx_timestamp was included in linux/skbuff.h even though it was
    only compiled in if phy timestamping was enabled.

    Signed-off-by: Alexander Duyck
    Signed-off-by: David S. Miller

    Alexander Duyck
     

08 Jul, 2014

1 commit


02 Apr, 2014

1 commit

  • This commit fixes a build error reported by Fengguang, that is
    triggered when CONFIG_NETWORK_PHY_TIMESTAMPING is not set:

    ERROR: "ptp_classify_raw" [drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.ko] undefined!

    The fix is to introduce its own file for the PTP BPF classifier,
    so that PTP_1588_CLOCK and/or NETWORK_PHY_TIMESTAMPING can select
    it independently from each other. IXP4xx driver on ARM needs to
    select it as well since it does not seem to select PTP_1588_CLOCK
    or similar that would pull it in automatically.

    This also allows for hiding all of the internals of the BPF PTP
    program inside that file, and only exporting relevant API bits
    to drivers.

    This patch also adds a kdoc documentation of ptp_classify_raw()
    API to make it clear that it can return PTP_CLASS_* defines. Also,
    the BPF program has been translated into bpf_asm code, so that it
    can be more easily read and altered (extensively documented in [1]).

    In the kernel tree under tools/net/ we have bpf_asm and bpf_dbg
    tools, so the commented program can simply be translated via
    `./bpf_asm -c prog` where prog is a file that contains the
    commented code. This makes it easily readable/verifiable and when
    there's a need to change something, jump offsets etc do not need
    to be replaced manually which can be very error prone. Instead,
    a newly translated version via bpf_asm can simply replace the old
    code. I have checked opcode diffs before/after and it's the very
    same filter.

    [1] Documentation/networking/filter.txt

    Fixes: 164d8c666521 ("net: ptp: do not reimplement PTP/BPF classifier")
    Reported-by: Fengguang Wu
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Cc: Richard Cochran
    Cc: Jiri Benc
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

31 Mar, 2014

2 commits

  • There are currently pch_gbe, cpts, and ixp4xx_eth drivers that open-code
    and reimplement a BPF classifier for the PTP protocol. Since all of them
    effectively do the very same thing and load the very same PTP/BPF filter,
    we can just consolidate that code by introducing ptp_classify_raw() in
    the time-stamping core framework which can be used in drivers.

    As drivers get initialized after bootstrapping the core networking
    subsystem, they can make use of ptp_insns wrapped through
    ptp_classify_raw(), which allows to simplify and remove PTP classifier
    setup code in drivers.

    Joint work with Alexei Starovoitov.

    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Cc: Richard Cochran
    Cc: Jiri Benc
    Signed-off-by: David S. Miller

    Daniel Borkmann
     
  • This patch migrates an open-coded sk_run_filter() implementation with
    proper use of the BPF API, that is, sk_unattached_filter_create(). This
    migration is needed, as we will be internally transforming the filter
    to a different representation, and therefore needs to be decoupled.

    It is okay to do so as skb_timestamping_init() is called during
    initialization of the network stack in core initcall via sock_init().
    This would effectively also allow for PTP filters to be jit compiled if
    bpf_jit_enable is set.

    For better readability, there are also some newlines introduced, also
    ptp_classify.h is only in kernel space.

    Joint work with Alexei Starovoitov.

    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Cc: Richard Cochran
    Cc: Jiri Benc
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

01 Nov, 2011

1 commit


24 Oct, 2011

1 commit

  • The pair of functions,

    * skb_clone_tx_timestamp()
    * skb_complete_tx_timestamp()

    were designed to allow timestamping in PHY devices. The first
    function, called during the MAC driver's hard_xmit method, identifies
    PTP protocol packets, clones them, and gives them to the PHY device
    driver. The PHY driver may hold onto the packet and deliver it at a
    later time using the second function, which adds the packet to the
    socket's error queue.

    As pointed out by Johannes, nothing prevents the socket from
    disappearing while the cloned packet is sitting in the PHY driver
    awaiting a timestamp. This patch fixes the issue by taking a reference
    on the socket for each such packet. In addition, the comments
    regarding the usage of these function are expanded to highlight the
    rule that PHY drivers must use skb_complete_tx_timestamp() to release
    the packet, in order to release the socket reference, too.

    These functions first appeared in v2.6.36.

    Reported-by: Johannes Berg
    Signed-off-by: Richard Cochran
    Cc:
    Signed-off-by: Eric Dumazet
    Reviewed-by: Johannes Berg
    Signed-off-by: David S. Miller

    Richard Cochran
     

21 Jun, 2011

1 commit


14 Jun, 2011

1 commit


18 Dec, 2010

1 commit


11 Dec, 2010

1 commit

  • After commit c1f19b51d1d8 (net: support time stamping in phy devices.),
    kernel might crash if CONFIG_NETWORK_PHY_TIMESTAMPING=y and
    skb_defer_rx_timestamp() handles a packet without an ethernet header.

    Fixes kernel bugzilla #24102

    Reference: https://bugzilla.kernel.org/show_bug.cgi?id=24102
    Reported-and-tested-by: Andrew Watts
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

09 Dec, 2010

1 commit


20 Nov, 2010

1 commit

  • Remove pc variable to avoid arithmetic to compute fentry at each filter
    instruction. Jumps directly manipulate fentry pointer.

    As the last instruction of filter[] is guaranteed to be a RETURN, and
    all jumps are before the last instruction, we dont need to check filter
    bounds (number of instructions in filter array) at each iteration, so we
    remove it from sk_run_filter() params.

    On x86_32 remove f_k var introduced in commit 57fe93b374a6b871
    (filter: make sure filters dont read uninitialized memory)

    Note : We could use a CONFIG_ARCH_HAS_{FEW|MANY}_REGISTERS in order to
    avoid too many ifdefs in this code.

    This helps compiler to use cpu registers to hold fentry and A
    accumulator.

    On x86_32, this saves 401 bytes, and more important, sk_run_filter()
    runs much faster because less register pressure (One less conditional
    branch per BPF instruction)

    # size net/core/filter.o net/core/filter_pre.o
    text data bss dec hex filename
    2948 0 0 2948 b84 net/core/filter.o
    3349 0 0 3349 d15 net/core/filter_pre.o

    on x86_64 :
    # size net/core/filter.o net/core/filter_pre.o
    text data bss dec hex filename
    5173 0 0 5173 1435 net/core/filter.o
    5224 0 0 5224 1468 net/core/filter_pre.o

    Signed-off-by: Eric Dumazet
    Acked-by: Changli Gao
    Signed-off-by: David S. Miller

    Eric Dumazet
     

19 Jul, 2010

1 commit

  • This patch adds a new networking option to allow hardware time stamps
    from PHY devices. When enabled, likely candidates among incoming and
    outgoing network packets are offered to the PHY driver for possible
    time stamping. When accepted by the PHY driver, incoming packets are
    deferred for later delivery by the driver.

    The patch also adds phylib driver methods for the SIOCSHWTSTAMP ioctl
    and callbacks for transmit and receive time stamping. Drivers may
    optionally implement these functions.

    Signed-off-by: Richard Cochran
    Signed-off-by: David S. Miller

    Richard Cochran