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  *  The information in this file is provided "AS IS" without warranty.
0008  *
0009  ******************************************************************************/
0010 
0011 #ifndef _SCMECM_
0012 #define _SCMECM_
0013 
0014 #if defined(PCI) && !defined(OSDEF)
0015 /*
0016  * In the case of the PCI bus the file osdef1st.h must be present
0017  */
0018 #define OSDEF
0019 #endif
0020 
0021 #ifdef  PCI
0022 #ifndef SUPERNET_3
0023 #define SUPERNET_3
0024 #endif
0025 #ifndef TAG_MODE
0026 #define TAG_MODE
0027 #endif
0028 #endif
0029 
0030 /*
0031  * include all other files in required order
0032  * the following files must have been included before:
0033  *  types.h
0034  *  fddi.h
0035  */
0036 #ifdef  OSDEF
0037 #include "osdef1st.h"
0038 #endif  /* OSDEF */
0039 #ifdef  OEM_CONCEPT
0040 #include "oemdef.h"
0041 #endif  /* OEM_CONCEPT */
0042 #include "smt.h"
0043 #include "cmtdef.h"
0044 #include "fddimib.h"
0045 #include "targethw.h"       /* all target hw dependencies */
0046 #include "targetos.h"       /* all target os dependencies */
0047 #ifdef  ESS
0048 #include "sba.h"
0049 #endif
0050 
0051 /*
0052  * Event Queue
0053  *  queue.c
0054  * events are class/value pairs
0055  *  class   is addressee, e.g. RMT, PCM etc.
0056  *  value   is command, e.g. line state change, ring op change etc.
0057  */
0058 struct event_queue {
0059     u_short class ;         /* event class */
0060     u_short event ;         /* event value */
0061 } ;
0062 
0063 /*
0064  * define event queue as circular buffer
0065  */
0066 #ifdef  CONCENTRATOR
0067 #define MAX_EVENT   128
0068 #else   /* nCONCENTRATOR */
0069 #define MAX_EVENT   64
0070 #endif  /* nCONCENTRATOR */
0071 
0072 struct s_queue {
0073 
0074     struct event_queue ev_queue[MAX_EVENT];
0075     struct event_queue *ev_put ;
0076     struct event_queue *ev_get ;
0077 } ;
0078 
0079 /*
0080  * ECM - Entity Coordination Management
0081  * ecm.c
0082  */
0083 struct s_ecm {
0084     u_char path_test ;      /* ECM path test variable */
0085     u_char sb_flag ;        /* ECM stuck bypass */
0086     u_char DisconnectFlag ;     /* jd 05-Aug-1999 Bug #10419 
0087                      * ECM disconnected */
0088     u_char ecm_line_state ;     /* flag to dispatcher : line states */
0089     u_long trace_prop ;     /* ECM Trace_Prop flag >= 16 bits !! */
0090     /* NUMPHYS note:
0091      * this variable must have enough bits to hold all entiies in
0092      * the station. So NUMPHYS may not be greater than 31.
0093      */
0094     char    ec_pad[2] ;
0095     struct smt_timer ecm_timer ;    /* timer */
0096 } ;
0097 
0098 
0099 /*
0100  * RMT - Ring Management
0101  * rmt.c
0102  */
0103 struct s_rmt {
0104     u_char dup_addr_test ;      /* state of dupl. addr. test */
0105     u_char da_flag ;        /* flag : duplicate address det. */
0106     u_char loop_avail ;     /* flag : MAC available for loopback */
0107     u_char sm_ma_avail ;        /* flag : MAC available for SMT */
0108     u_char no_flag ;        /* flag : ring not operational */
0109     u_char bn_flag ;        /* flag : MAC reached beacon state */
0110     u_char jm_flag ;        /* flag : jamming in NON_OP_DUP */
0111     u_char rm_join ;        /* CFM flag RM_Join */
0112     u_char rm_loop ;        /* CFM flag RM_Loop */
0113 
0114     long fast_rm_join ;     /* bit mask of active ports */
0115     /*
0116      * timer and flags
0117      */
0118     struct smt_timer rmt_timer0 ;   /* timer 0 */
0119     struct smt_timer rmt_timer1 ;   /* timer 1 */
0120     struct smt_timer rmt_timer2 ;   /* timer 2 */
0121     u_char timer0_exp ;     /* flag : timer 0 expired */
0122     u_char timer1_exp ;     /* flag : timer 1 expired */
0123     u_char timer2_exp ;     /* flag : timer 2 expired */
0124 
0125     u_char rm_pad1;
0126 } ;
0127 
0128 /*
0129  * CFM - Configuration Management
0130  * cfm.c
0131  * used for SAS and DAS
0132  */
0133 struct s_cfm {
0134     u_char cf_state;        /* CFM state machine current state */
0135     u_char cf_pad[3] ;
0136 } ;
0137 
0138 /*
0139  * CEM - Configuration Element Management
0140  * cem.c
0141  * used for Concentrator
0142  */
0143 #ifdef  CONCENTRATOR
0144 struct s_cem {
0145     int ce_state ;  /* CEM state */
0146     int ce_port ;   /* PA PB PM PM+1 .. */
0147     int ce_type ;   /* TA TB TS TM */
0148 } ;
0149 
0150 /*
0151  * linked list of CCEs in current token path
0152  */
0153 struct s_c_ring {
0154     struct s_c_ring *c_next ;
0155     char        c_entity ;
0156 } ;
0157 
0158 struct mib_path_config {
0159     u_long  fddimibPATHConfigSMTIndex;
0160     u_long  fddimibPATHConfigPATHIndex;
0161     u_long  fddimibPATHConfigTokenOrder;
0162     u_long  fddimibPATHConfigResourceType;
0163 #define SNMP_RES_TYPE_MAC   2   /* Resource is a MAC */
0164 #define SNMP_RES_TYPE_PORT  4   /* Resource is a PORT */
0165     u_long  fddimibPATHConfigResourceIndex;
0166     u_long  fddimibPATHConfigCurrentPath;
0167 #define SNMP_PATH_ISOLATED  1   /* Current path is isolated */
0168 #define SNMP_PATH_LOCAL     2   /* Current path is local */
0169 #define SNMP_PATH_SECONDARY 3   /* Current path is secondary */
0170 #define SNMP_PATH_PRIMARY   4   /* Current path is primary */
0171 #define SNMP_PATH_CONCATENATED  5   /* Current path is concatenated */
0172 #define SNMP_PATH_THRU      6   /* Current path is thru */
0173 };
0174 
0175 
0176 #endif
0177 
0178 /*
0179  * PCM connect states
0180  */
0181 #define PCM_DISABLED    0
0182 #define PCM_CONNECTING  1
0183 #define PCM_STANDBY 2
0184 #define PCM_ACTIVE  3
0185 
0186 struct s_pcm {
0187     u_char  pcm_pad[3] ;
0188 } ;
0189 
0190 /*
0191  * PHY struct
0192  * one per physical port
0193  */
0194 struct s_phy {
0195     /* Inter Module Globals */
0196     struct fddi_mib_p   *mib ;
0197 
0198     u_char np ;     /* index 0 .. NUMPHYS */
0199     u_char cf_join ;
0200     u_char cf_loop ;
0201     u_char wc_flag ;    /* withhold connection flag */
0202     u_char pc_mode ;    /* Holds the negotiated mode of the PCM */
0203     u_char pc_lem_fail ;    /* flag : LCT failed */
0204     u_char lc_test ;
0205     u_char scrub ;      /* CFM flag Scrub -> PCM */
0206     char phy_name ;
0207     u_char pmd_type[2] ;    /* SK connector/transceiver type codes */
0208 #define PMD_SK_CONN 0   /* pmd_type[PMD_SK_CONN] = Connector */
0209 #define PMD_SK_PMD  1   /* pmd_type[PMD_SK_PMD] = Xver */
0210     u_char pmd_scramble ;   /* scrambler on/off */
0211 
0212     /* inner Module Globals */
0213     u_char curr_ls ;    /* current line state */
0214     u_char ls_flag ;
0215     u_char rc_flag ;
0216     u_char tc_flag ;
0217     u_char td_flag ;
0218     u_char bitn ;
0219     u_char tr_flag ;    /* trace recvd while in active */
0220     u_char twisted ;    /* flag to indicate an A-A or B-B connection */
0221     u_char t_val[NUMBITS] ; /* transmit bits for signaling */
0222     u_char r_val[NUMBITS] ; /* receive bits for signaling */
0223     u_long t_next[NUMBITS] ;
0224     struct smt_timer pcm_timer0 ;
0225     struct smt_timer pcm_timer1 ;
0226     struct smt_timer pcm_timer2 ;
0227     u_char timer0_exp ;
0228     u_char timer1_exp ;
0229     u_char timer2_exp ;
0230     u_char pcm_pad1[1] ;
0231     int cem_pst ;   /* CEM private state; used for dual homing */
0232     struct lem_counter lem ;
0233 #ifdef  AMDPLC
0234     struct s_plc    plc ;
0235 #endif
0236 } ;
0237 
0238 /*
0239  * timer package
0240  * smttimer.c
0241  */
0242 struct s_timer {
0243     struct smt_timer    *st_queue ;
0244     struct smt_timer    st_fast ;
0245 } ;
0246 
0247 /*
0248  * SRF types and data
0249  */
0250 #define SMT_EVENT_BASE          1
0251 #define SMT_EVENT_MAC_PATH_CHANGE   (SMT_EVENT_BASE+0)
0252 #define SMT_EVENT_MAC_NEIGHBOR_CHANGE   (SMT_EVENT_BASE+1)
0253 #define SMT_EVENT_PORT_PATH_CHANGE  (SMT_EVENT_BASE+2)
0254 #define SMT_EVENT_PORT_CONNECTION   (SMT_EVENT_BASE+3)
0255 
0256 #define SMT_IS_CONDITION(x)         ((x)>=SMT_COND_BASE)
0257 
0258 #define SMT_COND_BASE       (SMT_EVENT_PORT_CONNECTION+1)
0259 #define SMT_COND_SMT_PEER_WRAP      (SMT_COND_BASE+0)
0260 #define SMT_COND_SMT_HOLD       (SMT_COND_BASE+1)
0261 #define SMT_COND_MAC_FRAME_ERROR    (SMT_COND_BASE+2)
0262 #define SMT_COND_MAC_DUP_ADDR       (SMT_COND_BASE+3)
0263 #define SMT_COND_MAC_NOT_COPIED     (SMT_COND_BASE+4)
0264 #define SMT_COND_PORT_EB_ERROR      (SMT_COND_BASE+5)
0265 #define SMT_COND_PORT_LER       (SMT_COND_BASE+6)
0266 
0267 #define SR0_WAIT    0
0268 #define SR1_HOLDOFF 1
0269 #define SR2_DISABLED    2
0270 
0271 struct s_srf {
0272     u_long  SRThreshold ;           /* threshold value */
0273     u_char  RT_Flag ;           /* report transmitted flag */
0274     u_char  sr_state ;          /* state-machine */
0275     u_char  any_report ;            /* any report required */
0276     u_long  TSR ;               /* timer */
0277     u_short ring_status ;           /* IBM ring status */
0278 } ;
0279 
0280 /*
0281  * IBM token ring status
0282  */
0283 #define RS_RES15    (1<<15)         /* reserved */
0284 #define RS_HARDERROR    (1<<14)         /* ring down */
0285 #define RS_SOFTERROR    (1<<13)         /* sent SRF */
0286 #define RS_BEACON   (1<<12)         /* transmitted beacon */
0287 #define RS_PATHTEST (1<<11)         /* path test failed */
0288 #define RS_SELFTEST (1<<10)         /* selftest required */
0289 #define RS_RES9     (1<< 9)         /* reserved */
0290 #define RS_DISCONNECT   (1<< 8)         /* remote disconnect */
0291 #define RS_RES7     (1<< 7)         /* reserved */
0292 #define RS_DUPADDR  (1<< 6)         /* duplicate address */
0293 #define RS_NORINGOP (1<< 5)         /* no ring op */
0294 #define RS_VERSION  (1<< 4)         /* SMT version mismatch */
0295 #define RS_STUCKBYPASSS (1<< 3)         /* stuck bypass */
0296 #define RS_EVENT    (1<< 2)         /* FDDI event occurred */
0297 #define RS_RINGOPCHANGE (1<< 1)         /* ring op changed */
0298 #define RS_RES0     (1<< 0)         /* reserved */
0299 
0300 #define RS_SET(smc,bit) \
0301     ring_status_indication(smc,smc->srf.ring_status |= bit)
0302 #define RS_CLEAR(smc,bit)   \
0303     ring_status_indication(smc,smc->srf.ring_status &= ~bit)
0304 
0305 #define RS_CLEAR_EVENT  (0xffff & ~(RS_NORINGOP))
0306 
0307 /* Define the AIX-event-Notification as null function if it isn't defined */
0308 /* in the targetos.h file */
0309 #ifndef AIX_EVENT
0310 #define AIX_EVENT(smc,opt0,opt1,opt2,opt3)  /* nothing */
0311 #endif
0312 
0313 struct s_srf_evc {
0314     u_char  evc_code ;          /* event code type */
0315     u_char  evc_index ;         /* index for mult. instances */
0316     u_char  evc_rep_required ;      /* report required */
0317     u_short evc_para ;          /* SMT Para Number */
0318     u_char  *evc_cond_state ;       /* condition state */
0319     u_char  *evc_multiple ;         /* multiple occurrence */
0320 } ;
0321 
0322 /*
0323  * Values used by frame based services
0324  * smt.c
0325  */
0326 #define SMT_MAX_TEST        5
0327 #define SMT_TID_NIF     0       /* pending NIF request */
0328 #define SMT_TID_NIF_TEST    1       /* pending NIF test */
0329 #define SMT_TID_ECF_UNA     2       /* pending ECF UNA test */
0330 #define SMT_TID_ECF_DNA     3       /* pending ECF DNA test */
0331 #define SMT_TID_ECF     4       /* pending ECF test */
0332 
0333 struct smt_values {
0334     u_long      smt_tvu ;       /* timer valid una */
0335     u_long      smt_tvd ;       /* timer valid dna */
0336     u_long      smt_tid ;       /* transaction id */
0337     u_long      pend[SMT_MAX_TEST] ;    /* TID of requests */
0338     u_long      uniq_time ;     /* unique time stamp */
0339     u_short     uniq_ticks  ;       /* unique time stamp */
0340     u_short     please_reconnect ;  /* flag : reconnect */
0341     u_long      smt_last_lem ;
0342     u_long      smt_last_notify ;
0343     struct smt_timer    smt_timer ; /* SMT NIF timer */
0344     u_long      last_tok_time[NUMMACS]; /* token cnt emulation */
0345 } ;
0346 
0347 /*
0348  * SMT/CMT configurable parameters
0349  */
0350 #define SMT_DAS 0           /* dual attach */
0351 #define SMT_SAS 1           /* single attach */
0352 #define SMT_NAC 2           /* null attach concentrator */
0353 
0354 struct smt_config {
0355     u_char  attach_s ;      /* CFM attach to secondary path */
0356     u_char  sas ;           /* SMT_DAS/SAS/NAC */
0357     u_char  build_ring_map ;    /* build ringmap if TRUE */
0358     u_char  numphys ;       /* number of active phys */
0359     u_char  sc_pad[1] ;
0360 
0361     u_long  pcm_tb_min ;        /* PCM : TB_Min timer value */
0362     u_long  pcm_tb_max ;        /* PCM : TB_Max timer value */
0363     u_long  pcm_c_min ;     /* PCM : C_Min timer value */
0364     u_long  pcm_t_out ;     /* PCM : T_Out timer value */
0365     u_long  pcm_tl_min ;        /* PCM : TL_min timer value */
0366     u_long  pcm_lc_short ;      /* PCM : LC_Short timer value */
0367     u_long  pcm_lc_medium ;     /* PCM : LC_Medium timer value */
0368     u_long  pcm_lc_long ;       /* PCM : LC_Long timer value */
0369     u_long  pcm_lc_extended ;   /* PCM : LC_Extended timer value */
0370     u_long  pcm_t_next_9 ;      /* PCM : T_Next[9] timer value */
0371     u_long  pcm_ns_max ;        /* PCM : NS_Max timer value */
0372 
0373     u_long  ecm_i_max ;     /* ECM : I_Max timer value */
0374     u_long  ecm_in_max ;        /* ECM : IN_Max timer value */
0375     u_long  ecm_td_min ;        /* ECM : TD_Min timer */
0376     u_long  ecm_test_done ;     /* ECM : path test done timer */
0377     u_long  ecm_check_poll ;    /* ECM : check bypass poller */
0378 
0379     u_long  rmt_t_non_op ;      /* RMT : T_Non_OP timer value */
0380     u_long  rmt_t_stuck ;       /* RMT : T_Stuck timer value */
0381     u_long  rmt_t_direct ;      /* RMT : T_Direct timer value */
0382     u_long  rmt_t_jam ;     /* RMT : T_Jam timer value */
0383     u_long  rmt_t_announce ;    /* RMT : T_Announce timer value */
0384     u_long  rmt_t_poll ;        /* RMT : claim/beacon poller */
0385     u_long  rmt_dup_mac_behavior ;  /* Flag for the beavior of SMT if
0386                      * a Duplicate MAC Address was detected.
0387                      * FALSE: SMT will leave finally the ring
0388                      * TRUE:  SMT will reinstert into the ring
0389                      */
0390     u_long  mac_d_max ;     /* MAC : D_Max timer value */
0391 
0392     u_long lct_short ;      /* LCT : error threshold */
0393     u_long lct_medium ;     /* LCT : error threshold */
0394     u_long lct_long ;       /* LCT : error threshold */
0395     u_long lct_extended ;       /* LCT : error threshold */
0396 } ;
0397 
0398 #ifdef  DEBUG
0399 /*
0400  * Debugging struct sometimes used in smc
0401  */
0402 struct  smt_debug {
0403     int d_smtf ;
0404     int d_smt ;
0405     int d_ecm ;
0406     int d_rmt ;
0407     int d_cfm ;
0408     int d_pcm ;
0409     int d_plc ;
0410 #ifdef  ESS
0411     int d_ess ;
0412 #endif
0413 #ifdef  SBA
0414     int d_sba ;
0415 #endif
0416     struct  os_debug    d_os;   /* Include specific OS DEBUG struct */
0417 } ;
0418 
0419 #ifndef DEBUG_BRD
0420 /* all boards shall be debugged with one debug struct */
0421 extern  struct  smt_debug   debug;  /* Declaration of debug struct */
0422 #endif  /* DEBUG_BRD */
0423 
0424 #endif  /* DEBUG */
0425 
0426 /*
0427  * the SMT Context Struct SMC
0428  * this struct contains ALL global variables of SMT
0429  */
0430 struct s_smc {
0431     struct s_smt_os os ;        /* os specific */
0432     struct s_smt_hw hw ;        /* hardware */
0433 
0434 /*
0435  * NOTE: os and hw MUST BE the first two structs
0436  * anything beyond hw WILL BE SET TO ZERO in smt_set_defaults()
0437  */
0438     struct smt_config s ;       /* smt constants */
0439     struct smt_values sm ;      /* smt variables */
0440     struct s_ecm    e ;     /* ecm */
0441     struct s_rmt    r ;     /* rmt */
0442     struct s_cfm    cf ;        /* cfm/cem */
0443 #ifdef  CONCENTRATOR
0444     struct s_cem    ce[NUMPHYS] ;   /* cem */
0445     struct s_c_ring cr[NUMPHYS+NUMMACS] ;
0446 #endif
0447     struct s_pcm    p ;     /* pcm */
0448     struct s_phy    y[NUMPHYS] ;    /* phy */
0449     struct s_queue  q ;     /* queue */
0450     struct s_timer  t ;     /* timer */
0451     struct s_srf srf ;      /* SRF */
0452     struct s_srf_evc evcs[6+NUMPHYS*4] ;
0453     struct fddi_mib mib ;       /* __THE_MIB__ */
0454 #ifdef  SBA
0455     struct s_sba    sba ;       /* SBA variables */
0456 #endif
0457 #ifdef  ESS
0458     struct s_ess    ess ;       /* Ess variables */
0459 #endif
0460 #if defined(DEBUG) && defined(DEBUG_BRD)
0461     /* If you want all single board to be debugged separately */
0462     struct smt_debug    debug;  /* Declaration of debug struct */
0463 #endif  /* DEBUG_BRD && DEBUG */
0464 } ;
0465 
0466 extern const struct fddi_addr fddi_broadcast;
0467 
0468 void all_selection_criteria(struct s_smc *smc);
0469 void card_stop(struct s_smc *smc);
0470 void init_board(struct s_smc *smc, u_char *mac_addr);
0471 int init_fplus(struct s_smc *smc);
0472 void init_plc(struct s_smc *smc);
0473 int init_smt(struct s_smc *smc, const u_char *mac_addr);
0474 void mac1_irq(struct s_smc *smc, u_short stu, u_short stl);
0475 void mac2_irq(struct s_smc *smc, u_short code_s2u, u_short code_s2l);
0476 void mac3_irq(struct s_smc *smc, u_short code_s3u, u_short code_s3l);
0477 int pcm_status_twisted(struct s_smc *smc);
0478 void plc1_irq(struct s_smc *smc);
0479 void plc2_irq(struct s_smc *smc);
0480 void read_address(struct s_smc *smc, u_char *mac_addr);
0481 void timer_irq(struct s_smc *smc);
0482 
0483 #endif  /* _SCMECM_ */
0484