xref: /openbmc/linux/drivers/net/ethernet/atheros/alx/alx.h (revision 4a134c39db2d9d6f31c55e7c3773fc33189c9320)
1ab69bde6SJohannes Berg /*
2ab69bde6SJohannes Berg  * Copyright (c) 2013 Johannes Berg <johannes@sipsolutions.net>
3ab69bde6SJohannes Berg  *
4ab69bde6SJohannes Berg  *  This file is free software: you may copy, redistribute and/or modify it
5ab69bde6SJohannes Berg  *  under the terms of the GNU General Public License as published by the
6ab69bde6SJohannes Berg  *  Free Software Foundation, either version 2 of the License, or (at your
7ab69bde6SJohannes Berg  *  option) any later version.
8ab69bde6SJohannes Berg  *
9ab69bde6SJohannes Berg  *  This file is distributed in the hope that it will be useful, but
10ab69bde6SJohannes Berg  *  WITHOUT ANY WARRANTY; without even the implied warranty of
11ab69bde6SJohannes Berg  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12ab69bde6SJohannes Berg  *  General Public License for more details.
13ab69bde6SJohannes Berg  *
14ab69bde6SJohannes Berg  *  You should have received a copy of the GNU General Public License
15ab69bde6SJohannes Berg  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16ab69bde6SJohannes Berg  *
17ab69bde6SJohannes Berg  * This file incorporates work covered by the following copyright and
18ab69bde6SJohannes Berg  * permission notice:
19ab69bde6SJohannes Berg  *
20ab69bde6SJohannes Berg  * Copyright (c) 2012 Qualcomm Atheros, Inc.
21ab69bde6SJohannes Berg  *
22ab69bde6SJohannes Berg  * Permission to use, copy, modify, and/or distribute this software for any
23ab69bde6SJohannes Berg  * purpose with or without fee is hereby granted, provided that the above
24ab69bde6SJohannes Berg  * copyright notice and this permission notice appear in all copies.
25ab69bde6SJohannes Berg  *
26ab69bde6SJohannes Berg  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
27ab69bde6SJohannes Berg  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
28ab69bde6SJohannes Berg  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
29ab69bde6SJohannes Berg  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
30ab69bde6SJohannes Berg  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
31ab69bde6SJohannes Berg  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
32ab69bde6SJohannes Berg  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
33ab69bde6SJohannes Berg  */
34ab69bde6SJohannes Berg 
35ab69bde6SJohannes Berg #ifndef _ALX_H_
36ab69bde6SJohannes Berg #define _ALX_H_
37ab69bde6SJohannes Berg 
38ab69bde6SJohannes Berg #include <linux/types.h>
39ab69bde6SJohannes Berg #include <linux/etherdevice.h>
40ab69bde6SJohannes Berg #include <linux/dma-mapping.h>
41ab69bde6SJohannes Berg #include <linux/spinlock.h>
42ab69bde6SJohannes Berg #include "hw.h"
43ab69bde6SJohannes Berg 
44ab69bde6SJohannes Berg #define ALX_WATCHDOG_TIME   (5 * HZ)
45ab69bde6SJohannes Berg 
46ab69bde6SJohannes Berg struct alx_buffer {
47ab69bde6SJohannes Berg 	struct sk_buff *skb;
48ab69bde6SJohannes Berg 	DEFINE_DMA_UNMAP_ADDR(dma);
49ab69bde6SJohannes Berg 	DEFINE_DMA_UNMAP_LEN(size);
50ab69bde6SJohannes Berg };
51ab69bde6SJohannes Berg 
52ab69bde6SJohannes Berg struct alx_rx_queue {
53ab69bde6SJohannes Berg 	struct alx_rrd *rrd;
54ab69bde6SJohannes Berg 	dma_addr_t rrd_dma;
55ab69bde6SJohannes Berg 
56ab69bde6SJohannes Berg 	struct alx_rfd *rfd;
57ab69bde6SJohannes Berg 	dma_addr_t rfd_dma;
58ab69bde6SJohannes Berg 
59ab69bde6SJohannes Berg 	struct alx_buffer *bufs;
60ab69bde6SJohannes Berg 
61ab69bde6SJohannes Berg 	u16 write_idx, read_idx;
62ab69bde6SJohannes Berg 	u16 rrd_read_idx;
63ab69bde6SJohannes Berg };
64ab69bde6SJohannes Berg #define ALX_RX_ALLOC_THRESH	32
65ab69bde6SJohannes Berg 
66ab69bde6SJohannes Berg struct alx_tx_queue {
67ab69bde6SJohannes Berg 	struct alx_txd *tpd;
68ab69bde6SJohannes Berg 	dma_addr_t tpd_dma;
69ab69bde6SJohannes Berg 	struct alx_buffer *bufs;
70ab69bde6SJohannes Berg 	u16 write_idx, read_idx;
71ab69bde6SJohannes Berg };
72ab69bde6SJohannes Berg 
73ab69bde6SJohannes Berg #define ALX_DEFAULT_TX_WORK 128
74ab69bde6SJohannes Berg 
75ab69bde6SJohannes Berg enum alx_device_quirks {
76ab69bde6SJohannes Berg 	ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG = BIT(0),
77ab69bde6SJohannes Berg };
78ab69bde6SJohannes Berg 
79ab69bde6SJohannes Berg struct alx_priv {
80ab69bde6SJohannes Berg 	struct net_device *dev;
81ab69bde6SJohannes Berg 
82ab69bde6SJohannes Berg 	struct alx_hw hw;
83ab69bde6SJohannes Berg 
84ab69bde6SJohannes Berg 	/* all descriptor memory */
85ab69bde6SJohannes Berg 	struct {
86ab69bde6SJohannes Berg 		dma_addr_t dma;
87ab69bde6SJohannes Berg 		void *virt;
88*4a134c39SJohannes Berg 		unsigned int size;
89ab69bde6SJohannes Berg 	} descmem;
90ab69bde6SJohannes Berg 
91ab69bde6SJohannes Berg 	/* protect int_mask updates */
92ab69bde6SJohannes Berg 	spinlock_t irq_lock;
93ab69bde6SJohannes Berg 	u32 int_mask;
94ab69bde6SJohannes Berg 
95*4a134c39SJohannes Berg 	unsigned int tx_ringsz;
96*4a134c39SJohannes Berg 	unsigned int rx_ringsz;
97*4a134c39SJohannes Berg 	unsigned int rxbuf_size;
98ab69bde6SJohannes Berg 
99ab69bde6SJohannes Berg 	struct napi_struct napi;
100ab69bde6SJohannes Berg 	struct alx_tx_queue txq;
101ab69bde6SJohannes Berg 	struct alx_rx_queue rxq;
102ab69bde6SJohannes Berg 
103ab69bde6SJohannes Berg 	struct work_struct link_check_wk;
104ab69bde6SJohannes Berg 	struct work_struct reset_wk;
105ab69bde6SJohannes Berg 
106ab69bde6SJohannes Berg 	u16 msg_enable;
107ab69bde6SJohannes Berg 
108ab69bde6SJohannes Berg 	bool msi;
109ab69bde6SJohannes Berg };
110ab69bde6SJohannes Berg 
111ab69bde6SJohannes Berg extern const struct ethtool_ops alx_ethtool_ops;
112ab69bde6SJohannes Berg extern const char alx_drv_name[];
113ab69bde6SJohannes Berg 
114ab69bde6SJohannes Berg #endif
115