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 72B3FA0547; Thu, 21 Oct 2021 11:52:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7A4F4122C; Thu, 21 Oct 2021 11:51:00 +0200 (CEST) Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by mails.dpdk.org (Postfix) with ESMTP id 796B44120F for ; Thu, 21 Oct 2021 11:50:53 +0200 (CEST) X-QQ-mid: bizesmtp38t1634809849tus6nbg8 Received: from jiawenwu.trustnetic.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Thu, 21 Oct 2021 17:50:48 +0800 (CST) X-QQ-SSF: 01400000000000E0I000000A0000000 X-QQ-FEAT: iANUFw1MatF+OafAdB+X8sK1MI8mCVcR16v/pnHWg4OfXKfIXjyrD9io8Smyu 0tHgCoNJxcgHEjuLzjhjgrhbQu7HNUVleJouobEZrRgoPC+xTkJJiZtJsW/pvTvtSPliflj XfW3y3TZeijg4y/DCCMQSfWhzlG/gBANXLEf3b44N5pOIfvDYKCT0gCotBgX1gBMWJpOeSi xJg3DjMVzJLxdXRsm5BxICHeQlgC1OgTBq87jz2vMBFb3K5klnpJ4y1GqDhMtc9Y9m/kZ95 MahuQmt9ISGFSc6Jb84QIr8evvRGnDEtier59W1DrRJLhlycwAWA0eE3lM4OJv71S9lyw7P SqpjETZD0pqR60JTSWMCXkWOF09FLaJVHfZnukP16Mg/zOUdYQ= X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Thu, 21 Oct 2021 17:50:08 +0800 Message-Id: <20211021095023.18288-12-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20211021095023.18288-1-jiawenwu@trustnetic.com> References: <20211021095023.18288-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign7 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v2 11/26] net/ngbe: support MTU set 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" Support updating port MTU. Signed-off-by: Jiawen Wu --- doc/guides/nics/features/ngbe.ini | 1 + drivers/net/ngbe/base/ngbe_type.h | 3 +++ drivers/net/ngbe/ngbe_ethdev.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/doc/guides/nics/features/ngbe.ini b/doc/guides/nics/features/ngbe.ini index c34f6d1b66..d4e66ab23f 100644 --- a/doc/guides/nics/features/ngbe.ini +++ b/doc/guides/nics/features/ngbe.ini @@ -9,6 +9,7 @@ Link status = Y Link status event = Y Queue start/stop = Y Burst mode info = Y +MTU update = Y Jumbo frame = Y Scattered Rx = Y TSO = Y diff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h index 93d0799852..58a5180881 100644 --- a/drivers/net/ngbe/base/ngbe_type.h +++ b/drivers/net/ngbe/base/ngbe_type.h @@ -8,6 +8,7 @@ #define NGBE_LINK_UP_TIME 90 /* 9.0 Seconds */ +#define NGBE_FRAME_SIZE_MAX (9728) /* Maximum frame size, +FCS */ #define NGBE_FRAME_SIZE_DFT (1522) /* Default frame size, +FCS */ #define NGBE_NUM_POOL (32) #define NGBE_MAX_QP (8) @@ -319,6 +320,8 @@ struct ngbe_hw { u16 nb_rx_queues; u16 nb_tx_queues; + u32 mode; + u32 q_rx_regs[8 * 4]; u32 q_tx_regs[8 * 4]; bool offset_loaded; diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index 0dcb68c5cd..adb51bf8d9 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -2046,6 +2046,33 @@ ngbe_dev_interrupt_handler(void *param) ngbe_dev_interrupt_action(dev); } +static int +ngbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + 4; + struct rte_eth_dev_data *dev_data = dev->data; + + /* 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 && + (frame_size + 2 * NGBE_VLAN_TAG_SIZE > + dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) { + PMD_INIT_LOG(ERR, "Stop port first."); + return -EINVAL; + } + + if (hw->mode) + wr32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK, + NGBE_FRAME_SIZE_MAX); + else + wr32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK, + NGBE_FRMSZ_MAX(frame_size)); + + return 0; +} + /** * Set the IVAR registers, mapping interrupt causes to vectors * @param hw @@ -2154,6 +2181,7 @@ static const struct eth_dev_ops ngbe_eth_dev_ops = { .xstats_get_names = ngbe_dev_xstats_get_names, .xstats_get_names_by_id = ngbe_dev_xstats_get_names_by_id, .dev_supported_ptypes_get = ngbe_dev_supported_ptypes_get, + .mtu_set = ngbe_dev_mtu_set, .vlan_filter_set = ngbe_vlan_filter_set, .vlan_tpid_set = ngbe_vlan_tpid_set, .vlan_offload_set = ngbe_vlan_offload_set, -- 2.21.0.windows.1