1 diff -Naur linux-2.6.24.orig/drivers/net/via-velocity.c linux-2.6.24/drivers/net/via-velocity.c
2 --- linux-2.6.24.orig/drivers/net/via-velocity.c 2008-01-31 23:11:26.000000000 -0600
3 +++ linux-2.6.24/drivers/net/via-velocity.c 2008-02-01 01:12:15.000000000 -0600
6 MODULE_DESCRIPTION("VIA Networking Velocity Family Gigabit Ethernet Adapter Driver");
8 +/* Valid values for vdebug (additive, this is a bitmask):
11 + * 0x02 => additional detail on tx (rx, too, if anyone implements same)
12 + * 0x04 => detail the initialization process
13 + * 0x08 => spot debug detail; to be used as developers see fit
15 +static int vdebug = 0;
17 +/* HAIL - these macros are for the normal 0x01-type tracing... */
19 + if (vdebug&1) printk(KERN_NOTICE "%s\n", (S));
21 + if (vdebug&1) printk(KERN_NOTICE "%s -> status=0x%x\n", (S), (T));
23 #define VELOCITY_PARAM(N,D) \
24 static int N[MAX_UNITS]=OPTION_DEFAULT;\
25 module_param_array(N, int, NULL, 0); \
26 MODULE_PARM_DESC(N, D);
28 +#define VELO_DEBUG_MIN 0
29 +#define VELO_DEBUG_MAX 255
30 +#define VELO_DEBUG_DEF 0
31 +VELOCITY_PARAM(velo_debug, "Debug level");
33 #define RX_DESC_MIN 64
34 #define RX_DESC_MAX 255
35 #define RX_DESC_DEF 64
38 *opt |= (def ? flag : 0);
39 else if (val < 0 || val > 1) {
40 - printk(KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (0-1)\n",
42 + printk(KERN_NOTICE "via-velocity: the value of parameter %s is invalid, the valid range is (0-1)\n",
44 *opt |= (def ? flag : 0);
46 - printk(KERN_INFO "%s: set parameter %s to %s\n",
47 - devname, name, val ? "TRUE" : "FALSE");
48 + printk(KERN_INFO "via-velocity: set parameter %s to %s\n",
49 + name, val ? "TRUE" : "FALSE");
50 *opt |= (val ? flag : 0);
54 static void __devinit velocity_get_options(struct velocity_opt *opts, int index, char *devname)
57 + velocity_set_int_opt(&opts->velo_debug, velo_debug[index], VELO_DEBUG_MIN, VELO_DEBUG_MAX, VELO_DEBUG_DEF, "velo_debug", devname);
58 velocity_set_int_opt(&opts->rx_thresh, rx_thresh[index], RX_THRESH_MIN, RX_THRESH_MAX, RX_THRESH_DEF, "rx_thresh", devname);
59 velocity_set_int_opt(&opts->DMA_length, DMA_length[index], DMA_LENGTH_MIN, DMA_LENGTH_MAX, DMA_LENGTH_DEF, "DMA_length", devname);
60 velocity_set_int_opt(&opts->numrx, RxDescriptors[index], RX_DESC_MIN, RX_DESC_MAX, RX_DESC_DEF, "RxDescriptors", devname);
62 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);
63 velocity_set_int_opt((int *) &opts->int_works, int_works[index], INT_WORKS_MIN, INT_WORKS_MAX, INT_WORKS_DEF, "Interrupt service works", devname);
64 opts->numrx = (opts->numrx & ~3);
65 + vdebug = opts->velo_debug;
70 struct mac_regs __iomem * regs = vptr->mac_regs;
73 + HAIL("velocity_init_cam_filter");
75 /* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */
76 WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, ®s->MCFG);
77 WORD_REG_BITS_ON(MCFG_VIDFR, ®s->MCFG);
81 mac_set_vlan_cam(regs, 0, (u8 *) &temp);
83 - mac_set_vlan_cam_mask(regs, (u8 *) &temp);
85 + /* mac_set_vlan_cam_mask(regs, (u8 *) &temp); BE */
86 + vptr->vCAMmask[0] |= 1; /* BE */
87 + mac_set_vlan_cam_mask(regs, vptr->vCAMmask); /* BE */
92 struct mac_regs __iomem * regs = vptr->mac_regs;
95 + HAIL("velocity_rx_reset");
96 vptr->rd_dirty = vptr->rd_filled = vptr->rd_curr = 0;
99 * Init state, all RD entries belong to the NIC
101 for (i = 0; i < vptr->options.numrx; ++i)
102 - vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC;
103 + /* vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC; BE */
104 + vptr->rd_ring[i].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
106 writew(vptr->options.numrx, ®s->RBRDU);
107 writel(vptr->rd_pool_dma, ®s->RDBaseLo);
108 @@ -704,12 +732,15 @@
109 struct mac_regs __iomem * regs = vptr->mac_regs;
112 + if (vdebug&5) printk(KERN_NOTICE "velocity_init_registers: entering\n");
117 case VELOCITY_INIT_RESET:
118 case VELOCITY_INIT_WOL:
120 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: RESET or WOL\n");
121 netif_stop_queue(vptr->dev);
124 @@ -737,12 +768,13 @@
126 case VELOCITY_INIT_COLD:
128 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: COLD or default\n");
132 velocity_soft_reset(vptr);
133 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: soft reset complete.\n");
136 mac_eeprom_reload(regs);
137 for (i = 0; i < 6; i++) {
138 writeb(vptr->dev->dev_addr[i], &(regs->PAR[i]));
139 @@ -760,11 +792,16 @@
141 BYTE_REG_BITS_SET(CFGB_OFSET, (CFGB_CRANDOM | CFGB_CAP | CFGB_MBA | CFGB_BAKOPT), ®s->CFGB);
143 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Initializing CAM filter\n");
147 + if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: about to init CAM filters\n");
148 + mdelay(5); /* MJW - ARM processors, kernel 2.6.19 - this fixes oopses and hangs */
149 velocity_init_cam_filter(vptr);
150 + if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: init CAM filters complete\n");
152 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Setting packet filter\n");
154 * Set packet filter: Receive directed and broadcast address
156 @@ -774,10 +811,12 @@
157 * Enable MII auto-polling
159 enable_mii_autopoll(regs);
160 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: enable_mii_autopoll complete.\n");
162 vptr->int_mask = INT_MASK_DEF;
164 - writel(cpu_to_le32(vptr->rd_pool_dma), ®s->RDBaseLo);
165 + /* writel(cpu_to_le32(vptr->rd_pool_dma), ®s->RDBaseLo); BE */
166 + writel((vptr->rd_pool_dma), ®s->RDBaseLo); /* BE */
167 writew(vptr->options.numrx - 1, ®s->RDCSize);
168 mac_rx_queue_run(regs);
169 mac_rx_queue_wake(regs);
170 @@ -785,10 +824,13 @@
171 writew(vptr->options.numtx - 1, ®s->TDCSize);
173 for (i = 0; i < vptr->num_txq; i++) {
174 - writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i]));
175 + /* writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); BE */
176 + writel((vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); /* BE */
177 mac_tx_queue_run(regs, i);
180 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: DMA settings complete.\n");
182 init_flow_control_register(vptr);
184 writel(CR0_STOP, ®s->CR0Clr);
187 enable_flow_control_ability(vptr);
188 mac_hw_mibs_init(regs);
189 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Set interrupt mask\n");
190 mac_write_int_mask(vptr->int_mask, regs);
192 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: complete.\n");
197 struct mac_regs __iomem * regs = vptr->mac_regs;
200 + HAIL("velocity_soft_reset");
201 writel(CR0_SFRST, ®s->CR0Set);
203 for (i = 0; i < W_MAX_TIMEOUT; i++) {
205 VELOCITY_FULL_DRV_NAM, VELOCITY_VERSION);
206 printk(KERN_INFO "Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n");
207 printk(KERN_INFO "Copyright (c) 2004 Red Hat Inc.\n");
208 + printk(KERN_INFO "BE support, misc. fixes MJW 01Jan2007 - may be unstable\n");
212 @@ -1104,6 +1150,7 @@
216 + HAIL("velocity_init_rings");
218 * Allocate all RD/TD rings a single pool
220 @@ -1166,6 +1213,7 @@
221 static void velocity_free_rings(struct velocity_info *vptr)
224 + HAIL("velocity_free_rings");
226 size = vptr->options.numrx * sizeof(struct rx_desc) +
227 vptr->options.numtx * sizeof(struct tx_desc) * vptr->num_txq;
228 @@ -1182,6 +1230,7 @@
229 struct mac_regs __iomem *regs = vptr->mac_regs;
230 int avail, dirty, unusable;
232 + HAIL("velocity_give_many_rx_descs");
234 * RD number must be equal to 4X per hardware spec
235 * (programming guide rev 1.20, p.13)
236 @@ -1195,7 +1244,8 @@
237 dirty = vptr->rd_dirty - unusable;
238 for (avail = vptr->rd_filled & 0xfffc; avail; avail--) {
239 dirty = (dirty > 0) ? dirty - 1 : vptr->options.numrx - 1;
240 - vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC;
241 + /* vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC; BE */
242 + vptr->rd_ring[dirty].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
245 writew(vptr->rd_filled & 0xfffc, ®s->RBRDU);
246 @@ -1205,12 +1255,14 @@
247 static int velocity_rx_refill(struct velocity_info *vptr)
249 int dirty = vptr->rd_dirty, done = 0, ret = 0;
250 + HAIL("velocity_rx_refill");
253 struct rx_desc *rd = vptr->rd_ring + dirty;
255 /* Fine for an all zero Rx desc at init time as well */
256 - if (rd->rdesc0.owner == OWNED_BY_NIC)
257 + /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */
258 + if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
261 if (!vptr->rd_info[dirty].skb) {
262 @@ -1244,6 +1296,7 @@
264 int mtu = vptr->dev->mtu;
266 + HAIL("velocity_init_rd_ring");
267 vptr->rx_buf_sz = (mtu <= ETH_DATA_LEN) ? PKT_BUF_SZ : mtu + 32;
269 vptr->rd_info = kcalloc(vptr->options.numrx,
270 @@ -1275,6 +1328,7 @@
274 + HAIL("velocity_free_rd_ring");
275 if (vptr->rd_info == NULL)
278 @@ -1314,6 +1368,7 @@
280 struct velocity_td_info *td_info;
282 + HAIL("velocity_init_td_ring");
283 /* Init the TD ring entries */
284 for (j = 0; j < vptr->num_txq; j++) {
285 curr = vptr->td_pool_dma[j];
286 @@ -1350,6 +1405,7 @@
287 struct velocity_td_info * td_info = &(vptr->td_infos[q][n]);
290 + HAIL("velocity_free_td_ring_entry");
294 @@ -1379,6 +1435,7 @@
298 + HAIL("velocity_free_td_ring");
299 for (j = 0; j < vptr->num_txq; j++) {
300 if (vptr->td_infos[j] == NULL)
302 @@ -1406,34 +1463,42 @@
303 struct net_device_stats *stats = &vptr->stats;
304 int rd_curr = vptr->rd_curr;
308 + HAILS("velocity_rx_srv", status);
310 struct rx_desc *rd = vptr->rd_ring + rd_curr;
312 if (!vptr->rd_info[rd_curr].skb)
315 - if (rd->rdesc0.owner == OWNED_BY_NIC)
316 + /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */
317 + if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
322 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
324 * Don't drop CE or RL error frame although RXOK is off
326 - if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) {
327 + /* if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) { BE */
328 + if ((wRSR & RSR_RXOK) || (!(wRSR & RSR_RXOK) && (wRSR & (RSR_CE | RSR_RL)))) { /* BE */
329 if (velocity_receive_frame(vptr, rd_curr) < 0)
332 - if (rd->rdesc0.RSR & RSR_CRC)
333 + /* if (rd->rdesc0.RSR & RSR_CRC) BE */
334 + if (wRSR & RSR_CRC) /* BE */
335 stats->rx_crc_errors++;
336 - if (rd->rdesc0.RSR & RSR_FAE)
337 + /* if (rd->rdesc0.RSR & RSR_FAE) BE */
338 + if (wRSR & RSR_FAE) /* BE */
339 stats->rx_frame_errors++;
345 + /* rd->inten = 1; BE */
346 + rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */
348 vptr->dev->last_rx = jiffies;
350 @@ -1464,13 +1529,21 @@
352 static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb)
355 + HAIL("velocity_rx_csum");
356 skb->ip_summed = CHECKSUM_NONE;
358 - if (rd->rdesc1.CSM & CSM_IPKT) {
359 - if (rd->rdesc1.CSM & CSM_IPOK) {
360 - if ((rd->rdesc1.CSM & CSM_TCPKT) ||
361 - (rd->rdesc1.CSM & CSM_UDPKT)) {
362 - if (!(rd->rdesc1.CSM & CSM_TUPOK)) {
363 +// if (rd->rdesc1.CSM & CSM_IPKT) {
364 +// if (rd->rdesc1.CSM & CSM_IPOK) {
365 +// if ((rd->rdesc1.CSM & CSM_TCPKT) ||
366 +// (rd->rdesc1.CSM & CSM_UDPKT)) {
367 +// if (!(rd->rdesc1.CSM & CSM_TUPOK)) {
368 + bCSM = (u8)(cpu_to_le32(rd->rdesc1) >> 16); /* BE */
369 + if (bCSM & CSM_IPKT) {
370 + if (bCSM & CSM_IPOK) {
371 + if ((bCSM & CSM_TCPKT) ||
372 + (bCSM & CSM_UDPKT)) {
373 + if (!(bCSM & CSM_TUPOK)) { /* BE */
377 @@ -1496,9 +1569,11 @@
381 + HAIL("velocity_rx_copy");
382 if (pkt_size < rx_copybreak) {
383 struct sk_buff *new_skb;
385 + HAIL("velocity_rx_copy (working...)");
386 new_skb = dev_alloc_skb(pkt_size + 2);
388 new_skb->dev = vptr->dev;
389 @@ -1529,10 +1604,12 @@
390 static inline void velocity_iph_realign(struct velocity_info *vptr,
391 struct sk_buff *skb, int pkt_size)
393 + HAIL("velocity_iph_realign");
394 /* FIXME - memmove ? */
395 if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
398 + HAIL("velocity_iph_realign (working...)");
399 for (i = pkt_size; i >= 0; i--)
400 *(skb->data + i + 2) = *(skb->data + i);
402 @@ -1551,19 +1628,27 @@
403 static int velocity_receive_frame(struct velocity_info *vptr, int idx)
405 void (*pci_action)(struct pci_dev *, dma_addr_t, size_t, int);
406 + u16 pkt_len; /* BE */
408 + struct sk_buff *skb;
409 struct net_device_stats *stats = &vptr->stats;
410 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
411 struct rx_desc *rd = &(vptr->rd_ring[idx]);
412 - int pkt_len = rd->rdesc0.len;
413 - struct sk_buff *skb;
414 + /* int pkt_len = rd->rdesc0.len BE */;
416 + pkt_len = ((cpu_to_le32(rd->rdesc0) >> 16) & 0x00003FFFUL); /* BE */
417 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
419 - if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) {
420 + HAIL("velocity_receive_frame");
421 + /* if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) { BE */
422 + if (wRSR & (RSR_STP | RSR_EDP)) { /* BE */
423 VELOCITY_PRT(MSG_LEVEL_VERBOSE, KERN_ERR " %s : the received frame span multple RDs.\n", vptr->dev->name);
424 stats->rx_length_errors++;
428 - if (rd->rdesc0.RSR & RSR_MAR)
429 + /* if (rd->rdesc0.RSR & RSR_MAR) BE */
430 + if (wRSR & RSR_MAR) /* BE */
431 vptr->stats.multicast++;
434 @@ -1576,7 +1661,8 @@
437 if (vptr->flags & VELOCITY_FLAGS_VAL_PKT_LEN) {
438 - if (rd->rdesc0.RSR & RSR_RL) {
439 + /* if (rd->rdesc0.RSR & RSR_RL) { BE */
440 + if (wRSR & RSR_RL) { /* BE */
441 stats->rx_length_errors++;
444 @@ -1620,6 +1706,7 @@
445 struct rx_desc *rd = &(vptr->rd_ring[idx]);
446 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
448 + HAIL("velocity_alloc_rx_buf");
449 rd_info->skb = dev_alloc_skb(vptr->rx_buf_sz + 64);
450 if (rd_info->skb == NULL)
452 @@ -1637,10 +1724,14 @@
455 *((u32 *) & (rd->rdesc0)) = 0;
456 - rd->len = cpu_to_le32(vptr->rx_buf_sz);
458 + /* rd->len = cpu_to_le32(vptr->rx_buf_sz); BE */
459 + /* rd->inten = 1; BE */
460 rd->pa_low = cpu_to_le32(rd_info->skb_dma);
462 + /* rd->pa_high = 0; BE */
463 + rd->ltwo &= cpu_to_le32(0xC000FFFFUL); /* BE */
464 + rd->ltwo |= cpu_to_le32((vptr->rx_buf_sz << 16)); /* BE */
465 + rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */
466 + rd->ltwo &= cpu_to_le32(0xFFFF0000UL); /* BE */
470 @@ -1661,9 +1752,11 @@
475 struct velocity_td_info *tdinfo;
476 struct net_device_stats *stats = &vptr->stats;
478 + HAILS("velocity_tx_srv", status);
479 for (qnum = 0; qnum < vptr->num_txq; qnum++) {
480 for (idx = vptr->td_tail[qnum]; vptr->td_used[qnum] > 0;
481 idx = (idx + 1) % vptr->options.numtx) {
482 @@ -1674,22 +1767,29 @@
483 td = &(vptr->td_rings[qnum][idx]);
484 tdinfo = &(vptr->td_infos[qnum][idx]);
486 - if (td->tdesc0.owner == OWNED_BY_NIC)
487 + /* if (td->tdesc0.owner == OWNED_BY_NIC) BE */
488 + if (td->tdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
494 - if (td->tdesc0.TSR & TSR0_TERR) {
495 + wTSR = (u16)cpu_to_le32(td->tdesc0);
496 + /* if (td->tdesc0.TSR & TSR0_TERR) { BE */
497 + if (wTSR & TSR0_TERR) { /* BE */
500 - if (td->tdesc0.TSR & TSR0_CDH)
501 + /* if (td->tdesc0.TSR & TSR0_CDH) BE */
502 + if (wTSR & TSR0_CDH) /* BE */
503 stats->tx_heartbeat_errors++;
504 - if (td->tdesc0.TSR & TSR0_CRS)
505 + /* if (td->tdesc0.TSR & TSR0_CRS) BE */
506 + if (wTSR & TSR0_CRS) /* BE */
507 stats->tx_carrier_errors++;
508 - if (td->tdesc0.TSR & TSR0_ABT)
509 + /* if (td->tdesc0.TSR & TSR0_ABT) BE */
510 + if (wTSR & TSR0_ABT) /* BE */
511 stats->tx_aborted_errors++;
512 - if (td->tdesc0.TSR & TSR0_OWC)
513 + /* if (td->tdesc0.TSR & TSR0_OWC) BE */
514 + if (wTSR & TSR0_OWC) /* BE */
515 stats->tx_window_errors++;
518 @@ -1778,6 +1878,7 @@
520 static void velocity_error(struct velocity_info *vptr, int status)
522 + HAILS("velocity_error", status);
524 if (status & ISR_TXSTLI) {
525 struct mac_regs __iomem * regs = vptr->mac_regs;
526 @@ -1867,6 +1968,7 @@
527 struct sk_buff *skb = tdinfo->skb;
530 + HAIL("velocity_free_tx_buf");
532 * Don't unmap the pre-allocated tx_bufs
534 @@ -2067,6 +2169,7 @@
535 struct velocity_td_info *tdinfo;
538 + u32 lbufsz; /* BE */
540 int pktlen = skb->len;
542 @@ -2083,9 +2186,18 @@
543 td_ptr = &(vptr->td_rings[qnum][index]);
544 tdinfo = &(vptr->td_infos[qnum][index]);
546 - td_ptr->tdesc1.TCPLS = TCPLS_NORMAL;
547 - td_ptr->tdesc1.TCR = TCR0_TIC;
548 - td_ptr->td_buf[0].queue = 0;
549 + td_ptr->tdesc0 = 0x00000000UL; /* BE */
550 + td_ptr->tdesc1 = 0x00000000UL; /* BE */
552 + /* td_ptr->tdesc1.TCPLS = TCPLS_NORMAL; BE */
553 + td_ptr->tdesc1 &= cpu_to_le32(0xfcffffffUL); /* BE */
554 + td_ptr->tdesc1 |= cpu_to_le32(((u32)TCPLS_NORMAL) << 24); /* BE */
556 + /* td_ptr->tdesc1.TCR = TCR0_TIC; BE */
557 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TIC); /* BE */
559 + /* td_ptr->td_buf[0].queue = 0; BE */
560 + td_ptr->td_buf[0].ltwo &= cpu_to_le32(~BE_QUEUE_ENABLE); /* BE */
564 @@ -2097,20 +2209,36 @@
565 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len);
567 tdinfo->skb_dma[0] = tdinfo->buf_dma;
568 - td_ptr->tdesc0.pktsize = pktlen;
569 + /* td_ptr->tdesc0.pktsize = pktlen; */
570 + td_ptr->tdesc0 &= cpu_to_le32(0xc000ffffUL); /* BE */
571 + lbufsz = pktlen; /* Assign, and make sure it's unsigned 32 bits - BE */
572 + lbufsz = lbufsz << 16; /* BE - shift over */
573 + td_ptr->tdesc0 |= cpu_to_le32(lbufsz); /* BE */
575 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
576 - td_ptr->td_buf[0].pa_high = 0;
577 - td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;
578 + /* td_ptr->td_buf[0].pa_high = 0; */
579 + /* td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; */
580 + td_ptr->td_buf[0].ltwo = cpu_to_le32(lbufsz); /* BE */
581 tdinfo->nskb_dma = 1;
582 - td_ptr->tdesc1.CMDZ = 2;
583 + /* td_ptr->tdesc1.CMDZ = 2; */
584 + td_ptr->tdesc1 &= cpu_to_le32(0x0fffffffUL); /* BE */
585 + td_ptr->tdesc1 |= cpu_to_le32(((u32)0x2) << 28); /* BE */
587 #ifdef VELOCITY_ZERO_COPY_SUPPORT
589 + * BE - NOTE on the VELOCITY_ZERO_COPY_SUPPORT:
590 + * This block of code has NOT been patched up for BE support, as
591 + * it is certainly broken -- if it compiles at all. Since the BE
592 + * fixes depend on the broken code, attempts to convert to BE support
593 + * would almost certainly confuse more than help.
595 if (skb_shinfo(skb)->nr_frags > 0) {
596 int nfrags = skb_shinfo(skb)->nr_frags;
599 skb_copy_from_linear_data(skb, tdinfo->buf, skb->len);
600 tdinfo->skb_dma[0] = tdinfo->buf_dma;
601 + /* BE: Er, exactly what value are we assigning in this next line? */
602 td_ptr->tdesc0.pktsize =
603 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
604 td_ptr->td_buf[0].pa_high = 0;
605 @@ -2127,6 +2255,7 @@
606 /* FIXME: support 48bit DMA later */
607 td_ptr->td_buf[i].pa_low = cpu_to_le32(tdinfo->skb_dma);
608 td_ptr->td_buf[i].pa_high = 0;
609 + /* BE: This next line can't be right: */
610 td_ptr->td_buf[i].bufsize = skb->len->skb->data_len;
612 for (i = 0; i < nfrags; i++) {
613 @@ -2144,7 +2273,7 @@
618 +#endif /* (broken) VELOCITY_ZERO_COPY_SUPPORT */
621 * Map the linear network buffer into PCI space and
622 @@ -2152,19 +2281,29 @@
625 tdinfo->skb_dma[0] = pci_map_single(vptr->pdev, skb->data, pktlen, PCI_DMA_TODEVICE);
626 - td_ptr->tdesc0.pktsize = pktlen;
627 + /* td_ptr->tdesc0.pktsize = pktlen; BE */
628 + td_ptr->tdesc0 &= cpu_to_le32(0xc000ffffUL); /* BE */
629 + lbufsz = pktlen; /* Assign, and make sure it's unsigned 32 bits - BE */
630 + lbufsz = lbufsz << 16; /* BE */
631 + td_ptr->tdesc0 |= cpu_to_le32(lbufsz); /* BE */
632 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
633 - td_ptr->td_buf[0].pa_high = 0;
634 - td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;
635 + /* td_ptr->td_buf[0].pa_high = 0; BE */
636 + /* td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; BE */
637 + td_ptr->td_buf[0].ltwo = cpu_to_le32(lbufsz); /* BE */
638 tdinfo->nskb_dma = 1;
639 - td_ptr->tdesc1.CMDZ = 2;
640 + /* td_ptr->tdesc1.CMDZ = 2; BE */
641 + td_ptr->tdesc1 &= cpu_to_le32(0x0fffffffUL); /* BE */
642 + td_ptr->tdesc1 |= cpu_to_le32(((u32)0x2) << 28); /* BE */
645 if (vptr->vlgrp && vlan_tx_tag_present(skb)) {
646 - td_ptr->tdesc1.pqinf.VID = vlan_tx_tag_get(skb);
647 - td_ptr->tdesc1.pqinf.priority = 0;
648 - td_ptr->tdesc1.pqinf.CFI = 0;
649 - td_ptr->tdesc1.TCR |= TCR0_VETAG;
650 + /* td_ptr->tdesc1.pqinf.VID = vlan_tx_tag_get(skb); BE */
651 + /* td_ptr->tdesc1.pqinf.priority = 0; BE */
652 + /* td_ptr->tdesc1.pqinf.CFI = 0; BE */
653 + /* td_ptr->tdesc1.TCR |= TCR0_VETAG; BE */
654 + td_ptr->tdesc1 &= cpu_to_le32(0xFFFF0000UL); /* BE */
655 + td_ptr->tdesc1 |= cpu_to_le32(vlan_tx_tag_get(skb)); /* BE */
656 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_VETAG); /* BE */
660 @@ -2174,26 +2313,34 @@
661 && (skb->ip_summed == CHECKSUM_PARTIAL)) {
662 const struct iphdr *ip = ip_hdr(skb);
663 if (ip->protocol == IPPROTO_TCP)
664 - td_ptr->tdesc1.TCR |= TCR0_TCPCK;
665 + /* td_ptr->tdesc1.TCR |= TCR0_TCPCK; BE */
666 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TCPCK); /* BE */
667 else if (ip->protocol == IPPROTO_UDP)
668 - td_ptr->tdesc1.TCR |= (TCR0_UDPCK);
669 - td_ptr->tdesc1.TCR |= TCR0_IPCK;
671 + /* td_ptr->tdesc1.TCR |= (TCR0_UDPCK); BE */
672 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_UDPCK); /* BE */
673 + /* td_ptr->tdesc1.TCR |= TCR0_IPCK; BE */
674 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_IPCK); /* BE */
678 int prev = index - 1;
681 prev = vptr->options.numtx - 1;
682 - td_ptr->tdesc0.owner = OWNED_BY_NIC;
683 + /* td_ptr->tdesc0.owner = OWNED_BY_NIC; BE */
684 + td_ptr->tdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
685 vptr->td_used[qnum]++;
686 vptr->td_curr[qnum] = (index + 1) % vptr->options.numtx;
688 if (AVAIL_TD(vptr, qnum) < 1)
689 netif_stop_queue(dev);
691 - td_ptr = &(vptr->td_rings[qnum][prev]);
692 - td_ptr->td_buf[0].queue = 1;
693 + td_ptr = &(vptr->td_rings[qnum][prev]);
694 + /* td_ptr->td_buf[0].queue = 1; BE */
695 + td_ptr->td_buf[0].ltwo |= cpu_to_le32(BE_QUEUE_ENABLE); /* BE */
696 + if (vdebug&2) printk(KERN_NOTICE "velocity_xmit: (%s) len=%d idx=%d tdesc0=0x%x tdesc1=0x%x ltwo=0x%x\n",
697 + (pktlen<ETH_ZLEN) ? "short" : "normal", pktlen, index,
698 + td_ptr->tdesc0, td_ptr->tdesc1, td_ptr->td_buf[0].ltwo);
699 mac_tx_queue_wake(vptr->mac_regs, qnum);
701 dev->trans_start = jiffies;
702 @@ -2219,7 +2366,7 @@
707 + HAIL("velocity_intr");
708 spin_lock(&vptr->lock);
709 isr_status = mac_read_isr(vptr->mac_regs);
711 @@ -2238,7 +2385,10 @@
713 while (isr_status != 0) {
714 mac_write_isr(vptr->mac_regs, isr_status);
715 - if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI)))
716 + HAILS("velocity_intr",isr_status);
717 + /* MJW - velocity_error is ALWAYS called; need to mask off some other flags */
718 + /* if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI))) */
719 + if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI | ISR_PTX0I | ISR_ISR0)))
720 velocity_error(vptr, isr_status);
721 if (isr_status & (ISR_PRXI | ISR_PPRXI))
722 max_count += velocity_rx_srv(vptr, isr_status);
723 @@ -2276,6 +2426,7 @@
725 struct dev_mc_list *mclist;
727 + HAIL("velocity_set_multi");
728 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
729 writel(0xffffffff, ®s->MARCAM[0]);
730 writel(0xffffffff, ®s->MARCAM[4]);
731 @@ -2319,6 +2470,7 @@
733 struct velocity_info *vptr = netdev_priv(dev);
735 + HAIL("net_device_stats");
736 /* If the hardware is down, don't touch MII */
737 if(!netif_running(dev))
739 @@ -2363,6 +2515,7 @@
740 struct velocity_info *vptr = netdev_priv(dev);
743 + HAIL("velocity_ioctl");
744 /* If we are asked for information and the device is power
745 saving then we need to bring the device back up to talk to it */
747 @@ -2581,6 +2734,8 @@
751 + HAIL("velocity_mii_read");
752 + HAIL("velocity_mii_write");
754 * Disable MIICR_MAUTO, so that mii addr can be set normally
756 diff -Naur linux-2.6.24.orig/drivers/net/via-velocity.h linux-2.6.24/drivers/net/via-velocity.h
757 --- linux-2.6.24.orig/drivers/net/via-velocity.h 2008-01-31 23:11:26.000000000 -0600
758 +++ linux-2.6.24/drivers/net/via-velocity.h 2008-02-01 01:12:15.000000000 -0600
759 @@ -196,64 +196,70 @@
764 - u16 RSR; /* Receive status */
765 - u16 len:14; /* Received packet length */
767 - u16 owner:1; /* Who owns this buffer ? */
776 +// u16 RSR; /* Receive status */
777 +// u16 len:14; /* Received packet length */
779 +// u16 owner:1; /* Who owns this buffer ? */
789 - struct rdesc0 rdesc0;
790 - struct rdesc1 rdesc1;
791 +// struct rdesc0 rdesc0;
792 +// struct rdesc1 rdesc1;
795 u32 pa_low; /* Low 32 bit PCI address */
796 - u16 pa_high; /* Next 16 bit PCI address (48 total) */
797 - u16 len:15; /* Frame size */
798 - u16 inten:1; /* Enable interrupt */
799 +// u16 pa_high; /* Next 16 bit PCI address (48 total) */
800 +// u16 len:15; /* Frame size */
801 +// u16 inten:1; /* Enable interrupt */
803 } __attribute__ ((__packed__));
806 * Transmit descriptor
810 - u16 TSR; /* Transmit status register */
811 - u16 pktsize:14; /* Size of frame */
813 - u16 owner:1; /* Who owns the buffer */
816 -struct pqinf { /* Priority queue info */
820 -} __attribute__ ((__packed__));
823 - struct pqinf pqinf;
828 -} __attribute__ ((__packed__));
830 +// u16 TSR; /* Transmit status register */
831 +// u16 pktsize:14; /* Size of frame */
833 +// u16 owner:1; /* Who owns the buffer */
836 +//struct pqinf { /* Priority queue info */
840 +//} __attribute__ ((__packed__));
843 +// struct pqinf pqinf;
848 +//} __attribute__ ((__packed__));
861 } __attribute__ ((__packed__));
864 - struct tdesc0 tdesc0;
865 - struct tdesc1 tdesc1;
866 +// struct tdesc0 tdesc0;
867 +// struct tdesc1 tdesc1;
870 struct td_buf td_buf[7];
877 +/* Constants added for the BE fixes */
878 +#define BE_OWNED_BY_NIC 0x80000000UL
879 +#define BE_INT_ENABLE 0x80000000UL
880 +#define BE_QUEUE_ENABLE 0x80000000UL
881 +#define BE_TCR_TIC 0x00800000UL
882 +#define BE_TCR_VETAG 0x00200000UL
883 +#define BE_TCR_TCPCK 0x00040000UL
884 +#define BE_TCR_UDPCK 0x00080000UL
885 +#define BE_TCR_IPCK 0x00100000UL
889 * MAC registers and macros.
890 @@ -1512,6 +1528,7 @@
893 struct velocity_opt {
894 + int velo_debug; /* debug flag */
895 int numrx; /* Number of RX descriptors */
896 int numtx; /* Number of TX descriptors */
897 enum speed_opt spd_dpx; /* Media link mode */