2 * Generic HDLC support routines for Linux
4 * Copyright (C) 1999-2005 Krzysztof Halasa <khc@pm.waw.pl>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation.
15 #define HDLC_MAX_MTU 1500 /* Ethernet 1500 bytes */
17 #define HDLC_MAX_MRU (HDLC_MAX_MTU + 10 + 14 + 4) /* for ETH+VLAN over FR */
19 #define HDLC_MAX_MRU 1600 /* as required for FR network */
25 #include <linux/skbuff.h>
26 #include <linux/netdevice.h>
27 #include <linux/hdlc/ioctl.h>
29 /* This structure is a private property of HDLC protocols.
30 Hardware drivers have no interest here */
33 int (*open
)(struct net_device
*dev
);
34 void (*close
)(struct net_device
*dev
);
35 void (*start
)(struct net_device
*dev
); /* if open & DCD */
36 void (*stop
)(struct net_device
*dev
); /* if open & !DCD */
37 void (*detach
)(struct net_device
*dev
);
38 int (*ioctl
)(struct net_device
*dev
, struct ifreq
*ifr
);
39 __be16 (*type_trans
)(struct sk_buff
*skb
, struct net_device
*dev
);
40 int (*netif_rx
)(struct sk_buff
*skb
);
41 netdev_tx_t (*xmit
)(struct sk_buff
*skb
, struct net_device
*dev
);
42 struct module
*module
;
43 struct hdlc_proto
*next
; /* next protocol in the list */
47 /* Pointed to by netdev_priv(dev) */
48 typedef struct hdlc_device
{
49 /* used by HDLC layer to take control over HDLC device from hw driver*/
50 int (*attach
)(struct net_device
*dev
,
51 unsigned short encoding
, unsigned short parity
);
53 /* hardware driver must handle this instead of dev->hard_start_xmit */
54 netdev_tx_t (*xmit
)(struct sk_buff
*skb
, struct net_device
*dev
);
56 /* Things below are for HDLC layer internal use only */
57 const struct hdlc_proto
*proto
;
60 spinlock_t state_lock
;
67 /* Exported from hdlc module */
69 /* Called by hardware driver when a user requests HDLC service */
70 int hdlc_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
);
72 /* Must be used by hardware driver on module startup/exit */
73 #define register_hdlc_device(dev) register_netdev(dev)
74 void unregister_hdlc_device(struct net_device
*dev
);
77 void register_hdlc_protocol(struct hdlc_proto
*proto
);
78 void unregister_hdlc_protocol(struct hdlc_proto
*proto
);
80 struct net_device
*alloc_hdlcdev(void *priv
);
82 static inline struct hdlc_device
* dev_to_hdlc(struct net_device
*dev
)
84 return netdev_priv(dev
);
87 static __inline__
void debug_frame(const struct sk_buff
*skb
)
91 for (i
=0; i
< skb
->len
; i
++) {
96 printk(" %02X", skb
->data
[i
]);
102 /* Must be called by hardware driver when HDLC device is being opened */
103 int hdlc_open(struct net_device
*dev
);
104 /* Must be called by hardware driver when HDLC device is being closed */
105 void hdlc_close(struct net_device
*dev
);
106 /* May be used by hardware driver */
107 int hdlc_change_mtu(struct net_device
*dev
, int new_mtu
);
108 /* Must be pointed to by hw driver's dev->netdev_ops->ndo_start_xmit */
109 netdev_tx_t
hdlc_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
111 int attach_hdlc_protocol(struct net_device
*dev
, struct hdlc_proto
*proto
,
113 /* May be used by hardware driver to gain control over HDLC device */
114 void detach_hdlc_protocol(struct net_device
*dev
);
116 static __inline__ __be16
hdlc_type_trans(struct sk_buff
*skb
,
117 struct net_device
*dev
)
119 hdlc_device
*hdlc
= dev_to_hdlc(dev
);
122 skb_reset_mac_header(skb
);
124 if (hdlc
->proto
->type_trans
)
125 return hdlc
->proto
->type_trans(skb
, dev
);
127 return htons(ETH_P_HDLC
);
130 #endif /* __KERNEL */
131 #endif /* __HDLC_H */
This page took 0.032229 seconds and 5 git commands to generate.