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 87BA7A0547; Thu, 21 Oct 2021 11:52:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 036BC41233; Thu, 21 Oct 2021 11:51:02 +0200 (CEST) Received: from smtpproxy21.qq.com (smtpbg704.qq.com [203.205.195.105]) by mails.dpdk.org (Postfix) with ESMTP id 98F204121E for ; Thu, 21 Oct 2021 11:50:57 +0200 (CEST) X-QQ-mid: bizesmtp38t1634809851t41455a2 Received: from jiawenwu.trustnetic.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Thu, 21 Oct 2021 17:50:50 +0800 (CST) X-QQ-SSF: 01400000000000E0I000000A0000000 X-QQ-FEAT: FWgLFBHtXoHdLJGyHOxT0x9h1e2zPr4uNocFHCb5oWNKcFfovYqSBFSrYKNzU zjxq+ZPGZEJ8rNFzyyPqvlK1pKCgWxx6MbS5t6QZ+iXsnlUnm7MTkm60thhUwOHey2UN5pK YQtcPznp2Mc2jLChfSo5cdCNbYmUwPH5m6OZJi0zcLVi+BgST1es/C13q9berqBmd61Jdu3 MZpQbvV3x3Gj9H15dSxqFBkbDRnScN0NzYoWZ6C6OLY+6hdzrhEM4R3Fr852xoZU6HkCZKs zvJdnInvx82cZf3BZMlCSU/lcfQ8slxmye8Sw0UsFF+JJWhUPM1DFftalMT6Ne1zm+X7zZj K7TmSZfmy2g55q5iEkenC5AqPsnZg9g0vmPsXgh479PXSC8xz4= X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Thu, 21 Oct 2021 17:50:09 +0800 Message-Id: <20211021095023.18288-13-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:qybgforeign6 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v2 12/26] net/ngbe: add device promiscuous and allmulticast mode 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 to enable/disable promiscuous and allmulticast mode for a port. Signed-off-by: Jiawen Wu --- doc/guides/nics/features/ngbe.ini | 2 + doc/guides/nics/ngbe.rst | 2 + drivers/net/ngbe/ngbe_ethdev.c | 63 +++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/doc/guides/nics/features/ngbe.ini b/doc/guides/nics/features/ngbe.ini index d4e66ab23f..1d0e87e8bb 100644 --- a/doc/guides/nics/features/ngbe.ini +++ b/doc/guides/nics/features/ngbe.ini @@ -13,6 +13,8 @@ MTU update = Y Jumbo frame = Y Scattered Rx = Y TSO = Y +Promiscuous mode = Y +Allmulticast mode = Y VLAN filter = Y CRC offload = Y VLAN offload = Y diff --git a/doc/guides/nics/ngbe.rst b/doc/guides/nics/ngbe.rst index a180acbea3..2a92f91e9f 100644 --- a/doc/guides/nics/ngbe.rst +++ b/doc/guides/nics/ngbe.rst @@ -16,6 +16,8 @@ Features - Checksum offload - VLAN/QinQ stripping and inserting - TSO offload +- Promiscuous mode +- Multicast mode - Port hardware statistics - Jumbo frames - Link state information diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index adb51bf8d9..665fb8fe41 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -1750,6 +1750,65 @@ ngbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) return ngbe_dev_link_update_share(dev, wait_to_complete); } +static int +ngbe_dev_promiscuous_enable(struct rte_eth_dev *dev) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + uint32_t fctrl; + + fctrl = rd32(hw, NGBE_PSRCTL); + fctrl |= (NGBE_PSRCTL_UCP | NGBE_PSRCTL_MCP); + wr32(hw, NGBE_PSRCTL, fctrl); + + return 0; +} + +static int +ngbe_dev_promiscuous_disable(struct rte_eth_dev *dev) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + uint32_t fctrl; + + fctrl = rd32(hw, NGBE_PSRCTL); + fctrl &= (~NGBE_PSRCTL_UCP); + if (dev->data->all_multicast == 1) + fctrl |= NGBE_PSRCTL_MCP; + else + fctrl &= (~NGBE_PSRCTL_MCP); + wr32(hw, NGBE_PSRCTL, fctrl); + + return 0; +} + +static int +ngbe_dev_allmulticast_enable(struct rte_eth_dev *dev) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + uint32_t fctrl; + + fctrl = rd32(hw, NGBE_PSRCTL); + fctrl |= NGBE_PSRCTL_MCP; + wr32(hw, NGBE_PSRCTL, fctrl); + + return 0; +} + +static int +ngbe_dev_allmulticast_disable(struct rte_eth_dev *dev) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + uint32_t fctrl; + + if (dev->data->promiscuous == 1) + return 0; /* must remain in all_multicast mode */ + + fctrl = rd32(hw, NGBE_PSRCTL); + fctrl &= (~NGBE_PSRCTL_MCP); + wr32(hw, NGBE_PSRCTL, fctrl); + + return 0; +} + /** * It clears the interrupt causes and enables the interrupt. * It will be called once only during NIC initialized. @@ -2172,6 +2231,10 @@ static const struct eth_dev_ops ngbe_eth_dev_ops = { .dev_stop = ngbe_dev_stop, .dev_close = ngbe_dev_close, .dev_reset = ngbe_dev_reset, + .promiscuous_enable = ngbe_dev_promiscuous_enable, + .promiscuous_disable = ngbe_dev_promiscuous_disable, + .allmulticast_enable = ngbe_dev_allmulticast_enable, + .allmulticast_disable = ngbe_dev_allmulticast_disable, .link_update = ngbe_dev_link_update, .stats_get = ngbe_dev_stats_get, .xstats_get = ngbe_dev_xstats_get, -- 2.21.0.windows.1