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