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