The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: sukhdeeps@marvell.com, netdev@vger.kernel.org
Cc: irusskikh@marvell.com, epomozov@marvell.com,
	richardcochran@gmail.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	vadim.fedorenko@linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 9/9] net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
Date: Tue, 12 May 2026 12:17:25 +0200	[thread overview]
Message-ID: <f8ab7286-8a4f-4dfd-96b1-db1f05b1f2b1@redhat.com> (raw)
In-Reply-To: <20260508120156.3060-10-sukhdeeps@marvell.com>

On 5/8/26 2:01 PM, sukhdeeps@marvell.com wrote:
> From: Sukhdeep Singh <sukhdeeps@marvell.com>
> 
> Add IEEE 1588 PTP support for the AQC113 (Antigua) network controller
> alongside the existing AQC107 (Atlantic) PTP implementation.
> 
> AQC113 PTP uses a different hardware architecture from AQC107:
> - Dual TSG clocks (sel 0 for PTP, sel 1 for PTM) instead of PHY-based
>   timestamping
> - TX timestamp via descriptor writeback instead of firmware mailbox
> - Per-instance PTP timestamp offsets instead of global static table
> - Hardware L3/L4 filters for PTP multicast steering with IPv4 and
>   IPv6 support (4 filter slots for multicast addresses)
> - Direct hardware clock control instead of firmware-mediated access
> 
> Key implementation details:
> 
> PTP clock management:
> - Add aq_ptp_state enum to distinguish first init, link up, and no
>   link states for proper clock initialization
> - On AQC113, only reset the clock on first init (not on every link
>   change) to avoid disrupting ongoing PTP synchronization
> - Re-apply RX filters on link change since hardware state is lost
> 
> TX timestamp path:
> - Add per-packet TX timestamp request via request_ts/clk_sel in the
>   ring buffer descriptor
> - Poll for TX timestamp completion in aq_ring_tx_clean() with a
>   timeout mechanism (aq_ptp_tx_ts_timedout/clear)
> - Set AQ_HW_TXD_CTL_TS_EN in TX descriptors for timestamp-requested
>   packets
> 
> RX filter management:
> - Replace single UDP filter with array of 4 for IPv4/IPv6 multicast
>   PTP addresses (224.0.1.129, 224.0.0.107, ff0e::181, ff02::6b)
> - Add aq_ptp_dpath_enable() for comprehensive filter setup/teardown
> - Add aq_ptp_parse_rx_filters() to map hwtstamp_rx_filters to L2/L4
>   enable flags
> 
> PTP TX path in aq_main.c:
> - Add IPv6 PTP packet detection using ipv6_hdr()->nexthdr
> - Use PTP_EV_PORT/PTP_GEN_PORT defines instead of magic numbers
> - Move skb_tx_timestamp() to non-PTP path to avoid double timestamps
> 
> IRQ and initialization:
> - Account for PTP IRQ vector (AQ_HW_PTP_IRQS) in vector math
> - Move filter/VLAN rule application to aq_nic_start() for proper
>   ordering after PTP ring setup
> - Add AQ_HW_FLAG_STARTED flag management in open/close
> 
> HW layer (hw_atl2.c):
> - Implement PTP clock enable/disable, read, adjust, increment
> - Add GPIO pulse generation for PPS output
> - Add TX/RX PTP ring initialization
> - Add TX timestamp descriptor readback
> - Add RX timestamp extraction from packet trailer
> - Re-enable PTP after hardware reset
> - Wire all PTP ops into hw_atl2_ops table
> 
> Per-instance PTP offsets with empirically measured values for AQC113
> at each link speed (100M/1G/2.5G/5G/10G).
> 
> Signed-off-by: Sukhdeep Singh <sukhdeeps@marvell.com>
> ---
>  .../net/ethernet/aquantia/atlantic/aq_hw.h    |   1 +
>  .../net/ethernet/aquantia/atlantic/aq_main.c  |  34 +-
>  .../net/ethernet/aquantia/atlantic/aq_nic.c   |  48 +-
>  .../ethernet/aquantia/atlantic/aq_pci_func.c  |   4 +-
>  .../net/ethernet/aquantia/atlantic/aq_ptp.c   | 535 ++++++++++++++----
>  .../net/ethernet/aquantia/atlantic/aq_ptp.h   |  15 +-
>  .../net/ethernet/aquantia/atlantic/aq_ring.c  |  42 +-
>  .../aquantia/atlantic/hw_atl2/hw_atl2.c       | 179 +++++-
>  .../aquantia/atlantic/hw_atl2/hw_atl2.h       |  12 +
>  .../atlantic/hw_atl2/hw_atl2_internal.h       |   3 +-
>  .../aquantia/atlantic/hw_atl2/hw_atl2_utils.h |  10 +
>  11 files changed, 710 insertions(+), 173 deletions(-)

