nvethernet: read ptp mac to mac role

Read PTP MAC to MAC sync role,
update osi_core structure and configure PTP
for interface.

Bug 200733666

Change-Id: I43c88ad05e36c979d337549127cb73498b9ddd78
Signed-off-by: Rakesh Goyal <rgoyal@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2568595
Reviewed-by: Nagarjuna Kristam <nkristam@nvidia.com>
Reviewed-by: Srinivas Ramachandran <srinivasra@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Bhadram Varka <vbhadram@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Rakesh Goyal
2021-08-01 13:52:47 +05:30
committed by Revanth Kumar Uppala
parent db74724d08
commit 9093f4e86f
2 changed files with 57 additions and 0 deletions

View File

@@ -5335,6 +5335,8 @@ static int ether_parse_dt(struct ether_priv_data *pdata)
int ret = -EINVAL;
unsigned int i, mtlq, chan, bitmap;
unsigned int dt_pad_calibration_enable;
/* This variable is for DT entry which should not fail bootup */
int ret_val = 0;
/* Read flag to skip MAC reset on platform */
ret = of_property_read_u32(np, "nvidia,skip_mac_reset",
@@ -5797,6 +5799,13 @@ static int ether_parse_dt(struct ether_priv_data *pdata)
goto exit;
}
}
/* Set MAC to MAC time sync role */
ret_val = of_property_read_u32(np, "nvidia,ptp_m2m_role",
&osi_core->m2m_role);
if (ret_val < 0 || osi_core->m2m_role > OSI_PTP_M2M_SECONDARY) {
osi_core->m2m_role = OSI_PTP_M2M_INACTIVE;
}
exit:
return ret;
}

View File

@@ -229,6 +229,50 @@ static struct ptp_clock_info ether_ptp_clock_ops = {
.settime64 = ether_set_time,
};
int ether_early_ptp_init(struct ether_priv_data *pdata)
{
struct osi_core_priv_data *osi_core = pdata->osi_core;
struct osi_ioctl ioctl_data = {};
int ret = 0;
#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
struct timespec now;
#else
struct timespec64 now;
#endif
osi_core->ptp_config.ptp_filter =
OSI_MAC_TCR_TSENA | OSI_MAC_TCR_TSCFUPDT |
OSI_MAC_TCR_TSCTRLSSR | OSI_MAC_TCR_TSVER2ENA |
OSI_MAC_TCR_TSIPENA | OSI_MAC_TCR_TSIPV6ENA |
OSI_MAC_TCR_TSIPV4ENA | OSI_MAC_TCR_SNAPTYPSEL_1;
/* Store default PTP clock frequency, so that we
* can make use of it for coarse correction */
osi_core->ptp_config.ptp_clock = pdata->ptp_ref_clock_speed;
/* initialize system time */
#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
getnstimeofday(&now);
#else
ktime_get_real_ts64(&now);
#endif
/* Store sec and nsec */
osi_core->ptp_config.sec = now.tv_sec;
osi_core->ptp_config.nsec = now.tv_nsec;
/* one nsec accuracy */
osi_core->ptp_config.one_nsec_accuracy = OSI_ENABLE;
/* enable the PTP configuration */
ioctl_data.arg1_u32 = OSI_ENABLE;
ioctl_data.cmd = OSI_CMD_CONFIG_PTP;
ret = osi_handle_ioctl(osi_core, &ioctl_data);
if (ret < 0) {
dev_err(pdata->dev, "Failure to enable CONFIG_PTP\n");
return -EFAULT;
}
return ret;
}
int ether_ptp_init(struct ether_priv_data *pdata)
{
if (pdata->hw_feat.tsstssel == OSI_DISABLE) {
@@ -251,6 +295,10 @@ int ether_ptp_init(struct ether_priv_data *pdata)
/* By default enable nano second accuracy */
pdata->osi_core->ptp_config.one_nsec_accuracy = OSI_ENABLE;
if ((pdata->osi_core->m2m_role == OSI_PTP_M2M_PRIMARY) ||
(pdata->osi_core->m2m_role == OSI_PTP_M2M_SECONDARY)) {
return ether_early_ptp_init(pdata);
}
return 0;
}