lkml.org 
[lkml]   [1999]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
Date
From
SubjectSyncppp patches for kernels 2.2.x and 2.3.x

Alan,

You probably remember our discussion on the issue of having a (struct
device *) instead of a (struct device) in the structure ppp_device of
syncppp. You agreed that it would be a Good Thing(tm), although
apparently complicated to implement.

I finally came up with a solution that would require minimal (although
necessary) changes in the drivers, and the patches for these changes are
attached. These patches are against 2.2.14pre11 and 2.3.31, respectively.

Basically, the changes in the drivers would be as follows:

- The first position in the driver's dev->priv structure must be a void
pointer, which would contain the address of the ppp_device structure.
The driver would initialize this pointer at init time.
- All references to the ppp_device (struct device) field in the drivers
must be changed accordingly (i.e., should refer to a pointer as opposed
to a structure, as previously).

With this change, both the WAN drivers and syncppp can use dev->priv to
obtain the necessary device information, while at the same time it still
allows different WAN drivers to have different dev->priv structures (as
long as they follow the aforementioned requirements). I think it's a very
reasonable compromise.

The patch also exports the function sync_ppp_init, to allow monolythic
drivers to work (when the driver is monolythic -- as well as the syncppp
driver --, it has to call sync_ppp_init in its init function, otherwise
the interface won't be able to receive data).

Please let me know what you think about this patch and whether it will be
applied or not. I'm surely open to other solutions, although I couldn't
find any.

Regards,
Ivan

P.S.: the 2.3.x patch also includes the netsyms.c patch (to allow syncppp
linkage), but as I've already submitted it before, it may not be
necessary.
--- linux/drivers/net/syncppp.c.orig Thu Dec 9 11:19:13 1999
+++ linux/drivers/net/syncppp.c Thu Dec 9 11:28:40 1999
@@ -151,9 +151,10 @@

static void if_down(struct device *dev)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);

- sp->pp_link_state=SPPP_LINK_DOWN;
+ sp->pp_link_state = SPPP_LINK_DOWN;
}

/*
@@ -189,7 +190,8 @@
void sppp_input (struct device *dev, struct sk_buff *skb)
{
struct ppp_header *h;
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);

skb->dev=dev;
skb->mac.raw=skb->data;
@@ -318,7 +320,8 @@
static int sppp_hard_header(struct sk_buff *skb, struct device *dev, __u16 type,
void *daddr, void *saddr, unsigned int len)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);
struct ppp_header *h;
skb_push(skb,sizeof(struct ppp_header));
h=(struct ppp_header *)skb->data;
@@ -824,7 +827,8 @@

int sppp_close (struct device *dev)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);
sp->pp_link_state = SPPP_LINK_DOWN;
sp->lcp.state = LCP_STATE_CLOSED;
sp->ipcp.state = IPCP_STATE_CLOSED;
@@ -837,7 +841,8 @@

int sppp_open (struct device *dev)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);
sppp_close(dev);
if (!(sp->pp_flags & PP_CISCO)) {
sppp_lcp_open (sp);
@@ -850,7 +855,8 @@

int sppp_reopen (struct device *dev)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);
sppp_close(dev);
if (!(sp->pp_flags & PP_CISCO))
{
@@ -860,7 +866,7 @@
sp->ipcp.state = IPCP_STATE_CLOSED;
/* Give it a moment for the line to settle then go */
sppp_set_timeout (sp, 1);
- }
+ }
sp->pp_link_state=SPPP_LINK_DOWN;
return 0;
}
@@ -879,7 +885,8 @@

int sppp_do_ioctl(struct device *dev, struct ifreq *ifr, int cmd)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);

if(dev->flags&IFF_UP)
return -EBUSY;
@@ -912,7 +919,7 @@

void sppp_attach(struct ppp_device *pd)
{
- struct device *dev=&pd->dev;
+ struct device *dev = pd->dev;
struct sppp *sp = &pd->sppp;

/* Initialize keepalive handler. */
@@ -969,7 +976,8 @@

void sppp_detach (struct device *dev)
{
- struct sppp **q, *p, *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp **q, *p, *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);


/* Remove the entry from the keepalive list. */
@@ -1295,6 +1303,8 @@
sppp_packet_type.type=htons(ETH_P_WAN_PPP);
dev_add_pack(&sppp_packet_type);
}
+
+EXPORT_SYMBOL(sync_ppp_init);

