Skip to content

Commit 4378b88

Browse files
caildavem330
authored andcommitted
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 <[email protected]> Signed-off-by: Mark Starovoytov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8664240 commit 4378b88

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,9 @@ static int aq_ethtool_get_ts_info(struct net_device *ndev,
607607
BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
608608
BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);
609609

610+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
610611
info->phc_index = ptp_clock_index(aq_ptp_get_ptp_clock(aq_nic->aq_ptp));
612+
#endif
611613

612614
return 0;
613615
}

drivers/net/ethernet/aquantia/atlantic/aq_main.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0-only
2-
/*
3-
* aQuantia Corporation Network Driver
4-
* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved
2+
/* Atlantic Network Driver
3+
*
4+
* Copyright (C) 2014-2019 aQuantia Corporation
5+
* Copyright (C) 2019-2020 Marvell International Ltd.
56
*/
67

78
/* 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)
9899
{
99100
struct aq_nic_s *aq_nic = netdev_priv(ndev);
100101

102+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
101103
if (unlikely(aq_utils_obj_test(&aq_nic->flags, AQ_NIC_PTP_DPATH_UP))) {
102104
/* Hardware adds the Timestamp for PTPv2 802.AS1
103105
* and PTPv2 IPv4 UDP.
@@ -114,6 +116,7 @@ static int aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *ndev)
114116
unlikely(eth_hdr(skb)->h_proto == htons(ETH_P_1588)))
115117
return aq_ptp_xmit(aq_nic, skb);
116118
}
119+
#endif
117120

118121
skb_tx_timestamp(skb);
119122
return aq_nic_xmit(aq_nic, skb);
@@ -222,6 +225,7 @@ static void aq_ndev_set_multicast_settings(struct net_device *ndev)
222225
(void)aq_nic_set_multicast_list(aq_nic, ndev);
223226
}
224227

228+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
225229
static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,
226230
struct hwtstamp_config *config)
227231
{
@@ -256,26 +260,31 @@ static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,
256260

257261
return aq_ptp_hwtstamp_config_set(aq_nic->aq_ptp, config);
258262
}
263+
#endif
259264

260265
static int aq_ndev_hwtstamp_set(struct aq_nic_s *aq_nic, struct ifreq *ifr)
261266
{
262267
struct hwtstamp_config config;
268+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
263269
int ret_val;
270+
#endif
264271

265272
if (!aq_nic->aq_ptp)
266273
return -EOPNOTSUPP;
267274

268275
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
269276
return -EFAULT;
270-
277+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
271278
ret_val = aq_ndev_config_hwtstamp(aq_nic, &config);
272279
if (ret_val)
273280
return ret_val;
281+
#endif
274282

275283
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
276284
-EFAULT : 0;
277285
}
278286

287+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
279288
static int aq_ndev_hwtstamp_get(struct aq_nic_s *aq_nic, struct ifreq *ifr)
280289
{
281290
struct hwtstamp_config config;
@@ -287,6 +296,7 @@ static int aq_ndev_hwtstamp_get(struct aq_nic_s *aq_nic, struct ifreq *ifr)
287296
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
288297
-EFAULT : 0;
289298
}
299+
#endif
290300

291301
static int aq_ndev_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
292302
{
@@ -296,8 +306,10 @@ static int aq_ndev_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
296306
case SIOCSHWTSTAMP:
297307
return aq_ndev_hwtstamp_set(aq_nic, ifr);
298308

309+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
299310
case SIOCGHWTSTAMP:
300311
return aq_ndev_hwtstamp_get(aq_nic, ifr);
312+
#endif
301313
}
302314

303315
return -EOPNOTSUPP;

drivers/net/ethernet/aquantia/atlantic/aq_ptp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0-only
2-
/* Aquantia Corporation Network Driver
3-
* Copyright (C) 2014-2019 Aquantia Corporation. All rights reserved
2+
/* Atlantic Network Driver
3+
*
4+
* Copyright (C) 2014-2019 aQuantia Corporation
5+
* Copyright (C) 2019-2020 Marvell International Ltd.
46
*/
57

68
/* File aq_ptp.c:
@@ -18,6 +20,8 @@
1820
#include "aq_phy.h"
1921
#include "aq_filters.h"
2022

23+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
24+
2125
#define AQ_PTP_TX_TIMEOUT (HZ * 10)
2226

2327
#define POLL_SYNC_TIMER_MS 15
@@ -1389,3 +1393,4 @@ static void aq_ptp_poll_sync_work_cb(struct work_struct *w)
13891393
schedule_delayed_work(&aq_ptp->poll_sync, timeout);
13901394
}
13911395
}
1396+
#endif

drivers/net/ethernet/aquantia/atlantic/aq_ring.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ int aq_ring_rx_clean(struct aq_ring_s *self,
490490

491491
void aq_ring_hwts_rx_clean(struct aq_ring_s *self, struct aq_nic_s *aq_nic)
492492
{
493+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
493494
while (self->sw_head != self->hw_head) {
494495
u64 ns;
495496

@@ -501,6 +502,7 @@ void aq_ring_hwts_rx_clean(struct aq_ring_s *self, struct aq_nic_s *aq_nic)
501502

502503
self->sw_head = aq_ring_next_dx(self, self->sw_head);
503504
}
505+
#endif
504506
}
505507

506508
int aq_ring_rx_fill(struct aq_ring_s *self)

0 commit comments

Comments
 (0)