^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * (C)Copyright 1998,1999 SysKonnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * See the file "skfddi.c" for further information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * The information in this file is provided "AS IS" without warranty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "h/types.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "h/fddi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "h/smc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "h/smt_p.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/bitrev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define KERNEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "h/smtstate.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * FC in SMbuf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define m_fc(mb) ((mb)->sm_data[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define SMT_TID_MAGIC 0x1f0a7b3c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static const char *const smt_type_name[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) "SMT_00??", "SMT_INFO", "SMT_02??", "SMT_03??",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) "SMT_04??", "SMT_05??", "SMT_06??", "SMT_07??",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) "SMT_08??", "SMT_09??", "SMT_0A??", "SMT_0B??",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) "SMT_0C??", "SMT_0D??", "SMT_0E??", "SMT_NSA"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static const char *const smt_class_name[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) "UNKNOWN","NIF","SIF_CONFIG","SIF_OPER","ECF","RAF","RDF",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) "SRF","PMF_GET","PMF_SET","ESF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define LAST_CLASS (SMT_PMF_SET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static const struct fddi_addr SMT_Unknown = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) { 0,0,0x1f,0,0,0 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * function prototypes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #ifdef LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static int smt_swap_short(u_short s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static int mac_index(struct s_smc *smc, int mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static int phy_index(struct s_smc *smc, int phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static int mac_con_resource_index(struct s_smc *smc, int mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static int phy_con_resource_index(struct s_smc *smc, int phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) static void smt_send_rdf(struct s_smc *smc, SMbuf *rej, int fc, int reason,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static void smt_send_nif(struct s_smc *smc, const struct fddi_addr *dest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int fc, u_long tid, int type, int local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static void smt_send_ecf(struct s_smc *smc, struct fddi_addr *dest, int fc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) u_long tid, int type, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static void smt_echo_test(struct s_smc *smc, int dna);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static void smt_send_sif_config(struct s_smc *smc, struct fddi_addr *dest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) u_long tid, int local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static void smt_send_sif_operation(struct s_smc *smc, struct fddi_addr *dest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u_long tid, int local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #ifdef LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static void smt_string_swap(char *data, const char *format, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static void smt_add_frame_len(SMbuf *mb, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static void smt_fill_una(struct s_smc *smc, struct smt_p_una *una);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static void smt_fill_sde(struct s_smc *smc, struct smt_p_sde *sde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static void smt_fill_state(struct s_smc *smc, struct smt_p_state *state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static void smt_fill_timestamp(struct s_smc *smc, struct smt_p_timestamp *ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static void smt_fill_policy(struct s_smc *smc, struct smt_p_policy *policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static void smt_fill_latency(struct s_smc *smc, struct smt_p_latency *latency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static void smt_fill_neighbor(struct s_smc *smc, struct smt_p_neighbor *neighbor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) static int smt_fill_path(struct s_smc *smc, struct smt_p_path *path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static void smt_fill_mac_status(struct s_smc *smc, struct smt_p_mac_status *st);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static void smt_fill_lem(struct s_smc *smc, struct smt_p_lem *lem, int phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static void smt_fill_version(struct s_smc *smc, struct smt_p_version *vers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static void smt_fill_fsc(struct s_smc *smc, struct smt_p_fsc *fsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static void smt_fill_mac_counter(struct s_smc *smc, struct smt_p_mac_counter *mc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static void smt_fill_mac_fnc(struct s_smc *smc, struct smt_p_mac_fnc *fnc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static void smt_fill_manufacturer(struct s_smc *smc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct smp_p_manufacturer *man);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) static void smt_fill_user(struct s_smc *smc, struct smp_p_user *user);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static void smt_fill_setcount(struct s_smc *smc, struct smt_p_setcount *setcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static void smt_fill_echo(struct s_smc *smc, struct smt_p_echo *echo, u_long seed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) static void smt_clear_una_dna(struct s_smc *smc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static void smt_clear_old_una_dna(struct s_smc *smc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #ifdef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static int entity_to_index(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static void update_dac(struct s_smc *smc, int report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static int div_ratio(u_long upper, u_long lower);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #ifdef USE_CAN_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static void hwm_conv_can(struct s_smc *smc, char *data, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define hwm_conv_can(smc,data,len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static inline int is_my_addr(const struct s_smc *smc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) const struct fddi_addr *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return(*(short *)(&addr->a[0]) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) *(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) && *(short *)(&addr->a[2]) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) *(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[2])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) && *(short *)(&addr->a[4]) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) *(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[4])) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static inline int is_broadcast(const struct fddi_addr *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) return *(u_short *)(&addr->a[0]) == 0xffff &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) *(u_short *)(&addr->a[2]) == 0xffff &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) *(u_short *)(&addr->a[4]) == 0xffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static inline int is_individual(const struct fddi_addr *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return !(addr->a[0] & GROUP_ADDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static inline int is_equal(const struct fddi_addr *addr1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) const struct fddi_addr *addr2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return *(u_short *)(&addr1->a[0]) == *(u_short *)(&addr2->a[0]) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) *(u_short *)(&addr1->a[2]) == *(u_short *)(&addr2->a[2]) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) *(u_short *)(&addr1->a[4]) == *(u_short *)(&addr2->a[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * list of mandatory paras in frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static const u_short plist_nif[] = { SMT_P_UNA,SMT_P_SDE,SMT_P_STATE,0 } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * init SMT agent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) void smt_agent_init(struct s_smc *smc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) int i ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * get MAC address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) smc->mib.m[MAC0].fddiMACSMTAddress = smc->hw.fddi_home_addr ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * get OUI address from driver (bia == built-in-address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) smc->mib.fddiSMTStationId.sid_oem[0] = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) smc->mib.fddiSMTStationId.sid_oem[1] = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) driver_get_bia(smc,&smc->mib.fddiSMTStationId.sid_node) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) for (i = 0 ; i < 6 ; i ++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) smc->mib.fddiSMTStationId.sid_node.a[i] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) bitrev8(smc->mib.fddiSMTStationId.sid_node.a[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) smc->mib.fddiSMTManufacturerData[0] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) smc->mib.fddiSMTStationId.sid_node.a[0] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) smc->mib.fddiSMTManufacturerData[1] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) smc->mib.fddiSMTStationId.sid_node.a[1] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) smc->mib.fddiSMTManufacturerData[2] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) smc->mib.fddiSMTStationId.sid_node.a[2] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) smc->sm.smt_tid = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) smc->mib.m[MAC0].fddiMACDupAddressTest = DA_NONE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) smc->mib.m[MAC0].fddiMACUNDA_Flag = FALSE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #ifndef SLIM_SMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) smt_clear_una_dna(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) smt_clear_old_una_dna(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) for (i = 0 ; i < SMT_MAX_TEST ; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) smc->sm.pend[i] = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) smc->sm.please_reconnect = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) smc->sm.uniq_ticks = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * SMT task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * forever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * delay 30 seconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * send NIF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * check tvu & tvd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) void smt_agent_task(struct s_smc *smc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) smt_timer_start(smc,&smc->sm.smt_timer, (u_long)1000000L,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) EV_TOKEN(EVENT_SMT,SM_TIMER)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) DB_SMT("SMT agent task");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #ifndef SMT_REAL_TOKEN_CT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) void smt_emulate_token_ct(struct s_smc *smc, int mac_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) u_long count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) u_long time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) time = smt_get_time();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) count = ((time - smc->sm.last_tok_time[mac_index]) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 100)/TICKS_PER_SECOND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * Only when ring is up we will have a token count. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * flag is unfortunately a single instance value. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * doesn't matter now, because we currently have only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * one MAC instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (smc->hw.mac_ring_is_up){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) smc->mib.m[mac_index].fddiMACToken_Ct += count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /* Remember current time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) smc->sm.last_tok_time[mac_index] = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /*ARGSUSED1*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) void smt_event(struct s_smc *smc, int event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) u_long time ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #ifndef SMT_REAL_TOKEN_CT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) int i ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (smc->sm.please_reconnect) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) smc->sm.please_reconnect -- ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if (smc->sm.please_reconnect == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) /* Counted down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) queue_event(smc,EVENT_ECM,EC_CONNECT) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (event == SM_FAST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * timer for periodic cleanup in driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * reset and start the watchdog (FM2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * ESS timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * SBA timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) smt_timer_poll(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) smt_start_watchdog(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) #ifndef SLIM_SMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) #ifndef BOOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) #ifdef ESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) ess_timer_poll(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) #ifdef SBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) sba_timer_poll(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) smt_srf_event(smc,0,0,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) #endif /* no SLIM_SMT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) time = smt_get_time() ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (time - smc->sm.smt_last_lem >= TICKS_PER_SECOND*8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) * Use 8 sec. for the time intervall, it simplifies the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * LER estimation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct fddi_mib_m *mib ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) u_long upper ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) u_long lower ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) int cond ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) int port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) struct s_phy *phy ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * calculate LEM bit error rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) sm_lem_evaluate(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) smc->sm.smt_last_lem = time ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) * check conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) #ifndef SLIM_SMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) mac_update_counter(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) mib = smc->mib.m ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) upper =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) (mib->fddiMACLost_Ct - mib->fddiMACOld_Lost_Ct) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) (mib->fddiMACError_Ct - mib->fddiMACOld_Error_Ct) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) lower =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) (mib->fddiMACFrame_Ct - mib->fddiMACOld_Frame_Ct) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) (mib->fddiMACLost_Ct - mib->fddiMACOld_Lost_Ct) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) mib->fddiMACFrameErrorRatio = div_ratio(upper,lower) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) cond =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) ((!mib->fddiMACFrameErrorThreshold &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) mib->fddiMACError_Ct != mib->fddiMACOld_Error_Ct) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) (mib->fddiMACFrameErrorRatio >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) mib->fddiMACFrameErrorThreshold)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) if (cond != mib->fddiMACFrameErrorFlag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) smt_srf_event(smc,SMT_COND_MAC_FRAME_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) INDEX_MAC,cond) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) upper =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) (mib->fddiMACNotCopied_Ct - mib->fddiMACOld_NotCopied_Ct) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) lower =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) upper +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) (mib->fddiMACCopied_Ct - mib->fddiMACOld_Copied_Ct) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) mib->fddiMACNotCopiedRatio = div_ratio(upper,lower) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) cond =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) ((!mib->fddiMACNotCopiedThreshold &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) mib->fddiMACNotCopied_Ct !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) mib->fddiMACOld_NotCopied_Ct)||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) (mib->fddiMACNotCopiedRatio >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) mib->fddiMACNotCopiedThreshold)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (cond != mib->fddiMACNotCopiedFlag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) smt_srf_event(smc,SMT_COND_MAC_NOT_COPIED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) INDEX_MAC,cond) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * set old values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) mib->fddiMACOld_Frame_Ct = mib->fddiMACFrame_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) mib->fddiMACOld_Copied_Ct = mib->fddiMACCopied_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) mib->fddiMACOld_Error_Ct = mib->fddiMACError_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) mib->fddiMACOld_Lost_Ct = mib->fddiMACLost_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) mib->fddiMACOld_NotCopied_Ct = mib->fddiMACNotCopied_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * Check port EBError Condition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) for (port = 0; port < NUMPHYS; port ++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) phy = &smc->y[port] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) if (!phy->mib->fddiPORTHardwarePresent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) cond = (phy->mib->fddiPORTEBError_Ct -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) phy->mib->fddiPORTOldEBError_Ct > 5) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) /* If ratio is more than 5 in 8 seconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * Set the condition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) smt_srf_event(smc,SMT_COND_PORT_EB_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) (int) (INDEX_PORT+ phy->np) ,cond) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) * set old values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) phy->mib->fddiPORTOldEBError_Ct =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) phy->mib->fddiPORTEBError_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) #endif /* no SLIM_SMT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #ifndef SLIM_SMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) if (time - smc->sm.smt_last_notify >= (u_long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) (smc->mib.fddiSMTTT_Notify * TICKS_PER_SECOND) ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * we can either send an announcement or a request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * a request will trigger a reply so that we can update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * our dna
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * note: same tid must be used until reply is received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) if (!smc->sm.pend[SMT_TID_NIF])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) smc->sm.pend[SMT_TID_NIF] = smt_get_tid(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) smt_send_nif(smc,&fddi_broadcast, FC_SMT_NSA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) smc->sm.pend[SMT_TID_NIF], SMT_REQUEST,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) smc->sm.smt_last_notify = time ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) * check timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) if (smc->sm.smt_tvu &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) time - smc->sm.smt_tvu > 228*TICKS_PER_SECOND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) DB_SMT("SMT : UNA expired");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) smc->sm.smt_tvu = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) if (!is_equal(&smc->mib.m[MAC0].fddiMACUpstreamNbr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) &SMT_Unknown)){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) /* Do not update unknown address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) smc->mib.m[MAC0].fddiMACOldUpstreamNbr=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) smc->mib.m[MAC0].fddiMACUpstreamNbr ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) smc->mib.m[MAC0].fddiMACUpstreamNbr = SMT_Unknown ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) smc->mib.m[MAC0].fddiMACUNDA_Flag = FALSE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) * Make sure the fddiMACUNDA_Flag = FALSE is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) * included in the SRF so we don't generate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) * a separate SRF for the deassertion of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) * condition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) update_dac(smc,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) smt_srf_event(smc, SMT_EVENT_MAC_NEIGHBOR_CHANGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) INDEX_MAC,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) if (smc->sm.smt_tvd &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) time - smc->sm.smt_tvd > 228*TICKS_PER_SECOND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) DB_SMT("SMT : DNA expired");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) smc->sm.smt_tvd = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) if (!is_equal(&smc->mib.m[MAC0].fddiMACDownstreamNbr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) &SMT_Unknown)){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /* Do not update unknown address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) smc->mib.m[MAC0].fddiMACOldDownstreamNbr=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) smc->mib.m[MAC0].fddiMACDownstreamNbr ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) smc->mib.m[MAC0].fddiMACDownstreamNbr = SMT_Unknown ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) smt_srf_event(smc, SMT_EVENT_MAC_NEIGHBOR_CHANGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) INDEX_MAC,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) #endif /* no SLIM_SMT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) #ifndef SMT_REAL_TOKEN_CT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * Token counter emulation section. If hardware supports the token
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) * count, the token counter will be updated in mac_update_counter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) for (i = MAC0; i < NUMMACS; i++ ){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) if (time - smc->sm.last_tok_time[i] > 2*TICKS_PER_SECOND ){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) smt_emulate_token_ct( smc, i );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) smt_timer_start(smc,&smc->sm.smt_timer, (u_long)1000000L,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) EV_TOKEN(EVENT_SMT,SM_TIMER)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) static int div_ratio(u_long upper, u_long lower)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) if ((upper<<16L) < upper)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) upper = 0xffff0000L ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) upper <<= 16L ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) if (!lower)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) return (int)(upper/lower) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) #ifndef SLIM_SMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) * receive packet handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) void smt_received_pack(struct s_smc *smc, SMbuf *mb, int fs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) /* int fs; frame status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) struct smt_header *sm ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) int local ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) int illegal = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) switch (m_fc(mb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) case FC_SMT_INFO :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) case FC_SMT_LAN_LOC :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) case FC_SMT_LOC :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) case FC_SMT_NSA :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) default :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) smt_free_mbuf(smc,mb) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) smc->mib.m[MAC0].fddiMACSMTCopied_Ct++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) sm = smtod(mb,struct smt_header *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) local = ((fs & L_INDICATOR) != 0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) hwm_conv_can(smc,(char *)sm,12) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) /* check destination address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) if (is_individual(&sm->smt_dest) && !is_my_addr(smc,&sm->smt_dest)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) smt_free_mbuf(smc,mb) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) #if 0 /* for DUP recognition, do NOT filter them */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) /* ignore loop back packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) if (is_my_addr(smc,&sm->smt_source) && !local) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) smt_free_mbuf(smc,mb) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) smt_swap_para(sm,(int) mb->sm_len,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) DB_SMT("SMT : received packet [%s] at 0x%p",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) smt_type_name[m_fc(mb) & 0xf], sm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) DB_SMT("SMT : version %d, class %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) sm->smt_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) smt_class_name[sm->smt_class > LAST_CLASS ? 0 : sm->smt_class]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) #ifdef SBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * check if NSA frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) if (m_fc(mb) == FC_SMT_NSA && sm->smt_class == SMT_NIF &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) (sm->smt_type == SMT_ANNOUNCE || sm->smt_type == SMT_REQUEST)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) smc->sba.sm = sm ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) sba(smc,NIF) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) * ignore any packet with NSA and A-indicator set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) if ( (fs & A_INDICATOR) && m_fc(mb) == FC_SMT_NSA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) DB_SMT("SMT : ignoring NSA with A-indicator set from %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) smt_free_mbuf(smc,mb) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) * ignore frames with illegal length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) if (((sm->smt_class == SMT_ECF) && (sm->smt_len > SMT_MAX_ECHO_LEN)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) ((sm->smt_class != SMT_ECF) && (sm->smt_len > SMT_MAX_INFO_LEN))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) smt_free_mbuf(smc,mb) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) * check SMT version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) switch (sm->smt_class) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) case SMT_NIF :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) case SMT_SIF_CONFIG :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) case SMT_SIF_OPER :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) case SMT_ECF :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) if (sm->smt_version != SMT_VID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) illegal = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) default :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) if (sm->smt_version != SMT_VID_2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) illegal = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) if (illegal) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) DB_SMT("SMT : version = %d, dest = %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) sm->smt_version, &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) smt_send_rdf(smc,mb,m_fc(mb),SMT_RDF_VERSION,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) smt_free_mbuf(smc,mb) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) if ((sm->smt_len > mb->sm_len - sizeof(struct smt_header)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) ((sm->smt_len & 3) && (sm->smt_class != SMT_ECF))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) DB_SMT("SMT: info length error, len = %d", sm->smt_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) smt_send_rdf(smc,mb,m_fc(mb),SMT_RDF_LENGTH,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) smt_free_mbuf(smc,mb) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) switch (sm->smt_class) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) case SMT_NIF :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) if (smt_check_para(smc,sm,plist_nif)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) DB_SMT("SMT: NIF with para problem, ignoring");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) switch (sm->smt_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) case SMT_ANNOUNCE :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) case SMT_REQUEST :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) if (!(fs & C_INDICATOR) && m_fc(mb) == FC_SMT_NSA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) && is_broadcast(&sm->smt_dest)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) struct smt_p_state *st ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) /* set my UNA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) if (!is_equal(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) &smc->mib.m[MAC0].fddiMACUpstreamNbr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) &sm->smt_source)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) DB_SMT("SMT : updated my UNA = %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) if (!is_equal(&smc->mib.m[MAC0].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) fddiMACUpstreamNbr,&SMT_Unknown)){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) /* Do not update unknown address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) smc->mib.m[MAC0].fddiMACOldUpstreamNbr=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) smc->mib.m[MAC0].fddiMACUpstreamNbr ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) smc->mib.m[MAC0].fddiMACUpstreamNbr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) sm->smt_source ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) smt_srf_event(smc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) SMT_EVENT_MAC_NEIGHBOR_CHANGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) INDEX_MAC,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) smt_echo_test(smc,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) smc->sm.smt_tvu = smt_get_time() ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) st = (struct smt_p_state *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) sm_to_para(smc,sm,SMT_P_STATE) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) if (st) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) smc->mib.m[MAC0].fddiMACUNDA_Flag =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) (st->st_dupl_addr & SMT_ST_MY_DUPA) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) TRUE : FALSE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) update_dac(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) if ((sm->smt_type == SMT_REQUEST) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) is_individual(&sm->smt_source) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) ((!(fs & A_INDICATOR) && m_fc(mb) == FC_SMT_NSA) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) (m_fc(mb) != FC_SMT_NSA))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) DB_SMT("SMT : replying to NIF request %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) smt_send_nif(smc,&sm->smt_source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) FC_SMT_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) sm->smt_tid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) SMT_REPLY,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) case SMT_REPLY :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) DB_SMT("SMT : received NIF response from %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) if (fs & A_INDICATOR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) smc->sm.pend[SMT_TID_NIF] = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) DB_SMT("SMT : duplicate address");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) smc->mib.m[MAC0].fddiMACDupAddressTest =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) DA_FAILED ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) smc->r.dup_addr_test = DA_FAILED ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) queue_event(smc,EVENT_RMT,RM_DUP_ADDR) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) smc->mib.m[MAC0].fddiMACDA_Flag = TRUE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) update_dac(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) if (sm->smt_tid == smc->sm.pend[SMT_TID_NIF]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) smc->sm.pend[SMT_TID_NIF] = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) /* set my DNA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) if (!is_equal(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) &smc->mib.m[MAC0].fddiMACDownstreamNbr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) &sm->smt_source)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) DB_SMT("SMT : updated my DNA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) if (!is_equal(&smc->mib.m[MAC0].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) fddiMACDownstreamNbr, &SMT_Unknown)){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) /* Do not update unknown address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) smc->mib.m[MAC0].fddiMACOldDownstreamNbr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) smc->mib.m[MAC0].fddiMACDownstreamNbr ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) smc->mib.m[MAC0].fddiMACDownstreamNbr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) sm->smt_source ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) smt_srf_event(smc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) SMT_EVENT_MAC_NEIGHBOR_CHANGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) INDEX_MAC,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) smt_echo_test(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) smc->mib.m[MAC0].fddiMACDA_Flag = FALSE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) update_dac(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) smc->sm.smt_tvd = smt_get_time() ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) smc->mib.m[MAC0].fddiMACDupAddressTest =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) DA_PASSED ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) if (smc->r.dup_addr_test != DA_PASSED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) smc->r.dup_addr_test = DA_PASSED ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) queue_event(smc,EVENT_RMT,RM_DUP_ADDR) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) else if (sm->smt_tid ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) smc->sm.pend[SMT_TID_NIF_TEST]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) DB_SMT("SMT : NIF test TID ok");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) DB_SMT("SMT : expected TID %lx, got %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) smc->sm.pend[SMT_TID_NIF], sm->smt_tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) default :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) illegal = 2 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) case SMT_SIF_CONFIG : /* station information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) if (sm->smt_type != SMT_REQUEST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) DB_SMT("SMT : replying to SIF Config request from %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) smt_send_sif_config(smc,&sm->smt_source,sm->smt_tid,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) case SMT_SIF_OPER : /* station information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (sm->smt_type != SMT_REQUEST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) DB_SMT("SMT : replying to SIF Operation request from %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) smt_send_sif_operation(smc,&sm->smt_source,sm->smt_tid,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) case SMT_ECF : /* echo frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) switch (sm->smt_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) case SMT_REPLY :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) smc->mib.priv.fddiPRIVECF_Reply_Rx++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) DB_SMT("SMT: received ECF reply from %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) if (sm_to_para(smc,sm,SMT_P_ECHODATA) == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) DB_SMT("SMT: ECHODATA missing");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) if (sm->smt_tid == smc->sm.pend[SMT_TID_ECF]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) DB_SMT("SMT : ECF test TID ok");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) else if (sm->smt_tid == smc->sm.pend[SMT_TID_ECF_UNA]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) DB_SMT("SMT : ECF test UNA ok");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) else if (sm->smt_tid == smc->sm.pend[SMT_TID_ECF_DNA]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) DB_SMT("SMT : ECF test DNA ok");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) DB_SMT("SMT : expected TID %lx, got %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) smc->sm.pend[SMT_TID_ECF],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) sm->smt_tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) case SMT_REQUEST :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) smc->mib.priv.fddiPRIVECF_Req_Rx++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) if (sm->smt_len && !sm_to_para(smc,sm,SMT_P_ECHODATA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) DB_SMT("SMT: ECF with para problem,sending RDF");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) smt_send_rdf(smc,mb,m_fc(mb),SMT_RDF_LENGTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) DB_SMT("SMT - sending ECF reply to %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) /* set destination addr. & reply */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) sm->smt_dest = sm->smt_source ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) sm->smt_type = SMT_REPLY ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) dump_smt(smc,sm,"ECF REPLY") ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) smc->mib.priv.fddiPRIVECF_Reply_Tx++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) smt_send_frame(smc,mb,FC_SMT_INFO,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) return ; /* DON'T free mbuf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) default :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) illegal = 1 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) #ifndef BOOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) case SMT_RAF : /* resource allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) #ifdef ESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) DB_ESSN(2, "ESS: RAF frame received");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) fs = ess_raf_received_pack(smc,mb,sm,fs) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) #ifdef SBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) DB_SBAN(2,"SBA: RAF frame received\n",0,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) sba_raf_received_pack(smc,sm,fs) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) case SMT_RDF : /* request denied */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) smc->mib.priv.fddiPRIVRDF_Rx++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) case SMT_ESF : /* extended service - not supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) if (sm->smt_type == SMT_REQUEST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) DB_SMT("SMT - received ESF, sending RDF");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) smt_send_rdf(smc,mb,m_fc(mb),SMT_RDF_CLASS,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) case SMT_PMF_GET :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) case SMT_PMF_SET :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) if (sm->smt_type != SMT_REQUEST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) /* update statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) if (sm->smt_class == SMT_PMF_GET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) smc->mib.priv.fddiPRIVPMF_Get_Rx++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) smc->mib.priv.fddiPRIVPMF_Set_Rx++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) * ignore PMF SET with I/G set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) if ((sm->smt_class == SMT_PMF_SET) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) !is_individual(&sm->smt_dest)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) DB_SMT("SMT: ignoring PMF-SET with I/G set");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) smt_pmf_received_pack(smc,mb, local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) case SMT_SRF :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) dump_smt(smc,sm,"SRF received") ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) default :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) if (sm->smt_type != SMT_REQUEST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) * For frames with unknown class:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) * we need to send a RDF frame according to 8.1.3.1.1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) * only if it is a REQUEST.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) DB_SMT("SMT : class = %d, send RDF to %pM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) sm->smt_class, &sm->smt_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) smt_send_rdf(smc,mb,m_fc(mb),SMT_RDF_CLASS,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) if (illegal) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) DB_SMT("SMT: discarding invalid frame, reason = %d", illegal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) smt_free_mbuf(smc,mb) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) static void update_dac(struct s_smc *smc, int report)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) int cond ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) cond = ( smc->mib.m[MAC0].fddiMACUNDA_Flag |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) smc->mib.m[MAC0].fddiMACDA_Flag) != 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) if (report && (cond != smc->mib.m[MAC0].fddiMACDuplicateAddressCond))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) smt_srf_event(smc, SMT_COND_MAC_DUP_ADDR,INDEX_MAC,cond) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) smc->mib.m[MAC0].fddiMACDuplicateAddressCond = cond ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) * send SMT frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) * set source address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) * set station ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) * send frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) void smt_send_frame(struct s_smc *smc, SMbuf *mb, int fc, int local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) /* SMbuf *mb; buffer to send */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) /* int fc; FC value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) struct smt_header *sm ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) if (!smc->r.sm_ma_avail && !local) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) smt_free_mbuf(smc,mb) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) sm = smtod(mb,struct smt_header *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) sm->smt_source = smc->mib.m[MAC0].fddiMACSMTAddress ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) sm->smt_sid = smc->mib.fddiSMTStationId ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) smt_swap_para(sm,(int) mb->sm_len,0) ; /* swap para & header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) hwm_conv_can(smc,(char *)sm,12) ; /* convert SA and DA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) smc->mib.m[MAC0].fddiMACSMTTransmit_Ct++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) smt_send_mbuf(smc,mb,local ? FC_SMT_LOC : fc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) * generate and send RDF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) static void smt_send_rdf(struct s_smc *smc, SMbuf *rej, int fc, int reason,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) int local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) /* SMbuf *rej; mbuf of offending frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) /* int fc; FC of denied frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) /* int reason; reason code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) SMbuf *mb ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) struct smt_header *sm ; /* header of offending frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) struct smt_rdf *rdf ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) int len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) int frame_len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) sm = smtod(rej,struct smt_header *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) if (sm->smt_type != SMT_REQUEST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) DB_SMT("SMT: sending RDF to %pM,reason = 0x%x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) &sm->smt_source, reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) * note: get framelength from MAC length, NOT from SMT header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) * smt header length is included in sm_len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) frame_len = rej->sm_len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) if (!(mb=smt_build_frame(smc,SMT_RDF,SMT_REPLY,sizeof(struct smt_rdf))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) rdf = smtod(mb,struct smt_rdf *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) rdf->smt.smt_tid = sm->smt_tid ; /* use TID from sm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) rdf->smt.smt_dest = sm->smt_source ; /* set dest = source */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) /* set P12 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) rdf->reason.para.p_type = SMT_P_REASON ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) rdf->reason.para.p_len = sizeof(struct smt_p_reason) - PARA_LEN ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) rdf->reason.rdf_reason = reason ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) /* set P14 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) rdf->version.para.p_type = SMT_P_VERSION ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) rdf->version.para.p_len = sizeof(struct smt_p_version) - PARA_LEN ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) rdf->version.v_pad = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) rdf->version.v_n = 1 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) rdf->version.v_index = 1 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) rdf->version.v_version[0] = SMT_VID_2 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) rdf->version.v_pad2 = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) /* set P13 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) if ((unsigned int) frame_len <= SMT_MAX_INFO_LEN - sizeof(*rdf) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) 2*sizeof(struct smt_header))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) len = frame_len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) len = SMT_MAX_INFO_LEN - sizeof(*rdf) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) 2*sizeof(struct smt_header) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) /* make length multiple of 4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) len &= ~3 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) rdf->refused.para.p_type = SMT_P_REFUSED ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) /* length of para is smt_frame + ref_fc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) rdf->refused.para.p_len = len + 4 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) rdf->refused.ref_fc = fc ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) /* swap it back */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) smt_swap_para(sm,frame_len,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) memcpy((char *) &rdf->refused.ref_header,(char *) sm,len) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) len -= sizeof(struct smt_header) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) mb->sm_len += len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) rdf->smt.smt_len += len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) dump_smt(smc,(struct smt_header *)rdf,"RDF") ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) smc->mib.priv.fddiPRIVRDF_Tx++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) smt_send_frame(smc,mb,FC_SMT_INFO,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) * generate and send NIF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) static void smt_send_nif(struct s_smc *smc, const struct fddi_addr *dest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) int fc, u_long tid, int type, int local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) /* struct fddi_addr *dest; dest address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) /* int fc; frame control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) /* u_long tid; transaction id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) /* int type; frame type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) struct smt_nif *nif ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) SMbuf *mb ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) if (!(mb = smt_build_frame(smc,SMT_NIF,type,sizeof(struct smt_nif))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) nif = smtod(mb, struct smt_nif *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) smt_fill_una(smc,&nif->una) ; /* set UNA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) smt_fill_sde(smc,&nif->sde) ; /* set station descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) smt_fill_state(smc,&nif->state) ; /* set state information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) #ifdef SMT6_10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) smt_fill_fsc(smc,&nif->fsc) ; /* set frame status cap. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) nif->smt.smt_dest = *dest ; /* destination address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) nif->smt.smt_tid = tid ; /* transaction ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) dump_smt(smc,(struct smt_header *)nif,"NIF") ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) smt_send_frame(smc,mb,fc,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) * send NIF request (test purpose)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) static void smt_send_nif_request(struct s_smc *smc, struct fddi_addr *dest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) smc->sm.pend[SMT_TID_NIF_TEST] = smt_get_tid(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) smt_send_nif(smc,dest, FC_SMT_INFO, smc->sm.pend[SMT_TID_NIF_TEST],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) SMT_REQUEST,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) * send ECF request (test purpose)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) static void smt_send_ecf_request(struct s_smc *smc, struct fddi_addr *dest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) smc->sm.pend[SMT_TID_ECF] = smt_get_tid(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) smt_send_ecf(smc,dest, FC_SMT_INFO, smc->sm.pend[SMT_TID_ECF],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) SMT_REQUEST,len) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) * echo test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) static void smt_echo_test(struct s_smc *smc, int dna)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) u_long tid ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) smc->sm.pend[dna ? SMT_TID_ECF_DNA : SMT_TID_ECF_UNA] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) tid = smt_get_tid(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) smt_send_ecf(smc, dna ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) &smc->mib.m[MAC0].fddiMACDownstreamNbr :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) &smc->mib.m[MAC0].fddiMACUpstreamNbr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) FC_SMT_INFO,tid, SMT_REQUEST, (SMT_TEST_ECHO_LEN & ~3)-8) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) * generate and send ECF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) static void smt_send_ecf(struct s_smc *smc, struct fddi_addr *dest, int fc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) u_long tid, int type, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) /* struct fddi_addr *dest; dest address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) /* int fc; frame control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) /* u_long tid; transaction id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) /* int type; frame type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) /* int len; frame length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) struct smt_ecf *ecf ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) SMbuf *mb ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) if (!(mb = smt_build_frame(smc,SMT_ECF,type,SMT_ECF_LEN + len)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) ecf = smtod(mb, struct smt_ecf *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) smt_fill_echo(smc,&ecf->ec_echo,tid,len) ; /* set ECHO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) ecf->smt.smt_dest = *dest ; /* destination address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) ecf->smt.smt_tid = tid ; /* transaction ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) smc->mib.priv.fddiPRIVECF_Req_Tx++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) smt_send_frame(smc,mb,fc,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) * generate and send SIF config response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) static void smt_send_sif_config(struct s_smc *smc, struct fddi_addr *dest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) u_long tid, int local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) /* struct fddi_addr *dest; dest address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) /* u_long tid; transaction id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) struct smt_sif_config *sif ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) SMbuf *mb ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) int len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) if (!(mb = smt_build_frame(smc,SMT_SIF_CONFIG,SMT_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) SIZEOF_SMT_SIF_CONFIG)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) sif = smtod(mb, struct smt_sif_config *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) smt_fill_timestamp(smc,&sif->ts) ; /* set time stamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) smt_fill_sde(smc,&sif->sde) ; /* set station descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) smt_fill_version(smc,&sif->version) ; /* set version information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) smt_fill_state(smc,&sif->state) ; /* set state information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) smt_fill_policy(smc,&sif->policy) ; /* set station policy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) smt_fill_latency(smc,&sif->latency); /* set station latency */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) smt_fill_neighbor(smc,&sif->neighbor); /* set station neighbor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) smt_fill_setcount(smc,&sif->setcount) ; /* set count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) len = smt_fill_path(smc,&sif->path); /* set station path descriptor*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) sif->smt.smt_dest = *dest ; /* destination address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) sif->smt.smt_tid = tid ; /* transaction ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) smt_add_frame_len(mb,len) ; /* adjust length fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) dump_smt(smc,(struct smt_header *)sif,"SIF Configuration Reply") ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) smt_send_frame(smc,mb,FC_SMT_INFO,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) * generate and send SIF operation response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) static void smt_send_sif_operation(struct s_smc *smc, struct fddi_addr *dest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) u_long tid, int local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) /* struct fddi_addr *dest; dest address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) /* u_long tid; transaction id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) struct smt_sif_operation *sif ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) SMbuf *mb ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) int ports ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) int i ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) ports = NUMPHYS ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) #ifndef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) if (smc->s.sas == SMT_SAS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) ports = 1 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) if (!(mb = smt_build_frame(smc,SMT_SIF_OPER,SMT_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) SIZEOF_SMT_SIF_OPERATION+ports*sizeof(struct smt_p_lem))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) return ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) sif = smtod(mb, struct smt_sif_operation *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) smt_fill_timestamp(smc,&sif->ts) ; /* set time stamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) smt_fill_mac_status(smc,&sif->status) ; /* set mac status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) smt_fill_mac_counter(smc,&sif->mc) ; /* set mac counter field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) smt_fill_mac_fnc(smc,&sif->fnc) ; /* set frame not copied counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) smt_fill_manufacturer(smc,&sif->man) ; /* set manufacturer field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) smt_fill_user(smc,&sif->user) ; /* set user field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) smt_fill_setcount(smc,&sif->setcount) ; /* set count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) * set link error mon information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) if (ports == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) smt_fill_lem(smc,sif->lem,PS) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) for (i = 0 ; i < ports ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) smt_fill_lem(smc,&sif->lem[i],i) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) sif->smt.smt_dest = *dest ; /* destination address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) sif->smt.smt_tid = tid ; /* transaction ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) dump_smt(smc,(struct smt_header *)sif,"SIF Operation Reply") ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) smt_send_frame(smc,mb,FC_SMT_INFO,local) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) * get and initialize SMT frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) SMbuf *smt_build_frame(struct s_smc *smc, int class, int type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) SMbuf *mb ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) struct smt_header *smt ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) if (!smc->r.sm_ma_avail) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) if (!(mb = smt_get_mbuf(smc)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) return mb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) mb->sm_len = length ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) smt = smtod(mb, struct smt_header *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) smt->smt_dest = fddi_broadcast ; /* set dest = broadcast */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) smt->smt_class = class ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) smt->smt_type = type ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) switch (class) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) case SMT_NIF :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) case SMT_SIF_CONFIG :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) case SMT_SIF_OPER :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) case SMT_ECF :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) smt->smt_version = SMT_VID ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) default :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) smt->smt_version = SMT_VID_2 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) smt->smt_tid = smt_get_tid(smc) ; /* set transaction ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) smt->smt_pad = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) smt->smt_len = length - sizeof(struct smt_header) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) return mb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) static void smt_add_frame_len(SMbuf *mb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) struct smt_header *smt ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) smt = smtod(mb, struct smt_header *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) smt->smt_len += len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) mb->sm_len += len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) * fill values in UNA parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) static void smt_fill_una(struct s_smc *smc, struct smt_p_una *una)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) SMTSETPARA(una,SMT_P_UNA) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) una->una_pad = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) una->una_node = smc->mib.m[MAC0].fddiMACUpstreamNbr ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) * fill values in SDE parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) static void smt_fill_sde(struct s_smc *smc, struct smt_p_sde *sde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) SMTSETPARA(sde,SMT_P_SDE) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) sde->sde_non_master = smc->mib.fddiSMTNonMaster_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) sde->sde_master = smc->mib.fddiSMTMaster_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) sde->sde_mac_count = NUMMACS ; /* only 1 MAC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) #ifdef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) sde->sde_type = SMT_SDE_CONCENTRATOR ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) sde->sde_type = SMT_SDE_STATION ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) * fill in values in station state parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) static void smt_fill_state(struct s_smc *smc, struct smt_p_state *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) int top ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) int twist ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) SMTSETPARA(state,SMT_P_STATE) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) state->st_pad = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) /* determine topology */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) top = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) if (smc->mib.fddiSMTPeerWrapFlag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) top |= SMT_ST_WRAPPED ; /* state wrapped */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) #ifdef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) if (cfm_status_unattached(smc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) top |= SMT_ST_UNATTACHED ; /* unattached concentrator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) if ((twist = pcm_status_twisted(smc)) & 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) top |= SMT_ST_TWISTED_A ; /* twisted cable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) if (twist & 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) top |= SMT_ST_TWISTED_B ; /* twisted cable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) #ifdef OPT_SRF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) top |= SMT_ST_SRF ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) if (pcm_rooted_station(smc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) top |= SMT_ST_ROOTED_S ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) if (smc->mib.a[0].fddiPATHSbaPayload != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) top |= SMT_ST_SYNC_SERVICE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) state->st_topology = top ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) state->st_dupl_addr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) ((smc->mib.m[MAC0].fddiMACDA_Flag ? SMT_ST_MY_DUPA : 0 ) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) (smc->mib.m[MAC0].fddiMACUNDA_Flag ? SMT_ST_UNA_DUPA : 0)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) * fill values in timestamp parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) static void smt_fill_timestamp(struct s_smc *smc, struct smt_p_timestamp *ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) SMTSETPARA(ts,SMT_P_TIMESTAMP) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) smt_set_timestamp(smc,ts->ts_time) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) void smt_set_timestamp(struct s_smc *smc, u_char *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) u_long time ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) u_long utime ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) * timestamp is 64 bits long ; resolution is 80 nS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) * our clock resolution is 10mS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) * 10mS/80ns = 125000 ~ 2^17 = 131072
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) utime = smt_get_time() ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) time = utime * 100 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) time /= TICKS_PER_SECOND ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) p[0] = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) p[1] = (u_char)((time>>(8+8+8+8-1)) & 1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) p[2] = (u_char)(time>>(8+8+8-1)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) p[3] = (u_char)(time>>(8+8-1)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) p[4] = (u_char)(time>>(8-1)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) p[5] = (u_char)(time<<1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) p[6] = (u_char)(smc->sm.uniq_ticks>>8) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) p[7] = (u_char)smc->sm.uniq_ticks ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) * make sure we don't wrap: restart whenever the upper digits change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) if (utime != smc->sm.uniq_time) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) smc->sm.uniq_ticks = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) smc->sm.uniq_ticks++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) smc->sm.uniq_time = utime ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) * fill values in station policy parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) static void smt_fill_policy(struct s_smc *smc, struct smt_p_policy *policy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) int i ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) const u_char *map ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) u_short in ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) u_short out ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) * MIB para 101b (fddiSMTConnectionPolicy) coding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) * is different from 0005 coding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) static const u_char ansi_weirdness[16] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 0,7,5,3,8,1,6,4,9,10,2,11,12,13,14,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) SMTSETPARA(policy,SMT_P_POLICY) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) out = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) in = smc->mib.fddiSMTConnectionPolicy ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) for (i = 0, map = ansi_weirdness ; i < 16 ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) if (in & 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) out |= (1<<*map) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) in >>= 1 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) map++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) policy->pl_config = smc->mib.fddiSMTConfigPolicy ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) policy->pl_connect = out ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) * fill values in latency equivalent parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) static void smt_fill_latency(struct s_smc *smc, struct smt_p_latency *latency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) SMTSETPARA(latency,SMT_P_LATENCY) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) latency->lt_phyout_idx1 = phy_index(smc,0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) latency->lt_latency1 = 10 ; /* in octets (byte clock) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) * note: latency has two phy entries by definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) * for a SAS, the 2nd one is null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) if (smc->s.sas == SMT_DAS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) latency->lt_phyout_idx2 = phy_index(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) latency->lt_latency2 = 10 ; /* in octets (byte clock) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) latency->lt_phyout_idx2 = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) latency->lt_latency2 = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) * fill values in MAC neighbors parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) static void smt_fill_neighbor(struct s_smc *smc, struct smt_p_neighbor *neighbor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) SMTSETPARA(neighbor,SMT_P_NEIGHBORS) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) neighbor->nb_mib_index = INDEX_MAC ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) neighbor->nb_mac_index = mac_index(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) neighbor->nb_una = smc->mib.m[MAC0].fddiMACUpstreamNbr ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) neighbor->nb_dna = smc->mib.m[MAC0].fddiMACDownstreamNbr ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) * fill values in path descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) #ifdef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) #define ALLPHYS NUMPHYS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) #define ALLPHYS ((smc->s.sas == SMT_SAS) ? 1 : 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) static int smt_fill_path(struct s_smc *smc, struct smt_p_path *path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) SK_LOC_DECL(int,type) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) SK_LOC_DECL(int,state) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) SK_LOC_DECL(int,remote) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) SK_LOC_DECL(int,mac) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) int len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) int p ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) int physp ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) struct smt_phy_rec *phy ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) struct smt_mac_rec *pd_mac ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) len = PARA_LEN +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) sizeof(struct smt_mac_rec) * NUMMACS +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) sizeof(struct smt_phy_rec) * ALLPHYS ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) path->para.p_type = SMT_P_PATH ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) path->para.p_len = len - PARA_LEN ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) /* PHYs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) for (p = 0,phy = path->pd_phy ; p < ALLPHYS ; p++, phy++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) physp = p ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) #ifndef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) if (smc->s.sas == SMT_SAS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) physp = PS ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) pcm_status_state(smc,physp,&type,&state,&remote,&mac) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) #ifdef LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) phy->phy_mib_index = smt_swap_short((u_short)p+INDEX_PORT) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) phy->phy_mib_index = p+INDEX_PORT ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) phy->phy_type = type ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) phy->phy_connect_state = state ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) phy->phy_remote_type = remote ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) phy->phy_remote_mac = mac ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) phy->phy_resource_idx = phy_con_resource_index(smc,p) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) /* MAC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) pd_mac = (struct smt_mac_rec *) phy ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) pd_mac->mac_addr = smc->mib.m[MAC0].fddiMACSMTAddress ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) pd_mac->mac_resource_idx = mac_con_resource_index(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) * fill values in mac status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) static void smt_fill_mac_status(struct s_smc *smc, struct smt_p_mac_status *st)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) SMTSETPARA(st,SMT_P_MAC_STATUS) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) st->st_mib_index = INDEX_MAC ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) st->st_mac_index = mac_index(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) mac_update_counter(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) * timer values are represented in SMT as 2's complement numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) * units : internal : 2's complement BCLK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) st->st_t_req = smc->mib.m[MAC0].fddiMACT_Req ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) st->st_t_neg = smc->mib.m[MAC0].fddiMACT_Neg ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) st->st_t_max = smc->mib.m[MAC0].fddiMACT_Max ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) st->st_tvx_value = smc->mib.m[MAC0].fddiMACTvxValue ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) st->st_t_min = smc->mib.m[MAC0].fddiMACT_Min ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) st->st_sba = smc->mib.a[PATH0].fddiPATHSbaPayload ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) st->st_frame_ct = smc->mib.m[MAC0].fddiMACFrame_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) st->st_error_ct = smc->mib.m[MAC0].fddiMACError_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) st->st_lost_ct = smc->mib.m[MAC0].fddiMACLost_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) * fill values in LEM status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) static void smt_fill_lem(struct s_smc *smc, struct smt_p_lem *lem, int phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) struct fddi_mib_p *mib ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) mib = smc->y[phy].mib ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) SMTSETPARA(lem,SMT_P_LEM) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) lem->lem_mib_index = phy+INDEX_PORT ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) lem->lem_phy_index = phy_index(smc,phy) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) lem->lem_pad2 = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) lem->lem_cutoff = mib->fddiPORTLer_Cutoff ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) lem->lem_alarm = mib->fddiPORTLer_Alarm ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) /* long term bit error rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) lem->lem_estimate = mib->fddiPORTLer_Estimate ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) /* # of rejected connections */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) lem->lem_reject_ct = mib->fddiPORTLem_Reject_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) lem->lem_ct = mib->fddiPORTLem_Ct ; /* total number of errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) * fill version parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) static void smt_fill_version(struct s_smc *smc, struct smt_p_version *vers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) SMTSETPARA(vers,SMT_P_VERSION) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) vers->v_pad = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) vers->v_n = 1 ; /* one version is enough .. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) vers->v_index = 1 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) vers->v_version[0] = SMT_VID_2 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) vers->v_pad2 = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) #ifdef SMT6_10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) * fill frame status capabilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) * note: this para 200B is NOT in swap table, because it's also set in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) * PMF add_para
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) static void smt_fill_fsc(struct s_smc *smc, struct smt_p_fsc *fsc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) SMTSETPARA(fsc,SMT_P_FSC) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) fsc->fsc_pad0 = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) fsc->fsc_mac_index = INDEX_MAC ; /* this is MIB ; MIB is NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) * mac_index ()i !
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) fsc->fsc_pad1 = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) fsc->fsc_value = FSC_TYPE0 ; /* "normal" node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) #ifdef LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) fsc->fsc_mac_index = smt_swap_short(INDEX_MAC) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) fsc->fsc_value = smt_swap_short(FSC_TYPE0) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) * fill mac counter field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) static void smt_fill_mac_counter(struct s_smc *smc, struct smt_p_mac_counter *mc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) SMTSETPARA(mc,SMT_P_MAC_COUNTER) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) mc->mc_mib_index = INDEX_MAC ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) mc->mc_index = mac_index(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) mc->mc_receive_ct = smc->mib.m[MAC0].fddiMACCopied_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) mc->mc_transmit_ct = smc->mib.m[MAC0].fddiMACTransmit_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) * fill mac frame not copied counter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) static void smt_fill_mac_fnc(struct s_smc *smc, struct smt_p_mac_fnc *fnc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) SMTSETPARA(fnc,SMT_P_MAC_FNC) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) fnc->nc_mib_index = INDEX_MAC ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) fnc->nc_index = mac_index(smc,1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) fnc->nc_counter = smc->mib.m[MAC0].fddiMACNotCopied_Ct ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) * fill manufacturer field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) static void smt_fill_manufacturer(struct s_smc *smc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) struct smp_p_manufacturer *man)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) SMTSETPARA(man,SMT_P_MANUFACTURER) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) memcpy((char *) man->mf_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) (char *) smc->mib.fddiSMTManufacturerData,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) sizeof(man->mf_data)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) * fill user field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) static void smt_fill_user(struct s_smc *smc, struct smp_p_user *user)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) SMTSETPARA(user,SMT_P_USER) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) memcpy((char *) user->us_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) (char *) smc->mib.fddiSMTUserData,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) sizeof(user->us_data)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) * fill set count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) static void smt_fill_setcount(struct s_smc *smc, struct smt_p_setcount *setcount)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) SMTSETPARA(setcount,SMT_P_SETCOUNT) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) setcount->count = smc->mib.fddiSMTSetCount.count ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) memcpy((char *)setcount->timestamp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) (char *)smc->mib.fddiSMTSetCount.timestamp,8) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) * fill echo data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) static void smt_fill_echo(struct s_smc *smc, struct smt_p_echo *echo, u_long seed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) u_char *p ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) SMTSETPARA(echo,SMT_P_ECHODATA) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) echo->para.p_len = len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) for (p = echo->ec_data ; len ; len--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) *p++ = (u_char) seed ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) seed += 13 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) * clear DNA and UNA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) * called from CFM if configuration changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) static void smt_clear_una_dna(struct s_smc *smc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) smc->mib.m[MAC0].fddiMACUpstreamNbr = SMT_Unknown ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) smc->mib.m[MAC0].fddiMACDownstreamNbr = SMT_Unknown ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) static void smt_clear_old_una_dna(struct s_smc *smc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) smc->mib.m[MAC0].fddiMACOldUpstreamNbr = SMT_Unknown ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) smc->mib.m[MAC0].fddiMACOldDownstreamNbr = SMT_Unknown ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) u_long smt_get_tid(struct s_smc *smc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) u_long tid ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) while ((tid = ++(smc->sm.smt_tid) ^ SMT_TID_MAGIC) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) return tid & 0x3fffffffL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) #ifdef LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) * table of parameter lengths
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) static const struct smt_pdef {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) int ptype ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) int plen ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) const char *pswap ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) } smt_pdef[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) { SMT_P_UNA, sizeof(struct smt_p_una) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) SWAP_SMT_P_UNA } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) { SMT_P_SDE, sizeof(struct smt_p_sde) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) SWAP_SMT_P_SDE } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) { SMT_P_STATE, sizeof(struct smt_p_state) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) SWAP_SMT_P_STATE } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) { SMT_P_TIMESTAMP,sizeof(struct smt_p_timestamp) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) SWAP_SMT_P_TIMESTAMP } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) { SMT_P_POLICY, sizeof(struct smt_p_policy) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) SWAP_SMT_P_POLICY } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) { SMT_P_LATENCY, sizeof(struct smt_p_latency) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) SWAP_SMT_P_LATENCY } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) { SMT_P_NEIGHBORS,sizeof(struct smt_p_neighbor) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) SWAP_SMT_P_NEIGHBORS } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) { SMT_P_PATH, sizeof(struct smt_p_path) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) SWAP_SMT_P_PATH } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) { SMT_P_MAC_STATUS,sizeof(struct smt_p_mac_status) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) SWAP_SMT_P_MAC_STATUS } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) { SMT_P_LEM, sizeof(struct smt_p_lem) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) SWAP_SMT_P_LEM } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) { SMT_P_MAC_COUNTER,sizeof(struct smt_p_mac_counter) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) SWAP_SMT_P_MAC_COUNTER } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) { SMT_P_MAC_FNC,sizeof(struct smt_p_mac_fnc) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) SWAP_SMT_P_MAC_FNC } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) { SMT_P_PRIORITY,sizeof(struct smt_p_priority) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) SWAP_SMT_P_PRIORITY } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) { SMT_P_EB,sizeof(struct smt_p_eb) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) SWAP_SMT_P_EB } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) { SMT_P_MANUFACTURER,sizeof(struct smp_p_manufacturer) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) SWAP_SMT_P_MANUFACTURER } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) { SMT_P_REASON, sizeof(struct smt_p_reason) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) SWAP_SMT_P_REASON } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) { SMT_P_REFUSED, sizeof(struct smt_p_refused) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) SWAP_SMT_P_REFUSED } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) { SMT_P_VERSION, sizeof(struct smt_p_version) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) SWAP_SMT_P_VERSION } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) #ifdef ESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) { SMT_P0015, sizeof(struct smt_p_0015) , SWAP_SMT_P0015 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) { SMT_P0016, sizeof(struct smt_p_0016) , SWAP_SMT_P0016 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) { SMT_P0017, sizeof(struct smt_p_0017) , SWAP_SMT_P0017 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) { SMT_P0018, sizeof(struct smt_p_0018) , SWAP_SMT_P0018 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) { SMT_P0019, sizeof(struct smt_p_0019) , SWAP_SMT_P0019 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) { SMT_P001A, sizeof(struct smt_p_001a) , SWAP_SMT_P001A } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) { SMT_P001B, sizeof(struct smt_p_001b) , SWAP_SMT_P001B } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) { SMT_P001C, sizeof(struct smt_p_001c) , SWAP_SMT_P001C } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) { SMT_P001D, sizeof(struct smt_p_001d) , SWAP_SMT_P001D } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) { SMT_P_FSC, sizeof(struct smt_p_fsc) ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) SWAP_SMT_P_FSC } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) { SMT_P_SETCOUNT,0, SWAP_SMT_P_SETCOUNT } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) { SMT_P1048, 0, SWAP_SMT_P1048 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) { SMT_P208C, 0, SWAP_SMT_P208C } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) { SMT_P208D, 0, SWAP_SMT_P208D } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) { SMT_P208E, 0, SWAP_SMT_P208E } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) { SMT_P208F, 0, SWAP_SMT_P208F } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) { SMT_P2090, 0, SWAP_SMT_P2090 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) #ifdef ESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) { SMT_P320B, sizeof(struct smt_p_320b) , SWAP_SMT_P320B } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) { SMT_P320F, sizeof(struct smt_p_320f) , SWAP_SMT_P320F } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) { SMT_P3210, sizeof(struct smt_p_3210) , SWAP_SMT_P3210 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) { SMT_P4050, 0, SWAP_SMT_P4050 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) { SMT_P4051, 0, SWAP_SMT_P4051 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) { SMT_P4052, 0, SWAP_SMT_P4052 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) { SMT_P4053, 0, SWAP_SMT_P4053 } ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) } ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) #define N_SMT_PLEN ARRAY_SIZE(smt_pdef)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) int smt_check_para(struct s_smc *smc, struct smt_header *sm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) const u_short list[])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) const u_short *p = list ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) while (*p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) if (!sm_to_para(smc,sm,(int) *p)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) DB_SMT("SMT: smt_check_para - missing para %hx", *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) p++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) void *sm_to_para(struct s_smc *smc, struct smt_header *sm, int para)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) char *p ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) int len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) int plen ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) void *found = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) len = sm->smt_len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) p = (char *)(sm+1) ; /* pointer to info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) while (len > 0 ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) if (((struct smt_para *)p)->p_type == para)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) found = (void *) p ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) plen = ((struct smt_para *)p)->p_len + PARA_LEN ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) p += plen ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) len -= plen ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) if (len < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) DB_SMT("SMT : sm_to_para - length error %d", plen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) if ((plen & 3) && (para != SMT_P_ECHODATA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) DB_SMT("SMT : sm_to_para - odd length %d", plen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) if (found)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) return found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) * send ANTC data test frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) void fddi_send_antc(struct s_smc *smc, struct fddi_addr *dest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) SK_UNUSED(dest) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) SMbuf *mb ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) struct smt_header *smt ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) int i ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) char *p ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) mb = smt_get_mbuf() ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) mb->sm_len = 3000+12 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) p = smtod(mb, char *) + 12 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) for (i = 0 ; i < 3000 ; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) *p++ = 1 << (i&7) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) smt = smtod(mb, struct smt_header *) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) smt->smt_dest = *dest ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) smt->smt_source = smc->mib.m[MAC0].fddiMACSMTAddress ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) smt_send_mbuf(smc,mb,FC_ASYNC_LLC) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) * return static mac index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) static int mac_index(struct s_smc *smc, int mac)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) SK_UNUSED(mac) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) #ifdef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) return NUMPHYS + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) return (smc->s.sas == SMT_SAS) ? 2 : 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) * return static phy index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) static int phy_index(struct s_smc *smc, int phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) return phy + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) * return dynamic mac connection resource index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) static int mac_con_resource_index(struct s_smc *smc, int mac)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) #ifdef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) SK_UNUSED(mac) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) return entity_to_index(smc, cem_get_downstream(smc, ENTITY_MAC));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) SK_UNUSED(mac) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) switch (smc->mib.fddiSMTCF_State) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) case SC9_C_WRAP_A :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) case SC5_THRU_B :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) case SC11_C_WRAP_S :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) case SC10_C_WRAP_B :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) case SC4_THRU_A :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) return smc->s.sas == SMT_SAS ? 2 : 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) * return dynamic phy connection resource index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) static int phy_con_resource_index(struct s_smc *smc, int phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) #ifdef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) return entity_to_index(smc, cem_get_downstream(smc, ENTITY_PHY(phy))) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) switch (smc->mib.fddiSMTCF_State) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) case SC9_C_WRAP_A :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) return phy == PA ? 3 : 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) case SC10_C_WRAP_B :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) return phy == PA ? 1 : 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) case SC4_THRU_A :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) return phy == PA ? 3 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) case SC5_THRU_B :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) return phy == PA ? 2 : 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) case SC11_C_WRAP_S :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) return phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) #ifdef CONCENTRATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) static int entity_to_index(struct s_smc *smc, int e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) if (e == ENTITY_MAC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) return mac_index(smc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) return phy_index(smc, e - ENTITY_PHY(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) #ifdef LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) static int smt_swap_short(u_short s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) return ((s>>8)&0xff) | ((s&0xff)<<8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) void smt_swap_para(struct smt_header *sm, int len, int direction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) /* int direction; 0 encode 1 decode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) struct smt_para *pa ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) const struct smt_pdef *pd ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) char *p ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) int plen ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) int type ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) int i ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) /* printf("smt_swap_para sm %x len %d dir %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) sm,len,direction) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) smt_string_swap((char *)sm,SWAP_SMTHEADER,len) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) /* swap args */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) len -= sizeof(struct smt_header) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) p = (char *) (sm + 1) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) while (len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) pa = (struct smt_para *) p ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) plen = pa->p_len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) type = pa->p_type ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) pa->p_type = smt_swap_short(pa->p_type) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) pa->p_len = smt_swap_short(pa->p_len) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) if (direction) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) plen = pa->p_len ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) type = pa->p_type ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) * note: paras can have 0 length !
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) if (plen < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) plen += PARA_LEN ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) for (i = N_SMT_PLEN, pd = smt_pdef; i ; i--,pd++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) if (pd->ptype == type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) if (i && pd->pswap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) smt_string_swap(p+PARA_LEN,pd->pswap,len) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) len -= plen ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) p += plen ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) static void smt_string_swap(char *data, const char *format, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) const char *open_paren = NULL ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) int x ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) while (len > 0 && *format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) switch (*format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) case '[' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) open_paren = format ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) case ']' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) format = open_paren ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) case '1' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) case '2' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) case '3' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) case '4' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) case '5' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) case '6' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) case '7' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) case '8' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) case '9' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) data += *format - '0' ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) len -= *format - '0' ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) case 'c':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) data++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) len-- ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) case 's' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) x = data[0] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) data[0] = data[1] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) data[1] = x ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) data += 2 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) len -= 2 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) case 'l' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) x = data[0] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) data[0] = data[3] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) data[3] = x ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) x = data[1] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) data[1] = data[2] ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) data[2] = x ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) data += 4 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) len -= 4 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) format++ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) void smt_swap_para(struct smt_header *sm, int len, int direction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) /* int direction; 0 encode 1 decode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) SK_UNUSED(sm) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) SK_UNUSED(len) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) SK_UNUSED(direction) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) * PMF actions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) int smt_action(struct s_smc *smc, int class, int code, int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) int event ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) int port ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) DB_SMT("SMT: action %d code %d", class, code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) switch(class) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) case SMT_STATION_ACTION :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) switch(code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) case SMT_STATION_ACTION_CONNECT :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) smc->mib.fddiSMTRemoteDisconnectFlag = FALSE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) queue_event(smc,EVENT_ECM,EC_CONNECT) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) case SMT_STATION_ACTION_DISCONNECT :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) queue_event(smc,EVENT_ECM,EC_DISCONNECT) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) smc->mib.fddiSMTRemoteDisconnectFlag = TRUE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) RS_SET(smc,RS_DISCONNECT) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) AIX_EVENT(smc, (u_long) FDDI_RING_STATUS, (u_long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) FDDI_SMT_EVENT, (u_long) FDDI_REMOTE_DISCONNECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) smt_get_event_word(smc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) case SMT_STATION_ACTION_PATHTEST :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) AIX_EVENT(smc, (u_long) FDDI_RING_STATUS, (u_long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) FDDI_SMT_EVENT, (u_long) FDDI_PATH_TEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) smt_get_event_word(smc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) case SMT_STATION_ACTION_SELFTEST :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) AIX_EVENT(smc, (u_long) FDDI_RING_STATUS, (u_long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) FDDI_SMT_EVENT, (u_long) FDDI_REMOTE_SELF_TEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) smt_get_event_word(smc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) case SMT_STATION_ACTION_DISABLE_A :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) if (smc->y[PA].pc_mode == PM_PEER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) RS_SET(smc,RS_EVENT) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) queue_event(smc,EVENT_PCM+PA,PC_DISABLE) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) case SMT_STATION_ACTION_DISABLE_B :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) if (smc->y[PB].pc_mode == PM_PEER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) RS_SET(smc,RS_EVENT) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) queue_event(smc,EVENT_PCM+PB,PC_DISABLE) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) case SMT_STATION_ACTION_DISABLE_M :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) for (port = 0 ; port < NUMPHYS ; port++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) if (smc->mib.p[port].fddiPORTMy_Type != TM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) continue ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) RS_SET(smc,RS_EVENT) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) queue_event(smc,EVENT_PCM+port,PC_DISABLE) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) default :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) case SMT_PORT_ACTION :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) switch(code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) case SMT_PORT_ACTION_ENABLE :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) event = PC_ENABLE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) case SMT_PORT_ACTION_DISABLE :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) event = PC_DISABLE ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) case SMT_PORT_ACTION_MAINT :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) event = PC_MAINT ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) case SMT_PORT_ACTION_START :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) event = PC_START ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) case SMT_PORT_ACTION_STOP :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) event = PC_STOP ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) default :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) queue_event(smc,EVENT_PCM+index,event) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) break ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) default :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) * canonical conversion of <len> bytes beginning form *data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) #ifdef USE_CAN_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) static void hwm_conv_can(struct s_smc *smc, char *data, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) int i ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) SK_UNUSED(smc) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) for (i = len; i ; i--, data++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) *data = bitrev8(*data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) #endif /* no SLIM_SMT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010)