xref: /linux/drivers/net/ethernet/freescale/fman/fman_port.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1*8585bdadSSean Anderson /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */
218a6c85fSIgal Liberman /*
318a6c85fSIgal Liberman  * Copyright 2008 - 2015 Freescale Semiconductor Inc.
418a6c85fSIgal Liberman  */
518a6c85fSIgal Liberman 
618a6c85fSIgal Liberman #ifndef __FMAN_PORT_H
718a6c85fSIgal Liberman #define __FMAN_PORT_H
818a6c85fSIgal Liberman 
918a6c85fSIgal Liberman #include "fman.h"
1018a6c85fSIgal Liberman 
1118a6c85fSIgal Liberman /* FM Port API
1218a6c85fSIgal Liberman  * The FM uses a general module called "port" to represent a Tx port (MAC),
1318a6c85fSIgal Liberman  * an Rx port (MAC).
1418a6c85fSIgal Liberman  * The number of ports in an FM varies between SOCs.
1518a6c85fSIgal Liberman  * The SW driver manages these ports as sub-modules of the FM,i.e. after an
1618a6c85fSIgal Liberman  * FM is initialized, its ports may be initialized and operated upon.
1718a6c85fSIgal Liberman  * The port is initialized aware of its type, but other functions on a port
1818a6c85fSIgal Liberman  * may be indifferent to its type. When necessary, the driver verifies
1918a6c85fSIgal Liberman  * coherence and returns error if applicable.
2018a6c85fSIgal Liberman  * On initialization, user specifies the port type and it's index (relative
2118a6c85fSIgal Liberman  * to the port's type) - always starting at 0.
2218a6c85fSIgal Liberman  */
2318a6c85fSIgal Liberman 
2418a6c85fSIgal Liberman /* FM Frame error */
2518a6c85fSIgal Liberman /* Frame Descriptor errors */
2618a6c85fSIgal Liberman /* Not for Rx-Port! Unsupported Format */
2718a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT	FM_FD_ERR_UNSUPPORTED_FORMAT
2818a6c85fSIgal Liberman /* Not for Rx-Port! Length Error */
2918a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_LENGTH			FM_FD_ERR_LENGTH
3018a6c85fSIgal Liberman /* DMA Data error */
3118a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_DMA			FM_FD_ERR_DMA
3218a6c85fSIgal Liberman /* non Frame-Manager error; probably come from SEC that was chained to FM */
3318a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_NON_FM			FM_FD_RX_STATUS_ERR_NON_FM
3418a6c85fSIgal Liberman  /* IPR error */
3518a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_IPRE			(FM_FD_ERR_IPR & ~FM_FD_IPR)
3618a6c85fSIgal Liberman /* IPR non-consistent-sp */
3718a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_IPR_NCSP		(FM_FD_ERR_IPR_NCSP &	\
3818a6c85fSIgal Liberman 						~FM_FD_IPR)
3918a6c85fSIgal Liberman 
4018a6c85fSIgal Liberman /* Rx FIFO overflow, FCS error, code error, running disparity
4118a6c85fSIgal Liberman  * error (SGMII and TBI modes), FIFO parity error.
4218a6c85fSIgal Liberman  * PHY Sequence error, PHY error control character detected.
4318a6c85fSIgal Liberman  */
4418a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_PHYSICAL                FM_FD_ERR_PHYSICAL
4518a6c85fSIgal Liberman /* Frame too long OR Frame size exceeds max_length_frame  */
4618a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_SIZE                    FM_FD_ERR_SIZE
4718a6c85fSIgal Liberman /* indicates a classifier "drop" operation */
4818a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_CLS_DISCARD             FM_FD_ERR_CLS_DISCARD
4918a6c85fSIgal Liberman /* Extract Out of Frame */
5018a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_EXTRACTION              FM_FD_ERR_EXTRACTION
5118a6c85fSIgal Liberman /* No Scheme Selected */
5218a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_NO_SCHEME               FM_FD_ERR_NO_SCHEME
5318a6c85fSIgal Liberman /* Keysize Overflow */
5418a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW        FM_FD_ERR_KEYSIZE_OVERFLOW
5518a6c85fSIgal Liberman /* Frame color is red */
5618a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_COLOR_RED               FM_FD_ERR_COLOR_RED
5718a6c85fSIgal Liberman /* Frame color is yellow */
5818a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_COLOR_YELLOW            FM_FD_ERR_COLOR_YELLOW
5918a6c85fSIgal Liberman /* Parser Time out Exceed */
6018a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_PRS_TIMEOUT             FM_FD_ERR_PRS_TIMEOUT
6118a6c85fSIgal Liberman /* Invalid Soft Parser instruction */
6218a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT        FM_FD_ERR_PRS_ILL_INSTRUCT
6318a6c85fSIgal Liberman /* Header error was identified during parsing */
6418a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_PRS_HDR_ERR             FM_FD_ERR_PRS_HDR_ERR
6518a6c85fSIgal Liberman /* Frame parsed beyind 256 first bytes */
6618a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED    FM_FD_ERR_BLOCK_LIMIT_EXCEEDED
6718a6c85fSIgal Liberman /* FPM Frame Processing Timeout Exceeded */
6818a6c85fSIgal Liberman #define FM_PORT_FRM_ERR_PROCESS_TIMEOUT         0x00000001
6918a6c85fSIgal Liberman 
7018a6c85fSIgal Liberman struct fman_port;
7118a6c85fSIgal Liberman 
7218a6c85fSIgal Liberman /* A structure for additional Rx port parameters */
7318a6c85fSIgal Liberman struct fman_port_rx_params {
7418a6c85fSIgal Liberman 	u32 err_fqid;			/* Error Queue Id. */
7518a6c85fSIgal Liberman 	u32 dflt_fqid;			/* Default Queue Id. */
767472f4f2SIordache Florinel-R70177 	u32 pcd_base_fqid;		/* PCD base Queue Id. */
777472f4f2SIordache Florinel-R70177 	u32 pcd_fqs_count;		/* Number of PCD FQs. */
787472f4f2SIordache Florinel-R70177 
7918a6c85fSIgal Liberman 	/* Which external buffer pools are used
8018a6c85fSIgal Liberman 	 * (up to FMAN_PORT_MAX_EXT_POOLS_NUM), and their sizes.
8118a6c85fSIgal Liberman 	 */
8218a6c85fSIgal Liberman 	struct fman_ext_pools ext_buf_pools;
8318a6c85fSIgal Liberman };
8418a6c85fSIgal Liberman 
8518a6c85fSIgal Liberman /* A structure for additional non-Rx port parameters */
8618a6c85fSIgal Liberman struct fman_port_non_rx_params {
8718a6c85fSIgal Liberman 	/* Error Queue Id. */
8818a6c85fSIgal Liberman 	u32 err_fqid;
8918a6c85fSIgal Liberman 	/* For Tx - Default Confirmation queue, 0 means no Tx confirmation
9018a6c85fSIgal Liberman 	 * for processed frames. For OP port - default Rx queue.
9118a6c85fSIgal Liberman 	 */
9218a6c85fSIgal Liberman 	u32 dflt_fqid;
9318a6c85fSIgal Liberman };
9418a6c85fSIgal Liberman 
9518a6c85fSIgal Liberman /* A union for additional parameters depending on port type */
9618a6c85fSIgal Liberman union fman_port_specific_params {
9718a6c85fSIgal Liberman 	/* Rx port parameters structure */
9818a6c85fSIgal Liberman 	struct fman_port_rx_params rx_params;
9918a6c85fSIgal Liberman 	/* Non-Rx port parameters structure */
10018a6c85fSIgal Liberman 	struct fman_port_non_rx_params non_rx_params;
10118a6c85fSIgal Liberman };
10218a6c85fSIgal Liberman 
10318a6c85fSIgal Liberman /* A structure representing FM initialization parameters */
10418a6c85fSIgal Liberman struct fman_port_params {
10518a6c85fSIgal Liberman 	/* Virtual Address of memory mapped FM Port registers. */
10618a6c85fSIgal Liberman 	void *fm;
10718a6c85fSIgal Liberman 	union fman_port_specific_params specific_params;
10818a6c85fSIgal Liberman 	/* Additional parameters depending on port type. */
10918a6c85fSIgal Liberman };
11018a6c85fSIgal Liberman 
11118a6c85fSIgal Liberman int fman_port_config(struct fman_port *port, struct fman_port_params *params);
11218a6c85fSIgal Liberman 
1137472f4f2SIordache Florinel-R70177 void fman_port_use_kg_hash(struct fman_port *port, bool enable);
1147472f4f2SIordache Florinel-R70177 
11518a6c85fSIgal Liberman int fman_port_init(struct fman_port *port);
11618a6c85fSIgal Liberman 
11718a6c85fSIgal Liberman int fman_port_cfg_buf_prefix_content(struct fman_port *port,
11818a6c85fSIgal Liberman 				     struct fman_buffer_prefix_content
11918a6c85fSIgal Liberman 				     *buffer_prefix_content);
12018a6c85fSIgal Liberman 
12118a6c85fSIgal Liberman int fman_port_disable(struct fman_port *port);
12218a6c85fSIgal Liberman 
12318a6c85fSIgal Liberman int fman_port_enable(struct fman_port *port);
12418a6c85fSIgal Liberman 
12518a6c85fSIgal Liberman u32 fman_port_get_qman_channel_id(struct fman_port *port);
12618a6c85fSIgal Liberman 
127056057e2SMadalin Bucur int fman_port_get_hash_result_offset(struct fman_port *port, u32 *offset);
128056057e2SMadalin Bucur 
129880f874cSYangbo Lu int fman_port_get_tstamp(struct fman_port *port, const void *data, u64 *tstamp);
130880f874cSYangbo Lu 
13118a6c85fSIgal Liberman struct fman_port *fman_port_bind(struct device *dev);
13218a6c85fSIgal Liberman 
133681e3838SLaurentiu Tudor struct device *fman_port_get_device(struct fman_port *port);
134681e3838SLaurentiu Tudor 
13518a6c85fSIgal Liberman #endif /* __FMAN_PORT_H */
136