xref: /OK3568_Linux_fs/kernel/drivers/net/ethernet/freescale/fman/fman_sp.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright 2008 - 2015 Freescale Semiconductor Inc.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Redistribution and use in source and binary forms, with or without
5*4882a593Smuzhiyun  * modification, are permitted provided that the following conditions are met:
6*4882a593Smuzhiyun  *     * Redistributions of source code must retain the above copyright
7*4882a593Smuzhiyun  *	 notice, this list of conditions and the following disclaimer.
8*4882a593Smuzhiyun  *     * Redistributions in binary form must reproduce the above copyright
9*4882a593Smuzhiyun  *	 notice, this list of conditions and the following disclaimer in the
10*4882a593Smuzhiyun  *	 documentation and/or other materials provided with the distribution.
11*4882a593Smuzhiyun  *     * Neither the name of Freescale Semiconductor nor the
12*4882a593Smuzhiyun  *	 names of its contributors may be used to endorse or promote products
13*4882a593Smuzhiyun  *	 derived from this software without specific prior written permission.
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * ALTERNATIVELY, this software may be distributed under the terms of the
16*4882a593Smuzhiyun  * GNU General Public License ("GPL") as published by the Free Software
17*4882a593Smuzhiyun  * Foundation, either version 2 of that License or (at your option) any
18*4882a593Smuzhiyun  * later version.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
21*4882a593Smuzhiyun  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22*4882a593Smuzhiyun  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23*4882a593Smuzhiyun  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
24*4882a593Smuzhiyun  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25*4882a593Smuzhiyun  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26*4882a593Smuzhiyun  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27*4882a593Smuzhiyun  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28*4882a593Smuzhiyun  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29*4882a593Smuzhiyun  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #ifndef __FM_SP_H
33*4882a593Smuzhiyun #define __FM_SP_H
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #include "fman.h"
36*4882a593Smuzhiyun #include <linux/types.h>
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #define ILLEGAL_BASE    (~0)
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun /* defaults */
41*4882a593Smuzhiyun #define DFLT_FM_SP_BUFFER_PREFIX_CONTEXT_DATA_ALIGN	64
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /* Registers bit fields */
44*4882a593Smuzhiyun #define FMAN_SP_EXT_BUF_POOL_EN_COUNTER		0x40000000
45*4882a593Smuzhiyun #define FMAN_SP_EXT_BUF_POOL_VALID			0x80000000
46*4882a593Smuzhiyun #define FMAN_SP_EXT_BUF_POOL_BACKUP			0x20000000
47*4882a593Smuzhiyun #define FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE		0x00100000
48*4882a593Smuzhiyun #define FMAN_SP_SG_DISABLE				0x80000000
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun /* shifts */
51*4882a593Smuzhiyun #define FMAN_SP_EXT_BUF_MARG_START_SHIFT		16
52*4882a593Smuzhiyun #define FMAN_SP_DMA_ATTR_SWP_SHIFT			30
53*4882a593Smuzhiyun #define FMAN_SP_IC_TO_EXT_SHIFT			16
54*4882a593Smuzhiyun #define FMAN_SP_IC_FROM_INT_SHIFT			8
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun /* structure for defining internal context copying */
57*4882a593Smuzhiyun struct fman_sp_int_context_data_copy {
58*4882a593Smuzhiyun 	/* < Offset in External buffer to which internal
59*4882a593Smuzhiyun 	 *  context is copied to (Rx) or taken from (Tx, Op).
60*4882a593Smuzhiyun 	 */
61*4882a593Smuzhiyun 	u16 ext_buf_offset;
62*4882a593Smuzhiyun 	/* Offset within internal context to copy from
63*4882a593Smuzhiyun 	 * (Rx) or to copy to (Tx, Op).
64*4882a593Smuzhiyun 	 */
65*4882a593Smuzhiyun 	u8 int_context_offset;
66*4882a593Smuzhiyun 	/* Internal offset size to be copied */
67*4882a593Smuzhiyun 	u16 size;
68*4882a593Smuzhiyun };
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun /*  struct for defining external buffer margins */
71*4882a593Smuzhiyun struct fman_sp_buf_margins {
72*4882a593Smuzhiyun 	/* Number of bytes to be left at the beginning
73*4882a593Smuzhiyun 	 * of the external buffer (must be divisible by 16)
74*4882a593Smuzhiyun 	 */
75*4882a593Smuzhiyun 	u16 start_margins;
76*4882a593Smuzhiyun 	/* number of bytes to be left at the end
77*4882a593Smuzhiyun 	 * of the external buffer(must be divisible by 16)
78*4882a593Smuzhiyun 	 */
79*4882a593Smuzhiyun 	u16 end_margins;
80*4882a593Smuzhiyun };
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun struct fman_sp_buffer_offsets {
83*4882a593Smuzhiyun 	u32 data_offset;
84*4882a593Smuzhiyun 	u32 prs_result_offset;
85*4882a593Smuzhiyun 	u32 time_stamp_offset;
86*4882a593Smuzhiyun 	u32 hash_result_offset;
87*4882a593Smuzhiyun };
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy
90*4882a593Smuzhiyun 				*int_context_data_copy,
91*4882a593Smuzhiyun 				struct fman_buffer_prefix_content
92*4882a593Smuzhiyun 				*buffer_prefix_content,
93*4882a593Smuzhiyun 				struct fman_sp_buf_margins *buf_margins,
94*4882a593Smuzhiyun 				struct fman_sp_buffer_offsets
95*4882a593Smuzhiyun 				*buffer_offsets,
96*4882a593Smuzhiyun 				u8 *internal_buf_offset);
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun void fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools
99*4882a593Smuzhiyun 						     *fm_ext_pools,
100*4882a593Smuzhiyun 						     u8 *ordered_array,
101*4882a593Smuzhiyun 						     u16 *sizes_array);
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun #endif	/* __FM_SP_H */
104