Commit 0066476b authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: More sorting out of members for isdn_net_local / isdn_net_dev

There is a one-to-one relation between struct net_device and
isdn_net_local, so reflect that in the declaration. There is
one list of active channels per network interface, so put
the list head into isdn_net_local, the list members are isdn_net_dev's.
parent 2f1efd68
...@@ -240,7 +240,7 @@ isdn_net_ciscohdlck_slarp_send_reply(isdn_net_local *lp) ...@@ -240,7 +240,7 @@ isdn_net_ciscohdlck_slarp_send_reply(isdn_net_local *lp)
u32 addr = 0; /* local ipv4 address */ u32 addr = 0; /* local ipv4 address */
u32 mask = 0; /* local netmask */ u32 mask = 0; /* local netmask */
if ((in_dev = lp->netdev->dev.ip_ptr) != NULL) { if ((in_dev = lp->dev.ip_ptr) != NULL) {
/* take primary(first) address of interface */ /* take primary(first) address of interface */
struct in_ifaddr *ifa = in_dev->ifa_list; struct in_ifaddr *ifa = in_dev->ifa_list;
if (ifa != NULL) { if (ifa != NULL) {
...@@ -337,10 +337,9 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_local *lp, struct sk_buff *skb) ...@@ -337,10 +337,9 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_local *lp, struct sk_buff *skb)
} }
static void static void
isdn_ciscohdlck_receive(isdn_net_dev *idev, isdn_net_local *olp, isdn_ciscohdlck_receive(isdn_net_local *lp, isdn_net_dev *idev,
struct sk_buff *skb) struct sk_buff *skb)
{ {
isdn_net_local *lp = &idev->local;
unsigned char *p; unsigned char *p;
u8 addr; u8 addr;
u8 ctrl; u8 ctrl;
...@@ -373,7 +372,7 @@ isdn_ciscohdlck_receive(isdn_net_dev *idev, isdn_net_local *olp, ...@@ -373,7 +372,7 @@ isdn_ciscohdlck_receive(isdn_net_dev *idev, isdn_net_local *olp,
goto out_free; goto out_free;
default: default:
/* no special cisco protocol */ /* no special cisco protocol */
isdn_net_reset_huptimer(idev, olp->netdev); isdn_net_reset_huptimer(lp, idev);
skb->protocol = htons(type); skb->protocol = htons(type);
netif_rx(skb); netif_rx(skb);
return; return;
......
This diff is collapsed.
...@@ -58,10 +58,10 @@ extern void isdn_net_write_super(isdn_net_dev *, struct sk_buff *skb); ...@@ -58,10 +58,10 @@ extern void isdn_net_write_super(isdn_net_dev *, struct sk_buff *skb);
extern int isdn_net_online(isdn_net_dev *); extern int isdn_net_online(isdn_net_dev *);
static inline void static inline void
isdn_net_reset_huptimer(isdn_net_dev *idev, isdn_net_dev *idev2) isdn_net_reset_huptimer(isdn_net_local *lp, isdn_net_dev *idev)
{ {
lp->netdev->huptimer = 0;
idev->huptimer = 0; idev->huptimer = 0;
idev2->huptimer = 0;
} }
#define ISDN_NET_MAX_QUEUE_LENGTH 2 #define ISDN_NET_MAX_QUEUE_LENGTH 2
...@@ -83,76 +83,75 @@ isdn_net_dev_busy(isdn_net_dev *idev) ...@@ -83,76 +83,75 @@ isdn_net_dev_busy(isdn_net_dev *idev)
* corresponding bundle. The returned channel is locked. * corresponding bundle. The returned channel is locked.
*/ */
static inline isdn_net_dev * static inline isdn_net_dev *
isdn_net_get_locked_dev(isdn_net_dev *nd) isdn_net_get_locked_dev(isdn_net_local *mlp)
{ {
unsigned long flags; unsigned long flags;
isdn_net_local *lp;
isdn_net_dev *idev; isdn_net_dev *idev;
isdn_net_dev *head;
spin_lock_irqsave(&nd->queue_lock, flags); spin_lock_irqsave(&mlp->queue_lock, flags);
lp = nd->queue; /* get lp on top of queue */ head = mlp->queue;
idev = nd->queue->netdev; idev = head;
spin_lock_bh(&idev->xmit_lock); spin_lock_bh(&idev->xmit_lock);
while (isdn_net_dev_busy(idev)) { while (isdn_net_dev_busy(idev)) {
spin_unlock_bh(&idev->xmit_lock); spin_unlock_bh(&idev->xmit_lock);
nd->queue = nd->queue->next; mlp->queue = mlp->queue->next;
idev = nd->queue->netdev; idev = mlp->queue;
if (nd->queue == lp) { /* not found -- should never happen */ if (idev == head) { /* not found -- should never happen */
lp = NULL; idev = NULL;
goto errout; goto errout;
} }
spin_lock_bh(&idev->xmit_lock); spin_lock_bh(&idev->xmit_lock);
} }
lp = nd->queue; idev = mlp->queue;
nd->queue = nd->queue->next; mlp->queue = mlp->queue->next;
errout: errout:
spin_unlock_irqrestore(&nd->queue_lock, flags); spin_unlock_irqrestore(&mlp->queue_lock, flags);
return lp ? lp->netdev : NULL; return idev;
} }
/* /*
* add a channel to a bundle * add a channel to a bundle
*/ */
static inline void static inline void
isdn_net_add_to_bundle(isdn_net_dev *nd, isdn_net_local *nlp) isdn_net_add_to_bundle(isdn_net_local *mlp, isdn_net_dev *idev)
{ {
isdn_net_local *lp; isdn_net_dev *qdev;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&nd->queue_lock, flags); spin_lock_irqsave(&mlp->queue_lock, flags);
lp = nd->queue; qdev = mlp->queue;
nlp->last = lp->last; idev->last = qdev->last;
lp->last->next = nlp; qdev->last->next = idev;
lp->last = nlp; qdev->last = idev;
nlp->next = lp; idev->next = qdev;
nd->queue = nlp; mlp->queue = idev;
spin_unlock_irqrestore(&nd->queue_lock, flags); spin_unlock_irqrestore(&mlp->queue_lock, flags);
} }
/* /*
* remove a channel from the bundle it belongs to * remove a channel from the bundle it belongs to
*/ */
static inline void static inline void
isdn_net_rm_from_bundle(isdn_net_local *lp) isdn_net_rm_from_bundle(isdn_net_dev *idev)
{ {
isdn_net_local *master_lp = lp; isdn_net_local *mlp;
unsigned long flags; unsigned long flags;
if (lp->master) if (idev->master)
master_lp = (isdn_net_local *) lp->master->priv; mlp = idev->master;
else
mlp = &idev->local;
spin_lock_irqsave(&master_lp->netdev->queue_lock, flags); spin_lock_irqsave(&mlp->queue_lock, flags);
lp->last->next = lp->next; idev->last->next = idev->next;
lp->next->last = lp->last; idev->next->last = idev->last;
if (master_lp->netdev->queue == lp) { if (mlp->queue == idev) {
master_lp->netdev->queue = lp->next; mlp->queue = idev->next;
if (lp->next == lp) { /* last in queue */
master_lp->netdev->queue = &master_lp->netdev->local;
}
} }
lp->next = lp->last = lp; /* (re)set own pointers */ idev->next = idev->last = idev; /* (re)set own pointers */
spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags); spin_unlock_irqrestore(&mlp->queue_lock, flags);
} }
/* /*
...@@ -162,12 +161,10 @@ isdn_net_rm_from_bundle(isdn_net_local *lp) ...@@ -162,12 +161,10 @@ isdn_net_rm_from_bundle(isdn_net_local *lp)
static inline void static inline void
isdn_net_dev_wake_queue(isdn_net_dev *idev) isdn_net_dev_wake_queue(isdn_net_dev *idev)
{ {
isdn_net_local *lp = &idev->local; if (idev->master)
netif_wake_queue(&idev->master->dev);
if (lp->master)
netif_wake_queue(lp->master);
else else
netif_wake_queue(&lp->netdev->dev); netif_wake_queue(&idev->local.dev);
} }
static inline int static inline int
......
This diff is collapsed.
...@@ -294,8 +294,8 @@ struct isdn_netif_ops { ...@@ -294,8 +294,8 @@ struct isdn_netif_ops {
unsigned short flags; /* interface flags (a la BSD) */ unsigned short flags; /* interface flags (a la BSD) */
unsigned short type; /* interface hardware type */ unsigned short type; /* interface hardware type */
unsigned char addr_len;/* hardware address length */ unsigned char addr_len;/* hardware address length */
void (*receive)(struct isdn_net_dev_s *p, void (*receive)(struct isdn_net_local_s *lp,
struct isdn_net_local_s *olp, struct isdn_net_dev_s *idev,
struct sk_buff *skb); struct sk_buff *skb);
void (*connected)(struct isdn_net_local_s *lp); void (*connected)(struct isdn_net_local_s *lp);
void (*disconnected)(struct isdn_net_local_s *lp); void (*disconnected)(struct isdn_net_local_s *lp);
...@@ -334,12 +334,13 @@ typedef struct isdn_net_local_s { ...@@ -334,12 +334,13 @@ typedef struct isdn_net_local_s {
struct list_head phone[2]; /* List of remote-phonenumbers */ struct list_head phone[2]; /* List of remote-phonenumbers */
/* phone[0] = Incoming Numbers */ /* phone[0] = Incoming Numbers */
/* phone[1] = Outgoing Numbers */ /* phone[1] = Outgoing Numbers */
struct net_device *master; /* Ptr to Master device for slaves */
struct net_device *slave; /* Ptr to Slave device for masters */
struct isdn_net_local_s *next; /* Ptr to next link in bundle */
struct isdn_net_local_s *last; /* Ptr to last link in bundle */
struct isdn_net_dev_s *netdev; /* Ptr to netdev */ struct isdn_net_dev_s *netdev; /* Ptr to netdev */
struct isdn_net_dev_s *queue; /* circular list of all bundled
channels, which are currently
online */
spinlock_t queue_lock; /* lock to protect queue */
#ifdef CONFIG_ISDN_X25 #ifdef CONFIG_ISDN_X25
struct concap_device_ops *dops; /* callbacks used by encapsulator */ struct concap_device_ops *dops; /* callbacks used by encapsulator */
#endif #endif
...@@ -352,7 +353,10 @@ typedef struct isdn_net_local_s { ...@@ -352,7 +353,10 @@ typedef struct isdn_net_local_s {
char cisco_line_state; /* state of line according to keepalive packets */ char cisco_line_state; /* state of line according to keepalive packets */
char cisco_debserint; /* debugging flag of cisco hdlc with slarp */ char cisco_debserint; /* debugging flag of cisco hdlc with slarp */
struct timer_list cisco_timer; struct timer_list cisco_timer;
struct isdn_netif_ops *ops; struct isdn_netif_ops *ops;
struct net_device dev; /* interface to upper levels */
} isdn_net_local; } isdn_net_local;
/* the interface itself */ /* the interface itself */
...@@ -397,13 +401,15 @@ typedef struct isdn_net_dev_s { ...@@ -397,13 +401,15 @@ typedef struct isdn_net_dev_s {
/* queued in HL driver */ /* queued in HL driver */
struct tq_struct tqueue; struct tq_struct tqueue;
isdn_net_local *queue; /* circular list of all bundled isdn_net_local *master; /* Ptr to Master device for slaves */
channels, which are currently struct isdn_net_dev_s *slave; /* Ptr to Slave device for masters */
online */
spinlock_t queue_lock; /* lock to protect queue */ struct isdn_net_dev_s *next; /* Ptr to next link in bundle */
struct isdn_net_dev_s *last; /* Ptr to last link in bundle */
char name[10]; /* Name of device */ char name[10]; /* Name of device */
struct list_head global_list; /* global list of all isdn_net_devs */ struct list_head global_list; /* global list of all isdn_net_devs */
struct net_device dev; /* interface to upper levels */
#ifdef CONFIG_ISDN_PPP #ifdef CONFIG_ISDN_PPP
ippp_bundle * pb; /* pointer to the common bundle structure ippp_bundle * pb; /* pointer to the common bundle structure
* with the per-bundle data */ * with the per-bundle data */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment