Commit e2d5b146 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Make hard_start_xmit() device type specific

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
parent 78032727
...@@ -406,6 +406,7 @@ isdn_ciscohdlck_header(struct sk_buff *skb, struct net_device *dev, ...@@ -406,6 +406,7 @@ isdn_ciscohdlck_header(struct sk_buff *skb, struct net_device *dev,
} }
struct isdn_netif_ops ciscohdlck_ops = { struct isdn_netif_ops ciscohdlck_ops = {
.hard_start_xmit = isdn_net_start_xmit,
.hard_header = isdn_ciscohdlck_header, .hard_header = isdn_ciscohdlck_header,
.do_ioctl = isdn_ciscohdlck_dev_ioctl, .do_ioctl = isdn_ciscohdlck_dev_ioctl,
.flags = IFF_NOARP | IFF_POINTOPOINT, .flags = IFF_NOARP | IFF_POINTOPOINT,
......
...@@ -39,7 +39,8 @@ ...@@ -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; struct net_device *ndev = concap -> net_dev;
isdn_net_dev *nd = ((isdn_net_local *) ndev->priv)->netdev; 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) ...@@ -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; struct net_device *ndev = concap -> net_dev;
isdn_net_local *lp = (isdn_net_local *) ndev->priv; isdn_net_local *lp = (isdn_net_local *) ndev->priv;
...@@ -71,7 +73,8 @@ int isdn_concap_dl_connect_req(struct concap_proto *concap) ...@@ -71,7 +73,8 @@ int isdn_concap_dl_connect_req(struct concap_proto *concap)
return ret; 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); 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 = { ...@@ -98,7 +101,8 @@ struct concap_device_ops isdn_concap_demand_dial_dops = {
this sourcefile does not need to include any protocol specific header this sourcefile does not need to include any protocol specific header
files. For now: files. For now:
*/ */
struct concap_proto * isdn_concap_new( int encap ) struct concap_proto *
isdn_concap_new( int encap )
{ {
switch ( encap ) { switch ( encap ) {
case ISDN_NET_ENCAP_X25IFACE: case ISDN_NET_ENCAP_X25IFACE:
...@@ -158,7 +162,7 @@ isdn_x25_disconnected(isdn_net_local *lp) ...@@ -158,7 +162,7 @@ isdn_x25_disconnected(isdn_net_local *lp)
pops -> disconn_ind(cprot); pops -> disconn_ind(cprot);
} }
int static int
isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev) isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
/* At this point hard_start_xmit() passes control to the encapsulation /* At this point hard_start_xmit() passes control to the encapsulation
...@@ -237,13 +241,8 @@ isdn_x25_cleanup(isdn_net_dev *p) ...@@ -237,13 +241,8 @@ isdn_x25_cleanup(isdn_net_dev *p)
restore_flags(flags); 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 = { struct isdn_netif_ops isdn_x25_ops = {
.hard_start_xmit = isdn_x25_start_xmit,
.flags = IFF_NOARP | IFF_POINTOPOINT, .flags = IFF_NOARP | IFF_POINTOPOINT,
.type = ARPHRD_X25, .type = ARPHRD_X25,
.receive = isdn_x25_receive, .receive = isdn_x25_receive,
......
...@@ -12,18 +12,4 @@ extern struct concap_device_ops isdn_concap_demand_dial_dops; ...@@ -12,18 +12,4 @@ extern struct concap_device_ops isdn_concap_demand_dial_dops;
struct concap_proto *isdn_concap_new(int); struct concap_proto *isdn_concap_new(int);
#ifdef CONFIG_ISDN_X25
extern struct isdn_netif_ops isdn_x25_ops; 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
...@@ -194,7 +194,6 @@ int isdn_net_online(isdn_net_dev *idev) ...@@ -194,7 +194,6 @@ int isdn_net_online(isdn_net_dev *idev)
/* Prototypes */ /* Prototypes */
static int isdn_net_force_dial_idev(isdn_net_dev *); 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 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_handle_event(isdn_net_dev *idev, int pr, void *arg);
static int isdn_net_set_encap(isdn_net_local *mlp, int encap); 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) ...@@ -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. * Based on cps-calculation, check if device is overloaded.
* If so, and if a slave exists, trigger dialing for it. * If so, and if a slave exists, trigger dialing for it.
* If any slave is online, deliver packets using a simple round robin * 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) ...@@ -908,8 +905,8 @@ void isdn_net_writebuf_skb(isdn_net_dev *idev, struct sk_buff *skb)
* Return: 0 on success, !0 on failure. * Return: 0 on success, !0 on failure.
*/ */
static int int
isdn_net_xmit(struct net_device *ndev, struct sk_buff *skb) isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
{ {
isdn_net_dev *idev, *sdev; isdn_net_dev *idev, *sdev;
isdn_net_local *mlp = ndev->priv; isdn_net_local *mlp = ndev->priv;
...@@ -919,10 +916,6 @@ isdn_net_xmit(struct net_device *ndev, struct sk_buff *skb) ...@@ -919,10 +916,6 @@ isdn_net_xmit(struct net_device *ndev, struct sk_buff *skb)
if (list_empty(&mlp->online)) if (list_empty(&mlp->online))
return isdn_net_autodial(skb, ndev); 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); idev = isdn_net_get_locked_dev(mlp);
if (!idev) { if (!idev) {
printk(KERN_WARNING "%s: all channels busy - requeuing!\n", ndev->name); 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) ...@@ -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. * Shutdown a net-interface.
*/ */
...@@ -1131,7 +1106,6 @@ isdn_net_init(struct net_device *ndev) ...@@ -1131,7 +1106,6 @@ isdn_net_init(struct net_device *ndev)
ndev->mtu = 1500; ndev->mtu = 1500;
ndev->tx_queue_len = 10; ndev->tx_queue_len = 10;
ndev->open = &isdn_net_open; ndev->open = &isdn_net_open;
ndev->hard_start_xmit = &isdn_net_start_xmit;
ndev->hard_header_len = ETH_HLEN + isdn_hard_header_len(); ndev->hard_header_len = ETH_HLEN + isdn_hard_header_len();
ndev->stop = &isdn_net_close; ndev->stop = &isdn_net_close;
ndev->get_stats = &isdn_net_get_stats; ndev->get_stats = &isdn_net_get_stats;
...@@ -1588,6 +1562,7 @@ isdn_net_set_encap(isdn_net_local *lp, int encap) ...@@ -1588,6 +1562,7 @@ isdn_net_set_encap(isdn_net_local *lp, int encap)
lp->p_encap = encap; lp->p_encap = encap;
lp->ops = netif_ops[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.hard_header = lp->ops->hard_header;
lp->dev.do_ioctl = lp->ops->do_ioctl; lp->dev.do_ioctl = lp->ops->do_ioctl;
lp->dev.flags = lp->ops->flags; lp->dev.flags = lp->ops->flags;
...@@ -2112,6 +2087,7 @@ isdn_iptyp_receive(isdn_net_local *lp, isdn_net_dev *idev, ...@@ -2112,6 +2087,7 @@ isdn_iptyp_receive(isdn_net_local *lp, isdn_net_dev *idev,
} }
static struct isdn_netif_ops iptyp_ops = { static struct isdn_netif_ops iptyp_ops = {
.hard_start_xmit = isdn_net_start_xmit,
.hard_header = isdn_iptyp_header, .hard_header = isdn_iptyp_header,
.flags = IFF_NOARP | IFF_POINTOPOINT, .flags = IFF_NOARP | IFF_POINTOPOINT,
.type = ARPHRD_PPP, .type = ARPHRD_PPP,
...@@ -2143,6 +2119,7 @@ isdn_uihdlc_receive(isdn_net_local *lp, isdn_net_dev *idev, ...@@ -2143,6 +2119,7 @@ isdn_uihdlc_receive(isdn_net_local *lp, isdn_net_dev *idev,
} }
static struct isdn_netif_ops uihdlc_ops = { static struct isdn_netif_ops uihdlc_ops = {
.hard_start_xmit = isdn_net_start_xmit,
.hard_header = isdn_uihdlc_header, .hard_header = isdn_uihdlc_header,
.flags = IFF_NOARP | IFF_POINTOPOINT, .flags = IFF_NOARP | IFF_POINTOPOINT,
.type = ARPHRD_HDLC, .type = ARPHRD_HDLC,
...@@ -2164,6 +2141,7 @@ isdn_rawip_receive(isdn_net_local *lp, isdn_net_dev *idev, ...@@ -2164,6 +2141,7 @@ isdn_rawip_receive(isdn_net_local *lp, isdn_net_dev *idev,
} }
static struct isdn_netif_ops rawip_ops = { static struct isdn_netif_ops rawip_ops = {
.hard_start_xmit = isdn_net_start_xmit,
.flags = IFF_NOARP | IFF_POINTOPOINT, .flags = IFF_NOARP | IFF_POINTOPOINT,
.type = ARPHRD_PPP, .type = ARPHRD_PPP,
.receive = isdn_rawip_receive, .receive = isdn_rawip_receive,
...@@ -2215,6 +2193,7 @@ isdn_ether_init(isdn_net_local *lp) ...@@ -2215,6 +2193,7 @@ isdn_ether_init(isdn_net_local *lp)
} }
static struct isdn_netif_ops ether_ops = { static struct isdn_netif_ops ether_ops = {
.hard_start_xmit = isdn_net_start_xmit,
.hard_header = eth_header, .hard_header = eth_header,
.receive = isdn_ether_receive, .receive = isdn_ether_receive,
.init = isdn_ether_init, .init = isdn_ether_init,
......
...@@ -57,6 +57,7 @@ extern void isdn_net_writebuf_skb(isdn_net_dev *, struct sk_buff *skb); ...@@ -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 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 *);
extern int isdn_net_autodial(struct sk_buff *skb, struct net_device *ndev); 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 #define ISDN_NET_MAX_QUEUE_LENGTH 2
......
...@@ -1112,10 +1112,10 @@ static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p,int len) ...@@ -1112,10 +1112,10 @@ static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p,int len)
* skb isn't allowed!! * skb isn't allowed!!
*/ */
int static int
isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) 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); isdn_net_dev *idev = list_entry(mlp->online.next, isdn_net_dev, online);
unsigned int proto = PPP_IP; /* 0x21 */ unsigned int proto = PPP_IP; /* 0x21 */
struct ippp_struct *ipt,*ipts; struct ippp_struct *ipt,*ipts;
...@@ -1137,7 +1137,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) ...@@ -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->pppcfg & SC_ENABLE_IP)) { /* PPP connected ? */
if (ipts->debug & 0x1) 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); netif_stop_queue(ndev);
return 1; return 1;
} }
...@@ -1158,7 +1158,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) ...@@ -1158,7 +1158,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
idev = isdn_net_get_locked_dev(mlp); idev = isdn_net_get_locked_dev(mlp);
if (!idev) { 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); netif_stop_queue(ndev);
return 1; return 1;
} }
...@@ -2816,6 +2816,7 @@ isdn_ppp_header(struct sk_buff *skb, struct net_device *dev, ...@@ -2816,6 +2816,7 @@ isdn_ppp_header(struct sk_buff *skb, struct net_device *dev,
} }
struct isdn_netif_ops isdn_ppp_ops = { struct isdn_netif_ops isdn_ppp_ops = {
.hard_start_xmit = isdn_ppp_start_xmit,
.hard_header = isdn_ppp_header, .hard_header = isdn_ppp_header,
.do_ioctl = isdn_ppp_dev_ioctl, .do_ioctl = isdn_ppp_dev_ioctl,
.flags = IFF_NOARP | IFF_POINTOPOINT, .flags = IFF_NOARP | IFF_POINTOPOINT,
......
...@@ -20,20 +20,6 @@ extern void isdn_ppp_cleanup(void); ...@@ -20,20 +20,6 @@ extern void isdn_ppp_cleanup(void);
extern int isdn_ppp_dial_slave(char *); extern int isdn_ppp_dial_slave(char *);
extern int isdn_ppp_hangup_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_OPEN 0x01
#define IPPP_CONNECT 0x02 #define IPPP_CONNECT 0x02
#define IPPP_CLOSEWAIT 0x04 #define IPPP_CLOSEWAIT 0x04
......
...@@ -282,6 +282,8 @@ struct isdn_net_dev_s; ...@@ -282,6 +282,8 @@ struct isdn_net_dev_s;
struct isdn_net_local_s; struct isdn_net_local_s;
struct isdn_netif_ops { struct isdn_netif_ops {
int (*hard_start_xmit) (struct sk_buff *skb,
struct net_device *dev);
int (*hard_header) (struct sk_buff *skb, int (*hard_header) (struct sk_buff *skb,
struct net_device *dev, struct net_device *dev,
unsigned short type, unsigned short type,
......
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