Deleted Added
full compact
if_ti.c (99058) if_ti.c (102336)
1/*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
1/*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD: head/sys/dev/ti/if_ti.c 99058 2002-06-29 11:26:05Z alfred $
32 * $FreeBSD: head/sys/dev/ti/if_ti.c 102336 2002-08-24 00:02:03Z alfred $
33 */
34
35/*
36 * Alteon Networks Tigon PCI gigabit ethernet driver for FreeBSD.
37 * Manuals, sample driver and firmware source kits are available
38 * from http://www.alteon.com/support/openkits.
39 *
40 * Written by Bill Paul <wpaul@ctr.columbia.edu>

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

147 * BDs.
148 */
149#if defined(TI_JUMBO_HDRSPLIT) && defined(TI_PRIVATE_JUMBOS)
150#error "options TI_JUMBO_HDRSPLIT and TI_PRIVATE_JUMBOS are mutually exclusive"
151#endif /* TI_JUMBO_HDRSPLIT && TI_JUMBO_HDRSPLIT */
152
153#if !defined(lint)
154static const char rcsid[] =
33 */
34
35/*
36 * Alteon Networks Tigon PCI gigabit ethernet driver for FreeBSD.
37 * Manuals, sample driver and firmware source kits are available
38 * from http://www.alteon.com/support/openkits.
39 *
40 * Written by Bill Paul <wpaul@ctr.columbia.edu>

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

147 * BDs.
148 */
149#if defined(TI_JUMBO_HDRSPLIT) && defined(TI_PRIVATE_JUMBOS)
150#error "options TI_JUMBO_HDRSPLIT and TI_PRIVATE_JUMBOS are mutually exclusive"
151#endif /* TI_JUMBO_HDRSPLIT && TI_JUMBO_HDRSPLIT */
152
153#if !defined(lint)
154static const char rcsid[] =
155 "$FreeBSD: head/sys/dev/ti/if_ti.c 99058 2002-06-29 11:26:05Z alfred $";
155 "$FreeBSD: head/sys/dev/ti/if_ti.c 102336 2002-08-24 00:02:03Z alfred $";
156#endif
157
158struct ti_softc *tis[8];
159
160typedef enum {
161 TI_SWAP_HTON,
162 TI_SWAP_NTOH
163} ti_swap_type;

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

425 *dest = byte;
426
427 return(0);
428}
429
430/*
431 * Read a sequence of bytes from the EEPROM.
432 */
156#endif
157
158struct ti_softc *tis[8];
159
160typedef enum {
161 TI_SWAP_HTON,
162 TI_SWAP_NTOH
163} ti_swap_type;

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

