bump to 2.6.23.12
[openwrt.git] / target / linux / ixp4xx / patches-2.6.23 / 012-velocity_BE.patch
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
5 MODULE_LICENSE("GPL");
6 MODULE_DESCRIPTION("VIA Networking Velocity Family Gigabit Ethernet Adapter Driver");
7
8 +/* Valid values for vdebug (additive, this is a bitmask):
9 + * 0x00 => off
10 + * 0x01 => always on
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
14 + */
15 +static int vdebug = 0;
16 +
17 +/* HAIL - these macros are for the normal 0x01-type tracing... */
18 +#define HAIL(S) \
19 + if (vdebug&1) printk(KERN_NOTICE "%s\n", (S));
20 +#define HAILS(S,T) \
21 + if (vdebug&1) printk(KERN_NOTICE "%s -> status=0x%x\n", (S), (T));
22 +
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);
27
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");
32 +
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
37 if (val == -1)
38 *opt = def;
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",
43 + name, min, max);
44 *opt = def;
45 } else {
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",
49 + name, val);
50 *opt = val;
51 }
52 }
53 @@ -415,12 +435,12 @@ static void __devinit velocity_set_bool_
54 if (val == -1)
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",
58 - devname, name);
59 + printk(KERN_NOTICE "via-velocity: the value of parameter %s is invalid, the valid range is (0-1)\n",
60 + name);
61 *opt |= (def ? flag : 0);
62 } else {
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);
68 }
69 }
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)
72 {
73
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;
83 }
84
85 /**
86 @@ -466,6 +488,8 @@ static void velocity_init_cam_filter(str
87 {
88 struct mac_regs __iomem * regs = vptr->mac_regs;
89
90 + HAIL("velocity_init_cam_filter");
91 +
92 /* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */
93 WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, &regs->MCFG);
94 WORD_REG_BITS_ON(MCFG_VIDFR, &regs->MCFG);
95 @@ -484,14 +508,12 @@ static void velocity_init_cam_filter(str
96 WORD_REG_BITS_ON(MCFG_RTGOPT, &regs->MCFG);
97
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);
101 } else {
102 u16 temp = 0;
103 mac_set_cam(regs, 0, (u8 *) &temp, VELOCITY_VLAN_ID_CAM);
104 - temp = 1;
105 - mac_set_cam_mask(regs, (u8 *) &temp, VELOCITY_VLAN_ID_CAM);
106 }
107 + vptr->vCAMmask[0] |= 1;
108 + mac_set_cam_mask(regs, vptr->vCAMmask, VELOCITY_VLAN_ID_CAM);
109 }
110
111 /**
112 @@ -508,13 +530,15 @@ static void velocity_rx_reset(struct vel
113 struct mac_regs __iomem * regs = vptr->mac_regs;
114 int i;
115
116 + HAIL("velocity_rx_reset");
117 vptr->rd_dirty = vptr->rd_filled = vptr->rd_curr = 0;
118
119 /*
120 * Init state, all RD entries belong to the NIC
121 */
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 */
126
127 writew(vptr->options.numrx, &regs->RBRDU);
128 writel(vptr->rd_pool_dma, &regs->RDBaseLo);
129 @@ -537,12 +561,15 @@ static void velocity_init_registers(stru
130 struct mac_regs __iomem * regs = vptr->mac_regs;
131 int i, mii_status;
132
133 + if (vdebug&5) printk(KERN_NOTICE "velocity_init_registers: entering\n");
134 +
135 mac_wol_reset(regs);
136
137 switch (type) {
138 case VELOCITY_INIT_RESET:
139 case VELOCITY_INIT_WOL:
140
141 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: RESET or WOL\n");
142 netif_stop_queue(vptr->dev);
143
144 /*
145 @@ -570,12 +597,13 @@ static void velocity_init_registers(stru
146
147 case VELOCITY_INIT_COLD:
148 default:
149 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: COLD or default\n");
150 /*
151 * Do reset
152 */
153 velocity_soft_reset(vptr);
154 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: soft reset complete.\n");
155 mdelay(5);
156 -
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
161 */
162 BYTE_REG_BITS_SET(CFGB_OFSET, (CFGB_CRANDOM | CFGB_CAP | CFGB_MBA | CFGB_BAKOPT), &regs->CFGB);
163
164 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Initializing CAM filter\n");
165 /*
166 * Init CAM filter
167 */
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");
172
173 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Setting packet filter\n");
174 /*
175 * Set packet filter: Receive directed and broadcast address
176 */
177 @@ -607,10 +640,12 @@ static void velocity_init_registers(stru
178 * Enable MII auto-polling
179 */
180 enable_mii_autopoll(regs);
181 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: enable_mii_autopoll complete.\n");
182
183 vptr->int_mask = INT_MASK_DEF;
184
185 - writel(cpu_to_le32(vptr->rd_pool_dma), &regs->RDBaseLo);
186 + /* writel(cpu_to_le32(vptr->rd_pool_dma), &regs->RDBaseLo); BE */
187 + writel((vptr->rd_pool_dma), &regs->RDBaseLo); /* BE */
188 writew(vptr->options.numrx - 1, &regs->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, &regs->TDCSize);
193
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);
199 }
200
201 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: DMA settings complete.\n");
202 +
203 init_flow_control_register(vptr);
204
205 writel(CR0_STOP, &regs->CR0Clr);
206 @@ -640,8 +678,10 @@ static void velocity_init_registers(stru
207
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);
212 mac_clear_isr(regs);
213 + if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: complete.\n");
214
215 }
216 }
217 @@ -659,6 +699,7 @@ static int velocity_soft_reset(struct ve
218 struct mac_regs __iomem * regs = vptr->mac_regs;
219 int i = 0;
220
221 + HAIL("velocity_soft_reset");
222 writel(CR0_SFRST, &regs->CR0Set);
223
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");
230 first = 0;
231 }
232
233 @@ -934,6 +976,7 @@ static int velocity_init_rings(struct ve
234 dma_addr_t pool_dma;
235 u8 *pool;
236
237 + HAIL("velocity_init_rings");
238 /*
239 * Allocate all RD/TD rings a single pool
240 */
241 @@ -996,6 +1039,7 @@ static int velocity_init_rings(struct ve
242 static void velocity_free_rings(struct velocity_info *vptr)
243 {
244 int size;
245 + HAIL("velocity_free_rings");
246
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;
252
253 + HAIL("velocity_give_many_rx_descs");
254 /*
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 */
264 }
265
266 writew(vptr->rd_filled & 0xfffc, &regs->RBRDU);
267 @@ -1035,12 +1081,14 @@ static inline void velocity_give_many_rx
268 static int velocity_rx_refill(struct velocity_info *vptr)
269 {
270 int dirty = vptr->rd_dirty, done = 0, ret = 0;
271 + HAIL("velocity_rx_refill");
272
273 do {
274 struct rx_desc *rd = vptr->rd_ring + dirty;
275
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 */
280 break;
281
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) *
285 vptr->options.numrx;
286
287 + HAIL("velocity_init_rd_ring");
288 vptr->rd_info = kmalloc(rsize, GFP_KERNEL);
289 if(vptr->rd_info == NULL)
290 goto out;
291 @@ -1104,6 +1153,7 @@ static void velocity_free_rd_ring(struct
292 {
293 int i;
294
295 + HAIL("velocity_free_rd_ring");
296 if (vptr->rd_info == NULL)
297 return;
298
299 @@ -1145,6 +1195,7 @@ static int velocity_init_td_ring(struct
300 unsigned int tsize = sizeof(struct velocity_td_info) *
301 vptr->options.numtx;
302
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]);
309 int i;
310
311 + HAIL("velocity_free_td_ring_entry");
312 if (td_info == NULL)
313 return;
314
315 @@ -1210,6 +1262,7 @@ static void velocity_free_td_ring(struct
316 {
317 int i, j;
318
319 + HAIL("velocity_free_td_ring");
320 for (j = 0; j < vptr->num_txq; j++) {
321 if (vptr->td_infos[j] == NULL)
322 continue;
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;
326 int works = 0;
327 + u16 wRSR; /* BE */
328
329 + HAILS("velocity_rx_srv", status);
330 do {
331 struct rx_desc *rd = vptr->rd_ring + rd_curr;
332
333 if (!vptr->rd_info[rd_curr].skb)
334 break;
335
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 */
339 break;
340
341 rmb();
342
343 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
344 /*
345 * Don't drop CE or RL error frame although RXOK is off
346 */
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)
351 stats->rx_dropped++;
352 } else {
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++;
361
362 stats->rx_dropped++;
363 }
364
365 - rd->inten = 1;
366 + /* rd->inten = 1; BE */
367 + rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */
368
369 vptr->dev->last_rx = jiffies;
370
371 @@ -1295,13 +1356,21 @@ static int velocity_rx_srv(struct veloci
372
373 static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb)
374 {
375 + u8 bCSM;
376 + HAIL("velocity_rx_csum");
377 skb->ip_summed = CHECKSUM_NONE;
378
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 */
395 return;
396 }
397 }
398 @@ -1327,9 +1396,11 @@ static inline int velocity_rx_copy(struc
399 {
400 int ret = -1;
401
402 + HAIL("velocity_rx_copy");
403 if (pkt_size < rx_copybreak) {
404 struct sk_buff *new_skb;
405
406 + HAIL("velocity_rx_copy (working...)");
407 new_skb = dev_alloc_skb(pkt_size + 2);
408 if (new_skb) {
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)
413 {
414 + HAIL("velocity_iph_realign");
415 /* FIXME - memmove ? */
416 if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
417 int i;
418
419 + HAIL("velocity_iph_realign (working...)");
420 for (i = pkt_size; i >= 0; i--)
421 *(skb->data + i + 2) = *(skb->data + i);
422 skb_reserve(skb, 2);
423 @@ -1382,19 +1455,27 @@ static inline void velocity_iph_realign(
424 static int velocity_receive_frame(struct velocity_info *vptr, int idx)
425 {
426 void (*pci_action)(struct pci_dev *, dma_addr_t, size_t, int);
427 + u16 pkt_len; /* BE */
428 + u16 wRSR; /* 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 */;
436 +
437 + pkt_len = ((cpu_to_le32(rd->rdesc0) >> 16) & 0x00003FFFUL); /* BE */
438 + wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */
439
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++;
446 return -EINVAL;
447 }
448
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++;
453
454 skb = rd_info->skb;
455 @@ -1407,7 +1488,8 @@ static int velocity_receive_frame(struct
456 */
457
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++;
463 return -EINVAL;
464 }
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]);
468
469 + HAIL("velocity_alloc_rx_buf");
470 rd_info->skb = dev_alloc_skb(vptr->rx_buf_sz + 64);
471 if (rd_info->skb == NULL)
472 return -ENOMEM;
473 @@ -1468,10 +1551,14 @@ static int velocity_alloc_rx_buf(struct
474 */
475
476 *((u32 *) & (rd->rdesc0)) = 0;
477 - rd->len = cpu_to_le32(vptr->rx_buf_sz);
478 - rd->inten = 1;
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);
482 - rd->pa_high = 0;
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 */
488 return 0;
489 }
490
491 @@ -1492,9 +1579,11 @@ static int velocity_tx_srv(struct veloci
492 int full = 0;
493 int idx;
494 int works = 0;
495 + u16 wTSR; /* BE */
496 struct velocity_td_info *tdinfo;
497 struct net_device_stats *stats = &vptr->stats;
498
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]);
506
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 */
510 break;
511
512 if ((works++ > 15))
513 break;
514
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 */
519 stats->tx_errors++;
520 stats->tx_dropped++;
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++;
537 } else {
538 stats->tx_packets++;
539 @@ -1609,6 +1705,7 @@ static void velocity_print_link_status(s
540
541 static void velocity_error(struct velocity_info *vptr, int status)
542 {
543 + HAILS("velocity_error", status);
544
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;
549 int i;
550
551 + HAIL("velocity_free_tx_buf");
552 /*
553 * Don't unmap the pre-allocated tx_bufs
554 */
555 @@ -1901,6 +1999,7 @@ static int velocity_xmit(struct sk_buff
556 struct velocity_td_info *tdinfo;
557 unsigned long flags;
558 int index;
559 + u32 lbufsz; /* BE */
560
561 int pktlen = skb->len;
562
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]);
566
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 */
572 +
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 */
576 +
577 + /* td_ptr->tdesc1.TCR = TCR0_TIC; BE */
578 + td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TIC); /* BE */
579 +
580 + /* td_ptr->td_buf[0].queue = 0; BE */
581 + td_ptr->td_buf[0].ltwo &= cpu_to_le32(~BE_QUEUE_ENABLE); /* BE */
582
583 /*
584 * Pad short frames.
585 @@ -1931,20 +2039,36 @@ static int velocity_xmit(struct sk_buff
586 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len);
587 tdinfo->skb = skb;
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 */
595 +
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 */
607 } else
608 #ifdef VELOCITY_ZERO_COPY_SUPPORT
609 + /*
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.
615 + */
616 if (skb_shinfo(skb)->nr_frags > 0) {
617 int nfrags = skb_shinfo(skb)->nr_frags;
618 tdinfo->skb = skb;
619 if (nfrags > 6) {
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;
632
633 for (i = 0; i < nfrags; i++) {
634 @@ -1978,7 +2103,7 @@ static int velocity_xmit(struct sk_buff
635 }
636
637 } else
638 -#endif
639 +#endif /* (broken) VELOCITY_ZERO_COPY_SUPPORT */
640 {
641 /*
642 * Map the linear network buffer into PCI space and
643 @@ -1986,19 +2111,30 @@ static int velocity_xmit(struct sk_buff
644 */
645 tdinfo->skb = skb;
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 */
659 +
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 */
665 }
666
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 */
679 }
680
681 /*
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;
692 - }
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 */
697 + }
698 {
699
700 int prev = index - 1;
701
702 if (prev < 0)
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;
709
710 if (AVAIL_TD(vptr, qnum) < 1)
711 netif_stop_queue(dev);
712
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);
722 }
723 dev->trans_start = jiffies;
724 @@ -2053,7 +2197,7 @@ static int velocity_intr(int irq, void *
725 u32 isr_status;
726 int max_count = 0;
727
728 -
729 + HAIL("velocity_intr");
730 spin_lock(&vptr->lock);
731 isr_status = mac_read_isr(vptr->mac_regs);
732
733 @@ -2072,7 +2216,10 @@ static int velocity_intr(int irq, void *
734
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
746 int i;
747 struct dev_mc_list *mclist;
748
749 + HAIL("velocity_set_multi");
750 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
751 writel(0xffffffff, &regs->MARCAM[0]);
752 writel(0xffffffff, &regs->MARCAM[4]);
753 @@ -2153,6 +2301,7 @@ static struct net_device_stats *velocity
754 {
755 struct velocity_info *vptr = netdev_priv(dev);
756
757 + HAIL("net_device_stats");
758 /* If the hardware is down, don't touch MII */
759 if(!netif_running(dev))
760 return &vptr->stats;
761 @@ -2197,6 +2346,7 @@ static int velocity_ioctl(struct net_dev
762 struct velocity_info *vptr = netdev_priv(dev);
763 int ret;
764
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 */
768
769 @@ -2415,6 +2565,7 @@ static int velocity_mii_read(struct mac_
770 {
771 u16 ww;
772
773 + HAIL("velocity_mii_read");
774 /*
775 * Disable MIICR_MAUTO, so that mii addr can be set normally
776 */
777 @@ -2451,6 +2602,7 @@ static int velocity_mii_write(struct mac
778 {
779 u16 ww;
780
781 + HAIL("velocity_mii_write");
782 /*
783 * Disable MIICR_MAUTO, so that mii addr can be set normally
784 */
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 @@
789 * Receive descriptor
790 */
791
792 -struct rdesc0 {
793 - u16 RSR; /* Receive status */
794 - u16 len:14; /* Received packet length */
795 - u16 reserved:1;
796 - u16 owner:1; /* Who owns this buffer ? */
797 -};
798 -
799 -struct rdesc1 {
800 - u16 PQTAG;
801 - u8 CSM;
802 - u8 IPKT;
803 -};
804 +//struct rdesc0 {
805 +// u16 RSR; /* Receive status */
806 +// u16 len:14; /* Received packet length */
807 +// u16 reserved:1;
808 +// u16 owner:1; /* Who owns this buffer ? */
809 +//};
810 +
811 +//struct rdesc1 {
812 +// u16 PQTAG;
813 +// u8 CSM;
814 +// u8 IPKT;
815 +//};
816
817 struct rx_desc {
818 - struct rdesc0 rdesc0;
819 - struct rdesc1 rdesc1;
820 +// struct rdesc0 rdesc0;
821 +// struct rdesc1 rdesc1;
822 + u32 rdesc0;
823 + u32 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 */
831 + u32 ltwo;
832 } __attribute__ ((__packed__));
833
834 /*
835 * Transmit descriptor
836 */
837
838 -struct tdesc0 {
839 - u16 TSR; /* Transmit status register */
840 - u16 pktsize:14; /* Size of frame */
841 - u16 reserved:1;
842 - u16 owner:1; /* Who owns the buffer */
843 -};
844 -
845 -struct pqinf { /* Priority queue info */
846 - u16 VID:12;
847 - u16 CFI:1;
848 - u16 priority:3;
849 -} __attribute__ ((__packed__));
850 -
851 -struct tdesc1 {
852 - struct pqinf pqinf;
853 - u8 TCR;
854 - u8 TCPLS:2;
855 - u8 reserved:2;
856 - u8 CMDZ:4;
857 -} __attribute__ ((__packed__));
858 +//struct tdesc0 {
859 +// u16 TSR; /* Transmit status register */
860 +// u16 pktsize:14; /* Size of frame */
861 +// u16 reserved:1;
862 +// u16 owner:1; /* Who owns the buffer */
863 +//};
864 +
865 +//struct pqinf { /* Priority queue info */
866 +// u16 VID:12;
867 +// u16 CFI:1;
868 +// u16 priority:3;
869 +//} __attribute__ ((__packed__));
870 +
871 +//struct tdesc1 {
872 +// struct pqinf pqinf;
873 +// u8 TCR;
874 +// u8 TCPLS:2;
875 +// u8 reserved:2;
876 +// u8 CMDZ:4;
877 +//} __attribute__ ((__packed__));
878
879 struct td_buf {
880 u32 pa_low;
881 - u16 pa_high;
882 - u16 bufsize:14;
883 - u16 reserved:1;
884 - u16 queue:1;
885 +// u16 pa_high;
886 +// u16 bufsize:14;
887 +// u16 reserved:1;
888 +// u16 queue:1;
889 + u32 ltwo;
890 } __attribute__ ((__packed__));
891
892 struct tx_desc {
893 - struct tdesc0 tdesc0;
894 - struct tdesc1 tdesc1;
895 +// struct tdesc0 tdesc0;
896 +// struct tdesc1 tdesc1;
897 + u32 tdesc0;
898 + u32 tdesc1;
899 struct td_buf td_buf[7];
900 };
901
902 @@ -279,6 +285,16 @@ enum velocity_owner {
903 OWNED_BY_NIC = 1
904 };
905
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
915 +
916
917 /*
918 * MAC registers and macros.
919 @@ -1698,6 +1714,7 @@ enum velocity_flow_cntl_type {
920 };
921
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 */
This page took 0.08041 seconds and 5 git commands to generate.