Very large patch, you should try to break it in smaller chunks.

> @@ -1035,46 +1246,49 @@ static struct ptp_clock_info aq_ptp_clock = {
>  	.pin_config	= NULL,
>  };
>  
> -#define ptp_offset_init(__idx, __mbps, __egress, __ingress)   do { \
> -		ptp_offset[__idx].mbps = (__mbps); \
> -		ptp_offset[__idx].egress = (__egress); \
> -		ptp_offset[__idx].ingress = (__ingress); } \
> -		while (0)
> +static inline void ptp_offset_init(struct aq_ptp_s *aq_ptp, int idx,
> +				   unsigned int mbps, int egress, int ingress)

'inline' in c files are highly discouraged. Use them only for critical
path and providing reasoning (i.e. the compiler does the wrong thing
otherwise).

[...]
> diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
> index e270327e47fd..a52d6d3fe464 100644
> --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
> +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
> @@ -308,24 +308,30 @@ bool aq_ring_tx_clean(struct aq_ring_s *self)
>  			}
>  		}
>  
> -		if (likely(!buff->is_eop))
> -			goto out;
> -
> -		if (buff->skb) {
> -			u64_stats_update_begin(&self->stats.tx.syncp);
> -			++self->stats.tx.packets;
> -			self->stats.tx.bytes += buff->skb->len;
> -			u64_stats_update_end(&self->stats.tx.syncp);
> -			dev_kfree_skb_any(buff->skb);
> -		} else if (buff->xdpf) {
> -			u64_stats_update_begin(&self->stats.tx.syncp);
> -			++self->stats.tx.packets;
> -			self->stats.tx.bytes += xdp_get_frame_len(buff->xdpf);
> -			u64_stats_update_end(&self->stats.tx.syncp);
> -			xdp_return_frame_rx_napi(buff->xdpf);
> -		}
> +		if (unlikely(buff->is_eop)) {

I see this is pre-exiting code, but why is this condition unlikely? I
suppose the NIC is expected to receive packets :-P

Also, using a goto statement would avoid excessive indentation.

> +			if (unlikely(buff->request_ts) &&
> +			    self->aq_nic->aq_hw_ops->hw_ring_tx_ptp_get_ts) {
> +				u64 ts = self->aq_nic->aq_hw_ops->hw_ring_tx_ptp_get_ts(self);
> +
> +				if (!ts)
> +					break;
>  
> -out:
> +				aq_ptp_tx_hwtstamp(self->aq_nic, ts);
> +			}
> +			if (buff->skb) {
> +				u64_stats_update_begin(&self->stats.tx.syncp);
> +				++self->stats.tx.packets;
> +				self->stats.tx.bytes += buff->skb->len;
> +				u64_stats_update_end(&self->stats.tx.syncp);
> +				dev_kfree_skb_any(buff->skb);
> +			} else if (buff->xdpf) {
> +				u64_stats_update_begin(&self->stats.tx.syncp);
> +				++self->stats.tx.packets;
> +				self->stats.tx.bytes += xdp_get_frame_len(buff->xdpf);
> +				u64_stats_update_end(&self->stats.tx.syncp);
> +				xdp_return_frame_rx_napi(buff->xdpf);
> +			}
> +		}
>  		buff->skb = NULL;
>  		buff->xdpf = NULL;
>  		buff->pa = 0U;

[...]
> @@ -886,6 +912,138 @@ static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self)
>  	return &self->curr_stats;
>  }
>  
> +static u32 hw_atl2_tsg_int_clk_freq(struct aq_hw_s *self)
> +{
> +	return AQ2_HW_PTP_COUNTER_HZ;
> +}

