Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/e1000/if_em.c
Show First 20 Lines • Show All 1,085 Lines • ▼ Show 20 Lines | em_if_attach_pre(if_ctx_t ctx) | ||||
iflib_set_mac(ctx, hw->mac.addr); | iflib_set_mac(ctx, hw->mac.addr); | ||||
return (0); | return (0); | ||||
err_late: | err_late: | ||||
em_release_hw_control(adapter); | em_release_hw_control(adapter); | ||||
err_pci: | err_pci: | ||||
em_free_pci_resources(ctx); | em_free_pci_resources(ctx); | ||||
free(adapter->mta, M_DEVBUF); | free(adapter->mta, M_DEVBUF); | ||||
markj: Let's set `adapter->mta = NULL` here too for consistency. | |||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
em_if_attach_post(if_ctx_t ctx) | em_if_attach_post(if_ctx_t ctx) | ||||
{ | { | ||||
struct adapter *adapter = iflib_get_softc(ctx); | struct adapter *adapter = iflib_get_softc(ctx); | ||||
struct e1000_hw *hw = &adapter->hw; | struct e1000_hw *hw = &adapter->hw; | ||||
int error = 0; | int error = 0; | ||||
/* Setup OS specific network interface */ | /* Setup OS specific network interface */ | ||||
error = em_setup_interface(ctx); | error = em_setup_interface(ctx); | ||||
if (error != 0) { | if (error != 0) { | ||||
device_printf(adapter->dev, "Interface setup failed: %d\n", error); | |||||
goto err_late; | goto err_late; | ||||
} | } | ||||
em_reset(ctx); | em_reset(ctx); | ||||
/* Initialize statistics */ | /* Initialize statistics */ | ||||
em_update_stats_counters(adapter); | em_update_stats_counters(adapter); | ||||
hw->mac.get_link_status = 1; | hw->mac.get_link_status = 1; | ||||
em_if_update_admin_status(ctx); | em_if_update_admin_status(ctx); | ||||
em_add_hw_stats(adapter); | em_add_hw_stats(adapter); | ||||
/* Non-AMT based hardware can now take control from firmware */ | /* Non-AMT based hardware can now take control from firmware */ | ||||
if (adapter->has_manage && !adapter->has_amt) | if (adapter->has_manage && !adapter->has_amt) | ||||
em_get_hw_control(adapter); | em_get_hw_control(adapter); | ||||
INIT_DEBUGOUT("em_if_attach_post: end"); | INIT_DEBUGOUT("em_if_attach_post: end"); | ||||
return (error); | return (0); | ||||
err_late: | err_late: | ||||
em_release_hw_control(adapter); | /* upon attach_post() error, iflib calls _if_detach() to free resources. */ | ||||
em_free_pci_resources(ctx); | |||||
em_if_queues_free(ctx); | |||||
free(adapter->mta, M_DEVBUF); | |||||
return (error); | return (error); | ||||
} | } | ||||
/********************************************************************* | /********************************************************************* | ||||
* Device removal routine | * Device removal routine | ||||
* | * | ||||
* The detach entry point is called when the driver is being removed. | * The detach entry point is called when the driver is being removed. | ||||
* This routine stops the adapter and deallocates all the resources | * This routine stops the adapter and deallocates all the resources | ||||
* that were allocated for driver operation. | * that were allocated for driver operation. | ||||
* | * | ||||
* return 0 on success, positive on failure | * return 0 on success, positive on failure | ||||
*********************************************************************/ | *********************************************************************/ | ||||
static int | static int | ||||
em_if_detach(if_ctx_t ctx) | em_if_detach(if_ctx_t ctx) | ||||
{ | { | ||||
struct adapter *adapter = iflib_get_softc(ctx); | struct adapter *adapter = iflib_get_softc(ctx); | ||||
INIT_DEBUGOUT("em_if_detach: begin"); | INIT_DEBUGOUT("em_if_detach: begin"); | ||||
e1000_phy_hw_reset(&adapter->hw); | e1000_phy_hw_reset(&adapter->hw); | ||||
em_release_manageability(adapter); | em_release_manageability(adapter); | ||||
em_release_hw_control(adapter); | em_release_hw_control(adapter); | ||||
em_free_pci_resources(ctx); | em_free_pci_resources(ctx); | ||||
free(adapter->mta, M_DEVBUF); | |||||
adapter->mta = NULL; | |||||
return (0); | return (0); | ||||
} | } | ||||
/********************************************************************* | /********************************************************************* | ||||
* | * | ||||
* Shutdown entry point | * Shutdown entry point | ||||
* | * | ||||
▲ Show 20 Lines • Show All 1,809 Lines • ▼ Show 20 Lines | if (tx_que != NULL) { | ||||
} | } | ||||
free(adapter->tx_queues, M_DEVBUF); | free(adapter->tx_queues, M_DEVBUF); | ||||
adapter->tx_queues = NULL; | adapter->tx_queues = NULL; | ||||
} | } | ||||
if (rx_que != NULL) { | if (rx_que != NULL) { | ||||
free(adapter->rx_queues, M_DEVBUF); | free(adapter->rx_queues, M_DEVBUF); | ||||
adapter->rx_queues = NULL; | adapter->rx_queues = NULL; | ||||
} | |||||
em_release_hw_control(adapter); | |||||
if (adapter->mta != NULL) { | |||||
free(adapter->mta, M_DEVBUF); | |||||
} | } | ||||
} | } | ||||
/********************************************************************* | /********************************************************************* | ||||
* | * | ||||
* Enable transmit unit. | * Enable transmit unit. | ||||
* | * | ||||
**********************************************************************/ | **********************************************************************/ | ||||
▲ Show 20 Lines • Show All 1,638 Lines • Show Last 20 Lines |
Let's set adapter->mta = NULL here too for consistency.