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 0914C460AB; Fri, 17 Jan 2025 12:46:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 695C842E4E; Fri, 17 Jan 2025 12:45:23 +0100 (CET) Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by mails.dpdk.org (Postfix) with ESMTP id BF48042E47 for ; Fri, 17 Jan 2025 12:45:21 +0100 (CET) X-QQ-mid: bizesmtp85t1737114316tpi16irz X-QQ-Originating-IP: OI2nnjmakNTdHTe0wcvU6zxGOh+AQwZlLty3Vw8m9Dg= Received: from DSK-zaiyuwang.trustnetic.com ( [36.24.187.167]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 17 Jan 2025 19:45:14 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17263600258582581060 From: Zaiyu Wang To: dev@dpdk.org Cc: Zaiyu Wang , Jiawen Wu Subject: [PATCH v3 05/15] net/ngbe: add set MTU ops for VF device Date: Fri, 17 Jan 2025 19:44:43 +0800 Message-Id: <20250117114455.15864-6-zaiyuwang@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20250117114455.15864-1-zaiyuwang@trustnetic.com> References: <20250109040227.1016-1-zaiyuwang@trustnetic.com> <20250117114455.15864-1-zaiyuwang@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz5a-1 X-QQ-XMAILINFO: Oel5xuXd1h7E4Vru+NQpSFgoT8hH44gruuM1jwxupBJmN7OE//gNjPkI auWnPsPI4gvc+Jl0qpXqnZrTMBktIkKlTEvK8iNQEQyGIQN4To5k5onOwcpvsGdpE/edsYB 7JziwjXYxHogGwvSeeGZvde9fT04B/DakQDoc2jZ1PaaqvDcRmU2dgkjDFyGGq2SdiiiFRl szebIY1mh9mdaxyma/Obt7zOYvLeUEgWymwXL0iqicHPTnUwiycwDglCY41DRAdsQxJwOak IMFIcFFor4klsI3YsaFhJPwv8xUauAYX6xmiEDG3D3EF+vRTVNBR5tkb9AYakoppUDAwEHJ aeo5XsXZk9qTvkpoRDdzkU0X/J1qz310uWkPAzvj9Oql9aCJyznuBjzuHenNRIB4Pyrw0iN a2jdmOKPomL+vRWlrH+I1M5jvE/rUXFBd/KUZ+3Iw9TbL20cuRYPwHg3IUwK3XsDTqbnEd3 q/Qco/DKJk/SwD79b4NEJMJ7Y/oqj5zGUvT/TSNj5O87nk0JW74vTM9pX80adKLfZqm1AFC XZ0T3ciogzkWC76Bj1o79jC5PJdxLp2RLhw2xc4dW3NPKeafrkhO3fQgJx8FGnortdgNPPb 9JSV0jGBS155NXuqCOfDJmV48VKhsZfyOKmSuJXq/eBafzN/q3VjmVHcSEMihcblOhJlhNV ZivnOckDMdBNN8ZMJm+nKRc0csYgodwgGzrKJpEB4w72xd409Uxnbzry8iM8QhmRB7mtJBz emqOiQG1f8FvWowNEVftTfkVi64/boLkN39cXT1QuroYIDOk5FVzRddzIoa6O5LnZ5O1/Pn EkNo8dU4bA5LjNWvE8is33nWQEx5ebNZ+2A87ascOLLtdirZvhmxR3YPrazjZiOnzCt7QBo dsbLzS8U6N7sR7XkgEIBN66V7kPKmzux2q7Y9XOeh0BByxokjkyeekVKp+OaRNRV7tzQido O89S3qzsjH4ptkds/sKgDZ6V25752ouGKMdCjmmcitvHdvXcpoTuIUlDsECYYkOleG5h9IN V1V2EVpqqouasct4egIxFuDNgX4CWDNT8oT+iOgmm8UvWSKhEN X-QQ-XMRINFO: Mp0Kj//9VHAxr69bL5MkOOs= X-QQ-RECHKSPAM: 0 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 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