Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : :
5 : : #ifndef _CNXK_BPHY_H_
6 : : #define _CNXK_BPHY_H_
7 : :
8 : : #include <stdint.h>
9 : :
10 : : #include <rte_common.h>
11 : : #include <rte_dev.h>
12 : : #include <rte_malloc.h>
13 : : #include <rte_memcpy.h>
14 : : #include <rte_rawdev.h>
15 : :
16 : : /**
17 : : * @file rte_pmd_bphy.h
18 : : *
19 : : * Marvell CGX and BPHY PMD specific structures and interface
20 : : *
21 : : * This API allows applications to manage BPHY memory in user space along with
22 : : * installing interrupt handlers for low latency signal processing.
23 : : */
24 : :
25 : : #ifdef __cplusplus
26 : : extern "C" {
27 : : #endif
28 : :
29 : : /** Available message types */
30 : : enum cnxk_bphy_cgx_msg_type {
31 : : /** Type used to obtain link information */
32 : : CNXK_BPHY_CGX_MSG_TYPE_GET_LINKINFO,
33 : : /** Type used to disable internal loopback */
34 : : CNXK_BPHY_CGX_MSG_TYPE_INTLBK_DISABLE,
35 : : /** Type used to enable loopback */
36 : : CNXK_BPHY_CGX_MSG_TYPE_INTLBK_ENABLE,
37 : : /** Type used to disable PTP on RX */
38 : : CNXK_BPHY_CGX_MSG_TYPE_PTP_RX_DISABLE,
39 : : /** Type used to enable PTP on RX */
40 : : CNXK_BPHY_CGX_MSG_TYPE_PTP_RX_ENABLE,
41 : : /** Type used to set link mode */
42 : : CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_MODE,
43 : : /** Type used to set link state */
44 : : CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_STATE,
45 : : /** Type used to start transmission and packet reception */
46 : : CNXK_BPHY_CGX_MSG_TYPE_START_RXTX,
47 : : /** Type used to stop transmission and packet reception */
48 : : CNXK_BPHY_CGX_MSG_TYPE_STOP_RXTX,
49 : : /** Type used to obtain supported FEC */
50 : : CNXK_BPHY_CGX_MSG_TYPE_GET_SUPPORTED_FEC,
51 : : /** Type used to set FEC */
52 : : CNXK_BPHY_CGX_MSG_TYPE_SET_FEC,
53 : : /** Type used to switch from eCPRI to CPRI */
54 : : CNXK_BPHY_CGX_MSG_TYPE_CPRI_MODE_CHANGE,
55 : : /** Type used to enable TX for CPRI SERDES */
56 : : CNXK_BPHY_CGX_MSG_TYPE_CPRI_TX_CONTROL,
57 : : /** Type use to change misc CPRI SERDES settings */
58 : : CNXK_BPHY_CGX_MSG_TYPE_CPRI_MODE_MISC,
59 : : };
60 : :
61 : : /** Available link speeds */
62 : : enum cnxk_bphy_cgx_eth_link_speed {
63 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_NONE, /**< None */
64 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_10M, /**< 10 Mbps */
65 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_100M, /**< 100 Mbps */
66 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_1G, /**< 1 Gbps */
67 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_2HG, /**< 2.5 Gbps */
68 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_5G, /**< 5 Gbps */
69 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_10G, /**< 10 Gbps */
70 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_20G, /**< 20 Gbps */
71 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_25G, /**< 25 Gbps */
72 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_40G, /**< 40 Gbps */
73 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_50G, /**< 50 Gbps */
74 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_80G, /**< 80 Gbps */
75 : : CNXK_BPHY_CGX_ETH_LINK_SPEED_100G, /**< 100 Gbps */
76 : : __CNXK_BPHY_CGX_ETH_LINK_SPEED_MAX
77 : : };
78 : :
79 : : /** Available FEC modes */
80 : : enum cnxk_bphy_cgx_eth_link_fec {
81 : : /** Disable FEC */
82 : : CNXK_BPHY_CGX_ETH_LINK_FEC_NONE,
83 : : /** Base FEC (IEEE 802.3 CLause 74) */
84 : : CNXK_BPHY_CGX_ETH_LINK_FEC_BASE_R,
85 : : /** Reed-Solomon FEC */
86 : : CNXK_BPHY_CGX_ETH_LINK_FEC_RS,
87 : : __CNXK_BPHY_CGX_ETH_LINK_FEC_MAX
88 : : };
89 : :
90 : : /** Available link modes */
91 : : enum cnxk_bphy_cgx_eth_link_mode {
92 : : /** SGMII */
93 : : CNXK_BPHY_CGX_ETH_LINK_MODE_SGMII_BIT,
94 : : /** 1000BASE-X */
95 : : CNXK_BPHY_CGX_ETH_LINK_MODE_1000_BASEX_BIT,
96 : : /** QSGMII */
97 : : CNXK_BPHY_CGX_ETH_LINK_MODE_QSGMII_BIT,
98 : : /** 10GBASE-C2C */
99 : : CNXK_BPHY_CGX_ETH_LINK_MODE_10G_C2C_BIT,
100 : : /** 10GBASE-C2M */
101 : : CNXK_BPHY_CGX_ETH_LINK_MODE_10G_C2M_BIT,
102 : : /** 10GBASE-KR */
103 : : CNXK_BPHY_CGX_ETH_LINK_MODE_10G_KR_BIT,
104 : : /** 20GBASE-C2C */
105 : : CNXK_BPHY_CGX_ETH_LINK_MODE_20G_C2C_BIT,
106 : : /** 25GBASE-C2C */
107 : : CNXK_BPHY_CGX_ETH_LINK_MODE_25G_C2C_BIT,
108 : : /** 25GBASE-C2M */
109 : : CNXK_BPHY_CGX_ETH_LINK_MODE_25G_C2M_BIT,
110 : : /** 25GBASE-2-C2M */
111 : : CNXK_BPHY_CGX_ETH_LINK_MODE_25G_2_C2C_BIT,
112 : : /** 25GBASE-CR */
113 : : CNXK_BPHY_CGX_ETH_LINK_MODE_25G_CR_BIT,
114 : : /** 25GBASE-KR */
115 : : CNXK_BPHY_CGX_ETH_LINK_MODE_25G_KR_BIT,
116 : : /** 40GBASE-C2C */
117 : : CNXK_BPHY_CGX_ETH_LINK_MODE_40G_C2C_BIT,
118 : : /** 40GBASE-C2M */
119 : : CNXK_BPHY_CGX_ETH_LINK_MODE_40G_C2M_BIT,
120 : : /** 40GBASE-CR4 */
121 : : CNXK_BPHY_CGX_ETH_LINK_MODE_40G_CR4_BIT,
122 : : /** 40GBASE-KR4 */
123 : : CNXK_BPHY_CGX_ETH_LINK_MODE_40G_KR4_BIT,
124 : : /** 40GAUI-C2C */
125 : : CNXK_BPHY_CGX_ETH_LINK_MODE_40GAUI_C2C_BIT,
126 : : /** 50GBASE-C2C */
127 : : CNXK_BPHY_CGX_ETH_LINK_MODE_50G_C2C_BIT,
128 : : /** 50GBASE-C2M */
129 : : CNXK_BPHY_CGX_ETH_LINK_MODE_50G_C2M_BIT,
130 : : /** 50GBASE-4-C2C */
131 : : CNXK_BPHY_CGX_ETH_LINK_MODE_50G_4_C2C_BIT,
132 : : /** 50GBASE-CR */
133 : : CNXK_BPHY_CGX_ETH_LINK_MODE_50G_CR_BIT,
134 : : /** 50GBASE-KR */
135 : : CNXK_BPHY_CGX_ETH_LINK_MODE_50G_KR_BIT,
136 : : /** 80GAUI-C2C */
137 : : CNXK_BPHY_CGX_ETH_LINK_MODE_80GAUI_C2C_BIT,
138 : : /** 100GBASE-C2C */
139 : : CNXK_BPHY_CGX_ETH_LINK_MODE_100G_C2C_BIT,
140 : : /** 100GBASE-C2M */
141 : : CNXK_BPHY_CGX_ETH_LINK_MODE_100G_C2M_BIT,
142 : : /** 100GBASE-CR4 */
143 : : CNXK_BPHY_CGX_ETH_LINK_MODE_100G_CR4_BIT,
144 : : /** 100GBASE-KR4 */
145 : : CNXK_BPHY_CGX_ETH_LINK_MODE_100G_KR4_BIT,
146 : : /** 50GAUI-2-C2C */
147 : : CNXK_BPHY_CGX_ETH_LINK_MODE_50GAUI_2_C2C_BIT,
148 : : /** 50GAUI-2-C2M */
149 : : CNXK_BPHY_CGX_ETH_LINK_MODE_50GAUI_2_C2M_BIT,
150 : : /** 50GBASE-CR2-C */
151 : : CNXK_BPHY_CGX_ETH_LINK_MODE_50GBASE_CR2_C_BIT,
152 : : /** 50GBASE-KR2-C */
153 : : CNXK_BPHY_CGX_ETH_LINK_MODE_50GBASE_KR2_C_BIT,
154 : : /** 100GAUI-2-C2C */
155 : : CNXK_BPHY_CGX_ETH_LINK_MODE_100GAUI_2_C2C_BIT,
156 : : /** 100GAUI-2-C2M */
157 : : CNXK_BPHY_CGX_ETH_LINK_MODE_100GAUI_2_C2M_BIT,
158 : : /** 100GBASE-CR2 */
159 : : CNXK_BPHY_CGX_ETH_LINK_MODE_100GBASE_CR2_BIT,
160 : : /** 100GBASE-KR2 */
161 : : CNXK_BPHY_CGX_ETH_LINK_MODE_100GBASE_KR2_BIT,
162 : : /** SFI-1G */
163 : : CNXK_BPHY_CGX_ETH_LINK_MODE_SFI_1G_BIT,
164 : : /** 25GBASE-CR-C */
165 : : CNXK_BPHY_CGX_ETH_LINK_MODE_25GBASE_CR_C_BIT,
166 : : /** 25GBASE-KR-C */
167 : : CNXK_BPHY_CGX_ETH_LINK_MODE_25GBASE_KR_C_BIT,
168 : : __CNXK_BPHY_CGX_ETH_LINK_MODE_MAX
169 : : };
170 : :
171 : : enum cnxk_bphy_cgx_eth_mode_cpri {
172 : : /** 2.4G Lane Rate */
173 : : CNXK_BPHY_CGX_ETH_MODE_CPRI_2_4G_BIT,
174 : : /** 3.1G Lane Rate */
175 : : CNXK_BPHY_CGX_ETH_MODE_CPRI_3_1G_BIT,
176 : : /** 4.9G Lane Rate */
177 : : CNXK_BPHY_CGX_ETH_MODE_CPRI_4_9G_BIT,
178 : : /** 6.1G Lane Rate */
179 : : CNXK_BPHY_CGX_ETH_MODE_CPRI_6_1G_BIT,
180 : : /** 9.8G Lane Rate */
181 : : CNXK_BPHY_CGX_ETH_MODE_CPRI_9_8G_BIT,
182 : : /** 10.1G Lane Rate */
183 : : CNXK_BPHY_CGX_ETH_MODE_CPRI_10_1_BIT,
184 : : /** 24.3G Lane Rate */
185 : : CNXK_BPHY_CGX_ETH_MODE_CPRI_24_3G_BIT,
186 : : };
187 : :
188 : : enum cnxk_bphy_cgx_mode_group {
189 : : /** ETH group */
190 : : CNXK_BPHY_CGX_MODE_GROUP_ETH,
191 : : /** CPRI group */
192 : : CNXK_BPHY_CGX_MODE_GROUP_CPRI = 2,
193 : : };
194 : :
195 : : struct cnxk_bphy_cgx_msg_link_mode {
196 : : /** Setting for full-duplex */
197 : : bool full_duplex;
198 : : /** Setting for automatic link negotiation */
199 : : bool autoneg;
200 : : /** Set to true to use port index */
201 : : bool use_portm_idx;
202 : : /** Port index */
203 : : unsigned int portm_idx;
204 : : /** Mode group */
205 : : enum cnxk_bphy_cgx_mode_group mode_group_idx;
206 : : /** Link speed */
207 : : enum cnxk_bphy_cgx_eth_link_speed speed;
208 : : union {
209 : : /** Link mode */
210 : : enum cnxk_bphy_cgx_eth_link_mode mode;
211 : : /** CPRI mode */
212 : : enum cnxk_bphy_cgx_eth_mode_cpri mode_cpri;
213 : : };
214 : : };
215 : :
216 : : struct cnxk_bphy_cgx_msg_link_info {
217 : : /** Link state information */
218 : : bool link_up;
219 : : /** Link full duplex state */
220 : : bool full_duplex;
221 : : /** Link speed */
222 : : enum cnxk_bphy_cgx_eth_link_speed speed;
223 : : /** Link auto-negotiation setting */
224 : : bool autoneg;
225 : : /** FEC mode */
226 : : enum cnxk_bphy_cgx_eth_link_fec fec;
227 : : /** Link configuration */
228 : : enum cnxk_bphy_cgx_eth_link_mode mode;
229 : : };
230 : :
231 : : struct cnxk_bphy_cgx_msg_set_link_state {
232 : : /** Defines link state result */
233 : : bool state; /* up or down */
234 : : };
235 : :
236 : : struct cnxk_bphy_cgx_msg_cpri_mode_change {
237 : : /** SERDES index (0 - 4) */
238 : : int gserc_idx;
239 : : /** Lane index (0 - 1) */
240 : : int lane_idx;
241 : : /** Baud rate (9830/4915/2458/6144/3072) */
242 : : int rate;
243 : : /** Disable LEQ */
244 : : bool disable_leq;
245 : : /** Disable DFE */
246 : : bool disable_dfe;
247 : : };
248 : :
249 : : struct cnxk_bphy_cgx_msg_cpri_mode_tx_ctrl {
250 : : /** SERDES index (0 - 4) */
251 : : int gserc_idx;
252 : : /** Lane index (0 - 1) */
253 : : int lane_idx;
254 : : /** Disable or enable SERDES */
255 : : bool enable;
256 : : };
257 : :
258 : : struct cnxk_bphy_cgx_msg_cpri_mode_misc {
259 : : /** SERDES index (0 - 4) */
260 : : int gserc_idx;
261 : : /** Lane index (0 - 1) */
262 : : int lane_idx;
263 : : /** Misc flags (0 - RX Eq, 1 - RX state machine reset) */
264 : : int flags;
265 : : };
266 : :
267 : : struct cnxk_bphy_cgx_msg {
268 : : /** Message type */
269 : : enum cnxk_bphy_cgx_msg_type type;
270 : : /**
271 : : * Data depends on message type and whether
272 : : * it's a request or a response
273 : : */
274 : : void *data;
275 : : };
276 : :
277 : : #define CNXK_BPHY_DEF_QUEUE 0
278 : :
279 : : /**
280 : : * BPHY interrupt handler
281 : : *
282 : : * @param irq_num
283 : : * Zero-based interrupt number
284 : : * @param isr_data
285 : : * Cookie passed to interrupt handler
286 : : */
287 : : typedef void (*cnxk_bphy_intr_handler_t)(int irq_num, void *isr_data);
288 : :
289 : : struct cnxk_bphy_mem {
290 : : /** Memory for BAR0 */
291 : : struct rte_mem_resource res0;
292 : : /** Memory for BAR2 */
293 : : struct rte_mem_resource res2;
294 : : };
295 : :
296 : : /** Available IRQ configuration commands */
297 : : enum cnxk_bphy_irq_msg_type {
298 : : /** Type used to initialize interrupts */
299 : : CNXK_BPHY_IRQ_MSG_TYPE_INIT,
300 : : /** Type used to deinitialize interrupts */
301 : : CNXK_BPHY_IRQ_MSG_TYPE_FINI,
302 : : /** Type used to register interrupt */
303 : : CNXK_BPHY_IRQ_MSG_TYPE_REGISTER,
304 : : /** Type used to unregister interrupt */
305 : : CNXK_BPHY_IRQ_MSG_TYPE_UNREGISTER,
306 : : /** Type used to retrieve BPHY memory */
307 : : CNXK_BPHY_IRQ_MSG_TYPE_MEM_GET,
308 : : /** Type used to retrieve NPA PF function */
309 : : CNXK_BPHY_MSG_TYPE_NPA_PF_FUNC,
310 : : /** Type used to retrieve NPA SSO function */
311 : : CNXK_BPHY_MSG_TYPE_SSO_PF_FUNC,
312 : : };
313 : :
314 : : struct cnxk_bphy_irq_msg {
315 : : /** Message command type */
316 : : enum cnxk_bphy_irq_msg_type type;
317 : : /**
318 : : * Data depends on message type and whether
319 : : * it is a request or a response
320 : : */
321 : : void *data;
322 : : };
323 : :
324 : : struct cnxk_bphy_irq_info {
325 : : /** Interrupt number */
326 : : int irq_num;
327 : : /** Interrupt handler */
328 : : cnxk_bphy_intr_handler_t handler;
329 : : /** Interrupt handler cookie */
330 : : void *data;
331 : : /** CPU zero-based number for interrupt execution */
332 : : int cpu;
333 : : };
334 : :
335 : : /** @internal helper routine for enqueuing/dequeuing messages */
336 : : static __rte_always_inline int
337 : : __rte_pmd_bphy_enq_deq(uint16_t dev_id, unsigned int queue, void *req,
338 : : void *rsp, size_t rsp_size)
339 : : {
340 : : struct rte_rawdev_buf *bufs[1];
341 : : struct rte_rawdev_buf buf;
342 : : void *q;
343 : : int ret;
344 : :
345 : 0 : q = (void *)(size_t)queue;
346 : 0 : buf.buf_addr = req;
347 : 0 : bufs[0] = &buf;
348 : :
349 : 0 : ret = rte_rawdev_enqueue_buffers(dev_id, bufs, RTE_DIM(bufs), q);
350 [ # # # # : 0 : if (ret < 0)
# # # # #
# # # # #
# # # # #
# # # #
# ]
351 : : return ret;
352 [ # # # # : 0 : if (ret != RTE_DIM(bufs))
# # # # #
# # # # #
# # # # #
# # # #
# ]
353 : : return -EIO;
354 : :
355 : : if (!rsp)
356 : : return 0;
357 : :
358 : 0 : ret = rte_rawdev_dequeue_buffers(dev_id, bufs, RTE_DIM(bufs), q);
359 [ # # # # ]: 0 : if (ret < 0)
360 : : return ret;
361 [ # # # # ]: 0 : if (ret != RTE_DIM(bufs))
362 : : return -EIO;
363 : :
364 [ # # # # ]: 0 : rte_memcpy(rsp, buf.buf_addr, rsp_size);
365 : 0 : rte_free(buf.buf_addr);
366 : :
367 : : return 0;
368 : : }
369 : :
370 : : /**
371 : : * Initialize BPHY subsystem
372 : : *
373 : : * @param dev_id
374 : : * The identifier of the device
375 : : *
376 : : * @return
377 : : * Returns 0 on success, negative error code otherwise
378 : : */
379 : : static __rte_always_inline int
380 : : rte_pmd_bphy_intr_init(uint16_t dev_id)
381 : : {
382 : 0 : struct cnxk_bphy_irq_msg msg = {
383 : : .type = CNXK_BPHY_IRQ_MSG_TYPE_INIT,
384 : : };
385 : :
386 : : return __rte_pmd_bphy_enq_deq(dev_id, CNXK_BPHY_DEF_QUEUE, &msg,
387 : : NULL, 0);
388 : : }
389 : :
390 : : /**
391 : : * Deinitialize BPHY subsystem
392 : : *
393 : : * @param dev_id
394 : : * The identifier of the device
395 : : *
396 : : * @return
397 : : * Returns 0 on success, negative error code otherwise
398 : : */
399 : : static __rte_always_inline int
400 : : rte_pmd_bphy_intr_fini(uint16_t dev_id)
401 : : {
402 : 0 : struct cnxk_bphy_irq_msg msg = {
403 : : .type = CNXK_BPHY_IRQ_MSG_TYPE_FINI,
404 : : };
405 : :
406 : 0 : return __rte_pmd_bphy_enq_deq(dev_id, CNXK_BPHY_DEF_QUEUE, &msg,
407 : : NULL, 0);
408 : : }
409 : :
410 : : /**
411 : : * Register BPHY interrupt handler
412 : : *
413 : : * @param dev_id
414 : : * The identifier of the device
415 : : * @param irq_num
416 : : * Zero-based interrupt number
417 : : * @param handler
418 : : * Interrupt handler to be executed
419 : : * @param data
420 : : * Data to be passed to interrupt handler
421 : : * @param cpu
422 : : * CPU number which will be handling interrupt
423 : : *
424 : : * @return
425 : : * Returns 0 on success, negative error code otherwise
426 : : */
427 : : static __rte_always_inline int
428 : : rte_pmd_bphy_intr_register(uint16_t dev_id, int irq_num,
429 : : cnxk_bphy_intr_handler_t handler, void *data,
430 : : int cpu)
431 : : {
432 : 0 : struct cnxk_bphy_irq_info info = {
433 : : .irq_num = irq_num,
434 : : .handler = handler,
435 : : .data = data,
436 : : .cpu = cpu,
437 : : };
438 : 0 : struct cnxk_bphy_irq_msg msg = {
439 : : .type = CNXK_BPHY_IRQ_MSG_TYPE_REGISTER,
440 : : .data = &info
441 : : };
442 : :
443 : : return __rte_pmd_bphy_enq_deq(dev_id, CNXK_BPHY_DEF_QUEUE, &msg,
444 : : NULL, 0);
445 : : }
446 : :
447 : : /**
448 : : * Unregister BPHY interrupt handler
449 : : *
450 : : * @param dev_id
451 : : * The identifier of the device
452 : : * @param irq_num
453 : : * Zero-based interrupt number used during registration
454 : : *
455 : : * @return
456 : : * Returns 0 on success, negative error code otherwise
457 : : */
458 : : static __rte_always_inline int
459 : : rte_pmd_bphy_intr_unregister(uint16_t dev_id, int irq_num)
460 : : {
461 : 0 : struct cnxk_bphy_irq_info info = {
462 : : .irq_num = irq_num,
463 : : };
464 : 0 : struct cnxk_bphy_irq_msg msg = {
465 : : .type = CNXK_BPHY_IRQ_MSG_TYPE_UNREGISTER,
466 : : .data = &info
467 : : };
468 : :
469 : : return __rte_pmd_bphy_enq_deq(dev_id, CNXK_BPHY_DEF_QUEUE, &msg,
470 : : NULL, 0);
471 : : }
472 : :
473 : : /**
474 : : * Obtain BPHY memory
475 : : *
476 : : * @param dev_id
477 : : * The identifier of the device
478 : : * @param mem
479 : : * Memory structure which will be filled for memory access
480 : : *
481 : : * @return
482 : : * Returns 0 on success, negative error code otherwise
483 : : */
484 : : static __rte_always_inline int
485 : : rte_pmd_bphy_intr_mem_get(uint16_t dev_id, struct cnxk_bphy_mem *mem)
486 : : {
487 : : struct cnxk_bphy_irq_msg msg = {
488 : : .type = CNXK_BPHY_IRQ_MSG_TYPE_MEM_GET,
489 : : };
490 : :
491 : : return __rte_pmd_bphy_enq_deq(dev_id, CNXK_BPHY_DEF_QUEUE, &msg,
492 : : mem, sizeof(*mem));
493 : : }
494 : :
495 : : /**
496 : : * Obtain NPA PF func
497 : : *
498 : : * @param dev_id
499 : : * The identifier of the device
500 : : * @param pf_func
501 : : * NPA PF function to obtain
502 : : *
503 : : * @return
504 : : * Returns 0 on success, negative error code otherwise
505 : : */
506 : : static __rte_always_inline int
507 : : rte_pmd_bphy_npa_pf_func_get(uint16_t dev_id, uint16_t *pf_func)
508 : : {
509 : 0 : struct cnxk_bphy_irq_msg msg = {
510 : : .type = CNXK_BPHY_MSG_TYPE_NPA_PF_FUNC,
511 : : };
512 : :
513 : : return __rte_pmd_bphy_enq_deq(dev_id, CNXK_BPHY_DEF_QUEUE, &msg,
514 : : pf_func, sizeof(*pf_func));
515 : : }
516 : :
517 : : /**
518 : : * Obtain SSO PF func
519 : : *
520 : : * @param dev_id
521 : : * The identifier of the device
522 : : * @param pf_func
523 : : * SSO PF function to obtain
524 : : *
525 : : * @return
526 : : * Returns 0 on success, negative error code otherwise
527 : : */
528 : : static __rte_always_inline int
529 : : rte_pmd_bphy_sso_pf_func_get(uint16_t dev_id, uint16_t *pf_func)
530 : : {
531 : 0 : struct cnxk_bphy_irq_msg msg = {
532 : : .type = CNXK_BPHY_MSG_TYPE_SSO_PF_FUNC,
533 : : };
534 : :
535 : : return __rte_pmd_bphy_enq_deq(dev_id, CNXK_BPHY_DEF_QUEUE, &msg,
536 : : pf_func, sizeof(*pf_func));
537 : : }
538 : :
539 : : /**
540 : : * Obtain link information
541 : : *
542 : : * @param dev_id
543 : : * The identifier of the device
544 : : * @param lmac
545 : : * LMAC number for operation
546 : : * @param info
547 : : * Link information structure
548 : : *
549 : : * @return
550 : : * Returns 0 on success, negative error code otherwise
551 : : */
552 : : static __rte_always_inline int
553 : : rte_pmd_bphy_cgx_get_link_info(uint16_t dev_id, uint16_t lmac,
554 : : struct cnxk_bphy_cgx_msg_link_info *info)
555 : : {
556 : 0 : struct cnxk_bphy_cgx_msg msg = {
557 : : .type = CNXK_BPHY_CGX_MSG_TYPE_GET_LINKINFO,
558 : : };
559 : :
560 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, info, sizeof(*info));
561 : : }
562 : :
563 : : /**
564 : : * Disable loopback mode for an interface
565 : : *
566 : : * @param dev_id
567 : : * The identifier of the device
568 : : * @param lmac
569 : : * LMAC number for operation
570 : : *
571 : : * @return
572 : : * Returns 0 on success, negative error code otherwise
573 : : */
574 : : static __rte_always_inline int
575 : : rte_pmd_bphy_cgx_intlbk_disable(uint16_t dev_id, uint16_t lmac)
576 : : {
577 : 0 : struct cnxk_bphy_cgx_msg msg = {
578 : : .type = CNXK_BPHY_CGX_MSG_TYPE_INTLBK_DISABLE,
579 : : };
580 : :
581 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
582 : : }
583 : :
584 : : /**
585 : : * Enable loopback mode for an interface
586 : : *
587 : : * @param dev_id
588 : : * The identifier of the device
589 : : * @param lmac
590 : : * LMAC number for operation
591 : : *
592 : : * @return
593 : : * Returns 0 on success, negative error code otherwise
594 : : */
595 : : static __rte_always_inline int
596 : : rte_pmd_bphy_cgx_intlbk_enable(uint16_t dev_id, uint16_t lmac)
597 : : {
598 : 0 : struct cnxk_bphy_cgx_msg msg = {
599 : : .type = CNXK_BPHY_CGX_MSG_TYPE_INTLBK_ENABLE,
600 : : };
601 : :
602 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
603 : : }
604 : :
605 : : /**
606 : : * Disable PTP on RX path
607 : : *
608 : : * @param dev_id
609 : : * The identifier of the device
610 : : * @param lmac
611 : : * LMAC number for operation
612 : : *
613 : : * @return
614 : : * Returns 0 on success, negative error code otherwise
615 : : */
616 : : static __rte_always_inline int
617 : : rte_pmd_bphy_cgx_ptp_rx_disable(uint16_t dev_id, uint16_t lmac)
618 : : {
619 : 0 : struct cnxk_bphy_cgx_msg msg = {
620 : : .type = CNXK_BPHY_CGX_MSG_TYPE_PTP_RX_DISABLE,
621 : : };
622 : :
623 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
624 : : }
625 : :
626 : : /**
627 : : * Enable PTP on RX path
628 : : *
629 : : * @param dev_id
630 : : * The identifier of the device
631 : : * @param lmac
632 : : * LMAC number for operation
633 : : *
634 : : * @return
635 : : * Returns 0 on success, negative error code otherwise
636 : : */
637 : : static __rte_always_inline int
638 : : rte_pmd_bphy_cgx_ptp_rx_enable(uint16_t dev_id, uint16_t lmac)
639 : : {
640 : 0 : struct cnxk_bphy_cgx_msg msg = {
641 : : .type = CNXK_BPHY_CGX_MSG_TYPE_PTP_RX_ENABLE,
642 : : };
643 : :
644 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
645 : : }
646 : :
647 : : /**
648 : : * Set link mode for a CGX
649 : : *
650 : : * @param dev_id
651 : : * The identifier of the device
652 : : * @param lmac
653 : : * LMAC number for operation
654 : : * @param mode
655 : : * Link mode to set
656 : : *
657 : : * @return
658 : : * Returns 0 on success, negative error code otherwise
659 : : */
660 : : static __rte_always_inline int
661 : : rte_pmd_bphy_cgx_set_link_mode(uint16_t dev_id, uint16_t lmac,
662 : : struct cnxk_bphy_cgx_msg_link_mode *mode)
663 : : {
664 : : struct cnxk_bphy_cgx_msg msg = {
665 : : .type = CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_MODE,
666 : : .data = mode,
667 : : };
668 : :
669 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
670 : : }
671 : :
672 : : /**
673 : : * Set link state for a CGX
674 : : *
675 : : * @param dev_id
676 : : * The identifier of the device
677 : : * @param lmac
678 : : * LMAC number for operation
679 : : * @param up
680 : : * Link state to set
681 : : *
682 : : * @return
683 : : * Returns 0 on success, negative error code otherwise
684 : : */
685 : : static __rte_always_inline int
686 : : rte_pmd_bphy_cgx_set_link_state(uint16_t dev_id, uint16_t lmac, bool up)
687 : : {
688 : 0 : struct cnxk_bphy_cgx_msg_set_link_state state = {
689 : : .state = up,
690 : : };
691 : 0 : struct cnxk_bphy_cgx_msg msg = {
692 : : .type = CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_STATE,
693 : : .data = &state,
694 : : };
695 : :
696 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
697 : : }
698 : :
699 : : /**
700 : : * Start CGX
701 : : *
702 : : * @param dev_id
703 : : * The identifier of the device
704 : : * @param lmac
705 : : * LMAC number for operation
706 : : *
707 : : * @return
708 : : * Returns 0 on success, negative error code otherwise
709 : : */
710 : : static __rte_always_inline int
711 : : rte_pmd_bphy_cgx_start_rxtx(uint16_t dev_id, uint16_t lmac)
712 : : {
713 : 0 : struct cnxk_bphy_cgx_msg msg = {
714 : : .type = CNXK_BPHY_CGX_MSG_TYPE_START_RXTX,
715 : : };
716 : :
717 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
718 : : }
719 : :
720 : : /**
721 : : * Stop CGX
722 : : *
723 : : * @param dev_id
724 : : * The identifier of the device
725 : : * @param lmac
726 : : * LMAC number for operation
727 : : *
728 : : * @return
729 : : * Returns 0 on success, negative error code otherwise
730 : : */
731 : : static __rte_always_inline int
732 : : rte_pmd_bphy_cgx_stop_rxtx(uint16_t dev_id, uint16_t lmac)
733 : : {
734 : 0 : struct cnxk_bphy_cgx_msg msg = {
735 : : .type = CNXK_BPHY_CGX_MSG_TYPE_STOP_RXTX,
736 : : };
737 : :
738 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
739 : : }
740 : :
741 : : /**
742 : : * Get supported list FEC mode
743 : : *
744 : : * @param dev_id
745 : : * The identifier of the device
746 : : * @param lmac
747 : : * LMAC number for operation
748 : : * @param fec
749 : : * FEC structure which holds information
750 : : *
751 : : * @return
752 : : * Returns 0 on success, negative error code otherwise
753 : : */
754 : : static __rte_always_inline int
755 : : rte_pmd_bphy_cgx_get_supported_fec(uint16_t dev_id, uint16_t lmac,
756 : : enum cnxk_bphy_cgx_eth_link_fec *fec)
757 : : {
758 : 0 : struct cnxk_bphy_cgx_msg msg = {
759 : : .type = CNXK_BPHY_CGX_MSG_TYPE_GET_SUPPORTED_FEC,
760 : : };
761 : :
762 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, fec, sizeof(*fec));
763 : : }
764 : :
765 : : /**
766 : : * Set FEC mode for a device
767 : : *
768 : : * @param dev_id
769 : : * The identifier of the device
770 : : * @param lmac
771 : : * LMAC number for operation
772 : : * @param fec
773 : : * FEC structure which holds information to set
774 : : *
775 : : * @return
776 : : * Returns 0 on success, negative error code otherwise
777 : : */
778 : : static __rte_always_inline int
779 : : rte_pmd_bphy_cgx_set_fec(uint16_t dev_id, uint16_t lmac,
780 : : enum cnxk_bphy_cgx_eth_link_fec fec)
781 : : {
782 : 0 : struct cnxk_bphy_cgx_msg msg = {
783 : : .type = CNXK_BPHY_CGX_MSG_TYPE_SET_FEC,
784 : : .data = &fec,
785 : : };
786 : :
787 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
788 : : }
789 : :
790 : : /**
791 : : * Switch from eCPRI to CPRI and change
792 : : *
793 : : * @param dev_id
794 : : * The identifier of the device
795 : : * @param lmac
796 : : * LMAC number for operation
797 : : * @param mode
798 : : * CPRI structure which holds configuration data
799 : : *
800 : : * @return
801 : : * Returns 0 on success, negative error code otherwise
802 : : */
803 : : static __rte_always_inline int
804 : : rte_pmd_bphy_cgx_cpri_mode_change(uint16_t dev_id, uint16_t lmac,
805 : : struct cnxk_bphy_cgx_msg_cpri_mode_change *mode)
806 : : {
807 : : struct cnxk_bphy_cgx_msg msg = {
808 : : .type = CNXK_BPHY_CGX_MSG_TYPE_CPRI_MODE_CHANGE,
809 : : .data = mode,
810 : : };
811 : :
812 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
813 : : }
814 : :
815 : : /**
816 : : * Enable TX for SERDES configured in CPRI mode
817 : : *
818 : : * @param dev_id
819 : : * The identifier of the device
820 : : * @param lmac
821 : : * LMAC number for operation
822 : : * @param mode
823 : : * CPRI TX control structure holding control data
824 : : *
825 : : * @return
826 : : * Returns 0 on success, negative error code otherwise
827 : : */
828 : : static __rte_always_inline int
829 : : rte_pmd_bphy_cgx_cpri_tx_control(uint16_t dev_id, uint16_t lmac,
830 : : struct cnxk_bphy_cgx_msg_cpri_mode_tx_ctrl *mode)
831 : : {
832 : : struct cnxk_bphy_cgx_msg msg = {
833 : : .type = CNXK_BPHY_CGX_MSG_TYPE_CPRI_TX_CONTROL,
834 : : .data = mode,
835 : : };
836 : :
837 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
838 : : }
839 : :
840 : : /**
841 : : * CPRI misc settings
842 : : *
843 : : * @param dev_id
844 : : * The identifier of the device
845 : : * @param lmac
846 : : * LMAC number for operation
847 : : * @param mode
848 : : * CPRI settings holding misc control data
849 : : *
850 : : * @return
851 : : * Returns 0 on success, negative error code otherwise
852 : : */
853 : : static __rte_always_inline int
854 : : rte_pmd_bphy_cgx_cpri_mode_misc(uint16_t dev_id, uint16_t lmac,
855 : : struct cnxk_bphy_cgx_msg_cpri_mode_misc *mode)
856 : : {
857 : : struct cnxk_bphy_cgx_msg msg = {
858 : : .type = CNXK_BPHY_CGX_MSG_TYPE_CPRI_MODE_MISC,
859 : : .data = mode,
860 : : };
861 : :
862 : : return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
863 : : }
864 : :
865 : : /**
866 : : * Obtain NPA PF func
867 : : *
868 : : * @param pf_func
869 : : * Address of an NPA PF and function for NPA free pointer
870 : : * requests to obtain
871 : : *
872 : : * @return
873 : : * Returns 0 on success, negative error code otherwise
874 : : */
875 : : int rte_pmd_bphy_npa_pf_func_get_rmt(uint16_t *pf_func);
876 : :
877 : : /**
878 : : * Obtain SSO PF func
879 : : *
880 : : * @param pf_func
881 : : * Address SSO PF and function for SSO add-work requests to obtain
882 : : *
883 : : * @return
884 : : * Returns 0 on success, negative error code otherwise
885 : : */
886 : : int rte_pmd_bphy_sso_pf_func_get_rmt(uint16_t *pf_func);
887 : :
888 : : #ifdef __cplusplus
889 : : }
890 : : #endif
891 : :
892 : : #endif /* _CNXK_BPHY_H_ */
|