xref: /linux/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h (revision 109d2446052a484c58f07f71f9457bf7b71017f8)
1c27a02cdSYevgeny Petrilin /*
2c27a02cdSYevgeny Petrilin  * Copyright (c) 2007 Mellanox Technologies. All rights reserved.
3c27a02cdSYevgeny Petrilin  *
4c27a02cdSYevgeny Petrilin  * This software is available to you under a choice of one of two
5c27a02cdSYevgeny Petrilin  * licenses.  You may choose to be licensed under the terms of the GNU
6c27a02cdSYevgeny Petrilin  * General Public License (GPL) Version 2, available from the file
7c27a02cdSYevgeny Petrilin  * COPYING in the main directory of this source tree, or the
8c27a02cdSYevgeny Petrilin  * OpenIB.org BSD license below:
9c27a02cdSYevgeny Petrilin  *
10c27a02cdSYevgeny Petrilin  *     Redistribution and use in source and binary forms, with or
11c27a02cdSYevgeny Petrilin  *     without modification, are permitted provided that the following
12c27a02cdSYevgeny Petrilin  *     conditions are met:
13c27a02cdSYevgeny Petrilin  *
14c27a02cdSYevgeny Petrilin  *      - Redistributions of source code must retain the above
15c27a02cdSYevgeny Petrilin  *        copyright notice, this list of conditions and the following
16c27a02cdSYevgeny Petrilin  *        disclaimer.
17c27a02cdSYevgeny Petrilin  *
18c27a02cdSYevgeny Petrilin  *      - Redistributions in binary form must reproduce the above
19c27a02cdSYevgeny Petrilin  *        copyright notice, this list of conditions and the following
20c27a02cdSYevgeny Petrilin  *        disclaimer in the documentation and/or other materials
21c27a02cdSYevgeny Petrilin  *        provided with the distribution.
22c27a02cdSYevgeny Petrilin  *
23c27a02cdSYevgeny Petrilin  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24c27a02cdSYevgeny Petrilin  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25c27a02cdSYevgeny Petrilin  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26c27a02cdSYevgeny Petrilin  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27c27a02cdSYevgeny Petrilin  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28c27a02cdSYevgeny Petrilin  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29c27a02cdSYevgeny Petrilin  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30c27a02cdSYevgeny Petrilin  * SOFTWARE.
31c27a02cdSYevgeny Petrilin  *
32c27a02cdSYevgeny Petrilin  */
33c27a02cdSYevgeny Petrilin 
34c27a02cdSYevgeny Petrilin #ifndef _MLX4_EN_H_
35c27a02cdSYevgeny Petrilin #define _MLX4_EN_H_
36c27a02cdSYevgeny Petrilin 
37f1b553fbSJiri Pirko #include <linux/bitops.h>
38c27a02cdSYevgeny Petrilin #include <linux/compiler.h>
39c27a02cdSYevgeny Petrilin #include <linux/list.h>
40c27a02cdSYevgeny Petrilin #include <linux/mutex.h>
41c27a02cdSYevgeny Petrilin #include <linux/netdevice.h>
42f1b553fbSJiri Pirko #include <linux/if_vlan.h>
43564c274cSAmir Vadai #ifdef CONFIG_MLX4_EN_DCB
44564c274cSAmir Vadai #include <linux/dcbnl.h>
45564c274cSAmir Vadai #endif
46c27a02cdSYevgeny Petrilin 
47c27a02cdSYevgeny Petrilin #include <linux/mlx4/device.h>
48c27a02cdSYevgeny Petrilin #include <linux/mlx4/qp.h>
49c27a02cdSYevgeny Petrilin #include <linux/mlx4/cq.h>
50c27a02cdSYevgeny Petrilin #include <linux/mlx4/srq.h>
51c27a02cdSYevgeny Petrilin #include <linux/mlx4/doorbell.h>
52e7c1c2c4SYevgeny Petrilin #include <linux/mlx4/cmd.h>
53c27a02cdSYevgeny Petrilin 
54c27a02cdSYevgeny Petrilin #include "en_port.h"
55c27a02cdSYevgeny Petrilin 
56c27a02cdSYevgeny Petrilin #define DRV_NAME	"mlx4_en"
576edf91daSYevgeny Petrilin #define DRV_VERSION	"2.0"
586edf91daSYevgeny Petrilin #define DRV_RELDATE	"Dec 2011"
59c27a02cdSYevgeny Petrilin 
60c27a02cdSYevgeny Petrilin #define MLX4_EN_MSG_LEVEL	(NETIF_MSG_LINK | NETIF_MSG_IFDOWN)
61c27a02cdSYevgeny Petrilin 
62c27a02cdSYevgeny Petrilin /*
63c27a02cdSYevgeny Petrilin  * Device constants
64c27a02cdSYevgeny Petrilin  */
65c27a02cdSYevgeny Petrilin 
66c27a02cdSYevgeny Petrilin 
67c27a02cdSYevgeny Petrilin #define MLX4_EN_PAGE_SHIFT	12
68c27a02cdSYevgeny Petrilin #define MLX4_EN_PAGE_SIZE	(1 << MLX4_EN_PAGE_SHIFT)
69c27a02cdSYevgeny Petrilin #define MAX_RX_RINGS		16
701fb9876eSYevgeny Petrilin #define MIN_RX_RINGS		4
71c27a02cdSYevgeny Petrilin #define TXBB_SIZE		64
72c27a02cdSYevgeny Petrilin #define HEADROOM		(2048 / TXBB_SIZE + 1)
73c27a02cdSYevgeny Petrilin #define STAMP_STRIDE		64
74c27a02cdSYevgeny Petrilin #define STAMP_DWORDS		(STAMP_STRIDE / 4)
75c27a02cdSYevgeny Petrilin #define STAMP_SHIFT		31
76c27a02cdSYevgeny Petrilin #define STAMP_VAL		0x7fffffff
77c27a02cdSYevgeny Petrilin #define STATS_DELAY		(HZ / 4)
78c27a02cdSYevgeny Petrilin 
79c27a02cdSYevgeny Petrilin /* Typical TSO descriptor with 16 gather entries is 352 bytes... */
80c27a02cdSYevgeny Petrilin #define MAX_DESC_SIZE		512
81c27a02cdSYevgeny Petrilin #define MAX_DESC_TXBBS		(MAX_DESC_SIZE / TXBB_SIZE)
82c27a02cdSYevgeny Petrilin 
83c27a02cdSYevgeny Petrilin /*
84c27a02cdSYevgeny Petrilin  * OS related constants and tunables
85c27a02cdSYevgeny Petrilin  */
86c27a02cdSYevgeny Petrilin 
87c27a02cdSYevgeny Petrilin #define MLX4_EN_WATCHDOG_TIMEOUT	(15 * HZ)
88c27a02cdSYevgeny Petrilin 
89c27a02cdSYevgeny Petrilin #define MLX4_EN_ALLOC_ORDER	2
90c27a02cdSYevgeny Petrilin #define MLX4_EN_ALLOC_SIZE	(PAGE_SIZE << MLX4_EN_ALLOC_ORDER)
91c27a02cdSYevgeny Petrilin 
92c27a02cdSYevgeny Petrilin #define MLX4_EN_MAX_LRO_DESCRIPTORS	32
93c27a02cdSYevgeny Petrilin 
94c27a02cdSYevgeny Petrilin /* Receive fragment sizes; we use at most 4 fragments (for 9600 byte MTU
95c27a02cdSYevgeny Petrilin  * and 4K allocations) */
96c27a02cdSYevgeny Petrilin enum {
97c27a02cdSYevgeny Petrilin 	FRAG_SZ0 = 512 - NET_IP_ALIGN,
98c27a02cdSYevgeny Petrilin 	FRAG_SZ1 = 1024,
99c27a02cdSYevgeny Petrilin 	FRAG_SZ2 = 4096,
100c27a02cdSYevgeny Petrilin 	FRAG_SZ3 = MLX4_EN_ALLOC_SIZE
101c27a02cdSYevgeny Petrilin };
102c27a02cdSYevgeny Petrilin #define MLX4_EN_MAX_RX_FRAGS	4
103c27a02cdSYevgeny Petrilin 
104bd531e36SYevgeny Petrilin /* Maximum ring sizes */
105bd531e36SYevgeny Petrilin #define MLX4_EN_MAX_TX_SIZE	8192
106bd531e36SYevgeny Petrilin #define MLX4_EN_MAX_RX_SIZE	8192
107bd531e36SYevgeny Petrilin 
108c27a02cdSYevgeny Petrilin /* Minimum ring size for our page-allocation sceme to work */
109c27a02cdSYevgeny Petrilin #define MLX4_EN_MIN_RX_SIZE	(MLX4_EN_ALLOC_SIZE / SMP_CACHE_BYTES)
110c27a02cdSYevgeny Petrilin #define MLX4_EN_MIN_TX_SIZE	(4096 / TXBB_SIZE)
111c27a02cdSYevgeny Petrilin 
112f813cad8SYevgeny Petrilin #define MLX4_EN_SMALL_PKT_SIZE		64
113f813cad8SYevgeny Petrilin #define MLX4_EN_NUM_TX_RINGS		8
114f813cad8SYevgeny Petrilin #define MLX4_EN_NUM_PPP_RINGS		8
115a0b4e6e0SYevgeny Petrilin #define MAX_TX_RINGS			(MLX4_EN_NUM_TX_RINGS + MLX4_EN_NUM_PPP_RINGS)
116564c274cSAmir Vadai #define MLX4_EN_NUM_UP			8
117f813cad8SYevgeny Petrilin #define MLX4_EN_DEF_TX_RING_SIZE	512
118c27a02cdSYevgeny Petrilin #define MLX4_EN_DEF_RX_RING_SIZE  	1024
119c27a02cdSYevgeny Petrilin 
1203db36fb2SYevgeny Petrilin /* Target number of packets to coalesce with interrupt moderation */
1213db36fb2SYevgeny Petrilin #define MLX4_EN_RX_COAL_TARGET	44
122c27a02cdSYevgeny Petrilin #define MLX4_EN_RX_COAL_TIME	0x10
123c27a02cdSYevgeny Petrilin 
124c27a02cdSYevgeny Petrilin #define MLX4_EN_TX_COAL_PKTS	5
125c27a02cdSYevgeny Petrilin #define MLX4_EN_TX_COAL_TIME	0x80
126c27a02cdSYevgeny Petrilin 
127c27a02cdSYevgeny Petrilin #define MLX4_EN_RX_RATE_LOW		400000
128c27a02cdSYevgeny Petrilin #define MLX4_EN_RX_COAL_TIME_LOW	0
129c27a02cdSYevgeny Petrilin #define MLX4_EN_RX_RATE_HIGH		450000
130c27a02cdSYevgeny Petrilin #define MLX4_EN_RX_COAL_TIME_HIGH	128
131c27a02cdSYevgeny Petrilin #define MLX4_EN_RX_SIZE_THRESH		1024
132c27a02cdSYevgeny Petrilin #define MLX4_EN_RX_RATE_THRESH		(1000000 / MLX4_EN_RX_COAL_TIME_HIGH)
133c27a02cdSYevgeny Petrilin #define MLX4_EN_SAMPLE_INTERVAL		0
13446afd0fbSYevgeny Petrilin #define MLX4_EN_AVG_PKT_SMALL		256
135c27a02cdSYevgeny Petrilin 
136c27a02cdSYevgeny Petrilin #define MLX4_EN_AUTO_CONF	0xffff
137c27a02cdSYevgeny Petrilin 
138c27a02cdSYevgeny Petrilin #define MLX4_EN_DEF_RX_PAUSE	1
139c27a02cdSYevgeny Petrilin #define MLX4_EN_DEF_TX_PAUSE	1
140c27a02cdSYevgeny Petrilin 
141af901ca1SAndré Goddard Rosa /* Interval between successive polls in the Tx routine when polling is used
142c27a02cdSYevgeny Petrilin    instead of interrupts (in per-core Tx rings) - should be power of 2 */
143c27a02cdSYevgeny Petrilin #define MLX4_EN_TX_POLL_MODER	16
144c27a02cdSYevgeny Petrilin #define MLX4_EN_TX_POLL_TIMEOUT	(HZ / 4)
145c27a02cdSYevgeny Petrilin 
146c27a02cdSYevgeny Petrilin #define ETH_LLC_SNAP_SIZE	8
147c27a02cdSYevgeny Petrilin 
148c27a02cdSYevgeny Petrilin #define SMALL_PACKET_SIZE      (256 - NET_IP_ALIGN)
149c27a02cdSYevgeny Petrilin #define HEADER_COPY_SIZE       (128 - NET_IP_ALIGN)
150e7c1c2c4SYevgeny Petrilin #define MLX4_LOOPBACK_TEST_PAYLOAD (HEADER_COPY_SIZE - ETH_HLEN)
151c27a02cdSYevgeny Petrilin 
152c27a02cdSYevgeny Petrilin #define MLX4_EN_MIN_MTU		46
153c27a02cdSYevgeny Petrilin #define ETH_BCAST		0xffffffffffffULL
154c27a02cdSYevgeny Petrilin 
155e7c1c2c4SYevgeny Petrilin #define MLX4_EN_LOOPBACK_RETRIES	5
156e7c1c2c4SYevgeny Petrilin #define MLX4_EN_LOOPBACK_TIMEOUT	100
157e7c1c2c4SYevgeny Petrilin 
158c27a02cdSYevgeny Petrilin #ifdef MLX4_EN_PERF_STAT
159c27a02cdSYevgeny Petrilin /* Number of samples to 'average' */
160c27a02cdSYevgeny Petrilin #define AVG_SIZE			128
161c27a02cdSYevgeny Petrilin #define AVG_FACTOR			1024
162c27a02cdSYevgeny Petrilin #define NUM_PERF_STATS			NUM_PERF_COUNTERS
163c27a02cdSYevgeny Petrilin 
164c27a02cdSYevgeny Petrilin #define INC_PERF_COUNTER(cnt)		(++(cnt))
165c27a02cdSYevgeny Petrilin #define ADD_PERF_COUNTER(cnt, add)	((cnt) += (add))
166c27a02cdSYevgeny Petrilin #define AVG_PERF_COUNTER(cnt, sample) \
167c27a02cdSYevgeny Petrilin 	((cnt) = ((cnt) * (AVG_SIZE - 1) + (sample) * AVG_FACTOR) / AVG_SIZE)
168c27a02cdSYevgeny Petrilin #define GET_PERF_COUNTER(cnt)		(cnt)
169c27a02cdSYevgeny Petrilin #define GET_AVG_PERF_COUNTER(cnt)	((cnt) / AVG_FACTOR)
170c27a02cdSYevgeny Petrilin 
171c27a02cdSYevgeny Petrilin #else
172c27a02cdSYevgeny Petrilin 
173c27a02cdSYevgeny Petrilin #define NUM_PERF_STATS			0
174c27a02cdSYevgeny Petrilin #define INC_PERF_COUNTER(cnt)		do {} while (0)
175c27a02cdSYevgeny Petrilin #define ADD_PERF_COUNTER(cnt, add)	do {} while (0)
176c27a02cdSYevgeny Petrilin #define AVG_PERF_COUNTER(cnt, sample)	do {} while (0)
177c27a02cdSYevgeny Petrilin #define GET_PERF_COUNTER(cnt)		(0)
178c27a02cdSYevgeny Petrilin #define GET_AVG_PERF_COUNTER(cnt)	(0)
179c27a02cdSYevgeny Petrilin #endif /* MLX4_EN_PERF_STAT */
180c27a02cdSYevgeny Petrilin 
181c27a02cdSYevgeny Petrilin /*
182c27a02cdSYevgeny Petrilin  * Configurables
183c27a02cdSYevgeny Petrilin  */
184c27a02cdSYevgeny Petrilin 
185c27a02cdSYevgeny Petrilin enum cq_type {
186c27a02cdSYevgeny Petrilin 	RX = 0,
187c27a02cdSYevgeny Petrilin 	TX = 1,
188c27a02cdSYevgeny Petrilin };
189c27a02cdSYevgeny Petrilin 
190c27a02cdSYevgeny Petrilin 
191c27a02cdSYevgeny Petrilin /*
192c27a02cdSYevgeny Petrilin  * Useful macros
193c27a02cdSYevgeny Petrilin  */
194c27a02cdSYevgeny Petrilin #define ROUNDUP_LOG2(x)		ilog2(roundup_pow_of_two(x))
195c27a02cdSYevgeny Petrilin #define XNOR(x, y)		(!(x) == !(y))
196c27a02cdSYevgeny Petrilin #define ILLEGAL_MAC(addr)	(addr == 0xffffffffffffULL || addr == 0x0)
197c27a02cdSYevgeny Petrilin 
198c27a02cdSYevgeny Petrilin 
199c27a02cdSYevgeny Petrilin struct mlx4_en_tx_info {
200c27a02cdSYevgeny Petrilin 	struct sk_buff *skb;
201c27a02cdSYevgeny Petrilin 	u32 nr_txbb;
202c27a02cdSYevgeny Petrilin 	u8 linear;
203c27a02cdSYevgeny Petrilin 	u8 data_offset;
20441efea5aSYevgeny Petrilin 	u8 inl;
205c27a02cdSYevgeny Petrilin };
206c27a02cdSYevgeny Petrilin 
207c27a02cdSYevgeny Petrilin 
208c27a02cdSYevgeny Petrilin #define MLX4_EN_BIT_DESC_OWN	0x80000000
209c27a02cdSYevgeny Petrilin #define CTRL_SIZE	sizeof(struct mlx4_wqe_ctrl_seg)
210c27a02cdSYevgeny Petrilin #define MLX4_EN_MEMTYPE_PAD	0x100
211c27a02cdSYevgeny Petrilin #define DS_SIZE		sizeof(struct mlx4_wqe_data_seg)
212c27a02cdSYevgeny Petrilin 
213c27a02cdSYevgeny Petrilin 
214c27a02cdSYevgeny Petrilin struct mlx4_en_tx_desc {
215c27a02cdSYevgeny Petrilin 	struct mlx4_wqe_ctrl_seg ctrl;
216c27a02cdSYevgeny Petrilin 	union {
217c27a02cdSYevgeny Petrilin 		struct mlx4_wqe_data_seg data; /* at least one data segment */
218c27a02cdSYevgeny Petrilin 		struct mlx4_wqe_lso_seg lso;
219c27a02cdSYevgeny Petrilin 		struct mlx4_wqe_inline_seg inl;
220c27a02cdSYevgeny Petrilin 	};
221c27a02cdSYevgeny Petrilin };
222c27a02cdSYevgeny Petrilin 
223c27a02cdSYevgeny Petrilin #define MLX4_EN_USE_SRQ		0x01000000
224c27a02cdSYevgeny Petrilin 
225725c8999SYevgeny Petrilin #define MLX4_EN_CX3_LOW_ID	0x1000
226725c8999SYevgeny Petrilin #define MLX4_EN_CX3_HIGH_ID	0x1005
227725c8999SYevgeny Petrilin 
228c27a02cdSYevgeny Petrilin struct mlx4_en_rx_alloc {
229c27a02cdSYevgeny Petrilin 	struct page *page;
230c27a02cdSYevgeny Petrilin 	u16 offset;
231c27a02cdSYevgeny Petrilin };
232c27a02cdSYevgeny Petrilin 
233c27a02cdSYevgeny Petrilin struct mlx4_en_tx_ring {
234c27a02cdSYevgeny Petrilin 	struct mlx4_hwq_resources wqres;
235c27a02cdSYevgeny Petrilin 	u32 size ; /* number of TXBBs */
236c27a02cdSYevgeny Petrilin 	u32 size_mask;
237c27a02cdSYevgeny Petrilin 	u16 stride;
238c27a02cdSYevgeny Petrilin 	u16 cqn;	/* index of port CQ associated with this ring */
239c27a02cdSYevgeny Petrilin 	u32 prod;
240c27a02cdSYevgeny Petrilin 	u32 cons;
241c27a02cdSYevgeny Petrilin 	u32 buf_size;
242c27a02cdSYevgeny Petrilin 	u32 doorbell_qpn;
243c27a02cdSYevgeny Petrilin 	void *buf;
244c27a02cdSYevgeny Petrilin 	u16 poll_cnt;
245c27a02cdSYevgeny Petrilin 	int blocked;
246c27a02cdSYevgeny Petrilin 	struct mlx4_en_tx_info *tx_info;
247c27a02cdSYevgeny Petrilin 	u8 *bounce_buf;
248c27a02cdSYevgeny Petrilin 	u32 last_nr_txbb;
249c27a02cdSYevgeny Petrilin 	struct mlx4_qp qp;
250c27a02cdSYevgeny Petrilin 	struct mlx4_qp_context context;
251c27a02cdSYevgeny Petrilin 	int qpn;
252c27a02cdSYevgeny Petrilin 	enum mlx4_qp_state qp_state;
253c27a02cdSYevgeny Petrilin 	struct mlx4_srq dummy;
254c27a02cdSYevgeny Petrilin 	unsigned long bytes;
255c27a02cdSYevgeny Petrilin 	unsigned long packets;
256ad04378cSYevgeny Petrilin 	unsigned long tx_csum;
257c27a02cdSYevgeny Petrilin 	spinlock_t comp_lock;
25887a5c389SYevgeny Petrilin 	struct mlx4_bf bf;
25987a5c389SYevgeny Petrilin 	bool bf_enabled;
260c27a02cdSYevgeny Petrilin };
261c27a02cdSYevgeny Petrilin 
262c27a02cdSYevgeny Petrilin struct mlx4_en_rx_desc {
263c27a02cdSYevgeny Petrilin 	/* actual number of entries depends on rx ring stride */
264c27a02cdSYevgeny Petrilin 	struct mlx4_wqe_data_seg data[0];
265c27a02cdSYevgeny Petrilin };
266c27a02cdSYevgeny Petrilin 
267c27a02cdSYevgeny Petrilin struct mlx4_en_rx_ring {
268c27a02cdSYevgeny Petrilin 	struct mlx4_hwq_resources wqres;
269c27a02cdSYevgeny Petrilin 	struct mlx4_en_rx_alloc page_alloc[MLX4_EN_MAX_RX_FRAGS];
270c27a02cdSYevgeny Petrilin 	u32 size ;	/* number of Rx descs*/
271c27a02cdSYevgeny Petrilin 	u32 actual_size;
272c27a02cdSYevgeny Petrilin 	u32 size_mask;
273c27a02cdSYevgeny Petrilin 	u16 stride;
274c27a02cdSYevgeny Petrilin 	u16 log_stride;
275c27a02cdSYevgeny Petrilin 	u16 cqn;	/* index of port CQ associated with this ring */
276c27a02cdSYevgeny Petrilin 	u32 prod;
277c27a02cdSYevgeny Petrilin 	u32 cons;
278c27a02cdSYevgeny Petrilin 	u32 buf_size;
2794a5f4dd8SYevgeny Petrilin 	u8  fcs_del;
280c27a02cdSYevgeny Petrilin 	void *buf;
281c27a02cdSYevgeny Petrilin 	void *rx_info;
282c27a02cdSYevgeny Petrilin 	unsigned long bytes;
283c27a02cdSYevgeny Petrilin 	unsigned long packets;
284ad04378cSYevgeny Petrilin 	unsigned long csum_ok;
285ad04378cSYevgeny Petrilin 	unsigned long csum_none;
286c27a02cdSYevgeny Petrilin };
287c27a02cdSYevgeny Petrilin 
288c27a02cdSYevgeny Petrilin 
289c27a02cdSYevgeny Petrilin static inline int mlx4_en_can_lro(__be16 status)
290c27a02cdSYevgeny Petrilin {
291c27a02cdSYevgeny Petrilin 	return (status & cpu_to_be16(MLX4_CQE_STATUS_IPV4	|
292c27a02cdSYevgeny Petrilin 				     MLX4_CQE_STATUS_IPV4F	|
293c27a02cdSYevgeny Petrilin 				     MLX4_CQE_STATUS_IPV6	|
294c27a02cdSYevgeny Petrilin 				     MLX4_CQE_STATUS_IPV4OPT	|
295c27a02cdSYevgeny Petrilin 				     MLX4_CQE_STATUS_TCP	|
296c27a02cdSYevgeny Petrilin 				     MLX4_CQE_STATUS_UDP	|
297c27a02cdSYevgeny Petrilin 				     MLX4_CQE_STATUS_IPOK)) ==
298c27a02cdSYevgeny Petrilin 		cpu_to_be16(MLX4_CQE_STATUS_IPV4 |
299c27a02cdSYevgeny Petrilin 			    MLX4_CQE_STATUS_IPOK |
300c27a02cdSYevgeny Petrilin 			    MLX4_CQE_STATUS_TCP);
301c27a02cdSYevgeny Petrilin }
302c27a02cdSYevgeny Petrilin 
303c27a02cdSYevgeny Petrilin struct mlx4_en_cq {
304c27a02cdSYevgeny Petrilin 	struct mlx4_cq          mcq;
305c27a02cdSYevgeny Petrilin 	struct mlx4_hwq_resources wqres;
306c27a02cdSYevgeny Petrilin 	int                     ring;
307c27a02cdSYevgeny Petrilin 	spinlock_t              lock;
308c27a02cdSYevgeny Petrilin 	struct net_device      *dev;
309c27a02cdSYevgeny Petrilin 	struct napi_struct	napi;
310c27a02cdSYevgeny Petrilin 	/* Per-core Tx cq processing support */
311c27a02cdSYevgeny Petrilin 	struct timer_list timer;
312c27a02cdSYevgeny Petrilin 	int size;
313c27a02cdSYevgeny Petrilin 	int buf_size;
314c27a02cdSYevgeny Petrilin 	unsigned vector;
315c27a02cdSYevgeny Petrilin 	enum cq_type is_tx;
316c27a02cdSYevgeny Petrilin 	u16 moder_time;
317c27a02cdSYevgeny Petrilin 	u16 moder_cnt;
318c27a02cdSYevgeny Petrilin 	struct mlx4_cqe *buf;
319c27a02cdSYevgeny Petrilin #define MLX4_EN_OPCODE_ERROR	0x1e
320c27a02cdSYevgeny Petrilin };
321c27a02cdSYevgeny Petrilin 
322c27a02cdSYevgeny Petrilin struct mlx4_en_port_profile {
323c27a02cdSYevgeny Petrilin 	u32 flags;
324c27a02cdSYevgeny Petrilin 	u32 tx_ring_num;
325c27a02cdSYevgeny Petrilin 	u32 rx_ring_num;
326c27a02cdSYevgeny Petrilin 	u32 tx_ring_size;
327c27a02cdSYevgeny Petrilin 	u32 rx_ring_size;
328d53b93f2SYevgeny Petrilin 	u8 rx_pause;
329d53b93f2SYevgeny Petrilin 	u8 rx_ppp;
330d53b93f2SYevgeny Petrilin 	u8 tx_pause;
331d53b93f2SYevgeny Petrilin 	u8 tx_ppp;
33293d3e367SYevgeny Petrilin 	int rss_rings;
333c27a02cdSYevgeny Petrilin };
334c27a02cdSYevgeny Petrilin 
335c27a02cdSYevgeny Petrilin struct mlx4_en_profile {
336c27a02cdSYevgeny Petrilin 	int rss_xor;
3370533943cSYevgeny Petrilin 	int udp_rss;
338c27a02cdSYevgeny Petrilin 	u8 rss_mask;
339c27a02cdSYevgeny Petrilin 	u32 active_ports;
340c27a02cdSYevgeny Petrilin 	u32 small_pkt_int;
341c27a02cdSYevgeny Petrilin 	u8 no_reset;
342c27a02cdSYevgeny Petrilin 	struct mlx4_en_port_profile prof[MLX4_MAX_PORTS + 1];
343c27a02cdSYevgeny Petrilin };
344c27a02cdSYevgeny Petrilin 
345c27a02cdSYevgeny Petrilin struct mlx4_en_dev {
346c27a02cdSYevgeny Petrilin 	struct mlx4_dev         *dev;
347c27a02cdSYevgeny Petrilin 	struct pci_dev		*pdev;
348c27a02cdSYevgeny Petrilin 	struct mutex		state_lock;
349c27a02cdSYevgeny Petrilin 	struct net_device       *pndev[MLX4_MAX_PORTS + 1];
350c27a02cdSYevgeny Petrilin 	u32                     port_cnt;
351c27a02cdSYevgeny Petrilin 	bool			device_up;
352c27a02cdSYevgeny Petrilin 	struct mlx4_en_profile  profile;
353c27a02cdSYevgeny Petrilin 	u32			LSO_support;
354c27a02cdSYevgeny Petrilin 	struct workqueue_struct *workqueue;
355c27a02cdSYevgeny Petrilin 	struct device           *dma_device;
356c27a02cdSYevgeny Petrilin 	void __iomem            *uar_map;
357c27a02cdSYevgeny Petrilin 	struct mlx4_uar         priv_uar;
358c27a02cdSYevgeny Petrilin 	struct mlx4_mr		mr;
359c27a02cdSYevgeny Petrilin 	u32                     priv_pdn;
360c27a02cdSYevgeny Petrilin 	spinlock_t              uar_lock;
361d7e1a487SYevgeny Petrilin 	u8			mac_removed[MLX4_MAX_PORTS + 1];
362c27a02cdSYevgeny Petrilin };
363c27a02cdSYevgeny Petrilin 
364c27a02cdSYevgeny Petrilin 
365c27a02cdSYevgeny Petrilin struct mlx4_en_rss_map {
366c27a02cdSYevgeny Petrilin 	int base_qpn;
367b6b912e0SYevgeny Petrilin 	struct mlx4_qp qps[MAX_RX_RINGS];
368b6b912e0SYevgeny Petrilin 	enum mlx4_qp_state state[MAX_RX_RINGS];
369c27a02cdSYevgeny Petrilin 	struct mlx4_qp indir_qp;
370c27a02cdSYevgeny Petrilin 	enum mlx4_qp_state indir_state;
371c27a02cdSYevgeny Petrilin };
372c27a02cdSYevgeny Petrilin 
373e7c1c2c4SYevgeny Petrilin struct mlx4_en_port_state {
374e7c1c2c4SYevgeny Petrilin 	int link_state;
375e7c1c2c4SYevgeny Petrilin 	int link_speed;
376e7c1c2c4SYevgeny Petrilin 	int transciver;
377e7c1c2c4SYevgeny Petrilin };
378e7c1c2c4SYevgeny Petrilin 
379c27a02cdSYevgeny Petrilin struct mlx4_en_pkt_stats {
380c27a02cdSYevgeny Petrilin 	unsigned long broadcast;
381c27a02cdSYevgeny Petrilin 	unsigned long rx_prio[8];
382c27a02cdSYevgeny Petrilin 	unsigned long tx_prio[8];
383c27a02cdSYevgeny Petrilin #define NUM_PKT_STATS		17
384c27a02cdSYevgeny Petrilin };
385c27a02cdSYevgeny Petrilin 
386c27a02cdSYevgeny Petrilin struct mlx4_en_port_stats {
387c27a02cdSYevgeny Petrilin 	unsigned long tso_packets;
388c27a02cdSYevgeny Petrilin 	unsigned long queue_stopped;
389c27a02cdSYevgeny Petrilin 	unsigned long wake_queue;
390c27a02cdSYevgeny Petrilin 	unsigned long tx_timeout;
391c27a02cdSYevgeny Petrilin 	unsigned long rx_alloc_failed;
392c27a02cdSYevgeny Petrilin 	unsigned long rx_chksum_good;
393c27a02cdSYevgeny Petrilin 	unsigned long rx_chksum_none;
394c27a02cdSYevgeny Petrilin 	unsigned long tx_chksum_offload;
395d61702f1SYevgeny Petrilin #define NUM_PORT_STATS		8
396c27a02cdSYevgeny Petrilin };
397c27a02cdSYevgeny Petrilin 
398c27a02cdSYevgeny Petrilin struct mlx4_en_perf_stats {
399c27a02cdSYevgeny Petrilin 	u32 tx_poll;
400c27a02cdSYevgeny Petrilin 	u64 tx_pktsz_avg;
401c27a02cdSYevgeny Petrilin 	u32 inflight_avg;
402c27a02cdSYevgeny Petrilin 	u16 tx_coal_avg;
403c27a02cdSYevgeny Petrilin 	u16 rx_coal_avg;
404c27a02cdSYevgeny Petrilin 	u32 napi_quota;
405c27a02cdSYevgeny Petrilin #define NUM_PERF_COUNTERS		6
406c27a02cdSYevgeny Petrilin };
407c27a02cdSYevgeny Petrilin 
408c27a02cdSYevgeny Petrilin struct mlx4_en_frag_info {
409c27a02cdSYevgeny Petrilin 	u16 frag_size;
410c27a02cdSYevgeny Petrilin 	u16 frag_prefix_size;
411c27a02cdSYevgeny Petrilin 	u16 frag_stride;
412c27a02cdSYevgeny Petrilin 	u16 frag_align;
413c27a02cdSYevgeny Petrilin 	u16 last_offset;
414c27a02cdSYevgeny Petrilin 
415c27a02cdSYevgeny Petrilin };
416c27a02cdSYevgeny Petrilin 
417564c274cSAmir Vadai #ifdef CONFIG_MLX4_EN_DCB
418564c274cSAmir Vadai /* Minimal TC BW - setting to 0 will block traffic */
419564c274cSAmir Vadai #define MLX4_EN_BW_MIN 1
420564c274cSAmir Vadai #define MLX4_EN_BW_MAX 100 /* Utilize 100% of the line */
421564c274cSAmir Vadai 
422564c274cSAmir Vadai #define MLX4_EN_TC_ETS 7
423564c274cSAmir Vadai 
424564c274cSAmir Vadai #endif
425564c274cSAmir Vadai 
426c27a02cdSYevgeny Petrilin struct mlx4_en_priv {
427c27a02cdSYevgeny Petrilin 	struct mlx4_en_dev *mdev;
428c27a02cdSYevgeny Petrilin 	struct mlx4_en_port_profile *prof;
429c27a02cdSYevgeny Petrilin 	struct net_device *dev;
430f1b553fbSJiri Pirko 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
431c27a02cdSYevgeny Petrilin 	struct net_device_stats stats;
432c27a02cdSYevgeny Petrilin 	struct net_device_stats ret_stats;
433e7c1c2c4SYevgeny Petrilin 	struct mlx4_en_port_state port_state;
434c27a02cdSYevgeny Petrilin 	spinlock_t stats_lock;
435c27a02cdSYevgeny Petrilin 
4366b4d8d9fSAlexander Guller 	unsigned long last_moder_packets[MAX_RX_RINGS];
437c27a02cdSYevgeny Petrilin 	unsigned long last_moder_tx_packets;
4386b4d8d9fSAlexander Guller 	unsigned long last_moder_bytes[MAX_RX_RINGS];
439c27a02cdSYevgeny Petrilin 	unsigned long last_moder_jiffies;
4406b4d8d9fSAlexander Guller 	int last_moder_time[MAX_RX_RINGS];
441c27a02cdSYevgeny Petrilin 	u16 rx_usecs;
442c27a02cdSYevgeny Petrilin 	u16 rx_frames;
443c27a02cdSYevgeny Petrilin 	u16 tx_usecs;
444c27a02cdSYevgeny Petrilin 	u16 tx_frames;
445c27a02cdSYevgeny Petrilin 	u32 pkt_rate_low;
446c27a02cdSYevgeny Petrilin 	u16 rx_usecs_low;
447c27a02cdSYevgeny Petrilin 	u32 pkt_rate_high;
448c27a02cdSYevgeny Petrilin 	u16 rx_usecs_high;
449c27a02cdSYevgeny Petrilin 	u16 sample_interval;
450c27a02cdSYevgeny Petrilin 	u16 adaptive_rx_coal;
451c27a02cdSYevgeny Petrilin 	u32 msg_enable;
452e7c1c2c4SYevgeny Petrilin 	u32 loopback_ok;
453e7c1c2c4SYevgeny Petrilin 	u32 validate_loopback;
454c27a02cdSYevgeny Petrilin 
455c27a02cdSYevgeny Petrilin 	struct mlx4_hwq_resources res;
456c27a02cdSYevgeny Petrilin 	int link_state;
457c27a02cdSYevgeny Petrilin 	int last_link_state;
458c27a02cdSYevgeny Petrilin 	bool port_up;
459c27a02cdSYevgeny Petrilin 	int port;
460c27a02cdSYevgeny Petrilin 	int registered;
461c27a02cdSYevgeny Petrilin 	int allocated;
462c27a02cdSYevgeny Petrilin 	int stride;
463c27a02cdSYevgeny Petrilin 	u64 mac;
464c27a02cdSYevgeny Petrilin 	int mac_index;
465c27a02cdSYevgeny Petrilin 	unsigned max_mtu;
466c27a02cdSYevgeny Petrilin 	int base_qpn;
467c27a02cdSYevgeny Petrilin 
468c27a02cdSYevgeny Petrilin 	struct mlx4_en_rss_map rss_map;
4694ef2a435SOr Gerlitz 	__be32 ctrl_flags;
470c27a02cdSYevgeny Petrilin 	u32 flags;
471c27a02cdSYevgeny Petrilin #define MLX4_EN_FLAG_PROMISC	0x1
4721679200fSYevgeny Petrilin #define MLX4_EN_FLAG_MC_PROMISC	0x2
473c27a02cdSYevgeny Petrilin 	u32 tx_ring_num;
474c27a02cdSYevgeny Petrilin 	u32 rx_ring_num;
475c27a02cdSYevgeny Petrilin 	u32 rx_skb_size;
476c27a02cdSYevgeny Petrilin 	struct mlx4_en_frag_info frag_info[MLX4_EN_MAX_RX_FRAGS];
477c27a02cdSYevgeny Petrilin 	u16 num_frags;
478c27a02cdSYevgeny Petrilin 	u16 log_rx_info;
479c27a02cdSYevgeny Petrilin 
480c27a02cdSYevgeny Petrilin 	struct mlx4_en_tx_ring tx_ring[MAX_TX_RINGS];
481c27a02cdSYevgeny Petrilin 	struct mlx4_en_rx_ring rx_ring[MAX_RX_RINGS];
482c27a02cdSYevgeny Petrilin 	struct mlx4_en_cq tx_cq[MAX_TX_RINGS];
483c27a02cdSYevgeny Petrilin 	struct mlx4_en_cq rx_cq[MAX_RX_RINGS];
484c27a02cdSYevgeny Petrilin 	struct work_struct mcast_task;
485c27a02cdSYevgeny Petrilin 	struct work_struct mac_task;
486c27a02cdSYevgeny Petrilin 	struct work_struct watchdog_task;
487c27a02cdSYevgeny Petrilin 	struct work_struct linkstate_task;
488c27a02cdSYevgeny Petrilin 	struct delayed_work stats_task;
489c27a02cdSYevgeny Petrilin 	struct mlx4_en_perf_stats pstats;
490c27a02cdSYevgeny Petrilin 	struct mlx4_en_pkt_stats pkstats;
491c27a02cdSYevgeny Petrilin 	struct mlx4_en_port_stats port_stats;
49293ece0c1SEugenia Emantayev 	u64 stats_bitmap;
493ff6e2163SJiri Pirko 	char *mc_addrs;
494ff6e2163SJiri Pirko 	int mc_addrs_cnt;
495c27a02cdSYevgeny Petrilin 	struct mlx4_en_stat_out_mbox hw_stats;
4964c3eb3caSEli Cohen 	int vids[128];
49714c07b13SYevgeny Petrilin 	bool wol;
498ebf8c9aaSYevgeny Petrilin 	struct device *ddev;
499564c274cSAmir Vadai 
500564c274cSAmir Vadai #ifdef CONFIG_MLX4_EN_DCB
501564c274cSAmir Vadai 	struct ieee_ets ets;
502*109d2446SAmir Vadai 	u16 maxrate[IEEE_8021QAZ_MAX_TCS];
503564c274cSAmir Vadai #endif
50414c07b13SYevgeny Petrilin };
50514c07b13SYevgeny Petrilin 
50614c07b13SYevgeny Petrilin enum mlx4_en_wol {
50714c07b13SYevgeny Petrilin 	MLX4_EN_WOL_MAGIC = (1ULL << 61),
50814c07b13SYevgeny Petrilin 	MLX4_EN_WOL_ENABLED = (1ULL << 62),
509c27a02cdSYevgeny Petrilin };
510c27a02cdSYevgeny Petrilin 
5110d9fdaa9SOr Gerlitz #define MLX4_EN_WOL_DO_MODIFY (1ULL << 63)
512c27a02cdSYevgeny Petrilin 
513c27a02cdSYevgeny Petrilin void mlx4_en_destroy_netdev(struct net_device *dev);
514c27a02cdSYevgeny Petrilin int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
515c27a02cdSYevgeny Petrilin 			struct mlx4_en_port_profile *prof);
516c27a02cdSYevgeny Petrilin 
51718cc42a3SYevgeny Petrilin int mlx4_en_start_port(struct net_device *dev);
51818cc42a3SYevgeny Petrilin void mlx4_en_stop_port(struct net_device *dev);
51918cc42a3SYevgeny Petrilin 
520fe0af03cSAlexander Guller void mlx4_en_free_resources(struct mlx4_en_priv *priv);
52118cc42a3SYevgeny Petrilin int mlx4_en_alloc_resources(struct mlx4_en_priv *priv);
52218cc42a3SYevgeny Petrilin 
523c27a02cdSYevgeny Petrilin int mlx4_en_create_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
524c27a02cdSYevgeny Petrilin 		      int entries, int ring, enum cq_type mode);
525fe0af03cSAlexander Guller void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
52676532d0cSAlexander Guller int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
52776532d0cSAlexander Guller 			int cq_idx);
528c27a02cdSYevgeny Petrilin void mlx4_en_deactivate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
529c27a02cdSYevgeny Petrilin int mlx4_en_set_cq_moder(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
530c27a02cdSYevgeny Petrilin int mlx4_en_arm_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
531c27a02cdSYevgeny Petrilin 
532c27a02cdSYevgeny Petrilin void mlx4_en_poll_tx_cq(unsigned long data);
533c27a02cdSYevgeny Petrilin void mlx4_en_tx_irq(struct mlx4_cq *mcq);
534f813cad8SYevgeny Petrilin u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb);
53561357325SStephen Hemminger netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev);
536c27a02cdSYevgeny Petrilin 
537c27a02cdSYevgeny Petrilin int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring,
53887a5c389SYevgeny Petrilin 			   int qpn, u32 size, u16 stride);
539c27a02cdSYevgeny Petrilin void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring);
540c27a02cdSYevgeny Petrilin int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
541c27a02cdSYevgeny Petrilin 			     struct mlx4_en_tx_ring *ring,
5420e98b523SAmir Vadai 			     int cq, int user_prio);
543c27a02cdSYevgeny Petrilin void mlx4_en_deactivate_tx_ring(struct mlx4_en_priv *priv,
544c27a02cdSYevgeny Petrilin 				struct mlx4_en_tx_ring *ring);
545c27a02cdSYevgeny Petrilin 
546c27a02cdSYevgeny Petrilin int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
547c27a02cdSYevgeny Petrilin 			   struct mlx4_en_rx_ring *ring,
548c27a02cdSYevgeny Petrilin 			   u32 size, u16 stride);
549c27a02cdSYevgeny Petrilin void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
55068355f71SThadeu Lima de Souza Cascardo 			     struct mlx4_en_rx_ring *ring,
55168355f71SThadeu Lima de Souza Cascardo 			     u32 size, u16 stride);
552c27a02cdSYevgeny Petrilin int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv);
553c27a02cdSYevgeny Petrilin void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv,
554c27a02cdSYevgeny Petrilin 				struct mlx4_en_rx_ring *ring);
555c27a02cdSYevgeny Petrilin int mlx4_en_process_rx_cq(struct net_device *dev,
556c27a02cdSYevgeny Petrilin 			  struct mlx4_en_cq *cq,
557c27a02cdSYevgeny Petrilin 			  int budget);
558c27a02cdSYevgeny Petrilin int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget);
559c27a02cdSYevgeny Petrilin void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
5600e98b523SAmir Vadai 		int is_tx, int rss, int qpn, int cqn, int user_prio,
561c27a02cdSYevgeny Petrilin 		struct mlx4_qp_context *context);
562966508f7SYevgeny Petrilin void mlx4_en_sqp_event(struct mlx4_qp *qp, enum mlx4_event event);
563c27a02cdSYevgeny Petrilin int mlx4_en_map_buffer(struct mlx4_buf *buf);
564c27a02cdSYevgeny Petrilin void mlx4_en_unmap_buffer(struct mlx4_buf *buf);
565c27a02cdSYevgeny Petrilin 
566c27a02cdSYevgeny Petrilin void mlx4_en_calc_rx_buf(struct net_device *dev);
567c27a02cdSYevgeny Petrilin int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv);
568c27a02cdSYevgeny Petrilin void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv);
569c27a02cdSYevgeny Petrilin int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring);
570c27a02cdSYevgeny Petrilin void mlx4_en_rx_irq(struct mlx4_cq *mcq);
571c27a02cdSYevgeny Petrilin 
572c27a02cdSYevgeny Petrilin int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode);
573f1b553fbSJiri Pirko int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv);
574c27a02cdSYevgeny Petrilin 
575c27a02cdSYevgeny Petrilin int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset);
576e7c1c2c4SYevgeny Petrilin int mlx4_en_QUERY_PORT(struct mlx4_en_dev *mdev, u8 port);
577e7c1c2c4SYevgeny Petrilin 
578564c274cSAmir Vadai #ifdef CONFIG_MLX4_EN_DCB
579564c274cSAmir Vadai extern const struct dcbnl_rtnl_ops mlx4_en_dcbnl_ops;
580564c274cSAmir Vadai #endif
581564c274cSAmir Vadai 
582e7c1c2c4SYevgeny Petrilin #define MLX4_EN_NUM_SELF_TEST	5
583e7c1c2c4SYevgeny Petrilin void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf);
584e7c1c2c4SYevgeny Petrilin u64 mlx4_en_mac_to_u64(u8 *addr);
585c27a02cdSYevgeny Petrilin 
586c27a02cdSYevgeny Petrilin /*
587c27a02cdSYevgeny Petrilin  * Globals
588c27a02cdSYevgeny Petrilin  */
589c27a02cdSYevgeny Petrilin extern const struct ethtool_ops mlx4_en_ethtool_ops;
5900a645e80SJoe Perches 
5910a645e80SJoe Perches 
5920a645e80SJoe Perches 
5930a645e80SJoe Perches /*
5940a645e80SJoe Perches  * printk / logging functions
5950a645e80SJoe Perches  */
5960a645e80SJoe Perches 
597b9075fa9SJoe Perches __printf(3, 4)
5980a645e80SJoe Perches int en_print(const char *level, const struct mlx4_en_priv *priv,
599b9075fa9SJoe Perches 	     const char *format, ...);
6000a645e80SJoe Perches 
6010a645e80SJoe Perches #define en_dbg(mlevel, priv, format, arg...)			\
6020a645e80SJoe Perches do {								\
6030a645e80SJoe Perches 	if (NETIF_MSG_##mlevel & priv->msg_enable)		\
6040a645e80SJoe Perches 		en_print(KERN_DEBUG, priv, format, ##arg);	\
6050a645e80SJoe Perches } while (0)
6060a645e80SJoe Perches #define en_warn(priv, format, arg...)			\
6070a645e80SJoe Perches 	en_print(KERN_WARNING, priv, format, ##arg)
6080a645e80SJoe Perches #define en_err(priv, format, arg...)			\
6090a645e80SJoe Perches 	en_print(KERN_ERR, priv, format, ##arg)
610e5cc44b2SYevgeny Petrilin #define en_info(priv, format, arg...)			\
611e5cc44b2SYevgeny Petrilin 	en_print(KERN_INFO, priv, format, ## arg)
6120a645e80SJoe Perches 
6130a645e80SJoe Perches #define mlx4_err(mdev, format, arg...)			\
6140a645e80SJoe Perches 	pr_err("%s %s: " format, DRV_NAME,		\
6150a645e80SJoe Perches 	       dev_name(&mdev->pdev->dev), ##arg)
6160a645e80SJoe Perches #define mlx4_info(mdev, format, arg...)			\
6170a645e80SJoe Perches 	pr_info("%s %s: " format, DRV_NAME,		\
6180a645e80SJoe Perches 		dev_name(&mdev->pdev->dev), ##arg)
6190a645e80SJoe Perches #define mlx4_warn(mdev, format, arg...)			\
6200a645e80SJoe Perches 	pr_warning("%s %s: " format, DRV_NAME,		\
6210a645e80SJoe Perches 		   dev_name(&mdev->pdev->dev), ##arg)
6220a645e80SJoe Perches 
623c27a02cdSYevgeny Petrilin #endif
624