Linux PFs report the max frame size of the VF in max_mtu of the VF
resources, minus 4 bytes for a port VLAN, and reject
VIRTCHNL_OP_CONFIG_VSI_QUEUES with a larger max_pkt_size. The driver
always reported 9728 bytes as max Rx packet length instead. With a port
VLAN on an ice PF and an MTU of 9702, starting the port failed with
"Failed to execute command VIRTCHNL_OP_CONFIG_VSI_QUEUES".

Report the PF limit as max_rx_pktlen, so ethdev rejects a larger MTU
at configuration time, and use it for the Rx queue check. Fall back to
9728 if the PF reports 0 or a value out of range.

Fixes: 69dd4c3d0898 ("net/avf: enable queue and device")
Cc: [email protected]

Suggested-by: Bruce Richardson <[email protected]>
Signed-off-by: Georg Müller <[email protected]>
---
v2:
* report the PF limit as max_rx_pktlen, so that ethdev rejects a larger
  MTU at configuration time, instead of silently clamping max_pkt_len
  at port start (suggested by Bruce Richardson)
* add .mailmap entry
 
Tested with a VF in a port VLAN on an Intel E810-C (ice PF).

 .mailmap                             |  1 +
 drivers/net/intel/iavf/iavf_ethdev.c | 25 ++++++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/.mailmap b/.mailmap
index a0096fb97a..09015b13d3 100644
--- a/.mailmap
+++ b/.mailmap
@@ -546,6 +546,7 @@ Gena Tertychnyi <[email protected]>
 Geoff Thorpe <[email protected]>
 Geoffrey Le Gourriérec <[email protected]>
 Geoffrey Lv <[email protected]>
+Georg Müller <[email protected]>
 Georg Sauthoff <[email protected]>
 George Prekas <[email protected]>
 George Wilkie <[email protected]> <[email protected]>
diff --git a/drivers/net/intel/iavf/iavf_ethdev.c 
b/drivers/net/intel/iavf/iavf_ethdev.c
index 10069feae2..84e9b0ae10 100644
--- a/drivers/net/intel/iavf/iavf_ethdev.c
+++ b/drivers/net/intel/iavf/iavf_ethdev.c
@@ -779,10 +779,29 @@ iavf_dev_configure(struct rte_eth_dev *dev)
        return 0;
 }
 
+/*
+ * The PF reports the max frame size of the VF in max_mtu,
+ * reduced by the VLAN tag if a port VLAN is set.
+ * A value of 0 or out of range means the PF does not report a limit.
+ */
+static uint32_t
+iavf_get_max_frame_size(struct iavf_info *vf)
+{
+       uint32_t max_frame_size = vf->vf_res->max_mtu;
+
+       if (max_frame_size < RTE_ETHER_MIN_MTU + IAVF_ETH_OVERHEAD ||
+           max_frame_size > IAVF_FRAME_SIZE_MAX)
+               return IAVF_FRAME_SIZE_MAX;
+
+       return max_frame_size;
+}
+
 static int
 iavf_init_rxq(struct rte_eth_dev *dev, struct ci_rx_queue *rxq)
 {
        struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+       uint32_t max_frame_size = iavf_get_max_frame_size(vf);
        struct rte_eth_dev_data *dev_data = dev->data;
        uint16_t buf_size, max_pkt_len;
        uint32_t frame_size = dev->data->mtu + IAVF_ETH_OVERHEAD;
@@ -797,11 +816,11 @@ iavf_init_rxq(struct rte_eth_dev *dev, struct ci_rx_queue 
*rxq)
 
        /* Check if maximum packet length is set correctly.  */
        if (max_pkt_len <= RTE_ETHER_MIN_LEN ||
-           max_pkt_len > IAVF_FRAME_SIZE_MAX) {
+           max_pkt_len > max_frame_size) {
                PMD_DRV_LOG(ERR, "maximum packet length must be "
                            "larger than %u and smaller than %u",
                            (uint32_t)IAVF_ETH_MAX_LEN,
-                           (uint32_t)IAVF_FRAME_SIZE_MAX);
+                           max_frame_size);
                return -EINVAL;
        }
 
@@ -1193,7 +1212,7 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
        dev_info->max_rx_queues = max_queue_pairs;
        dev_info->max_tx_queues = max_queue_pairs;
        dev_info->min_rx_bufsize = IAVF_BUF_SIZE_MIN;
-       dev_info->max_rx_pktlen = IAVF_FRAME_SIZE_MAX;
+       dev_info->max_rx_pktlen = iavf_get_max_frame_size(vf);
        dev_info->max_mtu = dev_info->max_rx_pktlen - IAVF_ETH_OVERHEAD;
        dev_info->min_mtu = RTE_ETHER_MIN_MTU;
        dev_info->hash_key_size = vf->vf_res->rss_key_size;
-- 
2.56.1

Reply via email to