Move eth_mac_addr and eth_change_mtu
Subsystems (2)
PATCH 1/1 Move eth_mac_addr and eth_change_mtu
Move eth_mac_addr() and eth_change_mtu() from drivers/net/net_init.c to net/ethernet/eth.c
Index: drivers/net/net_init.c
===================================================================
RCS file: /var/cvs/linux-2.5/drivers/net/net_init.c,v retrieving revision 1.4
net/net_init.c +0 -17
@@ -222,23 +222,6 @@ struct net_device *alloc_etherdev(int siEXPORT_SYMBOL (init_etherdev);EXPORT_SYMBOL (alloc_etherdev); -static int eth_mac_addr (struct net_device *dev,void *p) -{ -struct sockaddr *addr=p; -if (netif_running (dev)) -return -EBUSY ; -memcpy (dev->dev_addr, addr->sa_data,dev->addr_len); -return 0 ; -} - -static int eth_change_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <68 ) || (new_mtu >1500 )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -#ifdef CONFIG_FDDI /**
Index: include/linux/etherdevice.h
===================================================================
RCS file: /var/cvs/linux-2.5/include/linux/etherdevice.h,v retrieving revision 1.3
linux/etherdevice.h +2 -0
@@ -38,6 +38,8 @@ extern int eth_header_cache(struct neig struct hh_cache *hh);extern int eth_header_parse (struct sk_buff *skb,unsigned char *haddr); +extern int eth_mac_addr (struct net_device *dev,void *p); +extern int eth_change_mtu (struct net_device *dev,int new_mtu);extern struct net_device *init_etherdev (struct net_device *dev,int sizeof_priv);extern struct net_device *alloc_etherdev (int sizeof_priv);static inline void eth_copy_and_sum (struct sk_buff *dest,unsigned char *src,int len,int base)
Index: net/ethernet/eth.c
===================================================================
RCS file: /var/cvs/linux-2.5/net/ethernet/eth.c,v
retrieving revision 1.4
ethernet/eth.c +17 -0
@@ -241,3 +241,20 @@ void eth_header_cache_update(struct hh_cmemcpy (((u8 *)hh->hh_data) +HH_DATA_OFF (sizeof (struct ethhdr )), haddr, dev->addr_len); } + +int eth_mac_addr (struct net_device *dev,void *p) +{ +struct sockaddr *addr=p; +if (netif_running (dev)) +return -EBUSY ; +memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); +return 0 ; +} + +int eth_change_mtu (struct net_device *dev,int new_mtu) +{ +if ((new_mtu <68 ) || (new_mtu >1500 )) +return -EINVAL ; + dev->mtu = new_mtu; +return 0 ; +}
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 2 lines · Matthew Wilcox
Move
eth_mac_addr()andeth_change_mtu()fromdrivers/net/net_init.ctonet/ethernet/eth.c
Why? It's not used outside of net_init.c AFAICS.
And even so, don't you want to export those symbols?
Jeff
Quoted 5 lines · Jeff Garzik
Quoted 2 lines · Matthew Wilcox
Move
eth_mac_addr()andeth_change_mtu()fromdrivers/net/net_init.ctonet/ethernet/eth.cWhy? It's not used outside of
net_init.cAFAICS.
Preparation for the next stage of netdev_ops
Quoted 1 line
And even so, don't you want to export those symbols?
Yep, you're right, I'll need to do that too.
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 11 lines · Matthew Wilcox
Quoted 6 lines · Jeff Garzik
Quoted 2 lines · Matthew Wilcox
Move
eth_mac_addr()andeth_change_mtu()fromdrivers/net/net_init.ctonet/ethernet/eth.cWhy? It's not used outside of
net_init.cAFAICS.Preparation for the next stage of
netdev_ops
Well, I don't see/understand this next-stage, so elaboration would be nice. As-is, I do not support merging this patch.
Jeff
Quoted 2 lines · Jeff Garzik
Well, I don't see/understand this next-stage, so elaboration would be nice. As-is, I do not support merging this patch.
It's the next stage you're calling for -- move these functions:
dev->change_mtu = eth_change_mtu;
dev->hard_header = eth_header;
dev->rebuild_header = eth_rebuild_header;
dev->set_mac_address = eth_mac_addr;
dev->hard_header_cache = eth_header_cache;
dev->header_cache_update= eth_header_cache_update;
dev->hard_header_parse = eth_header_parse;into netdev_ops. Which means each driver will need to see them.
I thought I could justify moving these functions already on the grounds that if you were looking for the definition of eth_change_mtu(), net_init.c would be a much less likely place to look than net/ethernet/eth.c
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 15 lines · Matthew Wilcox
Quoted 1 line · Jeff Garzik
Well, I don't see/understand this next-stage, so elaboration would be nice. As-is, I do not support merging this patch.
It's the next stage you're calling for -- move these functions:
dev->change_mtu = eth_change_mtu; dev->hard_header = eth_header; dev->rebuild_header = eth_rebuild_header; dev->set_mac_address = eth_mac_addr; dev->hard_header_cache = eth_header_cache; dev->header_cache_update= eth_header_cache_update; dev->hard_header_parse = eth_header_parse;
Quoted 1 line
into
netdev_ops. Which means each driver will need to see them.
Drivers don't need to see them now, they shouldn't need to see them after netdev_ops.
It's hidden by ether_setup.
Quoted 4 lines
I thought I could justify moving these functions already on the grounds that if you were looking for the definition of
eth_change_mtu(),net_init.cwould be a much less likely place to look thannet/ethernet/eth.c
If you're gonna do that, move all of ether_setup, alloc_etherdev, etc. Don't just move two out of ~10 functions.
Jeff
Quoted 17 lines · Jeff Garzik
Quoted 16 lines · Matthew Wilcox
Quoted 2 lines · Jeff Garzik
Well, I don't see/understand this next-stage, so elaboration would be nice. As-is, I do not support merging this patch.
It's the next stage you're calling for -- move these functions:
dev->change_mtu = eth_change_mtu; dev->hard_header = eth_header; dev->rebuild_header = eth_rebuild_header; dev->set_mac_address = eth_mac_addr; dev->hard_header_cache = eth_header_cache; dev->header_cache_update= eth_header_cache_update; dev->hard_header_parse = eth_header_parse;
Quoted 6 lines
Quoted 1 line
into
netdev_ops. Which means each driver will need to see them.Drivers don't need to see them now, they shouldn't need to see them after
netdev_ops.It's hidden by
ether_setup.
Umm. Technically, yes. Seems a bit ugly to assign to the netdev_ops struct which is shared between the devices. Won't _break_ anything (unless some crazed person has a driver which drives the ethernet and token ring versions of the same chip ;-)
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk