mbox series

[v2,0/7] Add PTP support for BCM53128 switch

Message ID 20211109095013.27829-1-martin.kaistra@linutronix.de (mailing list archive)
Headers show
Series Add PTP support for BCM53128 switch | expand

Message

Martin Kaistra Nov. 9, 2021, 9:50 a.m. UTC
Hi,

this series adds PTP support to the b53 DSA driver for the BCM53128
switch using the BroadSync HD feature.

As there seems to be only one filter (either by Ethertype or DA) for
timestamping incoming packets, only L2 is supported.

To be able to use the timecounter infrastructure with a counter that
wraps around at a non-power of two point, patch 2 adds support for such
a custom point. Alternatively I could fix up the delta every time a
wrap-around occurs in the driver itself, but this way it can also be
useful for other hardware.

v1 -> v2: fix compiling each patch with W=1 C=1
          fix compiling when NET_DSA or B53 = m
          return error on request for too broad filters
          use aux_work for overflow check
          fix signature of b53_port_txtstamp() for !CONFIG_B53_PTP
          rework broadsync hd register definitions
          add and use register definitions for multiport control
          remove setting default value for B53_BROADSYNC_TIMEBASE_ADJ
          simplify initialisation of dev->ptp_clock_info
          fix pskb_may_pull() for different tag lengths
          add unlikely() to check for status frames
          add pointer to b53_port_hwtstamp from dp->priv to simplify access from tag_brcm.c

Ideally, for the B53=m case, I would have liked to include the PTP
support in the b53_module itself, however I couldn't find a way to do
that without renaming either the common source file or the module, which
I didn't want to do.

Instead, b53_ptp will be allowed as a loadable module, but only if
b53_common is also a module, otherwise it will be built-in.


This is v2, the previous version can be found here:
https://lore.kernel.org/netdev/20211104133204.19757-1-martin.kaistra@linutronix.de/

Thanks,
Martin

Kurt Kanzenbach (1):
  net: dsa: b53: Add BroadSync HD register definitions

Martin Kaistra (6):
  net: dsa: b53: Move struct b53_device to include/linux/dsa/b53.h
  timecounter: allow for non-power of two overflow
  net: dsa: b53: Add PHC clock support
  net: dsa: b53: Add logic for RX timestamping
  net: dsa: b53: Add logic for TX timestamping
  net: dsa: b53: Expose PTP timestamping ioctls to userspace

 drivers/net/dsa/b53/Kconfig      |   8 +
 drivers/net/dsa/b53/Makefile     |   4 +
 drivers/net/dsa/b53/b53_common.c |  21 ++
 drivers/net/dsa/b53/b53_priv.h   |  90 +-------
 drivers/net/dsa/b53/b53_ptp.c    | 366 +++++++++++++++++++++++++++++++
 drivers/net/dsa/b53/b53_ptp.h    |  67 ++++++
 drivers/net/dsa/b53/b53_regs.h   |  71 ++++++
 include/linux/dsa/b53.h          | 144 ++++++++++++
 include/linux/timecounter.h      |   3 +
 kernel/time/timecounter.c        |   3 +
 net/dsa/tag_brcm.c               |  81 ++++++-
 11 files changed, 760 insertions(+), 98 deletions(-)
 create mode 100644 drivers/net/dsa/b53/b53_ptp.c
 create mode 100644 drivers/net/dsa/b53/b53_ptp.h
 create mode 100644 include/linux/dsa/b53.h

Comments

Vladimir Oltean Nov. 9, 2021, 10:39 a.m. UTC | #1
On Tue, Nov 09, 2021 at 10:50:02AM +0100, Martin Kaistra wrote:
> Ideally, for the B53=m case, I would have liked to include the PTP
> support in the b53_module itself, however I couldn't find a way to do
> that without renaming either the common source file or the module, which
> I didn't want to do.
> 
> Instead, b53_ptp will be allowed as a loadable module, but only if
> b53_common is also a module, otherwise it will be built-in.

