mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	net: VMware virtual Ethernet NIC driver: vmxnet3
Ethernet NIC driver for VMware's vmxnet3 From: Shreyas Bhatewara <sbhatewara@vmware.com> This patch adds driver support for VMware's virtual Ethernet NIC: vmxnet3 Guests running on VMware hypervisors supporting vmxnet3 device will thus have access to improved network functionalities and performance. Signed-off-by: Shreyas Bhatewara <sbhatewara@vmware.com> Signed-off-by: Bhavesh Davda <bhavesh@vmware.com> Signed-off-by: Ronghua Zhang <ronghua@vmware.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									b9696ea325
								
							
						
					
					
						commit
						d1a890fa37
					
				
					 9 changed files with 4193 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -5612,6 +5612,13 @@ S:	Maintained
 | 
			
		|||
F:	drivers/vlynq/vlynq.c
 | 
			
		||||
F:	include/linux/vlynq.h
 | 
			
		||||
 | 
			
		||||
VMWARE VMXNET3 ETHERNET DRIVER
 | 
			
		||||
M:     Shreyas Bhatewara <sbhatewara@vmware.com>
 | 
			
		||||
M:     VMware, Inc. <pv-drivers@vmware.com>
 | 
			
		||||
L:     netdev@vger.kernel.org
 | 
			
		||||
S:     Maintained
 | 
			
		||||
F:     drivers/net/vmxnet3/
 | 
			
		||||
 | 
			
		||||
VOLTAGE AND CURRENT REGULATOR FRAMEWORK
 | 
			
		||||
M:	Liam Girdwood <lrg@slimlogic.co.uk>
 | 
			
		||||
M:	Mark Brown <broonie@opensource.wolfsonmicro.com>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3230,4 +3230,12 @@ config VIRTIO_NET
 | 
			
		|||
	  This is the virtual network driver for virtio.  It can be used with
 | 
			
		||||
          lguest or QEMU based VMMs (like KVM or Xen).  Say Y or M.
 | 
			
		||||
 | 
			
		||||
config VMXNET3
 | 
			
		||||
       tristate "VMware VMXNET3 ethernet driver"
 | 
			
		||||
       depends on PCI && X86
 | 
			
		||||
       help
 | 
			
		||||
         This driver supports VMware's vmxnet3 virtual ethernet NIC.
 | 
			
		||||
         To compile this driver as a module, choose M here: the
 | 
			
		||||
         module will be called vmxnet3.
 | 
			
		||||
 | 
			
		||||
endif # NETDEVICES
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,6 +30,7 @@ obj-$(CONFIG_TEHUTI) += tehuti.o
 | 
			
		|||
obj-$(CONFIG_ENIC) += enic/
 | 
			
		||||
obj-$(CONFIG_JME) += jme.o
 | 
			
		||||
obj-$(CONFIG_BE2NET) += benet/
 | 
			
		||||
obj-$(CONFIG_VMXNET3) += vmxnet3/
 | 
			
		||||
 | 
			
		||||
gianfar_driver-objs := gianfar.o \
 | 
			
		||||
		gianfar_ethtool.o \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										35
									
								
								drivers/net/vmxnet3/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								drivers/net/vmxnet3/Makefile
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,35 @@
 | 
			
		|||
################################################################################
 | 
			
		||||
#
 | 
			
		||||
# Linux driver for VMware's vmxnet3 ethernet NIC.
 | 
			
		||||
#
 | 
			
		||||
# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
 | 
			
		||||
#
 | 
			
		||||
# This program is free software; you can redistribute it and/or modify it
 | 
			
		||||
# under the terms of the GNU General Public License as published by the
 | 
			
		||||
# Free Software Foundation; version 2 of the License and no later version.
 | 
			
		||||
#
 | 
			
		||||
# This program is distributed in the hope that it will be useful, but
 | 
			
		||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 | 
			
		||||
# NON INFRINGEMENT.  See the GNU General Public License for more
 | 
			
		||||
# details.
 | 
			
		||||
#
 | 
			
		||||
# You should have received a copy of the GNU General Public License
 | 
			
		||||
# along with this program; if not, write to the Free Software
 | 
			
		||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
#
 | 
			
		||||
# The full GNU General Public License is included in this distribution in
 | 
			
		||||
# the file called "COPYING".
 | 
			
		||||
#
 | 
			
		||||
# Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com>
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
################################################################################
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# Makefile for the VMware vmxnet3 ethernet NIC driver
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
obj-$(CONFIG_VMXNET3) += vmxnet3.o
 | 
			
		||||
 | 
			
		||||
vmxnet3-objs := vmxnet3_drv.o vmxnet3_ethtool.o
 | 
			
		||||
							
								
								
									
										96
									
								
								drivers/net/vmxnet3/upt1_defs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								drivers/net/vmxnet3/upt1_defs.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,96 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Linux driver for VMware's vmxnet3 ethernet NIC.
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or modify it
 | 
			
		||||
 * under the terms of the GNU General Public License as published by the
 | 
			
		||||
 * Free Software Foundation; version 2 of the License and no later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful, but
 | 
			
		||||
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 | 
			
		||||
 * NON INFRINGEMENT.  See the GNU General Public License for more
 | 
			
		||||
 * details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 *
 | 
			
		||||
 * The full GNU General Public License is included in this distribution in
 | 
			
		||||
 * the file called "COPYING".
 | 
			
		||||
 *
 | 
			
		||||
 * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com>
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _UPT1_DEFS_H
 | 
			
		||||
#define _UPT1_DEFS_H
 | 
			
		||||
 | 
			
		||||
struct UPT1_TxStats {
 | 
			
		||||
	u64			TSOPktsTxOK;  /* TSO pkts post-segmentation */
 | 
			
		||||
	u64			TSOBytesTxOK;
 | 
			
		||||
	u64			ucastPktsTxOK;
 | 
			
		||||
	u64			ucastBytesTxOK;
 | 
			
		||||
	u64			mcastPktsTxOK;
 | 
			
		||||
	u64			mcastBytesTxOK;
 | 
			
		||||
	u64			bcastPktsTxOK;
 | 
			
		||||
	u64			bcastBytesTxOK;
 | 
			
		||||
	u64			pktsTxError;
 | 
			
