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