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 880CF45CF0; Tue, 12 Nov 2024 11:01:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43B9942E7E; Tue, 12 Nov 2024 11:01:13 +0100 (CET) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by mails.dpdk.org (Postfix) with ESMTP id 29ABC42E5A for ; Tue, 12 Nov 2024 11:01:11 +0100 (CET) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 4ACA19HL03640237, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=realsil.com.cn; s=dkim; t=1731405670; bh=sQcuV3yeq4aSunK6EQzrEPn3jzQ0UI9iijGk64EuOzk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type; b=Cq1KjS2iNj4KJOtIgrOpy6s1HqgvRQvz+FMoNlR1bQ8rFy/YXWVZUBZ1dLaOuIyhy EBS77J83xwkMSQdH2WN9koSw6MjAU7Y3K32+s1CmzpHoEH5Ip+kOc8xNw1jLhnp/UL 4orqE4RbCkYMWBClJ8dkWebGKYyLM/lUfdkYoEfDVntGyxK8vcgUHbBDoo34huSkwm C/xncF4cxX1ZbHLuHGiY1yMyR3avoYbyxmDTZ0ypOcsE3RIxkU79qgLYK7oXWqLC9F zvjtPPX6YjIBe/xJy0oQnE2eIvxJPdBo/zh7w/BW//+SZegiK7RWTH9GZzzk+sdDZ0 b2TQRlajwnoRg== Received: from RSEXMBS01.realsil.com.cn ([172.29.17.195]) by rtits2.realtek.com.tw (8.15.2/3.06/5.92) with ESMTPS id 4ACA19HL03640237 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 12 Nov 2024 18:01:10 +0800 Received: from RSEXH36502.realsil.com.cn (172.29.17.3) by RSEXMBS01.realsil.com.cn (172.29.17.195) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 12 Nov 2024 18:01:09 +0800 Received: from 172.29.32.27 (172.29.32.27) by RSEXH36502.realsil.com.cn (172.29.17.3) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 12 Nov 2024 18:01:09 +0800 From: Howard Wang To: CC: , Howard Wang Subject: [PATCH v7 14/17] net/r8169: implement promisc and allmulti modes Date: Tue, 12 Nov 2024 17:58:01 +0800 Message-ID: <20241112095804.42091-15-howard_wang@realsil.com.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112095804.42091-1-howard_wang@realsil.com.cn> References: <20241112095804.42091-1-howard_wang@realsil.com.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 Add support for promiscuous/allmulticast modes configuration. Signed-off-by: Howard Wang --- doc/guides/nics/features/r8169.ini | 4 ++ drivers/net/r8169/r8169_ethdev.c | 67 ++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/doc/guides/nics/features/r8169.ini b/doc/guides/nics/features/r8169.ini index e4bbcde2a0..d2ad94dcc6 100644 --- a/doc/guides/nics/features/r8169.ini +++ b/doc/guides/nics/features/r8169.ini @@ -10,6 +10,10 @@ Link status = Y Link status event = Y Scattered Rx = Y TSO = Y +Promiscuous mode = Y +Allmulticast mode = Y +Unicast MAC filter = Y +Multicast MAC filter = Y Flow control = Y L3 checksum offload = Y L4 checksum offload = Y diff --git a/drivers/net/r8169/r8169_ethdev.c b/drivers/net/r8169/r8169_ethdev.c index f0792681a3..c90c3c9d03 100644 --- a/drivers/net/r8169/r8169_ethdev.c +++ b/drivers/net/r8169/r8169_ethdev.c @@ -38,6 +38,10 @@ static int rtl_dev_infos_get(struct rte_eth_dev *dev, static int rtl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); static int rtl_dev_stats_reset(struct rte_eth_dev *dev); +static int rtl_promiscuous_enable(struct rte_eth_dev *dev); +static int rtl_promiscuous_disable(struct rte_eth_dev *dev); +static int rtl_allmulticast_enable(struct rte_eth_dev *dev); +static int rtl_allmulticast_disable(struct rte_eth_dev *dev); /* * The set of PCI devices this driver supports @@ -74,6 +78,11 @@ static const struct eth_dev_ops rtl_eth_dev_ops = { .dev_set_link_down = rtl_dev_set_link_down, .dev_infos_get = rtl_dev_infos_get, + .promiscuous_enable = rtl_promiscuous_enable, + .promiscuous_disable = rtl_promiscuous_disable, + .allmulticast_enable = rtl_allmulticast_enable, + .allmulticast_disable = rtl_allmulticast_disable, + .link_update = rtl_dev_link_update, .stats_get = rtl_dev_stats_get, @@ -372,6 +381,64 @@ rtl_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) return 0; } +static int +rtl_promiscuous_enable(struct rte_eth_dev *dev) +{ + struct rtl_adapter *adapter = RTL_DEV_PRIVATE(dev); + struct rtl_hw *hw = &adapter->hw; + + int rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys | AcceptAllPhys; + + RTL_W32(hw, RxConfig, rx_mode | (RTL_R32(hw, RxConfig))); + rtl_allmulticast_enable(dev); + + return 0; +} + +static int +rtl_promiscuous_disable(struct rte_eth_dev *dev) +{ + struct rtl_adapter *adapter = RTL_DEV_PRIVATE(dev); + struct rtl_hw *hw = &adapter->hw; + int rx_mode = ~AcceptAllPhys; + + RTL_W32(hw, RxConfig, rx_mode & (RTL_R32(hw, RxConfig))); + + if (dev->data->all_multicast == 1) + rtl_allmulticast_enable(dev); + else + rtl_allmulticast_disable(dev); + + return 0; +} + +static int +rtl_allmulticast_enable(struct rte_eth_dev *dev) +{ + struct rtl_adapter *adapter = RTL_DEV_PRIVATE(dev); + struct rtl_hw *hw = &adapter->hw; + + RTL_W32(hw, MAR0 + 0, 0xffffffff); + RTL_W32(hw, MAR0 + 4, 0xffffffff); + + return 0; +} + +static int +rtl_allmulticast_disable(struct rte_eth_dev *dev) +{ + struct rtl_adapter *adapter = RTL_DEV_PRIVATE(dev); + struct rtl_hw *hw = &adapter->hw; + + if (dev->data->promiscuous == 1) + return 0; /* Must remain in all_multicast mode */ + + RTL_W32(hw, MAR0 + 0, 0); + RTL_W32(hw, MAR0 + 4, 0); + + return 0; +} + static int rtl_dev_stats_reset(struct rte_eth_dev *dev) { -- 2.34.1