FreeBSD/sys/dev/ixl/ixlvc.c
/*
** ixlv_get_vf_config
**
** Get VF configuration from PF and populate hw structure. Must be called after
** admin queue is initialized. Busy waits until response is received from PF,
** with maximum timeout. Response from PF is returned in the buffer for further
** processing by the caller.
*/
ixlv_get_vf_config
Get VF configuration from PF and populate hw structure. Must be called after
admin queue is initialized. Busy waits until response is received from PF,
with maximum timeout. Response from PF is returned in the buffer for further
processing by the caller.
ixlv_get_vf_config Get VF configuration from PF and populate hw structure . Must be called after admin queue is initialized . Busy waits until response is received from PF with maximum timeout . Response from PF is returned in the buffer for further processing by the caller .
int
ixlv_get_vf_config(struct ixlv_sc *sc)
{
	struct i40e_hw	*hw = &sc->hw;
	device_t	dev = sc->dev;
	struct i40e_arq_event_info event;
	u16 len;
	i40e_status err = 0;
	u32 retries = 0;
	len = sizeof(struct i40e_virtchnl_vf_resource) +
	    sizeof(struct i40e_virtchnl_vsi_resource);
	event.buf_len = len;
	event.msg_buf = malloc(event.buf_len, M_DEVBUF, M_NOWAIT);
	if (!event.msg_buf) {
		err = ENOMEM;
		goto out;
	}
	for (;;) {
		err = i40e_clean_arq_element(hw, &event, NULL);
		if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK) {
			if (++retries <= IXLV_AQ_MAX_ERR)
				i40e_msec_pause(10);
		} else if ((enum i40e_virtchnl_ops)le32toh(event.desc.cookie_high) !=
		    I40E_VIRTCHNL_OP_GET_VF_RESOURCES) {
			DDPRINTF(dev, "Received a response from PF,"
			    " opcode %d, error %d",
			    le32toh(event.desc.cookie_high),
			    le32toh(event.desc.cookie_low));
			retries++;
			continue;
		} else {
			err = (i40e_status)le32toh(event.desc.cookie_low);
			if (err) {
				device_printf(dev, "%s: Error returned from PF,"
				    " opcode %d, error %d\n", __func__,
				    le32toh(event.desc.cookie_high),
				    le32toh(event.desc.cookie_low));
				err = EIO;
				goto out_alloc;
			}
			break;
		}
		if (retries > IXLV_AQ_MAX_ERR) {
			INIT_DBG_DEV(dev, "Did not receive response after %d tries.",
			    retries);
			err = ETIMEDOUT;
			goto out_alloc;
		}
	}
	memcpy(sc->vf_res, event.msg_buf, min(event.msg_len, len));
	i40e_vf_parse_hw_config(hw, sc->vf_res);
out_alloc:
	free(event.msg_buf, M_DEVBUF);
out:
	return err;
}
int ixlv_get_vf_config ( struct ixlv_sc * sc ) { struct i40e_hw * hw = & sc -> hw ; device_t dev = sc -> dev ; struct i40e_arq_event_info event ; u16 len ; i40e_status err = 0 ; u32 retries = 0 ; len = sizeof ( struct i40e_virtchnl_vf_resource ) + sizeof ( struct i40e_virtchnl_vsi_resource ) ; event . buf_len = len ; event . msg_buf = malloc ( event . buf_len , M_DEVBUF , M_NOWAIT ) ; if ( ! event . msg_buf ) { err = ENOMEM ; goto out ; } for ( ; ; ) { err = i40e_clean_arq_element ( hw , & event , NULL ) ; if ( err == I40E_ERR_ADMIN_QUEUE_NO_WORK ) { if ( ++ retries <= IXLV_AQ_MAX_ERR ) i40e_msec_pause ( 10 ) ; } else if ( ( enum i40e_virtchnl_ops ) le32toh ( event . desc . cookie_high ) != I40E_VIRTCHNL_OP_GET_VF_RESOURCES ) { DDPRINTF ( dev , " " " " , le32toh ( event . desc . cookie_high ) , le32toh ( event . desc . cookie_low ) ) ; retries ++ ; continue ; } else { err = ( i40e_status ) le32toh ( event . desc . cookie_low ) ; if ( err ) { device_printf ( dev , " " " \n " , __func__ , le32toh ( event . desc . cookie_high ) , le32toh ( event . desc . cookie_low ) ) ; err = EIO ; goto out_alloc ; } break ; } if ( retries > IXLV_AQ_MAX_ERR ) { INIT_DBG_DEV ( dev , " " , retries ) ; err = ETIMEDOUT ; goto out_alloc ; } } memcpy ( sc -> vf_res , event . msg_buf , min ( event . msg_len , len ) ) ; i40e_vf_parse_hw_config ( hw , sc -> vf_res ) ; out_alloc : free ( event . msg_buf , M_DEVBUF ) ; out : return err ; }
ixlv_get_vf_config
Get VF configuration from PF and populate hw structure.
ixlv_get_vf_config Get VF configuration from PF and populate hw structure .
/* Note this assumes a single VSI */ /* We retrieved the config message, with no errors */