New upstream version 17.11-rc3
[deb_dpdk.git] / drivers / bus / dpaa / include / fsl_fman.h
1 /*-
2  * This file is provided under a dual BSD/GPLv2 license. When using or
3  * redistributing this file, you may do so under either license.
4  *
5  *   BSD LICENSE
6  *
7  * Copyright 2017 NXP.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  * * Neither the name of the above-listed copyright holders nor the
17  * names of any contributors may be used to endorse or promote products
18  * derived from this software without specific prior written permission.
19  *
20  *   GPL LICENSE SUMMARY
21  *
22  * ALTERNATIVELY, this software may be distributed under the terms of the
23  * GNU General Public License ("GPL") as published by the Free Software
24  * Foundation, either version 2 of that License or (at your option) any
25  * later version.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39
40 #ifndef __FSL_FMAN_H
41 #define __FSL_FMAN_H
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 /* Status field in FD is updated on Rx side by FMAN with following information.
48  * Refer to field description in FM BG.
49  */
50 struct fm_status_t {
51         unsigned int reserved0:3;
52         unsigned int dcl4c:1; /* Don't Check L4 Checksum */
53         unsigned int reserved1:1;
54         unsigned int ufd:1; /* Unsupported Format */
55         unsigned int lge:1; /* Length Error */
56         unsigned int dme:1; /* DMA Error */
57
58         unsigned int reserved2:4;
59         unsigned int fpe:1; /* Frame physical Error */
60         unsigned int fse:1; /* Frame Size Error */
61         unsigned int dis:1; /* Discard by Classification */
62         unsigned int reserved3:1;
63
64         unsigned int eof:1; /* Key Extraction goes out of frame */
65         unsigned int nss:1; /* No Scheme selected */
66         unsigned int kso:1; /* Key Size Overflow */
67         unsigned int reserved4:1;
68         unsigned int fcl:2; /* Frame Color */
69         unsigned int ipp:1; /* Illegal Policer Profile Selected */
70         unsigned int flm:1; /* Frame Length Mismatch */
71         unsigned int pte:1; /* Parser Timeout */
72         unsigned int isp:1; /* Invalid Soft Parser Instruction */
73         unsigned int phe:1; /* Header Error during parsing */
74         unsigned int frdr:1; /* Frame Dropped by disabled port */
75         unsigned int reserved5:4;
76 } __attribute__ ((__packed__));
77
78 /* Set MAC address for a particular interface */
79 int fman_if_add_mac_addr(struct fman_if *p, uint8_t *eth, uint8_t addr_num);
80
81 /* Remove a MAC address for a particular interface */
82 void fman_if_clear_mac_addr(struct fman_if *p, uint8_t addr_num);
83
84 /* Get the FMAN statistics */
85 void fman_if_stats_get(struct fman_if *p, struct rte_eth_stats *stats);
86
87 /* Reset the FMAN statistics */
88 void fman_if_stats_reset(struct fman_if *p);
89
90 /* Get all of the FMAN statistics */
91 void fman_if_stats_get_all(struct fman_if *p, uint64_t *value, int n);
92
93 /* Set ignore pause option for a specific interface */
94 void fman_if_set_rx_ignore_pause_frames(struct fman_if *p, bool enable);
95
96 /* Set max frame length */
97 void fman_if_conf_max_frame_len(struct fman_if *p, unsigned int max_frame_len);
98
99 /* Enable/disable Rx promiscuous mode on specified interface */
100 void fman_if_promiscuous_enable(struct fman_if *p);
101 void fman_if_promiscuous_disable(struct fman_if *p);
102
103 /* Enable/disable Rx on specific interfaces */
104 void fman_if_enable_rx(struct fman_if *p);
105 void fman_if_disable_rx(struct fman_if *p);
106
107 /* Enable/disable loopback on specific interfaces */
108 void fman_if_loopback_enable(struct fman_if *p);
109 void fman_if_loopback_disable(struct fman_if *p);
110
111 /* Set buffer pool on specific interface */
112 void fman_if_set_bp(struct fman_if *fm_if, unsigned int num, int bpid,
113                     size_t bufsize);
114
115 /* Get Flow Control threshold parameters on specific interface */
116 int fman_if_get_fc_threshold(struct fman_if *fm_if);
117
118 /* Enable and Set Flow Control threshold parameters on specific interface */
119 int fman_if_set_fc_threshold(struct fman_if *fm_if,
120                         u32 high_water, u32 low_water, u32 bpid);
121
122 /* Get Flow Control pause quanta on specific interface */
123 int fman_if_get_fc_quanta(struct fman_if *fm_if);
124
125 /* Set Flow Control pause quanta on specific interface */
126 int fman_if_set_fc_quanta(struct fman_if *fm_if, u16 pause_quanta);
127
128 /* Set default error fqid on specific interface */
129 void fman_if_set_err_fqid(struct fman_if *fm_if, uint32_t err_fqid);
130
131 /* Get IC transfer params */
132 int fman_if_get_ic_params(struct fman_if *fm_if, struct fman_if_ic_params *icp);
133
134 /* Set IC transfer params */
135 int fman_if_set_ic_params(struct fman_if *fm_if,
136                           const struct fman_if_ic_params *icp);
137
138 /* Get interface fd->offset value */
139 int fman_if_get_fdoff(struct fman_if *fm_if);
140
141 /* Set interface fd->offset value */
142 void fman_if_set_fdoff(struct fman_if *fm_if, uint32_t fd_offset);
143
144 /* Get interface Max Frame length (MTU) */
145 uint16_t fman_if_get_maxfrm(struct fman_if *fm_if);
146
147 /* Set interface  Max Frame length (MTU) */
148 void fman_if_set_maxfrm(struct fman_if *fm_if, uint16_t max_frm);
149
150 /* Set interface next invoked action for dequeue operation */
151 void fman_if_set_dnia(struct fman_if *fm_if, uint32_t nia);
152
153 /* discard error packets on rx */
154 void fman_if_discard_rx_errors(struct fman_if *fm_if);
155
156 void fman_if_set_mcast_filter_table(struct fman_if *p);
157
158 void fman_if_reset_mcast_filter_table(struct fman_if *p);
159
160 int fman_if_add_hash_mac_addr(struct fman_if *p, uint8_t *eth);
161
162 int fman_if_get_primary_mac_addr(struct fman_if *p, uint8_t *eth);
163
164
165 /* Enable/disable Rx on all interfaces */
166 static inline void fman_if_enable_all_rx(void)
167 {
168         struct fman_if *__if;
169
170         list_for_each_entry(__if, fman_if_list, node)
171                 fman_if_enable_rx(__if);
172 }
173
174 static inline void fman_if_disable_all_rx(void)
175 {
176         struct fman_if *__if;
177
178         list_for_each_entry(__if, fman_if_list, node)
179                 fman_if_disable_rx(__if);
180 }
181 #endif /* __FSL_FMAN_H */