> -----Original Message----- > From: Yangbo Lu <yangbo...@nxp.com> > Sent: 2021年4月12日 17:03 > To: netdev@vger.kernel.org > Cc: Y.b. Lu <yangbo...@nxp.com>; David S . Miller <da...@davemloft.net>; > Richard Cochran <richardcoch...@gmail.com>; Claudiu Manoil > <claudiu.man...@nxp.com>; Jakub Kicinski <k...@kernel.org>; Vladimir > Oltean <vladimir.olt...@nxp.com>; Russell King <li...@armlinux.org.uk> > Subject: [net-next, v3, 2/2] enetc: support PTP Sync packet one-step > timestamping > > This patch is to add support for PTP Sync packet one-step timestamping. > Since ENETC single-step register has to be configured dynamically per packet > for correctionField offeset and UDP checksum update, current one-step > timestamping packet has to be sent only when the last one completes > transmitting on hardware. So, on the TX, this patch handles one-step > timestamping packet as below: > > - Trasmit packet immediately if no other one in transfer, or queue to > skb queue if there is already one in transfer. > The test_and_set_bit_lock() is used here to lock and check state. > - Start a work when complete transfer on hardware, to release the bit > lock and to send one skb in skb queue if has.
Sorry, I made a mistake on the implementation of the logic. A fix-up was sent. https://patchwork.kernel.org/project/netdevbpf/patch/20210413034817.8924-1-yangbo...@nxp.com/ > > And the configuration for one-step timestamping on ENETC before > transmitting is, > > - Set one-step timestamping flag in extension BD. > - Write 30 bits current timestamp in tstamp field of extension BD. > - Update PTP Sync packet originTimestamp field with current timestamp. > - Configure single-step register for correctionField offeset and UDP > checksum update. > > Signed-off-by: Yangbo Lu <yangbo...@nxp.com> > --- > Changes for v2: > - Rebased. > - Fixed issues from patchwork checks. > - netif_tx_lock for one-step timestamping packet sending. > Changes for v3: > - Used system workqueue. > - Set bit lock when transmitted one-step packet, and scheduled > work when completed. The worker cleared the bit lock, and > transmitted one skb in skb queue if has, instead of a loop. > --- > drivers/net/ethernet/freescale/enetc/enetc.c | 191 ++++++++++++++++-- > drivers/net/ethernet/freescale/enetc/enetc.h | 20 +- > .../ethernet/freescale/enetc/enetc_ethtool.c | 3 +- > .../net/ethernet/freescale/enetc/enetc_hw.h | 7 + > 4 files changed, 195 insertions(+), 26 deletions(-) [...]