FreeBSD/sys/dev/ixl/ixlvc.c
/*
** ixlv_verify_api_ver
**
** Compare API versions with the PF. Must be called after admin queue is
** initialized. Returns 0 if API versions match, EIO if
** they do not, or I40E_ERR_ADMIN_QUEUE_NO_WORK if the admin queue is empty.
*/
ixlv_verify_api_ver
Compare API versions with the PF. Must be called after admin queue is
initialized. Returns 0 if API versions match, EIO if
they do not, or I40E_ERR_ADMIN_QUEUE_NO_WORK if the admin queue is empty.
ixlv_verify_api_ver Compare API versions with the PF . Must be called after admin queue is initialized . Returns 0 if API versions match EIO if they do not or I40E_ERR_ADMIN_QUEUE_NO_WORK if the admin queue is empty .
int
ixlv_verify_api_ver(struct ixlv_sc *sc)
{
	struct i40e_virtchnl_version_info *pf_vvi;
	struct i40e_hw *hw = &sc->hw;
	struct i40e_arq_event_info event;
	device_t dev = sc->dev;
	i40e_status err;
	int retries = 0;
	event.buf_len = IXL_AQ_BUF_SZ;
	event.msg_buf = malloc(event.buf_len, M_DEVBUF, M_NOWAIT);
	if (!event.msg_buf) {
		err = ENOMEM;
		goto out;
	}
	for (;;) {
		if (++retries > IXLV_AQ_MAX_ERR)
			goto out_alloc;
		i40e_msec_pause(100);
		err = i40e_clean_arq_element(hw, &event, NULL);
		if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK)
			continue;
		else if (err) {
			err = EIO;
			goto out_alloc;
		}
		if ((enum i40e_virtchnl_ops)le32toh(event.desc.cookie_high) !=
		    I40E_VIRTCHNL_OP_VERSION) {
			DDPRINTF(dev, "Received unexpected op response: %d\n",
			    le32toh(event.desc.cookie_high));
			continue;
		}
		err = (i40e_status)le32toh(event.desc.cookie_low);
		if (err) {
			err = EIO;
			goto out_alloc;
		} else
			break;
	}
	pf_vvi = (struct i40e_virtchnl_version_info *)event.msg_buf;
	if ((pf_vvi->major > I40E_VIRTCHNL_VERSION_MAJOR) ||
	    ((pf_vvi->major == I40E_VIRTCHNL_VERSION_MAJOR) &&
	    (pf_vvi->minor > I40E_VIRTCHNL_VERSION_MINOR))) {
		device_printf(dev, "Critical PF/VF API version mismatch!\n");
		err = EIO;
	} else
		sc->pf_version = pf_vvi->minor;
	device_printf(dev, "PF API %d.%d / VF API %d.%d\n",
	    pf_vvi->major, pf_vvi->minor,
	    I40E_VIRTCHNL_VERSION_MAJOR, I40E_VIRTCHNL_VERSION_MINOR);
out_alloc:
	free(event.msg_buf, M_DEVBUF);
out:
	return (err);
}
int ixlv_verify_api_ver ( struct ixlv_sc * sc ) { struct i40e_virtchnl_version_info * pf_vvi ; struct i40e_hw * hw = & sc -> hw ; struct i40e_arq_event_info event ; device_t dev = sc -> dev ; i40e_status err ; int retries = 0 ; event . buf_len = IXL_AQ_BUF_SZ ; event . msg_buf = malloc ( event . buf_len , M_DEVBUF , M_NOWAIT ) ; if ( ! event . msg_buf ) { err = ENOMEM ; goto out ; } for ( ; ; ) { if ( ++ retries > IXLV_AQ_MAX_ERR ) goto out_alloc ; i40e_msec_pause ( 100 ) ; err = i40e_clean_arq_element ( hw , & event , NULL ) ; if ( err == I40E_ERR_ADMIN_QUEUE_NO_WORK ) continue ; else if ( err ) { err = EIO ; goto out_alloc ; } if ( ( enum i40e_virtchnl_ops ) le32toh ( event . desc . cookie_high ) != I40E_VIRTCHNL_OP_VERSION ) { DDPRINTF ( dev , " \n " , le32toh ( event . desc . cookie_high ) ) ; continue ; } err = ( i40e_status ) le32toh ( event . desc . cookie_low ) ; if ( err ) { err = EIO ; goto out_alloc ; } else break ; } pf_vvi = ( struct i40e_virtchnl_version_info * ) event . msg_buf ; if ( ( pf_vvi -> major > I40E_VIRTCHNL_VERSION_MAJOR ) || ( ( pf_vvi -> major == I40E_VIRTCHNL_VERSION_MAJOR ) && ( pf_vvi -> minor > I40E_VIRTCHNL_VERSION_MINOR ) ) ) { device_printf ( dev , " \n " ) ; err = EIO ; } else sc -> pf_version = pf_vvi -> minor ; device_printf ( dev , " \n " , pf_vvi -> major , pf_vvi -> minor , I40E_VIRTCHNL_VERSION_MAJOR , I40E_VIRTCHNL_VERSION_MINOR ) ; out_alloc : free ( event . msg_buf , M_DEVBUF ) ; out : return ( err ) ; }
ixlv_verify_api_ver
Compare API versions with the PF.
ixlv_verify_api_ver Compare API versions with the PF .
/* Initial delay here is necessary */ /* Don't stop looking for expected response */ /* Log PF/VF api versions */