New upstream version 18.02
[deb_dpdk.git] / drivers / net / szedata2 / szedata2_iobuf.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright (c) 2017 CESNET
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 CESNET 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 #include <stdint.h>
35
36 #include <rte_common.h>
37
38 #include "szedata2_iobuf.h"
39
40 /*
41  * IBUFs and OBUFs can generally be located at different offsets in different
42  * firmwares (modes).
43  * This part defines base offsets of IBUFs and OBUFs for various cards
44  * and firmwares (modes).
45  * Type of firmware (mode) is set through configuration option
46  * CONFIG_RTE_LIBRTE_PMD_SZEDATA2_AS.
47  * Possible values are:
48  * 0 - for cards (modes):
49  *     NFB-100G1 (100G1)
50  *
51  * 1 - for cards (modes):
52  *     NFB-100G2Q (100G1)
53  *
54  * 2 - for cards (modes):
55  *     NFB-40G2 (40G2)
56  *     NFB-100G2C (100G2)
57  *     NFB-100G2Q (40G2)
58  *
59  * 3 - for cards (modes):
60  *     NFB-40G2 (10G8)
61  *     NFB-100G2Q (10G8)
62  *
63  * 4 - for cards (modes):
64  *     NFB-100G1 (10G10)
65  *
66  * 5 - for experimental firmwares and future use
67  */
68 #if !defined(RTE_LIBRTE_PMD_SZEDATA2_AS)
69 #error "RTE_LIBRTE_PMD_SZEDATA2_AS has to be defined"
70 #elif RTE_LIBRTE_PMD_SZEDATA2_AS == 0
71
72 /*
73  * Cards (modes):
74  *     NFB-100G1 (100G1)
75  */
76
77 const uint32_t szedata2_ibuf_base_table[] = {
78         0x8000
79 };
80 const uint32_t szedata2_obuf_base_table[] = {
81         0x9000
82 };
83
84 #elif RTE_LIBRTE_PMD_SZEDATA2_AS == 1
85
86 /*
87  * Cards (modes):
88  *     NFB-100G2Q (100G1)
89  */
90
91 const uint32_t szedata2_ibuf_base_table[] = {
92         0x8800
93 };
94 const uint32_t szedata2_obuf_base_table[] = {
95         0x9800
96 };
97
98 #elif RTE_LIBRTE_PMD_SZEDATA2_AS == 2
99
100 /*
101  * Cards (modes):
102  *     NFB-40G2 (40G2)
103  *     NFB-100G2C (100G2)
104  *     NFB-100G2Q (40G2)
105  */
106
107 const uint32_t szedata2_ibuf_base_table[] = {
108         0x8000,
109         0x8800
110 };
111 const uint32_t szedata2_obuf_base_table[] = {
112         0x9000,
113         0x9800
114 };
115
116 #elif RTE_LIBRTE_PMD_SZEDATA2_AS == 3
117
118 /*
119  * Cards (modes):
120  *     NFB-40G2 (10G8)
121  *     NFB-100G2Q (10G8)
122  */
123
124 const uint32_t szedata2_ibuf_base_table[] = {
125         0x8000,
126         0x8200,
127         0x8400,
128         0x8600,
129         0x8800,
130         0x8A00,
131         0x8C00,
132         0x8E00
133 };
134 const uint32_t szedata2_obuf_base_table[] = {
135         0x9000,
136         0x9200,
137         0x9400,
138         0x9600,
139         0x9800,
140         0x9A00,
141         0x9C00,
142         0x9E00
143 };
144
145 #elif RTE_LIBRTE_PMD_SZEDATA2_AS == 4
146
147 /*
148  * Cards (modes):
149  *     NFB-100G1 (10G10)
150  */
151
152 const uint32_t szedata2_ibuf_base_table[] = {
153         0x8000,
154         0x8200,
155         0x8400,
156         0x8600,
157         0x8800,
158         0x8A00,
159         0x8C00,
160         0x8E00,
161         0x9000,
162         0x9200
163 };
164 const uint32_t szedata2_obuf_base_table[] = {
165         0xA000,
166         0xA200,
167         0xA400,
168         0xA600,
169         0xA800,
170         0xAA00,
171         0xAC00,
172         0xAE00,
173         0xB000,
174         0xB200
175 };
176
177 #elif RTE_LIBRTE_PMD_SZEDATA2_AS == 5
178
179 /*
180  * Future use and experimental firmwares.
181  */
182
183 const uint32_t szedata2_ibuf_base_table[] = {
184         0x8000,
185         0x8200,
186         0x8400,
187         0x8600,
188         0x8800
189 };
190 const uint32_t szedata2_obuf_base_table[] = {
191         0x9000,
192         0x9200,
193         0x9400,
194         0x9600,
195         0x9800
196 };
197
198 #else
199 #error "RTE_LIBRTE_PMD_SZEDATA2_AS has wrong value, see comments in config file"
200 #endif
201
202 const uint32_t szedata2_ibuf_count = RTE_DIM(szedata2_ibuf_base_table);
203 const uint32_t szedata2_obuf_count = RTE_DIM(szedata2_obuf_base_table);