FreeBSD/sys/dev/oce/oce_if.c
/* NOTE : This should only be called holding
 *        DEVICE_LOCK.
 */
NOTE : This should only be called holding
DEVICE_LOCK.
NOTE : This should only be called holding DEVICE_LOCK .
static void
oce_if_deactivate(POCE_SOFTC sc)
{
	int i, mtime = 0;
	int wait_req = 0;
	struct oce_rq *rq;
	struct oce_wq *wq;
	struct oce_eq *eq;
	sc->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
	while (mtime < 400) {
		wait_req = 0;
		for_all_wq_queues(sc, wq, i) {
			if (wq->ring->num_used) {
				wait_req = 1;
				DELAY(1);
				break;
			}
		}
		mtime += 1;
		if (!wait_req)
			break;
	}
	oce_hw_intr_disable(sc);
	UNLOCK(&sc->dev_lock);
	for (i = 0; i < sc->intr_count; i++) {
		if (sc->intrs[i].tq != NULL) {
			taskqueue_drain(sc->intrs[i].tq, &sc->intrs[i].task);
		}
	}
	LOCK(&sc->dev_lock);
	oce_stop_rx(sc);
	for_all_evnt_queues(sc, eq, i)	
		oce_drain_eq(eq);
	for_all_rq_queues(sc, rq, i)
		oce_drain_rq_cq(rq);
	for_all_wq_queues(sc, wq, i)
		oce_drain_wq_cq(wq);
	oce_hw_intr_enable(sc);
	oce_arm_eq(sc, sc->eq[0]->eq_id, 0, TRUE, FALSE);
	DELAY(10);
}
static void oce_if_deactivate ( POCE_SOFTC sc ) { int i , mtime = 0 ; int wait_req = 0 ; struct oce_rq * rq ; struct oce_wq * wq ; struct oce_eq * eq ; sc -> ifp -> if_drv_flags &= ~ ( IFF_DRV_RUNNING | IFF_DRV_OACTIVE ) ; while ( mtime < 400 ) { wait_req = 0 ; for_all_wq_queues ( sc , wq , i ) { if ( wq -> ring -> num_used ) { wait_req = 1 ; DELAY ( 1 ) ; break ; } } mtime += 1 ; if ( ! wait_req ) break ; } oce_hw_intr_disable ( sc ) ; UNLOCK ( & sc -> dev_lock ) ; for ( i = 0 ; i < sc -> intr_count ; i ++ ) { if ( sc -> intrs [ i ] . tq != NULL ) { taskqueue_drain ( sc -> intrs [ i ] . tq , & sc -> intrs [ i ] . task ) ; } } LOCK ( & sc -> dev_lock ) ; oce_stop_rx ( sc ) ; for_all_evnt_queues ( sc , eq , i ) oce_drain_eq ( eq ) ; for_all_rq_queues ( sc , rq , i ) oce_drain_rq_cq ( rq ) ; for_all_wq_queues ( sc , wq , i ) oce_drain_wq_cq ( wq ) ; oce_hw_intr_enable ( sc ) ; oce_arm_eq ( sc , sc -> eq [ 0 ] -> eq_id , 0 , TRUE , FALSE ) ; DELAY ( 10 ) ; }
NOTE : This should only be called holding
        DEVICE_LOCK.
NOTE : This should only be called holding DEVICE_LOCK .
/*Wait for max of 400ms for TX completions to be done */ /* Stop intrs and finish any bottom halves pending */ /* Since taskqueue_drain takes a Gaint Lock, We should not acquire
	   any other lock. So unlock device lock and require after
	   completing taskqueue_drain.
	*/ /* Delete RX queue in card with flush param */ /* Invalidate any pending cq and eq entries*/ /* But still we need to get MCC aync events.
	   So enable intrs and also arm first EQ
	*/