| 3889 | } |
| 3890 | |
| 3891 | static int |
| 3892 | i40e_vlan_tpid_set(struct rte_eth_dev *dev, |
| 3893 | enum rte_vlan_type vlan_type, |
| 3894 | uint16_t tpid) |
| 3895 | { |
| 3896 | struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); |
| 3897 | struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); |
| 3898 | int qinq = dev->data->dev_conf.rxmode.offloads & |
| 3899 | RTE_ETH_RX_OFFLOAD_VLAN_EXTEND; |
| 3900 | u16 sw_flags = 0, valid_flags = 0; |
| 3901 | int ret = 0; |
| 3902 | |
| 3903 | if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && |
| 3904 | vlan_type != RTE_ETH_VLAN_TYPE_OUTER) || |
| 3905 | (!qinq && vlan_type == RTE_ETH_VLAN_TYPE_INNER)) { |
| 3906 | PMD_DRV_LOG(ERR, |
| 3907 | "Unsupported vlan type."); |
| 3908 | return -EINVAL; |
| 3909 | } |
| 3910 | |
| 3911 | if (pf->support_multi_driver) { |
| 3912 | PMD_DRV_LOG(ERR, "Setting TPID is not supported."); |
| 3913 | return -ENOTSUP; |
| 3914 | } |
| 3915 | |
| 3916 | /* 802.1ad frames ability is added in NVM API 1.7*/ |
| 3917 | if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) { |
| 3918 | if (qinq) { |
| 3919 | if (pf->fw8_3gt) { |
| 3920 | sw_flags = I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN; |
| 3921 | valid_flags = I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN; |
| 3922 | } |
| 3923 | if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER) |
| 3924 | hw->first_tag = rte_cpu_to_le_16(tpid); |
| 3925 | else if (vlan_type == RTE_ETH_VLAN_TYPE_INNER) |
| 3926 | hw->second_tag = rte_cpu_to_le_16(tpid); |
| 3927 | } else { |
| 3928 | if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER) |
| 3929 | hw->second_tag = rte_cpu_to_le_16(tpid); |
| 3930 | } |
| 3931 | ret = i40e_aq_set_switch_config(hw, sw_flags, |
| 3932 | valid_flags, 0, NULL); |
| 3933 | if (ret != I40E_SUCCESS) { |
| 3934 | PMD_DRV_LOG(ERR, |
| 3935 | "Set switch config failed aq_err: %d", |
| 3936 | hw->aq.asq_last_status); |
| 3937 | ret = -EIO; |
| 3938 | } |
| 3939 | } else |
| 3940 | /* If NVM API < 1.7, keep the register setting */ |
| 3941 | ret = i40e_vlan_tpid_set_by_registers(dev, vlan_type, |
| 3942 | tpid, qinq); |
| 3943 | |
| 3944 | return ret; |
| 3945 | } |
| 3946 | |
| 3947 | /* Configure outer vlan stripping on or off in QinQ mode */ |
| 3948 | static int |
no test coverage detected