Changeset 28761
- Timestamp:
- 12/02/08 12:52:30 (5 weeks ago)
- Location:
- haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev
- Files:
-
- 1 removed
- 4 modified
-
mii/Jamfile (modified) (1 diff)
-
mii/miidevs.h (deleted)
-
nfe/if_nfe.c (modified) (36 diffs)
-
nfe/if_nfereg.h (modified) (6 diffs)
-
nfe/if_nfevar.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/mii/Jamfile
r23124 r28761 14 14 ukphy_subr.c 15 15 ; 16 17 ObjectHdrs [ FGristFiles ciphy$(SUFOBJ) ] 18 : [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) libs compat freebsd_network ] ; 19 Includes [ FGristFiles ciphy.c ] : <src!libs!compat!freebsd_network>miidevs.h ; -
haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/if_nfe.c
r23124 r28761 22 22 23 23 #include <sys/cdefs.h> 24 __FBSDID("$FreeBSD: src/sys/dev/nfe/if_nfe.c,v 1. 21 2007/09/14 05:12:25yongari Exp $");24 __FBSDID("$FreeBSD: src/sys/dev/nfe/if_nfe.c,v 1.30 2008/10/03 03:58:16 yongari Exp $"); 25 25 26 26 #ifdef HAVE_KERNEL_OPTION_HEADERS … … 77 77 static int nfe_suspend(device_t); 78 78 static int nfe_resume(device_t); 79 static voidnfe_shutdown(device_t);79 static int nfe_shutdown(device_t); 80 80 static void nfe_power(struct nfe_softc *); 81 81 static int nfe_miibus_readreg(device_t, int, int); … … 90 90 static int nfe_intr(void *); 91 91 static void nfe_int_task(void *, int); 92 static void *nfe_jalloc(struct nfe_softc *);93 static void nfe_jfree(void *, void *);94 92 static __inline void nfe_discard_rxbuf(struct nfe_softc *, int); 95 93 static __inline void nfe_discard_jrxbuf(struct nfe_softc *, int); … … 99 97 static int nfe_jrxeof(struct nfe_softc *, int); 100 98 static void nfe_txeof(struct nfe_softc *); 101 static struct mbuf *nfe_defrag(struct mbuf *, int, int);102 99 static int nfe_encap(struct nfe_softc *, struct mbuf **); 103 100 static void nfe_setmulti(struct nfe_softc *); … … 126 123 static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); 127 124 static int sysctl_hw_nfe_proc_limit(SYSCTL_HANDLER_ARGS); 125 static void nfe_sysctl_node(struct nfe_softc *); 126 static void nfe_stats_clear(struct nfe_softc *); 127 static void nfe_stats_update(struct nfe_softc *); 128 128 129 129 #ifdef NFE_DEBUG … … 145 145 #define NFE_UNLOCK(_sc) mtx_unlock(&(_sc)->nfe_mtx) 146 146 #define NFE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->nfe_mtx, MA_OWNED) 147 148 #define NFE_JLIST_LOCK(_sc) mtx_lock(&(_sc)->nfe_jlist_mtx)149 #define NFE_JLIST_UNLOCK(_sc) mtx_unlock(&(_sc)->nfe_jlist_mtx)150 147 151 148 /* Tunables. */ … … 244 241 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN4, 245 242 "NVIDIA nForce MCP67 Networking Adapter"}, 243 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN1, 244 "NVIDIA nForce MCP73 Networking Adapter"}, 245 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN2, 246 "NVIDIA nForce MCP73 Networking Adapter"}, 247 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN3, 248 "NVIDIA nForce MCP73 Networking Adapter"}, 249 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN4, 250 "NVIDIA nForce MCP73 Networking Adapter"}, 251 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_LAN1, 252 "NVIDIA nForce MCP77 Networking Adapter"}, 253 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_LAN2, 254 "NVIDIA nForce MCP77 Networking Adapter"}, 255 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_LAN3, 256 "NVIDIA nForce MCP77 Networking Adapter"}, 257 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_LAN4, 258 "NVIDIA nForce MCP77 Networking Adapter"}, 259 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_LAN1, 260 "NVIDIA nForce MCP79 Networking Adapter"}, 261 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_LAN2, 262 "NVIDIA nForce MCP79 Networking Adapter"}, 263 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_LAN3, 264 "NVIDIA nForce MCP79 Networking Adapter"}, 265 {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_LAN4, 266 "NVIDIA nForce MCP79 Networking Adapter"}, 246 267 {0, 0, NULL} 247 268 }; … … 327 348 mtx_init(&sc->nfe_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 328 349 MTX_DEF); 329 mtx_init(&sc->nfe_jlist_mtx, "nfe_jlist_mtx", NULL, MTX_DEF);330 350 callout_init_mtx(&sc->nfe_stat_ch, &sc->nfe_mtx, 0); 331 351 TASK_INIT(&sc->nfe_link_task, 0, nfe_link_task, sc); 332 SLIST_INIT(&sc->nfe_jfree_listhead);333 SLIST_INIT(&sc->nfe_jinuse_listhead);334 352 335 353 pci_enable_busmaster(dev); … … 440 458 case PCI_PRODUCT_NVIDIA_MCP51_LAN1: 441 459 case PCI_PRODUCT_NVIDIA_MCP51_LAN2: 442 sc->nfe_flags |= NFE_40BIT_ADDR | NFE_PWR_MGMT ;460 sc->nfe_flags |= NFE_40BIT_ADDR | NFE_PWR_MGMT | NFE_MIB_V1; 443 461 break; 444 462 case PCI_PRODUCT_NVIDIA_CK804_LAN1: … … 446 464 case PCI_PRODUCT_NVIDIA_MCP04_LAN1: 447 465 case PCI_PRODUCT_NVIDIA_MCP04_LAN2: 448 sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM; 466 sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM | 467 NFE_MIB_V1; 449 468 break; 450 469 case PCI_PRODUCT_NVIDIA_MCP55_LAN1: 451 470 case PCI_PRODUCT_NVIDIA_MCP55_LAN2: 452 471 sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM | 453 NFE_HW_VLAN | NFE_PWR_MGMT | NFE_TX_FLOW_CTRL ;472 NFE_HW_VLAN | NFE_PWR_MGMT | NFE_TX_FLOW_CTRL | NFE_MIB_V2; 454 473 break; 455 474 … … 462 481 case PCI_PRODUCT_NVIDIA_MCP67_LAN3: 463 482 case PCI_PRODUCT_NVIDIA_MCP67_LAN4: 483 case PCI_PRODUCT_NVIDIA_MCP73_LAN1: 484 case PCI_PRODUCT_NVIDIA_MCP73_LAN2: 485 case PCI_PRODUCT_NVIDIA_MCP73_LAN3: 486 case PCI_PRODUCT_NVIDIA_MCP73_LAN4: 464 487 sc->nfe_flags |= NFE_40BIT_ADDR | NFE_PWR_MGMT | 465 NFE_TX_FLOW_CTRL; 488 NFE_CORRECT_MACADDR | NFE_TX_FLOW_CTRL | NFE_MIB_V2; 489 break; 490 case PCI_PRODUCT_NVIDIA_MCP77_LAN1: 491 case PCI_PRODUCT_NVIDIA_MCP77_LAN2: 492 case PCI_PRODUCT_NVIDIA_MCP77_LAN3: 493 case PCI_PRODUCT_NVIDIA_MCP77_LAN4: 494 /* XXX flow control */ 495 sc->nfe_flags |= NFE_40BIT_ADDR | NFE_HW_CSUM | NFE_PWR_MGMT | 496 NFE_CORRECT_MACADDR | NFE_MIB_V3; 497 break; 498 case PCI_PRODUCT_NVIDIA_MCP79_LAN1: 499 case PCI_PRODUCT_NVIDIA_MCP79_LAN2: 500 case PCI_PRODUCT_NVIDIA_MCP79_LAN3: 501 case PCI_PRODUCT_NVIDIA_MCP79_LAN4: 502 /* XXX flow control */ 503 sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM | 504 NFE_PWR_MGMT | NFE_CORRECT_MACADDR | NFE_MIB_V3; 466 505 break; 467 506 case PCI_PRODUCT_NVIDIA_MCP65_LAN1: … … 470 509 case PCI_PRODUCT_NVIDIA_MCP65_LAN4: 471 510 sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | 472 NFE_PWR_MGMT | NFE_TX_FLOW_CTRL; 511 NFE_PWR_MGMT | NFE_CORRECT_MACADDR | NFE_TX_FLOW_CTRL | 512 NFE_MIB_V2; 473 513 break; 474 514 } … … 517 557 518 558 nfe_alloc_jrx_ring(sc, &sc->jrxq); 519 520 SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), 521 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), 522 OID_AUTO, "process_limit", CTLTYPE_INT | CTLFLAG_RW, 523 &sc->nfe_process_limit, 0, sysctl_hw_nfe_proc_limit, "I", 524 "max number of Rx events to process"); 525 526 sc->nfe_process_limit = NFE_PROC_DEFAULT; 527 error = resource_int_value(device_get_name(dev), device_get_unit(dev), 528 "process_limit", &sc->nfe_process_limit); 529 if (error == 0) { 530 if (sc->nfe_process_limit < NFE_PROC_MIN || 531 sc->nfe_process_limit > NFE_PROC_MAX) { 532 device_printf(dev, "process_limit value out of range; " 533 "using default: %d\n", NFE_PROC_DEFAULT); 534 sc->nfe_process_limit = NFE_PROC_DEFAULT; 535 } 536 } 559 /* Create sysctl node. */ 560 nfe_sysctl_node(sc); 537 561 538 562 ifp->if_softc = sc; … … 715 739 } 716 740 717 mtx_destroy(&sc->nfe_jlist_mtx);718 741 mtx_destroy(&sc->nfe_mtx); 719 742 … … 983 1006 } 984 1007 985 /*986 * Allocate a jumbo buffer.987 */988 static void *989 nfe_jalloc(struct nfe_softc *sc)990 {991 struct nfe_jpool_entry *entry;992 993 NFE_JLIST_LOCK(sc);994 995 entry = SLIST_FIRST(&sc->nfe_jfree_listhead);996 997 if (entry == NULL) {998 NFE_JLIST_UNLOCK(sc);999 return (NULL);1000 }1001 1002 SLIST_REMOVE_HEAD(&sc->nfe_jfree_listhead, jpool_entries);1003 SLIST_INSERT_HEAD(&sc->nfe_jinuse_listhead, entry, jpool_entries);1004 1005 NFE_JLIST_UNLOCK(sc);1006 1007 return (sc->jrxq.jslots[entry->slot]);1008 }1009 1010 /*1011 * Release a jumbo buffer.1012 */1013 static void1014 nfe_jfree(void *buf, void *args)1015 {1016 struct nfe_softc *sc;1017 struct nfe_jpool_entry *entry;1018 int i;1019 1020 /* Extract the softc struct pointer. */1021 sc = (struct nfe_softc *)args;1022 KASSERT(sc != NULL, ("%s: can't find softc pointer!", __func__));1023 1024 NFE_JLIST_LOCK(sc);1025 /* Calculate the slot this buffer belongs to. */1026 i = ((vm_offset_t)buf1027 - (vm_offset_t)sc->jrxq.jpool) / NFE_JLEN;1028 KASSERT(i >= 0 && i < NFE_JSLOTS,1029 ("%s: asked to free buffer that we don't manage!", __func__));1030 1031 entry = SLIST_FIRST(&sc->nfe_jinuse_listhead);1032 KASSERT(entry != NULL, ("%s: buffer not in use!", __func__));1033 entry->slot = i;1034 SLIST_REMOVE_HEAD(&sc->nfe_jinuse_listhead, jpool_entries);1035 SLIST_INSERT_HEAD(&sc->nfe_jfree_listhead, entry, jpool_entries);1036 if (SLIST_EMPTY(&sc->nfe_jinuse_listhead))1037 wakeup(sc);1038 1039 NFE_JLIST_UNLOCK(sc);1040 }1041 1042 1008 struct nfe_dmamap_arg { 1043 1009 bus_addr_t nfe_busaddr; … … 1148 1114 struct nfe_rx_data *data; 1149 1115 void *desc; 1150 struct nfe_jpool_entry *entry;1151 uint8_t *ptr;1152 1116 int i, error, descsize; 1153 1117 … … 1188 1152 } 1189 1153 1190 /* Create DMA tag for jumbo buffer blocks. */1191 error = bus_dma_tag_create(sc->nfe_parent_tag,1192 PAGE_SIZE, 0, /* alignment, boundary */1193 BUS_SPACE_MAXADDR, /* lowaddr */1194 BUS_SPACE_MAXADDR, /* highaddr */1195 NULL, NULL, /* filter, filterarg */1196 NFE_JMEM, /* maxsize */1197 1, /* nsegments */1198 NFE_JMEM, /* maxsegsize */1199 0, /* flags */1200 NULL, NULL, /* lockfunc, lockarg */1201 &ring->jrx_jumbo_tag);1202 if (error != 0) {1203 device_printf(sc->nfe_dev,1204 "could not create jumbo Rx buffer block DMA tag\n");1205 goto fail;1206 }1207 1208 1154 /* Create DMA tag for jumbo Rx buffers. */ 1209 1155 error = bus_dma_tag_create(sc->nfe_parent_tag, … … 1212 1158 BUS_SPACE_MAXADDR, /* highaddr */ 1213 1159 NULL, NULL, /* filter, filterarg */ 1214 NFE_JLEN, /* maxsize */1160 MJUM9BYTES, /* maxsize */ 1215 1161 1, /* nsegments */ 1216 NFE_JLEN, /* maxsegsize */1162 MJUM9BYTES, /* maxsegsize */ 1217 1163 0, /* flags */ 1218 1164 NULL, NULL, /* lockfunc, lockarg */ … … 1268 1214 } 1269 1215 1270 /* Allocate DMA'able memory and load the DMA map for jumbo buf. */1271 error = bus_dmamem_alloc(ring->jrx_jumbo_tag, (void **)&ring->jpool,1272 BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO,1273 &ring->jrx_jumbo_map);1274 if (error != 0) {1275 device_printf(sc->nfe_dev,1276 "could not allocate DMA'able memory for jumbo pool\n");1277 goto fail;1278 }1279 1280 ctx.nfe_busaddr = 0;1281 error = bus_dmamap_load(ring->jrx_jumbo_tag, ring->jrx_jumbo_map,1282 ring->jpool, NFE_JMEM, nfe_dma_map_segs, &ctx, 0);1283 if (error != 0) {1284 device_printf(sc->nfe_dev,1285 "could not load DMA'able memory for jumbo pool\n");1286 goto fail;1287 }1288 1289 /*1290 * Now divide it up into 9K pieces and save the addresses1291 * in an array.1292 */1293 ptr = ring->jpool;1294 for (i = 0; i < NFE_JSLOTS; i++) {1295 ring->jslots[i] = ptr;1296 ptr += NFE_JLEN;1297 entry = malloc(sizeof(struct nfe_jpool_entry), M_DEVBUF,1298 M_WAITOK);1299 if (entry == NULL) {1300 device_printf(sc->nfe_dev,1301 "no memory for jumbo buffers!\n");1302 error = ENOMEM;1303 goto fail;1304 }1305 entry->slot = i;1306 SLIST_INSERT_HEAD(&sc->nfe_jfree_listhead, entry,1307 jpool_entries);1308 }1309 1310 1216 return; 1311 1217 … … 1365 1271 descsize = sizeof (struct nfe_desc32); 1366 1272 } 1367 bzero(desc, descsize * NFE_ RX_RING_COUNT);1273 bzero(desc, descsize * NFE_JUMBO_RX_RING_COUNT); 1368 1274 for (i = 0; i < NFE_JUMBO_RX_RING_COUNT; i++) { 1369 1275 if (nfe_jnewbuf(sc, i) != 0) … … 1432 1338 nfe_free_jrx_ring(struct nfe_softc *sc, struct nfe_jrx_ring *ring) 1433 1339 { 1434 struct nfe_jpool_entry *entry;1435 1340 struct nfe_rx_data *data; 1436 1341 void *desc; … … 1439 1344 if ((sc->nfe_flags & NFE_JUMBO_SUP) == 0) 1440 1345 return; 1441 1442 NFE_JLIST_LOCK(sc);1443 while ((entry = SLIST_FIRST(&sc->nfe_jinuse_listhead))) {1444 device_printf(sc->nfe_dev,1445 "asked to free buffer that is in use!\n");1446 SLIST_REMOVE_HEAD(&sc->nfe_jinuse_listhead, jpool_entries);1447 SLIST_INSERT_HEAD(&sc->nfe_jfree_listhead, entry,1448 jpool_entries);1449 }1450 1451 while (!SLIST_EMPTY(&sc->nfe_jfree_listhead)) {1452 entry = SLIST_FIRST(&sc->nfe_jfree_listhead);1453 SLIST_REMOVE_HEAD(&sc->nfe_jfree_listhead, jpool_entries);1454 free(entry, M_DEVBUF);1455 }1456 NFE_JLIST_UNLOCK(sc);1457 1346 1458 1347 if (sc->nfe_flags & NFE_40BIT_ADDR) { … … 1493 1382 ring->jrx_desc_map = NULL; 1494 1383 } 1495 /* Destroy jumbo buffer block. */ 1496 if (ring->jrx_jumbo_map != NULL) 1497 bus_dmamap_unload(ring->jrx_jumbo_tag, ring->jrx_jumbo_map); 1498 if (ring->jrx_jumbo_map != NULL) { 1499 bus_dmamem_free(ring->jrx_jumbo_tag, ring->jpool, 1500 ring->jrx_jumbo_map); 1501 ring->jpool = NULL; 1502 ring->jrx_jumbo_map = NULL; 1503 } 1384 1504 1385 if (ring->jrx_desc_tag != NULL) { 1505 1386 bus_dma_tag_destroy(ring->jrx_desc_tag); … … 1690 1571 nfe_txeof(sc); 1691 1572 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) 1692 taskqueue_enqueue_fast( taskqueue_fast, &sc->nfe_tx_task);1573 taskqueue_enqueue_fast(sc->nfe_tq, &sc->nfe_tx_task); 1693 1574 1694 1575 if (cmd == POLL_AND_CHECK_STATUS) { … … 1899 1780 return (FILTER_STRAY); 1900 1781 nfe_disable_intr(sc); 1901 taskqueue_enqueue_fast( taskqueue_fast, &sc->nfe_int_task);1782 taskqueue_enqueue_fast(sc->nfe_tq, &sc->nfe_int_task); 1902 1783 1903 1784 return (FILTER_HANDLED); … … 1953 1834 1954 1835 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) 1955 taskqueue_enqueue_fast( taskqueue_fast, &sc->nfe_tx_task);1836 taskqueue_enqueue_fast(sc->nfe_tq, &sc->nfe_tx_task); 1956 1837 1957 1838 NFE_UNLOCK(sc); 1958 1839 1959 1840 if (domore || (NFE_READ(sc, sc->nfe_irq_status) != 0)) { 1960 taskqueue_enqueue_fast( taskqueue_fast, &sc->nfe_int_task);1841 taskqueue_enqueue_fast(sc->nfe_tq, &sc->nfe_int_task); 1961 1842 return; 1962 1843 } … … 2085 1966 bus_dmamap_t map; 2086 1967 int nsegs; 2087 void *buf; 2088 2089 MGETHDR(m, M_DONTWAIT, MT_DATA); 1968 1969 m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); 2090 1970 if (m == NULL) 2091 1971 return (ENOBUFS); 2092 buf = nfe_jalloc(sc);2093 if (buf == NULL) {2094 m_freem(m);2095 return (ENOBUFS);2096 }2097 /* Attach the buffer to the mbuf. */2098 MEXTADD(m, buf, NFE_JLEN, nfe_jfree, (struct nfe_softc *)sc, 0,2099 EXT_NET_DRV);2100 1972 if ((m->m_flags & M_EXT) == 0) { 2101 1973 m_freem(m); 2102 1974 return (ENOBUFS); 2103 1975 } 2104 m->m_pkthdr.len = m->m_len = NFE_JLEN;1976 m->m_pkthdr.len = m->m_len = MJUM9BYTES; 2105 1977 m_adj(m, ETHER_ALIGN); 2106 1978 … … 2438 2310 } 2439 2311 2440 /*2441 * It's copy of ath_defrag(ath(4)).2442 *2443 * Defragment an mbuf chain, returning at most maxfrags separate2444 * mbufs+clusters. If this is not possible NULL is returned and2445 * the original mbuf chain is left in it's present (potentially2446 * modified) state. We use two techniques: collapsing consecutive2447 * mbufs and replacing consecutive mbufs by a cluster.2448 */2449 static struct mbuf *2450 nfe_defrag(struct mbuf *m0, int how, int maxfrags)2451 {2452 struct mbuf *m, *n, *n2, **prev;2453 u_int curfrags;2454 2455 /*2456 * Calculate the current number of frags.2457 */2458 curfrags = 0;2459 for (m = m0; m != NULL; m = m->m_next)2460 curfrags++;2461 /*2462 * First, try to collapse mbufs. Note that we always collapse2463 * towards the front so we don't need to deal with moving the2464 * pkthdr. This may be suboptimal if the first mbuf has much2465 * less data than the following.2466 */2467 m = m0;2468 again:2469 for (;;) {2470 n = m->m_next;2471 if (n == NULL)2472 break;2473 if ((m->m_flags & M_RDONLY) == 0 &&2474 n->m_len < M_TRAILINGSPACE(m)) {2475 bcopy(mtod(n, void *), mtod(m, char *) + m->m_len,2476 n->m_len);2477 m->m_len += n->m_len;2478 m->m_next = n->m_next;2479 m_free(n);2480 if (--curfrags <= maxfrags)2481 return (m0);2482 } else2483 m = n;2484 }2485 KASSERT(maxfrags > 1,2486 ("maxfrags %u, but normal collapse failed", maxfrags));2487 /*2488 * Collapse consecutive mbufs to a cluster.2489 */2490 prev = &m0->m_next; /* NB: not the first mbuf */2491 while ((n = *prev) != NULL) {2492 if ((n2 = n->m_next) != NULL &&2493 n->m_len + n2->m_len < MCLBYTES) {2494 m = m_getcl(how, MT_DATA, 0);2495 if (m == NULL)2496 goto bad;2497 bcopy(mtod(n, void *), mtod(m, void *), n->m_len);2498 bcopy(mtod(n2, void *), mtod(m, char *) + n->m_len,2499 n2->m_len);2500 m->m_len = n->m_len + n2->m_len;2501 m->m_next = n2->m_next;2502 *prev = m;2503 m_free(n);2504 m_free(n2);2505 if (--curfrags <= maxfrags) /* +1 cl -2 mbufs */2506 return m0;2507 /*2508 * Still not there, try the normal collapse2509 * again before we allocate another cluster.2510 */2511 goto again;2512 }2513 prev = &n->m_next;2514 }2515 /*2516 * No place where we can collapse to a cluster; punt.2517 * This can occur if, for example, you request 2 frags2518 * but the packet requires that both be clusters (we2519 * never reallocate the first mbuf to avoid moving the2520 * packet header).2521 */2522 bad:2523 return (NULL);2524 }2525 2526 2527 2312 static int 2528 2313 nfe_encap(struct nfe_softc *sc, struct mbuf **m_head) … … 2543 2328 &nsegs, BUS_DMA_NOWAIT); 2544 2329 if (error == EFBIG) { 2545 m = nfe_defrag(*m_head, M_DONTWAIT, NFE_MAX_SCATTER);2330 m = m_collapse(*m_head, M_DONTWAIT, NFE_MAX_SCATTER); 2546 2331 if (m == NULL) { 2547 2332 m_freem(*m_head); … … 2809 2594 "-- recovering\n"); 2810 2595 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) 2811 taskqueue_enqueue_fast(taskqueue_fast, 2812 &sc->nfe_tx_task); 2596 taskqueue_enqueue_fast(sc->nfe_tq, &sc->nfe_tx_task); 2813 2597 return; 2814 2598 } … … 2972 2756 2973 2757 NFE_WRITE(sc, NFE_PHY_STATUS, 0xf); 2758 2759 /* Clear hardware stats. */ 2760 nfe_stats_clear(sc); 2974 2761 2975 2762 #ifdef DEVICE_POLLING … … 3061 2848 } 3062 2849 } 2850 /* Update hardware stats. */ 2851 nfe_stats_update(sc); 3063 2852 } 3064 2853 … … 3112 2901 mii = device_get_softc(sc->nfe_miibus); 3113 2902 mii_tick(mii); 2903 nfe_stats_update(sc); 3114 2904 nfe_watchdog(ifp); 3115 2905 callout_reset(&sc->nfe_stat_ch, hz, nfe_tick, sc); … … 3117 2907 3118 2908 3119 static void2909 static int 3120 2910 nfe_shutdown(device_t dev) 3121 2911 { … … 3130 2920 /* nfe_reset(sc); */ 3131 2921 NFE_UNLOCK(sc); 2922 2923 return (0); 3132 2924 } 3133 2925 … … 3217 3009 NFE_PROC_MAX)); 3218 3010 } 3011 3012 3013 #define NFE_SYSCTL_STAT_ADD32(c, h, n, p, d) \ 3014 SYSCTL_ADD_UINT(c, h, OID_AUTO, n, CTLFLAG_RD, p, 0, d) 3015 #define NFE_SYSCTL_STAT_ADD64(c, h, n, p, d) \ 3016 SYSCTL_ADD_QUAD(c, h, OID_AUTO, n, CTLFLAG_RD, p, d) 3017
