mbox series

[net-next,v4,0/4] sfc: support unicast PTP

Message ID 20230221125217.20775-1-ihuguet@redhat.com (mailing list archive)
Headers show
Series sfc: support unicast PTP | expand

Message

Íñigo Huguet Feb. 21, 2023, 12:52 p.m. UTC
Unicast PTP was not working with sfc NICs.

The reason was that these NICs don't timestamp all incoming packets,
but instead they only timestamp packets of the queues that are selected
for that. Currently, only one RX queue is configured for timestamp: the
RX queue of the PTP channel. The packets that are put in the PTP RX
queue are selected according to firmware filters configured from the
driver.

Multicast PTP was already working because the needed filters are known
in advance, so they're inserted when PTP is enabled. This patches
add the ability to dynamically add filters for unicast addresses,
extracted from the TX PTP-event packets.

Since we don't know in advance how many filters we'll need, some info
about the filters need to be saved. This will allow to check if a filter
already exists or if a filter is too old and should be removed.

Note that the previous point is unnecessary for multicast filters, but
I've opted to change how they're handled to match the new unicast's
filters to avoid having duplicate insert/remove_filters functions,
once for each type of filter.

Tested: With ptp4l, all combinations of IPv4/IPv6, master/slave and
unicast/multicast

Reported-by: Yalin Li <yalli@redhat.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>

v2:
 - fixed missing IS_ERR
 - added doc of missing fields in efx_ptp_rxfilter
v3:
 - dropped pointless static inline in source file
 - removed the now unused PTP_RXFILTERS_LEN
 - follow reverse xmas tree convention in xmit_skb_mc
 - pass expiry as argument to the insert_filter functions and keep returning an
   integer error code from them, and not pointers, as suggested by Martin
 - moved the unicast filters expiration check to the end of the worker function
   to avoid increasing TX latency, as suggested by Martin
 - added check to avoid inserting unicast filters when doing multicast PTP
v4:
 - fixed filter leak, catched by Edward

Íñigo Huguet (4):
  sfc: store PTP filters in a list
  sfc: allow insertion of filters for unicast PTP
  sfc: support unicast PTP
  sfc: remove expired unicast PTP filters

 drivers/net/ethernet/sfc/ptp.c | 272 +++++++++++++++++++++++++++------
 1 file changed, 223 insertions(+), 49 deletions(-)

--
2.34.3

Comments

Jakub Kicinski Feb. 21, 2023, 4:25 p.m. UTC | #1
On Tue, 21 Feb 2023 13:52:13 +0100 Íñigo Huguet wrote:
> Unicast PTP was not working with sfc NICs.
> 
> The reason was that these NICs don't timestamp all incoming packets,
> but instead they only timestamp packets of the queues that are selected
> for that. Currently, only one RX queue is configured for timestamp: the
> RX queue of the PTP channel. The packets that are put in the PTP RX
> queue are selected according to firmware filters configured from the
> driver.
> 
> Multicast PTP was already working because the needed filters are known
> in advance, so they're inserted when PTP is enabled. This patches
> add the ability to dynamically add filters for unicast addresses,
> extracted from the TX PTP-event packets.
> 
> Since we don't know in advance how many filters we'll need, some info
> about the filters need to be saved. This will allow to check if a filter
> already exists or if a filter is too old and should be removed.
> 
> Note that the previous point is unnecessary for multicast filters, but
> I've opted to change how they're handled to match the new unicast's
> filters to avoid having duplicate insert/remove_filters functions,
> once for each type of filter.
> 
> Tested: With ptp4l, all combinations of IPv4/IPv6, master/slave and
> unicast/multicast


# Form letter - net-next is closed

The merge window for v6.3 has begun and therefore net-next is closed
for new drivers, features, code refactoring and optimizations.
We are currently accepting bug fixes only.

Please repost when net-next reopens after Mar 6th.

RFC patches sent for review only are obviously welcome at any time.
Martin Habets Feb. 22, 2023, 9:24 a.m. UTC | #2
On Tue, Feb 21, 2023 at 01:52:13PM +0100, Íñigo Huguet wrote:
> Unicast PTP was not working with sfc NICs.
> 
> The reason was that these NICs don't timestamp all incoming packets,
> but instead they only timestamp packets of the queues that are selected
> for that. Currently, only one RX queue is configured for timestamp: the
> RX queue of the PTP channel. The packets that are put in the PTP RX
> queue are selected according to firmware filters configured from the
> driver.
> 
> Multicast PTP was already working because the needed filters are known
> in advance, so they're inserted when PTP is enabled. This patches
> add the ability to dynamically add filters for unicast addresses,
> extracted from the TX PTP-event packets.
> 
> Since we don't know in advance how many filters we'll need, some info
> about the filters need to be saved. This will allow to check if a filter
> already exists or if a filter is too old and should be removed.
> 
> Note that the previous point is unnecessary for multicast filters, but
> I've opted to change how they're handled to match the new unicast's
> filters to avoid having duplicate insert/remove_filters functions,
> once for each type of filter.
> 
> Tested: With ptp4l, all combinations of IPv4/IPv6, master/slave and
> unicast/multicast
> 
> Reported-by: Yalin Li <yalli@redhat.com>
> Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>

When you repost after net-next is open again please add my
Acked-by: Martin Habets <habetsm.xilinx@gmail.com>

Thanks!

> 
> v2:
>  - fixed missing IS_ERR
>  - added doc of missing fields in efx_ptp_rxfilter
> v3:
>  - dropped pointless static inline in source file
>  - removed the now unused PTP_RXFILTERS_LEN
>  - follow reverse xmas tree convention in xmit_skb_mc
>  - pass expiry as argument to the insert_filter functions and keep returning an
>    integer error code from them, and not pointers, as suggested by Martin
>  - moved the unicast filters expiration check to the end of the worker function
>    to avoid increasing TX latency, as suggested by Martin
>  - added check to avoid inserting unicast filters when doing multicast PTP
> v4:
>  - fixed filter leak, catched by Edward
> 
> Íñigo Huguet (4):
>   sfc: store PTP filters in a list
>   sfc: allow insertion of filters for unicast PTP
>   sfc: support unicast PTP
>   sfc: remove expired unicast PTP filters
> 
>  drivers/net/ethernet/sfc/ptp.c | 272 +++++++++++++++++++++++++++------
>  1 file changed, 223 insertions(+), 49 deletions(-)
> 
> --
> 2.34.3