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 BA16045CF3; Wed, 13 Nov 2024 10:32:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABE7740E96; Wed, 13 Nov 2024 10:32:51 +0100 (CET) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by mails.dpdk.org (Postfix) with ESMTP id 489BA40E41 for ; Wed, 13 Nov 2024 10:32:50 +0100 (CET) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 4AD9WmjnE1091751, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=realsil.com.cn; s=dkim; t=1731490368; bh=0iOmo0YeHDpkglwtBXL37ZEvmfgJdl7oXIfO49L/9Vs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type; b=jExiaIJDSoOTfwzCaM0o4A7K73BVdhPG4WYVOFYjeBkq1P3jl9Yl0Wa/jgnCwYpin HQS0S6xWjsJmKCw9kIJSAasE267uGRpUxLV+F75dT4jpXdiZei1kIKncJHGRn1cx0c TXWu9oGSMzsDB7lebKp6aQKkjc6FwrddrQLHEV/1xEDrpHHkGKNu28zsyRBOELKo7L koPH7Ob1NxnosJzg/jXUxwJFdGv9WBMF5irAjH1gpDwgqwOxKp+OBII/1HErt5VgHO Fumw3ENmNhSwmWzZmqlPdbZbAyrDv6jh0SiBvoolHBocBnWWtTy3WK3rTyQbMmsOCZ zPjia8dPdESbw== 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 4AD9WmjnE1091751 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 13 Nov 2024 17:32:48 +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; Wed, 13 Nov 2024 17:32:48 +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; Wed, 13 Nov 2024 17:32:48 +0800 From: Howard Wang To: CC: , Howard Wang Subject: [PATCH v8 14/17] net/r8169: implement promisc and allmulti modes Date: Wed, 13 Nov 2024 17:28:51 +0800 Message-ID: <20241113092854.91445-15-howard_wang@realsil.com.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241113092854.91445-1-howard_wang@realsil.com.cn> References: <20241113092854.91445-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 | 2 + drivers/net/r8169/r8169_ethdev.c | 67 ++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/doc/guides/nics/features/r8169.ini b/doc/guides/nics/features/r8169.ini index a9a4bd6a90..0ab596b692 100644 --- a/doc/guides/nics/features/r8169.ini +++ b/doc/guides/nics/features/r8169.ini @@ -10,6 +10,8 @@ Link status = Y Link status event = Y Scattered Rx = Y TSO = Y +Promiscuous mode = Y +Allmulticast mode = 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