fp@673: /*******************************************************************************
fp@673: 
fp@673:   
fp@673:   Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
fp@673:   
fp@673:   This program is free software; you can redistribute it and/or modify it 
fp@673:   under the terms of the GNU General Public License as published by the Free 
fp@673:   Software Foundation; either version 2 of the License, or (at your option) 
fp@673:   any later version.
fp@673:   
fp@673:   This program is distributed in the hope that it will be useful, but WITHOUT 
fp@673:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
fp@673:   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
fp@673:   more details.
fp@673:   
fp@673:   You should have received a copy of the GNU General Public License along with
fp@673:   this program; if not, write to the Free Software Foundation, Inc., 59 
fp@673:   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
fp@673:   
fp@673:   The full GNU General Public License is included in this distribution in the
fp@673:   file called LICENSE.
fp@673:   
fp@673:   Contact Information:
fp@673:   Linux NICS <linux.nics@intel.com>
fp@673:   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
fp@673: 
fp@673: *******************************************************************************/
fp@673: 
fp@673: 
fp@673: /* Linux PRO/1000 Ethernet Driver main header file */
fp@673: 
fp@673: #ifndef _E1000_H_
fp@673: #define _E1000_H_
fp@673: 
fp@673: #include <linux/stddef.h>
fp@673: #include <linux/config.h>
fp@673: #include <linux/module.h>
fp@673: #include <linux/types.h>
fp@673: #include <asm/byteorder.h>
fp@673: #include <linux/init.h>
fp@673: #include <linux/mm.h>
fp@673: #include <linux/errno.h>
fp@673: #include <linux/ioport.h>
fp@673: #include <linux/pci.h>
fp@673: #include <linux/kernel.h>
fp@673: #include <linux/netdevice.h>
fp@673: #include <linux/etherdevice.h>
fp@673: #include <linux/skbuff.h>
fp@673: #include <linux/delay.h>
fp@673: #include <linux/timer.h>
fp@673: #include <linux/slab.h>
fp@673: #include <linux/vmalloc.h>
fp@673: #include <linux/interrupt.h>
fp@673: #include <linux/string.h>
fp@673: #include <linux/pagemap.h>
fp@673: #include <linux/dma-mapping.h>
fp@673: #include <linux/bitops.h>
fp@673: #include <asm/io.h>
fp@673: #include <asm/irq.h>
fp@673: #include <linux/capability.h>
fp@673: #include <linux/in.h>
fp@673: #include <linux/ip.h>
fp@673: #include <linux/tcp.h>
fp@673: #include <linux/udp.h>
fp@673: #include <net/pkt_sched.h>
fp@673: #include <linux/list.h>
fp@673: #include <linux/reboot.h>
fp@673: #ifdef NETIF_F_TSO
fp@673: #include <net/checksum.h>
fp@673: #endif
fp@673: #include <linux/workqueue.h>
fp@673: #include <linux/mii.h>
fp@673: #include <linux/ethtool.h>
fp@673: #include <linux/if_vlan.h>
fp@673: #include "../ecdev.h"
fp@673: 
fp@673: 
fp@673: #define BAR_0		0
fp@673: #define BAR_1		1
fp@673: #define BAR_5		5
fp@673: 
fp@673: #define INTEL_E1000_ETHERNET_DEVICE(device_id) {\
fp@673: 	PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
fp@673: 
fp@673: struct e1000_adapter;
fp@673: 
fp@673: #include "e1000_hw-2.6.13-ethercat.h"
fp@673: 
fp@673: #ifdef DBG
fp@675: #define E1000_DBG(args...) printk(KERN_DEBUG "ec_e1000: " args)
fp@673: #else
fp@673: #define E1000_DBG(args...)
fp@673: #endif
fp@673: 
fp@675: #define E1000_ERR(args...) printk(KERN_ERR "ec_e1000: " args)
fp@675: 
fp@675: #define PFX "ec_e1000: "
fp@673: #define DPRINTK(nlevel, klevel, fmt, args...) \
fp@673: 	(void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
fp@673: 	printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
fp@673: 		__FUNCTION__ , ## args))
fp@673: 
fp@673: #define E1000_MAX_INTR 10
fp@673: 
fp@673: /* TX/RX descriptor defines */
fp@673: #define E1000_DEFAULT_TXD                  256
fp@673: #define E1000_MAX_TXD                      256
fp@673: #define E1000_MIN_TXD                       80
fp@673: #define E1000_MAX_82544_TXD               4096
fp@673: 
fp@673: #define E1000_DEFAULT_RXD                  256
fp@673: #define E1000_MAX_RXD                      256
fp@673: #define E1000_MIN_RXD                       80
fp@673: #define E1000_MAX_82544_RXD               4096
fp@673: 
fp@673: /* Supported Rx Buffer Sizes */
fp@673: #define E1000_RXBUFFER_128   128    /* Used for packet split */
fp@673: #define E1000_RXBUFFER_256   256    /* Used for packet split */
fp@673: #define E1000_RXBUFFER_2048  2048
fp@673: #define E1000_RXBUFFER_4096  4096
fp@673: #define E1000_RXBUFFER_8192  8192
fp@673: #define E1000_RXBUFFER_16384 16384
fp@673: 
fp@673: /* SmartSpeed delimiters */
fp@673: #define E1000_SMARTSPEED_DOWNSHIFT 3
fp@673: #define E1000_SMARTSPEED_MAX       15
fp@673: 
fp@673: /* Packet Buffer allocations */
fp@673: #define E1000_PBA_BYTES_SHIFT 0xA
fp@673: #define E1000_TX_HEAD_ADDR_SHIFT 7
fp@673: #define E1000_PBA_TX_MASK 0xFFFF0000
fp@673: 
fp@673: /* Flow Control Watermarks */
fp@673: #define E1000_FC_HIGH_DIFF 0x1638  /* High: 5688 bytes below Rx FIFO size */
fp@673: #define E1000_FC_LOW_DIFF 0x1640   /* Low:  5696 bytes below Rx FIFO size */
fp@673: 
fp@673: #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
fp@673: 
fp@673: /* How many Tx Descriptors do we need to call netif_wake_queue ? */
fp@673: #define E1000_TX_QUEUE_WAKE	16
fp@673: /* How many Rx Buffers do we bundle into one write to the hardware ? */
fp@673: #define E1000_RX_BUFFER_WRITE	16	/* Must be power of 2 */
fp@673: 
fp@673: #define AUTO_ALL_MODES            0
fp@673: #define E1000_EEPROM_82544_APM    0x0004
fp@673: #define E1000_EEPROM_APME         0x0400
fp@673: 
fp@673: #ifndef E1000_MASTER_SLAVE
fp@673: /* Switch to override PHY master/slave setting */
fp@673: #define E1000_MASTER_SLAVE	e1000_ms_hw_default
fp@673: #endif
fp@673: 
fp@673: #define E1000_MNG_VLAN_NONE -1
fp@673: /* Number of packet split data buffers (not including the header buffer) */
fp@673: #define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
fp@673: 
fp@673: /* only works for sizes that are powers of 2 */
fp@673: #define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
fp@673: 
fp@673: /* wrapper around a pointer to a socket buffer,
fp@673:  * so a DMA handle can be stored along with the buffer */
fp@673: struct e1000_buffer {
fp@673: 	struct sk_buff *skb;
fp@673: 	dma_addr_t dma;
fp@673: 	unsigned long time_stamp;
fp@673: 	uint16_t length;
fp@673: 	uint16_t next_to_watch;
fp@673: };
fp@673: 
fp@673: struct e1000_ps_page { struct page *ps_page[MAX_PS_BUFFERS]; };
fp@673: struct e1000_ps_page_dma { uint64_t ps_page_dma[MAX_PS_BUFFERS]; };
fp@673: 
fp@673: struct e1000_desc_ring {
fp@673: 	/* pointer to the descriptor ring memory */
fp@673: 	void *desc;
fp@673: 	/* physical address of the descriptor ring */
fp@673: 	dma_addr_t dma;
fp@673: 	/* length of descriptor ring in bytes */
fp@673: 	unsigned int size;
fp@673: 	/* number of descriptors in the ring */
fp@673: 	unsigned int count;
fp@673: 	/* next descriptor to associate a buffer with */
fp@673: 	unsigned int next_to_use;
fp@673: 	/* next descriptor to check for DD status bit */
fp@673: 	unsigned int next_to_clean;
fp@673: 	/* array of buffer information structs */
fp@673: 	struct e1000_buffer *buffer_info;
fp@673: 	/* arrays of page information for packet split */
fp@673: 	struct e1000_ps_page *ps_page;
fp@673: 	struct e1000_ps_page_dma *ps_page_dma;
fp@673: };
fp@673: 
fp@673: #define E1000_DESC_UNUSED(R) \
fp@673: 	((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
fp@673: 	(R)->next_to_clean - (R)->next_to_use - 1)
fp@673: 
fp@673: #define E1000_RX_DESC_PS(R, i)	    \
fp@673: 	(&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
fp@673: #define E1000_RX_DESC_EXT(R, i)	    \
fp@673: 	(&(((union e1000_rx_desc_extended *)((R).desc))[i]))
fp@673: #define E1000_GET_DESC(R, i, type)	(&(((struct type *)((R).desc))[i]))
fp@673: #define E1000_RX_DESC(R, i)		E1000_GET_DESC(R, i, e1000_rx_desc)
fp@673: #define E1000_TX_DESC(R, i)		E1000_GET_DESC(R, i, e1000_tx_desc)
fp@673: #define E1000_CONTEXT_DESC(R, i)	E1000_GET_DESC(R, i, e1000_context_desc)
fp@673: 
fp@673: /* board specific private data structure */
fp@673: 
fp@673: struct e1000_adapter {
fp@673: 	struct timer_list tx_fifo_stall_timer;
fp@673: 	struct timer_list watchdog_timer;
fp@673: 	struct timer_list phy_info_timer;
fp@673: 	struct vlan_group *vlgrp;
fp@673:     	uint16_t mng_vlan_id;
fp@673: 	uint32_t bd_number;
fp@673: 	uint32_t rx_buffer_len;
fp@673: 	uint32_t part_num;
fp@673: 	uint32_t wol;
fp@673: 	uint32_t smartspeed;
fp@673: 	uint32_t en_mng_pt;
fp@673: 	uint16_t link_speed;
fp@673: 	uint16_t link_duplex;
fp@673: 	spinlock_t stats_lock;
fp@673: 	atomic_t irq_sem;
fp@673: 	struct work_struct tx_timeout_task;
fp@673: 	struct work_struct watchdog_task;
fp@673: 	uint8_t fc_autoneg;
fp@673: 
fp@673: 	struct timer_list blink_timer;
fp@673: 	unsigned long led_status;
fp@673: 
fp@673: 	/* TX */
fp@673: 	struct e1000_desc_ring tx_ring;
fp@673: 	struct e1000_buffer previous_buffer_info;
fp@673: 	spinlock_t tx_lock;
fp@673: 	uint32_t txd_cmd;
fp@673: 	uint32_t tx_int_delay;
fp@673: 	uint32_t tx_abs_int_delay;
fp@673: 	uint32_t gotcl;
fp@673: 	uint64_t gotcl_old;
fp@673: 	uint64_t tpt_old;
fp@673: 	uint64_t colc_old;
fp@673: 	uint32_t tx_fifo_head;
fp@673: 	uint32_t tx_head_addr;
fp@673: 	uint32_t tx_fifo_size;
fp@673: 	atomic_t tx_fifo_stall;
fp@673: 	boolean_t pcix_82544;
fp@673: 	boolean_t detect_tx_hung;
fp@673: 
fp@673: 	/* RX */
fp@673: #ifdef CONFIG_E1000_NAPI
fp@673: 	boolean_t (*clean_rx) (struct e1000_adapter *adapter, int *work_done,
fp@673: 			  int work_to_do);
fp@673: #else
fp@673: 	boolean_t (*clean_rx) (struct e1000_adapter *adapter);
fp@673: #endif
fp@673: 	void (*alloc_rx_buf) (struct e1000_adapter *adapter);
fp@673: 	struct e1000_desc_ring rx_ring;
fp@673: 	uint64_t hw_csum_err;
fp@673: 	uint64_t hw_csum_good;
fp@673: 	uint32_t rx_int_delay;
fp@673: 	uint32_t rx_abs_int_delay;
fp@673: 	boolean_t rx_csum;
fp@673: 	boolean_t rx_ps;
fp@673: 	uint32_t gorcl;
fp@673: 	uint64_t gorcl_old;
fp@673: 	uint16_t rx_ps_bsize0;
fp@673: 
fp@673: 	/* Interrupt Throttle Rate */
fp@673: 	uint32_t itr;
fp@673: 
fp@673: 	/* OS defined structs */
fp@673: 	struct net_device *netdev;
fp@673: 	struct pci_dev *pdev;
fp@673: 	struct net_device_stats net_stats;
fp@673: 
fp@673: 	/* structs defined in e1000_hw.h */
fp@673: 	struct e1000_hw hw;
fp@673: 	struct e1000_hw_stats stats;
fp@673: 	struct e1000_phy_info phy_info;
fp@673: 	struct e1000_phy_stats phy_stats;
fp@673: 
fp@673: 	uint32_t test_icr;
fp@673: 	struct e1000_desc_ring test_tx_ring;
fp@673: 	struct e1000_desc_ring test_rx_ring;
fp@673: 
fp@673: 
fp@673: 	int msg_enable;
fp@673: #ifdef CONFIG_PCI_MSI
fp@673: 	boolean_t have_msi;
fp@673: #endif
fp@673: 
fp@673: 	ec_device_t *ecdev;
fp@676:     unsigned long ec_watchdog_jiffies;
fp@673: };
fp@673: #endif /* _E1000_H_ */