fp@680: /******************************************************************************* fp@680: fp@680: Intel PRO/1000 Linux driver fp@680: Copyright(c) 1999 - 2006 Intel Corporation. fp@680: fp@680: This program is free software; you can redistribute it and/or modify it fp@680: under the terms and conditions of the GNU General Public License, fp@680: version 2, as published by the Free Software Foundation. fp@680: fp@680: This program is distributed in the hope it will be useful, but WITHOUT fp@680: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or fp@680: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for fp@680: more details. fp@680: fp@680: You should have received a copy of the GNU General Public License along with fp@680: this program; if not, write to the Free Software Foundation, Inc., fp@680: 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. fp@680: fp@680: The full GNU General Public License is included in this distribution in fp@680: the file called "COPYING". fp@680: fp@680: Contact Information: fp@680: Linux NICS fp@680: e1000-devel Mailing List fp@680: Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 fp@680: fp@680: *******************************************************************************/ fp@680: fp@680: fp@680: /* Linux PRO/1000 Ethernet Driver main header file */ fp@680: fp@680: #ifndef _E1000_H_ fp@680: #define _E1000_H_ fp@680: fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #ifdef NETIF_F_TSO6 fp@680: #include fp@680: #endif fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #include fp@680: #ifdef NETIF_F_TSO fp@680: #include fp@680: #endif fp@680: #include fp@680: #include fp@680: #include fp@680: #include "../ecdev.h" fp@680: fp@680: fp@680: #define BAR_0 0 fp@680: #define BAR_1 1 fp@680: #define BAR_5 5 fp@680: fp@680: #define INTEL_E1000_ETHERNET_DEVICE(device_id) {\ fp@680: PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)} fp@680: fp@680: struct e1000_adapter; fp@680: fp@680: #include "e1000_hw-2.6.20-ethercat.h" fp@680: fp@680: #ifdef DBG fp@680: #define E1000_DBG(args...) printk(KERN_DEBUG "ec_e1000: " args) fp@680: #else fp@680: #define E1000_DBG(args...) fp@680: #endif fp@680: fp@680: #define E1000_ERR(args...) printk(KERN_ERR "ec_e1000: " args) fp@680: fp@680: #define PFX "ec_e1000: " fp@680: #define DPRINTK(nlevel, klevel, fmt, args...) \ fp@680: (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \ fp@680: printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \ fp@680: __FUNCTION__ , ## args)) fp@680: fp@680: #define E1000_MAX_INTR 10 fp@680: fp@680: /* TX/RX descriptor defines */ fp@680: #define E1000_DEFAULT_TXD 256 fp@680: #define E1000_MAX_TXD 256 fp@680: #define E1000_MIN_TXD 80 fp@680: #define E1000_MAX_82544_TXD 4096 fp@680: fp@680: #define E1000_DEFAULT_RXD 256 fp@680: #define E1000_MAX_RXD 256 fp@680: #define E1000_MIN_RXD 80 fp@680: #define E1000_MAX_82544_RXD 4096 fp@680: fp@680: /* this is the size past which hardware will drop packets when setting LPE=0 */ fp@680: #define MAXIMUM_ETHERNET_VLAN_SIZE 1522 fp@680: fp@680: /* Supported Rx Buffer Sizes */ fp@680: #define E1000_RXBUFFER_128 128 /* Used for packet split */ fp@680: #define E1000_RXBUFFER_256 256 /* Used for packet split */ fp@680: #define E1000_RXBUFFER_512 512 fp@680: #define E1000_RXBUFFER_1024 1024 fp@680: #define E1000_RXBUFFER_2048 2048 fp@680: #define E1000_RXBUFFER_4096 4096 fp@680: #define E1000_RXBUFFER_8192 8192 fp@680: #define E1000_RXBUFFER_16384 16384 fp@680: fp@680: /* SmartSpeed delimiters */ fp@680: #define E1000_SMARTSPEED_DOWNSHIFT 3 fp@680: #define E1000_SMARTSPEED_MAX 15 fp@680: fp@680: /* Packet Buffer allocations */ fp@680: #define E1000_PBA_BYTES_SHIFT 0xA fp@680: #define E1000_TX_HEAD_ADDR_SHIFT 7 fp@680: #define E1000_PBA_TX_MASK 0xFFFF0000 fp@680: fp@680: /* Flow Control Watermarks */ fp@680: #define E1000_FC_HIGH_DIFF 0x1638 /* High: 5688 bytes below Rx FIFO size */ fp@680: #define E1000_FC_LOW_DIFF 0x1640 /* Low: 5696 bytes below Rx FIFO size */ fp@680: fp@680: #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */ fp@680: fp@680: /* How many Tx Descriptors do we need to call netif_wake_queue ? */ fp@680: #define E1000_TX_QUEUE_WAKE 16 fp@680: /* How many Rx Buffers do we bundle into one write to the hardware ? */ fp@680: #define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */ fp@680: fp@680: #define AUTO_ALL_MODES 0 fp@680: #define E1000_EEPROM_82544_APM 0x0004 fp@680: #define E1000_EEPROM_ICH8_APME 0x0004 fp@680: #define E1000_EEPROM_APME 0x0400 fp@680: fp@680: #ifndef E1000_MASTER_SLAVE fp@680: /* Switch to override PHY master/slave setting */ fp@680: #define E1000_MASTER_SLAVE e1000_ms_hw_default fp@680: #endif fp@680: fp@680: #define E1000_MNG_VLAN_NONE -1 fp@680: /* Number of packet split data buffers (not including the header buffer) */ fp@680: #define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1 fp@680: fp@680: /* only works for sizes that are powers of 2 */ fp@680: #define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1))) fp@680: fp@680: /* wrapper around a pointer to a socket buffer, fp@680: * so a DMA handle can be stored along with the buffer */ fp@680: struct e1000_buffer { fp@680: struct sk_buff *skb; fp@680: dma_addr_t dma; fp@680: unsigned long time_stamp; fp@680: uint16_t length; fp@680: uint16_t next_to_watch; fp@680: }; fp@680: fp@680: fp@680: struct e1000_ps_page { struct page *ps_page[PS_PAGE_BUFFERS]; }; fp@680: struct e1000_ps_page_dma { uint64_t ps_page_dma[PS_PAGE_BUFFERS]; }; fp@680: fp@680: struct e1000_tx_ring { fp@680: /* pointer to the descriptor ring memory */ fp@680: void *desc; fp@680: /* physical address of the descriptor ring */ fp@680: dma_addr_t dma; fp@680: /* length of descriptor ring in bytes */ fp@680: unsigned int size; fp@680: /* number of descriptors in the ring */ fp@680: unsigned int count; fp@680: /* next descriptor to associate a buffer with */ fp@680: unsigned int next_to_use; fp@680: /* next descriptor to check for DD status bit */ fp@680: unsigned int next_to_clean; fp@680: /* array of buffer information structs */ fp@680: struct e1000_buffer *buffer_info; fp@680: fp@680: spinlock_t tx_lock; fp@680: uint16_t tdh; fp@680: uint16_t tdt; fp@680: boolean_t last_tx_tso; fp@680: }; fp@680: fp@680: struct e1000_rx_ring { fp@680: /* pointer to the descriptor ring memory */ fp@680: void *desc; fp@680: /* physical address of the descriptor ring */ fp@680: dma_addr_t dma; fp@680: /* length of descriptor ring in bytes */ fp@680: unsigned int size; fp@680: /* number of descriptors in the ring */ fp@680: unsigned int count; fp@680: /* next descriptor to associate a buffer with */ fp@680: unsigned int next_to_use; fp@680: /* next descriptor to check for DD status bit */ fp@680: unsigned int next_to_clean; fp@680: /* array of buffer information structs */ fp@680: struct e1000_buffer *buffer_info; fp@680: /* arrays of page information for packet split */ fp@680: struct e1000_ps_page *ps_page; fp@680: struct e1000_ps_page_dma *ps_page_dma; fp@680: fp@680: /* cpu for rx queue */ fp@680: int cpu; fp@680: fp@680: uint16_t rdh; fp@680: uint16_t rdt; fp@680: }; fp@680: fp@680: #define E1000_DESC_UNUSED(R) \ fp@680: ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \ fp@680: (R)->next_to_clean - (R)->next_to_use - 1) fp@680: fp@680: #define E1000_RX_DESC_PS(R, i) \ fp@680: (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) fp@680: #define E1000_RX_DESC_EXT(R, i) \ fp@680: (&(((union e1000_rx_desc_extended *)((R).desc))[i])) fp@680: #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) fp@680: #define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc) fp@680: #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc) fp@680: #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc) fp@680: fp@680: /* board specific private data structure */ fp@680: fp@680: struct e1000_adapter { fp@680: struct timer_list tx_fifo_stall_timer; fp@680: struct timer_list watchdog_timer; fp@680: struct timer_list phy_info_timer; fp@680: struct vlan_group *vlgrp; fp@680: uint16_t mng_vlan_id; fp@680: uint32_t bd_number; fp@680: uint32_t rx_buffer_len; fp@680: uint32_t wol; fp@680: uint32_t smartspeed; fp@680: uint32_t en_mng_pt; fp@680: uint16_t link_speed; fp@680: uint16_t link_duplex; fp@680: spinlock_t stats_lock; fp@680: #ifdef CONFIG_E1000_NAPI fp@680: spinlock_t tx_queue_lock; fp@680: #endif fp@680: atomic_t irq_sem; fp@680: unsigned int detect_link; fp@680: unsigned int total_tx_bytes; fp@680: unsigned int total_tx_packets; fp@680: unsigned int total_rx_bytes; fp@680: unsigned int total_rx_packets; fp@680: /* Interrupt Throttle Rate */ fp@680: uint32_t itr; fp@680: uint32_t itr_setting; fp@680: uint16_t tx_itr; fp@680: uint16_t rx_itr; fp@680: fp@680: struct work_struct reset_task; fp@680: uint8_t fc_autoneg; fp@680: fp@680: struct timer_list blink_timer; fp@680: unsigned long led_status; fp@680: fp@680: /* TX */ fp@680: struct e1000_tx_ring *tx_ring; /* One per active queue */ fp@680: unsigned int restart_queue; fp@680: unsigned long tx_queue_len; fp@680: uint32_t txd_cmd; fp@680: uint32_t tx_int_delay; fp@680: uint32_t tx_abs_int_delay; fp@680: uint32_t gotcl; fp@680: uint64_t gotcl_old; fp@680: uint64_t tpt_old; fp@680: uint64_t colc_old; fp@680: uint32_t tx_timeout_count; fp@680: uint32_t tx_fifo_head; fp@680: uint32_t tx_head_addr; fp@680: uint32_t tx_fifo_size; fp@680: uint8_t tx_timeout_factor; fp@680: atomic_t tx_fifo_stall; fp@680: boolean_t pcix_82544; fp@680: boolean_t detect_tx_hung; fp@680: fp@680: /* RX */ fp@680: #ifdef CONFIG_E1000_NAPI fp@680: boolean_t (*clean_rx) (struct e1000_adapter *adapter, fp@680: struct e1000_rx_ring *rx_ring, fp@680: int *work_done, int work_to_do); fp@680: #else fp@680: boolean_t (*clean_rx) (struct e1000_adapter *adapter, fp@680: struct e1000_rx_ring *rx_ring); fp@680: #endif fp@680: void (*alloc_rx_buf) (struct e1000_adapter *adapter, fp@680: struct e1000_rx_ring *rx_ring, fp@680: int cleaned_count); fp@680: struct e1000_rx_ring *rx_ring; /* One per active queue */ fp@680: #ifdef CONFIG_E1000_NAPI fp@680: struct net_device *polling_netdev; /* One per active queue */ fp@680: #endif fp@680: int num_tx_queues; fp@680: int num_rx_queues; fp@680: fp@680: uint64_t hw_csum_err; fp@680: uint64_t hw_csum_good; fp@680: uint64_t rx_hdr_split; fp@680: uint32_t alloc_rx_buff_failed; fp@680: uint32_t rx_int_delay; fp@680: uint32_t rx_abs_int_delay; fp@680: boolean_t rx_csum; fp@680: unsigned int rx_ps_pages; fp@680: uint32_t gorcl; fp@680: uint64_t gorcl_old; fp@680: uint16_t rx_ps_bsize0; fp@680: fp@680: fp@680: /* OS defined structs */ fp@680: struct net_device *netdev; fp@680: struct pci_dev *pdev; fp@680: struct net_device_stats net_stats; fp@680: fp@680: /* structs defined in e1000_hw.h */ fp@680: struct e1000_hw hw; fp@680: struct e1000_hw_stats stats; fp@680: struct e1000_phy_info phy_info; fp@680: struct e1000_phy_stats phy_stats; fp@680: fp@680: uint32_t test_icr; fp@680: struct e1000_tx_ring test_tx_ring; fp@680: struct e1000_rx_ring test_rx_ring; fp@680: fp@680: fp@680: uint32_t *config_space; fp@680: int msg_enable; fp@680: #ifdef CONFIG_PCI_MSI fp@680: boolean_t have_msi; fp@680: #endif fp@680: /* to not mess up cache alignment, always add to the bottom */ fp@680: #ifdef NETIF_F_TSO fp@680: boolean_t tso_force; fp@680: #endif fp@680: boolean_t smart_power_down; /* phy smart power down */ fp@680: boolean_t quad_port_a; fp@680: unsigned long flags; fp@680: uint32_t eeprom_wol; fp@680: fp@680: ec_device_t *ecdev; fp@680: unsigned long ec_watchdog_jiffies; fp@680: }; fp@680: fp@680: enum e1000_state_t { fp@680: __E1000_TESTING, fp@680: __E1000_RESETTING, fp@680: __E1000_DOWN fp@680: }; fp@680: fp@680: #endif /* _E1000_H_ */