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)
u32 addr = 0; /* local ipv4 address */
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 */
struct in_ifaddr *ifa = in_dev->ifa_list;
if (ifa != NULL) {
......@@ -337,10 +337,9 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_local *lp, struct sk_buff *skb)
}
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)
{
isdn_net_local *lp = &idev->local;
unsigned char *p;
u8 addr;
u8 ctrl;
......@@ -373,7 +372,7 @@ isdn_ciscohdlck_receive(isdn_net_dev *idev, isdn_net_local *olp,
goto out_free;
default:
/* no special cisco protocol */
isdn_net_reset_huptimer(idev, olp->netdev);
isdn_net_reset_huptimer(lp, idev);
skb->protocol = htons(type);
netif_rx(skb);
return;
......
This diff is collapsed.
......@@ -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 *);
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;
idev2->huptimer = 0;
}
#define ISDN_NET_MAX_QUEUE_LENGTH 2
......@@ -83,76 +83,75 @@ isdn_net_dev_busy(isdn_net_dev *idev)
* corresponding bundle. The returned channel is locked.
*/
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;
isdn_net_local *lp;
isdn_net_dev *idev;
isdn_net_dev *head;
spin_lock_irqsave(&nd->queue_lock, flags);
lp = nd->queue; /* get lp on top of queue */
idev = nd->queue->netdev;
spin_lock_irqsave(&mlp->queue_lock, flags);
head = mlp->queue;
idev = head;
spin_lock_bh(&idev->xmit_lock);
while (isdn_net_dev_busy(idev)) {
spin_unlock_bh(&idev->xmit_lock);
nd->queue = nd->queue->next;
idev = nd->queue->netdev;
if (nd->queue == lp) { /* not found -- should never happen */
lp = NULL;
mlp->queue = mlp->queue->next;
idev = mlp->queue;
if (idev == head) { /* not found -- should never happen */
idev = NULL;
goto errout;
}
spin_lock_bh(&idev->xmit_lock);
}
lp = nd->queue;
nd->queue = nd->queue->next;
idev = mlp->queue;
mlp->queue = mlp->queue->next;
errout:
spin_unlock_irqrestore(&nd->queue_lock, flags);
return lp ? lp->netdev : NULL;
spin_unlock_irqrestore(&mlp->queue_lock, flags);
return idev;
}
/*
* add a channel to a bundle
*/
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;
spin_lock_irqsave(&nd->queue_lock, flags);
spin_lock_irqsave(&mlp->queue_lock, flags);
lp = nd->queue;
nlp->last = lp->last;
lp->last->next = nlp;
lp->last = nlp;
nlp->next = lp;
nd->queue = nlp;
qdev = mlp->queue;
idev->last = qdev->last;
qdev->last->next = idev;
qdev->last = idev;
idev->next = qdev;
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
*/
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;
if (lp->master)
master_lp = (isdn_net_local *) lp->master->priv;
if (idev->master)
mlp = idev->master;
else
mlp = &idev->local;
spin_lock_irqsave(&master_lp->netdev->queue_lock, flags);
lp->last->next = lp->next;
lp->next->last = lp->last;
if (master_lp->netdev->queue == lp) {
master_lp->netdev->queue = lp->next;
if (lp->next == lp) { /* last in queue */
master_lp->netdev->queue = &master_lp->netdev->local;
}
spin_lock_irqsave(&mlp->queue_lock, flags);
idev->last->next = idev->next;
idev->next->last = idev->last;
if (mlp->queue == idev) {
mlp->queue = idev->next;
}
lp->next = lp->last = lp; /* (re)set own pointers */
spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags);
idev->next = idev->last = idev; /* (re)set own pointers */
spin_unlock_irqrestore(&mlp->queue_lock, flags);
}
/*
......@@ -162,12 +161,10 @@ isdn_net_rm_from_bundle(isdn_net_local *lp)
static inline void
isdn_net_dev_wake_queue(isdn_net_dev *idev)
{
isdn_net_local *lp = &idev->local;
if (lp->master)
netif_wake_queue(lp->master);
if (idev->master)
netif_wake_queue(&idev->master->dev);
else
netif_wake_queue(&lp->netdev->dev);
netif_wake_queue(&idev->local.dev);
}
static inline int
......
This diff is collapsed.
......@@ -294,8 +294,8 @@ struct isdn_netif_ops {
unsigned short flags; /* interface flags (a la BSD) */
unsigned short type; /* interface hardware type */
unsigned char addr_len;/* hardware address length */
void (*receive)(struct isdn_net_dev_s *p,
struct isdn_net_local_s *olp,
void (*receive)(struct isdn_net_local_s *lp,
struct isdn_net_dev_s *idev,
struct sk_buff *skb);
void (*connected)(struct isdn_net_local_s *lp);
void (*disconnected)(struct isdn_net_local_s *lp);
......@@ -334,12 +334,13 @@ typedef struct isdn_net_local_s {
struct list_head phone[2]; /* List of remote-phonenumbers */
/* phone[0] = Incoming 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 *queue; /* circular list of all bundled
channels, which are currently
online */
spinlock_t queue_lock; /* lock to protect queue */
#ifdef CONFIG_ISDN_X25
struct concap_device_ops *dops; /* callbacks used by encapsulator */
#endif
......@@ -351,8 +352,11 @@ typedef struct isdn_net_local_s {
ulong cisco_last_slarp_in; /* jiffie of last keepalive packet we received */
char cisco_line_state; /* state of line according to keepalive packets */
char cisco_debserint; /* debugging flag of cisco hdlc with slarp */
struct timer_list cisco_timer;
struct isdn_netif_ops *ops;
struct timer_list cisco_timer;
struct isdn_netif_ops *ops;
struct net_device dev; /* interface to upper levels */
} isdn_net_local;
/* the interface itself */
......@@ -397,13 +401,15 @@ typedef struct isdn_net_dev_s {
/* queued in HL driver */
struct tq_struct tqueue;
isdn_net_local *queue; /* circular list of all bundled
channels, which are currently
online */
spinlock_t queue_lock; /* lock to protect queue */
isdn_net_local *master; /* Ptr to Master device for slaves */
struct isdn_net_dev_s *slave; /* Ptr to Slave device for masters */
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 */
struct list_head global_list; /* global list of all isdn_net_devs */
struct net_device dev; /* interface to upper levels */
#ifdef CONFIG_ISDN_PPP
ippp_bundle * pb; /* pointer to the common bundle structure
* 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