1 /*- 2 * BSD LICENSE 3 * 4 * Copyright(c) Broadcom Limited. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * * Neither the name of Broadcom Corporation nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #ifndef _BNXT_RING_H_ 35 #define _BNXT_RING_H_ 36 37 #include <inttypes.h> 38 39 #include <rte_memory.h> 40 41 #define RING_NEXT(ring, idx) (((idx) + 1) & (ring)->ring_mask) 42 43 #define RTE_MBUF_DATA_DMA_ADDR(mb) \ 44 ((uint64_t)((mb)->buf_iova + (mb)->data_off)) 45 46 #define DB_IDX_MASK 0xffffff 47 #define DB_IDX_VALID (0x1 << 26) 48 #define DB_IRQ_DIS (0x1 << 27) 49 #define DB_KEY_TX (0x0 << 28) 50 #define DB_KEY_RX (0x1 << 28) 51 #define DB_KEY_CP (0x2 << 28) 52 #define DB_KEY_ST (0x3 << 28) 53 #define DB_KEY_TX_PUSH (0x4 << 28) 54 #define DB_LONG_TX_PUSH (0x2 << 24) 55 56 #define DEFAULT_CP_RING_SIZE 256 57 #define DEFAULT_RX_RING_SIZE 256 58 #define DEFAULT_TX_RING_SIZE 256 59 60 #define BNXT_TPA_MAX 64 61 #define AGG_RING_SIZE_FACTOR 2 62 63 /* These assume 4k pages */ 64 #define MAX_RX_DESC_CNT (8 * 1024) 65 #define MAX_TX_DESC_CNT (4 * 1024) 66 #define MAX_CP_DESC_CNT (16 * 1024) 67 68 #define INVALID_HW_RING_ID ((uint16_t)-1) 69 #define INVALID_STATS_CTX_ID ((uint16_t)-1) 70 71 struct bnxt_ring { 72 void *bd; 73 rte_iova_t bd_dma; 74 uint32_t ring_size; 75 uint32_t ring_mask; 76 77 int vmem_size; 78 void **vmem; 79 80 uint16_t fw_ring_id; /* Ring id filled by Chimp FW */ 81 const void *mem_zone; 82 }; 83 84 struct bnxt_ring_grp_info { 85 uint16_t fw_stats_ctx; 86 uint16_t fw_grp_id; 87 uint16_t rx_fw_ring_id; 88 uint16_t cp_fw_ring_id; 89 uint16_t ag_fw_ring_id; 90 }; 91 92 struct bnxt; 93 struct bnxt_tx_ring_info; 94 struct bnxt_rx_ring_info; 95 struct bnxt_cp_ring_info; 96 void bnxt_free_ring(struct bnxt_ring *ring); 97 int bnxt_init_ring_grps(struct bnxt *bp); 98 int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, 99 struct bnxt_tx_ring_info *tx_ring_info, 100 struct bnxt_rx_ring_info *rx_ring_info, 101 struct bnxt_cp_ring_info *cp_ring_info, 102 const char *suffix); 103 int bnxt_alloc_hwrm_rings(struct bnxt *bp); 104 105 #endif 106