Skip to content

Commit 7bd48d8

Browse files
haiyuewaanguy11
authored andcommitted
ice: Check CRC strip requirement for VLAN strip
When VLAN strip is enabled, the CRC strip must not be disabled. And when the CRC strip is disabled, the VLAN strip should not be enabled. The driver needs to check CRC strip disable setting parameter before configuring the Rx/Tx queues, otherwise, in current error handling, the already set Tx queue context doesn't roll back correctly, it will cause the Tx queue setup failure next time: "Failed to set LAN Tx queue context" Signed-off-by: Haiyue Wang <[email protected]> Reviewed-by: Jesse Brandeburg <[email protected]> Reviewed-by: Paul Menzel <[email protected]> Signed-off-by: Ahmed Zaki <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 730cb74 commit 7bd48d8

File tree

2 files changed

+58
-9
lines changed

2 files changed

+58
-9
lines changed

drivers/net/ethernet/intel/ice/ice_vf_lib.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ struct ice_vf {
123123
u8 num_req_qs; /* num of queue pairs requested by VF */
124124
u16 num_mac;
125125
u16 num_vf_qs; /* num of queue configured per VF */
126+
u8 vlan_strip_ena; /* Outer and Inner VLAN strip enable */
127+
#define ICE_INNER_VLAN_STRIP_ENA BIT(0)
128+
#define ICE_OUTER_VLAN_STRIP_ENA BIT(1)
126129
struct ice_mdd_vf_events mdd_rx_events;
127130
struct ice_mdd_vf_events mdd_tx_events;
128131
DECLARE_BITMAP(opcodes_allowlist, VIRTCHNL_OP_MAX);

drivers/net/ethernet/intel/ice/ice_virtchnl.c

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,15 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
16231623
goto error_param;
16241624
}
16251625

