diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/net/skfp/queue.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/net/skfp/queue.c')
-rw-r--r-- | drivers/net/skfp/queue.c | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/drivers/net/skfp/queue.c b/drivers/net/skfp/queue.c new file mode 100644 index 000000000000..09adb3d68b7c --- /dev/null +++ b/drivers/net/skfp/queue.c | |||
@@ -0,0 +1,173 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * (C)Copyright 1998,1999 SysKonnect, | ||
4 | * a business unit of Schneider & Koch & Co. Datensysteme GmbH. | ||
5 | * | ||
6 | * See the file "skfddi.c" for further information. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * The information in this file is provided "AS IS" without warranty. | ||
14 | * | ||
15 | ******************************************************************************/ | ||
16 | |||
17 | /* | ||
18 | SMT Event Queue Management | ||
19 | */ | ||
20 | |||
21 | #include "h/types.h" | ||
22 | #include "h/fddi.h" | ||
23 | #include "h/smc.h" | ||
24 | |||
25 | #ifndef lint | ||
26 | static const char ID_sccs[] = "@(#)queue.c 2.9 97/08/04 (C) SK " ; | ||
27 | #endif | ||
28 | |||
29 | #define PRINTF(a,b,c) | ||
30 | |||
31 | /* | ||
32 | * init event queue management | ||
33 | */ | ||
34 | void ev_init(struct s_smc *smc) | ||
35 | { | ||
36 | smc->q.ev_put = smc->q.ev_get = smc->q.ev_queue ; | ||
37 | } | ||
38 | |||
39 | /* | ||
40 | * add event to queue | ||
41 | */ | ||
42 | void queue_event(struct s_smc *smc, int class, int event) | ||
43 | { | ||
44 | PRINTF("queue class %d event %d\n",class,event) ; | ||
45 | smc->q.ev_put->class = class ; | ||
46 | smc->q.ev_put->event = event ; | ||
47 | if (++smc->q.ev_put == &smc->q.ev_queue[MAX_EVENT]) | ||
48 | smc->q.ev_put = smc->q.ev_queue ; | ||
49 | |||
50 | if (smc->q.ev_put == smc->q.ev_get) { | ||
51 | SMT_ERR_LOG(smc,SMT_E0137, SMT_E0137_MSG) ; | ||
52 | } | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * timer_event is called from HW timer package. | ||
57 | */ | ||
58 | void timer_event(struct s_smc *smc, u_long token) | ||
59 | { | ||
60 | PRINTF("timer event class %d token %d\n", | ||
61 | EV_T_CLASS(token), | ||
62 | EV_T_EVENT(token)) ; | ||
63 | queue_event(smc,EV_T_CLASS(token),EV_T_EVENT(token)); | ||
64 | } | ||
65 | |||
66 | /* | ||
67 | * event dispatcher | ||
68 | * while event queue is not empty | ||
69 | * get event from queue | ||
70 | * send command to state machine | ||
71 | * end | ||
72 | */ | ||
73 | void ev_dispatcher(struct s_smc *smc) | ||
74 | { | ||
75 | struct event_queue *ev ; /* pointer into queue */ | ||
76 | int class ; | ||
77 | |||
78 | ev = smc->q.ev_get ; | ||
79 | PRINTF("dispatch get %x put %x\n",ev,smc->q.ev_put) ; | ||
80 | while (ev != smc->q.ev_put) { | ||
81 | PRINTF("dispatch class %d event %d\n",ev->class,ev->event) ; | ||
82 | switch(class = ev->class) { | ||
83 | case EVENT_ECM : /* Entity Corordination Man. */ | ||
84 | ecm(smc,(int)ev->event) ; | ||
85 | break ; | ||
86 | case EVENT_CFM : /* Configuration Man. */ | ||
87 | cfm(smc,(int)ev->event) ; | ||
88 | break ; | ||
89 | case EVENT_RMT : /* Ring Man. */ | ||
90 | rmt(smc,(int)ev->event) ; | ||
91 | break ; | ||
92 | case EVENT_SMT : | ||
93 | smt_event(smc,(int)ev->event) ; | ||
94 | break ; | ||
95 | #ifdef CONCENTRATOR | ||
96 | case 99 : | ||
97 | timer_test_event(smc,(int)ev->event) ; | ||
98 | break ; | ||
99 | #endif | ||
100 | case EVENT_PCMA : /* PHY A */ | ||
101 | case EVENT_PCMB : /* PHY B */ | ||
102 | default : | ||
103 | if (class >= EVENT_PCMA && | ||
104 | class < EVENT_PCMA + NUMPHYS) { | ||
105 | pcm(smc,class - EVENT_PCMA,(int)ev->event) ; | ||
106 | break ; | ||
107 | } | ||
108 | SMT_PANIC(smc,SMT_E0121, SMT_E0121_MSG) ; | ||
109 | return ; | ||
110 | } | ||
111 | |||
112 | if (++ev == &smc->q.ev_queue[MAX_EVENT]) | ||
113 | ev = smc->q.ev_queue ; | ||
114 | |||
115 | /* Renew get: it is used in queue_events to detect overruns */ | ||
116 | smc->q.ev_get = ev; | ||
117 | } | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | * smt_online connects to or disconnects from the ring | ||
122 | * MUST be called to initiate connection establishment | ||
123 | * | ||
124 | * on 0 disconnect | ||
125 | * on 1 connect | ||
126 | */ | ||
127 | u_short smt_online(struct s_smc *smc, int on) | ||
128 | { | ||
129 | queue_event(smc,EVENT_ECM,on ? EC_CONNECT : EC_DISCONNECT) ; | ||
130 | ev_dispatcher(smc) ; | ||
131 | return(smc->mib.fddiSMTCF_State) ; | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | * set SMT flag to value | ||
136 | * flag flag name | ||
137 | * value flag value | ||
138 | * dump current flag setting | ||
139 | */ | ||
140 | #ifdef CONCENTRATOR | ||
141 | void do_smt_flag(struct s_smc *smc, char *flag, int value) | ||
142 | { | ||
143 | #ifdef DEBUG | ||
144 | struct smt_debug *deb; | ||
145 | |||
146 | SK_UNUSED(smc) ; | ||
147 | |||
148 | #ifdef DEBUG_BRD | ||
149 | deb = &smc->debug; | ||
150 | #else | ||
151 | deb = &debug; | ||
152 | #endif | ||
153 | if (!strcmp(flag,"smt")) | ||
154 | deb->d_smt = value ; | ||
155 | else if (!strcmp(flag,"smtf")) | ||
156 | deb->d_smtf = value ; | ||
157 | else if (!strcmp(flag,"pcm")) | ||
158 | deb->d_pcm = value ; | ||
159 | else if (!strcmp(flag,"rmt")) | ||
160 | deb->d_rmt = value ; | ||
161 | else if (!strcmp(flag,"cfm")) | ||
162 | deb->d_cfm = value ; | ||
163 | else if (!strcmp(flag,"ecm")) | ||
164 | deb->d_ecm = value ; | ||
165 | printf("smt %d\n",deb->d_smt) ; | ||
166 | printf("smtf %d\n",deb->d_smtf) ; | ||
167 | printf("pcm %d\n",deb->d_pcm) ; | ||
168 | printf("rmt %d\n",deb->d_rmt) ; | ||
169 | printf("cfm %d\n",deb->d_cfm) ; | ||
170 | printf("ecm %d\n",deb->d_ecm) ; | ||
171 | #endif /* DEBUG */ | ||
172 | } | ||
173 | #endif | ||