xref: /freebsd/sys/dev/dpaa/fman_port_var.h (revision 5d884fc07662760a2090928e98e51dc8162389a3)
1 /*
2  * Copyright (c) 2026 Justin Hibbits
3  *
4  * SPDX-License-Identifier: BSD-2-Clause
5  */
6 
7 #ifndef DPAA_FMAN_PORT_VAR_H
8 #define	DPAA_FMAN_PORT_VAR_H
9 
10 #include "fman_port.h"
11 
12 struct fman_port_rsrc {
13 	uint32_t	num;
14 	uint32_t	extra;
15 };
16 
17 /* Base softc.  Shared by all FMan port drivers. */
18 #define	MAX_BM_POOLS	64
19 struct fman_port_softc {
20 	device_t sc_dev;
21 	struct resource *sc_mem;
22 	int sc_port_id;
23 	int sc_port_type;
24 	int sc_port_speed;
25 
26 	int sc_revision_major;
27 	int sc_revision_minor;
28 
29 	int sc_max_frame_length;
30 	int sc_bm_max_pools;
31 	int sc_max_port_fifo_size;
32 
33 	int sc_default_fqid;
34 	int sc_err_fqid;
35 
36 	int sc_max_ext_portals;
37 	int sc_max_sub_portals;
38 
39 	struct fman_port_rsrc sc_open_dmas;
40 	struct fman_port_rsrc sc_tasks;
41 	struct fman_port_rsrc sc_fifo_bufs;
42 };
43 
44 #define	PORT_V3		0x01
45 
46 /* QMI per-port registers. */
47 #define	FMQM_PNC			0x400
48 #define	  PNC_EN			  0x80000000
49 #define	  PNC_STEN			  0x80000000
50 #define	FMQM_PNS			0x404
51 #define	  PNS_DEQ_FD_BSY		  0x20000000
52 #define	FMQM_PNEN			0x41c
53 #define	FMQM_PNDN			0x42c
54 #define	FMQM_PNDC			0x430
55 
56 #define	FMBM_CFG			0x000
57 #define	  BMI_PORT_CFG_EN		  0x80000000
58 
59 /*
60  * Next Invoked Action (NIA) engine + action codes.  Written into the
61  * per-engine "next" registers to chain BMI -> Parser -> KeyGen ->
62  * BMI-enqueue -> QMI-enqueue.
63  */
64 #define	NIA_ORDER_RESTORE		0x00800000
65 #define	NIA_ENG_BMI			0x00500000
66 #define	NIA_ENG_QMI_DEQ			0x00580000
67 #define	NIA_ENG_QMI_ENQ			0x00540000
68 #define	NIA_ENG_HWP			0x00440000
69 #define	NIA_ENG_HWK			0x00480000
70 #define	NIA_BMI_AC_TX_RELEASE		0x000002c0
71 #define	NIA_BMI_AC_TX			0x00000274
72 #define	NIA_BMI_AC_RELEASE		0x000000c0
73 #define	NIA_BMI_AC_ENQ_FRAME		0x00000002
74 #define	NIA_BMI_AC_FETCH_ALLFRAME	0x0000020c
75 
76 #define	PORT_MAX_FRAME_LENGTH		9600
77 
78 int fman_port_attach_common(device_t dev, struct fman_port_softc *sc,
79     int port_speed);
80 int fman_port_detach_common(device_t dev, struct fman_port_softc *sc);
81 
82 void fman_port_config_common(struct fman_port_softc *sc,
83     struct fman_port_params *params);
84 
85 #endif /* DPAA_FMAN_PORT_VAR_H */
86