1 /* Copyright 2008 - 2016 Freescale Semiconductor Inc.
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.
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
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.
34 #include <linux/netdevice.h>
35 #include <linux/refcount.h>
36 #include <soc/fsl/qman.h>
37 #include <soc/fsl/bman.h>
41 #include "dpaa_eth_trace.h"
43 /* Number of prioritised traffic classes */
45 /* Number of Tx queues per traffic class */
46 #define DPAA_TC_TXQ_NUM NR_CPUS
47 /* Total number of Tx queues */
48 #define DPAA_ETH_TXQ_NUM (DPAA_TC_NUM * DPAA_TC_TXQ_NUM)
50 /* More detailed FQ types - used for fine-grained WQ assignments */
52 FQ_TYPE_RX_DEFAULT
= 1, /* Rx Default FQs */
53 FQ_TYPE_RX_ERROR
, /* Rx Error FQs */
54 FQ_TYPE_RX_PCD
, /* Rx Parse Classify Distribute FQs */
55 FQ_TYPE_TX
, /* "Real" Tx FQs */
56 FQ_TYPE_TX_CONFIRM
, /* Tx default Conf FQ (actually an Rx FQ) */
57 FQ_TYPE_TX_CONF_MQ
, /* Tx conf FQs (one for each Tx FQ) */
58 FQ_TYPE_TX_ERROR
, /* Tx Error FQs (these are actually Rx FQs) */
62 struct qman_fq fq_base
;
63 struct list_head list
;
64 struct net_device
*net_dev
;
70 enum dpaa_fq_type fq_type
;
71 struct xdp_rxq_info xdp_rxq
;
75 struct qman_fq rx_defq
;
76 struct qman_fq tx_defq
;
77 struct qman_fq rx_errq
;
78 struct qman_fq tx_errq
;
79 struct qman_fq egress_ern
;
85 /* used in the DMA mapping operations */
86 struct dpaa_priv
*priv
;
87 /* current number of buffers in the buffer pool alloted to each CPU */
88 int __percpu
*percpu_count
;
89 /* all buffers allocated for this pool have this raw size */
91 /* all buffers in this pool have this same usable size */
93 /* the buffer pools are initialized with config_count buffers for each
94 * CPU; at runtime the number of buffers per CPU is constantly brought
99 struct bman_pool
*pool
;
100 /* bpool can be seeded before use by this cb */
101 int (*seed_cb
)(struct dpaa_bp
*);
102 /* bpool can be emptied before freeing by this cb */
103 void (*free_buf_cb
)(const struct dpaa_bp
*, struct bm_buffer
*);
107 struct dpaa_rx_errors
{
108 u64 dme
; /* DMA Error */
109 u64 fpe
; /* Frame Physical Error */
110 u64 fse
; /* Frame Size Error */
111 u64 phe
; /* Header Error */
114 /* Counters for QMan ERN frames - one counter per rejection code */
115 struct dpaa_ern_cnt
{
116 u64 cg_tdrop
; /* Congestion group taildrop */
117 u64 wred
; /* WRED congestion */
118 u64 err_cond
; /* Error condition */
119 u64 early_window
; /* Order restoration, frame too early */
120 u64 late_window
; /* Order restoration, frame too late */
121 u64 fq_tdrop
; /* FQ taildrop */
122 u64 fq_retired
; /* FQ is retired */
123 u64 orp_zero
; /* ORP disabled */
126 struct dpaa_napi_portal
{
127 struct napi_struct napi
;
128 struct qman_portal
*p
;
133 struct dpaa_percpu_priv
{
134 struct net_device
*net_dev
;
135 struct dpaa_napi_portal np
;
138 /* fragmented (non-linear) skbuffs received from the stack */
140 struct rtnl_link_stats64 stats
;
141 struct dpaa_rx_errors rx_errors
;
142 struct dpaa_ern_cnt ern_cnt
;
145 struct dpaa_buffer_layout
{
149 /* Information to be used on the Tx confirmation path. Stored just
150 * before the start of the transmit buffer. Maximum size allowed
151 * is DPAA_TX_PRIV_DATA_SIZE bytes.
153 struct dpaa_eth_swbp
{
155 struct xdp_frame
*xdpf
;
159 struct dpaa_percpu_priv __percpu
*percpu_priv
;
160 struct dpaa_bp
*dpaa_bp
;
161 /* Store here the needed Tx headroom for convenience and speed
162 * (even though it can be computed based on the fields of buf_layout)
165 struct net_device
*net_dev
;
166 struct mac_device
*mac_dev
;
167 struct device
*rx_dma_dev
;
168 struct device
*tx_dma_dev
;
169 struct qman_fq
*egress_fqs
[DPAA_ETH_TXQ_NUM
];
170 struct qman_fq
*conf_fqs
[DPAA_ETH_TXQ_NUM
];
173 struct list_head dpaa_fq_list
;
177 u32 msg_enable
; /* net_device message level */
180 /* All egress queues to a given net device belong to one
181 * (and the same) congestion group.
184 /* If congested, when it began. Used for performance stats. */
185 u32 congestion_start_jiffies
;
186 /* Number of jiffies the Tx port was congested. */
187 u32 congested_jiffies
;
188 /* Counter for the number of times the CGR
189 * entered congestion state
191 u32 cgr_congested_count
;
193 /* Use a per-port CGR for ingress traffic. */
194 bool use_ingress_cgr
;
195 struct qman_cgr ingress_cgr
;
197 struct dpaa_buffer_layout buf_layout
[2];
200 bool tx_tstamp
; /* Tx timestamping enabled */
201 bool rx_tstamp
; /* Rx timestamping enabled */
203 struct bpf_prog
*xdp_prog
;
206 /* from dpaa_ethtool.c */
207 extern const struct ethtool_ops dpaa_ethtool_ops
;
209 /* from dpaa_eth_sysfs.c */
210 void dpaa_eth_sysfs_remove(struct device
*dev
);
211 void dpaa_eth_sysfs_init(struct device
*dev
);
212 #endif /* __DPAA_H */