LCOV - code coverage report
Current view: top level - drivers/common/dpaax - dpaax_ptp.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 32 0.0 %
Date: 2025-12-01 19:08:10 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 22 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright 2025 NXP
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _DPAAX_PTP_H_
       6                 :            : #define _DPAAX_PTP_H_
       7                 :            : #include <stdlib.h>
       8                 :            : #include <rte_ether.h>
       9                 :            : #include <rte_ip.h>
      10                 :            : #include <rte_udp.h>
      11                 :            : 
      12                 :            : #define UDP_PTP_EVENT_DST_PORT 319
      13                 :            : #define UDP_PTP_GENERAL_DST_PORT 320
      14                 :            : 
      15                 :            : struct __rte_packed_begin rte_dpaax_ptp_header {
      16                 :            :         uint8_t tsmt;  /* transportSpecific | messageType */
      17                 :            :         uint8_t ver;   /* reserved          | versionPTP  */
      18                 :            :         rte_be16_t msg_len;
      19                 :            :         uint8_t domain_number;
      20                 :            :         uint8_t rsv;
      21                 :            :         uint8_t flags[2];
      22                 :            :         rte_be64_t correction;
      23                 :            :         uint8_t unused[];
      24                 :            : } __rte_packed_end;
      25                 :            : 
      26                 :            : static inline struct rte_dpaax_ptp_header *
      27                 :          0 : dpaax_timesync_ptp_parse_header(struct rte_mbuf *buf,
      28                 :            :         uint16_t *ts_offset, int *is_udp)
      29                 :            : {
      30                 :          0 :         struct rte_ether_hdr *eth = rte_pktmbuf_mtod(buf, void *);
      31                 :            :         void *next_hdr;
      32                 :            :         rte_be16_t ether_type;
      33                 :            :         struct rte_vlan_hdr *vlan;
      34                 :            :         struct rte_ipv4_hdr *ipv4;
      35                 :            :         struct rte_ipv6_hdr *ipv6;
      36                 :            :         struct rte_udp_hdr *udp;
      37                 :            :         struct rte_dpaax_ptp_header *ptp = NULL;
      38                 :            :         uint16_t offset = offsetof(struct rte_dpaax_ptp_header, correction);
      39                 :            : 
      40         [ #  # ]:          0 :         if (is_udp)
      41                 :          0 :                 *is_udp = false;
      42                 :            : 
      43                 :            :         offset += sizeof(struct rte_ether_hdr);
      44         [ #  # ]:          0 :         if (eth->ether_type == htons(RTE_ETHER_TYPE_1588)) {
      45                 :          0 :                 ptp = (void *)(eth + 1);
      46                 :          0 :                 goto quit;
      47                 :            :         }
      48                 :            : 
      49         [ #  # ]:          0 :         if (eth->ether_type == htons(RTE_ETHER_TYPE_VLAN)) {
      50                 :            :                 vlan = (void *)(eth + 1);
      51                 :          0 :                 ether_type = vlan->eth_proto;
      52                 :          0 :                 next_hdr = (void *)(vlan + 1);
      53                 :            :                 offset += sizeof(struct rte_vlan_hdr);
      54         [ #  # ]:          0 :                 if (ether_type == htons(RTE_ETHER_TYPE_1588)) {
      55                 :            :                         ptp = next_hdr;
      56                 :          0 :                         goto quit;
      57                 :            :                 }
      58                 :            :         } else {
      59                 :            :                 ether_type = eth->ether_type;
      60                 :          0 :                 next_hdr = (void *)(eth + 1);
      61                 :            :         }
      62                 :            : 
      63         [ #  # ]:          0 :         if (ether_type == htons(RTE_ETHER_TYPE_IPV4)) {
      64                 :            :                 ipv4 = next_hdr;
      65                 :          0 :                 offset += sizeof(struct rte_ipv4_hdr);
      66         [ #  # ]:          0 :                 if (ipv4->next_proto_id != IPPROTO_UDP)
      67                 :            :                         return NULL;
      68                 :          0 :                 udp = (void *)(ipv4 + 1);
      69                 :          0 :                 goto parse_udp;
      70         [ #  # ]:          0 :         } else if (ether_type == htons(RTE_ETHER_TYPE_IPV6)) {
      71                 :            :                 ipv6 = next_hdr;
      72                 :          0 :                 offset += sizeof(struct rte_ipv6_hdr);
      73         [ #  # ]:          0 :                 if (ipv6->proto != IPPROTO_UDP)
      74                 :            :                         return NULL;
      75                 :          0 :                 udp = (void *)(ipv6 + 1);
      76                 :          0 :                 goto parse_udp;
      77                 :            :         } else {
      78                 :            :                 return NULL;
      79                 :            :         }
      80                 :          0 : parse_udp:
      81                 :          0 :         offset += sizeof(struct rte_udp_hdr);
      82         [ #  # ]:          0 :         if (udp->dst_port != UDP_PTP_EVENT_DST_PORT &&
      83                 :            :                 udp->dst_port != UDP_PTP_GENERAL_DST_PORT)
      84                 :            :                 return NULL;
      85                 :          0 :         ptp = (void *)(udp + 1);
      86         [ #  # ]:          0 :         if (is_udp)
      87                 :          0 :                 *is_udp = true;
      88                 :          0 : quit:
      89         [ #  # ]:          0 :         if (ts_offset)
      90                 :          0 :                 *ts_offset = offset;
      91                 :            : 
      92                 :            :         return ptp;
      93                 :            : }
      94                 :            : 
      95                 :            : #endif /* _DPAAX_PTP_H_ */

Generated by: LCOV version 1.14