@@ -46,13 +46,79 @@ extern char igc_driver_version[];
4646#define MAX_Q_VECTORS 8
4747#define MAX_STD_JUMBO_FRAME_SIZE 9216
4848
49+ /* Supported Rx Buffer Sizes */
50+ #define IGC_RXBUFFER_256 256
51+ #define IGC_RXBUFFER_2048 2048
52+ #define IGC_RXBUFFER_3072 3072
53+
54+ #define IGC_RX_HDR_LEN IGC_RXBUFFER_256
55+
56+ /* RX and TX descriptor control thresholds.
57+ * PTHRESH - MAC will consider prefetch if it has fewer than this number of
58+ * descriptors available in its onboard memory.
59+ * Setting this to 0 disables RX descriptor prefetch.
60+ * HTHRESH - MAC will only prefetch if there are at least this many descriptors
61+ * available in host memory.
62+ * If PTHRESH is 0, this should also be 0.
63+ * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
64+ * descriptors until either it has this many to write back, or the
65+ * ITR timer expires.
66+ */
67+ #define IGC_RX_PTHRESH 8
68+ #define IGC_RX_HTHRESH 8
69+ #define IGC_TX_PTHRESH 8
70+ #define IGC_TX_HTHRESH 1
71+ #define IGC_RX_WTHRESH 4
72+ #define IGC_TX_WTHRESH 16
73+
74+ #define IGC_RX_DMA_ATTR \
75+ (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)
76+
77+ #define IGC_TS_HDR_LEN 16
78+
79+ #define IGC_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN)
80+
81+ #if (PAGE_SIZE < 8192 )
82+ #define IGC_MAX_FRAME_BUILD_SKB \
83+ (SKB_WITH_OVERHEAD(IGC_RXBUFFER_2048) - IGC_SKB_PAD - IGC_TS_HDR_LEN)
84+ #else
85+ #define IGC_MAX_FRAME_BUILD_SKB (IGC_RXBUFFER_2048 - IGC_TS_HDR_LEN)
86+ #endif
87+
4988enum igc_state_t {
5089 __IGC_TESTING ,
5190 __IGC_RESETTING ,
5291 __IGC_DOWN ,
5392 __IGC_PTP_TX_IN_PROGRESS ,
5493};
5594
95+ /* wrapper around a pointer to a socket buffer,
96+ * so a DMA handle can be stored along with the buffer
97+ */
98+ struct igc_tx_buffer {
99+ union igc_adv_tx_desc * next_to_watch ;
100+ unsigned long time_stamp ;
101+ struct sk_buff * skb ;
102+ unsigned int bytecount ;
103+ u16 gso_segs ;
104+ __be16 protocol ;
105+
106+ DEFINE_DMA_UNMAP_ADDR (dma );
107+ DEFINE_DMA_UNMAP_LEN (len );
108+ u32 tx_flags ;
109+ };
110+
111+ struct igc_rx_buffer {
112+ dma_addr_t dma ;
113+ struct page * page ;
114+ #if (BITS_PER_LONG > 32 ) || (PAGE_SIZE >= 65536 )
115+ __u32 page_offset ;
116+ #else
117+ __u16 page_offset ;
118+ #endif
119+ __u16 pagecnt_bias ;
120+ };
121+
56122struct igc_tx_queue_stats {
57123 u64 packets ;
58124 u64 bytes ;
@@ -214,4 +280,63 @@ struct igc_adapter {
214280 struct igc_mac_addr * mac_table ;
215281};
216282
283+ /* igc_desc_unused - calculate if we have unused descriptors */
284+ static inline u16 igc_desc_unused (const struct igc_ring * ring )
285+ {
286+ u16 ntc = ring -> next_to_clean ;
287+ u16 ntu = ring -> next_to_use ;
288+
289+ return ((ntc > ntu ) ? 0 : ring -> count ) + ntc - ntu - 1 ;
290+ }
291+
292+ static inline struct netdev_queue * txring_txq (const struct igc_ring * tx_ring )
293+ {
294+ return netdev_get_tx_queue (tx_ring -> netdev , tx_ring -> queue_index );
295+ }
296+
297+ enum igc_ring_flags_t {
298+ IGC_RING_FLAG_RX_3K_BUFFER ,
299+ IGC_RING_FLAG_RX_BUILD_SKB_ENABLED ,
300+ IGC_RING_FLAG_RX_SCTP_CSUM ,
301+ IGC_RING_FLAG_RX_LB_VLAN_BSWAP ,
302+ IGC_RING_FLAG_TX_CTX_IDX ,
303+ IGC_RING_FLAG_TX_DETECT_HANG
304+ };
305+
306+ #define ring_uses_large_buffer (ring ) \
307+ test_bit(IGC_RING_FLAG_RX_3K_BUFFER, &(ring)->flags)
308+
309+ #define ring_uses_build_skb (ring ) \
310+ test_bit(IGC_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags)
311+
312+ static inline unsigned int igc_rx_bufsz (struct igc_ring * ring )
313+ {
314+ #if (PAGE_SIZE < 8192 )
315+ if (ring_uses_large_buffer (ring ))
316+ return IGC_RXBUFFER_3072 ;
317+
318+ if (ring_uses_build_skb (ring ))
319+ return IGC_MAX_FRAME_BUILD_SKB + IGC_TS_HDR_LEN ;
320+ #endif
321+ return IGC_RXBUFFER_2048 ;
322+ }
323+
324+ static inline unsigned int igc_rx_pg_order (struct igc_ring * ring )
325+ {
326+ #if (PAGE_SIZE < 8192 )
327+ if (ring_uses_large_buffer (ring ))
328+ return 1 ;
329+ #endif
330+ return 0 ;
331+ }
332+
333+ #define igc_rx_pg_size (_ring ) (PAGE_SIZE << igc_rx_pg_order(_ring))
334+
335+ #define IGC_RX_DESC (R , i ) \
336+ (&(((union igc_adv_rx_desc *)((R)->desc))[i]))
337+ #define IGC_TX_DESC (R , i ) \
338+ (&(((union igc_adv_tx_desc *)((R)->desc))[i]))
339+ #define IGC_TX_CTXTDESC (R , i ) \
340+ (&(((struct igc_adv_tx_context_desc *)((R)->desc))[i]))
341+
217342#endif /* _IGC_H_ */
0 commit comments