425 *dest = byte;
426
427 return(0);
428}
429
430/*
431 * Read a sequence of bytes from the EEPROM.
432 */
433static int ti_read_eeprom(sc, dest, off, cnt)
433static int
434ti_read_eeprom(sc, dest, off, cnt)
434 struct ti_softc *sc;
435 caddr_t dest;
436 int off;
437 int cnt;
438{
439 int err = 0, i;
440 u_int8_t byte = 0;
441

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

448
449 return(err ? 1 : 0);
450}
451
452/*
453 * NIC memory access function. Can be used to either clear a section
454 * of NIC local memory or (if buf is non-NULL) copy data into it.
455 */
435 struct ti_softc *sc;
436 caddr_t dest;
437 int off;
438 int cnt;
439{
440 int err = 0, i;
441 u_int8_t byte = 0;
442

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

449
450 return(err ? 1 : 0);
451}
452
453/*
454 * NIC memory access function. Can be used to either clear a section
455 * of NIC local memory or (if buf is non-NULL) copy data into it.
456 */
456static void ti_mem(sc, addr, len, buf)
457static void
458ti_mem(sc, addr, len, buf)
457 struct ti_softc *sc;
458 u_int32_t addr, len;
459 caddr_t buf;
460{
461 int segptr, segsize, cnt;
462 caddr_t ti_winbase, ptr;
463
464 segptr = addr;

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

819 return(0);
820}
821
822/*
823 * Load firmware image into the NIC. Check that the firmware revision
824 * is acceptable and see if we want the firmware for the Tigon 1 or
825 * Tigon 2.
826 */
459 struct ti_softc *sc;
460 u_int32_t addr, len;
461 caddr_t buf;
462{
463 int segptr, segsize, cnt;
464 caddr_t ti_winbase, ptr;
465
466 segptr = addr;

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

821 return(0);
822}
823
824/*
825 * Load firmware image into the NIC. Check that the firmware revision
826 * is acceptable and see if we want the firmware for the Tigon 1 or
827 * Tigon 2.
828 */
827static void ti_loadfw(sc)
829static void
830ti_loadfw(sc)
828 struct ti_softc *sc;
829{
830 switch(sc->ti_hwrev) {
831 case TI_HWREV_TIGON:
832 if (tigonFwReleaseMajor != TI_FIRMWARE_MAJOR ||
833 tigonFwReleaseMinor != TI_FIRMWARE_MINOR ||
834 tigonFwReleaseFix != TI_FIRMWARE_FIX) {
835 printf("ti%d: firmware revision mismatch; want "

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

877 }
878
879 return;
880}
881
882/*
883 * Send the NIC a command via the command ring.
884 */
831 struct ti_softc *sc;
832{
833 switch(sc->ti_hwrev) {
834 case TI_HWREV_TIGON:
835 if (tigonFwReleaseMajor != TI_FIRMWARE_MAJOR ||
836 tigonFwReleaseMinor != TI_FIRMWARE_MINOR ||
837 tigonFwReleaseFix != TI_FIRMWARE_FIX) {
838 printf("ti%d: firmware revision mismatch; want "

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

880 }
881
882 return;
883}
884
885/*
886 * Send the NIC a command via the command ring.
887 */
885static void ti_cmd(sc, cmd)
888static void
889ti_cmd(sc, cmd)
886 struct ti_softc *sc;
887 struct ti_cmd_desc *cmd;
888{
889 u_int32_t index;
890
891 if (sc->ti_rdata->ti_cmd_ring == NULL)
892 return;
893

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

899
900 return;
901}
902
903/*
904 * Send the NIC an extended command. The 'len' parameter specifies the
905 * number of command slots to include after the initial command.
906 */
890 struct ti_softc *sc;
891 struct ti_cmd_desc *cmd;
892{
893 u_int32_t index;
894
895 if (sc->ti_rdata->ti_cmd_ring == NULL)
896 return;
897

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

903
904 return;
905}
906
907/*
908 * Send the NIC an extended command. The 'len' parameter specifies the
909 * number of command slots to include after the initial command.
910 */
907static void ti_cmd_ext(sc, cmd, arg, len)
911static void
912ti_cmd_ext(sc, cmd, arg, len)
908 struct ti_softc *sc;
909 struct ti_cmd_desc *cmd;
910 caddr_t arg;
911 int len;
912{
913 u_int32_t index;
914 register int i;
915

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

928 sc->ti_cmd_saved_prodidx = index;
929
930 return;
931}
932
933/*
934 * Handle events that have triggered interrupts.
935 */
913 struct ti_softc *sc;
914 struct ti_cmd_desc *cmd;
915 caddr_t arg;
916 int len;
917{
918 u_int32_t index;
919 register int i;
920

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

933 sc->ti_cmd_saved_prodidx = index;
934
935 return;
936}
937
938/*
939 * Handle events that have triggered interrupts.
940 */
936static void ti_handle_events(sc)
941static void
942ti_handle_events(sc)
937 struct ti_softc *sc;
938{
939 struct ti_event_desc *e;
940
941 if (sc->ti_rdata->ti_event_ring == NULL)
942 return;
943
944 while (sc->ti_ev_saved_considx != sc->ti_ev_prodidx.ti_idx) {

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

1004 * 256 slots in it, but at 9K per slot than can consume over 2MB of
1005 * RAM. This is a bit much, especially considering we also need
1006 * RAM for the standard ring and mini ring (on the Tigon 2). To
1007 * save space, we only actually allocate enough memory for 64 slots
1008 * by default, which works out to between 500 and 600K. This can
1009 * be tuned by changing a #define in if_tireg.h.
1010 */
1011
943 struct ti_softc *sc;
944{
945 struct ti_event_desc *e;
946
947 if (sc->ti_rdata->ti_event_ring == NULL)
948 return;
949
950 while (sc->ti_ev_saved_considx != sc->ti_ev_prodidx.ti_idx) {

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

1010 * 256 slots in it, but at 9K per slot than can consume over 2MB of
1011 * RAM. This is a bit much, especially considering we also need
1012 * RAM for the standard ring and mini ring (on the Tigon 2). To
1013 * save space, we only actually allocate enough memory for 64 slots
1014 * by default, which works out to between 500 and 600K. This can
1015 * be tuned by changing a #define in if_tireg.h.
1016 */
1017
1012static int ti_alloc_jumbo_mem(sc)
1018static int
1019ti_alloc_jumbo_mem(sc)
1013 struct ti_softc *sc;
1014{
1015 caddr_t ptr;
1016 register int i;
1017 struct ti_jpool_entry *entry;
1018
1019 /* Grab a big chunk o' storage. */
1020 sc->ti_cdata.ti_jumbo_buf = contigmalloc(TI_JMEM, M_DEVBUF,

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

1071 SLIST_REMOVE_HEAD(&sc->ti_jfree_listhead, jpool_entries);
1072 SLIST_INSERT_HEAD(&sc->ti_jinuse_listhead, entry, jpool_entries);
1073 return(sc->ti_cdata.ti_jslots[entry->slot]);
1074}
1075
1076/*
1077 * Release a jumbo buffer.
1078 */
1020 struct ti_softc *sc;
1021{
1022 caddr_t ptr;
1023 register int i;
1024 struct ti_jpool_entry *entry;
1025
1026 /* Grab a big chunk o' storage. */
1027 sc->ti_cdata.ti_jumbo_buf = contigmalloc(TI_JMEM, M_DEVBUF,

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

1078 SLIST_REMOVE_HEAD(&sc->ti_jfree_listhead, jpool_entries);
1079 SLIST_INSERT_HEAD(&sc->ti_jinuse_listhead, entry, jpool_entries);
1080 return(sc->ti_cdata.ti_jslots[entry->slot]);
1081}
1082
1083/*
1084 * Release a jumbo buffer.
1085 */
1079static void ti_jfree(buf, args)
1086static void
1087ti_jfree(buf, args)
1080 void *buf;
1081 void *args;
1082{
1083 struct ti_softc *sc;
1084 int i;
1085 struct ti_jpool_entry *entry;
1086
1087 /* Extract the softc struct pointer. */

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

1107 return;
1108}
1109
1110#endif /* TI_PRIVATE_JUMBOS */
1111
1112/*
1113 * Intialize a standard receive ring descriptor.
1114 */
1088 void *buf;
1089 void *args;
1090{
1091 struct ti_softc *sc;
1092 int i;
1093 struct ti_jpool_entry *entry;
1094
1095 /* Extract the softc struct pointer. */

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

1115 return;
1116}
1117
1118#endif /* TI_PRIVATE_JUMBOS */
1119
1120/*
1121 * Intialize a standard receive ring descriptor.
1122 */
1115static int ti_newbuf_std(sc, i, m)
1123static int
1124ti_newbuf_std(sc, i, m)
1116 struct ti_softc *sc;
1117 int i;
1118 struct mbuf *m;
1119{
1120 struct mbuf *m_new = NULL;
1121 struct ti_rx_desc *r;
1122
1123 if (m == NULL) {

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

1150
1151 return(0);
1152}
1153
1154/*
1155 * Intialize a mini receive ring descriptor. This only applies to
1156 * the Tigon 2.
1157 */
1125 struct ti_softc *sc;
1126 int i;
1127 struct mbuf *m;
1128{
1129 struct mbuf *m_new = NULL;
1130 struct ti_rx_desc *r;
1131
1132 if (m == NULL) {

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

1159
1160 return(0);
1161}
1162
1163/*
1164 * Intialize a mini receive ring descriptor. This only applies to
1165 * the Tigon 2.
1166 */
1158static int ti_newbuf_mini(sc, i, m)
1167static int
1168ti_newbuf_mini(sc, i, m)
1159 struct ti_softc *sc;
1160 int i;
1161 struct mbuf *m;
1162{
1163 struct mbuf *m_new = NULL;
1164 struct ti_rx_desc *r;
1165
1166 if (m == NULL) {

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

1190}
1191
1192#ifdef TI_PRIVATE_JUMBOS
1193
1194/*
1195 * Initialize a jumbo receive ring descriptor. This allocates
1196 * a jumbo buffer from the pool managed internally by the driver.
1197 */
1169 struct ti_softc *sc;
1170 int i;
1171 struct mbuf *m;
1172{
1173 struct mbuf *m_new = NULL;
1174 struct ti_rx_desc *r;
1175
1176 if (m == NULL) {

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

1200}
1201
1202#ifdef TI_PRIVATE_JUMBOS
1203
1204/*
1205 * Initialize a jumbo receive ring descriptor. This allocates
1206 * a jumbo buffer from the pool managed internally by the driver.
1207 */
1198static int ti_newbuf_jumbo(sc, i, m)
1208static int
1209ti_newbuf_jumbo(sc, i, m)
1199 struct ti_softc *sc;
1200 int i;
1201 struct mbuf *m;
1202{
1203 struct mbuf *m_new = NULL;
1204 struct ti_rx_desc *r;
1205
1206 if (m == NULL) {

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

1395
1396
1397/*
1398 * The standard receive ring has 512 entries in it. At 2K per mbuf cluster,
1399 * that's 1MB or memory, which is a lot. For now, we fill only the first
1400 * 256 ring entries and hope that our CPU is fast enough to keep up with
1401 * the NIC.
1402 */
1210 struct ti_softc *sc;
1211 int i;
1212 struct mbuf *m;
1213{
1214 struct mbuf *m_new = NULL;
1215 struct ti_rx_desc *r;
1216
1217 if (m == NULL) {

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

1406
1407
1408/*
1409 * The standard receive ring has 512 entries in it. At 2K per mbuf cluster,
1410 * that's 1MB or memory, which is a lot. For now, we fill only the first
1411 * 256 ring entries and hope that our CPU is fast enough to keep up with
1412 * the NIC.
1413 */
1403static int ti_init_rx_ring_std(sc)
1414static int
1415ti_init_rx_ring_std(sc)
1404 struct ti_softc *sc;
1405{
1406 register int i;
1407 struct ti_cmd_desc cmd;
1408
1409 for (i = 0; i < TI_SSLOTS; i++) {
1410 if (ti_newbuf_std(sc, i, NULL) == ENOBUFS)
1411 return(ENOBUFS);
1412 };
1413
1414 TI_UPDATE_STDPROD(sc, i - 1);
1415 sc->ti_std = i - 1;
1416
1417 return(0);
1418}
1419
1416 struct ti_softc *sc;
1417{
1418 register int i;
1419 struct ti_cmd_desc cmd;
1420
1421 for (i = 0; i < TI_SSLOTS; i++) {
1422 if (ti_newbuf_std(sc, i, NULL) == ENOBUFS)
1423 return(ENOBUFS);
1424 };
1425
1426 TI_UPDATE_STDPROD(sc, i - 1);
1427 sc->ti_std = i - 1;
1428
1429 return(0);
1430}
1431
1420static void ti_free_rx_ring_std(sc)
1432static void
1433ti_free_rx_ring_std(sc)
1421 struct ti_softc *sc;
1422{
1423 register int i;
1424
1425 for (i = 0; i < TI_STD_RX_RING_CNT; i++) {
1426 if (sc->ti_cdata.ti_rx_std_chain[i] != NULL) {
1427 m_freem(sc->ti_cdata.ti_rx_std_chain[i]);
1428 sc->ti_cdata.ti_rx_std_chain[i] = NULL;
1429 }
1430 bzero((char *)&sc->ti_rdata->ti_rx_std_ring[i],
1431 sizeof(struct ti_rx_desc));
1432 }
1433
1434 return;
1435}
1436
1434 struct ti_softc *sc;
1435{
1436 register int i;
1437
1438 for (i = 0; i < TI_STD_RX_RING_CNT; i++) {
1439 if (sc->ti_cdata.ti_rx_std_chain[i] != NULL) {
1440 m_freem(sc->ti_cdata.ti_rx_std_chain[i]);
1441 sc->ti_cdata.ti_rx_std_chain[i] = NULL;
1442 }
1443 bzero((char *)&sc->ti_rdata->ti_rx_std_ring[i],
1444 sizeof(struct ti_rx_desc));
1445 }
1446
1447 return;
1448}
1449
1437static int ti_init_rx_ring_jumbo(sc)
1450static int
1451ti_init_rx_ring_jumbo(sc)
1438 struct ti_softc *sc;
1439{
1440 register int i;
1441 struct ti_cmd_desc cmd;
1442
1443 for (i = 0; i < TI_JUMBO_RX_RING_CNT; i++) {
1444 if (ti_newbuf_jumbo(sc, i, NULL) == ENOBUFS)
1445 return(ENOBUFS);
1446 };
1447
1448 TI_UPDATE_JUMBOPROD(sc, i - 1);
1449 sc->ti_jumbo = i - 1;
1450
1451 return(0);
1452}
1453
1452 struct ti_softc *sc;
1453{
1454 register int i;
1455 struct ti_cmd_desc cmd;
1456
1457 for (i = 0; i < TI_JUMBO_RX_RING_CNT; i++) {
1458 if (ti_newbuf_jumbo(sc, i, NULL) == ENOBUFS)
1459 return(ENOBUFS);
1460 };
1461
1462 TI_UPDATE_JUMBOPROD(sc, i - 1);
1463 sc->ti_jumbo = i - 1;
1464
1465 return(0);
1466}
1467
1454static void ti_free_rx_ring_jumbo(sc)
1468static void
1469ti_free_rx_ring_jumbo(sc)
1455 struct ti_softc *sc;
1456{
1457 register int i;
1458
1459 for (i = 0; i < TI_JUMBO_RX_RING_CNT; i++) {
1460 if (sc->ti_cdata.ti_rx_jumbo_chain[i] != NULL) {
1461 m_freem(sc->ti_cdata.ti_rx_jumbo_chain[i]);
1462 sc->ti_cdata.ti_rx_jumbo_chain[i] = NULL;
1463 }
1464 bzero((char *)&sc->ti_rdata->ti_rx_jumbo_ring[i],
1465 sizeof(struct ti_rx_desc));
1466 }
1467
1468 return;
1469}
1470
1470 struct ti_softc *sc;
1471{
1472 register int i;
1473
1474 for (i = 0; i < TI_JUMBO_RX_RING_CNT; i++) {
1475 if (sc->ti_cdata.ti_rx_jumbo_chain[i] != NULL) {
1476 m_freem(sc->ti_cdata.ti_rx_jumbo_chain[i]);
1477 sc->ti_cdata.ti_rx_jumbo_chain[i] = NULL;
1478 }
1479 bzero((char *)&sc->ti_rdata->ti_rx_jumbo_ring[i],
1480 sizeof(struct ti_rx_desc));
1481 }
1482
1483 return;
1484}
1485
1471static int ti_init_rx_ring_mini(sc)
1486static int
1487ti_init_rx_ring_mini(sc)
1472 struct ti_softc *sc;
1473{
1474 register int i;
1475
1476 for (i = 0; i < TI_MSLOTS; i++) {
1477 if (ti_newbuf_mini(sc, i, NULL) == ENOBUFS)
1478 return(ENOBUFS);
1479 };
1480
1481 TI_UPDATE_MINIPROD(sc, i - 1);
1482 sc->ti_mini = i - 1;
1483
1484 return(0);
1485}
1486
1488 struct ti_softc *sc;
1489{
1490 register int i;
1491
1492 for (i = 0; i < TI_MSLOTS; i++) {
1493 if (ti_newbuf_mini(sc, i, NULL) == ENOBUFS)
1494 return(ENOBUFS);
1495 };
1496
1497 TI_UPDATE_MINIPROD(sc, i - 1);
1498 sc->ti_mini = i - 1;
1499
1500 return(0);
1501}
1502
1487static void ti_free_rx_ring_mini(sc)
1503static void
1504ti_free_rx_ring_mini(sc)
1488 struct ti_softc *sc;
1489{
1490 register int i;
1491
1492 for (i = 0; i < TI_MINI_RX_RING_CNT; i++) {
1493 if (sc->ti_cdata.ti_rx_mini_chain[i] != NULL) {
1494 m_freem(sc->ti_cdata.ti_rx_mini_chain[i]);
1495 sc->ti_cdata.ti_rx_mini_chain[i] = NULL;
1496 }
1497 bzero((char *)&sc->ti_rdata->ti_rx_mini_ring[i],
1498 sizeof(struct ti_rx_desc));
1499 }
1500
1501 return;
1502}
1503
1505 struct ti_softc *sc;
1506{
1507 register int i;
1508
1509 for (i = 0; i < TI_MINI_RX_RING_CNT; i++) {
1510 if (sc->ti_cdata.ti_rx_mini_chain[i] != NULL) {
1511 m_freem(sc->ti_cdata.ti_rx_mini_chain[i]);
1512 sc->ti_cdata.ti_rx_mini_chain[i] = NULL;
1513 }
1514 bzero((char *)&sc->ti_rdata->ti_rx_mini_ring[i],
1515 sizeof(struct ti_rx_desc));
1516 }
1517
1518 return;
1519}
1520
1504static void ti_free_tx_ring(sc)
1521static void
1522ti_free_tx_ring(sc)
1505 struct ti_softc *sc;
1506{
1507 register int i;
1508
1509 if (sc->ti_rdata->ti_tx_ring == NULL)
1510 return;
1511
1512 for (i = 0; i < TI_TX_RING_CNT; i++) {
1513 if (sc->ti_cdata.ti_tx_chain[i] != NULL) {
1514 m_freem(sc->ti_cdata.ti_tx_chain[i]);
1515 sc->ti_cdata.ti_tx_chain[i] = NULL;
1516 }
1517 bzero((char *)&sc->ti_rdata->ti_tx_ring[i],
1518 sizeof(struct ti_tx_desc));
1519 }
1520
1521 return;
1522}
1523
1523 struct ti_softc *sc;
1524{
1525 register int i;
1526
1527 if (sc->ti_rdata->ti_tx_ring == NULL)
1528 return;
1529
1530 for (i = 0; i < TI_TX_RING_CNT; i++) {
1531 if (sc->ti_cdata.ti_tx_chain[i] != NULL) {
1532 m_freem(sc->ti_cdata.ti_tx_chain[i]);
1533 sc->ti_cdata.ti_tx_chain[i] = NULL;
1534 }
1535 bzero((char *)&sc->ti_rdata->ti_tx_ring[i],
1536 sizeof(struct ti_tx_desc));
1537 }
1538
1539 return;
1540}
1541
1524static int ti_init_tx_ring(sc)
1542static int
1543ti_init_tx_ring(sc)
1525 struct ti_softc *sc;
1526{
1527 sc->ti_txcnt = 0;
1528 sc->ti_tx_saved_considx = 0;
1529 CSR_WRITE_4(sc, TI_MB_SENDPROD_IDX, 0);
1530 return(0);
1531}
1532
1533/*
1534 * The Tigon 2 firmware has a new way to add/delete multicast addresses,
1535 * but we have to support the old way too so that Tigon 1 cards will
1536 * work.
1537 */
1544 struct ti_softc *sc;
1545{
1546 sc->ti_txcnt = 0;
1547 sc->ti_tx_saved_considx = 0;
1548 CSR_WRITE_4(sc, TI_MB_SENDPROD_IDX, 0);
1549 return(0);
1550}
1551
1552/*
1553 * The Tigon 2 firmware has a new way to add/delete multicast addresses,
1554 * but we have to support the old way too so that Tigon 1 cards will
1555 * work.
1556 */
1538void ti_add_mcast(sc, addr)
1557void
1558ti_add_mcast(sc, addr)
1539 struct ti_softc *sc;
1540 struct ether_addr *addr;
1541{
1542 struct ti_cmd_desc cmd;
1543 u_int16_t *m;
1544 u_int32_t ext[2] = {0, 0};
1545
1546 m = (u_int16_t *)&addr->octet[0];

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

1559 default:
1560 printf("ti%d: unknown hwrev\n", sc->ti_unit);
1561 break;
1562 }
1563
1564 return;
1565}
1566
1559 struct ti_softc *sc;
1560 struct ether_addr *addr;
1561{
1562 struct ti_cmd_desc cmd;
1563 u_int16_t *m;
1564 u_int32_t ext[2] = {0, 0};
1565
1566 m = (u_int16_t *)&addr->octet[0];

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

1579 default:
1580 printf("ti%d: unknown hwrev\n", sc->ti_unit);
1581 break;
1582 }
1583
1584 return;
1585}
1586
1567void ti_del_mcast(sc, addr)
1587void
1588ti_del_mcast(sc, addr)
1568 struct ti_softc *sc;
1569 struct ether_addr *addr;
1570{
1571 struct ti_cmd_desc cmd;
1572 u_int16_t *m;
1573 u_int32_t ext[2] = {0, 0};
1574
1575 m = (u_int16_t *)&addr->octet[0];

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

1602 * changes and at that point we only have the current list of addresses:
1603 * we only know the current state, not the previous state, so we don't
1604 * actually know what addresses were removed or added. The firmware has
1605 * state, but we can't get our grubby mits on it, and there is no 'delete
1606 * all multicast addresses' command. Hence, we have to maintain our own
1607 * state so we know what addresses have been programmed into the NIC at
1608 * any given time.
1609 */
1589 struct ti_softc *sc;
1590 struct ether_addr *addr;
1591{
1592 struct ti_cmd_desc cmd;
1593 u_int16_t *m;
1594 u_int32_t ext[2] = {0, 0};
1595
1596 m = (u_int16_t *)&addr->octet[0];

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

1623 * changes and at that point we only have the current list of addresses:
1624 * we only know the current state, not the previous state, so we don't
1625 * actually know what addresses were removed or added. The firmware has
1626 * state, but we can't get our grubby mits on it, and there is no 'delete
1627 * all multicast addresses' command. Hence, we have to maintain our own
1628 * state so we know what addresses have been programmed into the NIC at
1629 * any given time.
1630 */
1610static void ti_setmulti(sc)
1631static void
1632ti_setmulti(sc)
1611 struct ti_softc *sc;
1612{
1613 struct ifnet *ifp;
1614 struct ifmultiaddr *ifma;
1615 struct ti_cmd_desc cmd;
1616 struct ti_mc_entry *mc;
1617 u_int32_t intrs;
1618

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

1680
1681 return(0);
1682}
1683
1684/*
1685 * Do endian, PCI and DMA initialization. Also check the on-board ROM
1686 * self-test results.
1687 */
1633 struct ti_softc *sc;
1634{
1635 struct ifnet *ifp;
1636 struct ifmultiaddr *ifma;
1637 struct ti_cmd_desc cmd;
1638 struct ti_mc_entry *mc;
1639 u_int32_t intrs;
1640

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

1702
1703 return(0);
1704}
1705
1706/*
1707 * Do endian, PCI and DMA initialization. Also check the on-board ROM
1708 * self-test results.
1709 */
1688static int ti_chipinit(sc)
1710static int
1711ti_chipinit(sc)
1689 struct ti_softc *sc;
1690{
1691 u_int32_t cacheline;
1692 u_int32_t pci_writemax = 0;
1693 u_int32_t hdrsplit;
1694
1695 /* Initialize link to down state. */
1696 sc->ti_linkstat = TI_EV_CODE_LINK_DOWN;

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

1844
1845 return(0);
1846}
1847
1848/*
1849 * Initialize the general information block and firmware, and
1850 * start the CPU(s) running.
1851 */
1712 struct ti_softc *sc;
1713{
1714 u_int32_t cacheline;
1715 u_int32_t pci_writemax = 0;
1716 u_int32_t hdrsplit;
1717
1718 /* Initialize link to down state. */
1719 sc->ti_linkstat = TI_EV_CODE_LINK_DOWN;

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

1867
1868 return(0);
1869}
1870
1871/*
1872 * Initialize the general information block and firmware, and
1873 * start the CPU(s) running.
1874 */
1852static int ti_gibinit(sc)
1875static int
1876ti_gibinit(sc)
1853 struct ti_softc *sc;
1854{
1855 struct ti_rcb *rcb;
1856 int i;
1857 struct ifnet *ifp;
1858
1859 ifp = &sc->arpcom.ac_if;
1860

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

2017
2018 return(0);
2019}
2020
2021/*
2022 * Probe for a Tigon chip. Check the PCI vendor and device IDs
2023 * against our list and return its name if we find a match.
2024 */
1877 struct ti_softc *sc;
1878{
1879 struct ti_rcb *rcb;
1880 int i;
1881 struct ifnet *ifp;
1882
1883 ifp = &sc->arpcom.ac_if;
1884

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

2041
2042 return(0);
2043}
2044
2045/*
2046 * Probe for a Tigon chip. Check the PCI vendor and device IDs
2047 * against our list and return its name if we find a match.
2048 */
2025static int ti_probe(dev)
2049static int
2050ti_probe(dev)
2026 device_t dev;
2027{
2028 struct ti_type *t;
2029
2030 t = ti_devs;
2031
2032 while(t->ti_name != NULL) {
2033 if ((pci_get_vendor(dev) == t->ti_vid) &&

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

2068 (int)mbstat.m_msize);
2069 return(EINVAL);
2070 }
2071 return(0);
2072}
2073#endif
2074
2075
2051 device_t dev;
2052{
2053 struct ti_type *t;
2054
2055 t = ti_devs;
2056
2057 while(t->ti_name != NULL) {
2058 if ((pci_get_vendor(dev) == t->ti_vid) &&

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

2093 (int)mbstat.m_msize);
2094 return(EINVAL);
2095 }
2096 return(0);
2097}
2098#endif
2099
2100
2076static int ti_attach(dev)
2101static int
2102ti_attach(dev)
2077 device_t dev;
2078{
2079 u_int32_t command;
2080 struct ifnet *ifp;
2081 struct ti_softc *sc;
2082 int unit, error = 0, rid;
2083
2084 sc = NULL;

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

2371 }
2372 /* now we know that there's a vnode in the cache. We hunt it
2373 down and kill it now, before unloading */
2374 vgone(ti_vn);
2375 return(0);
2376}
2377
2378
2103 device_t dev;
2104{
2105 u_int32_t command;
2106 struct ifnet *ifp;
2107 struct ti_softc *sc;
2108 int unit, error = 0, rid;
2109
2110 sc = NULL;

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

2397 }
2398 /* now we know that there's a vnode in the cache. We hunt it
2399 down and kill it now, before unloading */
2400 vgone(ti_vn);
2401 return(0);
2402}
2403
2404
2379static int ti_detach(dev)
2405static int
2406ti_detach(dev)
2380 device_t dev;
2381{
2382 struct ti_softc *sc;
2383 struct ifnet *ifp;
2384
2385 if (ti_unref_special(dev))
2386 return EBUSY;
2387

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

2471 *
2472 * Note: we have to be able to handle three possibilities here:
2473 * 1) the frame is from the mini receive ring (can only happen)
2474 * on Tigon 2 boards)
2475 * 2) the frame is from the jumbo recieve ring
2476 * 3) the frame is from the standard receive ring
2477 */
2478
2407 device_t dev;
2408{
2409 struct ti_softc *sc;
2410 struct ifnet *ifp;
2411
2412 if (ti_unref_special(dev))
2413 return EBUSY;
2414

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

2498 *
2499 * Note: we have to be able to handle three possibilities here:
2500 * 1) the frame is from the mini receive ring (can only happen)
2501 * on Tigon 2 boards)
2502 * 2) the frame is from the jumbo recieve ring
2503 * 3) the frame is from the standard receive ring
2504 */
2505
2479static void ti_rxeof(sc)
2506static void
2507ti_rxeof(sc)
2480 struct ti_softc *sc;
2481{
2482 struct ifnet *ifp;
2483 struct ti_cmd_desc cmd;
2484
2485 ifp = &sc->arpcom.ac_if;
2486
2487 while(sc->ti_rx_saved_considx != sc->ti_return_prodidx.ti_idx) {

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

2595
2596 TI_UPDATE_STDPROD(sc, sc->ti_std);
2597 TI_UPDATE_MINIPROD(sc, sc->ti_mini);
2598 TI_UPDATE_JUMBOPROD(sc, sc->ti_jumbo);
2599
2600 return;
2601}
2602
2508 struct ti_softc *sc;
2509{
2510 struct ifnet *ifp;
2511 struct ti_cmd_desc cmd;
2512
2513 ifp = &sc->arpcom.ac_if;
2514
2515 while(sc->ti_rx_saved_considx != sc->ti_return_prodidx.ti_idx) {

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

2623
2624 TI_UPDATE_STDPROD(sc, sc->ti_std);
2625 TI_UPDATE_MINIPROD(sc, sc->ti_mini);
2626 TI_UPDATE_JUMBOPROD(sc, sc->ti_jumbo);
2627
2628 return;
2629}
2630
2603static void ti_txeof(sc)
2631static void
2632ti_txeof(sc)
2604 struct ti_softc *sc;
2605{
2606 struct ti_tx_desc *cur_tx = NULL;
2607 struct ifnet *ifp;
2608
2609 ifp = &sc->arpcom.ac_if;
2610
2611 /*

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

2644 }
2645
2646 if (cur_tx != NULL)
2647 ifp->if_flags &= ~IFF_OACTIVE;
2648
2649 return;
2650}
2651
2633 struct ti_softc *sc;
2634{
2635 struct ti_tx_desc *cur_tx = NULL;
2636 struct ifnet *ifp;
2637
2638 ifp = &sc->arpcom.ac_if;
2639
2640 /*

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

2673 }
2674
2675 if (cur_tx != NULL)
2676 ifp->if_flags &= ~IFF_OACTIVE;
2677
2678 return;
2679}
2680
2652static void ti_intr(xsc)
2681static void
2682ti_intr(xsc)
2653 void *xsc;
2654{
2655 struct ti_softc *sc;
2656 struct ifnet *ifp;
2657
2658 sc = xsc;
2659 TI_LOCK(sc);
2660 ifp = &sc->arpcom.ac_if;

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

2687 if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL)
2688 ti_start(ifp);
2689
2690 TI_UNLOCK(sc);
2691
2692 return;
2693}
2694
2683 void *xsc;
2684{
2685 struct ti_softc *sc;
2686 struct ifnet *ifp;
2687
2688 sc = xsc;
2689 TI_LOCK(sc);
2690 ifp = &sc->arpcom.ac_if;

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

2717 if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL)
2718 ti_start(ifp);
2719
2720 TI_UNLOCK(sc);
2721
2722 return;
2723}
2724
2695static void ti_stats_update(sc)
2725static void
2726ti_stats_update(sc)
2696 struct ti_softc *sc;
2697{
2698 struct ifnet *ifp;
2699
2700 ifp = &sc->arpcom.ac_if;
2701
2702 ifp->if_collisions +=
2703 (sc->ti_rdata->ti_info.ti_stats.dot3StatsSingleCollisionFrames +

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

2708
2709 return;
2710}
2711
2712/*
2713 * Encapsulate an mbuf chain in the tx ring by coupling the mbuf data
2714 * pointers to descriptors.
2715 */
2727 struct ti_softc *sc;
2728{
2729 struct ifnet *ifp;
2730
2731 ifp = &sc->arpcom.ac_if;
2732
2733 ifp->if_collisions +=
2734 (sc->ti_rdata->ti_info.ti_stats.dot3StatsSingleCollisionFrames +

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

2739
2740 return;
2741}
2742
2743/*
2744 * Encapsulate an mbuf chain in the tx ring by coupling the mbuf data
2745 * pointers to descriptors.
2746 */
2716static int ti_encap(sc, m_head, txidx)
2747static int
2748ti_encap(sc, m_head, txidx)
2717 struct ti_softc *sc;
2718 struct mbuf *m_head;
2719 u_int32_t *txidx;
2720{
2721 struct ti_tx_desc *f = NULL;
2722 struct mbuf *m;
2723 u_int32_t frag, cur, cnt = 0;
2724 u_int16_t csum_flags = 0;

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

2808
2809 return(0);
2810}
2811
2812/*
2813 * Main transmit routine. To avoid having to do mbuf copies, we put pointers
2814 * to the mbuf data regions directly in the transmit descriptors.
2815 */
2749 struct ti_softc *sc;
2750 struct mbuf *m_head;
2751 u_int32_t *txidx;
2752{
2753 struct ti_tx_desc *f = NULL;
2754 struct mbuf *m;
2755 u_int32_t frag, cur, cnt = 0;
2756 u_int16_t csum_flags = 0;

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

2840
2841 return(0);
2842}
2843
2844/*
2845 * Main transmit routine. To avoid having to do mbuf copies, we put pointers
2846 * to the mbuf data regions directly in the transmit descriptors.
2847 */
2816static void ti_start(ifp)
2848static void
2849ti_start(ifp)
2817 struct ifnet *ifp;
2818{
2819 struct ti_softc *sc;
2820 struct mbuf *m_head = NULL;
2821 u_int32_t prodidx = 0;
2822
2823 sc = ifp->if_softc;
2824 TI_LOCK(sc);

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

2874 * Set a timeout in case the chip goes out to lunch.
2875 */
2876 ifp->if_timer = 5;
2877 TI_UNLOCK(sc);
2878
2879 return;
2880}
2881
2850 struct ifnet *ifp;
2851{
2852 struct ti_softc *sc;
2853 struct mbuf *m_head = NULL;
2854 u_int32_t prodidx = 0;
2855
2856 sc = ifp->if_softc;
2857 TI_LOCK(sc);

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

2907 * Set a timeout in case the chip goes out to lunch.
2908 */
2909 ifp->if_timer = 5;
2910 TI_UNLOCK(sc);
2911
2912 return;
2913}
2914
2882static void ti_init(xsc)
2915static void
2916ti_init(xsc)
2883 void *xsc;
2884{
2885 struct ti_softc *sc = xsc;
2886
2887 /* Cancel pending I/O and flush buffers. */
2888 ti_stop(sc);
2889
2890 TI_LOCK(sc);

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

2983 ifm->ifm_media = tmp;
2984
2985 return;
2986}
2987
2988/*
2989 * Set media options.
2990 */
2917 void *xsc;
2918{
2919 struct ti_softc *sc = xsc;
2920
2921 /* Cancel pending I/O and flush buffers. */
2922 ti_stop(sc);
2923
2924 TI_LOCK(sc);

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

3017 ifm->ifm_media = tmp;
3018
3019 return;
3020}
3021
3022/*
3023 * Set media options.
3024 */
2991static int ti_ifmedia_upd(ifp)
3025static int
3026ti_ifmedia_upd(ifp)
2992 struct ifnet *ifp;
2993{
2994 struct ti_softc *sc;
2995 struct ifmedia *ifm;
2996 struct ti_cmd_desc cmd;
2997 u_int32_t flowctl;
2998
2999 sc = ifp->if_softc;

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

3084 }
3085
3086 return(0);
3087}
3088
3089/*
3090 * Report current media status.
3091 */
3027 struct ifnet *ifp;
3028{
3029 struct ti_softc *sc;
3030 struct ifmedia *ifm;
3031 struct ti_cmd_desc cmd;
3032 u_int32_t flowctl;
3033
3034 sc = ifp->if_softc;

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

3119 }
3120
3121 return(0);
3122}
3123
3124/*
3125 * Report current media status.
3126 */
3092static void ti_ifmedia_sts(ifp, ifmr)
3127static void
3128ti_ifmedia_sts(ifp, ifmr)
3093 struct ifnet *ifp;
3094 struct ifmediareq *ifmr;
3095{
3096 struct ti_softc *sc;
3097 u_int32_t media = 0;
3098
3099 sc = ifp->if_softc;
3100

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

3133 ifmr->ifm_active |= IFM_FDX;
3134 if (media & TI_LNK_HALF_DUPLEX)
3135 ifmr->ifm_active |= IFM_HDX;
3136 }
3137
3138 return;
3139}
3140
3129 struct ifnet *ifp;
3130 struct ifmediareq *ifmr;
3131{
3132 struct ti_softc *sc;
3133 u_int32_t media = 0;
3134
3135 sc = ifp->if_softc;
3136

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

3169 ifmr->ifm_active |= IFM_FDX;
3170 if (media & TI_LNK_HALF_DUPLEX)
3171 ifmr->ifm_active |= IFM_HDX;
3172 }
3173
3174 return;
3175}
3176
3141static int ti_ioctl(ifp, command, data)
3177static int
3178ti_ioctl(ifp, command, data)
3142 struct ifnet *ifp;
3143 u_long command;
3144 caddr_t data;
3145{
3146 struct ti_softc *sc = ifp->if_softc;
3147 struct ifreq *ifr = (struct ifreq *) data;
3148 int mask, error = 0;
3149 struct ti_cmd_desc cmd;

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

3528 }
3529 default:
3530 error = ENOTTY;
3531 break;
3532 }
3533 return(error);
3534}
3535
3179 struct ifnet *ifp;
3180 u_long command;
3181 caddr_t data;
3182{
3183 struct ti_softc *sc = ifp->if_softc;
3184 struct ifreq *ifr = (struct ifreq *) data;
3185 int mask, error = 0;
3186 struct ti_cmd_desc cmd;

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

3565 }
3566 default:
3567 error = ENOTTY;
3568 break;
3569 }
3570 return(error);
3571}
3572
3536static void ti_watchdog(ifp)
3573static void
3574ti_watchdog(ifp)
3537 struct ifnet *ifp;
3538{
3539 struct ti_softc *sc;
3540
3541 sc = ifp->if_softc;
3542 TI_LOCK(sc);
3543
3544 /*

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

3560
3561 return;
3562}
3563
3564/*
3565 * Stop the adapter and free any mbufs allocated to the
3566 * RX and TX lists.
3567 */
3575 struct ifnet *ifp;
3576{
3577 struct ti_softc *sc;
3578
3579 sc = ifp->if_softc;
3580 TI_LOCK(sc);
3581
3582 /*

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

3598
3599 return;
3600}
3601
3602/*
3603 * Stop the adapter and free any mbufs allocated to the
3604 * RX and TX lists.
3605 */
3568static void ti_stop(sc)
3606static void
3607ti_stop(sc)
3569 struct ti_softc *sc;
3570{
3571 struct ifnet *ifp;
3572 struct ti_cmd_desc cmd;
3573
3574 TI_LOCK(sc);
3575
3576 ifp = &sc->arpcom.ac_if;

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

3609
3610 return;
3611}
3612
3613/*
3614 * Stop all chip I/O so that the kernel's probe routines don't
3615 * get confused by errant DMAs when rebooting.
3616 */
3608 struct ti_softc *sc;
3609{
3610 struct ifnet *ifp;
3611 struct ti_cmd_desc cmd;
3612
3613 TI_LOCK(sc);
3614
3615 ifp = &sc->arpcom.ac_if;

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

3648
3649 return;
3650}
3651
3652/*
3653 * Stop all chip I/O so that the kernel's probe routines don't
3654 * get confused by errant DMAs when rebooting.
3655 */
3617static void ti_shutdown(dev)
3656static void
3657ti_shutdown(dev)
3618 device_t dev;
3619{
3620 struct ti_softc *sc;
3621
3622 sc = device_get_softc(dev);
3623 TI_LOCK(sc);
3624 ti_chipinit(sc);
3625 TI_UNLOCK(sc);
3626
3627 return;
3628}
3658 device_t dev;
3659{
3660 struct ti_softc *sc;
3661
3662 sc = device_get_softc(dev);
3663 TI_LOCK(sc);
3664 ti_chipinit(sc);
3665 TI_UNLOCK(sc);
3666
3667 return;
3668}