]> git.neil.brown.name Git - history.git/commitdiff
ISDN: Make hard_start_xmit() device type specific
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Thu, 3 Oct 2002 16:01:34 +0000 (11:01 -0500)
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Thu, 3 Oct 2002 16:01:34 +0000 (11:01 -0500)
One goal is now achieved: Different types of ISDN net devices now have
a struct ops which describes them, so we don't have a mess of
if (lp->p_encap == <whatever>) everywhere, but things even nicely
split into

isdn_net.c: Common stuff and ethernet, raw-ip, and similar
isdn_ciscohdlck.c: Cisco HDLC + keepalive
isdn_ppp.c: Sync PPP

where common code to be used library-like is provided by isdn_net.c

drivers/isdn/i4l/isdn_ciscohdlck.c
drivers/isdn/i4l/isdn_concap.c
drivers/isdn/i4l/isdn_concap.h
drivers/isdn/i4l/isdn_net.c
drivers/isdn/i4l/isdn_net.h
drivers/isdn/i4l/isdn_ppp.c
drivers/isdn/i4l/isdn_ppp.h
include/linux/isdn.h

index 204d30b4d9bddb273bd7979998da49f4812f7958..0f08f3daea882fae4edda6bda4785401bd3465ff 100644 (file)
@@ -406,6 +406,7 @@ isdn_ciscohdlck_header(struct sk_buff *skb, struct net_device *dev,
 }
 
 struct isdn_netif_ops ciscohdlck_ops = {
+       .hard_start_xmit     = isdn_net_start_xmit,
        .hard_header         = isdn_ciscohdlck_header,
        .do_ioctl            = isdn_ciscohdlck_dev_ioctl,
        .flags               = IFF_NOARP | IFF_POINTOPOINT,
index e325ce283ceac2ec22d82754485deaa10b8cbab8..c7db6ce748435984a954ccf9df257a9c3a41d780 100644 (file)
@@ -39,7 +39,8 @@
    */
 
 
-int isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb)
+static int
+isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb)
 {
        struct net_device *ndev = concap -> net_dev;
        isdn_net_dev *nd = ((isdn_net_local *) ndev->priv)->netdev;
@@ -58,7 +59,8 @@ int isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb)
 }
 
 
-int isdn_concap_dl_connect_req(struct concap_proto *concap)
+static int
+isdn_concap_dl_connect_req(struct concap_proto *concap)
 {
        struct net_device *ndev = concap -> net_dev;
        isdn_net_local *lp = (isdn_net_local *) ndev->priv;
@@ -71,7 +73,8 @@ int isdn_concap_dl_connect_req(struct concap_proto *concap)
        return ret;
 }
 
