This source file includes following definitions.
- hysdn_sched_rx
- hysdn_sched_tx
- hysdn_tx_cfgline
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #include <linux/signal.h>
15 #include <linux/kernel.h>
16 #include <linux/ioport.h>
17 #include <linux/interrupt.h>
18 #include <linux/delay.h>
19 #include <asm/io.h>
20
21 #include "hysdn_defs.h"
22
23
24
25
26
27
28
29
30 int
31 hysdn_sched_rx(hysdn_card *card, unsigned char *buf, unsigned short len,
32 unsigned short chan)
33 {
34
35 switch (chan) {
36 case CHAN_NDIS_DATA:
37 if (hynet_enable & (1 << card->myid)) {
38
39 hysdn_rx_netpkt(card, buf, len);
40 }
41 break;
42
43 case CHAN_ERRLOG:
44 hysdn_card_errlog(card, (tErrLogEntry *) buf, len);
45 if (card->err_log_state == ERRLOG_STATE_ON)
46 card->err_log_state = ERRLOG_STATE_START;
47 break;
48 #ifdef CONFIG_HYSDN_CAPI
49 case CHAN_CAPI:
50
51 if (hycapi_enable & (1 << card->myid)) {
52 hycapi_rx_capipkt(card, buf, len);
53 }
54 break;
55 #endif
56 default:
57 printk(KERN_INFO "irq message channel %d len %d unhandled \n", chan, len);
58 break;
59
60 }
61
62 return (1);
63 }
64
65
66
67
68
69
70
71
72
73 int
74 hysdn_sched_tx(hysdn_card *card, unsigned char *buf,
75 unsigned short volatile *len, unsigned short volatile *chan,
76 unsigned short maxlen)
77 {
78 struct sk_buff *skb;
79
80 if (card->net_tx_busy) {
81 card->net_tx_busy = 0;
82 hysdn_tx_netack(card);
83 }
84
85 if (card->async_busy) {
86 if (card->async_len <= maxlen) {
87 memcpy(buf, card->async_data, card->async_len);
88 *len = card->async_len;
89 *chan = card->async_channel;
90 card->async_busy = 0;
91 return (1);
92 }
93 card->async_busy = 0;
94 }
95 if ((card->err_log_state == ERRLOG_STATE_START) &&
96 (maxlen >= ERRLOG_CMD_REQ_SIZE)) {
97 strcpy(buf, ERRLOG_CMD_REQ);
98 *len = ERRLOG_CMD_REQ_SIZE;
99 *chan = CHAN_ERRLOG;
100 card->err_log_state = ERRLOG_STATE_ON;
101 return (1);
102 }
103 if ((card->err_log_state == ERRLOG_STATE_STOP) &&
104 (maxlen >= ERRLOG_CMD_STOP_SIZE)) {
105 strcpy(buf, ERRLOG_CMD_STOP);
106 *len = ERRLOG_CMD_STOP_SIZE;
107 *chan = CHAN_ERRLOG;
108 card->err_log_state = ERRLOG_STATE_OFF;
109 return (1);
110 }
111
112 if ((hynet_enable & (1 << card->myid)) &&
113 (skb = hysdn_tx_netget(card)) != NULL)
114 {
115 if (skb->len <= maxlen) {
116
117 skb_copy_from_linear_data(skb, buf, skb->len);
118 *len = skb->len;
119 *chan = CHAN_NDIS_DATA;
120 card->net_tx_busy = 1;
121 return (1);
122 } else
123 hysdn_tx_netack(card);
124 }
125 #ifdef CONFIG_HYSDN_CAPI
126 if (((hycapi_enable & (1 << card->myid))) &&
127 ((skb = hycapi_tx_capiget(card)) != NULL))
128 {
129 if (skb->len <= maxlen) {
130 skb_copy_from_linear_data(skb, buf, skb->len);
131 *len = skb->len;
132 *chan = CHAN_CAPI;
133 hycapi_tx_capiack(card);
134 return (1);
135 }
136 }
137 #endif
138 return (0);
139 }
140
141
142
143
144
145
146
147
148
149 int
150 hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
151 {
152 int cnt = 50;
153 unsigned long flags;
154
155 if (card->debug_flags & LOG_SCHED_ASYN)
156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1);
157
158 while (card->async_busy) {
159
160 if (card->debug_flags & LOG_SCHED_ASYN)
161 hysdn_addlog(card, "async tx-cfg delayed");
162
163 msleep_interruptible(20);
164 if (!--cnt)
165 return (-ERR_ASYNC_TIME);
166 }
167
168 spin_lock_irqsave(&card->hysdn_lock, flags);
169 strcpy(card->async_data, line);
170 card->async_len = strlen(line) + 1;
171 card->async_channel = chan;
172 card->async_busy = 1;
173
174
175 schedule_work(&card->irq_queue);
176 spin_unlock_irqrestore(&card->hysdn_lock, flags);
177
178 if (card->debug_flags & LOG_SCHED_ASYN)
179 hysdn_addlog(card, "async tx-cfg data queued");
180
181 cnt++;
182
183 while (card->async_busy) {
184
185 if (card->debug_flags & LOG_SCHED_ASYN)
186 hysdn_addlog(card, "async tx-cfg waiting for tx-ready");
187
188 msleep_interruptible(20);
189 if (!--cnt)
190 return (-ERR_ASYNC_TIME);
191 }
192
193 if (card->debug_flags & LOG_SCHED_ASYN)
194 hysdn_addlog(card, "async tx-cfg data send");
195
196 return (0);
197 }