netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Parvathi Pudi <parvathi@couthit.com>
To: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Cc: parvathi <parvathi@couthit.com>, danishanwar <danishanwar@ti.com>,
	 rogerq <rogerq@kernel.org>,
	andrew+netdev <andrew+netdev@lunn.ch>,
	 davem <davem@davemloft.net>, edumazet <edumazet@google.com>,
	 kuba <kuba@kernel.org>, pabeni <pabeni@redhat.com>,
	 robh <robh@kernel.org>, krzk+dt <krzk+dt@kernel.org>,
	 conor+dt <conor+dt@kernel.org>, ssantosh <ssantosh@kernel.org>,
	 richardcochran <richardcochran@gmail.com>,
	 s hauer <s.hauer@pengutronix.de>,
	m-karicheri2 <m-karicheri2@ti.com>,
	 glaroque <glaroque@baylibre.com>, afd <afd@ti.com>,
	 saikrishnag@marvell.com, m-malladi <m-malladi@ti.com>,
	 jacob e keller <jacob.e.keller@intel.com>,
	 diogo ivo <diogo.ivo@siemens.com>,
	 javier carrasco cruz <javier.carrasco.cruz@gmail.com>,
	 horms <horms@kernel.org>, s-anna <s-anna@ti.com>,
	 basharath <basharath@couthit.com>,
	 linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	 netdev <netdev@vger.kernel.org>,
	 devicetree <devicetree@vger.kernel.org>,
	 linux-kernel <linux-kernel@vger.kernel.org>,
	 pratheesh <pratheesh@ti.com>, Prajith Jayarajan <prajith@ti.com>,
	 Vignesh Raghavendra <vigneshr@ti.com>,
	praneeth <praneeth@ti.com>,  srk <srk@ti.com>,
	rogerq <rogerq@ti.com>,  krishna <krishna@couthit.com>,
	pmohan <pmohan@couthit.com>,  mohan <mohan@couthit.com>
Subject: Re: [PATCH net-next v8 06/11] net: ti: prueth: Adds HW timestamping support for PTP using PRU-ICSS IEP module
Date: Fri, 13 Jun 2025 18:23:42 +0530 (IST)	[thread overview]
Message-ID: <909024001.1496409.1749819222224.JavaMail.zimbra@couthit.local> (raw)
In-Reply-To: <cdcd54ff-ff67-4ad8-8aa7-baa711928242@linux.dev>

Hi,

