da33d05ee831b661c2e78569d8e11e856147ec6f
[dpdk.git] / drivers / net / mrvl / mrvl_ethdev.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Semihalf. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *     * Neither the name of Semihalf nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef _MRVL_ETHDEV_H_
34 #define _MRVL_ETHDEV_H_
35
36 #include <rte_spinlock.h>
37 #include <drivers/mv_pp2_cls.h>
38 #include <drivers/mv_pp2_ppio.h>
39
40 /** Maximum number of rx queues per port */
41 #define MRVL_PP2_RXQ_MAX 32
42
43 /** Maximum number of tx queues per port */
44 #define MRVL_PP2_TXQ_MAX 8
45
46 /** Minimum number of descriptors in tx queue */
47 #define MRVL_PP2_TXD_MIN 16
48
49 /** Maximum number of descriptors in tx queue */
50 #define MRVL_PP2_TXD_MAX 2048
51
52 /** Tx queue descriptors alignment */
53 #define MRVL_PP2_TXD_ALIGN 16
54
55 /** Minimum number of descriptors in rx queue */
56 #define MRVL_PP2_RXD_MIN 16
57
58 /** Maximum number of descriptors in rx queue */
59 #define MRVL_PP2_RXD_MAX 2048
60
61 /** Rx queue descriptors alignment */
62 #define MRVL_PP2_RXD_ALIGN 16
63
64 /** Maximum number of descriptors in tx aggregated queue */
65 #define MRVL_PP2_AGGR_TXQD_MAX 2048
66
67 /** Maximum number of Traffic Classes. */
68 #define MRVL_PP2_TC_MAX 8
69
70 /** Packet offset inside RX buffer. */
71 #define MRVL_PKT_OFFS 64
72
73 /** Maximum number of descriptors in shadow queue. Must be power of 2 */
74 #define MRVL_PP2_TX_SHADOWQ_SIZE MRVL_PP2_TXD_MAX
75
76 /** Shadow queue size mask (since shadow queue size is power of 2) */
77 #define MRVL_PP2_TX_SHADOWQ_MASK (MRVL_PP2_TX_SHADOWQ_SIZE - 1)
78
79 /** Minimum number of sent buffers to release from shadow queue to BM */
80 #define MRVL_PP2_BUF_RELEASE_BURST_SIZE 64
81
82 struct mrvl_priv {
83         /* Hot fields, used in fast path. */
84         struct pp2_bpool *bpool;  /**< BPool pointer */
85         struct pp2_ppio *ppio;    /**< Port handler pointer */
86         rte_spinlock_t lock;      /**< Spinlock for checking bpool status */
87         uint16_t bpool_max_size;  /**< BPool maximum size */
88         uint16_t bpool_min_size;  /**< BPool minimum size  */
89         uint16_t bpool_init_size; /**< Configured BPool size  */
90
91         /** Mapping for DPDK rx queue->(TC, MRVL relative inq) */
92         struct {
93                 uint8_t tc;  /**< Traffic Class */
94                 uint8_t inq; /**< Relative in-queue number */
95         } rxq_map[MRVL_PP2_RXQ_MAX] __rte_cache_aligned;
96
97         /* Configuration data, used sporadically. */
98         uint8_t pp_id;
99         uint8_t ppio_id;
100         uint8_t bpool_bit;
101
102         struct pp2_ppio_params ppio_params;
103         struct pp2_cls_qos_tbl_params qos_tbl_params;
104         struct pp2_cls_tbl *qos_tbl;
105         uint16_t nb_rx_queues;
106 };
107
108 /** Number of ports configured. */
109 extern int mrvl_ports_nb;
110
111 #endif /* _MRVL_ETHDEV_H_ */