Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next -queue

Tony Nguyen says:

====================
Support rx-fcs on/off for VFs

Ahmed Zaki says:

Allow the user to turn on/off the CRC/FCS stripping through ethtool. We
first add the CRC offload capability in the virtchannel, then the feature
is enabled in ice and iavf drivers.

We make sure that the netdev features are fixed such that CRC stripping
cannot be disabled if VLAN rx offload (VLAN strip) is enabled. Also, VLAN
stripping cannot be enabled unless CRC stripping is ON.

Testing was done using tcpdump to make sure that the CRC is included in
the frame after:

# ethtool -K <interface> rx-fcs on

and is not included when it is back "off". Also, ethtool should return an
error for the above command if "rx-vlan-offload" is already on and at least
one VLAN interface/filter exists on the VF.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+141 -7
+2
drivers/net/ethernet/intel/iavf/iavf.h
··· 406 406 VIRTCHNL_VF_OFFLOAD_VLAN) 407 407 #define VLAN_V2_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \ 408 408 VIRTCHNL_VF_OFFLOAD_VLAN_V2) 409 + #define CRC_OFFLOAD_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \ 410 + VIRTCHNL_VF_OFFLOAD_CRC) 409 411 #define VLAN_V2_FILTERING_ALLOWED(_a) \ 410 412 (VLAN_V2_ALLOWED((_a)) && \ 411 413 ((_a)->vlan_v2_caps.filtering.filtering_support.outer || \
+58 -1
drivers/net/ethernet/intel/iavf/iavf_main.c
··· 4401 4401 (features & NETIF_VLAN_OFFLOAD_FEATURES)) 4402 4402 iavf_set_vlan_offload_features(adapter, netdev->features, 4403 4403 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); 4404 4407 4405 4408 return 0; 4406 4409 } ··· 4524 4521 hw_features |= NETIF_F_HW_VLAN_CTAG_TX; 4525 4522 } 4526 4523 } 4524 + 4525 + if (CRC_OFFLOAD_ALLOWED(adapter)) 4526 + hw_features |= NETIF_F_RXFCS; 4527 4527 4528 4528 return hw_features; 4529 4529 } ··· 4692 4686 } 4693 4687 4694 4688 /** 4689 + * iavf_fix_strip_features - fix NETDEV CRC and VLAN strip features 4690 + * @adapter: board private structure 4691 + * @requested_features: stack requested NETDEV features 4692 + * 4693 + * Returns fixed-up features bits 4694 + **/ 4695 + static netdev_features_t 4696 + iavf_fix_strip_features(struct iavf_adapter *adapter, 4697 + netdev_features_t requested_features) 4698 + { 4699 + struct net_device *netdev = adapter->netdev; 4700 + bool crc_offload_req, is_vlan_strip; 4701 + netdev_features_t vlan_strip; 4702 + int num_non_zero_vlan; 4703 + 4704 + crc_offload_req = CRC_OFFLOAD_ALLOWED(adapter) && 4705 + (requested_features & NETIF_F_RXFCS); 4706 + num_non_zero_vlan = iavf_get_num_vlans_added(adapter); 4707 + vlan_strip = (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX); 4708 + is_vlan_strip = requested_features & vlan_strip; 4709 + 4710 + if (!crc_offload_req) 4711 + return requested_features; 4712 + 4713 + if (!num_non_zero_vlan && (netdev->features & vlan_strip) && 4714 + !(netdev->features & NETIF_F_RXFCS) && is_vlan_strip) { 4715 + requested_features &= ~vlan_strip; 4716 + netdev_info(netdev, "Disabling VLAN stripping as FCS/CRC stripping is also disabled and there is no VLAN configured\n"); 4717 + return requested_features; 4718 + } 4719 + 4720 + if ((netdev->features & NETIF_F_RXFCS) && is_vlan_strip) { 4721 + requested_features &= ~vlan_strip; 4722 + if (!(netdev->features & vlan_strip)) 4723 + netdev_info(netdev, "To enable VLAN stripping, first need to enable FCS/CRC stripping"); 4724 + 4725 + return requested_features; 4726 + } 4727 + 4728 + if (num_non_zero_vlan && is_vlan_strip && 4729 + !(netdev->features & NETIF_F_RXFCS)) { 4730 + requested_features &= ~NETIF_F_RXFCS; 4731 + netdev_info(netdev, "To disable FCS/CRC stripping, first need to disable VLAN stripping"); 4732 + } 4733 + 4734 + return requested_features; 4735 + } 4736 + 4737 + /** 4695 4738 * iavf_fix_features - fix up the netdev feature bits 4696 4739 * @netdev: our net device 4697 4740 * @features: desired feature bits ··· 4752 4697 { 4753 4698 struct iavf_adapter *adapter = netdev_priv(netdev); 4754 4699 4755 - return iavf_fix_netdev_vlan_features(adapter, features); 4700 + features = iavf_fix_netdev_vlan_features(adapter, features); 4701 + 4702 + return iavf_fix_strip_features(adapter, features); 4756 4703 } 4757 4704 4758 4705 static const struct net_device_ops iavf_netdev_ops = {
+4
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
··· 142 142 VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 | 143 143 VIRTCHNL_VF_OFFLOAD_ENCAP | 144 144 VIRTCHNL_VF_OFFLOAD_VLAN_V2 | 145 + VIRTCHNL_VF_OFFLOAD_CRC | 145 146 VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM | 146 147 VIRTCHNL_VF_OFFLOAD_REQ_QUEUES | 147 148 VIRTCHNL_VF_OFFLOAD_ADQ | ··· 313 312 vqpi->rxq.databuffer_size = 314 313 ALIGN(adapter->rx_rings[i].rx_buf_len, 315 314 BIT_ULL(IAVF_RXQ_CTX_DBUFF_SHIFT)); 315 + if (CRC_OFFLOAD_ALLOWED(adapter)) 316 + vqpi->rxq.crc_disable = !!(adapter->netdev->features & 317 + NETIF_F_RXFCS); 316 318 vqpi++; 317 319 } 318 320
+3
drivers/net/ethernet/intel/ice/ice_vf_lib.h
··· 123 123 u8 num_req_qs; /* num of queue pairs requested by VF */ 124 124 u16 num_mac; 125 125 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) 126 129 struct ice_mdd_vf_events mdd_rx_events; 127 130 struct ice_mdd_vf_events mdd_tx_events; 128 131 DECLARE_BITMAP(opcodes_allowlist, VIRTCHNL_OP_MAX);
+65 -4
drivers/net/ethernet/intel/ice/ice_virtchnl.c
··· 486 486 if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_REQ_QUEUES) 487 487 vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_REQ_QUEUES; 488 488 489 + if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_CRC) 490 + vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_CRC; 491 + 489 492 if (vf->driver_caps & VIRTCHNL_VF_CAP_ADV_LINK_SPEED) 490 493 vfres->vf_cap_flags |= VIRTCHNL_VF_CAP_ADV_LINK_SPEED; 491 494 ··· 1624 1621 } 1625 1622 1626 1623 for (i = 0; i < qci->num_queue_pairs; i++) { 1624 + if (!qci->qpair[i].rxq.crc_disable) 1625 + continue; 1626 + 1627 + if (!(vf->driver_caps & VIRTCHNL_VF_OFFLOAD_CRC) || 1628 + vf->vlan_strip_ena) 1629 + goto error_param; 1630 + } 1631 + 1632 + for (i = 0; i < qci->num_queue_pairs; i++) { 1627 1633 qpi = &qci->qpair[i]; 1628 1634 if (qpi->txq.vsi_id != qci->vsi_id || 1629 1635 qpi->rxq.vsi_id != qci->vsi_id || ··· 1677 1665 1678 1666 vsi->rx_rings[i]->dma = qpi->rxq.dma_ring_addr; 1679 1667 vsi->rx_rings[i]->count = qpi->rxq.ring_len; 1668 + 1669 + if (qpi->rxq.crc_disable) 1670 + vsi->rx_rings[q_idx]->flags |= 1671 + ICE_RX_FLAGS_CRC_STRIP_DIS; 1672 + else 1673 + vsi->rx_rings[q_idx]->flags &= 1674 + ~ICE_RX_FLAGS_CRC_STRIP_DIS; 1680 1675 1681 1676 if (qpi->rxq.databuffer_size != 0 && 1682 1677 (qpi->rxq.databuffer_size > ((16 * 1024) - 128) || ··· 2430 2411 } 2431 2412 2432 2413 /** 2414 + * ice_vsi_is_rxq_crc_strip_dis - check if Rx queue CRC strip is disabled or not 2415 + * @vsi: pointer to the VF VSI info 2416 + */ 2417 + static bool ice_vsi_is_rxq_crc_strip_dis(struct ice_vsi *vsi) 2418 + { 2419 + unsigned int i; 2420 + 2421 + ice_for_each_alloc_rxq(vsi, i) 2422 + if (vsi->rx_rings[i]->flags & ICE_RX_FLAGS_CRC_STRIP_DIS) 2423 + return true; 2424 + 2425 + return false; 2426 + } 2427 + 2428 + /** 2433 2429 * ice_vc_ena_vlan_stripping 2434 2430 * @vf: pointer to the VF info 2435 2431 * ··· 2473 2439 2474 2440 if (vsi->inner_vlan_ops.ena_stripping(vsi, ETH_P_8021Q)) 2475 2441 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2442 + else 2443 + vf->vlan_strip_ena |= ICE_INNER_VLAN_STRIP_ENA; 2476 2444 2477 2445 error_param: 2478 2446 return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING, ··· 2510 2474 2511 2475 if (vsi->inner_vlan_ops.dis_stripping(vsi)) 2512 2476 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2477 + else 2478 + vf->vlan_strip_ena &= ~ICE_INNER_VLAN_STRIP_ENA; 2513 2479 2514 2480 error_param: 2515 2481 return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING, ··· 2687 2649 { 2688 2650 struct ice_vsi *vsi = ice_get_vf_vsi(vf); 2689 2651 2652 + vf->vlan_strip_ena = 0; 2653 + 2690 2654 if (!vsi) 2691 2655 return -EINVAL; 2692 2656 ··· 2698 2658 if (ice_vf_is_port_vlan_ena(vf) && !ice_is_dvm_ena(&vsi->back->hw)) 2699 2659 return 0; 2700 2660 2701 - if (ice_vf_vlan_offload_ena(vf->driver_caps)) 2702 - return vsi->inner_vlan_ops.ena_stripping(vsi, ETH_P_8021Q); 2703 - else 2704 - return vsi->inner_vlan_ops.dis_stripping(vsi); 2661 + if (ice_vf_vlan_offload_ena(vf->driver_caps)) { 2662 + int err; 2663 + 2664 + err = vsi->inner_vlan_ops.ena_stripping(vsi, ETH_P_8021Q); 2665 + if (!err) 2666 + vf->vlan_strip_ena |= ICE_INNER_VLAN_STRIP_ENA; 2667 + return err; 2668 + } 2669 + 2670 + return vsi->inner_vlan_ops.dis_stripping(vsi); 2705 2671 } 2706 2672 2707 2673 static u16 ice_vc_get_max_vlan_fltrs(struct ice_vf *vf) ··· 3481 3435 goto out; 3482 3436 } 3483 3437 3438 + if (ice_vsi_is_rxq_crc_strip_dis(vsi)) { 3439 + v_ret = VIRTCHNL_STATUS_ERR_NOT_SUPPORTED; 3440 + goto out; 3441 + } 3442 + 3484 3443 ethertype_setting = strip_msg->outer_ethertype_setting; 3485 3444 if (ethertype_setting) { 3486 3445 if (ice_vc_ena_vlan_offload(vsi, ··· 3506 3455 * enabled, is extracted in L2TAG1. 3507 3456 */ 3508 3457 ice_vsi_update_l2tsel(vsi, l2tsel); 3458 + 3459 + vf->vlan_strip_ena |= ICE_OUTER_VLAN_STRIP_ENA; 3509 3460 } 3510 3461 } 3511 3462 ··· 3518 3465 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 3519 3466 goto out; 3520 3467 } 3468 + 3469 + if (ethertype_setting) 3470 + vf->vlan_strip_ena |= ICE_INNER_VLAN_STRIP_ENA; 3521 3471 3522 3472 out: 3523 3473 return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2, ··· 3583 3527 * in L2TAG1. 3584 3528 */ 3585 3529 ice_vsi_update_l2tsel(vsi, l2tsel); 3530 + 3531 + vf->vlan_strip_ena &= ~ICE_OUTER_VLAN_STRIP_ENA; 3586 3532 } 3587 3533 } 3588 3534 ··· 3593 3535 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 3594 3536 goto out; 3595 3537 } 3538 + 3539 + if (ethertype_setting) 3540 + vf->vlan_strip_ena &= ~ICE_INNER_VLAN_STRIP_ENA; 3596 3541 3597 3542 out: 3598 3543 return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2,
+9 -2
include/linux/avf/virtchnl.h
··· 240 240 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6) 241 241 /* used to negotiate communicating link speeds in Mbps */ 242 242 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) 243 + #define VIRTCHNL_VF_OFFLOAD_CRC BIT(10) 243 244 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15) 244 245 #define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16) 245 246 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17) ··· 296 295 /* VIRTCHNL_OP_CONFIG_RX_QUEUE 297 296 * VF sends this message to set up parameters for one RX queue. 298 297 * External data buffer contains one instance of virtchnl_rxq_info. 299 - * PF configures requested queue and returns a status code. 298 + * PF configures requested queue and returns a status code. The 299 + * crc_disable flag disables CRC stripping on the VF. Setting 300 + * the crc_disable flag to 1 will disable CRC stripping for each 301 + * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC 302 + * offload must have been set prior to sending this info or the PF 303 + * will ignore the request. This flag should be set the same for 304 + * all of the queues for a VF. 300 305 */ 301 306 302 307 /* Rx queue config info */ ··· 314 307 u16 splithdr_enabled; /* deprecated with AVF 1.0 */ 315 308 u32 databuffer_size; 316 309 u32 max_pkt_size; 317 - u8 pad0; 310 + u8 crc_disable; 318 311 u8 rxdid; 319 312 u8 pad1[2]; 320 313 u64 dma_ring_addr;