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 *	See the file "skfddi.c" for further information.
8 *
9 *	The information in this file is provided "AS IS" without warranty.
10 *
11 ******************************************************************************/
12
13/*
14	Init SMT
15	call all module level initialization routines
16*/
17
18#include "h/types.h"
19#include "h/fddi.h"
20#include "h/smc.h"
21
22#ifndef	lint
23static const char ID_sccs[] = "@(#)smtinit.c	1.15 97/05/06 (C) SK " ;
24#endif
25
26void init_fddi_driver(struct s_smc *smc, u_char *mac_addr);
27
28/* define global debug variable */
29#if defined(DEBUG) && !defined(DEBUG_BRD)
30struct smt_debug debug;
31#endif
32
33#ifndef MULT_OEM
34#define OEMID(smc,i)	oem_id[i]
35	extern u_char	oem_id[] ;
36#else	/* MULT_OEM */
37#define OEMID(smc,i)	smc->hw.oem_id->oi_mark[i]
38	extern struct s_oem_ids	oem_ids[] ;
39#endif	/* MULT_OEM */
40
41/*
42 * Set OEM specific values
43 *
44 * Can not be called in smt_reset_defaults, because it is not sure that
45 * the OEM ID is already defined.
46 */
47static void set_oem_spec_val(struct s_smc *smc)
48{
49	struct fddi_mib *mib ;
50
51	mib = &smc->mib ;
52
53	/*
54	 * set IBM specific values
55	 */
56	if (OEMID(smc,0) == 'I') {
57		mib->fddiSMTConnectionPolicy = POLICY_MM ;
58	}
59}
60
61/*
62 * Init SMT
63 */
64int init_smt(struct s_smc *smc, u_char *mac_addr)
65/* u_char *mac_addr;	canonical address or NULL */
66{
67	int	p ;
68
69#if defined(DEBUG) && !defined(DEBUG_BRD)
70	debug.d_smt = 0 ;
71	debug.d_smtf = 0 ;
72	debug.d_rmt = 0 ;
73	debug.d_ecm = 0 ;
74	debug.d_pcm = 0 ;
75	debug.d_cfm = 0 ;
76
77	debug.d_plc = 0 ;
78#ifdef	ESS
79	debug.d_ess = 0 ;
80#endif
81#ifdef	SBA
82	debug.d_sba = 0 ;
83#endif
84#endif	/* DEBUG && !DEBUG_BRD */
85
86	/* First initialize the ports mib->pointers */
87	for ( p = 0; p < NUMPHYS; p ++ ) {
88		smc->y[p].mib = & smc->mib.p[p] ;
89	}
90
91	set_oem_spec_val(smc) ;
92	(void) smt_set_mac_opvalues(smc) ;
93	init_fddi_driver(smc,mac_addr) ;	/* HW driver */
94	smt_fixup_mib(smc) ;		/* update values that depend on s.sas */
95
96	ev_init(smc) ;			/* event queue */
97#ifndef	SLIM_SMT
98	smt_init_evc(smc) ;		/* evcs in MIB */
99#endif	/* no SLIM_SMT */
100	smt_timer_init(smc) ;		/* timer package */
101	smt_agent_init(smc) ;		/* SMT frame manager */
102
103	pcm_init(smc) ;			/* PCM state machine */
104	ecm_init(smc) ;			/* ECM state machine */
105	cfm_init(smc) ;			/* CFM state machine */
106	rmt_init(smc) ;			/* RMT state machine */
107
108	for (p = 0 ; p < NUMPHYS ; p++) {
109		pcm(smc,p,0) ;		/* PCM A state machine */
110	}
111	ecm(smc,0) ;			/* ECM state machine */
112	cfm(smc,0) ;			/* CFM state machine */
113	rmt(smc,0) ;			/* RMT state machine */
114
115	smt_agent_task(smc) ;		/* NIF FSM etc */
116
117        PNMI_INIT(smc) ;                /* PNMI initialization */
118
119	return 0;
120}
121
122