1 Index: linux-2.6.20-rc3/drivers/net/via-velocity.c
2 ===================================================================
3 --- linux-2.6.20-rc3.orig/drivers/net/via-velocity.c 2007-01-02 10:30:25.892465963 +0000
4 +++ linux-2.6.20-rc3/drivers/net/via-velocity.c 2007-01-02 10:30:36.261113964 +0000
7 MODULE_DESCRIPTION("VIA Networking Velocity Family Gigabit Ethernet Adapter Driver");
9 +/* Valid values for vdebug (additive, this is a bitmask):
12 + * 0x02 => additional detail on tx (rx, too, if anyone implements same)
13 + * 0x04 => detail the initialization process
14 + * 0x08 => spot debug detail; to be used as developers see fit
16 +static int vdebug = 0;
18 +/* HAIL - these macros are for the normal 0x01-type tracing... */
20 + if (vdebug&1) printk(KERN_NOTICE "%s\n", (S));
22 + if (vdebug&1) printk(KERN_NOTICE "%s -> status=0x%x\n", (S), (T));
24 #define VELOCITY_PARAM(N,D) \
25 static int N[MAX_UNITS]=OPTION_DEFAULT;\
26 module_param_array(N, int, NULL, 0); \
27 MODULE_PARM_DESC(N, D);
29 +#define VELO_DEBUG_MIN 0
30 +#define VELO_DEBUG_MAX 255
31 +#define VELO_DEBUG_DEF 0
32 +VELOCITY_PARAM(velo_debug, "Debug level");
34 #define RX_DESC_MIN 64
35 #define RX_DESC_MAX 255
36 #define RX_DESC_DEF 64
40 else if (val < min || val > max) {
41 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (%d-%d)\n",
42 - devname, name, min, max);
43 + VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "via-velocity: the value of parameter %s is invalid, the valid range is (%d-%d)\n",
47 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: set value of parameter %s to %d\n",
48 - devname, name, val);
49 + VELOCITY_PRT(MSG_LEVEL_INFO, KERN_INFO "via-velocity: set value of parameter %s to %d\n",
56 *opt |= (def ? flag : 0);
57 else if (val < 0 || val > 1) {
58 - printk(KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (0-1)\n",
60 + printk(KERN_NOTICE "via-velocity: the value of parameter %s is invalid, the valid range is (0-1)\n",
62 *opt |= (def ? flag : 0);
64 - printk(KERN_INFO "%s: set parameter %s to %s\n",
65 - devname, name, val ? "TRUE" : "FALSE");
66 + printk(KERN_INFO "via-velocity: set parameter %s to %s\n",
67 + name, val ? "TRUE" : "FALSE");
68 *opt |= (val ? flag : 0);
72 static void __devinit velocity_get_options(struct velocity_opt *opts, int index, char *devname)
75 + velocity_set_int_opt(&opts->velo_debug, velo_debug[index], VELO_DEBUG_MIN, VELO_DEBUG_MAX, VELO_DEBUG_DEF, "velo_debug", devname);
76 velocity_set_int_opt(&opts->rx_thresh, rx_thresh[index], RX_THRESH_MIN, RX_THRESH_MAX, RX_THRESH_DEF, "rx_thresh", devname);
77 velocity_set_int_opt(&opts->DMA_length, DMA_length[index], DMA_LENGTH_MIN, DMA_LENGTH_MAX, DMA_LENGTH_DEF, "DMA_length", devname);
78 velocity_set_int_opt(&opts->numrx, RxDescriptors[index], RX_DESC_MIN, RX_DESC_MAX, RX_DESC_DEF, "RxDescriptors", devname);
80 velocity_set_int_opt((int *) &opts->wol_opts, wol_opts[index], WOL_OPT_MIN, WOL_OPT_MAX, WOL_OPT_DEF, "Wake On Lan options", devname);
81 velocity_set_int_opt((int *) &opts->int_works, int_works[index], INT_WORKS_MIN, INT_WORKS_MAX, INT_WORKS_DEF, "Interrupt service works", devname);
82 opts->numrx = (opts->numrx & ~3);
83 + vdebug = opts->velo_debug;
89 struct mac_regs __iomem * regs = vptr->mac_regs;
91 + HAIL("velocity_init_cam_filter");
93 /* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */
94 WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, ®s->MCFG);
95 WORD_REG_BITS_ON(MCFG_VIDFR, ®s->MCFG);
97 WORD_REG_BITS_ON(MCFG_RTGOPT, ®s->MCFG);
99 mac_set_cam(regs, 0, (u8 *) & (vptr->options.vid), VELOCITY_VLAN_ID_CAM);
100 - vptr->vCAMmask[0] |= 1;
101 - mac_set_cam_mask(regs, vptr->vCAMmask, VELOCITY_VLAN_ID_CAM);
104 mac_set_cam(regs, 0, (u8 *) &temp, VELOCITY_VLAN_ID_CAM);
106 - mac_set_cam_mask(regs, (u8 *) &temp, VELOCITY_VLAN_ID_CAM);
108 + vptr->vCAMmask[0] |= 1;
109 + mac_set_cam_mask(regs, vptr->vCAMmask, VELOCITY_VLAN_ID_CAM);
113 @@ -508,13 +530,15 @@
114 struct mac_regs __iomem * regs = vptr->mac_regs;
117 + HAIL("velocity_rx_reset");
118 vptr->rd_dirty = vptr->rd_filled = vptr->rd_curr = 0;
121 * Init state, all RD entries belong to the NIC
123 for (i = 0; i < vptr->options.numrx; ++i)
124 - vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC;
125 + /* vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC; BE */
126 + vptr->rd_ring[i].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
128 writew(vptr->options.numrx, ®s->RBRDU);
129 writel(vptr->rd_pool_dma, ®s->RDBaseLo);
130 @@ -537,12 +561,15 @@
131 struct mac_regs __iomem * regs = vptr->mac_regs;
134 + if (vdebug&5) printk(KERN_NOTICE "velocity_init_registers: entering\n");
139 case VELOCITY_INIT_RESET:
140 case VELOCITY_INIT_WOL:
142 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: RESET or WOL\n");
143 netif_stop_queue(vptr->dev);
146 @@ -570,12 +597,13 @@
148 case VELOCITY_INIT_COLD:
150 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: COLD or default\n");
154 velocity_soft_reset(vptr);
155 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: soft reset complete.\n");
158 mac_eeprom_reload(regs);
159 for (i = 0; i < 6; i++) {
160 writeb(vptr->dev->dev_addr[i], &(regs->PAR[i]));
161 @@ -593,11 +621,16 @@
163 BYTE_REG_BITS_SET(CFGB_OFSET, (CFGB_CRANDOM | CFGB_CAP | CFGB_MBA | CFGB_BAKOPT), ®s->CFGB);
165 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Initializing CAM filter\n");
169 + if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: about to init CAM filters\n");
170 + mdelay(5); /* MJW - ARM processors, kernel 2.6.19 - this fixes oopses and hangs */
171 velocity_init_cam_filter(vptr);
172 + if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: init CAM filters complete\n");
174 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Setting packet filter\n");
176 * Set packet filter: Receive directed and broadcast address
178 @@ -607,10 +640,12 @@
179 * Enable MII auto-polling
181 enable_mii_autopoll(regs);
182 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: enable_mii_autopoll complete.\n");
184 vptr->int_mask = INT_MASK_DEF;
186 - writel(cpu_to_le32(vptr->rd_pool_dma), ®s->RDBaseLo);
187 + /* writel(cpu_to_le32(vptr->rd_pool_dma), ®s->RDBaseLo); BE */
188 + writel((vptr->rd_pool_dma), ®s->RDBaseLo); /* BE */
189 writew(vptr->options.numrx - 1, ®s->RDCSize);
190 mac_rx_queue_run(regs);
191 mac_rx_queue_wake(regs);
192 @@ -618,10 +653,13 @@
193 writew(vptr->options.numtx - 1, ®s->TDCSize);
195 for (i = 0; i < vptr->num_txq; i++) {
196 - writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i]));
197 + /* writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); BE */
198 + writel((vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); /* BE */
199 mac_tx_queue_run(regs, i);
202 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: DMA settings complete.\n");
204 init_flow_control_register(vptr);
206 writel(CR0_STOP, ®s->CR0Clr);
209 enable_flow_control_ability(vptr);
210 mac_hw_mibs_init(regs);
211 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Set interrupt mask\n");
212 mac_write_int_mask(vptr->int_mask, regs);
214 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: complete.\n");
219 struct mac_regs __iomem * regs = vptr->mac_regs;
222 + HAIL("velocity_soft_reset");
223 writel(CR0_SFRST, ®s->CR0Set);
225 for (i = 0; i < W_MAX_TIMEOUT; i++) {
227 VELOCITY_FULL_DRV_NAM, VELOCITY_VERSION);
228 printk(KERN_INFO "Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n");
229 printk(KERN_INFO "Copyright (c) 2004 Red Hat Inc.\n");
230 + printk(KERN_INFO "BE support, misc. fixes MJW 01Jan2007 - may be unstable\n");
238 + HAIL("velocity_init_rings");
240 * Allocate all RD/TD rings a single pool
243 static void velocity_free_rings(struct velocity_info *vptr)
246 + HAIL("velocity_free_rings");
248 size = vptr->options.numrx * sizeof(struct rx_desc) +
249 vptr->options.numtx * sizeof(struct tx_desc) * vptr->num_txq;
250 @@ -1013,6 +1057,7 @@
251 struct mac_regs __iomem *regs = vptr->mac_regs;
252 int avail, dirty, unusable;
254 + HAIL("velocity_give_many_rx_descs");
256 * RD number must be equal to 4X per hardware spec
257 * (programming guide rev 1.20, p.13)
258 @@ -1026,7 +1071,8 @@
259 dirty = vptr->rd_dirty - unusable;
260 for (avail = vptr->rd_filled & 0xfffc; avail; avail--) {
261 dirty = (dirty > 0) ? dirty - 1 : vptr->options.numrx - 1;
262 - vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC;
263 + /* vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC; BE */
264 + vptr->rd_ring[dirty].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
267 writew(vptr->rd_filled & 0xfffc, ®s->RBRDU);
268 @@ -1036,12 +1082,14 @@
269 static int velocity_rx_refill(struct velocity_info *vptr)
271 int dirty = vptr->rd_dirty, done = 0, ret = 0;
272 + HAIL("velocity_rx_refill");
275 struct rx_desc *rd = vptr->rd_ring + dirty;
277 /* Fine for an all zero Rx desc at init time as well */
278 - if (rd->rdesc0.owner == OWNED_BY_NIC)
279 + /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */
280 + if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
283 if (!vptr->rd_info[dirty].skb) {
284 @@ -1076,6 +1124,7 @@
285 unsigned int rsize = sizeof(struct velocity_rd_info) *
288 + HAIL("velocity_init_rd_ring");
289 vptr->rd_info = kmalloc(rsize, GFP_KERNEL);
290 if(vptr->rd_info == NULL)
292 @@ -1105,6 +1154,7 @@
296 + HAIL("velocity_free_rd_ring");
297 if (vptr->rd_info == NULL)
300 @@ -1146,6 +1196,7 @@
301 unsigned int tsize = sizeof(struct velocity_td_info) *
304 + HAIL("velocity_init_td_ring");
305 /* Init the TD ring entries */
306 for (j = 0; j < vptr->num_txq; j++) {
307 curr = vptr->td_pool_dma[j];
308 @@ -1182,6 +1233,7 @@
309 struct velocity_td_info * td_info = &(vptr->td_infos[q][n]);
312 + HAIL("velocity_free_td_ring_entry");
316 @@ -1211,6 +1263,7 @@
320 + HAIL("velocity_free_td_ring");
321 for (j = 0; j < vptr->num_txq; j++) {
322 if (vptr->td_infos[j] == NULL)
324 @@ -1238,34 +1291,42 @@
325 struct net_device_stats *stats = &vptr->stats;
326 int rd_curr = vptr->rd_curr;
330 + HAILS("velocity_rx_srv", status);
332 struct rx_desc *rd = vptr->rd_ring + rd_curr;
334 if (!vptr->rd_info[rd_curr].skb)
337 - if (rd->rdesc0.owner == OWNED_BY_NIC)
338 + /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */
339 + if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
344 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
346 * Don't drop CE or RL error frame although RXOK is off
348 - if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) {
349 + /* if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) { BE */
350 + if ((wRSR & RSR_RXOK) || (!(wRSR & RSR_RXOK) && (wRSR & (RSR_CE | RSR_RL)))) { /* BE */
351 if (velocity_receive_frame(vptr, rd_curr) < 0)
354 - if (rd->rdesc0.RSR & RSR_CRC)
355 + /* if (rd->rdesc0.RSR & RSR_CRC) BE */
356 + if (wRSR & RSR_CRC) /* BE */
357 stats->rx_crc_errors++;
358 - if (rd->rdesc0.RSR & RSR_FAE)
359 + /* if (rd->rdesc0.RSR & RSR_FAE) BE */
360 + if (wRSR & RSR_FAE) /* BE */
361 stats->rx_frame_errors++;
367 + /* rd->inten = 1; BE */
368 + rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */
370 vptr->dev->last_rx = jiffies;
372 @@ -1296,13 +1357,21 @@
374 static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb)
377 + HAIL("velocity_rx_csum");
378 skb->ip_summed = CHECKSUM_NONE;
380 - if (rd->rdesc1.CSM & CSM_IPKT) {
381 - if (rd->rdesc1.CSM & CSM_IPOK) {
382 - if ((rd->rdesc1.CSM & CSM_TCPKT) ||
383 - (rd->rdesc1.CSM & CSM_UDPKT)) {
384 - if (!(rd->rdesc1.CSM & CSM_TUPOK)) {
385 +// if (rd->rdesc1.CSM & CSM_IPKT) {
386 +// if (rd->rdesc1.CSM & CSM_IPOK) {
387 +// if ((rd->rdesc1.CSM & CSM_TCPKT) ||
388 +// (rd->rdesc1.CSM & CSM_UDPKT)) {
389 +// if (!(rd->rdesc1.CSM & CSM_TUPOK)) {
390 + bCSM = (u8)(cpu_to_le32(rd->rdesc1) >> 16); /* BE */
391 + if (bCSM & CSM_IPKT) {
392 + if (bCSM & CSM_IPOK) {
393 + if ((bCSM & CSM_TCPKT) ||
394 + (bCSM & CSM_UDPKT)) {
395 + if (!(bCSM & CSM_TUPOK)) { /* BE */
399 @@ -1328,9 +1397,11 @@
403 + HAIL("velocity_rx_copy");
404 if (pkt_size < rx_copybreak) {
405 struct sk_buff *new_skb;
407 + HAIL("velocity_rx_copy (working...)");
408 new_skb = dev_alloc_skb(pkt_size + 2);
410 new_skb->dev = vptr->dev;
411 @@ -1360,10 +1431,12 @@
412 static inline void velocity_iph_realign(struct velocity_info *vptr,
413 struct sk_buff *skb, int pkt_size)
415 + HAIL("velocity_iph_realign");
416 /* FIXME - memmove ? */
417 if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
420 + HAIL("velocity_iph_realign (working...)");
421 for (i = pkt_size; i >= 0; i--)
422 *(skb->data + i + 2) = *(skb->data + i);
424 @@ -1382,19 +1455,27 @@
425 static int velocity_receive_frame(struct velocity_info *vptr, int idx)
427 void (*pci_action)(struct pci_dev *, dma_addr_t, size_t, int);
428 + u16 pkt_len; /* BE */
430 + struct sk_buff *skb;
431 struct net_device_stats *stats = &vptr->stats;
432 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
433 struct rx_desc *rd = &(vptr->rd_ring[idx]);
434 - int pkt_len = rd->rdesc0.len;
435 - struct sk_buff *skb;
436 + /* int pkt_len = rd->rdesc0.len BE */;
438 + pkt_len = ((cpu_to_le32(rd->rdesc0) >> 16) & 0x00003FFFUL); /* BE */
439 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
441 - if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) {
442 + HAIL("velocity_receive_frame");
443 + /* if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) { BE */
444 + if (wRSR & (RSR_STP | RSR_EDP)) { /* BE */
445 VELOCITY_PRT(MSG_LEVEL_VERBOSE, KERN_ERR " %s : the received frame span multple RDs.\n", vptr->dev->name);
446 stats->rx_length_errors++;
450 - if (rd->rdesc0.RSR & RSR_MAR)
451 + /* if (rd->rdesc0.RSR & RSR_MAR) BE */
452 + if (wRSR & RSR_MAR) /* BE */
453 vptr->stats.multicast++;
456 @@ -1408,7 +1489,8 @@
459 if (vptr->flags & VELOCITY_FLAGS_VAL_PKT_LEN) {
460 - if (rd->rdesc0.RSR & RSR_RL) {
461 + /* if (rd->rdesc0.RSR & RSR_RL) { BE */
462 + if (wRSR & RSR_RL) { /* BE */
463 stats->rx_length_errors++;
466 @@ -1452,6 +1534,7 @@
467 struct rx_desc *rd = &(vptr->rd_ring[idx]);
468 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
470 + HAIL("velocity_alloc_rx_buf");
471 rd_info->skb = dev_alloc_skb(vptr->rx_buf_sz + 64);
472 if (rd_info->skb == NULL)
474 @@ -1469,10 +1552,14 @@
477 *((u32 *) & (rd->rdesc0)) = 0;
478 - rd->len = cpu_to_le32(vptr->rx_buf_sz);
480 + /* rd->len = cpu_to_le32(vptr->rx_buf_sz); BE */
481 + /* rd->inten = 1; BE */
482 rd->pa_low = cpu_to_le32(rd_info->skb_dma);
484 + /* rd->pa_high = 0; BE */
485 + rd->ltwo &= cpu_to_le32(0xC000FFFFUL); /* BE */
486 + rd->ltwo |= cpu_to_le32((vptr->rx_buf_sz << 16)); /* BE */
487 + rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */
488 + rd->ltwo &= cpu_to_le32(0xFFFF0000UL); /* BE */
492 @@ -1493,9 +1580,11 @@
497 struct velocity_td_info *tdinfo;
498 struct net_device_stats *stats = &vptr->stats;
500 + HAILS("velocity_tx_srv", status);
501 for (qnum = 0; qnum < vptr->num_txq; qnum++) {
502 for (idx = vptr->td_tail[qnum]; vptr->td_used[qnum] > 0;
503 idx = (idx + 1) % vptr->options.numtx) {
504 @@ -1506,22 +1595,29 @@
505 td = &(vptr->td_rings[qnum][idx]);
506 tdinfo = &(vptr->td_infos[qnum][idx]);
508 - if (td->tdesc0.owner == OWNED_BY_NIC)
509 + /* if (td->tdesc0.owner == OWNED_BY_NIC) BE */
510 + if (td->tdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
516 - if (td->tdesc0.TSR & TSR0_TERR) {
517 + wTSR = (u16)cpu_to_le32(td->tdesc0);
518 + /* if (td->tdesc0.TSR & TSR0_TERR) { BE */
519 + if (wTSR & TSR0_TERR) { /* BE */
522 - if (td->tdesc0.TSR & TSR0_CDH)
523 + /* if (td->tdesc0.TSR & TSR0_CDH) BE */
524 + if (wTSR & TSR0_CDH) /* BE */
525 stats->tx_heartbeat_errors++;
526 - if (td->tdesc0.TSR & TSR0_CRS)
527 + /* if (td->tdesc0.TSR & TSR0_CRS) BE */
528 + if (wTSR & TSR0_CRS) /* BE */
529 stats->tx_carrier_errors++;
530 - if (td->tdesc0.TSR & TSR0_ABT)
531 + /* if (td->tdesc0.TSR & TSR0_ABT) BE */
532 + if (wTSR & TSR0_ABT) /* BE */
533 stats->tx_aborted_errors++;
534 - if (td->tdesc0.TSR & TSR0_OWC)
535 + /* if (td->tdesc0.TSR & TSR0_OWC) BE */
536 + if (wTSR & TSR0_OWC) /* BE */
537 stats->tx_window_errors++;
540 @@ -1610,6 +1706,7 @@
542 static void velocity_error(struct velocity_info *vptr, int status)
544 + HAILS("velocity_error", status);
546 if (status & ISR_TXSTLI) {
547 struct mac_regs __iomem * regs = vptr->mac_regs;
548 @@ -1699,6 +1796,7 @@
549 struct sk_buff *skb = tdinfo->skb;
552 + HAIL("velocity_free_tx_buf");
554 * Don't unmap the pre-allocated tx_bufs
556 @@ -1902,6 +2000,7 @@
557 struct velocity_td_info *tdinfo;
560 + u32 lbufsz; /* BE */
562 int pktlen = skb->len;
564 @@ -1918,9 +2017,18 @@
565 td_ptr = &(vptr->td_rings[qnum][index]);
566 tdinfo = &(vptr->td_infos[qnum][index]);
568 - td_ptr->tdesc1.TCPLS = TCPLS_NORMAL;
569 - td_ptr->tdesc1.TCR = TCR0_TIC;
570 - td_ptr->td_buf[0].queue = 0;
571 + td_ptr->tdesc0 = 0x00000000UL; /* BE */
572 + td_ptr->tdesc1 = 0x00000000UL; /* BE */
574 + /* td_ptr->tdesc1.TCPLS = TCPLS_NORMAL; BE */
575 + td_ptr->tdesc1 &= cpu_to_le32(0xfcffffffUL); /* BE */
576 + td_ptr->tdesc1 |= cpu_to_le32(((u32)TCPLS_NORMAL) << 24); /* BE */
578 + /* td_ptr->tdesc1.TCR = TCR0_TIC; BE */
579 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TIC); /* BE */
581 + /* td_ptr->td_buf[0].queue = 0; BE */
582 + td_ptr->td_buf[0].ltwo &= cpu_to_le32(~BE_QUEUE_ENABLE); /* BE */
586 @@ -1932,20 +2040,35 @@
587 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len);
589 tdinfo->skb_dma[0] = tdinfo->buf_dma;
590 - td_ptr->tdesc0.pktsize = pktlen;
591 + /* td_ptr->tdesc0.pktsize = pktlen; */
592 + td_ptr->tdesc0 &= cpu_to_le32(0xc000ffffUL); /* BE */
593 + lbufsz = pktlen; /* Assign, and make sure it's unsigned 32 bits - BE */
594 + lbufsz = lbufsz << 16; /* BE - shift over */
595 + td_ptr->tdesc0 |= cpu_to_le32(lbufsz); /* BE */
596 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
597 - td_ptr->td_buf[0].pa_high = 0;
598 - td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;
599 + /* td_ptr->td_buf[0].pa_high = 0; */
600 + /* td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; */
601 + td_ptr->td_buf[0].ltwo = cpu_to_le32(lbufsz); /* BE */
602 tdinfo->nskb_dma = 1;
603 - td_ptr->tdesc1.CMDZ = 2;
604 + /* td_ptr->tdesc1.CMDZ = 2; */
605 + td_ptr->tdesc1 &= cpu_to_le32(0x0fffffffUL); /* BE */
606 + td_ptr->tdesc1 |= cpu_to_le32(((u32)0x2) << 28); /* BE */
608 #ifdef VELOCITY_ZERO_COPY_SUPPORT
610 + * BE - NOTE on the VELOCITY_ZERO_COPY_SUPPORT:
611 + * This block of code has NOT been patched up for BE support, as
612 + * it is certainly broken -- if it compiles at all. Since the BE
613 + * fixes depend on the broken code, attempts to convert to BE support
614 + * would almost certainly confuse more than help.
616 if (skb_shinfo(skb)->nr_frags > 0) {
617 int nfrags = skb_shinfo(skb)->nr_frags;
620 memcpy(tdinfo->buf, skb->data, skb->len);
621 tdinfo->skb_dma[0] = tdinfo->buf_dma;
622 + /* BE: Er, exactly what value are we assigning in this next line? */
623 td_ptr->tdesc0.pktsize =
624 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
625 td_ptr->td_buf[0].pa_high = 0;
626 @@ -1962,6 +2085,7 @@
627 /* FIXME: support 48bit DMA later */
628 td_ptr->td_buf[i].pa_low = cpu_to_le32(tdinfo->skb_dma);
629 td_ptr->td_buf[i].pa_high = 0;
630 + /* BE: This next line can't be right: */
631 td_ptr->td_buf[i].bufsize = skb->len->skb->data_len;
633 for (i = 0; i < nfrags; i++) {
634 @@ -1979,7 +2103,7 @@
639 +#endif /* (broken) VELOCITY_ZERO_COPY_SUPPORT */
642 * Map the linear network buffer into PCI space and
643 @@ -1987,19 +2111,30 @@
646 tdinfo->skb_dma[0] = pci_map_single(vptr->pdev, skb->data, pktlen, PCI_DMA_TODEVICE);
647 - td_ptr->tdesc0.pktsize = pktlen;
648 + /* td_ptr->tdesc0.pktsize = pktlen; BE */
649 + td_ptr->tdesc0 &= cpu_to_le32(0xc000ffffUL); /* BE */
650 + lbufsz = pktlen; /* Assign, and make sure it's unsigned 32 bits - BE */
651 + lbufsz = lbufsz << 16; /* BE */
652 + td_ptr->tdesc0 |= cpu_to_le32(lbufsz); /* BE */
653 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
654 - td_ptr->td_buf[0].pa_high = 0;
655 - td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;
656 + /* td_ptr->td_buf[0].pa_high = 0; BE */
657 + /* td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; BE */
658 + td_ptr->td_buf[0].ltwo = cpu_to_le32(lbufsz); /* BE */
660 tdinfo->nskb_dma = 1;
661 - td_ptr->tdesc1.CMDZ = 2;
662 + /* td_ptr->tdesc1.CMDZ = 2; BE */
663 + td_ptr->tdesc1 &= cpu_to_le32(0x0fffffffUL); /* BE */
664 + td_ptr->tdesc1 |= cpu_to_le32(((u32)0x2) << 28);/* BE */
667 if (vptr->flags & VELOCITY_FLAGS_TAGGING) {
668 - td_ptr->tdesc1.pqinf.VID = (vptr->options.vid & 0xfff);
669 - td_ptr->tdesc1.pqinf.priority = 0;
670 - td_ptr->tdesc1.pqinf.CFI = 0;
671 - td_ptr->tdesc1.TCR |= TCR0_VETAG;
672 + /* td_ptr->tdesc1.pqinf.priority = 0; BE */
673 + /* td_ptr->tdesc1.pqinf.CFI = 0; BE */
674 + td_ptr->tdesc1 &= cpu_to_le32(0xFFFF0000UL); /* BE */
675 + /* td_ptr->tdesc1.pqinf.VID = (vptr->options.vid & 0xfff); BE */
676 + td_ptr->tdesc1 |= cpu_to_le32((vptr->options.vid & 0xfff)); /* BE */
677 + /* td_ptr->tdesc1.TCR |= TCR0_VETAG; BE */
678 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_VETAG); /* BE */
682 @@ -2009,26 +2144,34 @@
683 && (skb->ip_summed == CHECKSUM_PARTIAL)) {
684 struct iphdr *ip = skb->nh.iph;
685 if (ip->protocol == IPPROTO_TCP)
686 - td_ptr->tdesc1.TCR |= TCR0_TCPCK;
687 + /* td_ptr->tdesc1.TCR |= TCR0_TCPCK; BE */
688 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TCPCK); /* BE */
689 else if (ip->protocol == IPPROTO_UDP)
690 - td_ptr->tdesc1.TCR |= (TCR0_UDPCK);
691 - td_ptr->tdesc1.TCR |= TCR0_IPCK;
693 + /* td_ptr->tdesc1.TCR |= (TCR0_UDPCK); BE */
694 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_UDPCK); /* BE */
695 + /* td_ptr->tdesc1.TCR |= TCR0_IPCK; BE */
696 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_IPCK); /* BE */
700 int prev = index - 1;
703 prev = vptr->options.numtx - 1;
704 - td_ptr->tdesc0.owner = OWNED_BY_NIC;
705 + /* td_ptr->tdesc0.owner = OWNED_BY_NIC; BE */
706 + td_ptr->tdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
707 vptr->td_used[qnum]++;
708 vptr->td_curr[qnum] = (index + 1) % vptr->options.numtx;
710 if (AVAIL_TD(vptr, qnum) < 1)
711 netif_stop_queue(dev);
713 - td_ptr = &(vptr->td_rings[qnum][prev]);
714 - td_ptr->td_buf[0].queue = 1;
715 + td_ptr = &(vptr->td_rings[qnum][prev]);
716 + /* td_ptr->td_buf[0].queue = 1; BE */
717 + td_ptr->td_buf[0].ltwo |= cpu_to_le32(BE_QUEUE_ENABLE); /* BE */
718 + if (vdebug&2) printk(KERN_NOTICE "velocity_xmit: (%s) len=%d idx=%d tdesc0=0x%x tdesc1=0x%x ltwo=0x%x\n",
719 + (pktlen<ETH_ZLEN) ? "short" : "normal", pktlen, index,
720 + td_ptr->tdesc0, td_ptr->tdesc1, td_ptr->td_buf[0].ltwo);
721 mac_tx_queue_wake(vptr->mac_regs, qnum);
723 dev->trans_start = jiffies;
724 @@ -2054,7 +2197,7 @@
729 + HAIL("velocity_intr");
730 spin_lock(&vptr->lock);
731 isr_status = mac_read_isr(vptr->mac_regs);
733 @@ -2073,7 +2216,10 @@
735 while (isr_status != 0) {
736 mac_write_isr(vptr->mac_regs, isr_status);
737 - if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI)))
738 + HAILS("velocity_intr",isr_status);
739 + /* MJW - velocity_error is ALWAYS called; need to mask off some other flags */
740 + /* if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI))) */
741 + if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI | ISR_PTX0I | ISR_ISR0)))
742 velocity_error(vptr, isr_status);
743 if (isr_status & (ISR_PRXI | ISR_PPRXI))
744 max_count += velocity_rx_srv(vptr, isr_status);
745 @@ -2111,6 +2257,7 @@
747 struct dev_mc_list *mclist;
749 + HAIL("velocity_set_multi");
750 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
751 writel(0xffffffff, ®s->MARCAM[0]);
752 writel(0xffffffff, ®s->MARCAM[4]);
753 @@ -2154,6 +2301,7 @@
755 struct velocity_info *vptr = netdev_priv(dev);
757 + HAIL("net_device_stats");
758 /* If the hardware is down, don't touch MII */
759 if(!netif_running(dev))
761 @@ -2198,6 +2346,7 @@
762 struct velocity_info *vptr = netdev_priv(dev);
765 + HAIL("velocity_ioctl");
766 /* If we are asked for information and the device is power
767 saving then we need to bring the device back up to talk to it */
769 @@ -2416,6 +2565,7 @@
773 + HAIL("velocity_mii_read");
775 * Disable MIICR_MAUTO, so that mii addr can be set normally
777 @@ -2452,6 +2602,7 @@
781 + HAIL("velocity_mii_write");
783 * Disable MIICR_MAUTO, so that mii addr can be set normally
785 Index: linux-2.6.20-rc3/drivers/net/via-velocity.h
786 ===================================================================
787 --- linux-2.6.20-rc3.orig/drivers/net/via-velocity.h 2006-11-29 21:57:37.000000000 +0000
788 +++ linux-2.6.20-rc3/drivers/net/via-velocity.h 2007-01-02 10:30:36.265114211 +0000
789 @@ -196,64 +196,70 @@
794 - u16 RSR; /* Receive status */
795 - u16 len:14; /* Received packet length */
797 - u16 owner:1; /* Who owns this buffer ? */
806 +// u16 RSR; /* Receive status */
807 +// u16 len:14; /* Received packet length */
809 +// u16 owner:1; /* Who owns this buffer ? */
819 - struct rdesc0 rdesc0;
820 - struct rdesc1 rdesc1;
821 +// struct rdesc0 rdesc0;
822 +// struct rdesc1 rdesc1;
825 u32 pa_low; /* Low 32 bit PCI address */
826 - u16 pa_high; /* Next 16 bit PCI address (48 total) */
827 - u16 len:15; /* Frame size */
828 - u16 inten:1; /* Enable interrupt */
829 +// u16 pa_high; /* Next 16 bit PCI address (48 total) */
830 +// u16 len:15; /* Frame size */
831 +// u16 inten:1; /* Enable interrupt */
833 } __attribute__ ((__packed__));
836 * Transmit descriptor
840 - u16 TSR; /* Transmit status register */
841 - u16 pktsize:14; /* Size of frame */
843 - u16 owner:1; /* Who owns the buffer */
846 -struct pqinf { /* Priority queue info */
850 -} __attribute__ ((__packed__));
853 - struct pqinf pqinf;
858 -} __attribute__ ((__packed__));
860 +// u16 TSR; /* Transmit status register */
861 +// u16 pktsize:14; /* Size of frame */
863 +// u16 owner:1; /* Who owns the buffer */
866 +//struct pqinf { /* Priority queue info */
870 +//} __attribute__ ((__packed__));
873 +// struct pqinf pqinf;
878 +//} __attribute__ ((__packed__));
891 } __attribute__ ((__packed__));
894 - struct tdesc0 tdesc0;
895 - struct tdesc1 tdesc1;
896 +// struct tdesc0 tdesc0;
897 +// struct tdesc1 tdesc1;
900 struct td_buf td_buf[7];
907 +/* Constants added for the BE fixes */
908 +#define BE_OWNED_BY_NIC 0x80000000UL
909 +#define BE_INT_ENABLE 0x80000000UL
910 +#define BE_QUEUE_ENABLE 0x80000000UL
911 +#define BE_TCR_TIC 0x00800000UL
912 +#define BE_TCR_VETAG 0x00200000UL
913 +#define BE_TCR_TCPCK 0x00040000UL
914 +#define BE_TCR_UDPCK 0x00080000UL
915 +#define BE_TCR_IPCK 0x00100000UL
919 * MAC registers and macros.
920 @@ -1698,6 +1714,7 @@
923 struct velocity_opt {
924 + int velo_debug; /* debug flag */
925 int numrx; /* Number of RX descriptors */
926 int numtx; /* Number of TX descriptors */
927 enum speed_opt spd_dpx; /* Media link mode */