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 C645845CA6; Fri, 8 Nov 2024 13:14:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8196743396; Fri, 8 Nov 2024 13:14:25 +0100 (CET) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by mails.dpdk.org (Postfix) with ESMTP id F248C43396 for ; Fri, 8 Nov 2024 13:14:23 +0100 (CET) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 4A8CELTA01902656, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=realsil.com.cn; s=dkim; t=1731068062; bh=Ac2eE5WJu2qZvrWAt1UNs0lAatbx3hY/UiNjNqhwIXY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type; b=l0iLwKneQ/+sO2diXew5sa7wosVHs3dYBKImdNLGhSP+FI8h6CM9JWDDrA1kzke/v /3CbS/0S8hjC0NMJzB5GHXGWl5uorqG6dc649GJNfyfTDZ+Z778a2y06+Lxftcyqb5 Jya1HpvxrsRSJDm+sZWYYcTpmizgi6xwIkeKiHOjOfEMEbVgQCTiRXVbxGkm+J2vzr tRUZevTzM/DHkNQTxVZ1dAhVYbSo+QLPv3ZWGOPSJmJQnL6fcCx7eX7s2TAuRCr27i YrYKkId3RYVOgHU39LUNr9bIHz78S2YRnDtsnQ12uHvAd6kTot8DCSllWQDtKPd4nJ rMv78Xi9+RZ1g== Received: from RSEXMBS03.realsil.com.cn ([172.29.17.197]) by rtits2.realtek.com.tw (8.15.2/3.06/5.92) with ESMTPS id 4A8CELTA01902656 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 8 Nov 2024 20:14:22 +0800 Received: from RSEXDAG02.realsil.com.cn (172.29.17.196) by RSEXMBS03.realsil.com.cn (172.29.17.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 8 Nov 2024 20:14:22 +0800 Received: from RSEXH36502.realsil.com.cn (172.29.17.3) by RSEXDAG02.realsil.com.cn (172.29.17.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 8 Nov 2024 20:14:21 +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; Fri, 8 Nov 2024 20:14:21 +0800 From: Howard Wang To: CC: , Howard Wang Subject: [PATCH v6 14/17] net/r8169: implement promisc and allmulti modes Date: Fri, 8 Nov 2024 20:11:20 +0800 Message-ID: <20241108121123.248797-15-howard_wang@realsil.com.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241108121123.248797-1-howard_wang@realsil.com.cn> References: <20241108121123.248797-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 b983f7ce55..d2aa132e41 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 CRC offload = Y L3 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