-int isdn_concap_dl_disconn_req(struct concap_proto *concap)
+static int
+isdn_concap_dl_disconn_req(struct concap_proto *concap)
 {
        IX25DEBUG( "isdn_concap_dl_disconn_req: %s \n", concap -> net_dev -> name);
 
@@ -98,7 +101,8 @@ struct concap_device_ops isdn_concap_demand_dial_dops = {
    this sourcefile does not need to include any protocol specific header
    files. For now:
    */
-struct concap_proto * isdn_concap_new( int encap )
+struct concap_proto *
+isdn_concap_new( int encap )
 {
        switch ( encap ) {
        case ISDN_NET_ENCAP_X25IFACE:
@@ -158,7 +162,7 @@ isdn_x25_disconnected(isdn_net_local *lp)
                pops -> disconn_ind(cprot);
 }
 
-int
+static int
 isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 /* At this point hard_start_xmit() passes control to the encapsulation
@@ -237,13 +241,8 @@ isdn_x25_cleanup(isdn_net_dev *p)
        restore_flags(flags);
 }
 
-void isdn_x25_realrm(isdn_net_dev *p)
-{
-       if( p -> cprot && p -> cprot -> pops )
-               p -> cprot -> pops -> proto_del ( p -> cprot );
-}
-
 struct isdn_netif_ops isdn_x25_ops = {
+       .hard_start_xmit     = isdn_x25_start_xmit,
        .flags               = IFF_NOARP | IFF_POINTOPOINT,
        .type                = ARPHRD_X25,
        .receive             = isdn_x25_receive,
index 94c7c83374cbf588d5673e46b9d4c0ee29c01c64..8150d6f595e03f86f3b9268dbc29f6a8b2b798fd 100644 (file)
@@ -12,18 +12,4 @@ extern struct concap_device_ops isdn_concap_demand_dial_dops;
 
 struct concap_proto *isdn_concap_new(int);
 
-#ifdef CONFIG_ISDN_X25
-
 extern struct isdn_netif_ops isdn_x25_ops;
-
-int  isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev);
-
-#else
-
-static inline int
-isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-       return 0;
-}
-
-#endif
index 935bb3154055e7702a33982a9e5a5781e6b40ca6..fb07f6bbd7015f3bad503866dff7244d2b42ec2d 100644 (file)
@@ -194,7 +194,6 @@ int isdn_net_online(isdn_net_dev *idev)
 /* Prototypes */
 
 static int isdn_net_force_dial_idev(isdn_net_dev *);
-static int isdn_net_start_xmit(struct sk_buff *, struct net_device *);
 static void do_dialout(isdn_net_dev *idev);
 static int isdn_net_handle_event(isdn_net_dev *idev, int pr, void *arg);
 static int isdn_net_set_encap(isdn_net_local *mlp, int encap);
@@ -898,8 +897,6 @@ void isdn_net_writebuf_skb(isdn_net_dev *idev, struct sk_buff *skb)
 
 
 /*
- *  Helper function for isdn_net_start_xmit.
- *  When called, the connection is already established.
  *  Based on cps-calculation, check if device is overloaded.
  *  If so, and if a slave exists, trigger dialing for it.
  *  If any slave is online, deliver packets using a simple round robin
@@ -908,8 +905,8 @@ void isdn_net_writebuf_skb(isdn_net_dev *idev, struct sk_buff *skb)
  *  Return: 0 on success, !0 on failure.
  */
 
-static int
-isdn_net_xmit(struct net_device *ndev, struct sk_buff *skb)
+int
+isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 {
        isdn_net_dev *idev, *sdev;
        isdn_net_local *mlp = ndev->priv;
@@ -919,10 +916,6 @@ isdn_net_xmit(struct net_device *ndev, struct sk_buff *skb)
        if (list_empty(&mlp->online))
                return isdn_net_autodial(skb, ndev);
 
-       /* For the other encaps the header has already been built */
-       if (mlp->p_encap == ISDN_NET_ENCAP_SYNCPPP) {
-               return isdn_ppp_xmit(skb, ndev);
-       }
        idev = isdn_net_get_locked_dev(mlp);
        if (!idev) {
                printk(KERN_WARNING "%s: all channels busy - requeuing!\n", ndev->name);
@@ -1029,24 +1022,6 @@ isdn_net_autodial(struct sk_buff *skb, struct net_device *ndev)
 }
 
 
-/*
- * Try sending a packet.
- * If this interface isn't connected to a ISDN-Channel, find a free channel,
- * and start dialing.
- */
-static int
-isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
-{
-       if (mlp->p_encap == ISDN_NET_ENCAP_X25IFACE)
-               return isdn_x25_start_xmit(skb, ndev);
-               
-       /* ISDN connection is established, try sending */
-       if (mlp->p_encap == ISDN_NET_ENCAP_SYNCPPP)
-               return isdn_ppp_xmit(skb, ndev);
-
-       return isdn_net_xmit(skb, ndev);
-}
-
 /*
  * Shutdown a net-interface.
  */
@@ -1131,7 +1106,6 @@ isdn_net_init(struct net_device *ndev)
        ndev->mtu = 1500;
        ndev->tx_queue_len = 10;
        ndev->open = &isdn_net_open;
-       ndev->hard_start_xmit = &isdn_net_start_xmit;
        ndev->hard_header_len = ETH_HLEN + isdn_hard_header_len();
        ndev->stop = &isdn_net_close;
        ndev->get_stats = &isdn_net_get_stats;
@@ -1588,6 +1562,7 @@ isdn_net_set_encap(isdn_net_local *lp, int encap)
        lp->p_encap = encap;
        lp->ops = netif_ops[encap];
 
+       lp->dev.hard_start_xmit     = lp->ops->hard_start_xmit;
        lp->dev.hard_header         = lp->ops->hard_header;
        lp->dev.do_ioctl            = lp->ops->do_ioctl;
        lp->dev.flags               = lp->ops->flags;
@@ -2112,6 +2087,7 @@ isdn_iptyp_receive(isdn_net_local *lp, isdn_net_dev *idev,
 }
 
 static struct isdn_netif_ops iptyp_ops = {
+       .hard_start_xmit     = isdn_net_start_xmit,
        .hard_header         = isdn_iptyp_header,
        .flags               = IFF_NOARP | IFF_POINTOPOINT,
        .type                = ARPHRD_PPP,
@@ -2143,6 +2119,7 @@ isdn_uihdlc_receive(isdn_net_local *lp, isdn_net_dev *idev,
 }
 
 static struct isdn_netif_ops uihdlc_ops = {
+       .hard_start_xmit     = isdn_net_start_xmit,
        .hard_header         = isdn_uihdlc_header,
        .flags               = IFF_NOARP | IFF_POINTOPOINT,
        .type                = ARPHRD_HDLC,
@@ -2164,6 +2141,7 @@ isdn_rawip_receive(isdn_net_local *lp, isdn_net_dev *idev,
 }
 
 static struct isdn_netif_ops rawip_ops = {
+       .hard_start_xmit     = isdn_net_start_xmit,
        .flags               = IFF_NOARP | IFF_POINTOPOINT,
        .type                = ARPHRD_PPP,
        .receive             = isdn_rawip_receive,
@@ -2215,6 +2193,7 @@ isdn_ether_init(isdn_net_local *lp)
 }
 
 static struct isdn_netif_ops ether_ops = {
+       .hard_start_xmit     = isdn_net_start_xmit,
        .hard_header         = eth_header,
        .receive             = isdn_ether_receive,
        .init                = isdn_ether_init,
index 8131bf9076c98f99bcf34f848b0480758ffb30e8..a4d898f749978d7bc1888154593a60eaa950c5ff 100644 (file)
@@ -57,6 +57,7 @@ extern void isdn_net_writebuf_skb(isdn_net_dev *, struct sk_buff *skb);
 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_autodial(struct sk_buff *skb, struct net_device *ndev);
+extern int isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev);
 
 #define ISDN_NET_MAX_QUEUE_LENGTH 2
 
index 3f985e411a8ab0209487a2237a0527652d26163b..3c59a373459bc66ad1f69714080adaa235e5b161 100644 (file)
@@ -1112,10 +1112,10 @@ static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p,int len)
  * skb isn't allowed!!
  */
 
-int
-isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
+static int
+isdn_ppp_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 {
-       isdn_net_local *mlp = netdev->priv;
+       isdn_net_local *mlp = ndev->priv;
        isdn_net_dev *idev = list_entry(mlp->online.next, isdn_net_dev, online);
        unsigned int proto = PPP_IP;     /* 0x21 */
        struct ippp_struct *ipt,*ipts;
@@ -1137,7 +1137,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
 
        if (!(ipts->pppcfg & SC_ENABLE_IP)) {   /* PPP connected ? */
                if (ipts->debug & 0x1)
-                       printk(KERN_INFO "%s: IP frame delayed.\n", netdev->name);
+                       printk(KERN_INFO "%s: IP frame delayed.\n", ndev->name);
                netif_stop_queue(ndev);
                return 1;
        }
@@ -1158,7 +1158,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
 
        idev = isdn_net_get_locked_dev(mlp);
        if (!idev) {
-               printk(KERN_WARNING "%s: all channels busy - requeuing!\n", netdev->name);
+               printk(KERN_WARNING "%s: all channels busy - requeuing!\n", ndev->name);
                netif_stop_queue(ndev);
                return 1;
        }
@@ -2816,6 +2816,7 @@ isdn_ppp_header(struct sk_buff *skb, struct net_device *dev,
 }
 
 struct isdn_netif_ops isdn_ppp_ops = {
+       .hard_start_xmit     = isdn_ppp_start_xmit,
        .hard_header         = isdn_ppp_header,
        .do_ioctl            = isdn_ppp_dev_ioctl,
        .flags               = IFF_NOARP | IFF_POINTOPOINT,
index c62028ce50ef732e8a3452787c94acb10460504f..af6f50fd11dbdb33a87a226aa9d1c6995ae81344 100644 (file)
@@ -20,20 +20,6 @@ extern void isdn_ppp_cleanup(void);
 extern int isdn_ppp_dial_slave(char *);
 extern int isdn_ppp_hangup_slave(char *);
 
-#ifdef CONFIG_ISDN_PPP
-
-int  isdn_ppp_xmit(struct sk_buff *, struct net_device *);
-
-#else
-
-static inline int
-isdn_ppp_xmit(struct sk_buff *, struct net_device *);
-{
-       return 0;
-}
-
-#endif
-
 #define IPPP_OPEN      0x01
 #define IPPP_CONNECT   0x02
 #define IPPP_CLOSEWAIT 0x04
index 1d255e01fbad9070c086a37c51a83a3d8dcda25c..e1d2a910400c692e61c9db7c4d685e64672592c6 100644 (file)
@@ -282,6 +282,8 @@ struct isdn_net_dev_s;
 struct isdn_net_local_s;
 
 struct isdn_netif_ops {
+       int                     (*hard_start_xmit) (struct sk_buff *skb,
+                                                   struct net_device *dev);
        int                     (*hard_header) (struct sk_buff *skb,
                                                struct net_device *dev,
                                                unsigned short type,