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