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