5 #ifndef _CNE_ETH_MEMIF_H_
6 #define _CNE_ETH_MEMIF_H_
12 #include <sys/queue.h>
19 #include "memif_socket.h"
21 #define PMD_NET_MEMIF_NAME "net_memif_socket"
23 #define CNE_ETH_MEMIF_DEFAULT_SOCKET_FILENAME "/var/run/memif.sock"
24 #define CNE_ETH_MEMIF_DEFAULT_RING_SIZE 10
25 #define CNE_ETH_MEMIF_DEFAULT_PKT_BUFFER_SIZE 2048
27 #define CNE_ETH_MEMIF_MAX_NUM_Q_PAIRS 1
28 #define CNE_ETH_MEMIF_MAX_LOG2_RING_SIZE 14
29 #define CNE_ETH_MEMIF_MAX_REGION_NUM 256
31 #define CNE_ETH_MEMIF_SHM_NAME_SIZE 32
32 #define CNE_ETH_MEMIF_DISC_STRING_SIZE 96
33 #define CNE_ETH_MEMIF_SECRET_SIZE 24
35 extern int cne_memif_logtype;
37 #define MIF_LOG(level, fmt, args...) cne_log(CNE_LOG_##level, __func__, __LINE__, fmt, ##args)
39 enum cne_memif_role_t {
40 CNE_MEMIF_ROLE_SERVER,
41 CNE_MEMIF_ROLE_CLIENT,
44 struct cne_memif_region {
46 cne_memif_region_size_t region_size;
48 uint32_t pkt_buffer_offset;
52 struct pmd_internals {
53 cne_memif_interface_id_t id;
54 enum cne_memif_role_t role;
56 #define CNE_ETH_MEMIF_FLAG_CONNECTING (1 << 0)
58 #define CNE_ETH_MEMIF_FLAG_CONNECTED (1 << 1)
60 #define CNE_ETH_MEMIF_FLAG_ZERO_COPY (1 << 2)
62 #define CNE_ETH_MEMIF_FLAG_DISABLED (1 << 3)
64 #define CNE_ETH_MEMIF_FLAG_SOCKET_ABSTRACT (1 << 4)
67 char *socket_filename;
68 struct cne_memif_socket *socket;
69 char secret[CNE_ETH_MEMIF_SECRET_SIZE];
71 struct cne_memif_control_channel *cc;
75 char remote_name[PKTDEV_NAME_MAX_LEN];
76 char remote_if_name[PKTDEV_NAME_MAX_LEN];
77 char pmd_name[PKTDEV_NAME_MAX_LEN];
80 cne_memif_log2_ring_size_t log2_ring_size;
81 uint8_t num_c2s_rings;
82 uint8_t num_s2c_rings;
83 uint16_t pkt_buffer_size;
87 cne_memif_log2_ring_size_t log2_ring_size;
88 uint8_t num_c2s_rings;
89 uint8_t num_s2c_rings;
90 uint16_t pkt_buffer_size;
94 char local_disc_string[CNE_ETH_MEMIF_DISC_STRING_SIZE];
96 char remote_disc_string[CNE_ETH_MEMIF_DISC_STRING_SIZE];
100 struct cne_memif_queue {
102 struct pmd_internals *pmd;
104 cne_memif_ring_type_t type;
105 cne_memif_region_index_t region;
109 cne_memif_region_offset_t ring_offset;
115 struct cne_mbuf **buffers;
126 cne_memif_log2_ring_size_t log2_ring_size;
129 struct pmd_process_private {
130 struct cne_memif_region *regions[CNE_ETH_MEMIF_MAX_REGION_NUM];
132 cne_memif_region_index_t regions_num;
141 void cne_memif_free_regions(
struct cne_pktdev *dev);
153 int cne_memif_connect(
struct cne_pktdev *dev);
155 int cne_memif_connect_start(
struct cne_pktdev *dev);
167 int cne_memif_init_regions_and_queues(
struct cne_pktdev *dev);
175 const char *cne_memif_version(
void);
178 #ifndef __NR_memfd_create
180 #if defined __x86_64__
181 #define __NR_memfd_create 319
183 #error "__NR_memfd_create unknown for this architecture"
189 memfd_create(
const char *name,
unsigned int flags)
191 return syscall(__NR_memfd_create, name, flags);
195 #ifndef F_LINUX_SPECIFIC_BASE
196 #define F_LINUX_SPECIFIC_BASE 1024
199 #ifndef MFD_ALLOW_SEALING
200 #define MFD_ALLOW_SEALING 0x0002U
204 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
205 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
207 #define F_SEAL_SEAL 0x0001
208 #define F_SEAL_SHRINK 0x0002
209 #define F_SEAL_GROW 0x0004
210 #define F_SEAL_WRITE 0x0008