NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
telemetry_exporter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021-2022 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #ifndef COMMON_TELEMETRY_EXPORTER_H_
27 #define COMMON_TELEMETRY_EXPORTER_H_
28 
29 #include <stdio.h>
30 #include <string.h>
31 
32 #include <rte_ring.h>
33 
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #define NETFLOW_QUEUE_SIZE 1024 /* Netflow queue size */
41 
42 /* Netflow record, should match the fields initialized in doca_telemetry_exporter_netflow_init */
43 struct __attribute__((packed)) doca_telemetry_exporter_netflow_record {
44  __be32 src_addr_v4; /* Source IPV4 Address */
45  __be32 dst_addr_v4; /* Destination IPV4 Address */
46  struct in6_addr src_addr_v6; /* Source IPV6 Address */
47  struct in6_addr dst_addr_v6; /* Destination IPV6 Address */
48  __be32 next_hop_v4; /* Next hop router's IPV4 Address */
49  struct in6_addr next_hop_v6; /* Next hop router's IPV6 Address */
50  __be16 input; /* Input interface index */
51  __be16 output; /* Output interface index */
52  __be16 src_port; /* TCP/UDP source port number or equivalent */
53  __be16 dst_port; /* TCP/UDP destination port number or equivalent */
54  uint8_t tcp_flags; /* Cumulative OR of tcp flags */
55  uint8_t protocol; /* IP protocol type (for example, TCP = 6;UDP = 17) */
56  uint8_t tos; /* IP Type-of-Service */
57  __be16 src_as; /* originating AS of source address */
58  __be16 dst_as; /* originating AS of destination address */
59  uint8_t src_mask; /* source address prefix mask bits */
60  uint8_t dst_mask; /* destination address prefix mask bits */
61  __be32 d_pkts; /* Packets sent in Duration */
62  __be32 d_octets; /* Octets sent in Duration */
63  __be32 first; /* SysUptime at start of flow */
64  __be32 last; /* and of last packet of flow */
65  __be64 flow_id; /* This identifies a transaction within a connection */
67  a classification*/
68 };
69 
70 /*
71  * Send Netflow records available in the pending queue
72  *
73  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
74  */
76 
77 /*
78  * Enqueues a single Netflow record to the pending queue
79  * This function can be used as callback function to the DPI Worker and is MP safe
80  *
81  * @record [in]: Netflow record to be enqueued
82  */
83 void enqueue_netflow_record_to_ring(const struct doca_telemetry_exporter_netflow_record *record);
84 
85 /*
86  * Destroy the Netflow telemetry resources
87  */
89 
90 /*
91  * Initialize the Netflow telemetry resources
92  *
93  * @id [in]: Netflow source id
94  * @source_tag [in]: Netflow source tag
95  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
96  */
97 doca_error_t init_netflow_schema_and_source(uint8_t id, char *source_tag);
98 
99 #ifdef __cplusplus
100 } /* extern "C" */
101 #endif
102 
103 #endif /* COMMON_TELEMETRY_EXPORTER_H_ */
#define DOCA_TELEMETRY_EXPORTER_NETFLOW_APPLICATION_NAME_DEFAULT_LENGTH
enum doca_error doca_error_t
DOCA API return codes.
uint32_t __be32
uint64_t __be64
uint16_t __be16
tcp_flags
Definition: packets.h:41
uint16_t src_port
Definition: packets.h:0
uint16_t dst_port
Definition: packets.h:1
char application_name[DOCA_TELEMETRY_EXPORTER_NETFLOW_APPLICATION_NAME_DEFAULT_LENGTH]
struct in6_addr next_hop_v6
struct in6_addr src_addr_v6
struct in6_addr dst_addr_v6
doca_error_t send_netflow_record(void)
void enqueue_netflow_record_to_ring(const struct doca_telemetry_exporter_netflow_record *record)
void destroy_netflow_schema_and_source(void)
doca_error_t init_netflow_schema_and_source(uint8_t id, char *source_tag)
struct __attribute__((packed)) doca_telemetry_exporter_netflow_record