aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mv643xx_eth.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/mv643xx_eth.h')
-rw-r--r--drivers/net/mv643xx_eth.h250
1 files changed, 92 insertions, 158 deletions
diff --git a/drivers/net/mv643xx_eth.h b/drivers/net/mv643xx_eth.h
index f769f9b626ea..7754d1974b9e 100644
--- a/drivers/net/mv643xx_eth.h
+++ b/drivers/net/mv643xx_eth.h
@@ -5,53 +5,16 @@
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/spinlock.h> 6#include <linux/spinlock.h>
7#include <linux/workqueue.h> 7#include <linux/workqueue.h>
8#include <linux/mii.h>
8 9
9#include <linux/mv643xx.h> 10#include <linux/mv643xx.h>
10 11
11#define BIT0 0x00000001
12#define BIT1 0x00000002
13#define BIT2 0x00000004
14#define BIT3 0x00000008
15#define BIT4 0x00000010
16#define BIT5 0x00000020
17#define BIT6 0x00000040
18#define BIT7 0x00000080
19#define BIT8 0x00000100
20#define BIT9 0x00000200
21#define BIT10 0x00000400
22#define BIT11 0x00000800
23#define BIT12 0x00001000
24#define BIT13 0x00002000
25#define BIT14 0x00004000
26#define BIT15 0x00008000
27#define BIT16 0x00010000
28#define BIT17 0x00020000
29#define BIT18 0x00040000
30#define BIT19 0x00080000
31#define BIT20 0x00100000
32#define BIT21 0x00200000
33#define BIT22 0x00400000
34#define BIT23 0x00800000
35#define BIT24 0x01000000
36#define BIT25 0x02000000
37#define BIT26 0x04000000
38#define BIT27 0x08000000
39#define BIT28 0x10000000
40#define BIT29 0x20000000
41#define BIT30 0x40000000
42#define BIT31 0x80000000
43
44/*
45 * The first part is the high level driver of the gigE ethernet ports.
46 */
47
48/* Checksum offload for Tx works for most packets, but 12/* Checksum offload for Tx works for most packets, but
49 * fails if previous packet sent did not use hw csum 13 * fails if previous packet sent did not use hw csum
50 */ 14 */
51#define MV643XX_CHECKSUM_OFFLOAD_TX 15#define MV643XX_CHECKSUM_OFFLOAD_TX
52#define MV643XX_NAPI 16#define MV643XX_NAPI
53#define MV643XX_TX_FAST_REFILL 17#define MV643XX_TX_FAST_REFILL
54#undef MV643XX_RX_QUEUE_FILL_ON_TASK /* Does not work, yet */
55#undef MV643XX_COAL 18#undef MV643XX_COAL
56 19
57/* 20/*
@@ -73,25 +36,40 @@
73#define MV643XX_RX_COAL 100 36#define MV643XX_RX_COAL 100
74#endif 37#endif
75 38
76/* 39#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
77 * The second part is the low level driver of the gigE ethernet ports. 40#define MAX_DESCS_PER_SKB (MAX_SKB_FRAGS + 1)
78 */ 41#else
42#define MAX_DESCS_PER_SKB 1
43#endif
79 44
80/* 45#define ETH_VLAN_HLEN 4
81 * Header File for : MV-643xx network interface header 46#define ETH_FCS_LEN 4
82 * 47#define ETH_DMA_ALIGN 8 /* hw requires 8-byte alignment */
83 * DESCRIPTION: 48#define ETH_HW_IP_ALIGN 2 /* hw aligns IP header */
84 * This header file contains macros typedefs and function declaration for 49#define ETH_WRAPPER_LEN (ETH_HW_IP_ALIGN + ETH_HLEN + \
85 * the Marvell Gig Bit Ethernet Controller. 50 ETH_VLAN_HLEN + ETH_FCS_LEN)
86 * 51#define ETH_RX_SKB_SIZE ((dev->mtu + ETH_WRAPPER_LEN + 7) & ~0x7)
87 * DEPENDENCIES: 52
88 * None. 53#define ETH_RX_QUEUES_ENABLED (1 << 0) /* use only Q0 for receive */
89 * 54#define ETH_TX_QUEUES_ENABLED (1 << 0) /* use only Q0 for transmit */
90 */ 55
56#define ETH_INT_CAUSE_RX_DONE (ETH_RX_QUEUES_ENABLED << 2)
57#define ETH_INT_CAUSE_RX_ERROR (ETH_RX_QUEUES_ENABLED << 9)
58#define ETH_INT_CAUSE_RX (ETH_INT_CAUSE_RX_DONE | ETH_INT_CAUSE_RX_ERROR)
59#define ETH_INT_CAUSE_EXT 0x00000002
60#define ETH_INT_UNMASK_ALL (ETH_INT_CAUSE_RX | ETH_INT_CAUSE_EXT)
91 61
92/* MAC accepet/reject macros */ 62#define ETH_INT_CAUSE_TX_DONE (ETH_TX_QUEUES_ENABLED << 0)
93#define ACCEPT_MAC_ADDR 0 63#define ETH_INT_CAUSE_TX_ERROR (ETH_TX_QUEUES_ENABLED << 8)
94#define REJECT_MAC_ADDR 1 64#define ETH_INT_CAUSE_TX (ETH_INT_CAUSE_TX_DONE | ETH_INT_CAUSE_TX_ERROR)
65#define ETH_INT_CAUSE_PHY 0x00010000
66#define ETH_INT_UNMASK_ALL_EXT (ETH_INT_CAUSE_TX | ETH_INT_CAUSE_PHY)
67
68#define ETH_INT_MASK_ALL 0x00000000
69#define ETH_INT_MASK_ALL_EXT 0x00000000
70
71#define PHY_WAIT_ITERATIONS 1000 /* 1000 iterations * 10uS = 10mS max */
72#define PHY_WAIT_MICRO_SECONDS 10
95 73
96/* Buffer offset from buffer pointer */ 74/* Buffer offset from buffer pointer */
97#define RX_BUF_OFFSET 0x2 75#define RX_BUF_OFFSET 0x2
@@ -133,88 +111,71 @@
133#define ETH_MIB_LATE_COLLISION 0x7c 111#define ETH_MIB_LATE_COLLISION 0x7c
134 112
135/* Port serial status reg (PSR) */ 113/* Port serial status reg (PSR) */
136#define ETH_INTERFACE_GMII_MII 0 114#define ETH_INTERFACE_PCM 0x00000001
137#define ETH_INTERFACE_PCM BIT0 115#define ETH_LINK_IS_UP 0x00000002
138#define ETH_LINK_IS_DOWN 0 116#define ETH_PORT_AT_FULL_DUPLEX 0x00000004
139#define ETH_LINK_IS_UP BIT1 117#define ETH_RX_FLOW_CTRL_ENABLED 0x00000008
140#define ETH_PORT_AT_HALF_DUPLEX 0 118#define ETH_GMII_SPEED_1000 0x00000010
141#define ETH_PORT_AT_FULL_DUPLEX BIT2 119#define ETH_MII_SPEED_100 0x00000020
142#define ETH_RX_FLOW_CTRL_DISABLED 0 120#define ETH_TX_IN_PROGRESS 0x00000080
143#define ETH_RX_FLOW_CTRL_ENBALED BIT3 121#define ETH_BYPASS_ACTIVE 0x00000100
144#define ETH_GMII_SPEED_100_10 0 122#define ETH_PORT_AT_PARTITION_STATE 0x00000200
145#define ETH_GMII_SPEED_1000 BIT4 123#define ETH_PORT_TX_FIFO_EMPTY 0x00000400
146#define ETH_MII_SPEED_10 0
147#define ETH_MII_SPEED_100 BIT5
148#define ETH_NO_TX 0
149#define ETH_TX_IN_PROGRESS BIT7
150#define ETH_BYPASS_NO_ACTIVE 0
151#define ETH_BYPASS_ACTIVE BIT8
152#define ETH_PORT_NOT_AT_PARTITION_STATE 0
153#define ETH_PORT_AT_PARTITION_STATE BIT9
154#define ETH_PORT_TX_FIFO_NOT_EMPTY 0
155#define ETH_PORT_TX_FIFO_EMPTY BIT10
156
157#define ETH_DEFAULT_RX_BPDU_QUEUE_3 (BIT23 | BIT22)
158#define ETH_DEFAULT_RX_BPDU_QUEUE_4 BIT24
159#define ETH_DEFAULT_RX_BPDU_QUEUE_5 (BIT24 | BIT22)
160#define ETH_DEFAULT_RX_BPDU_QUEUE_6 (BIT24 | BIT23)
161#define ETH_DEFAULT_RX_BPDU_QUEUE_7 (BIT24 | BIT23 | BIT22)
162 124
163/* SMI reg */ 125/* SMI reg */
164#define ETH_SMI_BUSY BIT28 /* 0 - Write, 1 - Read */ 126#define ETH_SMI_BUSY 0x10000000 /* 0 - Write, 1 - Read */
165#define ETH_SMI_READ_VALID BIT27 /* 0 - Write, 1 - Read */ 127#define ETH_SMI_READ_VALID 0x08000000 /* 0 - Write, 1 - Read */
166#define ETH_SMI_OPCODE_WRITE 0 /* Completion of Read operation */ 128#define ETH_SMI_OPCODE_WRITE 0 /* Completion of Read */
167#define ETH_SMI_OPCODE_READ BIT26 /* Operation is in progress */ 129#define ETH_SMI_OPCODE_READ 0x04000000 /* Operation is in progress */
130
131/* Interrupt Cause Register Bit Definitions */
168 132
169/* SDMA command status fields macros */ 133/* SDMA command status fields macros */
170 134
171/* Tx & Rx descriptors status */ 135/* Tx & Rx descriptors status */
172#define ETH_ERROR_SUMMARY (BIT0) 136#define ETH_ERROR_SUMMARY 0x00000001
173 137
174/* Tx & Rx descriptors command */ 138/* Tx & Rx descriptors command */
175#define ETH_BUFFER_OWNED_BY_DMA (BIT31) 139#define ETH_BUFFER_OWNED_BY_DMA 0x80000000
176 140
177/* Tx descriptors status */ 141/* Tx descriptors status */
178#define ETH_LC_ERROR (0 ) 142#define ETH_LC_ERROR 0
179#define ETH_UR_ERROR (BIT1 ) 143#define ETH_UR_ERROR 0x00000002
180#define ETH_RL_ERROR (BIT2 ) 144#define ETH_RL_ERROR 0x00000004
181#define ETH_LLC_SNAP_FORMAT (BIT9 ) 145#define ETH_LLC_SNAP_FORMAT 0x00000200
182 146
183/* Rx descriptors status */ 147/* Rx descriptors status */
184#define ETH_CRC_ERROR (0 ) 148#define ETH_OVERRUN_ERROR 0x00000002
185#define ETH_OVERRUN_ERROR (BIT1 ) 149#define ETH_MAX_FRAME_LENGTH_ERROR 0x00000004
186#define ETH_MAX_FRAME_LENGTH_ERROR (BIT2 ) 150#define ETH_RESOURCE_ERROR 0x00000006
187#define ETH_RESOURCE_ERROR ((BIT2 | BIT1)) 151#define ETH_VLAN_TAGGED 0x00080000
188#define ETH_VLAN_TAGGED (BIT19) 152#define ETH_BPDU_FRAME 0x00100000
189#define ETH_BPDU_FRAME (BIT20) 153#define ETH_UDP_FRAME_OVER_IP_V_4 0x00200000
190#define ETH_TCP_FRAME_OVER_IP_V_4 (0 ) 154#define ETH_OTHER_FRAME_TYPE 0x00400000
191#define ETH_UDP_FRAME_OVER_IP_V_4 (BIT21) 155#define ETH_LAYER_2_IS_ETH_V_2 0x00800000
192#define ETH_OTHER_FRAME_TYPE (BIT22) 156#define ETH_FRAME_TYPE_IP_V_4 0x01000000
193#define ETH_LAYER_2_IS_ETH_V_2 (BIT23) 157#define ETH_FRAME_HEADER_OK 0x02000000
194#define ETH_FRAME_TYPE_IP_V_4 (BIT24) 158#define ETH_RX_LAST_DESC 0x04000000
195#define ETH_FRAME_HEADER_OK (BIT25) 159#define ETH_RX_FIRST_DESC 0x08000000
196#define ETH_RX_LAST_DESC (BIT26) 160#define ETH_UNKNOWN_DESTINATION_ADDR 0x10000000
197#define ETH_RX_FIRST_DESC (BIT27) 161#define ETH_RX_ENABLE_INTERRUPT 0x20000000
198#define ETH_UNKNOWN_DESTINATION_ADDR (BIT28) 162#define ETH_LAYER_4_CHECKSUM_OK 0x40000000
199#define ETH_RX_ENABLE_INTERRUPT (BIT29)
200#define ETH_LAYER_4_CHECKSUM_OK (BIT30)
201 163
202/* Rx descriptors byte count */ 164/* Rx descriptors byte count */
203#define ETH_FRAME_FRAGMENTED (BIT2) 165#define ETH_FRAME_FRAGMENTED 0x00000004
204 166
205/* Tx descriptors command */ 167/* Tx descriptors command */
206#define ETH_LAYER_4_CHECKSUM_FIRST_DESC (BIT10) 168#define ETH_LAYER_4_CHECKSUM_FIRST_DESC 0x00000400
207#define ETH_FRAME_SET_TO_VLAN (BIT15) 169#define ETH_FRAME_SET_TO_VLAN 0x00008000
208#define ETH_TCP_FRAME (0 ) 170#define ETH_UDP_FRAME 0x00010000
209#define ETH_UDP_FRAME (BIT16) 171#define ETH_GEN_TCP_UDP_CHECKSUM 0x00020000
210#define ETH_GEN_TCP_UDP_CHECKSUM (BIT17) 172#define ETH_GEN_IP_V_4_CHECKSUM 0x00040000
211#define ETH_GEN_IP_V_4_CHECKSUM (BIT18) 173#define ETH_ZERO_PADDING 0x00080000
212#define ETH_ZERO_PADDING (BIT19) 174#define ETH_TX_LAST_DESC 0x00100000
213#define ETH_TX_LAST_DESC (BIT20) 175#define ETH_TX_FIRST_DESC 0x00200000
214#define ETH_TX_FIRST_DESC (BIT21) 176#define ETH_GEN_CRC 0x00400000
215#define ETH_GEN_CRC (BIT22) 177#define ETH_TX_ENABLE_INTERRUPT 0x00800000
216#define ETH_TX_ENABLE_INTERRUPT (BIT23) 178#define ETH_AUTO_MODE 0x40000000
217#define ETH_AUTO_MODE (BIT30)
218 179
219#define ETH_TX_IHL_SHIFT 11 180#define ETH_TX_IHL_SHIFT 11
220 181
@@ -324,13 +285,6 @@ struct mv643xx_mib_counters {
324 285
325struct mv643xx_private { 286struct mv643xx_private {
326 int port_num; /* User Ethernet port number */ 287 int port_num; /* User Ethernet port number */
327 u8 port_mac_addr[6]; /* User defined port MAC address.*/
328 u32 port_config; /* User port configuration value*/
329 u32 port_config_extend; /* User port config extend value*/
330 u32 port_sdma_config; /* User port SDMA config value */
331 u32 port_serial_control; /* User port serial control value */
332 u32 port_tx_queue_command; /* Port active Tx queues summary*/
333 u32 port_rx_queue_command; /* Port active Rx queues summary*/
334 288
335 u32 rx_sram_addr; /* Base address of rx sram area */ 289 u32 rx_sram_addr; /* Base address of rx sram area */
336 u32 rx_sram_size; /* Size of rx sram area */ 290 u32 rx_sram_size; /* Size of rx sram area */
@@ -338,7 +292,6 @@ struct mv643xx_private {
338 u32 tx_sram_size; /* Size of tx sram area */ 292 u32 tx_sram_size; /* Size of tx sram area */
339 293
340 int rx_resource_err; /* Rx ring resource error flag */ 294 int rx_resource_err; /* Rx ring resource error flag */
341 int tx_resource_err; /* Tx ring resource error flag */
342 295
343 /* Tx/Rx rings managment indexes fields. For driver use */ 296 /* Tx/Rx rings managment indexes fields. For driver use */
344 297
@@ -347,10 +300,6 @@ struct mv643xx_private {
347 300
348 /* Next available and first returning Tx resource */ 301 /* Next available and first returning Tx resource */
349 int tx_curr_desc_q, tx_used_desc_q; 302 int tx_curr_desc_q, tx_used_desc_q;
350#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
351 int tx_first_desc_q;
352 u32 tx_first_command;
353#endif
354 303
355#ifdef MV643XX_TX_FAST_REFILL 304#ifdef MV643XX_TX_FAST_REFILL
356 u32 tx_clean_threshold; 305 u32 tx_clean_threshold;
@@ -358,54 +307,43 @@ struct mv643xx_private {
358 307
359 struct eth_rx_desc *p_rx_desc_area; 308 struct eth_rx_desc *p_rx_desc_area;
360 dma_addr_t rx_desc_dma; 309 dma_addr_t rx_desc_dma;
361 unsigned int rx_desc_area_size; 310 int rx_desc_area_size;
362 struct sk_buff **rx_skb; 311 struct sk_buff **rx_skb;
363 312
364 struct eth_tx_desc *p_tx_desc_area; 313 struct eth_tx_desc *p_tx_desc_area;
365 dma_addr_t tx_desc_dma; 314 dma_addr_t tx_desc_dma;
366 unsigned int tx_desc_area_size; 315 int tx_desc_area_size;
367 struct sk_buff **tx_skb; 316 struct sk_buff **tx_skb;
368 317
369 struct work_struct tx_timeout_task; 318 struct work_struct tx_timeout_task;
370 319
371 /*
372 * Former struct mv643xx_eth_priv members start here
373 */
374 struct net_device_stats stats; 320 struct net_device_stats stats;
375 struct mv643xx_mib_counters mib_counters; 321 struct mv643xx_mib_counters mib_counters;
376 spinlock_t lock; 322 spinlock_t lock;
377 /* Size of Tx Ring per queue */ 323 /* Size of Tx Ring per queue */
378 unsigned int tx_ring_size; 324 int tx_ring_size;
379 /* Ammont of SKBs outstanding on Tx queue */ 325 /* Number of tx descriptors in use */
380 unsigned int tx_ring_skbs; 326 int tx_desc_count;
381 /* Size of Rx Ring per queue */ 327 /* Size of Rx Ring per queue */
382 unsigned int rx_ring_size; 328 int rx_ring_size;
383 /* Ammount of SKBs allocated to Rx Ring per queue */ 329 /* Number of rx descriptors in use */
384 unsigned int rx_ring_skbs; 330 int rx_desc_count;
385
386 /*
387 * rx_task used to fill RX ring out of bottom half context
388 */
389 struct work_struct rx_task;
390 331
391 /* 332 /*
392 * Used in case RX Ring is empty, which can be caused when 333 * Used in case RX Ring is empty, which can be caused when
393 * system does not have resources (skb's) 334 * system does not have resources (skb's)
394 */ 335 */
395 struct timer_list timeout; 336 struct timer_list timeout;
396 long rx_task_busy __attribute__ ((aligned(SMP_CACHE_BYTES)));
397 unsigned rx_timer_flag;
398 337
399 u32 rx_int_coal; 338 u32 rx_int_coal;
400 u32 tx_int_coal; 339 u32 tx_int_coal;
340 struct mii_if_info mii;
401}; 341};
402 342
403/* ethernet.h API list */
404
405/* Port operation control routines */ 343/* Port operation control routines */
406static void eth_port_init(struct mv643xx_private *mp); 344static void eth_port_init(struct mv643xx_private *mp);
407static void eth_port_reset(unsigned int eth_port_num); 345static void eth_port_reset(unsigned int eth_port_num);
408static void eth_port_start(struct mv643xx_private *mp); 346static void eth_port_start(struct net_device *dev);
409 347
410/* Port MAC address routines */ 348/* Port MAC address routines */
411static void eth_port_uc_addr_set(unsigned int eth_port_num, 349static void eth_port_uc_addr_set(unsigned int eth_port_num,
@@ -423,10 +361,6 @@ static void eth_port_read_smi_reg(unsigned int eth_port_num,
423static void eth_clear_mib_counters(unsigned int eth_port_num); 361static void eth_clear_mib_counters(unsigned int eth_port_num);
424 362
425/* Port data flow control routines */ 363/* Port data flow control routines */
426static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
427 struct pkt_info *p_pkt_info);
428static ETH_FUNC_RET_STATUS eth_tx_return_desc(struct mv643xx_private *mp,
429 struct pkt_info *p_pkt_info);
430static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp, 364static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp,
431 struct pkt_info *p_pkt_info); 365 struct pkt_info *p_pkt_info);
432static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp, 366static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp,