e1000.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 
00003   Intel PRO/1000 Linux driver
00004   Copyright(c) 1999 - 2008 Intel Corporation.
00005 
00006   This program is free software; you can redistribute it and/or modify it
00007   under the terms and conditions of the GNU General Public License,
00008   version 2, as published by the Free Software Foundation.
00009 
00010   This program is distributed in the hope it will be useful, but WITHOUT
00011   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00013   more details.
00014 
00015   You should have received a copy of the GNU General Public License along with
00016   this program; if not, write to the Free Software Foundation, Inc.,
00017   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019   The full GNU General Public License is included in this distribution in
00020   the file called "COPYING".
00021 
00022   Contact Information:
00023   Linux NICS <linux.nics@intel.com>
00024   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
00025   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
00026 
00027 *******************************************************************************/
00028 
00029 FILE_LICENCE ( GPL2_ONLY );
00030 
00031 /* Linux PRO/1000 Ethernet Driver main header file */
00032 
00033 #ifndef _E1000_H_
00034 #define _E1000_H_
00035 
00036 #include "e1000_api.h"
00037 
00038 #define BAR_0           0
00039 #define BAR_1           1
00040 #define BAR_5           5
00041 
00042 struct e1000_adapter;
00043 
00044 /* TX/RX descriptor defines */
00045 #define E1000_DEFAULT_TXD                  256
00046 #define E1000_MAX_TXD                      256
00047 #define E1000_MIN_TXD                       80
00048 #define E1000_MAX_82544_TXD               4096
00049 
00050 #define E1000_DEFAULT_TXD_PWR               12
00051 #define E1000_MAX_TXD_PWR                   12
00052 #define E1000_MIN_TXD_PWR                    7
00053 
00054 #define E1000_DEFAULT_RXD                  256
00055 #define E1000_MAX_RXD                      256
00056 
00057 #define E1000_MIN_RXD                       80
00058 #define E1000_MAX_82544_RXD               4096
00059 
00060 #define E1000_MIN_ITR_USECS                 10 /* 100000 irq/sec */
00061 #define E1000_MAX_ITR_USECS              10000 /* 100    irq/sec */
00062 
00063 
00064 /* this is the size past which hardware will drop packets when setting LPE=0 */
00065 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
00066 
00067 /* Supported Rx Buffer Sizes */
00068 #define E1000_RXBUFFER_128   128
00069 #define E1000_RXBUFFER_256   256
00070 #define E1000_RXBUFFER_512   512
00071 #define E1000_RXBUFFER_1024  1024
00072 #define E1000_RXBUFFER_2048  2048
00073 #define E1000_RXBUFFER_4096  4096
00074 #define E1000_RXBUFFER_8192  8192
00075 #define E1000_RXBUFFER_16384 16384
00076 
00077 /* SmartSpeed delimiters */
00078 #define E1000_SMARTSPEED_DOWNSHIFT 3
00079 #define E1000_SMARTSPEED_MAX       15
00080 
00081 /* Packet Buffer allocations */
00082 #define E1000_PBA_BYTES_SHIFT 0xA
00083 #define E1000_TX_HEAD_ADDR_SHIFT 7
00084 #define E1000_PBA_TX_MASK 0xFFFF0000
00085 
00086 /* Early Receive defines */
00087 #define E1000_ERT_2048 0x100
00088 
00089 #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
00090 
00091 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
00092 #define E1000_TX_QUEUE_WAKE     16
00093 /* How many Rx Buffers do we bundle into one write to the hardware ? */
00094 #define E1000_RX_BUFFER_WRITE   16      /* Must be power of 2 */
00095 
00096 #define AUTO_ALL_MODES            0
00097 #define E1000_EEPROM_82544_APM    0x0004
00098 #define E1000_EEPROM_APME         0x0400
00099 
00100 /* wrapper around a pointer to a socket buffer,
00101  * so a DMA handle can be stored along with the buffer */
00102 struct e1000_buffer {
00103         struct sk_buff *skb;
00104         dma_addr_t dma;
00105         unsigned long time_stamp;
00106         u16 length;
00107         u16 next_to_watch;
00108 };
00109 
00110 struct e1000_rx_buffer {
00111         struct sk_buff *skb;
00112         dma_addr_t dma;
00113         struct page *page;
00114 };
00115 
00116 
00117 
00118 struct e1000_tx_ring {
00119         /* pointer to the descriptor ring memory */
00120         void *desc;
00121         /* physical address of the descriptor ring */
00122         dma_addr_t dma;
00123         /* length of descriptor ring in bytes */
00124         unsigned int size;
00125         /* number of descriptors in the ring */
00126         unsigned int count;
00127         /* next descriptor to associate a buffer with */
00128         unsigned int next_to_use;
00129         /* next descriptor to check for DD status bit */
00130         unsigned int next_to_clean;
00131         /* array of buffer information structs */
00132         struct e1000_buffer *buffer_info;
00133 
00134         spinlock_t tx_lock;
00135         u16 tdh;
00136         u16 tdt;
00137 
00138         /* TXDdescriptor index increment to be used when advancing
00139         * to the next descriptor. This is normally one, but on some
00140         * architectures, but on some architectures there are cache
00141         * coherency issues that require only the first descriptor in
00142         * cache line can be used.
00143         */
00144         unsigned int step;
00145 
00146         bool last_tx_tso;
00147 };
00148 
00149 struct e1000_rx_ring {
00150         struct e1000_adapter *adapter; /* back link */
00151         /* pointer to the descriptor ring memory */
00152         void *desc;
00153         /* physical address of the descriptor ring */
00154         dma_addr_t dma;
00155         /* length of descriptor ring in bytes */
00156         unsigned int size;
00157         /* number of descriptors in the ring */
00158         unsigned int count;
00159         /* next descriptor to associate a buffer with */
00160         unsigned int next_to_use;
00161         /* next descriptor to check for DD status bit */
00162         unsigned int next_to_clean;
00163         /* array of buffer information structs */
00164         struct e1000_rx_buffer *buffer_info;
00165         struct sk_buff *rx_skb_top;
00166 
00167         /* cpu for rx queue */
00168         int cpu;
00169 
00170         u16 rdh;
00171         u16 rdt;
00172 };
00173 
00174 
00175 #define E1000_TX_DESC_INC(R,index) \
00176         {index += (R)->step; if (index == (R)->count) index = 0; }
00177 
00178 #define E1000_TX_DESC_DEC(R,index) \
00179         { if (index == 0) index = (R)->count - (R)->step; \
00180         else index -= (R)->step; }
00181 
00182 #define E1000_DESC_UNUSED(R) \
00183         ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
00184         (R)->next_to_clean - (R)->next_to_use - 1)
00185 
00186 #define E1000_RX_DESC_EXT(R, i)     \
00187         (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
00188 #define E1000_GET_DESC(R, i, type)      (&(((struct type *)((R).desc))[i]))
00189 #define E1000_RX_DESC(R, i)             E1000_GET_DESC(R, i, e1000_rx_desc)
00190 #define E1000_TX_DESC(R, i)             E1000_GET_DESC(R, i, e1000_tx_desc)
00191 #define E1000_CONTEXT_DESC(R, i)        E1000_GET_DESC(R, i, e1000_context_desc)
00192 
00193 /* board specific private data structure */
00194 
00195 struct e1000_adapter {
00196         u32 bd_number;
00197         u32 rx_buffer_len;
00198         u32 wol;
00199         u32 smartspeed;
00200         u32 en_mng_pt;
00201         u16 link_speed;
00202         u16 link_duplex;
00203         spinlock_t stats_lock;
00204         unsigned int total_tx_bytes;
00205         unsigned int total_tx_packets;
00206         unsigned int total_rx_bytes;
00207         unsigned int total_rx_packets;
00208         /* Interrupt Throttle Rate */
00209         u32 itr;
00210         u32 itr_setting;
00211         u16 tx_itr;
00212         u16 rx_itr;
00213 
00214         bool fc_autoneg;
00215 
00216         /* TX */
00217         struct e1000_tx_ring *tx_ring;
00218         unsigned int restart_queue;
00219         unsigned long tx_queue_len;
00220         u32 txd_cmd;
00221         u32 tx_int_delay;
00222         u32 tx_abs_int_delay;
00223         u32 gotc;
00224         u64 gotc_old;
00225         u64 tpt_old;
00226         u64 colc_old;
00227         u32 tx_timeout_count;
00228         u32 tx_fifo_head;
00229         u32 tx_head_addr;
00230         u32 tx_fifo_size;
00231         u8 tx_timeout_factor;
00232         bool pcix_82544;
00233         bool detect_tx_hung;
00234 
00235         /* RX */
00236         bool (*clean_rx) (struct e1000_adapter *adapter,
00237                                struct e1000_rx_ring *rx_ring);
00238         void (*alloc_rx_buf) (struct e1000_adapter *adapter,
00239                               struct e1000_rx_ring *rx_ring,
00240                                 int cleaned_count);
00241         struct e1000_rx_ring *rx_ring;
00242 
00243         u64 hw_csum_err;
00244         u64 hw_csum_good;
00245         u32 alloc_rx_buff_failed;
00246         u32 rx_int_delay;
00247         u32 rx_abs_int_delay;
00248         bool rx_csum;
00249         u32 gorc;
00250         u64 gorc_old;
00251         u32 max_frame_size;
00252         u32 min_frame_size;
00253 
00254 
00255         /* OS defined structs */
00256         struct net_device *netdev;
00257         struct pci_device *pdev;
00258         struct net_device_stats net_stats;
00259 
00260         /* structs defined in e1000_hw.h */
00261         struct e1000_hw hw;
00262         struct e1000_hw_stats stats;
00263         struct e1000_phy_info phy_info;
00264         struct e1000_phy_stats phy_stats;
00265 
00266         int msg_enable;
00267         /* to not mess up cache alignment, always add to the bottom */
00268         unsigned long state;
00269         u32 eeprom_wol;
00270 
00271         u32 *config_space;
00272 
00273         /* hardware capability, feature, and workaround flags */
00274         unsigned int flags;
00275 
00276         /* upper limit parameter for tx desc size */
00277         u32 tx_desc_pwr;
00278 
00279 #define NUM_TX_DESC     8
00280 #define NUM_RX_DESC     8
00281 
00282         struct io_buffer *tx_iobuf[NUM_TX_DESC];
00283         struct io_buffer *rx_iobuf[NUM_RX_DESC];
00284 
00285         struct e1000_tx_desc *tx_base;
00286         struct e1000_rx_desc *rx_base;
00287 
00288         uint32_t tx_ring_size;
00289         uint32_t rx_ring_size;
00290 
00291         uint32_t tx_head;
00292         uint32_t tx_tail;
00293         uint32_t tx_fill_ctr;
00294 
00295         uint32_t rx_curr;
00296 
00297         uint32_t ioaddr;
00298         uint32_t irqno;
00299 };
00300 
00301 #define E1000_FLAG_HAS_SMBUS                (1 << 0)
00302 #define E1000_FLAG_HAS_INTR_MODERATION      (1 << 4)
00303 #define E1000_FLAG_BAD_TX_CARRIER_STATS_FD  (1 << 6)
00304 #define E1000_FLAG_QUAD_PORT_A              (1 << 8)
00305 #define E1000_FLAG_SMART_POWER_DOWN         (1 << 9)
00306 
00307 extern char e1000_driver_name[];
00308 extern const char e1000_driver_version[];
00309 
00310 extern void e1000_power_up_phy(struct e1000_hw *hw);
00311 
00312 extern void e1000_set_ethtool_ops(struct net_device *netdev);
00313 extern void e1000_check_options(struct e1000_adapter *adapter);
00314 
00315 extern int e1000_up(struct e1000_adapter *adapter);
00316 extern void e1000_down(struct e1000_adapter *adapter);
00317 extern void e1000_reinit_locked(struct e1000_adapter *adapter);
00318 extern void e1000_reset(struct e1000_adapter *adapter);
00319 extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
00320 extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
00321 extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
00322 extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
00323 extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
00324 extern void e1000_update_stats(struct e1000_adapter *adapter);
00325 
00326 #endif /* _E1000_H_ */

Generated on Tue Apr 6 20:00:57 2010 for gPXE by  doxygen 1.5.7.1