| 2415 | } |
| 2416 | |
| 2417 | static void |
| 2418 | iflib_init_locked(if_ctx_t ctx) |
| 2419 | { |
| 2420 | if_softc_ctx_t sctx = &ctx->ifc_softc_ctx; |
| 2421 | if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; |
| 2422 | if_t ifp = ctx->ifc_ifp; |
| 2423 | iflib_fl_t fl; |
| 2424 | iflib_txq_t txq; |
| 2425 | iflib_rxq_t rxq; |
| 2426 | int i, j, tx_ip_csum_flags, tx_ip6_csum_flags; |
| 2427 | |
| 2428 | if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING); |
| 2429 | IFDI_INTR_DISABLE(ctx); |
| 2430 | |
| 2431 | /* |
| 2432 | * See iflib_stop(). Useful in case iflib_init_locked() is |
| 2433 | * called without first calling iflib_stop(). |
| 2434 | */ |
| 2435 | netmap_disable_all_rings(ifp); |
| 2436 | |
| 2437 | tx_ip_csum_flags = scctx->isc_tx_csum_flags & (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_SCTP); |
| 2438 | tx_ip6_csum_flags = scctx->isc_tx_csum_flags & (CSUM_IP6_TCP | CSUM_IP6_UDP | CSUM_IP6_SCTP); |
| 2439 | /* Set hardware offload abilities */ |
| 2440 | if_clearhwassist(ifp); |
| 2441 | if (if_getcapenable(ifp) & IFCAP_TXCSUM) |
| 2442 | if_sethwassistbits(ifp, tx_ip_csum_flags, 0); |
| 2443 | if (if_getcapenable(ifp) & IFCAP_TXCSUM_IPV6) |
| 2444 | if_sethwassistbits(ifp, tx_ip6_csum_flags, 0); |
| 2445 | if (if_getcapenable(ifp) & IFCAP_TSO4) |
| 2446 | if_sethwassistbits(ifp, CSUM_IP_TSO, 0); |
| 2447 | if (if_getcapenable(ifp) & IFCAP_TSO6) |
| 2448 | if_sethwassistbits(ifp, CSUM_IP6_TSO, 0); |
| 2449 | |
| 2450 | for (i = 0, txq = ctx->ifc_txqs; i < sctx->isc_ntxqsets; i++, txq++) { |
| 2451 | CALLOUT_LOCK(txq); |
| 2452 | callout_stop(&txq->ift_timer); |
| 2453 | #ifdef DEV_NETMAP |
| 2454 | callout_stop(&txq->ift_netmap_timer); |
| 2455 | #endif /* DEV_NETMAP */ |
| 2456 | CALLOUT_UNLOCK(txq); |
| 2457 | iflib_netmap_txq_init(ctx, txq); |
| 2458 | } |
| 2459 | |
| 2460 | /* |
| 2461 | * Calculate a suitable Rx mbuf size prior to calling IFDI_INIT, so |
| 2462 | * that drivers can use the value when setting up the hardware receive |
| 2463 | * buffers. |
| 2464 | */ |
| 2465 | iflib_calc_rx_mbuf_sz(ctx); |
| 2466 | |
| 2467 | #ifdef INVARIANTS |
| 2468 | i = if_getdrvflags(ifp); |
| 2469 | #endif |
| 2470 | IFDI_INIT(ctx); |
| 2471 | MPASS(if_getdrvflags(ifp) == i); |
| 2472 | for (i = 0, rxq = ctx->ifc_rxqs; i < sctx->isc_nrxqsets; i++, rxq++) { |
| 2473 | if (iflib_netmap_rxq_init(ctx, rxq) > 0) { |
| 2474 | /* This rxq is in netmap mode. Skip normal init. */ |
no test coverage detected