• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */
2 /*
3  * Copyright 2008 - 2015 Freescale Semiconductor Inc.
4  */
5 
6 #ifndef __FMAN_PORT_H
7 #define __FMAN_PORT_H
8 
9 #include "fman.h"
10 
11 /* FM Port API
12  * The FM uses a general module called "port" to represent a Tx port (MAC),
13  * an Rx port (MAC).
14  * The number of ports in an FM varies between SOCs.
15  * The SW driver manages these ports as sub-modules of the FM,i.e. after an
16  * FM is initialized, its ports may be initialized and operated upon.
17  * The port is initialized aware of its type, but other functions on a port
18  * may be indifferent to its type. When necessary, the driver verifies
19  * coherence and returns error if applicable.
20  * On initialization, user specifies the port type and it's index (relative
21  * to the port's type) - always starting at 0.
22  */
23 
24 /* FM Frame error */
25 /* Frame Descriptor errors */
26 /* Not for Rx-Port! Unsupported Format */
27 #define FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT	FM_FD_ERR_UNSUPPORTED_FORMAT
28 /* Not for Rx-Port! Length Error */
29 #define FM_PORT_FRM_ERR_LENGTH			FM_FD_ERR_LENGTH
30 /* DMA Data error */
31 #define FM_PORT_FRM_ERR_DMA			FM_FD_ERR_DMA
32 /* non Frame-Manager error; probably come from SEC that was chained to FM */
33 #define FM_PORT_FRM_ERR_NON_FM			FM_FD_RX_STATUS_ERR_NON_FM
34  /* IPR error */
35 #define FM_PORT_FRM_ERR_IPRE			(FM_FD_ERR_IPR & ~FM_FD_IPR)
36 /* IPR non-consistent-sp */
37 #define FM_PORT_FRM_ERR_IPR_NCSP		(FM_FD_ERR_IPR_NCSP &	\
38 						~FM_FD_IPR)
39 
40 /* Rx FIFO overflow, FCS error, code error, running disparity
41  * error (SGMII and TBI modes), FIFO parity error.
42  * PHY Sequence error, PHY error control character detected.
43  */
44 #define FM_PORT_FRM_ERR_PHYSICAL                FM_FD_ERR_PHYSICAL
45 /* Frame too long OR Frame size exceeds max_length_frame  */
46 #define FM_PORT_FRM_ERR_SIZE                    FM_FD_ERR_SIZE
47 /* indicates a classifier "drop" operation */
48 #define FM_PORT_FRM_ERR_CLS_DISCARD             FM_FD_ERR_CLS_DISCARD
49 /* Extract Out of Frame */
50 #define FM_PORT_FRM_ERR_EXTRACTION              FM_FD_ERR_EXTRACTION
51 /* No Scheme Selected */
52 #define FM_PORT_FRM_ERR_NO_SCHEME               FM_FD_ERR_NO_SCHEME
53 /* Keysize Overflow */
54 #define FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW        FM_FD_ERR_KEYSIZE_OVERFLOW
55 /* Frame color is red */
56 #define FM_PORT_FRM_ERR_COLOR_RED               FM_FD_ERR_COLOR_RED
57 /* Frame color is yellow */
58 #define FM_PORT_FRM_ERR_COLOR_YELLOW            FM_FD_ERR_COLOR_YELLOW
59 /* Parser Time out Exceed */
60 #define FM_PORT_FRM_ERR_PRS_TIMEOUT             FM_FD_ERR_PRS_TIMEOUT
61 /* Invalid Soft Parser instruction */
62 #define FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT        FM_FD_ERR_PRS_ILL_INSTRUCT
63 /* Header error was identified during parsing */
64 #define FM_PORT_FRM_ERR_PRS_HDR_ERR             FM_FD_ERR_PRS_HDR_ERR
65 /* Frame parsed beyind 256 first bytes */
66 #define FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED    FM_FD_ERR_BLOCK_LIMIT_EXCEEDED
67 /* FPM Frame Processing Timeout Exceeded */
68 #define FM_PORT_FRM_ERR_PROCESS_TIMEOUT         0x00000001
69 
70 struct fman_port;
71 
72 /* A structure for additional Rx port parameters */
73 struct fman_port_rx_params {
74 	u32 err_fqid;			/* Error Queue Id. */
75 	u32 dflt_fqid;			/* Default Queue Id. */
76 	u32 pcd_base_fqid;		/* PCD base Queue Id. */
77 	u32 pcd_fqs_count;		/* Number of PCD FQs. */
78 
79 	/* Which external buffer pools are used
80 	 * (up to FMAN_PORT_MAX_EXT_POOLS_NUM), and their sizes.
81 	 */
82 	struct fman_ext_pools ext_buf_pools;
83 };
84 
85 /* A structure for additional non-Rx port parameters */
86 struct fman_port_non_rx_params {
87 	/* Error Queue Id. */
88 	u32 err_fqid;
89 	/* For Tx - Default Confirmation queue, 0 means no Tx confirmation
90 	 * for processed frames. For OP port - default Rx queue.
91 	 */
92 	u32 dflt_fqid;
93 };
94 
95 /* A union for additional parameters depending on port type */
96 union fman_port_specific_params {
97 	/* Rx port parameters structure */
98 	struct fman_port_rx_params rx_params;
99 	/* Non-Rx port parameters structure */
100 	struct fman_port_non_rx_params non_rx_params;
101 };
102 
103 /* A structure representing FM initialization parameters */
104 struct fman_port_params {
105 	/* Virtual Address of memory mapped FM Port registers. */
106 	void *fm;
107 	union fman_port_specific_params specific_params;
108 	/* Additional parameters depending on port type. */
109 };
110 
111 int fman_port_config(struct fman_port *port, struct fman_port_params *params);
112 
113 void fman_port_use_kg_hash(struct fman_port *port, bool enable);
114 
115 int fman_port_init(struct fman_port *port);
116 
117 int fman_port_cfg_buf_prefix_content(struct fman_port *port,
118 				     struct fman_buffer_prefix_content
119 				     *buffer_prefix_content);
120 
121 int fman_port_disable(struct fman_port *port);
122 
123 int fman_port_enable(struct fman_port *port);
124 
125 u32 fman_port_get_qman_channel_id(struct fman_port *port);
126 
127 int fman_port_get_hash_result_offset(struct fman_port *port, u32 *offset);
128 
129 int fman_port_get_tstamp(struct fman_port *port, const void *data, u64 *tstamp);
130 
131 struct fman_port *fman_port_bind(struct device *dev);
132 
133 struct device *fman_port_get_device(struct fman_port *port);
134 
135 #endif /* __FMAN_PORT_H */
136