FreeBSD/sys/dev/ixl/if_ixlv.c
/*
 * ixlv_attach() helper function; initalizes the admin queue
 * and attempts to establish contact with the PF by
 * retrying the initial "API version" message several times
 * or until the PF responds.
 */
ixlv_attach() helper function; initalizes the admin queue
and attempts to establish contact with the PF by
retrying the initial "API version" message several times
or until the PF responds.
ixlv_attach () helper function ; initalizes the admin queue and attempts to establish contact with the PF by retrying the initial " API version " message several times or until the PF responds .
static int
ixlv_setup_vc(struct ixlv_sc *sc)
{
	struct i40e_hw *hw = &sc->hw;
	device_t dev = sc->dev;
	int error = 0, ret_error = 0, asq_retries = 0;
	bool send_api_ver_retried = 0;
	hw->aq.num_arq_entries = IXL_AQ_LEN;
	hw->aq.num_asq_entries = IXL_AQ_LEN;
	hw->aq.arq_buf_size = IXL_AQ_BUF_SZ;
	hw->aq.asq_buf_size = IXL_AQ_BUF_SZ;
	for (int i = 0; i < IXLV_AQ_MAX_ERR; i++) {
		error = i40e_init_adminq(hw);
		if (error) {
			device_printf(dev, "%s: init_adminq failed: %d\n",
			    __func__, error);
			ret_error = 1;
			continue;
		}
		INIT_DBG_DEV(dev, "Initialized Admin Queue; starting"
		    " send_api_ver attempt %d", i+1);
retry_send:
		error = ixlv_send_api_ver(sc);
		if (error) {
			i40e_shutdown_adminq(hw);
			ret_error = 2;
			device_printf(dev, "%s: unable to send api"
			    " version to PF on attempt %d, error %d\n",
			    __func__, i+1, error);
		}
		asq_retries = 0;
		while (!i40e_asq_done(hw)) {
			if (++asq_retries > IXLV_AQ_MAX_ERR) {
				i40e_shutdown_adminq(hw);
				device_printf(dev, "Admin Queue timeout "
				    "(waiting for send_api_ver), %d more tries...\n",
				    IXLV_AQ_MAX_ERR - (i + 1));
				ret_error = 3;
				break;
			} 
			i40e_msec_pause(10);
		}
		if (asq_retries > IXLV_AQ_MAX_ERR)
			continue;
		INIT_DBG_DEV(dev, "Sent API version message to PF");
		error = ixlv_verify_api_ver(sc);
		if (error == ETIMEDOUT) {
			if (!send_api_ver_retried) {
				send_api_ver_retried++;
				device_printf(dev,
				    "%s: Timeout while verifying API version on first"
				    " try!\n", __func__);
				goto retry_send;
			} else {
				device_printf(dev,
				    "%s: Timeout while verifying API version on second"
				    " try!\n", __func__);
				ret_error = 4;
				break;
			}
		}
		if (error) {
			device_printf(dev,
			    "%s: Unable to verify API version,"
			    " error %s\n", __func__, i40e_stat_str(hw, error));
			ret_error = 5;
		}
		break;
	}
	if (ret_error >= 4)
		i40e_shutdown_adminq(hw);
	return (ret_error);
}
static int ixlv_setup_vc ( struct ixlv_sc * sc ) { struct i40e_hw * hw = & sc -> hw ; device_t dev = sc -> dev ; int error = 0 , ret_error = 0 , asq_retries = 0 ; bool send_api_ver_retried = 0 ; hw -> aq . num_arq_entries = IXL_AQ_LEN ; hw -> aq . num_asq_entries = IXL_AQ_LEN ; hw -> aq . arq_buf_size = IXL_AQ_BUF_SZ ; hw -> aq . asq_buf_size = IXL_AQ_BUF_SZ ; for ( int i = 0 ; i < IXLV_AQ_MAX_ERR ; i ++ ) { error = i40e_init_adminq ( hw ) ; if ( error ) { device_printf ( dev , " \n " , __func__ , error ) ; ret_error = 1 ; continue ; } INIT_DBG_DEV ( dev , " " " " , i + 1 ) ; retry_send : error = ixlv_send_api_ver ( sc ) ; if ( error ) { i40e_shutdown_adminq ( hw ) ; ret_error = 2 ; device_printf ( dev , " " " \n " , __func__ , i + 1 , error ) ; } asq_retries = 0 ; while ( ! i40e_asq_done ( hw ) ) { if ( ++ asq_retries > IXLV_AQ_MAX_ERR ) { i40e_shutdown_adminq ( hw ) ; device_printf ( dev , " " " \n " , IXLV_AQ_MAX_ERR - ( i + 1 ) ) ; ret_error = 3 ; break ; } i40e_msec_pause ( 10 ) ; } if ( asq_retries > IXLV_AQ_MAX_ERR ) continue ; INIT_DBG_DEV ( dev , " " ) ; error = ixlv_verify_api_ver ( sc ) ; if ( error == ETIMEDOUT ) { if ( ! send_api_ver_retried ) { send_api_ver_retried ++ ; device_printf ( dev , " " " \n " , __func__ ) ; goto retry_send ; } else { device_printf ( dev , " " " \n " , __func__ ) ; ret_error = 4 ; break ; } } if ( error ) { device_printf ( dev , " " " \n " , __func__ , i40e_stat_str ( hw , error ) ) ; ret_error = 5 ; } break ; } if ( ret_error >= 4 ) i40e_shutdown_adminq ( hw ) ; return ( ret_error ) ; }
ixlv_attach() helper function; initalizes the admin queue
 and attempts to establish contact with the PF by
 retrying the initial "API version" message several times
 or until the PF responds.
ixlv_attach () helper function ; initalizes the admin queue and attempts to establish contact with the PF by retrying the initial " API version " message several times or until the PF responds .
/* Need to set these AQ paramters before initializing AQ */ /* Initialize admin queue */ /* Send VF's API version */ /* Verify that the VF accepts the PF's API version */ /* Resend message, one more time */