Why do you need an helper here? Using the macro directly should be just
fine.



  parent reply	other threads:[~2026-05-12 10:17 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 13:56 [PATCH net-next 0/9] net: atlantic: add PTP support for AQC113 (Antigua) sukhdeeps
2026-05-06 13:56 ` [PATCH net-next 1/9] net: atlantic: correct L3L4 filter flow_type masking and IPv6 handling masking and IPv6 handling sukhdeeps
2026-05-06 13:56 ` [PATCH net-next 2/9] net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write sukhdeeps
2026-05-12  9:53   ` Paolo Abeni
2026-05-06 13:57 ` [PATCH net-next 3/9] net: atlantic: decouple aq_set_data_fl3l4() from driver internals driver internals sukhdeeps
2026-05-06 13:57 ` [PATCH net-next 4/9] net: atlantic: add AQC113 hardware register definitions and accessors definitions and accessors sukhdeeps
2026-05-06 13:57 ` [PATCH net-next 5/9] net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query sukhdeeps
2026-05-12  9:53   ` Paolo Abeni
2026-05-06 13:57 ` [PATCH net-next 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management sukhdeeps
2026-05-06 22:43   ` Vadim Fedorenko
2026-05-08  6:56     ` [EXTERNAL] " Sukhdeep Soni [C]
2026-05-12  9:54   ` Paolo Abeni
2026-05-06 13:57 ` [PATCH net-next 7/9] net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup sukhdeeps
2026-05-12  9:54   ` Paolo Abeni
2026-05-06 13:57 ` [PATCH net-next 8/9] net: atlantic: extend hw_ops and TX descriptor for AQC113 PTP for AQC113 PTP sukhdeeps
2026-05-06 13:57 ` [PATCH net-next 9/9] net: atlantic: add PTP support for AQC113 (Antigua) (Antigua) sukhdeeps
2026-05-12  9:54   ` Paolo Abeni
2026-05-08 12:01 ` [PATCH net-next v2 0/9] net: atlantic: add PTP support for AQC113 (Antigua) sukhdeeps
2026-05-08 12:01   ` [PATCH net-next v2 1/9] net: atlantic: correct L3L4 filter flow_type masking and IPv6 handling masking and IPv6 handling sukhdeeps
2026-05-08 12:01   ` [PATCH net-next v2 2/9] net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write sukhdeeps
2026-05-08 12:01   ` [PATCH net-next v2 3/9] net: atlantic: decouple aq_set_data_fl3l4() from driver internals driver internals sukhdeeps
2026-05-08 12:01   ` [PATCH net-next v2 4/9] net: atlantic: add AQC113 hardware register definitions and accessors definitions and accessors sukhdeeps
2026-05-08 12:01   ` [PATCH net-next v2 5/9] net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query sukhdeeps
2026-05-08 12:01   ` [PATCH net-next v2 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management sukhdeeps
2026-05-12 10:00     ` Paolo Abeni
2026-05-12 10:04     ` Paolo Abeni
2026-05-08 12:01   ` [PATCH net-next v2 7/9] net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup sukhdeeps
2026-05-08 12:01   ` [PATCH net-next v2 8/9] net: atlantic: extend hw_ops and TX descriptor for AQC113 PTP for AQC113 PTP sukhdeeps
2026-05-08 12:01   ` [PATCH net-next v2 9/9] net: atlantic: add PTP support for AQC113 (Antigua) (Antigua) sukhdeeps
2026-05-12 10:01     ` Paolo Abeni
2026-05-12 10:17     ` Paolo Abeni [this message]
2026-05-08 23:06   ` [PATCH net-next v2 0/9] net: atlantic: add PTP support for AQC113 (Antigua) Jakub Kicinski
2026-05-11 12:26     ` [EXTERNAL] " Sukhdeep Soni [C]
2026-05-11 23:50       ` Jakub Kicinski
2026-05-12 11:27   ` Simon Horman

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=f8ab7286-8a4f-4dfd-96b1-db1f05b1f2b1@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=epomozov@marvell.com \
    --cc=irusskikh@marvell.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=sukhdeeps@marvell.com \
    --cc=vadim.fedorenko@linux.dev \
    /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