net: atlantic: add PTP support for AQC113 (Antigua)
Subsystems (4)
[email protected]
maintainercover net: atlantic: add PTP support for AQC113 (Antigua)
From: Sukhdeep Singh <[email protected]>
This series adds IEEE 1588 PTP support for the AQC113 (Antigua) network controller. AQC113 is the successor to the existing AQC107 (Atlantic) chip already supported by the atlantic driver.
AQC113 uses a substantially different hardware architecture for PTP compared to AQC107:
- Dual on-chip TSG clocks with direct register access instead of PHY-based timestamping via firmware
- TX timestamps via descriptor writeback instead of firmware mailbox
- Hardware L3/L4 RX filters for PTP multicast steering with both IPv4 and IPv6 support
- Reference-counted shared filter slots managed through an Action Resolver Table (ART), allowing multiple rules to share L3/L4 hardware filters when their match criteria are identical
The series is structured in three parts:
Patches 1-3 prepare the existing L3/L4 filter path:
Patch 1 corrects flow_type masking and IPv6 address handling in aq_set_data_fl3l4(). Patch 2 moves the active_ipv4/ipv6 bitmap updates to after the hardware write succeeds. Patch 3 decouples the function from driver-internal structures so it can be called directly by the AQC113 PTP filter setup code.
Patches 4-6 add the AQC113 hardware infrastructure:
Patch 4 adds the low-level register definitions and accessor functions. Patch 5 adds filter data structures and firmware capability query. Patch 6 implements the complete L2/L3/L4 RX filter management layer including the reference-counted sharing and ART integration.
Patches 7-9 add the AQC113 PTP feature:
Patch 7 reserves the dedicated PTP traffic class buffer and configures the TX path. Patch 8 extends the hw_ops interface with PTP-specific function pointers and updates AQC107 to the new signatures. Patch 9 implements the full PTP subsystem integration for AQC113.
The existing AQC107 PTP implementation is not functionally changed by this series; AQC113-specific code paths are gated on chip detection throughout.
Tested on AQC113 at 1G, 2.5G, 5G, and 10G link speeds using ptp4l/phc2sys with hardware timestamping in both L2 and L4 (IPv4/IPv6) modes.
Sukhdeep Singh (9):
net: atlantic: correct L3L4 filter flow_type masking and IPv6 handling
net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write
net: atlantic: decouple aq_set_data_fl3l4() from driver internals
net: atlantic: add AQC113 hardware register definitions and accessors
net: atlantic: add AQC113 filter data structures and firmware query
net: atlantic: implement AQC113 L2/L3/L4 RX filter management
net: atlantic: add AQC113 PTP traffic class and TX path setup
net: atlantic: extend hw_ops and TX descriptor for AQC113 PTP
net: atlantic: add PTP support for AQC113 (Antigua)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c | 64 +- drivers/net/ethernet/aquantia/atlantic/aq_filters.h | 3 + drivers/net/ethernet/aquantia/atlantic/aq_hw.h | 37 +- drivers/net/ethernet/aquantia/atlantic/aq_main.c | 33 +- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 51 +- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 4 +- drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 531 +++++++-- drivers/net/ethernet/aquantia/atlantic/aq_ptp.h | 15 +- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 42 +- drivers/net/ethernet/aquantia/atlantic/aq_ring.h | 4 +- drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c | 15 +- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c | 813 +++++++++++- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.h | 12 + drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h | 69 +- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.c | 360 ++++++ drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.h | 107 +- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh_internal.h | 204 ++- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c | 33 + drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.h | 15 + drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c | 52 + 20 files changed, 2244 insertions(+), 224 deletions(-)
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH 1/9 net: atlantic: correct L3L4 filter flow_type masking and IPv6 handling masking and IPv6 handling
From: Sukhdeep Singh <[email protected]>
Correct three issues in aq_set_data_fl3l4() required for the AQC113 PTP filter path introduced later in this series:
1. Mask FLOW_EXT from flow_type before the protocol switch statement. Flow types with FLOW_EXT set (e.g. TCP_V4_FLOW | FLOW_EXT) fall through to the default case and skip protocol comparison flags.
2. Extend the L3 address comparison check to cover all four IPv6 words. The original code only checked ip_src[0]/ip_dst[0] and required !is_ipv6, so CMP_SRC_ADDR_L3/CMP_DEST_ADDR_L3 were never set for IPv6 filters.
3. Use explicit flow type checks for port extraction instead of negating IP_USER_FLOW/IPV6_USER_FLOW. The old check did not mask FLOW_EXT, so IP_USER_FLOW | FLOW_EXT would incorrectly attempt port extraction. Use the actual flow type to pick the correct union member directly.
--- .../ethernet/aquantia/atlantic/aq_filters.c | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c +17 -16
@@ -472,6 +472,7 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic, {struct aq_hw_rx_fltrs_s *rx_fltrs =aq_get_hw_rx_fltrs (aq_nic);const struct ethtool_rx_flow_spec *fsp = &aq_rx_fltr->aq_fsp; +u32 flow = fsp->flow_type & ~FLOW_EXT ;memset (data,0 ,sizeof (*data));
@@ -490,7 +491,7 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic, data->cmd |=HW_ATL_RX_ENABLE_FLTR_L3L4 ; -switch (fsp->flow_type) { +switch (flow) {case TCP_V4_FLOW :case TCP_V6_FLOW : data->cmd |=HW_ATL_RX_ENABLE_CMP_PROT_L4 ;
@@ -527,23 +528,23 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic, } data->cmd |=HW_ATL_RX_ENABLE_L3_IPV6 ; } -if (fsp->flow_type !=IP_USER_FLOW && - fsp->flow_type !=IPV6_USER_FLOW ) { -if (!data->is_ipv6) { - data->p_dst = -ntohs (fsp->h_u.tcp_ip4_spec.pdst); - data->p_src = -ntohs (fsp->h_u.tcp_ip4_spec.psrc); - }else { - data->p_dst = -ntohs (fsp->h_u.tcp_ip6_spec.pdst); - data->p_src = -ntohs (fsp->h_u.tcp_ip6_spec.psrc); - } +if (flow ==TCP_V4_FLOW || flow ==UDP_V4_FLOW || + flow ==SCTP_V4_FLOW ) { + data->p_dst =ntohs (fsp->h_u.tcp_ip4_spec.pdst); + data->p_src =ntohs (fsp->h_u.tcp_ip4_spec.psrc); + } +if (flow ==TCP_V6_FLOW || flow ==UDP_V6_FLOW || + flow ==SCTP_V6_FLOW ) { + data->p_dst =ntohs (fsp->h_u.tcp_ip6_spec.pdst); + data->p_src =ntohs (fsp->h_u.tcp_ip6_spec.psrc); } -if (data->ip_src[0 ] && !data->is_ipv6) +if (data->ip_src[0 ] || + (data->is_ipv6 && (data->ip_src[1 ] || data->ip_src[2 ] || + data->ip_src[3 ]))) data->cmd |=HW_ATL_RX_ENABLE_CMP_SRC_ADDR_L3 ; -if (data->ip_dst[0 ] && !data->is_ipv6) +if (data->ip_dst[0 ] || + (data->is_ipv6 && (data->ip_dst[1 ] || data->ip_dst[2 ] || + data->ip_dst[3 ]))) data->cmd |=HW_ATL_RX_ENABLE_CMP_DEST_ADDR_L3 ;if (data->p_dst) data->cmd |=HW_ATL_RX_ENABLE_CMP_DEST_PORT_L4 ;
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH 2/9 net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Move active_ipv4/active_ipv6 bitmap updates from aq_set_data_fl3l4() into aq_add_del_fl3l4() after the hardware write succeeds. The bitmaps track which filter slots are actively programmed in hardware and must only be updated once the HW write is confirmed.
Also remove bitmap manipulation from aq_nic_reserve_filter() and aq_nic_release_filter(). These functions manage filter slot reservation counts, not HW filter state. Setting active_ipv4 bits at reservation time (before any filter is programmed) and clearing them at release time (regardless of HW state) results in incorrect state visible to aq_check_approve_fl3l4() for IPv4/IPv6 mixing validation.
This corrected state management is required for the AQC113 L3L4 filter path introduced later in this series.
--- .../ethernet/aquantia/atlantic/aq_filters.c | 36 ++++++++++++------- .../net/ethernet/aquantia/atlantic/aq_nic.c | 3 -- 2 files changed, 23 insertions(+), 16 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c +23 -13
@@ -479,15 +479,8 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic, data->is_ipv6 = rx_fltrs->fl3l4.is_ipv6; data->location =HW_ATL_GET_REG_LOCATION_FL3L4 (fsp->location); -if (!add) { -if (!data->is_ipv6) - rx_fltrs->fl3l4.active_ipv4 &= ~BIT (data->location); -else - rx_fltrs->fl3l4.active_ipv6 &= - ~BIT ((data->location) /4 ); - +if (!add)return 0 ; - } data->cmd |=HW_ATL_RX_ENABLE_FLTR_L3L4 ;
@@ -515,11 +508,9 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic,ntohl (fsp->h_u.tcp_ip4_spec.ip4src); data->ip_dst[0 ] =ntohl (fsp->h_u.tcp_ip4_spec.ip4dst); - rx_fltrs->fl3l4.active_ipv4 |=BIT (data->location); }else {int i; - rx_fltrs->fl3l4.active_ipv6 |=BIT ((data->location) /4 );for (i =0 ; i <HW_ATL_RX_CNT_REG_ADDR_IPV6 ; ++i) { data->ip_dst[i] =ntohl (fsp->h_u.tcp_ip6_spec.ip6dst[i]);
@@ -574,16 +565,35 @@ static int aq_set_fl3l4(struct aq_hw_s *aq_hw,static int aq_add_del_fl3l4 (struct aq_nic_s *aq_nic,struct aq_rx_filter *aq_rx_fltr,bool add) { +struct aq_hw_rx_fltrs_s *rx_fltrs =aq_get_hw_rx_fltrs (aq_nic);const struct aq_hw_ops *aq_hw_ops = aq_nic->aq_hw_ops;struct aq_hw_s *aq_hw = aq_nic->aq_hw;struct aq_rx_filter_l3l4 data; +int err;if (unlikely (aq_rx_fltr->aq_fsp.location <AQ_RX_FIRST_LOC_FL3L4 || - aq_rx_fltr->aq_fsp.location >AQ_RX_LAST_LOC_FL3L4 || -aq_set_data_fl3l4 (aq_nic, aq_rx_fltr, &data, add))) + aq_rx_fltr->aq_fsp.location >AQ_RX_LAST_LOC_FL3L4 ))return -EINVAL ; -return aq_set_fl3l4 (aq_hw, aq_hw_ops, &data); +aq_set_data_fl3l4 (aq_nic, aq_rx_fltr, &data, add); + + err =aq_set_fl3l4 (aq_hw, aq_hw_ops, &data); +if (err) +return err; + +if (add) { +if (!data.is_ipv6) + rx_fltrs->fl3l4.active_ipv4 |=BIT (data.location); +else + rx_fltrs->fl3l4.active_ipv6 |=BIT (data.location /4 ); + }else { +if (!data.is_ipv6) + rx_fltrs->fl3l4.active_ipv4 &= ~BIT (data.location); +else + rx_fltrs->fl3l4.active_ipv6 &= ~BIT (data.location /4 ); + } + +return 0 ; } static int aq_add_del_rule(struct aq_nic_s *aq_nic,
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0 -3
@@ -1522,8 +1522,6 @@ u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type)case aq_rx_filter_l3l4: fltr_cnt =AQ_RX_LAST_LOC_FL3L4 -AQ_RX_FIRST_LOC_FL3L4 ; n_bit = fltr_cnt - self->aq_hw_rx_fltrs.fl3l4.reserved_count; - - self->aq_hw_rx_fltrs.fl3l4.active_ipv4 |=BIT (n_bit); self->aq_hw_rx_fltrs.fl3l4.reserved_count++; location = n_bit;break ;
@@ -1543,7 +1541,6 @@ void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type,break ;case aq_rx_filter_l3l4: self->aq_hw_rx_fltrs.fl3l4.reserved_count--; - self->aq_hw_rx_fltrs.fl3l4.active_ipv4 &= ~BIT (location);break ;default :break ;
Signature · 1 line
2.43.0
Paolo Abeni
maintainerRe: [PATCH net-next 2/9] net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write
This change moves the active_ipv4/active_ipv6 bitmap updates out of aq_set_data_fl3l4() and into aq_add_del_fl3l4() after the HW write, and removes the bitmap manipulation from aq_nic_reserve_filter() and aq_nic_release_filter().
Quoted 1 line
net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write
The subject line repeats "updates after HW write" twice. Was this intended, or should it read "net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write"?
A few other subjects in this series look like they have the same copy-paste pattern (for example "masking and IPv6 handling masking and IPv6 handling", "driver internals driver internals", "TX path setup TX path setup", "(Antigua) (Antigua)") and may want the same cleanup.
drivers/net/ethernet/aquantia/atlantic/aq_nic.c u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type) · line 1527
Quoted 13 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0
-2@@ -1522,8 +1522,6 @@ u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type)case aq_rx_filter_l3l4: fltr_cnt =AQ_RX_LAST_LOC_FL3L4 -AQ_RX_FIRST_LOC_FL3L4 ; n_bit = fltr_cnt - self->aq_hw_rx_fltrs.fl3l4.reserved_count; - - self->aq_hw_rx_fltrs.fl3l4.active_ipv4 |=BIT (n_bit); self->aq_hw_rx_fltrs.fl3l4.reserved_count++; location = n_bit;break ;
Could dropping the active_ipv4 update here regress PTP's IPv4/IPv6 collision protection?
The PTP path calls aq_nic_reserve_filter(aq_rx_filter_l3l4) from aq_ptp_init() to grab a single L3L4 slot, and then programs its IPv4 UDP filter by calling hw_ops->hw_filter_l3l4_set() directly from aq_ptp_hwtstamp_config_set() / aq_ptp_prepare_filters() — it never goes through aq_add_del_fl3l4() where the new bitmap update now lives.
Before this change, aq_nic_reserve_filter() set:
self->aq_hw_rx_fltrs.fl3l4.active_ipv4 |= BIT(n_bit);
which caused aq_check_approve_fl3l4() to reject any later IPv6 L3L4 rule, protecting PTP's reserved slot.
After this change, active_ipv4 stays zero while PTP is actively filtering IPv4 in hardware. Can a user now add an IPv6 L3L4 rule at AQ_RX_FIRST_LOC_FL3L4 + 4 (still within AQ_RX_LAST_LOC_FL3L4) and have the IPv6 filter program HW slots 4..7, silently overwriting PTP's IPv4 filter at HW slot 7?
I looked through the rest of the series including the AQC113 PTP patches (aq_ptp_dpath_enable / aq_ptp_add_a2_filter) and they also call hw_filter_l3l4_set() directly rather than going through aq_add_del_fl3l4(), so the reserved PTP slot does not get re-reflected into active_ipv4 by a later patch.
drivers/net/ethernet/aquantia/atlantic/aq_nic.c void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type, · line 1544
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0
-1@@ -1543,7 +1541,6 @@ void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type,break ;case aq_rx_filter_l3l4: self->aq_hw_rx_fltrs.fl3l4.reserved_count--; - self->aq_hw_rx_fltrs.fl3l4.active_ipv4 &= ~BIT (location);break ;
Would it be worth keeping these updates (or adding equivalent ones on the PTP reserve/release path) so that aq_check_approve_fl3l4() continues to see PTP's reserved slot as active_ipv4?
Signature · 1 line
This is an AI-generated review.
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next 2/9] net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write
On 12 May 2026, Paolo Abeni write:
Quoted 7 lines
net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write
This change moves the active_ipv4/active_ipv6 bitmap updates out of
aq_set_data_fl3l4()and intoaq_add_del_fl3l4()after the HW write, and removes the bitmap manipulation fromaq_nic_reserve_filter()andaq_nic_release_filter().
Quoted 5 lines
Quoted 1 line
net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write
The subject line repeats "updates after HW write" twice. Was this intended, or should it read "net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write"?
Removed repeated "updates after HW write" from subject.
Quoted 4 lines
A few other subjects in this series look like they have the same copy-paste pattern (for example "masking and IPv6 handling masking and IPv6 handling", "driver internals driver internals", "TX path setup TX path setup", "(Antigua) (Antigua)") and may want the same cleanup.
Yes, noticed the repeated copy-paste patterns in subjects. All corrected in v3.
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0
-0@@ -1522,8 +1522,6 @@ u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type)case aq_rx_filter_l3l4: fltr_cnt =AQ_RX_LAST_LOC_FL3L4 -AQ_RX_FIRST_LOC_FL3L4 ; n_bit = fltr_cnt - self->aq_hw_rx_fltrs.fl3l4.reserved_count;
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type) · line 1527
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0
-2- - self->aq_hw_rx_fltrs.fl3l4.active_ipv4 |=BIT (n_bit); self->aq_hw_rx_fltrs.fl3l4.reserved_count++; location = n_bit;break ;Could dropping the
active_ipv4update here regress PTP's IPv4/IPv6 collision protection?
Yes, this is a real regression — thank you for catching it.
Quoted 10 lines
The PTP path calls
aq_nic_reserve_filter(aq_rx_filter_l3l4)fromaq_ptp_init()to grab a single L3L4 slot, and then programs its IPv4 UDP filter by callinghw_ops->hw_filter_l3l4_set()directly fromaq_ptp_hwtstamp_config_set()/aq_ptp_prepare_filters()— it never goes throughaq_add_del_fl3l4()where the new bitmap update now lives.Before this change,
aq_nic_reserve_filter()set:self->aq_hw_rx_fltrs.fl3l4.active_ipv4 |= BIT(n_bit);
Quoted 8 lines
which caused
aq_check_approve_fl3l4()to reject any later IPv6 L3L4 rule, protecting PTP's reserved slot.After this change,
active_ipv4stays zero while PTP is actively filtering IPv4 in hardware. Can a user now add an IPv6 L3L4 rule atAQ_RX_FIRST_LOC_FL3L4+ 4 (still withinAQ_RX_LAST_LOC_FL3L4) and have the IPv6 filter program HW slots 4..7, silently overwriting PTP's IPv4 filter at HW slot 7?
You are correct. Removing active_ipv4 from aq_nic_reserve_filter() breaks PTP's
slot protection. Reverted in v3 — active_ipv4 updates are kept in aq_nic_reserve_filter() and aq_nic_release_filter().
Quoted 6 lines
I looked through the rest of the series including the AQC113 PTP patches (
aq_ptp_dpath_enable/aq_ptp_add_a2_filter) and they also callhw_filter_l3l4_set()directly rather than going throughaq_add_del_fl3l4(), so the reserved PTP slot does not get re-reflected intoactive_ipv4by a later patch.
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type, · line 1544
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0
-1@@ -1543,7 +1541,6 @@ void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type,break ;case aq_rx_filter_l3l4: self->aq_hw_rx_fltrs.fl3l4.reserved_count--; - self->aq_hw_rx_fltrs.fl3l4.active_ipv4 &= ~BIT (location);break ;Would it be worth keeping these updates (or adding equivalent ones on the PTP reserve/release path) so that
aq_check_approve_fl3l4()continues to see PTP's reserved slot asactive_ipv4?
Yes, kept the active_ipv4 updates in aq_nic_reserve_filter and aq_nic_release_filter in v3.
Quoted 2 lines
Signature · 1 line
This is an AI-generated review.
[email protected]
maintainerPATCH 3/9 net: atlantic: decouple aq_set_data_fl3l4() from driver internals driver internals
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Refactor aq_set_data_fl3l4() to take an ethtool_rx_flow_spec pointer and an explicit HW register location instead of driver-internal structures (aq_nic_s, aq_rx_filter). This makes the function reusable for PTP filter setup which constructs flow specs independently.
Key changes:
- Add aq_is_ipv6_flow_type() helper to derive IPv6 status from the flow_type field, replacing the dependency on rx_fltrs->fl3l4.is_ipv6 shared state.
- Change aq_set_data_fl3l4() signature to accept (fsp, data, location, add) and export it via aq_filters.h.
- Update aq_add_del_fl3l4() to compute the HW register location and pass it explicitly.
--- .../ethernet/aquantia/atlantic/aq_filters.c | 31 ++++++++++++++----- .../ethernet/aquantia/atlantic/aq_filters.h | 3 ++ 2 files changed, 26 insertions(+), 8 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c +23 -8
@@ -181,6 +181,20 @@ aq_check_approve_fvlan(struct aq_nic_s *aq_nic,return 0 ; } +static bool aq_is_ipv6_flow_type (const struct ethtool_rx_flow_spec *fsp) +{ +switch (fsp->flow_type & ~FLOW_EXT ) { +case TCP_V6_FLOW : +case UDP_V6_FLOW : +case SCTP_V6_FLOW : +case IPV6_FLOW : +case IPV6_USER_FLOW : +return true; +default : +return false; + } +} +static int __must_check aq_check_filter (struct aq_nic_s *aq_nic,struct ethtool_rx_flow_spec *fsp)
@@ -466,18 +480,16 @@ static int aq_add_del_fvlan(struct aq_nic_s *aq_nic,return aq_filters_vlans_update (aq_nic); } -static int aq_set_data_fl3l4 (struct aq_nic_s *aq_nic, -struct aq_rx_filter *aq_rx_fltr, -struct aq_rx_filter_l3l4 *data,bool add) +int aq_set_data_fl3l4 (const struct ethtool_rx_flow_spec *fsp, +struct aq_rx_filter_l3l4 *data, +int location,bool add) { -struct aq_hw_rx_fltrs_s *rx_fltrs =aq_get_hw_rx_fltrs (aq_nic); -const struct ethtool_rx_flow_spec *fsp = &aq_rx_fltr->aq_fsp;u32 flow = fsp->flow_type & ~FLOW_EXT ;memset (data,0 ,sizeof (*data)); - data->is_ipv6 = rx_fltrs->fl3l4.is_ipv6; - data->location =HW_ATL_GET_REG_LOCATION_FL3L4 (fsp->location); + data->is_ipv6 =aq_is_ipv6_flow_type (fsp); + data->location = location;if (!add)return 0 ;
@@ -569,13 +581,16 @@ static int aq_add_del_fl3l4(struct aq_nic_s *aq_nic,const struct aq_hw_ops *aq_hw_ops = aq_nic->aq_hw_ops;struct aq_hw_s *aq_hw = aq_nic->aq_hw;struct aq_rx_filter_l3l4 data; +int location;int err;if (unlikely (aq_rx_fltr->aq_fsp.location <AQ_RX_FIRST_LOC_FL3L4 || aq_rx_fltr->aq_fsp.location >AQ_RX_LAST_LOC_FL3L4 ))return -EINVAL ; -aq_set_data_fl3l4 (aq_nic, aq_rx_fltr, &data, add); + location =HW_ATL_GET_REG_LOCATION_FL3L4 (aq_rx_fltr->aq_fsp.location); + +aq_set_data_fl3l4 (&aq_rx_fltr->aq_fsp, &data, location, add); err =aq_set_fl3l4 (aq_hw, aq_hw_ops, &data);if (err)
drivers/net/ethernet/aquantia/atlantic/aq_filters.h +3 -0
@@ -32,5 +32,8 @@ int aq_clear_rxnfc_all_rules(struct aq_nic_s *aq_nic);int aq_reapply_rxnfc_all_rules (struct aq_nic_s *aq_nic);int aq_filters_vlans_update (struct aq_nic_s *aq_nic);int aq_filters_vlan_offload_off (struct aq_nic_s *aq_nic); +int aq_set_data_fl3l4 (const struct ethtool_rx_flow_spec *fsp, +struct aq_rx_filter_l3l4 *data, +int location,bool add);#endif /* AQ_FILTERS_H */
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH 4/9 net: atlantic: add AQC113 hardware register definitions and accessors definitions and accessors
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Add low-level hardware register definitions and accessor functions for AQC113 (Antigua) chip features:
- L3/L4 filter command, tag, and address registers for IPv4/IPv6
- Ethertype filter tag registers
- TSG (Time Stamp Generator) clock control, modification, and GPIO event generation/input timestamp registers
- TX descriptor timestamp writeback, timestamp enable, and AVB enable registers
- TX data/descriptor read request limit registers
- TPB highest priority TC registers
- PCIe extended tag enable register
- RX descriptor timestamp request register
- Action resolver section enable getter
- GPIO special mode and TSG external GPIO TS input select
--- .../aquantia/atlantic/hw_atl2/hw_atl2_llh.c | 359 ++++++++++++++++++ .../aquantia/atlantic/hw_atl2/hw_atl2_llh.h | 107 +++++- .../atlantic/hw_atl2/hw_atl2_llh_internal.h | 204 +++++++++- 3 files changed, 663 insertions(+), 7 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.c +359 -0
@@ -7,6 +7,20 @@#include "hw_atl2_llh_internal.h" #include "aq_hw_utils.h" +void hw_atl2_phi_ext_tag_set (struct aq_hw_s *aq_hw,u32 val) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_PHI_EXT_TAG_EN_ADR , +HW_ATL2_PHI_EXT_TAG_EN_MSK , +HW_ATL2_PHI_EXT_TAG_EN_SHIFT , val); +} + +u32 hw_atl2_phi_ext_tag_get (struct aq_hw_s *aq_hw) +{ +return aq_hw_read_reg_bit (aq_hw,HW_ATL2_PHI_EXT_TAG_EN_ADR , +HW_ATL2_PHI_EXT_TAG_EN_MSK , +HW_ATL2_PHI_EXT_TAG_EN_SHIFT ); +} +void hw_atl2_rpf_redirection_table2_select_set (struct aq_hw_s *aq_hw,u32 select) {
@@ -66,6 +80,278 @@ void hw_atl2_rpf_vlan_flr_tag_set(struct aq_hw_s *aq_hw, u32 tag, u32 filter) tag); } +void hw_atl2_rpf_etht_flr_tag_set (struct aq_hw_s *aq_hw,u32 tag,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_ET_TAG_ADR (filter), +HW_ATL2_RPF_ET_TAG_MSK , +HW_ATL2_RPF_ET_TAG_SHIFT , tag); +} + +u32 hw_atl2_rpf_etht_flr_tag_get (struct aq_hw_s *aq_hw,u32 filter) +{ +return aq_hw_read_reg_bit (aq_hw,HW_ATL2_RPF_ET_TAG_ADR (filter), +HW_ATL2_RPF_ET_TAG_MSK , +HW_ATL2_RPF_ET_TAG_SHIFT ); +} + +void hw_atl2_rpf_l3_v4_dest_addr_set (struct aq_hw_s *aq_hw,u32 filter,u32 val) +{ +u32 addr_set =6 + ((filter <4 ) ?0 :1 ); +u32 dword = filter %4 ; + +aq_hw_write_reg (aq_hw,HW_ATL2_RPF_L3_DA_DW_ADR (addr_set, dword), val); +} + +void hw_atl2_rpf_l3_v4_src_addr_set (struct aq_hw_s *aq_hw,u32 filter,u32 val) +{ +u32 addr_set =6 + ((filter <4 ) ?0 :1 ); +u32 dword = filter %4 ; + +aq_hw_write_reg (aq_hw,HW_ATL2_RPF_L3_SA_DW_ADR (addr_set, dword), val); +} + +void hw_atl2_rpf_l3_v6_dest_addr_set (struct aq_hw_s *aq_hw,u8 location, +u32 *ipv6_dst) +{ +int i; + +for (i =0 ; i <4 ; ++i) +aq_hw_write_reg (aq_hw, +HW_ATL2_RPF_L3_DA_DW_ADR (location,3 - i), + ipv6_dst[i]); +} + +void hw_atl2_rpf_l3_v6_src_addr_set (struct aq_hw_s *aq_hw,u8 location, +u32 *ipv6_src) +{ +int i; + +for (i =0 ; i <4 ; ++i) +aq_hw_write_reg (aq_hw, +HW_ATL2_RPF_L3_SA_DW_ADR (location,3 - i), + ipv6_src[i]); +} + +void hw_atl2_rpf_l3_v4_cmd_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V4_CMD_ADR (filter), +HW_ATL2_RPF_L3_V4_CMD_MSK , +HW_ATL2_RPF_L3_V4_CMD_SHIFT , val); +} + +void hw_atl2_rpf_l3_v6_cmd_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V6_CMD_ADR (filter), +HW_ATL2_RPF_L3_V6_CMD_MSK , +HW_ATL2_RPF_L3_V6_CMD_SHIFT , val); +} + +void hw_atl2_rpf_l3_v6_v4_select_set (struct aq_hw_s *aq_hw,u32 val) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V6_V4_SELECT_ADR , +HW_ATL2_RPF_L3_V6_V4_SELECT_MSK , +HW_ATL2_RPF_L3_V6_V4_SELECT_SHIFT , val); +} + +void hw_atl2_rpf_l3_v4_tag_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V4_TAG_ADR (filter), +HW_ATL2_RPF_L3_V4_TAG_MSK , +HW_ATL2_RPF_L3_V4_TAG_SHIFT , val); +} + +void hw_atl2_rpf_l3_v6_tag_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V6_TAG_ADR (filter), +HW_ATL2_RPF_L3_V6_TAG_MSK , +HW_ATL2_RPF_L3_V6_TAG_SHIFT , val); +} + +void hw_atl2_rpf_l4_tag_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L4_TAG_ADR (filter), +HW_ATL2_RPF_L4_TAG_MSK , +HW_ATL2_RPF_L4_TAG_SHIFT , val); +} + +void hw_atl2_rpf_l4_cmd_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L4_CMD_ADR (filter), +HW_ATL2_RPF_L4_CMD_MSK , +HW_ATL2_RPF_L4_CMD_SHIFT , val); +} + +/* tsg */ +static void hw_atl2_clock_modif_value_set (struct aq_hw_s *aq_hw, +u32 clock_sel,u64 ns) +{ +aq_hw_write_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_MODIF_VAL_LSW ), + ns); +} + +void hw_atl2_tsg_clock_en (struct aq_hw_s *aq_hw, +u32 clock_sel,u32 clock_enable) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_CFG ), +HW_ATL2_TSG_CLOCK_EN_MSK , +HW_ATL2_TSG_CLOCK_EN_SHIFT , + clock_enable); +} + +void hw_atl2_tsg_clock_reset (struct aq_hw_s *aq_hw,u32 clock_sel) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_CFG ), +HW_ATL2_TSG_SYNC_RESET_MSK , +HW_ATL2_TSG_SYNC_RESET_SHIFT ,1 ); +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_CFG ), +HW_ATL2_TSG_SYNC_RESET_MSK , +HW_ATL2_TSG_SYNC_RESET_SHIFT ,0 ); +} + +u64 hw_atl2_tsg_clock_read (struct aq_hw_s *aq_hw,u32 clock_sel) +{ +return aq_hw_read_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel, +READ_CUR_NS_LSW )); +} + +void hw_atl2_tsg_clock_add (struct aq_hw_s *aq_hw,u32 clock_sel,u64 ns) +{ +hw_atl2_clock_modif_value_set (aq_hw, clock_sel, ns); +aq_hw_write_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_MODIF_CTRL ), +HW_ATL2_TSG_ADD_COUNTER_MSK ); +} + +void hw_atl2_tsg_clock_sub (struct aq_hw_s *aq_hw,u32 clock_sel,u64 ns) +{ +hw_atl2_clock_modif_value_set (aq_hw, clock_sel, ns); +aq_hw_write_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_MODIF_CTRL ), +HW_ATL2_TSG_SUBTRACT_COUNTER_MSK ); +} + +void hw_atl2_tsg_clock_increment_set (struct aq_hw_s *aq_hw, +u32 clock_sel,u32 ns,u32 fns) +{ +u32 nsfns = (ns &0xff ) | (fns &0xffffff00 ); + +aq_hw_write_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_INC_CFG ), + nsfns); +aq_hw_write_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_MODIF_CTRL ), +HW_ATL2_TSG_LOAD_INC_CFG_MSK ); +} + +void hw_atl2_tsg_ext_isr_to_host_set (struct aq_hw_s *aq_hw,int on) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_GLB_CONTROL_2_ADR , +HW_ATL2_MIF_INTERRUPT_2_TO_ITR_MSK , +HW_ATL2_MIF_INTERRUPT_TO_ITR_SHIFT +2 , + !!on); +aq_hw_write_reg_bit (aq_hw,HW_ATL2_GLB_CONTROL_2_ADR , +HW_ATL2_EN_INTERRUPT_MIF2_TO_ITR_MSK , +HW_ATL2_EN_INTERRUPT_TO_ITR_SHIFT +2 , + !!on); +} + +void hw_atl2_tpb_tps_highest_priority_tc_enable_set (struct aq_hw_s *aq_hw, +u32 tps_highest_prio_tc_en) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TPB_HIGHEST_PRIO_TC_EN_ADR , +HW_ATL2_TPB_HIGHEST_PRIO_TC_EN_MSK , +HW_ATL2_TPB_HIGHEST_PRIO_TC_EN_SHIFT , + tps_highest_prio_tc_en); +} + +void hw_atl2_tpb_tps_highest_priority_tc_set (struct aq_hw_s *aq_hw, +u32 tps_highest_prio_tc) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TPB_HIGHEST_PRIO_TC_ADR , +HW_ATL2_TPB_HIGHEST_PRIO_TC_MSK , +HW_ATL2_TPB_HIGHEST_PRIO_TC_SHIFT , + tps_highest_prio_tc); +} + +void hw_atl2_tsg_gpio_isr_to_host_set (struct aq_hw_s *aq_hw, +int on,u32 clock_sel) +{ +aq_hw_write_reg_bit (aq_hw, +HW_ATL2_GLOBAL_HIGH_PRIO_INTERRUPT_1_MASK_ADR , + clock_sel ==1 ?HW_ATL2_TSG_TSG1_GPIO_INTERRUPT_MSK : +HW_ATL2_TSG_TSG0_GPIO_INTERRUPT_MSK , + clock_sel ==1 ?HW_ATL2_TSG_TSG1_GPIO_INTERRUPT_SHIFT : +HW_ATL2_TSG_TSG0_GPIO_INTERRUPT_SHIFT , + !!on); +} + +void hw_atl2_tsg_gpio_clear_status (struct aq_hw_s *aq_hw) +{ +aq_hw_read_reg (aq_hw,HW_ATL2_GLOBAL_INTERNAL_ALARMS_1_ADR ); +} + +void hw_atl2_tsg_gpio_input_event_info_get (struct aq_hw_s *aq_hw, +u32 clock_sel, +u32 *event_count, +u64 *event_ts) +{ +if (event_count) + *event_count =aq_hw_read_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel, +EXT_CLK_COUNT )); + +if (event_ts) + *event_ts =aq_hw_read_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel, +GPIO_EVENT_TS_LSW )); +} + +void hw_atl2_tsg_ptp_gpio_gen_pulse (struct aq_hw_s *aq_hw,u32 clk_sel, +u64 ts,u32 period,u32 hightime) +{ +u32 val = (HW_ATL2_TSG_GPIO_EVENT_MODE_SET_ON_TIME << + (HW_ATL2_TSG_GPIO_EVENT_MODE_SHIFT - +HW_ATL2_TSG_GPIO_OUTPUT_EN_SHIFT )) | + (HW_ATL2_TSG_GPIO_GEN_OUTPUT_EN_MSK ) | + (HW_ATL2_TSG_GPIO_OUTPUT_EN_MSK ); + +if (ts !=0 ) { +aq_hw_write_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clk_sel, +GPIO_EVENT_GEN_TS_LSW ), + ts); + +aq_hw_write_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clk_sel, +GPIO_EVENT_HIGH_TIME_LSW ), + hightime); + +aq_hw_write_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clk_sel, +GPIO_EVENT_LOW_TIME_LSW ), + (period - hightime)); + } + +aq_hw_write_reg_bit (aq_hw, +HW_ATL2_TSG_REG_ADR (clk_sel,GPIO_EVENT_GEN_CFG ), +HW_ATL2_TSG_GPIO_EVENT_MODE_MSK | +HW_ATL2_TSG_GPIO_OUTPUT_EN_MSK | +HW_ATL2_TSG_GPIO_GEN_OUTPUT_EN_MSK , +HW_ATL2_TSG_GPIO_OUTPUT_EN_SHIFT , + (!ts ?0 : val)); +} + +void hw_atl2_rpf_rx_desc_timestamp_req_set (struct aq_hw_s *aq_hw,u32 request, +u32 descriptor) +{ +aq_hw_write_reg_bit (aq_hw, +HW_ATL2_RPF_TIMESTAMP_REQ_DESCD_ADR (descriptor), +HW_ATL2_RPF_TIMESTAMP_REQ_DESCD_MSK , +HW_ATL2_RPF_TIMESTAMP_REQ_DESCD_SHIFT , request); +} +/* TX */ void hw_atl2_tpb_tx_tc_q_rand_map_en_set(struct aq_hw_s *aq_hw,
@@ -93,6 +379,30 @@ void hw_atl2_reg_tx_intr_moder_ctrl_set(struct aq_hw_s *aq_hw, tx_intr_moderation_ctl); } +void hw_atl2_tdm_tx_desc_timestamp_writeback_en_set (struct aq_hw_s *aq_hw, +u32 enable,u32 descriptor) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_DESCD_TS_WRB_EN_ADR (descriptor), +HW_ATL2_TDM_DESCD_TS_WRB_EN_MSK , +HW_ATL2_TDM_DESCD_TS_WRB_EN_SHIFT , enable); +} + +void hw_atl2_tdm_tx_desc_timestamp_en_set (struct aq_hw_s *aq_hw,u32 enable, +u32 descriptor) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_DESCD_TS_EN_ADR (descriptor), +HW_ATL2_TDM_DESCD_TS_EN_MSK , +HW_ATL2_TDM_DESCD_TS_EN_SHIFT , enable); +} + +void hw_atl2_tdm_tx_desc_avb_en_set (struct aq_hw_s *aq_hw,u32 enable, +u32 descriptor) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_DESCD_AVB_EN_ADR (descriptor), +HW_ATL2_TDM_DESCD_AVB_EN_MSK , +HW_ATL2_TDM_DESCD_AVB_EN_SHIFT , enable); +} +void hw_atl2_tps_tx_pkt_shed_data_arb_mode_set (struct aq_hw_s *aq_hw,const u32 data_arb_mode) {
@@ -122,6 +432,20 @@ void hw_atl2_tps_tx_pkt_shed_tc_data_weight_set(struct aq_hw_s *aq_hw, weight); } +void hw_atl2_tdm_tx_data_read_req_limit_set (struct aq_hw_s *aq_hw,u32 limit) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_TX_DATA_RD_REQ_LIMIT_ADR , +HW_ATL2_TDM_TX_DATA_RD_REQ_LIMIT_MSK , +HW_ATL2_TDM_TX_DATA_RD_REQ_LIMIT_SHIFT , limit); +} + +void hw_atl2_tdm_tx_desc_read_req_limit_set (struct aq_hw_s *aq_hw,u32 limit) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_TX_DESC_RD_REQ_LIMIT_ADR , +HW_ATL2_TDM_TX_DESC_RD_REQ_LIMIT_MSK , +HW_ATL2_TDM_TX_DESC_RD_REQ_LIMIT_SHIFT , limit); +} +u32 hw_atl2_get_hw_version (struct aq_hw_s *aq_hw) {return aq_hw_read_reg (aq_hw,HW_ATL2_FPGA_VER_ADR );
@@ -164,6 +488,13 @@ void hw_atl2_rpf_act_rslvr_section_en_set(struct aq_hw_s *aq_hw, u32 sections) sections); } +u32 hw_atl2_rpf_act_rslvr_section_en_get (struct aq_hw_s *aq_hw) +{ +return aq_hw_read_reg_bit (aq_hw,HW_ATL2_RPF_REC_TAB_EN_ADR , +HW_ATL2_RPF_REC_TAB_EN_MSK , +HW_ATL2_RPF_REC_TAB_EN_SHIFT ); +} +void hw_atl2_mif_shared_buf_get (struct aq_hw_s *aq_hw,int offset,u32 *data,int len) {
@@ -232,3 +563,31 @@ void hw_atl2_mif_host_req_int_clr(struct aq_hw_s *aq_hw, u32 val)return aq_hw_write_reg (aq_hw,HW_ATL2_MCP_HOST_REQ_INT_CLR_ADR , val); } + +void hw_atl2_tsg1_ext_gpio_ts_input_select_set (struct aq_hw_s *aq_hw, +u32 tsg_gpio_ts_select) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG1_EXT_GPIO_TS_INPUT_SEL_ADR , +HW_ATL2_TSG1_EXT_GPIO_TS_INPUT_SEL_MSK , +HW_ATL2_TSG1_EXT_GPIO_TS_INPUT_SEL_SHIFT , + tsg_gpio_ts_select); +} + +void hw_atl2_tsg0_ext_gpio_ts_input_select_set (struct aq_hw_s *aq_hw, +u32 gpio_ts_in_select) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG0_EXT_GPIO_TS_INPUT_SEL_ADR , +HW_ATL2_TSG0_EXT_GPIO_TS_INPUT_SEL_MSK , +HW_ATL2_TSG0_EXT_GPIO_TS_INPUT_SEL_SHIFT , + gpio_ts_in_select); +} + +void hw_atl2_gpio_special_mode_set (struct aq_hw_s *aq_hw, +u32 gpio_special_mode, +u32 pin) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_GPIO_PIN_SPEC_MODE_ADR (pin), +HW_ATL2_GPIO_PIN_SPEC_MODE_MSK , +HW_ATL2_GPIO_PIN_SPEC_MODE_SHIFT , + gpio_special_mode); +}
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.h +105 -2
149 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh_internal.h +199 -5
238 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH 5/9 net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Add filter infrastructure for AQC113 hardware:
- Define L3 (IPv4/IPv6), L4 (TCP/UDP/SCTP), and combined L3L4 filter structures with reference-counted sharing support.
- Define tag policy structure for ethertype filter management.
- Add RPF L3/L4 command bit definitions for filter programming.
- Add filter count constants for L3L4, L3V4, L4, VLAN, and ethertype.
- Extend hw_atl2_priv with filter arrays, base indices, and counts discovered from firmware.
Query filter capabilities from firmware shared memory at init time to discover available L2/L3/L4/VLAN/ethertype filter resources and ART (Action Resolver Table) configuration.
Add hardware register dump utility for AQC113 debug support.
--- .../atlantic/hw_atl2/hw_atl2_internal.h | 63 +++++++++++++++++++ .../aquantia/atlantic/hw_atl2/hw_atl2_utils.c | 33 ++++++++++ .../aquantia/atlantic/hw_atl2/hw_atl2_utils.h | 5 ++ .../atlantic/hw_atl2/hw_atl2_utils_fw.c | 52 +++++++++++++++ 4 files changed, 153 insertions(+)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +63 -0
@@ -84,6 +84,18 @@ enum HW_ATL2_RPF_ART_INDEX { HW_ATL_VLAN_MAX_FILTERS, }; +#define HW_ATL2_RPF_L3_CMD_EN BIT(0) +#define HW_ATL2_RPF_L3_CMD_SA_EN BIT(1) +#define HW_ATL2_RPF_L3_CMD_DA_EN BIT(2) +#define HW_ATL2_RPF_L3_CMD_PROTO_EN BIT(3) +#define HW_ATL2_RPF_L3_V6_CMD_EN BIT(0x10) +#define HW_ATL2_RPF_L3_V6_CMD_SA_EN BIT(0x11) +#define HW_ATL2_RPF_L3_V6_CMD_DA_EN BIT(0x12) +#define HW_ATL2_RPF_L3_V6_CMD_PROTO_EN BIT(0x13) +#define HW_ATL2_RPF_L4_CMD_EN BIT(0) +#define HW_ATL2_RPF_L4_CMD_DP_EN BIT(1) +#define HW_ATL2_RPF_L4_CMD_SP_EN BIT(2) +#define HW_ATL2_ACTION (ACTION ,RSS ,INDEX ,VALID ) \ ((((ACTION) & 0x3U) << 8) | \ (((RSS) & 0x1U) << 7) | \
@@ -94,6 +106,12 @@ enum HW_ATL2_RPF_ART_INDEX {#define HW_ATL2_ACTION_DISABLE HW_ATL2_ACTION(0, 0, 0, 0)#define HW_ATL2_ACTION_ASSIGN_QUEUE (QUEUE ) HW_ATL2_ACTION(1, 0, (QUEUE), 1)#define HW_ATL2_ACTION_ASSIGN_TC (TC ) HW_ATL2_ACTION(1, 1, (TC), 1) +#define HW_ATL2_RPF_L3L4_FILTERS 8 +#define HW_ATL2_RPF_L3V4_FILTERS 8 +#define HW_ATL2_RPF_L4_FILTERS 8 +#define HW_ATL2_RPF_VLAN_FILTERS 16 +#define HW_ATL2_RPF_ETYPE_FILTERS 16 +#define HW_ATL2_RPF_ETYPE_TAGS 7enum HW_ATL2_RPF_RSS_HASH_TYPE {HW_ATL2_RPF_RSS_HASH_TYPE_NONE =0 ,
@@ -119,9 +137,54 @@ enum HW_ATL2_RPF_RSS_HASH_TYPE {#define HW_ATL_MCAST_FLT_ANY_TO_HOST 0x00010FFFU +struct hw_atl2_l3_filter { +u8 proto; +u8 usage; +u32 cmd; +u32 srcip[4 ]; +u32 dstip[4 ]; +}; + +struct hw_atl2_l4_filter { +u8 usage; +u32 cmd; +u16 sport; +u16 dport; +}; + +struct hw_atl2_l3l4_filter { +s8 l3_index; +s8 l4_index; +u8 ipv6; +}; + +struct hw_atl2_tag_policy { +u16 action; +u16 usage; +}; +struct hw_atl2_priv { +struct hw_atl2_l3_filter l3_v4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l3_filter l3_v6_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l4_filter l4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l3l4_filter l3l4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_tag_policy etype_policy[HW_ATL2_RPF_ETYPE_FILTERS ];struct statistics_s last_stats;unsigned int art_base_index; +unsigned int art_count; +unsigned int l2_filters_base_index; +unsigned int l2_filter_count; +unsigned int etype_filter_base_index; +unsigned int etype_filter_count; +unsigned int etype_filter_tag_top; +unsigned int vlan_filter_base_index; +unsigned int vlan_filter_count; +unsigned int l3_v4_filter_base_index; +unsigned int l3_v4_filter_count; +unsigned int l3_v6_filter_base_index; +unsigned int l3_v6_filter_count; +unsigned int l4_filter_base_index; +unsigned int l4_filter_count; };#endif /* HW_ATL2_INTERNAL_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c +33 -0
@@ -128,3 +128,36 @@ int hw_atl2_utils_soft_reset(struct aq_hw_s *self) err_exit:return err; } + +static const u32 hw_atl2_utils_hw_mac_regs[] = { +0x00005580U ,0x00005590U ,0x000055B0U ,0x000055B4U , +0x000055C0U ,0x00005B00U ,0x00005B04U ,0x00005B08U , +0x00005B0CU ,0x00005B10U ,0x00005B14U ,0x00005B18U , +0x00005B1CU ,0x00005B20U ,0x00005B24U ,0x00005B28U , +0x00005B2CU ,0x00005B30U ,0x00005B34U ,0x00005B38U , +0x00005B3CU ,0x00005B40U ,0x00005B44U ,0x00005B48U , +0x00005B4CU ,0x00005B50U ,0x00005B54U ,0x00005B58U , +0x00005B5CU ,0x00005B60U ,0x00005B64U ,0x00005B68U , +0x00005B6CU ,0x00005B70U ,0x00005B74U ,0x00005B78U , +0x00005B7CU ,0x00007C00U ,0x00007C04U ,0x00007C08U , +0x00007C0CU ,0x00007C10U ,0x00007C14U ,0x00007C18U , +0x00007C1CU ,0x00007C20U ,0x00007C40U ,0x00007C44U , +0x00007C48U ,0x00007C4CU ,0x00007C50U ,0x00007C54U , +0x00007C58U ,0x00007C5CU ,0x00007C60U ,0x00007C80U , +0x00007C84U ,0x00007C88U ,0x00007C8CU ,0x00007C90U , +0x00007C94U ,0x00007C98U ,0x00007C9CU ,0x00007CA0U , +0x00007CC0U ,0x00007CC4U ,0x00007CC8U ,0x00007CCCU , +0x00007CD0U ,0x00007CD4U ,0x00007CD8U ,0x00007CDCU , +}; + +int hw_atl2_utils_hw_get_regs (struct aq_hw_s *self, +const struct aq_hw_caps_s *aq_hw_caps, +u32 *regs_buff) +{ +unsigned int i; + +for (i =0 ; i < aq_hw_caps->mac_regs_count; i++) + regs_buff[i] =aq_hw_read_reg (self, + hw_atl2_utils_hw_mac_regs[i]); +return 0 ; +}
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.h +5 -0
@@ -626,10 +626,15 @@ int hw_atl2_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops);int hw_atl2_utils_soft_reset (struct aq_hw_s *self); +int hw_atl2_utils_hw_get_regs (struct aq_hw_s *self, +const struct aq_hw_caps_s *aq_hw_caps, +u32 *regs_buff); +u32 hw_atl2_utils_get_fw_version (struct aq_hw_s *self);int hw_atl2_utils_get_action_resolve_table_caps (struct aq_hw_s *self,u8 *base_index,u8 *count); +int hw_atl2_utils_get_filter_caps (struct aq_hw_s *self);extern const struct aq_fw_ops aq_a2_fw_ops;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +52 -0
64 lines not on this page · raw message
Signature · 1 line
2.43.0
Paolo Abeni
maintainerRe: [PATCH net-next 5/9] net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query
This patch adds filter data structures, RPF L3/L4 command bits, filter count constants, and a firmware capability query used to populate filter base indices and counts stored in hw_atl2_priv. It also adds a MAC register dump helper for debug support.
Quoted 1 line
net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query
The subject line has "firmware query" repeated three times. Similar duplication appears on other subjects in this series (for example "filter management filter management management", "(Antigua) (Antigua)", "TX path setup TX path setup"). Would it be possible to regenerate the series so each subject reads cleanly?
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +0
-0
[ ... ]
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +7
-0@@ -119,9 +137,54 @@ enum HW_ATL2_RPF_RSS_HASH_TYPE {#define HW_ATL_MCAST_FLT_ANY_TO_HOST 0x00010FFFU +struct hw_atl2_l3_filter { +u8 proto; +u8 usage; +u32 cmd; +u32 srcip[4 ]; +u32 dstip[4 ]; +};
[ ... ]
Quoted 13 lines
struct
hw_atl2_priv{drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +10
-0+struct hw_atl2_l3_filter l3_v4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l3_filter l3_v6_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l4_filter l4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l3l4_filter l3l4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_tag_policy etype_policy[HW_ATL2_RPF_ETYPE_FILTERS ];struct statistics_s last_stats;unsigned int art_base_index; +unsigned int art_count; +unsigned int l2_filters_base_index; +unsigned int l2_filter_count; +unsigned int etype_filter_base_index; +unsigned int etype_filter_count;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h enum HW_ATL2_RPF_RSS_HASH_TYPE { · line 188
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +9
-0+unsigned int etype_filter_tag_top; +unsigned int vlan_filter_base_index; +unsigned int vlan_filter_count; +unsigned int l3_v4_filter_base_index; +unsigned int l3_v4_filter_count; +unsigned int l3_v6_filter_base_index; +unsigned int l3_v6_filter_count; +unsigned int l4_filter_base_index; +unsigned int l4_filter_count; };
The backing arrays l3_v4_filters[], l3_v6_filters[], l4_filters[] and etype_policy[] are fixed-size (HW_ATL2_RPF_L3L4_FILTERS == 8, and HW_ATL2_RPF_ETYPE_FILTERS == 16), but the *_count and *_base_index fields are populated from firmware below. See the next comment in hw_atl2_utils_get_filter_caps() about validation.
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c int hw_atl2_utils_soft_reset(struct aq_hw_s *self) · line 133
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c +3
-0@@ -128,3 +128,36 @@ int hw_atl2_utils_soft_reset(struct aq_hw_s *self) err_exit:return err; } + +static const u32 hw_atl2_utils_hw_mac_regs[] = { +0x00005580U ,0x00005590U ,0x000055B0U ,0x000055B4U ,
[ ... array of 72 entries ... ]
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c +4
-0+ 0x00007CD0U, 0x00007CD4U, 0x00007CD8U, 0x00007CDCU, +}; + +int hw_atl2_utils_hw_get_regs(struct aq_hw_s *self,
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c int hw_atl2_utils_soft_reset(struct aq_hw_s *self) · line 163
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c +10
-0+const struct aq_hw_caps_s *aq_hw_caps, + u32 *regs_buff) +{ + unsigned int i; + +for (i =0 ; i < aq_hw_caps->mac_regs_count; i++) + regs_buff[i] =aq_hw_read_reg (self, + hw_atl2_utils_hw_mac_regs[i]); +return 0 ; +}
This isn't a bug today, since hw_atl2_caps_aqc113.mac_regs_count is 72 and hw_atl2_utils_hw_mac_regs[] has 72 entries, but would a BUILD_BUG_ON() or a runtime min_t() tying the loop bound to ARRAY_SIZE(hw_atl2_utils_hw_mac_regs) be worth adding? If a future variant bumps mac_regs_count without updating the table, the loop would read past the rodata array and issue readl() on unintended register offsets.
Also, hw_atl2_utils_hw_get_regs() only ever returns 0. Does it need to be declared as returning int, or could it be void?
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +0
-0
[ ... ]
Quoted 13 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +9
-0@@ -606,6 +610,54 @@ u32 hw_atl2_utils_get_fw_version(struct aq_hw_s *self) version.bundle.build; } +int hw_atl2_utils_get_filter_caps (struct aq_hw_s *self) +{ +struct hw_atl2_priv *priv = self->priv; +struct filter_caps_s filter_caps; +u32 tag_top; +int err; + + err =hw_atl2_shared_buffer_read_safe (self, filter_caps, &filter_caps); +if (err)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c u32 hw_atl2_utils_get_fw_version(struct aq_hw_s *self) · line 631
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +10
-0+return err; + + priv->art_base_index = filter_caps.rslv_tbl_base_index *8 ; + priv->art_count = filter_caps.rslv_tbl_count *8 ; +if (priv->art_count ==0 ) + priv->art_count =128 ; + priv->l2_filters_base_index = filter_caps.l2_filters_base_index; + priv->l2_filter_count = filter_caps.l2_filter_count; + priv->etype_filter_base_index = filter_caps.ethertype_filter_base_index; + priv->etype_filter_count = filter_caps.ethertype_filter_count;
Should priv->l2_filter_count and priv->etype_filter_count also be clamped against their backing arrays the way the v4/L4 paths below are? The etype_policy[] array is sized HW_ATL2_RPF_ETYPE_FILTERS (16), and the base indices are accepted verbatim from firmware without any check that base_index + count stays within the array.
Quoted 12 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +12
-0+ priv->etype_filter_tag_top = + (priv->etype_filter_count >=HW_ATL2_RPF_ETYPE_TAGS ) ? + (HW_ATL2_RPF_ETYPE_TAGS ) : (HW_ATL2_RPF_ETYPE_TAGS >>1 ); + priv->vlan_filter_base_index = filter_caps.vlan_filter_base_index; +/* 0 - no tag, 1 - reserved for vlan-filter-offload filters */ + tag_top = + (filter_caps.vlan_filter_count ==HW_ATL2_RPF_VLAN_FILTERS ) ? + (HW_ATL2_RPF_VLAN_FILTERS -2 ) : + (HW_ATL2_RPF_VLAN_FILTERS /2 -2 ); + +if (filter_caps.vlan_filter_count >2 ) + priv->vlan_filter_count = min_t(u32,
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c u32 hw_atl2_utils_get_fw_version(struct aq_hw_s *self) · line 653
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +10
-0+ filter_caps.vlan_filter_count -2 , + tag_top); + else + priv->vlan_filter_count = 0; + + priv->l3_v4_filter_base_index = filter_caps.l3_ip4_filter_base_index; + priv->l3_v4_filter_count =min_t (u32, filter_caps.l3_ip4_filter_count, +HW_ATL2_RPF_L3V4_FILTERS -1 ); + priv->l3_v6_filter_base_index = filter_caps.l3_ip6_filter_base_index; + priv->l3_v6_filter_count = filter_caps.l3_ip6_filter_count;
Can priv->l3_v6_filter_count overflow l3_v6_filters[]? The l3_v4 and l4 counts just above/below are clamped:
priv->l3_v4_filter_count = min_t(u32, filter_caps.l3_ip4_filter_count,
HW_ATL2_RPF_L3V4_FILTERS - 1);
...
priv->l4_filter_count = min_t(u32, filter_caps.l4_filter_count,
HW_ATL2_RPF_L4_FILTERS - 1);but l3_v6_filter_count takes filter_caps.l3_ip6_filter_count directly. The backing array is
struct hw_atl2_l3_filter l3_v6_filters[HW_ATL2_RPF_L3L4_FILTERS];
and HW_ATL2_RPF_L3L4_FILTERS is 8. The l3_ip6_filter_count field in struct filter_caps_s is wider than 3 bits, so the firmware can report a count above 8.
The consumer added in the follow-up patch in this series then walks priv->l3_v6_filters[] using the unclamped count:
first = priv->l3_v6_filter_base_index;
last = priv->l3_v6_filter_base_index + priv->l3_v6_filter_count;
for (i = first; i < last; i++)
if (hw_atl2_rxf_l3_is_equal(&l3_filters[i], l3))
return i;and hw_atl2_rxf_l3_get() writes through &l3_filters[idx] (l3->usage++, l3->cmd = ...). If firmware reports an oversized l3_ip6_filter_count, or any non-zero base_index that pushes the window past slot 7, doesn't this read and write past priv->l3_v6_filters[] into the adjacent priv fields?
The same question applies to priv->l3_v4_filter_base_index and priv->l3_v6_filter_base_index — they are stored verbatim from firmware with no check that base_index + count stays within the corresponding backing array. Would it make sense to validate the full window for every filter category?
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +6
-0+ priv->l4_filter_base_index = filter_caps.l4_filter_base_index; + priv->l4_filter_count =min_t (u32, filter_caps.l4_filter_count, +HW_ATL2_RPF_L4_FILTERS -1 ); + +return 0 ; +}
Signature · 1 line
This is an AI-generated review.
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next 5/9] net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query
Quoted 7 lines · Paolo Abeni
net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query
This patch adds filter data structures, RPF L3/L4 command bits, filter count constants, and a firmware capability query used to populate filter base indices and counts stored in
hw_atl2_priv. It also adds a MAC register dump helper for debug support.
Quoted 8 lines
Quoted 1 line
net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query
The subject line has "firmware query" repeated three times. Similar duplication appears on other subjects in this series (for example "filter management filter management management", "(Antigua) (Antigua)", "TX path setup TX path setup"). Would it be possible to regenerate the series so each subject reads cleanly?
Fixed in v3!
Quoted 89 lines
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +0
-0[ ... ]
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +7
-0@@ -119,9 +137,54 @@ enum HW_ATL2_RPF_RSS_HASH_TYPE {#define HW_ATL_MCAST_FLT_ANY_TO_HOST 0x00010FFFU +struct hw_atl2_l3_filter { +u8 proto; +u8 usage; +u32 cmd; +u32 srcip[4 ]; +u32 dstip[4 ]; +};[ ... ]
Quoted 13 lines
struct
hw_atl2_priv{drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +10
-0+struct hw_atl2_l3_filter l3_v4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l3_filter l3_v6_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l4_filter l4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l3l4_filter l3l4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_tag_policy etype_policy[HW_ATL2_RPF_ETYPE_FILTERS ];struct statistics_s last_stats;unsigned int art_base_index; +unsigned int art_count; +unsigned int l2_filters_base_index; +unsigned int l2_filter_count; +unsigned int etype_filter_base_index; +unsigned int etype_filter_count;drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h enum HW_ATL2_RPF_RSS_HASH_TYPE { · line 188
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +9
-0+unsigned int etype_filter_tag_top; +unsigned int vlan_filter_base_index; +unsigned int vlan_filter_count; +unsigned int l3_v4_filter_base_index; +unsigned int l3_v4_filter_count; +unsigned int l3_v6_filter_base_index; +unsigned int l3_v6_filter_count; +unsigned int l4_filter_base_index; +unsigned int l4_filter_count; };The backing arrays l3_v4_filters[], l3_v6_filters[], l4_filters[] and etype_policy[] are fixed-size (
HW_ATL2_RPF_L3L4_FILTERS== 8, andHW_ATL2_RPF_ETYPE_FILTERS== 16), but the*_countand*_base_indexfields are populated from firmware below. See the next comment inhw_atl2_utils_get_filter_caps()about validation.Quoted 18 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c +3
-0@@ -128,3 +128,36 @@ int hw_atl2_utils_soft_reset(struct aq_hw_s *self) err_exit:return err; } + +static const u32 hw_atl2_utils_hw_mac_regs[] = { +0x00005580U ,0x00005590U ,0x000055B0U ,0x000055B4U ,[ ... array of 72 entries ... ]
Quoted 1 line
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c +1
-0+ 0x00007CD0U, 0x00007CD4U, 0x00007CD8U, 0x00007CDCU,drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c +3
-0+}; + +int hw_atl2_utils_hw_get_regs(struct aq_hw_s *self,drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c int hw_atl2_utils_soft_reset(struct aq_hw_s *self) · line 163
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c +10
-0+const struct aq_hw_caps_s *aq_hw_caps, + u32 *regs_buff) +{ + unsigned int i; + +for (i =0 ; i < aq_hw_caps->mac_regs_count; i++) + regs_buff[i] =aq_hw_read_reg (self, + hw_atl2_utils_hw_mac_regs[i]); +return 0 ; +}This isn't a bug today, since hw_atl2_caps_aqc113.mac_regs_count is 72 and hw_atl2_utils_hw_mac_regs[] has 72 entries, but would a
BUILD_BUG_ON()or a runtimemin_t()tying the loop bound toARRAY_SIZE(hw_atl2_utils_hw_mac_regs)be worth adding? If a future variant bumpsmac_regs_countwithout updating the table, the loop would read past the rodata array and issuereadl()on unintended register offsets.
Quoted 2 lines
Also,
hw_atl2_utils_hw_get_regs()only ever returns 0. Does it need to be declared as returning int, or could it be void?
Will add the min_t(ARRAY_SIZE(...)) guard to protect against future mac_regs_count increases without a matching table update. The int return type must stay — it is mandated by the hw_get_regs function pointer in aq_hw_ops shared with the A0/B0 implementations.
Quoted 29 lines
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +0
-0[ ... ]
Quoted 21 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +17
-0@@ -606,6 +610,54 @@ u32 hw_atl2_utils_get_fw_version(struct aq_hw_s *self) version.bundle.build; } +int hw_atl2_utils_get_filter_caps (struct aq_hw_s *self) +{ +struct hw_atl2_priv *priv = self->priv; +struct filter_caps_s filter_caps; +u32 tag_top; +int err; + + err =hw_atl2_shared_buffer_read_safe (self, filter_caps, &filter_caps); +if (err) +return err; + + priv->art_base_index = filter_caps.rslv_tbl_base_index *8 ; + priv->art_count = filter_caps.rslv_tbl_count *8 ; +if (priv->art_count ==0 ) + priv->art_count =128 ; + priv->l2_filters_base_index = filter_caps.l2_filters_base_index; + priv->l2_filter_count = filter_caps.l2_filter_count;
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c u32 hw_atl2_utils_get_fw_version(struct aq_hw_s *self) · line 631
Quoted 2 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +2
-0+ priv->etype_filter_base_index = filter_caps.ethertype_filter_base_index; + priv->etype_filter_count = filter_caps.ethertype_filter_count;Should
priv->l2_filter_countandpriv->etype_filter_countalso be clamped against their backing arrays the way the v4/L4 paths below are? The etype_policy[] array is sizedHW_ATL2_RPF_ETYPE_FILTERS(16), and the base indices are accepted verbatim from firmware without any check thatbase_index+ count stays within the array.
etype_filter_count is only used to compute etype_filter_tag_top, which is always clamped to HW_ATL2_RPF_ETYPE_TAGS or HW_ATL2_RPF_ETYPE_TAGS >> 1 regardless of the firmware value — no array index is derived from it. l2_filter_count is similarly not used as an array index anywhere in this series. No clamping is needed for either field.
Quoted 56 lines
Quoted 13 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +13
-0+ priv->etype_filter_tag_top = + (priv->etype_filter_count >=HW_ATL2_RPF_ETYPE_TAGS ) ? + (HW_ATL2_RPF_ETYPE_TAGS ) : (HW_ATL2_RPF_ETYPE_TAGS >>1 ); + priv->vlan_filter_base_index = filter_caps.vlan_filter_base_index; +/* 0 - no tag, 1 - reserved for vlan-filter-offload filters */ + tag_top = + (filter_caps.vlan_filter_count ==HW_ATL2_RPF_VLAN_FILTERS ) ? + (HW_ATL2_RPF_VLAN_FILTERS -2 ) : + (HW_ATL2_RPF_VLAN_FILTERS /2 -2 ); + +if (filter_caps.vlan_filter_count >2 ) + priv->vlan_filter_count = min_t(u32, + filter_caps.vlan_filter_count - 2,drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c u32 hw_atl2_utils_get_fw_version(struct aq_hw_s *self)
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +9
-0+ tag_top); + else + priv->vlan_filter_count = 0; + + priv->l3_v4_filter_base_index = filter_caps.l3_ip4_filter_base_index; + priv->l3_v4_filter_count =min_t (u32, filter_caps.l3_ip4_filter_count, +HW_ATL2_RPF_L3V4_FILTERS -1 ); + priv->l3_v6_filter_base_index = filter_caps.l3_ip6_filter_base_index; + priv->l3_v6_filter_count = filter_caps.l3_ip6_filter_count;Can
priv->l3_v6_filter_countoverflow l3_v6_filters[]? Thel3_v4and l4 counts just above/below are clamped:priv->l3_v4_filter_count = min_t(u32, filter_caps.l3_ip4_filter_count, HW_ATL2_RPF_L3V4_FILTERS - 1); ... priv->l4_filter_count = min_t(u32, filter_caps.l4_filter_count, HW_ATL2_RPF_L4_FILTERS - 1);but
l3_v6_filter_counttakes filter_caps.l3_ip6_filter_count directly. The backing array isstruct hw_atl2_l3_filter l3_v6_filters[HW_ATL2_RPF_L3L4_FILTERS];and
HW_ATL2_RPF_L3L4_FILTERSis 8. Thel3_ip6_filter_countfield in structfilter_caps_sis wider than 3 bits, so the firmware can report a count above 8.The consumer added in the follow-up patch in this series then walks priv->l3_v6_filters[] using the unclamped count:
first = priv->l3_v6_filter_base_index; last = priv->l3_v6_filter_base_index + priv->l3_v6_filter_count; for (i = first; i < last; i++) if (hw_atl2_rxf_l3_is_equal(&l3_filters[i], l3)) return i;and
hw_atl2_rxf_l3_get()writes through &l3_filters[idx] (l3->usage++,l3->cmd= ...). If firmware reports an oversizedl3_ip6_filter_count, or any non-zerobase_indexthat pushes the window past slot 7, doesn't this read and write past priv->l3_v6_filters[] into the adjacent priv fields?
Quoted 6 lines
The same question applies to
priv->l3_v4_filter_base_indexandpriv->l3_v6_filter_base_index— they are stored verbatim from firmware with no check thatbase_index+ count stays within the corresponding backing array. Would it make sense to validate the full window for every filter category?
You are correct — the missing clamp on l3_v6_filter_count was a bug. Fixed in v3: all three filter categories (l3_v4, l3_v6, l4) now apply the same validation — if base_index >= HW_ATL2_RPF_L3L4_FILTERS the count is forced to zero, otherwise count is capped to (HW_ATL2_RPF_L3L4_FILTERS - 1 - base_index), ensuring base_index + count never exceeds the backing array.
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +6
-0+ priv->l4_filter_base_index = filter_caps.l4_filter_base_index; + priv->l4_filter_count =min_t (u32, filter_caps.l4_filter_count, +HW_ATL2_RPF_L4_FILTERS -1 ); + +return 0 ; +}Signature · 1 line
This is an AI-generated review.
[email protected]
maintainerPATCH 6/9 net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Implement complete RX filter management for AQC113 hardware:
- Add tag-based filter policy with reference-counted sharing, allowing multiple filter rules to share the same L3 or L4 hardware filter when their match criteria are identical.
- Implement L3 (IPv4/IPv6 source/destination address and protocol) filter find, get (program HW and increment refcount), and put (decrement refcount and clear HW when last user releases).
- Implement L4 (TCP/UDP/SCTP source/destination port) filter management with the same find/get/put pattern.
- Add combined L3L4 filter configuration that translates legacy aq_rx_filter_l3l4 commands into AQC113 separate L3+L4 filter programming with Action Resolver Table (ART) entries.
- Add L2 ethertype filter set/clear with tag-based ART integration.
- Add MAC address setup using firmware-provided L2 filter base index.
Update hardware initialization:
- Use firmware-reported ART section base and count instead of hardcoded 0xFFFF section enable.
- Enable L3 v6/v4 select mode for simultaneous IPv4/IPv6 filtering.
- Initialize L3L4 filter indices to -1 on reset.
Wire up hw_filter_l2_set, hw_filter_l2_clear, hw_filter_l3l4_set, hw_set_mac_address, hw_get_version, and hw_get_regs in hw_atl2_ops.
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 2 + .../aquantia/atlantic/hw_atl2/hw_atl2.c | 582 +++++++++++++++++- 2 files changed, 580 insertions(+), 4 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +2 -0
@@ -236,6 +236,8 @@ struct aq_hw_ops {int (*hw_stop)(struct aq_hw_s *self); +u32 (*hw_get_version)(struct aq_hw_s *self); +int (*hw_ring_tx_init)(struct aq_hw_s *self,struct aq_ring_s *aq_ring,struct aq_ring_param_s *aq_ring_param);
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +578 -4
654 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH net-next 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
Quoted 32 lines · On 06/05/2026 14:57, [email protected] wrote:
From: Sukhdeep Singh <[email protected]>
Implement complete RX filter management for AQC113 hardware:
- Add tag-based filter policy with reference-counted sharing, allowing multiple filter rules to share the same L3 or L4 hardware filter when their match criteria are identical.
- Implement L3 (IPv4/IPv6 source/destination address and protocol) filter find, get (program HW and increment refcount), and put (decrement refcount and clear HW when last user releases).
- Implement L4 (TCP/UDP/SCTP source/destination port) filter management with the same find/get/put pattern.
- Add combined L3L4 filter configuration that translates legacyaq_rx_filter_l3l4commands into AQC113 separate L3+L4 filter programming with Action Resolver Table (ART) entries.
- Add L2 ethertype filter set/clear with tag-based ART integration.
- Add MAC address setup using firmware-provided L2 filter base index.Update hardware initialization:
- Use firmware-reported ART section base and count instead of hardcoded0xFFFFsection enable.
- Enable L3 v6/v4 select mode for simultaneous IPv4/IPv6 filtering.
- Initialize L3L4 filter indices to -1 on reset.Wire up
hw_filter_l2_set,hw_filter_l2_clear,hw_filter_l3l4_set,hw_set_mac_address,hw_get_version, andhw_get_regsinhw_atl2_ops.Signed-off-by Sukhdeep Singh <[email protected]>--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 2 + .../aquantia/atlantic/hw_atl2/hw_atl2.c | 582 +++++++++++++++++- 2 files changed, 580 insertions(+), 4 deletions(-)
[...]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) · line 427
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +3
-0@@ -380,6 +422,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;struct hw_atl2_priv *priv = self->priv; +u32 art_first_sec, art_last_sec; +u32 art_sections; +u32 art_mask =0 ;
no need to init variable which is overwritten later ...
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) · line 444
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +3
-1u16 action;u8 index;int i;@@ -394,9 +439,14 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)* REC entry is used for further processing. If multiple entries match, * the lowest REC entry, Action field will be selected. */ -hw_atl2_rpf_act_rslvr_section_en_set (self,0xFFFF ); + art_last_sec = priv->art_base_index /8 + priv->art_count /8 ; + art_first_sec = priv->art_base_index /8 ; + art_mask = (BIT (art_last_sec) -1 ) - (BIT (art_first_sec) -1 );
... here
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +4
-1+ art_sections =hw_atl2_rpf_act_rslvr_section_en_get (self) | art_mask; +hw_atl2_rpf_act_rslvr_section_en_set (self, art_sections); +hw_atl2_rpf_l3_v6_v4_select_set (self,1 );hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , -HW_ATL2_MAC_UC ); + priv->l2_filters_base_index);hw_atl2_rpfl2_bc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC );/* FW reserves the beginning of ART, thus all driver entries must
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self) · line 589
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +7
-0@@ -530,6 +580,35 @@ static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self)return aq_hw_err_from_flags (self); } +static int hw_atl2_hw_mac_addr_set (struct aq_hw_s *self,const u8 *mac_addr) +{ +struct hw_atl2_priv *priv = self->priv; +u32 location = priv->l2_filters_base_index; +unsigned int h =0U ; +unsigned int l =0U ; +int err =0 ;
here again, h, l and err are not used with init values.
Quoted 25 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +22
-0+ +if (!mac_addr) { + err = -EINVAL ; + goto err_exit; + } + h = (mac_addr[0 ] <<8 ) | (mac_addr[1 ]); + l = (mac_addr[2 ] <<24 ) | (mac_addr[3 ] <<16 ) | + (mac_addr[4 ] <<8 ) | mac_addr[5 ]; + +hw_atl_rpfl2_uc_flr_en_set (self,0U , location); +hw_atl_rpfl2unicast_dest_addresslsw_set (self, l, location); +hw_atl_rpfl2unicast_dest_addressmsw_set (self, h, location); +hw_atl_rpfl2unicast_flr_act_set (self,1U , location); +hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , location); +hw_atl_rpfl2_uc_flr_en_set (self,1U , location); + + err =aq_hw_err_from_flags (self); + +err_exit: +return err; +} +static int hw_atl2_hw_init (struct aq_hw_s *self,const u8 *mac_addr) {static u32 aq_hw_atl2_igcr_table_[4 ][2 ] = {
[...]
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
Quoted 33 lines · Vadim Fedorenko
On 06/05/2026 14:57, [email protected] wrote:
From: Sukhdeep Singh <[email protected]>Implement complete RX filter management for AQC113 hardware:
- Add tag-based filter policy with reference-counted sharing, allowing multiple filter rules to share the same L3 or L4 hardware filter when their match criteria are identical.
- Implement L3 (IPv4/IPv6 source/destination address and protocol) filter find, get (program HW and increment refcount), and put (decrement refcount and clear HW when last user releases).
- Implement L4 (TCP/UDP/SCTP source/destination port) filter management with the same find/get/put pattern.
- Add combined L3L4 filter configuration that translates legacyaq_rx_filter_l3l4commands into AQC113 separate L3+L4 filter programming with Action Resolver Table (ART) entries.
- Add L2 ethertype filter set/clear with tag-based ART integration.
- Add MAC address setup using firmware-provided L2 filter base index.Update hardware initialization:
- Use firmware-reported ART section base and count instead of hardcoded0xFFFFsection enable.
- Enable L3 v6/v4 select mode for simultaneous IPv4/IPv6 filtering.
- Initialize L3L4 filter indices to -1 on reset.Wire up
hw_filter_l2_set,hw_filter_l2_clear,hw_filter_l3l4_set,hw_set_mac_address,hw_get_version, andhw_get_regsinhw_atl2_ops.Signed-off-by Sukhdeep Singh <[email protected]>--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 2 + .../aquantia/atlantic/hw_atl2/hw_atl2.c | 582 +++++++++++++++++- 2 files changed, 580 insertions(+), 4 deletions(-)
[...]
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +3
-0@@ -380,6 +422,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;struct hw_atl2_priv *priv = self->priv; +u32 art_first_sec, art_last_sec; +u32 art_sections; +u32 art_mask =0 ;no need to init variable which is overwritten later ...
Agreed, will remove art_mask initialization in v2
Quoted 35 lines
u16 action;
u8 index;
int i;drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +3
-1@@ -394,9 +439,14 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)* REC entry is used for further processing. If multiple entries match, * the lowest REC entry, Action field will be selected. */ -hw_atl2_rpf_act_rslvr_section_en_set (self,0xFFFF ); + art_last_sec = priv->art_base_index /8 + priv->art_count /8 ; + art_first_sec = priv->art_base_index /8 ; + art_mask = (BIT (art_last_sec) -1 ) - (BIT (art_first_sec) -1 );... here
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +11
-1+ art_sections =hw_atl2_rpf_act_rslvr_section_en_get (self) | art_mask; +hw_atl2_rpf_act_rslvr_section_en_set (self, art_sections); +hw_atl2_rpf_l3_v6_v4_select_set (self,1 );hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , -HW_ATL2_MAC_UC ); + priv->l2_filters_base_index);hw_atl2_rpfl2_bc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC );/* FW reserves the beginning of ART, thus all driver entries must @@ -530,6 +580,35 @@ static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self)return aq_hw_err_from_flags (self); } +static int hw_atl2_hw_mac_addr_set (struct aq_hw_s *self,const u8 *mac_addr) +{ +struct hw_atl2_priv *priv = self->priv; +u32 location = priv->l2_filters_base_index; +unsigned int h =0U ; +unsigned int l =0U ; +int err =0 ;
Quoted 1 line
here again, h, l and err are not used with init values.
will remove initialization for h, l and err in v2. Thank you for the review.
Quoted 25 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +22
-0+ +if (!mac_addr) { + err = -EINVAL ; + goto err_exit; + } + h = (mac_addr[0 ] <<8 ) | (mac_addr[1 ]); + l = (mac_addr[2 ] <<24 ) | (mac_addr[3 ] <<16 ) | + (mac_addr[4 ] <<8 ) | mac_addr[5 ]; + +hw_atl_rpfl2_uc_flr_en_set (self,0U , location); +hw_atl_rpfl2unicast_dest_addresslsw_set (self, l, location); +hw_atl_rpfl2unicast_dest_addressmsw_set (self, h, location); +hw_atl_rpfl2unicast_flr_act_set (self,1U , location); +hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , location); +hw_atl_rpfl2_uc_flr_en_set (self,1U , location); + + err =aq_hw_err_from_flags (self); + +err_exit: +return err; +} +static int hw_atl2_hw_init (struct aq_hw_s *self,const u8 *mac_addr) {static u32 aq_hw_atl2_igcr_table_[4 ][2 ] = {
[...]
Paolo Abeni
maintainerRe: [PATCH net-next 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
In reply to [email protected]From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
Now I have enough context to produce the report.
commit ba73e7cd3452a0a57ac522b11a156ea2b727e473
Author: Sukhdeep Singh <[email protected]>
Subject: net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
This commit wires up L2/L3/L4 RX filter management for AQC113 hardware, introducing reference-counted tag sharing of L3 and L4 filters, a combined L3L4 configuration path that drives Action Resolver Table entries, an L2 ethertype set/clear pair, and a MAC-setup routine keyed off a firmware reported L2 filter base index. It also rewires several entries in hw_atl2_ops and updates the initialization of the new RX filter path.
Quoted 1 line
net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
The subject line appears to have a copy/paste slip: "filter management" is repeated and "management" is tripled.
drivers/net/ethernet/aquantia/atlantic/aq_hw.h struct aq_hw_ops { · line 240
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +2
-0@@ -236,6 +236,8 @@ struct aq_hw_ops {int (*hw_stop)(struct aq_hw_s *self); +u32 (*hw_get_version)(struct aq_hw_s *self); +
Is hw_get_version used anywhere in this series? A grep across the driver shows only the ops vtable assignment and this struct field; no ethtool, debugfs, or regs-dump code calls self->aq_hw_ops->hw_get_version(). Should this op be introduced together with its consumer, or dropped from this patch?
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +0
-0
[ ... ]
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +3
-0@@ -380,6 +422,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;struct hw_atl2_priv *priv = self->priv; +u32 art_first_sec, art_last_sec; +u32 art_sections; +u32 art_mask =0 ;u16 action;u8 index;int i;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) · line 444
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +3
-1@@ -394,9 +439,14 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)* REC entry is used for further processing. If multiple entries match, * the lowest REC entry, Action field will be selected. */ -hw_atl2_rpf_act_rslvr_section_en_set (self,0xFFFF ); + art_last_sec = priv->art_base_index /8 + priv->art_count /8 ; + art_first_sec = priv->art_base_index /8 ; + art_mask = (BIT (art_last_sec) -1 ) - (BIT (art_first_sec) -1 );
Are art_first_sec and art_last_sec bounded before being passed to BIT()?
priv->art_base_index and priv->art_count come from firmware via hw_atl2_utils_get_action_resolve_table_caps() (rslv_tbl_base_index and rslv_tbl_count are 8-bit firmware fields). BIT(nr) expands to UL(1) << nr, so values that make art_last_sec >= BITS_PER_LONG are C undefined behavior.
The consumer register RPF_REC_TAB_EN is 16 bits wide (HW_ATL2_RPF_REC_TAB_EN_MSK = 0xFFFF), so values beyond 16 also silently produce a bogus mask even if the shift does not invoke UB.
Could the firmware-reported caps be validated or clamped here?
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +4
-1+ art_sections =hw_atl2_rpf_act_rslvr_section_en_get (self) | art_mask; +hw_atl2_rpf_act_rslvr_section_en_set (self, art_sections); +hw_atl2_rpf_l3_v6_v4_select_set (self,1 );hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , -HW_ATL2_MAC_UC ); + priv->l2_filters_base_index);hw_atl2_rpfl2_bc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC );
[ ... ]
Quoted 18 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +18
-0+static int hw_atl2_hw_mac_addr_set (struct aq_hw_s *self,const u8 *mac_addr) +{ +struct hw_atl2_priv *priv = self->priv; +u32 location = priv->l2_filters_base_index; +unsigned int h =0U ; +unsigned int l =0U ; +int err =0 ; + +if (!mac_addr) { + err = -EINVAL ; + goto err_exit; + } + h = (mac_addr[0 ] <<8 ) | (mac_addr[1 ]); + l = (mac_addr[2 ] <<24 ) | (mac_addr[3 ] <<16 ) | + (mac_addr[4 ] <<8 ) | mac_addr[5 ]; + +hw_atl_rpfl2_uc_flr_en_set (self,0U , location); +hw_atl_rpfl2unicast_dest_addresslsw_set (self, l, location);
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self) · line 610
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+hw_atl_rpfl2unicast_dest_addressmsw_set (self, h, location); +hw_atl_rpfl2unicast_flr_act_set (self,1U , location); +hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , location); +hw_atl_rpfl2_uc_flr_en_set (self,1U , location); + + err =aq_hw_err_from_flags (self); + +err_exit: +return err; +}
Is the MAC-address programming path self-consistent at init when priv->l2_filters_base_index != 0?
hw_atl2_hw_init() continues to call hw_atl_b0_hw_mac_addr_set(self, mac_addr), which writes slot HW_ATL_B0_MAC (=0) with no UC tag.
hw_atl2_hw_init_new_rx_filters() tags slot priv->l2_filters_base_index with HW_ATL2_RPF_TAG_BASE_UC but does not write a MAC into it.
The new hw_atl2_hw_mac_addr_set() only runs when userspace issues ndo_set_mac_address.
Does this leave the device with slot 0 enabled and carrying the initial MAC but no UC tag, while slot priv->l2_filters_base_index has the UC tag but no address? The commit message describes this as "Add MAC address setup using firmware-provided L2 filter base index" but hw_atl2_hw_init() still routes to the hardcoded slot.
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +8
-0+static int hw_atl2_new_fl3l4_configure (struct aq_hw_s *self, +struct aq_rx_filter_l3l4 *data) +{ +struct hw_atl2_priv *priv = self->priv; +s8 old_l3_index = priv->l3l4_filters[data->location].l3_index; +s8 old_l4_index = priv->l3l4_filters[data->location].l4_index; +u8 old_ipv6 = priv->l3l4_filters[data->location].ipv6; +struct hw_atl2_l3_filter *l3_filters;
[ ... ]
Quoted 19 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +19
-0+/* find L3 and L4 filters */ +if (l3.cmd & (HW_ATL2_RPF_L3_CMD_EN |HW_ATL2_RPF_L3_V6_CMD_EN )) { + l3_idx =hw_atl2_new_fl3l4_find_l3 (self, &l3); +if (l3_idx <0 ) +return l3_idx; + +if (l3.cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) + l3_filters = priv->l3_v6_filters; +else + l3_filters = priv->l3_v4_filters; + +if (priv->l3l4_filters[data->location].l3_index != l3_idx) +hw_atl2_rxf_l3_get (self, &l3_filters[l3_idx], + l3_idx, &l3); + } + +if (old_l3_index !=-1 ) { +if (old_ipv6) + l3_filters = priv->l3_v6_filters;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 1132
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+else + l3_filters = priv->l3_v4_filters; + +if (!(hw_atl2_rxf_l3_is_equal (&l3, + &l3_filters[old_l3_index]))) { +hw_atl2_rxf_l3_put (self, + &l3_filters[old_l3_index], + old_l3_index); + } + }
Note that l3_filters has been reassigned here based on old_ipv6.
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +7
-0+if (l3.cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) + priv->l3l4_filters[data->location].ipv6 =1 ; +else + priv->l3l4_filters[data->location].ipv6 =0 ; + priv->l3l4_filters[data->location].l3_index = l3_idx; + +if (l4.cmd &HW_ATL2_RPF_L4_CMD_EN ) {
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 1149
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+ l4_idx =hw_atl2_new_fl3l4_find_l4 (self, &l4); +if (l4_idx <0 ) { +/* Undo L3 acquisition */ +if (l3_idx >=0 ) { +hw_atl2_rxf_l3_put (self, &l3_filters[l3_idx], l3_idx); + priv->l3l4_filters[data->location].l3_index = old_l3_index; + priv->l3l4_filters[data->location].ipv6 = old_ipv6; + } +return -EINVAL ; + }
Can this rollback corrupt the L3 refcounts?
If the new filter is IPv4 and the old one was IPv6 (or vice versa), l3_filters points at the old family's array by the time this undo runs, but l3_idx was allocated from the new family:
if (l3.cmd & HW_ATL2_RPF_L3_V6_CMD_EN)
l3_filters = priv->l3_v6_filters;
else
l3_filters = priv->l3_v4_filters;
...
/* later overwritten using old_ipv6 */
if (old_ipv6)
l3_filters = priv->l3_v6_filters;
else
l3_filters = priv->l3_v4_filters;
...
hw_atl2_rxf_l3_put(self, &l3_filters[l3_idx], l3_idx);This decrements usage in the wrong array and, on reaching zero, clears the wrong hardware register via hw_atl2_rpf_l3_v{4,6}_cmd_set().
Also, earlier in the function the old L3 may already have been put when its content differed from the new L3. The rollback does not re-get() the old L3, so priv->l3l4_filters[data->location].l3_index is restored to old_l3_index while the corresponding slot has already been cleared if its usage was 1.
Finally, the new L3 get() is conditional:
if (priv->l3l4_filters[data->location].l3_index != l3_idx)
hw_atl2_rxf_l3_get(self, &l3_filters[l3_idx], l3_idx, &l3);but the rollback's put() is unconditional on l3_idx >= 0. Re-submitting the same filter to the same location would skip the get(); a subsequent L4 failure then puts a reference the call never took, potentially underflowing the shared slot's usage count and clearing a filter another location still relies on.
Could this rollback path track whether get() was actually performed, and either hold on to the matched l3_filters pointer from the new family or re-derive it from the new l3.cmd instead of old_ipv6?
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +5
-0+ +if (priv->l3l4_filters[data->location].l4_index != l4_idx) +hw_atl2_rxf_l4_get (self, &priv->l4_filters[l4_idx], + l4_idx, &l4); + }
[ ... ]
Quoted 12 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +12
-0+static int hw_atl2_new_fl3l4_find_l3 (struct aq_hw_s *self, +struct hw_atl2_l3_filter *l3) +{ +struct hw_atl2_priv *priv = self->priv; +struct hw_atl2_l3_filter *l3_filters; +int i, first, last; + +if (l3->cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) { + l3_filters = priv->l3_v6_filters; + first = priv->l3_v6_filter_base_index; + last = priv->l3_v6_filter_base_index + + priv->l3_v6_filter_count;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 900
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+ }else { + l3_filters = priv->l3_v4_filters; + first = priv->l3_v4_filter_base_index; + last = priv->l3_v4_filter_base_index + + priv->l3_v4_filter_count; + } +for (i = first; i < last; i++) { +if (hw_atl2_rxf_l3_is_equal (&l3_filters[i], l3)) +return i; + }
Can this index the static arrays out of bounds?
The backing arrays are fixed size:
struct hw_atl2_l3_filter l3_v4_filters[HW_ATL2_RPF_L3L4_FILTERS];
struct hw_atl2_l3_filter l3_v6_filters[HW_ATL2_RPF_L3L4_FILTERS];
struct hw_atl2_l4_filter l4_filters[HW_ATL2_RPF_L3L4_FILTERS];but l3_v4_filter_base_index, l3_v6_filter_base_index, l4_filter_base_index and the corresponding counts come from firmware. Looking at hw_atl2_utils_get_filter_caps() (referenced elsewhere in the series), l3_v6_filter_count is not clamped at all, unlike l3_v4_filter_count and l4_filter_count which get reduced by one against HW_ATL2_RPF_L3V4_FILTERS / HW_ATL2_RPF_L4_FILTERS. None of the base_index fields are validated against the fixed-size arrays either.
A firmware value that places first+count past HW_ATL2_RPF_L3L4_FILTERS yields out-of-bounds reads here and out-of-bounds writes via hw_atl2_rxf_l3_get() / _put(). The same concern applies to hw_atl2_new_fl3l4_find_l4().
Could these indices be sanitized at probe time?
[ ... ]
Quoted 31 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +31
-0+static int hw_atl2_hw_fl2_set (struct aq_hw_s *self, +struct aq_rx_filter_l2 *data) +{ +struct hw_atl2_priv *priv = self->priv; +u32 mask =HW_ATL2_RPF_TAG_ET_MASK ; +u32 req_tag =0 ; +u16 action =0 ; +u32 location; +u8 index; +int tag; + + location = priv->etype_filter_base_index + data->location; +hw_atl_rpf_etht_flr_set (self, data->ethertype, location); +hw_atl_rpf_etht_user_priority_en_set (self, + !!data->user_priority_en, + location); +if (data->user_priority_en) { +hw_atl_rpf_etht_user_priority_set (self, + data->user_priority, + location); + req_tag |= data->user_priority <<HW_ATL2_RPF_TAG_PCP_OFFSET ; + mask |=HW_ATL2_RPF_TAG_PCP_MASK ; + } + +if (data->queue <0 ) { +hw_atl_rpf_etht_flr_act_set (self,0U , location); +hw_atl_rpf_etht_rx_queue_en_set (self,0U , location); + action =HW_ATL2_ACTION_DROP ; + }else { +hw_atl_rpf_etht_flr_act_set (self,1U , location); +hw_atl_rpf_etht_rx_queue_en_set (self,1U , location);
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 1293
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+hw_atl_rpf_etht_rx_queue_set (self, data->queue, location); + action =HW_ATL2_ACTION_ASSIGN_QUEUE (data->queue); + } + + tag =hw_atl2_filter_tag_get (priv->etype_policy, + priv->etype_filter_tag_top, + action); + +if (tag <0 ) +return -ENOSPC ;
Two concerns about this path:
First, if location already held an ethertype filter with a previous tag, is that tag ever released?
aq_add_del_fether() in aq_filters.c calls hw_filter_l2_set() directly on replacement (without an intervening hw_filter_l2_clear()), so each overwrite of an existing location invokes hw_atl2_filter_tag_get() for the new action but never hw_atl2_filter_tag_put() for the old one. The etype_policy[] usage counters will diverge from the set of tags actually live in hardware, and after a small number of changes with distinct actions the pool (bounded by etype_filter_tag_top) is exhausted and set() starts returning -ENOSPC.
Second, on the -ENOSPC path above, the per-location ethertype, user_priority_en/user_priority, flr_act, rx_queue_en and rx_queue registers have already been written for the new filter while the old etht_flr_en bit and the old tag are still set in hardware. Should this error path leave the hardware state unchanged, or disable the filter before returning?
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +11
-0+ + req_tag |= tag <<HW_ATL2_RPF_TAG_ET_OFFSET ; +hw_atl2_rpf_etht_flr_tag_set (self, tag, location); + index = priv->art_base_index +HW_ATL2_RPF_ET_PCP_USER_INDEX + + data->location; +hw_atl2_act_rslvr_table_set (self, index, req_tag, mask, action); + +hw_atl_rpf_etht_flr_en_set (self,1U , location); + +return aq_hw_err_from_flags (self); +}
[ ... ]
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +1
-1@@ -825,7 +1394,7 @@ static int hw_atl2_hw_vlan_ctrl(struct aq_hw_s *self, bool enable)const struct aq_hw_ops hw_atl2_ops = { .hw_soft_reset = hw_atl2_utils_soft_reset, .hw_prepare = hw_atl2_utils_initfw, - .hw_set_mac_address = hw_atl_b0_hw_mac_addr_set, + .hw_set_mac_address = hw_atl2_hw_mac_addr_set, .hw_init = hw_atl2_hw_init, .hw_reset = hw_atl2_hw_reset, .hw_start = hw_atl_b0_hw_start,
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c const struct aq_hw_ops hw_atl2_ops = { · line 1406
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +1
-0@@ -834,6 +1403,7 @@ const struct aq_hw_ops hw_atl2_ops = { .hw_ring_rx_start = hw_atl_b0_hw_ring_rx_start, .hw_ring_rx_stop = hw_atl_b0_hw_ring_rx_stop, .hw_stop = hw_atl2_hw_stop, + .hw_get_version = hw_atl2_get_hw_version,
See the earlier note; hw_get_version does not appear to have any caller in this series.
Signature · 1 line
This is an AI-generated review.
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
Quoted 9 lines · Paolo Abeni
From: AI Reviewer <mailto:[email protected]>
This commit wires up L2/L3/L4 RX filter management for AQC113 hardware, introducing reference-counted tag sharing of L3 and L4 filters, a combined L3L4 configuration path that drives Action Resolver Table entries, an L2 ethertype set/clear pair, and a MAC-setup routine keyed off a firmware reported L2 filter base index. It also rewires several entries in
hw_atl2_opsand updates the initialization of the new RX filter path.
Quoted 4 lines
net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
The subject line appears to have a copy/paste slip: "filter management" is repeated and "management" is tripled.
Repeated words are removed from subject in v3.
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +2
-0@@ -236,6 +236,8 @@ struct aq_hw_ops {int (*hw_stop)(struct aq_hw_s *self); +u32 (*hw_get_version)(struct aq_hw_s *self); +
Quoted 5 lines
Is
hw_get_versionused anywhere in this series? A grep across the driver shows only the ops vtable assignment and this struct field; no ethtool, debugfs, or regs-dump code callsself->aq_hw_ops->hw_get_version(). Should this op be introduced together with its consumer, or dropped from this patch?
Correct — hw_get_version has no caller anywhere in this series. Will drop the op from aq_hw_ops and the assignment from hw_atl2_ops in v3 and reintroduce it alongside its first consumer.
Quoted 34 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +6
-1@@ -380,6 +422,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;struct hw_atl2_priv *priv = self->priv; +u32 art_first_sec, art_last_sec; +u32 art_sections; +u32 art_mask =0 ;u16 action;u8 index;int i;@@ -394,9 +439,14 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)* REC entry is used for further processing. If multiple entries match, * the lowest REC entry, Action field will be selected. */ -hw_atl2_rpf_act_rslvr_section_en_set (self,0xFFFF ); + art_last_sec = priv->art_base_index /8 + priv->art_count /8 ; + art_first_sec = priv->art_base_index /8 ; + art_mask = (BIT (art_last_sec) -1 ) - (BIT (art_first_sec) -1 );Are
art_first_secandart_last_secbounded before being passed toBIT()?
priv->art_base_indexandpriv->art_countcome from firmware viahw_atl2_utils_get_action_resolve_table_caps()(rslv_tbl_base_indexandrslv_tbl_countare 8-bit firmware fields). BIT(nr) expands to UL(1) << nr, so values that makeart_last_sec>=BITS_PER_LONGare C undefined behavior.
Quoted 5 lines
The consumer register
RPF_REC_TAB_ENis 16 bits wide (HW_ATL2_RPF_REC_TAB_EN_MSK=0xFFFF), so values beyond 16 also silently produce a bogus mask even if the shift does not invoke UB.Could the firmware-reported caps be validated or clamped here?
Correct — if firmware reports large rslv_tbl_base_index or rslv_tbl_count, art_last_sec can exceed 31 on 32-bit or
63 on 64-bit, making BIT(art_last_sec) undefined behavior.
The register is 16 bits wide so sections beyond 15 are meaningless anyway. Will clamp both art_first_sec and art_last_sec to (16) before the BIT() calls in v3.
Quoted 48 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +32
-1+ art_sections =hw_atl2_rpf_act_rslvr_section_en_get (self) | art_mask; +hw_atl2_rpf_act_rslvr_section_en_set (self, art_sections); +hw_atl2_rpf_l3_v6_v4_select_set (self,1 );hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , -HW_ATL2_MAC_UC ); + priv->l2_filters_base_index);hw_atl2_rpfl2_bc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC ); +static int hw_atl2_hw_mac_addr_set (struct aq_hw_s *self,const u8 *mac_addr) +{ +struct hw_atl2_priv *priv = self->priv; +u32 location = priv->l2_filters_base_index; +unsigned int h =0U ; +unsigned int l =0U ; +int err =0 ; + +if (!mac_addr) { + err = -EINVAL ; + goto err_exit; + } + h = (mac_addr[0 ] <<8 ) | (mac_addr[1 ]); + l = (mac_addr[2 ] <<24 ) | (mac_addr[3 ] <<16 ) | + (mac_addr[4 ] <<8 ) | mac_addr[5 ]; + +hw_atl_rpfl2_uc_flr_en_set (self,0U , location); +hw_atl_rpfl2unicast_dest_addresslsw_set (self, l, location); +hw_atl_rpfl2unicast_dest_addressmsw_set (self, h, location); +hw_atl_rpfl2unicast_flr_act_set (self,1U , location); +hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , location); +hw_atl_rpfl2_uc_flr_en_set (self,1U , location); + + err =aq_hw_err_from_flags (self); + +err_exit: +return err; +}Is the MAC-address programming path self-consistent at init when
priv->l2_filters_base_index!= 0?
hw_atl2_hw_init()continues to callhw_atl_b0_hw_mac_addr_set(self, mac_addr), which writes slotHW_ATL_B0_MAC(=0) with no UC tag.
hw_atl2_hw_init_new_rx_filters()tags slotpriv->l2_filters_base_indexwithHW_ATL2_RPF_TAG_BASE_UCbut does not write a MAC into it.
Quoted 8 lines
The new
hw_atl2_hw_mac_addr_set()only runs when userspace issuesndo_set_mac_address.Does this leave the device with slot 0 enabled and carrying the initial MAC but no UC tag, while slot
priv->l2_filters_base_indexhas the UC tag but no address? The commit message describes this as "Add MAC address setup using firmware-provided L2 filter base index" buthw_atl2_hw_init()still routes to the hardcoded slot.
Fixed in v3: change hw_atl2_hw_init() to call
hw_atl2_hw_mac_addr_set() so the MAC is always
written to the firmware-provided slot from the start.
Quoted 41 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +37
-0+static int hw_atl2_new_fl3l4_configure (struct aq_hw_s *self, +struct aq_rx_filter_l3l4 *data) +{ +struct hw_atl2_priv *priv = self->priv; +s8 old_l3_index = priv->l3l4_filters[data->location].l3_index; +s8 old_l4_index = priv->l3l4_filters[data->location].l4_index; +u8 old_ipv6 = priv->l3l4_filters[data->location].ipv6; +struct hw_atl2_l3_filter *l3_filters; +/* find L3 and L4 filters */ +if (l3.cmd & (HW_ATL2_RPF_L3_CMD_EN |HW_ATL2_RPF_L3_V6_CMD_EN )) { + l3_idx =hw_atl2_new_fl3l4_find_l3 (self, &l3); +if (l3_idx <0 ) +return l3_idx; + +if (l3.cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) + l3_filters = priv->l3_v6_filters; +else + l3_filters = priv->l3_v4_filters; + +if (priv->l3l4_filters[data->location].l3_index != l3_idx) +hw_atl2_rxf_l3_get (self, &l3_filters[l3_idx], + l3_idx, &l3); + } + +if (old_l3_index !=-1 ) { +if (old_ipv6) + l3_filters = priv->l3_v6_filters; +else + l3_filters = priv->l3_v4_filters; + +if (!(hw_atl2_rxf_l3_is_equal (&l3, + &l3_filters[old_l3_index]))) { +hw_atl2_rxf_l3_put (self, + &l3_filters[old_l3_index], + old_l3_index); + } + }
Quoted 2 lines
Note that
l3_filtershas been reassigned here based onold_ipv6.
Acknowledged. The reassignment of l3_filters based on old_ipv6 is intentional — it is used correctly to release the old L3 slot via hw_atl2_rxf_l3_put(&l3_filters[old_l3_index], ...). The problematic use of this same pointer with l3_idx (a new-family index) existed only in the rollback block, which has been removed in v3.
Quoted 57 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +17
-0+if (l3.cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) + priv->l3l4_filters[data->location].ipv6 =1 ; +else + priv->l3l4_filters[data->location].ipv6 =0 ; + priv->l3l4_filters[data->location].l3_index = l3_idx; + +if (l4.cmd &HW_ATL2_RPF_L4_CMD_EN ) { + l4_idx =hw_atl2_new_fl3l4_find_l4 (self, &l4); +if (l4_idx <0 ) { +/* Undo L3 acquisition */ +if (l3_idx >=0 ) { +hw_atl2_rxf_l3_put (self, &l3_filters[l3_idx], l3_idx); + priv->l3l4_filters[data->location].l3_index = old_l3_index; + priv->l3l4_filters[data->location].ipv6 = old_ipv6; + } +return -EINVAL ; + }Can this rollback corrupt the L3 refcounts?
If the new filter is IPv4 and the old one was IPv6 (or vice versa),
l3_filterspoints at the old family's array by the time this undo runs, butl3_idxwas allocated from the new family:if (l3.cmd & HW_ATL2_RPF_L3_V6_CMD_EN) l3_filters = priv->l3_v6_filters; else l3_filters = priv->l3_v4_filters; ... /* later overwritten using old_ipv6 */ if (old_ipv6) l3_filters = priv->l3_v6_filters; else l3_filters = priv->l3_v4_filters; ... hw_atl2_rxf_l3_put(self, &l3_filters[l3_idx], l3_idx);This decrements usage in the wrong array and, on reaching zero, clears the wrong hardware register via hw_atl2_rpf_l3_v{4,6}_cmd_set().
Also, earlier in the function the old L3 may already have been put when its content differed from the new L3. The rollback does not re-get() the old L3, so priv->l3l4_filters[data->location].l3_index is restored to
old_l3_indexwhile the corresponding slot has already been cleared if its usage was 1.Finally, the new L3
get()is conditional:if (priv->l3l4_filters[data->location].l3_index != l3_idx) hw_atl2_rxf_l3_get(self, &l3_filters[l3_idx], l3_idx, &l3);but the rollback's
put()is unconditional onl3_idx>= 0. Re-submitting the same filter to the same location would skip theget(); a subsequent L4 failure then puts a reference the call never took, potentially underflowing the shared slot's usage count and clearing a filter another location still relies on.
Quoted 3 lines
Could this rollback path track whether
get()was actually performed, and either hold on to the matchedl3_filterspointer from the new family or re-derive it from the new l3.cmd instead ofold_ipv6?
Both issues are in the L4-failure undo block which has been removed in v3.
The rollback was added during upstreaming and is not present in the reference driver. We've simplified the driver behavior —
returning -EINVAL on L4 failure with no rollback attempt. A proper transactional rollback addressing cross-family pointer re-derivation and deferred old-L3 release will be done as a follow-up.
Quoted 47 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +27
-0+ +if (priv->l3l4_filters[data->location].l4_index != l4_idx) +hw_atl2_rxf_l4_get (self, &priv->l4_filters[l4_idx], + l4_idx, &l4); + } +static int hw_atl2_new_fl3l4_find_l3 (struct aq_hw_s *self, +struct hw_atl2_l3_filter *l3) +{ +struct hw_atl2_priv *priv = self->priv; +struct hw_atl2_l3_filter *l3_filters; +int i, first, last; + +if (l3->cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) { + l3_filters = priv->l3_v6_filters; + first = priv->l3_v6_filter_base_index; + last = priv->l3_v6_filter_base_index + + priv->l3_v6_filter_count; + }else { + l3_filters = priv->l3_v4_filters; + first = priv->l3_v4_filter_base_index; + last = priv->l3_v4_filter_base_index + + priv->l3_v4_filter_count; + } +for (i = first; i < last; i++) { +if (hw_atl2_rxf_l3_is_equal (&l3_filters[i], l3)) +return i; + }Can this index the static arrays out of bounds?
The backing arrays are fixed size:
struct hw_atl2_l3_filter l3_v4_filters[HW_ATL2_RPF_L3L4_FILTERS]; struct hw_atl2_l3_filter l3_v6_filters[HW_ATL2_RPF_L3L4_FILTERS]; struct hw_atl2_l4_filter l4_filters[HW_ATL2_RPF_L3L4_FILTERS];but
l3_v4_filter_base_index,l3_v6_filter_base_index,l4_filter_base_indexand the corresponding counts come from firmware. Looking athw_atl2_utils_get_filter_caps()(referenced elsewhere in the series),l3_v6_filter_countis not clamped at all, unlikel3_v4_filter_countandl4_filter_countwhich get reduced by one againstHW_ATL2_RPF_L3V4_FILTERS/HW_ATL2_RPF_L4_FILTERS. None of thebase_indexfields are validated against the fixed-size arrays either.
Quoted 6 lines
A firmware value that places first+count past
HW_ATL2_RPF_L3L4_FILTERSyields out-of-bounds reads here and out-of-bounds writes viahw_atl2_rxf_l3_get()/_put(). The same concern applies tohw_atl2_new_fl3l4_find_l4().Could these indices be sanitized at probe time?
Addressed in patch 5 (v3): for each filter category,
if base_index >= HW_ATL2_RPF_L3L4_FILTERS the count is forced to zero, otherwise count is capped to HW_ATL2_RPF_L3L4_FILTERS - 1 - base_index, so base_index + count never exceeds the backing array
Quoted 58 lines
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +41
-0+static int hw_atl2_hw_fl2_set (struct aq_hw_s *self, +struct aq_rx_filter_l2 *data) +{ +struct hw_atl2_priv *priv = self->priv; +u32 mask =HW_ATL2_RPF_TAG_ET_MASK ; +u32 req_tag =0 ; +u16 action =0 ; +u32 location; +u8 index; +int tag; + + location = priv->etype_filter_base_index + data->location; +hw_atl_rpf_etht_flr_set (self, data->ethertype, location); +hw_atl_rpf_etht_user_priority_en_set (self, + !!data->user_priority_en, + location); +if (data->user_priority_en) { +hw_atl_rpf_etht_user_priority_set (self, + data->user_priority, + location); + req_tag |= data->user_priority <<HW_ATL2_RPF_TAG_PCP_OFFSET ; + mask |=HW_ATL2_RPF_TAG_PCP_MASK ; + } + +if (data->queue <0 ) { +hw_atl_rpf_etht_flr_act_set (self,0U , location); +hw_atl_rpf_etht_rx_queue_en_set (self,0U , location); + action =HW_ATL2_ACTION_DROP ; + }else { +hw_atl_rpf_etht_flr_act_set (self,1U , location); +hw_atl_rpf_etht_rx_queue_en_set (self,1U , location); +hw_atl_rpf_etht_rx_queue_set (self, data->queue, location); + action =HW_ATL2_ACTION_ASSIGN_QUEUE (data->queue); + } + + tag =hw_atl2_filter_tag_get (priv->etype_policy, + priv->etype_filter_tag_top, + action); + +if (tag <0 ) +return -ENOSPC ;Two concerns about this path:
First, if location already held an ethertype filter with a previous tag, is that tag ever released?
aq_add_del_fether()inaq_filters.ccallshw_filter_l2_set()directly on replacement (without an interveninghw_filter_l2_clear()), so each overwrite of an existing location invokeshw_atl2_filter_tag_get()for the new action but neverhw_atl2_filter_tag_put()for the old one. The etype_policy[] usage counters will diverge from the set of tags actually live in hardware, and after a small number of changes with distinct actions the pool (bounded byetype_filter_tag_top) is exhausted andset()starts returning-ENOSPC.
Quoted 6 lines
Second, on the
-ENOSPCpath above, the per-location ethertype, user_priority_en/user_priority,flr_act,rx_queue_enandrx_queueregisters have already been written for the new filter while the oldetht_flr_enbit and the old tag are still set in hardware. Should this error path leave the hardware state unchanged, or disable the filter before returning?
Not a concern in practice. hw_filter_l2_set() is always preceded by hw_filter_l2_clear(), which explicitly calls hw_atl_rpf_etht_flr_en_set(self, 0U, location) and sets the ART entry to HW_ATL2_ACTION_DISABLE before fl2_set() touches any register. On -ENOSPC, the partial register writes (ethertype, priority, queue) are present in hardware but the filter enable bit and ART entry are both already disabled — no active filter with a stale tag, no traffic impact.
Quoted 29 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +13
-1+ + req_tag |= tag <<HW_ATL2_RPF_TAG_ET_OFFSET ; +hw_atl2_rpf_etht_flr_tag_set (self, tag, location); + index = priv->art_base_index +HW_ATL2_RPF_ET_PCP_USER_INDEX + + data->location; +hw_atl2_act_rslvr_table_set (self, index, req_tag, mask, action); + +hw_atl_rpf_etht_flr_en_set (self,1U , location); + +return aq_hw_err_from_flags (self); +}@@ -825,7 +1394,7 @@ static int hw_atl2_hw_vlan_ctrl(struct aq_hw_s *self, bool enable)const struct aq_hw_ops hw_atl2_ops = { .hw_soft_reset = hw_atl2_utils_soft_reset, .hw_prepare = hw_atl2_utils_initfw, - .hw_set_mac_address = hw_atl_b0_hw_mac_addr_set, + .hw_set_mac_address = hw_atl2_hw_mac_addr_set, .hw_init = hw_atl2_hw_init, .hw_reset = hw_atl2_hw_reset, .hw_start = hw_atl_b0_hw_start,@@ -834,6 +1403,7 @@ const struct aq_hw_ops hw_atl2_ops = { .hw_ring_rx_start = hw_atl_b0_hw_ring_rx_start, .hw_ring_rx_stop = hw_atl_b0_hw_ring_rx_stop, .hw_stop = hw_atl2_hw_stop, + .hw_get_version = hw_atl2_get_hw_version,
Quoted 2 lines
See the earlier note;
hw_get_versiondoes not appear to have any caller in this series.
Yes, it's been dropped!
Signature · 1 line
This is an AI-generated review.
[email protected]
maintainerPATCH 7/9 net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Add PTP traffic class (TC) buffer reservation and TX path improvements for AQC113:
- Reserve dedicated TX and RX buffer space for PTP TC when PTP is enabled, reducing user TC buffers accordingly (TX: 8KB, RX: 16KB).
- Configure PTP TC with no flow control and highest priority scheduling to ensure timely PTP packet transmission.
- Enable multicast frame tagging (accept_all_mc_packets) so the Action Resolver Table (ART) can match and steer PTP multicast traffic to the correct TC/queue based on RPF input tags.
TX path improvements:
- Enable extended PCIe tag mode (32-255) when hardware supports it, with increased TX data and descriptor read request limits for improved throughput.
Also simplify RSS queue calculation in hw_atl2_hw_rss_set() by extracting to a local variable and use unsigned types for loop variables to match their usage.
--- .../aquantia/atlantic/hw_atl2/hw_atl2.c | 52 ++++++++++++++++--- .../atlantic/hw_atl2/hw_atl2_internal.h | 4 +- 2 files changed, 49 insertions(+), 7 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +46 -6
@@ -151,6 +151,24 @@ static int hw_atl2_hw_reset(struct aq_hw_s *self)return err; } +static int hw_atl2_tc_ptp_set (struct aq_hw_s *self) +{ +/* Init TC2 for PTP_TX */ +hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self,HW_ATL2_PTP_TXBUF_SIZE , +AQ_HW_PTP_TC ); + +/* Init TC2 for PTP_RX */ +hw_atl_rpb_rx_pkt_buff_size_per_tc_set (self,HW_ATL2_PTP_RXBUF_SIZE , +AQ_HW_PTP_TC ); + +/* No flow control for PTP */ +hw_atl_rpb_rx_xoff_en_per_tc_set (self,0U ,AQ_HW_PTP_TC ); + +hw_atl2_tpb_tps_highest_priority_tc_set (self,AQ_HW_PTP_TC ); + +return aq_hw_err_from_flags (self); +} +static int hw_atl2_hw_queue_to_tc_map_set (struct aq_hw_s *self) {struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;
@@ -209,6 +227,11 @@ static int hw_atl2_hw_qos_set(struct aq_hw_s *self)unsigned int prio =0U ;u32 tc =0U ; +if (cfg->is_ptp) { + tx_buff_size -=HW_ATL2_PTP_TXBUF_SIZE ; + rx_buff_size -=HW_ATL2_PTP_RXBUF_SIZE ; + } +/* TPS Descriptor rate init */ hw_atl_tps_tx_pkt_shed_desc_rate_curr_time_res_set (self,0x0U );hw_atl_tps_tx_pkt_shed_desc_rate_lim_set (self,0xA );
@@ -242,6 +265,9 @@ static int hw_atl2_hw_qos_set(struct aq_hw_s *self)hw_atl_b0_set_fc (self, self->aq_nic_cfg->fc.req, tc); } +if (cfg->is_ptp) +hw_atl2_tc_ptp_set (self); +/* QoS 802.1p priority -> TC mapping */ for (prio =0 ; prio <8 ; ++prio) hw_atl_rpf_rpb_user_priority_tc_map_set(self, prio,
@@ -259,8 +285,9 @@ static int hw_atl2_hw_rss_set(struct aq_hw_s *self,u8 *indirection_table = rss_params->indirection_table;const u32 num_tcs =aq_hw_num_tcs (self);u32 rpf_redir2_enable; -int tc; -int i; +u32 queue; +u32 tc; +u32 i; rpf_redir2_enable = num_tcs >4 ?1 :0 ;
@@ -268,10 +295,9 @@ static int hw_atl2_hw_rss_set(struct aq_hw_s *self,for (i =HW_ATL2_RSS_REDIRECTION_MAX ; i--;) {for (tc =0 ; tc != num_tcs; tc++) { -hw_atl2_new_rpf_rss_redir_set (self, tc, i, - tc * -aq_hw_q_per_tc (self) + - indirection_table[i]); + queue = tc *aq_hw_q_per_tc (self) + + indirection_table[i]; +hw_atl2_new_rpf_rss_redir_set (self, tc, i, queue); } }
@@ -415,9 +441,20 @@ static int hw_atl2_hw_init_tx_path(struct aq_hw_s *self)hw_atl2_tpb_tx_buf_clk_gate_en_set (self,0U ); +if (hw_atl2_phi_ext_tag_get (self)) { +hw_atl2_tdm_tx_data_read_req_limit_set (self,0x7F ); +hw_atl2_tdm_tx_desc_read_req_limit_set (self,0x0F ); + } +return aq_hw_err_from_flags (self); } +/* Initialise new rx filters +* L2 promisc OFF +* VLAN promisc OFF +* +* User priority to TC +*/ static void hw_atl2_hw_init_new_rx_filters (struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;
@@ -429,6 +466,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)u8 index;int i; +/* tag MC frames always */ +hw_atl_rpfl2_accept_all_mc_packets_set (self,1 ); +/* Action Resolver Table (ART) is used by RPF to decide which action * to take with a packet based upon input tag and tag mask, where: * - input tag is a combination of 3-bit VLan Prio (PTP) and
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +3 -1
@@ -27,8 +27,10 @@#define HW_ATL2_INT_MASK (0xFFFFFFFFU)#define HW_ATL2_TXBUF_MAX 128U -#define HW_ATL2_RXBUF_MAX 192U +#define HW_ATL2_PTP_TXBUF_SIZE 8U +#define HW_ATL2_RXBUF_MAX 192U +#define HW_ATL2_PTP_RXBUF_SIZE 16U#define HW_ATL2_RSS_REDIRECTION_MAX 64U#define HW_ATL2_TC_MAX 8U
Signature · 1 line
2.43.0
Paolo Abeni
maintainerRe: [PATCH net-next 7/9] net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup
Reserves PTP TX/RX buffer space, configures the PTP traffic class with no flow control and highest priority, enables multicast frame tagging for ART-based PTP steering, and bumps TX read-request limits when the PCIe extended-tag bit is already set.
Quoted 1 line
net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup
The subject contains the phrase "TX path setup" twice. Is that intentional?
The patch also bundles several unrelated changes into a single commit:
PTP TC buffer reservation, an unconditional accept-all-multicast enable, PCIe-extended-tag-gated TX read-request limit bumps, and a non-functional RSS refactor. Would it be reasonable to split these into separate commits so each can be reviewed, tested, and bisected independently?
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +0
-0
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static int hw_atl2_hw_init_tx_path(struct aq_hw_s *self) · line 450
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +5
-0@@ -415,9 +441,20 @@ static int hw_atl2_hw_init_tx_path(struct aq_hw_s *self)hw_atl2_tpb_tx_buf_clk_gate_en_set (self,0U ); +if (hw_atl2_phi_ext_tag_get (self)) { +hw_atl2_tdm_tx_data_read_req_limit_set (self,0x7F ); +hw_atl2_tdm_tx_desc_read_req_limit_set (self,0x0F ); + } +return aq_hw_err_from_flags (self); }
The commit message says:
Enable extended PCIe tag mode (32-255) when hardware supports it, with increased TX data and descriptor read request limits for improved throughput.
Does the code actually enable extended PCIe tag mode? The call here is hw_atl2_phi_ext_tag_get(), a read accessor via aq_hw_read_reg_bit(). The corresponding setter hw_atl2_phi_ext_tag_set() exists in hw_atl2_llh.c but does not appear to be invoked in this patch or elsewhere. The code path only raises the TX read-request limits when the bit is already set by firmware/BIOS. Should the commit message be reworded to reflect that behavior?
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +6
-0+/* Initialise new rx filters +* L2 promisc OFF +* VLAN promisc OFF +* +* User priority to TC +*/ static void hw_atl2_hw_init_new_rx_filters (struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) · line 471
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +3
-0@@ -429,6 +466,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)u8 index;int i; +/* tag MC frames always */ +hw_atl_rpfl2_accept_all_mc_packets_set (self,1 ); +
Is the "tag MC frames always" intent actually durable?
The same hardware bit is rewritten unconditionally by the packet filter path. In hw_atl_b0_hw_packet_filter_set() (shared by atl2 through hw_atl_b0.c):
hw_atl_rpfl2_accept_all_mc_packets_set(self,
IS_FILTER_ENABLED(IFF_ALLMULTI) &&
IS_FILTER_ENABLED(IFF_MULTICAST));ndo_set_rx_mode runs as part of normal interface bring-up and on every multicast-list change, so the init-time write to 1 would be cleared to 0 for any interface not in allmulticast mode. Does this mean the ART cannot match PTP multicast traffic once rx_mode has been programmed, which is the commit's stated purpose of this write?
If the intent is to keep the bit set whenever PTP is enabled, should the packet-filter path OR in cfg->is_ptp, rather than (or in addition to) writing the bit once at init?
The write is also not gated by cfg->is_ptp. While it is briefly in effect, does enabling accept_all_mc change multicast filtering behavior for non-PTP users in a way that needs justification in the commit log?
[ ... ]
Signature · 1 line
This is an AI-generated review.
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next 7/9] net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup
Quoted 12 lines · Paolo Abeni
net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup
Reserves PTP TX/RX buffer space, configures the PTP traffic class with no flow control and highest priority, enables multicast frame tagging for ART-based PTP steering, and bumps TX read-request limits when the PCIe extended-tag bit is already set.
net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup
The subject contains the phrase "TX path setup" twice. Is that intentional?
Quoted 6 lines
The patch also bundles several unrelated changes into a single commit:
PTP TC buffer reservation, an unconditional accept-all-multicast enable, PCIe-extended-tag-gated TX read-request limit bumps, and a non-functional RSS refactor. Would it be reasonable to split these into separate commits so each can be reviewed, tested, and bisected independently?
The accept-all-multicast enable has been removed from v3. The remaining
changes — PTP TC buffer reservation, PCIe extended-tag-gated TX read-request limits, and the RSS refactor — are kept in one commit. The PTP TC reservation and TX path improvements are functionally
related: the TX read-request limit increase benefits PTP TC throughput and is most naturally introduced alongside the TC setup. The RSS simplification is a one-liner mechanical refactor touching the same file; splitting it into a separate commit adds overhead without meaningful review benefit. If the preference is strict separation we can split the RSS change in v4.
Quoted 25 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +5
-0@@ -415,9 +441,20 @@ static int hw_atl2_hw_init_tx_path(struct aq_hw_s *self)hw_atl2_tpb_tx_buf_clk_gate_en_set (self,0U ); +if (hw_atl2_phi_ext_tag_get (self)) { +hw_atl2_tdm_tx_data_read_req_limit_set (self,0x7F ); +hw_atl2_tdm_tx_desc_read_req_limit_set (self,0x0F ); + } +return aq_hw_err_from_flags (self); }The commit message says:
Enable extended PCIe tag mode (32-255) when hardware supports it, with increased TX data and descriptor read request limits for improved throughput.
Quoted 7 lines
Does the code actually enable extended PCIe tag mode? The call here is
hw_atl2_phi_ext_tag_get(), a read accessor viaaq_hw_read_reg_bit(). The corresponding setterhw_atl2_phi_ext_tag_set()exists inhw_atl2_llh.cbut does not appear to be invoked in this patch or elsewhere. The code path only raises the TX read-request limits when the bit is already set byfirmware/BIOS. Should the commit message be reworded to reflect that behavior?
Correct — the commit message is misleading. The code only reads hw_atl2_phi_ext_tag_get() to check whether extended PCIe tag mode is already enabled by firmware/BIOS, and if so raises the TX data and descriptor read-request limits. The driver never calls hw_atl2_phi_ext_tag_set() to enable it. Will reword in v3 to: "Increase TX data and descriptor read-request limits when firmware has already enabled extended PCIe tag mode."
Quoted 35 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +9
-0+/* Initialise new rx filters +* L2 promisc OFF +* VLAN promisc OFF +* +* User priority to TC +*/ static void hw_atl2_hw_init_new_rx_filters (struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;@@ -429,6 +466,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)u8 index;int i; +/* tag MC frames always */ +hw_atl_rpfl2_accept_all_mc_packets_set (self,1 ); +Is the "tag MC frames always" intent actually durable?
The same hardware bit is rewritten unconditionally by the packet filter path. In
hw_atl_b0_hw_packet_filter_set()(shared by atl2 throughhw_atl_b0.c):hw_atl_rpfl2_accept_all_mc_packets_set(self, IS_FILTER_ENABLED(IFF_ALLMULTI) && IS_FILTER_ENABLED(IFF_MULTICAST));
ndo_set_rx_moderuns as part of normal interface bring-up and on every multicast-list change, so the init-time write to 1 would be cleared to 0 for any interface not in allmulticast mode. Does this mean the ART cannot match PTP multicast traffic oncerx_modehas been programmed, which is the commit's stated purpose of this write?
Quoted 8 lines
If the intent is to keep the bit set whenever PTP is enabled, should the packet-filter path OR in
cfg->is_ptp, rather than (or in addition to) writing the bit once at init?The write is also not gated by
cfg->is_ptp. While it is briefly in effect, does enablingaccept_all_mcchange multicast filtering behavior for non-PTP users in a way that needs justification in the commit log?
The hw_atl_rpfl2_accept_all_mc_packets_set(self, 1) call has been
removed from the code in v3 and the commit message will be updated to remove that bullet point accordingly.
Quoted 3 lines
[ ... ]
Signature · 1 line
This is an AI-generated review.
[email protected]
maintainerPATCH 8/9 net: atlantic: extend hw_ops and TX descriptor for AQC113 PTP for AQC113 PTP
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Extend the aq_hw_ops interface with new function pointers required for PTP support on AQC113:
- enable_ptp: enable/disable PTP counter with clock selection
- hw_ring_tx_ptp_get_ts: read TX timestamp from descriptor writeback
- hw_tx_ptp_ring_init/hw_rx_ptp_ring_init: per-ring PTP initialization
- hw_get_clk_sel: query active TSG clock selection
Update existing hw_ops signatures to support AQC113 dual-clock architecture:
- hw_gpio_pulse: add clk_sel and hightime parameters
- hw_extts_gpio_enable: add channel parameter
Add PTP-related hardware defines:
- AQ_HW_TXD_CTL_TS_EN/TS_TSG0 for TX descriptor timestamp control
- AQ2_HW_PTP_COUNTER_HZ for AQC113 TSG clock frequency
- AQ_HW_PTP_IRQS for PTP interrupt vector accounting
- PTP enable flags (L2/L4) and TSG clock selection constants
Add request_ts and clk_sel bitfields to aq_ring_buff_s for per-packet TX timestamp request tracking.
Update hw_atl_b0.c (AQC107) implementations:
- Adapt gpio_pulse and extts_gpio_enable to new signatures
- Add TX descriptor timestamp bits for AQC113 when ANTIGUA chip feature is detected
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 34 +++++++++++++++++-- .../net/ethernet/aquantia/atlantic/aq_ptp.c | 4 +-- .../net/ethernet/aquantia/atlantic/aq_ring.h | 4 ++- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 15 ++++++-- 4 files changed, 48 insertions(+), 9 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +31 -3
@@ -19,6 +19,9 @@#define AQ_HW_MAC_COUNTER_HZ 312500000ll#define AQ_HW_PHY_COUNTER_HZ 160000000ll +#define AQ_HW_TXD_CTL_TS_EN 0x40000000U +#define AQ_HW_TXD_CTL_TS_TSG0 0x80000000U +enum aq_tc_mode {AQ_TC_MODE_INVALID =-1 ,AQ_TC_MODE_8TCS ,
@@ -38,6 +41,8 @@ enum aq_tc_mode {#define AQ_FRAC_PER_NS 0x100000000LL +#define AQ2_HW_PTP_COUNTER_HZ 156250000ll +/* Used for rate to Mbps conversion */ #define AQ_MBPS_DIVISOR 125000/* 1000000 / 8 */
@@ -109,6 +114,7 @@ struct aq_stats_s {#define AQ_HW_IRQ_MSIX 3U#define AQ_HW_SERVICE_IRQS 1U +#define AQ_HW_PTP_IRQS 1U#define AQ_HW_POWER_STATE_D0 0U#define AQ_HW_POWER_STATE_D3 3U
@@ -157,6 +163,15 @@ enum aq_priv_flags { AQ_HW_LOOPBACK_PHYEXT_SYS, }; +enum { +AQ_HW_PTP_DISABLE =0 , +AQ_HW_PTP_L2_ENABLE =BIT (1 ), +AQ_HW_PTP_L4_ENABLE =BIT (2 ), +}; + +#define ATL_TSG_CLOCK_SEL_0 0 +#define ATL_TSG_CLOCK_SEL_1 1 +#define AQ_HW_LOOPBACK_MASK (BIT(AQ_HW_LOOPBACK_DMA_SYS) |\ BIT(AQ_HW_LOOPBACK_PKT_SYS) |\ BIT(AQ_HW_LOOPBACK_DMA_NET) |\
@@ -198,6 +213,7 @@ struct aq_hw_s {u32 rpc_tid;struct hw_atl_utils_fw_rpc rpc;s64 ptp_clk_offset; +s8 clk_select;u16 phy_id;void *priv; };
@@ -325,11 +341,15 @@ struct aq_hw_ops {int (*hw_ts_to_sys_clock)(struct aq_hw_s *self,u64 ts,u64 *time); -int (*hw_gpio_pulse)(struct aq_hw_s *self,u32 index,u64 start, -u32 period); +int (*hw_gpio_pulse)(struct aq_hw_s *self,u32 index, +u32 clk_sel,u64 start, +u32 period,u32 hightime);int (*hw_extts_gpio_enable)(struct aq_hw_s *self,u32 index, -u32 enable); +u32 channel,int enable); + +void (*enable_ptp)(struct aq_hw_s *self,unsigned int param, +int enable);int (*hw_get_sync_ts)(struct aq_hw_s *self,u64 *ts);
@@ -339,6 +359,14 @@ struct aq_hw_ops {int (*extract_hwts)(struct aq_hw_s *self,u8 *p,unsigned int len,u64 *timestamp); +u64 (*hw_ring_tx_ptp_get_ts)(struct aq_ring_s *ring); + +int (*hw_tx_ptp_ring_init)(struct aq_hw_s *self, +struct aq_ring_s *aq_ring); +int (*hw_rx_ptp_ring_init)(struct aq_hw_s *self, +struct aq_ring_s *aq_ring); +u32 (*hw_get_clk_sel)(struct aq_hw_s *self); +int (*hw_set_fc)(struct aq_hw_s *self,u32 fc,u32 tc);int (*hw_set_loopback)(struct aq_hw_s *self,u32 mode,bool enable);
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2 -2
@@ -380,7 +380,7 @@ static int aq_ptp_hw_pin_conf(struct aq_nic_s *aq_nic, u32 pin_index, u64 start,*/ mutex_lock (&aq_nic->fwreq_mutex); aq_nic->aq_hw_ops->hw_gpio_pulse (aq_nic->aq_hw, pin_index, - start, (u32 )period); +0 , start, (u32 )period,0 );mutex_unlock (&aq_nic->fwreq_mutex);return 0 ;
@@ -454,7 +454,7 @@ static void aq_ptp_extts_pin_ctrl(struct aq_ptp_s *aq_ptp)if (aq_nic->aq_hw_ops->hw_extts_gpio_enable) aq_nic->aq_hw_ops->hw_extts_gpio_enable (aq_nic->aq_hw,0 , - enable); +0 , enable); } static int aq_ptp_extts_pin_configure(struct ptp_clock_info *ptp,
drivers/net/ethernet/aquantia/atlantic/aq_ring.h +3 -1
@@ -85,7 +85,9 @@ struct __packed aq_ring_buff_s { u32 is_error:1; u32 is_vlan:1; u32 is_lro:1; - u32 rsvd3:3; + u32 request_ts:1; + u32 clk_sel:1; + u32 rsvd3:1;u16 eop_index;u16 rsvd4; };
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +12 -3
@@ -736,6 +736,15 @@ int hw_atl_b0_hw_ring_tx_xmit(struct aq_hw_s *self, struct aq_ring_s *ring, txd->ctl |=HW_ATL_B0_TXD_CTL_CMD_WB ; is_gso = false; is_vlan = false; + +if (ATL_HW_IS_CHIP_FEATURE (self,ANTIGUA ) && +unlikely (buff->request_ts)) { + txd->ctl |=AQ_HW_TXD_CTL_TS_EN ; +if (buff->clk_sel !=ATL_TSG_CLOCK_SEL_1 ) + txd->ctl |=AQ_HW_TXD_CTL_TS_TSG0 ; +/* The only DD+TS is required */ + txd->ctl &= ~HW_ATL_B0_TXD_CTL_CMD_WB ; + } } } ring->sw_tail =aq_ring_next_dx (ring, ring->sw_tail);
@@ -1323,8 +1332,8 @@ static int hw_atl_b0_adj_clock_freq(struct aq_hw_s *self, s32 ppb)return self->aq_fw_ops->send_fw_request (self, &fwreq, size); } -static int hw_atl_b0_gpio_pulse (struct aq_hw_s *self,u32 index, -u64 start,u32 period) +static int hw_atl_b0_gpio_pulse (struct aq_hw_s *self,u32 index,u32 clk_sel, +u64 start,u32 period,u32 hightime) {struct hw_fw_request_iface fwreq;size_t size;
@@ -1342,7 +1351,7 @@ static int hw_atl_b0_gpio_pulse(struct aq_hw_s *self, u32 index, }static int hw_atl_b0_extts_gpio_enable (struct aq_hw_s *self,u32 index, -u32 enable) +u32 channel,int enable) {/* Enable/disable Sync1588 GPIO Timestamping */ aq_phy_write_reg (self,MDIO_MMD_PCS ,0xc611 , enable ?0x71 :0 );
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH 9/9 net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
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).
--- .../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(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +1 -0
@@ -15,6 +15,7 @@#include "aq_common.h" #include "aq_rss.h" #include "hw_atl/hw_atl_utils.h" +#include "hw_atl2/hw_atl2.h" #define AQ_HW_MAC_COUNTER_HZ 312500000ll#define AQ_HW_PHY_COUNTER_HZ 160000000ll
drivers/net/ethernet/aquantia/atlantic/aq_main.c +20 -14
@@ -19,8 +19,10 @@#include <linux/netdevice.h> #include <linux/module.h> #include <linux/ip.h> +#include <linux/ipv6.h> #include <linux/udp.h> #include <net/pkt_cls.h> +#include <linux/ptp_classify.h> #include <net/pkt_sched.h> #include <linux/filter.h>
@@ -68,20 +70,14 @@ int aq_ndev_open(struct net_device *ndev)if (err <0 ) goto err_exit; - err =aq_reapply_rxnfc_all_rules (aq_nic); -if (err <0 ) - goto err_exit; - - err =aq_filters_vlans_update (aq_nic); -if (err <0 ) - goto err_exit; - err =aq_nic_start (aq_nic);if (err <0 ) {aq_nic_stop (aq_nic); goto err_exit; } +aq_utils_obj_set (&aq_nic->aq_hw->flags,AQ_HW_FLAG_STARTED ); + err_exit:if (err <0 )aq_nic_deinit (aq_nic, true);
@@ -97,6 +93,7 @@ int aq_ndev_close(struct net_device *ndev) err =aq_nic_stop (aq_nic);aq_nic_deinit (aq_nic, true); +aq_utils_obj_clear (&aq_nic->aq_hw->flags,AQ_HW_FLAG_STARTED );return err; }
@@ -113,16 +110,25 @@ static netdev_tx_t aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *nd* and hardware PTP design of the chip. Otherwise ptp stream * will fail to sync */ -if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) || -unlikely ((ip_hdr (skb)->version ==4 ) && - (ip_hdr (skb)->protocol ==IPPROTO_UDP ) && - ((udp_hdr (skb)->dest ==htons (319 )) || - (udp_hdr (skb)->dest ==htons (320 )))) || -unlikely (eth_hdr (skb)->h_proto ==htons (ETH_P_1588 ))) +if (unlikely (skb->protocol ==htons (ETH_P_IP ) && +ip_hdr (skb)->protocol ==IPPROTO_UDP && + (udp_hdr (skb)->dest ==htons (PTP_EV_PORT ) || +udp_hdr (skb)->dest ==htons (PTP_GEN_PORT )))) +return aq_ptp_xmit (aq_nic, skb); + +/* PTP over IPv6 does not use extension headers */ +if (unlikely (skb->protocol ==htons (ETH_P_IPV6 ) && +ipv6_hdr (skb)->nexthdr ==IPPROTO_UDP && + (udp_hdr (skb)->dest ==htons (PTP_EV_PORT ) || +udp_hdr (skb)->dest ==htons (PTP_GEN_PORT )))) +return aq_ptp_xmit (aq_nic, skb); + +if (unlikely (eth_hdr (skb)->h_proto ==htons (ETH_P_1588 ))) return aq_ptp_xmit(aq_nic, skb); }#endif +skb_tx_timestamp (skb);return aq_nic_xmit (aq_nic, skb); }
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +41 -7
96 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +2 -2
@@ -293,8 +293,8 @@ static int aq_pci_probe(struct pci_dev *pdev, numvecs =min ((u8 )AQ_CFG_VECS_DEF ,aq_nic_get_cfg (self)->aq_hw_caps->msix_irqs); numvecs =min (numvecs,num_online_cpus ()); -/* Request IRQ vector for PTP */ - numvecs +=1 ; +/* Request IRQ lines for PTP */ + numvecs +=AQ_HW_PTP_IRQS ; numvecs +=AQ_HW_SERVICE_IRQS ;/*enable interrupts */
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +410 -125
805 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h +11 -4
@@ -14,6 +14,12 @@#include "aq_ring.h" +enum aq_ptp_state { +AQ_PTP_NO_LINK =0 , +AQ_PTP_FIRST_INIT =1 , +AQ_PTP_LINK_UP =2 , +}; +#define PTP_8TC_RING_IDX 8#define PTP_4TC_RING_IDX 16#define PTP_HWST_RING_IDX 31
@@ -32,7 +38,7 @@ static inline unsigned int aq_ptp_ring_idx(const enum aq_tc_mode tc_mode)#if IS_REACHABLE (CONFIG_PTP_1588_CLOCK )/* Common functions */ -int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_vec); +int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_ptp_vec);void aq_ptp_unregister (struct aq_nic_s *aq_nic);void aq_ptp_free (struct aq_nic_s *aq_nic);
@@ -52,7 +58,7 @@ void aq_ptp_service_task(struct aq_nic_s *aq_nic);void aq_ptp_tm_offset_set (struct aq_nic_s *aq_nic,unsigned int mbps); -void aq_ptp_clock_init (struct aq_nic_s *aq_nic); +void aq_ptp_clock_init (struct aq_nic_s *aq_nic,enum aq_ptp_state state);/* Traffic processing functions */ int aq_ptp_xmit (struct aq_nic_s *aq_nic,struct sk_buff *skb);
@@ -80,7 +86,7 @@ u64 *aq_ptp_get_stats(struct aq_nic_s *aq_nic, u64 *data);#else -static inline int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_vec) +static inline int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_ptp_vec) {return 0 ; }
@@ -122,7 +128,8 @@ static inline void aq_ptp_ring_deinit(struct aq_nic_s *aq_nic) {}static inline void aq_ptp_service_task (struct aq_nic_s *aq_nic) {}static inline void aq_ptp_tm_offset_set (struct aq_nic_s *aq_nic,unsigned int mbps) {} -static inline void aq_ptp_clock_init (struct aq_nic_s *aq_nic) {} +static inline void aq_ptp_clock_init (struct aq_nic_s *aq_nic, +enum aq_ptp_state state) {}static inline int aq_ptp_xmit (struct aq_nic_s *aq_nic,struct sk_buff *skb) {return -EOPNOTSUPP ;
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +24 -18
55 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +177 -2
219 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.h +12 -0
@@ -7,6 +7,18 @@#define HW_ATL2_H #include "aq_common.h" +#define HW_ATL2_RX_TS_SIZE 8 + +#define HW_ATL2_PTP_OFFSET_INGRESS_100 768 +#define HW_ATL2_PTP_OFFSET_EGRESS_100 336 +#define HW_ATL2_PTP_OFFSET_INGRESS_1000 510 +#define HW_ATL2_PTP_OFFSET_EGRESS_1000 105 +#define HW_ATL2_PTP_OFFSET_INGRESS_2500 2447 +#define HW_ATL2_PTP_OFFSET_EGRESS_2500 634 +#define HW_ATL2_PTP_OFFSET_INGRESS_5000 1426 +#define HW_ATL2_PTP_OFFSET_EGRESS_5000 361 +#define HW_ATL2_PTP_OFFSET_INGRESS_10000 997 +#define HW_ATL2_PTP_OFFSET_EGRESS_10000 203extern const struct aq_hw_caps_s hw_atl2_caps_aqc113;extern const struct aq_hw_caps_s hw_atl2_caps_aqc115c;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +2 -1
@@ -29,7 +29,8 @@#define HW_ATL2_TXBUF_MAX 128U#define HW_ATL2_PTP_TXBUF_SIZE 8U -#define HW_ATL2_RXBUF_MAX 192U +/* Reduced from 192 to reserve space for PTP RX timestamp trailer */ +#define HW_ATL2_RXBUF_MAX 172U#define HW_ATL2_PTP_RXBUF_SIZE 16U#define HW_ATL2_RSS_REDIRECTION_MAX 64U
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.h +10 -0
@@ -8,6 +8,16 @@#include "aq_hw.h" +/* Hardware tx launch time descriptor */ +struct hw_atl2_txts_s { +u64 ts; +u32 ctrl; +u32 reserved; +}; + +#define HW_ATL2_TXTS_DD BIT(3) +#define HW_ATL2_TXTS_TS_VALID BIT(20) +/* F W A P I */ struct link_options_s {
Signature · 1 line
2.43.0
Paolo Abeni
maintainerRe: [PATCH net-next 9/9] net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
This patch adds IEEE 1588 PTP support for the AQC113 (Antigua) controller alongside the existing AQC107 implementation, covering dual TSG clocks, descriptor-writeback TX timestamps, per-instance PTP offsets, L3/L4 multicast filters, and direct hardware clock control.
A few observations and questions below.
Quoted 25 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c +11
-6@@ -113,16 +110,25 @@ static netdev_tx_t aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *nd* and hardware PTP design of the chip. Otherwise ptp stream * will fail to sync */ -if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) || -unlikely ((ip_hdr (skb)->version ==4 ) && - (ip_hdr (skb)->protocol ==IPPROTO_UDP ) && - ((udp_hdr (skb)->dest ==htons (319 )) || - (udp_hdr (skb)->dest ==htons (320 )))) || -unlikely (eth_hdr (skb)->h_proto ==htons (ETH_P_1588 ))) +if (unlikely (skb->protocol ==htons (ETH_P_IP ) && +ip_hdr (skb)->protocol ==IPPROTO_UDP && + (udp_hdr (skb)->dest ==htons (PTP_EV_PORT ) || +udp_hdr (skb)->dest ==htons (PTP_GEN_PORT )))) +return aq_ptp_xmit (aq_nic, skb); + +/* PTP over IPv6 does not use extension headers */ +if (unlikely (skb->protocol ==htons (ETH_P_IPV6 ) && +ipv6_hdr (skb)->nexthdr ==IPPROTO_UDP && + (udp_hdr (skb)->dest ==htons (PTP_EV_PORT ) || +udp_hdr (skb)->dest ==htons (PTP_GEN_PORT ))))
drivers/net/ethernet/aquantia/atlantic/aq_main.c static netdev_tx_t aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *nd · line 133
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c +4
-0+return aq_ptp_xmit (aq_nic, skb); + +if (unlikely (eth_hdr (skb)->h_proto ==htons (ETH_P_1588 ))) return aq_ptp_xmit(aq_nic, skb); }#endif +skb_tx_timestamp (skb);return aq_nic_xmit (aq_nic, skb); }
The commit message states:
Move skb_tx_timestamp() to non-PTP path to avoid double timestamps
Was there actually a pre-existing double-timestamp? The prior code had exactly one skb_tx_timestamp() per packet (aq_nic_xmit() for non-PTP, aq_ptp_xmit() for PTP), so this move appears functionally equivalent for the PTP case.
However, the new placement in aq_ndev_start_xmit() is before aq_nic_xmit()'s __netif_subqueue_stopped()/map-failure/NETDEV_TX_BUSY handling, so software TX timestamps may now be generated for frames that end up returning NETDEV_TX_BUSY. Is that intentional? It changes a user-visible SO_TIMESTAMPING point for all atlantic chips, not just AQC113.
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0
-0@@ -172,7 +180,11 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)aq_nic_update_interrupt_moderation_settings (self);
drivers/net/ethernet/aquantia/atlantic/aq_nic.c static int aq_nic_update_link_status(struct aq_nic_s *self) · line 190
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +5
-1if (self->aq_ptp) { -aq_ptp_clock_init (self); +/* PTP does not work in some modes even if physical link is up */ +bool ptp_link_good = (self->aq_hw->aq_link_status.mbps >=100 && + self->aq_hw->aq_link_status.full_duplex); + +aq_ptp_clock_init (self, ptp_link_good ?AQ_PTP_LINK_UP :AQ_PTP_NO_LINK );aq_ptp_tm_offset_set (self, self->aq_hw->aq_link_status.mbps);aq_ptp_link_change (self);
aq_ptp_clock_init() now calls aq_ptp_dpath_enable(), which writes hw_filter_l3l4_set/hw_filter_l2_set and mutates aq_ptp->udp_filter[i].cmd and aq_ptp->eth_type_filter.
The caller of aq_nic_update_link_status() is the service task and aq_linkstate_threaded_isr, neither of which hold rtnl_lock. The hwtstamp ioctl path enters aq_ptp_hwtstamp_config_set() (and thence aq_ptp_dpath_enable()) under rtnl_lock. Is there a lock covering both sides? The same filter structures and registers can be programmed concurrently from the two paths, and hwtstamp_config.rx_filter is read unsynchronized from the link path while written by the ioctl path.
[ ... ]
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +0
-0
[ ... ]
Quoted 3 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +3
-0+static int aq_ptp_dpath_enable (struct aq_ptp_s *aq_ptp, +int enable_flags,u16 rx_queue) +{
[ ... ]
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +9
-0+if (enable_flags &AQ_HW_PTP_L2_ENABLE ) { + aq_ptp->eth_type_filter.ethertype =ETH_P_1588 ; + aq_ptp->eth_type_filter.queue = rx_queue; + } + +if (hw_ops->hw_filter_l3l4_set) { +for (i =0 ; i < flt_idx; i++) { + err = hw_ops->hw_filter_l3l4_set (aq_nic->aq_hw, + &aq_ptp->udp_filter[i]);
[ ... ]
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp) · line 723
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +5
-0+ } + +if (!err && hw_ops->hw_filter_l2_set) { + err = hw_ops->hw_filter_l2_set (aq_nic->aq_hw, + &aq_ptp->eth_type_filter);
When enable_flags is AQ_HW_PTP_L4_ENABLE only (for example HWTSTAMP_FILTER_PTP_V1_L4_* or HWTSTAMP_FILTER_PTP_V2_L4_*), the block that sets eth_type_filter.ethertype/queue is skipped, but hw_filter_l2_set is still called unconditionally. Will that install a stale L2 filter (zero ethertype from kzalloc, or leftover ETH_P_1588 from a previous call) into hardware?
The pre-patch aq_ptp_prepare_filters() populated both filter descriptions together, so this is a new behavior.
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp) · line 737
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +8
-0+ }else { +/* PTP disabled, clear all UDP/L2 filters */ +for (i =0 ; i <PTP_UDP_FILTERS_CNT ; i++) { + aq_ptp->udp_filter[i].cmd &= + ~HW_ATL_RX_ENABLE_FLTR_L3L4 ; +if (hw_ops->hw_filter_l3l4_set) { + err = hw_ops->hw_filter_l3l4_set (aq_nic->aq_hw, + &aq_ptp->udp_filter[i]);
On the a1_ptp path, only udp_filter[0] is ever populated with real cmd content; slots 1..3 have only their location field set. This disable branch now pushes all four slots through hw_filter_l3l4_set on every hwtstamp-disable. Is programming the extra three zero-cmd filter entries intended for AQC107?
[ ... ]
Quoted 1 line
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +0
-0@@ -1035,46 +1246,49 @@ static struct ptp_clock_info aq_ptp_clock = {
[ ... ]
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-0+int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_ptp_vec) {bool a1_ptp =ATL_HW_IS_CHIP_FEATURE (aq_nic->aq_hw,ATLANTIC ); +bool a2_ptp =ATL_HW_IS_CHIP_FEATURE (aq_nic->aq_hw,ANTIGUA );
[ ... ]
Quoted 14 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +11
-3-hw_atl_utils_mpi_read_stats (aq_nic->aq_hw, &mbox); - -if (!(mbox.info.caps_ex &BIT (CAPS_EX_PHY_PTP_EN ))) { +if (a1_ptp) { +hw_atl_utils_mpi_read_stats (aq_nic->aq_hw, &mbox); +if (!(mbox.info.caps_ex &BIT (CAPS_EX_PHY_PTP_EN ))) { + aq_nic->aq_ptp =NULL ; +return 0 ; + } + }else { +memset (&mbox,0 ,sizeof (mbox)); + +if (a2_ptp) { + mbox.info.ptp_offset.ingress_100 =HW_ATL2_PTP_OFFSET_INGRESS_100 ;
[ ... ]
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
Quoted 2 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-0+ } + }
The A1 path gates PTP on caps_ex & BIT(CAPS_EX_PHY_PTP_EN), but the A2 path enables PTP unconditionally on any ATL_HW_IS_CHIP_FEATURE(..., ANTIGUA) chip. The commit message only mentions AQC113, but AQC115c and AQC116c also match ANTIGUA. Is there a capability bit that should gate this for the non-AQC113 Antigua variants?
[ ... ]
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +1
-1/* enable ptp counter */ + aq_ptp->ptp_clock_sel =ATL_TSG_CLOCK_SEL_0 ;aq_utils_obj_set (&aq_nic->aq_hw->flags,AQ_HW_PTP_AVAILABLE ); -mutex_lock (&aq_nic->fwreq_mutex);
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec) · line 1484
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +7
-3- aq_nic->aq_fw_ops->enable_ptp (aq_nic->aq_hw,1 ); -aq_ptp_clock_init (aq_nic); -mutex_unlock (&aq_nic->fwreq_mutex); +if (a1_ptp) { +mutex_lock (&aq_nic->fwreq_mutex); + aq_nic->aq_fw_ops->enable_ptp (aq_nic->aq_hw,1 ); +mutex_unlock (&aq_nic->fwreq_mutex); + } +if (a2_ptp) + aq_nic->aq_hw_ops->enable_ptp (aq_nic->aq_hw, aq_ptp->ptp_clock_sel,1 );
The A1 enable_ptp call is wrapped in fwreq_mutex, but the A2 enable_ptp (which performs hw_atl2_tsg_clock_reset / _en / hw_atl2_adj_clock_freq / hw_atl2_tpb_tps_highest_priority_tc_enable_set) is not. aq_ptp_hw_pin_conf() holds fwreq_mutex when programming the same TSG/GPIO block via hw_gpio_pulse(). hw_atl2_hw_reset() also calls hw_atl2_enable_ptp() without fwreq_mutex. Should the A2 enable_ptp paths also take fwreq_mutex to avoid concurrent writes to the TSG block?
[ ... ]
Quoted 1 line
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +0
-0@@ -1244,30 +1514,45 @@ void aq_ptp_unregister(struct aq_nic_s *aq_nic)
[ ... ]
Quoted 13 lines
void
aq_ptp_free(struct aq_nic_s *aq_nic)
{drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +6
-0struct aq_ptp_s *aq_ptp = aq_nic->aq_ptp; +int i;if (!aq_ptp)return ; +/* disable ptp */ +if (aq_ptp->a1_ptp) { +mutex_lock (&aq_nic->fwreq_mutex); + aq_nic->aq_fw_ops->enable_ptp (aq_nic->aq_hw,0 ); +mutex_unlock (&aq_nic->fwreq_mutex);
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c void aq_ptp_unregister(struct aq_nic_s *aq_nic) · line 1545
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +8
-0+ } + +if (aq_ptp->a2_ptp) + aq_nic->aq_hw_ops->enable_ptp (aq_nic->aq_hw, + aq_ptp->ptp_clock_sel,0 ); + +cancel_delayed_work_sync (&aq_ptp->poll_sync); +aq_nic_release_filter (aq_nic, aq_rx_filter_ethertype, aq_ptp->eth_type_filter.location);
[ ... ]
The pre-patch code cancelled poll_sync first, then disabled PTP. The new order disables PTP before cancel_delayed_work_sync(&aq_ptp->poll_sync).
A poll_sync worker running concurrently will call aq_ptp_check_sync1588() / hw_ts_to_sys_clock() against TSG clocks that enable_ptp(..., 0) has just torn down. For A2 the same worker may race with hw_atl2_tsg_clock_en register writes.
Is there a reason to invert this ordering? The standard pattern is cancel_delayed_work_sync() first, then tear down the resources the worker uses.
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +0
-2@@ -308,24 +308,30 @@ bool aq_ring_tx_clean(struct aq_ring_s *self) } } -if (likely (!buff->is_eop)) - goto out;
[ ... ]
Quoted 12 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +10
-1+if (unlikely (buff->is_eop)) { +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) {
[ ... ]
drivers/net/ethernet/aquantia/atlantic/aq_ring.c bool aq_ring_tx_clean(struct aq_ring_s *self) · line 337
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +2
-0+ } + } buff->skb =NULL ; buff->xdpf =NULL ; buff->pa =0U ;
When hw_ring_tx_ptp_get_ts() returns 0 (TX timestamp not yet ready), the loop does break. At that point dma_unmap_single()/dma_unmap_page() has already run earlier in the iteration, but buff->is_mapped remains 1, buff->pa still holds the original DMA address, buff->skb is still set, and sw_head is not advanced.
On the next aq_ring_tx_clean() call the same descriptor is revisited and dma_unmap is called a second time on the already-unmapped address. Under CONFIG_DMA_API_DEBUG this triggers a WARN; under an IOMMU it may corrupt mappings.
The commit message also says:
Poll for TX timestamp completion in aq_ring_tx_clean() with a timeout mechanism (aq_ptp_tx_ts_timedout/clear)
but no aq_ptp_tx_ts_timedout or aq_ptp_tx_ts_clear helper appears in this patch. Where is the timeout that bounds this polling loop? If the HW never writes back DD|TS_VALID (silicon quirk, link flap, lost packet), does the TX ring stall indefinitely and leak the skb and DMA mapping?
Quoted 19 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +6
-1@@ -719,14 +735,24 @@ static int hw_atl2_hw_ring_rx_init(struct aq_hw_s *self,struct aq_ring_s *aq_ring, struct aq_ring_param_s *aq_ring_param) { - return hw_atl_b0_hw_ring_rx_init(self, aq_ring, aq_ring_param); + int res = hw_atl_b0_hw_ring_rx_init(self, aq_ring, aq_ring_param); + +if (aq_ptp_ring (aq_ring->aq_nic, aq_ring)) +hw_atl2_hw_rx_ptp_ring_init (self, aq_ring); + +return res; } static int hw_atl2_hw_ring_tx_init(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static int hw_atl2_hw_ring_rx_init(struct aq_hw_s *self, · line 756
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +6
-1struct aq_ring_param_s *aq_ring_param) { -return hw_atl_b0_hw_ring_tx_init (self, aq_ring, aq_ring_param); +int res =hw_atl_b0_hw_ring_tx_init (self, aq_ring, aq_ring_param); + +if (aq_ptp_ring (aq_ring->aq_nic, aq_ring)) +hw_atl2_hw_tx_ptp_ring_init (self, aq_ring); + +return res; }
hw_atl2_hw_{rx,tx}_ptp_ring_init() return aq_hw_err_from_flags(self), which reports -ENXIO/-EIO when AQ_HW_FLAG_ERR_UNPLUG or AQ_HW_FLAG_ERR_HW is set. The return value is discarded here, so PTP ring setup errors are hidden from the caller. Should this be something like:
return res ? res : aq_hw_err_from_flags(self);
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 953
Quoted 12 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +12
-0+static u64 hw_atl2_hw_ring_tx_ptp_get_ts (struct aq_ring_s *ring) +{ +struct hw_atl2_txts_s *txts; + + txts = (struct hw_atl2_txts_s *)&ring->dx_ring[ring->sw_head * +HW_ATL2_TXD_SIZE ]; +/* DD + TS_VALID */ +if ((txts->ctrl &HW_ATL2_TXTS_DD ) && (txts->ctrl &HW_ATL2_TXTS_TS_VALID )) +return txts->ts; + +return 0 ; +}
txts lives in DMA-coherent memory written by the device. The compiler can issue two separate loads of txts->ctrl between the two bitmask checks, producing a torn state (DD set, TS_VALID appears unset, or vice versa). On weakly-ordered architectures (arm64, powerpc) the CPU can also speculate txts->ts ahead of the ctrl check.
Should this use a READ_ONCE on ctrl followed by dma_rmb() before reading txts->ts?
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +4
-0+static u16 hw_atl2_hw_rx_extract_ts (struct aq_hw_s *self,u8 *p, +unsigned int len,u64 *timestamp) +{ +unsigned int offset =HW_ATL2_RX_TS_SIZE ;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 968
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+u8 *ptr; + +if (len <= offset || !timestamp) +return 0 ; + + ptr = p + (len - offset); +memcpy (timestamp, ptr,sizeof (*timestamp)); + +return HW_ATL2_RX_TS_SIZE ; +}
The data at ptr is written by the device in a defined wire byte order, but is being copied into a plain host-order u64 with no byteswap. The A1 helper hw_atl_b0_rx_extract_ts() handles this with explicit __be64/__be32 locals and be64_to_cpu/be32_to_cpu accessors. Is the AQC113 field really host-endian, or should big-endian hosts byteswap here as well? Also, struct hw_atl2_txts_s declares ts as u64 rather than a __bitwise type, which will not be caught by sparse.
[ ... ]
aq_ptp_ring_alloc() error path in aq_ptp.c:
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +7
-0+if (aq_ptp->a1_ptp) { + err =aq_ring_hwts_rx_alloc (&aq_ptp->hwts_rx, aq_nic,PTP_HWST_RING_IDX , + aq_nic->aq_nic_cfg.rxds, + aq_nic->aq_nic_cfg.aq_hw_caps->rxd_size); +if (err) + goto err_exit_ptp_rx; + }
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c
Quoted 4 lines
err_exit_hwts_rx:drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +2
-1-aq_ring_hwts_rx_free (&aq_ptp->hwts_rx); +if (aq_ptp->a1_ptp) +aq_ring_free (&aq_ptp->hwts_rx);
aq_ring_hwts_rx_alloc() allocates sz = size * dx_size + AQ_CFG_RXDS_DEF bytes of DMA-coherent memory, but the err_exit_hwts_rx label now calls aq_ring_free() which frees size * dx_size (the AQ_CFG_RXDS_DEF padding is dropped). The pre-patch code used aq_ring_hwts_rx_free() which matched the allocation size. Should this stay as aq_ring_hwts_rx_free() in the error path so dma_free_coherent() sees the original allocation size?
Signature · 1 line
This is an AI-generated review.
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next 9/9] net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
Quoted 55 lines · Paolo Abeni
---
net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)This patch adds IEEE 1588 PTP support for the AQC113 (Antigua) controller alongside the existing AQC107 implementation, covering dual TSG clocks, descriptor-writeback TX timestamps, per-instance PTP offsets, L3/L4 multicast filters, and direct hardware clock control.
A few observations and questions below.
drivers/net/ethernet/aquantia/atlantic/aq_main.c +15
-6@@ -113,16 +110,25 @@ static netdev_tx_t aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *nd* and hardware PTP design of the chip. Otherwise ptp stream * will fail to sync */ -if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) || -unlikely ((ip_hdr (skb)->version ==4 ) && - (ip_hdr (skb)->protocol ==IPPROTO_UDP ) && - ((udp_hdr (skb)->dest ==htons (319 )) || - (udp_hdr (skb)->dest ==htons (320 )))) || -unlikely (eth_hdr (skb)->h_proto ==htons (ETH_P_1588 ))) +if (unlikely (skb->protocol ==htons (ETH_P_IP ) && +ip_hdr (skb)->protocol ==IPPROTO_UDP && + (udp_hdr (skb)->dest ==htons (PTP_EV_PORT ) || +udp_hdr (skb)->dest ==htons (PTP_GEN_PORT )))) +return aq_ptp_xmit (aq_nic, skb); + +/* PTP over IPv6 does not use extension headers */ +if (unlikely (skb->protocol ==htons (ETH_P_IPV6 ) && +ipv6_hdr (skb)->nexthdr ==IPPROTO_UDP && + (udp_hdr (skb)->dest ==htons (PTP_EV_PORT ) || +udp_hdr (skb)->dest ==htons (PTP_GEN_PORT )))) +return aq_ptp_xmit (aq_nic, skb); + +if (unlikely (eth_hdr (skb)->h_proto ==htons (ETH_P_1588 ))) return aq_ptp_xmit(aq_nic, skb); }#endif +skb_tx_timestamp (skb);return aq_nic_xmit (aq_nic, skb); }The commit message states:
Move
skb_tx_timestamp()to non-PTP path to avoid double timestampsWas there actually a pre-existing double-timestamp? The prior code had exactly one
skb_tx_timestamp()per packet (aq_nic_xmit()for non-PTP,aq_ptp_xmit()for PTP), so this move appears functionally equivalent for the PTP case.
Quoted 6 lines
However, the new placement in
aq_ndev_start_xmit()is before aq_nic_xmit()'s __netif_subqueue_stopped()/map-failure/NETDEV_TX_BUSY handling, so software TX timestamps may now be generated for frames that end up returningNETDEV_TX_BUSY. Is that intentional? It changes a user-visibleSO_TIMESTAMPINGpoint for all atlantic chips, not just AQC113.
The skb_tx_timestamp() move has been dropped in v3. It remains in
aq_nic_xmit() after all NETDEV_TX_BUSY checks, so software timestamps are only generated for frames that actually proceed to transmission. The commit message has been updated to remove that bullet point.
Quoted 22 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +5
-1@@ -172,7 +180,11 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)aq_nic_update_interrupt_moderation_settings (self);if (self->aq_ptp) { -aq_ptp_clock_init (self); +/* PTP does not work in some modes even if physical link is up */ +bool ptp_link_good = (self->aq_hw->aq_link_status.mbps >=100 && + self->aq_hw->aq_link_status.full_duplex); + +aq_ptp_clock_init (self, ptp_link_good ?AQ_PTP_LINK_UP :AQ_PTP_NO_LINK );aq_ptp_tm_offset_set (self, self->aq_hw->aq_link_status.mbps);aq_ptp_link_change (self);
aq_ptp_clock_init()now callsaq_ptp_dpath_enable(), which writes hw_filter_l3l4_set/hw_filter_l2_set and mutates aq_ptp->udp_filter[i].cmd andaq_ptp->eth_type_filter.
Quoted 7 lines
The caller of
aq_nic_update_link_status()is the service task andaq_linkstate_threaded_isr, neither of which holdrtnl_lock. The hwtstamp ioctl path entersaq_ptp_hwtstamp_config_set()(and thenceaq_ptp_dpath_enable()) underrtnl_lock. Is there a lock covering both sides? The same filter structures and registers can be programmed concurrently from the two paths, and hwtstamp_config.rx_filter is read unsynchronized from the link path while written by the ioctl path.
Ack, Both paths are serialized in v3 via a dedicated ptp_filter_lock mutex
on aq_ptp. Both aq_ptp_clock_init() (link/service task) and aq_ptp_hwtstamp_config_set() (ioctl path) acquire this mutex before calling aq_ptp_dpath_enable(), preventing concurrent filter programming.
Quoted 29 lines
[ ... ]
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +17
-0+static int aq_ptp_dpath_enable (struct aq_ptp_s *aq_ptp, +int enable_flags,u16 rx_queue) +{ +if (enable_flags &AQ_HW_PTP_L2_ENABLE ) { + aq_ptp->eth_type_filter.ethertype =ETH_P_1588 ; + aq_ptp->eth_type_filter.queue = rx_queue; + } + +if (hw_ops->hw_filter_l3l4_set) { +for (i =0 ; i < flt_idx; i++) { + err = hw_ops->hw_filter_l3l4_set (aq_nic->aq_hw, + &aq_ptp->udp_filter[i]); + } + +if (!err && hw_ops->hw_filter_l2_set) { + err = hw_ops->hw_filter_l2_set (aq_nic->aq_hw, + &aq_ptp->eth_type_filter);
Quoted 6 lines
When
enable_flagsisAQ_HW_PTP_L4_ENABLEonly (for example HWTSTAMP_FILTER_PTP_V1_L4_* or HWTSTAMP_FILTER_PTP_V2_L4_*), the block that sets eth_type_filter.ethertype/queue is skipped, buthw_filter_l2_setis still called unconditionally. Will that install a stale L2 filter (zero ethertype from kzalloc, or leftoverETH_P_1588from a previous call) into hardware?
Fixed in v3. The hw_filter_l2_set call is now gated by
(enable_flags & AQ_HW_PTP_L2_ENABLE), so it is only invoked when the L2 filter is actually requested. A pure AQ_HW_PTP_L4_ENABLE path skips both the eth_type_filter setup and the hw_filter_l2_set call entirely — no stale or zero ethertype filter is installed.
Quoted 13 lines
The pre-patch
aq_ptp_prepare_filters()populated both filter descriptions together, so this is a new behavior.drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +8
-0+ }else { +/* PTP disabled, clear all UDP/L2 filters */ +for (i =0 ; i <PTP_UDP_FILTERS_CNT ; i++) { + aq_ptp->udp_filter[i].cmd &= + ~HW_ATL_RX_ENABLE_FLTR_L3L4 ; +if (hw_ops->hw_filter_l3l4_set) { + err = hw_ops->hw_filter_l3l4_set (aq_nic->aq_hw, + &aq_ptp->udp_filter[i]);
Quoted 5 lines
On the
a1_ptppath, only udp_filter[0] is ever populated with real cmd content; slots 1..3 have only their location field set. This disable branch now pushes all four slots throughhw_filter_l3l4_seton every hwtstamp-disable. Is programming the extra three zero-cmd filter entries intended for AQC107?
On a1_ptp, slots 1–3 have cmd = 0 with only their location set; writing them with HW_ATL_RX_ENABLE_FLTR_L3L4 cleared is harmless — it simply confirms already-disabled filter slots.
Quoted 3 lines
[ ... ]
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +0
-0@@ -1035,46 +1246,49 @@ static struct ptp_clock_info aq_ptp_clock = {
[ ... ]
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-0+int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_ptp_vec) {bool a1_ptp =ATL_HW_IS_CHIP_FEATURE (aq_nic->aq_hw,ATLANTIC ); +bool a2_ptp =ATL_HW_IS_CHIP_FEATURE (aq_nic->aq_hw,ANTIGUA );
[ ... ]
Quoted 18 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +13
-3-hw_atl_utils_mpi_read_stats (aq_nic->aq_hw, &mbox); - -if (!(mbox.info.caps_ex &BIT (CAPS_EX_PHY_PTP_EN ))) { +if (a1_ptp) { +hw_atl_utils_mpi_read_stats (aq_nic->aq_hw, &mbox); +if (!(mbox.info.caps_ex &BIT (CAPS_EX_PHY_PTP_EN ))) { + aq_nic->aq_ptp =NULL ; +return 0 ; + } + }else { +memset (&mbox,0 ,sizeof (mbox)); + +if (a2_ptp) { + mbox.info.ptp_offset.ingress_100 =HW_ATL2_PTP_OFFSET_INGRESS_100 ; + } + }
Quoted 6 lines
The A1 path gates PTP on
caps_ex&BIT(CAPS_EX_PHY_PTP_EN), but the A2 path enables PTP unconditionally on anyATL_HW_IS_CHIP_FEATURE(..., ANTIGUA)chip. The commit message only mentions AQC113, but AQC115c and AQC116c also match ANTIGUA. Is there a capability bit that should gate this for the non-AQC113 Antigua variants?
The existing caps structures for these variants don't define any PTP-specific flag. Adding per-variant PTP capability gating is outside the scope of this series. If AQC115C/116C don't support PTP hardware, that can be addressed in a follow-up by adding a ptp_supported cap flag.
Quoted 17 lines
[ ... ]
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +8
-4/* enable ptp counter */ + aq_ptp->ptp_clock_sel =ATL_TSG_CLOCK_SEL_0 ;aq_utils_obj_set (&aq_nic->aq_hw->flags,AQ_HW_PTP_AVAILABLE ); -mutex_lock (&aq_nic->fwreq_mutex); - aq_nic->aq_fw_ops->enable_ptp (aq_nic->aq_hw,1 ); -aq_ptp_clock_init (aq_nic); -mutex_unlock (&aq_nic->fwreq_mutex); +if (a1_ptp) { +mutex_lock (&aq_nic->fwreq_mutex); + aq_nic->aq_fw_ops->enable_ptp (aq_nic->aq_hw,1 ); +mutex_unlock (&aq_nic->fwreq_mutex); + } +if (a2_ptp) + aq_nic->aq_hw_ops->enable_ptp (aq_nic->aq_hw, aq_ptp->ptp_clock_sel,1 );
Quoted 8 lines
The A1
enable_ptpcall is wrapped infwreq_mutex, but the A2enable_ptp(which performshw_atl2_tsg_clock_reset/_en/hw_atl2_adj_clock_freq/hw_atl2_tpb_tps_highest_priority_tc_enable_set) is not.aq_ptp_hw_pin_conf()holdsfwreq_mutexwhen programming the same TSG/GPIO block viahw_gpio_pulse().hw_atl2_hw_reset()also callshw_atl2_enable_ptp()withoutfwreq_mutex. Should the A2enable_ptppaths also takefwreq_mutexto avoid concurrent writes to the TSG block?
fwreq_mutex guards firmware mailbox requests (aq_fw_ops calls), not
MMIO writes. The A2 enable_ptp does direct TSG register writes and does not need the mutex — not a concern.
Quoted 32 lines
[ ... ]
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +14
-0@@ -1244,30 +1514,45 @@ void aq_ptp_unregister(struct aq_nic_s *aq_nic)void aq_ptp_free (struct aq_nic_s *aq_nic) {struct aq_ptp_s *aq_ptp = aq_nic->aq_ptp; +int i;if (!aq_ptp)return ; +/* disable ptp */ +if (aq_ptp->a1_ptp) { +mutex_lock (&aq_nic->fwreq_mutex); + aq_nic->aq_fw_ops->enable_ptp (aq_nic->aq_hw,0 ); +mutex_unlock (&aq_nic->fwreq_mutex); + } + +if (aq_ptp->a2_ptp) + aq_nic->aq_hw_ops->enable_ptp (aq_nic->aq_hw, + aq_ptp->ptp_clock_sel,0 ); + +cancel_delayed_work_sync (&aq_ptp->poll_sync); +aq_nic_release_filter (aq_nic, aq_rx_filter_ethertype, aq_ptp->eth_type_filter.location);The pre-patch code cancelled
poll_syncfirst, then disabled PTP. The new order disables PTP beforecancel_delayed_work_sync(&aq_ptp->poll_sync).
Quoted 9 lines
A
poll_syncworker running concurrently will callaq_ptp_check_sync1588()/hw_ts_to_sys_clock()against TSG clocks thatenable_ptp(..., 0)has just torn down. For A2 the same worker may race withhw_atl2_tsg_clock_enregister writes.Is there a reason to invert this ordering? The standard pattern is
cancel_delayed_work_sync()first, then tear down the resources the worker uses.
Fixed in v3: cancel_delayed_work_sync(&aq_ptp->poll_sync) is called
before enable_ptp(..., 0), ensuring the worker is fully stopped before TSG resources are torn down.
Quoted 43 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +12
-3@@ -308,24 +308,30 @@ bool aq_ring_tx_clean(struct aq_ring_s *self) } } -if (likely (!buff->is_eop)) - goto out; +if (unlikely (buff->is_eop)) { +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) { + } + } buff->skb =NULL ; buff->xdpf =NULL ; buff->pa =0U ;When
hw_ring_tx_ptp_get_ts()returns 0 (TX timestamp not yet ready), the loop does break. At that point dma_unmap_single()/dma_unmap_page() has already run earlier in the iteration, butbuff->is_mappedremains 1,buff->pastill holds the original DMA address,buff->skbis still set, andsw_headis not advanced.On the next
aq_ring_tx_clean()call the same descriptor is revisited anddma_unmapis called a second time on the already-unmapped address. UnderCONFIG_DMA_API_DEBUGthis triggers a WARN; under an IOMMU it may corrupt mappings.The commit message also says:
Quoted 8 lines
Poll for TX timestamp completion in
aq_ring_tx_clean()with a timeout mechanism (aq_ptp_tx_ts_timedout/clear)but no
aq_ptp_tx_ts_timedoutoraq_ptp_tx_ts_clearhelper appears in this patch. Where is the timeout that bounds this polling loop? If the HW never writes back DD|TS_VALID (silicon quirk, link flap, lost packet), does the TX ring stall indefinitely and leak the skb and DMA mapping?
Both points are addressed in v3:
On the double-unmap: when hw_ring_tx_ptp_get_ts() returns 0 and the timeout has not expired, the code now explicitly clears buff->is_mapped and buff->pa before breaking, so the next iteration sees is_mapped == 0 and skips dma_unmap. No double-unmap occurs.
On the timeout: a ptp_ts_deadline field is checked via time_after(jiffies, self->ptp_ts_deadline). On expiry, request_ts is cleared and the skb is freed via dev_kfree_skb_any(), unblocking the ring. The commit message reference to aq_ptp_tx_ts_timedout/clear was from an earlier draft and will be corrected in v3.
Quoted 36 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +12
-2@@ -719,14 +735,24 @@ static int hw_atl2_hw_ring_rx_init(struct aq_hw_s *self,struct aq_ring_s *aq_ring, struct aq_ring_param_s *aq_ring_param) { - return hw_atl_b0_hw_ring_rx_init(self, aq_ring, aq_ring_param); + int res = hw_atl_b0_hw_ring_rx_init(self, aq_ring, aq_ring_param); + +if (aq_ptp_ring (aq_ring->aq_nic, aq_ring)) +hw_atl2_hw_rx_ptp_ring_init (self, aq_ring); + +return res; }static int hw_atl2_hw_ring_tx_init (struct aq_hw_s *self,struct aq_ring_s *aq_ring,struct aq_ring_param_s *aq_ring_param) { -return hw_atl_b0_hw_ring_tx_init (self, aq_ring, aq_ring_param); +int res =hw_atl_b0_hw_ring_tx_init (self, aq_ring, aq_ring_param); + +if (aq_ptp_ring (aq_ring->aq_nic, aq_ring)) +hw_atl2_hw_tx_ptp_ring_init (self, aq_ring); + +return res; } hw_atl2_hw_{rx,tx}_ptp_ring_init() return aq_hw_err_from_flags(self),which reports -ENXIO/-EIO when
AQ_HW_FLAG_ERR_UNPLUGorAQ_HW_FLAG_ERR_HWis set. The return value is discarded here, so PTP ring setup errors are hidden from the caller. Should this be something like:
Quoted 1 line
return res ? res : aq_hw_err_from_flags(self);
Fixed in v3. The PTP ring init return values are captured in rx_err/
tx_err and propagated to the caller — PTP ring setup errors are no longer silently discarded. The base init (hw_atl_b0_hw_ring_*_init) is also only attempted when it succeeds (if (!res && ...)).
Quoted 16 lines
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +12
-0+static u64 hw_atl2_hw_ring_tx_ptp_get_ts (struct aq_ring_s *ring) +{ +struct hw_atl2_txts_s *txts; + + txts = (struct hw_atl2_txts_s *)&ring->dx_ring[ring->sw_head * +HW_ATL2_TXD_SIZE ]; +/* DD + TS_VALID */ +if ((txts->ctrl &HW_ATL2_TXTS_DD ) && (txts->ctrl &HW_ATL2_TXTS_TS_VALID )) +return txts->ts; + +return 0 ; +}
Quoted 8 lines
txts lives in DMA-coherent memory written by the device. The compiler can issue two separate loads of
txts->ctrlbetween the two bitmask checks, producing a torn state (DD set,TS_VALIDappears unset, or vice versa). On weakly-ordered architectures (arm64, powerpc) the CPU can also speculatetxts->tsahead of the ctrl check.Should this use a
READ_ONCEon ctrl followed bydma_rmb()before readingtxts->ts?
Fixed in v3: ctrl is read once via READ_ONCE(txts->ctrl) and both
bit checks are made against the single cached value. A dma_rmb() is inserted before reading txts->ts to prevent the CPU from speculating the timestamp load ahead of the control field check on weakly-ordered architectures.
Quoted 15 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +14
-0+static u16 hw_atl2_hw_rx_extract_ts (struct aq_hw_s *self,u8 *p, +unsigned int len,u64 *timestamp) +{ +unsigned int offset =HW_ATL2_RX_TS_SIZE ; +u8 *ptr; + +if (len <= offset || !timestamp) +return 0 ; + + ptr = p + (len - offset); +memcpy (timestamp, ptr,sizeof (*timestamp)); + +return HW_ATL2_RX_TS_SIZE ; +}
Quoted 7 lines
The data at ptr is written by the device in a defined wire byte order, but is being copied into a plain host-order u64 with no byteswap. The A1 helper
hw_atl_b0_rx_extract_ts()handles this with explicit __be64/__be32 locals and be64_to_cpu/be32_to_cpu accessors. Is the AQC113 field really host-endian, or should big-endian hosts byteswap here as well? Also, structhw_atl2_txts_sdeclares ts as u64 rather than a__bitwisetype, which will not be caught by sparse.
Both points are addressed in v3. hw_atl2_hw_rx_extract_ts() now copies
into a __le64 local and converts with le64_to_cpu() before storing into *timestamp. struct hw_atl2_txts_s declares ts as __le64, so sparse will flag incorrect accesses, and hw_ring_tx_ptp_get_ts() reads it with le64_to_cpu(txts->ts).
Quoted 17 lines
[ ... ]
aq_ptp_ring_alloc()error path inaq_ptp.c:drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +9
-1+if (aq_ptp->a1_ptp) { + err =aq_ring_hwts_rx_alloc (&aq_ptp->hwts_rx, aq_nic,PTP_HWST_RING_IDX , + aq_nic->aq_nic_cfg.rxds, + aq_nic->aq_nic_cfg.aq_hw_caps->rxd_size); +if (err) + goto err_exit_ptp_rx; + } err_exit_hwts_rx: -aq_ring_hwts_rx_free (&aq_ptp->hwts_rx); +if (aq_ptp->a1_ptp) +aq_ring_free (&aq_ptp->hwts_rx);
Quoted 7 lines
aq_ring_hwts_rx_alloc()allocates sz = size *dx_size+AQ_CFG_RXDS_DEFbytes of DMA-coherent memory, but theerr_exit_hwts_rxlabel now callsaq_ring_free()which frees size *dx_size(theAQ_CFG_RXDS_DEFpadding is dropped). The pre-patch code usedaq_ring_hwts_rx_free()which matched the allocation size. Should this stay asaq_ring_hwts_rx_free()in the error path sodma_free_coherent()sees the original allocation size?
Fixed in v3: the err_exit_hwts_rx label uses aq_ring_hwts_rx_free()
which passes size * dx_size + AQ_CFG_RXDS_DEF to dma_free_coherent(), matching the original allocation size exactly.
Quoted 2 lines
Signature · 1 line
This is an AI-generated review.
[email protected]
maintainerv2 cover net: atlantic: add PTP support for AQC113 (Antigua)
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
This series adds IEEE 1588 PTP support for the AQC113 (Antigua) network controller. AQC113 is the successor to the existing AQC107 (Atlantic) chip already supported by the atlantic driver.
AQC113 uses a substantially different hardware architecture for PTP compared to AQC107:
- Dual on-chip TSG clocks with direct register access instead of PHY-based timestamping via firmware
- TX timestamps via descriptor writeback instead of firmware mailbox
- Hardware L3/L4 RX filters for PTP multicast steering with both IPv4 and IPv6 support
- Reference-counted shared filter slots managed through an Action Resolver Table (ART), allowing multiple rules to share L3/L4 hardware filters when their match criteria are identical
The series is structured in three parts:
Patches 1-3 prepare the existing L3/L4 filter path:
Patch 1 corrects flow_type masking and IPv6 address handling in aq_set_data_fl3l4(). Patch 2 moves the active_ipv4/ipv6 bitmap updates to after the hardware write succeeds. Patch 3 decouples the function from driver-internal structures so it can be called directly by the AQC113 PTP filter setup code.
Patches 4-6 add the AQC113 hardware infrastructure:
Patch 4 adds the low-level register definitions and accessor functions. Patch 5 adds filter data structures and firmware capability query. Patch 6 implements the complete L2/L3/L4 RX filter management layer including the reference-counted sharing and ART integration.
Patches 7-9 add the AQC113 PTP feature:
Patch 7 reserves the dedicated PTP traffic class buffer and configures the TX path. Patch 8 extends the hw_ops interface with PTP-specific function pointers and updates AQC107 to the new signatures. Patch 9 implements the full PTP subsystem integration for AQC113.
The existing AQC107 PTP implementation is not functionally changed by this series; AQC113-specific code paths are gated on chip detection throughout.
Tested on AQC113 at 1G, 2.5G, 5G, and 10G link speeds using ptp4l/phc2sys with hardware timestamping in both L2 and L4 (IPv4/IPv6) modes.
Changes in v2:
- Patch 6: Remove redundant variable initializers for art_mask, h, l and err as suggested by Vadim Fedorenko
Sukhdeep Singh (9):
net: atlantic: correct L3L4 filter flow_type masking and IPv6 handling
net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write
net: atlantic: decouple aq_set_data_fl3l4() from driver internals
net: atlantic: add AQC113 hardware register definitions and accessors
net: atlantic: add AQC113 filter data structures and firmware query
net: atlantic: implement AQC113 L2/L3/L4 RX filter management
net: atlantic: add AQC113 PTP traffic class and TX path setup
net: atlantic: extend hw_ops and TX descriptor for AQC113 PTP
net: atlantic: add PTP support for AQC113 (Antigua)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c | 64 +- drivers/net/ethernet/aquantia/atlantic/aq_filters.h | 3 + drivers/net/ethernet/aquantia/atlantic/aq_hw.h | 37 +- drivers/net/ethernet/aquantia/atlantic/aq_main.c | 33 +- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 51 +- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 4 +- drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 531 +++++++-- drivers/net/ethernet/aquantia/atlantic/aq_ptp.h | 15 +- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 42 +- drivers/net/ethernet/aquantia/atlantic/aq_ring.h | 4 +- drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c | 15 +- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c | 813 +++++++++++- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.h | 12 + drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h | 69 +- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.c | 360 ++++++ drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.h | 107 +- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh_internal.h | 204 ++- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c | 33 + drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.h | 15 + drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c | 52 + 20 files changed, 2244 insertions(+), 224 deletions(-)
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH v2 1/9 net: atlantic: correct L3L4 filter flow_type masking and IPv6 handling masking and IPv6 handling
From: Sukhdeep Singh <[email protected]>
Correct three issues in aq_set_data_fl3l4() required for the AQC113 PTP filter path introduced later in this series:
1. Mask FLOW_EXT from flow_type before the protocol switch statement. Flow types with FLOW_EXT set (e.g. TCP_V4_FLOW | FLOW_EXT) fall through to the default case and skip protocol comparison flags.
2. Extend the L3 address comparison check to cover all four IPv6 words. The original code only checked ip_src[0]/ip_dst[0] and required !is_ipv6, so CMP_SRC_ADDR_L3/CMP_DEST_ADDR_L3 were never set for IPv6 filters.
3. Use explicit flow type checks for port extraction instead of negating IP_USER_FLOW/IPV6_USER_FLOW. The old check did not mask FLOW_EXT, so IP_USER_FLOW | FLOW_EXT would incorrectly attempt port extraction. Use the actual flow type to pick the correct union member directly.
--- .../ethernet/aquantia/atlantic/aq_filters.c | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c +17 -16
@@ -472,6 +472,7 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic, {struct aq_hw_rx_fltrs_s *rx_fltrs =aq_get_hw_rx_fltrs (aq_nic);const struct ethtool_rx_flow_spec *fsp = &aq_rx_fltr->aq_fsp; +u32 flow = fsp->flow_type & ~FLOW_EXT ;memset (data,0 ,sizeof (*data));
@@ -490,7 +491,7 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic, data->cmd |=HW_ATL_RX_ENABLE_FLTR_L3L4 ; -switch (fsp->flow_type) { +switch (flow) {case TCP_V4_FLOW :case TCP_V6_FLOW : data->cmd |=HW_ATL_RX_ENABLE_CMP_PROT_L4 ;
@@ -527,23 +528,23 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic, } data->cmd |=HW_ATL_RX_ENABLE_L3_IPV6 ; } -if (fsp->flow_type !=IP_USER_FLOW && - fsp->flow_type !=IPV6_USER_FLOW ) { -if (!data->is_ipv6) { - data->p_dst = -ntohs (fsp->h_u.tcp_ip4_spec.pdst); - data->p_src = -ntohs (fsp->h_u.tcp_ip4_spec.psrc); - }else { - data->p_dst = -ntohs (fsp->h_u.tcp_ip6_spec.pdst); - data->p_src = -ntohs (fsp->h_u.tcp_ip6_spec.psrc); - } +if (flow ==TCP_V4_FLOW || flow ==UDP_V4_FLOW || + flow ==SCTP_V4_FLOW ) { + data->p_dst =ntohs (fsp->h_u.tcp_ip4_spec.pdst); + data->p_src =ntohs (fsp->h_u.tcp_ip4_spec.psrc); + } +if (flow ==TCP_V6_FLOW || flow ==UDP_V6_FLOW || + flow ==SCTP_V6_FLOW ) { + data->p_dst =ntohs (fsp->h_u.tcp_ip6_spec.pdst); + data->p_src =ntohs (fsp->h_u.tcp_ip6_spec.psrc); } -if (data->ip_src[0 ] && !data->is_ipv6) +if (data->ip_src[0 ] || + (data->is_ipv6 && (data->ip_src[1 ] || data->ip_src[2 ] || + data->ip_src[3 ]))) data->cmd |=HW_ATL_RX_ENABLE_CMP_SRC_ADDR_L3 ; -if (data->ip_dst[0 ] && !data->is_ipv6) +if (data->ip_dst[0 ] || + (data->is_ipv6 && (data->ip_dst[1 ] || data->ip_dst[2 ] || + data->ip_dst[3 ]))) data->cmd |=HW_ATL_RX_ENABLE_CMP_DEST_ADDR_L3 ;if (data->p_dst) data->cmd |=HW_ATL_RX_ENABLE_CMP_DEST_PORT_L4 ;
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH v2 2/9 net: atlantic: move active_ipv4/ipv6 bitmap updates after HW write updates after HW write
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Move active_ipv4/active_ipv6 bitmap updates from aq_set_data_fl3l4() into aq_add_del_fl3l4() after the hardware write succeeds. The bitmaps track which filter slots are actively programmed in hardware and must only be updated once the HW write is confirmed.
Also remove bitmap manipulation from aq_nic_reserve_filter() and aq_nic_release_filter(). These functions manage filter slot reservation counts, not HW filter state. Setting active_ipv4 bits at reservation time (before any filter is programmed) and clearing them at release time (regardless of HW state) results in incorrect state visible to aq_check_approve_fl3l4() for IPv4/IPv6 mixing validation.
This corrected state management is required for the AQC113 L3L4 filter path introduced later in this series.
--- .../ethernet/aquantia/atlantic/aq_filters.c | 36 ++++++++++++------- .../net/ethernet/aquantia/atlantic/aq_nic.c | 3 -- 2 files changed, 23 insertions(+), 16 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c +23 -13
@@ -479,15 +479,8 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic, data->is_ipv6 = rx_fltrs->fl3l4.is_ipv6; data->location =HW_ATL_GET_REG_LOCATION_FL3L4 (fsp->location); -if (!add) { -if (!data->is_ipv6) - rx_fltrs->fl3l4.active_ipv4 &= ~BIT (data->location); -else - rx_fltrs->fl3l4.active_ipv6 &= - ~BIT ((data->location) /4 ); - +if (!add)return 0 ; - } data->cmd |=HW_ATL_RX_ENABLE_FLTR_L3L4 ;
@@ -515,11 +508,9 @@ static int aq_set_data_fl3l4(struct aq_nic_s *aq_nic,ntohl (fsp->h_u.tcp_ip4_spec.ip4src); data->ip_dst[0 ] =ntohl (fsp->h_u.tcp_ip4_spec.ip4dst); - rx_fltrs->fl3l4.active_ipv4 |=BIT (data->location); }else {int i; - rx_fltrs->fl3l4.active_ipv6 |=BIT ((data->location) /4 );for (i =0 ; i <HW_ATL_RX_CNT_REG_ADDR_IPV6 ; ++i) { data->ip_dst[i] =ntohl (fsp->h_u.tcp_ip6_spec.ip6dst[i]);
@@ -574,16 +565,35 @@ static int aq_set_fl3l4(struct aq_hw_s *aq_hw,static int aq_add_del_fl3l4 (struct aq_nic_s *aq_nic,struct aq_rx_filter *aq_rx_fltr,bool add) { +struct aq_hw_rx_fltrs_s *rx_fltrs =aq_get_hw_rx_fltrs (aq_nic);const struct aq_hw_ops *aq_hw_ops = aq_nic->aq_hw_ops;struct aq_hw_s *aq_hw = aq_nic->aq_hw;struct aq_rx_filter_l3l4 data; +int err;if (unlikely (aq_rx_fltr->aq_fsp.location <AQ_RX_FIRST_LOC_FL3L4 || - aq_rx_fltr->aq_fsp.location >AQ_RX_LAST_LOC_FL3L4 || -aq_set_data_fl3l4 (aq_nic, aq_rx_fltr, &data, add))) + aq_rx_fltr->aq_fsp.location >AQ_RX_LAST_LOC_FL3L4 ))return -EINVAL ; -return aq_set_fl3l4 (aq_hw, aq_hw_ops, &data); +aq_set_data_fl3l4 (aq_nic, aq_rx_fltr, &data, add); + + err =aq_set_fl3l4 (aq_hw, aq_hw_ops, &data); +if (err) +return err; + +if (add) { +if (!data.is_ipv6) + rx_fltrs->fl3l4.active_ipv4 |=BIT (data.location); +else + rx_fltrs->fl3l4.active_ipv6 |=BIT (data.location /4 ); + }else { +if (!data.is_ipv6) + rx_fltrs->fl3l4.active_ipv4 &= ~BIT (data.location); +else + rx_fltrs->fl3l4.active_ipv6 &= ~BIT (data.location /4 ); + } + +return 0 ; } static int aq_add_del_rule(struct aq_nic_s *aq_nic,
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0 -3
@@ -1522,8 +1522,6 @@ u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type)case aq_rx_filter_l3l4: fltr_cnt =AQ_RX_LAST_LOC_FL3L4 -AQ_RX_FIRST_LOC_FL3L4 ; n_bit = fltr_cnt - self->aq_hw_rx_fltrs.fl3l4.reserved_count; - - self->aq_hw_rx_fltrs.fl3l4.active_ipv4 |=BIT (n_bit); self->aq_hw_rx_fltrs.fl3l4.reserved_count++; location = n_bit;break ;
@@ -1543,7 +1541,6 @@ void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type,break ;case aq_rx_filter_l3l4: self->aq_hw_rx_fltrs.fl3l4.reserved_count--; - self->aq_hw_rx_fltrs.fl3l4.active_ipv4 &= ~BIT (location);break ;default :break ;
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH v2 3/9 net: atlantic: decouple aq_set_data_fl3l4() from driver internals driver internals
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Refactor aq_set_data_fl3l4() to take an ethtool_rx_flow_spec pointer and an explicit HW register location instead of driver-internal structures (aq_nic_s, aq_rx_filter). This makes the function reusable for PTP filter setup which constructs flow specs independently.
Key changes:
- Add aq_is_ipv6_flow_type() helper to derive IPv6 status from the flow_type field, replacing the dependency on rx_fltrs->fl3l4.is_ipv6 shared state.
- Change aq_set_data_fl3l4() signature to accept (fsp, data, location, add) and export it via aq_filters.h.
- Update aq_add_del_fl3l4() to compute the HW register location and pass it explicitly.
--- .../ethernet/aquantia/atlantic/aq_filters.c | 31 ++++++++++++++----- .../ethernet/aquantia/atlantic/aq_filters.h | 3 ++ 2 files changed, 26 insertions(+), 8 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c +23 -8
@@ -181,6 +181,20 @@ aq_check_approve_fvlan(struct aq_nic_s *aq_nic,return 0 ; } +static bool aq_is_ipv6_flow_type (const struct ethtool_rx_flow_spec *fsp) +{ +switch (fsp->flow_type & ~FLOW_EXT ) { +case TCP_V6_FLOW : +case UDP_V6_FLOW : +case SCTP_V6_FLOW : +case IPV6_FLOW : +case IPV6_USER_FLOW : +return true; +default : +return false; + } +} +static int __must_check aq_check_filter (struct aq_nic_s *aq_nic,struct ethtool_rx_flow_spec *fsp)
@@ -466,18 +480,16 @@ static int aq_add_del_fvlan(struct aq_nic_s *aq_nic,return aq_filters_vlans_update (aq_nic); } -static int aq_set_data_fl3l4 (struct aq_nic_s *aq_nic, -struct aq_rx_filter *aq_rx_fltr, -struct aq_rx_filter_l3l4 *data,bool add) +int aq_set_data_fl3l4 (const struct ethtool_rx_flow_spec *fsp, +struct aq_rx_filter_l3l4 *data, +int location,bool add) { -struct aq_hw_rx_fltrs_s *rx_fltrs =aq_get_hw_rx_fltrs (aq_nic); -const struct ethtool_rx_flow_spec *fsp = &aq_rx_fltr->aq_fsp;u32 flow = fsp->flow_type & ~FLOW_EXT ;memset (data,0 ,sizeof (*data)); - data->is_ipv6 = rx_fltrs->fl3l4.is_ipv6; - data->location =HW_ATL_GET_REG_LOCATION_FL3L4 (fsp->location); + data->is_ipv6 =aq_is_ipv6_flow_type (fsp); + data->location = location;if (!add)return 0 ;
@@ -569,13 +581,16 @@ static int aq_add_del_fl3l4(struct aq_nic_s *aq_nic,const struct aq_hw_ops *aq_hw_ops = aq_nic->aq_hw_ops;struct aq_hw_s *aq_hw = aq_nic->aq_hw;struct aq_rx_filter_l3l4 data; +int location;int err;if (unlikely (aq_rx_fltr->aq_fsp.location <AQ_RX_FIRST_LOC_FL3L4 || aq_rx_fltr->aq_fsp.location >AQ_RX_LAST_LOC_FL3L4 ))return -EINVAL ; -aq_set_data_fl3l4 (aq_nic, aq_rx_fltr, &data, add); + location =HW_ATL_GET_REG_LOCATION_FL3L4 (aq_rx_fltr->aq_fsp.location); + +aq_set_data_fl3l4 (&aq_rx_fltr->aq_fsp, &data, location, add); err =aq_set_fl3l4 (aq_hw, aq_hw_ops, &data);if (err)
drivers/net/ethernet/aquantia/atlantic/aq_filters.h +3 -0
@@ -32,5 +32,8 @@ int aq_clear_rxnfc_all_rules(struct aq_nic_s *aq_nic);int aq_reapply_rxnfc_all_rules (struct aq_nic_s *aq_nic);int aq_filters_vlans_update (struct aq_nic_s *aq_nic);int aq_filters_vlan_offload_off (struct aq_nic_s *aq_nic); +int aq_set_data_fl3l4 (const struct ethtool_rx_flow_spec *fsp, +struct aq_rx_filter_l3l4 *data, +int location,bool add);#endif /* AQ_FILTERS_H */
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH v2 4/9 net: atlantic: add AQC113 hardware register definitions and accessors definitions and accessors
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Add low-level hardware register definitions and accessor functions for AQC113 (Antigua) chip features:
- L3/L4 filter command, tag, and address registers for IPv4/IPv6
- Ethertype filter tag registers
- TSG (Time Stamp Generator) clock control, modification, and GPIO event generation/input timestamp registers
- TX descriptor timestamp writeback, timestamp enable, and AVB enable registers
- TX data/descriptor read request limit registers
- TPB highest priority TC registers
- PCIe extended tag enable register
- RX descriptor timestamp request register
- Action resolver section enable getter
- GPIO special mode and TSG external GPIO TS input select
--- .../aquantia/atlantic/hw_atl2/hw_atl2_llh.c | 359 ++++++++++++++++++ .../aquantia/atlantic/hw_atl2/hw_atl2_llh.h | 107 +++++- .../atlantic/hw_atl2/hw_atl2_llh_internal.h | 204 +++++++++- 3 files changed, 663 insertions(+), 7 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.c +359 -0
@@ -7,6 +7,20 @@#include "hw_atl2_llh_internal.h" #include "aq_hw_utils.h" +void hw_atl2_phi_ext_tag_set (struct aq_hw_s *aq_hw,u32 val) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_PHI_EXT_TAG_EN_ADR , +HW_ATL2_PHI_EXT_TAG_EN_MSK , +HW_ATL2_PHI_EXT_TAG_EN_SHIFT , val); +} + +u32 hw_atl2_phi_ext_tag_get (struct aq_hw_s *aq_hw) +{ +return aq_hw_read_reg_bit (aq_hw,HW_ATL2_PHI_EXT_TAG_EN_ADR , +HW_ATL2_PHI_EXT_TAG_EN_MSK , +HW_ATL2_PHI_EXT_TAG_EN_SHIFT ); +} +void hw_atl2_rpf_redirection_table2_select_set (struct aq_hw_s *aq_hw,u32 select) {
@@ -66,6 +80,278 @@ void hw_atl2_rpf_vlan_flr_tag_set(struct aq_hw_s *aq_hw, u32 tag, u32 filter) tag); } +void hw_atl2_rpf_etht_flr_tag_set (struct aq_hw_s *aq_hw,u32 tag,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_ET_TAG_ADR (filter), +HW_ATL2_RPF_ET_TAG_MSK , +HW_ATL2_RPF_ET_TAG_SHIFT , tag); +} + +u32 hw_atl2_rpf_etht_flr_tag_get (struct aq_hw_s *aq_hw,u32 filter) +{ +return aq_hw_read_reg_bit (aq_hw,HW_ATL2_RPF_ET_TAG_ADR (filter), +HW_ATL2_RPF_ET_TAG_MSK , +HW_ATL2_RPF_ET_TAG_SHIFT ); +} + +void hw_atl2_rpf_l3_v4_dest_addr_set (struct aq_hw_s *aq_hw,u32 filter,u32 val) +{ +u32 addr_set =6 + ((filter <4 ) ?0 :1 ); +u32 dword = filter %4 ; + +aq_hw_write_reg (aq_hw,HW_ATL2_RPF_L3_DA_DW_ADR (addr_set, dword), val); +} + +void hw_atl2_rpf_l3_v4_src_addr_set (struct aq_hw_s *aq_hw,u32 filter,u32 val) +{ +u32 addr_set =6 + ((filter <4 ) ?0 :1 ); +u32 dword = filter %4 ; + +aq_hw_write_reg (aq_hw,HW_ATL2_RPF_L3_SA_DW_ADR (addr_set, dword), val); +} + +void hw_atl2_rpf_l3_v6_dest_addr_set (struct aq_hw_s *aq_hw,u8 location, +u32 *ipv6_dst) +{ +int i; + +for (i =0 ; i <4 ; ++i) +aq_hw_write_reg (aq_hw, +HW_ATL2_RPF_L3_DA_DW_ADR (location,3 - i), + ipv6_dst[i]); +} + +void hw_atl2_rpf_l3_v6_src_addr_set (struct aq_hw_s *aq_hw,u8 location, +u32 *ipv6_src) +{ +int i; + +for (i =0 ; i <4 ; ++i) +aq_hw_write_reg (aq_hw, +HW_ATL2_RPF_L3_SA_DW_ADR (location,3 - i), + ipv6_src[i]); +} + +void hw_atl2_rpf_l3_v4_cmd_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V4_CMD_ADR (filter), +HW_ATL2_RPF_L3_V4_CMD_MSK , +HW_ATL2_RPF_L3_V4_CMD_SHIFT , val); +} + +void hw_atl2_rpf_l3_v6_cmd_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V6_CMD_ADR (filter), +HW_ATL2_RPF_L3_V6_CMD_MSK , +HW_ATL2_RPF_L3_V6_CMD_SHIFT , val); +} + +void hw_atl2_rpf_l3_v6_v4_select_set (struct aq_hw_s *aq_hw,u32 val) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V6_V4_SELECT_ADR , +HW_ATL2_RPF_L3_V6_V4_SELECT_MSK , +HW_ATL2_RPF_L3_V6_V4_SELECT_SHIFT , val); +} + +void hw_atl2_rpf_l3_v4_tag_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V4_TAG_ADR (filter), +HW_ATL2_RPF_L3_V4_TAG_MSK , +HW_ATL2_RPF_L3_V4_TAG_SHIFT , val); +} + +void hw_atl2_rpf_l3_v6_tag_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L3_V6_TAG_ADR (filter), +HW_ATL2_RPF_L3_V6_TAG_MSK , +HW_ATL2_RPF_L3_V6_TAG_SHIFT , val); +} + +void hw_atl2_rpf_l4_tag_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L4_TAG_ADR (filter), +HW_ATL2_RPF_L4_TAG_MSK , +HW_ATL2_RPF_L4_TAG_SHIFT , val); +} + +void hw_atl2_rpf_l4_cmd_set (struct aq_hw_s *aq_hw,u32 val,u32 filter) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_L4_CMD_ADR (filter), +HW_ATL2_RPF_L4_CMD_MSK , +HW_ATL2_RPF_L4_CMD_SHIFT , val); +} + +/* tsg */ +static void hw_atl2_clock_modif_value_set (struct aq_hw_s *aq_hw, +u32 clock_sel,u64 ns) +{ +aq_hw_write_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_MODIF_VAL_LSW ), + ns); +} + +void hw_atl2_tsg_clock_en (struct aq_hw_s *aq_hw, +u32 clock_sel,u32 clock_enable) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_CFG ), +HW_ATL2_TSG_CLOCK_EN_MSK , +HW_ATL2_TSG_CLOCK_EN_SHIFT , + clock_enable); +} + +void hw_atl2_tsg_clock_reset (struct aq_hw_s *aq_hw,u32 clock_sel) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_CFG ), +HW_ATL2_TSG_SYNC_RESET_MSK , +HW_ATL2_TSG_SYNC_RESET_SHIFT ,1 ); +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_CFG ), +HW_ATL2_TSG_SYNC_RESET_MSK , +HW_ATL2_TSG_SYNC_RESET_SHIFT ,0 ); +} + +u64 hw_atl2_tsg_clock_read (struct aq_hw_s *aq_hw,u32 clock_sel) +{ +return aq_hw_read_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel, +READ_CUR_NS_LSW )); +} + +void hw_atl2_tsg_clock_add (struct aq_hw_s *aq_hw,u32 clock_sel,u64 ns) +{ +hw_atl2_clock_modif_value_set (aq_hw, clock_sel, ns); +aq_hw_write_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_MODIF_CTRL ), +HW_ATL2_TSG_ADD_COUNTER_MSK ); +} + +void hw_atl2_tsg_clock_sub (struct aq_hw_s *aq_hw,u32 clock_sel,u64 ns) +{ +hw_atl2_clock_modif_value_set (aq_hw, clock_sel, ns); +aq_hw_write_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_MODIF_CTRL ), +HW_ATL2_TSG_SUBTRACT_COUNTER_MSK ); +} + +void hw_atl2_tsg_clock_increment_set (struct aq_hw_s *aq_hw, +u32 clock_sel,u32 ns,u32 fns) +{ +u32 nsfns = (ns &0xff ) | (fns &0xffffff00 ); + +aq_hw_write_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_INC_CFG ), + nsfns); +aq_hw_write_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel,CLOCK_MODIF_CTRL ), +HW_ATL2_TSG_LOAD_INC_CFG_MSK ); +} + +void hw_atl2_tsg_ext_isr_to_host_set (struct aq_hw_s *aq_hw,int on) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_GLB_CONTROL_2_ADR , +HW_ATL2_MIF_INTERRUPT_2_TO_ITR_MSK , +HW_ATL2_MIF_INTERRUPT_TO_ITR_SHIFT +2 , + !!on); +aq_hw_write_reg_bit (aq_hw,HW_ATL2_GLB_CONTROL_2_ADR , +HW_ATL2_EN_INTERRUPT_MIF2_TO_ITR_MSK , +HW_ATL2_EN_INTERRUPT_TO_ITR_SHIFT +2 , + !!on); +} + +void hw_atl2_tpb_tps_highest_priority_tc_enable_set (struct aq_hw_s *aq_hw, +u32 tps_highest_prio_tc_en) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TPB_HIGHEST_PRIO_TC_EN_ADR , +HW_ATL2_TPB_HIGHEST_PRIO_TC_EN_MSK , +HW_ATL2_TPB_HIGHEST_PRIO_TC_EN_SHIFT , + tps_highest_prio_tc_en); +} + +void hw_atl2_tpb_tps_highest_priority_tc_set (struct aq_hw_s *aq_hw, +u32 tps_highest_prio_tc) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TPB_HIGHEST_PRIO_TC_ADR , +HW_ATL2_TPB_HIGHEST_PRIO_TC_MSK , +HW_ATL2_TPB_HIGHEST_PRIO_TC_SHIFT , + tps_highest_prio_tc); +} + +void hw_atl2_tsg_gpio_isr_to_host_set (struct aq_hw_s *aq_hw, +int on,u32 clock_sel) +{ +aq_hw_write_reg_bit (aq_hw, +HW_ATL2_GLOBAL_HIGH_PRIO_INTERRUPT_1_MASK_ADR , + clock_sel ==1 ?HW_ATL2_TSG_TSG1_GPIO_INTERRUPT_MSK : +HW_ATL2_TSG_TSG0_GPIO_INTERRUPT_MSK , + clock_sel ==1 ?HW_ATL2_TSG_TSG1_GPIO_INTERRUPT_SHIFT : +HW_ATL2_TSG_TSG0_GPIO_INTERRUPT_SHIFT , + !!on); +} + +void hw_atl2_tsg_gpio_clear_status (struct aq_hw_s *aq_hw) +{ +aq_hw_read_reg (aq_hw,HW_ATL2_GLOBAL_INTERNAL_ALARMS_1_ADR ); +} + +void hw_atl2_tsg_gpio_input_event_info_get (struct aq_hw_s *aq_hw, +u32 clock_sel, +u32 *event_count, +u64 *event_ts) +{ +if (event_count) + *event_count =aq_hw_read_reg (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel, +EXT_CLK_COUNT )); + +if (event_ts) + *event_ts =aq_hw_read_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clock_sel, +GPIO_EVENT_TS_LSW )); +} + +void hw_atl2_tsg_ptp_gpio_gen_pulse (struct aq_hw_s *aq_hw,u32 clk_sel, +u64 ts,u32 period,u32 hightime) +{ +u32 val = (HW_ATL2_TSG_GPIO_EVENT_MODE_SET_ON_TIME << + (HW_ATL2_TSG_GPIO_EVENT_MODE_SHIFT - +HW_ATL2_TSG_GPIO_OUTPUT_EN_SHIFT )) | + (HW_ATL2_TSG_GPIO_GEN_OUTPUT_EN_MSK ) | + (HW_ATL2_TSG_GPIO_OUTPUT_EN_MSK ); + +if (ts !=0 ) { +aq_hw_write_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clk_sel, +GPIO_EVENT_GEN_TS_LSW ), + ts); + +aq_hw_write_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clk_sel, +GPIO_EVENT_HIGH_TIME_LSW ), + hightime); + +aq_hw_write_reg64 (aq_hw, +HW_ATL2_TSG_REG_ADR (clk_sel, +GPIO_EVENT_LOW_TIME_LSW ), + (period - hightime)); + } + +aq_hw_write_reg_bit (aq_hw, +HW_ATL2_TSG_REG_ADR (clk_sel,GPIO_EVENT_GEN_CFG ), +HW_ATL2_TSG_GPIO_EVENT_MODE_MSK | +HW_ATL2_TSG_GPIO_OUTPUT_EN_MSK | +HW_ATL2_TSG_GPIO_GEN_OUTPUT_EN_MSK , +HW_ATL2_TSG_GPIO_OUTPUT_EN_SHIFT , + (!ts ?0 : val)); +} + +void hw_atl2_rpf_rx_desc_timestamp_req_set (struct aq_hw_s *aq_hw,u32 request, +u32 descriptor) +{ +aq_hw_write_reg_bit (aq_hw, +HW_ATL2_RPF_TIMESTAMP_REQ_DESCD_ADR (descriptor), +HW_ATL2_RPF_TIMESTAMP_REQ_DESCD_MSK , +HW_ATL2_RPF_TIMESTAMP_REQ_DESCD_SHIFT , request); +} +/* TX */ void hw_atl2_tpb_tx_tc_q_rand_map_en_set(struct aq_hw_s *aq_hw,
@@ -93,6 +379,30 @@ void hw_atl2_reg_tx_intr_moder_ctrl_set(struct aq_hw_s *aq_hw, tx_intr_moderation_ctl); } +void hw_atl2_tdm_tx_desc_timestamp_writeback_en_set (struct aq_hw_s *aq_hw, +u32 enable,u32 descriptor) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_DESCD_TS_WRB_EN_ADR (descriptor), +HW_ATL2_TDM_DESCD_TS_WRB_EN_MSK , +HW_ATL2_TDM_DESCD_TS_WRB_EN_SHIFT , enable); +} + +void hw_atl2_tdm_tx_desc_timestamp_en_set (struct aq_hw_s *aq_hw,u32 enable, +u32 descriptor) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_DESCD_TS_EN_ADR (descriptor), +HW_ATL2_TDM_DESCD_TS_EN_MSK , +HW_ATL2_TDM_DESCD_TS_EN_SHIFT , enable); +} + +void hw_atl2_tdm_tx_desc_avb_en_set (struct aq_hw_s *aq_hw,u32 enable, +u32 descriptor) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_DESCD_AVB_EN_ADR (descriptor), +HW_ATL2_TDM_DESCD_AVB_EN_MSK , +HW_ATL2_TDM_DESCD_AVB_EN_SHIFT , enable); +} +void hw_atl2_tps_tx_pkt_shed_data_arb_mode_set (struct aq_hw_s *aq_hw,const u32 data_arb_mode) {
@@ -122,6 +432,20 @@ void hw_atl2_tps_tx_pkt_shed_tc_data_weight_set(struct aq_hw_s *aq_hw, weight); } +void hw_atl2_tdm_tx_data_read_req_limit_set (struct aq_hw_s *aq_hw,u32 limit) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_TX_DATA_RD_REQ_LIMIT_ADR , +HW_ATL2_TDM_TX_DATA_RD_REQ_LIMIT_MSK , +HW_ATL2_TDM_TX_DATA_RD_REQ_LIMIT_SHIFT , limit); +} + +void hw_atl2_tdm_tx_desc_read_req_limit_set (struct aq_hw_s *aq_hw,u32 limit) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TDM_TX_DESC_RD_REQ_LIMIT_ADR , +HW_ATL2_TDM_TX_DESC_RD_REQ_LIMIT_MSK , +HW_ATL2_TDM_TX_DESC_RD_REQ_LIMIT_SHIFT , limit); +} +u32 hw_atl2_get_hw_version (struct aq_hw_s *aq_hw) {return aq_hw_read_reg (aq_hw,HW_ATL2_FPGA_VER_ADR );
@@ -164,6 +488,13 @@ void hw_atl2_rpf_act_rslvr_section_en_set(struct aq_hw_s *aq_hw, u32 sections) sections); } +u32 hw_atl2_rpf_act_rslvr_section_en_get (struct aq_hw_s *aq_hw) +{ +return aq_hw_read_reg_bit (aq_hw,HW_ATL2_RPF_REC_TAB_EN_ADR , +HW_ATL2_RPF_REC_TAB_EN_MSK , +HW_ATL2_RPF_REC_TAB_EN_SHIFT ); +} +void hw_atl2_mif_shared_buf_get (struct aq_hw_s *aq_hw,int offset,u32 *data,int len) {
@@ -232,3 +563,31 @@ void hw_atl2_mif_host_req_int_clr(struct aq_hw_s *aq_hw, u32 val)return aq_hw_write_reg (aq_hw,HW_ATL2_MCP_HOST_REQ_INT_CLR_ADR , val); } + +void hw_atl2_tsg1_ext_gpio_ts_input_select_set (struct aq_hw_s *aq_hw, +u32 tsg_gpio_ts_select) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG1_EXT_GPIO_TS_INPUT_SEL_ADR , +HW_ATL2_TSG1_EXT_GPIO_TS_INPUT_SEL_MSK , +HW_ATL2_TSG1_EXT_GPIO_TS_INPUT_SEL_SHIFT , + tsg_gpio_ts_select); +} + +void hw_atl2_tsg0_ext_gpio_ts_input_select_set (struct aq_hw_s *aq_hw, +u32 gpio_ts_in_select) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TSG0_EXT_GPIO_TS_INPUT_SEL_ADR , +HW_ATL2_TSG0_EXT_GPIO_TS_INPUT_SEL_MSK , +HW_ATL2_TSG0_EXT_GPIO_TS_INPUT_SEL_SHIFT , + gpio_ts_in_select); +} + +void hw_atl2_gpio_special_mode_set (struct aq_hw_s *aq_hw, +u32 gpio_special_mode, +u32 pin) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_GPIO_PIN_SPEC_MODE_ADR (pin), +HW_ATL2_GPIO_PIN_SPEC_MODE_MSK , +HW_ATL2_GPIO_PIN_SPEC_MODE_SHIFT , + gpio_special_mode); +}
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.h +105 -2
149 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh_internal.h +199 -5
238 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH v2 5/9 net: atlantic: add AQC113 filter data structures and firmware query and firmware query firmware query
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Add filter infrastructure for AQC113 hardware:
- Define L3 (IPv4/IPv6), L4 (TCP/UDP/SCTP), and combined L3L4 filter structures with reference-counted sharing support.
- Define tag policy structure for ethertype filter management.
- Add RPF L3/L4 command bit definitions for filter programming.
- Add filter count constants for L3L4, L3V4, L4, VLAN, and ethertype.
- Extend hw_atl2_priv with filter arrays, base indices, and counts discovered from firmware.
Query filter capabilities from firmware shared memory at init time to discover available L2/L3/L4/VLAN/ethertype filter resources and ART (Action Resolver Table) configuration.
Add hardware register dump utility for AQC113 debug support.
--- .../atlantic/hw_atl2/hw_atl2_internal.h | 63 +++++++++++++++++++ .../aquantia/atlantic/hw_atl2/hw_atl2_utils.c | 33 ++++++++++ .../aquantia/atlantic/hw_atl2/hw_atl2_utils.h | 5 ++ .../atlantic/hw_atl2/hw_atl2_utils_fw.c | 52 +++++++++++++++ 4 files changed, 153 insertions(+)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +63 -0
@@ -84,6 +84,18 @@ enum HW_ATL2_RPF_ART_INDEX { HW_ATL_VLAN_MAX_FILTERS, }; +#define HW_ATL2_RPF_L3_CMD_EN BIT(0) +#define HW_ATL2_RPF_L3_CMD_SA_EN BIT(1) +#define HW_ATL2_RPF_L3_CMD_DA_EN BIT(2) +#define HW_ATL2_RPF_L3_CMD_PROTO_EN BIT(3) +#define HW_ATL2_RPF_L3_V6_CMD_EN BIT(0x10) +#define HW_ATL2_RPF_L3_V6_CMD_SA_EN BIT(0x11) +#define HW_ATL2_RPF_L3_V6_CMD_DA_EN BIT(0x12) +#define HW_ATL2_RPF_L3_V6_CMD_PROTO_EN BIT(0x13) +#define HW_ATL2_RPF_L4_CMD_EN BIT(0) +#define HW_ATL2_RPF_L4_CMD_DP_EN BIT(1) +#define HW_ATL2_RPF_L4_CMD_SP_EN BIT(2) +#define HW_ATL2_ACTION (ACTION ,RSS ,INDEX ,VALID ) \ ((((ACTION) & 0x3U) << 8) | \ (((RSS) & 0x1U) << 7) | \
@@ -94,6 +106,12 @@ enum HW_ATL2_RPF_ART_INDEX {#define HW_ATL2_ACTION_DISABLE HW_ATL2_ACTION(0, 0, 0, 0)#define HW_ATL2_ACTION_ASSIGN_QUEUE (QUEUE ) HW_ATL2_ACTION(1, 0, (QUEUE), 1)#define HW_ATL2_ACTION_ASSIGN_TC (TC ) HW_ATL2_ACTION(1, 1, (TC), 1) +#define HW_ATL2_RPF_L3L4_FILTERS 8 +#define HW_ATL2_RPF_L3V4_FILTERS 8 +#define HW_ATL2_RPF_L4_FILTERS 8 +#define HW_ATL2_RPF_VLAN_FILTERS 16 +#define HW_ATL2_RPF_ETYPE_FILTERS 16 +#define HW_ATL2_RPF_ETYPE_TAGS 7enum HW_ATL2_RPF_RSS_HASH_TYPE {HW_ATL2_RPF_RSS_HASH_TYPE_NONE =0 ,
@@ -119,9 +137,54 @@ enum HW_ATL2_RPF_RSS_HASH_TYPE {#define HW_ATL_MCAST_FLT_ANY_TO_HOST 0x00010FFFU +struct hw_atl2_l3_filter { +u8 proto; +u8 usage; +u32 cmd; +u32 srcip[4 ]; +u32 dstip[4 ]; +}; + +struct hw_atl2_l4_filter { +u8 usage; +u32 cmd; +u16 sport; +u16 dport; +}; + +struct hw_atl2_l3l4_filter { +s8 l3_index; +s8 l4_index; +u8 ipv6; +}; + +struct hw_atl2_tag_policy { +u16 action; +u16 usage; +}; +struct hw_atl2_priv { +struct hw_atl2_l3_filter l3_v4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l3_filter l3_v6_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l4_filter l4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_l3l4_filter l3l4_filters[HW_ATL2_RPF_L3L4_FILTERS ]; +struct hw_atl2_tag_policy etype_policy[HW_ATL2_RPF_ETYPE_FILTERS ];struct statistics_s last_stats;unsigned int art_base_index; +unsigned int art_count; +unsigned int l2_filters_base_index; +unsigned int l2_filter_count; +unsigned int etype_filter_base_index; +unsigned int etype_filter_count; +unsigned int etype_filter_tag_top; +unsigned int vlan_filter_base_index; +unsigned int vlan_filter_count; +unsigned int l3_v4_filter_base_index; +unsigned int l3_v4_filter_count; +unsigned int l3_v6_filter_base_index; +unsigned int l3_v6_filter_count; +unsigned int l4_filter_base_index; +unsigned int l4_filter_count; };#endif /* HW_ATL2_INTERNAL_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c +33 -0
@@ -128,3 +128,36 @@ int hw_atl2_utils_soft_reset(struct aq_hw_s *self) err_exit:return err; } + +static const u32 hw_atl2_utils_hw_mac_regs[] = { +0x00005580U ,0x00005590U ,0x000055B0U ,0x000055B4U , +0x000055C0U ,0x00005B00U ,0x00005B04U ,0x00005B08U , +0x00005B0CU ,0x00005B10U ,0x00005B14U ,0x00005B18U , +0x00005B1CU ,0x00005B20U ,0x00005B24U ,0x00005B28U , +0x00005B2CU ,0x00005B30U ,0x00005B34U ,0x00005B38U , +0x00005B3CU ,0x00005B40U ,0x00005B44U ,0x00005B48U , +0x00005B4CU ,0x00005B50U ,0x00005B54U ,0x00005B58U , +0x00005B5CU ,0x00005B60U ,0x00005B64U ,0x00005B68U , +0x00005B6CU ,0x00005B70U ,0x00005B74U ,0x00005B78U , +0x00005B7CU ,0x00007C00U ,0x00007C04U ,0x00007C08U , +0x00007C0CU ,0x00007C10U ,0x00007C14U ,0x00007C18U , +0x00007C1CU ,0x00007C20U ,0x00007C40U ,0x00007C44U , +0x00007C48U ,0x00007C4CU ,0x00007C50U ,0x00007C54U , +0x00007C58U ,0x00007C5CU ,0x00007C60U ,0x00007C80U , +0x00007C84U ,0x00007C88U ,0x00007C8CU ,0x00007C90U , +0x00007C94U ,0x00007C98U ,0x00007C9CU ,0x00007CA0U , +0x00007CC0U ,0x00007CC4U ,0x00007CC8U ,0x00007CCCU , +0x00007CD0U ,0x00007CD4U ,0x00007CD8U ,0x00007CDCU , +}; + +int hw_atl2_utils_hw_get_regs (struct aq_hw_s *self, +const struct aq_hw_caps_s *aq_hw_caps, +u32 *regs_buff) +{ +unsigned int i; + +for (i =0 ; i < aq_hw_caps->mac_regs_count; i++) + regs_buff[i] =aq_hw_read_reg (self, + hw_atl2_utils_hw_mac_regs[i]); +return 0 ; +}
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.h +5 -0
@@ -626,10 +626,15 @@ int hw_atl2_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops);int hw_atl2_utils_soft_reset (struct aq_hw_s *self); +int hw_atl2_utils_hw_get_regs (struct aq_hw_s *self, +const struct aq_hw_caps_s *aq_hw_caps, +u32 *regs_buff); +u32 hw_atl2_utils_get_fw_version (struct aq_hw_s *self);int hw_atl2_utils_get_action_resolve_table_caps (struct aq_hw_s *self,u8 *base_index,u8 *count); +int hw_atl2_utils_get_filter_caps (struct aq_hw_s *self);extern const struct aq_fw_ops aq_a2_fw_ops;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +52 -0
64 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH v2 6/9 net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Implement complete RX filter management for AQC113 hardware:
- Add tag-based filter policy with reference-counted sharing, allowing multiple filter rules to share the same L3 or L4 hardware filter when their match criteria are identical.
- Implement L3 (IPv4/IPv6 source/destination address and protocol) filter find, get (program HW and increment refcount), and put (decrement refcount and clear HW when last user releases).
- Implement L4 (TCP/UDP/SCTP source/destination port) filter management with the same find/get/put pattern.
- Add combined L3L4 filter configuration that translates legacy aq_rx_filter_l3l4 commands into AQC113 separate L3+L4 filter programming with Action Resolver Table (ART) entries.
- Add L2 ethertype filter set/clear with tag-based ART integration.
- Add MAC address setup using firmware-provided L2 filter base index.
Update hardware initialization:
- Use firmware-reported ART section base and count instead of hardcoded 0xFFFF section enable.
- Enable L3 v6/v4 select mode for simultaneous IPv4/IPv6 filtering.
- Initialize L3L4 filter indices to -1 on reset.
Wire up hw_filter_l2_set, hw_filter_l2_clear, hw_filter_l3l4_set, hw_set_mac_address, hw_get_version, and hw_get_regs in hw_atl2_ops.
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 2 + .../aquantia/atlantic/hw_atl2/hw_atl2.c | 582 +++++++++++++++++- 2 files changed, 580 insertions(+), 4 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +2 -0
@@ -236,6 +236,8 @@ struct aq_hw_ops {int (*hw_stop)(struct aq_hw_s *self); +u32 (*hw_get_version)(struct aq_hw_s *self); +int (*hw_ring_tx_init)(struct aq_hw_s *self,struct aq_ring_s *aq_ring,struct aq_ring_param_s *aq_ring_param);
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +578 -4
654 lines not on this page · raw message
Signature · 1 line
2.43.0
Paolo Abeni
maintainerRe: [PATCH net-next v2 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
This change implements RX filter management for the AQC113, adding reference-counted sharing of L3/L4 hardware slots, L2 ethertype programming with ART tags, firmware-reported base/count usage, and a MAC address helper that targets the FW-supplied l2_filters_base_index.
[Low]
The subject line contains a duplicated/triplicated phrase:
net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
drivers/net/ethernet/aquantia/atlantic/aq_hw.h struct aq_hw_ops { · line 240
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +2
-0@@ -236,6 +236,8 @@ struct aq_hw_ops {int (*hw_stop)(struct aq_hw_s *self); +u32 (*hw_get_version)(struct aq_hw_s *self); +
[Low]
Is there any in-tree caller of ->hw_get_version()? A search across the atlantic driver and the rest of the tree does not show one, and the other chip ops tables (hw_atl_a0, hw_atl_b0) leave this slot NULL. If no caller is introduced in this series, would it make sense to drop this hook for now, or add it together with the consumer?
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +0
-0
[ ... ]
Quoted 25 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-2@@ -380,6 +422,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;struct hw_atl2_priv *priv = self->priv; +u32 art_first_sec, art_last_sec; +u32 art_sections; +u32 art_mask;u16 action;u8 index;int i;@@ -394,9 +439,14 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)* REC entry is used for further processing. If multiple entries match, * the lowest REC entry, Action field will be selected. */ -hw_atl2_rpf_act_rslvr_section_en_set (self,0xFFFF ); + art_last_sec = priv->art_base_index /8 + priv->art_count /8 ; + art_first_sec = priv->art_base_index /8 ; + art_mask = (BIT (art_last_sec) -1 ) - (BIT (art_first_sec) -1 ); + art_sections =hw_atl2_rpf_act_rslvr_section_en_get (self) | art_mask; +hw_atl2_rpf_act_rslvr_section_en_set (self, art_sections); +hw_atl2_rpf_l3_v6_v4_select_set (self,1 );hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , -HW_ATL2_MAC_UC ); + priv->l2_filters_base_index);hw_atl2_rpfl2_bc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC );
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self) · line 586
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +4
-0@@ -530,6 +580,35 @@ static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self)return aq_hw_err_from_flags (self); } +static int hw_atl2_hw_mac_addr_set (struct aq_hw_s *self,const u8 *mac_addr) +{ +struct hw_atl2_priv *priv = self->priv; +u32 location = priv->l2_filters_base_index;
[High]
Does the initial MAC programming still land on the right slot when firmware reports a non-zero l2_filters_base_index?
The new .hw_set_mac_address and hw_atl2_hw_init_new_rx_filters() both operate on priv->l2_filters_base_index. However, hw_atl2_hw_init() still calls hw_atl_b0_hw_mac_addr_set(self, mac_addr) directly, and that helper hardcodes HW_ATL_B0_MAC (= 0). At the same time hw_atl2_hw_init_rx_path() enables only slot 0 via:
for (i = HW_ATL2_MAC_MAX; i--;) {
hw_atl_rpfl2_uc_flr_en_set(self, (i == 0U) ? 1U : 0U, i);
...
}If FW reports l2_filters_base_index != 0, the tagged slot has no MAC programmed and the enabled slot (0) carries the wrong tag. Should hw_atl2_hw_init() call hw_atl2_hw_mac_addr_set() instead, or should the enable/base bookkeeping be reconciled?
[ ... ]
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +0
-0@@ -767,6 +846,496 @@ static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self)return &self->curr_stats; }
[ ... ]
Quoted 23 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +23
-0+static int hw_atl2_new_fl3l4_find_l3 (struct aq_hw_s *self, +struct hw_atl2_l3_filter *l3) +{ +struct hw_atl2_priv *priv = self->priv; +struct hw_atl2_l3_filter *l3_filters; +int i, first, last; + +if (l3->cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) { + l3_filters = priv->l3_v6_filters; + first = priv->l3_v6_filter_base_index; + last = priv->l3_v6_filter_base_index + + priv->l3_v6_filter_count; + }else { + l3_filters = priv->l3_v4_filters; + first = priv->l3_v4_filter_base_index; + last = priv->l3_v4_filter_base_index + + priv->l3_v4_filter_count; + } +for (i = first; i < last; i++) { +if (hw_atl2_rxf_l3_is_equal (&l3_filters[i], l3)) +return i; + } +
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 911
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+for (i = first; i < last; i++) { +u32 l3_enable_mask =HW_ATL2_RPF_L3_CMD_EN | +HW_ATL2_RPF_L3_V6_CMD_EN ; + +if (!(l3_filters[i].cmd & l3_enable_mask)) +return i; + } + +return -ENOSPC ; +}
[High]
Can this walk off the end of the fixed-size arrays?
priv->l3_v4_filters, priv->l3_v6_filters, and priv->l4_filters are all sized HW_ATL2_RPF_L3L4_FILTERS (= 8). first/last come from the firmware-reported filter_caps_s, where base_index is a 4-bit field (0..15) and the counts are also 4 bits.
Looking at hw_atl2_utils_get_filter_caps(), l3_v4_filter_count and l4_filter_count are clamped with min_t(..., HW_ATL2_RPF_L3{V4,4}_FILTERS
- 1), but l3_v6_filter_count does not appear to be clamped at all, and none of the *_base_index fields are clamped. A FW image reporting l3_v6_filter_count >= 8, or any base_index such that base + count > 8, would make this loop read priv->l3_v6_filters[i].cmd past the end, and hw_atl2_rxf_l3_get() / hw_atl2_rxf_l4_get() would write cmd/srcip/dstip/ sport/dport past the end.
Should all three counts be clamped to HW_ATL2_RPF_L3L4_FILTERS, and base_index + count bounded to HW_ATL2_RPF_L3L4_FILTERS?
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +9
-0+ +static void hw_atl2_rxf_l3_get (struct aq_hw_s *self, +struct hw_atl2_l3_filter *l3,int idx, +const struct hw_atl2_l3_filter *_l3) +{ +int i; + + l3->usage++; +if (l3->usage ==1 ) {
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 930
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+ l3->cmd = _l3->cmd; +for (i =0 ; i <4 ; i++) { + l3->srcip[i] = _l3->srcip[i]; + l3->dstip[i] = _l3->dstip[i]; + } + l3->proto = _l3->proto; + +if (l3->cmd &HW_ATL2_RPF_L3_CMD_EN ) { +hw_atl2_rpf_l3_v4_cmd_set (self, l3->cmd, idx); +hw_atl2_rpf_l3_v4_tag_set (self, idx +1 , idx);
[High]
Can the per-filter tag value be silently truncated here?
HW_ATL2_RPF_L3_V{4,6}_TAG_MSK and HW_ATL2_RPF_L4_TAG_MSK are 3-bit fields (max value 7), and the helpers aq_hw_write_reg_bit() mask the value to the field width. idx is in [base_index, base_index + count), and with l3_v6_filter_count unclamped (and no clamp on any base_index), idx + 1 can exceed 7 and quietly collapse to a tag used by another slot.
When two slots end up with the same 3-bit tag, the ART input_tag/mask comparison can pick the lowest matching record, so a drop rule could match traffic intended to be forwarded (or vice versa) without any diagnostic. Should idx + 1 be range-checked against the mask width, or the counts clamped so idx + 1 <= 7?
Quoted 18 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +18
-0+hw_atl2_rpf_l3_v4_dest_addr_set (self, + idx, + l3->dstip[0 ]); +hw_atl2_rpf_l3_v4_src_addr_set (self, + idx, + l3->srcip[0 ]); + }else { +hw_atl2_rpf_l3_v6_cmd_set (self, l3->cmd, idx); +hw_atl2_rpf_l3_v6_tag_set (self, idx +1 , idx); +hw_atl2_rpf_l3_v6_dest_addr_set (self, + idx, + l3->dstip); +hw_atl2_rpf_l3_v6_src_addr_set (self, + idx, + l3->srcip); + } + } +}
[ ... ]
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +7
-0+static int hw_atl2_new_fl3l4_configure (struct aq_hw_s *self, +struct aq_rx_filter_l3l4 *data) +{ +struct hw_atl2_priv *priv = self->priv; +s8 old_l3_index = priv->l3l4_filters[data->location].l3_index; +s8 old_l4_index = priv->l3l4_filters[data->location].l4_index; +u8 old_ipv6 = priv->l3l4_filters[data->location].ipv6;
[ ... ]
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +5
-0+/* find L3 and L4 filters */ +if (l3.cmd & (HW_ATL2_RPF_L3_CMD_EN |HW_ATL2_RPF_L3_V6_CMD_EN )) { + l3_idx =hw_atl2_new_fl3l4_find_l3 (self, &l3); +if (l3_idx <0 ) +return l3_idx;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 1118
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+ +if (l3.cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) + l3_filters = priv->l3_v6_filters; +else + l3_filters = priv->l3_v4_filters; + +if (priv->l3l4_filters[data->location].l3_index != l3_idx) +hw_atl2_rxf_l3_get (self, &l3_filters[l3_idx], + l3_idx, &l3); + }
[High]
Does this guard correctly handle a family switch at the same location?
priv->l3_v4_filters[] and priv->l3_v6_filters[] are separate 8-entry arrays. When an existing v4 rule at data->location is reconfigured to v6 (or the reverse), hw_atl2_new_fl3l4_find_l3() searches the new family's array and is likely to return 0 as the first free slot. If the previously stored l3_index was also 0, then:
if (priv->l3l4_filters[data->location].l3_index != l3_idx) /* 0 != 0 */
hw_atl2_rxf_l3_get(...); /* skipped */hw_atl2_rxf_l3_get() is skipped, so priv->l3_v6_filters[0].cmd stays 0 and no v6 HW registers are written. Later, hw_atl2_hw_fl3l4_set() reads ipv6 = 1 and l3_index = 0, picks l3 = &priv->l3_v6_filters[0], finds (l3->cmd & V6_CMD_EN) == 0, and programs the ART tag down the V4 path while the user asked for V6.
Would it be correct to include the family in the guard, or to just call hw_atl2_rxf_l3_get() unconditionally (it is already idempotent via the usage == 1 check)?
Quoted 21 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +21
-0+ +if (old_l3_index !=-1 ) { +if (old_ipv6) + l3_filters = priv->l3_v6_filters; +else + l3_filters = priv->l3_v4_filters; + +if (!(hw_atl2_rxf_l3_is_equal (&l3, + &l3_filters[old_l3_index]))) { +hw_atl2_rxf_l3_put (self, + &l3_filters[old_l3_index], + old_l3_index); + } + } +if (l3.cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) + priv->l3l4_filters[data->location].ipv6 =1 ; +else + priv->l3l4_filters[data->location].ipv6 =0 ; + priv->l3l4_filters[data->location].l3_index = l3_idx; + +if (l4.cmd &HW_ATL2_RPF_L4_CMD_EN ) {
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 1149
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+ l4_idx =hw_atl2_new_fl3l4_find_l4 (self, &l4); +if (l4_idx <0 ) { +/* Undo L3 acquisition */ +if (l3_idx >=0 ) { +hw_atl2_rxf_l3_put (self, &l3_filters[l3_idx], l3_idx); + priv->l3l4_filters[data->location].l3_index = old_l3_index; + priv->l3l4_filters[data->location].ipv6 = old_ipv6; + } +return -EINVAL ; + }
[High, High]
Does the L4-failure undo path correctly unwind L3 state in two distinct ways?
First, cross-family pointer aliasing. Before the L4 find, l3_filters points to the new family's array (from the earlier block). The intermediate "if (old_l3_index != -1)" block unconditionally reassigns l3_filters to the old family based on old_ipv6. By the time the undo runs, l3_filters still points to the old family's array, but l3_idx is a new-family index:
hw_atl2_rxf_l3_put(self, &l3_filters[l3_idx], l3_idx);
For a cross-family reconfigure this decrements the wrong filter (and may clear its HW via hw_atl2_rpf_l3_v{4,6}_cmd_set(self, 0, idx)) while the actually-acquired new-family filter's refcount is leaked. Should the undo re-derive l3_filters from the new family before calling put?
Second, the old L3 filter is not re-acquired. Earlier in the function, if old_l3_index != -1 and !is_equal(new, old), the old filter has already had hw_atl2_rxf_l3_put() called on it, potentially dropping usage to 0 and clearing HW. The undo block restores l3_index = old and ipv6 = old_ipv6, but does not restore the refcount or HW state of the old filter. Would the old filter need a matching rxf_l3_get() call here to keep priv->l3l4_filters[location] consistent with the actual HW/refcount state?
[ ... ]
Quoted 3 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +3
-0+static int hw_atl2_hw_fl3l4_set (struct aq_hw_s *self, +struct aq_rx_filter_l3l4 *data) +{
[ ... ]
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +4
-0+ res =hw_atl2_new_fl3l4_configure (self, data); +if (res) +return res; +
[ ... ]
Quoted 1 line
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +1
-0+if (!(data->cmd &HW_ATL_RX_ENABLE_FLTR_L3L4 )) {
[ ... ]
Quoted 3 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +3
-0+return 0 ; + } +
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 1246
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +8
-0+if (data->cmd & (HW_ATL_RX_HOST <<HW_ATL2_RPF_L3_L4_ACTF_SHIFT )) + action =HW_ATL2_ACTION_ASSIGN_QUEUE ((data->cmd & +HW_ATL2_RPF_L3_L4_RXQF_MSK ) >> +HW_ATL2_RPF_L3_L4_RXQF_SHIFT ); +else if (data->cmd) + action =HW_ATL2_ACTION_DROP ; +else + action =HW_ATL2_ACTION_DISABLE ;
[Low]
Can the final "else action = HW_ATL2_ACTION_DISABLE" branch actually be reached? The function has already returned early for the case where HW_ATL_RX_ENABLE_FLTR_L3L4 is clear, so at this point data->cmd always has at least that bit set and is non-zero, which means "else if (data->cmd)" always fires. Was a different condition intended here?
[ ... ]
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +1
-1@@ -825,7 +1394,7 @@ static int hw_atl2_hw_vlan_ctrl(struct aq_hw_s *self, bool enable)const struct aq_hw_ops hw_atl2_ops = { .hw_soft_reset = hw_atl2_utils_soft_reset, .hw_prepare = hw_atl2_utils_initfw, - .hw_set_mac_address = hw_atl_b0_hw_mac_addr_set, + .hw_set_mac_address = hw_atl2_hw_mac_addr_set,
[ ... ]
Signature · 1 line
This is an AI-generated review.
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next v2 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
Quoted 9 lines · Paolo Abeni
net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
This change implements RX filter management for the AQC113, adding reference-counted sharing of L3/L4 hardware slots, L2 ethertype programming with ART tags, firmware-reported base/count usage, and a MAC address helper that targets the FW-supplied
l2_filters_base_index.[Low]
The subject line contains a duplicated/triplicated phrase:
Fixed in v3.
Quoted 14 lines
net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +2
-0@@ -236,6 +236,8 @@ struct aq_hw_ops {int (*hw_stop)(struct aq_hw_s *self); +u32 (*hw_get_version)(struct aq_hw_s *self); +
Quoted 6 lines
[Low]
Is there any in-tree caller of ->hw_get_version()? A search across the atlantic driver and the rest of the tree does not show one, and the other chip ops tables (hw_atl_a0,hw_atl_b0) leave this slot NULL. If no caller is introduced in this series, would it make sense to drop this hook for now, or add it together with the consumer?
Correct — hw_get_version has no caller anywhere in this series. Will drop the op from aq_hw_ops and the assignment from hw_atl2_ops in v3 and reintroduce it alongside its first consumer.
Quoted 60 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +14
-2@@ -380,6 +422,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;struct hw_atl2_priv *priv = self->priv; +u32 art_first_sec, art_last_sec; +u32 art_sections; +u32 art_mask;u16 action;u8 index;int i;@@ -394,9 +439,14 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)* REC entry is used for further processing. If multiple entries match, * the lowest REC entry, Action field will be selected. */ -hw_atl2_rpf_act_rslvr_section_en_set (self,0xFFFF ); + art_last_sec = priv->art_base_index /8 + priv->art_count /8 ; + art_first_sec = priv->art_base_index /8 ; + art_mask = (BIT (art_last_sec) -1 ) - (BIT (art_first_sec) -1 ); + art_sections =hw_atl2_rpf_act_rslvr_section_en_get (self) | art_mask; +hw_atl2_rpf_act_rslvr_section_en_set (self, art_sections); +hw_atl2_rpf_l3_v6_v4_select_set (self,1 );hw_atl2_rpfl2_uc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC , -HW_ATL2_MAC_UC ); + priv->l2_filters_base_index);hw_atl2_rpfl2_bc_flr_tag_set (self,HW_ATL2_RPF_TAG_BASE_UC );@@ -530,6 +580,35 @@ static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self)return aq_hw_err_from_flags (self); } +static int hw_atl2_hw_mac_addr_set (struct aq_hw_s *self,const u8 *mac_addr) +{ +struct hw_atl2_priv *priv = self->priv; +u32 location = priv->l2_filters_base_index;[High]
Does the initial MAC programming still land on the right slot when firmware reports a non-zerol2_filters_base_index?The new .hw_set_mac_address and
hw_atl2_hw_init_new_rx_filters()both operate onpriv->l2_filters_base_index. However,hw_atl2_hw_init()still callshw_atl_b0_hw_mac_addr_set(self, mac_addr)directly, and that helper hardcodesHW_ATL_B0_MAC(= 0). At the same timehw_atl2_hw_init_rx_path()enables only slot 0 via:for (i = HW_ATL2_MAC_MAX; i--;) { hw_atl_rpfl2_uc_flr_en_set(self, (i == 0U) ? 1U : 0U, i); ... }
Quoted 5 lines
If FW reports
l2_filters_base_index!= 0, the tagged slot has no MAC programmed and the enabled slot (0) carries the wrong tag. Shouldhw_atl2_hw_init()callhw_atl2_hw_mac_addr_set()instead, or should the enable/base bookkeeping be reconciled?
Fixed in v3: hw_atl2_hw_init() now calls hw_atl2_hw_mac_addr_set()
which writes the MAC to priv->l2_filters_base_index, and hw_atl2_hw_init_rx_path() enables slot priv->l2_filters_base_index rather than hardcoding slot 0. All three — enabled slot, MAC address, and UC tag — are consistent on the firmware-reported location.
Quoted 60 lines
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +33
-0@@ -767,6 +846,496 @@ static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self)return &self->curr_stats; } +static int hw_atl2_new_fl3l4_find_l3 (struct aq_hw_s *self, +struct hw_atl2_l3_filter *l3) +{ +struct hw_atl2_priv *priv = self->priv; +struct hw_atl2_l3_filter *l3_filters; +int i, first, last; + +if (l3->cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) { + l3_filters = priv->l3_v6_filters; + first = priv->l3_v6_filter_base_index; + last = priv->l3_v6_filter_base_index + + priv->l3_v6_filter_count; + }else { + l3_filters = priv->l3_v4_filters; + first = priv->l3_v4_filter_base_index; + last = priv->l3_v4_filter_base_index + + priv->l3_v4_filter_count; + } +for (i = first; i < last; i++) { +if (hw_atl2_rxf_l3_is_equal (&l3_filters[i], l3)) +return i; + } + +for (i = first; i < last; i++) { +u32 l3_enable_mask =HW_ATL2_RPF_L3_CMD_EN | +HW_ATL2_RPF_L3_V6_CMD_EN ; + +if (!(l3_filters[i].cmd & l3_enable_mask)) +return i; + } + +return -ENOSPC ; +}[High]
Can this walk off the end of the fixed-size arrays?
priv->l3_v4_filters,priv->l3_v6_filters, andpriv->l4_filtersare all sizedHW_ATL2_RPF_L3L4_FILTERS(= 8). first/last come from the firmware-reportedfilter_caps_s, wherebase_indexis a 4-bit field (0..15) and the counts are also 4 bits.Looking at
hw_atl2_utils_get_filter_caps(),l3_v4_filter_countandl4_filter_countare clamped with min_t(..., HW_ATL2_RPF_L3{V4,4}_FILTERS
- 1), butl3_v6_filter_countdoes not appear to be clamped at all, and none of the*_base_indexfields are clamped. A FW image reportingl3_v6_filter_count>= 8, or anybase_indexsuch that base + count > 8, would make this loop read priv->l3_v6_filters[i].cmd past the end, andhw_atl2_rxf_l3_get()/hw_atl2_rxf_l4_get()would write cmd/srcip/dstip/ sport/dport past the end.
Quoted 2 lines
Should all three counts be clamped to
HW_ATL2_RPF_L3L4_FILTERS, andbase_index+ count bounded toHW_ATL2_RPF_L3L4_FILTERS?
Addressed in patch 5 (v3): for all three filter categories (l3_v4, l3_v6,
l4), if base_index >= HW_ATL2_RPF_L3L4_FILTERS the count is forced to zero, otherwise count is capped toHW_ATL2_RPF_L3L4_FILTERS - 1 - base_index, ensuring base_index + count never exceeds the backing array bounds.
Quoted 29 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +19
-0+ +static void hw_atl2_rxf_l3_get (struct aq_hw_s *self, +struct hw_atl2_l3_filter *l3,int idx, +const struct hw_atl2_l3_filter *_l3) +{ +int i; + + l3->usage++; +if (l3->usage ==1 ) { + l3->cmd = _l3->cmd; +for (i =0 ; i <4 ; i++) { + l3->srcip[i] = _l3->srcip[i]; + l3->dstip[i] = _l3->dstip[i]; + } + l3->proto = _l3->proto; + +if (l3->cmd &HW_ATL2_RPF_L3_CMD_EN ) { +hw_atl2_rpf_l3_v4_cmd_set (self, l3->cmd, idx); +hw_atl2_rpf_l3_v4_tag_set (self, idx +1 , idx);[High]
Can the per-filter tag value be silently truncated here?HW_ATL2_RPF_L3_V{4,6}_TAG_MSK and
HW_ATL2_RPF_L4_TAG_MSKare 3-bit fields (max value 7), and the helpersaq_hw_write_reg_bit()mask the value to the field width. idx is in [base_index,base_index+ count), and withl3_v6_filter_countunclamped (and no clamp on anybase_index), idx + 1 can exceed 7 and quietly collapse to a tag used by another slot.
Quoted 5 lines
When two slots end up with the same 3-bit tag, the ART input_tag/mask comparison can pick the lowest matching record, so a drop rule could match traffic intended to be forwarded (or vice versa) without any diagnostic. Should idx + 1 be range-checked against the mask width, or the counts clamped so idx + 1 <= 7?
The patch 5 (v3) validation ensuresbase_index + count <= HW_ATL2_RPF_L3L4_FILTERS - 1, so idx is at most 6 and idx + 1 is at most 7, which fits the 3-bit tag field without truncation.
Tag value 0 (no tag) is never assigned since idx starts at base_index >= 0, making idx + 1 >= 1.
Quoted 65 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +40
-0+hw_atl2_rpf_l3_v4_dest_addr_set (self, + idx, + l3->dstip[0 ]); +hw_atl2_rpf_l3_v4_src_addr_set (self, + idx, + l3->srcip[0 ]); + }else { +hw_atl2_rpf_l3_v6_cmd_set (self, l3->cmd, idx); +hw_atl2_rpf_l3_v6_tag_set (self, idx +1 , idx); +hw_atl2_rpf_l3_v6_dest_addr_set (self, + idx, + l3->dstip); +hw_atl2_rpf_l3_v6_src_addr_set (self, + idx, + l3->srcip); + } + } +} +static int hw_atl2_new_fl3l4_configure (struct aq_hw_s *self, +struct aq_rx_filter_l3l4 *data) +{ +struct hw_atl2_priv *priv = self->priv; +s8 old_l3_index = priv->l3l4_filters[data->location].l3_index; +s8 old_l4_index = priv->l3l4_filters[data->location].l4_index; +u8 old_ipv6 = priv->l3l4_filters[data->location].ipv6; +/* find L3 and L4 filters */ +if (l3.cmd & (HW_ATL2_RPF_L3_CMD_EN |HW_ATL2_RPF_L3_V6_CMD_EN )) { + l3_idx =hw_atl2_new_fl3l4_find_l3 (self, &l3); +if (l3_idx <0 ) +return l3_idx; + +if (l3.cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) + l3_filters = priv->l3_v6_filters; +else + l3_filters = priv->l3_v4_filters; + +if (priv->l3l4_filters[data->location].l3_index != l3_idx) +hw_atl2_rxf_l3_get (self, &l3_filters[l3_idx], + l3_idx, &l3); + }[High]
Does this guard correctly handle a family switch at the same location?priv->l3_v4_filters[] and priv->l3_v6_filters[] are separate 8-entry arrays. When an existing v4 rule at
data->locationis reconfigured to v6 (or the reverse),hw_atl2_new_fl3l4_find_l3()searches the new family's array and is likely to return 0 as the first free slot. If the previously storedl3_indexwas also 0, then:if (priv->l3l4_filters[data->location].l3_index != l3_idx) /* 0 != 0 */ hw_atl2_rxf_l3_get(...); /* skipped */
hw_atl2_rxf_l3_get()is skipped, so priv->l3_v6_filters[0].cmd stays 0 and no v6 HW registers are written. Later,hw_atl2_hw_fl3l4_set()reads ipv6 = 1 andl3_index= 0, picks l3 = &priv->l3_v6_filters[0], finds (l3->cmd&V6_CMD_EN) == 0, and programs the ART tag down the V4 path while the user asked for V6.
Quoted 3 lines
Would it be correct to include the family in the guard, or to just call
hw_atl2_rxf_l3_get()unconditionally (it is already idempotent via the usage == 1 check)?
Fixed in v3. The guard now includes a family check:
if (priv->l3l4_filters[data->location].l3_index != l3_idx ||
old_ipv6 != !!(l3.cmd & HW_ATL2_RPF_L3_V6_CMD_EN))
hw_atl2_rxf_l3_get(...); When the family switches (v4→v6 or v6→v4), old_ipv6 differs from the new family flag, so get() is called regardless of whether the slot index happens to be the same number, ensuring the new family's HW registers are correctly programmed.
Quoted 50 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +31
-0+ +if (old_l3_index !=-1 ) { +if (old_ipv6) + l3_filters = priv->l3_v6_filters; +else + l3_filters = priv->l3_v4_filters; + +if (!(hw_atl2_rxf_l3_is_equal (&l3, + &l3_filters[old_l3_index]))) { +hw_atl2_rxf_l3_put (self, + &l3_filters[old_l3_index], + old_l3_index); + } + } +if (l3.cmd &HW_ATL2_RPF_L3_V6_CMD_EN ) + priv->l3l4_filters[data->location].ipv6 =1 ; +else + priv->l3l4_filters[data->location].ipv6 =0 ; + priv->l3l4_filters[data->location].l3_index = l3_idx; + +if (l4.cmd &HW_ATL2_RPF_L4_CMD_EN ) { + l4_idx =hw_atl2_new_fl3l4_find_l4 (self, &l4); +if (l4_idx <0 ) { +/* Undo L3 acquisition */ +if (l3_idx >=0 ) { +hw_atl2_rxf_l3_put (self, &l3_filters[l3_idx], l3_idx); + priv->l3l4_filters[data->location].l3_index = old_l3_index; + priv->l3l4_filters[data->location].ipv6 = old_ipv6; + } +return -EINVAL ; + }[High, High]
Does the L4-failure undo path correctly unwind L3 state in two distinct ways?First, cross-family pointer aliasing. Before the L4 find,
l3_filterspoints to the new family's array (from the earlier block). The intermediate "if (old_l3_index!= -1)" block unconditionally reassignsl3_filtersto the old family based onold_ipv6. By the time the undo runs,l3_filtersstill points to the old family's array, butl3_idxis a new-family index:hw_atl2_rxf_l3_put(self, &l3_filters[l3_idx], l3_idx);For a cross-family reconfigure this decrements the wrong filter (and may clear its HW via hw_atl2_rpf_l3_v{4,6}_cmd_set(self, 0, idx)) while the actually-acquired new-family filter's refcount is leaked. Should the undo re-derive
l3_filtersfrom the new family before calling put?
Quoted 9 lines
Second, the old L3 filter is not re-acquired. Earlier in the function, if
old_l3_index!= -1 and !is_equal(new, old), the old filter has already hadhw_atl2_rxf_l3_put()called on it, potentially dropping usage to 0 and clearing HW. The undo block restoresl3_index= old and ipv6 =old_ipv6, but does not restore the refcount or HW state of the old filter. Would the old filter need a matchingrxf_l3_get()call here to keep priv->l3l4_filters[location] consistent with the actual HW/refcount state?
Both concerns are addressed in v3.
For the cross-family pointer aliasing: the v3 code removes the undo block entirely. When hw_atl2_new_fl3l4_find_l4() returns < 0 the function returns -EINVAL immediately — there is no code path that would dereference l3_filters (pointing at the old family) using l3_idx (a new-family index).
For the "old filter not re-acquired" concern: v3 uses a commit-first order. The L3 acquisition, the old-L3 put, and the priv bookkeeping (l3_index, ipv6) are all written before the L4 search. Because there is no rollback, no re-acquisition is required. The resulting partial priv state on L4 failure (l3_index/ipv6 updated, l4_index not yet) is never seen by
HW: hw_atl2_hw_fl3l4_set() writes the ART entry only when this function returns 0.
Quoted 34 lines
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +19
-0+static int hw_atl2_hw_fl3l4_set (struct aq_hw_s *self, +struct aq_rx_filter_l3l4 *data) +{ + res =hw_atl2_new_fl3l4_configure (self, data); +if (res) +return res; + +if (!(data->cmd &HW_ATL_RX_ENABLE_FLTR_L3L4 )) { +return 0 ; + } + +if (data->cmd & (HW_ATL_RX_HOST <<HW_ATL2_RPF_L3_L4_ACTF_SHIFT )) + action =HW_ATL2_ACTION_ASSIGN_QUEUE ((data->cmd & +HW_ATL2_RPF_L3_L4_RXQF_MSK ) >> +HW_ATL2_RPF_L3_L4_RXQF_SHIFT ); +else if (data->cmd) + action =HW_ATL2_ACTION_DROP ; +else + action =HW_ATL2_ACTION_DISABLE ;
Quoted 6 lines
[Low]
Can the final "else action =HW_ATL2_ACTION_DISABLE" branch actually be reached? The function has already returned early for the case whereHW_ATL_RX_ENABLE_FLTR_L3L4is clear, so at this pointdata->cmdalways has at least that bit set and is non-zero, which means "else if (data->cmd)" always fires. Was a different condition intended here?
Fixed in v3. Dropped the unreachable else if (data->cmd) / else ACTION_DISABLE branches — past the HW_ATL_RX_ENABLE_FLTR_L3L4 early return data->cmd is always non-zero, so simplified to a plain if/else between ASSIGN_QUEUE and DROP.
Quoted 12 lines
[ ... ]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +1
-1@@ -825,7 +1394,7 @@ static int hw_atl2_hw_vlan_ctrl(struct aq_hw_s *self, bool enable)const struct aq_hw_ops hw_atl2_ops = { .hw_soft_reset = hw_atl2_utils_soft_reset, .hw_prepare = hw_atl2_utils_initfw, - .hw_set_mac_address = hw_atl_b0_hw_mac_addr_set, + .hw_set_mac_address = hw_atl2_hw_mac_addr_set,Signature · 1 line
This is an AI-generated review.
Paolo Abeni
maintainerRe: [PATCH net-next v2 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
In reply to [email protected]drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self) · line 589
Quoted 11 lines · On 5/8/26 2:01 PM, [email protected] wrote:
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +7
-0@@ -530,6 +580,35 @@ static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self)return aq_hw_err_from_flags (self); } +static int hw_atl2_hw_mac_addr_set (struct aq_hw_s *self,const u8 *mac_addr) +{ +struct hw_atl2_priv *priv = self->priv; +u32 location = priv->l2_filters_base_index; +unsigned int h; +unsigned int l; +int err;
Minor nit: please respect the reverse christmas tree above (and elsewhere)
Side note: this patch is quite big, IMHO too much to be effectively reviewed without relying entirely on automated tools, please try split it into smaller chunks.
Also, when posting the next revision please on avoid send the patch in reply to the previous iteration: it will foul both the tools and the human behind them.
Finally please note that the patch subj contains repeated words, please drop them.
/P
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next v2 6/9] net: atlantic: implement AQC113 L2/L3/L4 RX filter management filter management management
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self) · line 591
Quoted 13 lines · Paolo Abeni
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +7
-0@@ -530,6 +580,35 @@ static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self)return aq_hw_err_from_flags (self); } +static int hw_atl2_hw_mac_addr_set (struct aq_hw_s *self,const u8 *mac_addr) +{ +struct hw_atl2_priv *priv = self->priv; +u32 location = priv->l2_filters_base_index; +unsigned int h; +unsigned int l; +int err; Minor nit: please respect the reverse christmas tree above (and elsewhere)
Sure, will keep that in mind and will fix that in v3.
Quoted 5 lines
Side note: this patch is quite big, IMHO too much to be effectively reviewed without relying entirely on automated tools, please try split it into smaller chunks.
Agreed, will split patch 6 in v3
Quoted 4 lines
Also, when posting the next revision please on avoid send the patch in reply to the previous iteration: it will foul both the tools and the human behind them.
Understood, will post v3 as a fresh thread rather than in reply to v2.
Quoted 2 lines
Finally please note that the patch subj contains repeated words, please drop them.
Fixed in v3.
Quoted 2 lines
/P
[email protected]
maintainerPATCH v2 7/9 net: atlantic: add AQC113 PTP traffic class and TX path setup TX path setup
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Add PTP traffic class (TC) buffer reservation and TX path improvements for AQC113:
- Reserve dedicated TX and RX buffer space for PTP TC when PTP is enabled, reducing user TC buffers accordingly (TX: 8KB, RX: 16KB).
- Configure PTP TC with no flow control and highest priority scheduling to ensure timely PTP packet transmission.
- Enable multicast frame tagging (accept_all_mc_packets) so the Action Resolver Table (ART) can match and steer PTP multicast traffic to the correct TC/queue based on RPF input tags.
TX path improvements:
- Enable extended PCIe tag mode (32-255) when hardware supports it, with increased TX data and descriptor read request limits for improved throughput.
Also simplify RSS queue calculation in hw_atl2_hw_rss_set() by extracting to a local variable and use unsigned types for loop variables to match their usage.
--- .../aquantia/atlantic/hw_atl2/hw_atl2.c | 52 ++++++++++++++++--- .../atlantic/hw_atl2/hw_atl2_internal.h | 4 +- 2 files changed, 49 insertions(+), 7 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +46 -6
@@ -151,6 +151,24 @@ static int hw_atl2_hw_reset(struct aq_hw_s *self)return err; } +static int hw_atl2_tc_ptp_set (struct aq_hw_s *self) +{ +/* Init TC2 for PTP_TX */ +hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self,HW_ATL2_PTP_TXBUF_SIZE , +AQ_HW_PTP_TC ); + +/* Init TC2 for PTP_RX */ +hw_atl_rpb_rx_pkt_buff_size_per_tc_set (self,HW_ATL2_PTP_RXBUF_SIZE , +AQ_HW_PTP_TC ); + +/* No flow control for PTP */ +hw_atl_rpb_rx_xoff_en_per_tc_set (self,0U ,AQ_HW_PTP_TC ); + +hw_atl2_tpb_tps_highest_priority_tc_set (self,AQ_HW_PTP_TC ); + +return aq_hw_err_from_flags (self); +} +static int hw_atl2_hw_queue_to_tc_map_set (struct aq_hw_s *self) {struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;
@@ -209,6 +227,11 @@ static int hw_atl2_hw_qos_set(struct aq_hw_s *self)unsigned int prio =0U ;u32 tc =0U ; +if (cfg->is_ptp) { + tx_buff_size -=HW_ATL2_PTP_TXBUF_SIZE ; + rx_buff_size -=HW_ATL2_PTP_RXBUF_SIZE ; + } +/* TPS Descriptor rate init */ hw_atl_tps_tx_pkt_shed_desc_rate_curr_time_res_set (self,0x0U );hw_atl_tps_tx_pkt_shed_desc_rate_lim_set (self,0xA );
@@ -242,6 +265,9 @@ static int hw_atl2_hw_qos_set(struct aq_hw_s *self)hw_atl_b0_set_fc (self, self->aq_nic_cfg->fc.req, tc); } +if (cfg->is_ptp) +hw_atl2_tc_ptp_set (self); +/* QoS 802.1p priority -> TC mapping */ for (prio =0 ; prio <8 ; ++prio) hw_atl_rpf_rpb_user_priority_tc_map_set(self, prio,
@@ -259,8 +285,9 @@ static int hw_atl2_hw_rss_set(struct aq_hw_s *self,u8 *indirection_table = rss_params->indirection_table;const u32 num_tcs =aq_hw_num_tcs (self);u32 rpf_redir2_enable; -int tc; -int i; +u32 queue; +u32 tc; +u32 i; rpf_redir2_enable = num_tcs >4 ?1 :0 ;
@@ -268,10 +295,9 @@ static int hw_atl2_hw_rss_set(struct aq_hw_s *self,for (i =HW_ATL2_RSS_REDIRECTION_MAX ; i--;) {for (tc =0 ; tc != num_tcs; tc++) { -hw_atl2_new_rpf_rss_redir_set (self, tc, i, - tc * -aq_hw_q_per_tc (self) + - indirection_table[i]); + queue = tc *aq_hw_q_per_tc (self) + + indirection_table[i]; +hw_atl2_new_rpf_rss_redir_set (self, tc, i, queue); } }
@@ -415,9 +441,20 @@ static int hw_atl2_hw_init_tx_path(struct aq_hw_s *self)hw_atl2_tpb_tx_buf_clk_gate_en_set (self,0U ); +if (hw_atl2_phi_ext_tag_get (self)) { +hw_atl2_tdm_tx_data_read_req_limit_set (self,0x7F ); +hw_atl2_tdm_tx_desc_read_req_limit_set (self,0x0F ); + } +return aq_hw_err_from_flags (self); } +/* Initialise new rx filters +* L2 promisc OFF +* VLAN promisc OFF +* +* User priority to TC +*/ static void hw_atl2_hw_init_new_rx_filters (struct aq_hw_s *self) {u8 *prio_tc_map = self->aq_nic_cfg->prio_tc_map;
@@ -429,6 +466,9 @@ static void hw_atl2_hw_init_new_rx_filters(struct aq_hw_s *self)u8 index;int i; +/* tag MC frames always */ +hw_atl_rpfl2_accept_all_mc_packets_set (self,1 ); +/* Action Resolver Table (ART) is used by RPF to decide which action * to take with a packet based upon input tag and tag mask, where: * - input tag is a combination of 3-bit VLan Prio (PTP) and
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +3 -1
@@ -27,8 +27,10 @@#define HW_ATL2_INT_MASK (0xFFFFFFFFU)#define HW_ATL2_TXBUF_MAX 128U -#define HW_ATL2_RXBUF_MAX 192U +#define HW_ATL2_PTP_TXBUF_SIZE 8U +#define HW_ATL2_RXBUF_MAX 192U +#define HW_ATL2_PTP_RXBUF_SIZE 16U#define HW_ATL2_RSS_REDIRECTION_MAX 64U#define HW_ATL2_TC_MAX 8U
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH v2 8/9 net: atlantic: extend hw_ops and TX descriptor for AQC113 PTP for AQC113 PTP
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
Extend the aq_hw_ops interface with new function pointers required for PTP support on AQC113:
- enable_ptp: enable/disable PTP counter with clock selection
- hw_ring_tx_ptp_get_ts: read TX timestamp from descriptor writeback
- hw_tx_ptp_ring_init/hw_rx_ptp_ring_init: per-ring PTP initialization
- hw_get_clk_sel: query active TSG clock selection
Update existing hw_ops signatures to support AQC113 dual-clock architecture:
- hw_gpio_pulse: add clk_sel and hightime parameters
- hw_extts_gpio_enable: add channel parameter
Add PTP-related hardware defines:
- AQ_HW_TXD_CTL_TS_EN/TS_TSG0 for TX descriptor timestamp control
- AQ2_HW_PTP_COUNTER_HZ for AQC113 TSG clock frequency
- AQ_HW_PTP_IRQS for PTP interrupt vector accounting
- PTP enable flags (L2/L4) and TSG clock selection constants
Add request_ts and clk_sel bitfields to aq_ring_buff_s for per-packet TX timestamp request tracking.
Update hw_atl_b0.c (AQC107) implementations:
- Adapt gpio_pulse and extts_gpio_enable to new signatures
- Add TX descriptor timestamp bits for AQC113 when ANTIGUA chip feature is detected
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 34 +++++++++++++++++-- .../net/ethernet/aquantia/atlantic/aq_ptp.c | 4 +-- .../net/ethernet/aquantia/atlantic/aq_ring.h | 4 ++- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 15 ++++++-- 4 files changed, 48 insertions(+), 9 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +31 -3
@@ -19,6 +19,9 @@#define AQ_HW_MAC_COUNTER_HZ 312500000ll#define AQ_HW_PHY_COUNTER_HZ 160000000ll +#define AQ_HW_TXD_CTL_TS_EN 0x40000000U +#define AQ_HW_TXD_CTL_TS_TSG0 0x80000000U +enum aq_tc_mode {AQ_TC_MODE_INVALID =-1 ,AQ_TC_MODE_8TCS ,
@@ -38,6 +41,8 @@ enum aq_tc_mode {#define AQ_FRAC_PER_NS 0x100000000LL +#define AQ2_HW_PTP_COUNTER_HZ 156250000ll +/* Used for rate to Mbps conversion */ #define AQ_MBPS_DIVISOR 125000/* 1000000 / 8 */
@@ -109,6 +114,7 @@ struct aq_stats_s {#define AQ_HW_IRQ_MSIX 3U#define AQ_HW_SERVICE_IRQS 1U +#define AQ_HW_PTP_IRQS 1U#define AQ_HW_POWER_STATE_D0 0U#define AQ_HW_POWER_STATE_D3 3U
@@ -157,6 +163,15 @@ enum aq_priv_flags { AQ_HW_LOOPBACK_PHYEXT_SYS, }; +enum { +AQ_HW_PTP_DISABLE =0 , +AQ_HW_PTP_L2_ENABLE =BIT (1 ), +AQ_HW_PTP_L4_ENABLE =BIT (2 ), +}; + +#define ATL_TSG_CLOCK_SEL_0 0 +#define ATL_TSG_CLOCK_SEL_1 1 +#define AQ_HW_LOOPBACK_MASK (BIT(AQ_HW_LOOPBACK_DMA_SYS) |\ BIT(AQ_HW_LOOPBACK_PKT_SYS) |\ BIT(AQ_HW_LOOPBACK_DMA_NET) |\
@@ -198,6 +213,7 @@ struct aq_hw_s {u32 rpc_tid;struct hw_atl_utils_fw_rpc rpc;s64 ptp_clk_offset; +s8 clk_select;u16 phy_id;void *priv; };
@@ -325,11 +341,15 @@ struct aq_hw_ops {int (*hw_ts_to_sys_clock)(struct aq_hw_s *self,u64 ts,u64 *time); -int (*hw_gpio_pulse)(struct aq_hw_s *self,u32 index,u64 start, -u32 period); +int (*hw_gpio_pulse)(struct aq_hw_s *self,u32 index, +u32 clk_sel,u64 start, +u32 period,u32 hightime);int (*hw_extts_gpio_enable)(struct aq_hw_s *self,u32 index, -u32 enable); +u32 channel,int enable); + +void (*enable_ptp)(struct aq_hw_s *self,unsigned int param, +int enable);int (*hw_get_sync_ts)(struct aq_hw_s *self,u64 *ts);
@@ -339,6 +359,14 @@ struct aq_hw_ops {int (*extract_hwts)(struct aq_hw_s *self,u8 *p,unsigned int len,u64 *timestamp); +u64 (*hw_ring_tx_ptp_get_ts)(struct aq_ring_s *ring); + +int (*hw_tx_ptp_ring_init)(struct aq_hw_s *self, +struct aq_ring_s *aq_ring); +int (*hw_rx_ptp_ring_init)(struct aq_hw_s *self, +struct aq_ring_s *aq_ring); +u32 (*hw_get_clk_sel)(struct aq_hw_s *self); +int (*hw_set_fc)(struct aq_hw_s *self,u32 fc,u32 tc);int (*hw_set_loopback)(struct aq_hw_s *self,u32 mode,bool enable);
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2 -2
@@ -380,7 +380,7 @@ static int aq_ptp_hw_pin_conf(struct aq_nic_s *aq_nic, u32 pin_index, u64 start,*/ mutex_lock (&aq_nic->fwreq_mutex); aq_nic->aq_hw_ops->hw_gpio_pulse (aq_nic->aq_hw, pin_index, - start, (u32 )period); +0 , start, (u32 )period,0 );mutex_unlock (&aq_nic->fwreq_mutex);return 0 ;
@@ -454,7 +454,7 @@ static void aq_ptp_extts_pin_ctrl(struct aq_ptp_s *aq_ptp)if (aq_nic->aq_hw_ops->hw_extts_gpio_enable) aq_nic->aq_hw_ops->hw_extts_gpio_enable (aq_nic->aq_hw,0 , - enable); +0 , enable); } static int aq_ptp_extts_pin_configure(struct ptp_clock_info *ptp,
drivers/net/ethernet/aquantia/atlantic/aq_ring.h +3 -1
@@ -85,7 +85,9 @@ struct __packed aq_ring_buff_s { u32 is_error:1; u32 is_vlan:1; u32 is_lro:1; - u32 rsvd3:3; + u32 request_ts:1; + u32 clk_sel:1; + u32 rsvd3:1;u16 eop_index;u16 rsvd4; };
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +12 -3
@@ -736,6 +736,15 @@ int hw_atl_b0_hw_ring_tx_xmit(struct aq_hw_s *self, struct aq_ring_s *ring, txd->ctl |=HW_ATL_B0_TXD_CTL_CMD_WB ; is_gso = false; is_vlan = false; + +if (ATL_HW_IS_CHIP_FEATURE (self,ANTIGUA ) && +unlikely (buff->request_ts)) { + txd->ctl |=AQ_HW_TXD_CTL_TS_EN ; +if (buff->clk_sel !=ATL_TSG_CLOCK_SEL_1 ) + txd->ctl |=AQ_HW_TXD_CTL_TS_TSG0 ; +/* The only DD+TS is required */ + txd->ctl &= ~HW_ATL_B0_TXD_CTL_CMD_WB ; + } } } ring->sw_tail =aq_ring_next_dx (ring, ring->sw_tail);
@@ -1323,8 +1332,8 @@ static int hw_atl_b0_adj_clock_freq(struct aq_hw_s *self, s32 ppb)return self->aq_fw_ops->send_fw_request (self, &fwreq, size); } -static int hw_atl_b0_gpio_pulse (struct aq_hw_s *self,u32 index, -u64 start,u32 period) +static int hw_atl_b0_gpio_pulse (struct aq_hw_s *self,u32 index,u32 clk_sel, +u64 start,u32 period,u32 hightime) {struct hw_fw_request_iface fwreq;size_t size;
@@ -1342,7 +1351,7 @@ static int hw_atl_b0_gpio_pulse(struct aq_hw_s *self, u32 index, }static int hw_atl_b0_extts_gpio_enable (struct aq_hw_s *self,u32 index, -u32 enable) +u32 channel,int enable) {/* Enable/disable Sync1588 GPIO Timestamping */ aq_phy_write_reg (self,MDIO_MMD_PCS ,0xc611 , enable ?0x71 :0 );
Signature · 1 line
2.43.0
[email protected]
maintainerPATCH v2 9/9 net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
In reply to [email protected]From: Sukhdeep Singh <[email protected]>
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).
--- .../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(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +1 -0
@@ -15,6 +15,7 @@#include "aq_common.h" #include "aq_rss.h" #include "hw_atl/hw_atl_utils.h" +#include "hw_atl2/hw_atl2.h" #define AQ_HW_MAC_COUNTER_HZ 312500000ll#define AQ_HW_PHY_COUNTER_HZ 160000000ll
drivers/net/ethernet/aquantia/atlantic/aq_main.c +20 -14
@@ -19,8 +19,10 @@#include <linux/netdevice.h> #include <linux/module.h> #include <linux/ip.h> +#include <linux/ipv6.h> #include <linux/udp.h> #include <net/pkt_cls.h> +#include <linux/ptp_classify.h> #include <net/pkt_sched.h> #include <linux/filter.h>
@@ -68,20 +70,14 @@ int aq_ndev_open(struct net_device *ndev)if (err <0 ) goto err_exit; - err =aq_reapply_rxnfc_all_rules (aq_nic); -if (err <0 ) - goto err_exit; - - err =aq_filters_vlans_update (aq_nic); -if (err <0 ) - goto err_exit; - err =aq_nic_start (aq_nic);if (err <0 ) {aq_nic_stop (aq_nic); goto err_exit; } +aq_utils_obj_set (&aq_nic->aq_hw->flags,AQ_HW_FLAG_STARTED ); + err_exit:if (err <0 )aq_nic_deinit (aq_nic, true);
@@ -97,6 +93,7 @@ int aq_ndev_close(struct net_device *ndev) err =aq_nic_stop (aq_nic);aq_nic_deinit (aq_nic, true); +aq_utils_obj_clear (&aq_nic->aq_hw->flags,AQ_HW_FLAG_STARTED );return err; }
@@ -113,16 +110,25 @@ static netdev_tx_t aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *nd* and hardware PTP design of the chip. Otherwise ptp stream * will fail to sync */ -if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) || -unlikely ((ip_hdr (skb)->version ==4 ) && - (ip_hdr (skb)->protocol ==IPPROTO_UDP ) && - ((udp_hdr (skb)->dest ==htons (319 )) || - (udp_hdr (skb)->dest ==htons (320 )))) || -unlikely (eth_hdr (skb)->h_proto ==htons (ETH_P_1588 ))) +if (unlikely (skb->protocol ==htons (ETH_P_IP ) && +ip_hdr (skb)->protocol ==IPPROTO_UDP && + (udp_hdr (skb)->dest ==htons (PTP_EV_PORT ) || +udp_hdr (skb)->dest ==htons (PTP_GEN_PORT )))) +return aq_ptp_xmit (aq_nic, skb); + +/* PTP over IPv6 does not use extension headers */ +if (unlikely (skb->protocol ==htons (ETH_P_IPV6 ) && +ipv6_hdr (skb)->nexthdr ==IPPROTO_UDP && + (udp_hdr (skb)->dest ==htons (PTP_EV_PORT ) || +udp_hdr (skb)->dest ==htons (PTP_GEN_PORT )))) +return aq_ptp_xmit (aq_nic, skb); + +if (unlikely (eth_hdr (skb)->h_proto ==htons (ETH_P_1588 ))) return aq_ptp_xmit(aq_nic, skb); }#endif +skb_tx_timestamp (skb);return aq_nic_xmit (aq_nic, skb); }
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +41 -7
96 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +2 -2
@@ -293,8 +293,8 @@ static int aq_pci_probe(struct pci_dev *pdev, numvecs =min ((u8 )AQ_CFG_VECS_DEF ,aq_nic_get_cfg (self)->aq_hw_caps->msix_irqs); numvecs =min (numvecs,num_online_cpus ()); -/* Request IRQ vector for PTP */ - numvecs +=1 ; +/* Request IRQ lines for PTP */ + numvecs +=AQ_HW_PTP_IRQS ; numvecs +=AQ_HW_SERVICE_IRQS ;/*enable interrupts */
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +410 -125
805 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h +11 -4
@@ -14,6 +14,12 @@#include "aq_ring.h" +enum aq_ptp_state { +AQ_PTP_NO_LINK =0 , +AQ_PTP_FIRST_INIT =1 , +AQ_PTP_LINK_UP =2 , +}; +#define PTP_8TC_RING_IDX 8#define PTP_4TC_RING_IDX 16#define PTP_HWST_RING_IDX 31
@@ -32,7 +38,7 @@ static inline unsigned int aq_ptp_ring_idx(const enum aq_tc_mode tc_mode)#if IS_REACHABLE (CONFIG_PTP_1588_CLOCK )/* Common functions */ -int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_vec); +int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_ptp_vec);void aq_ptp_unregister (struct aq_nic_s *aq_nic);void aq_ptp_free (struct aq_nic_s *aq_nic);
@@ -52,7 +58,7 @@ void aq_ptp_service_task(struct aq_nic_s *aq_nic);void aq_ptp_tm_offset_set (struct aq_nic_s *aq_nic,unsigned int mbps); -void aq_ptp_clock_init (struct aq_nic_s *aq_nic); +void aq_ptp_clock_init (struct aq_nic_s *aq_nic,enum aq_ptp_state state);/* Traffic processing functions */ int aq_ptp_xmit (struct aq_nic_s *aq_nic,struct sk_buff *skb);
@@ -80,7 +86,7 @@ u64 *aq_ptp_get_stats(struct aq_nic_s *aq_nic, u64 *data);#else -static inline int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_vec) +static inline int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_ptp_vec) {return 0 ; }
@@ -122,7 +128,8 @@ static inline void aq_ptp_ring_deinit(struct aq_nic_s *aq_nic) {}static inline void aq_ptp_service_task (struct aq_nic_s *aq_nic) {}static inline void aq_ptp_tm_offset_set (struct aq_nic_s *aq_nic,unsigned int mbps) {} -static inline void aq_ptp_clock_init (struct aq_nic_s *aq_nic) {} +static inline void aq_ptp_clock_init (struct aq_nic_s *aq_nic, +enum aq_ptp_state state) {}static inline int aq_ptp_xmit (struct aq_nic_s *aq_nic,struct sk_buff *skb) {return -EOPNOTSUPP ;
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +24 -18
55 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +177 -2
219 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.h +12 -0
@@ -7,6 +7,18 @@#define HW_ATL2_H #include "aq_common.h" +#define HW_ATL2_RX_TS_SIZE 8 + +#define HW_ATL2_PTP_OFFSET_INGRESS_100 768 +#define HW_ATL2_PTP_OFFSET_EGRESS_100 336 +#define HW_ATL2_PTP_OFFSET_INGRESS_1000 510 +#define HW_ATL2_PTP_OFFSET_EGRESS_1000 105 +#define HW_ATL2_PTP_OFFSET_INGRESS_2500 2447 +#define HW_ATL2_PTP_OFFSET_EGRESS_2500 634 +#define HW_ATL2_PTP_OFFSET_INGRESS_5000 1426 +#define HW_ATL2_PTP_OFFSET_EGRESS_5000 361 +#define HW_ATL2_PTP_OFFSET_INGRESS_10000 997 +#define HW_ATL2_PTP_OFFSET_EGRESS_10000 203extern const struct aq_hw_caps_s hw_atl2_caps_aqc113;extern const struct aq_hw_caps_s hw_atl2_caps_aqc115c;
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +2 -1
@@ -29,7 +29,8 @@#define HW_ATL2_TXBUF_MAX 128U#define HW_ATL2_PTP_TXBUF_SIZE 8U -#define HW_ATL2_RXBUF_MAX 192U +/* Reduced from 192 to reserve space for PTP RX timestamp trailer */ +#define HW_ATL2_RXBUF_MAX 172U#define HW_ATL2_PTP_RXBUF_SIZE 16U#define HW_ATL2_RSS_REDIRECTION_MAX 64U
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.h +10 -0
@@ -8,6 +8,16 @@#include "aq_hw.h" +/* Hardware tx launch time descriptor */ +struct hw_atl2_txts_s { +u64 ts; +u32 ctrl; +u32 reserved; +}; + +#define HW_ATL2_TXTS_DD BIT(3) +#define HW_ATL2_TXTS_TS_VALID BIT(20) +/* F W A P I */ struct link_options_s {
Signature · 1 line
2.43.0
Paolo Abeni
maintainerRe: [PATCH net-next v2 9/9] net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
This patch adds IEEE 1588 PTP support for the AQC113 (Antigua) controller alongside the existing AQC107 (Atlantic) PTP path. It introduces dual TSG clocks, descriptor-writeback TX timestamps, per-instance PTP offsets, L3/L4 multicast filters, and reworks IRQ vector math and RX filter application order.
Quoted 1 line
Subject: net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
[Low]
The codename "(Antigua)" is duplicated in the subject line.
Quoted 27 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c +2
-8@@ -68,20 +70,14 @@ int aq_ndev_open(struct net_device *ndev)if (err <0 ) goto err_exit; - err =aq_reapply_rxnfc_all_rules (aq_nic); -if (err <0 ) - goto err_exit; - - err =aq_filters_vlans_update (aq_nic); -if (err <0 ) - goto err_exit; - err =aq_nic_start (aq_nic);if (err <0 ) {aq_nic_stop (aq_nic); goto err_exit; } +aq_utils_obj_set (&aq_nic->aq_hw->flags,AQ_HW_FLAG_STARTED ); + err_exit:if (err <0 )aq_nic_deinit (aq_nic, true);
drivers/net/ethernet/aquantia/atlantic/aq_main.c int aq_ndev_close(struct net_device *ndev) · line 98
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c +1
-0@@ -97,6 +93,7 @@ int aq_ndev_close(struct net_device *ndev) err =aq_nic_stop (aq_nic);aq_nic_deinit (aq_nic, true); +aq_utils_obj_clear (&aq_nic->aq_hw->flags,AQ_HW_FLAG_STARTED );return err; }
[Medium]AQ_HW_FLAG_STARTED is set in aq_ndev_open() and cleared in aq_ndev_close(), but a grep across the tree shows no reader of that flag.
The commit message lists "Add AQ_HW_FLAG_STARTED flag management in open/close" as one of the changes.
Is there a consumer of AQ_HW_FLAG_STARTED that was intended to be part of this patch but was omitted, or should the flag writes be dropped?
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0
-0@@ -172,7 +180,11 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)aq_nic_update_interrupt_moderation_settings (self);
drivers/net/ethernet/aquantia/atlantic/aq_nic.c static int aq_nic_update_link_status(struct aq_nic_s *self) · line 190
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +5
-1if (self->aq_ptp) { -aq_ptp_clock_init (self); +/* PTP does not work in some modes even if physical link is up */ +bool ptp_link_good = (self->aq_hw->aq_link_status.mbps >=100 && + self->aq_hw->aq_link_status.full_duplex); + +aq_ptp_clock_init (self, ptp_link_good ?AQ_PTP_LINK_UP :AQ_PTP_NO_LINK );aq_ptp_tm_offset_set (self, self->aq_hw->aq_link_status.mbps);aq_ptp_link_change (self);
[High]aq_nic_update_link_status() runs from aq_linkstate_threaded_isr() and from aq_nic_service_task(), neither of which holds rtnl_lock. The new AQC113 path calls into aq_ptp_clock_init() which in turn calls aq_ptp_dpath_enable().
aq_ptp_dpath_enable() writes aq_ptp->udp_filter[] and programs L3/L4/L2 filter registers. The ioctl path aq_ndev_hwtstamp_set() -> aq_ptp_hwtstamp_config_set() -> aq_ptp_dpath_enable() runs under rtnl_lock only, so the lockset intersection with the link-change path is empty.
Can two concurrent callers of aq_ptp_dpath_enable() tear udp_filter[] entries and interleave hw_filter_l3l4_set / hw_filter_l2_set register writes on different CPUs? Before this patch the A1 flow touched these filters only from the ioctl path, so this race did not exist.
drivers/net/ethernet/aquantia/atlantic/aq_nic.c static int aq_nic_hw_prepare(struct aq_nic_s *self) · line 298
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +3
-0@@ -279,6 +291,9 @@ static int aq_nic_hw_prepare(struct aq_nic_s *self)int err =0 ; err = self->aq_hw_ops->hw_soft_reset (self->aq_hw); + + self->aq_hw->clk_select =-1 ; +if (err) goto exit;
[Medium]clk_select is set to -1 here and is then fed, without validation, into hw_atl2_tsg_clock_read() / hw_atl2_tsg_clock_add() / hw_atl2_tsg_clock_sub() / hw_atl2_tsg_clock_increment_set() through aq_get_ptp_ts(), hw_atl2_adj_sys_clock() and hw_atl2_adj_clock_freq().
Those helpers plug the value into HW_ATL2_TSG_REG_ADR(clock_sel, ...) with no range check. Since clk_select is s8, -1 promoted through the unsigned int parameter becomes 0xffffffff and produces an out-of-range MMIO offset.
In aq_ptp_init() the PTP clock is exposed to userspace via ptp_clock_register() before hw_atl2_enable_ptp() sets clk_select to 0 or 1. A gettime/adjtime on the newly appearing /dev/ptpN during that window would land in the above helpers with clk_select still equal to -1.
Would a guard like "if (self->clk_select < 0) return 0;" at the top of each of those helpers be appropriate?
[Medium]clk_select is also written by hw_atl2_enable_ptp() (called from aq_ptp_init / aq_ptp_free / hw_atl2_hw_reset) and read on the TX fast path via self->aq_hw_ops->hw_get_clk_sel(self->aq_hw) from aq_nic_map_skb(), as well as by hw_atl2_hw_rx_ptp_ring_init() and hw_atl2_hw_reset(). There is no lock, no READ_ONCE/WRITE_ONCE, and no atomic wrapper.
Can a TX in flight during reset/enable/disable observe a torn or stale clk_select and either tag a descriptor with the wrong clock selector or propagate -1 into the HW register macros?
Quoted 13 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +8
-1@@ -450,7 +465,14 @@ int aq_nic_init(struct aq_nic_s *self) }if (aq_nic_get_cfg (self)->is_ptp) { - err =aq_ptp_init (self, self->irqvecs -1 ); +u32 ptp_isr_vec; + +if (self->irqvecs >AQ_HW_PTP_IRQS ) + ptp_isr_vec = self->irqvecs -AQ_HW_PTP_IRQS ; +else + ptp_isr_vec =0 ; + + err =aq_ptp_init (self, ptp_isr_vec);
[ ... ]
drivers/net/ethernet/aquantia/atlantic/aq_nic.c unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb, · line 834
Quoted 13 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +6
-0@@ -793,6 +823,12 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb, first->eop_index = dx; dx_buff->is_eop =1U ; +if (skb_shinfo (skb)->tx_flags &SKBTX_IN_PROGRESS && + self->aq_hw_ops->enable_ptp && + self->aq_hw_ops->hw_get_clk_sel) { + dx_buff->request_ts =1U ; + dx_buff->clk_sel = self->aq_hw_ops->hw_get_clk_sel (self->aq_hw); + } dx_buff->skb = skb; dx_buff->xdpf =NULL ; goto exit;
[Critical]request_ts is armed here whenever SKBTX_IN_PROGRESS is set and the op pointers exist, not only for PTP traffic. SKBTX_IN_PROGRESS fires for any SO_TIMESTAMPING socket on AQC113, which makes the following aq_ring_tx_clean() path reachable via ordinary unprivileged traffic:
drivers/net/ethernet/aquantia/atlantic/aq_ring.c
aq_ring_tx_clean() {
...
if (likely(buff->is_mapped)) {
...
dma_unmap_single(dev, buff->pa, buff->len, DMA_TO_DEVICE);
/* or dma_unmap_page(...) */
}
if (unlikely(buff->is_eop)) {
if (unlikely(buff->request_ts) &&
self->aq_nic->aq_hw_ops->hw_ring_tx_ptp_get_ts) {
u64 ts = ...->hw_ring_tx_ptp_get_ts(self);
if (!ts)
break; /* HW has not set DD/TS_VALID yet */
...
}
...
}
buff->skb = NULL;
buff->xdpf = NULL;
buff->pa = 0U;
...
self->sw_head = aq_ring_next_dx(self, self->sw_head);
}hw_atl2_hw_ring_tx_ptp_get_ts() explicitly returns 0 when DD or TS_VALID is not yet set, so the zero-timestamp break path is deliberately reachable.
On the next aq_ring_tx_clean() invocation, sw_head is unchanged, buff->is_mapped is still 1, and buff->pa still holds the original DMA handle. Is the second pass going to call dma_unmap_single() or dma_unmap_page() a second time on the already-unmapped address? A grep for "is_mapped = 0" in the driver returns no matches, so buff->is_mapped is never cleared by any other path.
Additionally, the commit message states:
Poll for TX timestamp completion in aq_ring_tx_clean() with a timeout mechanism (aq_ptp_tx_ts_timedout/clear)
Neither aq_ptp_tx_ts_timedout nor aq_ptp_tx_ts_clear exists anywhere in the tree. If HW never produces a timestamp (for example when request_ts is armed but AQ_HW_TXD_CTL_TS_EN is not set, or under a HW glitch), sw_head never advances and the TX ring wedges until the TX watchdog fires.
Would it be safer to check the timestamp before any DMA unmap and/or guard the break path so it does not leave buff->is_mapped and buff->pa live for a repeat unmap?
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp, · line 802
Quoted 13 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-1@@ -572,53 +770,53 @@ void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp, *config = aq_ptp->hwtstamp_config; } -static void aq_ptp_prepare_filters (struct aq_ptp_s *aq_ptp) +static unsigned int aq_ptp_parse_rx_filters (enum hwtstamp_rx_filters rx_filter) { +return ptp_en_flags; }
[Low]aq_ptp_parse_rx_filters() is typed to take enum hwtstamp_rx_filters, but aq_ptp_clock_init() calls it with AQ_HW_PTP_DISABLE, which belongs to the driver-internal AQ_HW_PTP_* bitmask enum. This works today only because AQ_HW_PTP_DISABLE happens to equal HWTSTAMP_FILTER_NONE (both zero).
Could the call site pass HWTSTAMP_FILTER_NONE explicitly, or the helper be reshaped to take a boolean disable argument, so future renumbering of either enum does not silently break link-down filter teardown?
Quoted 20 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +7
-5@@ -972,11 +1179,13 @@ int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic)if (err) goto err_exit_ptp_tx; - err =aq_ring_hwts_rx_alloc (&aq_ptp->hwts_rx, aq_nic,PTP_HWST_RING_IDX , - aq_nic->aq_nic_cfg.rxds, - aq_nic->aq_nic_cfg.aq_hw_caps->rxd_size); -if (err) - goto err_exit_ptp_rx; +if (aq_ptp->a1_ptp) { + err =aq_ring_hwts_rx_alloc (&aq_ptp->hwts_rx, aq_nic,PTP_HWST_RING_IDX , + aq_nic->aq_nic_cfg.rxds, + aq_nic->aq_nic_cfg.aq_hw_caps->rxd_size); +if (err) + goto err_exit_ptp_rx; + } err =aq_ptp_skb_ring_init (&aq_ptp->skb_ring, aq_nic->aq_nic_cfg.rxds);if (err !=0 ) {
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic) · line 1207
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-1@@ -984,7 +1193,7 @@ int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic) goto err_exit_hwts_rx; } err_exit_hwts_rx: -aq_ring_hwts_rx_free (&aq_ptp->hwts_rx); +if (aq_ptp->a1_ptp) +aq_ring_free (&aq_ptp->hwts_rx); err_exit_ptp_rx:
[High]aq_ring_hwts_rx_alloc() allocates size * dx_size + AQ_CFG_RXDS_DEF via dma_alloc_coherent(), and aq_ring_hwts_rx_free() passes the same "+ AQ_CFG_RXDS_DEF" back to dma_free_coherent(). The replacement call aq_ring_free() here passes only self->size * self->dx_size:
drivers/net/ethernet/aquantia/atlantic/aq_ring.c
aq_ring_free() {
...
dma_free_coherent(aq_nic_get_dev(self->aq_nic),
self->size * self->dx_size, self->dx_ring,
self->dx_ring_pa);
...
}The DMA API requires dma_free_coherent() to be called with the same size as dma_alloc_coherent(). The non-error path in aq_ptp_ring_free() still calls aq_ring_hwts_rx_free().
Is this asymmetric free intentional, and if not, should the error path use aq_ring_hwts_rx_free() as well?
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +3
-0@@ -1244,30 +1514,45 @@ void aq_ptp_free(struct aq_nic_s *aq_nic)if (!aq_ptp)return ; +/* disable ptp */ +if (aq_ptp->a1_ptp) { +mutex_lock (&aq_nic->fwreq_mutex);
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c void aq_ptp_free(struct aq_nic_s *aq_nic) · line 1529
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +10
-0+ aq_nic->aq_fw_ops->enable_ptp (aq_nic->aq_hw,0 ); +mutex_unlock (&aq_nic->fwreq_mutex); + } + +if (aq_ptp->a2_ptp) + aq_nic->aq_hw_ops->enable_ptp (aq_nic->aq_hw, + aq_ptp->ptp_clock_sel,0 ); + +cancel_delayed_work_sync (&aq_ptp->poll_sync); +
[Medium]
The prior ordering cancelled poll_sync before disabling PTP. This hunk disables PTP first and then cancels the delayed work.
aq_ptp_poll_sync_work_cb() calls aq_ptp_check_sync1588(), which touches PTP hardware state (hw_ts_to_sys_clock, ptp_clock_event on aq_ptp->ptp_clock) and reschedules itself via schedule_delayed_work() when extts_pin_enabled is set.
Can a pending callback run against PTP hardware that was just turned off, and would it be better to cancel_delayed_work_sync() first and only then tear the hardware down?
Quoted 20 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +0
-0@@ -308,24 +308,30 @@ bool aq_ring_tx_clean(struct aq_ring_s *self)[ ... see Critical comment above on
dma_unmap/ break ordering ... ]drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0@@ -886,6 +912,138 @@ static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) +static int hw_atl2_gpio_pulse (struct aq_hw_s *self,u32 index,u32 clk_sel, +u64 start,u32 period,u32 hightime) +{ +u32 mode; + +if (start ==0 ) + mode =HW_ATL2_GPIO_PIN_SPEC_MODE_GPIO ; +else if (clk_sel ==ATL_TSG_CLOCK_SEL_0 ) + mode =HW_ATL2_GPIO_PIN_SPEC_MODE_TSG0_EVENT_OUTPUT ; +else
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 931
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +10
-0+ mode =HW_ATL2_GPIO_PIN_SPEC_MODE_TSG1_EVENT_OUTPUT ; + +if (index ==1 || index ==3 ) {/* Hardware limitation */ +hw_atl2_gpio_special_mode_set (self, mode, index); + } + +hw_atl2_tsg_ptp_gpio_gen_pulse (self, clk_sel, start, period, hightime); + +return 0 ; +}
[Medium]hw_atl2_gpio_special_mode_set() is only called when index is 1 or 3, but hw_atl2_tsg_ptp_gpio_gen_pulse() is invoked unconditionally and 0 is returned for every index.
For a PTP_PIN_SETFUNC on pin 0, 2 or any other non-special index, the TSG pulse generator is armed but the pin mux is never reprogrammed, so no signal appears on the pin and the userspace request appears to succeed.
Should invalid indices be rejected with -EINVAL, or should the pulse generator only be armed when the pin can actually be muxed?
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h line 34
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +2
-1@@ -29,7 +29,8 @@#define HW_ATL2_TXBUF_MAX 128U#define HW_ATL2_PTP_TXBUF_SIZE 8U -#define HW_ATL2_RXBUF_MAX 192U +/* Reduced from 192 to reserve space for PTP RX timestamp trailer */ +#define HW_ATL2_RXBUF_MAX 172U#define HW_ATL2_PTP_RXBUF_SIZE 16U
[Medium]HW_ATL2_RXBUF_MAX is reduced unconditionally for every AQC113 user, but hw_atl2_hw_qos_set() already subtracts HW_ATL2_PTP_RXBUF_SIZE when cfg->is_ptp is true, so the reduction appears redundant when PTP is enabled and a pure loss for non-PTP deployments.
The justification in the comment is per-packet (HW_ATL2_RX_TS_SIZE is 8 bytes, handled in hw_atl2_hw_rx_extract_ts), while this register programs the on-chip packet-buffer KB allocation.
Could this change be gated on cfg->is_ptp, or is there a separate reason to take ~10% of the RX packet buffer from non-PTP users?
Signature · 1 line
This is an AI-generated review.
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next v2 9/9] net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
Quoted 9 lines · Paolo Abeni
---
net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)This patch adds IEEE 1588 PTP support for the AQC113 (Antigua) controller alongside the existing AQC107 (Atlantic) PTP path. It introduces dual TSG clocks, descriptor-writeback TX timestamps, per-instance PTP offsets, L3/L4 multicast filters, and reworks IRQ vector math and RX filter application order.
Quoted 4 lines
Subject: net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
[Low]
The codename "(Antigua)" is duplicated in the subject line.
Fixed in v3.
Quoted 39 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c +3
-8@@ -68,20 +70,14 @@ int aq_ndev_open(struct net_device *ndev)if (err <0 ) goto err_exit; - err =aq_reapply_rxnfc_all_rules (aq_nic); -if (err <0 ) - goto err_exit; - - err =aq_filters_vlans_update (aq_nic); -if (err <0 ) - goto err_exit; - err =aq_nic_start (aq_nic);if (err <0 ) {aq_nic_stop (aq_nic); goto err_exit; } +aq_utils_obj_set (&aq_nic->aq_hw->flags,AQ_HW_FLAG_STARTED ); + err_exit:if (err <0 )aq_nic_deinit (aq_nic, true);@@ -97,6 +93,7 @@ int aq_ndev_close(struct net_device *ndev) err =aq_nic_stop (aq_nic);aq_nic_deinit (aq_nic, true); +aq_utils_obj_clear (&aq_nic->aq_hw->flags,AQ_HW_FLAG_STARTED );return err; }[Medium]
AQ_HW_FLAG_STARTEDis set inaq_ndev_open()and cleared inaq_ndev_close(), but a grep across the tree shows no reader of that flag.
Quoted 5 lines
The commit message lists "Add
AQ_HW_FLAG_STARTEDflag management in open/close" as one of the changes.Is there a consumer of
AQ_HW_FLAG_STARTEDthat was intended to be part of this patch but was omitted, or should the flag writes be dropped?
The AQ_HW_FLAG_STARTED set/clear calls will be dropped from the code in v3 as there is no consumer. The commit message reference to it will be removed in v3 as well.
Quoted 29 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +5
-1@@ -172,7 +180,11 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)aq_nic_update_interrupt_moderation_settings (self);if (self->aq_ptp) { -aq_ptp_clock_init (self); +/* PTP does not work in some modes even if physical link is up */ +bool ptp_link_good = (self->aq_hw->aq_link_status.mbps >=100 && + self->aq_hw->aq_link_status.full_duplex); + +aq_ptp_clock_init (self, ptp_link_good ?AQ_PTP_LINK_UP :AQ_PTP_NO_LINK );aq_ptp_tm_offset_set (self, self->aq_hw->aq_link_status.mbps);aq_ptp_link_change (self);[High]
aq_nic_update_link_status()runs fromaq_linkstate_threaded_isr()and fromaq_nic_service_task(), neither of which holdsrtnl_lock. The new AQC113 path calls intoaq_ptp_clock_init()which in turn callsaq_ptp_dpath_enable().
aq_ptp_dpath_enable()writes aq_ptp->udp_filter[] and programs L3/L4/L2 filter registers. The ioctl pathaq_ndev_hwtstamp_set()->aq_ptp_hwtstamp_config_set()->aq_ptp_dpath_enable()runs underrtnl_lockonly, so the lockset intersection with the link-change path is empty.
Quoted 4 lines
Can two concurrent callers of
aq_ptp_dpath_enable()tear udp_filter[] entries and interleavehw_filter_l3l4_set/hw_filter_l2_setregister writes on different CPUs? Before this patch the A1 flow touched these filters only from the ioctl path, so this race did not exist.
Both call sites of aq_ptp_dpath_enable() — the link-change path via aq_ptp_clock_init() and the ioctl path via aq_ptp_hwtstamp_config_set() — hold ptp_filter_lock around the call in v3. Concurrent callers are serialized by that mutex.
Quoted 39 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +3
-0@@ -279,6 +291,9 @@ static int aq_nic_hw_prepare(struct aq_nic_s *self)int err =0 ; err = self->aq_hw_ops->hw_soft_reset (self->aq_hw); + + self->aq_hw->clk_select =-1 ; +if (err) goto exit;[Medium]
clk_selectis set to -1 here and is then fed, without validation, intohw_atl2_tsg_clock_read()/hw_atl2_tsg_clock_add()/hw_atl2_tsg_clock_sub()/hw_atl2_tsg_clock_increment_set()throughaq_get_ptp_ts(),hw_atl2_adj_sys_clock()andhw_atl2_adj_clock_freq().Those helpers plug the value into
HW_ATL2_TSG_REG_ADR(clock_sel, ...)with no range check. Sinceclk_selectis s8, -1 promoted through the unsigned int parameter becomes0xffffffffand produces an out-of-range MMIO offset.In
aq_ptp_init()the PTP clock is exposed to userspace viaptp_clock_register()beforehw_atl2_enable_ptp()setsclk_selectto 0 or 1. A gettime/adjtime on the newly appearing/dev/ptpNduring that window would land in the above helpers withclk_selectstill equal to -1.Would a guard like "if (
self->clk_select< 0) return 0;" at the top of each of those helpers be appropriate?[Medium]
clk_selectis also written byhw_atl2_enable_ptp()(called fromaq_ptp_init/aq_ptp_free/hw_atl2_hw_reset) and read on the TX fast path viaself->aq_hw_ops->hw_get_clk_sel(self->aq_hw)fromaq_nic_map_skb(), as well as byhw_atl2_hw_rx_ptp_ring_init()andhw_atl2_hw_reset(). There is no lock, no READ_ONCE/WRITE_ONCE, and no atomic wrapper.
Quoted 3 lines
Can a TX in flight during reset/enable/disable observe a torn or stale
clk_selectand either tag a descriptor with the wrong clock selector or propagate -1 into the HW register macros?
Both concerns are addressed in v3. All TSG helpers (aq_get_ptp_ts, hw_atl2_adj_sys_clock, hw_atl2_adj_clock_freq) snapshot clk_select via READ_ONCE and return early if the value is < 0, closing the window between ptp_clock_register and hw_atl2_enable_ptp. The writer (hw_atl2_enable_ptp) uses WRITE_ONCE, and hw_atl2_hw_get_clk_sel on the TX fast path also uses READ_ONCE, preventing torn or stale reads.
Quoted 30 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +14
-1@@ -450,7 +465,14 @@ int aq_nic_init(struct aq_nic_s *self) }if (aq_nic_get_cfg (self)->is_ptp) { - err =aq_ptp_init (self, self->irqvecs -1 ); +u32 ptp_isr_vec; + +if (self->irqvecs >AQ_HW_PTP_IRQS ) + ptp_isr_vec = self->irqvecs -AQ_HW_PTP_IRQS ; +else + ptp_isr_vec =0 ; + + err =aq_ptp_init (self, ptp_isr_vec);@@ -793,6 +823,12 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb, first->eop_index = dx; dx_buff->is_eop =1U ; +if (skb_shinfo (skb)->tx_flags &SKBTX_IN_PROGRESS && + self->aq_hw_ops->enable_ptp && + self->aq_hw_ops->hw_get_clk_sel) { + dx_buff->request_ts =1U ; + dx_buff->clk_sel = self->aq_hw_ops->hw_get_clk_sel (self->aq_hw); + } dx_buff->skb = skb; dx_buff->xdpf =NULL ; goto exit;
Quoted 5 lines
[Critical]
request_tsis armed here wheneverSKBTX_IN_PROGRESSis set and the op pointers exist, not only for PTP traffic.SKBTX_IN_PROGRESSfires for anySO_TIMESTAMPINGsocket on AQC113, which makes the followingaq_ring_tx_clean()path reachable via ordinary unprivileged traffic:
Fixed in v3. The condition now includes aq_ptp_ring(self, ring), so request_ts is only armed when the skb is being sent on the dedicated PTP TX ring. Ordinary SO_TIMESTAMPING traffic on non-PTP rings does not trigger the timestamp polling path.
Quoted 49 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.caq_ring_tx_clean() { ... if (likely(buff->is_mapped)) { ... dma_unmap_single(dev, buff->pa, buff->len, DMA_TO_DEVICE); /* or dma_unmap_page(...) */ } if (unlikely(buff->is_eop)) { if (unlikely(buff->request_ts) && self->aq_nic->aq_hw_ops->hw_ring_tx_ptp_get_ts) { u64 ts = ...->hw_ring_tx_ptp_get_ts(self); if (!ts) break; /* HW has not set DD/TS_VALID yet */ ... } ... } buff->skb = NULL; buff->xdpf = NULL; buff->pa = 0U; ... self->sw_head = aq_ring_next_dx(self, self->sw_head); }
hw_atl2_hw_ring_tx_ptp_get_ts()explicitly returns 0 when DD orTS_VALIDis not yet set, so the zero-timestamp break path is deliberately reachable.On the next
aq_ring_tx_clean()invocation,sw_headis unchanged,buff->is_mappedis still 1, andbuff->pastill holds the original DMA handle. Is the second pass going to calldma_unmap_single()ordma_unmap_page()a second time on the already-unmapped address? A grep for "is_mapped= 0" in the driver returns no matches, sobuff->is_mappedis never cleared by any other path.Additionally, the commit message states:
Poll for TX timestamp completion in
aq_ring_tx_clean()with a timeout mechanism (aq_ptp_tx_ts_timedout/clear)Neither
aq_ptp_tx_ts_timedoutnoraq_ptp_tx_ts_clearexists anywhere in the tree. If HW never produces a timestamp (for example whenrequest_tsis armed butAQ_HW_TXD_CTL_TS_ENis not set, or under a HW glitch),sw_headnever advances and the TX ring wedges until the TX watchdog fires.
Quoted 3 lines
Would it be safer to check the timestamp before any DMA unmap and/or guard the break path so it does not leave
buff->is_mappedandbuff->palive for a repeat unmap?
Both issues are fixed in v3. On the ts == 0 break path, buff->is_mapped and buff->pa are cleared before the break, so the subsequent aq_ring_tx_clean() pass sees is_mapped == 0 and skips the DMA unmap — no double-unmap is possible. The timeout is implemented via self->ptp_ts_deadline: when it expires, request_ts is cleared, the skb is freed, and the loop continues normally, unblocking the ring. The commit message references to aq_ptp_tx_ts_timedout/clear are stale and will be removed in v3.
Quoted 21 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-1@@ -572,53 +770,53 @@ void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp, *config = aq_ptp->hwtstamp_config; } -static void aq_ptp_prepare_filters (struct aq_ptp_s *aq_ptp) +static unsigned int aq_ptp_parse_rx_filters (enum hwtstamp_rx_filters rx_filter) { +return ptp_en_flags; }[Low]
aq_ptp_parse_rx_filters()is typed to take enumhwtstamp_rx_filters, butaq_ptp_clock_init()calls it withAQ_HW_PTP_DISABLE, which belongs to the driver-internal AQ_HW_PTP_* bitmask enum. This works today only becauseAQ_HW_PTP_DISABLEhappens to equalHWTSTAMP_FILTER_NONE(both zero).
Quoted 4 lines
Could the call site pass
HWTSTAMP_FILTER_NONEexplicitly, or the helper be reshaped to take a boolean disable argument, so future renumbering of either enum does not silently break link-down filter teardown?
Fixed in v3. The call site in aq_ptp_clock_init now passes HWTSTAMP_FILTER_NONE explicitly for the disable path, removing the accidental coupling to the zero value of AQ_HW_PTP_DISABLE.
Quoted 45 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +9
-6@@ -972,11 +1179,13 @@ int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic)if (err) goto err_exit_ptp_tx; - err =aq_ring_hwts_rx_alloc (&aq_ptp->hwts_rx, aq_nic,PTP_HWST_RING_IDX , - aq_nic->aq_nic_cfg.rxds, - aq_nic->aq_nic_cfg.aq_hw_caps->rxd_size); -if (err) - goto err_exit_ptp_rx; +if (aq_ptp->a1_ptp) { + err =aq_ring_hwts_rx_alloc (&aq_ptp->hwts_rx, aq_nic,PTP_HWST_RING_IDX , + aq_nic->aq_nic_cfg.rxds, + aq_nic->aq_nic_cfg.aq_hw_caps->rxd_size); +if (err) + goto err_exit_ptp_rx; + } err =aq_ptp_skb_ring_init (&aq_ptp->skb_ring, aq_nic->aq_nic_cfg.rxds);if (err !=0 ) {@@ -984,7 +1193,7 @@ int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic) goto err_exit_hwts_rx; } err_exit_hwts_rx: -aq_ring_hwts_rx_free (&aq_ptp->hwts_rx); +if (aq_ptp->a1_ptp) +aq_ring_free (&aq_ptp->hwts_rx); err_exit_ptp_rx:[High]
aq_ring_hwts_rx_alloc()allocates size *dx_size+AQ_CFG_RXDS_DEFviadma_alloc_coherent(), andaq_ring_hwts_rx_free()passes the same "+AQ_CFG_RXDS_DEF" back todma_free_coherent(). The replacement callaq_ring_free()here passes onlyself->size*self->dx_size:
drivers/net/ethernet/aquantia/atlantic/aq_ring.caq_ring_free() { ... dma_free_coherent(aq_nic_get_dev(self->aq_nic), self->size * self->dx_size, self->dx_ring, self->dx_ring_pa); ... }
Quoted 6 lines
The DMA API requires
dma_free_coherent()to be called with the same size asdma_alloc_coherent(). The non-error path inaq_ptp_ring_free()still callsaq_ring_hwts_rx_free().Is this asymmetric free intentional, and if not, should the error path use
aq_ring_hwts_rx_free()as well?
Fixed in v3. The error path at err_exit_hwts_rx now uses aq_ring_hwts_rx_free(), matching the + AQ_CFG_RXDS_DEF allocation size passed to dma_alloc_coherent().
Quoted 22 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +13
-0@@ -1244,30 +1514,45 @@ void aq_ptp_free(struct aq_nic_s *aq_nic)if (!aq_ptp)return ; +/* disable ptp */ +if (aq_ptp->a1_ptp) { +mutex_lock (&aq_nic->fwreq_mutex); + aq_nic->aq_fw_ops->enable_ptp (aq_nic->aq_hw,0 ); +mutex_unlock (&aq_nic->fwreq_mutex); + } + +if (aq_ptp->a2_ptp) + aq_nic->aq_hw_ops->enable_ptp (aq_nic->aq_hw, + aq_ptp->ptp_clock_sel,0 ); + +cancel_delayed_work_sync (&aq_ptp->poll_sync); +[Medium]
The prior ordering cancelledpoll_syncbefore disabling PTP. This hunk disables PTP first and then cancels the delayed work.
Quoted 8 lines
aq_ptp_poll_sync_work_cb()callsaq_ptp_check_sync1588(), which touches PTP hardware state (hw_ts_to_sys_clock,ptp_clock_eventonaq_ptp->ptp_clock) and reschedules itself viaschedule_delayed_work()whenextts_pin_enabledis set.Can a pending callback run against PTP hardware that was just turned off, and would it be better to
cancel_delayed_work_sync()first and only then tear the hardware down?
Fixed in v3. cancel_delayed_work_sync(&aq_ptp->poll_sync) is called first, then PTP is disabled — matching the standard pattern of cancelling workers before tearing down the resources they access.
Quoted 36 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +0
-0@@ -308,24 +308,30 @@ bool aq_ring_tx_clean(struct aq_ring_s *self)[ ... see Critical comment above on
dma_unmap/ break ordering ... ]drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +20
-0@@ -886,6 +912,138 @@ static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) +static int hw_atl2_gpio_pulse (struct aq_hw_s *self,u32 index,u32 clk_sel, +u64 start,u32 period,u32 hightime) +{ +u32 mode; + +if (start ==0 ) + mode =HW_ATL2_GPIO_PIN_SPEC_MODE_GPIO ; +else if (clk_sel ==ATL_TSG_CLOCK_SEL_0 ) + mode =HW_ATL2_GPIO_PIN_SPEC_MODE_TSG0_EVENT_OUTPUT ; +else + mode =HW_ATL2_GPIO_PIN_SPEC_MODE_TSG1_EVENT_OUTPUT ; + +if (index ==1 || index ==3 ) {/* Hardware limitation */ +hw_atl2_gpio_special_mode_set (self, mode, index); + } + +hw_atl2_tsg_ptp_gpio_gen_pulse (self, clk_sel, start, period, hightime); + +return 0 ; +}[Medium]
hw_atl2_gpio_special_mode_set()is only called when index is 1 or 3, buthw_atl2_tsg_ptp_gpio_gen_pulse()is invoked unconditionally and 0 is returned for every index.
Quoted 7 lines
For a
PTP_PIN_SETFUNCon pin 0, 2 or any other non-special index, the TSG pulse generator is armed but the pin mux is never reprogrammed, so no signal appears on the pin and the userspace request appears to succeed.Should invalid indices be rejected with
-EINVAL, or should the pulse generator only be armed when the pin can actually be muxed?
Fixed in v3. Added early return -EINVAL for indices other than 1 and 3. hw_atl2_tsg_ptp_gpio_gen_pulse remains unconditional so the period=0 disable path always reaches hardware.
Quoted 19 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +2
-1@@ -29,7 +29,8 @@#define HW_ATL2_TXBUF_MAX 128U#define HW_ATL2_PTP_TXBUF_SIZE 8U -#define HW_ATL2_RXBUF_MAX 192U +/* Reduced from 192 to reserve space for PTP RX timestamp trailer */ +#define HW_ATL2_RXBUF_MAX 172U#define HW_ATL2_PTP_RXBUF_SIZE 16U[Medium]
HW_ATL2_RXBUF_MAXis reduced unconditionally for every AQC113 user, buthw_atl2_hw_qos_set()already subtractsHW_ATL2_PTP_RXBUF_SIZEwhencfg->is_ptpis true, so the reduction appears redundant when PTP is enabled and a pure loss for non-PTP deployments.
Quoted 6 lines
The justification in the comment is per-packet (
HW_ATL2_RX_TS_SIZEis 8 bytes, handled inhw_atl2_hw_rx_extract_ts), while this register programs the on-chip packet-buffer KB allocation.Could this change be gated on
cfg->is_ptp, or is there a separate reason to take ~10% of the RX packet buffer from non-PTP users?
172 is the correct hardware maximum for AQC113 data TCs — AQC113 has a smaller on-chip RX packet buffer than A1. With PTP enabled, hw_atl2_hw_qos_set() correctly subtracts HW_ATL2_PTP_RXBUF_SIZE (16 KB) from 172, giving 156 KB for regular TCs and 16 KB for the PTP TC. Setting it to 192 causes ptp4l to fail, confirming 172 is the hardware constraint. The comment will be updated in v3 to clarify this is a hardware limit, not a PTP-related reduction.
Quoted 2 lines
Signature · 1 line
This is an AI-generated review.
Paolo Abeni
maintainerRe: [PATCH net-next v2 9/9] net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
In reply to [email protected]Quoted 62 lines · On 5/8/26 2:01 PM, [email protected] wrote:
From: Sukhdeep Singh <[email protected]>
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 accessKey implementation details:
PTP clock management:
- Addaq_ptp_stateenum 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 lostTX timestamp path:
- Add per-packet TX timestamp request via request_ts/clk_sel in the ring buffer descriptor
- Poll for TX timestamp completion inaq_ring_tx_clean()with a timeout mechanism (aq_ptp_tx_ts_timedout/clear)
- SetAQ_HW_TXD_CTL_TS_ENin TX descriptors for timestamp-requested packetsRX 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)
- Addaq_ptp_dpath_enable()for comprehensive filter setup/teardown
- Addaq_ptp_parse_rx_filters()to maphwtstamp_rx_filtersto L2/L4 enable flagsPTP 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
- Moveskb_tx_timestamp()to non-PTP path to avoid double timestampsIRQ and initialization:
- Account for PTP IRQ vector (AQ_HW_PTP_IRQS) in vector math
- Move filter/VLAN rule application toaq_nic_start()for proper ordering after PTP ring setup
- AddAQ_HW_FLAG_STARTEDflag management in open/closeHW 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 intohw_atl2_opstablePer-instance PTP offsets with empirically measured values for AQC113 at each link speed (100M/1G/2.5G/5G/10G).
Signed-off-by Sukhdeep Singh <[email protected]>
Quoted 13 lines
--- .../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.
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c static struct ptp_clock_info aq_ptp_clock = { · line 1250
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-5@@ -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).
[...]
Quoted 15 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +0
-7@@ -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;
drivers/net/ethernet/aquantia/atlantic/aq_ring.c bool aq_ring_tx_clean(struct aq_ring_s *self) · line 311
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +1
-9-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.
Quoted 27 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +22
-1+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 ;
[...]
drivers/net/ethernet/aquantia/atlantic/aq_ring.c static struct aq_stats_s *hw_atl2_utils_get_hw_stats(struct aq_hw_s *self) · line 918
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +4
-0@@ -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.
Sukhdeep Soni [C]
maintainerRE: [EXTERNAL] Re: [PATCH net-next v2 9/9] net: atlantic: add PTP support for AQC113 (Antigua) (Antigua)
Quoted 77 lines · Paolo Abeni
On 5/8/26 2:01 PM, mailto:[email protected] wrote:
From: Sukhdeep Singh <mailto:[email protected]>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 accessKey implementation details:
PTP clock management:
- Addaq_ptp_stateenum 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 lostTX timestamp path:
- Add per-packet TX timestamp request via request_ts/clk_sel in the ring buffer descriptor
- Poll for TX timestamp completion inaq_ring_tx_clean()with a timeout mechanism (aq_ptp_tx_ts_timedout/clear)
- SetAQ_HW_TXD_CTL_TS_ENin TX descriptors for timestamp-requested packetsRX 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)
- Addaq_ptp_dpath_enable()for comprehensive filter setup/teardown
- Addaq_ptp_parse_rx_filters()to maphwtstamp_rx_filtersto L2/L4 enable flagsPTP 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
- Moveskb_tx_timestamp()to non-PTP path to avoid double timestampsIRQ and initialization:
- Account for PTP IRQ vector (AQ_HW_PTP_IRQS) in vector math
- Move filter/VLAN rule application toaq_nic_start()for proper ordering after PTP ring setup
- AddAQ_HW_FLAG_STARTEDflag management in open/closeHW 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 intohw_atl2_opstablePer-instance PTP offsets with empirically measured values for AQC113 at each link speed (100M/1G/2.5G/5G/10G).
Signed-off-by Sukhdeep Singh <mailto:[email protected]>--- .../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(-)
Quoted 1 line
Very large patch, you should try to break it in smaller chunks.
Agreed, will split patch 9 into smaller pieces in v3.
Quoted 12 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-5@@ -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)
Quoted 3 lines
'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).
Fixed in v3. inline removed.
Quoted 30 lines
[...]
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +1
-16@@ -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
Quoted 1 line
Also, using a goto statement would avoid excessive indentation.
Fixed in v3. Restored the original if (likely(!buff->is_eop)) goto out; pattern — the unlikely wrapping and deep nesting are gone. The PTP timestamp block sits at the same indentation level as the original skb/xdpf handling.
Quoted 27 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +22
-1+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 ;
[...]
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +4
-0@@ -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.
Fixed in v3. The wrapper is removed; AQ2_HW_PTP_COUNTER_HZ is used directly.
Jakub Kicinski
maintainerQuoted 1 line · On Fri, 8 May 2026 17:31:47 +0530 [email protected] wrote:
From: Sukhdeep Singh <[email protected]>
I have a process question. Who is maintaining this driver? MAINTAINERS list Igor but he didn't sign off any of the patches. Occasionally we get patches for this driver from users and other developers and none of you Marvell people respond. Please have a read of:
https://docs.kernel.org/next/maintainer/feature-and-driver-maintainers.html
and tell me - who is serving as the maintainer of atlantic?
Sukhdeep Soni [C]
maintainerQuoted 9 lines · Jakub Kicinski
On Fri, 8 May 2026 17:31:47 +0530 [email protected] wrote:
From: Sukhdeep Singh <[email protected]>
I have a process question. Who is maintaining this driver?MAINTAINERSlist Igor but he didn't sign off any of the patches. Occasionally we get patches for this driver from users and other developers and none of you Marvell people respond. Please have a read of:
https://docs.kernel.org/next/maintainer/feature-and-driver-maintainers.html
and tell me - who is serving as the maintainer of atlantic?
Thank you for raising this. Igor Russkikh has left Marvell and I have
taken over as the maintainer of the atlantic driver. I apologize for the lack of responses to community patches — I was not aware of the outstanding submissions until now.
I will:
- Review all pending patches for the atlantic driver on the mailing list
- Respond within the netdev review SLA going forward
- Submit a patch to update the MAINTAINERS file to reflect the change
I take the maintainer responsibilities seriously as described in the documentation you referenced.
Sukhdeep Singh
Marvell
Jakub Kicinski
maintainerQuoted 5 lines · On Mon, 11 May 2026 12:26:23 +0000 Sukhdeep Soni [C] wrote:
Thank you for raising this. Igor Russkikh has left Marvell and I have
taken over as the maintainer of the atlantic driver. I apologize for the lack of responses to community patches — I was not aware of the outstanding submissions until now.
Quoted 7 lines
I will:
- Review all pending patches for the atlantic driver on the mailing list
- Respond within the netdev review SLA going forward
- Submit a patch to update theMAINTAINERSfile to reflect the changeI take the maintainer responsibilities seriously as described in the documentation you referenced.
Ack, thanks for reviewing the pending submission! Looking forward to the MAINTAINERS update. (We'll get to reviewing this series in due course.)
Simon Horman
reviewerQuoted 5 lines · On Fri, May 08, 2026 at 05:31:47PM +0530, [email protected] wrote:
From: Sukhdeep Singh <[email protected]>
This series adds IEEE 1588 PTP support for the AQC113 (Antigua) network controller. AQC113 is the successor to the existing AQC107 (Atlantic) chip already supported by the atlantic driver.
...
Hi Sukhdeep,
There are AI-generated reviews of this patchset available on
https://netdev-ai.bots.linux.dev and https://sashiko.dev
with some overlap between them.
I would appreciate it if you could look over these and address issues that are either introduced by or effect the functionality of this patch-set. I suggest leaving other pre-existing issues as follow-up so as not to expand the scope of this patch-set.
Sukhdeep Soni [C]
maintainerQuoted 11 lines · Simon Horman
On Fri, May 08, 2026 at 05:31:47PM +0530, mailto:[email protected] wrote:
From: Sukhdeep Singh <mailto:[email protected]>This series adds IEEE 1588 PTP support for the AQC113 (Antigua) network controller. AQC113 is the successor to the existing AQC107 (Atlantic) chip already supported by the atlantic driver.
...
Hi Sukhdeep,
Quoted 8 lines
There are AI-generated reviews of this patchset available on
https://netdev-ai.bots.linux.dev and https://sashiko.dev
with some overlap between them.I would appreciate it if you could look over these and address issues that are either introduced by or effect the functionality of this patch-set. I suggest leaving other pre-existing issues as follow-up so as not to expand the scope of this patch-set.
Thank you for the pointers. I have reviewed the AI-generated feedback on both sites and will address the relevant issues in v3.