net/bntx: use new API to get iova address XXX
[dpdk.git] / drivers / net / bnxt / bnxt_ring.h
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 DB_IDX_MASK                                             0xffffff
44 #define DB_IDX_VALID                                            (0x1 << 26)
45 #define DB_IRQ_DIS                                              (0x1 << 27)
46 #define DB_KEY_TX                                               (0x0 << 28)
47 #define DB_KEY_RX                                               (0x1 << 28)
48 #define DB_KEY_CP                                               (0x2 << 28)
49 #define DB_KEY_ST                                               (0x3 << 28)
50 #define DB_KEY_TX_PUSH                                          (0x4 << 28)
51 #define DB_LONG_TX_PUSH                                         (0x2 << 24)
52
53 #define DEFAULT_CP_RING_SIZE    256
54 #define DEFAULT_RX_RING_SIZE    256
55 #define DEFAULT_TX_RING_SIZE    256
56
57 #define BNXT_TPA_MAX            64
58 #define AGG_RING_SIZE_FACTOR    2
59
60 /* These assume 4k pages */
61 #define MAX_RX_DESC_CNT (8 * 1024)
62 #define MAX_TX_DESC_CNT (4 * 1024)
63 #define MAX_CP_DESC_CNT (16 * 1024)
64
65 #define INVALID_HW_RING_ID      ((uint16_t)-1)
66 #define INVALID_STATS_CTX_ID            ((uint16_t)-1)
67
68 struct bnxt_ring {
69         void                    *bd;
70         rte_iova_t              bd_dma;
71         uint32_t                ring_size;
72         uint32_t                ring_mask;
73
74         int                     vmem_size;
75         void                    **vmem;
76
77         uint16_t                fw_ring_id; /* Ring id filled by Chimp FW */
78         const void              *mem_zone;
79 };
80
81 struct bnxt_ring_grp_info {
82         uint16_t        fw_stats_ctx;
83         uint16_t        fw_grp_id;
84         uint16_t        rx_fw_ring_id;
85         uint16_t        cp_fw_ring_id;
86         uint16_t        ag_fw_ring_id;
87 };
88
89 struct bnxt;
90 struct bnxt_tx_ring_info;
91 struct bnxt_rx_ring_info;
92 struct bnxt_cp_ring_info;
93 void bnxt_free_ring(struct bnxt_ring *ring);
94 void bnxt_init_ring_grps(struct bnxt *bp);
95 int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
96                             struct bnxt_tx_ring_info *tx_ring_info,
97                             struct bnxt_rx_ring_info *rx_ring_info,
98                             struct bnxt_cp_ring_info *cp_ring_info,
99                             const char *suffix);
100 int bnxt_alloc_hwrm_rings(struct bnxt *bp);
101
102 #endif