MCPcopy Create free account
hub / github.com/F-Stack/f-stack / axgbe_timesync_enable

Function axgbe_timesync_enable

dpdk/drivers/net/axgbe/axgbe_ethdev.c:1665–1729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1663}
1664
1665static int
1666axgbe_timesync_enable(struct rte_eth_dev *dev)
1667{
1668 struct axgbe_port *pdata = dev->data->dev_private;
1669 unsigned int mac_tscr = 0;
1670 uint64_t dividend;
1671 struct timespec timestamp;
1672 uint64_t nsec;
1673
1674 /* Set one nano-second accuracy */
1675 AXGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSCTRLSSR, 1);
1676
1677 /* Set fine timestamp update */
1678 AXGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSCFUPDT, 1);
1679
1680 /* Overwrite earlier timestamps */
1681 AXGMAC_SET_BITS(mac_tscr, MAC_TSCR, TXTSSTSM, 1);
1682
1683 AXGMAC_IOWRITE(pdata, MAC_TSCR, mac_tscr);
1684
1685 /* Enabling processing of ptp over eth pkt */
1686 AXGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPENA, 1);
1687 AXGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
1688 /* Enable timestamp for all pkts*/
1689 AXGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSENALL, 1);
1690
1691 /* enabling timestamp */
1692 AXGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSENA, 1);
1693 AXGMAC_IOWRITE(pdata, MAC_TSCR, mac_tscr);
1694
1695 /* Exit if timestamping is not enabled */
1696 if (!AXGMAC_GET_BITS(mac_tscr, MAC_TSCR, TSENA)) {
1697 PMD_DRV_LOG(ERR, "Exiting as timestamp is not enabled\n");
1698 return 0;
1699 }
1700
1701 /* Sub-second Increment Value*/
1702 AXGMAC_IOWRITE_BITS(pdata, MAC_SSIR, SSINC, AXGBE_TSTAMP_SSINC);
1703 /* Sub-nanosecond Increment Value */
1704 AXGMAC_IOWRITE_BITS(pdata, MAC_SSIR, SNSINC, AXGBE_TSTAMP_SNSINC);
1705
1706 pdata->ptpclk_rate = AXGBE_V2_PTP_CLOCK_FREQ;
1707 dividend = 50000000;
1708 dividend <<= 32;
1709 pdata->tstamp_addend = div_u64(dividend, pdata->ptpclk_rate);
1710
1711 axgbe_update_tstamp_addend(pdata, pdata->tstamp_addend);
1712 axgbe_set_tstamp_time(pdata, 0, 0);
1713
1714 /* Initialize the timecounter */
1715 memset(&pdata->systime_tc, 0, sizeof(struct rte_timecounter));
1716
1717 pdata->systime_tc.cc_mask = AXGBE_CYCLECOUNTER_MASK;
1718 pdata->systime_tc.cc_shift = 0;
1719 pdata->systime_tc.nsec_mask = 0;
1720
1721 PMD_DRV_LOG(DEBUG, "Initializing system time counter with realtime\n");
1722

Callers

nothing calls this directly

Calls 6

div_u64Function · 0.85
axgbe_set_tstamp_timeFunction · 0.85
memsetFunction · 0.85
rte_timespec_to_nsFunction · 0.85
rte_timecounter_updateFunction · 0.85

Tested by

no test coverage detected