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_master(struct rte_eth_dev *dev);
66 * If device is properly configured, send connection request.
72 * - On failure, a negative value.
74 int memif_connect_slave(struct rte_eth_dev *dev);
76 struct memif_socket_dev_list_elt {
77 TAILQ_ENTRY(memif_socket_dev_list_elt) next;
78 struct rte_eth_dev *dev; /**< pointer to device internals */
79 char dev_name[RTE_ETH_NAME_MAX_LEN];
82 #define MEMIF_SOCKET_HASH_NAME "memif-sh"
83 #define MEMIF_SOCKET_UN_SIZE \
84 (sizeof(struct sockaddr_un) - offsetof(struct sockaddr_un, sun_path))
87 struct rte_intr_handle intr_handle; /**< interrupt handle */
88 char filename[MEMIF_SOCKET_UN_SIZE]; /**< socket filename */
90 TAILQ_HEAD(, memif_socket_dev_list_elt) dev_queue;
91 /**< Queue of devices using this socket */
92 uint8_t listener; /**< if not zero socket is listener */
95 /* Control message queue. */
96 struct memif_msg_queue_elt {
97 memif_msg_t msg; /**< control message */
98 TAILQ_ENTRY(memif_msg_queue_elt) next;
99 int fd; /**< fd to be sent to peer */
102 struct memif_control_channel {
103 struct rte_intr_handle intr_handle; /**< interrupt handle */
104 TAILQ_HEAD(, memif_msg_queue_elt) msg_queue; /**< control message queue */
105 struct memif_socket *socket; /**< pointer to socket */
106 struct rte_eth_dev *dev; /**< pointer to device */
109 #endif /* MEMIF_SOCKET_H */