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