Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /******************************************************************************
0003  *
0004  *  (C)Copyright 1998,1999 SysKonnect,
0005  *  a business unit of Schneider & Koch & Co. Datensysteme GmbH.
0006  *
0007  *  See the file "skfddi.c" for further information.
0008  *
0009  *  The information in this file is provided "AS IS" without warranty.
0010  *
0011  ******************************************************************************/
0012 
0013 /*
0014     SMT Event Queue Management
0015 */
0016 
0017 #include "h/types.h"
0018 #include "h/fddi.h"
0019 #include "h/smc.h"
0020 
0021 #define PRINTF(a,b,c)
0022 
0023 /*
0024  * init event queue management
0025  */
0026 void ev_init(struct s_smc *smc)
0027 {
0028     smc->q.ev_put = smc->q.ev_get = smc->q.ev_queue ;
0029 }
0030 
0031 /*
0032  * add event to queue
0033  */
0034 void queue_event(struct s_smc *smc, int class, int event)
0035 {
0036     PRINTF("queue class %d event %d\n",class,event) ;
0037     smc->q.ev_put->class = class ;
0038     smc->q.ev_put->event = event ;
0039     if (++smc->q.ev_put == &smc->q.ev_queue[MAX_EVENT])
0040         smc->q.ev_put = smc->q.ev_queue ;
0041 
0042     if (smc->q.ev_put == smc->q.ev_get) {
0043         SMT_ERR_LOG(smc,SMT_E0137, SMT_E0137_MSG) ;
0044     }
0045 }
0046 
0047 /*
0048  * timer_event is called from HW timer package.
0049  */
0050 void timer_event(struct s_smc *smc, u_long token)
0051 {
0052     PRINTF("timer event class %d token %d\n",
0053         EV_T_CLASS(token),
0054         EV_T_EVENT(token)) ;
0055     queue_event(smc,EV_T_CLASS(token),EV_T_EVENT(token));
0056 }
0057 
0058 /*
0059  * event dispatcher
0060  *  while event queue is not empty
0061  *      get event from queue
0062  *      send command to state machine
0063  *  end
0064  */
0065 void ev_dispatcher(struct s_smc *smc)
0066 {
0067     struct event_queue *ev ;    /* pointer into queue */
0068     int     class ;
0069 
0070     ev = smc->q.ev_get ;
0071     PRINTF("dispatch get %x put %x\n",ev,smc->q.ev_put) ;
0072     while (ev != smc->q.ev_put) {
0073         PRINTF("dispatch class %d event %d\n",ev->class,ev->event) ;
0074         switch(class = ev->class) {
0075         case EVENT_ECM :        /* Entity Corordination  Man. */
0076             ecm(smc,(int)ev->event) ;
0077             break ;
0078         case EVENT_CFM :        /* Configuration Man. */
0079             cfm(smc,(int)ev->event) ;
0080             break ;
0081         case EVENT_RMT :        /* Ring Man. */
0082             rmt(smc,(int)ev->event) ;
0083             break ;
0084         case EVENT_SMT :
0085             smt_event(smc,(int)ev->event) ;
0086             break ;
0087 #ifdef  CONCENTRATOR
0088         case 99 :
0089             timer_test_event(smc,(int)ev->event) ;
0090             break ;
0091 #endif
0092         case EVENT_PCMA :       /* PHY A */
0093         case EVENT_PCMB :       /* PHY B */
0094         default :
0095             if (class >= EVENT_PCMA &&
0096                 class < EVENT_PCMA + NUMPHYS) {
0097                 pcm(smc,class - EVENT_PCMA,(int)ev->event) ;
0098                 break ;
0099             }
0100             SMT_PANIC(smc,SMT_E0121, SMT_E0121_MSG) ;
0101             return ;
0102         }
0103 
0104         if (++ev == &smc->q.ev_queue[MAX_EVENT])
0105             ev = smc->q.ev_queue ;
0106 
0107         /* Renew get: it is used in queue_events to detect overruns */
0108         smc->q.ev_get = ev;
0109     }
0110 }
0111 
0112 /*
0113  * smt_online connects to or disconnects from the ring
0114  * MUST be called to initiate connection establishment
0115  *
0116  *  on  0   disconnect
0117  *  on  1   connect
0118  */
0119 u_short smt_online(struct s_smc *smc, int on)
0120 {
0121     queue_event(smc,EVENT_ECM,on ? EC_CONNECT : EC_DISCONNECT) ;
0122     ev_dispatcher(smc) ;
0123     return smc->mib.fddiSMTCF_State;
0124 }
0125 
0126 /*
0127  * set SMT flag to value
0128  *  flag        flag name
0129  *  value       flag value
0130  * dump current flag setting
0131  */
0132 #ifdef  CONCENTRATOR
0133 void do_smt_flag(struct s_smc *smc, char *flag, int value)
0134 {
0135 #ifdef  DEBUG
0136     struct smt_debug    *deb;
0137 
0138     SK_UNUSED(smc) ;
0139 
0140 #ifdef  DEBUG_BRD
0141     deb = &smc->debug;
0142 #else
0143     deb = &debug;
0144 #endif
0145     if (!strcmp(flag,"smt"))
0146         deb->d_smt = value ;
0147     else if (!strcmp(flag,"smtf"))
0148         deb->d_smtf = value ;
0149     else if (!strcmp(flag,"pcm"))
0150         deb->d_pcm = value ;
0151     else if (!strcmp(flag,"rmt"))
0152         deb->d_rmt = value ;
0153     else if (!strcmp(flag,"cfm"))
0154         deb->d_cfm = value ;
0155     else if (!strcmp(flag,"ecm"))
0156         deb->d_ecm = value ;
0157     printf("smt %d\n",deb->d_smt) ;
0158     printf("smtf    %d\n",deb->d_smtf) ;
0159     printf("pcm %d\n",deb->d_pcm) ;
0160     printf("rmt %d\n",deb->d_rmt) ;
0161     printf("cfm %d\n",deb->d_cfm) ;
0162     printf("ecm %d\n",deb->d_ecm) ;
0163 #endif  /* DEBUG */
0164 }
0165 #endif