net/i40e: add outer VLAN processing
PATCH 1/1 net/i40e: add outer VLAN processing
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK. This will not impact on an old firmware.
--- drivers/net/i40e/i40e_ethdev.c | 58 +++++++++++++++++++++++++++++++--- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 56 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_ethdev.c +53 -5
@@ -2591,11 +2591,31 @@ i40e_dev_close(struct rte_eth_dev *dev)int ret;uint8_t aq_fail =0 ;int retries =0 ; +int mask =0 ; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;PMD_INIT_FUNC_TRACE ();if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +/* +* To avoid global register conflict with kernel driver, need set +* switch configuration back to default, disable double vlan and +* clear the VLAN filters when dev close. +*/ +if (pf->is_outer_vlan_processing && + (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + mask =RTE_ETH_VLAN_EXTEND_MASK ; + rxmode->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; + +if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_FILTER ) { + mask |=RTE_ETH_VLAN_FILTER_MASK ; + rxmode->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_FILTER ; + } + +i40e_vlan_offload_set (dev, mask); + } + ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret)PMD_INIT_LOG (WARNING ,"failed to free switch domain: %d" , ret);
@@ -3918,6 +3938,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ;int ret =0 ; +u16 sw_flags =0 , valid_flags =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && vlan_type != RTE_ETH_VLAN_TYPE_OUTER) ||
@@ -3935,15 +3956,28 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->is_outer_vlan_processing) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +if (pf->is_outer_vlan_processing) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + } +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) { +if (pf->is_outer_vlan_processing) + hw->first_tag =rte_cpu_to_le_16 (tpid); +else + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",
@@ -4022,9 +4056,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->is_outer_vlan_processing) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -4854,6 +4891,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->is_outer_vlan_processing = true; + }else { + pf->is_outer_vlan_processing = false; + } +return 0 ; }
drivers/net/i40e/i40e_ethdev.h +3 -0
@@ -1190,6 +1190,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* The enable flag for outer VLAN processing */ +bool is_outer_vlan_processing; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;
Signature · 1 line
2.25.1
PATCH v2 1/1 net/i40e: add outer VLAN processing
Outer VLAN processing is supported after firmware v8.4, kernel driver also changes the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
--- drivers/net/i40e/i40e_ethdev.c | 79 +++++++++++++++++++++++++++++++--- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 77 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_ethdev.c +74 -5
@@ -3910,6 +3910,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ;int ret =0 ; +u16 sw_flags =0 , valid_flags =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && vlan_type != RTE_ETH_VLAN_TYPE_OUTER) ||
@@ -3927,15 +3928,28 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->is_outer_vlan_processing) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +if (pf->is_outer_vlan_processing) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + } +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) { +if (pf->is_outer_vlan_processing) + hw->first_tag =rte_cpu_to_le_16 (tpid); +else + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",
@@ -3987,8 +4001,12 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num, ret; +void *temp; rxmode = &dev->data->dev_conf.rxmode;if (mask &RTE_ETH_VLAN_FILTER_MASK ) {
@@ -4007,6 +4025,35 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/** +* Outer VLAN processing is supported after firmware v8.4, kernel driver +* also changes the default behavior to support this feature. To align with +* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for +* outer VLAN processing. But it is forbidden for firmware to change the +* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the +* switch table. Therefore, we need to clear the MAC table before setting +* config, and then restore the MAC table after setting. This feature is +* recommended to be used in firmware v8.6 at least. +**/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret =i40e_vsi_delete_mac (vsi, &f->mac_info.mac_addr); +if (ret !=I40E_SUCCESS ) { +PMD_DRV_LOG (ERR ,"Failed to delete mac filter" ); +return -EIO ; + } + i++; + }if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ) {i40e_vsi_config_double_vlan (vsi, TRUE);/* Set global registers with default ethertype. */
@@ -4014,9 +4061,20 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->is_outer_vlan_processing) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret !=I40E_SUCCESS ) { +PMD_DRV_LOG (ERR ,"Failed to add mac filter" ); +return -EIO ; + } + } }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -4846,6 +4904,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->is_outer_vlan_processing = true; + }else { + pf->is_outer_vlan_processing = false; + } +return 0 ; }
drivers/net/i40e/i40e_ethdev.h +3 -0
@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* The enable flag for outer VLAN processing */ +bool is_outer_vlan_processing; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;
Signature · 1 line
2.25.1
PATCH v3 1/1 net/i40e: add outer VLAN processing
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
--- drivers/net/i40e/i40e_ethdev.c | 76 +++++++++++++++++++++++++++++++--- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 74 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_ethdev.c +71 -5
@@ -3909,6 +3909,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&
@@ -3927,15 +3928,34 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->is_outer_vlan_processing) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/*When FW > 8.3, the tpid must be set to QinQ to close extend*/ +if (tpid ==RTE_ETHER_TYPE_QINQ ) { +if (pf->is_outer_vlan_processing) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + } +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) { +if (pf->is_outer_vlan_processing) + hw->first_tag =rte_cpu_to_le_16 (tpid); +else + hw->second_tag =rte_cpu_to_le_16 (tpid); + } + }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",
@@ -3987,8 +4007,12 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; rxmode = &dev->data->dev_conf.rxmode;if (mask &RTE_ETH_VLAN_FILTER_MASK ) {
@@ -4007,6 +4031,30 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/** +* Outer VLAN processing is supported after firmware v8.4, kernel driver +* also change the default behavior to support this feature. To align with +* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for +* outer VLAN processing. But it is forbidden for firmware to change the +* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the +* switch table. Therefore, we need to clear the MAC table before setting +* config, and then restore the MAC table after setting. This feature is +* recommended to be used in firmware v8.6. +**/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; +i40e_vsi_delete_mac (vsi, &f->mac_info.mac_addr); + }if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ) {i40e_vsi_config_double_vlan (vsi, TRUE);/* Set global registers with default ethertype. */
@@ -4014,9 +4062,16 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->is_outer_vlan_processing) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) +i40e_vsi_add_mac (vsi, &mac_filter[i]); +rte_free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -4846,6 +4901,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->is_outer_vlan_processing = true; + }else { + pf->is_outer_vlan_processing = false; + } +return 0 ; }
drivers/net/i40e/i40e_ethdev.h +3 -0
@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* The enable flag for outer VLAN processing */ +bool is_outer_vlan_processing; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;
Signature · 1 line
2.34.1
PATCH v4 1/1 net/i40e: add outer VLAN processing
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
--- drivers/net/i40e/i40e_ethdev.c | 83 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 81 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_ethdev.c +78 -5
@@ -3909,6 +3909,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&
@@ -3927,15 +3928,34 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->is_outer_vlan_processing) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/*When FW > 8.3, the tpid must be set to QinQ to close extend*/ +if (tpid ==RTE_ETHER_TYPE_QINQ ) { +if (pf->is_outer_vlan_processing) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + } +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) { +if (pf->is_outer_vlan_processing) + hw->first_tag =rte_cpu_to_le_16 (tpid); +else + hw->second_tag =rte_cpu_to_le_16 (tpid); + } + }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",
@@ -3987,8 +4007,13 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode;if (mask &RTE_ETH_VLAN_FILTER_MASK ) {
@@ -4007,6 +4032,33 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/** +* Outer VLAN processing is supported after firmware v8.4, kernel driver +* also change the default behavior to support this feature. To align with +* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for +* outer VLAN processing. But it is forbidden for firmware to change the +* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the +* switch table. Therefore, we need to clear the MAC table before setting +* config, and then restore the MAC table after setting. This feature is +* recommended to be used in firmware v8.6. +**/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret =i40e_vsi_delete_mac (vsi, &f->mac_info.mac_addr); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi delete mac fail." ); + i++; + }if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ) {i40e_vsi_config_double_vlan (vsi, TRUE);/* Set global registers with default ethertype. */
@@ -4014,9 +4066,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->is_outer_vlan_processing) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -4846,6 +4908,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->is_outer_vlan_processing = true; + }else { + pf->is_outer_vlan_processing = false; + } +return 0 ; }
drivers/net/i40e/i40e_ethdev.h +3 -0
@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* The enable flag for outer VLAN processing */ +bool is_outer_vlan_processing; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;
Signature · 1 line
2.34.1
Quoted 62 lines
-----Original Message-----
From: Kevin Liu <[email protected]>
Sent: Thursday, June 9, 2022 10:43 PM
To: [email protected]
Cc: Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v4] net/i40e: add outer VLAN processingFrom: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table.
Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 83 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 81 insertions(+), 5 deletions(-)drivers/net/i40e/i40e_ethdev.c +1
-0@@ -3909,6 +3909,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data- >dev_private);int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ;drivers/net/i40e/i40e_ethdev.c +3
-0if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && @@ -3927,15 +3928,34 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, /* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) { if (qinq) { + if (pf->is_outer_vlan_processing) { + sw_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +2
-2+ }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/*When FW > 8.3, the tpid must be set to QinQ to
Quoted 1 line
close extend*/
The comment is confusing, there is no firmware version related check in below code And what is "set to QinQ to close extend" means?
PATCH v5 1/1 net/i40e: add outer VLAN processing
In reply to Kevin LiuFrom: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_ethdev.c +89 -5
@@ -2513,11 +2513,24 @@ i40e_dev_stop(struct rte_eth_dev *dev)struct i40e_vsi *main_vsi = pf->main_vsi;struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;int i;if (hw->adapter_stopped ==1 )return 0 ; +/* +* It is a workaround, when firmware > v8.3, if the double VLAN +* is disabled when the program exits, an abnormal error will occur +* on the NIC. Need to enable double VLAN when dev is closed. +*/ +if (pf->is_outer_vlan_processing) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } +if (dev->data->dev_conf.intr_conf.rxq ==0 ) {rte_eal_alarm_cancel (i40e_dev_alarm_handler, dev);rte_intr_enable (intr_handle);
@@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&
@@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->is_outer_vlan_processing) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/* +* When firmware > 8.3, if tpid is equal to 0x88A8, +* indicates that the disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/ +if (pf->is_outer_vlan_processing && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->first_tag =rte_cpu_to_le_16 (tpid); + }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",
@@ -3987,8 +4018,13 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode;if (mask &RTE_ETH_VLAN_FILTER_MASK ) {
@@ -4007,6 +4043,33 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver +* also change the default behavior to support this feature. To align with +* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for +* outer VLAN processing. But it is forbidden for firmware to change the +* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the +* switch table. Therefore, we need to clear the MAC table before setting +* config, and then restore the MAC table after setting. This feature is +* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret =i40e_vsi_delete_mac (vsi, &f->mac_info.mac_addr); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi delete mac fail." ); + i++; + }if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ) {i40e_vsi_config_double_vlan (vsi, TRUE);/* Set global registers with default ethertype. */
@@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->is_outer_vlan_processing) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -4846,6 +4919,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->is_outer_vlan_processing = true; + }else { + pf->is_outer_vlan_processing = false; + } +return 0 ; }
drivers/net/i40e/i40e_ethdev.h +3 -0
@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* The enable flag for outer VLAN processing */ +bool is_outer_vlan_processing; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;
Signature · 1 line
2.34.1
PATCH v6 1/1 net/i40e: add outer VLAN processing
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_ethdev.c +89 -5
@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;uint32_t reg;
@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +/* +* It is a workaround, when firmware > v8.3, if the double VLAN +* is disabled when the program exits, an abnormal error will occur +* on the NIC. Need to enable double VLAN when dev is closed. +*/ +if (pf->is_outer_vlan_processing) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } + ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret)PMD_INIT_LOG (WARNING ,"failed to free switch domain: %d" , ret);
@@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&
@@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->is_outer_vlan_processing) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/* +* When firmware > 8.3, if tpid is equal to 0x88A8, +* indicates that the disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/ +if (pf->is_outer_vlan_processing && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->first_tag =rte_cpu_to_le_16 (tpid); + }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",
@@ -3987,8 +4018,13 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode;if (mask &RTE_ETH_VLAN_FILTER_MASK ) {
@@ -4007,6 +4043,33 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver +* also change the default behavior to support this feature. To align with +* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for +* outer VLAN processing. But it is forbidden for firmware to change the +* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the +* switch table. Therefore, we need to clear the MAC table before setting +* config, and then restore the MAC table after setting. This feature is +* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret =i40e_vsi_delete_mac (vsi, &f->mac_info.mac_addr); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi delete mac fail." ); + i++; + }if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ) {i40e_vsi_config_double_vlan (vsi, TRUE);/* Set global registers with default ethertype. */
@@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->is_outer_vlan_processing) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -4846,6 +4919,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->is_outer_vlan_processing = true; + }else { + pf->is_outer_vlan_processing = false; + } +return 0 ; }
drivers/net/i40e/i40e_ethdev.h +3 -0
@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* The enable flag for outer VLAN processing */ +bool is_outer_vlan_processing; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;
Signature · 1 line
2.34.1
Quoted 201 lines
-----Original Message-----
From: Kevin Liu <[email protected]>
Sent: Friday, June 10, 2022 11:52 PM
To: [email protected]
Cc: Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v6] net/i40e: add outer VLAN processingFrom: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table.
Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)drivers/net/i40e/i40e_ethdev.c +1
-0@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data- >dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;drivers/net/i40e/i40e_ethdev.c +12
-0uint32_t reg;@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +/* +* It is a workaround, when firmware > v8.3, if the double VLAN +* is disabled when the program exits, an abnormal error will occur +* on the NIC. Need to enable double VLAN when dev is closed. +*/ +if (pf->is_outer_vlan_processing) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } +drivers/net/i40e/i40e_ethdev.c +0
-0ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret) PMD_INIT_LOG(WARNING, "failed to free switch domain: %d",ret); @@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct
rte_eth_dev*dev,
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c +4
-0int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && @@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, /* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) { if (qinq) { + if (pf->is_outer_vlan_processing) { + sw_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +4
-2+ }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/* +* When firmware > 8.3, if tpid is equal to 0x88A8, +* indicates that the disable double VLAN operation is in progress.
drivers/net/i40e/i40e_ethdev.c +3
-0+* Need set switch configuration back to default. +*/ + if (pf->is_outer_vlan_processing && tpid ==
RTE_ETHER_TYPE_QINQ) {drivers/net/i40e/i40e_ethdev.c +2
-0+ sw_flags =0 ; + valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +2
-0+if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->first_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +3
-0+ }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +3
-1+ } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d", @@ -3987,8 +4018,13 @@ static int
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask){
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c +5
-0+struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode; if (mask & RTE_ETH_VLAN_FILTER_MASK) { @@ -4007,6 +4043,33@@
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)drivers/net/i40e/i40e_ethdev.c +11
-0}if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver
drivers/net/i40e/i40e_ethdev.c +1
-0+* also change the default behavior to support this feature. To align with
drivers/net/i40e/i40e_ethdev.c +1
-0+* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for
drivers/net/i40e/i40e_ethdev.c +1
-0+* outer VLAN processing. But it is forbidden for firmware to change the
drivers/net/i40e/i40e_ethdev.c +1
-0+* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the
drivers/net/i40e/i40e_ethdev.c +1
-0+* switch table. Therefore, we need to clear the MAC table before setting
drivers/net/i40e/i40e_ethdev.c +1
-0+* config, and then restore the MAC table after setting. This feature is
drivers/net/i40e/i40e_ethdev.c +6
-0+* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret = i40e_vsi_delete_mac(vsi, &f-Quoted 1 line
mac_info.mac_addr);
drivers/net/i40e/i40e_ethdev.c +2
-0+if (ret) + PMD_DRV_LOG(ERR, "i40e vsi delete macfail.");
drivers/net/i40e/i40e_ethdev.c +2
-0+ i++; + } if (rxmode->offloads &
RTE_ETH_RX_OFFLOAD_VLAN_EXTEND) {drivers/net/i40e/i40e_ethdev.c +0
-1i40e_vsi_config_double_vlan (vsi, TRUE); /* Set global registers with default ethertype. */ @@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, intmask)
drivers/net/i40e/i40e_ethdev.c +3
-2RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->is_outer_vlan_processing) + i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_OUTER,drivers/net/i40e/i40e_ethdev.c +9
-0+ RTE_ETHER_TYPE_QINQ);i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
drivers/net/i40e/i40e_ethdev.c i40e_pf_parameter_init(struct rte_eth_dev *dev) · line 4928
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +7
-0@@ -4846,6 +4919,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->is_outer_vlan_processing = true;
Why not just name the flag as "fw8_3gt?
Then you don't need to repeat explain "when firmware > 8.3" above the is_outer_vlan_processing flag.
Quoted 233 lines
-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: 2022年6月10日 16:07
To: Liu, KevinX <[email protected]>; [email protected]
Cc: Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>; Liu, KevinX <[email protected]>
Subject: RE: [PATCH v6] net/i40e: add outer VLAN processingQuoted 62 lines
-----Original Message-----
From: Kevin Liu <[email protected]>
Sent: Friday, June 10, 2022 11:52 PM
To: [email protected]
Cc: Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v6] net/i40e: add outer VLAN processingFrom: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex755786dc10..c708bdb0d4100644drivers/net/i40e/i40e_ethdev.c +1
-0@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data- >dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;drivers/net/i40e/i40e_ethdev.c +12
-0uint32_t reg;@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +/* +* It is a workaround, when firmware > v8.3, if the double VLAN +* is disabled when the program exits, an abnormal error will occur +* on the NIC. Need to enable double VLAN when dev is closed. +*/ +if (pf->is_outer_vlan_processing) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } +drivers/net/i40e/i40e_ethdev.c i40e_dev_close(struct rte_eth_dev *dev)
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +0
-0ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret) PMD_INIT_LOG(WARNING, "failed to free switchdomain: %d", ret); @@
Quoted 37 lines
-3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct
rte_eth_dev*dev,
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c +4
-0int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && @@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, /* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) { if (qinq) { + if (pf->is_outer_vlan_processing) { + sw_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +4
-2+ }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/* +* When firmware > 8.3, if tpid is equal to 0x88A8, +* indicates that the disable double VLAN operation is in progress.
drivers/net/i40e/i40e_ethdev.c +3
-0+* Need set switch configuration back to default. +*/ + if (pf->is_outer_vlan_processing && tpid ==
RTE_ETHER_TYPE_QINQ) {drivers/net/i40e/i40e_ethdev.c +2
-0+ sw_flags =0 ; + valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c
Quoted 1 line
drivers/net/i40e/i40e_ethdev.c +1
-0+ if (vlan_type ==
RTE_ETH_VLAN_TYPE_OUTER)drivers/net/i40e/i40e_ethdev.c
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c +1
-0+ hw->first_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +2
-0+ }else { + if (vlan_type ==
RTE_ETH_VLAN_TYPE_OUTER)Quoted 14 lines
drivers/net/i40e/i40e_ethdev.c +1
-0+ hw->second_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +3
-1+ } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d", @@ -3987,8 +4018,13 @@ static int
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask){
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c static int
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode; if (mask & RTE_ETH_VLAN_FILTER_MASK) { @@ -4007,6 +4043,33@@
Quoted 16 lines
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)drivers/net/i40e/i40e_ethdev.c +11
-0}if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver
drivers/net/i40e/i40e_ethdev.c
Quoted 1 line
drivers/net/i40e/i40e_ethdev.c +1
-0+* also change the default behavior to support this feature. To
drivers/net/i40e/i40e_ethdev.c
Quoted 6 lines
align with
drivers/net/i40e/i40e_ethdev.c +1
-0+* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for
drivers/net/i40e/i40e_ethdev.c +1
-0+* outer VLAN processing. But it is forbidden for firmware to change the
drivers/net/i40e/i40e_ethdev.c +1
-0+* Inner/Outer VLAN configuration while there are MAC/VLAN
Quoted 23 lines
filters in the
drivers/net/i40e/i40e_ethdev.c +1
-0+* switch table. Therefore, we need to clear the MAC table before setting
drivers/net/i40e/i40e_ethdev.c +1
-0+* config, and then restore the MAC table after setting. This feature is
drivers/net/i40e/i40e_ethdev.c +6
-0+* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret = i40e_vsi_delete_mac(vsi, &f-Quoted 1 line
mac_info.mac_addr);
drivers/net/i40e/i40e_ethdev.c +2
-0+if (ret) + PMD_DRV_LOG(ERR, "i40e vsi delete macfail.");
drivers/net/i40e/i40e_ethdev.c +2
-0+ i++; + } if (rxmode->offloads &
RTE_ETH_RX_OFFLOAD_VLAN_EXTEND) {drivers/net/i40e/i40e_ethdev.c +0
-1i40e_vsi_config_double_vlan (vsi, TRUE); /* Set global registers with default ethertype. */ @@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, intmask)
drivers/net/i40e/i40e_ethdev.c
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +0
-0RTE_ETHER_TYPE_VLAN); i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_INNER,Quoted 21 lines
drivers/net/i40e/i40e_ethdev.c +3
-2RTE_ETHER_TYPE_VLAN); - } -else + }else { +if (pf->is_outer_vlan_processing) + i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_OUTER,drivers/net/i40e/i40e_ethdev.c +9
-0+ RTE_ETHER_TYPE_QINQ);i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); } if (mask & RTE_ETH_QINQ_STRIP_MASK) { @@ -4846,6 +4919,17 @@
i40e_pf_parameter_init(struct rte_eth_dev *dev)drivers/net/i40e/i40e_ethdev.c i40e_pf_parameter_init(struct rte_eth_dev *dev) · line 4928
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +7
-0return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->is_outer_vlan_processing = true;Why not just name the flag as "
fw8_3gt?
Quoted 3 lines
Then you don't need to repeat explain "when firmware > 8.3" above the
is_outer_vlan_processingflag.
That's a good idea, I will send v7, thank you!
PATCH v7 1/1 net/i40e: add outer VLAN processing
In reply to Kevin LiuFrom: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_ethdev.c +89 -5
@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;uint32_t reg;
@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +/* +* It is a workaround, if the double VLAN is disabled when +* the program exits, an abnormal error will occur on the +* NIC. Need to enable double VLAN when dev is closed. +*/ +if (pf->fw8_3gt) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } + ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret)PMD_INIT_LOG (WARNING ,"failed to free switch domain: %d" , ret);
@@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&
@@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->fw8_3gt) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/* +* If tpid is equal to 0x88A8, indicates that the +* disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/ +if (pf->fw8_3gt && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->first_tag =rte_cpu_to_le_16 (tpid); + }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",
@@ -3987,8 +4018,13 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode;if (mask &RTE_ETH_VLAN_FILTER_MASK ) {
@@ -4007,6 +4043,33 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver +* also change the default behavior to support this feature. To align with +* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for +* outer VLAN processing. But it is forbidden for firmware to change the +* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the +* switch table. Therefore, we need to clear the MAC table before setting +* config, and then restore the MAC table after setting. This feature is +* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret =i40e_vsi_delete_mac (vsi, &f->mac_info.mac_addr); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi delete mac fail." ); + i++; + }if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ) {i40e_vsi_config_double_vlan (vsi, TRUE);/* Set global registers with default ethertype. */
@@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->fw8_3gt) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -4846,6 +4919,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->fw8_3gt = true; + }else { + pf->fw8_3gt = false; + } +return 0 ; }
drivers/net/i40e/i40e_ethdev.h +3 -0
@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* When firmware > 8.3, the enable flag for outer VLAN processing */ +bool fw8_3gt; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;
Signature · 1 line
2.34.1
I'm trying to understand if this change is at all related to an issue we are experiencing with newer firmwares (
https://mails.dpdk.org/archives/dev/2022-April/238621.html) that happened to start with 8.4 and affected qinq offload processing. I can say loading this patch and running testpmd does not seem to have any effect on the issue we are experiencing.
Side note, there is also a minor typo in the comment block "i40e_vlan_tpie_set" vs "i40e_vlan_tpid_set".
Thanks
Quoted 226 lines · Kevin Liu
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)drivers/net/i40e/i40e_ethdev.c +1
-0@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;uint32_t reg;drivers/net/i40e/i40e_ethdev.c +12
-0@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +/* +* It is a workaround, if the double VLAN is disabled when +* the program exits, an abnormal error will occur on the +* NIC. Need to enable double VLAN when dev is closed. +*/ +if (pf->fw8_3gt) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } + ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret)PMD_INIT_LOG(WARNING, "failed to free switch domain: %d",
ret);drivers/net/i40e/i40e_ethdev.c +1
-0@@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ;if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&drivers/net/i40e/i40e_ethdev.c +25
-3@@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->fw8_3gt) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/* +* If tpid is equal to 0x88A8, indicates that the +* disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/ +if (pf->fw8_3gt && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->first_tag =rte_cpu_to_le_16 (tpid); + }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",@@ -3987,8 +4018,13 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode;if (mask & RTE_ETH_VLAN_FILTER_MASK) {drivers/net/i40e/i40e_ethdev.c +11
-0@@ -4007,6 +4043,33 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver
+ * also change the default behavior to support this
feature. To align with
+ * kernel driver, set switch config in
'i40e_vlan_tpie_set' to support for
+ * outer VLAN processing. But it is forbidden for firmware
to change the
+ * Inner/Outer VLAN configuration while there are MAC/VLAN
filters in the
+ * switch table. Therefore, we need to clear the MAC table
before setting
+ * config, and then restore the MAC table after setting.
This feature isdrivers/net/i40e/i40e_ethdev.c +6
-0+* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret = i40e_vsi_delete_mac(vsi,
&f->mac_info.mac_addr);drivers/net/i40e/i40e_ethdev.c +2
-0+if (ret) + PMD_DRV_LOG(ERR, "i40e vsi delete macfail.");
drivers/net/i40e/i40e_ethdev.c +14
-2+ i++; + }if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ) {i40e_vsi_config_double_vlan (vsi, TRUE);/* Set global registers with default ethertype. */ @@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->fw8_3gt) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }if (mask & RTE_ETH_QINQ_STRIP_MASK) {drivers/net/i40e/i40e_ethdev.c +11
-0@@ -4846,6 +4919,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->fw8_3gt = true; + }else { + pf->fw8_3gt = false; + } +return 0 ; }drivers/net/i40e/i40e_ethdev.h +3
-0@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* When firmware > 8.3, the enable flag for outer VLAN processing */ +bool fw8_3gt; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;--
2.34.1
Hi, Ben
This patch can only take effect after firmware v8.6. It cannot be used on firmware v8.4 and v8.5. The reason is that the firmware team gave a clear reply that there are many related bugs in firmware v8.4 and v8.5, and they were fixed in firmware v8.6. The firmware team recommends using v8.6.
Regards
Kevin
From: Ben Magistro <[email protected]>
Sent: 2022年6月10日 22:27
To: Liu, KevinX <[email protected]>
Cc: [email protected]; Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: Re: [PATCH v7] net/i40e: add outer VLAN processing
I'm trying to understand if this change is at all related to an issue we are experiencing with newer firmwares (https://mails.dpdk.org/archives/dev/2022-April/238621.html) that happened to start with 8.4 and affected qinq offload processing. I can say loading this patch and running testpmd does not seem to have any effect on the issue we are experiencing.
Side note, there is also a minor typo in the comment block "i40e_vlan_tpie_set" vs "i40e_vlan_tpid_set".
Thanks
On Fri, Jun 10, 2022 at 4:30 AM Kevin Liu <[email protected]<mailto:[email protected]>> wrote:
From: Robin Zhang <[email protected]<mailto:[email protected]>>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_ethdev.c +89 -5
@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;uint32_t reg;
@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +/* +* It is a workaround, if the double VLAN is disabled when +* the program exits, an abnormal error will occur on the +* NIC. Need to enable double VLAN when dev is closed. +*/ +if (pf->fw8_3gt) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } + ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret)PMD_INIT_LOG (WARNING ,"failed to free switch domain: %d" , ret);
@@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&
@@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->fw8_3gt) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/* +* If tpid is equal to 0x88A8, indicates that the +* disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/ +if (pf->fw8_3gt && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->first_tag =rte_cpu_to_le_16 (tpid); + }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",
@@ -3987,8 +4018,13 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode;if (mask &RTE_ETH_VLAN_FILTER_MASK ) {
@@ -4007,6 +4043,33 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver +* also change the default behavior to support this feature. To align with +* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for +* outer VLAN processing. But it is forbidden for firmware to change the +* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the +* switch table. Therefore, we need to clear the MAC table before setting +* config, and then restore the MAC table after setting. This feature is +* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret =i40e_vsi_delete_mac (vsi, &f->mac_info.mac_addr); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi delete mac fail." ); + i++; + }if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ) {i40e_vsi_config_double_vlan (vsi, TRUE);/* Set global registers with default ethertype. */
@@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->fw8_3gt) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -4846,6 +4919,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->fw8_3gt = true; + }else { + pf->fw8_3gt = false; + } +return 0 ; }
drivers/net/i40e/i40e_ethdev.h +3 -0
@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* When firmware > 8.3, the enable flag for outer VLAN processing */ +bool fw8_3gt; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;
--
2.34.1
Thanks for the information on 8.4. Unfortunately most of NICs are from Dell so will need to push them to produce another update package and would prefer to wait till we know what is required to fix our issue.
I loaded 8.6 and 8.7 on one of our test hosts and our issue still exists so will continue pushing the open case we have with Intel as that is where we still think this lies.
Cheers,
Ben
Quoted 271 lines · KevinX
Hi, Ben
This patch can only take effect after firmware v8.6. It cannot be used on firmware v8.4 and v8.5. The reason is that the firmware team gave a clear reply that there are many related bugs in firmware v8.4 and v8.5, and they were fixed in firmware v8.6. The firmware team recommends using v8.6.
Regards
Kevin
*From:* Ben Magistro <[email protected]>
*Sent:* 2022年6月10日 22:27
*To:* Liu, KevinX <[email protected]>
*Cc:* [email protected]; Zhang, Yuying <[email protected]>; Xing, Beilei < [email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
*Subject:* Re: [PATCH v7] net/i40e: add outer VLAN processingI'm trying to understand if this change is at all related to an issue we are experiencing with newer firmwares (
https://mails.dpdk.org/archives/dev/2022-April/238621.html) that happened to start with 8.4 and affected qinq offload processing. I can say loading this patch and running testpmd does not seem to have any effect on the issue we are experiencing.Side note, there is also a minor typo in the comment block "
i40e_vlan_tpie_set" vs "i40e_vlan_tpid_set".Thanks
On Fri, Jun 10, 2022 at 4:30 AM Kevin Liu <[email protected]> wrote:
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)drivers/net/i40e/i40e_ethdev.c +1
-0@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;uint32_t reg;drivers/net/i40e/i40e_ethdev.c +12
-0@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +/* +* It is a workaround, if the double VLAN is disabled when +* the program exits, an abnormal error will occur on the +* NIC. Need to enable double VLAN when dev is closed. +*/ +if (pf->fw8_3gt) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } + ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret)PMD_INIT_LOG(WARNING, "failed to free switch domain: %d",
ret);drivers/net/i40e/i40e_ethdev.c +1
-0@@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ;if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&drivers/net/i40e/i40e_ethdev.c +25
-3@@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,/* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags &I40E_HW_FLAG_802_1AD_CAPABLE ) {if (qinq) { +if (pf->fw8_3gt) { + sw_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; + }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/* +* If tpid is equal to 0x88A8, indicates that the +* disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/ +if (pf->fw8_3gt && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN ; +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->first_tag =rte_cpu_to_le_16 (tpid); + }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =rte_cpu_to_le_16 (tpid); + } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d",@@ -3987,8 +4018,13 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode;if (mask & RTE_ETH_VLAN_FILTER_MASK) {drivers/net/i40e/i40e_ethdev.c +11
-0@@ -4007,6 +4043,33 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver
+ * also change the default behavior to support this
feature. To align with
+ * kernel driver, set switch config in
'i40e_vlan_tpie_set' to support for
+ * outer VLAN processing. But it is forbidden for firmware
to change the
+ * Inner/Outer VLAN configuration while there are MAC/VLAN
filters in the
+ * switch table. Therefore, we need to clear the MAC table
before setting
+ * config, and then restore the MAC table after setting.
This feature isdrivers/net/i40e/i40e_ethdev.c +6
-0+* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret = i40e_vsi_delete_mac(vsi,
&f->mac_info.mac_addr);drivers/net/i40e/i40e_ethdev.c +2
-0+if (ret) + PMD_DRV_LOG(ERR, "i40e vsi delete macfail.");
drivers/net/i40e/i40e_ethdev.c +14
-2+ i++; + }if (rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ) {i40e_vsi_config_double_vlan (vsi, TRUE);/* Set global registers with default ethertype. */ @@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->fw8_3gt) +i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_OUTER , +RTE_ETHER_TYPE_QINQ );i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }if (mask & RTE_ETH_QINQ_STRIP_MASK) {drivers/net/i40e/i40e_ethdev.c +11
-0@@ -4846,6 +4919,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->fw8_3gt = true; + }else { + pf->fw8_3gt = false; + } +return 0 ; }drivers/net/i40e/i40e_ethdev.h +3
-0@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* When firmware > 8.3, the enable flag for outer VLAN processing */ +bool fw8_3gt; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes;--
2.34.1
Hi Kevin,
Quoted 9 lines
-----Original Message-----
From: Liu, KevinX <[email protected]>
Sent: Saturday, June 11, 2022 12:30 AM
To: [email protected]
Cc: Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v7] net/i40e: add outer VLAN processing
Quoted 3 lines
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also
Since this patch can only be enabled with firmware v8.6, should you sync with dpdk here?
Quoted 31 lines
change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)drivers/net/i40e/i40e_ethdev.c +1
-0@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data- >dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;drivers/net/i40e/i40e_ethdev.c +0
-0uint32_t reg;
drivers/net/i40e/i40e_ethdev.c i40e_dev_close(struct rte_eth_dev *dev) · line 2595
Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c +5
-0@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +/* +* It is a workaround, if the double VLAN is disabled when +* the program exits, an abnormal error will occur on the +* NIC. Need to enable double VLAN when dev is closed. +*/
What is the root cause of this error, I suggest finding a true fix instead of adding additonal process here.
Quoted 35 lines
drivers/net/i40e/i40e_ethdev.c +7
-0+if (pf->fw8_3gt) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } +drivers/net/i40e/i40e_ethdev.c +0
-0ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret) PMD_INIT_LOG(WARNING, "failed to free switchdomain: %d", ret); @@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct
rte_eth_dev*dev,
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c +4
-0int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && @@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, /* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) { if (qinq) { + if (pf->fw8_3gt) { + sw_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);
drivers/net/i40e/i40e_ethdev.c i40e_vlan_tpid_set(struct rte_eth_dev *dev, · line 3957
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +5
-2else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid); +/* +* If tpid is equal to 0x88A8, indicates that the +* disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/
I don't suppose we need to set qinq tpid in vlan case. Please explain this situation in details.
Quoted 135 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+if (pf->fw8_3gt && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +2
-0+if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->first_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +3
-0+ }else { +if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) + hw->second_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +3
-1+ } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d", @@ -3987,8 +4018,13 @@ static int
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask){
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c +5
-0+struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode; if (mask & RTE_ETH_VLAN_FILTER_MASK) { @@ -4007,6 +4043,33@@
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)drivers/net/i40e/i40e_ethdev.c +11
-0}if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver
drivers/net/i40e/i40e_ethdev.c +1
-0+* also change the default behavior to support this feature. To align with
drivers/net/i40e/i40e_ethdev.c +1
-0+* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for
drivers/net/i40e/i40e_ethdev.c +1
-0+* outer VLAN processing. But it is forbidden for firmware to change the
drivers/net/i40e/i40e_ethdev.c +1
-0+* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the
drivers/net/i40e/i40e_ethdev.c +1
-0+* switch table. Therefore, we need to clear the MAC table before setting
drivers/net/i40e/i40e_ethdev.c +1
-0+* config, and then restore the MAC table after setting. This feature is
drivers/net/i40e/i40e_ethdev.c +6
-0+* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret = i40e_vsi_delete_mac(vsi, &f-Quoted 1 line
mac_info.mac_addr);
drivers/net/i40e/i40e_ethdev.c +2
-0+if (ret) + PMD_DRV_LOG(ERR, "i40e vsi delete macfail.");
drivers/net/i40e/i40e_ethdev.c +2
-0+ i++; + } if (rxmode->offloads &
RTE_ETH_RX_OFFLOAD_VLAN_EXTEND) {drivers/net/i40e/i40e_ethdev.c +0
-1i40e_vsi_config_double_vlan (vsi, TRUE); /* Set global registers with default ethertype. */ @@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, intmask)
drivers/net/i40e/i40e_ethdev.c +3
-2RTE_ETHER_TYPE_VLAN);i40e_vlan_tpid_set (dev,RTE_ETH_VLAN_TYPE_INNER ,RTE_ETHER_TYPE_VLAN ); - } -else + }else { +if (pf->fw8_3gt) + i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_OUTER,drivers/net/i40e/i40e_ethdev.c +20
-0+ RTE_ETHER_TYPE_QINQ);i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {@@ -4846,6 +4919,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->fw8_3gt = true; + }else { + pf->fw8_3gt = false; + } +return 0 ; }drivers/net/i40e/i40e_ethdev.h +3
-1@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* When firmware > 8.3, the enable flag for outer VLAN processing */ +bool fw8_3gt; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes; --2.34.1
Hi, Yuying
Quoted 19 lines
-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: 2022年6月14日 10:44
To: Liu, KevinX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: RE: [PATCH v7] net/i40e: add outer VLAN processingHi Kevin,
Quoted 9 lines
-----Original Message-----
From: Liu, KevinX <[email protected]>
Sent: Saturday, June 11, 2022 12:30 AM
To: [email protected]
Cc: Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v7] net/i40e: add outer VLAN processing
Quoted 7 lines
Quoted 4 lines
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also
Since this patch can only be enabled with firmware v8.6, should you sync with dpdk here?
OK, I'll revise it here.
Quoted 36 lines
Quoted 36 lines
change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex755786dc10..4cae163cb9100644drivers/net/i40e/i40e_ethdev.c +1
-0@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data- >dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;drivers/net/i40e/i40e_ethdev.c +0
-0uint32_t reg;@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ;
Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c i40e_dev_close(struct rte_eth_dev *dev) · line 2595
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+/* +* It is a workaround, if the double VLAN is disabled when +* the program exits, an abnormal error will occur on the +* NIC. Need to enable double VLAN when dev is closed. +*/ What is the root cause of this error, I suggest finding a true fix instead of adding additonal process here.
About this error, dpdk has reported a known issue. Because it doesn't know the root cause of the problem, it adds a workaround here to temporarily avoid some problems.
Quoted 41 lines
Quoted 41 lines
drivers/net/i40e/i40e_ethdev.c +7
-0+if (pf->fw8_3gt) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } +drivers/net/i40e/i40e_ethdev.c +0
-0ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret) PMD_INIT_LOG(WARNING, "failed to free switchdomain: %d", ret); @@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct
rte_eth_dev*dev,
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c +4
-0int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && @@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, /* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) { if (qinq) { + if (pf->fw8_3gt) { + sw_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-2+ }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid);
Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c i40e_vlan_tpid_set(struct rte_eth_dev *dev, · line 3957
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+/* +* If tpid is equal to 0x88A8, indicates that the +* disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/ I don't suppose we need to set qinq tpid in vlan case. Please explain this situation in details.
I'll think about how to explain this place. Thank you.
Quoted 141 lines
drivers/net/i40e/i40e_ethdev.c
Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+if (pf->fw8_3gt && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ if (vlan_type ==
RTE_ETH_VLAN_TYPE_OUTER)drivers/net/i40e/i40e_ethdev.c
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c +1
-0+ hw->first_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +2
-0+ }else { + if (vlan_type ==
RTE_ETH_VLAN_TYPE_OUTER)Quoted 14 lines
drivers/net/i40e/i40e_ethdev.c +1
-0+ hw->second_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +3
-1+ } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d", @@ -3987,8 +4018,13 @@ static int
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask){
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c static int
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode; if (mask & RTE_ETH_VLAN_FILTER_MASK) { @@ -4007,6 +4043,33@@
Quoted 46 lines
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)drivers/net/i40e/i40e_ethdev.c +11
-0}if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver
drivers/net/i40e/i40e_ethdev.c +1
-0+* also change the default behavior to support this feature. To align with
drivers/net/i40e/i40e_ethdev.c +1
-0+* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for
drivers/net/i40e/i40e_ethdev.c +1
-0+* outer VLAN processing. But it is forbidden for firmware to change the
drivers/net/i40e/i40e_ethdev.c +1
-0+* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the
drivers/net/i40e/i40e_ethdev.c +1
-0+* switch table. Therefore, we need to clear the MAC table before setting
drivers/net/i40e/i40e_ethdev.c +1
-0+* config, and then restore the MAC table after setting. This feature is
drivers/net/i40e/i40e_ethdev.c +6
-0+* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret = i40e_vsi_delete_mac(vsi, &f-Quoted 1 line
mac_info.mac_addr);
drivers/net/i40e/i40e_ethdev.c +2
-0+if (ret) + PMD_DRV_LOG(ERR, "i40e vsi delete macfail.");
drivers/net/i40e/i40e_ethdev.c +2
-0+ i++; + } if (rxmode->offloads &
RTE_ETH_RX_OFFLOAD_VLAN_EXTEND) {drivers/net/i40e/i40e_ethdev.c +0
-1i40e_vsi_config_double_vlan (vsi, TRUE); /* Set global registers with default ethertype. */ @@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, intmask)
drivers/net/i40e/i40e_ethdev.c
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +0
-0RTE_ETHER_TYPE_VLAN); i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_INNER,Quoted 43 lines
drivers/net/i40e/i40e_ethdev.c +3
-2RTE_ETHER_TYPE_VLAN); - } -else + }else { +if (pf->fw8_3gt) + i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_OUTER,drivers/net/i40e/i40e_ethdev.c +9
-0+ RTE_ETHER_TYPE_QINQ);i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); } if (mask & RTE_ETH_QINQ_STRIP_MASK) { @@ -4846,6 +4919,17 @@
i40e_pf_parameter_init(struct rte_eth_dev *dev)drivers/net/i40e/i40e_ethdev.c +11
-0return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->fw8_3gt = true; + }else { + pf->fw8_3gt = false; + } +return 0 ; }(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.hindexa1ebdc093c..fe943a45ff100644drivers/net/i40e/i40e_ethdev.h struct i40e_pf { · line 1191
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.h +1
-0@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* When firmware > 8.3, the enable flag for outer VLAN processing */
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.h +2
-1+bool fw8_3gt; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes; --2.34.1
Zhang, Yuying
Acked-byHi Kevin,
Workaround should be replaced when root cause be found.
Best regards,
Yuying
Quoted 30 lines
-----Original Message-----
From: Liu, KevinX <[email protected]>
Sent: Tuesday, June 14, 2022 11:07 AM
To: Zhang, Yuying <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: RE: [PATCH v7] net/i40e: add outer VLAN processingHi, Yuying
Quoted 20 lines
-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: 2022年6月14日 10:44
To: Liu, KevinX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: RE: [PATCH v7] net/i40e: add outer VLAN processingHi Kevin,
Quoted 10 lines
-----Original Message-----
From: Liu, KevinX <[email protected]>
Sent: Saturday, June 11, 2022 12:30 AM
To: [email protected]
Cc: Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v7] net/i40e: add outer VLAN processing
Quoted 21 lines
Quoted 7 lines
Quoted 4 lines
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also
Since this patch can only be enabled with firmware v8.6, should you sync with dpdk here?
OK, I'll revise it here.
Quoted 13 lines
Quoted 13 lines
change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>
Quoted 227 lines
Quoted 23 lines
Quoted 23 lines
--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex755786dc10..4cae163cb9100644drivers/net/i40e/i40e_ethdev.c +1
-0@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data- >dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;drivers/net/i40e/i40e_ethdev.c +0
-0uint32_t reg;@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ;Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c i40e_dev_close(struct rte_eth_dev *dev) · line 2595
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+/* +* It is a workaround, if the double VLAN is disabled when +* the program exits, an abnormal error will occur on the +* NIC. Need to enable double VLAN when dev is closed. +*/ What is the root cause of this error, I suggest finding a true fix instead of adding additonal process here.
About this error, dpdk has reported a known issue. Because it doesn't know the root cause of the problem, it adds a workaround here to temporarily avoid some problems.
Quoted 41 lines
Quoted 41 lines
drivers/net/i40e/i40e_ethdev.c +7
-0+if (pf->fw8_3gt) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } +drivers/net/i40e/i40e_ethdev.c +0
-0ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret) PMD_INIT_LOG(WARNING, "failed to free switchdomain: %d", ret); @@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct
rte_eth_dev*dev,
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c +4
-0int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && @@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, /* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) { if (qinq) { + if (pf->fw8_3gt) { + sw_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-2+ }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid);Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c i40e_vlan_tpid_set(struct rte_eth_dev *dev, · line 3957
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+/* +* If tpid is equal to 0x88A8, indicates that the +* disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/ I don't suppose we need to set qinq tpid in vlan case. Please explain this situation in details.
I'll think about how to explain this place. Thank you.
Quoted 106 lines
drivers/net/i40e/i40e_ethdev.c
Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+if (pf->fw8_3gt && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ if (vlan_type ==
RTE_ETH_VLAN_TYPE_OUTER)drivers/net/i40e/i40e_ethdev.c
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c +1
-0+ hw->first_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +2
-0+ }else { + if (vlan_type ==
RTE_ETH_VLAN_TYPE_OUTER)Quoted 14 lines
drivers/net/i40e/i40e_ethdev.c +1
-0+ hw->second_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +3
-1+ } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d", @@ -3987,8 +4018,13 @@ static int
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask){
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c static int
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode; if (mask & RTE_ETH_VLAN_FILTER_MASK) { @@ -4007,6 +4043,33@@
Quoted 47 lines
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)drivers/net/i40e/i40e_ethdev.c +11
-0}if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver
drivers/net/i40e/i40e_ethdev.c +1
-0+* also change the default behavior to support this feature. To align with
drivers/net/i40e/i40e_ethdev.c +1
-0+* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for
drivers/net/i40e/i40e_ethdev.c +1
-0+* outer VLAN processing. But it is forbidden for firmware to change the
drivers/net/i40e/i40e_ethdev.c +1
-0+* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the
drivers/net/i40e/i40e_ethdev.c +1
-0+* switch table. Therefore, we need to clear the MAC table before setting
drivers/net/i40e/i40e_ethdev.c +1
-0+* config, and then restore the MAC table after setting. This feature is
drivers/net/i40e/i40e_ethdev.c +6
-0+* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret = i40e_vsi_delete_mac(vsi, &f-Quoted 1 line
mac_info.mac_addr);
drivers/net/i40e/i40e_ethdev.c +2
-0+if (ret) + PMD_DRV_LOG(ERR, "i40e vsi delete macfail.");
drivers/net/i40e/i40e_ethdev.c +2
-0+ i++; + } if (rxmode->offloads &
RTE_ETH_RX_OFFLOAD_VLAN_EXTEND) {drivers/net/i40e/i40e_ethdev.c +0
-1i40e_vsi_config_double_vlan (vsi, TRUE); /* Set global registers with default ethertype. */ @@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev,int
mask)drivers/net/i40e/i40e_ethdev.c
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +0
-0RTE_ETHER_TYPE_VLAN); i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_INNER,Quoted 19 lines
drivers/net/i40e/i40e_ethdev.c +3
-2RTE_ETHER_TYPE_VLAN); - } -else + }else { +if (pf->fw8_3gt) + i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_OUTER,drivers/net/i40e/i40e_ethdev.c +9
-0+ RTE_ETHER_TYPE_QINQ);i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }Quoted 1 line
Quoted 1 line
if (mask &
RTE_ETH_QINQ_STRIP_MASK) { @@ -4846,6 +4919,17@@
Quoted 35 lines
Quoted 23 lines
i40e_pf_parameter_init(struct rte_eth_dev *dev)drivers/net/i40e/i40e_ethdev.c +11
-0return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->fw8_3gt = true; + }else { + pf->fw8_3gt = false; + } +return 0 ; }(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.hindexa1ebdc093c..fe943a45ff100644drivers/net/i40e/i40e_ethdev.h struct i40e_pf { · line 1191
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.h +1
-0@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* When firmware > 8.3, the enable flag for outer VLAN processing */
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.h +2
-1+bool fw8_3gt; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes; --2.34.1
Yes, that is necessary. Thank you very much for your review!
Quoted 299 lines
-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: 2022年6月14日 16:40
To: Liu, KevinX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: RE: [PATCH v7] net/i40e: add outer VLAN processingHi Kevin,
Workaround should be replaced when root cause be found.
Best regards,
YuyingQuoted 30 lines
-----Original Message-----
From: Liu, KevinX <[email protected]>
Sent: Tuesday, June 14, 2022 11:07 AM
To: Zhang, Yuying <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: RE: [PATCH v7] net/i40e: add outer VLAN processingHi, Yuying
Quoted 20 lines
-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: 2022年6月14日 10:44
To: Liu, KevinX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: RE: [PATCH v7] net/i40e: add outer VLAN processingHi Kevin,
Quoted 10 lines
-----Original Message-----
From: Liu, KevinX <[email protected]>
Sent: Saturday, June 11, 2022 12:30 AM
To: [email protected]
Cc: Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v7] net/i40e: add outer VLAN processingQuoted 21 lines
Quoted 7 lines
Quoted 4 lines
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also
Since this patch can only be enabled with firmware v8.6, should you sync with dpdk here?
OK, I'll revise it here.
Quoted 13 lines
Quoted 13 lines
change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>Acked-by Yuying Zhang <[email protected]>Quoted 230 lines
Quoted 24 lines
Quoted 24 lines
--- drivers/net/i40e/i40e_ethdev.c | 94 ++++++++++++++++++++++++++++++++-- drivers/net/i40e/i40e_ethdev.h | 3 ++ 2 files changed, 92 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex755786dc10..4cae163cb9100644drivers/net/i40e/i40e_ethdev.c +1
-0@@ -2575,6 +2575,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data- >dev_private);struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;drivers/net/i40e/i40e_ethdev.c +0
-0uint32_t reg;@@ -2587,6 +2588,18 @@ i40e_dev_close(struct rte_eth_dev *dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ;Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c i40e_dev_close(struct rte_eth_dev *dev) · line 2595
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+/* +* It is a workaround, if the double VLAN is disabled when +* the program exits, an abnormal error will occur on the +* NIC. Need to enable double VLAN when dev is closed. +*/ What is the root cause of this error, I suggest finding a true fix instead of adding additonal process here.
About this error, dpdk has reported a known issue. Because it doesn't know the root cause of the problem, it adds a workaround here to temporarily avoid some problems.
Quoted 41 lines
Quoted 41 lines
drivers/net/i40e/i40e_ethdev.c +7
-0+if (pf->fw8_3gt) { +if (!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND )) { + rxmode->offloads |=RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +i40e_vlan_offload_set (dev,RTE_ETH_VLAN_EXTEND_MASK ); + } + } +drivers/net/i40e/i40e_ethdev.c +0
-0ret =rte_eth_switch_domain_free (pf->switch_domain_id);if (ret) PMD_INIT_LOG(WARNING, "failed to free switchdomain: %d", ret); @@ -3909,6 +3922,7 @@ i40e_vlan_tpid_set(struct
rte_eth_dev*dev,
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c +4
-0int qinq = dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ; +u16 sw_flags =0 , valid_flags =0 ;int ret =0 ; if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER && @@ -3927,15 +3941,32 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, /* 802.1ad frames ability is added in NVM API 1.7*/ if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) { if (qinq) { + if (pf->fw8_3gt) { + sw_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-2+ }if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) hw->first_tag =rte_cpu_to_le_16 (tpid);else if (vlan_type ==RTE_ETH_VLAN_TYPE_INNER ) hw->second_tag =rte_cpu_to_le_16 (tpid); }else { -if (vlan_type ==RTE_ETH_VLAN_TYPE_OUTER ) - hw->second_tag =rte_cpu_to_le_16 (tpid);Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c i40e_vlan_tpid_set(struct rte_eth_dev *dev, · line 3957
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+/* +* If tpid is equal to 0x88A8, indicates that the +* disable double VLAN operation is in progress. +* Need set switch configuration back to default. +*/ I don't suppose we need to set qinq tpid in vlan case. Please explain this situation in details.
I'll think about how to explain this place. Thank you.
Quoted 106 lines
drivers/net/i40e/i40e_ethdev.c
Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+if (pf->fw8_3gt && tpid ==RTE_ETHER_TYPE_QINQ ) { + sw_flags =0 ; + valid_flags =
I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;drivers/net/i40e/i40e_ethdev.c +1
-0+ if (vlan_type ==
RTE_ETH_VLAN_TYPE_OUTER)drivers/net/i40e/i40e_ethdev.c
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c +1
-0+ hw->first_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +2
-0+ }else { + if (vlan_type ==
RTE_ETH_VLAN_TYPE_OUTER)Quoted 14 lines
drivers/net/i40e/i40e_ethdev.c +1
-0+ hw->second_tag =
rte_cpu_to_le_16(tpid);drivers/net/i40e/i40e_ethdev.c +3
-1+ } } - ret =i40e_aq_set_switch_config (hw,0 ,0 ,0 ,NULL ); + ret =i40e_aq_set_switch_config (hw, sw_flags, + valid_flags,0 ,NULL );if (ret !=I40E_SUCCESS ) { PMD_DRV_LOG(ERR, "Set switch config failed aq_err: %d", @@ -3987,8 +4018,13 @@ static int
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask){
structi40e_pf*pf = I40E_DEV_PRIVATE_TO_PF(dev->data-Quoted 1 line
dev_private);drivers/net/i40e/i40e_ethdev.c static int
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode; +struct i40e_mac_filter *f; +int i, num; +void *temp; +int ret; rxmode = &dev->data->dev_conf.rxmode; if (mask & RTE_ETH_VLAN_FILTER_MASK) { @@ -4007,6 +4043,33@@
Quoted 47 lines
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)drivers/net/i40e/i40e_ethdev.c +11
-0}if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { + i =0 ; + num = vsi->mac_num; + mac_filter =rte_zmalloc ("mac_filter_info_data" , + num *sizeof (*mac_filter),0 ); +if (mac_filter ==NULL ) { +PMD_DRV_LOG (ERR ,"failed to allocate memory" ); +return I40E_ERR_NO_MEMORY ; + } + +/* +* Outer VLAN processing is supported after firmware v8.4, kernel driver
drivers/net/i40e/i40e_ethdev.c +1
-0+* also change the default behavior to support this feature. To align with
drivers/net/i40e/i40e_ethdev.c +1
-0+* kernel driver, set switch config in 'i40e_vlan_tpie_set' to support for
drivers/net/i40e/i40e_ethdev.c +1
-0+* outer VLAN processing. But it is forbidden for firmware to change the
drivers/net/i40e/i40e_ethdev.c +1
-0+* Inner/Outer VLAN configuration while there are MAC/VLAN filters in the
drivers/net/i40e/i40e_ethdev.c +1
-0+* switch table. Therefore, we need to clear the MAC table before setting
drivers/net/i40e/i40e_ethdev.c +1
-0+* config, and then restore the MAC table after setting. This feature is
drivers/net/i40e/i40e_ethdev.c +6
-0+* recommended to be used in firmware v8.6. +*/ +/* Remove all existing mac */ + RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { + mac_filter[i] = f->mac_info; + ret = i40e_vsi_delete_mac(vsi, &f-Quoted 1 line
mac_info.mac_addr);
drivers/net/i40e/i40e_ethdev.c +2
-0+if (ret) + PMD_DRV_LOG(ERR, "i40e vsi delete macfail.");
drivers/net/i40e/i40e_ethdev.c +2
-0+ i++; + } if (rxmode->offloads &
RTE_ETH_RX_OFFLOAD_VLAN_EXTEND) {drivers/net/i40e/i40e_ethdev.c +0
-1i40e_vsi_config_double_vlan (vsi, TRUE); /* Set global registers with default ethertype. */ @@ -4014,9 +4077,19 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev,int
mask)drivers/net/i40e/i40e_ethdev.c
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +0
-0RTE_ETHER_TYPE_VLAN); i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_INNER,Quoted 19 lines
drivers/net/i40e/i40e_ethdev.c +3
-2RTE_ETHER_TYPE_VLAN); - } -else + }else { +if (pf->fw8_3gt) + i40e_vlan_tpid_set(dev,
RTE_ETH_VLAN_TYPE_OUTER,drivers/net/i40e/i40e_ethdev.c +9
-0+ RTE_ETHER_TYPE_QINQ);i40e_vsi_config_double_vlan (vsi, FALSE); + } +/* Restore all mac */ +for (i =0 ; i < num; i++) { + ret =i40e_vsi_add_mac (vsi, &mac_filter[i]); +if (ret) +PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); + } +rte_free (mac_filter); }Quoted 1 line
Quoted 1 line
if (mask &
RTE_ETH_QINQ_STRIP_MASK) { @@ -4846,6 +4919,17@@
Quoted 37 lines
Quoted 24 lines
i40e_pf_parameter_init(struct rte_eth_dev *dev)drivers/net/i40e/i40e_ethdev.c +11
-0return -EINVAL ; } +/** +* Enable outer VLAN processing if firmware version is greater +* than v8.3 +*/ +if (hw->aq.fw_maj_ver >8 || + (hw->aq.fw_maj_ver ==8 && hw->aq.fw_min_ver >3 )) { + pf->fw8_3gt = true; + }else { + pf->fw8_3gt = false; + } +return 0 ; }(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.hindexa1ebdc093c..fe943a45ff100644drivers/net/i40e/i40e_ethdev.h struct i40e_pf { · line 1192
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.h +2
-0@@ -1188,6 +1188,9 @@ struct i40e_pf {/* Switch Domain Id */ uint16_t switch_domain_id; +/* When firmware > 8.3, the enable flag for outer VLAN +processing */
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.h +2
-1+bool fw8_3gt; +struct i40e_vf_msg_cfg vf_msg_cfg;uint64_t prev_rx_bytes;uint64_t prev_tx_bytes; --2.34.1
Zhang, Qi Z
AppliedQuoted 64 lines
-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: Tuesday, June 14, 2022 4:40 PM
To: Liu, KevinX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: RE: [PATCH v7] net/i40e: add outer VLAN processingHi Kevin,
Workaround should be replaced when root cause be found.
Best regards,
YuyingQuoted 47 lines
-----Original Message-----
From: Liu, KevinX <[email protected]>
Sent: Tuesday, June 14, 2022 11:07 AM
To: Zhang, Yuying <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: RE: [PATCH v7] net/i40e: add outer VLAN processingHi, Yuying
Quoted 20 lines
-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: 2022年6月14日 10:44
To: Liu, KevinX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>
Subject: RE: [PATCH v7] net/i40e: add outer VLAN processingHi Kevin,
Quoted 10 lines
-----Original Message-----
From: Liu, KevinX <[email protected]>
Sent: Saturday, June 11, 2022 12:30 AM
To: [email protected]
Cc: Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Zhang, RobinX <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v7] net/i40e: add outer VLAN processingQuoted 7 lines
Quoted 4 lines
From: Robin Zhang <[email protected]>
Outer VLAN processing is supported after firmware v8.4, kernel driver also
Since this patch can only be enabled with firmware v8.6, should you sync with dpdk here?
OK, I'll revise it here.
Quoted 9 lines
Quoted 9 lines
change the default behavior to support this feature. To align with kernel driver, add support for outer VLAN processing in DPDK.
But it is forbidden for firmware to change the Inner/Outer VLAN configuration while there are MAC/VLAN filters in the switch table. Therefore, we need to clear the MAC table before setting config, and then restore the MAC table after setting.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
This will not impact on an old firmware.
Signed-off-by Robin Zhang <[email protected]>Signed-off-by Kevin Liu <[email protected]>Acked-by Yuying Zhang <[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi