Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ice/if_ice_iflib.c
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
static void ice_if_update_admin_status(if_ctx_t ctx); | static void ice_if_update_admin_status(if_ctx_t ctx); | ||||
static void ice_if_multi_set(if_ctx_t ctx); | static void ice_if_multi_set(if_ctx_t ctx); | ||||
static void ice_if_vlan_register(if_ctx_t ctx, u16 vtag); | static void ice_if_vlan_register(if_ctx_t ctx, u16 vtag); | ||||
static void ice_if_vlan_unregister(if_ctx_t ctx, u16 vtag); | static void ice_if_vlan_unregister(if_ctx_t ctx, u16 vtag); | ||||
static void ice_if_stop(if_ctx_t ctx); | static void ice_if_stop(if_ctx_t ctx); | ||||
static uint64_t ice_if_get_counter(if_ctx_t ctx, ift_counter counter); | static uint64_t ice_if_get_counter(if_ctx_t ctx, ift_counter counter); | ||||
static int ice_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data); | static int ice_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data); | ||||
static int ice_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req); | static int ice_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req); | ||||
static int ice_if_suspend(if_ctx_t ctx); | |||||
static int ice_if_resume(if_ctx_t ctx); | |||||
static int ice_msix_que(void *arg); | static int ice_msix_que(void *arg); | ||||
static int ice_msix_admin(void *arg); | static int ice_msix_admin(void *arg); | ||||
/* | /* | ||||
* Helper function prototypes | * Helper function prototypes | ||||
*/ | */ | ||||
static int ice_pci_mapping(struct ice_softc *sc); | static int ice_pci_mapping(struct ice_softc *sc); | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | static device_method_t ice_iflib_methods[] = { | ||||
DEVMETHOD(ifdi_timer, ice_if_timer), | DEVMETHOD(ifdi_timer, ice_if_timer), | ||||
DEVMETHOD(ifdi_update_admin_status, ice_if_update_admin_status), | DEVMETHOD(ifdi_update_admin_status, ice_if_update_admin_status), | ||||
DEVMETHOD(ifdi_multi_set, ice_if_multi_set), | DEVMETHOD(ifdi_multi_set, ice_if_multi_set), | ||||
DEVMETHOD(ifdi_vlan_register, ice_if_vlan_register), | DEVMETHOD(ifdi_vlan_register, ice_if_vlan_register), | ||||
DEVMETHOD(ifdi_vlan_unregister, ice_if_vlan_unregister), | DEVMETHOD(ifdi_vlan_unregister, ice_if_vlan_unregister), | ||||
DEVMETHOD(ifdi_get_counter, ice_if_get_counter), | DEVMETHOD(ifdi_get_counter, ice_if_get_counter), | ||||
DEVMETHOD(ifdi_priv_ioctl, ice_if_priv_ioctl), | DEVMETHOD(ifdi_priv_ioctl, ice_if_priv_ioctl), | ||||
DEVMETHOD(ifdi_i2c_req, ice_if_i2c_req), | DEVMETHOD(ifdi_i2c_req, ice_if_i2c_req), | ||||
DEVMETHOD(ifdi_suspend, ice_if_suspend), | |||||
DEVMETHOD(ifdi_resume, ice_if_resume), | |||||
DEVMETHOD_END | DEVMETHOD_END | ||||
}; | }; | ||||
/** | /** | ||||
* @var ice_driver | * @var ice_driver | ||||
* @brief driver structure for the generic device stack | * @brief driver structure for the generic device stack | ||||
* | * | ||||
* driver_t definition used to setup the generic device methods. | * driver_t definition used to setup the generic device methods. | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
devclass_t ice_devclass; | devclass_t ice_devclass; | ||||
DRIVER_MODULE(ice, pci, ice_driver, ice_devclass, ice_module_event_handler, 0); | DRIVER_MODULE(ice, pci, ice_driver, ice_devclass, ice_module_event_handler, 0); | ||||
MODULE_VERSION(ice, 1); | MODULE_VERSION(ice, 1); | ||||
MODULE_DEPEND(ice, pci, 1, 1, 1); | MODULE_DEPEND(ice, pci, 1, 1, 1); | ||||
MODULE_DEPEND(ice, ether, 1, 1, 1); | MODULE_DEPEND(ice, ether, 1, 1, 1); | ||||
MODULE_DEPEND(ice, iflib, 1, 1, 1); | MODULE_DEPEND(ice, iflib, 1, 1, 1); | ||||
MODULE_DEPEND(ice, firmware, 1, 1, 1); | |||||
IFLIB_PNP_INFO(pci, ice, ice_vendor_info_array); | IFLIB_PNP_INFO(pci, ice, ice_vendor_info_array); | ||||
/* Static driver-wide sysctls */ | /* Static driver-wide sysctls */ | ||||
#include "ice_iflib_sysctls.h" | #include "ice_iflib_sysctls.h" | ||||
/** | /** | ||||
* ice_pci_mapping - Map PCI BAR memory | * ice_pci_mapping - Map PCI BAR memory | ||||
▲ Show 20 Lines • Show All 368 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* This call only updates the currently supported media types if the link | * This call only updates the currently supported media types if the link | ||||
* status changed, or if update_media is set to true. | * status changed, or if update_media is set to true. | ||||
*/ | */ | ||||
static void | static void | ||||
ice_update_link_status(struct ice_softc *sc, bool update_media) | ice_update_link_status(struct ice_softc *sc, bool update_media) | ||||
{ | { | ||||
struct ice_hw *hw = &sc->hw; | struct ice_hw *hw = &sc->hw; | ||||
enum ice_status status; | |||||
/* Never report link up when in recovery mode */ | /* Never report link up when in recovery mode */ | ||||
if (ice_test_state(&sc->state, ICE_STATE_RECOVERY_MODE)) | if (ice_test_state(&sc->state, ICE_STATE_RECOVERY_MODE)) | ||||
return; | return; | ||||
/* Report link status to iflib only once each time it changes */ | /* Report link status to iflib only once each time it changes */ | ||||
if (!ice_testandset_state(&sc->state, ICE_STATE_LINK_STATUS_REPORTED)) { | if (!ice_testandset_state(&sc->state, ICE_STATE_LINK_STATUS_REPORTED)) { | ||||
if (sc->link_up) { /* link is up */ | if (sc->link_up) { /* link is up */ | ||||
uint64_t baudrate = ice_aq_speed_to_rate(sc->hw.port_info); | uint64_t baudrate = ice_aq_speed_to_rate(sc->hw.port_info); | ||||
ice_set_default_local_lldp_mib(sc); | |||||
iflib_link_state_change(sc->ctx, LINK_STATE_UP, baudrate); | iflib_link_state_change(sc->ctx, LINK_STATE_UP, baudrate); | ||||
ice_link_up_msg(sc); | ice_link_up_msg(sc); | ||||
update_media = true; | update_media = true; | ||||
} else { /* link is down */ | } else { /* link is down */ | ||||
iflib_link_state_change(sc->ctx, LINK_STATE_DOWN, 0); | iflib_link_state_change(sc->ctx, LINK_STATE_DOWN, 0); | ||||
update_media = true; | update_media = true; | ||||
} | } | ||||
} | } | ||||
/* Update the supported media types */ | /* Update the supported media types */ | ||||
if (update_media) { | if (update_media) { | ||||
enum ice_status status = ice_add_media_types(sc, sc->media); | status = ice_add_media_types(sc, sc->media); | ||||
if (status) | if (status) | ||||
device_printf(sc->dev, "Error adding device media types: %s aq_err %s\n", | device_printf(sc->dev, "Error adding device media types: %s aq_err %s\n", | ||||
ice_status_str(status), | ice_status_str(status), | ||||
ice_aq_str(hw->adminq.sq_last_status)); | ice_aq_str(hw->adminq.sq_last_status)); | ||||
} | } | ||||
/* TODO: notify VFs of link state change */ | /* TODO: notify VFs of link state change */ | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,123 Lines • ▼ Show 20 Lines | |||||
ice_if_init(if_ctx_t ctx) | ice_if_init(if_ctx_t ctx) | ||||
{ | { | ||||
struct ice_softc *sc = (struct ice_softc *)iflib_get_softc(ctx); | struct ice_softc *sc = (struct ice_softc *)iflib_get_softc(ctx); | ||||
device_t dev = sc->dev; | device_t dev = sc->dev; | ||||
int err; | int err; | ||||
ASSERT_CTX_LOCKED(sc); | ASSERT_CTX_LOCKED(sc); | ||||
/* | |||||
* We've seen an issue with 11.3/12.1 where sideband routines are | |||||
* called after detach is called. This would call routines after | |||||
* if_stop, causing issues with the teardown process. This has | |||||
* seemingly been fixed in STABLE snapshots, but it seems like a | |||||
* good idea to have this guard here regardless. | |||||
*/ | |||||
if (ice_driver_is_detaching(sc)) | |||||
return; | |||||
if (ice_test_state(&sc->state, ICE_STATE_RECOVERY_MODE)) | if (ice_test_state(&sc->state, ICE_STATE_RECOVERY_MODE)) | ||||
return; | return; | ||||
if (ice_test_state(&sc->state, ICE_STATE_RESET_FAILED)) { | if (ice_test_state(&sc->state, ICE_STATE_RESET_FAILED)) { | ||||
device_printf(sc->dev, "request to start interface cannot be completed as the device failed to reset\n"); | device_printf(sc->dev, "request to start interface cannot be completed as the device failed to reset\n"); | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 730 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
/* | /* | ||||
* A failed pkg file download triggers safe mode, disabling advanced | * A failed pkg file download triggers safe mode, disabling advanced | ||||
* device feature support | * device feature support | ||||
*/ | */ | ||||
if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_SAFE_MODE)) | if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_SAFE_MODE)) | ||||
return; | return; | ||||
/* Set capabilities that the driver supports */ | /* Set capabilities that all devices support */ | ||||
ice_set_bit(ICE_FEATURE_SRIOV, sc->feat_cap); | ice_set_bit(ICE_FEATURE_SRIOV, sc->feat_cap); | ||||
ice_set_bit(ICE_FEATURE_RSS, sc->feat_cap); | ice_set_bit(ICE_FEATURE_RSS, sc->feat_cap); | ||||
ice_set_bit(ICE_FEATURE_LENIENT_LINK_MODE, sc->feat_cap); | ice_set_bit(ICE_FEATURE_LENIENT_LINK_MODE, sc->feat_cap); | ||||
ice_set_bit(ICE_FEATURE_DEFAULT_OVERRIDE, sc->feat_cap); | ice_set_bit(ICE_FEATURE_DEFAULT_OVERRIDE, sc->feat_cap); | ||||
/* Disable features due to hardware limitations... */ | /* Disable features due to hardware limitations... */ | ||||
if (!sc->hw.func_caps.common_cap.rss_table_size) | if (!sc->hw.func_caps.common_cap.rss_table_size) | ||||
ice_clear_bit(ICE_FEATURE_RSS, sc->feat_cap); | ice_clear_bit(ICE_FEATURE_RSS, sc->feat_cap); | ||||
▲ Show 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | |||||
* @remark The iflib-only part is pretty simple. | * @remark The iflib-only part is pretty simple. | ||||
*/ | */ | ||||
static int | static int | ||||
ice_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req) | ice_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req) | ||||
{ | { | ||||
struct ice_softc *sc = (struct ice_softc *)iflib_get_softc(ctx); | struct ice_softc *sc = (struct ice_softc *)iflib_get_softc(ctx); | ||||
return ice_handle_i2c_req(sc, req); | return ice_handle_i2c_req(sc, req); | ||||
} | |||||
/** | |||||
* ice_if_suspend - PCI device suspend handler for iflib | |||||
* @ctx: iflib context pointer | |||||
* | |||||
* Deinitializes the driver and clears HW resources in preparation for | |||||
* suspend or an FLR. | |||||
* | |||||
* @returns 0; this return value is ignored | |||||
*/ | |||||
static int | |||||
ice_if_suspend(if_ctx_t ctx) | |||||
{ | |||||
struct ice_softc *sc = (struct ice_softc *)iflib_get_softc(ctx); | |||||
/* At least a PFR is always going to happen after this; | |||||
* either via FLR or during the D3->D0 transition. | |||||
*/ | |||||
ice_clear_state(&sc->state, ICE_STATE_RESET_PFR_REQ); | |||||
ice_prepare_for_reset(sc); | |||||
return (0); | |||||
} | |||||
/** | |||||
* ice_if_resume - PCI device resume handler for iflib | |||||
* @ctx: iflib context pointer | |||||
* | |||||
* Reinitializes the driver and the HW after PCI resume or after | |||||
* an FLR. An init is performed by iflib after this function is finished. | |||||
* | |||||
* @returns 0; this return value is ignored | |||||
*/ | |||||
static int | |||||
ice_if_resume(if_ctx_t ctx) | |||||
{ | |||||
struct ice_softc *sc = (struct ice_softc *)iflib_get_softc(ctx); | |||||
ice_rebuild(sc); | |||||
return (0); | |||||
} | } | ||||