1 Index: linux-2.6.23.16/drivers/net/sl351x_gmac.c
2 ===================================================================
3 --- linux-2.6.23.16.orig/drivers/net/sl351x_gmac.c 2008-03-15 17:00:55.366700383 +0200
4 +++ linux-2.6.23.16/drivers/net/sl351x_gmac.c 2008-03-15 17:01:08.367441241 +0200
7 #include <linux/mtd/kvctl.h>
9 +#define GET_RPTR(x) ((x) & 0xFFFF)
10 +#define GET_WPTR(x) ((x) >> 16)
14 -#define VITESSE_G5SWITCH 1
15 +// #define VITESSE_G5SWITCH 1
16 +#undef VITESSE_G5SWITCH
18 #ifndef CONFIG_SL351x_RXTOE
19 //#define CONFIG_SL351x_RXTOE 1
21 *************************************************************/
22 static int gmac_initialized = 0;
23 TOE_INFO_T toe_private_data;
24 -static int do_again = 0;
25 static int rx_poll_enabled;
26 spinlock_t gmac_fq_lock;
27 unsigned int FLAG_SWITCH;
29 void mac_set_sw_tx_weight(struct net_device *dev, char *weight);
30 void mac_get_hw_tx_weight(struct net_device *dev, char *weight);
31 void mac_set_hw_tx_weight(struct net_device *dev, char *weight);
32 -static inline void toe_gmac_fill_free_q(void);
33 +static inline void toe_gmac_fill_free_q(int count);
35 #ifdef VITESSE_G5SWITCH
36 extern int Get_Set_port_status(void);
38 for(j = 0; i<CONFIG_MAC_NUM; j++)
41 +#ifdef VITESSE_G5SWITCH
42 if(Giga_switch){ // if gswitch present, swap eth0/1
50 tp = (GMAC_INFO_T *)&toe_private_data.gmac[i];
53 toe->gmac[1].dma_base_addr = TOE_GMAC1_DMA_BASE;
54 toe->gmac[0].auto_nego_cfg = 1;
55 toe->gmac[1].auto_nego_cfg = 1;
56 -#ifdef CONFIG_SL3516_ASIC
57 +#ifndef CONFIG_SL3516_ASIC
58 toe->gmac[0].speed_cfg = GMAC_SPEED_1000;
59 toe->gmac[1].speed_cfg = GMAC_SPEED_1000;
62 // Write GLOBAL_QUEUE_THRESHOLD_REG
64 threshold.bits.swfq_empty = (TOE_SW_FREEQ_DESC_NUM > 256) ? 255 :
65 - TOE_SW_FREEQ_DESC_NUM/2;
66 + TOE_SW_FREEQ_DESC_NUM/16;
67 threshold.bits.hwfq_empty = (TOE_HW_FREEQ_DESC_NUM > 256) ? 256/4 :
68 TOE_HW_FREEQ_DESC_NUM/4;
69 threshold.bits.toe_class = (TOE_TOE_DESC_NUM > 256) ? 256/4 :
71 rwptr_reg.bits.rptr = 0;
72 toe->fq_rx_rwptr.bits32 = rwptr_reg.bits32;
73 writel(rwptr_reg.bits32, TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
74 + printk("SWFQ: %08X\n", readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG));
76 // SW Free Queue Descriptors
77 for (i=0; i<TOE_SW_FREEQ_DESC_NUM; i++)
80 sw_desc_ptr->word0.bits.buffer_size = SW_RX_BUF_SIZE;
81 - sw_desc_ptr->word1.bits.sw_id = i; // used to locate skb
82 + sw_desc_ptr->word1.bits.sw_id = 0; // used to locate skb
83 if ( (skb = dev_alloc_skb(SW_RX_BUF_SIZE))==NULL) /* allocate socket buffer */
85 printk("%s::skb buffer allocation fail !\n",__func__); while(1);
87 - REG32(skb->data) = (unsigned int)skb;
90 skb_reserve(skb, SKB_RESERVE_BYTES);
92 + REG32(data + 0) = (unsigned int)skb;
93 + REG32(data + 4) = (unsigned short)i;
95 // toe->rx_skb[i] = skb;
96 sw_desc_ptr->word2.buf_adr = (unsigned int)__pa(skb->data);
97 // consistent_sync((unsigned int)desc_ptr, sizeof(GMAC_RXDESC_T), PCI_DMA_TODEVICE);
99 *----------------------------------------------------------------------*/
100 static void toe_init_default_queue(void)
104 volatile NONTOE_QHDR_T *qhdr;
105 - GMAC_RXDESC_T *desc_ptr;
106 - DMA_SKB_SIZE_T skb_size;
107 + GMAC_RXDESC_T *desc_ptr;
108 + DMA_SKB_SIZE_T skb_size;
110 toe = (TOE_INFO_T *)&toe_private_data;
111 desc_ptr = (GMAC_RXDESC_T *)DMA_MALLOC((TOE_DEFAULT_Q0_DESC_NUM * sizeof(GMAC_RXDESC_T)),
112 - (dma_addr_t *)&toe->gmac[0].default_desc_base_dma);
113 + (dma_addr_t *)&toe->gmac[0].default_desc_base_dma);
116 printk("%s::DMA_MALLOC fail !\n",__func__);
117 @@ -866,14 +878,17 @@
119 memset((void *)desc_ptr, 0, TOE_DEFAULT_Q0_DESC_NUM * sizeof(GMAC_RXDESC_T));
120 toe->gmac[0].default_desc_base = (unsigned int)desc_ptr;
121 + printk("toe->gmac[0].default_desc_base_dma: %08X\n", toe->gmac[0].default_desc_base_dma);
123 toe->gmac[0].default_desc_num = TOE_DEFAULT_Q0_DESC_NUM;
124 qhdr = (volatile NONTOE_QHDR_T *)TOE_DEFAULT_Q0_HDR_BASE;
125 qhdr->word0.base_size = ((unsigned int)toe->gmac[0].default_desc_base_dma & NONTOE_QHDR0_BASE_MASK) | TOE_DEFAULT_Q0_DESC_POWER;
126 qhdr->word1.bits32 = 0;
127 toe->gmac[0].rx_rwptr.bits32 = 0;
128 toe->gmac[0].default_qhdr = (NONTOE_QHDR_T *)qhdr;
130 desc_ptr = (GMAC_RXDESC_T *)DMA_MALLOC((TOE_DEFAULT_Q1_DESC_NUM * sizeof(GMAC_RXDESC_T)),
131 - (dma_addr_t *)&toe->gmac[1].default_desc_base_dma);
132 + (dma_addr_t *)&toe->gmac[1].default_desc_base_dma);
135 printk("%s::DMA_MALLOC fail !\n",__func__);
136 @@ -1071,12 +1086,16 @@
138 data = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_0_REG) & ~tp->intr0_selected;
139 writel(data, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_0_REG);
141 data = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_1_REG) & ~tp->intr1_selected;
142 writel(data, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_1_REG);
144 data = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_2_REG) & ~tp->intr2_selected;
145 writel(data, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_2_REG);
147 data = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_3_REG) & ~tp->intr3_selected;
148 writel(data, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_3_REG);
150 data = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_4_REG) & ~tp->intr4_selected;
151 writel(data, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_4_REG);
153 @@ -1176,11 +1195,11 @@
154 GMAC_CONFIG2_T config2_val;
155 GMAC_CONFIG0_T config0,config0_mask;
156 GMAC_CONFIG1_T config1;
157 - #ifdef CONFIG_SL351x_NAT
158 GMAC_CONFIG3_T config3_val;
160 GMAC_TX_WCR0_T hw_weigh;
161 GMAC_TX_WCR1_T sw_weigh;
163 + uint32_t weight = 0;
164 // GMAC_HASH_ENABLE_REG0_T hash_ctrl;
166 #if 0 /* mac address will be set in late_initcall */
167 @@ -1202,24 +1221,23 @@
168 // config1.bits32 = 0x002004; //next version
169 /* set flow control threshold */
171 - config1.bits.set_threshold = 32 / 2;
172 - config1.bits.rel_threshold = 32 / 4 * 3;
173 + config1.bits.set_threshold = (32 / 2);
174 + config1.bits.rel_threshold = (32 / 4) * 3;
175 gmac_write_reg(tp->base_addr, GMAC_CONFIG1, config1.bits32, 0xffffffff);
177 - /* set flow control threshold */
178 + /* TODO: set flow control threshold */
179 config2_val.bits32 = 0;
180 - config2_val.bits.set_threshold = TOE_SW_FREEQ_DESC_NUM/2;
181 - config2_val.bits.rel_threshold = TOE_SW_FREEQ_DESC_NUM*3/4;
182 + config2_val.bits.set_threshold = TOE_SW_FREEQ_DESC_NUM/4;
183 + config2_val.bits.rel_threshold = TOE_SW_FREEQ_DESC_NUM/2;
184 gmac_write_reg(tp->base_addr, GMAC_CONFIG2, config2_val.bits32,0xffffffff);
186 - #ifdef CONFIG_SL351x_NAT
187 - /* set HW free queue flow control threshold */
188 + /* TODO: set HW free queue flow control threshold */
189 config3_val.bits32 = 0;
190 config3_val.bits.set_threshold = PAUSE_SET_HW_FREEQ;
191 config3_val.bits.rel_threshold = PAUSE_REL_HW_FREEQ;
192 gmac_write_reg(tp->base_addr, GMAC_CONFIG3, config3_val.bits32,0xffffffff);
194 - /* set_mcast_filter mask*/
196 + /* TODO: set_mcast_filter mask*/
197 // gmac_write_reg(tp->base_addr,GMAC_MCAST_FIL0,0x0,0xffffffff);
198 // gmac_write_reg(tp->base_addr,GMAC_MCAST_FIL1,0x0,0xffffffff);
200 @@ -1249,7 +1267,7 @@
201 config0.bits.dis_rx = 1; /* disable rx */
202 config0.bits.dis_tx = 1; /* disable tx */
203 config0.bits.loop_back = 0; /* enable/disable GMAC loopback */
204 - config0.bits.rx_err_detect = 1;
205 + config0.bits.rx_err_detect = 1; /* TODO: was 1, means disabled, 0 enabled ! */
206 config0.bits.rgmii_en = 0;
207 config0.bits.rgmm_edge = 1;
208 config0.bits.rxc_inv = 0;
209 @@ -1342,6 +1360,9 @@
210 gmac_write_reg(tp->dma_base_addr, GMAC_AHB_WEIGHT_REG, ahb_weight.bits32, ahb_weight_mask.bits32);
213 + weight = gmac_read_reg(tp->dma_base_addr, GMAC_AHB_WEIGHT_REG);
214 + printk("====> %08X\n", weight);
216 #if defined(CONFIG_SL351x_NAT) || defined(CONFIG_SL351x_RXTOE)
217 gmac_write_reg(tp->dma_base_addr, GMAC_SPR0, IPPROTO_TCP, 0xffffffff);
219 @@ -1552,7 +1573,7 @@
220 rwptr.bits32 = readl(swtxq->rwptr_reg);
221 if (rwptr.bits.rptr == swtxq->finished_idx)
223 - curr_desc = (volatile GMAC_TXDESC_T *)swtxq->desc_base + swtxq->finished_idx;
224 + curr_desc = (volatile GMAC_TXDESC_T *)swtxq->desc_base + swtxq->finished_idx;
225 // consistent_sync((void *)curr_desc, sizeof(GMAC_TXDESC_T), PCI_DMA_FROMDEVICE);
226 word0.bits32 = curr_desc->word0.bits32;
227 word1.bits32 = curr_desc->word1.bits32;
228 @@ -1573,6 +1594,7 @@
229 swtxq->finished_idx = RWPTR_ADVANCE_ONE(swtxq->finished_idx, swtxq->total_desc_num);
230 curr_desc = (GMAC_TXDESC_T *)swtxq->desc_base + swtxq->finished_idx;
231 word0.bits32 = curr_desc->word0.bits32;
233 #ifdef _DUMP_TX_TCP_CONTENT
234 if (curr_desc->word0.bits.buffer_size < 16)
236 @@ -1592,12 +1614,12 @@
237 word0.bits.status_tx_ok = 0;
238 if (swtxq->tx_skb[swtxq->finished_idx])
241 - dev_kfree_skb_irq(swtxq->tx_skb[swtxq->finished_idx]);
243 - dev_kfree_skb(swtxq->tx_skb[swtxq->finished_idx]);
244 + dev_kfree_skb(swtxq->tx_skb[swtxq->finished_idx]);
245 swtxq->tx_skb[swtxq->finished_idx] = NULL;
250 curr_desc->word0.bits32 = word0.bits32;
251 swtxq->curr_finished_desc = (GMAC_TXDESC_T *)curr_desc;
252 swtxq->total_finished++;
253 @@ -1624,31 +1646,29 @@
254 *----------------------------------------------------------------------*/
255 static int gmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
257 - GMAC_INFO_T *tp= dev->priv;
258 -// static unsigned int pcount = 0;
259 -// unsigned int tx_qid;
261 - volatile GMAC_TXDESC_T *curr_desc;
262 - int snd_pages = skb_shinfo(skb)->nr_frags + 1; /* get number of descriptor */
264 - int len, total_len = skb->len;
265 + GMAC_INFO_T *tp= dev->priv;
267 + GMAC_TXDESC_T *curr_desc;
268 + int snd_pages = skb_shinfo(skb)->nr_frags + 1; /* get number of descriptor */
270 + int len, total_len = skb->len;
271 struct net_device_stats *isPtr;
272 - unsigned int free_desc;
273 - GMAC_SWTXQ_T *swtxq;
274 + unsigned int free_desc;
275 + GMAC_SWTXQ_T *swtxq;
276 register unsigned long word0, word1, word2, word3;
277 unsigned short wptr, rptr;
278 #ifdef L2_jumbo_frame
279 int header_len = skb->len;
280 struct iphdr *ip_hdr;
281 - struct tcphdr *tcp_hdr;
283 - unsigned char *ptr;
286 + struct tcphdr *tcp_hdr;
288 + unsigned char *ptr;
293 #ifdef GMAC_LEN_1_2_ISSUE
296 total_pages = snd_pages;
299 @@ -1664,13 +1684,6 @@
304 - if (storlink_ctl.recvfile==2)
306 - printk("snd_pages=%d skb->len=%d\n",snd_pages,skb->len);
313 @@ -1703,9 +1716,9 @@
314 toe_gmac_tx_complete(tp, tx_qid, dev, 0);
316 if (wptr >= swtxq->finished_idx)
317 - free_desc = swtxq->total_desc_num - wptr - 1 + swtxq->finished_idx;
318 + free_desc = swtxq->total_desc_num - wptr + swtxq->finished_idx;
320 - free_desc = swtxq->finished_idx - wptr - 1;
321 + free_desc = swtxq->finished_idx - wptr;
322 if (free_desc < snd_pages)
324 // spin_unlock(&tp->tx_mutex);
325 @@ -2063,9 +2076,10 @@
326 struct net_device_stats * gmac_get_stats(struct net_device *dev)
328 GMAC_INFO_T *tp = (GMAC_INFO_T *)dev->priv;
329 +#if 0 /* don't read stats from hardware, scary numbers. */
330 // unsigned int flags;
331 - unsigned int pkt_drop;
332 - unsigned int pkt_error;
333 + unsigned int pkt_drop = 0;
334 + unsigned int pkt_error = 0;
336 if (netif_running(dev))
338 @@ -2073,10 +2087,14 @@
339 // spin_lock_irqsave(&tp->lock,flags);
340 pkt_drop = gmac_read_reg(tp->base_addr,GMAC_IN_DISCARDS);
341 pkt_error = gmac_read_reg(tp->base_addr,GMAC_IN_ERRORS);
342 + printk("**** stack: %lu, hw: %lu\n", tp->ifStatics.rx_dropped, pkt_drop);
344 tp->ifStatics.rx_dropped = tp->ifStatics.rx_dropped + pkt_drop;
345 tp->ifStatics.rx_errors = tp->ifStatics.rx_errors + pkt_error;
346 // spin_unlock_irqrestore(&tp->lock,flags);
350 return &tp->ifStatics;
353 @@ -2401,36 +2419,63 @@
354 * toe_gmac_fill_free_q
355 * allocate buffers for free queue.
356 *----------------------------------------------------------------------*/
357 -static inline void toe_gmac_fill_free_q(void)
358 +static inline void toe_gmac_fill_free_q(int count)
361 volatile DMA_RWPTR_T fq_rwptr;
362 volatile GMAC_RXDESC_T *fq_desc;
363 - unsigned long flags;
364 + unsigned long flags;
365 + unsigned short index;
367 + static int entered;
368 // unsigned short max_cnt=TOE_SW_FREEQ_DESC_NUM>>1;
370 + BUG_ON(entered == 1);
375 fq_rwptr.bits32 = readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
376 // spin_lock_irqsave(&gmac_fq_lock, flags);
377 //while ((max_cnt--) && (unsigned short)RWPTR_ADVANCE_ONE(fq_rwptr.bits.wptr,
378 // TOE_SW_FREEQ_DESC_NUM) != fq_rwptr.bits.rptr) {
379 - while ((unsigned short)RWPTR_ADVANCE_ONE(fq_rwptr.bits.wptr,
380 - TOE_SW_FREEQ_DESC_NUM) != fq_rwptr.bits.rptr) {
381 + index = fq_rwptr.bits.wptr;
383 + printk("wptr: %hu, rptr: %hu, refill idx: %hu\n",
384 + GET_RPTR(fq_rwptr.bits32),
385 + GET_WPTR(fq_rwptr.bits32),
389 + index = RWPTR_ADVANCE_ONE(index, TOE_SW_FREEQ_DESC_NUM);
390 + fq_desc = (GMAC_RXDESC_T*)toe_private_data.swfq_desc_base + index;
391 + while (fq_desc->word2.buf_adr == 0) {
394 if ((skb = dev_alloc_skb(SW_RX_BUF_SIZE)) == NULL) {
395 printk("%s::skb allocation fail!\n", __func__);
400 - REG32(skb->data) = (unsigned int)skb;
403 skb_reserve(skb, SKB_RESERVE_BYTES);
404 - // fq_rwptr.bits32 = readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
405 - fq_rwptr.bits.wptr = RWPTR_ADVANCE_ONE(fq_rwptr.bits.wptr,
406 - TOE_SW_FREEQ_DESC_NUM);
407 - fq_desc = (GMAC_RXDESC_T*)toe_private_data.swfq_desc_base+fq_rwptr.bits.wptr;
409 + REG32(data + 0) = (unsigned int)skb;
410 + REG32(data + 4) = (unsigned short)index;
412 + // printk("refill skb: %p, idx: %hu\n", skb, index);
413 fq_desc->word2.buf_adr = (unsigned int)__pa(skb->data);
414 - SET_WPTR(TOE_GLOBAL_BASE+GLOBAL_SWFQ_RWPTR_REG, fq_rwptr.bits.wptr);
415 - toe_private_data.fq_rx_rwptr.bits32 = fq_rwptr.bits32;
416 + writel(0x07960202, TOE_GMAC0_BASE+GMAC_CONFIG0);
417 + SET_WPTR(TOE_GLOBAL_BASE+GLOBAL_SWFQ_RWPTR_REG, index);
418 + writel(0x07960200, TOE_GMAC0_BASE+GMAC_CONFIG0);
420 + index = RWPTR_ADVANCE_ONE(index, TOE_SW_FREEQ_DESC_NUM);
421 + fq_desc = (GMAC_RXDESC_T*)toe_private_data.swfq_desc_base+index;
424 // spin_unlock_irqrestore(&gmac_fq_lock, flags);
428 // EXPORT_SYMBOL(toe_gmac_fill_free_q);
430 @@ -2442,14 +2487,14 @@
431 unsigned int status3;
432 unsigned int status4;
434 - printk("%s\n", message);
436 status0 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_0_REG);
437 status1 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_1_REG);
438 status2 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_2_REG);
439 status3 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_3_REG);
440 status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_4_REG);
442 + printk("%s\n", message);
444 printk("status: s0:%08X, s1:%08X, s2:%08X, s3:%08X, s4:%08X\n",
445 status0, status1, status2, status3, status4);
447 @@ -2468,8 +2513,9 @@
448 status3 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_3_REG);
449 status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_4_REG);
451 - printk("select: s0:%08X, s1:%08X, s2:%08X, s3:%08X, s4:%08X\n",
452 - status0, status1, status2, status3, status4);
453 + if (status0 || status1 || status2 || status3 || status4)
454 + printk("select: s0:%08X, s1:%08X, s2:%08X, s3:%08X, s4:%08X\n",
455 + status0, status1, status2, status3, status4);
457 /*----------------------------------------------------------------------
459 @@ -2485,75 +2531,44 @@
460 unsigned int status3;
461 unsigned int status4;
463 -// struct net_device_stats *isPtr = (struct net_device_stats *)&tp->ifStatics;
464 toe = (TOE_INFO_T *)&toe_private_data;
466 -#ifdef CONFIG_SL_NAPI
467 - /* XXX: check this, changed from 'storlink_ctl.pauseoff == 1' to if (1) */
470 -/* disable GMAC interrupt */
471 - //toe_gmac_disable_interrupt(tp->irq);
473 -// isPtr->interrupts++;
474 + if (0 && rx_poll_enabled) {
475 + gmac_registers("interrupt handler");
478 /* read Interrupt status */
479 status0 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_0_REG);
480 status1 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_1_REG);
481 status2 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_2_REG);
482 status3 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_3_REG);
483 status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_4_REG);
484 - // prompt warning if status bit ON but not enabled
487 - if (status0 & ~tp->intr0_enabled)
488 - printk("Intr 0 Status error. status = 0x%X, enable = 0x%X\n",
489 - status0, tp->intr0_enabled);
490 - if (status1 & ~tp->intr1_enabled)
491 - printk("Intr 1 Status error. status = 0x%X, enable = 0x%X\n",
492 - status1, tp->intr1_enabled);
493 - if (status2 & ~tp->intr2_enabled)
494 - printk("Intr 2 Status error. status = 0x%X, enable = 0x%X\n",
495 - status2, tp->intr2_enabled);
496 - if (status3 & ~tp->intr3_enabled)
497 - printk("Intr 3 Status error. status = 0x%X, enable = 0x%X\n",
498 - status3, tp->intr3_enabled);
499 - if (status4 & ~tp->intr4_enabled)
500 - printk("Intr 4 Status error. status = 0x%X, enable = 0x%X\n",
501 - status4, tp->intr4_enabled);
502 + /* handle freeq interrupt first */
503 + if (status4 & SWFQ_EMPTY_INT_BIT)
505 + toe_gmac_fill_free_q();
506 + writel(status4 & SWFQ_EMPTY_INT_BIT, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_4_REG);
507 + tp->sw_fq_empty_cnt++;
511 + if (status4 & GMAC0_MIB_INT_BIT)
512 + writel(GMAC0_MIB_INT_BIT, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_4_REG);
514 + if (status4 & GMAC0_RX_OVERRUN_INT_BIT)
515 + writel(GMAC0_RX_OVERRUN_INT_BIT, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_4_REG);
518 writel(status0 & tp->intr0_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_0_REG);
520 - writel(status1 & tp->intr1_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_1_REG);
522 writel(status2 & tp->intr2_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_2_REG);
524 writel(status3 & tp->intr3_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_3_REG);
526 - writel(status4 & tp->intr4_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_4_REG);
529 - /* handle freeq interrupt first */
530 - if (status4 & tp->intr4_enabled) {
531 - if ((status4 & SWFQ_EMPTY_INT_BIT) && (tp->intr4_enabled & SWFQ_EMPTY_INT_BIT))
533 - // unsigned long data = REG32(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
534 - //gmac_write_reg(TOE_GLOBAL_BASE, GLOBAL_INTERRUPT_ENABLE_4_REG,
535 - // tp->intr4_enabled & ~SWFQ_EMPTY_INT_BIT, SWFQ_EMPTY_INT_BIT);
537 - if (toe->gmac[0].dev && netif_running(toe->gmac[0].dev))
538 - toe_gmac_handle_default_rxq(toe->gmac[0].dev,&toe->gmac[0]);
539 - if (toe->gmac[1].dev && netif_running(toe->gmac[1].dev))
540 - toe_gmac_handle_default_rxq(toe->gmac[1].dev,&toe->gmac[1]);
541 - printk("\nfreeq int\n");
542 - toe_gmac_fill_free_q();
543 - tp->sw_fq_empty_cnt++;
548 // Interrupt Status 1
549 - if (status1 & tp->intr1_enabled)
550 + if ((status1 & 3) || (status4 & 1))
552 #define G1_INTR0_BITS (GMAC1_HWTQ13_EOF_INT_BIT | GMAC1_HWTQ12_EOF_INT_BIT | GMAC1_HWTQ11_EOF_INT_BIT | GMAC1_HWTQ10_EOF_INT_BIT)
553 #define G0_INTR0_BITS (GMAC0_HWTQ03_EOF_INT_BIT | GMAC0_HWTQ02_EOF_INT_BIT | GMAC0_HWTQ01_EOF_INT_BIT | GMAC0_HWTQ00_EOF_INT_BIT)
554 @@ -2563,7 +2578,7 @@
555 // because they should pass packets to upper layer
556 if (tp->port_id == 0)
558 - if (netif_running(dev) && (status1 & G0_INTR0_BITS) && (tp->intr1_enabled & G0_INTR0_BITS))
559 + if (((status1 & G0_INTR0_BITS) && (tp->intr1_enabled & G0_INTR0_BITS)) || (status4 & 1))
561 if (status1 & GMAC0_HWTQ03_EOF_INT_BIT)
562 tp->hwtxq[3].eof_cnt++;
563 @@ -2574,50 +2589,51 @@
564 if (status1 & GMAC0_HWTQ00_EOF_INT_BIT)
565 tp->hwtxq[0].eof_cnt++;
567 - if (netif_running(dev) && (status1 & DEFAULT_Q0_INT_BIT) && (tp->intr1_enabled & DEFAULT_Q0_INT_BIT))
568 + if (status1 & DEFAULT_Q0_INT_BIT || status4 & 1)
570 + if (likely(netif_rx_schedule_prep(dev)))
572 - if (!rx_poll_enabled && likely(netif_rx_schedule_prep(dev)))
574 - unsigned int data32;
575 + unsigned int data32;
577 + BUG_ON(rx_poll_enabled == 1);
579 - if (rx_poll_enabled)
580 - gmac_registers("check #1");
581 + /* Masks GMAC-0 rx interrupt */
582 + data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
583 + data32 &= ~(DEFAULT_Q0_INT_BIT);
584 + writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
586 - BUG_ON(rx_poll_enabled == 1);
587 + /* Masks GMAC-0 queue empty interrupt */
588 + data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
589 + data32 &= ~DEFAULT_Q0_INT_BIT;
590 + writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
592 + __netif_rx_schedule(dev);
593 + rx_poll_enabled = 1;
596 - /* Masks GMAC-0 rx interrupt */
597 - data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
598 - data32 &= ~(DEFAULT_Q0_INT_BIT);
599 - writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
601 - /* Masks GMAC-0 queue empty interrupt */
602 - data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
603 - data32 &= ~DEFAULT_Q0_INT_BIT;
604 - writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
606 - data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_4_REG);
607 - data32 &= ~DEFAULT_Q0_INT_BIT;
608 - writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_4_REG);
611 - // class-Q & TOE-Q are implemented in future
612 - //data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
613 - //data32 &= ~DEFAULT_Q0_INT_BIT;
614 - //writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
615 - //printk("\%s: DEFAULT_Q0_INT_BIT===================>>>>>>>>>>>>\n",__func__);
616 - writel(0x0, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_ENABLE_1_REG);
617 - //tp->total_q_cnt_napi=0;
618 - //rx_time = jiffies;
619 - //rx_old_bytes = isPtr->rx_bytes;
620 - __netif_rx_schedule(dev);
621 - rx_poll_enabled = 1;
623 + unsigned int data32;
625 + if (rx_poll_enabled)
626 + gmac_registers("->poll() running.");
627 + /* Masks GMAC-0 rx interrupt */
628 + data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
629 + data32 &= ~(DEFAULT_Q0_INT_BIT);
630 + writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
632 + /* Masks GMAC-0 queue empty interrupt */
633 + data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
634 + data32 &= ~DEFAULT_Q0_INT_BIT;
635 + writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
640 + gmac_registers("status1 & DEFAULT_Q0_INT_BIT || status4 & 1");
643 - else if (tp->port_id == 1)
644 + else if (tp->port_id == 1 && netif_running(dev))
646 - if (netif_running(dev) && (status1 & G1_INTR0_BITS) && (tp->intr1_enabled & G1_INTR0_BITS))
647 + if ((status1 & G1_INTR0_BITS) && (tp->intr1_enabled & G1_INTR0_BITS))
649 if (status1 & GMAC1_HWTQ13_EOF_INT_BIT)
650 tp->hwtxq[3].eof_cnt++;
651 @@ -2629,14 +2645,14 @@
652 tp->hwtxq[0].eof_cnt++;
655 - if (netif_running(dev) && (status1 & DEFAULT_Q1_INT_BIT) && (tp->intr1_enabled & DEFAULT_Q1_INT_BIT))
656 + if ((status1 & DEFAULT_Q1_INT_BIT) && (tp->intr1_enabled & DEFAULT_Q1_INT_BIT))
658 if (!rx_poll_enabled && likely(netif_rx_schedule_prep(dev)))
660 - unsigned int data32;
662 + unsigned int data32;
665 - gmac_registers("check #2");
666 + gmac_registers("check #2");
668 BUG_ON(rx_poll_enabled == 1);
670 @@ -2646,7 +2662,7 @@
671 data32 &= ~(DEFAULT_Q1_INT_BIT);
672 writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
674 - /* Masks GMAC-1 queue empty interrupt */
675 + /* Masks GMAC-1 queue empty interrupt */
676 data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
677 data32 &= ~DEFAULT_Q1_INT_BIT;
678 writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
679 @@ -2656,24 +2672,21 @@
680 writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_4_REG);
683 - // disable GMAC-0 rx interrupt
684 - // class-Q & TOE-Q are implemented in future
685 - //data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
686 - //data32 &= ~DEFAULT_Q1_INT_BIT;
687 + // disable GMAC-0 rx interrupt
688 + // class-Q & TOE-Q are implemented in future
689 + //data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
690 + //data32 &= ~DEFAULT_Q1_INT_BIT;
691 //writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
692 //printk("\%s: 1111111111--->DEFAULT_Q1_INT_BIT===================>>>>>>>>>>>>\n",__func__);
693 writel(0x0, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_ENABLE_1_REG);
694 //tp->total_q_cnt_napi=0;
696 //rx_old_bytes = isPtr->rx_bytes;
697 - __netif_rx_schedule(dev);
698 - rx_poll_enabled = 1;
700 + __netif_rx_schedule(dev);
701 + rx_poll_enabled = 1;
707 - gmac_registers("check #3");
710 // Interrupt Status 0
711 @@ -2814,676 +2827,93 @@
715 - //toe_gmac_enable_interrupt(tp->irq);
716 -#ifdef IxscriptMate_1518
717 - if (storlink_ctl.pauseoff == 1)
719 - GMAC_CONFIG0_T config0;
720 - config0.bits32 = readl(TOE_GMAC0_BASE+GMAC_CONFIG0);
721 - config0.bits.dis_rx = 0;
722 - writel(config0.bits32, TOE_GMAC0_BASE+GMAC_CONFIG0);
723 - config0.bits32 = readl(TOE_GMAC1_BASE+GMAC_CONFIG0);
724 - config0.bits.dis_rx = 0;
725 - writel(config0.bits32, TOE_GMAC1_BASE+GMAC_CONFIG0);
728 -// enable_irq(gmac_irq[dev_index]);
729 - //printk("gmac_interrupt complete!\n\n");
730 -// return IRQ_RETVAL(handled);
731 return IRQ_RETVAL(1);
737 +/*----------------------------------------------------------------------
738 +* gmac_get_phy_vendor
739 +*----------------------------------------------------------------------*/
740 +static unsigned int gmac_get_phy_vendor(int phy_addr)
742 + unsigned int reg_val;
743 + reg_val=(mii_read(phy_addr,0x02) << 16) + mii_read(phy_addr,0x03);
747 - /* disable GMAC interrupt */
748 - toe_gmac_disable_interrupt(tp->irq);
749 +/*----------------------------------------------------------------------
750 +* gmac_set_phy_status
751 +*----------------------------------------------------------------------*/
752 +void gmac_set_phy_status(struct net_device *dev)
754 + GMAC_INFO_T *tp = dev->priv;
755 + GMAC_STATUS_T status;
756 + unsigned int reg_val, ability,wan_port_id;
757 + unsigned int i = 0;
759 -// isPtr->interrupts++;
760 - /* read Interrupt status */
761 - status0 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_0_REG);
762 - status1 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_1_REG);
763 - status2 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_2_REG);
764 - status3 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_3_REG);
765 - status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_4_REG);
766 - // prompt warning if status bit ON but not enabled
767 +#ifdef VITESSE_G5SWITCH
768 + if((tp->port_id == GMAC_PORT1)&&(Giga_switch==1)){
770 - if (status0 & ~tp->intr0_enabled)
771 - printk("Intr 0 Status error. status = 0x%X, enable = 0x%X\n",
772 - status0, tp->intr0_enabled);
773 - if (status1 & ~tp->intr1_enabled)
774 - printk("Intr 1 Status error. status = 0x%X, enable = 0x%X\n",
775 - status1, tp->intr1_enabled);
776 - if (status2 & ~tp->intr2_enabled)
777 - printk("Intr 2 Status error. status = 0x%X, enable = 0x%X\n",
778 - status2, tp->intr2_enabled);
779 - if (status3 & ~tp->intr3_enabled)
780 - printk("Intr 3 Status error. status = 0x%X, enable = 0x%X\n",
781 - status3, tp->intr3_enabled);
782 - if (status4 & ~tp->intr4_enabled)
783 - printk("Intr 4 Status error. status = 0x%X, enable = 0x%X\n",
784 - status4, tp->intr4_enabled);
786 -#define INTERRUPT_SELECT 1
788 - writel(status0 & tp->intr0_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_0_REG);
790 - writel(status1 & tp->intr1_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_1_REG);
792 - writel(status2 & tp->intr2_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_2_REG);
794 - writel(status3 & tp->intr3_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_3_REG);
796 - writel(status4 & tp->intr4_enabled, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_4_REG);
798 - /* handle freeq interrupt first */
799 - if (status4 & tp->intr4_enabled) {
800 - if ((status4 & SWFQ_EMPTY_INT_BIT) && (tp->intr4_enabled & SWFQ_EMPTY_INT_BIT))
802 - // unsigned long data = REG32(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
803 - //gmac_write_reg(TOE_GLOBAL_BASE, GLOBAL_INTERRUPT_ENABLE_4_REG,
804 - // tp->intr4_enabled & ~SWFQ_EMPTY_INT_BIT, SWFQ_EMPTY_INT_BIT);
806 - //gmac_write_reg(TOE_GLOBAL_BASE, GLOBAL_INTERRUPT_STATUS_4_REG,
807 - // SWFQ_EMPTY_INT_BIT, SWFQ_EMPTY_INT_BIT);
808 - if (toe->gmac[0].dev && netif_running(toe->gmac[0].dev))
809 - toe_gmac_handle_default_rxq(toe->gmac[0].dev,&toe->gmac[0]);
810 - if (toe->gmac[1].dev && netif_running(toe->gmac[1].dev))
811 - toe_gmac_handle_default_rxq(toe->gmac[1].dev,&toe->gmac[1]);
812 - printk("\nfreeq int\n");
813 - toe_gmac_fill_free_q();
814 - tp->sw_fq_empty_cnt++;
816 - gmac_write_reg(TOE_GLOBAL_BASE, GLOBAL_INTERRUPT_STATUS_4_REG, status4,
817 - SWFQ_EMPTY_INT_BIT);
821 - // Interrupt Status 1
822 - if (status1 & tp->intr1_enabled)
824 - #define G1_INTR0_BITS (GMAC1_HWTQ13_EOF_INT_BIT | GMAC1_HWTQ12_EOF_INT_BIT | GMAC1_HWTQ11_EOF_INT_BIT | GMAC1_HWTQ10_EOF_INT_BIT)
825 - #define G0_INTR0_BITS (GMAC0_HWTQ03_EOF_INT_BIT | GMAC0_HWTQ02_EOF_INT_BIT | GMAC0_HWTQ01_EOF_INT_BIT | GMAC0_HWTQ00_EOF_INT_BIT)
826 - // Handle GMAC 0/1 HW Tx queue 0-3 EOF events
828 - // TOE, Classification, and default queues interrupts are handled by ISR
829 - // because they should pass packets to upper layer
830 - if (tp->port_id == 0)
832 -#ifndef INTERRUPT_SELECT
833 - if (netif_running(dev) && (status1 & G0_INTR0_BITS) && (tp->intr1_enabled & G0_INTR0_BITS))
835 - if (status1 & GMAC0_HWTQ03_EOF_INT_BIT)
836 - tp->hwtxq[3].eof_cnt++;
837 - if (status1 & GMAC0_HWTQ02_EOF_INT_BIT)
838 - tp->hwtxq[2].eof_cnt++;
839 - if (status1 & GMAC0_HWTQ01_EOF_INT_BIT)
840 - tp->hwtxq[1].eof_cnt++;
841 - if (status1 & GMAC0_HWTQ00_EOF_INT_BIT)
842 - tp->hwtxq[0].eof_cnt++;
843 -#endif //INTERRUPT_SELECT
844 -#ifndef INTERRUPT_SELECT
846 -#endif //INTERRUPT_SELECT
847 - if (netif_running(dev) && (status1 & DEFAULT_Q0_INT_BIT) && (tp->intr1_enabled & DEFAULT_Q0_INT_BIT))
849 - tp->default_q_intr_cnt++;
850 - toe_gmac_handle_default_rxq(dev, tp);
851 + rcv_mask = SPI_read(2,0,0x10); // Receive mask
854 + reg_val = BIT(26)|(i<<21)|(10<<16);
855 + SPI_write(3,0,1,reg_val);
857 + reg_val = SPI_read(3,0,2);
858 + if(reg_val & 0x0c00){
859 + printk("Port%d:Giga mode\n",i);
860 + SPI_write(1,i,0x00,0x300701B1);
861 + SPI_write(1,i,0x00,0x10070181);
862 + switch_pre_link[i]=LINK_UP;
863 + switch_pre_speed[i]=GMAC_SPEED_1000;
865 -#ifdef CONFIG_SL351x_RXTOE
866 - if (netif_running(dev) && (status1 & TOE_IQ_ALL_BITS) &&
867 - (tp->intr1_enabled & TOE_IQ_ALL_BITS)) {
868 - //printk("status %x, bits %x, slct %x\n", status1, TOE_IQ_ALL_BITS, tp->intr1_selected);
869 - toe_gmac_handle_toeq(dev, tp, status1);
870 - //toe_gmac_handle_toeq(dev, toe, tp, status1);
872 + reg_val = BIT(26)|(i<<21)|(5<<16);
873 + SPI_write(3,0,1,reg_val);
875 + ability = (reg_val = SPI_read(3,0,2)&0x5e0) >>5;
876 + if ((ability & 0x0C)) /* 100M full duplex */
878 + SPI_write(1,i,0x00,0x30050472);
879 + SPI_write(1,i,0x00,0x10050442);
880 + printk("Port%d:100M\n",i);
881 + switch_pre_link[i]=LINK_UP;
882 + switch_pre_speed[i]=GMAC_SPEED_100;
884 + else if((ability & 0x03)) /* 10M full duplex */
886 + SPI_write(1,i,0x00,0x30050473);
887 + SPI_write(1,i,0x00,0x10050443);
888 + printk("Port%d:10M\n",i);
889 + switch_pre_link[i]=LINK_UP;
890 + switch_pre_speed[i]=GMAC_SPEED_10;
893 + SPI_write(1,i,0x00,BIT(16)); // disable RX
894 + SPI_write(5,0,0x0E,BIT(i)); // dicard packet
895 + while((SPI_read(5,0,0x0C)&BIT(i))==0) // wait to be empty
898 + SPI_write(1,i,0x00,0x20000030); // PORT_RST
899 + switch_pre_link[i]=LINK_DOWN;
900 + switch_pre_speed[i]=GMAC_SPEED_10;
901 + rcv_mask &= ~BIT(i);
902 + SPI_write(2,0,0x10,rcv_mask); // Disable Receive
907 - else if (tp->port_id == 1)
909 -#ifndef INTERRUPT_SELECT
910 - if (netif_running(dev) && (status1 & G1_INTR0_BITS) && (tp->intr1_enabled & G1_INTR0_BITS))
912 - if (status1 & GMAC1_HWTQ13_EOF_INT_BIT)
913 - tp->hwtxq[3].eof_cnt++;
914 - if (status1 & GMAC1_HWTQ12_EOF_INT_BIT)
915 - tp->hwtxq[2].eof_cnt++;
916 - if (status1 & GMAC1_HWTQ11_EOF_INT_BIT)
917 - tp->hwtxq[1].eof_cnt++;
918 - if (status1 & GMAC1_HWTQ10_EOF_INT_BIT)
919 - tp->hwtxq[0].eof_cnt++;
920 -#endif //INTERRUPT_SELECT
921 -#ifndef INTERRUPT_SELECT
923 -#endif //INTERRUPT_SELECT
924 - if (netif_running(dev) && (status1 & DEFAULT_Q1_INT_BIT) && (tp->intr1_enabled & DEFAULT_Q1_INT_BIT))
926 - tp->default_q_intr_cnt++;
927 - toe_gmac_handle_default_rxq(dev, tp);
929 -#ifdef CONFIG_SL351x_RXTOE
930 - if (netif_running(dev) && (status1 & TOE_IQ_ALL_BITS) &&
931 - (tp->intr1_enabled & TOE_IQ_ALL_BITS)) {
932 - //printk("status %x, bits %x, slct %x\n", status1, TOE_IQ_ALL_BITS, tp->intr1_selected);
933 - toe_gmac_handle_toeq(dev, tp, status1);
934 - //toe_gmac_handle_toeq(dev, toe, tp, status1);
938 + gmac_get_switch_status(dev);
939 + gmac_write_reg(tp->base_addr, GMAC_STATUS, 0x7d, 0x0000007f);
940 +// SPI_write(2,0,0x10,rcv_mask); // Enable Receive
945 + reg_val = gmac_get_phy_vendor(tp->phy_addr);
946 + printk("GMAC-%d Addr %d Vendor ID: 0x%08x\n", tp->port_id, tp->phy_addr, reg_val);
948 - // Interrupt Status 0
949 - if (status0 & tp->intr0_enabled)
952 - #define ERR_INTR_BITS (GMAC0_TXDERR_INT_BIT | GMAC0_TXPERR_INT_BIT | \
953 - GMAC1_TXDERR_INT_BIT | GMAC1_TXPERR_INT_BIT | \
954 - GMAC0_RXDERR_INT_BIT | GMAC0_RXPERR_INT_BIT | \
955 - GMAC1_RXDERR_INT_BIT | GMAC1_RXPERR_INT_BIT)
956 -#ifndef INTERRUPT_SELECT
957 - if (status0 & ERR_INTR_BITS)
959 - if ((status0 & GMAC0_TXDERR_INT_BIT) && (tp->intr0_enabled & GMAC0_TXDERR_INT_BIT))
961 - tp->txDerr_cnt[0]++;
962 - printk("GMAC0 TX AHB Bus Error!\n");
964 - if ((status0 & GMAC0_TXPERR_INT_BIT) && (tp->intr0_enabled & GMAC0_TXPERR_INT_BIT))
966 - tp->txPerr_cnt[0]++;
967 - printk("GMAC0 Tx Descriptor Protocol Error!\n");
969 - if ((status0 & GMAC1_TXDERR_INT_BIT) && (tp->intr0_enabled & GMAC1_TXDERR_INT_BIT))
971 - tp->txDerr_cnt[1]++;
972 - printk("GMAC1 Tx AHB Bus Error!\n");
974 - if ((status0 & GMAC1_TXPERR_INT_BIT) && (tp->intr0_enabled & GMAC1_TXPERR_INT_BIT))
976 - tp->txPerr_cnt[1]++;
977 - printk("GMAC1 Tx Descriptor Protocol Error!\n");
980 - if ((status0 & GMAC0_RXDERR_INT_BIT) && (tp->intr0_enabled & GMAC0_RXDERR_INT_BIT))
982 - tp->RxDerr_cnt[0]++;
983 - printk("GMAC0 Rx AHB Bus Error!\n");
985 - if ((status0 & GMAC0_RXPERR_INT_BIT) && (tp->intr0_enabled & GMAC0_RXPERR_INT_BIT))
987 - tp->RxPerr_cnt[0]++;
988 - printk("GMAC0 Rx Descriptor Protocol Error!\n");
990 - if ((status0 & GMAC1_RXDERR_INT_BIT) && (tp->intr0_enabled & GMAC1_RXDERR_INT_BIT))
992 - tp->RxDerr_cnt[1]++;
993 - printk("GMAC1 Rx AHB Bus Error!\n");
995 - if ((status0 & GMAC1_RXPERR_INT_BIT) && (tp->intr0_enabled & GMAC1_RXPERR_INT_BIT))
997 - tp->RxPerr_cnt[1]++;
998 - printk("GMAC1 Rx Descriptor Protocol Error!\n");
1001 -#endif //INTERRUPT_SELECT
1002 -#ifndef GMAX_TX_INTR_DISABLED
1003 - if (tp->port_id == 1 && netif_running(dev) &&
1004 - (((status0 & GMAC1_SWTQ10_FIN_INT_BIT) && (tp->intr0_enabled & GMAC1_SWTQ10_FIN_INT_BIT))
1006 - ((status0 & GMAC1_SWTQ10_EOF_INT_BIT) && (tp->intr0_enabled & GMAC1_SWTQ10_EOF_INT_BIT))))
1008 - toe_gmac_tx_complete(&toe_private_data.gmac[1], 0, dev, 1);
1011 - if (tp->port_id == 0 && netif_running(dev) &&
1012 - (((status0 & GMAC0_SWTQ00_FIN_INT_BIT) && (tp->intr0_enabled & GMAC0_SWTQ00_FIN_INT_BIT))
1014 - ((status0 & GMAC0_SWTQ00_EOF_INT_BIT) && (tp->intr0_enabled & GMAC0_SWTQ00_EOF_INT_BIT))))
1016 - toe_gmac_tx_complete(&toe_private_data.gmac[0], 0, dev, 1);
1019 - // clear enabled status bits
1021 - // Interrupt Status 4
1022 -#ifndef INTERRUPT_SELECT
1023 - if (status4 & tp->intr4_enabled)
1025 - #define G1_INTR4_BITS (0xff000000)
1026 - #define G0_INTR4_BITS (0x00ff0000)
1028 - if (tp->port_id == 0)
1030 - if ((status4 & G0_INTR4_BITS) && (tp->intr4_enabled & G0_INTR4_BITS))
1032 - if (status4 & GMAC0_RESERVED_INT_BIT)
1033 - printk("GMAC0_RESERVED_INT_BIT is ON\n");
1034 - if (status4 & GMAC0_MIB_INT_BIT)
1035 - tp->mib_full_cnt++;
1036 - if (status4 & GMAC0_RX_PAUSE_ON_INT_BIT)
1037 - tp->rx_pause_on_cnt++;
1038 - if (status4 & GMAC0_TX_PAUSE_ON_INT_BIT)
1039 - tp->tx_pause_on_cnt++;
1040 - if (status4 & GMAC0_RX_PAUSE_OFF_INT_BIT)
1041 - tp->rx_pause_off_cnt++;
1042 - if (status4 & GMAC0_TX_PAUSE_OFF_INT_BIT)
1043 - tp->rx_pause_off_cnt++;
1044 - if (status4 & GMAC0_RX_OVERRUN_INT_BIT)
1045 - tp->rx_overrun_cnt++;
1046 - if (status4 & GMAC0_STATUS_CHANGE_INT_BIT)
1047 - tp->status_changed_cnt++;
1050 - else if (tp->port_id == 1)
1052 - if ((status4 & G1_INTR4_BITS) && (tp->intr4_enabled & G1_INTR4_BITS))
1054 - if (status4 & GMAC1_RESERVED_INT_BIT)
1055 - printk("GMAC1_RESERVED_INT_BIT is ON\n");
1056 - if (status4 & GMAC1_MIB_INT_BIT)
1057 - tp->mib_full_cnt++;
1058 - if (status4 & GMAC1_RX_PAUSE_ON_INT_BIT)
1060 - //printk("Gmac pause on\n");
1061 - tp->rx_pause_on_cnt++;
1063 - if (status4 & GMAC1_TX_PAUSE_ON_INT_BIT)
1065 - //printk("Gmac pause on\n");
1066 - tp->tx_pause_on_cnt++;
1068 - if (status4 & GMAC1_RX_PAUSE_OFF_INT_BIT)
1070 - //printk("Gmac pause off\n");
1071 - tp->rx_pause_off_cnt++;
1073 - if (status4 & GMAC1_TX_PAUSE_OFF_INT_BIT)
1075 - //printk("Gmac pause off\n");
1076 - tp->rx_pause_off_cnt++;
1078 - if (status4 & GMAC1_RX_OVERRUN_INT_BIT)
1080 - //printk("Gmac Rx Overrun \n");
1081 - tp->rx_overrun_cnt++;
1083 - if (status4 & GMAC1_STATUS_CHANGE_INT_BIT)
1084 - tp->status_changed_cnt++;
1088 - if ((status4 & SWFQ_EMPTY_INT_BIT) && (tp->intr4_enabled & SWFQ_EMPTY_INT_BIT))
1090 - // unsigned long data = REG32(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
1091 -// mac_stop_rxdma(tp->sc);
1092 - gmac_write_reg(TOE_GLOBAL_BASE, GLOBAL_INTERRUPT_ENABLE_4_REG,
1093 - tp->intr4_enabled & ~SWFQ_EMPTY_INT_BIT, SWFQ_EMPTY_INT_BIT);
1095 - gmac_write_reg(TOE_GLOBAL_BASE, GLOBAL_INTERRUPT_STATUS_4_REG,
1096 - SWFQ_EMPTY_INT_BIT, SWFQ_EMPTY_INT_BIT);
1097 - toe_gmac_fill_free_q();
1098 - tp->sw_fq_empty_cnt++;
1100 - gmac_write_reg(TOE_GLOBAL_BASE, GLOBAL_INTERRUPT_STATUS_4_REG, status4,
1101 - SWFQ_EMPTY_INT_BIT);
1103 -/* if (netif_running(dev))
1104 - toe_gmac_handle_default_rxq(dev, tp);
1105 - printk("SWFQ_EMPTY_INT_BIT is ON!\n"); // should not be happened */
1110 -#endif //INTERRUPT_SELECT
1111 - toe_gmac_enable_interrupt(tp->irq);
1112 -//enable gmac rx function when do RFC 2544
1113 -#ifdef IxscriptMate_1518
1114 - if (storlink_ctl.pauseoff == 1)
1116 - GMAC_CONFIG0_T config0;
1117 - config0.bits32 = readl(TOE_GMAC0_BASE+GMAC_CONFIG0);
1118 - config0.bits.dis_rx = 0;
1119 - writel(config0.bits32, TOE_GMAC0_BASE+GMAC_CONFIG0);
1120 - config0.bits32 = readl(TOE_GMAC1_BASE+GMAC_CONFIG0);
1121 - config0.bits.dis_rx = 0;
1122 - writel(config0.bits32, TOE_GMAC1_BASE+GMAC_CONFIG0);
1125 - //printk("gmac_interrupt complete!\n\n");
1126 -// return IRQ_RETVAL(handled);
1127 - return IRQ_RETVAL(1);
1128 -#ifdef CONFIG_SL_NAPI
1133 -/*----------------------------------------------------------------------
1134 -* toe_gmac_handle_default_rxq
1135 -* (1) Get rx Buffer for default Rx queue
1136 -* (2) notify or call upper-routine to handle it
1137 -* (3) get a new buffer and insert it into SW free queue
1138 -* (4) Note: The SW free queue Read-Write Pointer should be locked when accessing
1139 -*----------------------------------------------------------------------*/
1140 -//static inline void toe_gmac_handle_default_rxq(struct net_device *dev, GMAC_INFO_T *tp)
1141 -static void toe_gmac_handle_default_rxq(struct net_device *dev, GMAC_INFO_T *tp)
1144 - GMAC_RXDESC_T *curr_desc;
1145 - struct sk_buff *skb;
1146 - DMA_RWPTR_T rwptr;
1147 - unsigned int pkt_size;
1149 - unsigned int desc_count;
1150 - unsigned int good_frame, chksum_status, rx_status;
1151 - struct net_device_stats *isPtr = (struct net_device_stats *)&tp->ifStatics;
1153 -//when do ixia RFC 2544 test and packet size is select 1518 bytes,disable gmace rx function immediately after one interrupt come in.
1154 -#ifdef IxscriptMate_1518
1155 - if (storlink_ctl.pauseoff == 1)
1157 - GMAC_CONFIG0_T config0;
1158 - config0.bits32 = readl(TOE_GMAC0_BASE+GMAC_CONFIG0);
1159 - config0.bits.dis_rx = 1;
1160 - writel(config0.bits32, TOE_GMAC0_BASE+GMAC_CONFIG0);
1161 - config0.bits32 = readl(TOE_GMAC1_BASE+GMAC_CONFIG0);
1162 - config0.bits.dis_rx = 1;
1163 - writel(config0.bits32, TOE_GMAC1_BASE+GMAC_CONFIG0);
1166 - rwptr.bits32 = readl(&tp->default_qhdr->word1);
1168 - if (rwptr.bits.rptr != tp->rx_rwptr.bits.rptr)
1170 - mac_stop_txdma((struct net_device *)tp->dev);
1171 - printk("Default Queue HW RD ptr (0x%x) != SW RD Ptr (0x%x)\n",
1172 - rwptr.bits32, tp->rx_rwptr.bits.rptr);
1176 - toe = (TOE_INFO_T *)&toe_private_data;
1177 - max_cnt = DEFAULT_RXQ_MAX_CNT;
1178 - while ((--max_cnt) && rwptr.bits.rptr != rwptr.bits.wptr)
1179 -// while (rwptr.bits.rptr != rwptr.bits.wptr)
1181 -//if packet size is not 1518 for RFC 2544,enable gmac rx function.The other packet size have RX workaround.
1182 -#ifdef IxscriptMate_1518
1183 - if (storlink_ctl.pauseoff == 1)
1185 - if (pkt_size != 1514)
1187 - GMAC_CONFIG0_T config0;
1188 - config0.bits32 = readl(TOE_GMAC0_BASE+GMAC_CONFIG0);
1189 - config0.bits.dis_rx = 0;
1190 - writel(config0.bits32, TOE_GMAC0_BASE+GMAC_CONFIG0);
1191 - config0.bits32 = readl(TOE_GMAC1_BASE+GMAC_CONFIG0);
1192 - config0.bits.dis_rx = 0;
1193 - writel(config0.bits32, TOE_GMAC1_BASE+GMAC_CONFIG0);
1197 - curr_desc = (GMAC_RXDESC_T *)tp->default_desc_base + rwptr.bits.rptr;
1198 -// consistent_sync(curr_desc, sizeof(GMAC_RXDESC_T), PCI_DMA_FROMDEVICE);
1199 - tp->default_q_cnt++;
1200 - tp->rx_curr_desc = (unsigned int)curr_desc;
1201 - rx_status = curr_desc->word0.bits.status;
1202 - chksum_status = curr_desc->word0.bits.chksum_status;
1203 - tp->rx_status_cnt[rx_status]++;
1204 - tp->rx_chksum_cnt[chksum_status]++;
1205 - pkt_size = curr_desc->word1.bits.byte_count; /*total byte count in a frame*/
1206 - desc_count = curr_desc->word0.bits.desc_count; /* get descriptor count per frame */
1208 - if ((curr_desc->word0.bits32 & (GMAC_RXDESC_0_T_derr | GMAC_RXDESC_0_T_perr))
1209 - || (pkt_size < 60)
1210 - || (chksum_status & 0x4)
1214 - if (curr_desc->word0.bits32 & GMAC_RXDESC_0_T_derr)
1215 - printk("%s::derr (GMAC-%d)!!!\n", __func__, tp->port_id);
1216 - if (curr_desc->word0.bits32 & GMAC_RXDESC_0_T_perr)
1217 - printk("%s::perr (GMAC-%d)!!!\n", __func__, tp->port_id);
1220 - if (rx_status == 4 || rx_status == 7)
1221 - isPtr->rx_crc_errors++;
1222 -// printk("%s::Status=%d (GMAC-%d)!!!\n", __func__, rx_status, tp->port_id);
1224 -#ifdef SL351x_GMAC_WORKAROUND
1225 - else if (pkt_size < 60)
1227 - if (tp->short_frames_cnt < GMAC_SHORT_FRAME_THRESHOLD)
1228 - tp->short_frames_cnt++;
1229 - if (tp->short_frames_cnt >= GMAC_SHORT_FRAME_THRESHOLD)
1231 - GMAC_CONFIG0_T config0;
1232 - config0.bits32 = readl(TOE_GMAC0_BASE+GMAC_CONFIG0);
1233 - config0.bits.dis_rx = 1;
1234 - writel(config0.bits32, TOE_GMAC0_BASE+GMAC_CONFIG0);
1235 - config0.bits32 = readl(TOE_GMAC1_BASE+GMAC_CONFIG0);
1236 - config0.bits.dis_rx = 1;
1237 - writel(config0.bits32, TOE_GMAC1_BASE+GMAC_CONFIG0);
1241 -// if (chksum_status)
1242 -// printk("%s::Checksum Status=%d (GMAC-%d)!!!\n", __func__, chksum_status, tp->port_id);
1243 - skb = (struct sk_buff *)(REG32(__va(curr_desc->word2.buf_adr) - SKB_RESERVE_BYTES));
1244 - dev_kfree_skb_irq(skb);
1248 - if (curr_desc->word0.bits.drop)
1249 - printk("%s::Drop (GMAC-%d)!!!\n", __func__, tp->port_id);
1250 -// if (chksum_status)
1251 -// printk("%s::Checksum Status=%d (GMAC-%d)!!!\n", __func__, chksum_status, tp->port_id);
1253 - /* get frame information from the first descriptor of the frame */
1254 -#ifdef SL351x_GMAC_WORKAROUND
1255 - if (tp->short_frames_cnt >= GMAC_SHORT_FRAME_THRESHOLD)
1257 - GMAC_CONFIG0_T config0;
1258 - config0.bits32 = readl(TOE_GMAC0_BASE+GMAC_CONFIG0);
1259 - config0.bits.dis_rx = 0;
1260 - writel(config0.bits32, TOE_GMAC0_BASE+GMAC_CONFIG0);
1261 - config0.bits32 = readl(TOE_GMAC1_BASE+GMAC_CONFIG0);
1262 - config0.bits.dis_rx = 0;
1263 - writel(config0.bits32, TOE_GMAC1_BASE+GMAC_CONFIG0);
1265 - tp->short_frames_cnt = 0;
1267 - isPtr->rx_packets++;
1268 - skb = (struct sk_buff *)(REG32(__va(curr_desc->word2.buf_adr - SKB_RESERVE_BYTES)));
1271 - printk("Fatal Error!!skb==NULL\n");
1274 - tp->curr_rx_skb = skb;
1275 - // consistent_sync((void *)__va(curr_desc->word2.buf_adr), pkt_size, PCI_DMA_FROMDEVICE);
1277 - // curr_desc->word2.buf_adr = 0;
1279 - skb_reserve (skb, RX_INSERT_BYTES); /* 16 byte align the IP fields. */
1280 - skb_put(skb, pkt_size);
1282 - if (chksum_status == RX_CHKSUM_IP_UDP_TCP_OK)
1284 - skb->ip_summed = CHECKSUM_UNNECESSARY;
1285 -#ifdef CONFIG_SL351x_NAT
1286 - if (nat_cfg.enabled && curr_desc->word3.bits.l3_offset && curr_desc->word3.bits.l4_offset)
1288 - struct iphdr *ip_hdr;
1289 - ip_hdr = (struct iphdr *)&(skb->data[curr_desc->word3.bits.l3_offset]);
1290 - sl351x_nat_input(skb,
1292 - (void *)curr_desc->word3.bits.l3_offset,
1293 - (void *)curr_desc->word3.bits.l4_offset);
1296 - skb->protocol = eth_type_trans(skb,dev); /* set skb protocol */
1298 -#ifdef CONFIG_SL351x_RXTOE
1299 - if (storlink_ctl.rx_max_pktsize) {
1300 - struct iphdr *ip_hdr;
1301 - struct tcphdr *tcp_hdr;
1304 - ip_hdr = (struct iphdr*)&(skb->data[0]);
1305 - if ((skb->protocol == __constant_htons(ETH_P_IP)) &&
1306 - ((ip_hdr->protocol & 0x00ff) == IPPROTO_TCP)) {
1307 - ip_hdrlen = ip_hdr->ihl << 2;
1308 - tcp_hdr = (struct tcphdr*)&(skb->data[ip_hdrlen]);
1309 - if (tcp_hdr->syn) {
1310 - struct toe_conn* connection = init_toeq(ip_hdr->version,
1311 - ip_hdr, tcp_hdr, toe, &(skb->data[0]) - 14);
1312 - TCP_SKB_CB(skb)->connection = connection;
1313 - // hash_dump_entry(TCP_SKB_CB(skb)->connection->hash_entry_index);
1314 - // printk("%s::skb data %x, conn %x, mode %x\n",
1315 - // __func__, skb->data, connection, connection->mode);
1322 - else if (chksum_status == RX_CHKSUM_IP_OK_ONLY)
1324 - skb->ip_summed = CHECKSUM_UNNECESSARY;
1325 -#ifdef CONFIG_SL351x_NAT
1326 - if (nat_cfg.enabled && curr_desc->word3.bits.l3_offset && curr_desc->word3.bits.l4_offset)
1328 - struct iphdr *ip_hdr;
1329 - //struct tcphdr *tcp_hdr;
1330 - ip_hdr = (struct iphdr *)&(skb->data[curr_desc->word3.bits.l3_offset]);
1331 - //tcp_hdr = (struct tcphdr *)&(skb->data[curr_desc->word3.bits.l4_offset]);
1332 - if (ip_hdr->protocol == IPPROTO_UDP)
1334 - sl351x_nat_input(skb,
1336 - (void *)curr_desc->word3.bits.l3_offset,
1337 - (void *)curr_desc->word3.bits.l4_offset);
1339 - else if (ip_hdr->protocol == IPPROTO_GRE)
1341 - sl351x_nat_input(skb,
1343 - (void *)curr_desc->word3.bits.l3_offset,
1344 - (void *)curr_desc->word3.bits.l4_offset);
1348 - skb->protocol = eth_type_trans(skb,dev); /* set skb protocol */
1352 - skb->protocol = eth_type_trans(skb,dev); /* set skb protocol */
1355 - netif_rx(skb); /* socket rx */
1356 - dev->last_rx = jiffies;
1358 - isPtr->rx_bytes += pkt_size;
1363 - // advance one for Rx default Q 0/1
1364 - rwptr.bits.rptr = RWPTR_ADVANCE_ONE(rwptr.bits.rptr, tp->default_desc_num);
1365 - SET_RPTR(&tp->default_qhdr->word1, rwptr.bits.rptr);
1366 - tp->rx_rwptr.bits32 = rwptr.bits32;
1370 - /* Handles first available packets only then refill the queue. */
1371 - toe_gmac_fill_free_q();
1374 -/*----------------------------------------------------------------------
1375 -* gmac_get_phy_vendor
1376 -*----------------------------------------------------------------------*/
1377 -static unsigned int gmac_get_phy_vendor(int phy_addr)
1379 - unsigned int reg_val;
1380 - reg_val=(mii_read(phy_addr,0x02) << 16) + mii_read(phy_addr,0x03);
1384 -/*----------------------------------------------------------------------
1385 -* gmac_set_phy_status
1386 -*----------------------------------------------------------------------*/
1387 -void gmac_set_phy_status(struct net_device *dev)
1389 - GMAC_INFO_T *tp = dev->priv;
1390 - GMAC_STATUS_T status;
1391 - unsigned int reg_val, ability,wan_port_id;
1392 - unsigned int i = 0;
1394 -#ifdef VITESSE_G5SWITCH
1395 - if((tp->port_id == GMAC_PORT1)&&(Giga_switch==1)){
1397 - rcv_mask = SPI_read(2,0,0x10); // Receive mask
1400 - reg_val = BIT(26)|(i<<21)|(10<<16);
1401 - SPI_write(3,0,1,reg_val);
1403 - reg_val = SPI_read(3,0,2);
1404 - if(reg_val & 0x0c00){
1405 - printk("Port%d:Giga mode\n",i);
1406 - SPI_write(1,i,0x00,0x300701B1);
1407 - SPI_write(1,i,0x00,0x10070181);
1408 - switch_pre_link[i]=LINK_UP;
1409 - switch_pre_speed[i]=GMAC_SPEED_1000;
1412 - reg_val = BIT(26)|(i<<21)|(5<<16);
1413 - SPI_write(3,0,1,reg_val);
1415 - ability = (reg_val = SPI_read(3,0,2)&0x5e0) >>5;
1416 - if ((ability & 0x0C)) /* 100M full duplex */
1418 - SPI_write(1,i,0x00,0x30050472);
1419 - SPI_write(1,i,0x00,0x10050442);
1420 - printk("Port%d:100M\n",i);
1421 - switch_pre_link[i]=LINK_UP;
1422 - switch_pre_speed[i]=GMAC_SPEED_100;
1424 - else if((ability & 0x03)) /* 10M full duplex */
1426 - SPI_write(1,i,0x00,0x30050473);
1427 - SPI_write(1,i,0x00,0x10050443);
1428 - printk("Port%d:10M\n",i);
1429 - switch_pre_link[i]=LINK_UP;
1430 - switch_pre_speed[i]=GMAC_SPEED_10;
1433 - SPI_write(1,i,0x00,BIT(16)); // disable RX
1434 - SPI_write(5,0,0x0E,BIT(i)); // dicard packet
1435 - while((SPI_read(5,0,0x0C)&BIT(i))==0) // wait to be empty
1438 - SPI_write(1,i,0x00,0x20000030); // PORT_RST
1439 - switch_pre_link[i]=LINK_DOWN;
1440 - switch_pre_speed[i]=GMAC_SPEED_10;
1441 - rcv_mask &= ~BIT(i);
1442 - SPI_write(2,0,0x10,rcv_mask); // Disable Receive
1447 - gmac_get_switch_status(dev);
1448 - gmac_write_reg(tp->base_addr, GMAC_STATUS, 0x7d, 0x0000007f);
1449 -// SPI_write(2,0,0x10,rcv_mask); // Enable Receive
1454 - reg_val = gmac_get_phy_vendor(tp->phy_addr);
1455 - printk("GMAC-%d Addr %d Vendor ID: 0x%08x\n", tp->port_id, tp->phy_addr, reg_val);
1457 - switch (tp->phy_mode)
1458 + switch (tp->phy_mode)
1461 mii_write(tp->phy_addr,0x04,0x05e1); /* advertisement 100M full duplex, pause capable on */
1462 @@ -3552,6 +2982,7 @@
1463 status.bits.link = LINK_DOWN;
1464 // clear_bit(__LINK_STATE_START, &dev->state);
1465 printk("Link Down (0x%04x) ", reg_val);
1466 +#ifdef VITESSE_G5SWITCH
1467 if(Giga_switch == 1)
1470 @@ -3565,6 +2996,7 @@
1471 storlink_ctl.link[ tp->port_id] = 0;
1478 @@ -3572,6 +3004,7 @@
1479 status.bits.link = LINK_UP;
1480 // set_bit(__LINK_STATE_START, &dev->state);
1481 printk("Link Up (0x%04x) ",reg_val);
1482 +#ifdef VITESSE_G5SWITCH
1483 if(Giga_switch == 1)
1486 @@ -3585,6 +3018,7 @@
1487 storlink_ctl.link[ tp->port_id] = 1;
1492 // value = mii_read(PHY_ADDR,0x05);
1494 @@ -3863,6 +3297,7 @@
1497 status.bits.link = LINK_UP; /* link up */
1498 +#ifdef VITESSE_G5SWITCH
1502 @@ -3874,6 +3309,7 @@
1503 storlink_ctl.link[ tp->port_id] = 1;
1507 if ((ability & 0x20)==0x20)
1509 if (tp->flow_control_enable == 0)
1510 @@ -3914,6 +3350,7 @@
1513 status.bits.link = LINK_DOWN; /* link down */
1514 +#ifdef VITESSE_G5SWITCH
1515 if(Giga_switch == 1)
1518 @@ -3925,6 +3362,7 @@
1519 storlink_ctl.link[ tp->port_id] = 0;
1523 if (tp->pre_phy_status == LINK_UP)
1525 printk("GMAC-%d LINK_Down......\n",tp->port_id);
1526 @@ -4298,86 +3736,102 @@
1529 #ifdef CONFIG_SL_NAPI
1531 +static int gmax_rx(struct net_device *dev, int *budget)
1536 +static int gmac_tx(struct net_device *dev, int *budget)
1541 /*----------------------------------------------------------------------
1543 *----------------------------------------------------------------------*/
1544 static int gmac_rx_poll(struct net_device *dev, int *budget)
1547 - GMAC_RXDESC_T *curr_desc;
1548 - struct sk_buff *skb;
1549 - DMA_RWPTR_T rwptr;
1550 - unsigned int data32;
1551 - unsigned int pkt_size;
1552 - unsigned int desc_count;
1553 - unsigned int good_frame, chksum_status, rx_status;
1554 - int rx_pkts_num = 0;
1555 - int quota = min(dev->quota, *budget);
1556 - GMAC_INFO_T *tp = (GMAC_INFO_T *)dev->priv;
1557 - unsigned int status4;
1558 - volatile DMA_RWPTR_T fq_rwptr;
1559 - // int max_cnt = TOE_SW_FREEQ_DESC_NUM;//TOE_SW_FREEQ_DESC_NUM = 64
1560 - //unsigned long rx_old_bytes;
1562 + GMAC_RXDESC_T *curr_desc;
1563 + struct sk_buff *skb;
1564 + DMA_RWPTR_T rwptr;
1565 + unsigned int data32;
1566 + unsigned int pkt_size;
1567 + unsigned int desc_count;
1568 + unsigned int good_frame, chksum_status, rx_status;
1569 + int rx_pkts_num = 0;
1570 + int quota = min(dev->quota, *budget);
1571 + GMAC_INFO_T *tp = (GMAC_INFO_T *)dev->priv;
1572 + unsigned int status1;
1573 + unsigned int status4;
1574 struct net_device_stats *isPtr = (struct net_device_stats *)&tp->ifStatics;
1575 - //unsigned long long rx_time;
1578 BUG_ON(rx_poll_enabled == 0);
1582 - toe_gmac_fill_free_q();
1583 - status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_4_REG);
1584 - fq_rwptr.bits32 = readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
1585 - //printk("\n%s:: do_again toe_gmac_fill_free_q =======>status4=0x%x =====fq_rwptr =0x%8x======>JKJKJKJKJKJKJKJKJ \n", __func__,status4,fq_rwptr.bits32);
1586 - if (fq_rwptr.bits.wptr != fq_rwptr.bits.rptr)
1588 - //status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_4_REG);
1590 - //netif_rx_complete(dev);
1591 - gmac_write_reg(TOE_GLOBAL_BASE, GLOBAL_INTERRUPT_STATUS_4_REG, status4, 0x1);
1592 - fq_rwptr.bits32 = readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
1593 - rwptr.bits32 = readl(&tp->default_qhdr->word1);
1599 - rwptr.bits32 = readl(&tp->default_qhdr->word1);
1601 - if (rwptr.bits.rptr != tp->rx_rwptr.bits.rptr)
1603 - mac_stop_txdma((struct net_device *)tp->dev);
1604 - printk("Default Queue HW RD ptr (0x%x) != SW RD Ptr (0x%x)\n",
1605 - rwptr.bits32, tp->rx_rwptr.bits.rptr);
1610 toe = (TOE_INFO_T *)&toe_private_data;
1612 - fq_rwptr.bits32 = readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
1613 - //printk("%s:---Before-------------->Default Queue HW RW ptr (0x%8x), fq_rwptr =0x%8x \n",__func__,rwptr.bits32,fq_rwptr.bits32 );
1614 - //printk("%s:---Before while rx_pkts_num=%d------rx_finished_idx=0x%x------->Default_Q [rwptr.bits.rptr(SW)=0x%x, rwptr.bits.wptr(HW) = 0x%x ]---->Free_Q(SW_HW) = 0x%8x \n",__func__,rx_pkts_num,rx_finished_idx,rwptr.bits.rptr,rwptr.bits.wptr,fq_rwptr.bits32 );
1615 -// while ((--max_cnt) && (rwptr.bits.rptr != rwptr.bits.wptr) && (rx_pkts_num < quota))
1617 + status1 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_1_REG);
1618 + if (status1 & 1) {
1619 + writel(1, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_1_REG);
1622 + rwptr.bits32 = readl(&tp->default_qhdr->word1);
1623 while ((rwptr.bits.rptr != rwptr.bits.wptr) && (rx_pkts_num < quota))
1626 - curr_desc = (GMAC_RXDESC_T *)tp->default_desc_base + rwptr.bits.rptr;
1627 + curr_desc = (GMAC_RXDESC_T *)tp->default_desc_base + rwptr.bits.rptr;
1628 tp->default_q_cnt++;
1629 - tp->rx_curr_desc = (unsigned int)curr_desc;
1630 - rx_status = curr_desc->word0.bits.status;
1631 - chksum_status = curr_desc->word0.bits.chksum_status;
1632 - tp->rx_status_cnt[rx_status]++;
1633 - tp->rx_chksum_cnt[chksum_status]++;
1634 - pkt_size = curr_desc->word1.bits.byte_count; /*total byte count in a frame*/
1635 + tp->rx_curr_desc = (unsigned int)curr_desc;
1636 + rx_status = curr_desc->word0.bits.status;
1637 + chksum_status = curr_desc->word0.bits.chksum_status;
1638 + tp->rx_status_cnt[rx_status]++;
1639 + tp->rx_chksum_cnt[chksum_status]++;
1640 + pkt_size = curr_desc->word1.bits.byte_count; /*total byte count in a frame*/
1641 desc_count = curr_desc->word0.bits.desc_count; /* get descriptor count per frame */
1650 + rwptr1 = readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
1651 + free = (GET_WPTR(rwptr1) - GET_RPTR(rwptr1)) & 0xFF;
1653 + rwptr2 = readl(&tp->default_qhdr->word1);
1654 + busy = (GET_RPTR(rwptr2) - GET_WPTR(rwptr2)) & 0xFF;
1656 + if (GET_WPTR(rwptr1) == GET_RPTR(rwptr1)) {
1657 + printk("frame status: %d\n"
1658 + "SWFQ: wptr: %hu, rptr: %hu, free: %d\n"
1659 + "GMAC: wptr: %hu, rptr: %hu, free: %d\n",
1661 + GET_WPTR(rwptr1), GET_RPTR(rwptr1), free,
1662 + GET_WPTR(rwptr2), GET_RPTR(rwptr2), busy);
1667 + GMAC_RXDESC_T *fq_desc;
1669 + struct sk_buff *skb;
1670 + unsigned short idx;
1672 + skb = (struct sk_buff *)(REG32(__va(curr_desc->word2.buf_adr) - SKB_RESERVE_BYTES));
1673 + idx = (unsigned short)(REG32(__va(curr_desc->word2.buf_adr) - SKB_RESERVE_BYTES + 4));
1675 + BUG_ON(idx > TOE_SW_FREEQ_DESC_NUM);
1676 + BUG_ON(skb == NULL);
1677 + fq_desc = (GMAC_RXDESC_T*)toe->swfq_desc_base + idx;
1678 + fq_desc->word2.buf_adr = 0;
1681 if ((curr_desc->word0.bits32 & (GMAC_RXDESC_0_T_derr | GMAC_RXDESC_0_T_perr))
1682 - || (pkt_size < 60)
1683 + || (pkt_size < 60)
1684 || (chksum_status & 0x4)
1686 -// || rx_status || (rwptr.bits.rptr > rwptr.bits.wptr ))
1689 if (curr_desc->word0.bits32 & GMAC_RXDESC_0_T_derr)
1690 @@ -4388,7 +3842,6 @@
1692 if (rx_status == 4 || rx_status == 7)
1693 isPtr->rx_crc_errors++;
1694 -// printk("%s::Status=%d (GMAC-%d)!!!\n", __func__, rx_status, tp->port_id);
1696 #ifdef SL351x_GMAC_WORKAROUND
1697 else if (pkt_size < 60)
1698 @@ -4407,17 +3860,32 @@
1702 -// if (chksum_status)
1703 -// printk("%s::Checksum Status=%d (GMAC-%d)!!!\n", __func__, chksum_status, tp->port_id);
1704 skb = (struct sk_buff *)(REG32(__va(curr_desc->word2.buf_adr) - SKB_RESERVE_BYTES));
1705 - dev_kfree_skb_irq(skb);
1706 + dev_kfree_skb(skb);
1713 + rwptr1 = readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
1714 + free = (GET_WPTR(rwptr1) - GET_RPTR(rwptr1)) & 0xFF;
1716 + rwptr2 = readl(&tp->default_qhdr->word1);
1717 + busy = (GET_RPTR(rwptr2) - GET_WPTR(rwptr2)) & 0xFF;
1719 + printk("frame status: %d\n"
1720 + "SWFQ: wptr: %hu, rptr: %hu, free: %d\n"
1721 + "GMAC: wptr: %hu, rptr: %hu, free: %d\n",
1723 + GET_WPTR(rwptr1), GET_RPTR(rwptr1), free,
1724 + GET_WPTR(rwptr2), GET_RPTR(rwptr2), busy);
1729 if (curr_desc->word0.bits.drop)
1730 printk("%s::Drop (GMAC-%d)!!!\n", __func__, tp->port_id);
1731 -// if (chksum_status)
1732 -// printk("%s::Checksum Status=%d (GMAC-%d)!!!\n", __func__, chksum_status, tp->port_id);
1734 #ifdef SL351x_GMAC_WORKAROUND
1735 if (tp->short_frames_cnt >= GMAC_SHORT_FRAME_THRESHOLD)
1736 @@ -4432,225 +3900,118 @@
1738 tp->short_frames_cnt = 0;
1740 - /* get frame information from the first descriptor of the frame */
1741 + /* get frame information from the first descriptor of the frame */
1742 isPtr->rx_packets++;
1743 - //consistent_sync((void *)__va(curr_desc->word2.buf_adr), pkt_size, PCI_DMA_FROMDEVICE);
1744 + consistent_sync((void *)__va(curr_desc->word2.buf_adr), pkt_size, PCI_DMA_FROMDEVICE);
1745 skb = (struct sk_buff *)(REG32(__va(curr_desc->word2.buf_adr) - SKB_RESERVE_BYTES));
1746 tp->curr_rx_skb = skb;
1747 - // curr_desc->word2.buf_adr = 0;
1749 - //skb_reserve (skb, SKB_RESERVE_BYTES);
1750 skb_reserve (skb, RX_INSERT_BYTES); /* 2 byte align the IP fields. */
1751 - //if ((skb->tail+pkt_size) > skb->end )
1752 - //printk("%s::------------->Here skb->len=%d,pkt_size= %d,skb->head=0x%x,skb->tail= 0x%x, skb->end= 0x%x\n", __func__, skb->len, pkt_size,skb->head,skb->tail,skb->end);
1753 skb_put(skb, pkt_size);
1757 if (chksum_status == RX_CHKSUM_IP_UDP_TCP_OK)
1759 skb->ip_summed = CHECKSUM_UNNECESSARY;
1760 -#ifdef CONFIG_SL351x_NAT
1761 - if (nat_cfg.enabled && curr_desc->word3.bits.l3_offset && curr_desc->word3.bits.l4_offset)
1763 - struct iphdr *ip_hdr;
1764 - ip_hdr = (struct iphdr *)&(skb->data[curr_desc->word3.bits.l3_offset]);
1765 - sl351x_nat_input(skb,
1767 - (void *)curr_desc->word3.bits.l3_offset,
1768 - (void *)curr_desc->word3.bits.l4_offset);
1771 skb->protocol = eth_type_trans(skb,dev); /* set skb protocol */
1773 -#ifdef CONFIG_SL351x_RXTOE
1774 - if (storlink_ctl.rx_max_pktsize) {
1775 - struct iphdr *ip_hdr;
1776 - struct tcphdr *tcp_hdr;
1779 - ip_hdr = (struct iphdr*)&(skb->data[0]);
1780 - if ((skb->protocol == __constant_htons(ETH_P_IP)) &&
1781 - ((ip_hdr->protocol & 0x00ff) == IPPROTO_TCP)) {
1782 - ip_hdrlen = ip_hdr->ihl << 2;
1783 - tcp_hdr = (struct tcphdr*)&(skb->data[ip_hdrlen]);
1784 - if (tcp_hdr->syn) {
1785 - struct toe_conn* connection = init_toeq(ip_hdr->version,
1786 - ip_hdr, tcp_hdr, toe, &(skb->data[0]) - 14);
1787 - TCP_SKB_CB(skb)->connection = connection;
1788 - // hash_dump_entry(TCP_SKB_CB(skb)->connection->hash_entry_index);
1789 - // printk("%s::skb data %x, conn %x, mode %x\n",
1790 - // __func__, skb->data, connection, connection->mode);
1797 else if (chksum_status == RX_CHKSUM_IP_OK_ONLY)
1799 skb->ip_summed = CHECKSUM_UNNECESSARY;
1800 -#ifdef CONFIG_SL351x_NAT
1801 - if (nat_cfg.enabled && curr_desc->word3.bits.l3_offset && curr_desc->word3.bits.l4_offset)
1803 - struct iphdr *ip_hdr;
1804 - ip_hdr = (struct iphdr *)&(skb->data[curr_desc->word3.bits.l3_offset]);
1805 - if (ip_hdr->protocol == IPPROTO_UDP)
1807 - sl351x_nat_input(skb,
1809 - (void *)curr_desc->word3.bits.l3_offset,
1810 - (void *)curr_desc->word3.bits.l4_offset);
1812 - else if (ip_hdr->protocol == IPPROTO_GRE)
1814 - sl351x_nat_input(skb,
1816 - (void *)curr_desc->word3.bits.l3_offset,
1817 - (void *)curr_desc->word3.bits.l4_offset);
1821 skb->protocol = eth_type_trans(skb,dev); /* set skb protocol */
1825 skb->protocol = eth_type_trans(skb,dev); /* set skb protocol */
1827 - //netif_rx(skb); /* socket rx */
1829 netif_receive_skb(skb); //For NAPI
1830 dev->last_rx = jiffies;
1832 isPtr->rx_bytes += pkt_size;
1833 - //printk("------------------->isPtr->rx_bytes = %d\n",isPtr->rx_bytes);
1838 // advance one for Rx default Q 0/1
1839 rwptr.bits.rptr = RWPTR_ADVANCE_ONE(rwptr.bits.rptr, tp->default_desc_num);
1840 SET_RPTR(&tp->default_qhdr->word1, rwptr.bits.rptr);
1841 - tp->rx_rwptr.bits32 = rwptr.bits32;
1842 + tp->rx_rwptr.bits32 = rwptr.bits32;
1844 - //rwptr.bits32 = readl(&tp->default_qhdr->word1);//try read default_qhdr again
1845 - //fq_rwptr.bits32 = readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
1846 - //printk("%s:---Loop -------->rx_pkts_num=%d------------>Default Queue HW RW ptr = (0x%8x), fq_rwptr =0x%8x \n",__func__,rx_pkts_num,rwptr.bits32,fq_rwptr.bits32 );
1848 - if ((status4 & 0x1) == 0)
1850 - //if (!((dev->last_rx <= (rx_time + 2)) && (isPtr->rx_bytes > (rx_old_bytes + 1000000 ))))
1851 - if (tp->total_q_cnt_napi < 1024)
1853 - tp->total_q_cnt_napi++;
1854 - toe_gmac_fill_free_q(); //for iperf test disable
1857 - //printk("%s:---isPtr->rx_bytes =%u , rx_old_bytes =%u\n",__func__,isPtr->rx_bytes,rx_old_bytes );
1858 + // rwptr.bits32 = readl(&tp->default_qhdr->word1);
1860 + status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_4_REG);
1861 + if (status4 & 1) {
1862 + writel(status4 & SWFQ_EMPTY_INT_BIT, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_4_REG);
1865 + toe_gmac_fill_free_q(5);
1869 + /* avoid races with hard_start_xmit() */
1871 + spin_lock(&gmac_fq_lock);
1872 + toe_gmac_tx_complete(&toe_private_data.gmac[0], 0, dev, 1);
1873 + spin_unlock(&gmac_fq_lock);
1875 - //rwptr.bits.rptr = RWPTR_ADVANCE_ONE(rwptr.bits.rptr, tp->default_desc_num);
1876 - //printk("%s:---Loop -------->rx_pkts_num=%d----rwptr.bits.rptr=0x%x-------->Default Queue HW RW ptr = (0x%8x), fq_rwptr =0x%8x \n",__func__,rx_pkts_num,rwptr.bits.rptr,rwptr.bits32,fq_rwptr.bits32 );
1877 - //printk("%s:---Loop rx_pkts_num=%d------rwptr.bits.rptr=0x%x------->Default_Q [rwptr.bits.rptr(SW)=0x%x, rwptr.bits.wptr(HW) = 0x%x ]---->Free_Q(SW_HW) = 0x%8x \n",__func__,rx_pkts_num,rwptr.bits.rptr,rwptr.bits.rptr,rwptr.bits.wptr,fq_rwptr.bits32 );
1879 + status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_4_REG);
1882 + writel(status4 & SWFQ_EMPTY_INT_BIT, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_STATUS_4_REG);
1883 + status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_4_REG);
1884 + toe_gmac_fill_free_q(rx_pkts_num);
1886 - // advance one for Rx default Q 0/1
1888 - //rwptr.bits.rptr = RWPTR_ADVANCE_ONE(rwptr.bits.rptr, tp->default_desc_num);
1889 - //SET_RPTR(&tp->default_qhdr->word1, rwptr.bits.rptr);
1890 - //tp->rx_rwptr.bits32 = rwptr.bits32;
1891 - //rwptr.bits.rptr = rwptr.bits.rptr;
1892 + rwptr.bits32 = readl(&tp->default_qhdr->word1);
1893 + if (rwptr.bits.rptr != rwptr.bits.wptr &&
1894 + quota > rx_pkts_num)
1895 + goto rx_poll_retry;
1897 dev->quota -= rx_pkts_num;
1898 *budget -= rx_pkts_num;
1900 - status4 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_4_REG);//try read SWFQ empty again
1901 - //fq_rwptr.bits32 = readl(TOE_GLOBAL_BASE + GLOBAL_SWFQ_RWPTR_REG);
1902 - rwptr.bits32 = readl(&tp->default_qhdr->word1); //try read default_qhdr again
1903 - //printk("%s:---After rx_pkts_num=%d------rwptr.bits.rptr=0x%x------->Default_Q [rwptr.bits.rptr(SW)=0x%x, rwptr.bits.wptr(HW) = 0x%x ]---->Free_Q(SW_HW) = 0x%8x \n",__func__,rx_pkts_num,rwptr.bits.rptr,rwptr.bits.rptr,rwptr.bits.wptr,fq_rwptr.bits32 );
1904 -// if (rwptr.bits.rptr > rwptr.bits.wptr )
1906 - //toe_gmac_disable_rx(dev);
1907 - //wait_event_interruptible_timeout(freeq_wait,
1908 - //(rx_pkts_num == 100), CMTP_INTEROP_TIMEOUT);
1909 - //printk("\n%s:: return 22222=======> rx_pkts_num =%d, rwptr.bits.rptr=%d, rwptr.bits.wptr = %d ====---------=======>JKJKJKJKJK\n",
1910 - //__func__,rx_pkts_num,rwptr.bits.rptr,rwptr.bits.wptr);
1914 - if (rwptr.bits.rptr == rwptr.bits.wptr)
1915 + /* Receive queue is empty now */
1916 + if (quota >= rx_pkts_num)
1918 - // unsigned int data32;
1919 - //printk("%s:---[rwptr.bits.rptr == rwptr.bits.wptr] rx_pkts_num=%d------rwptr.bits.rptr=0x%x------->Default_Q [rwptr.bits.rptr(SW)=0x%x, rwptr.bits.wptr(HW) = 0x%x ]---->Free_Q(SW_HW) = 0x%8x \n",__func__,rx_pkts_num,rwptr.bits.rptr,rwptr.bits.rptr,rwptr.bits.wptr,fq_rwptr.bits32 );
1921 - /* Receive descriptor is empty now */
1923 - if (status4 & 0x1)
1926 - //writel(0x40400000, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_ENABLE_4_REG); //disable SWFQ empty interrupt
1927 - //toe_gmac_disable_interrupt(tp->irq);
1928 - tp->sw_fq_empty_cnt++;
1929 - //toe_gmac_disable_rx(dev);
1930 - writel(0x07960202, TOE_GMAC0_BASE+GMAC_CONFIG0);
1931 - writel(0x07960202, TOE_GMAC1_BASE+GMAC_CONFIG0);
1932 - //printk("\n%s :: freeq int-----tp->sw_fq_empty_cnt =%d---------====================----------------->\n",__func__,tp->sw_fq_empty_cnt);
1933 - //while ((fq_rwptr.bits.wptr >= (fq_rwptr.bits.rptr+256)) || (fq_rwptr.bits.wptr <= (fq_rwptr.bits.rptr+256)))
1935 - //gmac_write_reg(TOE_GLOBAL_BASE, GLOBAL_INTERRUPT_STATUS_4_REG, status4,
1937 - //printk("\n%s::fq_rwptr.wrptr = %x =======> ===========>here \n", __func__,fq_rwptr.bits32);
1938 - //if ((status4 & 0x1) == 0)
1942 + unsigned long flags;
1944 + netif_rx_complete(dev);
1945 + rx_poll_enabled = 0;
1947 + status1 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_STATUS_1_REG);
1948 + if (status1 & 1) {
1949 + if (netif_rx_reschedule(dev, rx_pkts_num)) {
1950 + rx_poll_enabled = 1;
1955 - //toe_gmac_fill_free_q();
1956 - netif_rx_complete(dev);
1958 - rx_poll_enabled = 0;
1960 - data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
1961 - if (tp->port_id == 0)
1962 - data32 |= DEFAULT_Q0_INT_BIT;
1964 - data32 |= DEFAULT_Q1_INT_BIT;
1965 - writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
1966 + spin_lock_irqsave(&gmac_fq_lock, flags);
1968 data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
1969 if (tp->port_id == 0)
1970 - data32 |= DEFAULT_Q0_INT_BIT;
1971 + data32 |= DEFAULT_Q0_INT_BIT;
1973 - data32 |= DEFAULT_Q1_INT_BIT;
1974 + data32 |= DEFAULT_Q1_INT_BIT;
1975 writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_4_REG);
1977 - data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_4_REG);
1978 + data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
1979 if (tp->port_id == 0)
1980 - data32 |= DEFAULT_Q0_INT_BIT;
1981 + data32 |= DEFAULT_Q0_INT_BIT;
1983 - data32 |= DEFAULT_Q1_INT_BIT;
1984 - writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_SELECT_4_REG);
1985 + data32 |= DEFAULT_Q1_INT_BIT;
1986 + writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
1988 - // enable GMAC-0 rx interrupt
1989 - // class-Q & TOE-Q are implemented in future
1990 - //data32 = readl(TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
1991 - //if (tp->port_id == 0)
1992 - //data32 |= DEFAULT_Q0_INT_BIT;
1994 - //data32 |= DEFAULT_Q1_INT_BIT;
1995 - //writel(data32, TOE_GLOBAL_BASE + GLOBAL_INTERRUPT_ENABLE_1_REG);
1996 - writel(0x3, TOE_GLOBAL_BASE+GLOBAL_INTERRUPT_ENABLE_1_REG);
1997 - //printk("\n%s::netif_rx_complete--> rx_pkts_num =%d, rwptr.bits.rptr=0x%x, rwptr.bits.wptr = 0x%x ====---------=======>JKJKJKJKJK\n",
1998 - //__func__,rx_pkts_num,rwptr.bits.rptr,rwptr.bits.wptr);
1999 - writel(0x07960200, TOE_GMAC0_BASE+GMAC_CONFIG0);
2000 - writel(0x07960200, TOE_GMAC1_BASE+GMAC_CONFIG0);
2005 - //printk("\n%s:: return 1 -->status4= 0x%x,rx_pkts_num =%d, rwptr.bits.rptr=0x%x, rwptr.bits.wptr = 0x%x ======> \n", __func__,status4,rx_pkts_num,rwptr.bits.rptr,rwptr.bits.wptr);
2008 + spin_unlock_irqrestore(&gmac_fq_lock, flags);
2014 + /* not done, will call ->poll() later. */
2020 @@ -5114,6 +4475,7 @@
2022 sl351x_nat_workaround_cnt++;
2023 sl351x_nat_workaround_handler();
2024 + printk("%():%d - workaround\n", __func__, __LINE__);
2028 @@ -5124,6 +4486,7 @@
2032 + printk("doing workaround ?!\n");
2034 gmac_initialized = 0;
2036 @@ -5290,6 +4653,7 @@
2037 GMAC_SWTXQ_T *swtxq;
2040 + printk("**** %s():%d\n", __func__, __LINE__);
2041 toe = (TOE_INFO_T *)&toe_private_data;
2042 tp = (GMAC_INFO_T *)&toe->gmac[0];
2043 for (i=0; i<GMAC_NUM; i++, tp++)
2044 @@ -5341,6 +4705,7 @@
2045 volatile GMAC_RXDESC_T *curr_desc;
2046 struct sk_buff *skb;
2048 + printk("**** %s():%d\n", __func__, __LINE__);
2049 toe = (TOE_INFO_T *)&toe_private_data;
2050 tp = (GMAC_INFO_T *)&toe->gmac[0];
2051 for (i=0; i<GMAC_NUM; i++, tp++)
2052 @@ -5374,6 +4739,7 @@
2053 volatile GMAC_RXDESC_T *curr_desc;
2054 struct sk_buff *skb;
2056 + printk("**** %s():%d\n", __func__, __LINE__);
2057 toe = (TOE_INFO_T *)&toe_private_data;
2058 classq = (CLASSQ_INFO_T *)&toe->classq[0];
2059 for (i=0; i<TOE_CLASS_QUEUE_NUM; i++, classq++)
2060 @@ -5410,6 +4776,7 @@
2061 GMAC_RXDESC_T *toe_curr_desc;
2062 struct sk_buff *skb;
2064 + printk("**** %s():%d\n", __func__, __LINE__);
2065 toe = (TOE_INFO_T *)&toe_private_data;
2066 toe_qhdr = (TOE_QHDR_T *)TOE_TOE_QUE_HDR_BASE;
2067 for (i=0; i<TOE_TOE_QUEUE_NUM; i++, toe_qhdr++)
2068 Index: linux-2.6.23.16/include/asm-arm/arch-sl2312/sl351x_gmac.h
2069 ===================================================================
2070 --- linux-2.6.23.16.orig/include/asm-arm/arch-sl2312/sl351x_gmac.h 2008-03-15 17:00:21.364762892 +0200
2071 +++ linux-2.6.23.16/include/asm-arm/arch-sl2312/sl351x_gmac.h 2008-03-15 17:01:08.367441241 +0200
2073 * The base address and descriptor number are configured at
2074 * DMA Queues Descriptor Ring Base Address/Size Register (offset 0x0004)
2075 **********************************************************************/
2076 -#define TOE_SW_FREEQ_DESC_POWER 10
2077 +#define TOE_SW_FREEQ_DESC_POWER 8
2078 #define TOE_SW_FREEQ_DESC_NUM (1<<TOE_SW_FREEQ_DESC_POWER)
2079 #define TOE_HW_FREEQ_DESC_POWER 8
2080 #define TOE_HW_FREEQ_DESC_NUM (1<<TOE_HW_FREEQ_DESC_POWER)
2081 @@ -123,12 +123,12 @@
2082 #define TOE_DEFAULT_Q0_DESC_NUM (1<<TOE_DEFAULT_Q0_DESC_POWER)
2083 #define TOE_DEFAULT_Q1_DESC_POWER 8
2084 #define TOE_DEFAULT_Q1_DESC_NUM (1<<TOE_DEFAULT_Q1_DESC_POWER)
2085 -#define TOE_TOE_DESC_POWER 8
2086 -#define TOE_TOE_DESC_NUM (1<<TOE_TOE_DESC_POWER)
2087 +#define TOE_TOE_DESC_POWER 8
2088 +#define TOE_TOE_DESC_NUM (1<<TOE_TOE_DESC_POWER)
2089 #define TOE_CLASS_DESC_POWER 8
2090 -#define TOE_CLASS_DESC_NUM (1<<TOE_CLASS_DESC_POWER)
2091 -#define TOE_INTR_DESC_POWER 8
2092 -#define TOE_INTR_DESC_NUM (1<<TOE_INTR_DESC_POWER)
2093 +#define TOE_CLASS_DESC_NUM (1<<TOE_CLASS_DESC_POWER)
2094 +#define TOE_INTR_DESC_POWER 8
2095 +#define TOE_INTR_DESC_NUM (1<<TOE_INTR_DESC_POWER)
2097 #define TOE_TOE_QUEUE_MAX 64
2098 #define TOE_TOE_QUEUE_NUM 64