LCOV - code coverage report
Current view: top level - drivers/net/dpaa - dpaa_ptp.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 34 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 14 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                 :            :         struct fman_if *fif;
      38                 :            :         uint64_t time;
      39                 :            : 
      40                 :          0 :         fif = dev->process_private;
      41                 :            :         __fif = container_of(fif, struct __fman_if, __if);
      42                 :            : 
      43                 :          0 :         tmr_cnt_h = &((struct rtc_regs *)__fif->rtc_map)->tmr_cnt_h;
      44                 :            :         tmr_cnt_l = &((struct rtc_regs *)__fif->rtc_map)->tmr_cnt_l;
      45                 :            : 
      46                 :          0 :         time = (uint64_t)in_be32(tmr_cnt_l);
      47         [ #  # ]:          0 :         time |= ((uint64_t)in_be32(tmr_cnt_h) << 32);
      48                 :            : 
      49                 :          0 :         *timestamp = rte_ns_to_timespec(time);
      50                 :          0 :         return 0;
      51                 :            : }
      52                 :            : 
      53                 :            : int
      54                 :          0 : dpaa_timesync_write_time(struct rte_eth_dev *dev,
      55                 :            :                                         const struct timespec *ts)
      56                 :            : {
      57                 :            :         uint32_t *tmr_cnt_h, *tmr_cnt_l;
      58                 :            :         struct __fman_if *__fif;
      59                 :            :         struct fman_if *fif;
      60                 :            :         uint64_t time;
      61                 :            : 
      62                 :          0 :         fif = dev->process_private;
      63                 :            :         __fif = container_of(fif, struct __fman_if, __if);
      64                 :            : 
      65         [ #  # ]:          0 :         tmr_cnt_h = &((struct rtc_regs *)__fif->rtc_map)->tmr_cnt_h;
      66                 :            :         tmr_cnt_l = &((struct rtc_regs *)__fif->rtc_map)->tmr_cnt_l;
      67                 :            : 
      68                 :            :         time = rte_timespec_to_ns(ts);
      69                 :            : 
      70         [ #  # ]:          0 :         out_be32(tmr_cnt_l, (uint32_t)time);
      71         [ #  # ]:          0 :         out_be32(tmr_cnt_h, (uint32_t)(time >> 32));
      72                 :            : 
      73                 :          0 :         return 0;
      74                 :            : }
      75                 :            : 
      76                 :            : int
      77                 :          0 : dpaa_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
      78                 :            : {
      79                 :          0 :         struct timespec ts = {0, 0}, *timestamp = &ts;
      80                 :            :         uint64_t ns;
      81                 :            : 
      82                 :          0 :         dpaa_timesync_read_time(dev, timestamp);
      83                 :            : 
      84                 :            :         ns = rte_timespec_to_ns(timestamp);
      85                 :            :         ns += delta;
      86                 :          0 :         *timestamp = rte_ns_to_timespec(ns);
      87                 :            : 
      88                 :          0 :         dpaa_timesync_write_time(dev, timestamp);
      89                 :            : 
      90                 :          0 :         return 0;
      91                 :            : }
      92                 :            : 
      93                 :            : int
      94                 :          0 : dpaa_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
      95                 :            :                                                 struct timespec *timestamp)
      96                 :            : {
      97                 :          0 :         struct dpaa_if *dpaa_intf = dev->data->dev_private;
      98                 :            : 
      99         [ #  # ]:          0 :         if (dpaa_intf->next_tx_conf_queue) {
     100         [ #  # ]:          0 :                 while (!dpaa_intf->tx_timestamp)
     101                 :          0 :                         dpaa_eth_tx_conf(dpaa_intf->next_tx_conf_queue);
     102                 :            :         } else {
     103                 :            :                 return -1;
     104                 :            :         }
     105                 :          0 :         *timestamp = rte_ns_to_timespec(dpaa_intf->tx_timestamp);
     106                 :            : 
     107                 :          0 :         return 0;
     108                 :            : }
     109                 :            : 
     110                 :            : int
     111                 :          0 : dpaa_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
     112                 :            :                                                 struct timespec *timestamp,
     113                 :            :                                                 uint32_t flags __rte_unused)
     114                 :            : {
     115                 :          0 :         struct dpaa_if *dpaa_intf = dev->data->dev_private;
     116         [ #  # ]:          0 :         *timestamp = rte_ns_to_timespec(dpaa_intf->rx_timestamp);
     117                 :          0 :         return 0;
     118                 :            : }

Generated by: LCOV version 1.14