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