> On 10/06/2025 13:32, Parvathi Pudi wrote:
>> From: Roger Quadros <rogerq@ti.com>
>> 
>> PRU-ICSS IEP module, which is capable of timestamping RX and
>> TX packets at HW level, is used for time synchronization by PTP4L.
>> 
>> This change includes interaction between firmware and user space
>> application (ptp4l) with required packet timestamps. The driver
>> initializes the PRU firmware with appropriate mode and configuration
>> flags. Firmware updates local registers with the flags set by driver
>> and uses for further operation. RX SOF timestamp comes along with
>> packet and firmware will rise interrupt with TX SOF timestamp after
>> pushing the packet on to the wire.
>> 
>> IEP driver is available in upstream and we are reusing for hardware
>> configuration for ICSSM as well. On top of that we have extended it
>> with the changes for AM57xx SoC.
>> 
>> Extended ethtool for reading HW timestamping capability of the PRU
>> interfaces.
>> 
>> Currently ordinary clock (OC) configuration has been validated with
>> Linux ptp4l.
>> 
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> Signed-off-by: Andrew F. Davis <afd@ti.com>
>> Signed-off-by: Basharath Hussain Khaja <basharath@couthit.com>
>> Signed-off-by: Parvathi Pudi <parvathi@couthit.com>
>> ---
>>   drivers/net/ethernet/ti/icssg/icss_iep.c      |  42 ++
>>   drivers/net/ethernet/ti/icssm/icssm_ethtool.c |  23 +
>>   drivers/net/ethernet/ti/icssm/icssm_prueth.c  | 443 +++++++++++++++++-
>>   drivers/net/ethernet/ti/icssm/icssm_prueth.h  |  11 +
>>   .../net/ethernet/ti/icssm/icssm_prueth_ptp.h  |  85 ++++
>>   5 files changed, 602 insertions(+), 2 deletions(-)
>>   create mode 100644 drivers/net/ethernet/ti/icssm/icssm_prueth_ptp.h
> 
> [...]
> 
>> @@ -732,9 +949,22 @@ int icssm_emac_rx_packet(struct prueth_emac *emac, u16
>> *bd_rd_ptr,
>>   		src_addr += actual_pkt_len;
>>   	}
>>   
>> +	if (pkt_info->timestamp) {
>> +		src_addr = (void *)PTR_ALIGN((uintptr_t)src_addr,
>> +					   ICSS_BLOCK_SIZE);
>> +		dst_addr = &ts;
>> +		memcpy(dst_addr, src_addr, sizeof(ts));
>> +	}
>> +
>>   	if (!pkt_info->sv_frame) {
>>   		skb_put(skb, actual_pkt_len);
>>   
>> +		if (icssm_prueth_ptp_rx_ts_is_enabled(emac) &&
>> +		    pkt_info->timestamp) {
>> +			ssh = skb_hwtstamps(skb);
>> +			memset(ssh, 0, sizeof(*ssh));
>> +			ssh->hwtstamp = ns_to_ktime(ts);
>> +		}
>>   		/* send packet up the stack */
>>   		skb->protocol = eth_type_trans(skb, ndev);
>>   		netif_receive_skb(skb);
> 
> Could you please explain why do you need to copy timestamp to a
> temporary variable if you won't use it in some cases? I believe these
> 2 blocks should be placed under the last if condition and simplified a
> bit, like
> 
> +		if (icssm_prueth_ptp_rx_ts_is_enabled(emac) &&
> +		    pkt_info->timestamp) {
> +			src_addr = (void*)PTR_ALIGN((uintptr_t)src_addr,
> +					   ICSS_BLOCK_SIZE);
> +			memcpy(&ts, src_addr, sizeof(ts));
> +			ssh = skb_hwtstamps(skb);
> +			ssh->hwtstamp = ns_to_ktime(ts);
> +		}
> 
> This will avoid useless copy when the packet will be dropped anyway, WDYT?

Yes, we can merge both the if conditions to make it simple.

We will address this in the next version.

Thanks and Regards,
Parvathi.

  reply	other threads:[~2025-06-13 12:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10 10:57 [PATCH net-next v8 00/11] PRU-ICSSM Ethernet Driver Parvathi Pudi
2025-06-10 10:57 ` [PATCH net-next v8 01/11] dt-bindings: net: ti: Adds DUAL-EMAC mode support on PRU-ICSS2 for AM57xx, AM43xx and AM33xx SOCs Parvathi Pudi
2025-06-10 10:57 ` [PATCH net-next v8 02/11] net: ti: prueth: Adds ICSSM Ethernet driver Parvathi Pudi
2025-06-10 10:57 ` [PATCH net-next v8 03/11] net: ti: prueth: Adds PRUETH HW and SW configuration Parvathi Pudi
2025-06-10 12:32 ` [PATCH net-next v8 04/11] net: ti: prueth: Adds link detection, RX and TX support Parvathi Pudi
2025-06-10 12:32 ` [PATCH net-next v8 05/11] net: ti: prueth: Adds ethtool support for ICSSM PRUETH Driver Parvathi Pudi
2025-06-10 12:32 ` [PATCH net-next v8 06/11] net: ti: prueth: Adds HW timestamping support for PTP using PRU-ICSS IEP module Parvathi Pudi
2025-06-11 10:29   ` Vadim Fedorenko
2025-06-13 12:53     ` Parvathi Pudi [this message]
2025-06-10 12:32 ` [PATCH net-next v8 07/11] net: ti: prueth: Adds support for network filters for traffic control supported by PRU-ICSS Parvathi Pudi
2025-06-10 13:58 ` [PATCH net-next v8 08/11] net: ti: prueth: Adds support for RX interrupt coalescing/pacing Parvathi Pudi
2025-06-10 13:58 ` [PATCH net-next v8 09/11] net: ti: prueth: Adds power management support for PRU-ICSS Parvathi Pudi
2025-06-10 13:58 ` [PATCH net-next v8 10/11] net: ti: prueth: Adds support for PRUETH on AM33x and AM43x SOCs Parvathi Pudi
2025-06-10 13:58 ` [PATCH net-next v8 11/11] net: ti: prueth: Adds PTP OC Support for AM335x and AM437x Parvathi Pudi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=909024001.1496409.1749819222224.JavaMail.zimbra@couthit.local \
    --to=parvathi@couthit.com \
    --cc=afd@ti.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=basharath@couthit.com \
    --cc=conor+dt@kernel.org \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=diogo.ivo@siemens.com \
    --cc=edumazet@google.com \
    --cc=glaroque@baylibre.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=krishna@couthit.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    --cc=m-malladi@ti.com \
    --cc=mohan@couthit.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pmohan@couthit.com \
    --cc=prajith@ti.com \
    --cc=praneeth@ti.com \
    --cc=pratheesh@ti.com \
    --cc=richardcochran@gmail.com \
    --cc=robh@kernel.org \
    --cc=rogerq@kernel.org \
    --cc=rogerq@ti.com \
    --cc=s-anna@ti.com \
    --cc=s.hauer@pengutronix.de \
    --cc=saikrishnag@marvell.com \
    --cc=srk@ti.com \
    --cc=ssantosh@kernel.org \
    --cc=vadim.fedorenko@linux.dev \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).