if_bwi.c (6cec9cad762b6476313fb1f8e931a1647822db6b) | if_bwi.c (c8dfaf382fa6df9dc6fd1e1c3356e0c8bf607e6a) |
---|---|
1/* 2 * Copyright (c) 2007 The DragonFly Project. All rights reserved. 3 * 4 * This code is derived from software contributed to The DragonFly Project 5 * by Sepherosa Ziehau <sepherosa@gmail.com> 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 1387 unchanged lines hidden (view full) --- 1396 1397 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; 1398 wh = mtod(m, struct ieee80211_frame *); 1399 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { 1400 k = ieee80211_crypto_encap(ni, m); 1401 if (k == NULL) { 1402 ieee80211_free_node(ni); 1403 m_freem(m); | 1/* 2 * Copyright (c) 2007 The DragonFly Project. All rights reserved. 3 * 4 * This code is derived from software contributed to The DragonFly Project 5 * by Sepherosa Ziehau <sepherosa@gmail.com> 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 1387 unchanged lines hidden (view full) --- 1396 1397 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; 1398 wh = mtod(m, struct ieee80211_frame *); 1399 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { 1400 k = ieee80211_crypto_encap(ni, m); 1401 if (k == NULL) { 1402 ieee80211_free_node(ni); 1403 m_freem(m); |
1404 ifp->if_oerrors++; | 1404 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
1405 continue; 1406 } 1407 } 1408 wh = NULL; /* Catch any invalid use */ 1409 1410 if (bwi_encap(sc, idx, m, ni) != 0) { 1411 /* 'm' is freed in bwi_encap() if we reach here */ 1412 if (ni != NULL) 1413 ieee80211_free_node(ni); | 1405 continue; 1406 } 1407 } 1408 wh = NULL; /* Catch any invalid use */ 1409 1410 if (bwi_encap(sc, idx, m, ni) != 0) { 1411 /* 'm' is freed in bwi_encap() if we reach here */ 1412 if (ni != NULL) 1413 ieee80211_free_node(ni); |
1414 ifp->if_oerrors++; | 1414 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
1415 continue; 1416 } 1417 1418 trans = 1; 1419 tbd->tbd_used++; 1420 idx = (idx + 1) % BWI_TX_NDESC; 1421 | 1415 continue; 1416 } 1417 1418 trans = 1; 1419 tbd->tbd_used++; 1420 idx = (idx + 1) % BWI_TX_NDESC; 1421 |
1422 ifp->if_opackets++; | 1422 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); |
1423 1424 if (tbd->tbd_used + BWI_TX_NSPRDESC >= BWI_TX_NDESC) { 1425 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 1426 break; 1427 } 1428 } 1429 tbd->tbd_idx = idx; 1430 --- 30 unchanged lines hidden (view full) --- 1461 } else { 1462 /* 1463 * Caller supplied explicit parameters to use in 1464 * sending the frame. 1465 */ 1466 error = bwi_encap_raw(sc, idx, m, ni, params); 1467 } 1468 if (error == 0) { | 1423 1424 if (tbd->tbd_used + BWI_TX_NSPRDESC >= BWI_TX_NDESC) { 1425 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 1426 break; 1427 } 1428 } 1429 tbd->tbd_idx = idx; 1430 --- 30 unchanged lines hidden (view full) --- 1461 } else { 1462 /* 1463 * Caller supplied explicit parameters to use in 1464 * sending the frame. 1465 */ 1466 error = bwi_encap_raw(sc, idx, m, ni, params); 1467 } 1468 if (error == 0) { |
1469 ifp->if_opackets++; | 1469 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); |
1470 if (++tbd->tbd_used + BWI_TX_NSPRDESC >= BWI_TX_NDESC) 1471 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 1472 tbd->tbd_idx = (idx + 1) % BWI_TX_NDESC; 1473 sc->sc_tx_timer = 5; 1474 } else { 1475 /* NB: m is reclaimed on encap failure */ 1476 ieee80211_free_node(ni); | 1470 if (++tbd->tbd_used + BWI_TX_NSPRDESC >= BWI_TX_NDESC) 1471 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 1472 tbd->tbd_idx = (idx + 1) % BWI_TX_NDESC; 1473 sc->sc_tx_timer = 5; 1474 } else { 1475 /* NB: m is reclaimed on encap failure */ 1476 ieee80211_free_node(ni); |
1477 ifp->if_oerrors++; | 1477 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
1478 } 1479 BWI_UNLOCK(sc); 1480 return error; 1481} 1482 1483static void 1484bwi_watchdog(void *arg) 1485{ 1486 struct bwi_softc *sc; 1487 struct ifnet *ifp; 1488 1489 sc = arg; 1490 ifp = sc->sc_ifp; 1491 BWI_ASSERT_LOCKED(sc); 1492 if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0) { 1493 if_printf(ifp, "watchdog timeout\n"); | 1478 } 1479 BWI_UNLOCK(sc); 1480 return error; 1481} 1482 1483static void 1484bwi_watchdog(void *arg) 1485{ 1486 struct bwi_softc *sc; 1487 struct ifnet *ifp; 1488 1489 sc = arg; 1490 ifp = sc->sc_ifp; 1491 BWI_ASSERT_LOCKED(sc); 1492 if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0) { 1493 if_printf(ifp, "watchdog timeout\n"); |
1494 ifp->if_oerrors++; | 1494 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
1495 taskqueue_enqueue(sc->sc_tq, &sc->sc_restart_task); 1496 } 1497 callout_reset(&sc->sc_watchdog_timer, hz, bwi_watchdog, sc); 1498} 1499 1500static void 1501bwi_stop(struct bwi_softc *sc, int statechg) 1502{ --- 1131 unchanged lines hidden (view full) --- 2634 uint16_t flags2; 2635 int buflen, wh_ofs, hdr_extra, rssi, noise, type, rate; 2636 2637 m = rb->rb_mbuf; 2638 bus_dmamap_sync(sc->sc_buf_dtag, rb->rb_dmap, 2639 BUS_DMASYNC_POSTREAD); 2640 2641 if (bwi_newbuf(sc, idx, 0)) { | 1495 taskqueue_enqueue(sc->sc_tq, &sc->sc_restart_task); 1496 } 1497 callout_reset(&sc->sc_watchdog_timer, hz, bwi_watchdog, sc); 1498} 1499 1500static void 1501bwi_stop(struct bwi_softc *sc, int statechg) 1502{ --- 1131 unchanged lines hidden (view full) --- 2634 uint16_t flags2; 2635 int buflen, wh_ofs, hdr_extra, rssi, noise, type, rate; 2636 2637 m = rb->rb_mbuf; 2638 bus_dmamap_sync(sc->sc_buf_dtag, rb->rb_dmap, 2639 BUS_DMASYNC_POSTREAD); 2640 2641 if (bwi_newbuf(sc, idx, 0)) { |
2642 ifp->if_ierrors++; | 2642 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
2643 goto next; 2644 } 2645 2646 hdr = mtod(m, struct bwi_rxbuf_hdr *); 2647 flags2 = le16toh(hdr->rxh_flags2); 2648 2649 hdr_extra = 0; 2650 if (flags2 & BWI_RXH_F2_TYPE2FRAME) 2651 hdr_extra = 2; 2652 wh_ofs = hdr_extra + 6; /* XXX magic number */ 2653 2654 buflen = le16toh(hdr->rxh_buflen); 2655 if (buflen < BWI_FRAME_MIN_LEN(wh_ofs)) { 2656 if_printf(ifp, "%s: zero length data, hdr_extra %d\n", 2657 __func__, hdr_extra); | 2643 goto next; 2644 } 2645 2646 hdr = mtod(m, struct bwi_rxbuf_hdr *); 2647 flags2 = le16toh(hdr->rxh_flags2); 2648 2649 hdr_extra = 0; 2650 if (flags2 & BWI_RXH_F2_TYPE2FRAME) 2651 hdr_extra = 2; 2652 wh_ofs = hdr_extra + 6; /* XXX magic number */ 2653 2654 buflen = le16toh(hdr->rxh_buflen); 2655 if (buflen < BWI_FRAME_MIN_LEN(wh_ofs)) { 2656 if_printf(ifp, "%s: zero length data, hdr_extra %d\n", 2657 __func__, hdr_extra); |
2658 ifp->if_ierrors++; | 2658 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
2659 m_freem(m); 2660 goto next; 2661 } 2662 2663 bcopy((uint8_t *)(hdr + 1) + hdr_extra, &plcp, sizeof(plcp)); 2664 rssi = bwi_calc_rssi(sc, hdr); 2665 noise = bwi_calc_noise(sc); 2666 --- 1391 unchanged lines hidden --- | 2659 m_freem(m); 2660 goto next; 2661 } 2662 2663 bcopy((uint8_t *)(hdr + 1) + hdr_extra, &plcp, sizeof(plcp)); 2664 rssi = bwi_calc_rssi(sc, hdr); 2665 noise = bwi_calc_noise(sc); 2666 --- 1391 unchanged lines hidden --- |