[v6,15/17] net/r8169: implement MTU configuration

Message ID 20241108121123.248797-16-howard_wang@realsil.com.cn (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series Modify code as suggested by the maintainer. |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Howard Wang Nov. 8, 2024, 12:11 p.m. UTC
Add support for updating MTU value.

Signed-off-by: Howard Wang <howard_wang@realsil.com.cn>
---
 doc/guides/nics/features/r8169.ini |  1 +
 drivers/net/r8169/r8169_ethdev.c   | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
  

Patch

diff --git a/doc/guides/nics/features/r8169.ini b/doc/guides/nics/features/r8169.ini
index d2aa132e41..3bcba23ea5 100644
--- a/doc/guides/nics/features/r8169.ini
+++ b/doc/guides/nics/features/r8169.ini
@@ -8,6 +8,7 @@  Speed capabilities   = Y
 Link speed configuration = Y
 Link status          = Y
 Link status event    = Y
+MTU update           = Y
 Scattered Rx         = Y
 TSO                  = Y
 Promiscuous mode     = Y
diff --git a/drivers/net/r8169/r8169_ethdev.c b/drivers/net/r8169/r8169_ethdev.c
index c90c3c9d03..8daf1c26ab 100644
--- a/drivers/net/r8169/r8169_ethdev.c
+++ b/drivers/net/r8169/r8169_ethdev.c
@@ -42,6 +42,7 @@  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);
+static int rtl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 /*
  * The set of PCI devices this driver supports
@@ -88,6 +89,8 @@  static const struct eth_dev_ops rtl_eth_dev_ops = {
 	.stats_get            = rtl_dev_stats_get,
 	.stats_reset          = rtl_dev_stats_reset,
 
+	.mtu_set              = rtl_dev_mtu_set,
+
 	.rx_queue_setup       = rtl_rx_queue_setup,
 	.rx_queue_release     = rtl_rx_queue_release,
 	.rxq_info_get         = rtl_rxq_info_get,
@@ -374,6 +377,9 @@  rtl_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		break;
 	}
 
+	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+	dev_info->max_mtu = dev_info->max_rx_pktlen - RTL_ETH_OVERHEAD;
+
 	dev_info->rx_offload_capa = (rtl_get_rx_port_offloads() |
 				     dev_info->rx_queue_offload_capa);
 	dev_info->tx_offload_capa = rtl_get_tx_port_offloads();
@@ -596,6 +602,20 @@  rtl_dev_close(struct rte_eth_dev *dev)
 	return ret_stp;
 }
 
+static int
+rtl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct rtl_adapter *adapter = RTL_DEV_PRIVATE(dev);
+	struct rtl_hw *hw = &adapter->hw;
+	uint32_t frame_size = mtu + RTL_ETH_OVERHEAD;
+
+	hw->mtu = mtu;
+
+	RTL_W16(hw, RxMaxSize, frame_size);
+
+	return 0;
+}
+
 static int
 rtl_dev_init(struct rte_eth_dev *dev)
 {