Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright(c) 1999 - 2008 Intel Corporation. */
0003 
0004 #ifndef _IXGB_H_
0005 #define _IXGB_H_
0006 
0007 #include <linux/stddef.h>
0008 #include <linux/module.h>
0009 #include <linux/types.h>
0010 #include <asm/byteorder.h>
0011 #include <linux/mm.h>
0012 #include <linux/errno.h>
0013 #include <linux/ioport.h>
0014 #include <linux/pci.h>
0015 #include <linux/kernel.h>
0016 #include <linux/netdevice.h>
0017 #include <linux/etherdevice.h>
0018 #include <linux/skbuff.h>
0019 #include <linux/delay.h>
0020 #include <linux/timer.h>
0021 #include <linux/slab.h>
0022 #include <linux/vmalloc.h>
0023 #include <linux/interrupt.h>
0024 #include <linux/string.h>
0025 #include <linux/pagemap.h>
0026 #include <linux/dma-mapping.h>
0027 #include <linux/bitops.h>
0028 #include <asm/io.h>
0029 #include <asm/irq.h>
0030 #include <linux/capability.h>
0031 #include <linux/in.h>
0032 #include <linux/ip.h>
0033 #include <linux/tcp.h>
0034 #include <linux/udp.h>
0035 #include <net/pkt_sched.h>
0036 #include <linux/list.h>
0037 #include <linux/reboot.h>
0038 #include <net/checksum.h>
0039 
0040 #include <linux/ethtool.h>
0041 #include <linux/if_vlan.h>
0042 
0043 #define BAR_0       0
0044 #define BAR_1       1
0045 
0046 struct ixgb_adapter;
0047 #include "ixgb_hw.h"
0048 #include "ixgb_ee.h"
0049 #include "ixgb_ids.h"
0050 
0051 /* TX/RX descriptor defines */
0052 #define DEFAULT_TXD      256
0053 #define MAX_TXD         4096
0054 #define MIN_TXD           64
0055 
0056 /* hardware cannot reliably support more than 512 descriptors owned by
0057  * hardware descriptor cache otherwise an unreliable ring under heavy
0058  * receive load may result */
0059 #define DEFAULT_RXD      512
0060 #define MAX_RXD          512
0061 #define MIN_RXD           64
0062 
0063 /* Supported Rx Buffer Sizes */
0064 #define IXGB_RXBUFFER_2048  2048
0065 #define IXGB_RXBUFFER_4096  4096
0066 #define IXGB_RXBUFFER_8192  8192
0067 #define IXGB_RXBUFFER_16384 16384
0068 
0069 /* How many Rx Buffers do we bundle into one write to the hardware ? */
0070 #define IXGB_RX_BUFFER_WRITE    8   /* Must be power of 2 */
0071 
0072 /* wrapper around a pointer to a socket buffer,
0073  * so a DMA handle can be stored along with the buffer */
0074 struct ixgb_buffer {
0075     struct sk_buff *skb;
0076     dma_addr_t dma;
0077     unsigned long time_stamp;
0078     u16 length;
0079     u16 next_to_watch;
0080     u16 mapped_as_page;
0081 };
0082 
0083 struct ixgb_desc_ring {
0084     /* pointer to the descriptor ring memory */
0085     void *desc;
0086     /* physical address of the descriptor ring */
0087     dma_addr_t dma;
0088     /* length of descriptor ring in bytes */
0089     unsigned int size;
0090     /* number of descriptors in the ring */
0091     unsigned int count;
0092     /* next descriptor to associate a buffer with */
0093     unsigned int next_to_use;
0094     /* next descriptor to check for DD status bit */
0095     unsigned int next_to_clean;
0096     /* array of buffer information structs */
0097     struct ixgb_buffer *buffer_info;
0098 };
0099 
0100 #define IXGB_DESC_UNUSED(R) \
0101     ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
0102     (R)->next_to_clean - (R)->next_to_use - 1)
0103 
0104 #define IXGB_GET_DESC(R, i, type)   (&(((struct type *)((R).desc))[i]))
0105 #define IXGB_RX_DESC(R, i)      IXGB_GET_DESC(R, i, ixgb_rx_desc)
0106 #define IXGB_TX_DESC(R, i)      IXGB_GET_DESC(R, i, ixgb_tx_desc)
0107 #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
0108 
0109 /* board specific private data structure */
0110 
0111 struct ixgb_adapter {
0112     struct timer_list watchdog_timer;
0113     unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
0114     u32 bd_number;
0115     u32 rx_buffer_len;
0116     u32 part_num;
0117     u16 link_speed;
0118     u16 link_duplex;
0119     struct work_struct tx_timeout_task;
0120 
0121     /* TX */
0122     struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
0123     unsigned int restart_queue;
0124     unsigned long timeo_start;
0125     u32 tx_cmd_type;
0126     u64 hw_csum_tx_good;
0127     u64 hw_csum_tx_error;
0128     u32 tx_int_delay;
0129     u32 tx_timeout_count;
0130     bool tx_int_delay_enable;
0131     bool detect_tx_hung;
0132 
0133     /* RX */
0134     struct ixgb_desc_ring rx_ring;
0135     u64 hw_csum_rx_error;
0136     u64 hw_csum_rx_good;
0137     u32 rx_int_delay;
0138     bool rx_csum;
0139 
0140     /* OS defined structs */
0141     struct napi_struct napi;
0142     struct net_device *netdev;
0143     struct pci_dev *pdev;
0144 
0145     /* structs defined in ixgb_hw.h */
0146     struct ixgb_hw hw;
0147     u16 msg_enable;
0148     struct ixgb_hw_stats stats;
0149     u32 alloc_rx_buff_failed;
0150     bool have_msi;
0151     unsigned long flags;
0152 };
0153 
0154 enum ixgb_state_t {
0155     /* TBD
0156     __IXGB_TESTING,
0157     __IXGB_RESETTING,
0158     */
0159     __IXGB_DOWN
0160 };
0161 
0162 /* Exported from other modules */
0163 void ixgb_check_options(struct ixgb_adapter *adapter);
0164 void ixgb_set_ethtool_ops(struct net_device *netdev);
0165 extern char ixgb_driver_name[];
0166 
0167 void ixgb_set_speed_duplex(struct net_device *netdev);
0168 
0169 int ixgb_up(struct ixgb_adapter *adapter);
0170 void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
0171 void ixgb_reset(struct ixgb_adapter *adapter);
0172 int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
0173 int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
0174 void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
0175 void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
0176 void ixgb_update_stats(struct ixgb_adapter *adapter);
0177 
0178 
0179 #endif /* _IXGB_H_ */