(1/8) hdlc wan device disembedding
Subsystems (3)
PATCH 1/1 (1/8) hdlc wan device disembedding
Change the hdlc wan device's to not have the net_device structure embedded inside the hdlc_device structure. This won't work on 2.6 where the net_device structure may need to live after module unload due to sysfs. Instead, use alloc_netdev and setup so that netdev->priv = hdlc and have hdlc->dev_data for device private data.
Patch is against net-drivers-2.5-exp tree. This portion breaks the actual hardware drivers but that is fixed in parts 2-5. I don't have any of this hardware so the code has only been tested by compiling and loading the modules.
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1502 -> 1.1503
# drivers/net/wan/hdlc_generic.c 1.14 -> 1.15
# drivers/net/wan/hdlc_cisco.c 1.9 -> 1.10
# drivers/net/wan/hdlc_fr.c 1.9 -> 1.10
# include/linux/hdlc.h 1.10 -> 1.11
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/12/01 [email protected] 1.1503
# 1-hdlc_device
# --------------------------------------------
#
drivers/net/wan/hdlc_cisco.c +4 -4
@@ -222,8 +222,8 @@ hdlc->state.cisco.settings.timeout * HZ) { hdlc->state.cisco.up =0 ;printk (KERN_INFO "%s: Link down\n" ,hdlc_to_name (hdlc)); -if (netif_carrier_ok (&hdlc->netdev)) -netif_carrier_off (&hdlc->netdev); +if (netif_carrier_ok (hdlc->netdev)) +netif_carrier_off (hdlc->netdev); } cisco_keepalive_send(hdlc, CISCO_KEEPALIVE_REQ,
@@ -256,8 +256,8 @@static void cisco_stop (hdlc_device *hdlc) {del_timer_sync (&hdlc->state.cisco.timer); -if (netif_carrier_ok (&hdlc->netdev)) -netif_carrier_off (&hdlc->netdev); +if (netif_carrier_ok (hdlc->netdev)) +netif_carrier_off (hdlc->netdev); }
drivers/net/wan/hdlc_fr.c +6 -6
@@ -543,8 +543,8 @@ hdlc->state.fr.reliable = reliable;if (reliable) { -if (!netif_carrier_ok (&hdlc->netdev)) -netif_carrier_on (&hdlc->netdev); +if (!netif_carrier_ok (hdlc->netdev)) +netif_carrier_on (hdlc->netdev); hdlc->state.fr.n391cnt =0 ;/* Request full status */ hdlc->state.fr.dce_changed =1 ;
@@ -558,8 +558,8 @@ } } }else { -if (netif_carrier_ok (&hdlc->netdev)) -netif_carrier_off (&hdlc->netdev); +if (netif_carrier_ok (hdlc->netdev)) +netif_carrier_off (hdlc->netdev);while (pvc) {/* Deactivate all PVCs */ pvc_carrier (0 , pvc);
@@ -938,8 +938,8 @@printk (KERN_DEBUG "fr_start\n" );#endif if (hdlc->state.fr.settings.lmi !=LMI_NONE ) { -if (netif_carrier_ok (&hdlc->netdev)) -netif_carrier_off (&hdlc->netdev); +if (netif_carrier_ok (hdlc->netdev)) +netif_carrier_off (hdlc->netdev); hdlc->state.fr.last_poll =0 ; hdlc->state.fr.reliable =0 ; hdlc->state.fr.dce_changed =1 ;
drivers/net/wan/hdlc_generic.c +30 -21
108 lines not on this page · raw message
include/linux/hdlc.h +8 -7
@@ -96,7 +96,9 @@ typedef struct hdlc_device_struct { /* To be initialized by hardware driver */ - struct net_device netdev; /* master net device - must be first */ + struct net_device *netdev; /* master net device */ + void *dev_data; + struct net_device_stats stats; /* used by HDLC layer to take control over HDLC device from hw driver*/
@@ -180,6 +182,8 @@/* Exported from hdlc.o */ +hdlc_device *alloc_hdlc_device (int sizeof_priv); +void free_hdlc_device (hdlc_device *hdlc);/* Called by hardware driver when a user requests HDLC service */ int hdlc_ioctl (struct net_device *dev,struct ifreq *ifr,int cmd);
@@ -188,18 +192,15 @@int register_hdlc_device (hdlc_device *hdlc);void unregister_hdlc_device (hdlc_device *hdlc); -static __inline__struct net_device *hdlc_to_dev (hdlc_device *hdlc) { -return &hdlc->netdev; +return hdlc->netdev; } - -static __inline__hdlc_device *dev_to_hdlc (struct net_device *dev) +static __inline__hdlc_device *dev_to_hdlc (struct net_device *dev) { -return (hdlc_device *)dev; +return dev->priv; } -static __inline__pvc_device *dev_to_pvc (struct net_device *dev) {
Krzysztof Halasa
maintainerQuoted 6 lines · Stephen Hemminger
Change the hdlc wan device's to not have the
net_devicestructure embedded inside thehdlc_devicestructure. This won't work on 2.6 where thenet_device
structure may need to live after module unload due to sysfs. Instead, usealloc_netdevand setup so thatnetdev->priv= hdlc and havehdlc->dev_datafor device private data.
Hmm... I always wanted dev->priv to be available for hw drivers (and yes, PPP proto doesn't currently meet that).
Any other idea maybe?
It seems the whole WAN (drivers/net/wan) needs some major rewrite, as the recent patches (starting with last 2.5.x ones) have broken few things (at least for me) which are not all fixed.
First I would duplicate syncppp.c code in hdlc_ppp.c (removing Cisco HDLC support and polishing it to suit generic HDLC needs) so it no longer depends on syncppp (long-term I plan switching to generic PPP but it's certainly post-2.6 thing and I'm not even sure how to do it). This would result in few hundred lines of duplicated code, though.
The positive side is that I can test the generic HDLC + hw drivers for C101, N2, wanXL, PCI200SYN (being merged) and PC300.
The other thing would be converting drivers using syncppp.c to use generic HDLC instead (it would add support for X.25, Frame-Relay and raw HDLC). While I can probably make a patch I can't test it.
The remaining drivers use either Sangoma (sdla/dlci/wanpipe/wanrouter) or comx code. Not sure about their status, are they both maintained?
Comments?
Signature · 1 line
Krzysztof Halasa, B*FH