From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=80.241.56.152 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795977095; b=Avo140018zn43d+k0Fl4MNlPCB7BDIuIMdocZ103IxiWXd5TRieNdprfMc4sh6khshSn i51jOkwYwVW/x+YwI+4KhyAzwRPkKrv9w21xbK3jgb4zqNa9mmiliUmPvae0Q3uG/Fq2k To0/rP0EavOXOYUHWibZcr2i7mGdEGV0SYflZmiCBj4Ctxm+BeaUhB6UdkVGWzZfyVvSW fFbYzFvg/TftcJ1wOfHhwwRNRpH8KNWWiMWQviqV1uP48Gk2jwH5opzvfZ4W9+3v5vnbJ dhMe8jBazIyt/tjcgie9C1Nu3BbRNqm6BgZ3spC+noQd03CB5ciJ4EXaesNWEKG1j/A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795977095; h=DMARC-Filter:Received:DKIM-Signature:Message-ID:Subject:From:To:Cc: Date:In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version:X-MBO-RS-META:X-MBO-RS-ID; bh=4ZMmE9SMPxnD0akB5zFdyE/iLq9a8x+3A5AyVC86cdw=; b=zeu1VJl/73a1f6BosWFEt+jmMOidKjSoZDkgCetCAtiB5NlBfBQjOxBHzxAlFUFLevHY 4IsnGYNPTqdWHnobGqrWS9hpZJ5+nbRJOPx6MZifmjSa0dh9ZU8N+NPgN1c3JaUjIlZp8 Oiw9P2f8pC7egQjDPZtNwn8BIUIrFEbsCc1H7wdaOap5ptApHytajA1fGBh/pwCnxBQec nOy5DgsYiWRH+fg2ZVNfZ/5WE0+61U6gLTkTv9bv4PuAcR0CCGrO4+haYSDtGs8PvqeR/ AkPe0JtkatCUyz0vGhzsiOgPmjjG2PAxAjYHQO38nbaGtClO1sm/S3dBy8FUmiF6/mw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mailbox.org; spf=pass smtp.mailfrom=mailbox.org; dkim=pass header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=E4e8JQak; arc=none smtp.remote-ip=80.241.56.152 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93B0E606A31C; Sun, 29 Nov 2026 18:31:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 93B0E606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mailbox.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=E4e8JQak Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4jcwhx223DzKr5m; Sun, 29 Nov 2026 19:31:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1795977089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4ZMmE9SMPxnD0akB5zFdyE/iLq9a8x+3A5AyVC86cdw=; b=E4e8JQaklRA8V7XDANAbhwyu3ABdBTpNk0drnpCcFyBNpza6otfa+6RWR/2I6nMak06DFa +HKLrC2KcADcTHWXObL8vgTRvLNsRedxhhYLr3VgXiNirkJFOcsjWy0iioc/l7n8Drf44M tD3YV0kfRXN/YgravSo2K3BzMbbtWplI0nljCrLjQeEPtKFAzbLwmB4Fej0U7DPSIQwwbp JDZGv9YfKXYf9KBEihLE1FZmJNc/nbsqEajtjIbRWEsqSW2y1zrmEY4nlfYf+NU283kHZu eGEO+x8wlE/wr3hRxuCMT+ekBj1qTv3by57m3k3PbQGm8U+fsbI0PqzLI0I2IQ== Message-ID: Subject: Re: [PATCH net-next 2/3] net: usb: ax88179: Add PTP Implementation From: Manuel Ebner To: Birger Koblitz , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Russell King Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sun, 29 Nov 2026 19:31:25 +0100 In-Reply-To: <20261129-ptp-v1-2-8148c402beaf@birger-koblitz.de> References: <20261129-ptp-v1-0-8148c402beaf@birger-koblitz.de> <20261129-ptp-v1-2-8148c402beaf@birger-koblitz.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.62.1 (3.62.1-1.fc45) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MBO-RS-META: ecr1ycpofb5nh39a6r7xxzzzfusoku11 X-MBO-RS-ID: edad1f1b4cd65ed4b24 On Sun, 2026-11-29 at 10:29 +0100, Birger Koblitz wrote: > Adds support to match TX timestamps for packets for which TX timestamps > are requested against TX timestamps received separately by the host and > processing of the hardware timestamps inserted in received frames. >=20 > For both AX88179A and AX88279 support for a PTP clock with adjfine(), > adjtime(), gettime64() and settime64() is added. >=20 > AX88179A and AX88279 implement reception of the TX timestamp information > differently: the AX279A uses USB bulk requests, whereas the AX88179A uses > a control transfer read. Since the control transfer reads via usbnet are > synchronous (in contrast to the AX88279A bulk reads), they are handled as > work items. >=20 > TX frames for which a timestamp is requested are copied to a separate > ptp->tx_skbs queue and matched in a delayed work against received TX > timestamps. >=20 > Signed-off-by: Birger Koblitz > --- > =C2=A0drivers/net/usb/Kconfig=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |= =C2=A0=C2=A0 1 + > =C2=A0drivers/net/usb/Makefile=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2= =A0=C2=A0 2 +- > =C2=A0drivers/net/usb/ax88179a_ptp.c | 845 ++++++++++++++++++++++++++++++= +++++++++++ > =C2=A0drivers/net/usb/ax88179a_ptp.h | 249 ++++++++++++ > =C2=A04 files changed, 1096 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig > index cc8f2e150339915908fe1c28dea82e1103bbf17d..2a811116d34dc1a5d2225d947= 662b983dac7ddfe 100644 > --- a/drivers/net/usb/Kconfig > +++ b/drivers/net/usb/Kconfig > @@ -166,6 +166,7 @@ config USB_USBNET > =C2=A0config USB_NET_AX8817X > =C2=A0=09tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" > =C2=A0=09depends on USB_USBNET > +=09depends on PTP_1588_CLOCK_OPTIONAL > =C2=A0=09select CRC32 > =C2=A0=09select PHYLINK > =C2=A0=09select AX88796B_PHY > diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile > index 4026f19ecb826a6465de38f1d9bb0e4c0af80421..812adcf839dc4061d4d6ef270= 25a26723bd51927 100644 > --- a/drivers/net/usb/Makefile > +++ b/drivers/net/usb/Makefile > @@ -13,7 +13,7 @@ obj-$(CONFIG_USB_LAN78XX)=09+=3D lan78xx.o > =C2=A0obj-$(CONFIG_USB_NET_AX8817X)=09+=3D asix.o > =C2=A0asix-y :=3D asix_devices.o asix_common.o ax88172a.o > =C2=A0obj-$(CONFIG_USB_NET_AX88179)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 +=3D ax= 88179.o > -ax88179-y :=3D ax88179_178a.o ax88179a_devices.o ax88179_lib.o > +ax88179-y :=3D ax88179_178a.o ax88179a_devices.o ax88179_lib.o ax88179a_= ptp.o > =C2=A0obj-$(CONFIG_USB_NET_CDCETHER)=09+=3D cdc_ether.o > =C2=A0obj-$(CONFIG_USB_NET_CDC_EEM)=09+=3D cdc_eem.o > =C2=A0obj-$(CONFIG_USB_NET_DM9601)=09+=3D dm9601.o > diff --git a/drivers/net/usb/ax88179a_ptp.c b/drivers/net/usb/ax88179a_pt= p.c > new file mode 100644 > index 0000000000000000000000000000000000000000..9a04a93e509523436ccd19895= b2a6cb6a819aea0 > --- /dev/null > +++ b/drivers/net/usb/ax88179a_ptp.c > @@ -0,0 +1,845 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > + > +#include > +#include Sort headers alphabetically.=20 > +#include > +#include "ax88179_lib.h" > +#include "ax88179a_ptp.h" > + > +#define ptp_to_dev(ptp) container_of(ptp, struct ax88179a_ptp, ptp_ci) > + > +static int ax88279_ptp_pbus_write(struct usbnet *dev, u16 offset, > +=09=09=09=09=C2=A0 u16 len, void *data) > +{ > +=09int ret; > + > +=09ret =3D ax88179_write_cmd(dev, AX88279_PBUS_A32, offset, > +=09=09=09=09AX88279_PTP_REG_BASE_ADDR_HI, len, data); > +=09if (ret < 0) > +=09=09return ret; > + > +=09return 0; > +} > + > +static int ax88279_ptp_pbus_write_u32(struct usbnet *dev, u16 offset, u3= 2 data) > +{ > +=09u32 buf =3D data; > + > +=09return ax88279_ptp_pbus_write(dev, offset, 4, &buf); > +} > + > +static int ax88279_ptp_clk_read(struct usbnet *dev, u16 offset, u16 len,= void *data) > +{ > +=09int ret; > + > +=09ret =3D ax88179_read_cmd(dev, AX_PTP_CLK, 0x0002, offset, len, data); > +=09if (ret < 0) > +=09=09return ret; > + > +=09return 0; > +} > + > +static int ax88279_ptp_clk_write(struct usbnet *dev, u16 offset, u16 len= , void *data) > +{ > +=09int ret; > + > +=09ret =3D ax88179_write_cmd(dev, AX88279_PBUS_A32, offset, > +=09=09=09=09AX88279_PTP_REG_BASE_ADDR_HI, len, data); > +=09if (ret < 0) > +=09=09return ret; > + > +=09return 0; > +} > + > +void ax88179a_process_rx_ts(struct sk_buff *skb, u64 timestamp_l, u64 ti= mestamp_h) > +{ > +=09struct skb_shared_hwtstamps *shhwtstamps =3D skb_hwtstamps(skb); > +=09u64 time64; > + > +=09timestamp_h <<=3D 32; > +=09timestamp_h |=3D (timestamp_l >> 32) & 0xFFFFFFFF; > +=09time64 =3D (timestamp_h * NSEC_PER_SEC); > +=09time64 +=3D (timestamp_l & 0xFFFFFFFF); > + > +=09memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps)); > + > +=09shhwtstamps->hwtstamp =3D ktime_sub_ns(ns_to_ktime(time64), 0); > +} > + > +static int ax88179a_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_= ppm) > +{ > +=09long ppb =3D scaled_ppm_to_ppb(scaled_ppm); > +=09struct ax88179a_ptp *ax88179a_ptp; > +=09struct ax88179_data *ax179_data; > +=09bool neg_adj =3D false; > +=09u32 new_addend_val; > +=09u64 adjust_val; > +=09int ret =3D 0; > + > +=09ax88179a_ptp =3D ptp_to_dev(ptp); > +=09ax179_data=C2=A0 =3D ax88179a_ptp->ax179_data; Here's a double" "^^. Reviewed-by: Manuel Ebner Thanks Manuel > [...]