1 diff -uprN linux-2.6.23.orig/drivers/net/via-velocity.c linux-2.6.23/drivers/net/via-velocity.c
2 --- linux-2.6.23.orig/drivers/net/via-velocity.c 2007-10-09 15:31:38.000000000 -0500
3 +++ linux-2.6.23/drivers/net/via-velocity.c 2007-10-11 00:53:45.000000000 -0500
4 @@ -96,11 +96,31 @@ MODULE_AUTHOR("VIA Networking Technologi
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
36 @@ -385,12 +405,12 @@ static void __devinit velocity_set_int_o
39 else if (val < min || val > max) {
40 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (%d-%d)\n",
41 - devname, name, min, max);
42 + VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "via-velocity: the value of parameter %s is invalid, the valid range is (%d-%d)\n",
46 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: set value of parameter %s to %d\n",
47 - devname, name, val);
48 + VELOCITY_PRT(MSG_LEVEL_INFO, KERN_INFO "via-velocity: set value of parameter %s to %d\n",
53 @@ -415,12 +435,12 @@ static void __devinit velocity_set_bool_
55 *opt |= (def ? flag : 0);
56 else if (val < 0 || val > 1) {
57 - printk(KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (0-1)\n",
59 + printk(KERN_NOTICE "via-velocity: the value of parameter %s is invalid, the valid range is (0-1)\n",
61 *opt |= (def ? flag : 0);
63 - printk(KERN_INFO "%s: set parameter %s to %s\n",
64 - devname, name, val ? "TRUE" : "FALSE");
65 + printk(KERN_INFO "via-velocity: set parameter %s to %s\n",
66 + name, val ? "TRUE" : "FALSE");
67 *opt |= (val ? flag : 0);
70 @@ -438,6 +458,7 @@ static void __devinit velocity_set_bool_
71 static void __devinit velocity_get_options(struct velocity_opt *opts, int index, char *devname)
74 + velocity_set_int_opt(&opts->velo_debug, velo_debug[index], VELO_DEBUG_MIN, VELO_DEBUG_MAX, VELO_DEBUG_DEF, "velo_debug", devname);
75 velocity_set_int_opt(&opts->rx_thresh, rx_thresh[index], RX_THRESH_MIN, RX_THRESH_MAX, RX_THRESH_DEF, "rx_thresh", devname);
76 velocity_set_int_opt(&opts->DMA_length, DMA_length[index], DMA_LENGTH_MIN, DMA_LENGTH_MAX, DMA_LENGTH_DEF, "DMA_length", devname);
77 velocity_set_int_opt(&opts->numrx, RxDescriptors[index], RX_DESC_MIN, RX_DESC_MAX, RX_DESC_DEF, "RxDescriptors", devname);
78 @@ -452,6 +473,7 @@ static void __devinit velocity_get_optio
79 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);
80 velocity_set_int_opt((int *) &opts->int_works, int_works[index], INT_WORKS_MIN, INT_WORKS_MAX, INT_WORKS_DEF, "Interrupt service works", devname);
81 opts->numrx = (opts->numrx & ~3);
82 + vdebug = opts->velo_debug;
86 @@ -466,6 +488,8 @@ static void velocity_init_cam_filter(str
88 struct mac_regs __iomem * regs = vptr->mac_regs;
90 + HAIL("velocity_init_cam_filter");
92 /* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */
93 WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, ®s->MCFG);
94 WORD_REG_BITS_ON(MCFG_VIDFR, ®s->MCFG);
95 @@ -484,14 +508,12 @@ static void velocity_init_cam_filter(str
96 WORD_REG_BITS_ON(MCFG_RTGOPT, ®s->MCFG);
98 mac_set_cam(regs, 0, (u8 *) & (vptr->options.vid), VELOCITY_VLAN_ID_CAM);
99 - vptr->vCAMmask[0] |= 1;
100 - mac_set_cam_mask(regs, vptr->vCAMmask, VELOCITY_VLAN_ID_CAM);
103 mac_set_cam(regs, 0, (u8 *) &temp, VELOCITY_VLAN_ID_CAM);
105 - mac_set_cam_mask(regs, (u8 *) &temp, VELOCITY_VLAN_ID_CAM);
107 + vptr->vCAMmask[0] |= 1;
108 + mac_set_cam_mask(regs, vptr->vCAMmask, VELOCITY_VLAN_ID_CAM);
112 @@ -508,13 +530,15 @@ static void velocity_rx_reset(struct vel
113 struct mac_regs __iomem * regs = vptr->mac_regs;
116 + HAIL("velocity_rx_reset");
117 vptr->rd_dirty = vptr->rd_filled = vptr->rd_curr = 0;
120 * Init state, all RD entries belong to the NIC
122 for (i = 0; i < vptr->options.numrx; ++i)
123 - vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC;
124 + /* vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC; BE */
125 + vptr->rd_ring[i].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
127 writew(vptr->options.numrx, ®s->RBRDU);
128 writel(vptr->rd_pool_dma, ®s->RDBaseLo);
129 @@ -537,12 +561,15 @@ static void velocity_init_registers(stru
130 struct mac_regs __iomem * regs = vptr->mac_regs;
133 + if (vdebug&5) printk(KERN_NOTICE "velocity_init_registers: entering\n");
138 case VELOCITY_INIT_RESET:
139 case VELOCITY_INIT_WOL:
141 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: RESET or WOL\n");
142 netif_stop_queue(vptr->dev);
145 @@ -570,12 +597,13 @@ static void velocity_init_registers(stru
147 case VELOCITY_INIT_COLD:
149 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: COLD or default\n");
153 velocity_soft_reset(vptr);
154 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: soft reset complete.\n");
157 mac_eeprom_reload(regs);
158 for (i = 0; i < 6; i++) {
159 writeb(vptr->dev->dev_addr[i], &(regs->PAR[i]));
160 @@ -593,11 +621,16 @@ static void velocity_init_registers(stru
162 BYTE_REG_BITS_SET(CFGB_OFSET, (CFGB_CRANDOM | CFGB_CAP | CFGB_MBA | CFGB_BAKOPT), ®s->CFGB);
164 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Initializing CAM filter\n");
168 + if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: about to init CAM filters\n");
169 + mdelay(5); /* MJW - ARM processors, kernel 2.6.19 - this fixes oopses and hangs */
170 velocity_init_cam_filter(vptr);
171 + if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: init CAM filters complete\n");
173 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Setting packet filter\n");
175 * Set packet filter: Receive directed and broadcast address
177 @@ -607,10 +640,12 @@ static void velocity_init_registers(stru
178 * Enable MII auto-polling
180 enable_mii_autopoll(regs);
181 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: enable_mii_autopoll complete.\n");
183 vptr->int_mask = INT_MASK_DEF;
185 - writel(cpu_to_le32(vptr->rd_pool_dma), ®s->RDBaseLo);
186 + /* writel(cpu_to_le32(vptr->rd_pool_dma), ®s->RDBaseLo); BE */
187 + writel((vptr->rd_pool_dma), ®s->RDBaseLo); /* BE */
188 writew(vptr->options.numrx - 1, ®s->RDCSize);
189 mac_rx_queue_run(regs);
190 mac_rx_queue_wake(regs);
191 @@ -618,10 +653,13 @@ static void velocity_init_registers(stru
192 writew(vptr->options.numtx - 1, ®s->TDCSize);
194 for (i = 0; i < vptr->num_txq; i++) {
195 - writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i]));
196 + /* writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); BE */
197 + writel((vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); /* BE */
198 mac_tx_queue_run(regs, i);
201 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: DMA settings complete.\n");
203 init_flow_control_register(vptr);
205 writel(CR0_STOP, ®s->CR0Clr);
206 @@ -640,8 +678,10 @@ static void velocity_init_registers(stru
208 enable_flow_control_ability(vptr);
209 mac_hw_mibs_init(regs);
210 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Set interrupt mask\n");
211 mac_write_int_mask(vptr->int_mask, regs);
213 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: complete.\n");
217 @@ -659,6 +699,7 @@ static int velocity_soft_reset(struct ve
218 struct mac_regs __iomem * regs = vptr->mac_regs;
221 + HAIL("velocity_soft_reset");
222 writel(CR0_SFRST, ®s->CR0Set);
224 for (i = 0; i < W_MAX_TIMEOUT; i++) {
225 @@ -722,6 +763,7 @@ static int __devinit velocity_found1(str
226 VELOCITY_FULL_DRV_NAM, VELOCITY_VERSION);
227 printk(KERN_INFO "Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n");
228 printk(KERN_INFO "Copyright (c) 2004 Red Hat Inc.\n");
229 + printk(KERN_INFO "BE support, misc. fixes MJW 01Jan2007 - may be unstable\n");
233 @@ -934,6 +976,7 @@ static int velocity_init_rings(struct ve
237 + HAIL("velocity_init_rings");
239 * Allocate all RD/TD rings a single pool
241 @@ -996,6 +1039,7 @@ static int velocity_init_rings(struct ve
242 static void velocity_free_rings(struct velocity_info *vptr)
245 + HAIL("velocity_free_rings");
247 size = vptr->options.numrx * sizeof(struct rx_desc) +
248 vptr->options.numtx * sizeof(struct tx_desc) * vptr->num_txq;
249 @@ -1012,6 +1056,7 @@ static inline void velocity_give_many_rx
250 struct mac_regs __iomem *regs = vptr->mac_regs;
251 int avail, dirty, unusable;
253 + HAIL("velocity_give_many_rx_descs");
255 * RD number must be equal to 4X per hardware spec
256 * (programming guide rev 1.20, p.13)
257 @@ -1025,7 +1070,8 @@ static inline void velocity_give_many_rx
258 dirty = vptr->rd_dirty - unusable;
259 for (avail = vptr->rd_filled & 0xfffc; avail; avail--) {
260 dirty = (dirty > 0) ? dirty - 1 : vptr->options.numrx - 1;
261 - vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC;
262 + /* vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC; BE */
263 + vptr->rd_ring[dirty].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
266 writew(vptr->rd_filled & 0xfffc, ®s->RBRDU);
267 @@ -1035,12 +1081,14 @@ static inline void velocity_give_many_rx
268 static int velocity_rx_refill(struct velocity_info *vptr)
270 int dirty = vptr->rd_dirty, done = 0, ret = 0;
271 + HAIL("velocity_rx_refill");
274 struct rx_desc *rd = vptr->rd_ring + dirty;
276 /* Fine for an all zero Rx desc at init time as well */
277 - if (rd->rdesc0.owner == OWNED_BY_NIC)
278 + /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */
279 + if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
282 if (!vptr->rd_info[dirty].skb) {
283 @@ -1075,6 +1123,7 @@ static int velocity_init_rd_ring(struct
284 unsigned int rsize = sizeof(struct velocity_rd_info) *
287 + HAIL("velocity_init_rd_ring");
288 vptr->rd_info = kmalloc(rsize, GFP_KERNEL);
289 if(vptr->rd_info == NULL)
291 @@ -1104,6 +1153,7 @@ static void velocity_free_rd_ring(struct
295 + HAIL("velocity_free_rd_ring");
296 if (vptr->rd_info == NULL)
299 @@ -1145,6 +1195,7 @@ static int velocity_init_td_ring(struct
300 unsigned int tsize = sizeof(struct velocity_td_info) *
303 + HAIL("velocity_init_td_ring");
304 /* Init the TD ring entries */
305 for (j = 0; j < vptr->num_txq; j++) {
306 curr = vptr->td_pool_dma[j];
307 @@ -1181,6 +1232,7 @@ static void velocity_free_td_ring_entry(
308 struct velocity_td_info * td_info = &(vptr->td_infos[q][n]);
311 + HAIL("velocity_free_td_ring_entry");
315 @@ -1210,6 +1262,7 @@ static void velocity_free_td_ring(struct
319 + HAIL("velocity_free_td_ring");
320 for (j = 0; j < vptr->num_txq; j++) {
321 if (vptr->td_infos[j] == NULL)
323 @@ -1237,34 +1290,42 @@ static int velocity_rx_srv(struct veloci
324 struct net_device_stats *stats = &vptr->stats;
325 int rd_curr = vptr->rd_curr;
329 + HAILS("velocity_rx_srv", status);
331 struct rx_desc *rd = vptr->rd_ring + rd_curr;
333 if (!vptr->rd_info[rd_curr].skb)
336 - if (rd->rdesc0.owner == OWNED_BY_NIC)
337 + /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */
338 + if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
343 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
345 * Don't drop CE or RL error frame although RXOK is off
347 - if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) {
348 + /* if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) { BE */
349 + if ((wRSR & RSR_RXOK) || (!(wRSR & RSR_RXOK) && (wRSR & (RSR_CE | RSR_RL)))) { /* BE */
350 if (velocity_receive_frame(vptr, rd_curr) < 0)
353 - if (rd->rdesc0.RSR & RSR_CRC)
354 + /* if (rd->rdesc0.RSR & RSR_CRC) BE */
355 + if (wRSR & RSR_CRC) /* BE */
356 stats->rx_crc_errors++;
357 - if (rd->rdesc0.RSR & RSR_FAE)
358 + /* if (rd->rdesc0.RSR & RSR_FAE) BE */
359 + if (wRSR & RSR_FAE) /* BE */
360 stats->rx_frame_errors++;
366 + /* rd->inten = 1; BE */
367 + rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */
369 vptr->dev->last_rx = jiffies;
371 @@ -1295,13 +1356,21 @@ static int velocity_rx_srv(struct veloci
373 static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb)
376 + HAIL("velocity_rx_csum");
377 skb->ip_summed = CHECKSUM_NONE;
379 - if (rd->rdesc1.CSM & CSM_IPKT) {
380 - if (rd->rdesc1.CSM & CSM_IPOK) {
381 - if ((rd->rdesc1.CSM & CSM_TCPKT) ||
382 - (rd->rdesc1.CSM & CSM_UDPKT)) {
383 - if (!(rd->rdesc1.CSM & CSM_TUPOK)) {
384 +// if (rd->rdesc1.CSM & CSM_IPKT) {
385 +// if (rd->rdesc1.CSM & CSM_IPOK) {
386 +// if ((rd->rdesc1.CSM & CSM_TCPKT) ||
387 +// (rd->rdesc1.CSM & CSM_UDPKT)) {
388 +// if (!(rd->rdesc1.CSM & CSM_TUPOK)) {
389 + bCSM = (u8)(cpu_to_le32(rd->rdesc1) >> 16); /* BE */
390 + if (bCSM & CSM_IPKT) {
391 + if (bCSM & CSM_IPOK) {
392 + if ((bCSM & CSM_TCPKT) ||
393 + (bCSM & CSM_UDPKT)) {
394 + if (!(bCSM & CSM_TUPOK)) { /* BE */
398 @@ -1327,9 +1396,11 @@ static inline int velocity_rx_copy(struc
402 + HAIL("velocity_rx_copy");
403 if (pkt_size < rx_copybreak) {
404 struct sk_buff *new_skb;
406 + HAIL("velocity_rx_copy (working...)");
407 new_skb = dev_alloc_skb(pkt_size + 2);
409 new_skb->dev = vptr->dev;
410 @@ -1360,10 +1431,12 @@ static inline int velocity_rx_copy(struc
411 static inline void velocity_iph_realign(struct velocity_info *vptr,
412 struct sk_buff *skb, int pkt_size)
414 + HAIL("velocity_iph_realign");
415 /* FIXME - memmove ? */
416 if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
419 + HAIL("velocity_iph_realign (working...)");
420 for (i = pkt_size; i >= 0; i--)
421 *(skb->data + i + 2) = *(skb->data + i);
423 @@ -1382,19 +1455,27 @@ static inline void velocity_iph_realign(
424 static int velocity_receive_frame(struct velocity_info *vptr, int idx)
426 void (*pci_action)(struct pci_dev *, dma_addr_t, size_t, int);
427 + u16 pkt_len; /* BE */
429 + struct sk_buff *skb;
430 struct net_device_stats *stats = &vptr->stats;
431 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
432 struct rx_desc *rd = &(vptr->rd_ring[idx]);
433 - int pkt_len = rd->rdesc0.len;
434 - struct sk_buff *skb;
435 + /* int pkt_len = rd->rdesc0.len BE */;
437 + pkt_len = ((cpu_to_le32(rd->rdesc0) >> 16) & 0x00003FFFUL); /* BE */
438 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
440 - if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) {
441 + HAIL("velocity_receive_frame");
442 + /* if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) { BE */
443 + if (wRSR & (RSR_STP | RSR_EDP)) { /* BE */
444 VELOCITY_PRT(MSG_LEVEL_VERBOSE, KERN_ERR " %s : the received frame span multple RDs.\n", vptr->dev->name);
445 stats->rx_length_errors++;
449 - if (rd->rdesc0.RSR & RSR_MAR)
450 + /* if (rd->rdesc0.RSR & RSR_MAR) BE */
451 + if (wRSR & RSR_MAR) /* BE */
452 vptr->stats.multicast++;
455 @@ -1407,7 +1488,8 @@ static int velocity_receive_frame(struct
458 if (vptr->flags & VELOCITY_FLAGS_VAL_PKT_LEN) {
459 - if (rd->rdesc0.RSR & RSR_RL) {
460 + /* if (rd->rdesc0.RSR & RSR_RL) { BE */
461 + if (wRSR & RSR_RL) { /* BE */
462 stats->rx_length_errors++;
465 @@ -1451,6 +1533,7 @@ static int velocity_alloc_rx_buf(struct
466 struct rx_desc *rd = &(vptr->rd_ring[idx]);
467 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
469 + HAIL("velocity_alloc_rx_buf");
470 rd_info->skb = dev_alloc_skb(vptr->rx_buf_sz + 64);
471 if (rd_info->skb == NULL)
473 @@ -1468,10 +1551,14 @@ static int velocity_alloc_rx_buf(struct
476 *((u32 *) & (rd->rdesc0)) = 0;
477 - rd->len = cpu_to_le32(vptr->rx_buf_sz);
479 + /* rd->len = cpu_to_le32(vptr->rx_buf_sz); BE */
480 + /* rd->inten = 1; BE */
481 rd->pa_low = cpu_to_le32(rd_info->skb_dma);
483 + /* rd->pa_high = 0; BE */
484 + rd->ltwo &= cpu_to_le32(0xC000FFFFUL); /* BE */
485 + rd->ltwo |= cpu_to_le32((vptr->rx_buf_sz << 16)); /* BE */
486 + rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */
487 + rd->ltwo &= cpu_to_le32(0xFFFF0000UL); /* BE */
491 @@ -1492,9 +1579,11 @@ static int velocity_tx_srv(struct veloci
496 struct velocity_td_info *tdinfo;
497 struct net_device_stats *stats = &vptr->stats;
499 + HAILS("velocity_tx_srv", status);
500 for (qnum = 0; qnum < vptr->num_txq; qnum++) {
501 for (idx = vptr->td_tail[qnum]; vptr->td_used[qnum] > 0;
502 idx = (idx + 1) % vptr->options.numtx) {
503 @@ -1505,22 +1594,29 @@ static int velocity_tx_srv(struct veloci
504 td = &(vptr->td_rings[qnum][idx]);
505 tdinfo = &(vptr->td_infos[qnum][idx]);
507 - if (td->tdesc0.owner == OWNED_BY_NIC)
508 + /* if (td->tdesc0.owner == OWNED_BY_NIC) BE */
509 + if (td->tdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
515 - if (td->tdesc0.TSR & TSR0_TERR) {
516 + wTSR = (u16)cpu_to_le32(td->tdesc0);
517 + /* if (td->tdesc0.TSR & TSR0_TERR) { BE */
518 + if (wTSR & TSR0_TERR) { /* BE */
521 - if (td->tdesc0.TSR & TSR0_CDH)
522 + /* if (td->tdesc0.TSR & TSR0_CDH) BE */
523 + if (wTSR & TSR0_CDH) /* BE */
524 stats->tx_heartbeat_errors++;
525 - if (td->tdesc0.TSR & TSR0_CRS)
526 + /* if (td->tdesc0.TSR & TSR0_CRS) BE */
527 + if (wTSR & TSR0_CRS) /* BE */
528 stats->tx_carrier_errors++;
529 - if (td->tdesc0.TSR & TSR0_ABT)
530 + /* if (td->tdesc0.TSR & TSR0_ABT) BE */
531 + if (wTSR & TSR0_ABT) /* BE */
532 stats->tx_aborted_errors++;
533 - if (td->tdesc0.TSR & TSR0_OWC)
534 + /* if (td->tdesc0.TSR & TSR0_OWC) BE */
535 + if (wTSR & TSR0_OWC) /* BE */
536 stats->tx_window_errors++;
539 @@ -1609,6 +1705,7 @@ static void velocity_print_link_status(s
541 static void velocity_error(struct velocity_info *vptr, int status)
543 + HAILS("velocity_error", status);
545 if (status & ISR_TXSTLI) {
546 struct mac_regs __iomem * regs = vptr->mac_regs;
547 @@ -1698,6 +1795,7 @@ static void velocity_free_tx_buf(struct
548 struct sk_buff *skb = tdinfo->skb;
551 + HAIL("velocity_free_tx_buf");
553 * Don't unmap the pre-allocated tx_bufs
555 @@ -1901,6 +1999,7 @@ static int velocity_xmit(struct sk_buff
556 struct velocity_td_info *tdinfo;
559 + u32 lbufsz; /* BE */
561 int pktlen = skb->len;
563 @@ -1917,9 +2016,18 @@ static int velocity_xmit(struct sk_buff
564 td_ptr = &(vptr->td_rings[qnum][index]);
565 tdinfo = &(vptr->td_infos[qnum][index]);
567 - td_ptr->tdesc1.TCPLS = TCPLS_NORMAL;
568 - td_ptr->tdesc1.TCR = TCR0_TIC;
569 - td_ptr->td_buf[0].queue = 0;
570 + td_ptr->tdesc0 = 0x00000000UL; /* BE */
571 + td_ptr->tdesc1 = 0x00000000UL; /* BE */
573 + /* td_ptr->tdesc1.TCPLS = TCPLS_NORMAL; BE */
574 + td_ptr->tdesc1 &= cpu_to_le32(0xfcffffffUL); /* BE */
575 + td_ptr->tdesc1 |= cpu_to_le32(((u32)TCPLS_NORMAL) << 24); /* BE */
577 + /* td_ptr->tdesc1.TCR = TCR0_TIC; BE */
578 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TIC); /* BE */
580 + /* td_ptr->td_buf[0].queue = 0; BE */
581 + td_ptr->td_buf[0].ltwo &= cpu_to_le32(~BE_QUEUE_ENABLE); /* BE */
585 @@ -1931,20 +2039,36 @@ static int velocity_xmit(struct sk_buff
586 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len);
588 tdinfo->skb_dma[0] = tdinfo->buf_dma;
589 - td_ptr->tdesc0.pktsize = pktlen;
590 + /* td_ptr->tdesc0.pktsize = pktlen; */
591 + td_ptr->tdesc0 &= cpu_to_le32(0xc000ffffUL); /* BE */
592 + lbufsz = pktlen; /* Assign, and make sure it's unsigned 32 bits - BE */
593 + lbufsz = lbufsz << 16; /* BE - shift over */
594 + 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 skb_copy_from_linear_data(skb, tdinfo->buf, 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 @@ -1961,6 +2085,7 @@ static int velocity_xmit(struct sk_buff
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 @@ -1978,7 +2103,7 @@ static int velocity_xmit(struct sk_buff
639 +#endif /* (broken) VELOCITY_ZERO_COPY_SUPPORT */
642 * Map the linear network buffer into PCI space and
643 @@ -1986,19 +2111,30 @@ static int velocity_xmit(struct sk_buff
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 @@ -2008,26 +2144,34 @@ static int velocity_xmit(struct sk_buff
683 && (skb->ip_summed == CHECKSUM_PARTIAL)) {
684 const struct iphdr *ip = ip_hdr(skb);
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 @@ -2053,7 +2197,7 @@ static int velocity_intr(int irq, void *
729 + HAIL("velocity_intr");
730 spin_lock(&vptr->lock);
731 isr_status = mac_read_isr(vptr->mac_regs);
733 @@ -2072,7 +2216,10 @@ static int velocity_intr(int irq, void *
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 @@ -2110,6 +2257,7 @@ static void velocity_set_multi(struct ne
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 @@ -2153,6 +2301,7 @@ static struct net_device_stats *velocity
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 @@ -2197,6 +2346,7 @@ static int velocity_ioctl(struct net_dev
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 @@ -2415,6 +2565,7 @@ static int velocity_mii_read(struct mac_
773 + HAIL("velocity_mii_read");
775 * Disable MIICR_MAUTO, so that mii addr can be set normally
777 @@ -2451,6 +2602,7 @@ static int velocity_mii_write(struct mac
781 + HAIL("velocity_mii_write");
783 * Disable MIICR_MAUTO, so that mii addr can be set normally
785 diff -uprN linux-2.6.23.orig/drivers/net/via-velocity.h linux-2.6.23/drivers/net/via-velocity.h
786 --- linux-2.6.23.orig/drivers/net/via-velocity.h 2007-10-09 15:31:38.000000000 -0500
787 +++ linux-2.6.23/drivers/net/via-velocity.h 2007-10-11 00:53:45.000000000 -0500
788 @@ -196,64 +196,70 @@
793 - u16 RSR; /* Receive status */
794 - u16 len:14; /* Received packet length */
796 - u16 owner:1; /* Who owns this buffer ? */
805 +// u16 RSR; /* Receive status */
806 +// u16 len:14; /* Received packet length */
808 +// u16 owner:1; /* Who owns this buffer ? */
818 - struct rdesc0 rdesc0;
819 - struct rdesc1 rdesc1;
820 +// struct rdesc0 rdesc0;
821 +// struct rdesc1 rdesc1;
824 u32 pa_low; /* Low 32 bit PCI address */
825 - u16 pa_high; /* Next 16 bit PCI address (48 total) */
826 - u16 len:15; /* Frame size */
827 - u16 inten:1; /* Enable interrupt */
828 +// u16 pa_high; /* Next 16 bit PCI address (48 total) */
829 +// u16 len:15; /* Frame size */
830 +// u16 inten:1; /* Enable interrupt */
832 } __attribute__ ((__packed__));
835 * Transmit descriptor
839 - u16 TSR; /* Transmit status register */
840 - u16 pktsize:14; /* Size of frame */
842 - u16 owner:1; /* Who owns the buffer */
845 -struct pqinf { /* Priority queue info */
849 -} __attribute__ ((__packed__));
852 - struct pqinf pqinf;
857 -} __attribute__ ((__packed__));
859 +// u16 TSR; /* Transmit status register */
860 +// u16 pktsize:14; /* Size of frame */
862 +// u16 owner:1; /* Who owns the buffer */
865 +//struct pqinf { /* Priority queue info */
869 +//} __attribute__ ((__packed__));
872 +// struct pqinf pqinf;
877 +//} __attribute__ ((__packed__));
890 } __attribute__ ((__packed__));
893 - struct tdesc0 tdesc0;
894 - struct tdesc1 tdesc1;
895 +// struct tdesc0 tdesc0;
896 +// struct tdesc1 tdesc1;
899 struct td_buf td_buf[7];
902 @@ -279,6 +285,16 @@ enum velocity_owner {
906 +/* Constants added for the BE fixes */
907 +#define BE_OWNED_BY_NIC 0x80000000UL
908 +#define BE_INT_ENABLE 0x80000000UL
909 +#define BE_QUEUE_ENABLE 0x80000000UL
910 +#define BE_TCR_TIC 0x00800000UL
911 +#define BE_TCR_VETAG 0x00200000UL
912 +#define BE_TCR_TCPCK 0x00040000UL
913 +#define BE_TCR_UDPCK 0x00080000UL
914 +#define BE_TCR_IPCK 0x00100000UL
918 * MAC registers and macros.
919 @@ -1698,6 +1714,7 @@ enum velocity_flow_cntl_type {
922 struct velocity_opt {
923 + int velo_debug; /* debug flag */
924 int numrx; /* Number of RX descriptors */
925 int numtx; /* Number of TX descriptors */
926 enum speed_opt spd_dpx; /* Media link mode */