FreeBSD/sys/dev/ixl/if_ixlv.c
/*
 * ixlv_attach() helper function; asks the PF for this VF's
 * configuration, and saves the information if it receives it.
 */
ixlv_attach() helper function; asks the PF for this VF's
configuration, and saves the information if it receives it.
ixlv_attach () helper function ; asks the PF for this VF ' s configuration and saves the information if it receives it .
static int
ixlv_vf_config(struct ixlv_sc *sc)
{
	struct i40e_hw *hw = &sc->hw;
	device_t dev = sc->dev;
	int bufsz, error = 0, ret_error = 0;
	int asq_retries, retried = 0;
retry_config:
	error = ixlv_send_vf_config_msg(sc);
	if (error) {
		device_printf(dev,
		    "%s: Unable to send VF config request, attempt %d,"
		    " error %d\n", __func__, retried + 1, error);
		ret_error = 2;
	}
	asq_retries = 0;
	while (!i40e_asq_done(hw)) {
		if (++asq_retries > IXLV_AQ_MAX_ERR) {
			device_printf(dev, "%s: Admin Queue timeout "
			    "(waiting for send_vf_config_msg), attempt %d\n",
			    __func__, retried + 1);
			ret_error = 3;
			goto fail;
		}
		i40e_msec_pause(10);
	}
	INIT_DBG_DEV(dev, "Sent VF config message to PF, attempt %d",
	    retried + 1);
	if (!sc->vf_res) {
		bufsz = sizeof(struct i40e_virtchnl_vf_resource) +
		    (I40E_MAX_VF_VSI * sizeof(struct i40e_virtchnl_vsi_resource));
		sc->vf_res = malloc(bufsz, M_DEVBUF, M_NOWAIT);
		if (!sc->vf_res) {
			device_printf(dev,
			    "%s: Unable to allocate memory for VF configuration"
			    " message from PF on attempt %d\n", __func__, retried + 1);
			ret_error = 1;
			goto fail;
		}
	}
	error = ixlv_get_vf_config(sc);
	if (error == ETIMEDOUT) {
		if (!retried) {
			retried++;
			goto retry_config;
		}
		device_printf(dev,
		    "%s: ixlv_get_vf_config() timed out waiting for a response\n",
		    __func__);
	}
	if (error) {
		device_printf(dev,
		    "%s: Unable to get VF configuration from PF after %d tries!\n",
		    __func__, retried + 1);
		ret_error = 4;
	}
	goto done;
fail:
	free(sc->vf_res, M_DEVBUF);
done:
	return (ret_error);
}
static int ixlv_vf_config ( struct ixlv_sc * sc ) { struct i40e_hw * hw = & sc -> hw ; device_t dev = sc -> dev ; int bufsz , error = 0 , ret_error = 0 ; int asq_retries , retried = 0 ; retry_config : error = ixlv_send_vf_config_msg ( sc ) ; if ( error ) { device_printf ( dev , " " " \n " , __func__ , retried + 1 , error ) ; ret_error = 2 ; } asq_retries = 0 ; while ( ! i40e_asq_done ( hw ) ) { if ( ++ asq_retries > IXLV_AQ_MAX_ERR ) { device_printf ( dev , " " " \n " , __func__ , retried + 1 ) ; ret_error = 3 ; goto fail ; } i40e_msec_pause ( 10 ) ; } INIT_DBG_DEV ( dev , " " , retried + 1 ) ; if ( ! sc -> vf_res ) { bufsz = sizeof ( struct i40e_virtchnl_vf_resource ) + ( I40E_MAX_VF_VSI * sizeof ( struct i40e_virtchnl_vsi_resource ) ) ; sc -> vf_res = malloc ( bufsz , M_DEVBUF , M_NOWAIT ) ; if ( ! sc -> vf_res ) { device_printf ( dev , " " " \n " , __func__ , retried + 1 ) ; ret_error = 1 ; goto fail ; } } error = ixlv_get_vf_config ( sc ) ; if ( error == ETIMEDOUT ) { if ( ! retried ) { retried ++ ; goto retry_config ; } device_printf ( dev , " \n " , __func__ ) ; } if ( error ) { device_printf ( dev , " \n " , __func__ , retried + 1 ) ; ret_error = 4 ; } goto done ; fail : free ( sc -> vf_res , M_DEVBUF ) ; done : return ( ret_error ) ; }
ixlv_attach() helper function; asks the PF for this VF's
 configuration, and saves the information if it receives it.
ixlv_attach () helper function ; asks the PF for this VF ' s configuration and saves the information if it receives it .
/* Check for VF config response */ /* The 1st time we timeout, send the configuration message again */