Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/gve/gve_main.c
Show First 20 Lines • Show All 511 Lines • ▼ Show 20 Lines | gve_alloc_rings(struct gve_priv *priv) | ||||
return (0); | return (0); | ||||
abort: | abort: | ||||
gve_free_rings(priv); | gve_free_rings(priv); | ||||
return (err); | return (err); | ||||
} | } | ||||
static void | static void | ||||
gve_deconfigure_resources(struct gve_priv *priv) | gve_deconfigure_and_free_device_resources(struct gve_priv *priv) | ||||
{ | { | ||||
int err; | int err; | ||||
if (gve_get_state_flag(priv, GVE_STATE_FLAG_RESOURCES_OK)) { | if (gve_get_state_flag(priv, GVE_STATE_FLAG_RESOURCES_OK)) { | ||||
err = gve_adminq_deconfigure_device_resources(priv); | err = gve_adminq_deconfigure_device_resources(priv); | ||||
if (err != 0) { | if (err != 0) { | ||||
device_printf(priv->dev, "Failed to deconfigure device resources: err=%d\n", | device_printf(priv->dev, "Failed to deconfigure device resources: err=%d\n", | ||||
err); | err); | ||||
Show All 9 Lines | gve_deconfigure_and_free_device_resources(struct gve_priv *priv) | ||||
if (priv->ptype_lut_dqo) { | if (priv->ptype_lut_dqo) { | ||||
free(priv->ptype_lut_dqo, M_GVE); | free(priv->ptype_lut_dqo, M_GVE); | ||||
priv->ptype_lut_dqo = NULL; | priv->ptype_lut_dqo = NULL; | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
gve_configure_resources(struct gve_priv *priv) | gve_alloc_and_configure_device_resources(struct gve_priv *priv) | ||||
{ | { | ||||
int err; | int err; | ||||
if (gve_get_state_flag(priv, GVE_STATE_FLAG_RESOURCES_OK)) | if (gve_get_state_flag(priv, GVE_STATE_FLAG_RESOURCES_OK)) | ||||
return (0); | return (0); | ||||
err = gve_alloc_counter_array(priv); | err = gve_alloc_counter_array(priv); | ||||
if (err != 0) | if (err != 0) | ||||
Show All 24 Lines | gve_alloc_and_configure_device_resources(struct gve_priv *priv) | ||||
} | } | ||||
gve_set_state_flag(priv, GVE_STATE_FLAG_RESOURCES_OK); | gve_set_state_flag(priv, GVE_STATE_FLAG_RESOURCES_OK); | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(priv->dev, "Configured device resources\n"); | device_printf(priv->dev, "Configured device resources\n"); | ||||
return (0); | return (0); | ||||
abort: | abort: | ||||
gve_deconfigure_resources(priv); | gve_deconfigure_and_free_device_resources(priv); | ||||
return (err); | return (err); | ||||
} | } | ||||
static void | static void | ||||
gve_set_queue_cnts(struct gve_priv *priv) | gve_set_queue_cnts(struct gve_priv *priv) | ||||
{ | { | ||||
priv->tx_cfg.max_queues = gve_reg_bar_read_4(priv, MAX_TX_QUEUES); | priv->tx_cfg.max_queues = gve_reg_bar_read_4(priv, MAX_TX_QUEUES); | ||||
priv->rx_cfg.max_queues = gve_reg_bar_read_4(priv, MAX_RX_QUEUES); | priv->rx_cfg.max_queues = gve_reg_bar_read_4(priv, MAX_RX_QUEUES); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | gve_schedule_reset(struct gve_priv *priv) | ||||
gve_set_state_flag(priv, GVE_STATE_FLAG_DO_RESET); | gve_set_state_flag(priv, GVE_STATE_FLAG_DO_RESET); | ||||
taskqueue_enqueue(priv->service_tq, &priv->service_task); | taskqueue_enqueue(priv->service_tq, &priv->service_task); | ||||
} | } | ||||
static void | static void | ||||
gve_destroy(struct gve_priv *priv) | gve_destroy(struct gve_priv *priv) | ||||
{ | { | ||||
gve_down(priv); | gve_down(priv); | ||||
gve_deconfigure_resources(priv); | gve_deconfigure_and_free_device_resources(priv); | ||||
gve_release_adminq(priv); | gve_release_adminq(priv); | ||||
} | } | ||||
static void | static void | ||||
gve_restore(struct gve_priv *priv) | gve_restore(struct gve_priv *priv) | ||||
{ | { | ||||
int err; | int err; | ||||
err = gve_adminq_alloc(priv); | err = gve_adminq_alloc(priv); | ||||
if (err != 0) | if (err != 0) | ||||
goto abort; | goto abort; | ||||
err = gve_configure_resources(priv); | err = gve_adminq_configure_device_resources(priv); | ||||
if (err != 0) | if (err != 0) { | ||||
device_printf(priv->dev, "Failed to configure device resources: err=%d\n", | |||||
err); | |||||
err = (ENXIO); | |||||
goto abort; | goto abort; | ||||
} | |||||
if (!gve_is_gqi(priv)) { | |||||
err = gve_adminq_get_ptype_map_dqo(priv, priv->ptype_lut_dqo); | |||||
if (err != 0) { | |||||
device_printf(priv->dev, "Failed to configure ptype lut: err=%d\n", | |||||
err); | |||||
goto abort; | |||||
} | |||||
} | |||||
err = gve_up(priv); | err = gve_up(priv); | ||||
if (err != 0) | if (err != 0) | ||||
goto abort; | goto abort; | ||||
return; | return; | ||||
abort: | abort: | ||||
device_printf(priv->dev, "Restore failed!\n"); | device_printf(priv->dev, "Restore failed!\n"); | ||||
return; | return; | ||||
} | } | ||||
static void | static void | ||||
gve_clear_device_resources(struct gve_priv *priv) | |||||
{ | |||||
int i; | |||||
for (i = 0; i < priv->num_event_counters; i++) | |||||
priv->counters[i] = 0; | |||||
bus_dmamap_sync(priv->counter_array_mem.tag, priv->counter_array_mem.map, | |||||
BUS_DMASYNC_PREWRITE); | |||||
for (i = 0; i < priv->num_queues; i++) | |||||
priv->irq_db_indices[i] = (struct gve_irq_db){}; | |||||
bus_dmamap_sync(priv->irqs_db_mem.tag, priv->irqs_db_mem.map, | |||||
BUS_DMASYNC_PREWRITE); | |||||
if (priv->ptype_lut_dqo) | |||||
*priv->ptype_lut_dqo = (struct gve_ptype_lut){0}; | |||||
} | |||||
static void | |||||
gve_handle_reset(struct gve_priv *priv) | gve_handle_reset(struct gve_priv *priv) | ||||
{ | { | ||||
if (!gve_get_state_flag(priv, GVE_STATE_FLAG_DO_RESET)) | if (!gve_get_state_flag(priv, GVE_STATE_FLAG_DO_RESET)) | ||||
return; | return; | ||||
gve_clear_state_flag(priv, GVE_STATE_FLAG_DO_RESET); | gve_clear_state_flag(priv, GVE_STATE_FLAG_DO_RESET); | ||||
gve_set_state_flag(priv, GVE_STATE_FLAG_IN_RESET); | gve_set_state_flag(priv, GVE_STATE_FLAG_IN_RESET); | ||||
Show All 14 Lines | gve_handle_reset(struct gve_priv *priv) | ||||
*/ | */ | ||||
gve_release_adminq(priv); | gve_release_adminq(priv); | ||||
gve_clear_state_flag(priv, GVE_STATE_FLAG_RESOURCES_OK); | gve_clear_state_flag(priv, GVE_STATE_FLAG_RESOURCES_OK); | ||||
gve_clear_state_flag(priv, GVE_STATE_FLAG_QPLREG_OK); | gve_clear_state_flag(priv, GVE_STATE_FLAG_QPLREG_OK); | ||||
gve_clear_state_flag(priv, GVE_STATE_FLAG_RX_RINGS_OK); | gve_clear_state_flag(priv, GVE_STATE_FLAG_RX_RINGS_OK); | ||||
gve_clear_state_flag(priv, GVE_STATE_FLAG_TX_RINGS_OK); | gve_clear_state_flag(priv, GVE_STATE_FLAG_TX_RINGS_OK); | ||||
gve_down(priv); | gve_down(priv); | ||||
gve_clear_device_resources(priv); | |||||
gve_restore(priv); | gve_restore(priv); | ||||
GVE_IFACE_LOCK_UNLOCK(priv->gve_iface_lock); | GVE_IFACE_LOCK_UNLOCK(priv->gve_iface_lock); | ||||
priv->reset_cnt++; | priv->reset_cnt++; | ||||
gve_clear_state_flag(priv, GVE_STATE_FLAG_IN_RESET); | gve_clear_state_flag(priv, GVE_STATE_FLAG_IN_RESET); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | if (priv->msix_table == NULL) { | ||||
err = ENXIO; | err = ENXIO; | ||||
goto abort; | goto abort; | ||||
} | } | ||||
err = gve_alloc_adminq_and_describe_device(priv); | err = gve_alloc_adminq_and_describe_device(priv); | ||||
if (err != 0) | if (err != 0) | ||||
goto abort; | goto abort; | ||||
err = gve_configure_resources(priv); | err = gve_alloc_and_configure_device_resources(priv); | ||||
if (err != 0) | if (err != 0) | ||||
goto abort; | goto abort; | ||||
err = gve_alloc_rings(priv); | err = gve_alloc_rings(priv); | ||||
if (err != 0) | if (err != 0) | ||||
goto abort; | goto abort; | ||||
gve_setup_ifnet(dev, priv); | gve_setup_ifnet(dev, priv); | ||||
Show All 12 Lines | taskqueue_start_threads(&priv->service_tq, 1, PI_NET, "%s service tq", | ||||
gve_setup_sysctl(priv); | gve_setup_sysctl(priv); | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(priv->dev, "Successfully attached %s", GVE_DRIVER_VERSION); | device_printf(priv->dev, "Successfully attached %s", GVE_DRIVER_VERSION); | ||||
return (0); | return (0); | ||||
abort: | abort: | ||||
gve_free_rings(priv); | gve_free_rings(priv); | ||||
gve_deconfigure_resources(priv); | gve_deconfigure_and_free_device_resources(priv); | ||||
gve_release_adminq(priv); | gve_release_adminq(priv); | ||||
gve_free_sys_res_mem(priv); | gve_free_sys_res_mem(priv); | ||||
GVE_IFACE_LOCK_DESTROY(priv->gve_iface_lock); | GVE_IFACE_LOCK_DESTROY(priv->gve_iface_lock); | ||||
return (err); | return (err); | ||||
} | } | ||||
static int | static int | ||||
gve_detach(device_t dev) | gve_detach(device_t dev) | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |