CNDP  22.08.0
memif_socket.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018-2021 Cisco Systems, Inc. All rights reserved.
3  */
4 
5 #ifndef _MEMIF_SOCKET_H_
6 #define _MEMIF_SOCKET_H_
7 
8 #include <sys/queue.h>
9 #include <sys/un.h>
10 #include <cne_event.h>
11 #include "memif.h"
12 
13 struct cne_memif_socket_dev_list_elt {
14  TAILQ_ENTRY(cne_memif_socket_dev_list_elt) next;
15  struct cne_pktdev *dev;
16 };
17 
18 #define CNE_MEMIF_SOCKET_HASH_NAME "memif-sh"
19 #define UNIX_PATH_MAX 108
20 
21 struct cne_memif_socket {
22  struct cne_ev_handle ev_handle;
23  char filename[UNIX_PATH_MAX];
25  TAILQ_HEAD(, cne_memif_socket_dev_list_elt) dev_queue;
27  uint8_t listener;
28 };
29 
30 /* Control message queue. */
31 struct cne_memif_msg_queue_elt {
32  cne_memif_msg_t msg;
33  TAILQ_ENTRY(cne_memif_msg_queue_elt) next;
34  int fd;
35 };
36 
37 struct cne_memif_control_channel {
38  struct cne_ev_handle ev_handle;
39  TAILQ_HEAD(, cne_memif_msg_queue_elt) msg_queue;
40  struct cne_memif_socket *socket;
41  struct cne_pktdev *dev;
42 };
43 
51 void cne_memif_socket_remove_device(struct cne_pktdev *dev);
52 
63 void cne_memif_msg_enq_disconnect(struct cne_memif_control_channel *cc, const char *reason,
64  int err_code);
65 
77 int cne_memif_socket_init(struct cne_pktdev *dev, const char *socket_filename);
78 
85 void cne_memif_disconnect(struct cne_pktdev *dev);
86 
96 int cne_memif_connect_server(struct cne_pktdev *dev);
97 
107 int cne_memif_connect_client(struct cne_pktdev *dev);
108 
109 #endif /* MEMIF_SOCKET_H */
TAILQ_HEAD(pktdev_driver_list, pktdev_driver)