1 /* 2 * Copyright (c) 2023 Enphase Energy 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ETH_IVSHMEM_PRIV_H 8 #define ETH_IVSHMEM_PRIV_H 9 10 #include <stdbool.h> 11 #include <stddef.h> 12 #include <stdint.h> 13 14 #include <openamp/virtio_ring.h> 15 16 struct eth_ivshmem_queue { 17 struct { 18 struct vring vring; 19 void *shmem; 20 uint16_t desc_head; 21 uint16_t desc_len; 22 uint32_t data_head; 23 uint32_t data_tail; 24 uint32_t data_len; 25 uint16_t avail_idx; 26 uint16_t used_idx; 27 28 uint32_t pending_data_head; 29 uint32_t pending_data_len; 30 } tx; 31 struct { 32 struct vring vring; 33 void *shmem; 34 uint16_t avail_idx; 35 uint16_t used_idx; 36 } rx; 37 uint16_t desc_max_len; 38 uint32_t vring_header_size; 39 uint32_t vring_data_max_len; 40 }; 41 42 int eth_ivshmem_queue_init( 43 struct eth_ivshmem_queue *q, uintptr_t shmem, 44 size_t shmem_section_size, bool tx_buffer_first); 45 void eth_ivshmem_queue_reset(struct eth_ivshmem_queue *q); 46 int eth_ivshmem_queue_tx_get_buff(struct eth_ivshmem_queue *q, void **data, size_t len); 47 int eth_ivshmem_queue_tx_commit_buff(struct eth_ivshmem_queue *q); 48 int eth_ivshmem_queue_rx(struct eth_ivshmem_queue *q, const void **data, size_t *len); 49 int eth_ivshmem_queue_rx_complete(struct eth_ivshmem_queue *q); 50 51 #endif /* ETH_IVSHMEM_PRIV_H */ 52