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_
11 * Remove device from socket device list. If no device is left on the socket,
12 * remove the socket as well.
17 void memif_socket_remove_device(struct rte_eth_dev *dev);
20 * Enqueue disconnect message to control channel message queue.
25 * const string stating disconnect reason (96 characters)
29 void memif_msg_enq_disconnect(struct memif_control_channel *cc, const char *reason,
33 * Initialize memif socket for specified device. If socket doesn't exist, create socket.
37 * @param socket_filename
41 * - On failure, a negative value.
43 int memif_socket_init(struct rte_eth_dev *dev, const char *socket_filename);
46 * Disconnect memif device. Close control channel and shared memory.
51 void memif_disconnect(struct rte_eth_dev *dev);
54 * If device is properly configured, enable connection establishment.
60 * - On failure, a negative value.
62 int memif_connect_master(struct rte_eth_dev *dev);
65 * If device is properly configured, send connection request.
71 * - On failure, a negative value.
73 int memif_connect_slave(struct rte_eth_dev *dev);
75 struct memif_socket_dev_list_elt {
76 TAILQ_ENTRY(memif_socket_dev_list_elt) next;
77 struct rte_eth_dev *dev; /**< pointer to device internals */
78 char dev_name[RTE_ETH_NAME_MAX_LEN];
81 #define MEMIF_SOCKET_HASH_NAME "memif-sh"
83 struct rte_intr_handle intr_handle; /**< interrupt handle */
84 char filename[256]; /**< socket filename */
86 TAILQ_HEAD(, memif_socket_dev_list_elt) dev_queue;
87 /**< Queue of devices using this socket */
88 uint8_t listener; /**< if not zero socket is listener */
91 /* Control message queue. */
92 struct memif_msg_queue_elt {
93 memif_msg_t msg; /**< control message */
94 TAILQ_ENTRY(memif_msg_queue_elt) next;
95 int fd; /**< fd to be sent to peer */
98 struct memif_control_channel {
99 struct rte_intr_handle intr_handle; /**< interrupt handle */
100 TAILQ_HEAD(, memif_msg_queue_elt) msg_queue; /**< control message queue */
101 struct memif_socket *socket; /**< pointer to socket */
102 struct rte_eth_dev *dev; /**< pointer to device */
105 #endif /* MEMIF_SOCKET_H */