FreeBSD/sys/dev/ixl/ixl_pf_iov.c
/*
 * Allocate the VSI for a VF.
 */
Allocate the VSI for a VF.
Allocate the VSI for a VF .
static int
ixl_vf_alloc_vsi(struct ixl_pf *pf, struct ixl_vf *vf)
{
	device_t dev;
	struct i40e_hw *hw;
	struct ixl_vsi *vsi;
	struct i40e_vsi_context vsi_ctx;
	int i;
	enum i40e_status_code code;
	hw = &pf->hw;
	vsi = &pf->vsi;
	dev = pf->dev;
	vsi_ctx.pf_num = hw->pf_id;
	vsi_ctx.uplink_seid = pf->veb_seid;
	vsi_ctx.connection_type = IXL_VSI_DATA_PORT;
	vsi_ctx.vf_num = hw->func_caps.vf_base_id + vf->vf_num;
	vsi_ctx.flags = I40E_AQ_VSI_TYPE_VF;
	bzero(&vsi_ctx.info, sizeof(vsi_ctx.info));
	vsi_ctx.info.valid_sections = htole16(I40E_AQ_VSI_PROP_SWITCH_VALID);
	vsi_ctx.info.switch_id = htole16(0);
	vsi_ctx.info.valid_sections |= htole16(I40E_AQ_VSI_PROP_SECURITY_VALID);
	vsi_ctx.info.sec_flags = 0;
	if (vf->vf_flags & VF_FLAG_MAC_ANTI_SPOOF)
		vsi_ctx.info.sec_flags |= I40E_AQ_VSI_SEC_FLAG_ENABLE_MAC_CHK;
	vsi_ctx.info.valid_sections |= htole16(I40E_AQ_VSI_PROP_VLAN_VALID);
	vsi_ctx.info.port_vlan_flags = I40E_AQ_VSI_PVLAN_MODE_ALL |
	    I40E_AQ_VSI_PVLAN_EMOD_NOTHING;
	vsi_ctx.info.valid_sections |=
	    htole16(I40E_AQ_VSI_PROP_QUEUE_MAP_VALID);
	vsi_ctx.info.mapping_flags = htole16(I40E_AQ_VSI_QUE_MAP_NONCONTIG);
	for (i = 0; i < vf->qtag.num_active; i++)
		vsi_ctx.info.queue_mapping[i] = vf->qtag.qidx[i];
	for (; i < nitems(vsi_ctx.info.queue_mapping); i++)
		vsi_ctx.info.queue_mapping[i] = htole16(I40E_AQ_VSI_QUEUE_MASK);
	vsi_ctx.info.tc_mapping[0] = htole16(
	    (0 << I40E_AQ_VSI_TC_QUE_OFFSET_SHIFT) |
	    (bsrl(vf->qtag.num_allocated) << I40E_AQ_VSI_TC_QUE_NUMBER_SHIFT));
	code = i40e_aq_add_vsi(hw, &vsi_ctx, NULL);
	if (code != I40E_SUCCESS)
		return (ixl_adminq_err_to_errno(hw->aq.asq_last_status));
	vf->vsi.seid = vsi_ctx.seid;
	vf->vsi.vsi_num = vsi_ctx.vsi_number;
	vf->vsi.num_queues = vf->qtag.num_active;
	code = i40e_aq_get_vsi_params(hw, &vsi_ctx, NULL);
	if (code != I40E_SUCCESS)
		return (ixl_adminq_err_to_errno(hw->aq.asq_last_status));
	code = i40e_aq_config_vsi_bw_limit(hw, vf->vsi.seid, 0, 0, NULL);
	if (code != I40E_SUCCESS) {
		device_printf(dev, "Failed to disable BW limit: %d\n",
		    ixl_adminq_err_to_errno(hw->aq.asq_last_status));
		return (ixl_adminq_err_to_errno(hw->aq.asq_last_status));
	}
	memcpy(&vf->vsi.info, &vsi_ctx.info, sizeof(vf->vsi.info));
	return (0);
}
static int ixl_vf_alloc_vsi ( struct ixl_pf * pf , struct ixl_vf * vf ) { device_t dev ; struct i40e_hw * hw ; struct ixl_vsi * vsi ; struct i40e_vsi_context vsi_ctx ; int i ; enum i40e_status_code code ; hw = & pf -> hw ; vsi = & pf -> vsi ; dev = pf -> dev ; vsi_ctx . pf_num = hw -> pf_id ; vsi_ctx . uplink_seid = pf -> veb_seid ; vsi_ctx . connection_type = IXL_VSI_DATA_PORT ; vsi_ctx . vf_num = hw -> func_caps . vf_base_id + vf -> vf_num ; vsi_ctx . flags = I40E_AQ_VSI_TYPE_VF ; bzero ( & vsi_ctx . info , sizeof ( vsi_ctx . info ) ) ; vsi_ctx . info . valid_sections = htole16 ( I40E_AQ_VSI_PROP_SWITCH_VALID ) ; vsi_ctx . info . switch_id = htole16 ( 0 ) ; vsi_ctx . info . valid_sections |= htole16 ( I40E_AQ_VSI_PROP_SECURITY_VALID ) ; vsi_ctx . info . sec_flags = 0 ; if ( vf -> vf_flags & VF_FLAG_MAC_ANTI_SPOOF ) vsi_ctx . info . sec_flags |= I40E_AQ_VSI_SEC_FLAG_ENABLE_MAC_CHK ; vsi_ctx . info . valid_sections |= htole16 ( I40E_AQ_VSI_PROP_VLAN_VALID ) ; vsi_ctx . info . port_vlan_flags = I40E_AQ_VSI_PVLAN_MODE_ALL | I40E_AQ_VSI_PVLAN_EMOD_NOTHING ; vsi_ctx . info . valid_sections |= htole16 ( I40E_AQ_VSI_PROP_QUEUE_MAP_VALID ) ; vsi_ctx . info . mapping_flags = htole16 ( I40E_AQ_VSI_QUE_MAP_NONCONTIG ) ; for ( i = 0 ; i < vf -> qtag . num_active ; i ++ ) vsi_ctx . info . queue_mapping [ i ] = vf -> qtag . qidx [ i ] ; for ( ; i < nitems ( vsi_ctx . info . queue_mapping ) ; i ++ ) vsi_ctx . info . queue_mapping [ i ] = htole16 ( I40E_AQ_VSI_QUEUE_MASK ) ; vsi_ctx . info . tc_mapping [ 0 ] = htole16 ( ( 0 << I40E_AQ_VSI_TC_QUE_OFFSET_SHIFT ) | ( bsrl ( vf -> qtag . num_allocated ) << I40E_AQ_VSI_TC_QUE_NUMBER_SHIFT ) ) ; code = i40e_aq_add_vsi ( hw , & vsi_ctx , NULL ) ; if ( code != I40E_SUCCESS ) return ( ixl_adminq_err_to_errno ( hw -> aq . asq_last_status ) ) ; vf -> vsi . seid = vsi_ctx . seid ; vf -> vsi . vsi_num = vsi_ctx . vsi_number ; vf -> vsi . num_queues = vf -> qtag . num_active ; code = i40e_aq_get_vsi_params ( hw , & vsi_ctx , NULL ) ; if ( code != I40E_SUCCESS ) return ( ixl_adminq_err_to_errno ( hw -> aq . asq_last_status ) ) ; code = i40e_aq_config_vsi_bw_limit ( hw , vf -> vsi . seid , 0 , 0 , NULL ) ; if ( code != I40E_SUCCESS ) { device_printf ( dev , " \n " , ixl_adminq_err_to_errno ( hw -> aq . asq_last_status ) ) ; return ( ixl_adminq_err_to_errno ( hw -> aq . asq_last_status ) ) ; } memcpy ( & vf -> vsi . info , & vsi_ctx . info , sizeof ( vf -> vsi . info ) ) ; return ( 0 ) ; }
Allocate the VSI for a VF.
Allocate the VSI for a VF .
/* ERJ: Only scattered allocation is supported for VFs right now */ // vf->vsi.first_queue = vf->qtag.qidx[0];