Skip to content

Commit 0507ef8

Browse files
aneftinJeff Kirsher
authored and
Jeff Kirsher
committed
igc: Add transmit and receive fastpath and interrupt handlers
This patch adds support for allocating, configuring, and freeing Tx/Rx ring resources. With these changes in place the descriptor queues are in a state where they are ready to transmit or receive if provided buffers. This also adds the transmit and receive fastpath and interrupt handlers. With this code in place the network device is now able to send and receive frames over the network interface using a single queue. Signed-off-by: Sasha Neftin <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 13b5b7f commit 0507ef8

File tree

4 files changed

+1205
-44
lines changed

4 files changed

+1205
-44
lines changed

drivers/net/ethernet/intel/igc/igc.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,31 @@ extern char igc_driver_version[];
3232
#define IGC_START_ITR 648 /* ~6000 ints/sec */
3333
#define IGC_FLAG_HAS_MSI BIT(0)
3434
#define IGC_FLAG_QUEUE_PAIRS BIT(4)
35+
#define IGC_FLAG_NEED_LINK_UPDATE BIT(9)
3536
#define IGC_FLAG_HAS_MSIX BIT(13)
37+
#define IGC_FLAG_VLAN_PROMISC BIT(15)
3638

3739
#define IGC_START_ITR 648 /* ~6000 ints/sec */
3840
#define IGC_4K_ITR 980
3941
#define IGC_20K_ITR 196
4042
#define IGC_70K_ITR 56
4143

44+
#define IGC_DEFAULT_ITR 3 /* dynamic */
45+
#define IGC_MAX_ITR_USECS 10000
46+
#define IGC_MIN_ITR_USECS 10
47+
#define NON_Q_VECTORS 1
48+
#define MAX_MSIX_ENTRIES 10
49+
50+
/* TX/RX descriptor defines */
51+
#define IGC_DEFAULT_TXD 256
52+
#define IGC_DEFAULT_TX_WORK 128
53+
#define IGC_MIN_TXD 80
54+
#define IGC_MAX_TXD 4096
55+
56+
#define IGC_DEFAULT_RXD 256
57+
#define IGC_MIN_RXD 80
58+
#define IGC_MAX_RXD 4096
59+
4260
/* Transmit and receive queues */
4361
#define IGC_MAX_RX_QUEUES 4
4462
#define IGC_MAX_TX_QUEUES 4
@@ -85,13 +103,44 @@ extern char igc_driver_version[];
85103
#define IGC_MAX_FRAME_BUILD_SKB (IGC_RXBUFFER_2048 - IGC_TS_HDR_LEN)
86104
#endif
87105

106+
/* How many Rx Buffers do we bundle into one write to the hardware ? */
107+
#define IGC_RX_BUFFER_WRITE 16 /* Must be power of 2 */
108+
109+
/* igc_test_staterr - tests bits within Rx descriptor status and error fields */
110+
static inline __le32 igc_test_staterr(union igc_adv_rx_desc *rx_desc,
111+
const u32 stat_err_bits)
112+
{
113+
return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
114+
}
115+
88116
enum igc_state_t {
89117
__IGC_TESTING,
90118
__IGC_RESETTING,
91119
__IGC_DOWN,
92120
__IGC_PTP_TX_IN_PROGRESS,
93121
};
94122

123+
enum igc_tx_flags {
124+
/* cmd_type flags */
125+
IGC_TX_FLAGS_VLAN = 0x01,
126+
IGC_TX_FLAGS_TSO = 0x02,
127+
IGC_TX_FLAGS_TSTAMP = 0x04,
128+
129+
/* olinfo flags */
130+
IGC_TX_FLAGS_IPV4 = 0x10,
131+
IGC_TX_FLAGS_CSUM = 0x20,
132+
};
133+
134+
/* The largest size we can write to the descriptor is 65535. In order to
135+
* maintain a power of two alignment we have to limit ourselves to 32K.
136+
*/
137+
#define IGC_MAX_TXD_PWR 15
138+
#define IGC_MAX_DATA_PER_TXD BIT(IGC_MAX_TXD_PWR)
139+
140+
/* Tx Descriptors needed, worst case */
141+
#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IGC_MAX_DATA_PER_TXD)
142+
#define DESC_NEEDED (MAX_SKB_FRAGS + 4)
143+
95144
/* wrapper around a pointer to a socket buffer,
96145
* so a DMA handle can be stored along with the buffer
97146
*/
@@ -123,6 +172,7 @@ struct igc_tx_queue_stats {
123172
u64 packets;
124173
u64 bytes;
125174
u64 restart_queue;
175+
u64 restart_queue2;
126176
};
127177

