Deleted Added
full compact
if_cs.c (140926) if_cs.c (140927)
1/*-
2 * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/cs/if_cs.c 140926 2005-01-28 06:35:39Z imp $");
30__FBSDID("$FreeBSD: head/sys/dev/cs/if_cs.c 140927 2005-01-28 06:45:42Z imp $");
31
32/*
33 *
34 * Device driver for Crystal Semiconductor CS8920 based ethernet
35 * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997
36 */
37
38/*

--- 146 unchanged lines hidden (view full) ---

185
186 DELAY(500000);
187}
188
189
190static int
191cs_duplex_auto(struct cs_softc *sc)
192{
31
32/*
33 *
34 * Device driver for Crystal Semiconductor CS8920 based ethernet
35 * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997
36 */
37
38/*

--- 146 unchanged lines hidden (view full) ---

185
186 DELAY(500000);
187}
188
189
190static int
191cs_duplex_auto(struct cs_softc *sc)
192{
193 int i, error=0;
194
193 int i, error=0;
194
195 cs_writereg(sc, PP_AutoNegCTL,
196 RE_NEG_NOW | ALLOW_FDX | AUTO_NEG_ENABLE);
195 cs_writereg(sc, PP_AutoNegCTL,
196 RE_NEG_NOW | ALLOW_FDX | AUTO_NEG_ENABLE);
197 for (i=0; cs_readreg(sc, PP_AutoNegST) & AUTO_NEG_BUSY; i++) {
198 if (i > 40000) {
199 if_printf(&sc->arpcom.ac_if,
200 "full/half duplex auto negotiation timeout\n");
197 for (i=0; cs_readreg(sc, PP_AutoNegST) & AUTO_NEG_BUSY; i++) {
198 if (i > 40000) {
199 if_printf(&sc->arpcom.ac_if,
200 "full/half duplex auto negotiation timeout\n");
201 error = ETIMEDOUT;
201 error = ETIMEDOUT;
202 break;
203 }
204 DELAY(1000);
205 }
206 DELAY( 1000000 );
202 break;
203 }
204 DELAY(1000);
205 }
206 DELAY(1000000);
207 return error;
208}
209
210static int
211enable_tp(struct cs_softc *sc)
212{
213
214 cs_writereg(sc, PP_LineCTL, sc->line_ctl & ~AUI_ONLY);
215 control_dc_dc(sc, 0);
216 DELAY( 150000 );
217
218 if ((cs_readreg(sc, PP_LineST) & LINK_OK)==0) {
219 if_printf(&sc->arpcom.ac_if, "failed to enable TP\n");
207 return error;
208}
209
210static int
211enable_tp(struct cs_softc *sc)
212{
213
214 cs_writereg(sc, PP_LineCTL, sc->line_ctl & ~AUI_ONLY);
215 control_dc_dc(sc, 0);
216 DELAY( 150000 );
217
218 if ((cs_readreg(sc, PP_LineST) & LINK_OK)==0) {
219 if_printf(&sc->arpcom.ac_if, "failed to enable TP\n");
220 return EINVAL;
220 return EINVAL;
221 }
222
223 return 0;
224}
225
226/*
227 * XXX This was rewritten from Linux driver without any tests.
221 }
222
223 return 0;
224}
225
226/*
227 * XXX This was rewritten from Linux driver without any tests.
228 */
228 */
229static int
230send_test_pkt(struct cs_softc *sc)
231{
232 char test_packet[] = { 0,0,0,0,0,0, 0,0,0,0,0,0,
233 0, 46, /* A 46 in network order */
234 0, 0, /* DSAP=0 & SSAP=0 fields */
235 0xf3, 0 /* Control (Test Req + P bit set) */ };
236 int i;

--- 37 unchanged lines hidden (view full) ---

274
275 control_dc_dc(sc, 0);
276 cs_writereg(sc, PP_LineCTL,
277 (sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
278
279 if (!send_test_pkt(sc)) {
280 if_printf(&sc->arpcom.ac_if, "failed to enable AUI\n");
281 return EINVAL;
229static int
230send_test_pkt(struct cs_softc *sc)
231{
232 char test_packet[] = { 0,0,0,0,0,0, 0,0,0,0,0,0,
233 0, 46, /* A 46 in network order */
234 0, 0, /* DSAP=0 & SSAP=0 fields */
235 0xf3, 0 /* Control (Test Req + P bit set) */ };
236 int i;

--- 37 unchanged lines hidden (view full) ---

274
275 control_dc_dc(sc, 0);
276 cs_writereg(sc, PP_LineCTL,
277 (sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
278
279 if (!send_test_pkt(sc)) {
280 if_printf(&sc->arpcom.ac_if, "failed to enable AUI\n");
281 return EINVAL;
282 }
283 return 0;
282 }
283 return 0;
284}
285
286/*
287 * XXX This was rewritten from Linux driver without any tests.
284}
285
286/*
287 * XXX This was rewritten from Linux driver without any tests.
288 */
288 */
289static int
290enable_bnc(struct cs_softc *sc)
291{
292
293 control_dc_dc(sc, 1);
294 cs_writereg(sc, PP_LineCTL,
295 (sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
296
297 if (!send_test_pkt(sc)) {
298 if_printf(&sc->arpcom.ac_if, "failed to enable BNC\n");
299 return EINVAL;
289static int
290enable_bnc(struct cs_softc *sc)
291{
292
293 control_dc_dc(sc, 1);
294 cs_writereg(sc, PP_LineCTL,
295 (sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
296
297 if (!send_test_pkt(sc)) {
298 if_printf(&sc->arpcom.ac_if, "failed to enable BNC\n");
299 return EINVAL;
300 }
301 return 0;
300 }
301 return 0;
302}
303
304int
305cs_cs89x0_probe(device_t dev)
306{
307 int i;
308 int error;
309 u_long irq, junk;

--- 41 unchanged lines hidden (view full) ---

351 pp_isadma = PP_CS8900_ISADMA;
352 sc->send_cmd = TX_CS8900_AFTER_ALL;
353 } else {
354 pp_isaint = PP_CS8920_ISAINT;
355 pp_isadma = PP_CS8920_ISADMA;
356 sc->send_cmd = TX_CS8920_AFTER_ALL;
357 }
358
302}
303
304int
305cs_cs89x0_probe(device_t dev)
306{
307 int i;
308 int error;
309 u_long irq, junk;

--- 41 unchanged lines hidden (view full) ---

351 pp_isadma = PP_CS8900_ISADMA;
352 sc->send_cmd = TX_CS8900_AFTER_ALL;
353 } else {
354 pp_isaint = PP_CS8920_ISAINT;
355 pp_isadma = PP_CS8920_ISADMA;
356 sc->send_cmd = TX_CS8920_AFTER_ALL;
357 }
358
359 /*
360 * Clear some fields so that fail of EEPROM will left them clean
361 */
362 sc->auto_neg_cnf = 0;
363 sc->adapter_cnf = 0;
364 sc->isa_config = 0;
365
366 /*
359 /*
360 * Clear some fields so that fail of EEPROM will left them clean
361 */
362 sc->auto_neg_cnf = 0;
363 sc->adapter_cnf = 0;
364 sc->isa_config = 0;
365
366 /*
367 * If no interrupt specified (or "?"), use what the board tells us.
368 */
369 error = bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, &junk);
370
371 /*
372 * Get data from EEPROM
373 */
374 if((cs_readreg(sc, PP_SelfST) & EEPROM_PRESENT) == 0) {
375 device_printf(dev, "No EEPROM, assuming defaults.\n");
376 } else {
377 if (get_eeprom_data(sc,START_EEPROM_DATA,CHKSUM_LEN, eeprom_buff)<0) {
378 device_printf(dev, "EEPROM read failed, "
379 "assuming defaults.\n");
380 } else {
381 if (get_eeprom_cksum(START_EEPROM_DATA,CHKSUM_LEN, eeprom_buff)<0) {
382 device_printf(dev, "EEPROM cheksum bad, "
383 "assuming defaults.\n");
384 } else {
367 * If no interrupt specified (or "?"), use what the board tells us.
368 */
369 error = bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, &junk);
370
371 /*
372 * Get data from EEPROM
373 */
374 if((cs_readreg(sc, PP_SelfST) & EEPROM_PRESENT) == 0) {
375 device_printf(dev, "No EEPROM, assuming defaults.\n");
376 } else {
377 if (get_eeprom_data(sc,START_EEPROM_DATA,CHKSUM_LEN, eeprom_buff)<0) {
378 device_printf(dev, "EEPROM read failed, "
379 "assuming defaults.\n");
380 } else {
381 if (get_eeprom_cksum(START_EEPROM_DATA,CHKSUM_LEN, eeprom_buff)<0) {
382 device_printf(dev, "EEPROM cheksum bad, "
383 "assuming defaults.\n");
384 } else {
385 sc->auto_neg_cnf =
386 eeprom_buff[AUTO_NEG_CNF_OFFSET/2];
387 sc->adapter_cnf =
388 eeprom_buff[ADAPTER_CNF_OFFSET/2];
389 sc->isa_config =
390 eeprom_buff[ISA_CNF_OFFSET/2];
385 sc->auto_neg_cnf =
386 eeprom_buff[AUTO_NEG_CNF_OFFSET/2];
387 sc->adapter_cnf =
388 eeprom_buff[ADAPTER_CNF_OFFSET/2];
389 sc->isa_config =
390 eeprom_buff[ISA_CNF_OFFSET/2];
391
392 for (i=0; i<ETHER_ADDR_LEN/2; i++) {
393 sc->arpcom.ac_enaddr[i*2]=
394 eeprom_buff[i];
395 sc->arpcom.ac_enaddr[i*2+1]=
396 eeprom_buff[i] >> 8;
397 }
391
398
392 for (i=0; i<ETHER_ADDR_LEN/2; i++) {
393 sc->arpcom.ac_enaddr[i*2]=
394 eeprom_buff[i];
395 sc->arpcom.ac_enaddr[i*2+1]=
396 eeprom_buff[i] >> 8;
397 }
398
399 /*
400 * If no interrupt specified (or "?"),
401 * use what the board tells us.
402 */
399 /*
400 * If no interrupt specified,
401 * use what the board tells us.
402 */
403 if (error) {
404 irq = sc->isa_config & INT_NO_MASK;
403 if (error) {
404 irq = sc->isa_config & INT_NO_MASK;
405 if (chip_type==CS8900) {
406 switch(irq) {
407 case 0:
405 if (chip_type==CS8900) {
406 switch(irq) {
407 case 0:
408 irq=10;
409 error=0;
410 break;
408 irq=10;
409 error=0;
410 break;
411 case 1:
411 case 1:
412 irq=11;
413 error=0;
414 break;
412 irq=11;
413 error=0;
414 break;
415 case 2:
415 case 2:
416 irq=12;
417 error=0;
418 break;
416 irq=12;
417 error=0;
418 break;
419 case 3:
419 case 3:
420 irq=5;
421 error=0;
422 break;
423 default:
424 device_printf(dev, "invalid irq in EEPROM.\n");
425 error=EINVAL;
420 irq=5;
421 error=0;
422 break;
423 default:
424 device_printf(dev, "invalid irq in EEPROM.\n");
425 error=EINVAL;
426 }
426 }
427 } else {
428 if (irq>CS8920_NO_INTS) {
429 device_printf(dev, "invalid irq in EEPROM.\n");
430 error=EINVAL;
431 } else {
432 error=0;
433 }
434 }
435
436 if (!error)
437 bus_set_resource(dev, SYS_RES_IRQ, 0,
438 irq, 1);
439 }
440 }
427 } else {
428 if (irq>CS8920_NO_INTS) {
429 device_printf(dev, "invalid irq in EEPROM.\n");
430 error=EINVAL;
431 } else {
432 error=0;
433 }
434 }
435
436 if (!error)
437 bus_set_resource(dev, SYS_RES_IRQ, 0,
438 irq, 1);
439 }
440 }
441 }
442 }
441 }
442 }
443
444 if (!error) {
443
444 if (!error) {
445 if (chip_type == CS8900) {
445 if (chip_type == CS8900) {
446 switch(irq) {
447 case 5:
448 irq = 3;
449 break;
450 case 10:
451 irq = 0;
452 break;
453 case 11:
454 irq = 1;
455 break;
456 case 12:
457 irq = 2;
458 break;
459 default:
460 error=EINVAL;
461 }
446 switch(irq) {
447 case 5:
448 irq = 3;
449 break;
450 case 10:
451 irq = 0;
452 break;
453 case 11:
454 irq = 1;
455 break;
456 case 12:
457 irq = 2;
458 break;
459 default:
460 error=EINVAL;
461 }
462 } else {
463 if (irq > CS8920_NO_INTS) {
464 error = EINVAL;
465 }
466 }
462 } else {
463 if (irq > CS8920_NO_INTS) {
464 error = EINVAL;
465 }
466 }
467 }
468
469 if (!error) {
470 if (!(sc->flags & CS_NO_IRQ))
471 cs_writereg(sc, pp_isaint, irq);
472 } else {
473 device_printf(dev, "Unknown or invalid irq\n");
467 }
468
469 if (!error) {
470 if (!(sc->flags & CS_NO_IRQ))
471 cs_writereg(sc, pp_isaint, irq);
472 } else {
473 device_printf(dev, "Unknown or invalid irq\n");
474 return (ENXIO);
475 }
476
477 /*
478 * Temporary disabled
479 *
480 if (drq>0)
474 return (ENXIO);
475 }
476
477 /*
478 * Temporary disabled
479 *
480 if (drq>0)
481 cs_writereg(sc, pp_isadma, drq);
482 else {
483 device_printf(dev, "incorrect drq\n",);
484 return 0;
485 }
481 cs_writereg(sc, pp_isadma, drq);
482 else {
483 device_printf(dev, "incorrect drq\n",);
484 return 0;
485 }
486 */
486 */
487
488 if (bootverbose)
489 device_printf(dev, "CS89%c0%s rev %c media%s%s%s\n",
490 chip_type==CS8900 ? '0' : '2',
491 chip_type==CS8920M ? "M" : "",
492 chip_revision,
493 (sc->adapter_cnf & A_CNF_10B_T) ? " TP" : "",
494 (sc->adapter_cnf & A_CNF_AUI) ? " AUI" : "",
495 (sc->adapter_cnf & A_CNF_10B_2) ? " BNC" : "");
496
487
488 if (bootverbose)
489 device_printf(dev, "CS89%c0%s rev %c media%s%s%s\n",
490 chip_type==CS8900 ? '0' : '2',
491 chip_type==CS8920M ? "M" : "",
492 chip_revision,
493 (sc->adapter_cnf & A_CNF_10B_T) ? " TP" : "",
494 (sc->adapter_cnf & A_CNF_AUI) ? " AUI" : "",
495 (sc->adapter_cnf & A_CNF_10B_2) ? " BNC" : "");
496
497 if ((sc->adapter_cnf & A_CNF_EXTND_10B_2) &&
498 (sc->adapter_cnf & A_CNF_LOW_RX_SQUELCH))
499 sc->line_ctl = LOW_RX_SQUELCH;
500 else
501 sc->line_ctl = 0;
497 if ((sc->adapter_cnf & A_CNF_EXTND_10B_2) &&
498 (sc->adapter_cnf & A_CNF_LOW_RX_SQUELCH))
499 sc->line_ctl = LOW_RX_SQUELCH;
500 else
501 sc->line_ctl = 0;
502
502
503
504 return 0;
505}
506
507/*
508 * Allocate a port resource with the given resource id.
509 */
510int cs_alloc_port(device_t dev, int rid, int size)
511{
503 return 0;
504}
505
506/*
507 * Allocate a port resource with the given resource id.
508 */
509int cs_alloc_port(device_t dev, int rid, int size)
510{
512 struct cs_softc *sc = device_get_softc(dev);
513 struct resource *res;
511 struct cs_softc *sc = device_get_softc(dev);
512 struct resource *res;
514
513
515 res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
516 0ul, ~0ul, size, RF_ACTIVE);
517 if (res) {
518 sc->port_rid = rid;
519 sc->port_res = res;
520 sc->port_used = size;
521 return (0);
522 } else {
523 return (ENOENT);
524 }
514 res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
515 0ul, ~0ul, size, RF_ACTIVE);
516 if (res) {
517 sc->port_rid = rid;
518 sc->port_res = res;
519 sc->port_used = size;
520 return (0);
521 } else {
522 return (ENOENT);
523 }
525}
526
527/*
528 * Allocate a memory resource with the given resource id.
529 */
530int cs_alloc_memory(device_t dev, int rid, int size)
531{
524}
525
526/*
527 * Allocate a memory resource with the given resource id.
528 */
529int cs_alloc_memory(device_t dev, int rid, int size)
530{
532 struct cs_softc *sc = device_get_softc(dev);
533 struct resource *res;
531 struct cs_softc *sc = device_get_softc(dev);
532 struct resource *res;
534
533
535 res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
536 0ul, ~0ul, size, RF_ACTIVE);
537 if (res) {
538 sc->mem_rid = rid;
539 sc->mem_res = res;
540 sc->mem_used = size;
541 return (0);
542 } else {
543 return (ENOENT);
544 }
534 res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
535 0ul, ~0ul, size, RF_ACTIVE);
536 if (res) {
537 sc->mem_rid = rid;
538 sc->mem_res = res;
539 sc->mem_used = size;
540 return (0);
541 } else {
542 return (ENOENT);
543 }
545}
546
547/*
548 * Allocate an irq resource with the given resource id.
549 */
550int cs_alloc_irq(device_t dev, int rid, int flags)
551{
544}
545
546/*
547 * Allocate an irq resource with the given resource id.
548 */
549int cs_alloc_irq(device_t dev, int rid, int flags)
550{
552 struct cs_softc *sc = device_get_softc(dev);
553 struct resource *res;
551 struct cs_softc *sc = device_get_softc(dev);
552 struct resource *res;
554
553
555 res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
556 (RF_ACTIVE | flags));
557 if (res) {
558 sc->irq_rid = rid;
559 sc->irq_res = res;
560 return (0);
561 } else {
562 return (ENOENT);
563 }
554 res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
555 (RF_ACTIVE | flags));
556 if (res) {
557 sc->irq_rid = rid;
558 sc->irq_res = res;
559 return (0);
560 } else {
561 return (ENOENT);
562 }
564}
565
566/*
567 * Release all resources
568 */
569void cs_release_resources(device_t dev)
570{
563}
564
565/*
566 * Release all resources
567 */
568void cs_release_resources(device_t dev)
569{
571 struct cs_softc *sc = device_get_softc(dev);
570 struct cs_softc *sc = device_get_softc(dev);
572
571
573 if (sc->port_res) {
574 bus_release_resource(dev, SYS_RES_IOPORT,
575 sc->port_rid, sc->port_res);
576 sc->port_res = 0;
577 }
578 if (sc->mem_res) {
579 bus_release_resource(dev, SYS_RES_MEMORY,
580 sc->mem_rid, sc->mem_res);
581 sc->mem_res = 0;
582 }
583 if (sc->irq_res) {
584 bus_release_resource(dev, SYS_RES_IRQ,
585 sc->irq_rid, sc->irq_res);
586 sc->irq_res = 0;
587 }
572 if (sc->port_res) {
573 bus_release_resource(dev, SYS_RES_IOPORT,
574 sc->port_rid, sc->port_res);
575 sc->port_res = 0;
576 }
577 if (sc->mem_res) {
578 bus_release_resource(dev, SYS_RES_MEMORY,
579 sc->mem_rid, sc->mem_res);
580 sc->mem_res = 0;
581 }
582 if (sc->irq_res) {
583 bus_release_resource(dev, SYS_RES_IRQ,
584 sc->irq_rid, sc->irq_res);
585 sc->irq_res = 0;
586 }
588}
589
590/*
591 * Install the interface into kernel networking data structures
592 */
593int
594cs_attach(device_t dev)
595{
587}
588
589/*
590 * Install the interface into kernel networking data structures
591 */
592int
593cs_attach(device_t dev)
594{
596 int media=0;
595 int media=0;
597 struct cs_softc *sc = device_get_softc(dev);;
598 struct ifnet *ifp = &(sc->arpcom.ac_if);
599
600 cs_stop( sc );
601
602 ifp->if_softc=sc;
603 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
604 ifp->if_start=cs_start;

--- 130 unchanged lines hidden (view full) ---

735 /* Configure the receiver mode */
736 cs_setmode(sc);
737
738 /*
739 * This defines what type of frames will cause interrupts
740 * Bad frames should generate interrupts so that the driver
741 * could track statistics of discarded packets
742 */
596 struct cs_softc *sc = device_get_softc(dev);;
597 struct ifnet *ifp = &(sc->arpcom.ac_if);
598
599 cs_stop( sc );
600
601 ifp->if_softc=sc;
602 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
603 ifp->if_start=cs_start;

--- 130 unchanged lines hidden (view full) ---

734 /* Configure the receiver mode */
735 cs_setmode(sc);
736
737 /*
738 * This defines what type of frames will cause interrupts
739 * Bad frames should generate interrupts so that the driver
740 * could track statistics of discarded packets
741 */
743 rx_cfg = RX_OK_ENBL | RX_CRC_ERROR_ENBL | RX_RUNT_ENBL |
742 rx_cfg = RX_OK_ENBL | RX_CRC_ERROR_ENBL | RX_RUNT_ENBL |
744 RX_EXTRA_DATA_ENBL;
745 if (sc->isa_config & STREAM_TRANSFER)
746 rx_cfg |= RX_STREAM_ENBL;
747 cs_writereg(sc, PP_RxCFG, rx_cfg);
748 cs_writereg(sc, PP_TxCFG, TX_LOST_CRS_ENBL |
749 TX_SQE_ERROR_ENBL | TX_OK_ENBL | TX_LATE_COL_ENBL |
750 TX_JBR_ENBL | TX_ANY_COL_ENBL | TX_16_COL_ENBL);
751 cs_writereg(sc, PP_BufCFG, READY_FOR_TX_ENBL |
752 RX_MISS_COUNT_OVRFLOW_ENBL | TX_COL_COUNT_OVRFLOW_ENBL |
753 TX_UNDERRUN_ENBL /*| RX_DMA_ENBL*/);
754
743 RX_EXTRA_DATA_ENBL;
744 if (sc->isa_config & STREAM_TRANSFER)
745 rx_cfg |= RX_STREAM_ENBL;
746 cs_writereg(sc, PP_RxCFG, rx_cfg);
747 cs_writereg(sc, PP_TxCFG, TX_LOST_CRS_ENBL |
748 TX_SQE_ERROR_ENBL | TX_OK_ENBL | TX_LATE_COL_ENBL |
749 TX_JBR_ENBL | TX_ANY_COL_ENBL | TX_16_COL_ENBL);
750 cs_writereg(sc, PP_BufCFG, READY_FOR_TX_ENBL |
751 RX_MISS_COUNT_OVRFLOW_ENBL | TX_COL_COUNT_OVRFLOW_ENBL |
752 TX_UNDERRUN_ENBL /*| RX_DMA_ENBL*/);
753
755 /* Write MAC address into IA filter */
756 for (i=0; i<ETHER_ADDR_LEN/2; i++)
757 cs_writereg(sc, PP_IA + i * 2,
754 /* Write MAC address into IA filter */
755 for (i=0; i<ETHER_ADDR_LEN/2; i++)
756 cs_writereg(sc, PP_IA + i * 2,
758 sc->arpcom.ac_enaddr[i * 2] |
759 (sc->arpcom.ac_enaddr[i * 2 + 1] << 8) );
760
761 /*
762 * Now enable everything
763 */
764/*
765#ifdef CS_USE_64K_DMA
766 cs_writereg(sc, PP_BusCTL, ENABLE_IRQ | RX_DMA_SIZE_64K);
767#else
757 sc->arpcom.ac_enaddr[i * 2] |
758 (sc->arpcom.ac_enaddr[i * 2 + 1] << 8) );
759
760 /*
761 * Now enable everything
762 */
763/*
764#ifdef CS_USE_64K_DMA
765 cs_writereg(sc, PP_BusCTL, ENABLE_IRQ | RX_DMA_SIZE_64K);
766#else
768 cs_writereg(sc, PP_BusCTL, ENABLE_IRQ);
767 cs_writereg(sc, PP_BusCTL, ENABLE_IRQ);
769#endif
770*/
771 cs_writereg(sc, PP_BusCTL, ENABLE_IRQ);
772
773 /*
774 * Set running and clear output active flags
775 */
776 sc->arpcom.ac_if.if_flags |= IFF_RUNNING;

--- 67 unchanged lines hidden (view full) ---

844#endif
845
846 if (status & (RX_IA | RX_BROADCAST) ||
847 (ifp->if_flags & IFF_MULTICAST && status & RX_HASHED)) {
848 /* Feed the packet to the upper layer */
849 (*ifp->if_input)(ifp, m);
850 ifp->if_ipackets++;
851 if (length == ETHER_MAX_LEN-ETHER_CRC_LEN)
768#endif
769*/
770 cs_writereg(sc, PP_BusCTL, ENABLE_IRQ);
771
772 /*
773 * Set running and clear output active flags
774 */
775 sc->arpcom.ac_if.if_flags |= IFF_RUNNING;

--- 67 unchanged lines hidden (view full) ---

843#endif
844
845 if (status & (RX_IA | RX_BROADCAST) ||
846 (ifp->if_flags & IFF_MULTICAST && status & RX_HASHED)) {
847 /* Feed the packet to the upper layer */
848 (*ifp->if_input)(ifp, m);
849 ifp->if_ipackets++;
850 if (length == ETHER_MAX_LEN-ETHER_CRC_LEN)
852 DELAY(cs_recv_delay);
851 DELAY(cs_recv_delay);
853 } else {
854 m_freem(m);
855 }
856
857 return 0;
858}
859
860/*

--- 12 unchanged lines hidden (view full) ---

873
874 while ((status=cs_inw(sc, ISQ_PORT))) {
875
876#ifdef CS_DEBUG
877 if_printf(ifp, "from ISQ: %04x\n", status);
878#endif
879
880 switch (status & ISQ_EVENT_MASK) {
852 } else {
853 m_freem(m);
854 }
855
856 return 0;
857}
858
859/*

--- 12 unchanged lines hidden (view full) ---

872
873 while ((status=cs_inw(sc, ISQ_PORT))) {
874
875#ifdef CS_DEBUG
876 if_printf(ifp, "from ISQ: %04x\n", status);
877#endif
878
879 switch (status & ISQ_EVENT_MASK) {
881 case ISQ_RECEIVER_EVENT:
882 cs_get_packet(sc);
883 break;
880 case ISQ_RECEIVER_EVENT:
881 cs_get_packet(sc);
882 break;
884
883
885 case ISQ_TRANSMITTER_EVENT:
886 if (status & TX_OK)
887 ifp->if_opackets++;
888 else
889 ifp->if_oerrors++;
890 ifp->if_flags &= ~IFF_OACTIVE;
891 ifp->if_timer = 0;
892 break;
884 case ISQ_TRANSMITTER_EVENT:
885 if (status & TX_OK)
886 ifp->if_opackets++;
887 else
888 ifp->if_oerrors++;
889 ifp->if_flags &= ~IFF_OACTIVE;
890 ifp->if_timer = 0;
891 break;
893
892
894 case ISQ_BUFFER_EVENT:
895 if (status & READY_FOR_TX) {
896 ifp->if_flags &= ~IFF_OACTIVE;
897 ifp->if_timer = 0;
898 }
893 case ISQ_BUFFER_EVENT:
894 if (status & READY_FOR_TX) {
895 ifp->if_flags &= ~IFF_OACTIVE;
896 ifp->if_timer = 0;
897 }
899
898
900 if (status & TX_UNDERRUN) {
901 ifp->if_flags &= ~IFF_OACTIVE;
902 ifp->if_timer = 0;
903 ifp->if_oerrors++;
904 }
905 break;
899 if (status & TX_UNDERRUN) {
900 ifp->if_flags &= ~IFF_OACTIVE;
901 ifp->if_timer = 0;
902 ifp->if_oerrors++;
903 }
904 break;
906
905
907 case ISQ_RX_MISS_EVENT:
908 ifp->if_ierrors+=(status>>6);
909 break;
906 case ISQ_RX_MISS_EVENT:
907 ifp->if_ierrors+=(status>>6);
908 break;
910
909
911 case ISQ_TX_COL_EVENT:
912 ifp->if_collisions+=(status>>6);
913 break;
914 }
915 }
910 case ISQ_TX_COL_EVENT:
911 ifp->if_collisions+=(status>>6);
912 break;
913 }
914 }
916
915
917 if (!(ifp->if_flags & IFF_OACTIVE)) {
918 cs_start(ifp);
919 }
916 if (!(ifp->if_flags & IFF_OACTIVE)) {
917 cs_start(ifp);
918 }
920}
921
922/*
923 * Save the data in buffer
924 */
925
926static void
927cs_write_mbufs( struct cs_softc *sc, struct mbuf *m )

--- 79 unchanged lines hidden (view full) ---

1007 */
1008 if (!(cs_readreg(sc, PP_BusST) & READY_FOR_TX_NOW)) {
1009 ifp->if_timer = sc->buf_len;
1010 (void) splx(s);
1011 ifp->if_flags |= IFF_OACTIVE;
1012 return;
1013 }
1014
919}
920
921/*
922 * Save the data in buffer
923 */
924
925static void
926cs_write_mbufs( struct cs_softc *sc, struct mbuf *m )

--- 79 unchanged lines hidden (view full) ---

1006 */
1007 if (!(cs_readreg(sc, PP_BusST) & READY_FOR_TX_NOW)) {
1008 ifp->if_timer = sc->buf_len;
1009 (void) splx(s);
1010 ifp->if_flags |= IFF_OACTIVE;
1011 return;
1012 }
1013
1015 cs_xmit_buf(sc);
1014 cs_xmit_buf(sc);
1016
1017 /*
1018 * Set the watchdog timer in case we never hear
1019 * from board again. (I don't know about correct
1020 * value for this timeout)
1021 */
1022 ifp->if_timer = length;
1023

--- 86 unchanged lines hidden (view full) ---

1110
1111 s=splimp();
1112
1113 switch (command) {
1114 case SIOCSIFFLAGS:
1115 /*
1116 * Switch interface state between "running" and
1117 * "stopped", reflecting the UP flag.
1015
1016 /*
1017 * Set the watchdog timer in case we never hear
1018 * from board again. (I don't know about correct
1019 * value for this timeout)
1020 */
1021 ifp->if_timer = length;
1022

--- 86 unchanged lines hidden (view full) ---

1109
1110 s=splimp();
1111
1112 switch (command) {
1113 case SIOCSIFFLAGS:
1114 /*
1115 * Switch interface state between "running" and
1116 * "stopped", reflecting the UP flag.
1118 */
1119 if (sc->arpcom.ac_if.if_flags & IFF_UP) {
1120 if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)==0) {
1121 cs_init(sc);
1122 }
1123 } else {
1124 if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)!=0) {
1125 cs_stop(sc);
1126 }
1117 */
1118 if (sc->arpcom.ac_if.if_flags & IFF_UP) {
1119 if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)==0) {
1120 cs_init(sc);
1121 }
1122 } else {
1123 if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)!=0) {
1124 cs_stop(sc);
1125 }
1127 }
1128 /*
1129 * Promiscuous and/or multicast flags may have changed,
1130 * so reprogram the multicast filter and/or receive mode.
1131 *
1132 * See note about multicasts in cs_setmode
1133 */
1134 cs_setmode(sc);

