NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
eth_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 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 ETH_COMMON_H_
27 #define ETH_COMMON_H_
28 
29 #include <unistd.h>
30 
31 #include <doca_pe.h>
32 #include <doca_dev.h>
33 #include <doca_mmap.h>
34 #include <doca_buf_inventory.h>
35 #include <doca_error.h>
36 
37 #include "common.h"
38 
40  struct program_core_objects core_objs; /* DOCA core objects */
41  void *mem_addr; /* Address of allocated memory for mmap (might not be aligned) */
42  void *mmap_addr; /* Address of DOCA mmap start memory address (aligned address) */
43  uint32_t mmap_size; /* DOCA memory map size */
44 };
45 
47  uint32_t mmap_size; /* Size of the memory map */
48  size_t inventory_num_elements; /* Elements number of the buffer inventory */
49  tasks_check check_device; /* Function to check device capability */
50  const char *ibdev_name; /* DOCA IB device name */
51 };
52 
53 struct ether_hdr {
54  uint8_t dst_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]; /* Destination addr bytes in tx order */
55  uint8_t src_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]; /* Source addr bytes in tx order */
56  uint16_t ether_type; /* Frame type */
57 } __attribute__((__packed__));
58 
59 /*
60  * Allocate ETH core resources
61  *
62  * @cfg [in]: Configuration parameters
63  * @resources [out]: ETH core resources to allocate
64  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
65  */
67 
68 /*
69  * Destroy ETH core resources
70  *
71  * @resources [in]: ETH core resources to destroy
72  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
73  */
75 
76 /*
77  * Extract IB device name after checking it's a valid IB device name
78  *
79  * @ibdev_name [in]: IB device name to check and extract from
80  * @ibdev_name_out [out]: buffer to extract/copy IB device name to
81  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
82  */
83 doca_error_t extract_ibdev_name(char *ibdev_name, char *ibdev_name_out);
84 
85 /*
86  * Extract MAC address after checking it's a valid MAC address
87  *
88  * @mac_addr [in]: MAC address to check and extract from
89  * @mac_addr_out [out]: uint8_t array to extract MAC address to
90  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
91  */
92 doca_error_t extract_mac_addr(char *mac_addr, uint8_t *mac_addr_out);
93 
94 #endif /* ETH_COMMON_H_ */
doca_error_t destroy_eth_core_resources(struct eth_core_resources *resources)
Definition: eth_common.c:98
doca_error_t extract_ibdev_name(char *ibdev_name, char *ibdev_name_out)
Definition: eth_common.c:128
doca_error_t allocate_eth_core_resources(struct eth_core_config *cfg, struct eth_core_resources *resources)
Definition: eth_common.c:38
doca_error_t extract_mac_addr(char *mac_addr, uint8_t *mac_addr_out)
Definition: eth_common.c:146
struct rdma_resources resources
#define DOCA_DEVINFO_MAC_ADDR_SIZE
Length of MAC address.
Definition: doca_dev.h:301
enum doca_error doca_error_t
DOCA API return codes.
struct ether_hdr __attribute__((__packed__))
Definition: doca_flow.h:267
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
doca_error_t(* tasks_check)(struct doca_devinfo *)
Definition: common.h:42
uint32_t mmap_size
Definition: eth_common.h:47
size_t inventory_num_elements
Definition: eth_common.h:48
tasks_check check_device
Definition: eth_common.h:49
const char * ibdev_name
Definition: eth_common.h:50
struct program_core_objects core_objs
Definition: eth_common.h:40
uint32_t mmap_size
Definition: eth_common.h:43
uint8_t dst_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]
Definition: eth_common.h:54
uint16_t ether_type
Definition: packets.h:63
uint8_t src_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]
Definition: eth_common.h:55