1626+
for (i = 0; i < qci->num_queue_pairs; i++) {
1627+
if (!qci->qpair[i].rxq.crc_disable)
1628+
continue;
1629+
1630+
if (!(vf->driver_caps & VIRTCHNL_VF_OFFLOAD_CRC) ||
1631+
vf->vlan_strip_ena)
1632+
goto error_param;
1633+
}
1634+
16261635
for (i = 0; i < qci->num_queue_pairs; i++) {
16271636
qpi = &qci->qpair[i];
16281637
if (qpi->txq.vsi_id != qci->vsi_id ||
@@ -1669,11 +1678,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
16691678
vsi->rx_rings[i]->dma = qpi->rxq.dma_ring_addr;
16701679
vsi->rx_rings[i]->count = qpi->rxq.ring_len;
16711680

1672-
if (qpi->rxq.crc_disable &&
1673-
!(vf->driver_caps & VIRTCHNL_VF_OFFLOAD_CRC)) {
1674-
goto error_param;
1675-
}
1676-
16771681
if (qpi->rxq.crc_disable)
16781682
vsi->rx_rings[q_idx]->flags |=
16791683
ICE_RX_FLAGS_CRC_STRIP_DIS;
@@ -2425,6 +2429,21 @@ static int ice_vc_remove_vlan_msg(struct ice_vf *vf, u8 *msg)
24252429
return ice_vc_process_vlan_msg(vf, msg, false);
24262430
}
24272431

2432+
/**
2433+
* ice_vsi_is_rxq_crc_strip_dis - check if Rx queue CRC strip is disabled or not
2434+
* @vsi: pointer to the VF VSI info
2435+
*/
2436+
static bool ice_vsi_is_rxq_crc_strip_dis(struct ice_vsi *vsi)
2437+
{
2438+
unsigned int i;
2439+
2440+
ice_for_each_alloc_rxq(vsi, i)
2441+
if (vsi->rx_rings[i]->flags & ICE_RX_FLAGS_CRC_STRIP_DIS)
2442+
return true;
2443+
2444+
return false;
2445+
}
2446+
24282447
/**
24292448
* ice_vc_ena_vlan_stripping
24302449
* @vf: pointer to the VF info
@@ -2454,6 +2473,8 @@ static int ice_vc_ena_vlan_stripping(struct ice_vf *vf)
24542473

24552474
if (vsi->inner_vlan_ops.ena_stripping(vsi, ETH_P_8021Q))
24562475
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
2476+
else
2477+
vf->vlan_strip_ena |= ICE_INNER_VLAN_STRIP_ENA;
24572478

24582479
error_param:
24592480
return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING,
@@ -2489,6 +2510,8 @@ static int ice_vc_dis_vlan_stripping(struct ice_vf *vf)
24892510

24902511
if (vsi->inner_vlan_ops.dis_stripping(vsi))
24912512
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
2513+
else
2514+
vf->vlan_strip_ena &= ~ICE_INNER_VLAN_STRIP_ENA;
24922515

24932516
error_param:
24942517
return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING,
@@ -2664,6 +2687,8 @@ static int ice_vf_init_vlan_stripping(struct ice_vf *vf)
26642687
{
26652688
struct ice_vsi *vsi = ice_get_vf_vsi(vf);
26662689

2690+
vf->vlan_strip_ena = 0;
2691+
26672692
if (!vsi)
26682693
return -EINVAL;
26692694

@@ -2673,10 +2698,16 @@ static int ice_vf_init_vlan_stripping(struct ice_vf *vf)
26732698
if (ice_vf_is_port_vlan_ena(vf) && !ice_is_dvm_ena(&vsi->back->hw))
26742699
return 0;
26752700

2676-
if (ice_vf_vlan_offload_ena(vf->driver_caps))
2677-
return vsi->inner_vlan_ops.ena_stripping(vsi, ETH_P_8021Q);
2678-
else
2679-
return vsi->inner_vlan_ops.dis_stripping(vsi);
2701+
if (ice_vf_vlan_offload_ena(vf->driver_caps)) {
2702+
int err;
2703+
2704+
err = vsi->inner_vlan_ops.ena_stripping(vsi, ETH_P_8021Q);
2705+
if (!err)
2706+
vf->vlan_strip_ena |= ICE_INNER_VLAN_STRIP_ENA;
2707+
return err;
2708+
}
2709+
2710+
return vsi->inner_vlan_ops.dis_stripping(vsi);
26802711
}
26812712

26822713
static u16 ice_vc_get_max_vlan_fltrs(struct ice_vf *vf)
@@ -3450,6 +3481,11 @@ static int ice_vc_ena_vlan_stripping_v2_msg(struct ice_vf *vf, u8 *msg)
34503481
goto out;
34513482
}
34523483

3484+
if (ice_vsi_is_rxq_crc_strip_dis(vsi)) {
3485+
v_ret = VIRTCHNL_STATUS_ERR_NOT_SUPPORTED;
3486+
goto out;
3487+
}
3488+
34533489
ethertype_setting = strip_msg->outer_ethertype_setting;
34543490
if (ethertype_setting) {
34553491
if (ice_vc_ena_vlan_offload(vsi,
@@ -3470,6 +3506,8 @@ static int ice_vc_ena_vlan_stripping_v2_msg(struct ice_vf *vf, u8 *msg)
34703506
* enabled, is extracted in L2TAG1.
34713507
*/
34723508
ice_vsi_update_l2tsel(vsi, l2tsel);
3509+
3510+
vf->vlan_strip_ena |= ICE_OUTER_VLAN_STRIP_ENA;
34733511
}
34743512
}
34753513

@@ -3481,6 +3519,9 @@ static int ice_vc_ena_vlan_stripping_v2_msg(struct ice_vf *vf, u8 *msg)
34813519
goto out;
34823520
}
34833521

3522+
if (ethertype_setting)
3523+
vf->vlan_strip_ena |= ICE_INNER_VLAN_STRIP_ENA;
3524+
34843525
out:
34853526
return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2,
34863527
v_ret, NULL, 0);
@@ -3542,6 +3583,8 @@ static int ice_vc_dis_vlan_stripping_v2_msg(struct ice_vf *vf, u8 *msg)
35423583
* in L2TAG1.
35433584
*/
35443585
ice_vsi_update_l2tsel(vsi, l2tsel);
3586+
3587+
vf->vlan_strip_ena &= ~ICE_OUTER_VLAN_STRIP_ENA;
35453588
}
35463589
}
35473590

@@ -3551,6 +3594,9 @@ static int ice_vc_dis_vlan_stripping_v2_msg(struct ice_vf *vf, u8 *msg)
35513594
goto out;
35523595
}
35533596

3597+
if (ethertype_setting)
3598+
vf->vlan_strip_ena &= ~ICE_INNER_VLAN_STRIP_ENA;
3599+
35543600
out:
35553601
return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2,
35563602
v_ret, NULL, 0);

0 commit comments

Comments
 (0)