--- 6 unchanged lines hidden (view full) ---

1141 * accordingly.
1142 *
1143 * See note about multicasts in cs_setmode
1144 */
1145 cs_setmode(sc);
1146 error = 0;
1147 break;
1148
1126 }
1127 /*
1128 * Promiscuous and/or multicast flags may have changed,
1129 * so reprogram the multicast filter and/or receive mode.
1130 *
1131 * See note about multicasts in cs_setmode
1132 */
1133 cs_setmode(sc);

--- 6 unchanged lines hidden (view full) ---

1140 * accordingly.
1141 *
1142 * See note about multicasts in cs_setmode
1143 */
1144 cs_setmode(sc);
1145 error = 0;
1146 break;
1147
1149 case SIOCSIFMEDIA:
1150 case SIOCGIFMEDIA:
1151 error = ifmedia_ioctl(ifp, ifr, &sc->media, command);
1152 break;
1148 case SIOCSIFMEDIA:
1149 case SIOCGIFMEDIA:
1150 error = ifmedia_ioctl(ifp, ifr, &sc->media, command);
1151 break;
1153
1152
1154 default:
1153 default:
1155 error = ether_ioctl(ifp, command, data);
1156 break;
1154 error = ether_ioctl(ifp, command, data);
1155 break;
1157 }
1156 }
1158
1159 (void) splx(s);
1160 return error;
1161}
1162
1163/*
1164 * Device timeout/watchdog routine. Entered if the device neglects to
1165 * generate an interrupt after a transmit has been started on it.

--- 55 unchanged lines hidden (view full) ---

1221 ifmr->ifm_active |= IFM_10_5;
1222 }
1223 }
1224}
1225
1226static int
1227cs_mediaset(struct cs_softc *sc, int media)
1228{
1157
1158 (void) splx(s);
1159 return error;
1160}
1161
1162/*
1163 * Device timeout/watchdog routine. Entered if the device neglects to
1164 * generate an interrupt after a transmit has been started on it.

--- 55 unchanged lines hidden (view full) ---

1220 ifmr->ifm_active |= IFM_10_5;
1221 }
1222 }
1223}
1224
1225static int
1226cs_mediaset(struct cs_softc *sc, int media)
1227{
1229 int error;
1228 int error;
1230
1231 /* Stop the receiver & transmitter */
1232 cs_writereg(sc, PP_LineCTL, cs_readreg(sc, PP_LineCTL) &
1233 ~(SERIAL_RX_ON | SERIAL_TX_ON));
1234
1235#ifdef CS_DEBUG
1236 if_printf(&sc->arpcom.ac_if, "cs_setmedia(%x)\n", media);
1237#endif

--- 35 unchanged lines hidden ---
1229
1230 /* Stop the receiver & transmitter */
1231 cs_writereg(sc, PP_LineCTL, cs_readreg(sc, PP_LineCTL) &
1232 ~(SERIAL_RX_ON | SERIAL_TX_ON));
1233
1234#ifdef CS_DEBUG
1235 if_printf(&sc->arpcom.ac_if, "cs_setmedia(%x)\n", media);
1236#endif

--- 35 unchanged lines hidden ---