From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (unknown [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4A504460AB; Fri, 17 Jan 2025 11:44:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8784B42D2B; Fri, 17 Jan 2025 11:43:31 +0100 (CET) Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) by mails.dpdk.org (Postfix) with ESMTP id 3DA9042D0B for ; Fri, 17 Jan 2025 11:43:28 +0100 (CET) X-QQ-mid: bizesmtpsz8t1737110604tzoiwys X-QQ-Originating-IP: yUO6sO40sTMtamcJXR2U3fhHYGzSlT8dzgjVFo4YckI= Received: from DSK-zaiyuwang.trustnetic.com ( [36.24.187.167]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 17 Jan 2025 18:43:23 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 15172754518013336735 From: Zaiyu Wang To: dev@dpdk.org Cc: Zaiyu Wang , Jiawen Wu Subject: [PATCH v2 05/15] net/ngbe: add set MTU ops for VF device Date: Fri, 17 Jan 2025 18:41:04 +0800 Message-Id: <20250117104115.16528-6-zaiyuwang@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20250117104115.16528-1-zaiyuwang@trustnetic.com> References: <20250109040227.1016-1-zaiyuwang@trustnetic.com> <20250117104115.16528-1-zaiyuwang@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz5a-1 X-QQ-XMAILINFO: N7MSp95pYuqVEc5ShlaCq2paR9vGybiHkfdKy7xEo7LB6/ZlT44dCeW/ WwnhkWr21yCIcxgjFC/kRf4vjUAMHZUIrUsYv06bKm4V/cO/mYiVFY2yG+5T4p6qP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discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Support to update MTU for VF device. Signed-off-by: Zaiyu Wang --- doc/guides/nics/features/ngbe_vf.ini | 1 + drivers/net/ngbe/base/ngbe_type.h | 1 + drivers/net/ngbe/base/ngbe_vf.c | 24 +++++++++++++++++++ drivers/net/ngbe/base/ngbe_vf.h | 1 + drivers/net/ngbe/ngbe_ethdev_vf.c | 36 ++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+) diff --git a/doc/guides/nics/features/ngbe_vf.ini b/doc/guides/nics/features/ngbe_vf.ini index f8928c5a6c..570b5ac25b 100644 --- a/doc/guides/nics/features/ngbe_vf.ini +++ b/doc/guides/nics/features/ngbe_vf.ini @@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +MTU update = Y Promiscuous mode = Y Allmulticast mode = Y CRC offload = P diff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h index 29dcd5f912..f780b92efa 100644 --- a/drivers/net/ngbe/base/ngbe_type.h +++ b/drivers/net/ngbe/base/ngbe_type.h @@ -352,6 +352,7 @@ struct ngbe_mac_info { void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw, bool enable, int vf); s32 (*update_xcast_mode)(struct ngbe_hw *hw, int xcast_mode); + s32 (*set_rlpml)(struct ngbe_hw *hw, u16 max_size); /* Flow Control */ s32 (*fc_enable)(struct ngbe_hw *hw); diff --git a/drivers/net/ngbe/base/ngbe_vf.c b/drivers/net/ngbe/base/ngbe_vf.c index ccf7148b9c..c0436c7b8a 100644 --- a/drivers/net/ngbe/base/ngbe_vf.c +++ b/drivers/net/ngbe/base/ngbe_vf.c @@ -228,6 +228,29 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode) return 0; } +/** + * ngbevf_rlpml_set_vf - Set the maximum receive packet length + * @hw: pointer to the HW structure + * @max_size: value to assign to max frame size + **/ +s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size) +{ + u32 msgbuf[2]; + s32 retval; + + msgbuf[0] = NGBE_VF_SET_LPE; + msgbuf[1] = max_size; + + retval = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2); + if (retval) + return retval; + if ((msgbuf[0] & NGBE_VF_SET_LPE) && + (msgbuf[0] & NGBE_VT_MSGTYPE_NACK)) + return NGBE_ERR_MBX; + + return 0; +} + /** * ngbevf_negotiate_api_version - Negotiate supported API version * @hw: pointer to the HW structure @@ -339,6 +362,7 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw) mac->negotiate_api_version = ngbevf_negotiate_api_version; mac->update_xcast_mode = ngbevf_update_xcast_mode; + mac->set_rlpml = ngbevf_rlpml_set_vf; mac->max_tx_queues = 1; mac->max_rx_queues = 1; diff --git a/drivers/net/ngbe/base/ngbe_vf.h b/drivers/net/ngbe/base/ngbe_vf.h index 79891e8389..a64de9d332 100644 --- a/drivers/net/ngbe/base/ngbe_vf.h +++ b/drivers/net/ngbe/base/ngbe_vf.h @@ -17,6 +17,7 @@ s32 ngbe_start_hw_vf(struct ngbe_hw *hw); s32 ngbe_reset_hw_vf(struct ngbe_hw *hw); s32 ngbe_stop_hw_vf(struct ngbe_hw *hw); s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode); +s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size); int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api); int ngbevf_get_queues(struct ngbe_hw *hw, unsigned int *num_tcs, unsigned int *default_tc); diff --git a/drivers/net/ngbe/ngbe_ethdev_vf.c b/drivers/net/ngbe/ngbe_ethdev_vf.c index 28000471b5..f53c17cc82 100644 --- a/drivers/net/ngbe/ngbe_ethdev_vf.c +++ b/drivers/net/ngbe/ngbe_ethdev_vf.c @@ -269,6 +269,41 @@ ngbevf_dev_close(struct rte_eth_dev *dev) return 0; } +static int +ngbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct ngbe_hw *hw; + uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; + struct rte_eth_dev_data *dev_data = dev->data; + + hw = ngbe_dev_hw(dev); + + if (mtu < RTE_ETHER_MIN_MTU || + max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN) + return -EINVAL; + + /* If device is started, refuse mtu that requires the support of + * scattered packets when this feature has not been enabled before. + */ + if (dev_data->dev_started && !dev_data->scattered_rx && + (max_frame + 2 * RTE_VLAN_HLEN > + dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) { + PMD_INIT_LOG(ERR, "Stop port first."); + return -EINVAL; + } + + /* + * When supported by the underlying PF driver, use the NGBE_VF_SET_MTU + * request of the version 2.0 of the mailbox API. + * For now, use the NGBE_VF_SET_LPE request of the version 1.0 + * of the mailbox API. + */ + if (ngbevf_rlpml_set_vf(hw, max_frame)) + return -EINVAL; + + return 0; +} + static int ngbevf_dev_promiscuous_enable(struct rte_eth_dev *dev) { @@ -366,6 +401,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = { .allmulticast_enable = ngbevf_dev_allmulticast_enable, .allmulticast_disable = ngbevf_dev_allmulticast_disable, .dev_infos_get = ngbevf_dev_info_get, + .mtu_set = ngbevf_dev_set_mtu, }; RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd); -- 2.21.0.windows.1