コード例 #1
0
ファイル: i40e_vf_representor.c プロジェクト: btw616/dpdk
static int
i40e_vf_representor_vlan_offload_set(struct rte_eth_dev *ethdev, int mask)
{
	struct i40e_vf_representor *representor = ethdev->data->dev_private;
	struct rte_eth_dev *pdev;
	struct i40e_pf_vf *vf;
	struct i40e_vsi *vsi;
	struct i40e_pf *pf;
	uint32_t vfid;

	pdev = representor->adapter->eth_dev;
	vfid = representor->vf_id;

	if (!is_i40e_supported(pdev)) {
		PMD_DRV_LOG(ERR, "Invalid PF dev.");
		return -EINVAL;
	}

	pf = I40E_DEV_PRIVATE_TO_PF(pdev->data->dev_private);

	if (vfid >= pf->vf_num || !pf->vfs) {
		PMD_DRV_LOG(ERR, "Invalid VF ID.");
		return -EINVAL;
	}

	vf = &pf->vfs[vfid];
	vsi = vf->vsi;
	if (!vsi) {
		PMD_DRV_LOG(ERR, "Invalid VSI.");
		return -EINVAL;
	}

	if (mask & ETH_VLAN_FILTER_MASK) {
		/* Enable or disable VLAN filtering offload */
		if (ethdev->data->dev_conf.rxmode.offloads &
		    DEV_RX_OFFLOAD_VLAN_FILTER)
			return i40e_vsi_config_vlan_filter(vsi, TRUE);
		else
			return i40e_vsi_config_vlan_filter(vsi, FALSE);
	}

	if (mask & ETH_VLAN_STRIP_MASK) {
		/* Enable or disable VLAN stripping offload */
		if (ethdev->data->dev_conf.rxmode.offloads &
		    DEV_RX_OFFLOAD_VLAN_STRIP)
			return i40e_vsi_config_vlan_stripping(vsi, TRUE);
		else
			return i40e_vsi_config_vlan_stripping(vsi, FALSE);
	}

	return -EINVAL;
}
コード例 #2
0
ファイル: i40e_pf.c プロジェクト: AMildner/MoonGen
static int
i40e_pf_host_process_cmd_cfg_vlan_offload(
					struct i40e_pf_vf *vf,
					uint8_t *msg,
					uint16_t msglen)
{
	int ret = I40E_SUCCESS;
	struct i40e_virtchnl_vlan_offload_info *offload =
			(struct i40e_virtchnl_vlan_offload_info *)msg;

	if (msg == NULL || msglen != sizeof(*offload)) {
		ret = I40E_ERR_PARAM;
		goto send_msg;
	}

	ret = i40e_vsi_config_vlan_stripping(vf->vsi,
						!!offload->enable_vlan_strip);
	if (ret != 0)
		PMD_DRV_LOG(ERR, "Failed to configure vlan stripping\n");

send_msg:
	i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD,
					ret, NULL, 0);

	return ret;
}