1dc488f88SScott Feldman /* 2dc488f88SScott Feldman * QEMU rocker switch emulation - Descriptor ring support 3dc488f88SScott Feldman * 4dc488f88SScott Feldman * Copyright (c) 2014 Scott Feldman <sfeldma@gmail.com> 5dc488f88SScott Feldman * 6dc488f88SScott Feldman * This program is free software; you can redistribute it and/or modify 7dc488f88SScott Feldman * it under the terms of the GNU General Public License as published by 8dc488f88SScott Feldman * the Free Software Foundation; either version 2 of the License, or 9dc488f88SScott Feldman * (at your option) any later version. 10dc488f88SScott Feldman * 11dc488f88SScott Feldman * This program is distributed in the hope that it will be useful, 12dc488f88SScott Feldman * but WITHOUT ANY WARRANTY; without even the implied warranty of 13dc488f88SScott Feldman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14dc488f88SScott Feldman * GNU General Public License for more details. 15dc488f88SScott Feldman */ 16dc488f88SScott Feldman 17*2a6a4076SMarkus Armbruster #ifndef ROCKER_DESC_H 18*2a6a4076SMarkus Armbruster #define ROCKER_DESC_H 19dc488f88SScott Feldman 20dc488f88SScott Feldman #include "rocker_hw.h" 21dc488f88SScott Feldman 22dc488f88SScott Feldman typedef int (desc_ring_consume)(Rocker *r, DescInfo *info); 23dc488f88SScott Feldman 24dc488f88SScott Feldman uint16_t desc_buf_size(DescInfo *info); 25dc488f88SScott Feldman uint16_t desc_tlv_size(DescInfo *info); 26dc488f88SScott Feldman char *desc_get_buf(DescInfo *info, bool read_only); 27dc488f88SScott Feldman int desc_set_buf(DescInfo *info, size_t tlv_size); 28dc488f88SScott Feldman DescRing *desc_get_ring(DescInfo *info); 29dc488f88SScott Feldman 30dc488f88SScott Feldman int desc_ring_index(DescRing *ring); 31dc488f88SScott Feldman bool desc_ring_set_base_addr(DescRing *ring, uint64_t base_addr); 32dc488f88SScott Feldman uint64_t desc_ring_get_base_addr(DescRing *ring); 33dc488f88SScott Feldman bool desc_ring_set_size(DescRing *ring, uint32_t size); 34dc488f88SScott Feldman uint32_t desc_ring_get_size(DescRing *ring); 35dc488f88SScott Feldman bool desc_ring_set_head(DescRing *ring, uint32_t new); 36dc488f88SScott Feldman uint32_t desc_ring_get_head(DescRing *ring); 37dc488f88SScott Feldman uint32_t desc_ring_get_tail(DescRing *ring); 38dc488f88SScott Feldman void desc_ring_set_ctrl(DescRing *ring, uint32_t val); 39dc488f88SScott Feldman bool desc_ring_ret_credits(DescRing *ring, uint32_t credits); 40dc488f88SScott Feldman uint32_t desc_ring_get_credits(DescRing *ring); 41dc488f88SScott Feldman 42dc488f88SScott Feldman DescInfo *desc_ring_fetch_desc(DescRing *ring); 43dc488f88SScott Feldman bool desc_ring_post_desc(DescRing *ring, int status); 44dc488f88SScott Feldman 45dc488f88SScott Feldman void desc_ring_set_consume(DescRing *ring, desc_ring_consume *consume, 46dc488f88SScott Feldman unsigned vector); 47dc488f88SScott Feldman unsigned desc_ring_get_msix_vector(DescRing *ring); 48dc488f88SScott Feldman DescRing *desc_ring_alloc(Rocker *r, int index); 49dc488f88SScott Feldman void desc_ring_free(DescRing *ring); 50dc488f88SScott Feldman void desc_ring_reset(DescRing *ring); 51dc488f88SScott Feldman 52dc488f88SScott Feldman #endif 53