-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: aquantia: PTP skeleton declarations and callbacks
Here we add basic function for PTP clock register/unregister. We also declare FW/HW capability bits used to control PTP feature on device. PTP device is created if network card has appropriate FW that has PTP enabled in config. HW supports timestamping for PTPv2 802.AS1 and PTPv2 IPv4 UDP packets. It also supports basic PTP callbacks for getting/setting time, adjusting frequency and time as well. Signed-off-by: Egor Pomozov <epomozov@marvell.com> Co-developed-by: Sergey Samoilenko <sergey.samoilenko@aquantia.com> Signed-off-by: Sergey Samoilenko <sergey.samoilenko@aquantia.com> Co-developed-by: Dmitry Bezrukov <dmitry.bezrukov@aquantia.com> Signed-off-by: Dmitry Bezrukov <dmitry.bezrukov@aquantia.com> Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Egor Pomozov
authored and
David S. Miller
committed
Oct 24, 2019
1 parent
337d866
commit 1a64f8d
Showing
6 changed files
with
201 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* Aquantia Corporation Network Driver | ||
* Copyright (C) 2014-2019 Aquantia Corporation. All rights reserved | ||
*/ | ||
|
||
/* File aq_ptp.c: | ||
* Definition of functions for Linux PTP support. | ||
*/ | ||
|
||
#include <linux/ptp_clock_kernel.h> | ||
#include <linux/clocksource.h> | ||
|
||
#include "aq_nic.h" | ||
#include "aq_ptp.h" | ||
|
||
struct aq_ptp_s { | ||
struct aq_nic_s *aq_nic; | ||
struct ptp_clock *ptp_clock; | ||
struct ptp_clock_info ptp_info; | ||
}; | ||
|
||
static struct ptp_clock_info aq_ptp_clock = { | ||
.owner = THIS_MODULE, | ||
.name = "atlantic ptp", | ||
.n_ext_ts = 0, | ||
.pps = 0, | ||
.n_per_out = 0, | ||
.n_pins = 0, | ||
.pin_config = NULL, | ||
}; | ||
|
||
int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec) | ||
{ | ||
struct hw_atl_utils_mbox mbox; | ||
struct aq_ptp_s *aq_ptp; | ||
int err = 0; | ||
|
||
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; | ||
} | ||
|
||
aq_ptp = kzalloc(sizeof(*aq_ptp), GFP_KERNEL); | ||
if (!aq_ptp) { | ||
err = -ENOMEM; | ||
goto err_exit; | ||
} | ||
|
||
aq_ptp->aq_nic = aq_nic; | ||
|
||
aq_ptp->ptp_info = aq_ptp_clock; | ||
|
||
aq_nic->aq_ptp = aq_ptp; | ||
|
||
return 0; | ||
|
||
err_exit: | ||
kfree(aq_ptp); | ||
aq_nic->aq_ptp = NULL; | ||
return err; | ||
} | ||
|
||
void aq_ptp_unregister(struct aq_nic_s *aq_nic) | ||
{ | ||
struct aq_ptp_s *aq_ptp = aq_nic->aq_ptp; | ||
|
||
if (!aq_ptp) | ||
return; | ||
|
||
ptp_clock_unregister(aq_ptp->ptp_clock); | ||
} | ||
|
||
void aq_ptp_free(struct aq_nic_s *aq_nic) | ||
{ | ||
struct aq_ptp_s *aq_ptp = aq_nic->aq_ptp; | ||
|
||
if (!aq_ptp) | ||
return; | ||
|
||
kfree(aq_ptp); | ||
aq_nic->aq_ptp = NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* Aquantia Corporation Network Driver | ||
* Copyright (C) 2014-2019 Aquantia Corporation. All rights reserved | ||
*/ | ||
|
||
/* File aq_ptp.h: Declaration of PTP functions. | ||
*/ | ||
#ifndef AQ_PTP_H | ||
#define AQ_PTP_H | ||
|
||
#include <linux/net_tstamp.h> | ||
#include <linux/version.h> | ||
|
||
/* Common functions */ | ||
int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec); | ||
|
||
void aq_ptp_unregister(struct aq_nic_s *aq_nic); | ||
void aq_ptp_free(struct aq_nic_s *aq_nic); | ||
|
||
void aq_ptp_clock_init(struct aq_nic_s *aq_nic); | ||
|
||
#endif /* AQ_PTP_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters