aboutsummaryrefslogtreecommitdiffstats
path: root/package/ar7-atm/patches/170-add-hotplug-status.patch
blob: 121a1e4c53e369d4093459031dc873f21c8eb0af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
diff -urN sangam_atm-D7.03.01.00.orig/tn7dsl.c sangam_atm-D7.03.01.00/tn7dsl.c
--- sangam_atm-D7.03.01.00.orig/tn7dsl.c	2008-01-05 03:11:03.000000000 +0100
+++ sangam_atm-D7.03.01.00/tn7dsl.c	2008-01-06 18:13:24.000000000 +0000
@@ -109,6 +109,11 @@
 #include <linux/vmalloc.h>
 #include <linux/file.h>
 #include <linux/firmware.h>
+#include <linux/skbuff.h>
+#include <linux/netlink.h>
+#include <net/sock.h>
+#include <linux/kobject.h>
+#include <asm/uaccess.h>
 
 #include <asm/io.h>
 #include <asm/ar7/ar7.h>
@@ -296,6 +301,8 @@
 /* externs */
 extern struct atm_dev *mydev;
 extern unsigned int oamFarLBCount[4];
+extern struct sock *uevent_sock;
+extern u64 uevent_next_seqnum(void);
 
 /* module wide declars */
 static PITIDSLHW_T    pIhw;
@@ -333,6 +340,75 @@
 	return 0;
 }
 
+static inline void add_msg(struct sk_buff *skb, char *msg) 
+{ 
+	char *scratch; 
+	scratch = skb_put(skb, strlen(msg) + 1); 
+	sprintf(scratch, msg); 
+} 
+
+static void hotplug_dsl_status(void)
+{
+	struct sk_buff *skb;
+	size_t len;
+	char *scratch, *dsl_status;
+	char buf[128];
+	u64 seq;
+	
+	if (!uevent_sock) {
+        	printk("avsar: unable to create netlink socket!\n");
+        	return;
+	}    
+
+	switch (pIhw->AppData.bState)
+	{
+	case RSTATE_TEST:
+                dsl_status="TEST";
+		break;
+	case RSTATE_IDLE:
+		dsl_status="IDLE";
+                break;
+	case RSTATE_INIT:
+		dsl_status="INIT";
+                break;
+	case RSTATE_HS:
+		dsl_status="HANDSHAKE";
+                break;
+	case RSTATE_RTDL:
+		dsl_status="RETRAIN";
+                break;
+	case RSTATE_SHOWTIME:
+		dsl_status="SHOWTIME";
+                break;
+	default:
+		dsl_status="UNKNOWN";
+	}
+
+	/* allocate message with the maximum possible size */
+	len = strlen(dsl_status) +2;
+	skb = alloc_skb(len + 2048, GFP_KERNEL);
+	if (!skb)
+		return;
+	
+	/* add header */
+	scratch = skb_put(skb, len);
+	sprintf(scratch, "%s@",dsl_status);
+
+	/* copy keys to our continuous event payload buffer */
+	add_msg(skb, "HOME=/");
+	add_msg(skb, "PATH=/sbin:/bin:/usr/sbin:/usr/bin");
+	add_msg(skb, "SUBSYSTEM=atm");
+	add_msg(skb, "DEVICENAME=avsar0");
+	snprintf(buf, 128, "ACTION=%s", dsl_status); 
+	add_msg(skb, buf);
+	seq = uevent_next_seqnum();
+	snprintf(buf, 128, "SEQNUM=%llu", (unsigned long long)seq);
+	add_msg(skb, buf);
+	
+	NETLINK_CB(skb).dst_group = 1;
+	netlink_broadcast(uevent_sock, skb, 0, 1, GFP_KERNEL);
+}
+
 
 int os_atoi(const char *pStr)
 {
@@ -2558,7 +2634,7 @@
 
 inline int tn7dsl_handle_interrupt(void)
 {
-  int intsrc;
+  int intsrc,curState;
   unsigned char cMsgRa[6];
   short margin;
   extern unsigned int def_sar_inter_pace;   //Sorry
@@ -2573,7 +2649,7 @@
 
     if (nohost_flag) return 0;
 
-
+    curState=pIhw->AppData.bState;
     dslhal_api_handleTrainingInterrupt(pIhw, intsrc);
 
     if(pIhw->lConnected == TC_SYNC)
@@ -2704,8 +2780,8 @@
       }
 
 #endif
-
     }
+    if(pIhw->AppData.bState != curState) hotplug_dsl_status();
 
     //UR8_MERGE_START CQ10442 Manjula K
     if (pIhw->AppData.SRA)