Does this not work?

obj-$(CONFIG_B53)		+= b53_common.o

ifdef CONFIG_B53_PTP
b53_common-objs += b53_ptp.o
endif

(haven't tried though)
Martin Kaistra Nov. 9, 2021, 11:13 a.m. UTC | #2
Am 09.11.21 um 11:39 schrieb Vladimir Oltean:
> On Tue, Nov 09, 2021 at 10:50:02AM +0100, Martin Kaistra wrote:
>> Ideally, for the B53=m case, I would have liked to include the PTP
>> support in the b53_module itself, however I couldn't find a way to do
>> that without renaming either the common source file or the module, which
>> I didn't want to do.
>>
>> Instead, b53_ptp will be allowed as a loadable module, but only if
>> b53_common is also a module, otherwise it will be built-in.
> 
> Does this not work?
> 
> obj-$(CONFIG_B53)		+= b53_common.o
> 
> ifdef CONFIG_B53_PTP
> b53_common-objs += b53_ptp.o
> endif
> 
> (haven't tried though)
> 

I get:

arm-linux-gnueabihf-ld  -EL    -r -o drivers/net/dsa/b53/b53_common.o 
drivers/net/dsa/b53/b53_ptp.o



and



ERROR: modpost: "b53_switch_register" [drivers/net/dsa/b53/b53_mdio.ko] 
undefined!

ERROR: modpost: "b53_switch_alloc" [drivers/net/dsa/b53/b53_mdio.ko] 
undefined!

ERROR: modpost: "b53_switch_register" [drivers/net/dsa/b53/b53_spi.ko] 
undefined!

ERROR: modpost: "b53_switch_alloc" [drivers/net/dsa/b53/b53_spi.ko] 
undefined!

It seems to me, that b53_common.c does not get included at all.
Florian Fainelli Nov. 9, 2021, 6:13 p.m. UTC | #3
On 11/9/21 3:13 AM, Martin Kaistra wrote:
> 
> 
> Am 09.11.21 um 11:39 schrieb Vladimir Oltean:
>> On Tue, Nov 09, 2021 at 10:50:02AM +0100, Martin Kaistra wrote:
>>> Ideally, for the B53=m case, I would have liked to include the PTP
>>> support in the b53_module itself, however I couldn't find a way to do
>>> that without renaming either the common source file or the module, which
>>> I didn't want to do.
>>>
>>> Instead, b53_ptp will be allowed as a loadable module, but only if
>>> b53_common is also a module, otherwise it will be built-in.
>>
>> Does this not work?
>>
>> obj-$(CONFIG_B53)        += b53_common.o
>>
>> ifdef CONFIG_B53_PTP
>> b53_common-objs += b53_ptp.o
>> endif
>>
>> (haven't tried though)
>>
> 
> I get:
> 
> arm-linux-gnueabihf-ld  -EL    -r -o drivers/net/dsa/b53/b53_common.o
> drivers/net/dsa/b53/b53_ptp.o
> 
> 
> 
> and
> 
> 
> 
> ERROR: modpost: "b53_switch_register" [drivers/net/dsa/b53/b53_mdio.ko]
> undefined!
> 
> ERROR: modpost: "b53_switch_alloc" [drivers/net/dsa/b53/b53_mdio.ko]
> undefined!
> 
> ERROR: modpost: "b53_switch_register" [drivers/net/dsa/b53/b53_spi.ko]
> undefined!
> 
> ERROR: modpost: "b53_switch_alloc" [drivers/net/dsa/b53/b53_spi.ko]
> undefined!
> 
> It seems to me, that b53_common.c does not get included at all.

You need to play tricks with '-' and '_' and do something like this:

obj-$(CONFIG_B53)	+= b53-common.o

b53-common-objs		+= b53_common.o b53_ptp.o

and that should result in a b53-common.ko which would be accepted by
modprobe b53_common or b53-common AFAICT.