xref: /openbmc/linux/drivers/net/fddi/skfp/h/smc.h (revision 2e0566ae)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /******************************************************************************
3  *
4  *	(C)Copyright 1998,1999 SysKonnect,
5  *	a business unit of Schneider & Koch & Co. Datensysteme GmbH.
6  *
7  *	The information in this file is provided "AS IS" without warranty.
8  *
9  ******************************************************************************/
10 
11 #ifndef	_SCMECM_
12 #define _SCMECM_
13 
14 #if	defined(PCI) && !defined(OSDEF)
15 /*
16  * In the case of the PCI bus the file osdef1st.h must be present
17  */
18 #define	OSDEF
19 #endif
20 
21 #ifdef	PCI
22 #ifndef	SUPERNET_3
23 #define	SUPERNET_3
24 #endif
25 #ifndef	TAG_MODE
26 #define	TAG_MODE
27 #endif
28 #endif
29 
30 /*
31  * include all other files in required order
32  * the following files must have been included before:
33  *	types.h
34  *	fddi.h
35  */
36 #ifdef	OSDEF
37 #include "osdef1st.h"
38 #endif	/* OSDEF */
39 #ifdef	OEM_CONCEPT
40 #include "oemdef.h"
41 #endif	/* OEM_CONCEPT */
42 #include "smt.h"
43 #include "cmtdef.h"
44 #include "fddimib.h"
45 #include "targethw.h"		/* all target hw dependencies */
46 #include "targetos.h"		/* all target os dependencies */
47 #ifdef	ESS
48 #include "sba.h"
49 #endif
50 
51 /*
52  * Event Queue
53  *	queue.c
54  * events are class/value pairs
55  *	class	is addressee, e.g. RMT, PCM etc.
56  *	value	is command, e.g. line state change, ring op change etc.
57  */
58 struct event_queue {
59 	u_short	class ;			/* event class */
60 	u_short	event ;			/* event value */
61 } ;
62 
63 /*
64  * define event queue as circular buffer
65  */
66 #ifdef	CONCENTRATOR
67 #define MAX_EVENT	128
68 #else	/* nCONCENTRATOR */
69 #define MAX_EVENT	64
70 #endif	/* nCONCENTRATOR */
71 
72 struct s_queue {
73 
74 	struct event_queue ev_queue[MAX_EVENT];
75 	struct event_queue *ev_put ;
76 	struct event_queue *ev_get ;
77 } ;
78 
79 /*
80  * ECM - Entity Coordination Management
81  * ecm.c
82  */
83 struct s_ecm {
84 	u_char path_test ;		/* ECM path test variable */
85 	u_char sb_flag ;		/* ECM stuck bypass */
86 	u_char DisconnectFlag ;		/* jd 05-Aug-1999 Bug #10419
87 					 * ECM disconnected */
88 	u_char ecm_line_state ;		/* flag to dispatcher : line states */
89 	u_long trace_prop ;		/* ECM Trace_Prop flag >= 16 bits !! */
90 	/* NUMPHYS note:
91 	 * this variable must have enough bits to hold all entiies in
92 	 * the station. So NUMPHYS may not be greater than 31.
93 	 */
94 	char	ec_pad[2] ;
95 	struct smt_timer ecm_timer ;	/* timer */
96 } ;
97 
98 
99 /*
100  * RMT - Ring Management
101  * rmt.c
102  */
103 struct s_rmt {
104 	u_char dup_addr_test ;		/* state of dupl. addr. test */
105 	u_char da_flag ;		/* flag : duplicate address det. */
106 	u_char loop_avail ;		/* flag : MAC available for loopback */
107 	u_char sm_ma_avail ;		/* flag : MAC available for SMT */
108 	u_char no_flag ;		/* flag : ring not operational */
109 	u_char bn_flag ;		/* flag : MAC reached beacon state */
110 	u_char jm_flag ;		/* flag : jamming in NON_OP_DUP */
111 	u_char rm_join ;		/* CFM flag RM_Join */
112 	u_char rm_loop ;		/* CFM flag RM_Loop */
113 
114 	long fast_rm_join ;		/* bit mask of active ports */
115 	/*
116 	 * timer and flags
117 	 */
118 	struct smt_timer rmt_timer0 ;	/* timer 0 */
119 	struct smt_timer rmt_timer1 ;	/* timer 1 */
120 	struct smt_timer rmt_timer2 ;	/* timer 2 */
121 	u_char timer0_exp ;		/* flag : timer 0 expired */
122 	u_char timer1_exp ;		/* flag : timer 1 expired */
123 	u_char timer2_exp ;		/* flag : timer 2 expired */
124 
125 	u_char rm_pad1;
126 } ;
127 
128 /*
129  * CFM - Configuration Management
130  * cfm.c
131  * used for SAS and DAS
132  */
133 struct s_cfm {
134 	u_char cf_state;		/* CFM state machine current state */
135 	u_char cf_pad[3] ;
136 } ;
137 
138 /*
139  * CEM - Configuration Element Management
140  * cem.c
141  * used for Concentrator
142  */
143 #ifdef	CONCENTRATOR
144 struct s_cem {
145 	int	ce_state ;	/* CEM state */
146 	int	ce_port ;	/* PA PB PM PM+1 .. */
147 	int	ce_type ;	/* TA TB TS TM */
148 } ;
149 
150 /*
151  * linked list of CCEs in current token path
152  */
153 struct s_c_ring {
154 	struct s_c_ring	*c_next ;
155 	char		c_entity ;
156 } ;
157 
158 struct mib_path_config {
159 	u_long	fddimibPATHConfigSMTIndex;
160 	u_long	fddimibPATHConfigPATHIndex;
161 	u_long	fddimibPATHConfigTokenOrder;
162 	u_long	fddimibPATHConfigResourceType;
163 #define SNMP_RES_TYPE_MAC	2	/* Resource is a MAC */
164 #define SNMP_RES_TYPE_PORT	4	/* Resource is a PORT */
165 	u_long	fddimibPATHConfigResourceIndex;
166 	u_long	fddimibPATHConfigCurrentPath;
167 #define SNMP_PATH_ISOLATED	1	/* Current path is isolated */
168 #define SNMP_PATH_LOCAL		2	/* Current path is local */
169 #define SNMP_PATH_SECONDARY	3	/* Current path is secondary */
170 #define SNMP_PATH_PRIMARY	4	/* Current path is primary */
171 #define SNMP_PATH_CONCATENATED	5	/* Current path is concatenated */
172 #define SNMP_PATH_THRU		6	/* Current path is thru */
173 };
174 
175 
176 #endif
177 
178 /*
179  * PCM connect states
180  */
181 #define PCM_DISABLED	0
182 #define PCM_CONNECTING	1
183 #define PCM_STANDBY	2
184 #define PCM_ACTIVE	3
185 
186 struct s_pcm {
187 	u_char	pcm_pad[3] ;
188 } ;
189 
190 /*
191  * PHY struct
192  * one per physical port
193  */
194 struct s_phy {
195 	/* Inter Module Globals */
196 	struct fddi_mib_p	*mib ;
197 
198 	u_char np ;		/* index 0 .. NUMPHYS */
199 	u_char cf_join ;
200 	u_char cf_loop ;
201 	u_char wc_flag ;	/* withhold connection flag */
202 	u_char pc_mode ;	/* Holds the negotiated mode of the PCM */
203 	u_char pc_lem_fail ;	/* flag : LCT failed */
204 	u_char lc_test ;
205 	u_char scrub ;		/* CFM flag Scrub -> PCM */
206 	char phy_name ;
207 	u_char pmd_type[2] ;	/* SK connector/transceiver type codes */
208 #define PMD_SK_CONN	0	/* pmd_type[PMD_SK_CONN] = Connector */
209 #define PMD_SK_PMD	1	/* pmd_type[PMD_SK_PMD] = Xver */
210 	u_char pmd_scramble ;	/* scrambler on/off */
211 
212 	/* inner Module Globals */
213 	u_char curr_ls ;	/* current line state */
214 	u_char ls_flag ;
215 	u_char rc_flag ;
216 	u_char tc_flag ;
217 	u_char td_flag ;
218 	u_char bitn ;
219 	u_char tr_flag ;	/* trace recvd while in active */
220 	u_char twisted ;	/* flag to indicate an A-A or B-B connection */
221 	u_char t_val[NUMBITS] ;	/* transmit bits for signaling */
222 	u_char r_val[NUMBITS] ;	/* receive bits for signaling */
223 	u_long t_next[NUMBITS] ;
224 	struct smt_timer pcm_timer0 ;
225 	struct smt_timer pcm_timer1 ;
226 	struct smt_timer pcm_timer2 ;
227 	u_char timer0_exp ;
228 	u_char timer1_exp ;
229 	u_char timer2_exp ;
230 	u_char pcm_pad1[1] ;
231 	int	cem_pst ;	/* CEM private state; used for dual homing */
232 	struct lem_counter lem ;
233 #ifdef	AMDPLC
234 	struct s_plc	plc ;
235 #endif
236 } ;
237 
238 /*
239  * timer package
240  * smttimer.c
241  */
242 struct s_timer {
243 	struct smt_timer	*st_queue ;
244 	struct smt_timer	st_fast ;
245 } ;
246 
247 /*
248  * SRF types and data
249  */
250 #define SMT_EVENT_BASE			1
251 #define SMT_EVENT_MAC_PATH_CHANGE	(SMT_EVENT_BASE+0)
252 #define SMT_EVENT_MAC_NEIGHBOR_CHANGE	(SMT_EVENT_BASE+1)
253 #define SMT_EVENT_PORT_PATH_CHANGE	(SMT_EVENT_BASE+2)
254 #define SMT_EVENT_PORT_CONNECTION	(SMT_EVENT_BASE+3)
255 
256 #define SMT_IS_CONDITION(x)			((x)>=SMT_COND_BASE)
257 
258 #define SMT_COND_BASE		(SMT_EVENT_PORT_CONNECTION+1)
259 #define SMT_COND_SMT_PEER_WRAP		(SMT_COND_BASE+0)
260 #define SMT_COND_SMT_HOLD		(SMT_COND_BASE+1)
261 #define SMT_COND_MAC_FRAME_ERROR	(SMT_COND_BASE+2)
262 #define SMT_COND_MAC_DUP_ADDR		(SMT_COND_BASE+3)
263 #define SMT_COND_MAC_NOT_COPIED		(SMT_COND_BASE+4)
264 #define SMT_COND_PORT_EB_ERROR		(SMT_COND_BASE+5)
265 #define SMT_COND_PORT_LER		(SMT_COND_BASE+6)
266 
267 #define SR0_WAIT	0
268 #define SR1_HOLDOFF	1
269 #define SR2_DISABLED	2
270 
271 struct s_srf {
272 	u_long	SRThreshold ;			/* threshold value */
273 	u_char	RT_Flag ;			/* report transmitted flag */
274 	u_char	sr_state ;			/* state-machine */
275 	u_char	any_report ;			/* any report required */
276 	u_long	TSR ;				/* timer */
277 	u_short	ring_status ;			/* IBM ring status */
278 } ;
279 
280 /*
281  * IBM token ring status
282  */
283 #define RS_RES15	(1<<15)			/* reserved */
284 #define RS_HARDERROR	(1<<14)			/* ring down */
285 #define RS_SOFTERROR	(1<<13)			/* sent SRF */
286 #define RS_BEACON	(1<<12)			/* transmitted beacon */
287 #define RS_PATHTEST	(1<<11)			/* path test failed */
288 #define RS_SELFTEST	(1<<10)			/* selftest required */
289 #define RS_RES9		(1<< 9)			/* reserved */
290 #define RS_DISCONNECT	(1<< 8)			/* remote disconnect */
291 #define RS_RES7		(1<< 7)			/* reserved */
292 #define RS_DUPADDR	(1<< 6)			/* duplicate address */
293 #define RS_NORINGOP	(1<< 5)			/* no ring op */
294 #define RS_VERSION	(1<< 4)			/* SMT version mismatch */
295 #define RS_STUCKBYPASSS	(1<< 3)			/* stuck bypass */
296 #define RS_EVENT	(1<< 2)			/* FDDI event occurred */
297 #define RS_RINGOPCHANGE	(1<< 1)			/* ring op changed */
298 #define RS_RES0		(1<< 0)			/* reserved */
299 
300 #define RS_SET(smc,bit) \
301 	ring_status_indication(smc,smc->srf.ring_status |= bit)
302 #define RS_CLEAR(smc,bit)	\
303 	ring_status_indication(smc,smc->srf.ring_status &= ~bit)
304 
305 #define RS_CLEAR_EVENT	(0xffff & ~(RS_NORINGOP))
306 
307 /* Define the AIX-event-Notification as null function if it isn't defined */
308 /* in the targetos.h file */
309 #ifndef AIX_EVENT
310 #define AIX_EVENT(smc,opt0,opt1,opt2,opt3)	/* nothing */
311 #endif
312 
313 struct s_srf_evc {
314 	u_char	evc_code ;			/* event code type */
315 	u_char	evc_index ;			/* index for mult. instances */
316 	u_char	evc_rep_required ;		/* report required */
317 	u_short	evc_para ;			/* SMT Para Number */
318 	u_char	*evc_cond_state ;		/* condition state */
319 	u_char	*evc_multiple ;			/* multiple occurrence */
320 } ;
321 
322 /*
323  * Values used by frame based services
324  * smt.c
325  */
326 #define SMT_MAX_TEST		5
327 #define SMT_TID_NIF		0		/* pending NIF request */
328 #define SMT_TID_NIF_TEST	1		/* pending NIF test */
329 #define SMT_TID_ECF_UNA		2		/* pending ECF UNA test */
330 #define SMT_TID_ECF_DNA		3		/* pending ECF DNA test */
331 #define SMT_TID_ECF		4		/* pending ECF test */
332 
333 struct smt_values {
334 	u_long		smt_tvu ;		/* timer valid una */
335 	u_long		smt_tvd ;		/* timer valid dna */
336 	u_long		smt_tid ;		/* transaction id */
337 	u_long		pend[SMT_MAX_TEST] ;	/* TID of requests */
338 	u_long		uniq_time ;		/* unique time stamp */
339 	u_short		uniq_ticks  ;		/* unique time stamp */
340 	u_short		please_reconnect ;	/* flag : reconnect */
341 	u_long		smt_last_lem ;
342 	u_long		smt_last_notify ;
343 	struct smt_timer	smt_timer ;	/* SMT NIF timer */
344 	u_long		last_tok_time[NUMMACS];	/* token cnt emulation */
345 } ;
346 
347 /*
348  * SMT/CMT configurable parameters
349  */
350 #define SMT_DAS	0			/* dual attach */
351 #define SMT_SAS	1			/* single attach */
352 #define SMT_NAC	2			/* null attach concentrator */
353 
354 struct smt_config {
355 	u_char	attach_s ;		/* CFM attach to secondary path */
356 	u_char	sas ;			/* SMT_DAS/SAS/NAC */
357 	u_char	build_ring_map ;	/* build ringmap if TRUE */
358 	u_char	numphys ;		/* number of active phys */
359 	u_char	sc_pad[1] ;
360 
361 	u_long	pcm_tb_min ;		/* PCM : TB_Min timer value */
362 	u_long	pcm_tb_max ;		/* PCM : TB_Max timer value */
363 	u_long	pcm_c_min ;		/* PCM : C_Min timer value */
364 	u_long	pcm_t_out ;		/* PCM : T_Out timer value */
365 	u_long	pcm_tl_min ;		/* PCM : TL_min timer value */
366 	u_long	pcm_lc_short ;		/* PCM : LC_Short timer value */
367 	u_long	pcm_lc_medium ;		/* PCM : LC_Medium timer value */
368 	u_long	pcm_lc_long ;		/* PCM : LC_Long timer value */
369 	u_long	pcm_lc_extended ;	/* PCM : LC_Extended timer value */
370 	u_long	pcm_t_next_9 ;		/* PCM : T_Next[9] timer value */
371 	u_long	pcm_ns_max ;		/* PCM : NS_Max timer value */
372 
373 	u_long	ecm_i_max ;		/* ECM : I_Max timer value */
374 	u_long	ecm_in_max ;		/* ECM : IN_Max timer value */
375 	u_long	ecm_td_min ;		/* ECM : TD_Min timer */
376 	u_long	ecm_test_done ;		/* ECM : path test done timer */
377 	u_long	ecm_check_poll ;	/* ECM : check bypass poller */
378 
379 	u_long	rmt_t_non_op ;		/* RMT : T_Non_OP timer value */
380 	u_long	rmt_t_stuck ;		/* RMT : T_Stuck timer value */
381 	u_long	rmt_t_direct ;		/* RMT : T_Direct timer value */
382 	u_long	rmt_t_jam ;		/* RMT : T_Jam timer value */
383 	u_long	rmt_t_announce ;	/* RMT : T_Announce timer value */
384 	u_long	rmt_t_poll ;		/* RMT : claim/beacon poller */
385 	u_long  rmt_dup_mac_behavior ;  /* Flag for the beavior of SMT if
386 					 * a Duplicate MAC Address was detected.
387 					 * FALSE: SMT will leave finally the ring
388 					 * TRUE:  SMT will reinstert into the ring
389 					 */
390 	u_long	mac_d_max ;		/* MAC : D_Max timer value */
391 
392 	u_long lct_short ;		/* LCT : error threshold */
393 	u_long lct_medium ;		/* LCT : error threshold */
394 	u_long lct_long ;		/* LCT : error threshold */
395 	u_long lct_extended ;		/* LCT : error threshold */
396 } ;
397 
398 #ifdef	DEBUG
399 /*
400  * Debugging struct sometimes used in smc
401  */
402 struct	smt_debug {
403 	int	d_smtf ;
404 	int	d_smt ;
405 	int	d_ecm ;
406 	int	d_rmt ;
407 	int	d_cfm ;
408 	int	d_pcm ;
409 	int	d_plc ;
410 #ifdef	ESS
411 	int	d_ess ;
412 #endif
413 #ifdef	SBA
414 	int	d_sba ;
415 #endif
416 	struct	os_debug	d_os;	/* Include specific OS DEBUG struct */
417 } ;
418 
419 #ifndef	DEBUG_BRD
420 /* all boards shall be debugged with one debug struct */
421 extern	struct	smt_debug	debug;	/* Declaration of debug struct */
422 #endif	/* DEBUG_BRD */
423 
424 #endif	/* DEBUG */
425 
426 /*
427  * the SMT Context Struct SMC
428  * this struct contains ALL global variables of SMT
429  */
430 struct s_smc {
431 	struct s_smt_os	os ;		/* os specific */
432 	struct s_smt_hw	hw ;		/* hardware */
433 
434 /*
435  * NOTE: os and hw MUST BE the first two structs
436  * anything beyond hw WILL BE SET TO ZERO in smt_set_defaults()
437  */
438 	struct smt_config s ;		/* smt constants */
439 	struct smt_values sm ;		/* smt variables */
440 	struct s_ecm	e ;		/* ecm */
441 	struct s_rmt	r ;		/* rmt */
442 	struct s_cfm	cf ;		/* cfm/cem */
443 #ifdef	CONCENTRATOR
444 	struct s_cem	ce[NUMPHYS] ;	/* cem */
445 	struct s_c_ring	cr[NUMPHYS+NUMMACS] ;
446 #endif
447 	struct s_pcm	p ;		/* pcm */
448 	struct s_phy	y[NUMPHYS] ;	/* phy */
449 	struct s_queue	q ;		/* queue */
450 	struct s_timer	t ;		/* timer */
451 	struct s_srf srf ;		/* SRF */
452 	struct s_srf_evc evcs[6+NUMPHYS*4] ;
453 	struct fddi_mib	mib ;		/* __THE_MIB__ */
454 #ifdef	SBA
455 	struct s_sba	sba ;		/* SBA variables */
456 #endif
457 #ifdef	ESS
458 	struct s_ess	ess ;		/* Ess variables */
459 #endif
460 #if	defined(DEBUG) && defined(DEBUG_BRD)
461 	/* If you want all single board to be debugged separately */
462 	struct smt_debug	debug;	/* Declaration of debug struct */
463 #endif	/* DEBUG_BRD && DEBUG */
464 } ;
465 
466 extern const struct fddi_addr fddi_broadcast;
467 
468 void all_selection_criteria(struct s_smc *smc);
469 void card_stop(struct s_smc *smc);
470 void init_board(struct s_smc *smc, u_char *mac_addr);
471 int init_fplus(struct s_smc *smc);
472 void init_plc(struct s_smc *smc);
473 int init_smt(struct s_smc *smc, const u_char *mac_addr);
474 void mac1_irq(struct s_smc *smc, u_short stu, u_short stl);
475 void mac2_irq(struct s_smc *smc, u_short code_s2u, u_short code_s2l);
476 void mac3_irq(struct s_smc *smc, u_short code_s3u, u_short code_s3l);
477 int pcm_status_twisted(struct s_smc *smc);
478 void plc1_irq(struct s_smc *smc);
479 void plc2_irq(struct s_smc *smc);
480 void read_address(struct s_smc *smc, u_char *mac_addr);
481 void timer_irq(struct s_smc *smc);
482 
483 #endif	/* _SCMECM_ */
484 
485