128178
struct igc_rx_queue_stats {
@@ -181,11 +231,14 @@ struct igc_ring {
181231
/* TX */
182232
struct {
183233
struct igc_tx_queue_stats tx_stats;
234+
struct u64_stats_sync tx_syncp;
235+
struct u64_stats_sync tx_syncp2;
184236
};
185237
/* RX */
186238
struct {
187239
struct igc_rx_queue_stats rx_stats;
188240
struct igc_rx_packet_stats pkt_stats;
241+
struct u64_stats_sync rx_syncp;
189242
struct sk_buff *skb;
190243
};
191244
};
@@ -258,11 +311,17 @@ struct igc_adapter {
258311
struct work_struct watchdog_task;
259312
struct work_struct dma_err_task;
260313

314+
u8 tx_timeout_factor;
315+
261316
int msg_enable;
262317
u32 max_frame_size;
318+
u32 min_frame_size;
263319

264320
/* OS defined structs */
265321
struct pci_dev *pdev;
322+
/* lock for statistics */
323+
spinlock_t stats64_lock;
324+
struct rtnl_link_stats64 stats64;
266325

267326
/* structs defined in igc_hw.h */
268327
struct igc_hw hw;
@@ -275,8 +334,13 @@ struct igc_adapter {
275334
u16 tx_ring_count;
276335
u16 rx_ring_count;
277336

337+
u32 *shadow_vfta;
338+
278339
u32 rss_queues;
279340

341+
/* lock for RX network flow classification filter */
342+
spinlock_t nfc_lock;
343+
280344
struct igc_mac_addr *mac_table;
281345
};
282346

@@ -332,6 +396,8 @@ static inline unsigned int igc_rx_pg_order(struct igc_ring *ring)
332396

333397
#define igc_rx_pg_size(_ring) (PAGE_SIZE << igc_rx_pg_order(_ring))
334398

399+
#define IGC_TXD_DCMD (IGC_ADVTXD_DCMD_EOP | IGC_ADVTXD_DCMD_RS)
400+
335401
#define IGC_RX_DESC(R, i) \
336402
(&(((union igc_adv_rx_desc *)((R)->desc))[i]))
337403
#define IGC_TX_DESC(R, i) \

drivers/net/ethernet/intel/igc/igc_base.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ union igc_adv_tx_desc {
2121
} wb;
2222
};
2323

24+
/* Adv Transmit Descriptor Config Masks */
25+
#define IGC_ADVTXD_MAC_TSTAMP 0x00080000 /* IEEE1588 Timestamp packet */
26+
#define IGC_ADVTXD_DTYP_CTXT 0x00200000 /* Advanced Context Descriptor */
27+
#define IGC_ADVTXD_DTYP_DATA 0x00300000 /* Advanced Data Descriptor */
28+
#define IGC_ADVTXD_DCMD_EOP 0x01000000 /* End of Packet */
29+
#define IGC_ADVTXD_DCMD_IFCS 0x02000000 /* Insert FCS (Ethernet CRC) */
30+
#define IGC_ADVTXD_DCMD_RS 0x08000000 /* Report Status */
31+
#define IGC_ADVTXD_DCMD_DEXT 0x20000000 /* Descriptor extension (1=Adv) */
32+
#define IGC_ADVTXD_DCMD_VLE 0x40000000 /* VLAN pkt enable */
33+
#define IGC_ADVTXD_DCMD_TSE 0x80000000 /* TCP Seg enable */
34+
#define IGC_ADVTXD_PAYLEN_SHIFT 14 /* Adv desc PAYLEN shift */
35+
2436
struct igc_adv_data_desc {
2537
__le64 buffer_addr; /* Address of the descriptor's data buffer */
2638
union {
@@ -75,6 +87,9 @@ union igc_adv_rx_desc {
7587
} wb; /* writeback */
7688
};
7789

90+
/* Adv Transmit Descriptor Config Masks */
91+
#define IGC_ADVTXD_PAYLEN_SHIFT 14 /* Adv desc PAYLEN shift */
92+
7893
/* Additional Transmit Descriptor Control definitions */
7994
#define IGC_TXDCTL_QUEUE_ENABLE 0x02000000 /* Ena specific Tx Queue */
8095

drivers/net/ethernet/intel/igc/igc_defines.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,29 @@
8484
#define IGC_GPIE_EIAME 0x40000000
8585
#define IGC_GPIE_PBA 0x80000000
8686

87+
/* Transmit Descriptor bit definitions */
88+
#define IGC_TXD_DTYP_D 0x00100000 /* Data Descriptor */
89+
#define IGC_TXD_DTYP_C 0x00000000 /* Context Descriptor */
90+
#define IGC_TXD_POPTS_IXSM 0x01 /* Insert IP checksum */
91+
#define IGC_TXD_POPTS_TXSM 0x02 /* Insert TCP/UDP checksum */
92+
#define IGC_TXD_CMD_EOP 0x01000000 /* End of Packet */
93+
#define IGC_TXD_CMD_IFCS 0x02000000 /* Insert FCS (Ethernet CRC) */
94+
#define IGC_TXD_CMD_IC 0x04000000 /* Insert Checksum */
95+
#define IGC_TXD_CMD_RS 0x08000000 /* Report Status */
96+
#define IGC_TXD_CMD_RPS 0x10000000 /* Report Packet Sent */
97+
#define IGC_TXD_CMD_DEXT 0x20000000 /* Desc extension (0 = legacy) */
98+
#define IGC_TXD_CMD_VLE 0x40000000 /* Add VLAN tag */
99+
#define IGC_TXD_CMD_IDE 0x80000000 /* Enable Tidv register */
100+
#define IGC_TXD_STAT_DD 0x00000001 /* Descriptor Done */
101+
#define IGC_TXD_STAT_EC 0x00000002 /* Excess Collisions */
102+
#define IGC_TXD_STAT_LC 0x00000004 /* Late Collisions */
103+
#define IGC_TXD_STAT_TU 0x00000008 /* Transmit underrun */
104+
#define IGC_TXD_CMD_TCP 0x01000000 /* TCP packet */
105+
#define IGC_TXD_CMD_IP 0x02000000 /* IP packet */
106+
#define IGC_TXD_CMD_TSE 0x04000000 /* TCP Seg enable */
107+
#define IGC_TXD_STAT_TC 0x00000004 /* Tx Underrun */
108+
#define IGC_TXD_EXTCMD_TSTAMP 0x00000010 /* IEEE1588 Timestamp packet */
109+
87110
/* Transmit Control */
88111
#define IGC_TCTL_EN 0x00000002 /* enable Tx */
89112
#define IGC_TCTL_PSP 0x00000008 /* pad short packets */
@@ -111,6 +134,25 @@
111134
#define IGC_RCTL_RDMTS_HALF 0x00000000 /* Rx desc min thresh size */
112135
#define IGC_RCTL_BAM 0x00008000 /* broadcast enable */
113136

137+
/* Receive Descriptor bit definitions */
138+
#define IGC_RXD_STAT_EOP 0x02 /* End of Packet */
139+
140+
#define IGC_RXDEXT_STATERR_CE 0x01000000
141+
#define IGC_RXDEXT_STATERR_SE 0x02000000
142+
#define IGC_RXDEXT_STATERR_SEQ 0x04000000
143+
#define IGC_RXDEXT_STATERR_CXE 0x10000000
144+
#define IGC_RXDEXT_STATERR_TCPE 0x20000000
145+
#define IGC_RXDEXT_STATERR_IPE 0x40000000
146+
#define IGC_RXDEXT_STATERR_RXE 0x80000000
147+
148+
/* Same mask, but for extended and packet split descriptors */
149+
#define IGC_RXDEXT_ERR_FRAME_ERR_MASK ( \
150+
IGC_RXDEXT_STATERR_CE | \
151+
IGC_RXDEXT_STATERR_SE | \
152+
IGC_RXDEXT_STATERR_SEQ | \
153+
IGC_RXDEXT_STATERR_CXE | \
154+
IGC_RXDEXT_STATERR_RXE)
155+
114156
/* Header split receive */
115157
#define IGC_RFCTL_IPV6_EX_DIS 0x00010000
116158
#define IGC_RFCTL_LEF 0x00040000
@@ -123,6 +165,9 @@
123165
#define IGC_RCTL_PMCF 0x00800000 /* pass MAC control frames */
124166
#define IGC_RCTL_SECRC 0x04000000 /* Strip Ethernet CRC */
125167

168+
#define I225_RXPBSIZE_DEFAULT 0x000000A2 /* RXPBSIZE default */
169+
#define I225_TXPBSIZE_DEFAULT 0x04000014 /* TXPBSIZE default */
170+
126171
#define IGC_N0_QUEUE -1
127172

128173
#endif /* _IGC_DEFINES_H_ */

0 commit comments

Comments
 (0)