mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
net: atlantic: decouple aq_set_data_fl3l4() from driver internals
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. Signed-off-by: Sukhdeep Singh <sukhdeeps@marvell.com> Link: https://patch.msgid.link/20260610115448.272-4-sukhdeeps@marvell.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
dfb7a7468b
commit
7bd1820974
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user