patch-2.4.25 linux-2.4.25/drivers/net/wan/hdlc_fr.c

Next file: linux-2.4.25/drivers/net/wan/hdlc_generic.c
Previous file: linux-2.4.25/drivers/net/wan/hdlc_cisco.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.24/drivers/net/wan/hdlc_fr.c linux-2.4.25/drivers/net/wan/hdlc_fr.c
@@ -19,7 +19,6 @@
              -> 1 when "PVC up" and (exist,new) = 1,0
 */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
@@ -36,12 +35,95 @@
 #include <linux/etherdevice.h>
 #include <linux/hdlc.h>
 
+#undef DEBUG_PKT
+#undef DEBUG_ECN
 
-__inline__ pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci)
+#define MAXLEN_LMISTAT  20	/* max size of status enquiry frame */
+
+#define PVC_STATE_NEW	 0x01
+#define PVC_STATE_ACTIVE 0x02
+#define PVC_STATE_FECN	 0x08 /* FECN condition */
+#define PVC_STATE_BECN	 0x10 /* BECN condition */
+
+
+#define FR_UI		 0x03
+#define FR_PAD		 0x00
+
+#define NLPID_IP	 0xCC
+#define NLPID_IPV6	 0x8E
+#define NLPID_SNAP	 0x80
+#define NLPID_PAD	 0x00
+#define NLPID_Q933	 0x08
+
+
+#define LMI_DLCI                   0 /* LMI DLCI */
+#define LMI_PROTO               0x08
+#define LMI_CALLREF             0x00 /* Call Reference */
+#define LMI_ANSI_LOCKSHIFT      0x95 /* ANSI lockshift */
+#define LMI_REPTYPE                1 /* report type */
+#define LMI_CCITT_REPTYPE       0x51
+#define LMI_ALIVE                  3 /* keep alive */
+#define LMI_CCITT_ALIVE         0x53
+#define LMI_PVCSTAT                7 /* pvc status */
+#define LMI_CCITT_PVCSTAT       0x57
+#define LMI_FULLREP                0 /* full report  */
+#define LMI_INTEGRITY              1 /* link integrity report */
+#define LMI_SINGLE                 2 /* single pvc report */
+#define LMI_STATUS_ENQUIRY      0x75
+#define LMI_STATUS              0x7D /* reply */
+
+#define LMI_REPT_LEN               1 /* report type element length */
+#define LMI_INTEG_LEN              2 /* link integrity element length */
+
+#define LMI_LENGTH                13 /* standard LMI frame length */
+#define LMI_ANSI_LENGTH           14
+
+
+typedef struct {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+	unsigned ea1:	1;
+	unsigned cr:	1;
+	unsigned dlcih:	6;
+  
+	unsigned ea2:	1;
+	unsigned de:	1;
+	unsigned becn:	1;
+	unsigned fecn:	1;
+	unsigned dlcil:	4;
+#else
+	unsigned dlcih:	6;
+	unsigned cr:	1;
+	unsigned ea1:	1;
+
+	unsigned dlcil:	4;
+	unsigned fecn:	1;
+	unsigned becn:	1;
+	unsigned de:	1;
+	unsigned ea2:	1;
+#endif
+}__attribute__ ((packed)) fr_hdr;
+
+
+static inline u16 q922_to_dlci(u8 *hdr)
+{
+	return ((hdr[0] & 0xFC) << 2) | ((hdr[1] & 0xF0) >> 4);
+}
+
+
+
+static inline void dlci_to_q922(u8 *hdr, u16 dlci)
+{
+	hdr[0] = (dlci >> 2) & 0xFC;
+	hdr[1] = ((dlci << 4) & 0xF0) | 0x01;
+}
+
+
+
+static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci)
 {
 	pvc_device *pvc = hdlc->state.fr.first_pvc;
 
-	while(pvc) {
+	while (pvc) {
 		if (pvc->dlci == dlci)
 			return pvc;
 		if (pvc->dlci > dlci)
@@ -53,15 +135,15 @@
 }
 
 
-__inline__ pvc_device* add_pvc(hdlc_device *hdlc, u16 dlci)
+static inline pvc_device* add_pvc(hdlc_device *hdlc, u16 dlci)
 {
 	pvc_device *pvc, **pvc_p = &hdlc->state.fr.first_pvc;
 
-	while(*pvc_p) {
+	while (*pvc_p) {
 		if ((*pvc_p)->dlci == dlci)
 			return *pvc_p;
 		if ((*pvc_p)->dlci > dlci)
-			break;	/* the listed is sorted */
+			break;	/* the list is sorted */
 		pvc_p = &(*pvc_p)->next;
 	}
 
@@ -78,17 +160,17 @@
 }
 
 
-__inline__ int pvc_is_used(pvc_device *pvc)
+static inline int pvc_is_used(pvc_device *pvc)
 {
 	return pvc->main != NULL || pvc->ether != NULL;
 }
 
 
-__inline__ void delete_unused_pvcs(hdlc_device *hdlc)
+static inline void delete_unused_pvcs(hdlc_device *hdlc)
 {
 	pvc_device **pvc_p = &hdlc->state.fr.first_pvc;
 
-	while(*pvc_p) {
+	while (*pvc_p) {
 		if (!pvc_is_used(*pvc_p)) {
 			pvc_device *pvc = *pvc_p;
 			*pvc_p = pvc->next;
@@ -100,7 +182,7 @@
 }
 
 
-__inline__ struct net_device** get_dev_p(pvc_device *pvc, int type)
+static inline struct net_device** get_dev_p(pvc_device *pvc, int type)
 {
 	if (type == ARPHRD_ETHER)
 		return &pvc->ether;
@@ -109,20 +191,19 @@
 }
 
 
-__inline__ u16 status_to_dlci(u8 *status, int *active, int *new)
+static inline u16 status_to_dlci(u8 *status, int *active, int *new)
 {
 	*new = (status[2] & 0x08) ? 1 : 0;
 	*active = (status[2] & 0x02) ? 1 : 0;
 
-	return ((status[0] & 0x3F)<<4) | ((status[1] & 0x78)>>3);
+	return ((status[0] & 0x3F) << 4) | ((status[1] & 0x78) >> 3);
 }
 
 
-__inline__ void dlci_to_status(u16 dlci, u8 *status,
-			       int active, int new)
+static inline void dlci_to_status(u16 dlci, u8 *status, int active, int new)
 {
-	status[0] = (dlci>>4) & 0x3F;
-	status[1] = ((dlci<<3) & 0x78) | 0x80;
+	status[0] = (dlci >> 4) & 0x3F;
+	status[1] = ((dlci << 3) & 0x78) | 0x80;
 	status[2] = 0x80;
 
 	if (new)
@@ -138,7 +219,7 @@
 	u16 head_len;
 	struct sk_buff *skb = *skb_p;
 
-	switch(skb->protocol) {
+	switch (skb->protocol) {
 	case __constant_ntohs(ETH_P_IP):
 		head_len = 4;
 		skb_push(skb, head_len);
@@ -260,7 +341,7 @@
 }
 
 
-__inline__ struct net_device_stats *pvc_get_stats(struct net_device *dev)
+static inline struct net_device_stats *pvc_get_stats(struct net_device *dev)
 {
 	return (struct net_device_stats *)
 		((char *)dev + sizeof(struct net_device));
@@ -632,8 +713,7 @@
 			pvc->state.exist = 1;
 			pvc->state.deleted = 0;
 			if (active != pvc->state.active ||
-			    new != pvc->state.new ||
-			    !pvc->state.exist) {
+			    new != pvc->state.new) {
 				pvc->state.new = new;
 				pvc->state.active = active;
 				fr_log_dlci_active(pvc);
@@ -699,7 +779,7 @@
 
 	pvc = find_pvc(hdlc, dlci);
 	if (!pvc) {
-#ifdef CONFIG_HDLC_DEBUG_PKT
+#ifdef DEBUG_PKT
 		printk(KERN_INFO "%s: No PVC for received frame's DLCI %d\n",
 		       hdlc_to_name(hdlc), dlci);
 #endif
@@ -708,7 +788,7 @@
 	}
 
 	if (pvc->state.fecn != fh->fecn) {
-#ifdef CONFIG_HDLC_DEBUG_ECN
+#ifdef DEBUG_ECN
 		printk(KERN_DEBUG "%s: DLCI %d FECN O%s\n", hdlc_to_name(pvc),
 		       dlci, fh->fecn ? "N" : "FF");
 #endif
@@ -716,7 +796,7 @@
 	}
 
 	if (pvc->state.becn != fh->becn) {
-#ifdef CONFIG_HDLC_DEBUG_ECN
+#ifdef DEBUG_ECN
 		printk(KERN_DEBUG "%s: DLCI %d BECN O%s\n", hdlc_to_name(pvc),
 		       dlci, fh->becn ? "N" : "FF");
 #endif
@@ -820,7 +900,7 @@
 	if (hdlc->state.fr.settings.lmi != LMI_NONE)
 		del_timer_sync(&hdlc->state.fr.timer);
 
-	while(pvc) {		/* Shutdown all PVCs for this FRAD */
+	while (pvc) {		/* Shutdown all PVCs for this FRAD */
 		if (pvc->main)
 			dev_close(pvc->main);
 		if (pvc->ether)
@@ -941,7 +1021,7 @@
 static void fr_destroy(hdlc_device *hdlc)
 {
 	pvc_device *pvc = hdlc->state.fr.first_pvc;
-	while(pvc) {
+	while (pvc) {
 		pvc_device *next = pvc->next;
 		if (pvc->main) {
 			unregister_netdevice(pvc->main);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)