1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018-2019 Cisco Systems, Inc. All rights reserved.
5 #ifndef _MEMIF_SOCKET_H_
6 #define _MEMIF_SOCKET_H_
12 * Remove device from socket device list. If no device is left on the socket,
13 * remove the socket as well.
18 void memif_socket_remove_device(struct rte_eth_dev *dev);
21 * Enqueue disconnect message to control channel message queue.
26 * const string stating disconnect reason (96 characters)
30 void memif_msg_enq_disconnect(struct memif_control_channel *cc, const char *reason,
34 * Initialize memif socket for specified device. If socket doesn't exist, create socket.
38 * @param socket_filename
42 * - On failure, a negative value.
44 int memif_socket_init(struct rte_eth_dev *dev, const char *socket_filename);
47 * Disconnect memif device. Close control channel and shared memory.
52 void memif_disconnect(struct rte_eth_dev *dev);
55 * If device is properly configured, enable connection establishment.
61 * - On failure, a negative value.
63 int memif_connect_server(struct rte_eth_dev *dev);
67 * If device is properly configured, send connection request.
73 * - On failure, a negative value.
75 int memif_connect_client(struct rte_eth_dev *dev);
77 struct memif_socket_dev_list_elt {
78 TAILQ_ENTRY(memif_socket_dev_list_elt) next;
79 struct rte_eth_dev *dev; /**< pointer to device internals */
80 char dev_name[RTE_ETH_NAME_MAX_LEN];
83 #define MEMIF_SOCKET_HASH_NAME "memif-sh"
84 #define MEMIF_SOCKET_UN_SIZE \
85 (sizeof(struct sockaddr_un) - offsetof(struct sockaddr_un, sun_path))
88 struct rte_intr_handle intr_handle; /**< interrupt handle */
89 char filename[MEMIF_SOCKET_UN_SIZE]; /**< socket filename */
91 TAILQ_HEAD(, memif_socket_dev_list_elt) dev_queue;
92 /**< Queue of devices using this socket */
93 uint8_t listener; /**< if not zero socket is listener */
96 /* Control message queue. */
97 struct memif_msg_queue_elt {
98 memif_msg_t msg; /**< control message */
99 TAILQ_ENTRY(memif_msg_queue_elt) next;
100 int fd; /**< fd to be sent to peer */
103 struct memif_control_channel {
104 struct rte_intr_handle intr_handle; /**< interrupt handle */
105 TAILQ_HEAD(, memif_msg_queue_elt) msg_queue; /**< control message queue */
106 struct memif_socket *socket; /**< pointer to socket */
107 struct rte_eth_dev *dev; /**< pointer to device */
110 #endif /* MEMIF_SOCKET_H */