Imported Upstream version 16.04
[deb_dpdk.git] / lib / librte_eal / linuxapp / kni / ethtool / igb / igb.h
1 /*******************************************************************************
2
3   Intel(R) Gigabit Ethernet Linux driver
4   Copyright(c) 2007-2013 Intel Corporation.
5
6   This program is free software; you can redistribute it and/or modify it
7   under the terms and conditions of the GNU General Public License,
8   version 2, as published by the Free Software Foundation.
9
10   This program is distributed in the hope it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13   more details.
14
15   You should have received a copy of the GNU General Public License along with
16   this program; if not, write to the Free Software Foundation, Inc.,
17   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19   The full GNU General Public License is included in this distribution in
20   the file called "COPYING".
21
22   Contact Information:
23   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25
26 *******************************************************************************/
27
28 /* Linux PRO/1000 Ethernet Driver main header file */
29
30 #ifndef _IGB_H_
31 #define _IGB_H_
32
33 #include <linux/kobject.h>
34
35 #ifndef IGB_NO_LRO
36 #include <net/tcp.h>
37 #endif
38
39 #undef HAVE_HW_TIME_STAMP
40 #ifdef HAVE_HW_TIME_STAMP
41 #include <linux/pci.h>
42 #include <linux/netdevice.h>
43 #include <linux/vmalloc.h>
44
45 #endif
46 #ifdef SIOCETHTOOL
47 #include <linux/ethtool.h>
48 #endif
49
50 struct igb_adapter;
51
52 #if defined(CONFIG_DCA) || defined(CONFIG_DCA_MODULE)
53 //#define IGB_DCA
54 #endif
55 #ifdef IGB_DCA
56 #include <linux/dca.h>
57 #endif
58
59 #include "kcompat.h"
60
61 #ifdef HAVE_SCTP
62 #include <linux/sctp.h>
63 #endif
64
65 #include "e1000_api.h"
66 #include "e1000_82575.h"
67 #include "e1000_manage.h"
68 #include "e1000_mbx.h"
69
70 #define IGB_ERR(args...) printk(KERN_ERR "igb: " args)
71
72 #define PFX "igb: "
73 #define DPRINTK(nlevel, klevel, fmt, args...) \
74         (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
75         printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
76                 __FUNCTION__ , ## args))
77
78 #ifdef HAVE_PTP_1588_CLOCK
79 #include <linux/clocksource.h>
80 #include <linux/net_tstamp.h>
81 #include <linux/ptp_clock_kernel.h>
82 #endif /* HAVE_PTP_1588_CLOCK */
83
84 #ifdef HAVE_I2C_SUPPORT
85 #include <linux/i2c.h>
86 #include <linux/i2c-algo-bit.h>
87 #endif /* HAVE_I2C_SUPPORT */
88
89 /* Interrupt defines */
90 #define IGB_START_ITR                    648 /* ~6000 ints/sec */
91 #define IGB_4K_ITR                       980
92 #define IGB_20K_ITR                      196
93 #define IGB_70K_ITR                       56
94
95 /* Interrupt modes, as used by the IntMode parameter */
96 #define IGB_INT_MODE_LEGACY                0
97 #define IGB_INT_MODE_MSI                   1
98 #define IGB_INT_MODE_MSIX                  2
99
100 /* TX/RX descriptor defines */
101 #define IGB_DEFAULT_TXD                  256
102 #define IGB_DEFAULT_TX_WORK              128
103 #define IGB_MIN_TXD                       80
104 #define IGB_MAX_TXD                     4096
105
106 #define IGB_DEFAULT_RXD                  256
107 #define IGB_MIN_RXD                       80
108 #define IGB_MAX_RXD                     4096
109
110 #define IGB_MIN_ITR_USECS                 10 /* 100k irq/sec */
111 #define IGB_MAX_ITR_USECS               8191 /* 120  irq/sec */
112
113 #define NON_Q_VECTORS                      1
114 #define MAX_Q_VECTORS                     10
115
116 /* Transmit and receive queues */
117 #define IGB_MAX_RX_QUEUES                 16
118 #define IGB_MAX_TX_QUEUES                 16
119
120 #define IGB_MAX_VF_MC_ENTRIES             30
121 #define IGB_MAX_VF_FUNCTIONS               8
122 #define IGB_82576_VF_DEV_ID           0x10CA
123 #define IGB_I350_VF_DEV_ID            0x1520
124 #define IGB_MAX_UTA_ENTRIES              128
125 #define MAX_EMULATION_MAC_ADDRS           16
126 #define OUI_LEN                            3
127 #define IGB_MAX_VMDQ_QUEUES                8
128
129
130 struct vf_data_storage {
131         unsigned char vf_mac_addresses[ETH_ALEN];
132         u16 vf_mc_hashes[IGB_MAX_VF_MC_ENTRIES];
133         u16 num_vf_mc_hashes;
134         u16 default_vf_vlan_id;
135         u16 vlans_enabled;
136         unsigned char em_mac_addresses[MAX_EMULATION_MAC_ADDRS * ETH_ALEN];
137         u32 uta_table_copy[IGB_MAX_UTA_ENTRIES];
138         u32 flags;
139         unsigned long last_nack;
140 #ifdef IFLA_VF_MAX
141         u16 pf_vlan; /* When set, guest VLAN config not allowed. */
142         u16 pf_qos;
143         u16 tx_rate;
144 #ifdef HAVE_VF_SPOOFCHK_CONFIGURE
145         bool spoofchk_enabled;
146 #endif
147 #endif
148 };
149
150 #define IGB_VF_FLAG_CTS            0x00000001 /* VF is clear to send data */
151 #define IGB_VF_FLAG_UNI_PROMISC    0x00000002 /* VF has unicast promisc */
152 #define IGB_VF_FLAG_MULTI_PROMISC  0x00000004 /* VF has multicast promisc */
153 #define IGB_VF_FLAG_PF_SET_MAC     0x00000008 /* PF has set MAC address */
154
155 /* RX descriptor control thresholds.
156  * PTHRESH - MAC will consider prefetch if it has fewer than this number of
157  *           descriptors available in its onboard memory.
158  *           Setting this to 0 disables RX descriptor prefetch.
159  * HTHRESH - MAC will only prefetch if there are at least this many descriptors
160  *           available in host memory.
161  *           If PTHRESH is 0, this should also be 0.
162  * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
163  *           descriptors until either it has this many to write back, or the
164  *           ITR timer expires.
165  */
166 #define IGB_RX_PTHRESH  ((hw->mac.type == e1000_i354) ? 12 : 8)
167 #define IGB_RX_HTHRESH  8
168 #define IGB_TX_PTHRESH  ((hw->mac.type == e1000_i354) ? 20 : 8)
169 #define IGB_TX_HTHRESH  1
170 #define IGB_RX_WTHRESH  ((hw->mac.type == e1000_82576 && \
171                           adapter->msix_entries) ? 1 : 4)
172
173 /* this is the size past which hardware will drop packets when setting LPE=0 */
174 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
175
176 /* NOTE: netdev_alloc_skb reserves 16 bytes, NET_IP_ALIGN means we
177  * reserve 2 more, and skb_shared_info adds an additional 384 more,
178  * this adds roughly 448 bytes of extra data meaning the smallest
179  * allocation we could have is 1K.
180  * i.e. RXBUFFER_512 --> size-1024 slab
181  */
182 /* Supported Rx Buffer Sizes */
183 #define IGB_RXBUFFER_256   256
184 #define IGB_RXBUFFER_2048  2048
185 #define IGB_RXBUFFER_16384 16384
186 #define IGB_RX_HDR_LEN     IGB_RXBUFFER_256
187 #if MAX_SKB_FRAGS < 8
188 #define IGB_RX_BUFSZ       ALIGN(MAX_JUMBO_FRAME_SIZE / MAX_SKB_FRAGS, 1024)
189 #else
190 #define IGB_RX_BUFSZ       IGB_RXBUFFER_2048
191 #endif
192
193
194 /* Packet Buffer allocations */
195 #define IGB_PBA_BYTES_SHIFT 0xA
196 #define IGB_TX_HEAD_ADDR_SHIFT 7
197 #define IGB_PBA_TX_MASK 0xFFFF0000
198
199 #define IGB_FC_PAUSE_TIME 0x0680 /* 858 usec */
200
201 /* How many Rx Buffers do we bundle into one write to the hardware ? */
202 #define IGB_RX_BUFFER_WRITE     16      /* Must be power of 2 */
203
204 #define IGB_EEPROM_APME         0x0400
205 #define AUTO_ALL_MODES          0
206
207 #ifndef IGB_MASTER_SLAVE
208 /* Switch to override PHY master/slave setting */
209 #define IGB_MASTER_SLAVE        e1000_ms_hw_default
210 #endif
211
212 #define IGB_MNG_VLAN_NONE -1
213
214 #ifndef IGB_NO_LRO
215 #define IGB_LRO_MAX 32 /*Maximum number of LRO descriptors*/
216 struct igb_lro_stats {
217         u32 flushed;
218         u32 coal;
219 };
220
221 /*
222  * igb_lro_header - header format to be aggregated by LRO
223  * @iph: IP header without options
224  * @tcp: TCP header
225  * @ts:  Optional TCP timestamp data in TCP options
226  *
227  * This structure relies on the check above that verifies that the header
228  * is IPv4 and does not contain any options.
229  */
230 struct igb_lrohdr {
231         struct iphdr iph;
232         struct tcphdr th;
233         __be32 ts[0];
234 };
235
236 struct igb_lro_list {
237         struct sk_buff_head active;
238         struct igb_lro_stats stats;
239 };
240
241 #endif /* IGB_NO_LRO */
242 struct igb_cb {
243 #ifndef IGB_NO_LRO
244 #ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
245         union {                         /* Union defining head/tail partner */
246                 struct sk_buff *head;
247                 struct sk_buff *tail;
248         };
249 #endif
250         __be32  tsecr;                  /* timestamp echo response */
251         u32     tsval;                  /* timestamp value in host order */
252         u32     next_seq;               /* next expected sequence number */
253         u16     free;                   /* 65521 minus total size */
254         u16     mss;                    /* size of data portion of packet */
255         u16     append_cnt;             /* number of skb's appended */
256 #endif /* IGB_NO_LRO */
257 #ifdef HAVE_VLAN_RX_REGISTER
258         u16     vid;                    /* VLAN tag */
259 #endif
260 };
261 #define IGB_CB(skb) ((struct igb_cb *)(skb)->cb)
262
263 enum igb_tx_flags {
264         /* cmd_type flags */
265         IGB_TX_FLAGS_VLAN       = 0x01,
266         IGB_TX_FLAGS_TSO        = 0x02,
267         IGB_TX_FLAGS_TSTAMP     = 0x04,
268
269         /* olinfo flags */
270         IGB_TX_FLAGS_IPV4       = 0x10,
271         IGB_TX_FLAGS_CSUM       = 0x20,
272 };
273
274 /* VLAN info */
275 #define IGB_TX_FLAGS_VLAN_MASK          0xffff0000
276 #define IGB_TX_FLAGS_VLAN_SHIFT                 16
277
278 /*
279  * The largest size we can write to the descriptor is 65535.  In order to
280  * maintain a power of two alignment we have to limit ourselves to 32K.
281  */
282 #define IGB_MAX_TXD_PWR         15
283 #define IGB_MAX_DATA_PER_TXD    (1 << IGB_MAX_TXD_PWR)
284
285 /* Tx Descriptors needed, worst case */
286 #define TXD_USE_COUNT(S)        DIV_ROUND_UP((S), IGB_MAX_DATA_PER_TXD)
287 #ifndef MAX_SKB_FRAGS
288 #define DESC_NEEDED     4
289 #elif (MAX_SKB_FRAGS < 16)
290 #define DESC_NEEDED     ((MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE)) + 4)
291 #else
292 #define DESC_NEEDED     (MAX_SKB_FRAGS + 4)
293 #endif
294
295 /* wrapper around a pointer to a socket buffer,
296  * so a DMA handle can be stored along with the buffer */
297 struct igb_tx_buffer {
298         union e1000_adv_tx_desc *next_to_watch;
299         unsigned long time_stamp;
300         struct sk_buff *skb;
301         unsigned int bytecount;
302         u16 gso_segs;
303         __be16 protocol;
304         DEFINE_DMA_UNMAP_ADDR(dma);
305         DEFINE_DMA_UNMAP_LEN(len);
306         u32 tx_flags;
307 };
308
309 struct igb_rx_buffer {
310         dma_addr_t dma;
311 #ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
312         struct sk_buff *skb;
313 #else
314         struct page *page;
315         u32 page_offset;
316 #endif
317 };
318
319 struct igb_tx_queue_stats {
320         u64 packets;
321         u64 bytes;
322         u64 restart_queue;
323 };
324
325 struct igb_rx_queue_stats {
326         u64 packets;
327         u64 bytes;
328         u64 drops;
329         u64 csum_err;
330         u64 alloc_failed;
331         u64 ipv4_packets;      /* IPv4 headers processed */
332         u64 ipv4e_packets;     /* IPv4E headers with extensions processed */
333         u64 ipv6_packets;      /* IPv6 headers processed */
334         u64 ipv6e_packets;     /* IPv6E headers with extensions processed */
335         u64 tcp_packets;       /* TCP headers processed */
336         u64 udp_packets;       /* UDP headers processed */
337         u64 sctp_packets;      /* SCTP headers processed */
338         u64 nfs_packets;       /* NFS headers processe */
339 };
340
341 struct igb_ring_container {
342         struct igb_ring *ring;          /* pointer to linked list of rings */
343         unsigned int total_bytes;       /* total bytes processed this int */
344         unsigned int total_packets;     /* total packets processed this int */
345         u16 work_limit;                 /* total work allowed per interrupt */
346         u8 count;                       /* total number of rings in vector */
347         u8 itr;                         /* current ITR setting for ring */
348 };
349
350 struct igb_ring {
351         struct igb_q_vector *q_vector;  /* backlink to q_vector */
352         struct net_device *netdev;      /* back pointer to net_device */
353         struct device *dev;             /* device for dma mapping */
354         union {                         /* array of buffer info structs */
355                 struct igb_tx_buffer *tx_buffer_info;
356                 struct igb_rx_buffer *rx_buffer_info;
357         };
358 #ifdef HAVE_PTP_1588_CLOCK
359         unsigned long last_rx_timestamp;
360 #endif /* HAVE_PTP_1588_CLOCK */
361         void *desc;                     /* descriptor ring memory */
362         unsigned long flags;            /* ring specific flags */
363         void __iomem *tail;             /* pointer to ring tail register */
364         dma_addr_t dma;                 /* phys address of the ring */
365         unsigned int size;              /* length of desc. ring in bytes */
366
367         u16 count;                      /* number of desc. in the ring */
368         u8 queue_index;                 /* logical index of the ring*/
369         u8 reg_idx;                     /* physical index of the ring */
370
371         /* everything past this point are written often */
372         u16 next_to_clean;
373         u16 next_to_use;
374         u16 next_to_alloc;
375
376         union {
377                 /* TX */
378                 struct {
379                         struct igb_tx_queue_stats tx_stats;
380                 };
381                 /* RX */
382                 struct {
383                         struct igb_rx_queue_stats rx_stats;
384 #ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
385                         u16 rx_buffer_len;
386 #else
387                         struct sk_buff *skb;
388 #endif
389                 };
390         };
391 #ifdef CONFIG_IGB_VMDQ_NETDEV
392         struct net_device *vmdq_netdev;
393         int vqueue_index;               /* queue index for virtual netdev */
394 #endif
395 } ____cacheline_internodealigned_in_smp;
396
397 struct igb_q_vector {
398         struct igb_adapter *adapter;    /* backlink */
399         int cpu;                        /* CPU for DCA */
400         u32 eims_value;                 /* EIMS mask value */
401
402         u16 itr_val;
403         u8 set_itr;
404         void __iomem *itr_register;
405
406         struct igb_ring_container rx, tx;
407
408         struct napi_struct napi;
409 #ifndef IGB_NO_LRO
410         struct igb_lro_list lrolist;   /* LRO list for queue vector*/
411 #endif
412         char name[IFNAMSIZ + 9];
413 #ifndef HAVE_NETDEV_NAPI_LIST
414         struct net_device poll_dev;
415 #endif
416
417         /* for dynamic allocation of rings associated with this q_vector */
418         struct igb_ring ring[0] ____cacheline_internodealigned_in_smp;
419 };
420
421 enum e1000_ring_flags_t {
422 #ifndef HAVE_NDO_SET_FEATURES
423         IGB_RING_FLAG_RX_CSUM,
424 #endif
425         IGB_RING_FLAG_RX_SCTP_CSUM,
426         IGB_RING_FLAG_RX_LB_VLAN_BSWAP,
427         IGB_RING_FLAG_TX_CTX_IDX,
428         IGB_RING_FLAG_TX_DETECT_HANG,
429 };
430
431 struct igb_mac_addr {
432         u8 addr[ETH_ALEN];
433         u16 queue;
434         u16 state; /* bitmask */
435 };
436 #define IGB_MAC_STATE_DEFAULT   0x1
437 #define IGB_MAC_STATE_MODIFIED  0x2
438 #define IGB_MAC_STATE_IN_USE    0x4
439
440 #define IGB_TXD_DCMD (E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_RS)
441
442 #define IGB_RX_DESC(R, i)           \
443         (&(((union e1000_adv_rx_desc *)((R)->desc))[i]))
444 #define IGB_TX_DESC(R, i)           \
445         (&(((union e1000_adv_tx_desc *)((R)->desc))[i]))
446 #define IGB_TX_CTXTDESC(R, i)       \
447         (&(((struct e1000_adv_tx_context_desc *)((R)->desc))[i]))
448
449 #ifdef CONFIG_IGB_VMDQ_NETDEV
450 #define netdev_ring(ring) \
451         ((ring->vmdq_netdev ? ring->vmdq_netdev : ring->netdev))
452 #define ring_queue_index(ring) \
453         ((ring->vmdq_netdev ? ring->vqueue_index : ring->queue_index))
454 #else
455 #define netdev_ring(ring) (ring->netdev)
456 #define ring_queue_index(ring) (ring->queue_index)
457 #endif /* CONFIG_IGB_VMDQ_NETDEV */
458
459 /* igb_test_staterr - tests bits within Rx descriptor status and error fields */
460 static inline __le32 igb_test_staterr(union e1000_adv_rx_desc *rx_desc,
461                                       const u32 stat_err_bits)
462 {
463         return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
464 }
465
466 /* igb_desc_unused - calculate if we have unused descriptors */
467 static inline u16 igb_desc_unused(const struct igb_ring *ring)
468 {
469         u16 ntc = ring->next_to_clean;
470         u16 ntu = ring->next_to_use;
471
472         return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
473 }
474
475 #ifdef CONFIG_BQL
476 static inline struct netdev_queue *txring_txq(const struct igb_ring *tx_ring)
477 {
478         return netdev_get_tx_queue(tx_ring->netdev, tx_ring->queue_index);
479 }
480 #endif /* CONFIG_BQL */
481
482 // #ifdef EXT_THERMAL_SENSOR_SUPPORT
483 // #ifdef IGB_PROCFS
484 struct igb_therm_proc_data
485 {
486         struct e1000_hw *hw;
487         struct e1000_thermal_diode_data *sensor_data;
488 };
489
490 //  #endif /* IGB_PROCFS */
491 // #endif /* EXT_THERMAL_SENSOR_SUPPORT */
492
493 #ifdef IGB_HWMON
494 #define IGB_HWMON_TYPE_LOC      0
495 #define IGB_HWMON_TYPE_TEMP     1
496 #define IGB_HWMON_TYPE_CAUTION  2
497 #define IGB_HWMON_TYPE_MAX      3
498
499 struct hwmon_attr {
500         struct device_attribute dev_attr;
501         struct e1000_hw *hw;
502         struct e1000_thermal_diode_data *sensor;
503         char name[12];
504         };
505
506 struct hwmon_buff {
507         struct device *device;
508         struct hwmon_attr *hwmon_list;
509         unsigned int n_hwmon;
510         };
511 #endif /* IGB_HWMON */
512
513 /* board specific private data structure */
514 struct igb_adapter {
515 #ifdef HAVE_VLAN_RX_REGISTER
516         /* vlgrp must be first member of structure */
517         struct vlan_group *vlgrp;
518 #else
519         unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
520 #endif
521         struct net_device *netdev;
522
523         unsigned long state;
524         unsigned int flags;
525
526         unsigned int num_q_vectors;
527         struct msix_entry *msix_entries;
528
529
530         /* TX */
531         u16 tx_work_limit;
532         u32 tx_timeout_count;
533         int num_tx_queues;
534         struct igb_ring *tx_ring[IGB_MAX_TX_QUEUES];
535
536         /* RX */
537         int num_rx_queues;
538         struct igb_ring *rx_ring[IGB_MAX_RX_QUEUES];
539
540         struct timer_list watchdog_timer;
541         struct timer_list dma_err_timer;
542         struct timer_list phy_info_timer;
543         u16 mng_vlan_id;
544         u32 bd_number;
545         u32 wol;
546         u32 en_mng_pt;
547         u16 link_speed;
548         u16 link_duplex;
549         u8 port_num;
550
551         /* Interrupt Throttle Rate */
552         u32 rx_itr_setting;
553         u32 tx_itr_setting;
554
555         struct work_struct reset_task;
556         struct work_struct watchdog_task;
557         struct work_struct dma_err_task;
558         bool fc_autoneg;
559         u8  tx_timeout_factor;
560
561 #ifdef DEBUG
562         bool tx_hang_detected;
563         bool disable_hw_reset;
564 #endif
565         u32 max_frame_size;
566
567         /* OS defined structs */
568         struct pci_dev *pdev;
569 #ifndef HAVE_NETDEV_STATS_IN_NETDEV
570         struct net_device_stats net_stats;
571 #endif
572 #ifndef IGB_NO_LRO
573         struct igb_lro_stats lro_stats;
574 #endif
575
576         /* structs defined in e1000_hw.h */
577         struct e1000_hw hw;
578         struct e1000_hw_stats stats;
579         struct e1000_phy_info phy_info;
580         struct e1000_phy_stats phy_stats;
581
582 #ifdef ETHTOOL_TEST
583         u32 test_icr;
584         struct igb_ring test_tx_ring;
585         struct igb_ring test_rx_ring;
586 #endif
587
588         int msg_enable;
589
590         struct igb_q_vector *q_vector[MAX_Q_VECTORS];
591         u32 eims_enable_mask;
592         u32 eims_other;
593
594         /* to not mess up cache alignment, always add to the bottom */
595         u32 *config_space;
596         u16 tx_ring_count;
597         u16 rx_ring_count;
598         struct vf_data_storage *vf_data;
599 #ifdef IFLA_VF_MAX
600         int vf_rate_link_speed;
601 #endif
602         u32 lli_port;
603         u32 lli_size;
604         unsigned int vfs_allocated_count;
605         /* Malicious Driver Detection flag. Valid only when SR-IOV is enabled */
606         bool mdd;
607         int int_mode;
608         u32 rss_queues;
609         u32 vmdq_pools;
610         char fw_version[32];
611         u32 wvbr;
612         struct igb_mac_addr *mac_table;
613 #ifdef CONFIG_IGB_VMDQ_NETDEV
614         struct net_device *vmdq_netdev[IGB_MAX_VMDQ_QUEUES];
615 #endif
616         int vferr_refcount;
617         int dmac;
618         u32 *shadow_vfta;
619
620         /* External Thermal Sensor support flag */
621         bool ets;
622 #ifdef IGB_HWMON
623         struct hwmon_buff igb_hwmon_buff;
624 #else /* IGB_HWMON */
625 #ifdef IGB_PROCFS
626         struct proc_dir_entry *eth_dir;
627         struct proc_dir_entry *info_dir;
628         struct proc_dir_entry *therm_dir[E1000_MAX_SENSORS];
629         struct igb_therm_proc_data therm_data[E1000_MAX_SENSORS];
630         bool old_lsc;
631 #endif /* IGB_PROCFS */
632 #endif /* IGB_HWMON */
633         u32 etrack_id;
634
635 #ifdef HAVE_PTP_1588_CLOCK
636         struct ptp_clock *ptp_clock;
637         struct ptp_clock_info ptp_caps;
638         struct delayed_work ptp_overflow_work;
639         struct work_struct ptp_tx_work;
640         struct sk_buff *ptp_tx_skb;
641         unsigned long ptp_tx_start;
642         unsigned long last_rx_ptp_check;
643         spinlock_t tmreg_lock;
644         struct cyclecounter cc;
645         struct timecounter tc;
646         u32 tx_hwtstamp_timeouts;
647         u32 rx_hwtstamp_cleared;
648 #endif /* HAVE_PTP_1588_CLOCK */
649
650 #ifdef HAVE_I2C_SUPPORT
651         struct i2c_algo_bit_data i2c_algo;
652         struct i2c_adapter i2c_adap;
653         struct i2c_client *i2c_client;
654 #endif /* HAVE_I2C_SUPPORT */
655         unsigned long link_check_timeout;
656
657
658         int devrc;
659
660         int copper_tries;
661         u16 eee_advert;
662 };
663
664 #ifdef CONFIG_IGB_VMDQ_NETDEV
665 struct igb_vmdq_adapter {
666 #ifdef HAVE_VLAN_RX_REGISTER
667         /* vlgrp must be first member of structure */
668         struct vlan_group *vlgrp;
669 #else
670         unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
671 #endif
672         struct igb_adapter *real_adapter;
673         struct net_device *vnetdev;
674         struct net_device_stats net_stats;
675         struct igb_ring *tx_ring;
676         struct igb_ring *rx_ring;
677 };
678 #endif
679
680 #define IGB_FLAG_HAS_MSI                (1 << 0)
681 #define IGB_FLAG_DCA_ENABLED            (1 << 1)
682 #define IGB_FLAG_LLI_PUSH               (1 << 2)
683 #define IGB_FLAG_QUAD_PORT_A            (1 << 3)
684 #define IGB_FLAG_QUEUE_PAIRS            (1 << 4)
685 #define IGB_FLAG_EEE                    (1 << 5)
686 #define IGB_FLAG_DMAC                   (1 << 6)
687 #define IGB_FLAG_DETECT_BAD_DMA         (1 << 7)
688 #define IGB_FLAG_PTP                    (1 << 8)
689 #define IGB_FLAG_RSS_FIELD_IPV4_UDP     (1 << 9)
690 #define IGB_FLAG_RSS_FIELD_IPV6_UDP     (1 << 10)
691 #define IGB_FLAG_WOL_SUPPORTED          (1 << 11)
692 #define IGB_FLAG_NEED_LINK_UPDATE       (1 << 12)
693 #define IGB_FLAG_LOOPBACK_ENABLE        (1 << 13)
694 #define IGB_FLAG_MEDIA_RESET            (1 << 14)
695 #define IGB_FLAG_MAS_ENABLE             (1 << 15)
696
697 /* Media Auto Sense */
698 #define IGB_MAS_ENABLE_0                0X0001
699 #define IGB_MAS_ENABLE_1                0X0002
700 #define IGB_MAS_ENABLE_2                0X0004
701 #define IGB_MAS_ENABLE_3                0X0008
702
703 #define IGB_MIN_TXPBSIZE           20408
704 #define IGB_TX_BUF_4096            4096
705
706 #define IGB_DMCTLX_DCFLUSH_DIS     0x80000000  /* Disable DMA Coal Flush */
707
708 /* DMA Coalescing defines */
709 #define IGB_DMAC_DISABLE          0
710 #define IGB_DMAC_MIN            250
711 #define IGB_DMAC_500            500
712 #define IGB_DMAC_EN_DEFAULT    1000
713 #define IGB_DMAC_2000          2000
714 #define IGB_DMAC_3000          3000
715 #define IGB_DMAC_4000          4000
716 #define IGB_DMAC_5000          5000
717 #define IGB_DMAC_6000          6000
718 #define IGB_DMAC_7000          7000
719 #define IGB_DMAC_8000          8000
720 #define IGB_DMAC_9000          9000
721 #define IGB_DMAC_MAX          10000
722
723 #define IGB_82576_TSYNC_SHIFT 19
724 #define IGB_82580_TSYNC_SHIFT 24
725 #define IGB_TS_HDR_LEN        16
726
727 /* CEM Support */
728 #define FW_HDR_LEN           0x4
729 #define FW_CMD_DRV_INFO      0xDD
730 #define FW_CMD_DRV_INFO_LEN  0x5
731 #define FW_CMD_RESERVED      0X0
732 #define FW_RESP_SUCCESS      0x1
733 #define FW_UNUSED_VER        0x0
734 #define FW_MAX_RETRIES       3
735 #define FW_STATUS_SUCCESS    0x1
736 #define FW_FAMILY_DRV_VER    0Xffffffff
737
738 #define IGB_MAX_LINK_TRIES   20
739
740 struct e1000_fw_hdr {
741         u8 cmd;
742         u8 buf_len;
743         union
744         {
745                 u8 cmd_resv;
746                 u8 ret_status;
747         } cmd_or_resp;
748         u8 checksum;
749 };
750
751 #pragma pack(push,1)
752 struct e1000_fw_drv_info {
753         struct e1000_fw_hdr hdr;
754         u8 port_num;
755         u32 drv_version;
756         u16 pad; /* end spacing to ensure length is mult. of dword */
757         u8  pad2; /* end spacing to ensure length is mult. of dword2 */
758 };
759 #pragma pack(pop)
760
761 enum e1000_state_t {
762         __IGB_TESTING,
763         __IGB_RESETTING,
764         __IGB_DOWN
765 };
766
767 extern char igb_driver_name[];
768 extern char igb_driver_version[];
769
770 extern int igb_up(struct igb_adapter *);
771 extern void igb_down(struct igb_adapter *);
772 extern void igb_reinit_locked(struct igb_adapter *);
773 extern void igb_reset(struct igb_adapter *);
774 extern int igb_set_spd_dplx(struct igb_adapter *, u16);
775 extern int igb_setup_tx_resources(struct igb_ring *);
776 extern int igb_setup_rx_resources(struct igb_ring *);
777 extern void igb_free_tx_resources(struct igb_ring *);
778 extern void igb_free_rx_resources(struct igb_ring *);
779 extern void igb_configure_tx_ring(struct igb_adapter *, struct igb_ring *);
780 extern void igb_configure_rx_ring(struct igb_adapter *, struct igb_ring *);
781 extern void igb_setup_tctl(struct igb_adapter *);
782 extern void igb_setup_rctl(struct igb_adapter *);
783 extern netdev_tx_t igb_xmit_frame_ring(struct sk_buff *, struct igb_ring *);
784 extern void igb_unmap_and_free_tx_resource(struct igb_ring *,
785                                            struct igb_tx_buffer *);
786 extern void igb_alloc_rx_buffers(struct igb_ring *, u16);
787 extern void igb_clean_rx_ring(struct igb_ring *);
788 extern void igb_update_stats(struct igb_adapter *);
789 extern bool igb_has_link(struct igb_adapter *adapter);
790 extern void igb_set_ethtool_ops(struct net_device *);
791 extern void igb_check_options(struct igb_adapter *);
792 extern void igb_power_up_link(struct igb_adapter *);
793 #ifdef HAVE_PTP_1588_CLOCK
794 extern void igb_ptp_init(struct igb_adapter *adapter);
795 extern void igb_ptp_stop(struct igb_adapter *adapter);
796 extern void igb_ptp_reset(struct igb_adapter *adapter);
797 extern void igb_ptp_tx_work(struct work_struct *work);
798 extern void igb_ptp_rx_hang(struct igb_adapter *adapter);
799 extern void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter);
800 extern void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
801                                 struct sk_buff *skb);
802 extern void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector,
803                                 unsigned char *va,
804                                 struct sk_buff *skb);
805 static inline void igb_ptp_rx_hwtstamp(struct igb_ring *rx_ring,
806                                        union e1000_adv_rx_desc *rx_desc,
807                                        struct sk_buff *skb)
808 {
809         if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) {
810 #ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
811                 igb_ptp_rx_pktstamp(rx_ring->q_vector, skb->data, skb);
812                 skb_pull(skb, IGB_TS_HDR_LEN);
813 #endif
814                 return;
815         }
816
817         if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TS))
818                 igb_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
819
820         /* Update the last_rx_timestamp timer in order to enable watchdog check
821          * for error case of latched timestamp on a dropped packet.
822          */
823         rx_ring->last_rx_timestamp = jiffies;
824 }
825
826 extern int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
827                                   struct ifreq *ifr, int cmd);
828 #endif /* HAVE_PTP_1588_CLOCK */
829 #ifdef ETHTOOL_OPS_COMPAT
830 extern int ethtool_ioctl(struct ifreq *);
831 #endif
832 extern int igb_write_mc_addr_list(struct net_device *netdev);
833 extern int igb_add_mac_filter(struct igb_adapter *adapter, u8 *addr, u16 queue);
834 extern int igb_del_mac_filter(struct igb_adapter *adapter, u8* addr, u16 queue);
835 extern int igb_available_rars(struct igb_adapter *adapter);
836 extern s32 igb_vlvf_set(struct igb_adapter *, u32, bool, u32);
837 extern void igb_configure_vt_default_pool(struct igb_adapter *adapter);
838 extern void igb_enable_vlan_tags(struct igb_adapter *adapter);
839 #ifndef HAVE_VLAN_RX_REGISTER
840 extern void igb_vlan_mode(struct net_device *, u32);
841 #endif
842
843 #define E1000_PCS_CFG_IGN_SD    1
844
845 #ifdef IGB_HWMON
846 void igb_sysfs_exit(struct igb_adapter *adapter);
847 int igb_sysfs_init(struct igb_adapter *adapter);
848 #else
849 #ifdef IGB_PROCFS
850 int igb_procfs_init(struct igb_adapter* adapter);
851 void igb_procfs_exit(struct igb_adapter* adapter);
852 int igb_procfs_topdir_init(void);
853 void igb_procfs_topdir_exit(void);
854 #endif /* IGB_PROCFS */
855 #endif /* IGB_HWMON */
856
857
858
859 #endif /* _IGB_H_ */