		||||
	u64			pktsTxDiscard;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct UPT1_RxStats {
 | 
			
		||||
	u64			LROPktsRxOK;    /* LRO pkts */
 | 
			
		||||
	u64			LROBytesRxOK;   /* bytes from LRO pkts */
 | 
			
		||||
	/* the following counters are for pkts from the wire, i.e., pre-LRO */
 | 
			
		||||
	u64			ucastPktsRxOK;
 | 
			
		||||
	u64			ucastBytesRxOK;
 | 
			
		||||
	u64			mcastPktsRxOK;
 | 
			
		||||
	u64			mcastBytesRxOK;
 | 
			
		||||
	u64			bcastPktsRxOK;
 | 
			
		||||
	u64			bcastBytesRxOK;
 | 
			
		||||
	u64			pktsRxOutOfBuf;
 | 
			
		||||
	u64			pktsRxError;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* interrupt moderation level */
 | 
			
		||||
enum {
 | 
			
		||||
	UPT1_IML_NONE		= 0, /* no interrupt moderation */
 | 
			
		||||
	UPT1_IML_HIGHEST	= 7, /* least intr generated */
 | 
			
		||||
	UPT1_IML_ADAPTIVE	= 8, /* adpative intr moderation */
 | 
			
		||||
};
 | 
			
		||||
/* values for UPT1_RSSConf.hashFunc */
 | 
			
		||||
enum {
 | 
			
		||||
	UPT1_RSS_HASH_TYPE_NONE      = 0x0,
 | 
			
		||||
	UPT1_RSS_HASH_TYPE_IPV4      = 0x01,
 | 
			
		||||
	UPT1_RSS_HASH_TYPE_TCP_IPV4  = 0x02,
 | 
			
		||||
	UPT1_RSS_HASH_TYPE_IPV6      = 0x04,
 | 
			
		||||
	UPT1_RSS_HASH_TYPE_TCP_IPV6  = 0x08,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
	UPT1_RSS_HASH_FUNC_NONE      = 0x0,
 | 
			
		||||
	UPT1_RSS_HASH_FUNC_TOEPLITZ  = 0x01,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define UPT1_RSS_MAX_KEY_SIZE        40
 | 
			
		||||
#define UPT1_RSS_MAX_IND_TABLE_SIZE  128
 | 
			
		||||
 | 
			
		||||
struct UPT1_RSSConf {
 | 
			
		||||
	u16			hashType;
 | 
			
		||||
	u16			hashFunc;
 | 
			
		||||
	u16			hashKeySize;
 | 
			
		||||
	u16			indTableSize;
 | 
			
		||||
	u8			hashKey[UPT1_RSS_MAX_KEY_SIZE];
 | 
			
		||||
	u8			indTable[UPT1_RSS_MAX_IND_TABLE_SIZE];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* features */
 | 
			
		||||
enum {
 | 
			
		||||
	UPT1_F_RXCSUM		= 0x0001,   /* rx csum verification */
 | 
			
		||||
	UPT1_F_RSS		= 0x0002,
 | 
			
		||||
	UPT1_F_RXVLAN		= 0x0004,   /* VLAN tag stripping */
 | 
			
		||||
	UPT1_F_LRO		= 0x0008,
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										535
									
								
								drivers/net/vmxnet3/vmxnet3_defs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										535
									
								
								drivers/net/vmxnet3/vmxnet3_defs.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,535 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Linux driver for VMware's vmxnet3 ethernet NIC.
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or modify it
 | 
			
		||||
 * under the terms of the GNU General Public License as published by the
 | 
			
		||||
 * Free Software Foundation; version 2 of the License and no later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful, but
 | 
			
		||||
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 | 
			
		||||
 * NON INFRINGEMENT.  See the GNU General Public License for more
 | 
			
		||||
 * details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 *
 | 
			
		||||
 * The full GNU General Public License is included in this distribution in
 | 
			
		||||
 * the file called "COPYING".
 | 
			
		||||
 *
 | 
			
		||||
 * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com>
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _VMXNET3_DEFS_H_
 | 
			
		||||
#define _VMXNET3_DEFS_H_
 | 
			
		||||
 | 
			
		||||
#include "upt1_defs.h"
 | 
			
		||||
 | 
			
		||||
/* all registers are 32 bit wide */
 | 
			
		||||
/* BAR 1 */
 | 
			
		||||
enum {
 | 
			
		||||
	VMXNET3_REG_VRRS	= 0x0,	/* Vmxnet3 Revision Report Selection */
 | 
			
		||||
	VMXNET3_REG_UVRS	= 0x8,	/* UPT Version Report Selection */
 | 
			
		||||
	VMXNET3_REG_DSAL	= 0x10,	/* Driver Shared Address Low */
 | 
			
		||||
	VMXNET3_REG_DSAH	= 0x18,	/* Driver Shared Address High */
 | 
			
		||||
	VMXNET3_REG_CMD		= 0x20,	/* Command */
 | 
			
		||||
	VMXNET3_REG_MACL	= 0x28,	/* MAC Address Low */
 | 
			
		||||
	VMXNET3_REG_MACH	= 0x30,	/* MAC Address High */
 | 
			
		||||
	VMXNET3_REG_ICR		= 0x38,	/* Interrupt Cause Register */
 | 
			
		||||
	VMXNET3_REG_ECR		= 0x40	/* Event Cause Register */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* BAR 0 */
 | 
			
		||||
enum {
 | 
			
		||||
	VMXNET3_REG_IMR		= 0x0,	 /* Interrupt Mask Register */
 | 
			
		||||
	VMXNET3_REG_TXPROD	= 0x600, /* Tx Producer Index */
 | 
			
		||||
	VMXNET3_REG_RXPROD	= 0x800, /* Rx Producer Index for ring 1 */
 | 
			
		||||
	VMXNET3_REG_RXPROD2	= 0xA00	 /* Rx Producer Index for ring 2 */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_PT_REG_SIZE     4096	/* BAR 0 */
 | 
			
		||||
#define VMXNET3_VD_REG_SIZE     4096	/* BAR 1 */
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_REG_ALIGN       8	/* All registers are 8-byte aligned. */
 | 
			
		||||
#define VMXNET3_REG_ALIGN_MASK  0x7
 | 
			
		||||
 | 
			
		||||
/* I/O Mapped access to registers */
 | 
			
		||||
#define VMXNET3_IO_TYPE_PT              0
 | 
			
		||||
#define VMXNET3_IO_TYPE_VD              1
 | 
			
		||||
#define VMXNET3_IO_ADDR(type, reg)      (((type) << 24) | ((reg) & 0xFFFFFF))
 | 
			
		||||
#define VMXNET3_IO_TYPE(addr)           ((addr) >> 24)
 | 
			
		||||
#define VMXNET3_IO_REG(addr)            ((addr) & 0xFFFFFF)
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
	VMXNET3_CMD_FIRST_SET = 0xCAFE0000,
 | 
			
		||||
	VMXNET3_CMD_ACTIVATE_DEV = VMXNET3_CMD_FIRST_SET,
 | 
			
		||||
	VMXNET3_CMD_QUIESCE_DEV,
 | 
			
		||||
	VMXNET3_CMD_RESET_DEV,
 | 
			
		||||
	VMXNET3_CMD_UPDATE_RX_MODE,
 | 
			
		||||
	VMXNET3_CMD_UPDATE_MAC_FILTERS,
 | 
			
		||||
	VMXNET3_CMD_UPDATE_VLAN_FILTERS,
 | 
			
		||||
	VMXNET3_CMD_UPDATE_RSSIDT,
 | 
			
		||||
	VMXNET3_CMD_UPDATE_IML,
 | 
			
		||||
	VMXNET3_CMD_UPDATE_PMCFG,
 | 
			
		||||
	VMXNET3_CMD_UPDATE_FEATURE,
 | 
			
		||||
	VMXNET3_CMD_LOAD_PLUGIN,
 | 
			
		||||
 | 
			
		||||
	VMXNET3_CMD_FIRST_GET = 0xF00D0000,
 | 
			
		||||
	VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
 | 
			
		||||
	VMXNET3_CMD_GET_STATS,
 | 
			
		||||
	VMXNET3_CMD_GET_LINK,
 | 
			
		||||
	VMXNET3_CMD_GET_PERM_MAC_LO,
 | 
			
		||||
	VMXNET3_CMD_GET_PERM_MAC_HI,
 | 
			
		||||
	VMXNET3_CMD_GET_DID_LO,
 | 
			
		||||
	VMXNET3_CMD_GET_DID_HI,
 | 
			
		||||
	VMXNET3_CMD_GET_DEV_EXTRA_INFO,
 | 
			
		||||
	VMXNET3_CMD_GET_CONF_INTR
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_TxDesc {
 | 
			
		||||
	u64		addr;
 | 
			
		||||
 | 
			
		||||
	u32		len:14;
 | 
			
		||||
	u32		gen:1;      /* generation bit */
 | 
			
		||||
	u32		rsvd:1;
 | 
			
		||||
	u32		dtype:1;    /* descriptor type */
 | 
			
		||||
	u32		ext1:1;
 | 
			
		||||
	u32		msscof:14;  /* MSS, checksum offset, flags */
 | 
			
		||||
 | 
			
		||||
	u32		hlen:10;    /* header len */
 | 
			
		||||
	u32		om:2;       /* offload mode */
 | 
			
		||||
	u32		eop:1;      /* End Of Packet */
 | 
			
		||||
	u32		cq:1;       /* completion request */
 | 
			
		||||
	u32		ext2:1;
 | 
			
		||||
	u32		ti:1;       /* VLAN Tag Insertion */
 | 
			
		||||
	u32		tci:16;     /* Tag to Insert */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* TxDesc.OM values */
 | 
			
		||||
#define VMXNET3_OM_NONE		0
 | 
			
		||||
#define VMXNET3_OM_CSUM		2
 | 
			
		||||
#define VMXNET3_OM_TSO		3
 | 
			
		||||
 | 
			
		||||
/* fields in TxDesc we access w/o using bit fields */
 | 
			
		||||
#define VMXNET3_TXD_EOP_SHIFT	12
 | 
			
		||||
#define VMXNET3_TXD_CQ_SHIFT	13
 | 
			
		||||
#define VMXNET3_TXD_GEN_SHIFT	14
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_TXD_CQ		(1 << VMXNET3_TXD_CQ_SHIFT)
 | 
			
		||||
#define VMXNET3_TXD_EOP		(1 << VMXNET3_TXD_EOP_SHIFT)
 | 
			
		||||
#define VMXNET3_TXD_GEN		(1 << VMXNET3_TXD_GEN_SHIFT)
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_HDR_COPY_SIZE   128
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_TxDataDesc {
 | 
			
		||||
	u8		data[VMXNET3_HDR_COPY_SIZE];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_TxCompDesc {
 | 
			
		||||
	u32		txdIdx:12;    /* Index of the EOP TxDesc */
 | 
			
		||||
	u32		ext1:20;
 | 
			
		||||
 | 
			
		||||
	u32		ext2;
 | 
			
		||||
	u32		ext3;
 | 
			
		||||
 | 
			
		||||
	u32		rsvd:24;
 | 
			
		||||
	u32		type:7;       /* completion type */
 | 
			
		||||
	u32		gen:1;        /* generation bit */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_RxDesc {
 | 
			
		||||
	u64		addr;
 | 
			
		||||
 | 
			
		||||
	u32		len:14;
 | 
			
		||||
	u32		btype:1;      /* Buffer Type */
 | 
			
		||||
	u32		dtype:1;      /* Descriptor type */
 | 
			
		||||
	u32		rsvd:15;
 | 
			
		||||
	u32		gen:1;        /* Generation bit */
 | 
			
		||||
 | 
			
		||||
	u32		ext1;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* values of RXD.BTYPE */
 | 
			
		||||
#define VMXNET3_RXD_BTYPE_HEAD   0    /* head only */
 | 
			
		||||
#define VMXNET3_RXD_BTYPE_BODY   1    /* body only */
 | 
			
		||||
 | 
			
		||||
/* fields in RxDesc we access w/o using bit fields */
 | 
			
		||||
#define VMXNET3_RXD_BTYPE_SHIFT  14
 | 
			
		||||
#define VMXNET3_RXD_GEN_SHIFT    31
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_RxCompDesc {
 | 
			
		||||
	u32		rxdIdx:12;    /* Index of the RxDesc */
 | 
			
		||||
	u32		ext1:2;
 | 
			
		||||
	u32		eop:1;        /* End of Packet */
 | 
			
		||||
	u32		sop:1;        /* Start of Packet */
 | 
			
		||||
	u32		rqID:10;      /* rx queue/ring ID */
 | 
			
		||||
	u32		rssType:4;    /* RSS hash type used */
 | 
			
		||||
	u32		cnc:1;        /* Checksum Not Calculated */
 | 
			
		||||
	u32		ext2:1;
 | 
			
		||||
 | 
			
		||||
	u32		rssHash;      /* RSS hash value */
 | 
			
		||||
 | 
			
		||||
	u32		len:14;       /* data length */
 | 
			
		||||
	u32		err:1;        /* Error */
 | 
			
		||||
	u32		ts:1;         /* Tag is stripped */
 | 
			
		||||
	u32		tci:16;       /* Tag stripped */
 | 
			
		||||
 | 
			
		||||
	u32		csum:16;
 | 
			
		||||
	u32		tuc:1;        /* TCP/UDP Checksum Correct */
 | 
			
		||||
	u32		udp:1;        /* UDP packet */
 | 
			
		||||
	u32		tcp:1;        /* TCP packet */
 | 
			
		||||
	u32		ipc:1;        /* IP Checksum Correct */
 | 
			
		||||
	u32		v6:1;         /* IPv6 */
 | 
			
		||||
	u32		v4:1;         /* IPv4 */
 | 
			
		||||
	u32		frg:1;        /* IP Fragment */
 | 
			
		||||
	u32		fcs:1;        /* Frame CRC correct */
 | 
			
		||||
	u32		type:7;       /* completion type */
 | 
			
		||||
	u32		gen:1;        /* generation bit */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */
 | 
			
		||||
#define VMXNET3_RCD_TUC_SHIFT	16
 | 
			
		||||
#define VMXNET3_RCD_IPC_SHIFT	19
 | 
			
		||||
 | 
			
		||||
/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.qword[1] */
 | 
			
		||||
#define VMXNET3_RCD_TYPE_SHIFT	56
 | 
			
		||||
#define VMXNET3_RCD_GEN_SHIFT	63
 | 
			
		||||
 | 
			
		||||
/* csum OK for TCP/UDP pkts over IP */
 | 
			
		||||
#define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \
 | 
			
		||||
			     1 << VMXNET3_RCD_IPC_SHIFT)
 | 
			
		||||
 | 
			
		||||
/* value of RxCompDesc.rssType */
 | 
			
		||||
enum {
 | 
			
		||||
	VMXNET3_RCD_RSS_TYPE_NONE     = 0,
 | 
			
		||||
	VMXNET3_RCD_RSS_TYPE_IPV4     = 1,
 | 
			
		||||
	VMXNET3_RCD_RSS_TYPE_TCPIPV4  = 2,
 | 
			
		||||
	VMXNET3_RCD_RSS_TYPE_IPV6     = 3,
 | 
			
		||||
	VMXNET3_RCD_RSS_TYPE_TCPIPV6  = 4,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* a union for accessing all cmd/completion descriptors */
 | 
			
		||||
union Vmxnet3_GenericDesc {
 | 
			
		||||
	u64				qword[2];
 | 
			
		||||
	u32				dword[4];
 | 
			
		||||
	u16				word[8];
 | 
			
		||||
	struct Vmxnet3_TxDesc		txd;
 | 
			
		||||
	struct Vmxnet3_RxDesc		rxd;
 | 
			
		||||
	struct Vmxnet3_TxCompDesc	tcd;
 | 
			
		||||
	struct Vmxnet3_RxCompDesc	rcd;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_INIT_GEN       1
 | 
			
		||||
 | 
			
		||||
/* Max size of a single tx buffer */
 | 
			
		||||
#define VMXNET3_MAX_TX_BUF_SIZE  (1 << 14)
 | 
			
		||||
 | 
			
		||||
/* # of tx desc needed for a tx buffer size */
 | 
			
		||||
#define VMXNET3_TXD_NEEDED(size) (((size) + VMXNET3_MAX_TX_BUF_SIZE - 1) / \
 | 
			
		||||
				  VMXNET3_MAX_TX_BUF_SIZE)
 | 
			
		||||
 | 
			
		||||
/* max # of tx descs for a non-tso pkt */
 | 
			
		||||
#define VMXNET3_MAX_TXD_PER_PKT 16
 | 
			
		||||
 | 
			
		||||
/* Max size of a single rx buffer */
 | 
			
		||||
#define VMXNET3_MAX_RX_BUF_SIZE  ((1 << 14) - 1)
 | 
			
		||||
/* Minimum size of a type 0 buffer */
 | 
			
		||||
#define VMXNET3_MIN_T0_BUF_SIZE  128
 | 
			
		||||
#define VMXNET3_MAX_CSUM_OFFSET  1024
 | 
			
		||||
 | 
			
		||||
/* Ring base address alignment */
 | 
			
		||||
#define VMXNET3_RING_BA_ALIGN   512
 | 
			
		||||
#define VMXNET3_RING_BA_MASK    (VMXNET3_RING_BA_ALIGN - 1)
 | 
			
		||||
 | 
			
		||||
/* Ring size must be a multiple of 32 */
 | 
			
		||||
#define VMXNET3_RING_SIZE_ALIGN 32
 | 
			
		||||
#define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 | 
			
		||||
 | 
			
		||||
/* Max ring size */
 | 
			
		||||
#define VMXNET3_TX_RING_MAX_SIZE   4096
 | 
			
		||||
#define VMXNET3_TC_RING_MAX_SIZE   4096
 | 
			
		||||
#define VMXNET3_RX_RING_MAX_SIZE   4096
 | 
			
		||||
#define VMXNET3_RC_RING_MAX_SIZE   8192
 | 
			
		||||
 | 
			
		||||
/* a list of reasons for queue stop */
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
 VMXNET3_ERR_NOEOP        = 0x80000000,  /* cannot find the EOP desc of a pkt */
 | 
			
		||||
 VMXNET3_ERR_TXD_REUSE    = 0x80000001,  /* reuse TxDesc before tx completion */
 | 
			
		||||
 VMXNET3_ERR_BIG_PKT      = 0x80000002,  /* too many TxDesc for a pkt */
 | 
			
		||||
 VMXNET3_ERR_DESC_NOT_SPT = 0x80000003,  /* descriptor type not supported */
 | 
			
		||||
 VMXNET3_ERR_SMALL_BUF    = 0x80000004,  /* type 0 buffer too small */
 | 
			
		||||
 VMXNET3_ERR_STRESS       = 0x80000005,  /* stress option firing in vmkernel */
 | 
			
		||||
 VMXNET3_ERR_SWITCH       = 0x80000006,  /* mode switch failure */
 | 
			
		||||
 VMXNET3_ERR_TXD_INVALID  = 0x80000007,  /* invalid TxDesc */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* completion descriptor types */
 | 
			
		||||
#define VMXNET3_CDTYPE_TXCOMP      0    /* Tx Completion Descriptor */
 | 
			
		||||
#define VMXNET3_CDTYPE_RXCOMP      3    /* Rx Completion Descriptor */
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
	VMXNET3_GOS_BITS_UNK    = 0,   /* unknown */
 | 
			
		||||
	VMXNET3_GOS_BITS_32     = 1,
 | 
			
		||||
	VMXNET3_GOS_BITS_64     = 2,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_GOS_TYPE_LINUX	1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_GOSInfo {
 | 
			
		||||
	u32				gosBits:2;	/* 32-bit or 64-bit? */
 | 
			
		||||
	u32				gosType:4;   /* which guest */
 | 
			
		||||
	u32				gosVer:16;   /* gos version */
 | 
			
		||||
	u32				gosMisc:10;  /* other info about gos */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_DriverInfo {
 | 
			
		||||
	u32				version;
 | 
			
		||||
	struct Vmxnet3_GOSInfo		gos;
 | 
			
		||||
	u32				vmxnet3RevSpt;
 | 
			
		||||
	u32				uptVerSpt;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_REV1_MAGIC  0xbabefee1
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * QueueDescPA must be 128 bytes aligned. It points to an array of
 | 
			
		||||
 * Vmxnet3_TxQueueDesc followed by an array of Vmxnet3_RxQueueDesc.
 | 
			
		||||
 * The number of Vmxnet3_TxQueueDesc/Vmxnet3_RxQueueDesc are specified by
 | 
			
		||||
 * Vmxnet3_MiscConf.numTxQueues/numRxQueues, respectively.
 | 
			
		||||
 */
 | 
			
		||||
#define VMXNET3_QUEUE_DESC_ALIGN  128
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_MiscConf {
 | 
			
		||||
	struct Vmxnet3_DriverInfo driverInfo;
 | 
			
		||||
	u64		uptFeatures;
 | 
			
		||||
	u64		ddPA;         /* driver data PA */
 | 
			
		||||
	u64		queueDescPA;  /* queue descriptor table PA */
 | 
			
		||||
	u32		ddLen;        /* driver data len */
 | 
			
		||||
	u32		queueDescLen; /* queue desc. table len in bytes */
 | 
			
		||||
	u32		mtu;
 | 
			
		||||
	u16		maxNumRxSG;
 | 
			
		||||
	u8		numTxQueues;
 | 
			
		||||
	u8		numRxQueues;
 | 
			
		||||
	u32		reserved[4];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_TxQueueConf {
 | 
			
		||||
	u64		txRingBasePA;
 | 
			
		||||
	u64		dataRingBasePA;
 | 
			
		||||
	u64		compRingBasePA;
 | 
			
		||||
	u64		ddPA;         /* driver data */
 | 
			
		||||
	u64		reserved;
 | 
			
		||||
	u32		txRingSize;   /* # of tx desc */
 | 
			
		||||
	u32		dataRingSize; /* # of data desc */
 | 
			
		||||
	u32		compRingSize; /* # of comp desc */
 | 
			
		||||
	u32		ddLen;        /* size of driver data */
 | 
			
		||||
	u8		intrIdx;
 | 
			
		||||
	u8		_pad[7];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_RxQueueConf {
 | 
			
		||||
	u64		rxRingBasePA[2];
 | 
			
		||||
	u64		compRingBasePA;
 | 
			
		||||
	u64		ddPA;            /* driver data */
 | 
			
		||||
	u64		reserved;
 | 
			
		||||
	u32		rxRingSize[2];   /* # of rx desc */
 | 
			
		||||
	u32		compRingSize;    /* # of rx comp desc */
 | 
			
		||||
	u32		ddLen;           /* size of driver data */
 | 
			
		||||
	u8		intrIdx;
 | 
			
		||||
	u8		_pad[7];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
enum vmxnet3_intr_mask_mode {
 | 
			
		||||
	VMXNET3_IMM_AUTO   = 0,
 | 
			
		||||
	VMXNET3_IMM_ACTIVE = 1,
 | 
			
		||||
	VMXNET3_IMM_LAZY   = 2
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum vmxnet3_intr_type {
 | 
			
		||||
	VMXNET3_IT_AUTO = 0,
 | 
			
		||||
	VMXNET3_IT_INTX = 1,
 | 
			
		||||
	VMXNET3_IT_MSI  = 2,
 | 
			
		||||
	VMXNET3_IT_MSIX = 3
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_MAX_TX_QUEUES  8
 | 
			
		||||
#define VMXNET3_MAX_RX_QUEUES  16
 | 
			
		||||
/* addition 1 for events */
 | 
			
		||||
#define VMXNET3_MAX_INTRS      25
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_IntrConf {
 | 
			
		||||
	bool		autoMask;
 | 
			
		||||
	u8		numIntrs;      /* # of interrupts */
 | 
			
		||||
	u8		eventIntrIdx;
 | 
			
		||||
	u8		modLevels[VMXNET3_MAX_INTRS];	/* moderation level for
 | 
			
		||||
							 * each intr */
 | 
			
		||||
	u32		reserved[3];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* one bit per VLAN ID, the size is in the units of u32	*/
 | 
			
		||||
#define VMXNET3_VFT_SIZE  (4096 / (sizeof(u32) * 8))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_QueueStatus {
 | 
			
		||||
	bool		stopped;
 | 
			
		||||
	u8		_pad[3];
 | 
			
		||||
	u32		error;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_TxQueueCtrl {
 | 
			
		||||
	u32		txNumDeferred;
 | 
			
		||||
	u32		txThreshold;
 | 
			
		||||
	u64		reserved;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_RxQueueCtrl {
 | 
			
		||||
	bool		updateRxProd;
 | 
			
		||||
	u8		_pad[7];
 | 
			
		||||
	u64		reserved;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
	VMXNET3_RXM_UCAST     = 0x01,  /* unicast only */
 | 
			
		||||
	VMXNET3_RXM_MCAST     = 0x02,  /* multicast passing the filters */
 | 
			
		||||
	VMXNET3_RXM_BCAST     = 0x04,  /* broadcast only */
 | 
			
		||||
	VMXNET3_RXM_ALL_MULTI = 0x08,  /* all multicast */
 | 
			
		||||
	VMXNET3_RXM_PROMISC   = 0x10  /* promiscuous */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_RxFilterConf {
 | 
			
		||||
	u32		rxMode;       /* VMXNET3_RXM_xxx */
 | 
			
		||||
	u16		mfTableLen;   /* size of the multicast filter table */
 | 
			
		||||
	u16		_pad1;
 | 
			
		||||
	u64		mfTablePA;    /* PA of the multicast filters table */
 | 
			
		||||
	u32		vfTable[VMXNET3_VFT_SIZE]; /* vlan filter */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_PM_MAX_FILTERS        6
 | 
			
		||||
#define VMXNET3_PM_MAX_PATTERN_SIZE   128
 | 
			
		||||
#define VMXNET3_PM_MAX_MASK_SIZE      (VMXNET3_PM_MAX_PATTERN_SIZE / 8)
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_PM_WAKEUP_MAGIC       0x01  /* wake up on magic pkts */
 | 
			
		||||
#define VMXNET3_PM_WAKEUP_FILTER      0x02  /* wake up on pkts matching
 | 
			
		||||
					     * filters */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_PM_PktFilter {
 | 
			
		||||
	u8		maskSize;
 | 
			
		||||
	u8		patternSize;
 | 
			
		||||
	u8		mask[VMXNET3_PM_MAX_MASK_SIZE];
 | 
			
		||||
	u8		pattern[VMXNET3_PM_MAX_PATTERN_SIZE];
 | 
			
		||||
	u8		pad[6];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_PMConf {
 | 
			
		||||
	u16		wakeUpEvents;  /* VMXNET3_PM_WAKEUP_xxx */
 | 
			
		||||
	u8		numFilters;
 | 
			
		||||
	u8		pad[5];
 | 
			
		||||
	struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_VariableLenConfDesc {
 | 
			
		||||
	u32		confVer;
 | 
			
		||||
	u32		confLen;
 | 
			
		||||
	u64		confPA;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_TxQueueDesc {
 | 
			
		||||
	struct Vmxnet3_TxQueueCtrl		ctrl;
 | 
			
		||||
	struct Vmxnet3_TxQueueConf		conf;
 | 
			
		||||
 | 
			
		||||
	/* Driver read after a GET command */
 | 
			
		||||
	struct Vmxnet3_QueueStatus		status;
 | 
			
		||||
	struct UPT1_TxStats			stats;
 | 
			
		||||
	u8					_pad[88]; /* 128 aligned */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_RxQueueDesc {
 | 
			
		||||
	struct Vmxnet3_RxQueueCtrl		ctrl;
 | 
			
		||||
	struct Vmxnet3_RxQueueConf		conf;
 | 
			
		||||
	/* Driver read after a GET commad */
 | 
			
		||||
	struct Vmxnet3_QueueStatus		status;
 | 
			
		||||
	struct UPT1_RxStats			stats;
 | 
			
		||||
	u8				      __pad[88]; /* 128 aligned */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct Vmxnet3_DSDevRead {
 | 
			
		||||
	/* read-only region for device, read by dev in response to a SET cmd */
 | 
			
		||||
	struct Vmxnet3_MiscConf			misc;
 | 
			
		||||
	struct Vmxnet3_IntrConf			intrConf;
 | 
			
		||||
	struct Vmxnet3_RxFilterConf		rxFilterConf;
 | 
			
		||||
	struct Vmxnet3_VariableLenConfDesc	rssConfDesc;
 | 
			
		||||
	struct Vmxnet3_VariableLenConfDesc	pmConfDesc;
 | 
			
		||||
	struct Vmxnet3_VariableLenConfDesc	pluginConfDesc;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* All structures in DriverShared are padded to multiples of 8 bytes */
 | 
			
		||||
struct Vmxnet3_DriverShared {
 | 
			
		||||
	u32				magic;
 | 
			
		||||
	/* make devRead start at 64bit boundaries */
 | 
			
		||||
	u32					pad;
 | 
			
		||||
	struct Vmxnet3_DSDevRead		devRead;
 | 
			
		||||
	u32					ecr;
 | 
			
		||||
	u32					reserved[5];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_ECR_RQERR       (1 << 0)
 | 
			
		||||
#define VMXNET3_ECR_TQERR       (1 << 1)
 | 
			
		||||
#define VMXNET3_ECR_LINK        (1 << 2)
 | 
			
		||||
#define VMXNET3_ECR_DIC         (1 << 3)
 | 
			
		||||
#define VMXNET3_ECR_DEBUG       (1 << 4)
 | 
			
		||||
 | 
			
		||||
/* flip the gen bit of a ring */
 | 
			
		||||
#define VMXNET3_FLIP_RING_GEN(gen) ((gen) = (gen) ^ 0x1)
 | 
			
		||||
 | 
			
		||||
/* only use this if moving the idx won't affect the gen bit */
 | 
			
		||||
#define VMXNET3_INC_RING_IDX_ONLY(idx, ring_size) \
 | 
			
		||||
	do {\
 | 
			
		||||
		(idx)++;\
 | 
			
		||||
		if (unlikely((idx) == (ring_size))) {\
 | 
			
		||||
			(idx) = 0;\
 | 
			
		||||
		} \
 | 
			
		||||
	} while (0)
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid) \
 | 
			
		||||
	(vfTable[vid >> 5] |= (1 << (vid & 31)))
 | 
			
		||||
#define VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid) \
 | 
			
		||||
	(vfTable[vid >> 5] &= ~(1 << (vid & 31)))
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_VFTABLE_ENTRY_IS_SET(vfTable, vid) \
 | 
			
		||||
	((vfTable[vid >> 5] & (1 << (vid & 31))) != 0)
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_MAX_MTU     9000
 | 
			
		||||
#define VMXNET3_MIN_MTU     60
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_LINK_UP         (10000 << 16 | 1)    /* 10 Gbps, up */
 | 
			
		||||
#define VMXNET3_LINK_DOWN       0
 | 
			
		||||
 | 
			
		||||
#endif /* _VMXNET3_DEFS_H_ */
 | 
			
		||||
							
								
								
									
										2556
									
								
								drivers/net/vmxnet3/vmxnet3_drv.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2556
									
								
								drivers/net/vmxnet3/vmxnet3_drv.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										566
									
								
								drivers/net/vmxnet3/vmxnet3_ethtool.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										566
									
								
								drivers/net/vmxnet3/vmxnet3_ethtool.c
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,566 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Linux driver for VMware's vmxnet3 ethernet NIC.
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or modify it
 | 
			
		||||
 * under the terms of the GNU General Public License as published by the
 | 
			
		||||
 * Free Software Foundation; version 2 of the License and no later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful, but
 | 
			
		||||
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 | 
			
		||||
 * NON INFRINGEMENT.  See the GNU General Public License for more
 | 
			
		||||
 * details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 *
 | 
			
		||||
 * The full GNU General Public License is included in this distribution in
 | 
			
		||||
 * the file called "COPYING".
 | 
			
		||||
 *
 | 
			
		||||
 * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com>
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "vmxnet3_int.h"
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_stat_desc {
 | 
			
		||||
	char desc[ETH_GSTRING_LEN];
 | 
			
		||||
	int  offset;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static u32
 | 
			
		||||
vmxnet3_get_rx_csum(struct net_device *netdev)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
	return adapter->rxcsum;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
vmxnet3_set_rx_csum(struct net_device *netdev, u32 val)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
 | 
			
		||||
	if (adapter->rxcsum != val) {
 | 
			
		||||
		adapter->rxcsum = val;
 | 
			
		||||
		if (netif_running(netdev)) {
 | 
			
		||||
			if (val)
 | 
			
		||||
				adapter->shared->devRead.misc.uptFeatures |=
 | 
			
		||||
								UPT1_F_RXCSUM;
 | 
			
		||||
			else
 | 
			
		||||
				adapter->shared->devRead.misc.uptFeatures &=
 | 
			
		||||
								~UPT1_F_RXCSUM;
 | 
			
		||||
 | 
			
		||||
			VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
 | 
			
		||||
					       VMXNET3_CMD_UPDATE_FEATURE);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* per tq stats maintained by the device */
 | 
			
		||||
static const struct vmxnet3_stat_desc
 | 
			
		||||
vmxnet3_tq_dev_stats[] = {
 | 
			
		||||
	/* description,         offset */
 | 
			
		||||
	{ "TSO pkts tx",        offsetof(struct UPT1_TxStats, TSOPktsTxOK) },
 | 
			
		||||
	{ "TSO bytes tx",       offsetof(struct UPT1_TxStats, TSOBytesTxOK) },
 | 
			
		||||
	{ "ucast pkts tx",      offsetof(struct UPT1_TxStats, ucastPktsTxOK) },
 | 
			
		||||
	{ "ucast bytes tx",     offsetof(struct UPT1_TxStats, ucastBytesTxOK) },
 | 
			
		||||
	{ "mcast pkts tx",      offsetof(struct UPT1_TxStats, mcastPktsTxOK) },
 | 
			
		||||
	{ "mcast bytes tx",     offsetof(struct UPT1_TxStats, mcastBytesTxOK) },
 | 
			
		||||
	{ "bcast pkts tx",      offsetof(struct UPT1_TxStats, bcastPktsTxOK) },
 | 
			
		||||
	{ "bcast bytes tx",     offsetof(struct UPT1_TxStats, bcastBytesTxOK) },
 | 
			
		||||
	{ "pkts tx err",        offsetof(struct UPT1_TxStats, pktsTxError) },
 | 
			
		||||
	{ "pkts tx discard",    offsetof(struct UPT1_TxStats, pktsTxDiscard) },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* per tq stats maintained by the driver */
 | 
			
		||||
static const struct vmxnet3_stat_desc
 | 
			
		||||
vmxnet3_tq_driver_stats[] = {
 | 
			
		||||
	/* description,         offset */
 | 
			
		||||
	{"drv dropped tx total", offsetof(struct vmxnet3_tq_driver_stats,
 | 
			
		||||
					drop_total) },
 | 
			
		||||
	{ "   too many frags",  offsetof(struct vmxnet3_tq_driver_stats,
 | 
			
		||||
					drop_too_many_frags) },
 | 
			
		||||
	{ "   giant hdr",       offsetof(struct vmxnet3_tq_driver_stats,
 | 
			
		||||
					drop_oversized_hdr) },
 | 
			
		||||
	{ "   hdr err",         offsetof(struct vmxnet3_tq_driver_stats,
 | 
			
		||||
					drop_hdr_inspect_err) },
 | 
			
		||||
	{ "   tso",             offsetof(struct vmxnet3_tq_driver_stats,
 | 
			
		||||
					drop_tso) },
 | 
			
		||||
	{ "ring full",          offsetof(struct vmxnet3_tq_driver_stats,
 | 
			
		||||
					tx_ring_full) },
 | 
			
		||||
	{ "pkts linearized",    offsetof(struct vmxnet3_tq_driver_stats,
 | 
			
		||||
					linearized) },
 | 
			
		||||
	{ "hdr cloned",         offsetof(struct vmxnet3_tq_driver_stats,
 | 
			
		||||
					copy_skb_header) },
 | 
			
		||||
	{ "giant hdr",          offsetof(struct vmxnet3_tq_driver_stats,
 | 
			
		||||
					oversized_hdr) },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* per rq stats maintained by the device */
 | 
			
		||||
static const struct vmxnet3_stat_desc
 | 
			
		||||
vmxnet3_rq_dev_stats[] = {
 | 
			
		||||
	{ "LRO pkts rx",        offsetof(struct UPT1_RxStats, LROPktsRxOK) },
 | 
			
		||||
	{ "LRO byte rx",        offsetof(struct UPT1_RxStats, LROBytesRxOK) },
 | 
			
		||||
	{ "ucast pkts rx",      offsetof(struct UPT1_RxStats, ucastPktsRxOK) },
 | 
			
		||||
	{ "ucast bytes rx",     offsetof(struct UPT1_RxStats, ucastBytesRxOK) },
 | 
			
		||||
	{ "mcast pkts rx",      offsetof(struct UPT1_RxStats, mcastPktsRxOK) },
 | 
			
		||||
	{ "mcast bytes rx",     offsetof(struct UPT1_RxStats, mcastBytesRxOK) },
 | 
			
		||||
	{ "bcast pkts rx",      offsetof(struct UPT1_RxStats, bcastPktsRxOK) },
 | 
			
		||||
	{ "bcast bytes rx",     offsetof(struct UPT1_RxStats, bcastBytesRxOK) },
 | 
			
		||||
	{ "pkts rx out of buf", offsetof(struct UPT1_RxStats, pktsRxOutOfBuf) },
 | 
			
		||||
	{ "pkts rx err",        offsetof(struct UPT1_RxStats, pktsRxError) },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* per rq stats maintained by the driver */
 | 
			
		||||
static const struct vmxnet3_stat_desc
 | 
			
		||||
vmxnet3_rq_driver_stats[] = {
 | 
			
		||||
	/* description,         offset */
 | 
			
		||||
	{ "drv dropped rx total", offsetof(struct vmxnet3_rq_driver_stats,
 | 
			
		||||
					   drop_total) },
 | 
			
		||||
	{ "   err",            offsetof(struct vmxnet3_rq_driver_stats,
 | 
			
		||||
					drop_err) },
 | 
			
		||||
	{ "   fcs",            offsetof(struct vmxnet3_rq_driver_stats,
 | 
			
		||||
					drop_fcs) },
 | 
			
		||||
	{ "rx buf alloc fail", offsetof(struct vmxnet3_rq_driver_stats,
 | 
			
		||||
					rx_buf_alloc_failure) },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* gloabl stats maintained by the driver */
 | 
			
		||||
static const struct vmxnet3_stat_desc
 | 
			
		||||
vmxnet3_global_stats[] = {
 | 
			
		||||
	/* description,         offset */
 | 
			
		||||
	{ "tx timeout count",   offsetof(struct vmxnet3_adapter,
 | 
			
		||||
					 tx_timeout_count) }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct net_device_stats *
 | 
			
		||||
vmxnet3_get_stats(struct net_device *netdev)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter;
 | 
			
		||||
	struct vmxnet3_tq_driver_stats *drvTxStats;
 | 
			
		||||
	struct vmxnet3_rq_driver_stats *drvRxStats;
 | 
			
		||||
	struct UPT1_TxStats *devTxStats;
 | 
			
		||||
	struct UPT1_RxStats *devRxStats;
 | 
			
		||||
	struct net_device_stats *net_stats = &netdev->stats;
 | 
			
		||||
 | 
			
		||||
	adapter = netdev_priv(netdev);
 | 
			
		||||
 | 
			
		||||
	/* Collect the dev stats into the shared area */
 | 
			
		||||
	VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
 | 
			
		||||
 | 
			
		||||
	/* Assuming that we have a single queue device */
 | 
			
		||||
	devTxStats = &adapter->tqd_start->stats;
 | 
			
		||||
	devRxStats = &adapter->rqd_start->stats;
 | 
			
		||||
 | 
			
		||||
	/* Get access to the driver stats per queue */
 | 
			
		||||
	drvTxStats = &adapter->tx_queue.stats;
 | 
			
		||||
	drvRxStats = &adapter->rx_queue.stats;
 | 
			
		||||
 | 
			
		||||
	memset(net_stats, 0, sizeof(*net_stats));
 | 
			
		||||
 | 
			
		||||
	net_stats->rx_packets = devRxStats->ucastPktsRxOK +
 | 
			
		||||
				devRxStats->mcastPktsRxOK +
 | 
			
		||||
				devRxStats->bcastPktsRxOK;
 | 
			
		||||
 | 
			
		||||
	net_stats->tx_packets = devTxStats->ucastPktsTxOK +
 | 
			
		||||
				devTxStats->mcastPktsTxOK +
 | 
			
		||||
				devTxStats->bcastPktsTxOK;
 | 
			
		||||
 | 
			
		||||
	net_stats->rx_bytes = devRxStats->ucastBytesRxOK +
 | 
			
		||||
			      devRxStats->mcastBytesRxOK +
 | 
			
		||||
			      devRxStats->bcastBytesRxOK;
 | 
			
		||||
 | 
			
		||||
	net_stats->tx_bytes = devTxStats->ucastBytesTxOK +
 | 
			
		||||
			      devTxStats->mcastBytesTxOK +
 | 
			
		||||
			      devTxStats->bcastBytesTxOK;
 | 
			
		||||
 | 
			
		||||
	net_stats->rx_errors = devRxStats->pktsRxError;
 | 
			
		||||
	net_stats->tx_errors = devTxStats->pktsTxError;
 | 
			
		||||
	net_stats->rx_dropped = drvRxStats->drop_total;
 | 
			
		||||
	net_stats->tx_dropped = drvTxStats->drop_total;
 | 
			
		||||
	net_stats->multicast =  devRxStats->mcastPktsRxOK;
 | 
			
		||||
 | 
			
		||||
	return net_stats;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
vmxnet3_get_sset_count(struct net_device *netdev, int sset)
 | 
			
		||||
{
 | 
			
		||||
	switch (sset) {
 | 
			
		||||
	case ETH_SS_STATS:
 | 
			
		||||
		return ARRAY_SIZE(vmxnet3_tq_dev_stats) +
 | 
			
		||||
			ARRAY_SIZE(vmxnet3_tq_driver_stats) +
 | 
			
		||||
			ARRAY_SIZE(vmxnet3_rq_dev_stats) +
 | 
			
		||||
			ARRAY_SIZE(vmxnet3_rq_driver_stats) +
 | 
			
		||||
			ARRAY_SIZE(vmxnet3_global_stats);
 | 
			
		||||
	default:
 | 
			
		||||
		return -EOPNOTSUPP;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
vmxnet3_get_regs_len(struct net_device *netdev)
 | 
			
		||||
{
 | 
			
		||||
	return 20 * sizeof(u32);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
 | 
			
		||||
	strlcpy(drvinfo->driver, vmxnet3_driver_name, sizeof(drvinfo->driver));
 | 
			
		||||
	drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';
 | 
			
		||||
 | 
			
		||||
	strlcpy(drvinfo->version, VMXNET3_DRIVER_VERSION_REPORT,
 | 
			
		||||
		sizeof(drvinfo->version));
 | 
			
		||||
	drvinfo->driver[sizeof(drvinfo->version) - 1] = '\0';
 | 
			
		||||
 | 
			
		||||
	strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
 | 
			
		||||
	drvinfo->fw_version[sizeof(drvinfo->fw_version) - 1] = '\0';
 | 
			
		||||
 | 
			
		||||
	strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
 | 
			
		||||
		ETHTOOL_BUSINFO_LEN);
 | 
			
		||||
	drvinfo->n_stats = vmxnet3_get_sset_count(netdev, ETH_SS_STATS);
 | 
			
		||||
	drvinfo->testinfo_len = 0;
 | 
			
		||||
	drvinfo->eedump_len   = 0;
 | 
			
		||||
	drvinfo->regdump_len  = vmxnet3_get_regs_len(netdev);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf)
 | 
			
		||||
{
 | 
			
		||||
	if (stringset == ETH_SS_STATS) {
 | 
			
		||||
		int i;
 | 
			
		||||
 | 
			
		||||
		for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) {
 | 
			
		||||
			memcpy(buf, vmxnet3_tq_dev_stats[i].desc,
 | 
			
		||||
			       ETH_GSTRING_LEN);
 | 
			
		||||
			buf += ETH_GSTRING_LEN;
 | 
			
		||||
		}
 | 
			
		||||
		for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++) {
 | 
			
		||||
			memcpy(buf, vmxnet3_tq_driver_stats[i].desc,
 | 
			
		||||
			       ETH_GSTRING_LEN);
 | 
			
		||||
			buf += ETH_GSTRING_LEN;
 | 
			
		||||
		}
 | 
			
		||||
		for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) {
 | 
			
		||||
			memcpy(buf, vmxnet3_rq_dev_stats[i].desc,
 | 
			
		||||
			       ETH_GSTRING_LEN);
 | 
			
		||||
			buf += ETH_GSTRING_LEN;
 | 
			
		||||
		}
 | 
			
		||||
		for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++) {
 | 
			
		||||
			memcpy(buf, vmxnet3_rq_driver_stats[i].desc,
 | 
			
		||||
			       ETH_GSTRING_LEN);
 | 
			
		||||
			buf += ETH_GSTRING_LEN;
 | 
			
		||||
		}
 | 
			
		||||
		for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) {
 | 
			
		||||
			memcpy(buf, vmxnet3_global_stats[i].desc,
 | 
			
		||||
				ETH_GSTRING_LEN);
 | 
			
		||||
			buf += ETH_GSTRING_LEN;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static u32
 | 
			
		||||
vmxnet3_get_flags(struct net_device *netdev) {
 | 
			
		||||
	return netdev->features;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
vmxnet3_set_flags(struct net_device *netdev, u32 data) {
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
	u8 lro_requested = (data & ETH_FLAG_LRO) == 0 ? 0 : 1;
 | 
			
		||||
	u8 lro_present = (netdev->features & NETIF_F_LRO) == 0 ? 0 : 1;
 | 
			
		||||
 | 
			
		||||
	if (lro_requested ^ lro_present) {
 | 
			
		||||
		/* toggle the LRO feature*/
 | 
			
		||||
		netdev->features ^= NETIF_F_LRO;
 | 
			
		||||
 | 
			
		||||
		/* update harware LRO capability accordingly */
 | 
			
		||||
		if (lro_requested)
 | 
			
		||||
			adapter->shared->devRead.misc.uptFeatures &= UPT1_F_LRO;
 | 
			
		||||
		else
 | 
			
		||||
			adapter->shared->devRead.misc.uptFeatures &=
 | 
			
		||||
								~UPT1_F_LRO;
 | 
			
		||||
		VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
 | 
			
		||||
				       VMXNET3_CMD_UPDATE_FEATURE);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
vmxnet3_get_ethtool_stats(struct net_device *netdev,
 | 
			
		||||
			  struct ethtool_stats *stats, u64  *buf)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
	u8 *base;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
 | 
			
		||||
 | 
			
		||||
	/* this does assume each counter is 64-bit wide */
 | 
			
		||||
 | 
			
		||||
	base = (u8 *)&adapter->tqd_start->stats;
 | 
			
		||||
	for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++)
 | 
			
		||||
		*buf++ = *(u64 *)(base + vmxnet3_tq_dev_stats[i].offset);
 | 
			
		||||
 | 
			
		||||
	base = (u8 *)&adapter->tx_queue.stats;
 | 
			
		||||
	for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++)
 | 
			
		||||
		*buf++ = *(u64 *)(base + vmxnet3_tq_driver_stats[i].offset);
 | 
			
		||||
 | 
			
		||||
	base = (u8 *)&adapter->rqd_start->stats;
 | 
			
		||||
	for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++)
 | 
			
		||||
		*buf++ = *(u64 *)(base + vmxnet3_rq_dev_stats[i].offset);
 | 
			
		||||
 | 
			
		||||
	base = (u8 *)&adapter->rx_queue.stats;
 | 
			
		||||
	for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++)
 | 
			
		||||
		*buf++ = *(u64 *)(base + vmxnet3_rq_driver_stats[i].offset);
 | 
			
		||||
 | 
			
		||||
	base = (u8 *)adapter;
 | 
			
		||||
	for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++)
 | 
			
		||||
		*buf++ = *(u64 *)(base + vmxnet3_global_stats[i].offset);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
vmxnet3_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
	u32 *buf = p;
 | 
			
		||||
 | 
			
		||||
	memset(p, 0, vmxnet3_get_regs_len(netdev));
 | 
			
		||||
 | 
			
		||||
	regs->version = 1;
 | 
			
		||||
 | 
			
		||||
	/* Update vmxnet3_get_regs_len if we want to dump more registers */
 | 
			
		||||
 | 
			
		||||
	/* make each ring use multiple of 16 bytes */
 | 
			
		||||
	buf[0] = adapter->tx_queue.tx_ring.next2fill;
 | 
			
		||||
	buf[1] = adapter->tx_queue.tx_ring.next2comp;
 | 
			
		||||
	buf[2] = adapter->tx_queue.tx_ring.gen;
 | 
			
		||||
	buf[3] = 0;
 | 
			
		||||
 | 
			
		||||
	buf[4] = adapter->tx_queue.comp_ring.next2proc;
 | 
			
		||||
	buf[5] = adapter->tx_queue.comp_ring.gen;
 | 
			
		||||
	buf[6] = adapter->tx_queue.stopped;
 | 
			
		||||
	buf[7] = 0;
 | 
			
		||||
 | 
			
		||||
	buf[8] = adapter->rx_queue.rx_ring[0].next2fill;
 | 
			
		||||
	buf[9] = adapter->rx_queue.rx_ring[0].next2comp;
 | 
			
		||||
	buf[10] = adapter->rx_queue.rx_ring[0].gen;
 | 
			
		||||
	buf[11] = 0;
 | 
			
		||||
 | 
			
		||||
	buf[12] = adapter->rx_queue.rx_ring[1].next2fill;
 | 
			
		||||
	buf[13] = adapter->rx_queue.rx_ring[1].next2comp;
 | 
			
		||||
	buf[14] = adapter->rx_queue.rx_ring[1].gen;
 | 
			
		||||
	buf[15] = 0;
 | 
			
		||||
 | 
			
		||||
	buf[16] = adapter->rx_queue.comp_ring.next2proc;
 | 
			
		||||
	buf[17] = adapter->rx_queue.comp_ring.gen;
 | 
			
		||||
	buf[18] = 0;
 | 
			
		||||
	buf[19] = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
vmxnet3_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
 | 
			
		||||
	wol->supported = WAKE_UCAST | WAKE_ARP | WAKE_MAGIC;
 | 
			
		||||
	wol->wolopts = adapter->wol;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
vmxnet3_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
 | 
			
		||||
	if (wol->wolopts & (WAKE_PHY | WAKE_MCAST | WAKE_BCAST |
 | 
			
		||||
			    WAKE_MAGICSECURE)) {
 | 
			
		||||
		return -EOPNOTSUPP;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	adapter->wol = wol->wolopts;
 | 
			
		||||
 | 
			
		||||
	device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
vmxnet3_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
 | 
			
		||||
	ecmd->supported = SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full |
 | 
			
		||||
			  SUPPORTED_TP;
 | 
			
		||||
	ecmd->advertising = ADVERTISED_TP;
 | 
			
		||||
	ecmd->port = PORT_TP;
 | 
			
		||||
	ecmd->transceiver = XCVR_INTERNAL;
 | 
			
		||||
 | 
			
		||||
	if (adapter->link_speed) {
 | 
			
		||||
		ecmd->speed = adapter->link_speed;
 | 
			
		||||
		ecmd->duplex = DUPLEX_FULL;
 | 
			
		||||
	} else {
 | 
			
		||||
		ecmd->speed = -1;
 | 
			
		||||
		ecmd->duplex = -1;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
vmxnet3_get_ringparam(struct net_device *netdev,
 | 
			
		||||
		      struct ethtool_ringparam *param)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
 | 
			
		||||
	param->rx_max_pending = VMXNET3_RX_RING_MAX_SIZE;
 | 
			
		||||
	param->tx_max_pending = VMXNET3_TX_RING_MAX_SIZE;
 | 
			
		||||
	param->rx_mini_max_pending = 0;
 | 
			
		||||
	param->rx_jumbo_max_pending = 0;
 | 
			
		||||
 | 
			
		||||
	param->rx_pending = adapter->rx_queue.rx_ring[0].size;
 | 
			
		||||
	param->tx_pending = adapter->tx_queue.tx_ring.size;
 | 
			
		||||
	param->rx_mini_pending = 0;
 | 
			
		||||
	param->rx_jumbo_pending = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
vmxnet3_set_ringparam(struct net_device *netdev,
 | 
			
		||||
		      struct ethtool_ringparam *param)
 | 
			
		||||
{
 | 
			
		||||
	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
 | 
			
		||||
	u32 new_tx_ring_size, new_rx_ring_size;
 | 
			
		||||
	u32 sz;
 | 
			
		||||
	int err = 0;
 | 
			
		||||
 | 
			
		||||
	if (param->tx_pending == 0 || param->tx_pending >
 | 
			
		||||
						VMXNET3_TX_RING_MAX_SIZE)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
	if (param->rx_pending == 0 || param->rx_pending >
 | 
			
		||||
						VMXNET3_RX_RING_MAX_SIZE)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/* round it up to a multiple of VMXNET3_RING_SIZE_ALIGN */
 | 
			
		||||
	new_tx_ring_size = (param->tx_pending + VMXNET3_RING_SIZE_MASK) &
 | 
			
		||||
							~VMXNET3_RING_SIZE_MASK;
 | 
			
		||||
	new_tx_ring_size = min_t(u32, new_tx_ring_size,
 | 
			
		||||
				 VMXNET3_TX_RING_MAX_SIZE);
 | 
			
		||||
	if (new_tx_ring_size > VMXNET3_TX_RING_MAX_SIZE || (new_tx_ring_size %
 | 
			
		||||
						VMXNET3_RING_SIZE_ALIGN) != 0)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
	/* ring0 has to be a multiple of
 | 
			
		||||
	 * rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN
 | 
			
		||||
	 */
 | 
			
		||||
	sz = adapter->rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN;
 | 
			
		||||
	new_rx_ring_size = (param->rx_pending + sz - 1) / sz * sz;
 | 
			
		||||
	new_rx_ring_size = min_t(u32, new_rx_ring_size,
 | 
			
		||||
				 VMXNET3_RX_RING_MAX_SIZE / sz * sz);
 | 
			
		||||
	if (new_rx_ring_size > VMXNET3_RX_RING_MAX_SIZE || (new_rx_ring_size %
 | 
			
		||||
							   sz) != 0)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
	if (new_tx_ring_size == adapter->tx_queue.tx_ring.size &&
 | 
			
		||||
			new_rx_ring_size == adapter->rx_queue.rx_ring[0].size) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Reset_work may be in the middle of resetting the device, wait for its
 | 
			
		||||
	 * completion.
 | 
			
		||||
	 */
 | 
			
		||||
	while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state))
 | 
			
		||||
		msleep(1);
 | 
			
		||||
 | 
			
		||||
	if (netif_running(netdev)) {
 | 
			
		||||
		vmxnet3_quiesce_dev(adapter);
 | 
			
		||||
		vmxnet3_reset_dev(adapter);
 | 
			
		||||
 | 
			
		||||
		/* recreate the rx queue and the tx queue based on the
 | 
			
		||||
		 * new sizes */
 | 
			
		||||
		vmxnet3_tq_destroy(&adapter->tx_queue, adapter);
 | 
			
		||||
		vmxnet3_rq_destroy(&adapter->rx_queue, adapter);
 | 
			
		||||
 | 
			
		||||
		err = vmxnet3_create_queues(adapter, new_tx_ring_size,
 | 
			
		||||
			new_rx_ring_size, VMXNET3_DEF_RX_RING_SIZE);
 | 
			
		||||
		if (err) {
 | 
			
		||||
			/* failed, most likely because of OOM, try default
 | 
			
		||||
			 * size */
 | 
			
		||||
			printk(KERN_ERR "%s: failed to apply new sizes, try the"
 | 
			
		||||
				" default ones\n", netdev->name);
 | 
			
		||||
			err = vmxnet3_create_queues(adapter,
 | 
			
		||||
						    VMXNET3_DEF_TX_RING_SIZE,
 | 
			
		||||
						    VMXNET3_DEF_RX_RING_SIZE,
 | 
			
		||||
						    VMXNET3_DEF_RX_RING_SIZE);
 | 
			
		||||
			if (err) {
 | 
			
		||||
				printk(KERN_ERR "%s: failed to create queues "
 | 
			
		||||
					"with default sizes. Closing it\n",
 | 
			
		||||
					netdev->name);
 | 
			
		||||
				goto out;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		err = vmxnet3_activate_dev(adapter);
 | 
			
		||||
		if (err)
 | 
			
		||||
			printk(KERN_ERR "%s: failed to re-activate, error %d."
 | 
			
		||||
				" Closing it\n", netdev->name, err);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
out:
 | 
			
		||||
	clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state);
 | 
			
		||||
	if (err)
 | 
			
		||||
		vmxnet3_force_close(adapter);
 | 
			
		||||
 | 
			
		||||
	return err;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static struct ethtool_ops vmxnet3_ethtool_ops = {
 | 
			
		||||
	.get_settings      = vmxnet3_get_settings,
 | 
			
		||||
	.get_drvinfo       = vmxnet3_get_drvinfo,
 | 
			
		||||
	.get_regs_len      = vmxnet3_get_regs_len,
 | 
			
		||||
	.get_regs          = vmxnet3_get_regs,
 | 
			
		||||
	.get_wol           = vmxnet3_get_wol,
 | 
			
		||||
	.set_wol           = vmxnet3_set_wol,
 | 
			
		||||
	.get_link          = ethtool_op_get_link,
 | 
			
		||||
	.get_rx_csum       = vmxnet3_get_rx_csum,
 | 
			
		||||
	.set_rx_csum       = vmxnet3_set_rx_csum,
 | 
			
		||||
	.get_tx_csum       = ethtool_op_get_tx_csum,
 | 
			
		||||
	.set_tx_csum       = ethtool_op_set_tx_hw_csum,
 | 
			
		||||
	.get_sg            = ethtool_op_get_sg,
 | 
			
		||||
	.set_sg            = ethtool_op_set_sg,
 | 
			
		||||
	.get_tso           = ethtool_op_get_tso,
 | 
			
		||||
	.set_tso           = ethtool_op_set_tso,
 | 
			
		||||
	.get_strings       = vmxnet3_get_strings,
 | 
			
		||||
	.get_flags	   = vmxnet3_get_flags,
 | 
			
		||||
	.set_flags	   = vmxnet3_set_flags,
 | 
			
		||||
	.get_sset_count	   = vmxnet3_get_sset_count,
 | 
			
		||||
	.get_ethtool_stats = vmxnet3_get_ethtool_stats,
 | 
			
		||||
	.get_ringparam     = vmxnet3_get_ringparam,
 | 
			
		||||
	.set_ringparam     = vmxnet3_set_ringparam,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void vmxnet3_set_ethtool_ops(struct net_device *netdev)
 | 
			
		||||
{
 | 
			
		||||
	SET_ETHTOOL_OPS(netdev, &vmxnet3_ethtool_ops);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										389
									
								
								drivers/net/vmxnet3/vmxnet3_int.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										389
									
								
								drivers/net/vmxnet3/vmxnet3_int.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,389 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Linux driver for VMware's vmxnet3 ethernet NIC.
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or modify it
 | 
			
		||||
 * under the terms of the GNU General Public License as published by the
 | 
			
		||||
 * Free Software Foundation; version 2 of the License and no later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful, but
 | 
			
		||||
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 | 
			
		||||
 * NON INFRINGEMENT.  See the GNU General Public License for more
 | 
			
		||||
 * details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 *
 | 
			
		||||
 * The full GNU General Public License is included in this distribution in
 | 
			
		||||
 * the file called "COPYING".
 | 
			
		||||
 *
 | 
			
		||||
 * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com>
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _VMXNET3_INT_H
 | 
			
		||||
#define _VMXNET3_INT_H
 | 
			
		||||
 | 
			
		||||
#include <linux/types.h>
 | 
			
		||||
#include <linux/ethtool.h>
 | 
			
		||||
#include <linux/delay.h>
 | 
			
		||||
#include <linux/netdevice.h>
 | 
			
		||||
#include <linux/pci.h>
 | 
			
		||||
#include <linux/ethtool.h>
 | 
			
		||||
#include <linux/compiler.h>
 | 
			
		||||
#include <linux/module.h>
 | 
			
		||||
#include <linux/moduleparam.h>
 | 
			
		||||
#include <linux/slab.h>
 | 
			
		||||
#include <linux/spinlock.h>
 | 
			
		||||
#include <linux/ioport.h>
 | 
			
		||||
#include <linux/highmem.h>
 | 
			
		||||
#include <linux/init.h>
 | 
			
		||||
#include <linux/timer.h>
 | 
			
		||||
#include <linux/skbuff.h>
 | 
			
		||||
#include <linux/interrupt.h>
 | 
			
		||||
#include <linux/workqueue.h>
 | 
			
		||||
#include <linux/uaccess.h>
 | 
			
		||||
#include <asm/dma.h>
 | 
			
		||||
#include <asm/page.h>
 | 
			
		||||
 | 
			
		||||
#include <linux/tcp.h>
 | 
			
		||||
#include <linux/udp.h>
 | 
			
		||||
#include <linux/ip.h>
 | 
			
		||||
#include <linux/ipv6.h>
 | 
			
		||||
#include <linux/in.h>
 | 
			
		||||
#include <linux/etherdevice.h>
 | 
			
		||||
#include <asm/checksum.h>
 | 
			
		||||
#include <linux/if_vlan.h>
 | 
			
		||||
#include <linux/if_arp.h>
 | 
			
		||||
#include <linux/inetdevice.h>
 | 
			
		||||
#include <linux/dst.h>
 | 
			
		||||
 | 
			
		||||
#include "vmxnet3_defs.h"
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
# define VMXNET3_DRIVER_VERSION_REPORT VMXNET3_DRIVER_VERSION_STRING"-NAPI(debug)"
 | 
			
		||||
#else
 | 
			
		||||
# define VMXNET3_DRIVER_VERSION_REPORT VMXNET3_DRIVER_VERSION_STRING"-NAPI"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Version numbers
 | 
			
		||||
 */
 | 
			
		||||
#define VMXNET3_DRIVER_VERSION_STRING   "1.0.5.0-k"
 | 
			
		||||
 | 
			
		||||
/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
 | 
			
		||||
#define VMXNET3_DRIVER_VERSION_NUM      0x01000500
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Capabilities
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
	VMNET_CAP_SG	        = 0x0001, /* Can do scatter-gather transmits. */
 | 
			
		||||
	VMNET_CAP_IP4_CSUM      = 0x0002, /* Can checksum only TCP/UDP over
 | 
			
		||||
					   * IPv4 */
 | 
			
		||||
	VMNET_CAP_HW_CSUM       = 0x0004, /* Can checksum all packets. */
 | 
			
		||||
	VMNET_CAP_HIGH_DMA      = 0x0008, /* Can DMA to high memory. */
 | 
			
		||||
	VMNET_CAP_TOE	        = 0x0010, /* Supports TCP/IP offload. */
 | 
			
		||||
	VMNET_CAP_TSO	        = 0x0020, /* Supports TCP Segmentation
 | 
			
		||||
					   * offload */
 | 
			
		||||
	VMNET_CAP_SW_TSO        = 0x0040, /* Supports SW TCP Segmentation */
 | 
			
		||||
	VMNET_CAP_VMXNET_APROM  = 0x0080, /* Vmxnet APROM support */
 | 
			
		||||
	VMNET_CAP_HW_TX_VLAN    = 0x0100, /* Can we do VLAN tagging in HW */
 | 
			
		||||
	VMNET_CAP_HW_RX_VLAN    = 0x0200, /* Can we do VLAN untagging in HW */
 | 
			
		||||
	VMNET_CAP_SW_VLAN       = 0x0400, /* VLAN tagging/untagging in SW */
 | 
			
		||||
	VMNET_CAP_WAKE_PCKT_RCV = 0x0800, /* Can wake on network packet recv? */
 | 
			
		||||
	VMNET_CAP_ENABLE_INT_INLINE = 0x1000,  /* Enable Interrupt Inline */
 | 
			
		||||
	VMNET_CAP_ENABLE_HEADER_COPY = 0x2000,  /* copy header for vmkernel */
 | 
			
		||||
	VMNET_CAP_TX_CHAIN      = 0x4000, /* Guest can use multiple tx entries
 | 
			
		||||
					  * for a pkt */
 | 
			
		||||
	VMNET_CAP_RX_CHAIN      = 0x8000, /* pkt can span multiple rx entries */
 | 
			
		||||
	VMNET_CAP_LPD           = 0x10000, /* large pkt delivery */
 | 
			
		||||
	VMNET_CAP_BPF           = 0x20000, /* BPF Support in VMXNET Virtual HW*/
 | 
			
		||||
	VMNET_CAP_SG_SPAN_PAGES = 0x40000, /* Scatter-gather can span multiple*/
 | 
			
		||||
					   /* pages transmits */
 | 
			
		||||
	VMNET_CAP_IP6_CSUM      = 0x80000, /* Can do IPv6 csum offload. */
 | 
			
		||||
	VMNET_CAP_TSO6         = 0x100000, /* TSO seg. offload for IPv6 pkts. */
 | 
			
		||||
	VMNET_CAP_TSO256k      = 0x200000, /* Can do TSO seg offload for */
 | 
			
		||||
					   /* pkts up to 256kB. */
 | 
			
		||||
	VMNET_CAP_UPT          = 0x400000  /* Support UPT */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * PCI vendor and device IDs.
 | 
			
		||||
 */
 | 
			
		||||
#define PCI_VENDOR_ID_VMWARE            0x15AD
 | 
			
		||||
#define PCI_DEVICE_ID_VMWARE_VMXNET3    0x07B0
 | 
			
		||||
#define MAX_ETHERNET_CARDS		10
 | 
			
		||||
#define MAX_PCI_PASSTHRU_DEVICE		6
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_cmd_ring {
 | 
			
		||||
	union Vmxnet3_GenericDesc *base;
 | 
			
		||||
	u32		size;
 | 
			
		||||
	u32		next2fill;
 | 
			
		||||
	u32		next2comp;
 | 
			
		||||
	u8		gen;
 | 
			
		||||
	dma_addr_t	basePA;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static inline void
 | 
			
		||||
vmxnet3_cmd_ring_adv_next2fill(struct vmxnet3_cmd_ring *ring)
 | 
			
		||||
{
 | 
			
		||||
	ring->next2fill++;
 | 
			
		||||
	if (unlikely(ring->next2fill == ring->size)) {
 | 
			
		||||
		ring->next2fill = 0;
 | 
			
		||||
		VMXNET3_FLIP_RING_GEN(ring->gen);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline void
 | 
			
		||||
vmxnet3_cmd_ring_adv_next2comp(struct vmxnet3_cmd_ring *ring)
 | 
			
		||||
{
 | 
			
		||||
	VMXNET3_INC_RING_IDX_ONLY(ring->next2comp, ring->size);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline int
 | 
			
		||||
vmxnet3_cmd_ring_desc_avail(struct vmxnet3_cmd_ring *ring)
 | 
			
		||||
{
 | 
			
		||||
	return (ring->next2comp > ring->next2fill ? 0 : ring->size) +
 | 
			
		||||
		ring->next2comp - ring->next2fill - 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_comp_ring {
 | 
			
		||||
	union Vmxnet3_GenericDesc *base;
 | 
			
		||||
	u32               size;
 | 
			
		||||
	u32               next2proc;
 | 
			
		||||
	u8                gen;
 | 
			
		||||
	u8                intr_idx;
 | 
			
		||||
	dma_addr_t           basePA;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static inline void
 | 
			
		||||
vmxnet3_comp_ring_adv_next2proc(struct vmxnet3_comp_ring *ring)
 | 
			
		||||
{
 | 
			
		||||
	ring->next2proc++;
 | 
			
		||||
	if (unlikely(ring->next2proc == ring->size)) {
 | 
			
		||||
		ring->next2proc = 0;
 | 
			
		||||
		VMXNET3_FLIP_RING_GEN(ring->gen);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_tx_data_ring {
 | 
			
		||||
	struct Vmxnet3_TxDataDesc *base;
 | 
			
		||||
	u32              size;
 | 
			
		||||
	dma_addr_t          basePA;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum vmxnet3_buf_map_type {
 | 
			
		||||
	VMXNET3_MAP_INVALID = 0,
 | 
			
		||||
	VMXNET3_MAP_NONE,
 | 
			
		||||
	VMXNET3_MAP_SINGLE,
 | 
			
		||||
	VMXNET3_MAP_PAGE,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_tx_buf_info {
 | 
			
		||||
	u32      map_type;
 | 
			
		||||
	u16      len;
 | 
			
		||||
	u16      sop_idx;
 | 
			
		||||
	dma_addr_t  dma_addr;
 | 
			
		||||
	struct sk_buff *skb;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_tq_driver_stats {
 | 
			
		||||
	u64 drop_total;     /* # of pkts dropped by the driver, the
 | 
			
		||||
				* counters below track droppings due to
 | 
			
		||||
				* different reasons
 | 
			
		||||
				*/
 | 
			
		||||
	u64 drop_too_many_frags;
 | 
			
		||||
	u64 drop_oversized_hdr;
 | 
			
		||||
	u64 drop_hdr_inspect_err;
 | 
			
		||||
	u64 drop_tso;
 | 
			
		||||
 | 
			
		||||
	u64 tx_ring_full;
 | 
			
		||||
	u64 linearized;         /* # of pkts linearized */
 | 
			
		||||
	u64 copy_skb_header;    /* # of times we have to copy skb header */
 | 
			
		||||
	u64 oversized_hdr;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_tx_ctx {
 | 
			
		||||
	bool   ipv4;
 | 
			
		||||
	u16 mss;
 | 
			
		||||
	u32 eth_ip_hdr_size; /* only valid for pkts requesting tso or csum
 | 
			
		||||
				 * offloading
 | 
			
		||||
				 */
 | 
			
		||||
	u32 l4_hdr_size;     /* only valid if mss != 0 */
 | 
			
		||||
	u32 copy_size;       /* # of bytes copied into the data ring */
 | 
			
		||||
	union Vmxnet3_GenericDesc *sop_txd;
 | 
			
		||||
	union Vmxnet3_GenericDesc *eop_txd;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_tx_queue {
 | 
			
		||||
	spinlock_t                      tx_lock;
 | 
			
		||||
	struct vmxnet3_cmd_ring         tx_ring;
 | 
			
		||||
	struct vmxnet3_tx_buf_info     *buf_info;
 | 
			
		||||
	struct vmxnet3_tx_data_ring     data_ring;
 | 
			
		||||
	struct vmxnet3_comp_ring        comp_ring;
 | 
			
		||||
	struct Vmxnet3_TxQueueCtrl            *shared;
 | 
			
		||||
	struct vmxnet3_tq_driver_stats  stats;
 | 
			
		||||
	bool                            stopped;
 | 
			
		||||
	int                             num_stop;  /* # of times the queue is
 | 
			
		||||
						    * stopped */
 | 
			
		||||
} __attribute__((__aligned__(SMP_CACHE_BYTES)));
 | 
			
		||||
 | 
			
		||||
enum vmxnet3_rx_buf_type {
 | 
			
		||||
	VMXNET3_RX_BUF_NONE = 0,
 | 
			
		||||
	VMXNET3_RX_BUF_SKB = 1,
 | 
			
		||||
	VMXNET3_RX_BUF_PAGE = 2
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_rx_buf_info {
 | 
			
		||||
	enum vmxnet3_rx_buf_type buf_type;
 | 
			
		||||
	u16     len;
 | 
			
		||||
	union {
 | 
			
		||||
		struct sk_buff *skb;
 | 
			
		||||
		struct page    *page;
 | 
			
		||||
	};
 | 
			
		||||
	dma_addr_t dma_addr;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_rx_ctx {
 | 
			
		||||
	struct sk_buff *skb;
 | 
			
		||||
	u32 sop_idx;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_rq_driver_stats {
 | 
			
		||||
	u64 drop_total;
 | 
			
		||||
	u64 drop_err;
 | 
			
		||||
	u64 drop_fcs;
 | 
			
		||||
	u64 rx_buf_alloc_failure;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_rx_queue {
 | 
			
		||||
	struct vmxnet3_cmd_ring   rx_ring[2];
 | 
			
		||||
	struct vmxnet3_comp_ring  comp_ring;
 | 
			
		||||
	struct vmxnet3_rx_ctx     rx_ctx;
 | 
			
		||||
	u32 qid;            /* rqID in RCD for buffer from 1st ring */
 | 
			
		||||
	u32 qid2;           /* rqID in RCD for buffer from 2nd ring */
 | 
			
		||||
	u32 uncommitted[2]; /* # of buffers allocated since last RXPROD
 | 
			
		||||
				* update */
 | 
			
		||||
	struct vmxnet3_rx_buf_info     *buf_info[2];
 | 
			
		||||
	struct Vmxnet3_RxQueueCtrl            *shared;
 | 
			
		||||
	struct vmxnet3_rq_driver_stats  stats;
 | 
			
		||||
} __attribute__((__aligned__(SMP_CACHE_BYTES)));
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_LINUX_MAX_MSIX_VECT     1
 | 
			
		||||
 | 
			
		||||
struct vmxnet3_intr {
 | 
			
		||||
	enum vmxnet3_intr_mask_mode  mask_mode;
 | 
			
		||||
	enum vmxnet3_intr_type       type;	/* MSI-X, MSI, or INTx? */
 | 
			
		||||
	u8  num_intrs;			/* # of intr vectors */
 | 
			
		||||
	u8  event_intr_idx;		/* idx of the intr vector for event */
 | 
			
		||||
	u8  mod_levels[VMXNET3_LINUX_MAX_MSIX_VECT]; /* moderation level */
 | 
			
		||||
#ifdef CONFIG_PCI_MSI
 | 
			
		||||
	struct msix_entry msix_entries[VMXNET3_LINUX_MAX_MSIX_VECT];
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_STATE_BIT_RESETTING   0
 | 
			
		||||
#define VMXNET3_STATE_BIT_QUIESCED    1
 | 
			
		||||
struct vmxnet3_adapter {
 | 
			
		||||
	struct vmxnet3_tx_queue         tx_queue;
 | 
			
		||||
	struct vmxnet3_rx_queue         rx_queue;
 | 
			
		||||
	struct napi_struct              napi;
 | 
			
		||||
	struct vlan_group              *vlan_grp;
 | 
			
		||||
 | 
			
		||||
	struct vmxnet3_intr             intr;
 | 
			
		||||
 | 
			
		||||
	struct Vmxnet3_DriverShared    *shared;
 | 
			
		||||
	struct Vmxnet3_PMConf          *pm_conf;
 | 
			
		||||
	struct Vmxnet3_TxQueueDesc     *tqd_start;     /* first tx queue desc */
 | 
			
		||||
	struct Vmxnet3_RxQueueDesc     *rqd_start;     /* first rx queue desc */
 | 
			
		||||
	struct net_device              *netdev;
 | 
			
		||||
	struct pci_dev                 *pdev;
 | 
			
		||||
 | 
			
		||||
	u8				*hw_addr0; /* for BAR 0 */
 | 
			
		||||
	u8				*hw_addr1; /* for BAR 1 */
 | 
			
		||||
 | 
			
		||||
	/* feature control */
 | 
			
		||||
	bool				rxcsum;
 | 
			
		||||
	bool				lro;
 | 
			
		||||
	bool				jumbo_frame;
 | 
			
		||||
 | 
			
		||||
	/* rx buffer related */
 | 
			
		||||
	unsigned			skb_buf_size;
 | 
			
		||||
	int		rx_buf_per_pkt;  /* only apply to the 1st ring */
 | 
			
		||||
	dma_addr_t			shared_pa;
 | 
			
		||||
	dma_addr_t queue_desc_pa;
 | 
			
		||||
 | 
			
		||||
	/* Wake-on-LAN */
 | 
			
		||||
	u32     wol;
 | 
			
		||||
 | 
			
		||||
	/* Link speed */
 | 
			
		||||
	u32     link_speed; /* in mbps */
 | 
			
		||||
 | 
			
		||||
	u64     tx_timeout_count;
 | 
			
		||||
	struct work_struct work;
 | 
			
		||||
 | 
			
		||||
	unsigned long  state;    /* VMXNET3_STATE_BIT_xxx */
 | 
			
		||||
 | 
			
		||||
	int dev_number;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_WRITE_BAR0_REG(adapter, reg, val)  \
 | 
			
		||||
	writel((val), (adapter)->hw_addr0 + (reg))
 | 
			
		||||
#define VMXNET3_READ_BAR0_REG(adapter, reg)        \
 | 
			
		||||
	readl((adapter)->hw_addr0 + (reg))
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_WRITE_BAR1_REG(adapter, reg, val)  \
 | 
			
		||||
	writel((val), (adapter)->hw_addr1 + (reg))
 | 
			
		||||
#define VMXNET3_READ_BAR1_REG(adapter, reg)        \
 | 
			
		||||
	readl((adapter)->hw_addr1 + (reg))
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_WAKE_QUEUE_THRESHOLD(tq)  (5)
 | 
			
		||||
#define VMXNET3_RX_ALLOC_THRESHOLD(rq, ring_idx, adapter) \
 | 
			
		||||
	((rq)->rx_ring[ring_idx].size >> 3)
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_GET_ADDR_LO(dma)   ((u32)(dma))
 | 
			
		||||
#define VMXNET3_GET_ADDR_HI(dma)   ((u32)(((u64)(dma)) >> 32))
 | 
			
		||||
 | 
			
		||||
/* must be a multiple of VMXNET3_RING_SIZE_ALIGN */
 | 
			
		||||
#define VMXNET3_DEF_TX_RING_SIZE    512
 | 
			
		||||
#define VMXNET3_DEF_RX_RING_SIZE    256
 | 
			
		||||
 | 
			
		||||
#define VMXNET3_MAX_ETH_HDR_SIZE    22
 | 
			
		||||
#define VMXNET3_MAX_SKB_BUF_SIZE    (3*1024)
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter);
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
vmxnet3_activate_dev(struct vmxnet3_adapter *adapter);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
vmxnet3_force_close(struct vmxnet3_adapter *adapter);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
vmxnet3_reset_dev(struct vmxnet3_adapter *adapter);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
 | 
			
		||||
		   struct vmxnet3_adapter *adapter);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
vmxnet3_rq_destroy(struct vmxnet3_rx_queue *rq,
 | 
			
		||||
		   struct vmxnet3_adapter *adapter);
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
vmxnet3_create_queues(struct vmxnet3_adapter *adapter,
 | 
			
		||||
		      u32 tx_ring_size, u32 rx_ring_size, u32 rx_ring2_size);
 | 
			
		||||
 | 
			
		||||
extern void vmxnet3_set_ethtool_ops(struct net_device *netdev);
 | 
			
		||||
extern struct net_device_stats *vmxnet3_get_stats(struct net_device *netdev);
 | 
			
		||||
 | 
			
		||||
extern char vmxnet3_driver_name[];
 | 
			
		||||
#endif
 | 
			
		||||
		Loading…
	
		Reference in a new issue