Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ice/if_ice_iflib.c
/* SPDX-License-Identifier: BSD-3-Clause */ | /* SPDX-License-Identifier: BSD-3-Clause */ | ||||
/* Copyright (c) 2022, Intel Corporation | /* Copyright (c) 2023, Intel Corporation | ||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions are met: | * modification, are permitted provided that the following conditions are met: | ||||
* | * | ||||
* 1. Redistributions of source code must retain the above copyright notice, | * 1. Redistributions of source code must retain the above copyright notice, | ||||
* this list of conditions and the following disclaimer. | * this list of conditions and the following disclaimer. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 684 Lines • ▼ Show 20 Lines | 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); | 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_rdma_link_change(sc, LINK_STATE_UP, baudrate); | ice_rdma_link_change(sc, LINK_STATE_UP, baudrate); | ||||
ice_link_up_msg(sc); | ice_link_up_msg(sc); | ||||
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); | ||||
ice_rdma_link_change(sc, LINK_STATE_DOWN, 0); | ice_rdma_link_change(sc, 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) { | ||||
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 */ | |||||
} | } | ||||
/** | /** | ||||
* ice_if_attach_post - Late device attach logic | * ice_if_attach_post - Late device attach logic | ||||
* @ctx: the iflib context structure | * @ctx: the iflib context structure | ||||
* | * | ||||
* Called by iflib to finish up attaching the device. Performs any attach | * Called by iflib to finish up attaching the device. Performs any attach | ||||
* logic which must wait until after the Tx and Rx queues have been | * logic which must wait until after the Tx and Rx queues have been | ||||
▲ Show 20 Lines • Show All 1,229 Lines • ▼ Show 20 Lines | ice_if_init(if_ctx_t ctx) | ||||
err = ice_cfg_vsi_for_rx(&sc->pf_vsi); | err = ice_cfg_vsi_for_rx(&sc->pf_vsi); | ||||
if (err) { | if (err) { | ||||
device_printf(dev, | device_printf(dev, | ||||
"Unable to configure the main VSI for Rx: %s\n", | "Unable to configure the main VSI for Rx: %s\n", | ||||
ice_err_str(err)); | ice_err_str(err)); | ||||
goto err_cleanup_tx; | goto err_cleanup_tx; | ||||
} | } | ||||
err = ice_control_rx_queues(&sc->pf_vsi, true); | err = ice_control_all_rx_queues(&sc->pf_vsi, true); | ||||
if (err) { | if (err) { | ||||
device_printf(dev, | device_printf(dev, | ||||
"Unable to enable Rx rings for transmit: %s\n", | "Unable to enable Rx rings for transmit: %s\n", | ||||
ice_err_str(err)); | ice_err_str(err)); | ||||
goto err_cleanup_tx; | goto err_cleanup_tx; | ||||
} | } | ||||
err = ice_cfg_pf_default_mac_filters(sc); | err = ice_cfg_pf_default_mac_filters(sc); | ||||
if (err) { | if (err) { | ||||
device_printf(dev, | device_printf(dev, | ||||
"Unable to configure default MAC filters: %s\n", | "Unable to configure default MAC filters: %s\n", | ||||
ice_err_str(err)); | ice_err_str(err)); | ||||
goto err_stop_rx; | goto err_stop_rx; | ||||
} | } | ||||
/* We use software interrupts for Tx, so we only program the hardware | /* We use software interrupts for Tx, so we only program the hardware | ||||
* interrupts for Rx. | * interrupts for Rx. | ||||
*/ | */ | ||||
ice_configure_rxq_interrupts(&sc->pf_vsi); | ice_configure_all_rxq_interrupts(&sc->pf_vsi); | ||||
ice_configure_rx_itr(&sc->pf_vsi); | ice_configure_rx_itr(&sc->pf_vsi); | ||||
/* Configure promiscuous mode */ | /* Configure promiscuous mode */ | ||||
ice_if_promisc_set(ctx, if_getflags(sc->ifp)); | ice_if_promisc_set(ctx, if_getflags(sc->ifp)); | ||||
ice_rdma_pf_init(sc); | ice_rdma_pf_init(sc); | ||||
ice_set_state(&sc->state, ICE_STATE_DRIVER_INITIALIZED); | ice_set_state(&sc->state, ICE_STATE_DRIVER_INITIALIZED); | ||||
return; | return; | ||||
err_stop_rx: | err_stop_rx: | ||||
ice_control_rx_queues(&sc->pf_vsi, false); | ice_control_all_rx_queues(&sc->pf_vsi, false); | ||||
err_cleanup_tx: | err_cleanup_tx: | ||||
ice_vsi_disable_tx(&sc->pf_vsi); | ice_vsi_disable_tx(&sc->pf_vsi); | ||||
} | } | ||||
/** | /** | ||||
* ice_poll_for_media_avail - Re-enable link if media is detected | * ice_poll_for_media_avail - Re-enable link if media is detected | ||||
* @sc: device private structure | * @sc: device private structure | ||||
* | * | ||||
▲ Show 20 Lines • Show All 889 Lines • ▼ Show 20 Lines | ice_if_stop(if_ctx_t ctx) | ||||
ice_rm_pf_default_mac_filters(sc); | ice_rm_pf_default_mac_filters(sc); | ||||
/* Dissociate the Tx and Rx queues from the interrupts */ | /* Dissociate the Tx and Rx queues from the interrupts */ | ||||
ice_flush_txq_interrupts(&sc->pf_vsi); | ice_flush_txq_interrupts(&sc->pf_vsi); | ||||
ice_flush_rxq_interrupts(&sc->pf_vsi); | ice_flush_rxq_interrupts(&sc->pf_vsi); | ||||
/* Disable the Tx and Rx queues */ | /* Disable the Tx and Rx queues */ | ||||
ice_vsi_disable_tx(&sc->pf_vsi); | ice_vsi_disable_tx(&sc->pf_vsi); | ||||
ice_control_rx_queues(&sc->pf_vsi, false); | ice_control_all_rx_queues(&sc->pf_vsi, false); | ||||
} | } | ||||
/** | /** | ||||
* ice_if_get_counter - Get current value of an ifnet statistic | * ice_if_get_counter - Get current value of an ifnet statistic | ||||
* @ctx: iflib context pointer | * @ctx: iflib context pointer | ||||
* @counter: ifnet counter to read | * @counter: ifnet counter to read | ||||
* | * | ||||
* Reads the current value of an ifnet counter for the device. | * Reads the current value of an ifnet counter for the device. | ||||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |