Re: [PATCH] ucc_geth: Convert to net_device_ops

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Timur Tabi
Date: Friday, March 27, 2009 - 11:50 am

On Tue, Mar 24, 2009 at 6:08 PM, Joakim Tjernlund
<Joakim.Tjernlund@transmode.se> wrote:


I have an old patch for change_mtu support for ucc_geth which I've
been meaning to push upstream.  This patch uses this function instead
of eth_change_mtu():

+static int ucc_geth_change_mtu(struct net_device *dev, int new_mtu)
+{
+	int max_rx_buf_length;
+	struct ucc_geth_private *ugeth = netdev_priv(dev);
+	int frame_size = new_mtu + 18;
+	struct ucc_geth_info *ug_info;
+	struct ucc_fast_info *uf_info;
+
+	if (ugeth->p_rx_glbl_pram) {
+		printk("%s: Interface is active!\n", __FUNCTION__);
+	} else {
+
+		ug_info = ugeth->ug_info;
+		uf_info = &ug_info->uf_info;
+
+		if ((frame_size < 64) || (frame_size > JUMBO_FRAME_SIZE)) {
+			printk(KERN_ERR "%s: Invalid MTU setting\n", dev->name);
+			return -EINVAL;
+		}
+
+		max_rx_buf_length =
+		    (frame_size & ~(UCC_GETH_MRBLR_ALIGNMENT - 1)) +
+		    UCC_GETH_MRBLR_ALIGNMENT;
+
+		ugeth->ug_info->uf_info.max_rx_buf_length = max_rx_buf_length;
+		dev->mtu = new_mtu;
+
+		/* Set the max. rx buffer size (MRBLR) */
+		uf_info->max_rx_buf_length = max_rx_buf_length;
+
+		/* set the max. frame length (MFLR) */
+		ug_info->maxFrameLength = frame_size;
+
+		ugeth_info("%s: MTU = %d (frame size=%d)\n", dev->name,
+		       dev->mtu, frame_size);
+	}
+	return 0;
+}

Do you think this is how it should be done?  I don't know enough about
ucc_geth and MTUs to know off-hand.

-- 
Timur Tabi
Linux kernel developer at Freescale
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] ucc_geth: Convert to net_device_ops, Joakim Tjernlund, (Mon Mar 23, 3:17 am)
Re: [PATCH] ucc_geth: Convert to net_device_ops, David Miller, (Mon Mar 23, 11:49 am)
Re: [PATCH] ucc_geth: Convert to net_device_ops, Joakim Tjernlund, (Tue Mar 24, 3:37 am)
Re: [PATCH] ucc_geth: Convert to net_device_ops, David Miller, (Tue Mar 24, 2:22 pm)
Re: [PATCH] ucc_geth: Convert to net_device_ops, Joakim Tjernlund, (Tue Mar 24, 3:45 pm)
Re: [PATCH] ucc_geth: Convert to net_device_ops, David Miller, (Tue Mar 24, 3:49 pm)
Re: [PATCH] ucc_geth: Convert to net_device_ops, Joakim Tjernlund, (Tue Mar 24, 4:08 pm)
Re: [PATCH] ucc_geth: Convert to net_device_ops, David Miller, (Tue Mar 24, 4:29 pm)
Re: [PATCH] ucc_geth: Convert to net_device_ops, Joakim Tjernlund, (Tue Mar 24, 4:35 pm)
Re: [PATCH] ucc_geth: Convert to net_device_ops, Timur Tabi, (Fri Mar 27, 11:50 am)
Re: [PATCH] ucc_geth: Convert to net_device_ops, Joakim Tjernlund, (Sat Mar 28, 4:27 am)