source: rtems-libbsd/linux/drivers/net/ethernet/freescale/fman/fman_port.h @ 28ee86a

55-freebsd-126-freebsd-12
Last change on this file since 28ee86a was 28ee86a, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/16 at 09:58:19

Import DPAA driver snapshot

Imported from Freescale Linux repository

git://git.freescale.com/ppc/upstream/linux.git

commit 2774c204cd8bfc56a200ff4dcdfc9cdf5b6fc161.

Linux compatibility layer is partly from FreeBSD.

  • Property mode set to 100644
File size: 9.0 KB
Line 
1/*
2 * Copyright 2008 - 2015 Freescale Semiconductor Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *     * Redistributions of source code must retain the above copyright
7 *       notice, this list of conditions and the following disclaimer.
8 *     * Redistributions in binary form must reproduce the above copyright
9 *       notice, this list of conditions and the following disclaimer in the
10 *       documentation and/or other materials provided with the distribution.
11 *     * Neither the name of Freescale Semiconductor nor the
12 *       names of its contributors may be used to endorse or promote products
13 *       derived from this software without specific prior written permission.
14 *
15 *
16 * ALTERNATIVELY, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") as published by the Free Software
18 * Foundation, either version 2 of that License or (at your option) any
19 * later version.
20 *
21 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef __FMAN_PORT_H
34#define __FMAN_PORT_H
35
36#include "fman.h"
37
38/* FM Port API
39 * The FM uses a general module called "port" to represent a Tx port (MAC),
40 * an Rx port (MAC).
41 * The number of ports in an FM varies between SOCs.
42 * The SW driver manages these ports as sub-modules of the FM,i.e. after an
43 * FM is initialized, its ports may be initialized and operated upon.
44 * The port is initialized aware of its type, but other functions on a port
45 * may be indifferent to its type. When necessary, the driver verifies
46 * coherence and returns error if applicable.
47 * On initialization, user specifies the port type and it's index (relative
48 * to the port's type) - always starting at 0.
49 */
50
51/* FM Frame error */
52/* Frame Descriptor errors */
53/* Not for Rx-Port! Unsupported Format */
54#define FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT      FM_FD_ERR_UNSUPPORTED_FORMAT
55/* Not for Rx-Port! Length Error */
56#define FM_PORT_FRM_ERR_LENGTH                  FM_FD_ERR_LENGTH
57/* DMA Data error */
58#define FM_PORT_FRM_ERR_DMA                     FM_FD_ERR_DMA
59/* non Frame-Manager error; probably come from SEC that was chained to FM */
60#define FM_PORT_FRM_ERR_NON_FM                  FM_FD_RX_STATUS_ERR_NON_FM
61 /* IPR error */
62#define FM_PORT_FRM_ERR_IPRE                    (FM_FD_ERR_IPR & ~FM_FD_IPR)
63/* IPR non-consistent-sp */
64#define FM_PORT_FRM_ERR_IPR_NCSP                (FM_FD_ERR_IPR_NCSP &   \
65                                                ~FM_FD_IPR)
66
67/* Rx FIFO overflow, FCS error, code error, running disparity
68 * error (SGMII and TBI modes), FIFO parity error.
69 * PHY Sequence error, PHY error control character detected.
70 */
71#define FM_PORT_FRM_ERR_PHYSICAL                FM_FD_ERR_PHYSICAL
72/* Frame too long OR Frame size exceeds max_length_frame  */
73#define FM_PORT_FRM_ERR_SIZE                    FM_FD_ERR_SIZE
74/* indicates a classifier "drop" operation */
75#define FM_PORT_FRM_ERR_CLS_DISCARD             FM_FD_ERR_CLS_DISCARD
76/* Extract Out of Frame */
77#define FM_PORT_FRM_ERR_EXTRACTION              FM_FD_ERR_EXTRACTION
78/* No Scheme Selected */
79#define FM_PORT_FRM_ERR_NO_SCHEME               FM_FD_ERR_NO_SCHEME
80/* Keysize Overflow */
81#define FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW        FM_FD_ERR_KEYSIZE_OVERFLOW
82/* Frame color is red */
83#define FM_PORT_FRM_ERR_COLOR_RED               FM_FD_ERR_COLOR_RED
84/* Frame color is yellow */
85#define FM_PORT_FRM_ERR_COLOR_YELLOW            FM_FD_ERR_COLOR_YELLOW
86/* Parser Time out Exceed */
87#define FM_PORT_FRM_ERR_PRS_TIMEOUT             FM_FD_ERR_PRS_TIMEOUT
88/* Invalid Soft Parser instruction */
89#define FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT        FM_FD_ERR_PRS_ILL_INSTRUCT
90/* Header error was identified during parsing */
91#define FM_PORT_FRM_ERR_PRS_HDR_ERR             FM_FD_ERR_PRS_HDR_ERR
92/* Frame parsed beyind 256 first bytes */
93#define FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED    FM_FD_ERR_BLOCK_LIMIT_EXCEEDED
94/* FPM Frame Processing Timeout Exceeded */
95#define FM_PORT_FRM_ERR_PROCESS_TIMEOUT         0x00000001
96
97struct fman_port;
98
99/* A structure for additional Rx port parameters */
100struct fman_port_rx_params {
101        u32 err_fqid;                   /* Error Queue Id. */
102        u32 dflt_fqid;                  /* Default Queue Id. */
103        /* Which external buffer pools are used
104         * (up to FMAN_PORT_MAX_EXT_POOLS_NUM), and their sizes.
105         */
106        struct fman_ext_pools ext_buf_pools;
107};
108
109/* A structure for additional non-Rx port parameters */
110struct fman_port_non_rx_params {
111        /* Error Queue Id. */
112        u32 err_fqid;
113        /* For Tx - Default Confirmation queue, 0 means no Tx confirmation
114         * for processed frames. For OP port - default Rx queue.
115         */
116        u32 dflt_fqid;
117};
118
119/* A union for additional parameters depending on port type */
120union fman_port_specific_params {
121        /* Rx port parameters structure */
122        struct fman_port_rx_params rx_params;
123        /* Non-Rx port parameters structure */
124        struct fman_port_non_rx_params non_rx_params;
125};
126
127/* A structure representing FM initialization parameters */
128struct fman_port_params {
129        /* Virtual Address of memory mapped FM Port registers. */
130        void *fm;
131        union fman_port_specific_params specific_params;
132        /* Additional parameters depending on port type. */
133};
134
135/**
136 * fman_port_config
137 * @port:       Pointer to the port structure
138 * @params:     Pointer to data structure of parameters
139 *
140 * Creates a descriptor for the FM PORT module.
141 * The routine returns a pointer to the FM PORT object.
142 * This descriptor must be passed as first parameter to all other FM PORT
143 * function calls.
144 * No actual initialization or configuration of FM hardware is done by this
145 * routine.
146 *
147 * Return: 0 on success; Error code otherwise.
148 */
149int fman_port_config(struct fman_port *port, struct fman_port_params *params);
150
151/**
152 * fman_port_init
153 * port:        A pointer to a FM Port module.
154 * Initializes the FM PORT module by defining the software structure and
155 * configuring the hardware registers.
156 *
157 * Return: 0 on success; Error code otherwise.
158 */
159int fman_port_init(struct fman_port *port);
160
161/**
162 * fman_port_cfg_buf_prefix_content
163 * @port                        A pointer to a FM Port module.
164 * @buffer_prefix_content       A structure of parameters describing
165 *                              the structure of the buffer.
166 *                              Out parameter:
167 *                              Start margin - offset of data from
168 *                              start of external buffer.
169 * Defines the structure, size and content of the application buffer.
170 * The prefix, in Tx ports, if 'pass_prs_result', the application should set
171 * a value to their offsets in the prefix of the FM will save the first
172 * 'priv_data_size', than, depending on 'pass_prs_result' and
173 * 'pass_time_stamp', copy parse result and timeStamp, and the packet itself
174 * (in this order), to the application buffer, and to offset.
175 * Calling this routine changes the buffer margins definitions in the internal
176 * driver data base from its default configuration:
177 * Data size:  [DEFAULT_PORT_BUFFER_PREFIX_CONTENT_PRIV_DATA_SIZE]
178 * Pass Parser result: [DEFAULT_PORT_BUFFER_PREFIX_CONTENT_PASS_PRS_RESULT].
179 * Pass timestamp: [DEFAULT_PORT_BUFFER_PREFIX_CONTENT_PASS_TIME_STAMP].
180 * May be used for all ports
181 *
182 * Allowed only following fman_port_config() and before fman_port_init().
183 *
184 * Return: 0 on success; Error code otherwise.
185 */
186int fman_port_cfg_buf_prefix_content(struct fman_port *port,
187                                     struct fman_buffer_prefix_content
188                                     *buffer_prefix_content);
189
190/**
191 * fman_port_disable
192 * port:        A pointer to a FM Port module.
193 *
194 * Gracefully disable an FM port. The port will not start new   tasks after all
195 * tasks associated with the port are terminated.
196 *
197 * This is a blocking routine, it returns after port is gracefully stopped,
198 * i.e. the port will not except new frames, but it will finish all frames
199 * or tasks which were already began.
200 * Allowed only following fman_port_init().
201 *
202 * Return: 0 on success; Error code otherwise.
203 */
204int fman_port_disable(struct fman_port *port);
205
206/**
207 * fman_port_enable
208 * port:        A pointer to a FM Port module.
209 *
210 * A runtime routine provided to allow disable/enable of port.
211 *
212 * Allowed only following fman_port_init().
213 *
214 * Return: 0 on success; Error code otherwise.
215 */
216int fman_port_enable(struct fman_port *port);
217
218/**
219 * fman_port_get_qman_channel_id
220 * port:        Pointer to the FMan port devuce
221 *
222 * Get the QMan channel ID for the specific port
223 *
224 * Return: QMan channel ID
225 */
226u32 fman_port_get_qman_channel_id(struct fman_port *port);
227
228/**
229 * fman_port_bind
230 * dev:         FMan Port OF device pointer
231 *
232 * Bind to a specific FMan Port.
233 *
234 * Allowed only after the port was created.
235 *
236 * Return: A pointer to the FMan port device.
237 */
238struct fman_port *fman_port_bind(struct device *dev);
239
240#endif /* __FMAN_PORT_H */
Note: See TracBrowser for help on using the repository browser.