1 | /* Copyright 2008 - 2016 Freescale Semiconductor Inc. |
---|
2 | * |
---|
3 | * Redistribution and use in source and binary forms, with or without |
---|
4 | * modification, are permitted provided that the following conditions are met: |
---|
5 | * * Redistributions of source code must retain the above copyright |
---|
6 | * notice, this list of conditions and the following disclaimer. |
---|
7 | * * Redistributions in binary form must reproduce the above copyright |
---|
8 | * notice, this list of conditions and the following disclaimer in the |
---|
9 | * documentation and/or other materials provided with the distribution. |
---|
10 | * * Neither the name of Freescale Semiconductor nor the |
---|
11 | * names of its contributors may be used to endorse or promote products |
---|
12 | * derived from this software without specific prior written permission. |
---|
13 | * |
---|
14 | * ALTERNATIVELY, this software may be distributed under the terms of the |
---|
15 | * GNU General Public License ("GPL") as published by the Free Software |
---|
16 | * Foundation, either version 2 of that License or (at your option) any |
---|
17 | * later version. |
---|
18 | * |
---|
19 | * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY |
---|
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
---|
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
---|
22 | * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY |
---|
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
---|
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
---|
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
---|
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
29 | */ |
---|
30 | |
---|
31 | #ifndef __DPAA_H |
---|
32 | #define __DPAA_H |
---|
33 | |
---|
34 | #include <linux/netdevice.h> |
---|
35 | #include <soc/fsl/qman.h> |
---|
36 | #include <soc/fsl/bman.h> |
---|
37 | |
---|
38 | #include "fman.h" |
---|
39 | #include "mac.h" |
---|
40 | #include "dpaa_eth_trace.h" |
---|
41 | |
---|
42 | #define DPAA_ETH_TXQ_NUM NR_CPUS |
---|
43 | |
---|
44 | #ifndef __rtems__ |
---|
45 | #define DPAA_BPS_NUM 3 /* number of bpools per interface */ |
---|
46 | #else /* __rtems__ */ |
---|
47 | #define DPAA_BPS_NUM 1 |
---|
48 | #endif /* __rtems__ */ |
---|
49 | |
---|
50 | /* More detailed FQ types - used for fine-grained WQ assignments */ |
---|
51 | enum dpaa_fq_type { |
---|
52 | FQ_TYPE_RX_DEFAULT = 1, /* Rx Default FQs */ |
---|
53 | FQ_TYPE_RX_ERROR, /* Rx Error FQs */ |
---|
54 | FQ_TYPE_TX, /* "Real" Tx FQs */ |
---|
55 | FQ_TYPE_TX_CONFIRM, /* Tx default Conf FQ (actually an Rx FQ) */ |
---|
56 | FQ_TYPE_TX_CONF_MQ, /* Tx conf FQs (one for each Tx FQ) */ |
---|
57 | FQ_TYPE_TX_ERROR, /* Tx Error FQs (these are actually Rx FQs) */ |
---|
58 | }; |
---|
59 | |
---|
60 | struct dpaa_fq { |
---|
61 | struct qman_fq fq_base; |
---|
62 | struct list_head list; |
---|
63 | struct net_device *net_dev; |
---|
64 | bool init; |
---|
65 | u32 fqid; |
---|
66 | u32 flags; |
---|
67 | u16 channel; |
---|
68 | u8 wq; |
---|
69 | enum dpaa_fq_type fq_type; |
---|
70 | }; |
---|
71 | |
---|
72 | struct dpaa_fq_cbs { |
---|
73 | struct qman_fq rx_defq; |
---|
74 | struct qman_fq tx_defq; |
---|
75 | struct qman_fq rx_errq; |
---|
76 | struct qman_fq tx_errq; |
---|
77 | struct qman_fq egress_ern; |
---|
78 | }; |
---|
79 | |
---|
80 | struct dpaa_bp { |
---|
81 | /* device used in the DMA mapping operations */ |
---|
82 | struct device *dev; |
---|
83 | /* current number of buffers in the buffer pool alloted to each CPU */ |
---|
84 | int __percpu *percpu_count; |
---|
85 | /* all buffers allocated for this pool have this raw size */ |
---|
86 | size_t raw_size; |
---|
87 | /* all buffers in this pool have this same usable size */ |
---|
88 | size_t size; |
---|
89 | /* the buffer pools are initialized with config_count buffers for each |
---|
90 | * CPU; at runtime the number of buffers per CPU is constantly brought |
---|
91 | * back to this level |
---|
92 | */ |
---|
93 | u16 config_count; |
---|
94 | u8 bpid; |
---|
95 | struct bman_pool *pool; |
---|
96 | /* bpool can be seeded before use by this cb */ |
---|
97 | int (*seed_cb)(struct dpaa_bp *); |
---|
98 | /* bpool can be emptied before freeing by this cb */ |
---|
99 | void (*free_buf_cb)(const struct dpaa_bp *, struct bm_buffer *); |
---|
100 | atomic_t refs; |
---|
101 | }; |
---|
102 | |
---|
103 | struct dpaa_rx_errors { |
---|
104 | u64 dme; /* DMA Error */ |
---|
105 | u64 fpe; /* Frame Physical Error */ |
---|
106 | u64 fse; /* Frame Size Error */ |
---|
107 | u64 phe; /* Header Error */ |
---|
108 | }; |
---|
109 | |
---|
110 | /* Counters for QMan ERN frames - one counter per rejection code */ |
---|
111 | struct dpaa_ern_cnt { |
---|
112 | u64 cg_tdrop; /* Congestion group taildrop */ |
---|
113 | u64 wred; /* WRED congestion */ |
---|
114 | u64 err_cond; /* Error condition */ |
---|
115 | u64 early_window; /* Order restoration, frame too early */ |
---|
116 | u64 late_window; /* Order restoration, frame too late */ |
---|
117 | u64 fq_tdrop; /* FQ taildrop */ |
---|
118 | u64 fq_retired; /* FQ is retired */ |
---|
119 | u64 orp_zero; /* ORP disabled */ |
---|
120 | }; |
---|
121 | |
---|
122 | struct dpaa_napi_portal { |
---|
123 | #ifndef __rtems__ |
---|
124 | struct napi_struct napi; |
---|
125 | #endif /* __rtems__ */ |
---|
126 | struct qman_portal *p; |
---|
127 | bool down; |
---|
128 | }; |
---|
129 | |
---|
130 | struct dpaa_percpu_priv { |
---|
131 | struct net_device *net_dev; |
---|
132 | struct dpaa_napi_portal np; |
---|
133 | u64 in_interrupt; |
---|
134 | u64 tx_confirm; |
---|
135 | /* fragmented (non-linear) skbuffs received from the stack */ |
---|
136 | u64 tx_frag_skbuffs; |
---|
137 | #ifndef __rtems__ |
---|
138 | struct rtnl_link_stats64 stats; |
---|
139 | #endif /* __rtems__ */ |
---|
140 | struct dpaa_rx_errors rx_errors; |
---|
141 | struct dpaa_ern_cnt ern_cnt; |
---|
142 | }; |
---|
143 | |
---|
144 | struct dpaa_buffer_layout { |
---|
145 | u16 priv_data_size; |
---|
146 | }; |
---|
147 | |
---|
148 | struct dpaa_priv { |
---|
149 | struct dpaa_percpu_priv __percpu *percpu_priv; |
---|
150 | struct dpaa_bp *dpaa_bps[DPAA_BPS_NUM]; |
---|
151 | /* Store here the needed Tx headroom for convenience and speed |
---|
152 | * (even though it can be computed based on the fields of buf_layout) |
---|
153 | */ |
---|
154 | u16 tx_headroom; |
---|
155 | struct net_device *net_dev; |
---|
156 | struct mac_device *mac_dev; |
---|
157 | struct qman_fq *egress_fqs[DPAA_ETH_TXQ_NUM]; |
---|
158 | struct qman_fq *conf_fqs[DPAA_ETH_TXQ_NUM]; |
---|
159 | |
---|
160 | u16 channel; |
---|
161 | struct list_head dpaa_fq_list; |
---|
162 | |
---|
163 | #ifndef __rtems__ |
---|
164 | u32 msg_enable; /* net_device message level */ |
---|
165 | #endif /* __rtems__ */ |
---|
166 | |
---|
167 | struct { |
---|
168 | /* All egress queues to a given net device belong to one |
---|
169 | * (and the same) congestion group. |
---|
170 | */ |
---|
171 | struct qman_cgr cgr; |
---|
172 | /* If congested, when it began. Used for performance stats. */ |
---|
173 | u32 congestion_start_jiffies; |
---|
174 | /* Number of jiffies the Tx port was congested. */ |
---|
175 | u32 congested_jiffies; |
---|
176 | /* Counter for the number of times the CGR |
---|
177 | * entered congestion state |
---|
178 | */ |
---|
179 | u32 cgr_congested_count; |
---|
180 | } cgr_data; |
---|
181 | /* Use a per-port CGR for ingress traffic. */ |
---|
182 | bool use_ingress_cgr; |
---|
183 | struct qman_cgr ingress_cgr; |
---|
184 | |
---|
185 | struct dpaa_buffer_layout buf_layout[2]; |
---|
186 | u16 rx_headroom; |
---|
187 | }; |
---|
188 | |
---|
189 | /* from dpaa_ethtool.c */ |
---|
190 | extern const struct ethtool_ops dpaa_ethtool_ops; |
---|
191 | |
---|
192 | /* from dpaa_eth_sysfs.c */ |
---|
193 | void dpaa_eth_sysfs_remove(struct device *dev); |
---|
194 | void dpaa_eth_sysfs_init(struct device *dev); |
---|
195 | #ifdef __rtems__ |
---|
196 | #include <sys/mbuf.h> |
---|
197 | |
---|
198 | #define DPAA_ENQUEUE_RETRIES 100000 |
---|
199 | #define DPAA_SGT_MAX_ENTRIES 16 |
---|
200 | #define DPAA_TX_PRIV_DATA_SIZE 16 |
---|
201 | #define FM_L3_PARSE_RESULT_IPV4 0x8000 |
---|
202 | #define FM_L3_PARSE_RESULT_IPV6 0x4000 |
---|
203 | #define FM_L4_PARSE_RESULT_UDP 0x40 |
---|
204 | #define FM_L4_PARSE_RESULT_TCP 0x20 |
---|
205 | #define FSL_DPAA_BPID_INV 0xff |
---|
206 | |
---|
207 | void dpaa_cleanup_tx_fd(struct ifnet *ifp, const struct qm_fd *fd); |
---|
208 | #endif /* __rtems__ */ |
---|
209 | #endif /* __DPAA_H */ |
---|