1d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara/* 2d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * Linux driver for VMware's vmxnet3 ethernet NIC. 3d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * 4d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved. 5d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * 6d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * This program is free software; you can redistribute it and/or modify it 7d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * under the terms of the GNU General Public License as published by the 8d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * Free Software Foundation; version 2 of the License and no later version. 9d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * 10d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * This program is distributed in the hope that it will be useful, but 11d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * WITHOUT ANY WARRANTY; without even the implied warranty of 12d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 13d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * NON INFRINGEMENT. See the GNU General Public License for more 14d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * details. 15d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * 16d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * You should have received a copy of the GNU General Public License 17d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * along with this program; if not, write to the Free Software 18d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * 20d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * The full GNU General Public License is included in this distribution in 21d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * the file called "COPYING". 22d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * 23d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com> 24d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * 25d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara */ 26d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 27d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#ifndef _VMXNET3_INT_H 28d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define _VMXNET3_INT_H 29d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 3072e85c45b9541e1f3d233e775da1dc6f68b85867Jesse Gross#include <linux/bitops.h> 31d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/ethtool.h> 32d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/delay.h> 33d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/netdevice.h> 34d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/pci.h> 35d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/compiler.h> 36d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/slab.h> 37d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/spinlock.h> 38d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/ioport.h> 39d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/highmem.h> 40d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/timer.h> 41d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/skbuff.h> 42d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/interrupt.h> 43d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/workqueue.h> 44d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/uaccess.h> 45d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <asm/dma.h> 46d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <asm/page.h> 47d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 48d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/tcp.h> 49d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/udp.h> 50d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/ip.h> 51d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/ipv6.h> 52d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/in.h> 53d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/etherdevice.h> 54d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <asm/checksum.h> 55d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/if_vlan.h> 56d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/if_arp.h> 57d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include <linux/inetdevice.h> 58eebb02b1f03b3722d678bfcb560f3b26661ab0d2Shreyas Bhatewara#include <linux/log2.h> 59d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 60d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#include "vmxnet3_defs.h" 61d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 62d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#ifdef DEBUG 63d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara# define VMXNET3_DRIVER_VERSION_REPORT VMXNET3_DRIVER_VERSION_STRING"-NAPI(debug)" 64d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#else 65d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara# define VMXNET3_DRIVER_VERSION_REPORT VMXNET3_DRIVER_VERSION_STRING"-NAPI" 66d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#endif 67d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 68d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 69d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara/* 70d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * Version numbers 71d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara */ 724ad9a64f53c619969dede1143d56ccda1a453c39Andy King#define VMXNET3_DRIVER_VERSION_STRING "1.2.1.0-k" 73d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 74d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ 754ad9a64f53c619969dede1143d56ccda1a453c39Andy King#define VMXNET3_DRIVER_VERSION_NUM 0x01020100 76d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 7709c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#if defined(CONFIG_PCI_MSI) 7809c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara /* RSS only makes sense if MSI-X is supported. */ 7909c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara #define VMXNET3_RSS 8009c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#endif 81d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 82d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara/* 83d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * Capabilities 84d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara */ 85d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 86d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaraenum { 87d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_SG = 0x0001, /* Can do scatter-gather transmits. */ 88d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_IP4_CSUM = 0x0002, /* Can checksum only TCP/UDP over 89d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * IPv4 */ 90d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_HW_CSUM = 0x0004, /* Can checksum all packets. */ 91d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_HIGH_DMA = 0x0008, /* Can DMA to high memory. */ 92d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_TOE = 0x0010, /* Supports TCP/IP offload. */ 93d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_TSO = 0x0020, /* Supports TCP Segmentation 94d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * offload */ 95d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_SW_TSO = 0x0040, /* Supports SW TCP Segmentation */ 96d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_VMXNET_APROM = 0x0080, /* Vmxnet APROM support */ 97d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_HW_TX_VLAN = 0x0100, /* Can we do VLAN tagging in HW */ 98d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_HW_RX_VLAN = 0x0200, /* Can we do VLAN untagging in HW */ 99d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_SW_VLAN = 0x0400, /* VLAN tagging/untagging in SW */ 100d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_WAKE_PCKT_RCV = 0x0800, /* Can wake on network packet recv? */ 101d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_ENABLE_INT_INLINE = 0x1000, /* Enable Interrupt Inline */ 102d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_ENABLE_HEADER_COPY = 0x2000, /* copy header for vmkernel */ 103d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_TX_CHAIN = 0x4000, /* Guest can use multiple tx entries 104d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * for a pkt */ 105d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_RX_CHAIN = 0x8000, /* pkt can span multiple rx entries */ 106d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_LPD = 0x10000, /* large pkt delivery */ 107d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_BPF = 0x20000, /* BPF Support in VMXNET Virtual HW*/ 108d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_SG_SPAN_PAGES = 0x40000, /* Scatter-gather can span multiple*/ 109d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara /* pages transmits */ 110d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_IP6_CSUM = 0x80000, /* Can do IPv6 csum offload. */ 111d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_TSO6 = 0x100000, /* TSO seg. offload for IPv6 pkts. */ 112d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_TSO256k = 0x200000, /* Can do TSO seg offload for */ 113d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara /* pkts up to 256kB. */ 114d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMNET_CAP_UPT = 0x400000 /* Support UPT */ 115d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 116d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 117d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara/* 118d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * PCI vendor and device IDs. 119d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara */ 120d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define PCI_DEVICE_ID_VMWARE_VMXNET3 0x07B0 121d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define MAX_ETHERNET_CARDS 10 122d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define MAX_PCI_PASSTHRU_DEVICE 6 123d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 124d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_cmd_ring { 125d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara union Vmxnet3_GenericDesc *base; 126d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 size; 127d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 next2fill; 128d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 next2comp; 129d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u8 gen; 130d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara dma_addr_t basePA; 131d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 132d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 133d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastatic inline void 134d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravmxnet3_cmd_ring_adv_next2fill(struct vmxnet3_cmd_ring *ring) 135d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara{ 136d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara ring->next2fill++; 137d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara if (unlikely(ring->next2fill == ring->size)) { 138d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara ring->next2fill = 0; 139d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_FLIP_RING_GEN(ring->gen); 140d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara } 141d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara} 142d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 143d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastatic inline void 144d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravmxnet3_cmd_ring_adv_next2comp(struct vmxnet3_cmd_ring *ring) 145d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara{ 146d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_INC_RING_IDX_ONLY(ring->next2comp, ring->size); 147d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara} 148d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 149d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastatic inline int 150d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravmxnet3_cmd_ring_desc_avail(struct vmxnet3_cmd_ring *ring) 151d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara{ 152d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara return (ring->next2comp > ring->next2fill ? 0 : ring->size) + 153d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara ring->next2comp - ring->next2fill - 1; 154d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara} 155d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 156d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_comp_ring { 157d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara union Vmxnet3_GenericDesc *base; 158d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 size; 159d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 next2proc; 160d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u8 gen; 161d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u8 intr_idx; 162d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara dma_addr_t basePA; 163d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 164d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 165d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastatic inline void 166d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravmxnet3_comp_ring_adv_next2proc(struct vmxnet3_comp_ring *ring) 167d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara{ 168d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara ring->next2proc++; 169d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara if (unlikely(ring->next2proc == ring->size)) { 170d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara ring->next2proc = 0; 171d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_FLIP_RING_GEN(ring->gen); 172d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara } 173d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara} 174d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 175d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_tx_data_ring { 176d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct Vmxnet3_TxDataDesc *base; 177d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 size; 178d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara dma_addr_t basePA; 179d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 180d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 181d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaraenum vmxnet3_buf_map_type { 182d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_MAP_INVALID = 0, 183d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_MAP_NONE, 184d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_MAP_SINGLE, 185d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_MAP_PAGE, 186d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 187d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 188d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_tx_buf_info { 189d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 map_type; 190d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u16 len; 191d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u16 sop_idx; 192d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara dma_addr_t dma_addr; 193d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct sk_buff *skb; 194d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 195d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 196d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_tq_driver_stats { 197d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 drop_total; /* # of pkts dropped by the driver, the 198d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * counters below track droppings due to 199d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * different reasons 200d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara */ 201d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 drop_too_many_frags; 202d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 drop_oversized_hdr; 203d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 drop_hdr_inspect_err; 204d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 drop_tso; 205d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 206d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 tx_ring_full; 207d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 linearized; /* # of pkts linearized */ 208d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 copy_skb_header; /* # of times we have to copy skb header */ 209d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 oversized_hdr; 210d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 211d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 212d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_tx_ctx { 213d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara bool ipv4; 214d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u16 mss; 215d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 eth_ip_hdr_size; /* only valid for pkts requesting tso or csum 216d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * offloading 217d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara */ 218d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 l4_hdr_size; /* only valid if mss != 0 */ 219d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 copy_size; /* # of bytes copied into the data ring */ 220d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara union Vmxnet3_GenericDesc *sop_txd; 221d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara union Vmxnet3_GenericDesc *eop_txd; 222d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 223d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 224d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_tx_queue { 22509c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara char name[IFNAMSIZ+8]; /* To identify interrupt */ 22609c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct vmxnet3_adapter *adapter; 227d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara spinlock_t tx_lock; 228d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct vmxnet3_cmd_ring tx_ring; 22909c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct vmxnet3_tx_buf_info *buf_info; 230b0eb57cb97e7837ebb746404c2c58c6f536f23faAndy King dma_addr_t buf_info_pa; 231d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct vmxnet3_tx_data_ring data_ring; 232d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct vmxnet3_comp_ring comp_ring; 23309c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct Vmxnet3_TxQueueCtrl *shared; 234d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct vmxnet3_tq_driver_stats stats; 235d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara bool stopped; 236d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara int num_stop; /* # of times the queue is 237d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara * stopped */ 23809c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara int qid; 239d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara} __attribute__((__aligned__(SMP_CACHE_BYTES))); 240d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 241d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaraenum vmxnet3_rx_buf_type { 242d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_RX_BUF_NONE = 0, 243d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_RX_BUF_SKB = 1, 244d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara VMXNET3_RX_BUF_PAGE = 2 245d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 246d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 247d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_rx_buf_info { 248d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara enum vmxnet3_rx_buf_type buf_type; 249d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u16 len; 250d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara union { 251d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct sk_buff *skb; 252d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct page *page; 253d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara }; 254d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara dma_addr_t dma_addr; 255d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 256d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 257d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_rx_ctx { 258d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct sk_buff *skb; 259d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 sop_idx; 260d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 261d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 262d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_rq_driver_stats { 263d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 drop_total; 264d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 drop_err; 265d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 drop_fcs; 266d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 rx_buf_alloc_failure; 267d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 268d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 269d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_rx_queue { 27009c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara char name[IFNAMSIZ + 8]; /* To identify interrupt */ 27109c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct vmxnet3_adapter *adapter; 27209c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct napi_struct napi; 273d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct vmxnet3_cmd_ring rx_ring[2]; 274d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct vmxnet3_comp_ring comp_ring; 275d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct vmxnet3_rx_ctx rx_ctx; 276d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 qid; /* rqID in RCD for buffer from 1st ring */ 277d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 qid2; /* rqID in RCD for buffer from 2nd ring */ 278d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct vmxnet3_rx_buf_info *buf_info[2]; 279b0eb57cb97e7837ebb746404c2c58c6f536f23faAndy King dma_addr_t buf_info_pa; 280d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct Vmxnet3_RxQueueCtrl *shared; 281d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct vmxnet3_rq_driver_stats stats; 282d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara} __attribute__((__aligned__(SMP_CACHE_BYTES))); 283d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 28409c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#define VMXNET3_DEVICE_MAX_TX_QUEUES 8 28509c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#define VMXNET3_DEVICE_MAX_RX_QUEUES 8 /* Keep this value as a power of 2 */ 28609c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara 28709c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara/* Should be less than UPT1_RSS_MAX_IND_TABLE_SIZE */ 28809c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#define VMXNET3_RSS_IND_TABLE_SIZE (VMXNET3_DEVICE_MAX_RX_QUEUES * 4) 28909c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara 29009c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#define VMXNET3_LINUX_MAX_MSIX_VECT (VMXNET3_DEVICE_MAX_TX_QUEUES + \ 29109c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara VMXNET3_DEVICE_MAX_RX_QUEUES + 1) 2927e96fbf2320782fb8f0970928026105cd34b41bdShreyas Bhatewara#define VMXNET3_LINUX_MIN_MSIX_VECT 2 /* 1 for tx-rx pair and 1 for event */ 29309c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara 294d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 295d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_intr { 296d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara enum vmxnet3_intr_mask_mode mask_mode; 297d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara enum vmxnet3_intr_type type; /* MSI-X, MSI, or INTx? */ 298d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u8 num_intrs; /* # of intr vectors */ 299d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u8 event_intr_idx; /* idx of the intr vector for event */ 300d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u8 mod_levels[VMXNET3_LINUX_MAX_MSIX_VECT]; /* moderation level */ 30109c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara char event_msi_vector_name[IFNAMSIZ+11]; 302d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#ifdef CONFIG_PCI_MSI 303d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct msix_entry msix_entries[VMXNET3_LINUX_MAX_MSIX_VECT]; 304d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#endif 305d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 306d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 30709c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara/* Interrupt sharing schemes, share_intr */ 30809c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#define VMXNET3_INTR_BUDDYSHARE 0 /* Corresponding tx,rx queues share irq */ 30909c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#define VMXNET3_INTR_TXSHARE 1 /* All tx queues share one irq */ 31009c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#define VMXNET3_INTR_DONTSHARE 2 /* each queue has its own irq */ 31109c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara 31209c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara 313d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_STATE_BIT_RESETTING 0 314d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_STATE_BIT_QUIESCED 1 315d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewarastruct vmxnet3_adapter { 31609c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct vmxnet3_tx_queue tx_queue[VMXNET3_DEVICE_MAX_TX_QUEUES]; 31709c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct vmxnet3_rx_queue rx_queue[VMXNET3_DEVICE_MAX_RX_QUEUES]; 31872e85c45b9541e1f3d233e775da1dc6f68b85867Jesse Gross unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 31909c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct vmxnet3_intr intr; 32083d0feffc5695d7dc24c6b8dac9ab265533beb78Shreyas Bhatewara spinlock_t cmd_lock; 32109c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct Vmxnet3_DriverShared *shared; 32209c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct Vmxnet3_PMConf *pm_conf; 32309c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct Vmxnet3_TxQueueDesc *tqd_start; /* all tx queue desc */ 32409c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct Vmxnet3_RxQueueDesc *rqd_start; /* all rx queue desc */ 32509c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct net_device *netdev; 32609c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct pci_dev *pdev; 327d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 32881e8e5601fba4ea5bc3bfbed0fec074cf65feca5Harvey Harrison u8 __iomem *hw_addr0; /* for BAR 0 */ 32981e8e5601fba4ea5bc3bfbed0fec074cf65feca5Harvey Harrison u8 __iomem *hw_addr1; /* for BAR 1 */ 330d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 33109c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#ifdef VMXNET3_RSS 33209c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara struct UPT1_RSSConf *rss_conf; 33309c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara bool rss; 33409c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara#endif 33509c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara u32 num_rx_queues; 33609c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara u32 num_tx_queues; 337d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 338d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara /* rx buffer related */ 339d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara unsigned skb_buf_size; 340d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara int rx_buf_per_pkt; /* only apply to the 1st ring */ 341d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara dma_addr_t shared_pa; 342d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara dma_addr_t queue_desc_pa; 343d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 344d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara /* Wake-on-LAN */ 345d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 wol; 346d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 347d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara /* Link speed */ 348d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 link_speed; /* in mbps */ 349d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 350d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u64 tx_timeout_count; 351f00e2b0ac3ae25a37c04a113ed03bf249fad15d8Neil Horman 352f00e2b0ac3ae25a37c04a113ed03bf249fad15d8Neil Horman /* Ring sizes */ 353f00e2b0ac3ae25a37c04a113ed03bf249fad15d8Neil Horman u32 tx_ring_size; 354f00e2b0ac3ae25a37c04a113ed03bf249fad15d8Neil Horman u32 rx_ring_size; 355f00e2b0ac3ae25a37c04a113ed03bf249fad15d8Neil Horman 356d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara struct work_struct work; 357d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 358d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara unsigned long state; /* VMXNET3_STATE_BIT_xxx */ 359d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 36009c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewara int share_intr; 361b0eb57cb97e7837ebb746404c2c58c6f536f23faAndy King 362b0eb57cb97e7837ebb746404c2c58c6f536f23faAndy King dma_addr_t adapter_pa; 363b0eb57cb97e7837ebb746404c2c58c6f536f23faAndy King dma_addr_t pm_conf_pa; 364b0eb57cb97e7837ebb746404c2c58c6f536f23faAndy King dma_addr_t rss_conf_pa; 365d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara}; 366d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 367d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_WRITE_BAR0_REG(adapter, reg, val) \ 368b8744cabb79a6522bb2e1c22c4edd8fb39fcfc7eHarvey Harrison writel((val), (adapter)->hw_addr0 + (reg)) 369d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_READ_BAR0_REG(adapter, reg) \ 370b8744cabb79a6522bb2e1c22c4edd8fb39fcfc7eHarvey Harrison readl((adapter)->hw_addr0 + (reg)) 371d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 372d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_WRITE_BAR1_REG(adapter, reg, val) \ 373b8744cabb79a6522bb2e1c22c4edd8fb39fcfc7eHarvey Harrison writel((val), (adapter)->hw_addr1 + (reg)) 374d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_READ_BAR1_REG(adapter, reg) \ 375b8744cabb79a6522bb2e1c22c4edd8fb39fcfc7eHarvey Harrison readl((adapter)->hw_addr1 + (reg)) 376d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 377d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_WAKE_QUEUE_THRESHOLD(tq) (5) 378d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_RX_ALLOC_THRESHOLD(rq, ring_idx, adapter) \ 379d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara ((rq)->rx_ring[ring_idx].size >> 3) 380d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 381d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_GET_ADDR_LO(dma) ((u32)(dma)) 382d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_GET_ADDR_HI(dma) ((u32)(((u64)(dma)) >> 32)) 383d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 384d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara/* must be a multiple of VMXNET3_RING_SIZE_ALIGN */ 385d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_DEF_TX_RING_SIZE 512 386d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_DEF_RX_RING_SIZE 256 387d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 388d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_MAX_ETH_HDR_SIZE 22 389d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#define VMXNET3_MAX_SKB_BUF_SIZE (3*1024) 390d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 391d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaraint 392d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter); 393d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 394d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaraint 395d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravmxnet3_activate_dev(struct vmxnet3_adapter *adapter); 396d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 397d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravoid 398d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravmxnet3_force_close(struct vmxnet3_adapter *adapter); 399d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 400d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravoid 401d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravmxnet3_reset_dev(struct vmxnet3_adapter *adapter); 402d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 403d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravoid 40409c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewaravmxnet3_tq_destroy_all(struct vmxnet3_adapter *adapter); 405d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 406d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravoid 40709c5088e5c5993be217a2c85dca088147ffc9b72Shreyas Bhatewaravmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter); 408d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 409d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaraint 410c8f44affb7244f2ac3e703cab13d55ede27621bbMichał Mirosławvmxnet3_set_features(struct net_device *netdev, netdev_features_t features); 411a0d2730c9571aeba793cb5d3009094ee1d8fda35Michał Mirosław 412a0d2730c9571aeba793cb5d3009094ee1d8fda35Michał Mirosławint 413d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaravmxnet3_create_queues(struct vmxnet3_adapter *adapter, 414d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara u32 tx_ring_size, u32 rx_ring_size, u32 rx_ring2_size); 415d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 416d8dea1eb36bcc004416b9587f09730430905e5b7Joe Perchesvoid vmxnet3_set_ethtool_ops(struct net_device *netdev); 41795305f6c3b4e8c0bdd5044604c418a8ad2defc4estephen hemminger 418d8dea1eb36bcc004416b9587f09730430905e5b7Joe Perchesstruct rtnl_link_stats64 * 41995305f6c3b4e8c0bdd5044604c418a8ad2defc4estephen hemmingervmxnet3_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats); 420d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara 421d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewaraextern char vmxnet3_driver_name[]; 422d1a890fa37f27d6aca3abc6e25e4148efc3223a6Shreyas Bhatewara#endif 423