Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : :
5 : : #ifndef _ROC_NIX_H_
6 : : #define _ROC_NIX_H_
7 : :
8 : : /* Constants */
9 : : #define ROC_NIX_BPF_PER_PFFUNC 64
10 : : #define ROC_NIX_BPF_ID_INVALID 0xFFFF
11 : : #define ROC_NIX_BPF_LEVEL_IDX_INVALID 0xFF
12 : : #define ROC_NIX_BPF_LEVEL_MAX 3
13 : : #define ROC_NIX_BPF_STATS_MAX 12
14 : : #define ROC_NIX_MTR_ID_INVALID UINT32_MAX
15 : : #define ROC_NIX_PFC_CLASS_INVALID UINT8_MAX
16 : : #define ROC_NIX_SQB_THRESH 30U
17 : : #define ROC_NIX_SQB_SLACK 12U
18 : : #define ROC_NIX_AURA_THRESH 95U
19 : : #define ROC_NIX_LINK_SPEED_ALL 0xFFFFF
20 : :
21 : : /* Reserved interface types for BPID allocation */
22 : : #define ROC_NIX_INTF_TYPE_CGX 0
23 : : #define ROC_NIX_INTF_TYPE_LBK 1
24 : : #define ROC_NIX_INTF_TYPE_SDP 2
25 : : #define ROC_NIX_INTF_TYPE_CPT 3
26 : : #define ROC_NIX_INTF_TYPE_RSVD 4
27 : :
28 : : /* Application based types for BPID allocation, start from end (255 unused rsvd) */
29 : : #define ROC_NIX_INTF_TYPE_CPT_NIX 254
30 : : #define ROC_NIX_INTF_TYPE_SSO 253
31 : :
32 : : /* Software defined LSO base format IDX */
33 : : #define ROC_NIX_LSO_FORMAT_IDX_TSOV4 0
34 : : #define ROC_NIX_LSO_FORMAT_IDX_TSOV6 1
35 : : #define ROC_NIX_LSO_FORMAT_IDX_IPV4 2
36 : :
37 : : #define ROC_NIX_RQ_MAX_PB_CACHING_VAL 3
38 : :
39 : : /* First aligned cache block is allocated into the LLC.
40 : : * All remaining cache blocks are not allocated.
41 : : */
42 : : #define ROC_NIX_RQ_DEFAULT_PB_CACHING 2
43 : :
44 : : /* Writes of WQE data are allocated into LLC. */
45 : : #define ROC_NIX_RQ_DEFAULT_WQE_CACHING 1
46 : :
47 : : enum roc_nix_rss_reta_sz {
48 : : ROC_NIX_RSS_RETA_SZ_64 = 64,
49 : : ROC_NIX_RSS_RETA_SZ_128 = 128,
50 : : ROC_NIX_RSS_RETA_SZ_256 = 256,
51 : : };
52 : :
53 : : enum roc_nix_sq_max_sqe_sz {
54 : : roc_nix_maxsqesz_w16 = NIX_MAXSQESZ_W16,
55 : : roc_nix_maxsqesz_w8 = NIX_MAXSQESZ_W8,
56 : : };
57 : :
58 : : enum roc_nix_fc_mode {
59 : : ROC_NIX_FC_NONE = 0,
60 : : ROC_NIX_FC_RX,
61 : : ROC_NIX_FC_TX,
62 : : ROC_NIX_FC_FULL
63 : : };
64 : :
65 : : enum roc_nix_vlan_type {
66 : : ROC_NIX_VLAN_TYPE_INNER = 0x01,
67 : : ROC_NIX_VLAN_TYPE_OUTER = 0x02,
68 : : };
69 : :
70 : : enum roc_nix_bpf_level_flag {
71 : : ROC_NIX_BPF_LEVEL_F_LEAF = BIT(0),
72 : : ROC_NIX_BPF_LEVEL_F_MID = BIT(1),
73 : : ROC_NIX_BPF_LEVEL_F_TOP = BIT(2),
74 : : };
75 : :
76 : : enum roc_nix_bpf_precolor_tbl_size {
77 : : ROC_NIX_BPF_PRECOLOR_TBL_SIZE_GEN = 16,
78 : : ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN = 16,
79 : : ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP = 64,
80 : : };
81 : :
82 : : enum roc_nix_bpf_pc_mode {
83 : : ROC_NIX_BPF_PC_MODE_VLAN_INNER,
84 : : ROC_NIX_BPF_PC_MODE_VLAN_OUTER,
85 : : ROC_NIX_BPF_PC_MODE_DSCP_INNER,
86 : : ROC_NIX_BPF_PC_MODE_DSCP_OUTER,
87 : : ROC_NIX_BPF_PC_MODE_GEN_INNER,
88 : : ROC_NIX_BPF_PC_MODE_GEN_OUTER
89 : : };
90 : :
91 : : enum roc_nix_bpf_color {
92 : : ROC_NIX_BPF_COLOR_GREEN,
93 : : ROC_NIX_BPF_COLOR_YELLOW,
94 : : ROC_NIX_BPF_COLOR_RED,
95 : : ROC_NIX_BPF_COLOR_MAX
96 : : };
97 : :
98 : : enum roc_nix_bpf_algo {
99 : : ROC_NIX_BPF_ALGO_NONE,
100 : : ROC_NIX_BPF_ALGO_2698,
101 : : ROC_NIX_BPF_ALGO_4115,
102 : : ROC_NIX_BPF_ALGO_2697
103 : : };
104 : :
105 : : enum roc_nix_bpf_lmode { ROC_NIX_BPF_LMODE_BYTE, ROC_NIX_BPF_LMODE_PACKET };
106 : :
107 : : enum roc_nix_bpf_action {
108 : : ROC_NIX_BPF_ACTION_PASS,
109 : : ROC_NIX_BPF_ACTION_DROP,
110 : : ROC_NIX_BPF_ACTION_RED
111 : : };
112 : :
113 : : enum roc_nix_bpf_stats {
114 : : ROC_NIX_BPF_GREEN_PKT_F_PASS = BIT_ULL(0),
115 : : ROC_NIX_BPF_GREEN_OCTS_F_PASS = BIT_ULL(1),
116 : : ROC_NIX_BPF_GREEN_PKT_F_DROP = BIT_ULL(2),
117 : : ROC_NIX_BPF_GREEN_OCTS_F_DROP = BIT_ULL(3),
118 : : ROC_NIX_BPF_YELLOW_PKT_F_PASS = BIT_ULL(4),
119 : : ROC_NIX_BPF_YELLOW_OCTS_F_PASS = BIT_ULL(5),
120 : : ROC_NIX_BPF_YELLOW_PKT_F_DROP = BIT_ULL(6),
121 : : ROC_NIX_BPF_YELLOW_OCTS_F_DROP = BIT_ULL(7),
122 : : ROC_NIX_BPF_RED_PKT_F_PASS = BIT_ULL(8),
123 : : ROC_NIX_BPF_RED_OCTS_F_PASS = BIT_ULL(9),
124 : : ROC_NIX_BPF_RED_PKT_F_DROP = BIT_ULL(10),
125 : : ROC_NIX_BPF_RED_OCTS_F_DROP = BIT_ULL(11),
126 : : };
127 : :
128 : : enum roc_nix_link_duplex {
129 : : ROC_NIX_LINK_DUPLEX_FULL = 0,
130 : : ROC_NIX_LINK_DUPLEX_HALF = 1
131 : : };
132 : :
133 : : enum roc_nix_link_speed_bits {
134 : : ROC_NIX_LINK_SPEED_NONE_BIT = BIT_ULL(0),
135 : : ROC_NIX_LINK_SPEED_10M_HD_BIT = BIT_ULL(1),
136 : : ROC_NIX_LINK_SPEED_10M_BIT = BIT_ULL(2),
137 : : ROC_NIX_LINK_SPEED_100M_HD_BIT = BIT_ULL(3),
138 : : ROC_NIX_LINK_SPEED_100M_BIT = BIT_ULL(4),
139 : : ROC_NIX_LINK_SPEED_1G_BIT = BIT_ULL(5),
140 : : ROC_NIX_LINK_SPEED_2_5G_BIT = BIT_ULL(6),
141 : : ROC_NIX_LINK_SPEED_5G_BIT = BIT_ULL(7),
142 : : ROC_NIX_LINK_SPEED_10G_BIT = BIT_ULL(8),
143 : : ROC_NIX_LINK_SPEED_20G_BIT = BIT_ULL(9),
144 : : ROC_NIX_LINK_SPEED_25G_BIT = BIT_ULL(10),
145 : : ROC_NIX_LINK_SPEED_40G_BIT = BIT_ULL(11),
146 : : ROC_NIX_LINK_SPEED_50G_BIT = BIT_ULL(12),
147 : : ROC_NIX_LINK_SPEED_56G_BIT = BIT_ULL(13),
148 : : ROC_NIX_LINK_SPEED_100G_BIT = BIT_ULL(14),
149 : : ROC_NIX_LINK_SPEED_200G_BIT = BIT_ULL(15),
150 : : ROC_NIX_LINK_SPEED_400G_BIT = BIT_ULL(16),
151 : : ROC_NIX_LINK_SPEED_MAX = 17
152 : : };
153 : :
154 : : enum roc_nix_link_mode {
155 : : ROC_NIX_LINK_MODE_10BASET_HD = BIT_ULL(0),
156 : : ROC_NIX_LINK_MODE_10BASET_FD = BIT_ULL(1),
157 : : ROC_NIX_LINK_MODE_100BASET_HD = BIT_ULL(2),
158 : : ROC_NIX_LINK_MODE_100BASET_FD = BIT_ULL(3),
159 : : ROC_NIX_LINK_MODE_1000BASET_HD = BIT_ULL(4),
160 : : ROC_NIX_LINK_MODE_1000BASET_FD = BIT_ULL(5),
161 : : ROC_NIX_LINK_MODE_AUTONEG = BIT_ULL(6),
162 : : ROC_NIX_LINK_MODE_10000BASET_FD = BIT_ULL(12),
163 : : ROC_NIX_LINK_MODE_2500BASEX_FD = BIT_ULL(15),
164 : : ROC_NIX_LINK_MODE_1000BASEKX_FD = BIT_ULL(17),
165 : : ROC_NIX_LINK_MODE_10000BASEKX4_FD = BIT_ULL(18),
166 : : ROC_NIX_LINK_MODE_10000BASEKR_FD = BIT_ULL(19),
167 : : ROC_NIX_LINK_MODE_10000BASER_FEC = BIT_ULL(20),
168 : : ROC_NIX_LINK_MODE_20000BASEMLD2_FD = BIT_ULL(21),
169 : : ROC_NIX_LINK_MODE_20000BASEKR2_FD = BIT_ULL(22),
170 : : ROC_NIX_LINK_MODE_40000BASEKR4_FD = BIT_ULL(23),
171 : : ROC_NIX_LINK_MODE_40000BASECR4_FD = BIT_ULL(24),
172 : : ROC_NIX_LINK_MODE_40000BASESR4_FD = BIT_ULL(25),
173 : : ROC_NIX_LINK_MODE_40000BASELR4_FD = BIT_ULL(26),
174 : : ROC_NIX_LINK_MODE_56000BASEKR4_FD = BIT_ULL(27),
175 : : ROC_NIX_LINK_MODE_56000BASECR4_FD = BIT_ULL(28),
176 : : ROC_NIX_LINK_MODE_56000BASESR4_FD = BIT_ULL(29),
177 : : ROC_NIX_LINK_MODE_56000BASELR4_FD = BIT_ULL(30),
178 : : ROC_NIX_LINK_MODE_25000BASECR_FD = BIT_ULL(31),
179 : : ROC_NIX_LINK_MODE_25000BASEKR_FD = BIT_ULL(32),
180 : : ROC_NIX_LINK_MODE_25000BASESR_FD = BIT_ULL(33),
181 : : ROC_NIX_LINK_MODE_50000BASECR2_FD = BIT_ULL(34),
182 : : ROC_NIX_LINK_MODE_50000BASEKR2_FD = BIT_ULL(35),
183 : : ROC_NIX_LINK_MODE_100000BASEKR4_FD = BIT_ULL(36),
184 : : ROC_NIX_LINK_MODE_100000BASESR4_FD = BIT_ULL(37),
185 : : ROC_NIX_LINK_MODE_100000BASECR4_FD = BIT_ULL(38),
186 : : ROC_NIX_LINK_MODE_100000BASELR4_ER4_FD = BIT_ULL(39),
187 : : ROC_NIX_LINK_MODE_50000BASESR2_FD = BIT_ULL(40),
188 : : ROC_NIX_LINK_MODE_1000BASEX_FD = BIT_ULL(41),
189 : : ROC_NIX_LINK_MODE_10000BASECR_FD = BIT_ULL(42),
190 : : ROC_NIX_LINK_MODE_10000BASESR_FD = BIT_ULL(43),
191 : : ROC_NIX_LINK_MODE_10000BASELR_FD = BIT_ULL(44),
192 : : ROC_NIX_LINK_MODE_10000BASELRM_FD = BIT_ULL(45),
193 : : ROC_NIX_LINK_MODE_10000BASEER_FD = BIT_ULL(46),
194 : : ROC_NIX_LINK_MODE_2500BASET_FD = BIT_ULL(47),
195 : : ROC_NIX_LINK_MODE_5000BASET_FD = BIT_ULL(48),
196 : : ROC_NIX_LINK_MODE_FEC_NONE = BIT_ULL(49),
197 : : ROC_NIX_LINK_MODE_FEC_RS = BIT_ULL(50),
198 : : ROC_NIX_LINK_MODE_FEC_BASER = BIT_ULL(51),
199 : : ROC_NIX_LINK_MODE_50000BASEKR_FD = BIT_ULL(52),
200 : : ROC_NIX_LINK_MODE_50000BASESR_FD = BIT_ULL(53),
201 : : ROC_NIX_LINK_MODE_50000BASECR_FD = BIT_ULL(54),
202 : : ROC_NIX_LINK_MODE_50000BASELR_ER_FR_FD = BIT_ULL(55),
203 : : ROC_NIX_LINK_MODE_50000BASEDR_FD = BIT_ULL(56),
204 : : ROC_NIX_LINK_MODE_100000BASEKR2_FD = BIT_ULL(57),
205 : : ROC_NIX_LINK_MODE_100000BASESR2_FD = BIT_ULL(58),
206 : : ROC_NIX_LINK_MODE_100000BASECR2_FD = BIT_ULL(59),
207 : : ROC_NIX_LINK_MODE_100000BASELR2_ER2_FR2_FD = BIT_ULL(60),
208 : : ROC_NIX_LINK_MODE_100000BASEDR2_FD = BIT_ULL(61),
209 : : };
210 : :
211 : : struct roc_nix_bpf_cfg {
212 : : enum roc_nix_bpf_algo alg;
213 : : enum roc_nix_bpf_lmode lmode;
214 : : enum roc_nix_bpf_color icolor;
215 : : enum roc_nix_bpf_pc_mode pc_mode;
216 : : bool tnl_ena;
217 : : union {
218 : : /* Valid when *alg* is set to ROC_NIX_BPF_ALGO_2697. */
219 : : struct {
220 : : uint64_t cir;
221 : : uint64_t cbs;
222 : : uint64_t ebs;
223 : : } algo2697;
224 : :
225 : : /* Valid when *alg* is set to ROC_NIX_BPF_ALGO_2698. */
226 : : struct {
227 : : uint64_t cir;
228 : : uint64_t pir;
229 : : uint64_t cbs;
230 : : uint64_t pbs;
231 : : } algo2698;
232 : :
233 : : /* Valid when *alg* is set to ROC_NIX_BPF_ALGO_4115. */
234 : : struct {
235 : : uint64_t cir;
236 : : uint64_t eir;
237 : : uint64_t cbs;
238 : : uint64_t ebs;
239 : : } algo4115;
240 : : };
241 : :
242 : : enum roc_nix_bpf_action action[ROC_NIX_BPF_COLOR_MAX];
243 : :
244 : : /* Reserved for future config*/
245 : : uint32_t rsvd[3];
246 : : };
247 : :
248 : : struct roc_nix_bpf_objs {
249 : : uint16_t level;
250 : : uint16_t count;
251 : : uint16_t ids[ROC_NIX_BPF_PER_PFFUNC];
252 : : };
253 : :
254 : : struct roc_nix_bpf_precolor {
255 : : #define ROC_NIX_BPF_PRE_COLOR_MAX 64
256 : : uint8_t count;
257 : : enum roc_nix_bpf_pc_mode mode;
258 : : enum roc_nix_bpf_color color[ROC_NIX_BPF_PRE_COLOR_MAX];
259 : : };
260 : :
261 : : struct roc_nix_vlan_config {
262 : : uint32_t type;
263 : : union {
264 : : struct {
265 : : uint32_t vtag_inner;
266 : : uint32_t vtag_outer;
267 : : } vlan;
268 : :
269 : : struct {
270 : : int idx_inner;
271 : : int idx_outer;
272 : : } mcam;
273 : : };
274 : : };
275 : :
276 : : struct roc_nix_fc_cfg {
277 : : #define ROC_NIX_FC_RXCHAN_CFG 0
278 : : #define ROC_NIX_FC_CQ_CFG 1
279 : : #define ROC_NIX_FC_TM_CFG 2
280 : : #define ROC_NIX_FC_RQ_CFG 3
281 : : uint8_t type;
282 : : union {
283 : : struct {
284 : : bool enable;
285 : : } rxchan_cfg;
286 : :
287 : : struct {
288 : : uint32_t rq;
289 : : uint16_t tc;
290 : : uint16_t cq_drop;
291 : : uint16_t cq_bp;
292 : : bool enable;
293 : : } cq_cfg;
294 : :
295 : : struct {
296 : : uint32_t rq;
297 : : uint16_t tc;
298 : : uint16_t cq_drop;
299 : : uint16_t cq_bp;
300 : : uint64_t pool;
301 : : uint64_t spb_pool;
302 : : uint64_t pool_drop_pct;
303 : : uint64_t spb_pool_drop_pct;
304 : : bool enable;
305 : : } rq_cfg;
306 : :
307 : : struct {
308 : : uint32_t sq;
309 : : uint16_t tc;
310 : : bool enable;
311 : : } tm_cfg;
312 : : };
313 : : };
314 : :
315 : : struct roc_nix_pfc_cfg {
316 : : enum roc_nix_fc_mode mode;
317 : : /* For SET, tc must be [0, 15].
318 : : * For GET, TC will represent bitmap
319 : : */
320 : : uint16_t tc;
321 : : };
322 : :
323 : : struct roc_nix_eeprom_info {
324 : : #define ROC_NIX_EEPROM_SIZE 256
325 : : uint16_t sff_id;
326 : : uint8_t buf[ROC_NIX_EEPROM_SIZE];
327 : : };
328 : :
329 : : /* Range to adjust PTP frequency. Valid range is
330 : : * (-ROC_NIX_PTP_FREQ_ADJUST, ROC_NIX_PTP_FREQ_ADJUST)
331 : : */
332 : : #define ROC_NIX_PTP_FREQ_ADJUST (1 << 9)
333 : :
334 : : /* NIX LF RX offload configuration flags.
335 : : * These are input flags to roc_nix_lf_alloc:rx_cfg
336 : : */
337 : : #define ROC_NIX_LF_RX_CFG_DROP_RE BIT_ULL(32)
338 : : #define ROC_NIX_LF_RX_CFG_L2_LEN_ERR BIT_ULL(33)
339 : : #define ROC_NIX_LF_RX_CFG_IP6_UDP_OPT BIT_ULL(34)
340 : : #define ROC_NIX_LF_RX_CFG_DIS_APAD BIT_ULL(35)
341 : : #define ROC_NIX_LF_RX_CFG_CSUM_IL4 BIT_ULL(36)
342 : : #define ROC_NIX_LF_RX_CFG_CSUM_OL4 BIT_ULL(37)
343 : : #define ROC_NIX_LF_RX_CFG_LEN_IL4 BIT_ULL(38)
344 : : #define ROC_NIX_LF_RX_CFG_LEN_IL3 BIT_ULL(39)
345 : : #define ROC_NIX_LF_RX_CFG_LEN_OL4 BIT_ULL(40)
346 : : #define ROC_NIX_LF_RX_CFG_LEN_OL3 BIT_ULL(41)
347 : : #define ROC_NIX_LF_RX_CFG_APAD_MODE BIT_ULL(42)
348 : :
349 : : #define ROC_NIX_LF_RX_CFG_RX_ERROR_MASK 0xFFFFFFFFFFF80000
350 : : #define ROC_NIX_RE_PARTIAL BIT_ULL(1)
351 : : #define ROC_NIX_RE_JABBER BIT_ULL(2)
352 : : #define ROC_NIX_RE_CRC8_PCH BIT_ULL(5)
353 : : #define ROC_NIX_RE_CNC_INV BIT_ULL(6)
354 : : #define ROC_NIX_RE_FCS BIT_ULL(7)
355 : : #define ROC_NIX_RE_FCS_RCV BIT_ULL(8)
356 : : #define ROC_NIX_RE_TERMINATE BIT_ULL(9)
357 : : #define ROC_NIX_RE_MACSEC BIT_ULL(10)
358 : : #define ROC_NIX_RE_RX_CTL BIT_ULL(11)
359 : : #define ROC_NIX_RE_SKIP BIT_ULL(12)
360 : : #define ROC_NIX_RE_DMAPKT BIT_ULL(15)
361 : : #define ROC_NIX_RE_UNDERSIZE BIT_ULL(16)
362 : : #define ROC_NIX_RE_OVERSIZE BIT_ULL(17)
363 : : #define ROC_NIX_RE_OL2_LENMISM BIT_ULL(18)
364 : :
365 : : /* Group 0 will be used for RSS, 1 -7 will be used for npc_flow RSS action*/
366 : : #define ROC_NIX_RSS_GROUP_DEFAULT 0
367 : : #define ROC_NIX_RSS_GRPS 8
368 : : #define ROC_NIX_RSS_RETA_MAX ROC_NIX_RSS_RETA_SZ_256
369 : : #define ROC_NIX_RSS_KEY_LEN 48 /* 352 Bits */
370 : : #define ROC_NIX_RSS_MCAM_IDX_DEFAULT (-1)
371 : :
372 : : #define ROC_NIX_VWQE_MAX_SIZE_LOG2 11
373 : : #define ROC_NIX_VWQE_MIN_SIZE_LOG2 2
374 : :
375 : : struct roc_nix_stats {
376 : : /* Rx */
377 : : uint64_t rx_octs;
378 : : uint64_t rx_ucast;
379 : : uint64_t rx_bcast;
380 : : uint64_t rx_mcast;
381 : : uint64_t rx_drop;
382 : : uint64_t rx_drop_octs;
383 : : uint64_t rx_fcs;
384 : : uint64_t rx_err;
385 : : uint64_t rx_drop_bcast;
386 : : uint64_t rx_drop_mcast;
387 : : uint64_t rx_drop_l3_bcast;
388 : : uint64_t rx_drop_l3_mcast;
389 : : /* Tx */
390 : : uint64_t tx_ucast;
391 : : uint64_t tx_bcast;
392 : : uint64_t tx_mcast;
393 : : uint64_t tx_drop;
394 : : uint64_t tx_octs;
395 : : };
396 : :
397 : : struct roc_nix_stats_queue {
398 : : union {
399 : : struct {
400 : : /* Rx */
401 : : uint64_t rx_pkts;
402 : : uint64_t rx_octs;
403 : : uint64_t rx_drop_pkts;
404 : : uint64_t rx_drop_octs;
405 : : uint64_t rx_error_pkts;
406 : : };
407 : : struct {
408 : : /* Tx */
409 : : uint64_t tx_pkts;
410 : : uint64_t tx_octs;
411 : : uint64_t tx_drop_pkts;
412 : : uint64_t tx_drop_octs;
413 : : uint64_t tx_age_drop_pkts;
414 : : uint64_t tx_age_drop_octs;
415 : : };
416 : : };
417 : : };
418 : :
419 : : struct roc_nix_rq {
420 : : /* Input parameters */
421 : : uint16_t qid;
422 : : uint16_t cqid; /* Not valid when SSO is enabled */
423 : : uint16_t bpf_id;
424 : : uint64_t aura_handle;
425 : : bool ipsech_ena;
426 : : uint16_t first_skip;
427 : : uint16_t later_skip;
428 : : uint16_t wqe_skip;
429 : : uint16_t lpb_size;
430 : : uint32_t tag_mask;
431 : : uint32_t flow_tag_width;
432 : : uint8_t tt; /* Valid when SSO is enabled */
433 : : uint16_t hwgrp; /* Valid when SSO is enabled */
434 : : bool sso_ena;
435 : : bool vwqe_ena;
436 : : uint64_t spb_aura_handle; /* Valid when SPB is enabled */
437 : : uint16_t spb_size; /* Valid when SPB is enabled */
438 : : bool spb_ena;
439 : : uint8_t vwqe_first_skip;
440 : : uint32_t vwqe_max_sz_exp;
441 : : uint64_t vwqe_wait_tmo;
442 : : uint64_t vwqe_aura_handle;
443 : : /* Average LPB aura level drop threshold for RED */
444 : : uint8_t red_drop;
445 : : /* Average LPB aura level pass threshold for RED */
446 : : uint8_t red_pass;
447 : : /* Average SPB aura level drop threshold for RED */
448 : : uint8_t spb_red_drop;
449 : : /* Average SPB aura level pass threshold for RED */
450 : : uint8_t xqe_red_pass;
451 : : /* Average xqe level drop threshold for RED */
452 : : uint8_t xqe_red_drop;
453 : : /* Average xqe level pass threshold for RED */
454 : : uint8_t spb_red_pass;
455 : : /* LPB aura drop enable */
456 : : bool lpb_drop_ena;
457 : : /* SPB aura drop enable */
458 : : bool spb_drop_ena;
459 : : /* XQE drop enable */
460 : : bool xqe_drop_ena;
461 : : /* RQ PB caching */
462 : : uint8_t pb_caching;
463 : : /* RQ WQE caching */
464 : : uint8_t wqe_caching;
465 : : /* End of Input parameters */
466 : : struct roc_nix *roc_nix;
467 : : uint64_t meta_aura_handle;
468 : : uint16_t inl_dev_refs;
469 : : uint8_t tc;
470 : : };
471 : :
472 : : struct roc_nix_cq {
473 : : /* Input parameters */
474 : : uint16_t qid;
475 : : uint32_t nb_desc;
476 : : uint8_t stash_thresh;
477 : : /* End of Input parameters */
478 : : uint16_t drop_thresh;
479 : : uint16_t bp_thresh;
480 : : struct roc_nix *roc_nix;
481 : : uintptr_t door;
482 : : int64_t *status;
483 : : uint64_t wdata;
484 : : void *desc_base;
485 : : uint32_t qmask;
486 : : uint32_t head;
487 : : };
488 : :
489 : : struct roc_nix_sq {
490 : : /* Input parameters */
491 : : enum roc_nix_sq_max_sqe_sz max_sqe_sz;
492 : : uint32_t nb_desc;
493 : : uint16_t qid;
494 : : uint16_t cqid;
495 : : uint16_t cq_drop_thresh;
496 : : bool sso_ena;
497 : : bool cq_ena;
498 : : uint8_t fc_hyst_bits;
499 : : /* End of Input parameters */
500 : : uint16_t sqes_per_sqb;
501 : : uint16_t sqes_per_sqb_log2;
502 : : struct roc_nix *roc_nix;
503 : : uint64_t aura_handle;
504 : : int16_t nb_sqb_bufs_adj;
505 : : uint16_t nb_sqb_bufs;
506 : : uint16_t aura_sqb_bufs;
507 : : plt_iova_t io_addr;
508 : : void *lmt_addr;
509 : : void *sqe_mem;
510 : : void *fc;
511 : : void *sq_cnt_ptr;
512 : : uint8_t update_sq_cnt;
513 : : uint8_t tc;
514 : : bool enable;
515 : : };
516 : :
517 : : struct roc_nix_link_info {
518 : : uint64_t status : 1;
519 : : uint64_t full_duplex : 1;
520 : : uint64_t lmac_type_id : 4;
521 : : uint64_t speed : 20;
522 : : uint64_t speed_bitmask : 16;
523 : : uint64_t autoneg : 1;
524 : : uint64_t fec : 2;
525 : : uint64_t port : 8;
526 : : uint64_t advertising;
527 : : };
528 : :
529 : : struct roc_nix_mac_fwdata {
530 : : uint64_t advertised_link_modes;
531 : : uint64_t supported_link_modes;
532 : : uint64_t port_type;
533 : : uint64_t supported_an;
534 : : };
535 : :
536 : : /** Maximum name length for extended statistics counters */
537 : : #define ROC_NIX_XSTATS_NAME_SIZE 64
538 : :
539 : : struct roc_nix_xstat {
540 : : uint64_t id; /**< The index in xstats name array. */
541 : : uint64_t value; /**< The statistic counter value. */
542 : : };
543 : :
544 : : struct roc_nix_xstat_name {
545 : : char name[ROC_NIX_XSTATS_NAME_SIZE];
546 : : };
547 : :
548 : : struct roc_nix_ipsec_cfg {
549 : : uint32_t sa_size;
550 : : uint32_t tag_const;
551 : : plt_iova_t iova;
552 : : uint16_t max_sa;
553 : : uint8_t tt;
554 : : int8_t res_addr_offset;
555 : : };
556 : :
557 : : /* Link status update callback */
558 : : typedef void (*link_status_t)(struct roc_nix *roc_nix,
559 : : struct roc_nix_link_info *link);
560 : :
561 : : /* PTP info update callback */
562 : : typedef int (*ptp_info_update_t)(struct roc_nix *roc_nix, bool enable);
563 : :
564 : : /* Queue Error get callback */
565 : : typedef void (*q_err_get_t)(struct roc_nix *roc_nix, void *data);
566 : :
567 : : /* Link status get callback */
568 : : typedef void (*link_info_get_t)(struct roc_nix *roc_nix,
569 : : struct roc_nix_link_info *link);
570 : :
571 : : TAILQ_HEAD(roc_nix_list, roc_nix);
572 : :
573 : : struct roc_nix {
574 : : /* Input parameters */
575 : : struct plt_pci_device *pci_dev;
576 : : uint16_t port_id;
577 : : bool rss_tag_as_xor;
578 : : uint16_t max_sqb_count;
579 : : enum roc_nix_rss_reta_sz reta_sz;
580 : : bool enable_loop;
581 : : bool tx_compl_ena;
582 : : bool hw_vlan_ins;
583 : : uint8_t lock_rx_ctx;
584 : : uint16_t sqb_slack;
585 : : uint16_t outb_nb_crypto_qs;
586 : : uint32_t outb_nb_desc;
587 : : uint32_t ipsec_in_min_spi;
588 : : uint32_t ipsec_in_max_spi;
589 : : uint32_t ipsec_out_max_sa;
590 : : uint32_t dwrr_mtu;
591 : : bool ipsec_out_sso_pffunc;
592 : : bool custom_sa_action;
593 : : int8_t res_addr_offset;
594 : : bool local_meta_aura_ena;
595 : : uint32_t meta_buf_sz;
596 : : bool force_rx_aura_bp;
597 : : bool custom_meta_aura_ena;
598 : : bool rx_inj_ena;
599 : : bool custom_inb_sa;
600 : : bool use_write_sa;
601 : : uint32_t root_sched_weight;
602 : : uint16_t inb_cfg_param1;
603 : : uint16_t inb_cfg_param2;
604 : : bool force_tail_drop;
605 : : bool dis_xqe_drop;
606 : : bool sq_resize_ena;
607 : : uint8_t def_first_skip;
608 : : uint32_t rxc_step;
609 : : /* End of input parameters */
610 : : /* LMT line base for "Per Core Tx LMT line" mode*/
611 : : uintptr_t lmt_base;
612 : : bool io_enabled;
613 : : bool rx_ptp_ena;
614 : : bool sqb_halo_ena;
615 : : uint16_t cints;
616 : : uint32_t buf_sz;
617 : : uint64_t meta_aura_handle;
618 : : uintptr_t meta_mempool;
619 : : uint16_t rep_cnt;
620 : : uint16_t rep_pfvf_map[MAX_PFVF_REP];
621 : : bool reass_ena;
622 : : bool use_multi_bpids;
623 : : TAILQ_ENTRY(roc_nix) next;
624 : :
625 : : #define ROC_NIX_MEM_SZ (6 * 1131)
626 : : uint8_t reserved[ROC_NIX_MEM_SZ] __plt_cache_aligned;
627 : : } __plt_cache_aligned;
628 : :
629 : : enum roc_nix_lso_tun_type {
630 : : ROC_NIX_LSO_TUN_V4V4,
631 : : ROC_NIX_LSO_TUN_V4V6,
632 : : ROC_NIX_LSO_TUN_V6V4,
633 : : ROC_NIX_LSO_TUN_V6V6,
634 : : ROC_NIX_LSO_TUN_MAX,
635 : : };
636 : :
637 : : /* Restrict CN9K sched weight to have a minimum quantum */
638 : : #define ROC_NIX_CN9K_TM_RR_WEIGHT_MAX 255u
639 : :
640 : : /* NIX TM Inlines */
641 : : static inline uint64_t
642 : : roc_nix_tm_max_sched_wt_get(void)
643 : : {
644 [ # # # # : 0 : if (roc_model_is_cn9k())
# # # # ]
645 : : return ROC_NIX_CN9K_TM_RR_WEIGHT_MAX;
646 : : else
647 : 0 : return NIX_TM_RR_WEIGHT_MAX;
648 : : }
649 : :
650 : : static inline uint64_t
651 : : roc_nix_tm_max_shaper_burst_get(void)
652 : : {
653 [ # # ]: 0 : if (roc_model_is_cn9k())
654 : : return NIX_CN9K_TM_MAX_SHAPER_BURST;
655 : : else
656 : 0 : return NIX_TM_MAX_SHAPER_BURST;
657 : : }
658 : :
659 : : /* Dev */
660 : : int __roc_api roc_nix_dev_init(struct roc_nix *roc_nix);
661 : : int __roc_api roc_nix_dev_fini(struct roc_nix *roc_nix);
662 : :
663 : : /* Type */
664 : : bool __roc_api roc_nix_is_lbk(struct roc_nix *roc_nix);
665 : : bool __roc_api roc_nix_is_esw(struct roc_nix *roc_nix);
666 : : bool __roc_api roc_nix_is_sdp(struct roc_nix *roc_nix);
667 : : bool __roc_api roc_nix_is_pf(struct roc_nix *roc_nix);
668 : : bool __roc_api roc_nix_is_vf_or_sdp(struct roc_nix *roc_nix);
669 : : int __roc_api roc_nix_get_base_chan(struct roc_nix *roc_nix);
670 : : uint8_t __roc_api roc_nix_get_rx_chan_cnt(struct roc_nix *roc_nix);
671 : : int __roc_api roc_nix_get_pf(struct roc_nix *roc_nix);
672 : : int __roc_api roc_nix_get_vf(struct roc_nix *roc_nix);
673 : : uint16_t __roc_api roc_nix_get_pf_func(struct roc_nix *roc_nix);
674 : : uint16_t __roc_api roc_nix_get_vwqe_interval(struct roc_nix *roc_nix);
675 : : int __roc_api roc_nix_max_pkt_len(struct roc_nix *roc_nix);
676 : :
677 : : /* LF ops */
678 : : int __roc_api roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq,
679 : : uint32_t nb_txq, uint64_t rx_cfg);
680 : : int __roc_api roc_nix_lf_free(struct roc_nix *roc_nix);
681 : : int __roc_api roc_nix_lf_inl_ipsec_cfg(struct roc_nix *roc_nix,
682 : : struct roc_nix_ipsec_cfg *cfg, bool enb);
683 : : int __roc_api roc_nix_cpt_ctx_cache_sync(struct roc_nix *roc_nix);
684 : : int __roc_api roc_nix_rx_drop_re_set(struct roc_nix *roc_nix, bool ena);
685 : :
686 : : /* Debug */
687 : : int __roc_api roc_nix_lf_get_reg_count(struct roc_nix *roc_nix);
688 : : int __roc_api roc_nix_lf_reg_dump(struct roc_nix *roc_nix, uint64_t *data);
689 : : int __roc_api roc_nix_queues_ctx_dump(struct roc_nix *roc_nix, FILE *file);
690 : : void __roc_api roc_nix_cqe_dump(FILE *file, const struct nix_cqe_hdr_s *cq);
691 : : void __roc_api roc_nix_rq_dump(struct roc_nix_rq *rq, FILE *file);
692 : : void __roc_api roc_nix_cq_dump(struct roc_nix_cq *cq, FILE *file);
693 : : void __roc_api roc_nix_sq_dump(struct roc_nix_sq *sq, FILE *file);
694 : : int __roc_api roc_nix_sq_desc_dump(struct roc_nix *roc_nix, uint16_t q, uint16_t offset,
695 : : uint16_t num, FILE *file);
696 : : void __roc_api roc_nix_tm_dump(struct roc_nix *roc_nix, FILE *file);
697 : : void __roc_api roc_nix_dump(struct roc_nix *roc_nix, FILE *file);
698 : :
699 : : /* IRQ */
700 : : void __roc_api roc_nix_rx_queue_intr_enable(struct roc_nix *roc_nix,
701 : : uint16_t rxq_id);
702 : : void __roc_api roc_nix_rx_queue_intr_disable(struct roc_nix *roc_nix,
703 : : uint16_t rxq_id);
704 : : void __roc_api roc_nix_err_intr_ena_dis(struct roc_nix *roc_nix, bool enb);
705 : : void __roc_api roc_nix_ras_intr_ena_dis(struct roc_nix *roc_nix, bool enb);
706 : : int __roc_api roc_nix_register_queue_irqs(struct roc_nix *roc_nix);
707 : : void __roc_api roc_nix_unregister_queue_irqs(struct roc_nix *roc_nix);
708 : : int __roc_api roc_nix_register_cq_irqs(struct roc_nix *roc_nix);
709 : : void __roc_api roc_nix_unregister_cq_irqs(struct roc_nix *roc_nix);
710 : :
711 : : /* Traffic Management */
712 : : #define ROC_NIX_TM_SHAPER_PROFILE_NONE UINT32_MAX
713 : : #define ROC_NIX_TM_NODE_ID_INVALID UINT32_MAX
714 : :
715 : : enum roc_nix_tm_tree {
716 : : ROC_NIX_TM_DEFAULT = 0,
717 : : ROC_NIX_TM_RLIMIT,
718 : : ROC_NIX_TM_PFC,
719 : : ROC_NIX_TM_SDP,
720 : : ROC_NIX_TM_USER,
721 : : ROC_NIX_TM_TREE_MAX,
722 : : };
723 : :
724 : : enum roc_tm_node_level {
725 : : ROC_TM_LVL_ROOT = 0,
726 : : ROC_TM_LVL_SCH1,
727 : : ROC_TM_LVL_SCH2,
728 : : ROC_TM_LVL_SCH3,
729 : : ROC_TM_LVL_SCH4,
730 : : ROC_TM_LVL_QUEUE,
731 : : ROC_TM_LVL_MAX,
732 : : };
733 : :
734 : : /*
735 : : * TM runtime hierarchy init API.
736 : : */
737 : : int __roc_api roc_nix_tm_init(struct roc_nix *roc_nix);
738 : : void __roc_api roc_nix_tm_fini(struct roc_nix *roc_nix);
739 : : int __roc_api roc_nix_tm_sq_aura_fc(struct roc_nix_sq *sq, bool enable);
740 : : int __roc_api roc_nix_tm_sq_flush_spin(struct roc_nix_sq *sq);
741 : :
742 : : /*
743 : : * TM User hierarchy API.
744 : : */
745 : :
746 : : struct roc_nix_tm_node {
747 : : #define ROC_NIX_TM_NODE_SZ (128)
748 : : uint8_t reserved[ROC_NIX_TM_NODE_SZ];
749 : :
750 : : uint32_t id;
751 : : uint32_t parent_id;
752 : : uint32_t priority;
753 : : uint32_t weight;
754 : : uint32_t shaper_profile_id;
755 : : uint16_t lvl;
756 : : bool pkt_mode;
757 : : bool pkt_mode_set;
758 : : /* Function to free this memory */
759 : : void (*free_fn)(void *node);
760 : : };
761 : :
762 : : struct roc_nix_tm_shaper_profile {
763 : : #define ROC_NIX_TM_SHAPER_PROFILE_SZ (128)
764 : : uint8_t reserved[ROC_NIX_TM_SHAPER_PROFILE_SZ];
765 : :
766 : : uint32_t id;
767 : : uint64_t commit_rate;
768 : : uint64_t commit_sz;
769 : : uint64_t peak_rate;
770 : : uint64_t peak_sz;
771 : : int32_t pkt_len_adj;
772 : : bool pkt_mode;
773 : : int8_t accuracy;
774 : : uint8_t red_algo;
775 : : /* Function to free this memory */
776 : : void (*free_fn)(void *profile);
777 : : };
778 : :
779 : : enum roc_nix_tm_node_stats_type {
780 : : ROC_NIX_TM_NODE_PKTS_DROPPED,
781 : : ROC_NIX_TM_NODE_BYTES_DROPPED,
782 : : ROC_NIX_TM_NODE_GREEN_PKTS,
783 : : ROC_NIX_TM_NODE_GREEN_BYTES,
784 : : ROC_NIX_TM_NODE_YELLOW_PKTS,
785 : : ROC_NIX_TM_NODE_YELLOW_BYTES,
786 : : ROC_NIX_TM_NODE_RED_PKTS,
787 : : ROC_NIX_TM_NODE_RED_BYTES,
788 : : ROC_NIX_TM_NODE_STATS_MAX,
789 : : };
790 : :
791 : : struct roc_nix_tm_node_stats {
792 : : uint64_t stats[ROC_NIX_TM_NODE_STATS_MAX];
793 : : };
794 : :
795 : : enum roc_nix_tm_mark {
796 : : ROC_NIX_TM_MARK_VLAN_DEI,
797 : : ROC_NIX_TM_MARK_IPV4_DSCP,
798 : : ROC_NIX_TM_MARK_IPV4_ECN,
799 : : ROC_NIX_TM_MARK_IPV6_DSCP,
800 : : ROC_NIX_TM_MARK_IPV6_ECN,
801 : : ROC_NIX_TM_MARK_MAX
802 : : };
803 : :
804 : : enum roc_nix_tm_mark_color {
805 : : ROC_NIX_TM_MARK_COLOR_Y,
806 : : ROC_NIX_TM_MARK_COLOR_R,
807 : : ROC_NIX_TM_MARK_COLOR_Y_R,
808 : : ROC_NIX_TM_MARK_COLOR_MAX
809 : : };
810 : :
811 : : int __roc_api roc_nix_tm_node_add(struct roc_nix *roc_nix,
812 : : struct roc_nix_tm_node *roc_node);
813 : : int __roc_api roc_nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
814 : : bool free);
815 : : int __roc_api roc_nix_tm_free_resources(struct roc_nix *roc_nix, bool hw_only);
816 : : int __roc_api roc_nix_tm_node_suspend_resume(struct roc_nix *roc_nix,
817 : : uint32_t node_id, bool suspend);
818 : : int __roc_api roc_nix_tm_node_parent_update(struct roc_nix *roc_nix,
819 : : uint32_t node_id,
820 : : uint32_t new_parent_id,
821 : : uint32_t priority, uint32_t weight);
822 : : int __roc_api roc_nix_tm_node_shaper_update(struct roc_nix *roc_nix,
823 : : uint32_t node_id,
824 : : uint32_t profile_id,
825 : : bool force_update);
826 : : int __roc_api roc_nix_tm_node_pkt_mode_update(struct roc_nix *roc_nix,
827 : : uint32_t node_id, bool pkt_mode);
828 : : int __roc_api roc_nix_tm_shaper_profile_add(
829 : : struct roc_nix *roc_nix, struct roc_nix_tm_shaper_profile *profile);
830 : : int __roc_api roc_nix_tm_shaper_profile_update(
831 : : struct roc_nix *roc_nix, struct roc_nix_tm_shaper_profile *profile);
832 : : int __roc_api roc_nix_tm_shaper_profile_delete(struct roc_nix *roc_nix,
833 : : uint32_t id);
834 : :
835 : : int __roc_api roc_nix_tm_prealloc_res(struct roc_nix *roc_nix, uint8_t lvl,
836 : : uint16_t discontig, uint16_t contig);
837 : : uint16_t __roc_api roc_nix_tm_leaf_cnt(struct roc_nix *roc_nix);
838 : :
839 : : struct roc_nix_tm_node *__roc_api roc_nix_tm_node_get(struct roc_nix *roc_nix,
840 : : uint32_t node_id);
841 : : struct roc_nix_tm_node *__roc_api
842 : : roc_nix_tm_node_next(struct roc_nix *roc_nix, struct roc_nix_tm_node *__prev);
843 : : struct roc_nix_tm_shaper_profile *__roc_api
844 : : roc_nix_tm_shaper_profile_get(struct roc_nix *roc_nix, uint32_t profile_id);
845 : : struct roc_nix_tm_shaper_profile *__roc_api roc_nix_tm_shaper_profile_next(
846 : : struct roc_nix *roc_nix, struct roc_nix_tm_shaper_profile *__prev);
847 : :
848 : : int __roc_api roc_nix_tm_node_stats_get(struct roc_nix *roc_nix,
849 : : uint32_t node_id, bool clear,
850 : : struct roc_nix_tm_node_stats *stats);
851 : : /*
852 : : * TM ratelimit tree API.
853 : : */
854 : : int __roc_api roc_nix_tm_rlimit_sq(struct roc_nix *roc_nix, uint16_t qid, uint64_t rate);
855 : :
856 : : /*
857 : : * TM PFC tree ratelimit API.
858 : : */
859 : : int __roc_api roc_nix_tm_pfc_rlimit_sq(struct roc_nix *roc_nix, uint16_t qid, uint64_t rate);
860 : :
861 : : /*
862 : : * TM hierarchy enable/disable API.
863 : : */
864 : : int __roc_api roc_nix_tm_hierarchy_disable(struct roc_nix *roc_nix);
865 : : int __roc_api roc_nix_tm_hierarchy_enable(struct roc_nix *roc_nix,
866 : : enum roc_nix_tm_tree tree,
867 : : bool xmit_enable);
868 : : int __roc_api roc_nix_tm_hierarchy_xmit_enable(struct roc_nix *roc_nix, enum roc_nix_tm_tree tree);
869 : :
870 : :
871 : : /*
872 : : * TM utilities API.
873 : : */
874 : : int __roc_api roc_nix_tm_node_lvl(struct roc_nix *roc_nix, uint32_t node_id);
875 : : bool __roc_api roc_nix_tm_root_has_sp(struct roc_nix *roc_nix);
876 : : void __roc_api roc_nix_tm_rsrc_max(bool pf, uint16_t schq[ROC_TM_LVL_MAX]);
877 : : int __roc_api roc_nix_tm_rsrc_count(struct roc_nix *roc_nix,
878 : : uint16_t schq[ROC_TM_LVL_MAX]);
879 : : int __roc_api roc_nix_tm_node_name_get(struct roc_nix *roc_nix,
880 : : uint32_t node_id, char *buf,
881 : : size_t buflen);
882 : : int __roc_api roc_nix_smq_flush(struct roc_nix *roc_nix);
883 : : int __roc_api roc_nix_tm_max_prio(struct roc_nix *roc_nix, int lvl);
884 : : int __roc_api roc_nix_tm_lvl_is_leaf(struct roc_nix *roc_nix, int lvl);
885 : : void __roc_api
886 : : roc_nix_tm_shaper_default_red_algo(struct roc_nix_tm_node *node,
887 : : struct roc_nix_tm_shaper_profile *profile);
888 : : int __roc_api roc_nix_tm_lvl_cnt_get(struct roc_nix *roc_nix);
889 : : int __roc_api roc_nix_tm_lvl_have_link_access(struct roc_nix *roc_nix, int lvl);
890 : : int __roc_api roc_nix_tm_prepare_rate_limited_tree(struct roc_nix *roc_nix);
891 : : int __roc_api roc_nix_tm_pfc_prepare_tree(struct roc_nix *roc_nix);
892 : : int __roc_api roc_nix_tm_sdp_prepare_tree(struct roc_nix *roc_nix);
893 : : bool __roc_api roc_nix_tm_is_user_hierarchy_enabled(struct roc_nix *nix);
894 : : int __roc_api roc_nix_tm_tree_type_get(struct roc_nix *nix);
895 : : int __roc_api roc_nix_tm_mark_config(struct roc_nix *roc_nix,
896 : : enum roc_nix_tm_mark type, int mark_yellow,
897 : : int mark_red);
898 : : uint64_t __roc_api roc_nix_tm_mark_format_get(struct roc_nix *roc_nix,
899 : : uint64_t *flags);
900 : : int __roc_api roc_nix_tm_egress_link_cfg_set(struct roc_nix *roc_nix, uint64_t dst_pf_func,
901 : : bool enable);
902 : :
903 : : /* Ingress Policer API */
904 : : int __roc_api roc_nix_bpf_timeunit_get(struct roc_nix *roc_nix,
905 : : uint32_t *time_unit);
906 : :
907 : : int __roc_api
908 : : roc_nix_bpf_count_get(struct roc_nix *roc_nix, uint8_t lvl_mask,
909 : : uint16_t count[ROC_NIX_BPF_LEVEL_MAX] /* Out */);
910 : :
911 : : int __roc_api roc_nix_bpf_alloc(struct roc_nix *roc_nix, uint8_t lvl_mask,
912 : : uint16_t per_lvl_cnt[ROC_NIX_BPF_LEVEL_MAX],
913 : : struct roc_nix_bpf_objs *profs /* Out */);
914 : :
915 : : int __roc_api roc_nix_bpf_free(struct roc_nix *roc_nix,
916 : : struct roc_nix_bpf_objs *profs,
917 : : uint8_t num_prof);
918 : :
919 : : int __roc_api roc_nix_bpf_free_all(struct roc_nix *roc_nix);
920 : :
921 : : int __roc_api roc_nix_bpf_config(struct roc_nix *roc_nix, uint16_t id,
922 : : enum roc_nix_bpf_level_flag lvl_flag,
923 : : struct roc_nix_bpf_cfg *cfg);
924 : :
925 : : int __roc_api roc_nix_bpf_ena_dis(struct roc_nix *roc_nix, uint16_t id,
926 : : struct roc_nix_rq *rq, bool enable);
927 : :
928 : : int __roc_api roc_nix_bpf_dump(struct roc_nix *roc_nix, uint16_t id,
929 : : enum roc_nix_bpf_level_flag lvl_flag);
930 : :
931 : : int __roc_api roc_nix_bpf_pre_color_tbl_setup(
932 : : struct roc_nix *roc_nix, uint16_t id,
933 : : enum roc_nix_bpf_level_flag lvl_flag, struct roc_nix_bpf_precolor *tbl);
934 : :
935 : : /* Use ROC_NIX_BPF_ID_INVALID as dst_id to disconnect */
936 : : int __roc_api roc_nix_bpf_connect(struct roc_nix *roc_nix,
937 : : enum roc_nix_bpf_level_flag lvl_flag,
938 : : uint16_t src_id, uint16_t dst_id);
939 : :
940 : : int __roc_api
941 : : roc_nix_bpf_stats_read(struct roc_nix *roc_nix, uint16_t id, uint64_t mask,
942 : : enum roc_nix_bpf_level_flag lvl_flag,
943 : : uint64_t stats[ROC_NIX_BPF_STATS_MAX] /* Out */);
944 : :
945 : : int __roc_api roc_nix_bpf_stats_reset(struct roc_nix *roc_nix, uint16_t id,
946 : : uint64_t mask,
947 : : enum roc_nix_bpf_level_flag lvl_flag);
948 : :
949 : : int __roc_api
950 : : roc_nix_bpf_lf_stats_read(struct roc_nix *roc_nix, uint64_t mask,
951 : : uint64_t stats[ROC_NIX_BPF_STATS_MAX] /* Out */);
952 : :
953 : : int __roc_api roc_nix_bpf_lf_stats_reset(struct roc_nix *roc_nix,
954 : : uint64_t mask);
955 : :
956 : : uint8_t __roc_api
957 : : roc_nix_bpf_level_to_idx(enum roc_nix_bpf_level_flag lvl_flag);
958 : :
959 : : uint8_t __roc_api roc_nix_bpf_stats_to_idx(enum roc_nix_bpf_stats lvl_flag);
960 : :
961 : : /* MAC */
962 : : int __roc_api roc_nix_mac_rxtx_start_stop(struct roc_nix *roc_nix, bool start);
963 : : int __roc_api roc_nix_mac_link_event_start_stop(struct roc_nix *roc_nix,
964 : : bool start);
965 : : int __roc_api roc_nix_mac_loopback_enable(struct roc_nix *roc_nix, bool enable);
966 : : int __roc_api roc_nix_mac_addr_set(struct roc_nix *roc_nix,
967 : : const uint8_t addr[]);
968 : : int __roc_api roc_nix_mac_max_entries_get(struct roc_nix *roc_nix);
969 : : int __roc_api roc_nix_mac_addr_add(struct roc_nix *roc_nix, uint8_t addr[]);
970 : : int __roc_api roc_nix_mac_addr_del(struct roc_nix *roc_nix, uint32_t index);
971 : : int __roc_api roc_nix_mac_promisc_mode_enable(struct roc_nix *roc_nix,
972 : : int enable);
973 : : int __roc_api roc_nix_mac_link_state_set(struct roc_nix *roc_nix, uint8_t up);
974 : : int __roc_api roc_nix_mac_link_info_set(struct roc_nix *roc_nix,
975 : : struct roc_nix_link_info *link_info);
976 : : int __roc_api roc_nix_mac_link_info_get(struct roc_nix *roc_nix,
977 : : struct roc_nix_link_info *link_info);
978 : : int __roc_api roc_nix_mac_mtu_set(struct roc_nix *roc_nix, uint16_t mtu);
979 : : int __roc_api roc_nix_mac_max_rx_len_set(struct roc_nix *roc_nix,
980 : : uint16_t maxlen);
981 : : int __roc_api roc_nix_mac_link_cb_register(struct roc_nix *roc_nix,
982 : : link_status_t link_update);
983 : : void __roc_api roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix);
984 : : int __roc_api roc_nix_mac_link_info_get_cb_register(
985 : : struct roc_nix *roc_nix, link_info_get_t link_info_get);
986 : : void __roc_api roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix);
987 : : int __roc_api roc_nix_q_err_cb_register(struct roc_nix *roc_nix, q_err_get_t sq_err_handle);
988 : : void __roc_api roc_nix_q_err_cb_unregister(struct roc_nix *roc_nix);
989 : : int __roc_api roc_nix_mac_stats_reset(struct roc_nix *roc_nix);
990 : : int __roc_api roc_nix_mac_fwdata_get(struct roc_nix *roc_nix, struct roc_nix_mac_fwdata *fwdata);
991 : :
992 : : /* Ops */
993 : : int __roc_api roc_nix_switch_hdr_set(struct roc_nix *roc_nix,
994 : : uint64_t switch_header_type,
995 : : uint8_t pre_l2_size_offset,
996 : : uint8_t pre_l2_size_offset_mask,
997 : : uint8_t pre_l2_size_shift_dir);
998 : : int __roc_api roc_nix_lso_fmt_setup(struct roc_nix *roc_nix);
999 : : int __roc_api roc_nix_lso_fmt_get(struct roc_nix *roc_nix,
1000 : : uint8_t udp_tun[ROC_NIX_LSO_TUN_MAX],
1001 : : uint8_t tun[ROC_NIX_LSO_TUN_MAX]);
1002 : : int __roc_api roc_nix_lso_fmt_ipv4_frag_get(struct roc_nix *roc_nix);
1003 : : int __roc_api roc_nix_lso_custom_fmt_setup(struct roc_nix *roc_nix,
1004 : : struct nix_lso_format *fields,
1005 : : uint16_t nb_fields);
1006 : : int __roc_api roc_nix_lso_alt_flags_profile_setup(struct roc_nix *roc_nix,
1007 : : nix_lso_alt_flg_format_t *fmt);
1008 : :
1009 : : int __roc_api roc_nix_eeprom_info_get(struct roc_nix *roc_nix,
1010 : : struct roc_nix_eeprom_info *info);
1011 : :
1012 : : /* Flow control */
1013 : : int __roc_api roc_nix_fc_config_set(struct roc_nix *roc_nix,
1014 : : struct roc_nix_fc_cfg *fc_cfg);
1015 : :
1016 : : int __roc_api roc_nix_fc_config_get(struct roc_nix *roc_nix,
1017 : : struct roc_nix_fc_cfg *fc_cfg);
1018 : :
1019 : : int __roc_api roc_nix_fc_mode_set(struct roc_nix *roc_nix,
1020 : : enum roc_nix_fc_mode mode);
1021 : :
1022 : : int __roc_api roc_nix_pfc_mode_set(struct roc_nix *roc_nix,
1023 : : struct roc_nix_pfc_cfg *pfc_cfg);
1024 : :
1025 : : int __roc_api roc_nix_pfc_mode_get(struct roc_nix *roc_nix,
1026 : : struct roc_nix_pfc_cfg *pfc_cfg);
1027 : :
1028 : : uint16_t __roc_api roc_nix_chan_count_get(struct roc_nix *roc_nix);
1029 : :
1030 : : enum roc_nix_fc_mode __roc_api roc_nix_fc_mode_get(struct roc_nix *roc_nix);
1031 : :
1032 : : void __roc_api roc_nix_fc_npa_bp_cfg(struct roc_nix *roc_nix, uint64_t pool_id, uint8_t ena,
1033 : : uint8_t force, uint8_t tc, uint64_t drop_percent);
1034 : : int __roc_api roc_nix_bpids_alloc(struct roc_nix *roc_nix, uint8_t type,
1035 : : uint8_t bp_cnt, uint16_t *bpids);
1036 : : int __roc_api roc_nix_bpids_free(struct roc_nix *roc_nix, uint8_t bp_cnt,
1037 : : uint16_t *bpids);
1038 : : int __roc_api roc_nix_rx_chan_cfg_get(struct roc_nix *roc_nix, uint16_t chan,
1039 : : bool is_cpt, uint64_t *cfg);
1040 : : int __roc_api roc_nix_rx_chan_cfg_set(struct roc_nix *roc_nix, uint16_t chan,
1041 : : bool is_cpt, uint64_t val);
1042 : : int __roc_api roc_nix_chan_bpid_set(struct roc_nix *roc_nix, uint16_t chan,
1043 : : uint64_t bpid, int ena, bool cpt_chan);
1044 : :
1045 : : /* NPC */
1046 : : int __roc_api roc_nix_npc_promisc_ena_dis(struct roc_nix *roc_nix, int enable);
1047 : :
1048 : : int __roc_api roc_nix_npc_mac_addr_set(struct roc_nix *roc_nix, uint8_t addr[]);
1049 : :
1050 : : int __roc_api roc_nix_npc_mac_addr_get(struct roc_nix *roc_nix, uint8_t *addr);
1051 : :
1052 : : int __roc_api roc_nix_npc_rx_ena_dis(struct roc_nix *roc_nix, bool enable);
1053 : :
1054 : : int __roc_api roc_nix_npc_mcast_config(struct roc_nix *roc_nix,
1055 : : bool mcast_enable, bool prom_enable);
1056 : :
1057 : : /* RSS */
1058 : : void __roc_api roc_nix_rss_key_default_fill(struct roc_nix *roc_nix,
1059 : : uint8_t key[ROC_NIX_RSS_KEY_LEN]);
1060 : : void __roc_api roc_nix_rss_key_set(struct roc_nix *roc_nix,
1061 : : const uint8_t key[ROC_NIX_RSS_KEY_LEN]);
1062 : : void __roc_api roc_nix_rss_key_get(struct roc_nix *roc_nix,
1063 : : uint8_t key[ROC_NIX_RSS_KEY_LEN]);
1064 : : int __roc_api roc_nix_rss_reta_set(struct roc_nix *roc_nix, uint8_t group,
1065 : : uint16_t reta[ROC_NIX_RSS_RETA_MAX]);
1066 : : int __roc_api roc_nix_rss_reta_get(struct roc_nix *roc_nix, uint8_t group,
1067 : : uint16_t reta[ROC_NIX_RSS_RETA_MAX]);
1068 : : int __roc_api roc_nix_rss_flowkey_set(struct roc_nix *roc_nix, uint8_t *alg_idx,
1069 : : uint32_t flowkey, uint8_t group,
1070 : : int mcam_index);
1071 : : int __roc_api roc_nix_rss_default_setup(struct roc_nix *roc_nix,
1072 : : uint32_t flowkey);
1073 : :
1074 : : /* Stats */
1075 : : int __roc_api roc_nix_stats_get(struct roc_nix *roc_nix,
1076 : : struct roc_nix_stats *stats);
1077 : : int __roc_api roc_nix_stats_reset(struct roc_nix *roc_nix);
1078 : : int __roc_api roc_nix_stats_queue_get(struct roc_nix *roc_nix, uint16_t qid,
1079 : : bool is_rx,
1080 : : struct roc_nix_stats_queue *qstats);
1081 : : int __roc_api roc_nix_stats_queue_reset(struct roc_nix *roc_nix, uint16_t qid,
1082 : : bool is_rx);
1083 : : int __roc_api roc_nix_num_xstats_get(struct roc_nix *roc_nix);
1084 : : int __roc_api roc_nix_xstats_get(struct roc_nix *roc_nix,
1085 : : struct roc_nix_xstat *xstats, unsigned int n);
1086 : : int __roc_api roc_nix_xstats_names_get(struct roc_nix *roc_nix,
1087 : : struct roc_nix_xstat_name *xstats_names,
1088 : : unsigned int limit);
1089 : :
1090 : : /* Queue */
1091 : : int __roc_api roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq,
1092 : : bool ena);
1093 : : int __roc_api roc_nix_rq_modify(struct roc_nix *roc_nix, struct roc_nix_rq *rq,
1094 : : bool ena);
1095 : : int __roc_api roc_nix_rq_cman_config(struct roc_nix *roc_nix, struct roc_nix_rq *rq);
1096 : : int __roc_api roc_nix_rq_ena_dis(struct roc_nix_rq *rq, bool enable);
1097 : : int __roc_api roc_nix_rq_is_sso_enable(struct roc_nix *roc_nix, uint32_t qid);
1098 : : int __roc_api roc_nix_rq_fini(struct roc_nix_rq *rq);
1099 : : int __roc_api roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq);
1100 : : int __roc_api roc_nix_cq_fini(struct roc_nix_cq *cq);
1101 : : void __roc_api roc_nix_cq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid,
1102 : : uint32_t *head, uint32_t *tail);
1103 : : int __roc_api roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq);
1104 : : int __roc_api roc_nix_sq_fini(struct roc_nix_sq *sq);
1105 : : int __roc_api roc_nix_sq_ena_dis(struct roc_nix_sq *sq, bool enable);
1106 : : void __roc_api roc_nix_sq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid,
1107 : : uint32_t *head, uint32_t *tail);
1108 : : int __roc_api roc_nix_sq_cnt_update(struct roc_nix_sq *sq, bool enable);
1109 : : int __roc_api roc_nix_sq_resize(struct roc_nix_sq *sq, uint32_t nb_desc);
1110 : :
1111 : : /* PTP */
1112 : : int __roc_api roc_nix_ptp_rx_ena_dis(struct roc_nix *roc_nix, int enable);
1113 : : int __roc_api roc_nix_ptp_tx_ena_dis(struct roc_nix *roc_nix, int enable);
1114 : : int __roc_api roc_nix_ptp_clock_read(struct roc_nix *roc_nix, uint64_t *clock,
1115 : : uint64_t *tsc, uint8_t is_pmu);
1116 : : int __roc_api roc_nix_ptp_sync_time_adjust(struct roc_nix *roc_nix,
1117 : : int64_t delta);
1118 : : int __roc_api roc_nix_ptp_info_cb_register(struct roc_nix *roc_nix,
1119 : : ptp_info_update_t ptp_update);
1120 : : void __roc_api roc_nix_ptp_info_cb_unregister(struct roc_nix *roc_nix);
1121 : : bool __roc_api roc_nix_ptp_is_enable(struct roc_nix *roc_nix);
1122 : :
1123 : : /* VLAN */
1124 : : int __roc_api
1125 : : roc_nix_vlan_mcam_entry_read(struct roc_nix *roc_nix, uint32_t index,
1126 : : void **rsp);
1127 : : int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix, uint32_t index, void *entry,
1128 : : uint8_t intf, uint8_t enable);
1129 : : int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix, void *entry,
1130 : : uint8_t intf, uint8_t priority,
1131 : : uint8_t ref_entry);
1132 : : int __roc_api roc_nix_vlan_mcam_entry_free(struct roc_nix *roc_nix,
1133 : : uint32_t index);
1134 : : int __roc_api roc_nix_vlan_mcam_entry_ena_dis(struct roc_nix *roc_nix,
1135 : : uint32_t index, const int enable);
1136 : : int __roc_api roc_nix_vlan_strip_vtag_ena_dis(struct roc_nix *roc_nix,
1137 : : bool enable);
1138 : : int __roc_api roc_nix_vlan_insert_ena_dis(struct roc_nix *roc_nix,
1139 : : struct roc_nix_vlan_config *vlan_cfg,
1140 : : uint64_t *mcam_index, bool enable);
1141 : : int __roc_api roc_nix_vlan_tpid_set(struct roc_nix *roc_nix, uint32_t type,
1142 : : uint16_t tpid);
1143 : :
1144 : : /* MCAST*/
1145 : : int __roc_api roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix,
1146 : : uint16_t nb_entries,
1147 : : uint8_t priority,
1148 : : uint16_t index[]);
1149 : : int __roc_api roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix,
1150 : : uint32_t index);
1151 : : int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index,
1152 : : uint8_t intf, uint64_t action);
1153 : : int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, uint32_t index,
1154 : : bool enable);
1155 : : int __roc_api roc_nix_mcast_list_setup(struct mbox *mbox, uint8_t intf, int nb_entries,
1156 : : uint16_t *pf_funcs, uint16_t *channels, uint32_t *rqs,
1157 : : uint32_t *grp_index, uint32_t *start_index);
1158 : : int __roc_api roc_nix_mcast_list_free(struct mbox *mbox, uint32_t mcast_grp_index);
1159 : : int __roc_api roc_nix_max_rep_count(struct roc_nix *roc_nix);
1160 : : #endif /* _ROC_NIX_H_ */
|