iPXE
igbvf.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 
00003   Intel(R) 82576 Virtual Function 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 _IGBVF_H_
00034 #define _IGBVF_H_
00035 
00036 #include "igbvf_vf.h"
00037 
00038 /* Forward declarations */
00039 struct igbvf_info;
00040 struct igbvf_adapter;
00041 
00042 /* Interrupt defines */
00043 #define IGBVF_START_ITR                    648 /* ~6000 ints/sec */
00044 
00045 /* Tx/Rx descriptor defines */
00046 #define IGBVF_DEFAULT_TXD               256
00047 #define IGBVF_MAX_TXD                   4096
00048 #define IGBVF_MIN_TXD                   80
00049 
00050 #define IGBVF_DEFAULT_RXD               256
00051 #define IGBVF_MAX_RXD                   4096
00052 #define IGBVF_MIN_RXD                   80
00053 
00054 #define IGBVF_MIN_ITR_USECS             10 /* 100000 irq/sec */
00055 #define IGBVF_MAX_ITR_USECS             10000 /* 100    irq/sec */
00056 
00057 /* RX descriptor control thresholds.
00058  * PTHRESH - MAC will consider prefetch if it has fewer than this number of
00059  *           descriptors available in its onboard memory.
00060  *           Setting this to 0 disables RX descriptor prefetch.
00061  * HTHRESH - MAC will only prefetch if there are at least this many descriptors
00062  *           available in host memory.
00063  *           If PTHRESH is 0, this should also be 0.
00064  * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
00065  *           descriptors until either it has this many to write back, or the
00066  *           ITR timer expires.
00067  */
00068 #define IGBVF_RX_PTHRESH                    16
00069 #define IGBVF_RX_HTHRESH                     8
00070 #define IGBVF_RX_WTHRESH                     1
00071 
00072 #define IGBVF_TX_PTHRESH                     8
00073 #define IGBVF_TX_HTHRESH                     1
00074 #define IGBVF_TX_WTHRESH                     1
00075 
00076 /* this is the size past which hardware will drop packets when setting LPE=0 */
00077 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
00078 
00079 #define IGBVF_FC_PAUSE_TIME             0x0680 /* 858 usec */
00080 
00081 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
00082 #define IGBVF_TX_QUEUE_WAKE     32
00083 /* How many Rx Buffers do we bundle into one write to the hardware ? */
00084 #define IGBVF_RX_BUFFER_WRITE           16 /* Must be power of 2 */
00085 
00086 #define AUTO_ALL_MODES                  0
00087 #define IGBVF_EEPROM_APME               0x0400
00088 
00089 #define IGBVF_MNG_VLAN_NONE             (-1)
00090 
00091 enum igbvf_boards {
00092         board_vf,
00093 };
00094 
00095 struct igbvf_queue_stats {
00096         u64 packets;
00097         u64 bytes;
00098 };
00099 
00100 /*
00101  * wrappers around a pointer to a socket buffer,
00102  * so a DMA handle can be stored along with the buffer
00103  */
00104 struct igbvf_buffer {
00105 #if 0
00106         dma_addr_t dma;
00107         dma_addr_t page_dma;
00108         struct sk_buff *skb;
00109         union {
00110                 /* Tx */
00111                 struct {
00112                         unsigned long time_stamp;
00113                         u16 length;
00114                         u16 next_to_watch;
00115                 };
00116                 /* Rx */
00117                 struct {
00118                         struct page *page;
00119                         unsigned int page_offset;
00120                 };
00121         };
00122         struct page *page;
00123 #endif
00124 };
00125 
00126 struct igbvf_ring {
00127 #if 0
00128         struct igbvf_adapter *adapter;  /* backlink */
00129         void *desc;                     /* pointer to ring memory  */
00130         dma_addr_t dma;                 /* phys address of ring    */
00131         unsigned int size;              /* length of ring in bytes */
00132         unsigned int count;             /* number of desc. in ring */
00133 
00134         u16 next_to_use;
00135         u16 next_to_clean;
00136 
00137         u16 head;
00138         u16 tail;
00139 
00140         /* array of buffer information structs */
00141         struct igbvf_buffer *buffer_info;
00142         struct napi_struct napi;
00143 
00144         char name[IFNAMSIZ + 5];
00145         u32 eims_value;
00146         u32 itr_val;
00147         u16 itr_register;
00148         int set_itr;
00149 
00150         struct sk_buff *rx_skb_top;
00151 
00152         struct igbvf_queue_stats stats;
00153 #endif
00154 };
00155 
00156 /* board specific private data structure */
00157 struct igbvf_adapter {
00158 #if 0
00159         struct timer_list watchdog_timer;
00160         struct timer_list blink_timer;
00161 
00162         struct work_struct reset_task;
00163         struct work_struct watchdog_task;
00164 
00165         const struct igbvf_info *ei;
00166 
00167         struct vlan_group *vlgrp;
00168         u32 bd_number;
00169         u32 rx_buffer_len;
00170         u32 polling_interval;
00171         u16 mng_vlan_id;
00172         u16 link_speed;
00173         u16 link_duplex;
00174 
00175         spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
00176 
00177         /* track device up/down/testing state */
00178         unsigned long state;
00179 
00180         /* Interrupt Throttle Rate */
00181         u32 itr;
00182         u32 itr_setting;
00183         u16 tx_itr;
00184         u16 rx_itr;
00185 
00186         /*
00187          * Tx
00188          */
00189         struct igbvf_ring *tx_ring /* One per active queue */
00190                                                 ____cacheline_aligned_in_smp;
00191 
00192         unsigned long tx_queue_len;
00193         unsigned int restart_queue;
00194         u32 txd_cmd;
00195 
00196         bool detect_tx_hung;
00197         u8 tx_timeout_factor;
00198 
00199         unsigned int total_tx_bytes;
00200         unsigned int total_tx_packets;
00201         unsigned int total_rx_bytes;
00202         unsigned int total_rx_packets;
00203 
00204         /* Tx stats */
00205         u32 tx_timeout_count;
00206         u32 tx_fifo_head;
00207         u32 tx_head_addr;
00208         u32 tx_fifo_size;
00209         u32 tx_dma_failed;
00210 
00211         /*
00212          * Rx
00213          */
00214         struct igbvf_ring *rx_ring;
00215 
00216         /* Rx stats */
00217         u64 hw_csum_err;
00218         u64 hw_csum_good;
00219         u64 rx_hdr_split;
00220         u32 alloc_rx_buff_failed;
00221         u32 rx_dma_failed;
00222 
00223         unsigned int rx_ps_hdr_size;
00224         u32 max_frame_size;
00225         u32 min_frame_size;
00226 
00227         /* OS defined structs */
00228         struct net_device *netdev;
00229         struct pci_dev *pdev;
00230         struct net_device_stats net_stats;
00231         spinlock_t stats_lock;      /* prevent concurrent stats updates */
00232 
00233         /* structs defined in e1000_hw.h */
00234         struct e1000_hw hw;
00235 
00236         /* The VF counters don't clear on read so we have to get a base
00237          * count on driver start up and always subtract that base on
00238          * on the first update, thus the flag..
00239          */
00240         struct e1000_vf_stats stats;
00241         u64 zero_base;
00242 
00243         struct igbvf_ring test_tx_ring;
00244         struct igbvf_ring test_rx_ring;
00245         u32 test_icr;
00246 
00247         u32 msg_enable;
00248         struct msix_entry *msix_entries;
00249         int int_mode;
00250         u32 eims_enable_mask;
00251         u32 eims_other;
00252         u32 int_counter0;
00253         u32 int_counter1;
00254 
00255         u32 eeprom_wol;
00256         u32 wol;
00257         u32 pba;
00258 
00259         bool fc_autoneg;
00260 
00261         unsigned long led_status;
00262 
00263         unsigned int flags;
00264         unsigned long last_reset;
00265         u32 *config_space;
00266 #endif
00267         /* OS defined structs */
00268         struct net_device *netdev;
00269         struct pci_device *pdev;
00270         struct net_device_stats net_stats;
00271 
00272         /* structs defined in e1000_hw.h */
00273         struct e1000_hw hw;
00274 
00275         u32 min_frame_size;
00276         u32 max_frame_size;
00277 
00278         u32 max_hw_frame_size;
00279 
00280 #define NUM_TX_DESC     8
00281 #define NUM_RX_DESC     8
00282 
00283         struct io_buffer *tx_iobuf[NUM_TX_DESC];
00284         struct io_buffer *rx_iobuf[NUM_RX_DESC];
00285 
00286         union e1000_adv_tx_desc *tx_base;
00287         union e1000_adv_rx_desc *rx_base;
00288 
00289         uint32_t tx_ring_size;
00290         uint32_t rx_ring_size;
00291 
00292         uint32_t tx_head;
00293         uint32_t tx_tail;
00294         uint32_t tx_fill_ctr;
00295 
00296         uint32_t rx_curr;
00297 
00298         uint32_t ioaddr;
00299         uint32_t irqno;
00300 
00301         uint32_t tx_int_delay;
00302         uint32_t tx_abs_int_delay;
00303         uint32_t txd_cmd;
00304 };
00305 
00306 struct igbvf_info {
00307         enum e1000_mac_type     mac;
00308         unsigned int            flags;
00309         u32                     pba;
00310         void                    (*init_ops)(struct e1000_hw *);
00311         s32                     (*get_variants)(struct igbvf_adapter *);
00312 };
00313 
00314 /* hardware capability, feature, and workaround flags */
00315 #define IGBVF_FLAG_RX_CSUM_DISABLED       (1 << 0)
00316 
00317 #define IGBVF_DESC_UNUSED(R) \
00318         ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
00319         (R)->next_to_clean - (R)->next_to_use - 1)
00320 
00321 #define IGBVF_RX_DESC_ADV(R, i)     \
00322         (&(((union e1000_adv_rx_desc *)((R).desc))[i]))
00323 #define IGBVF_TX_DESC_ADV(R, i)     \
00324         (&(((union e1000_adv_tx_desc *)((R).desc))[i]))
00325 #define IGBVF_TX_CTXTDESC_ADV(R, i)         \
00326         (&(((struct e1000_adv_tx_context_desc *)((R).desc))[i]))
00327 
00328 enum igbvf_state_t {
00329         __IGBVF_TESTING,
00330         __IGBVF_RESETTING,
00331         __IGBVF_DOWN
00332 };
00333 
00334 enum latency_range {
00335         lowest_latency = 0,
00336         low_latency = 1,
00337         bulk_latency = 2,
00338         latency_invalid = 255
00339 };
00340 
00341 extern char igbvf_driver_name[];
00342 extern const char igbvf_driver_version[];
00343 
00344 extern void igbvf_check_options(struct igbvf_adapter *adapter);
00345 extern void igbvf_set_ethtool_ops(struct net_device *netdev);
00346 #ifdef ETHTOOL_OPS_COMPAT
00347 extern int ethtool_ioctl(struct ifreq *ifr);
00348 #endif
00349 
00350 extern int igbvf_up(struct igbvf_adapter *adapter);
00351 extern void igbvf_down(struct igbvf_adapter *adapter);
00352 extern void igbvf_reinit_locked(struct igbvf_adapter *adapter);
00353 extern void igbvf_reset(struct igbvf_adapter *adapter);
00354 extern int igbvf_setup_rx_resources(struct igbvf_adapter *adapter);
00355 extern int igbvf_setup_tx_resources(struct igbvf_adapter *adapter);
00356 extern void igbvf_free_rx_resources(struct igbvf_adapter *adapter);
00357 extern void igbvf_free_tx_resources(struct igbvf_adapter *adapter);
00358 extern void igbvf_update_stats(struct igbvf_adapter *adapter);
00359 extern void igbvf_set_interrupt_capability(struct igbvf_adapter *adapter);
00360 extern void igbvf_reset_interrupt_capability(struct igbvf_adapter *adapter);
00361 
00362 extern unsigned int copybreak;
00363 
00364 static inline u32 __er32(struct e1000_hw *hw, unsigned long reg)
00365 {
00366         return readl(hw->hw_addr + reg);
00367 }
00368 
00369 static inline void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
00370 {
00371         writel(val, hw->hw_addr + reg);
00372 }
00373 #define er32(reg)       E1000_READ_REG(hw, E1000_##reg)
00374 #define ew32(reg,val)   E1000_WRITE_REG(hw, E1000_##reg, (val))
00375 #define e1e_flush()     er32(STATUS)
00376 
00377 #endif /* _IGBVF_H_ */