mirror of https://gitee.com/openkylin/linux.git
net: atlantic: put ptp code under IS_REACHABLE check
A1 requires additional processing for both egress and ingress to support PTP. And it makes sense to get rid of this processing altogether (via ifdef), if PTP clock is disabled globally. This patch puts the PTP code under the corresponding IS_REACHABLE check. Signed-off-by: Igor Russkikh <irusskikh@marvell.com> Signed-off-by: Mark Starovoytov <mstarovoitov@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8664240e30
commit
4378b882bf
|
@ -607,7 +607,9 @@ static int aq_ethtool_get_ts_info(struct net_device *ndev,
|
||||||
BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
|
BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
|
||||||
BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);
|
BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);
|
||||||
|
|
||||||
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
||||||
info->phc_index = ptp_clock_index(aq_ptp_get_ptp_clock(aq_nic->aq_ptp));
|
info->phc_index = ptp_clock_index(aq_ptp_get_ptp_clock(aq_nic->aq_ptp));
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/*
|
/* Atlantic Network Driver
|
||||||
* aQuantia Corporation Network Driver
|
*
|
||||||
* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved
|
* Copyright (C) 2014-2019 aQuantia Corporation
|
||||||
|
* Copyright (C) 2019-2020 Marvell International Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* File aq_main.c: Main file for aQuantia Linux driver. */
|
/* File aq_main.c: Main file for aQuantia Linux driver. */
|
||||||
|
@ -98,6 +99,7 @@ static int aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *ndev)
|
||||||
{
|
{
|
||||||
struct aq_nic_s *aq_nic = netdev_priv(ndev);
|
struct aq_nic_s *aq_nic = netdev_priv(ndev);
|
||||||
|
|
||||||
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
||||||
if (unlikely(aq_utils_obj_test(&aq_nic->flags, AQ_NIC_PTP_DPATH_UP))) {
|
if (unlikely(aq_utils_obj_test(&aq_nic->flags, AQ_NIC_PTP_DPATH_UP))) {
|
||||||
/* Hardware adds the Timestamp for PTPv2 802.AS1
|
/* Hardware adds the Timestamp for PTPv2 802.AS1
|
||||||
* and PTPv2 IPv4 UDP.
|
* and PTPv2 IPv4 UDP.
|
||||||
|
@ -114,6 +116,7 @@ static int aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *ndev)
|
||||||
unlikely(eth_hdr(skb)->h_proto == htons(ETH_P_1588)))
|
unlikely(eth_hdr(skb)->h_proto == htons(ETH_P_1588)))
|
||||||
return aq_ptp_xmit(aq_nic, skb);
|
return aq_ptp_xmit(aq_nic, skb);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
skb_tx_timestamp(skb);
|
skb_tx_timestamp(skb);
|
||||||
return aq_nic_xmit(aq_nic, skb);
|
return aq_nic_xmit(aq_nic, skb);
|
||||||
|
@ -222,6 +225,7 @@ static void aq_ndev_set_multicast_settings(struct net_device *ndev)
|
||||||
(void)aq_nic_set_multicast_list(aq_nic, ndev);
|
(void)aq_nic_set_multicast_list(aq_nic, ndev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
||||||
static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,
|
static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,
|
||||||
struct hwtstamp_config *config)
|
struct hwtstamp_config *config)
|
||||||
{
|
{
|
||||||
|
@ -256,26 +260,31 @@ static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,
|
||||||
|
|
||||||
return aq_ptp_hwtstamp_config_set(aq_nic->aq_ptp, config);
|
return aq_ptp_hwtstamp_config_set(aq_nic->aq_ptp, config);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int aq_ndev_hwtstamp_set(struct aq_nic_s *aq_nic, struct ifreq *ifr)
|
static int aq_ndev_hwtstamp_set(struct aq_nic_s *aq_nic, struct ifreq *ifr)
|
||||||
{
|
{
|
||||||
struct hwtstamp_config config;
|
struct hwtstamp_config config;
|
||||||
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
||||||
int ret_val;
|
int ret_val;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!aq_nic->aq_ptp)
|
if (!aq_nic->aq_ptp)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
|
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
||||||
ret_val = aq_ndev_config_hwtstamp(aq_nic, &config);
|
ret_val = aq_ndev_config_hwtstamp(aq_nic, &config);
|
||||||
if (ret_val)
|
if (ret_val)
|
||||||
return ret_val;
|
return ret_val;
|
||||||
|
#endif
|
||||||
|
|
||||||
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
|
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
|
||||||
-EFAULT : 0;
|
-EFAULT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
||||||
static int aq_ndev_hwtstamp_get(struct aq_nic_s *aq_nic, struct ifreq *ifr)
|
static int aq_ndev_hwtstamp_get(struct aq_nic_s *aq_nic, struct ifreq *ifr)
|
||||||
{
|
{
|
||||||
struct hwtstamp_config config;
|
struct hwtstamp_config config;
|
||||||
|
@ -287,6 +296,7 @@ static int aq_ndev_hwtstamp_get(struct aq_nic_s *aq_nic, struct ifreq *ifr)
|
||||||
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
|
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
|
||||||
-EFAULT : 0;
|
-EFAULT : 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int aq_ndev_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
|
static int aq_ndev_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
|
||||||
{
|
{
|
||||||
|
@ -296,8 +306,10 @@ static int aq_ndev_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
|
||||||
case SIOCSHWTSTAMP:
|
case SIOCSHWTSTAMP:
|
||||||
return aq_ndev_hwtstamp_set(aq_nic, ifr);
|
return aq_ndev_hwtstamp_set(aq_nic, ifr);
|
||||||
|
|
||||||
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
||||||
case SIOCGHWTSTAMP:
|
case SIOCGHWTSTAMP:
|
||||||
return aq_ndev_hwtstamp_get(aq_nic, ifr);
|
return aq_ndev_hwtstamp_get(aq_nic, ifr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/* Aquantia Corporation Network Driver
|
/* Atlantic Network Driver
|
||||||
* Copyright (C) 2014-2019 Aquantia Corporation. All rights reserved
|
*
|
||||||
|
* Copyright (C) 2014-2019 aQuantia Corporation
|
||||||
|
* Copyright (C) 2019-2020 Marvell International Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* File aq_ptp.c:
|
/* File aq_ptp.c:
|
||||||
|
@ -18,6 +20,8 @@
|
||||||
#include "aq_phy.h"
|
#include "aq_phy.h"
|
||||||
#include "aq_filters.h"
|
#include "aq_filters.h"
|
||||||
|
|
||||||
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
||||||
|
|
||||||
#define AQ_PTP_TX_TIMEOUT (HZ * 10)
|
#define AQ_PTP_TX_TIMEOUT (HZ * 10)
|
||||||
|
|
||||||
#define POLL_SYNC_TIMER_MS 15
|
#define POLL_SYNC_TIMER_MS 15
|
||||||
|
@ -1389,3 +1393,4 @@ static void aq_ptp_poll_sync_work_cb(struct work_struct *w)
|
||||||
schedule_delayed_work(&aq_ptp->poll_sync, timeout);
|
schedule_delayed_work(&aq_ptp->poll_sync, timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -490,6 +490,7 @@ int aq_ring_rx_clean(struct aq_ring_s *self,
|
||||||
|
|
||||||
void aq_ring_hwts_rx_clean(struct aq_ring_s *self, struct aq_nic_s *aq_nic)
|
void aq_ring_hwts_rx_clean(struct aq_ring_s *self, struct aq_nic_s *aq_nic)
|
||||||
{
|
{
|
||||||
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
||||||
while (self->sw_head != self->hw_head) {
|
while (self->sw_head != self->hw_head) {
|
||||||
u64 ns;
|
u64 ns;
|
||||||
|
|
||||||
|
@ -501,6 +502,7 @@ void aq_ring_hwts_rx_clean(struct aq_ring_s *self, struct aq_nic_s *aq_nic)
|
||||||
|
|
||||||
self->sw_head = aq_ring_next_dx(self, self->sw_head);
|
self->sw_head = aq_ring_next_dx(self, self->sw_head);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int aq_ring_rx_fill(struct aq_ring_s *self)
|
int aq_ring_rx_fill(struct aq_ring_s *self)
|
||||||
|
|
Loading…
Reference in New Issue