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