#ifdef MODULE

--- linux/drivers/net/syncppp.h.orig Thu Dec 9 11:19:13 1999
+++ linux/drivers/net/syncppp.h Thu Dec 9 11:30:42 1999
@@ -52,7 +52,7 @@

struct ppp_device
{
- struct device dev; /* Network device */
+ struct device *dev; /* Network device pointer */
struct sppp sppp; /* Synchronous PPP */
};

@@ -86,6 +86,7 @@
int sppp_open (struct device *dev);
int sppp_reopen (struct device *dev);
int sppp_close (struct device *dev);
+void sync_ppp_init (void);
#endif

#define SPPPIOCCISCO (SIOCDEVPRIVATE)--- linux/drivers/net/wan/syncppp.c.orig Mon Oct 11 10:13:25 1999
+++ linux/drivers/net/wan/syncppp.c Thu Dec 9 10:47:08 1999
@@ -187,7 +187,8 @@
void sppp_input (struct net_device *dev, struct sk_buff *skb)
{
struct ppp_header *h;
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);

skb->dev=dev;
skb->mac.raw=skb->data;
@@ -316,7 +317,8 @@
static int sppp_hard_header(struct sk_buff *skb, struct net_device *dev, __u16 type,
void *daddr, void *saddr, unsigned int len)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);
struct ppp_header *h;
skb_push(skb,sizeof(struct ppp_header));
h=(struct ppp_header *)skb->data;
@@ -826,7 +828,8 @@

int sppp_close (struct net_device *dev)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);
dev->flags &= ~IFF_RUNNING;
sp->lcp.state = LCP_STATE_CLOSED;
sp->ipcp.state = IPCP_STATE_CLOSED;
@@ -839,7 +842,8 @@

int sppp_open (struct net_device *dev)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);
sppp_close(dev);
dev->flags |= IFF_RUNNING;
if (!(sp->pp_flags & PP_CISCO))
@@ -851,7 +855,8 @@

int sppp_reopen (struct net_device *dev)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);
sppp_close(dev);
dev->flags |= IFF_RUNNING;
if (!(sp->pp_flags & PP_CISCO))
@@ -880,7 +885,8 @@

int sppp_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
- struct sppp *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);

if(dev->flags&IFF_UP)
return -EBUSY;
@@ -913,7 +919,7 @@

void sppp_attach(struct ppp_device *pd)
{
- struct net_device *dev=&pd->dev;
+ struct net_device *dev = pd->dev;
struct sppp *sp = &pd->sppp;

/* Initialize keepalive handler. */
@@ -970,7 +976,8 @@

void sppp_detach (struct net_device *dev)
{
- struct sppp **q, *p, *sp = &((struct ppp_device *)dev)->sppp;
+ struct sppp **q, *p, *sp = (struct sppp *)
+ (&((struct ppp_device *)(*(unsigned long *)dev->priv))->sppp);


/* Remove the entry from the keepalive list. */
@@ -1296,6 +1303,8 @@
sppp_packet_type.type=htons(ETH_P_WAN_PPP);
dev_add_pack(&sppp_packet_type);
}
+
+EXPORT_SYMBOL(sync_ppp_init);

#ifdef MODULE

--- linux/drivers/net/wan/syncppp.h.orig Mon Oct 11 10:13:25 1999
+++ linux/drivers/net/wan/syncppp.h Thu Dec 9 10:47:08 1999
@@ -51,7 +51,7 @@

struct ppp_device
{
- struct net_device dev; /* Network device */
+ struct net_device *dev; /* Network device pointer */
struct sppp sppp; /* Synchronous PPP */
};

@@ -82,6 +82,7 @@
int sppp_open (struct net_device *dev);
int sppp_reopen (struct net_device *dev);
int sppp_close (struct net_device *dev);
+void sync_ppp_init (void);
#endif

#define SPPPIOCCISCO (SIOCDEVPRIVATE)
--- linux/net/netsyms.c.orig Thu Nov 18 19:25:28 1999
+++ linux/net/netsyms.c Thu Dec 9 10:47:08 1999
@@ -223,6 +223,7 @@

#ifdef CONFIG_INET
/* Internet layer registration */
+EXPORT_SYMBOL(inetdev_lock);
EXPORT_SYMBOL(inet_add_protocol);
EXPORT_SYMBOL(inet_del_protocol);
EXPORT_SYMBOL(ip_route_output);
\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.065 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site