From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A50A2A0A03; Mon, 18 Jan 2021 09:35:20 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85F07140D59; Mon, 18 Jan 2021 09:35:20 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 175AF140D4E; Mon, 18 Jan 2021 09:35:18 +0100 (CET) IronPort-SDR: oEeTblTenbOh8F/GFHZuUbkC4HJ5u9hcYq9CmHir713PXKZNi3YiZqwEq/fw44ZvpXFRhga3QM TIRrfZlsM5Lg== X-IronPort-AV: E=McAfee;i="6000,8403,9867"; a="176202883" X-IronPort-AV: E=Sophos;i="5.79,355,1602572400"; d="scan'208";a="176202883" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2021 00:35:15 -0800 IronPort-SDR: BKXbz8s4gy3aJIZIc5L0zVqU/iudvM3nCR1o+bYhDxFh2uGr/71IwcXcIyWkXs4/1d/sIQsGXW eNs54ib0ElSA== X-IronPort-AV: E=Sophos;i="5.79,355,1602572400"; d="scan'208";a="401974745" Received: from shwdenpg235.ccr.corp.intel.com ([10.240.182.60]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2021 00:35:13 -0800 From: "Zhang,Alvin" To: jia.guo@intel.com, WeiX.Xie@intel.com, haiyue.wang@intel.com Cc: dev@dpdk.org, Alvin Zhang , stable@dpdk.org Date: Mon, 18 Jan 2021 16:35:07 +0800 Message-Id: <20210118083507.13544-1-alvinx.zhang@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20210118050341.1460-1-alvinx.zhang@intel.com> References: <20210118050341.1460-1-alvinx.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6] net/ixgbe: fix configuration of max frame size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Alvin Zhang For some types of NIC, jumbo frame is not supported in IOV mode, so if a VF requests to configure the frame size to not bigger than RTE_ETHER_MAX_LEN, the kernel driver returns 0, but the DPDK ixgbe PMD returens -1, this will cause the VF to fail to start when the PF driven by DPDK ixgbe PMD. This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation. In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu. Fixes: 1b9ea09c067b ("ixgbe: support X550") Fixes: 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF") Cc: stable@dpdk.org Signed-off-by: Alvin Zhang --- V3: Restore variable name from cur_frame_size to max_frs. V4: Update git log and add notes. V5: Add check for VF api version. V6: Update notes. --- drivers/net/ixgbe/ixgbe_pf.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c index 833863a..2762995 100644 --- a/drivers/net/ixgbe/ixgbe_pf.c +++ b/drivers/net/ixgbe/ixgbe_pf.c @@ -552,20 +552,47 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev) } static int -ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf) +ixgbe_set_vf_lpe(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) { struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); - uint32_t new_mtu = msgbuf[1]; + uint32_t max_frame = msgbuf[1]; uint32_t max_frs; uint32_t hlreg0; - int max_frame = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; /* X540 and X550 support jumbo frames in IOV mode */ if (hw->mac.type != ixgbe_mac_X540 && hw->mac.type != ixgbe_mac_X550 && hw->mac.type != ixgbe_mac_X550EM_x && - hw->mac.type != ixgbe_mac_X550EM_a) - return -1; + hw->mac.type != ixgbe_mac_X550EM_a) { + struct ixgbe_vf_info *vfinfo = + *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private); + + switch (vfinfo[vf].api_version) { + case ixgbe_mbox_api_11: + case ixgbe_mbox_api_12: + case ixgbe_mbox_api_13: + /** + * Version 1.1&1.2&1.3 supports jumbo frames on VFs + * if PF has jumbo frames enabled which means legacy + * VFs are disabled. + */ + if (dev->data->dev_conf.rxmode.max_rx_pkt_len > + RTE_ETHER_MAX_LEN) + break; + /* fall through */ + default: + /** + * If the PF or VF are running w/ jumbo frames enabled, + * we return -1 as we cannot support jumbo frames on + * legacy VFs. + */ + if (max_frame > RTE_ETHER_MAX_LEN || + dev->data->dev_conf.rxmode.max_rx_pkt_len > + RTE_ETHER_MAX_LEN) + return -1; + break; + } + } if (max_frame < RTE_ETHER_MIN_LEN || max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN) @@ -573,9 +600,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev) max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) & IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT; - if (max_frs < new_mtu) { + if (max_frs < max_frame) { hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0); - if (new_mtu > RTE_ETHER_MAX_LEN) { + if (max_frame > RTE_ETHER_MAX_LEN) { dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; hlreg0 |= IXGBE_HLREG0_JUMBOEN; @@ -586,7 +613,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev) } IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); - max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT; + max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT; IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs); } -- 1.8.3.1