1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

ice(4): Stop checking for failures from malloc(M_WAITOK)

As a consequence now ice_alloc_vsi_qmap() does not fail. Remove unneeded
error checks.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45852

(cherry picked from commit 5f97656fa3)
This commit is contained in:
Zhenlei Huang 2024-09-03 18:25:29 +08:00
parent e4de0a965f
commit bb8c6f4325
3 changed files with 6 additions and 33 deletions

View File

@ -426,31 +426,21 @@ ice_setup_pf_vsi(struct ice_softc *sc)
* all queues for this VSI are not yet assigned an index and thus,
* not ready for use.
*
* Returns an error code on failure.
*/
int
void
ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
const int max_rx_queues)
{
struct ice_softc *sc = vsi->sc;
int i;
MPASS(max_tx_queues > 0);
MPASS(max_rx_queues > 0);
/* Allocate Tx queue mapping memory */
if (!(vsi->tx_qmap =
(u16 *) malloc(sizeof(u16) * max_tx_queues, M_ICE, M_WAITOK))) {
device_printf(sc->dev, "Unable to allocate Tx qmap memory\n");
return (ENOMEM);
}
vsi->tx_qmap = malloc(sizeof(u16) * max_tx_queues, M_ICE, M_WAITOK);
/* Allocate Rx queue mapping memory */
if (!(vsi->rx_qmap =
(u16 *) malloc(sizeof(u16) * max_rx_queues, M_ICE, M_WAITOK))) {
device_printf(sc->dev, "Unable to allocate Rx qmap memory\n");
goto free_tx_qmap;
}
vsi->rx_qmap = malloc(sizeof(u16) * max_rx_queues, M_ICE, M_WAITOK);
/* Mark every queue map as invalid to start with */
for (i = 0; i < max_tx_queues; i++) {
@ -459,14 +449,6 @@ ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
for (i = 0; i < max_rx_queues; i++) {
vsi->rx_qmap[i] = ICE_INVALID_RES_IDX;
}
return 0;
free_tx_qmap:
free(vsi->tx_qmap, M_ICE);
vsi->tx_qmap = NULL;
return (ENOMEM);
}
/**

View File

@ -830,7 +830,7 @@ void ice_free_bar(device_t dev, struct ice_bar_info *bar);
void ice_set_ctrlq_len(struct ice_hw *hw);
void ice_release_vsi(struct ice_vsi *vsi);
struct ice_vsi *ice_alloc_vsi(struct ice_softc *sc, enum ice_vsi_type type);
int ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
void ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
const int max_rx_queues);
void ice_free_vsi_qmaps(struct ice_vsi *vsi);
int ice_initialize_vsi(struct ice_vsi *vsi);

View File

@ -631,12 +631,8 @@ ice_if_attach_pre(if_ctx_t ctx)
*/
ice_setup_pf_vsi(sc);
err = ice_alloc_vsi_qmap(&sc->pf_vsi, scctx->isc_ntxqsets_max,
ice_alloc_vsi_qmap(&sc->pf_vsi, scctx->isc_ntxqsets_max,
scctx->isc_nrxqsets_max);
if (err) {
device_printf(dev, "Unable to allocate VSI Queue maps\n");
goto free_main_vsi;
}
/* Allocate MSI-X vectors (due to isc_flags IFLIB_SKIP_MSIX) */
err = ice_allocate_msix(sc);
@ -3518,12 +3514,7 @@ ice_setup_mirror_vsi(struct ice_mirr_if *mif)
mif->vsi = vsi;
/* Reserve VSI queue allocation from PF queues */
ret = ice_alloc_vsi_qmap(vsi, ICE_DEFAULT_VF_QUEUES, ICE_DEFAULT_VF_QUEUES);
if (ret) {
device_printf(dev, "%s: Unable to allocate mirror VSI queue maps (%d queues): %s\n",
__func__, ICE_DEFAULT_VF_QUEUES, ice_err_str(ret));
goto release_vsi;
}
ice_alloc_vsi_qmap(vsi, ICE_DEFAULT_VF_QUEUES, ICE_DEFAULT_VF_QUEUES);
vsi->num_tx_queues = vsi->num_rx_queues = ICE_DEFAULT_VF_QUEUES;
/* Assign Tx queues from PF space */