LCOV - code coverage report
Current view: top level - drivers/net/dpaa - dpaa_ptp.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 35 0.0 %
Date: 2025-10-01 17:51:42 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 16 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright 2022-2024 NXP
       3                 :            :  */
       4                 :            : 
       5                 :            : /* System headers */
       6                 :            : #include <stdio.h>
       7                 :            : #include <inttypes.h>
       8                 :            : #include <unistd.h>
       9                 :            : 
      10                 :            : #include <rte_ethdev.h>
      11                 :            : #include <rte_log.h>
      12                 :            : #include <rte_eth_ctrl.h>
      13                 :            : #include <rte_malloc.h>
      14                 :            : #include <rte_time.h>
      15                 :            : 
      16                 :            : #include <dpaa_ethdev.h>
      17                 :            : #include <dpaa_rxtx.h>
      18                 :            : 
      19                 :            : int
      20                 :          0 : dpaa_timesync_enable(struct rte_eth_dev *dev __rte_unused)
      21                 :            : {
      22                 :          0 :         return 0;
      23                 :            : }
      24                 :            : 
      25                 :            : int
      26                 :          0 : dpaa_timesync_disable(struct rte_eth_dev *dev __rte_unused)
      27                 :            : {
      28                 :          0 :         return 0;
      29                 :            : }
      30                 :            : 
      31                 :            : int
      32                 :          0 : dpaa_timesync_read_time(struct rte_eth_dev *dev,
      33                 :            :                                         struct timespec *timestamp)
      34                 :            : {
      35                 :            :         uint32_t *tmr_cnt_h, *tmr_cnt_l;
      36                 :            :         struct fman_if *fif;
      37                 :            :         uint64_t time;
      38                 :            : 
      39                 :          0 :         fif = dev->process_private;
      40                 :            : 
      41                 :          0 :         tmr_cnt_h = &((struct rtc_regs *)fif->fman->time_vir)->tmr_cnt_h;
      42                 :            :         tmr_cnt_l = &((struct rtc_regs *)fif->fman->time_vir)->tmr_cnt_l;
      43                 :            : 
      44                 :          0 :         time = (uint64_t)in_be32(tmr_cnt_l);
      45         [ #  # ]:          0 :         time |= ((uint64_t)in_be32(tmr_cnt_h) << 32);
      46                 :            : 
      47                 :          0 :         *timestamp = rte_ns_to_timespec(time);
      48                 :          0 :         return 0;
      49                 :            : }
      50                 :            : 
      51                 :            : int
      52                 :          0 : dpaa_timesync_write_time(struct rte_eth_dev *dev,
      53                 :            :                                         const struct timespec *ts)
      54                 :            : {
      55                 :            :         uint32_t *tmr_cnt_h, *tmr_cnt_l;
      56                 :            :         struct fman_if *fif;
      57                 :            :         uint64_t time;
      58                 :            : 
      59                 :          0 :         fif = dev->process_private;
      60                 :            : 
      61         [ #  # ]:          0 :         tmr_cnt_h = &((struct rtc_regs *)fif->fman->time_vir)->tmr_cnt_h;
      62                 :            :         tmr_cnt_l = &((struct rtc_regs *)fif->fman->time_vir)->tmr_cnt_l;
      63                 :            : 
      64                 :            :         time = rte_timespec_to_ns(ts);
      65                 :            : 
      66         [ #  # ]:          0 :         out_be32(tmr_cnt_l, (uint32_t)time);
      67         [ #  # ]:          0 :         out_be32(tmr_cnt_h, (uint32_t)(time >> 32));
      68                 :            : 
      69                 :          0 :         return 0;
      70                 :            : }
      71                 :            : 
      72                 :            : int
      73                 :          0 : dpaa_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
      74                 :            : {
      75                 :          0 :         struct timespec ts = {0, 0}, *timestamp = &ts;
      76                 :            :         uint64_t ns;
      77                 :            : 
      78                 :          0 :         dpaa_timesync_read_time(dev, timestamp);
      79                 :            : 
      80                 :            :         ns = rte_timespec_to_ns(timestamp);
      81         [ #  # ]:          0 :         ns += delta;
      82                 :          0 :         *timestamp = rte_ns_to_timespec(ns);
      83                 :            : 
      84                 :          0 :         dpaa_timesync_write_time(dev, timestamp);
      85                 :            : 
      86                 :          0 :         return 0;
      87                 :            : }
      88                 :            : 
      89                 :            : int
      90                 :          0 : dpaa_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
      91                 :            :                                                 struct timespec *timestamp)
      92                 :            : {
      93                 :          0 :         struct dpaa_if *dpaa_intf = dev->data->dev_private;
      94                 :            : 
      95         [ #  # ]:          0 :         if (dpaa_intf->next_tx_conf_queue) {
      96         [ #  # ]:          0 :                 while (!dpaa_intf->tx_timestamp)
      97                 :          0 :                         dpaa_eth_tx_conf(dpaa_intf->next_tx_conf_queue);
      98                 :            :         } else {
      99                 :            :                 return -1;
     100                 :            :         }
     101                 :          0 :         *timestamp = rte_ns_to_timespec(dpaa_intf->tx_timestamp);
     102                 :            : 
     103                 :          0 :         return 0;
     104                 :            : }
     105                 :            : 
     106                 :            : int
     107                 :          0 : dpaa_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
     108                 :            :                                                 struct timespec *timestamp,
     109                 :            :                                                 uint32_t flags __rte_unused)
     110                 :            : {
     111                 :          0 :         struct dpaa_if *dpaa_intf = dev->data->dev_private;
     112         [ #  # ]:          0 :         *timestamp = rte_ns_to_timespec(dpaa_intf->rx_timestamp);
     113                 :          0 :         return 0;
     114                 :            : }

Generated by: LCOV version 1.14