Thread (36 messages) 36 messages, 4 authors, 2024-08-05

Re: [RFC PATCH net-next 05/10] net: hibmcge: Implement some .ndo functions

From: Andrew Lunn <andrew@lunn.ch>
Date: 2024-08-01 00:51:33
Also in: lkml

+static int hbg_net_set_mac_address(struct net_device *dev, void *addr)
+{
+	struct hbg_priv *priv = netdev_priv(dev);
+	u8 *mac_addr;
+
+	mac_addr = ((struct sockaddr *)addr)->sa_data;
+	if (ether_addr_equal(dev->dev_addr, mac_addr))
+		return 0;
+
+	if (!is_valid_ether_addr(mac_addr))
+		return -EADDRNOTAVAIL;
How does the core pass you an invalid MAC address?
+static int hbg_net_change_mtu(struct net_device *dev, int new_mtu)
+{
+	struct hbg_priv *priv = netdev_priv(dev);
+	bool is_opened = hbg_nic_is_open(priv);
+	u32 frame_len;
+
+	if (new_mtu == dev->mtu)
+		return 0;
+
+	if (new_mtu < priv->dev_specs.min_mtu || new_mtu > priv->dev_specs.max_mtu)
+		return -EINVAL;
You just need to set dev->min_mtu and dev->max_mtu, and the core will
do this validation for you.
+	dev_info(&priv->pdev->dev,
+		 "change mtu from %u to %u\n", dev->mtu, new_mtu);
dev_dbg() Don't spam the log for normal operations.

	Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help