net/i40e: support VLAN stripping for VF

VLAN stripping configuration is supported only for DPDK PF
previously. Since kernel PF supports VLAN stripping now, this
patch adds VLAN stripping support for both DPDK PF and kernel
PF.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
This commit is contained in:
Beilei Xing 2017-07-04 16:26:16 +08:00 committed by Ferruh Yigit
parent bc42e6d9c3
commit 5f0b95d59a
3 changed files with 74 additions and 53 deletions

View File

@ -517,30 +517,46 @@ i40evf_config_promisc(struct rte_eth_dev *dev,
return err;
}
/* Configure vlan and double vlan offload. Use flag to specify which part to configure */
static int
i40evf_config_vlan_offload(struct rte_eth_dev *dev,
bool enable_vlan_strip)
i40evf_enable_vlan_strip(struct rte_eth_dev *dev)
{
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
int err;
struct vf_cmd_info args;
struct virtchnl_vlan_offload_info offload;
int ret;
offload.vsi_id = vf->vsi_res->vsi_id;
offload.enable_vlan_strip = enable_vlan_strip;
args.ops = (enum virtchnl_ops)I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD;
args.in_args = (uint8_t *)&offload;
args.in_args_size = sizeof(offload);
memset(&args, 0, sizeof(args));
args.ops = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
args.in_args = NULL;
args.in_args_size = 0;
args.out_buffer = vf->aq_resp;
args.out_size = I40E_AQ_BUF_SZ;
ret = i40evf_execute_vf_cmd(dev, &args);
if (ret)
PMD_DRV_LOG(ERR, "Failed to execute command of "
"VIRTCHNL_OP_ENABLE_VLAN_STRIPPING");
err = i40evf_execute_vf_cmd(dev, &args);
if (err)
PMD_DRV_LOG(ERR, "fail to execute command CFG_VLAN_OFFLOAD");
return ret;
}
return err;
static int
i40evf_disable_vlan_strip(struct rte_eth_dev *dev)
{
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
struct vf_cmd_info args;
int ret;
memset(&args, 0, sizeof(args));
args.ops = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
args.in_args = NULL;
args.in_args_size = 0;
args.out_buffer = vf->aq_resp;
args.out_size = I40E_AQ_BUF_SZ;
ret = i40evf_execute_vf_cmd(dev, &args);
if (ret)
PMD_DRV_LOG(ERR, "Failed to execute command of "
"VIRTCHNL_OP_DISABLE_VLAN_STRIPPING");
return ret;
}
static int
@ -1621,22 +1637,15 @@ i40evf_init_vlan(struct rte_eth_dev *dev)
static void
i40evf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
{
bool enable_vlan_strip = 0;
struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
/* Linux pf host doesn't support vlan offload yet */
if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
/* Vlan stripping setting */
if (mask & ETH_VLAN_STRIP_MASK) {
/* Enable or disable VLAN stripping */
if (dev_conf->rxmode.hw_vlan_strip)
enable_vlan_strip = 1;
else
enable_vlan_strip = 0;
i40evf_config_vlan_offload(dev, enable_vlan_strip);
}
/* Vlan stripping setting */
if (mask & ETH_VLAN_STRIP_MASK) {
/* Enable or disable VLAN stripping */
if (dev_conf->rxmode.hw_vlan_strip)
i40evf_enable_vlan_strip(dev);
else
i40evf_disable_vlan_strip(dev);
}
}

View File

@ -1113,37 +1113,47 @@ i40e_pf_host_process_cmd_get_stats(struct i40e_pf_vf *vf, bool b_op)
}
static int
i40e_pf_host_process_cmd_cfg_vlan_offload(
struct i40e_pf_vf *vf,
uint8_t *msg,
uint16_t msglen,
bool b_op)
i40e_pf_host_process_cmd_enable_vlan_strip(struct i40e_pf_vf *vf, bool b_op)
{
int ret = I40E_SUCCESS;
struct virtchnl_vlan_offload_info *offload =
(struct virtchnl_vlan_offload_info *)msg;
if (!b_op) {
i40e_pf_host_send_msg_to_vf(
vf,
I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD,
VIRTCHNL_OP_ENABLE_VLAN_STRIPPING,
I40E_NOT_SUPPORTED, NULL, 0);
return ret;
}
if (msg == NULL || msglen != sizeof(*offload)) {
ret = I40E_ERR_PARAM;
goto send_msg;
ret = i40e_vsi_config_vlan_stripping(vf->vsi, TRUE);
if (ret != 0)
PMD_DRV_LOG(ERR, "Failed to enable vlan stripping");
i40e_pf_host_send_msg_to_vf(vf, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING,
ret, NULL, 0);
return ret;
}
static int
i40e_pf_host_process_cmd_disable_vlan_strip(struct i40e_pf_vf *vf, bool b_op)
{
int ret = I40E_SUCCESS;
if (!b_op) {
i40e_pf_host_send_msg_to_vf(
vf,
VIRTCHNL_OP_DISABLE_VLAN_STRIPPING,
I40E_NOT_SUPPORTED, NULL, 0);
return ret;
}
ret = i40e_vsi_config_vlan_stripping(vf->vsi,
!!offload->enable_vlan_strip);
ret = i40e_vsi_config_vlan_stripping(vf->vsi, FALSE);
if (ret != 0)
PMD_DRV_LOG(ERR, "Failed to configure vlan stripping");
PMD_DRV_LOG(ERR, "Failed to disable vlan stripping");
send_msg:
i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD,
ret, NULL, 0);
i40e_pf_host_send_msg_to_vf(vf, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING,
ret, NULL, 0);
return ret;
}
@ -1342,10 +1352,13 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
PMD_DRV_LOG(INFO, "OP_GET_STATS received");
i40e_pf_host_process_cmd_get_stats(vf, b_op);
break;
case I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD:
PMD_DRV_LOG(INFO, "OP_CFG_VLAN_OFFLOAD received");
i40e_pf_host_process_cmd_cfg_vlan_offload(vf, msg,
msglen, b_op);
case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
PMD_DRV_LOG(INFO, "OP_ENABLE_VLAN_STRIPPING received");
i40e_pf_host_process_cmd_enable_vlan_strip(vf, b_op);
break;
case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
PMD_DRV_LOG(INFO, "OP_DISABLE_VLAN_STRIPPING received");
i40e_pf_host_process_cmd_disable_vlan_strip(vf, b_op);
break;
case I40E_VIRTCHNL_OP_CFG_VLAN_PVID:
PMD_DRV_LOG(INFO, "OP_CFG_VLAN_PVID received");

View File

@ -54,9 +54,8 @@ enum virtchnl_ops_dpdk {
* Keep some gap between Linux PF commands and
* DPDK PF extended commands.
*/
I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD = VIRTCHNL_OP_VERSION +
I40E_DPDK_OFFSET,
I40E_VIRTCHNL_OP_CFG_VLAN_PVID,
I40E_VIRTCHNL_OP_CFG_VLAN_PVID = VIRTCHNL_OP_VERSION +
I40E_DPDK_OFFSET,
VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT,
};