1 Index: linux-2.6.24.7/drivers/net/via-velocity.c
2 ===================================================================
3 --- linux-2.6.24.7.orig/drivers/net/via-velocity.c
4 +++ linux-2.6.24.7/drivers/net/via-velocity.c
5 @@ -254,11 +254,31 @@ MODULE_AUTHOR("VIA Networking Technologi
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
37 @@ -557,12 +577,12 @@ static void __devinit velocity_set_bool_
39 *opt |= (def ? flag : 0);
40 else if (val < 0 || val > 1) {
41 - printk(KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (0-1)\n",
43 + printk(KERN_NOTICE "via-velocity: the value of parameter %s is invalid, the valid range is (0-1)\n",
45 *opt |= (def ? flag : 0);
47 - printk(KERN_INFO "%s: set parameter %s to %s\n",
48 - devname, name, val ? "TRUE" : "FALSE");
49 + printk(KERN_INFO "via-velocity: set parameter %s to %s\n",
50 + name, val ? "TRUE" : "FALSE");
51 *opt |= (val ? flag : 0);
54 @@ -580,6 +600,7 @@ static void __devinit velocity_set_bool_
55 static void __devinit velocity_get_options(struct velocity_opt *opts, int index, char *devname)
58 + velocity_set_int_opt(&opts->velo_debug, velo_debug[index], VELO_DEBUG_MIN, VELO_DEBUG_MAX, VELO_DEBUG_DEF, "velo_debug", devname);
59 velocity_set_int_opt(&opts->rx_thresh, rx_thresh[index], RX_THRESH_MIN, RX_THRESH_MAX, RX_THRESH_DEF, "rx_thresh", devname);
60 velocity_set_int_opt(&opts->DMA_length, DMA_length[index], DMA_LENGTH_MIN, DMA_LENGTH_MAX, DMA_LENGTH_DEF, "DMA_length", devname);
61 velocity_set_int_opt(&opts->numrx, RxDescriptors[index], RX_DESC_MIN, RX_DESC_MAX, RX_DESC_DEF, "RxDescriptors", devname);
62 @@ -593,6 +614,7 @@ static void __devinit velocity_get_optio
63 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);
64 velocity_set_int_opt((int *) &opts->int_works, int_works[index], INT_WORKS_MIN, INT_WORKS_MAX, INT_WORKS_DEF, "Interrupt service works", devname);
65 opts->numrx = (opts->numrx & ~3);
66 + vdebug = opts->velo_debug;
70 @@ -608,6 +630,8 @@ static void velocity_init_cam_filter(str
71 struct mac_regs __iomem * regs = vptr->mac_regs;
74 + HAIL("velocity_init_cam_filter");
76 /* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */
77 WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, ®s->MCFG);
78 WORD_REG_BITS_ON(MCFG_VIDFR, ®s->MCFG);
79 @@ -636,8 +660,10 @@ static void velocity_init_cam_filter(str
82 mac_set_vlan_cam(regs, 0, (u8 *) &temp);
84 - mac_set_vlan_cam_mask(regs, (u8 *) &temp);
86 + /* mac_set_vlan_cam_mask(regs, (u8 *) &temp); BE */
87 + vptr->vCAMmask[0] |= 1; /* BE */
88 + mac_set_vlan_cam_mask(regs, vptr->vCAMmask); /* BE */
92 @@ -675,13 +701,15 @@ static void velocity_rx_reset(struct vel
93 struct mac_regs __iomem * regs = vptr->mac_regs;
96 + HAIL("velocity_rx_reset");
97 vptr->rd_dirty = vptr->rd_filled = vptr->rd_curr = 0;
100 * Init state, all RD entries belong to the NIC
102 for (i = 0; i < vptr->options.numrx; ++i)
103 - vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC;
104 + /* vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC; BE */
105 + vptr->rd_ring[i].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
107 writew(vptr->options.numrx, ®s->RBRDU);
108 writel(vptr->rd_pool_dma, ®s->RDBaseLo);
109 @@ -704,12 +732,15 @@ static void velocity_init_registers(stru
110 struct mac_regs __iomem * regs = vptr->mac_regs;
113 + if (vdebug&5) printk(KERN_NOTICE "velocity_init_registers: entering\n");
118 case VELOCITY_INIT_RESET:
119 case VELOCITY_INIT_WOL:
121 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: RESET or WOL\n");
122 netif_stop_queue(vptr->dev);
125 @@ -737,12 +768,13 @@ static void velocity_init_registers(stru
127 case VELOCITY_INIT_COLD:
129 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: COLD or default\n");
133 velocity_soft_reset(vptr);
134 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: soft reset complete.\n");
137 mac_eeprom_reload(regs);
138 for (i = 0; i < 6; i++) {
139 writeb(vptr->dev->dev_addr[i], &(regs->PAR[i]));
140 @@ -760,11 +792,16 @@ static void velocity_init_registers(stru
142 BYTE_REG_BITS_SET(CFGB_OFSET, (CFGB_CRANDOM | CFGB_CAP | CFGB_MBA | CFGB_BAKOPT), ®s->CFGB);
144 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Initializing CAM filter\n");
148 + if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: about to init CAM filters\n");
149 + mdelay(5); /* MJW - ARM processors, kernel 2.6.19 - this fixes oopses and hangs */
150 velocity_init_cam_filter(vptr);
151 + if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: init CAM filters complete\n");
153 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Setting packet filter\n");
155 * Set packet filter: Receive directed and broadcast address
157 @@ -774,10 +811,12 @@ static void velocity_init_registers(stru
158 * Enable MII auto-polling
160 enable_mii_autopoll(regs);
161 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: enable_mii_autopoll complete.\n");
163 vptr->int_mask = INT_MASK_DEF;
165 - writel(cpu_to_le32(vptr->rd_pool_dma), ®s->RDBaseLo);
166 + /* writel(cpu_to_le32(vptr->rd_pool_dma), ®s->RDBaseLo); BE */
167 + writel((vptr->rd_pool_dma), ®s->RDBaseLo); /* BE */
168 writew(vptr->options.numrx - 1, ®s->RDCSize);
169 mac_rx_queue_run(regs);
170 mac_rx_queue_wake(regs);
171 @@ -785,10 +824,13 @@ static void velocity_init_registers(stru
172 writew(vptr->options.numtx - 1, ®s->TDCSize);
174 for (i = 0; i < vptr->num_txq; i++) {
175 - writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i]));
176 + /* writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); BE */
177 + writel((vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); /* BE */
178 mac_tx_queue_run(regs, i);
181 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: DMA settings complete.\n");
183 init_flow_control_register(vptr);
185 writel(CR0_STOP, ®s->CR0Clr);
186 @@ -807,8 +849,10 @@ static void velocity_init_registers(stru
188 enable_flow_control_ability(vptr);
189 mac_hw_mibs_init(regs);
190 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Set interrupt mask\n");
191 mac_write_int_mask(vptr->int_mask, regs);
193 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: complete.\n");
197 @@ -826,6 +870,7 @@ static int velocity_soft_reset(struct ve
198 struct mac_regs __iomem * regs = vptr->mac_regs;
201 + HAIL("velocity_soft_reset");
202 writel(CR0_SFRST, ®s->CR0Set);
204 for (i = 0; i < W_MAX_TIMEOUT; i++) {
205 @@ -888,6 +933,7 @@ static int __devinit velocity_found1(str
206 VELOCITY_FULL_DRV_NAM, VELOCITY_VERSION);
207 printk(KERN_INFO "Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n");
208 printk(KERN_INFO "Copyright (c) 2004 Red Hat Inc.\n");
209 + printk(KERN_INFO "BE support, misc. fixes MJW 01Jan2007 - may be unstable\n");
213 @@ -1104,6 +1150,7 @@ static int velocity_init_rings(struct ve
217 + HAIL("velocity_init_rings");
219 * Allocate all RD/TD rings a single pool
221 @@ -1166,6 +1213,7 @@ static int velocity_init_rings(struct ve
222 static void velocity_free_rings(struct velocity_info *vptr)
225 + HAIL("velocity_free_rings");
227 size = vptr->options.numrx * sizeof(struct rx_desc) +
228 vptr->options.numtx * sizeof(struct tx_desc) * vptr->num_txq;
229 @@ -1182,6 +1230,7 @@ static inline void velocity_give_many_rx
230 struct mac_regs __iomem *regs = vptr->mac_regs;
231 int avail, dirty, unusable;
233 + HAIL("velocity_give_many_rx_descs");
235 * RD number must be equal to 4X per hardware spec
236 * (programming guide rev 1.20, p.13)
237 @@ -1195,7 +1244,8 @@ static inline void velocity_give_many_rx
238 dirty = vptr->rd_dirty - unusable;
239 for (avail = vptr->rd_filled & 0xfffc; avail; avail--) {
240 dirty = (dirty > 0) ? dirty - 1 : vptr->options.numrx - 1;
241 - vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC;
242 + /* vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC; BE */
243 + vptr->rd_ring[dirty].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
246 writew(vptr->rd_filled & 0xfffc, ®s->RBRDU);
247 @@ -1205,12 +1255,14 @@ static inline void velocity_give_many_rx
248 static int velocity_rx_refill(struct velocity_info *vptr)
250 int dirty = vptr->rd_dirty, done = 0, ret = 0;
251 + HAIL("velocity_rx_refill");
254 struct rx_desc *rd = vptr->rd_ring + dirty;
256 /* Fine for an all zero Rx desc at init time as well */
257 - if (rd->rdesc0.owner == OWNED_BY_NIC)
258 + /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */
259 + if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
262 if (!vptr->rd_info[dirty].skb) {
263 @@ -1244,6 +1296,7 @@ static int velocity_init_rd_ring(struct
265 int mtu = vptr->dev->mtu;
267 + HAIL("velocity_init_rd_ring");
268 vptr->rx_buf_sz = (mtu <= ETH_DATA_LEN) ? PKT_BUF_SZ : mtu + 32;
270 vptr->rd_info = kcalloc(vptr->options.numrx,
271 @@ -1275,6 +1328,7 @@ static void velocity_free_rd_ring(struct
275 + HAIL("velocity_free_rd_ring");
276 if (vptr->rd_info == NULL)
279 @@ -1314,6 +1368,7 @@ static int velocity_init_td_ring(struct
281 struct velocity_td_info *td_info;
283 + HAIL("velocity_init_td_ring");
284 /* Init the TD ring entries */
285 for (j = 0; j < vptr->num_txq; j++) {
286 curr = vptr->td_pool_dma[j];
287 @@ -1350,6 +1405,7 @@ static void velocity_free_td_ring_entry(
288 struct velocity_td_info * td_info = &(vptr->td_infos[q][n]);
291 + HAIL("velocity_free_td_ring_entry");
295 @@ -1379,6 +1435,7 @@ static void velocity_free_td_ring(struct
299 + HAIL("velocity_free_td_ring");
300 for (j = 0; j < vptr->num_txq; j++) {
301 if (vptr->td_infos[j] == NULL)
303 @@ -1406,34 +1463,42 @@ static int velocity_rx_srv(struct veloci
304 struct net_device_stats *stats = &vptr->stats;
305 int rd_curr = vptr->rd_curr;
309 + HAILS("velocity_rx_srv", status);
311 struct rx_desc *rd = vptr->rd_ring + rd_curr;
313 if (!vptr->rd_info[rd_curr].skb)
316 - if (rd->rdesc0.owner == OWNED_BY_NIC)
317 + /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */
318 + if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
323 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
325 * Don't drop CE or RL error frame although RXOK is off
327 - if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) {
328 + /* if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) { BE */
329 + if ((wRSR & RSR_RXOK) || (!(wRSR & RSR_RXOK) && (wRSR & (RSR_CE | RSR_RL)))) { /* BE */
330 if (velocity_receive_frame(vptr, rd_curr) < 0)
333 - if (rd->rdesc0.RSR & RSR_CRC)
334 + /* if (rd->rdesc0.RSR & RSR_CRC) BE */
335 + if (wRSR & RSR_CRC) /* BE */
336 stats->rx_crc_errors++;
337 - if (rd->rdesc0.RSR & RSR_FAE)
338 + /* if (rd->rdesc0.RSR & RSR_FAE) BE */
339 + if (wRSR & RSR_FAE) /* BE */
340 stats->rx_frame_errors++;
346 + /* rd->inten = 1; BE */
347 + rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */
349 vptr->dev->last_rx = jiffies;
351 @@ -1464,13 +1529,21 @@ static int velocity_rx_srv(struct veloci
353 static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb)
356 + HAIL("velocity_rx_csum");
357 skb->ip_summed = CHECKSUM_NONE;
359 - if (rd->rdesc1.CSM & CSM_IPKT) {
360 - if (rd->rdesc1.CSM & CSM_IPOK) {
361 - if ((rd->rdesc1.CSM & CSM_TCPKT) ||
362 - (rd->rdesc1.CSM & CSM_UDPKT)) {
363 - if (!(rd->rdesc1.CSM & CSM_TUPOK)) {
364 +// if (rd->rdesc1.CSM & CSM_IPKT) {
365 +// if (rd->rdesc1.CSM & CSM_IPOK) {
366 +// if ((rd->rdesc1.CSM & CSM_TCPKT) ||
367 +// (rd->rdesc1.CSM & CSM_UDPKT)) {
368 +// if (!(rd->rdesc1.CSM & CSM_TUPOK)) {
369 + bCSM = (u8)(cpu_to_le32(rd->rdesc1) >> 16); /* BE */
370 + if (bCSM & CSM_IPKT) {
371 + if (bCSM & CSM_IPOK) {
372 + if ((bCSM & CSM_TCPKT) ||
373 + (bCSM & CSM_UDPKT)) {
374 + if (!(bCSM & CSM_TUPOK)) { /* BE */
378 @@ -1496,9 +1569,11 @@ static inline int velocity_rx_copy(struc
382 + HAIL("velocity_rx_copy");
383 if (pkt_size < rx_copybreak) {
384 struct sk_buff *new_skb;
386 + HAIL("velocity_rx_copy (working...)");
387 new_skb = dev_alloc_skb(pkt_size + 2);
389 new_skb->dev = vptr->dev;
390 @@ -1529,10 +1604,12 @@ static inline int velocity_rx_copy(struc
391 static inline void velocity_iph_realign(struct velocity_info *vptr,
392 struct sk_buff *skb, int pkt_size)
394 + HAIL("velocity_iph_realign");
395 /* FIXME - memmove ? */
396 if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
399 + HAIL("velocity_iph_realign (working...)");
400 for (i = pkt_size; i >= 0; i--)
401 *(skb->data + i + 2) = *(skb->data + i);
403 @@ -1551,19 +1628,27 @@ static inline void velocity_iph_realign(
404 static int velocity_receive_frame(struct velocity_info *vptr, int idx)
406 void (*pci_action)(struct pci_dev *, dma_addr_t, size_t, int);
407 + u16 pkt_len; /* BE */
409 + struct sk_buff *skb;
410 struct net_device_stats *stats = &vptr->stats;
411 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
412 struct rx_desc *rd = &(vptr->rd_ring[idx]);
413 - int pkt_len = rd->rdesc0.len;
414 - struct sk_buff *skb;
415 + /* int pkt_len = rd->rdesc0.len BE */;
417 + pkt_len = ((cpu_to_le32(rd->rdesc0) >> 16) & 0x00003FFFUL); /* BE */
418 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
420 - if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) {
421 + HAIL("velocity_receive_frame");
422 + /* if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) { BE */
423 + if (wRSR & (RSR_STP | RSR_EDP)) { /* BE */
424 VELOCITY_PRT(MSG_LEVEL_VERBOSE, KERN_ERR " %s : the received frame span multple RDs.\n", vptr->dev->name);
425 stats->rx_length_errors++;
429 - if (rd->rdesc0.RSR & RSR_MAR)
430 + /* if (rd->rdesc0.RSR & RSR_MAR) BE */
431 + if (wRSR & RSR_MAR) /* BE */
432 vptr->stats.multicast++;
435 @@ -1576,7 +1661,8 @@ static int velocity_receive_frame(struct
438 if (vptr->flags & VELOCITY_FLAGS_VAL_PKT_LEN) {
439 - if (rd->rdesc0.RSR & RSR_RL) {
440 + /* if (rd->rdesc0.RSR & RSR_RL) { BE */
441 + if (wRSR & RSR_RL) { /* BE */
442 stats->rx_length_errors++;
445 @@ -1620,6 +1706,7 @@ static int velocity_alloc_rx_buf(struct
446 struct rx_desc *rd = &(vptr->rd_ring[idx]);
447 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
449 + HAIL("velocity_alloc_rx_buf");
450 rd_info->skb = dev_alloc_skb(vptr->rx_buf_sz + 64);
451 if (rd_info->skb == NULL)
453 @@ -1637,10 +1724,14 @@ static int velocity_alloc_rx_buf(struct
456 *((u32 *) & (rd->rdesc0)) = 0;
457 - rd->len = cpu_to_le32(vptr->rx_buf_sz);
459 + /* rd->len = cpu_to_le32(vptr->rx_buf_sz); BE */
460 + /* rd->inten = 1; BE */
461 rd->pa_low = cpu_to_le32(rd_info->skb_dma);
463 + /* rd->pa_high = 0; BE */
464 + rd->ltwo &= cpu_to_le32(0xC000FFFFUL); /* BE */
465 + rd->ltwo |= cpu_to_le32((vptr->rx_buf_sz << 16)); /* BE */
466 + rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */
467 + rd->ltwo &= cpu_to_le32(0xFFFF0000UL); /* BE */
471 @@ -1661,9 +1752,11 @@ static int velocity_tx_srv(struct veloci
476 struct velocity_td_info *tdinfo;
477 struct net_device_stats *stats = &vptr->stats;
479 + HAILS("velocity_tx_srv", status);
480 for (qnum = 0; qnum < vptr->num_txq; qnum++) {
481 for (idx = vptr->td_tail[qnum]; vptr->td_used[qnum] > 0;
482 idx = (idx + 1) % vptr->options.numtx) {
483 @@ -1674,22 +1767,29 @@ static int velocity_tx_srv(struct veloci
484 td = &(vptr->td_rings[qnum][idx]);
485 tdinfo = &(vptr->td_infos[qnum][idx]);
487 - if (td->tdesc0.owner == OWNED_BY_NIC)
488 + /* if (td->tdesc0.owner == OWNED_BY_NIC) BE */
489 + if (td->tdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */
495 - if (td->tdesc0.TSR & TSR0_TERR) {
496 + wTSR = (u16)cpu_to_le32(td->tdesc0);
497 + /* if (td->tdesc0.TSR & TSR0_TERR) { BE */
498 + if (wTSR & TSR0_TERR) { /* BE */
501 - if (td->tdesc0.TSR & TSR0_CDH)
502 + /* if (td->tdesc0.TSR & TSR0_CDH) BE */
503 + if (wTSR & TSR0_CDH) /* BE */
504 stats->tx_heartbeat_errors++;
505 - if (td->tdesc0.TSR & TSR0_CRS)
506 + /* if (td->tdesc0.TSR & TSR0_CRS) BE */
507 + if (wTSR & TSR0_CRS) /* BE */
508 stats->tx_carrier_errors++;
509 - if (td->tdesc0.TSR & TSR0_ABT)
510 + /* if (td->tdesc0.TSR & TSR0_ABT) BE */
511 + if (wTSR & TSR0_ABT) /* BE */
512 stats->tx_aborted_errors++;
513 - if (td->tdesc0.TSR & TSR0_OWC)
514 + /* if (td->tdesc0.TSR & TSR0_OWC) BE */
515 + if (wTSR & TSR0_OWC) /* BE */
516 stats->tx_window_errors++;
519 @@ -1778,6 +1878,7 @@ static void velocity_print_link_status(s
521 static void velocity_error(struct velocity_info *vptr, int status)
523 + HAILS("velocity_error", status);
525 if (status & ISR_TXSTLI) {
526 struct mac_regs __iomem * regs = vptr->mac_regs;
527 @@ -1867,6 +1968,7 @@ static void velocity_free_tx_buf(struct
528 struct sk_buff *skb = tdinfo->skb;
531 + HAIL("velocity_free_tx_buf");
533 * Don't unmap the pre-allocated tx_bufs
535 @@ -2067,6 +2169,7 @@ static int velocity_xmit(struct sk_buff
536 struct velocity_td_info *tdinfo;
539 + u32 lbufsz; /* BE */
541 int pktlen = skb->len;
543 @@ -2083,9 +2186,18 @@ static int velocity_xmit(struct sk_buff
544 td_ptr = &(vptr->td_rings[qnum][index]);
545 tdinfo = &(vptr->td_infos[qnum][index]);
547 - td_ptr->tdesc1.TCPLS = TCPLS_NORMAL;
548 - td_ptr->tdesc1.TCR = TCR0_TIC;
549 - td_ptr->td_buf[0].queue = 0;
550 + td_ptr->tdesc0 = 0x00000000UL; /* BE */
551 + td_ptr->tdesc1 = 0x00000000UL; /* BE */
553 + /* td_ptr->tdesc1.TCPLS = TCPLS_NORMAL; BE */
554 + td_ptr->tdesc1 &= cpu_to_le32(0xfcffffffUL); /* BE */
555 + td_ptr->tdesc1 |= cpu_to_le32(((u32)TCPLS_NORMAL) << 24); /* BE */
557 + /* td_ptr->tdesc1.TCR = TCR0_TIC; BE */
558 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TIC); /* BE */
560 + /* td_ptr->td_buf[0].queue = 0; BE */
561 + td_ptr->td_buf[0].ltwo &= cpu_to_le32(~BE_QUEUE_ENABLE); /* BE */
565 @@ -2097,20 +2209,36 @@ static int velocity_xmit(struct sk_buff
566 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len);
568 tdinfo->skb_dma[0] = tdinfo->buf_dma;
569 - td_ptr->tdesc0.pktsize = pktlen;
570 + /* td_ptr->tdesc0.pktsize = pktlen; */
571 + td_ptr->tdesc0 &= cpu_to_le32(0xc000ffffUL); /* BE */
572 + lbufsz = pktlen; /* Assign, and make sure it's unsigned 32 bits - BE */
573 + lbufsz = lbufsz << 16; /* BE - shift over */
574 + td_ptr->tdesc0 |= cpu_to_le32(lbufsz); /* BE */
576 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
577 - td_ptr->td_buf[0].pa_high = 0;
578 - td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;
579 + /* td_ptr->td_buf[0].pa_high = 0; */
580 + /* td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; */
581 + td_ptr->td_buf[0].ltwo = cpu_to_le32(lbufsz); /* BE */
582 tdinfo->nskb_dma = 1;
583 - td_ptr->tdesc1.CMDZ = 2;
584 + /* td_ptr->tdesc1.CMDZ = 2; */
585 + td_ptr->tdesc1 &= cpu_to_le32(0x0fffffffUL); /* BE */
586 + td_ptr->tdesc1 |= cpu_to_le32(((u32)0x2) << 28); /* BE */
588 #ifdef VELOCITY_ZERO_COPY_SUPPORT
590 + * BE - NOTE on the VELOCITY_ZERO_COPY_SUPPORT:
591 + * This block of code has NOT been patched up for BE support, as
592 + * it is certainly broken -- if it compiles at all. Since the BE
593 + * fixes depend on the broken code, attempts to convert to BE support
594 + * would almost certainly confuse more than help.
596 if (skb_shinfo(skb)->nr_frags > 0) {
597 int nfrags = skb_shinfo(skb)->nr_frags;
600 skb_copy_from_linear_data(skb, tdinfo->buf, skb->len);
601 tdinfo->skb_dma[0] = tdinfo->buf_dma;
602 + /* BE: Er, exactly what value are we assigning in this next line? */
603 td_ptr->tdesc0.pktsize =
604 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
605 td_ptr->td_buf[0].pa_high = 0;
606 @@ -2127,6 +2255,7 @@ static int velocity_xmit(struct sk_buff
607 /* FIXME: support 48bit DMA later */
608 td_ptr->td_buf[i].pa_low = cpu_to_le32(tdinfo->skb_dma);
609 td_ptr->td_buf[i].pa_high = 0;
610 + /* BE: This next line can't be right: */
611 td_ptr->td_buf[i].bufsize = skb->len->skb->data_len;
613 for (i = 0; i < nfrags; i++) {
614 @@ -2144,7 +2273,7 @@ static int velocity_xmit(struct sk_buff
619 +#endif /* (broken) VELOCITY_ZERO_COPY_SUPPORT */
622 * Map the linear network buffer into PCI space and
623 @@ -2152,19 +2281,29 @@ static int velocity_xmit(struct sk_buff
626 tdinfo->skb_dma[0] = pci_map_single(vptr->pdev, skb->data, pktlen, PCI_DMA_TODEVICE);
627 - td_ptr->tdesc0.pktsize = pktlen;
628 + /* td_ptr->tdesc0.pktsize = pktlen; BE */
629 + td_ptr->tdesc0 &= cpu_to_le32(0xc000ffffUL); /* BE */
630 + lbufsz = pktlen; /* Assign, and make sure it's unsigned 32 bits - BE */
631 + lbufsz = lbufsz << 16; /* BE */
632 + td_ptr->tdesc0 |= cpu_to_le32(lbufsz); /* BE */
633 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
634 - td_ptr->td_buf[0].pa_high = 0;
635 - td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;
636 + /* td_ptr->td_buf[0].pa_high = 0; BE */
637 + /* td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; BE */
638 + td_ptr->td_buf[0].ltwo = cpu_to_le32(lbufsz); /* BE */
639 tdinfo->nskb_dma = 1;
640 - td_ptr->tdesc1.CMDZ = 2;
641 + /* td_ptr->tdesc1.CMDZ = 2; BE */
642 + td_ptr->tdesc1 &= cpu_to_le32(0x0fffffffUL); /* BE */
643 + td_ptr->tdesc1 |= cpu_to_le32(((u32)0x2) << 28); /* BE */
646 if (vptr->vlgrp && vlan_tx_tag_present(skb)) {
647 - td_ptr->tdesc1.pqinf.VID = vlan_tx_tag_get(skb);
648 - td_ptr->tdesc1.pqinf.priority = 0;
649 - td_ptr->tdesc1.pqinf.CFI = 0;
650 - td_ptr->tdesc1.TCR |= TCR0_VETAG;
651 + /* td_ptr->tdesc1.pqinf.VID = vlan_tx_tag_get(skb); BE */
652 + /* td_ptr->tdesc1.pqinf.priority = 0; BE */
653 + /* td_ptr->tdesc1.pqinf.CFI = 0; BE */
654 + /* td_ptr->tdesc1.TCR |= TCR0_VETAG; BE */
655 + td_ptr->tdesc1 &= cpu_to_le32(0xFFFF0000UL); /* BE */
656 + td_ptr->tdesc1 |= cpu_to_le32(vlan_tx_tag_get(skb)); /* BE */
657 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_VETAG); /* BE */
661 @@ -2174,26 +2313,34 @@ static int velocity_xmit(struct sk_buff
662 && (skb->ip_summed == CHECKSUM_PARTIAL)) {
663 const struct iphdr *ip = ip_hdr(skb);
664 if (ip->protocol == IPPROTO_TCP)
665 - td_ptr->tdesc1.TCR |= TCR0_TCPCK;
666 + /* td_ptr->tdesc1.TCR |= TCR0_TCPCK; BE */
667 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TCPCK); /* BE */
668 else if (ip->protocol == IPPROTO_UDP)
669 - td_ptr->tdesc1.TCR |= (TCR0_UDPCK);
670 - td_ptr->tdesc1.TCR |= TCR0_IPCK;
672 + /* td_ptr->tdesc1.TCR |= (TCR0_UDPCK); BE */
673 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_UDPCK); /* BE */
674 + /* td_ptr->tdesc1.TCR |= TCR0_IPCK; BE */
675 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_IPCK); /* BE */
679 int prev = index - 1;
682 prev = vptr->options.numtx - 1;
683 - td_ptr->tdesc0.owner = OWNED_BY_NIC;
684 + /* td_ptr->tdesc0.owner = OWNED_BY_NIC; BE */
685 + td_ptr->tdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */
686 vptr->td_used[qnum]++;
687 vptr->td_curr[qnum] = (index + 1) % vptr->options.numtx;
689 if (AVAIL_TD(vptr, qnum) < 1)
690 netif_stop_queue(dev);
692 - td_ptr = &(vptr->td_rings[qnum][prev]);
693 - td_ptr->td_buf[0].queue = 1;
694 + td_ptr = &(vptr->td_rings[qnum][prev]);
695 + /* td_ptr->td_buf[0].queue = 1; BE */
696 + td_ptr->td_buf[0].ltwo |= cpu_to_le32(BE_QUEUE_ENABLE); /* BE */
697 + if (vdebug&2) printk(KERN_NOTICE "velocity_xmit: (%s) len=%d idx=%d tdesc0=0x%x tdesc1=0x%x ltwo=0x%x\n",
698 + (pktlen<ETH_ZLEN) ? "short" : "normal", pktlen, index,
699 + td_ptr->tdesc0, td_ptr->tdesc1, td_ptr->td_buf[0].ltwo);
700 mac_tx_queue_wake(vptr->mac_regs, qnum);
702 dev->trans_start = jiffies;
703 @@ -2219,7 +2366,7 @@ static int velocity_intr(int irq, void *
708 + HAIL("velocity_intr");
709 spin_lock(&vptr->lock);
710 isr_status = mac_read_isr(vptr->mac_regs);
712 @@ -2238,7 +2385,10 @@ static int velocity_intr(int irq, void *
714 while (isr_status != 0) {
715 mac_write_isr(vptr->mac_regs, isr_status);
716 - if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI)))
717 + HAILS("velocity_intr",isr_status);
718 + /* MJW - velocity_error is ALWAYS called; need to mask off some other flags */
719 + /* if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI))) */
720 + if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI | ISR_PTX0I | ISR_ISR0)))
721 velocity_error(vptr, isr_status);
722 if (isr_status & (ISR_PRXI | ISR_PPRXI))
723 max_count += velocity_rx_srv(vptr, isr_status);
724 @@ -2276,6 +2426,7 @@ static void velocity_set_multi(struct ne
726 struct dev_mc_list *mclist;
728 + HAIL("velocity_set_multi");
729 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
730 writel(0xffffffff, ®s->MARCAM[0]);
731 writel(0xffffffff, ®s->MARCAM[4]);
732 @@ -2319,6 +2470,7 @@ static struct net_device_stats *velocity
734 struct velocity_info *vptr = netdev_priv(dev);
736 + HAIL("net_device_stats");
737 /* If the hardware is down, don't touch MII */
738 if(!netif_running(dev))
740 @@ -2363,6 +2515,7 @@ static int velocity_ioctl(struct net_dev
741 struct velocity_info *vptr = netdev_priv(dev);
744 + HAIL("velocity_ioctl");
745 /* If we are asked for information and the device is power
746 saving then we need to bring the device back up to talk to it */
748 @@ -2581,6 +2734,8 @@ static int velocity_mii_read(struct mac_
752 + HAIL("velocity_mii_read");
753 + HAIL("velocity_mii_write");
755 * Disable MIICR_MAUTO, so that mii addr can be set normally
757 Index: linux-2.6.24.7/drivers/net/via-velocity.h
758 ===================================================================
759 --- linux-2.6.24.7.orig/drivers/net/via-velocity.h
760 +++ linux-2.6.24.7/drivers/net/via-velocity.h
761 @@ -196,64 +196,70 @@
766 - u16 RSR; /* Receive status */
767 - u16 len:14; /* Received packet length */
769 - u16 owner:1; /* Who owns this buffer ? */
778 +// u16 RSR; /* Receive status */
779 +// u16 len:14; /* Received packet length */
781 +// u16 owner:1; /* Who owns this buffer ? */
791 - struct rdesc0 rdesc0;
792 - struct rdesc1 rdesc1;
793 +// struct rdesc0 rdesc0;
794 +// struct rdesc1 rdesc1;
797 u32 pa_low; /* Low 32 bit PCI address */
798 - u16 pa_high; /* Next 16 bit PCI address (48 total) */
799 - u16 len:15; /* Frame size */
800 - u16 inten:1; /* Enable interrupt */
801 +// u16 pa_high; /* Next 16 bit PCI address (48 total) */
802 +// u16 len:15; /* Frame size */
803 +// u16 inten:1; /* Enable interrupt */
805 } __attribute__ ((__packed__));
808 * Transmit descriptor
812 - u16 TSR; /* Transmit status register */
813 - u16 pktsize:14; /* Size of frame */
815 - u16 owner:1; /* Who owns the buffer */
818 -struct pqinf { /* Priority queue info */
822 -} __attribute__ ((__packed__));
825 - struct pqinf pqinf;
830 -} __attribute__ ((__packed__));
832 +// u16 TSR; /* Transmit status register */
833 +// u16 pktsize:14; /* Size of frame */
835 +// u16 owner:1; /* Who owns the buffer */
838 +//struct pqinf { /* Priority queue info */
842 +//} __attribute__ ((__packed__));
845 +// struct pqinf pqinf;
850 +//} __attribute__ ((__packed__));
863 } __attribute__ ((__packed__));
866 - struct tdesc0 tdesc0;
867 - struct tdesc1 tdesc1;
868 +// struct tdesc0 tdesc0;
869 +// struct tdesc1 tdesc1;
872 struct td_buf td_buf[7];
875 @@ -279,6 +285,16 @@ enum velocity_owner {
879 +/* Constants added for the BE fixes */
880 +#define BE_OWNED_BY_NIC 0x80000000UL
881 +#define BE_INT_ENABLE 0x80000000UL
882 +#define BE_QUEUE_ENABLE 0x80000000UL
883 +#define BE_TCR_TIC 0x00800000UL
884 +#define BE_TCR_VETAG 0x00200000UL
885 +#define BE_TCR_TCPCK 0x00040000UL
886 +#define BE_TCR_UDPCK 0x00080000UL
887 +#define BE_TCR_IPCK 0x00100000UL
891 * MAC registers and macros.
892 @@ -1512,6 +1528,7 @@ enum velocity_flow_cntl_type {
895 struct velocity_opt {
896 + int velo_debug; /* debug flag */
897 int numrx; /* Number of RX descriptors */
898 int numtx; /* Number of TX descriptors */
899 enum speed_opt spd_dpx; /* Media link mode */