Skip to content

Commit 7559d67

Browse files
norbertx-zulinskianguy11
authored andcommitted
iavf: Add ability to turn off CRC stripping for VF
Previously CRC stripping was always enabled for VF. Now it is possible to turn off CRC stripping via ethtool: #ethtool -K <interface> rx-fcs on To turn off CRC stripping, first VLAN stripping must be disabled: #ethtool -K <interface> rx-vlan-offload off if any VLAN interfaces exists, otherwise VLAN stripping will be turned off by the driver. In iavf_configure_queues add check if CRC stripping is enabled for VF, if it's enabled then set crc_disabled to false on every VF's queue. In iavf_set_features add check if CRC stripping setting was changed then schedule reset. Signed-off-by: Norbert Zulinski <[email protected]> Reviewed-by: Jesse Brandeburg <[email protected]> Signed-off-by: Ahmed Zaki <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 7bd48d8 commit 7559d67

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

drivers/net/ethernet/intel/iavf/iavf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ struct iavf_adapter {
406406
VIRTCHNL_VF_OFFLOAD_VLAN)
407407
#define VLAN_V2_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
408408
VIRTCHNL_VF_OFFLOAD_VLAN_V2)
409+
#define CRC_OFFLOAD_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
410+
VIRTCHNL_VF_OFFLOAD_CRC)
409411
#define VLAN_V2_FILTERING_ALLOWED(_a) \
410412
(VLAN_V2_ALLOWED((_a)) && \
411413
((_a)->vlan_v2_caps.filtering.filtering_support.outer || \

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4401,6 +4401,9 @@ static int iavf_set_features(struct net_device *netdev,
44014401
(features & NETIF_VLAN_OFFLOAD_FEATURES))
44024402
iavf_set_vlan_offload_features(adapter, netdev->features,
44034403
features);
4404+
if (CRC_OFFLOAD_ALLOWED(adapter) &&
4405+
((netdev->features & NETIF_F_RXFCS) ^ (features & NETIF_F_RXFCS)))
4406+
iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED);
44044407

44054408
return 0;
44064409
}
@@ -4522,6 +4525,9 @@ iavf_get_netdev_vlan_hw_features(struct iavf_adapter *adapter)
45224525
}
45234526
}
45244527

4528+
if (CRC_OFFLOAD_ALLOWED(adapter))
4529+
hw_features |= NETIF_F_RXFCS;
4530+
45254531
return hw_features;
45264532
}
45274533

@@ -4685,6 +4691,55 @@ iavf_fix_netdev_vlan_features(struct iavf_adapter *adapter,
46854691
return requested_features;
46864692
}
46874693

4694+
/**
4695+
* iavf_fix_strip_features - fix NETDEV CRC and VLAN strip features
4696+
* @adapter: board private structure
4697+
* @requested_features: stack requested NETDEV features
4698+
*
4699+
* Returns fixed-up features bits
4700+
**/
4701+
static netdev_features_t
4702+
iavf_fix_strip_features(struct iavf_adapter *adapter,
4703+
netdev_features_t requested_features)
4704+
{
4705+
struct net_device *netdev = adapter->netdev;
4706+
bool crc_offload_req, is_vlan_strip;
4707+
netdev_features_t vlan_strip;
4708+
int num_non_zero_vlan;
4709+
4710+
crc_offload_req = CRC_OFFLOAD_ALLOWED(adapter) &&
4711+
(requested_features & NETIF_F_RXFCS);
4712+
num_non_zero_vlan = iavf_get_num_vlans_added(adapter);
4713+
vlan_strip = (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX);
4714+
is_vlan_strip = requested_features & vlan_strip;
4715+
4716+
if (!crc_offload_req)
4717+
return requested_features;
4718+
4719+
if (!num_non_zero_vlan && (netdev->features & vlan_strip) &&
4720+
!(netdev->features & NETIF_F_RXFCS) && is_vlan_strip) {
4721+
requested_features &= ~vlan_strip;
4722+
netdev_info(netdev, "Disabling VLAN stripping as FCS/CRC stripping is also disabled and there is no VLAN configured\n");
4723+
return requested_features;
4724+
}
4725+
4726+
if ((netdev->features & NETIF_F_RXFCS) && is_vlan_strip) {
4727+
requested_features &= ~vlan_strip;
4728+
if (!(netdev->features & vlan_strip))
4729+
netdev_info(netdev, "To enable VLAN stripping, first need to enable FCS/CRC stripping");
4730+
4731+
return requested_features;
4732+
}
4733+
4734+
if (num_non_zero_vlan && is_vlan_strip &&
4735+
!(netdev->features & NETIF_F_RXFCS)) {
4736+
requested_features &= ~NETIF_F_RXFCS;
4737+
netdev_info(netdev, "To disable FCS/CRC stripping, first need to disable VLAN stripping");
4738+
}
4739+
4740+
return requested_features;
4741+
}
4742+
46884743
/**
46894744
* iavf_fix_features - fix up the netdev feature bits
46904745
* @netdev: our net device
@@ -4697,7 +4752,9 @@ static netdev_features_t iavf_fix_features(struct net_device *netdev,
46974752
{
46984753
struct iavf_adapter *adapter = netdev_priv(netdev);
46994754

4700-
return iavf_fix_netdev_vlan_features(adapter, features);
4755+
features = iavf_fix_netdev_vlan_features(adapter, features);
4756+
4757+
return iavf_fix_strip_features(adapter, features);
47014758
}
47024759

47034760
static const struct net_device_ops iavf_netdev_ops = {

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ int iavf_send_vf_config_msg(struct iavf_adapter *adapter)
142142
VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 |
143143
VIRTCHNL_VF_OFFLOAD_ENCAP |
144144
VIRTCHNL_VF_OFFLOAD_VLAN_V2 |
145+
VIRTCHNL_VF_OFFLOAD_CRC |
145146
VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM |
146147
VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
147148
VIRTCHNL_VF_OFFLOAD_ADQ |
@@ -312,6 +313,9 @@ void iavf_configure_queues(struct iavf_adapter *adapter)
312313
vqpi->rxq.databuffer_size =
313314
ALIGN(adapter->rx_rings[i].rx_buf_len,
314315
BIT_ULL(IAVF_RXQ_CTX_DBUFF_SHIFT));
316+
if (CRC_OFFLOAD_ALLOWED(adapter))
317+
vqpi->rxq.crc_disable = !!(adapter->netdev->features &
318+
NETIF_F_RXFCS);
315319
vqpi++;
316320
}
317321

0 commit comments

Comments
 (0)