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