lnkstat.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /******************************************************************************
  2. *
  3. * (C)Copyright 1998,1999 SysKonnect,
  4. * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
  5. *
  6. * See the file "skfddi.c" for further information.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * The information in this file is provided "AS IS" without warranty.
  14. *
  15. ******************************************************************************/
  16. /*
  17. IBM FDDI read error log function
  18. */
  19. #include "h/types.h"
  20. #include "h/fddi.h"
  21. #include "h/smc.h"
  22. #include "h/lnkstat.h"
  23. #ifndef lint
  24. static const char ID_sccs[] = "@(#)lnkstat.c 1.8 97/04/11 (C) SK " ;
  25. #endif
  26. #ifdef sun
  27. #define _far
  28. #endif
  29. #define EL_IS_OK(x,l) ((((int)&(((struct s_error_log *)0)->x)) + \
  30. sizeof(er->x)) <= l)
  31. /*
  32. BEGIN_MANUAL_ENTRY(if,func;others;11)
  33. u_long smt_get_error_word(smc)
  34. struct s_smc *smc ;
  35. Function DOWNCALL (SMT, lnkstat.c)
  36. This functions returns the SMT error work for AIX events.
  37. Return smt_error_word These bits are supported:
  38. SMT_ERL_ALC == [PS/PA].fddiPORTLerFlag
  39. SMT_ERL_BLC == [PB].fddiPORTLerFlag
  40. SMT_ERL_NCC == fddiMACNotCopiedFlag
  41. SMT_ERL_FEC == fddiMACFrameErrorFlag
  42. END_MANUAL_ENTRY()
  43. */
  44. u_long smt_get_error_word(struct s_smc *smc)
  45. {
  46. u_long st;
  47. /*
  48. * smt error word low
  49. */
  50. st = 0 ;
  51. if (smc->s.sas == SMT_SAS) {
  52. if (smc->mib.p[PS].fddiPORTLerFlag)
  53. st |= SMT_ERL_ALC ;
  54. }
  55. else {
  56. if (smc->mib.p[PA].fddiPORTLerFlag)
  57. st |= SMT_ERL_ALC ;
  58. if (smc->mib.p[PB].fddiPORTLerFlag)
  59. st |= SMT_ERL_BLC ;
  60. }
  61. if (smc->mib.m[MAC0].fddiMACNotCopiedFlag)
  62. st |= SMT_ERL_NCC ; /* not copied condition */
  63. if (smc->mib.m[MAC0].fddiMACFrameErrorFlag)
  64. st |= SMT_ERL_FEC ; /* frame error condition */
  65. return st;
  66. }
  67. /*
  68. BEGIN_MANUAL_ENTRY(if,func;others;11)
  69. u_long smt_get_event_word(smc)
  70. struct s_smc *smc ;
  71. Function DOWNCALL (SMT, lnkstat.c)
  72. This functions returns the SMT event work for AIX events.
  73. Return smt_event_word always 0
  74. END_MANUAL_ENTRY()
  75. */
  76. u_long smt_get_event_word(struct s_smc *smc)
  77. {
  78. return (u_long) 0;
  79. }
  80. /*
  81. BEGIN_MANUAL_ENTRY(if,func;others;11)
  82. u_long smt_get_port_event_word(smc)
  83. struct s_smc *smc ;
  84. Function DOWNCALL (SMT, lnkstat.c)
  85. This functions returns the SMT port event work for AIX events.
  86. Return smt_port_event_word always 0
  87. END_MANUAL_ENTRY()
  88. */
  89. u_long smt_get_port_event_word(struct s_smc *smc)
  90. {
  91. return (u_long) 0;
  92. }
  93. /*
  94. BEGIN_MANUAL_ENTRY(if,func;others;11)
  95. u_long smt_read_errorlog(smc,p,len)
  96. struct s_smc *smc ;
  97. char _far *p ;
  98. int len ;
  99. Function DOWNCALL (SMT, lnkstat.c)
  100. This functions returns the SMT error log field for AIX events.
  101. Para p pointer to the error log field
  102. len len of the error log field
  103. Return len used len of the error log field
  104. END_MANUAL_ENTRY()
  105. */
  106. int smt_read_errorlog(struct s_smc *smc, char _far *p, int len)
  107. {
  108. int i ;
  109. int st ;
  110. struct s_error_log _far *er ;
  111. er = (struct s_error_log _far *) p ;
  112. if (len > sizeof(struct s_error_log))
  113. len = sizeof(struct s_error_log) ;
  114. for (i = 0 ; i < len ; i++)
  115. *p++ = 0 ;
  116. /*
  117. * set count
  118. */
  119. if (EL_IS_OK(set_count_high,len)) {
  120. er->set_count_low = (u_short)smc->mib.fddiSMTSetCount.count ;
  121. er->set_count_high =
  122. (u_short)(smc->mib.fddiSMTSetCount.count >> 16L) ;
  123. }
  124. /*
  125. * aci
  126. */
  127. if (EL_IS_OK(aci_id_code,len)) {
  128. er->aci_id_code = 0 ;
  129. }
  130. /*
  131. * purge counter is missed frames; 16 bits only
  132. */
  133. if (EL_IS_OK(purge_frame_counter,len)) {
  134. if (smc->mib.m[MAC0].fddiMACCopied_Ct > 0xffff)
  135. er->purge_frame_counter = 0xffff ;
  136. else
  137. er->purge_frame_counter =
  138. (u_short)smc->mib.m[MAC0].fddiMACCopied_Ct ;
  139. }
  140. /*
  141. * CMT and RMT state machines
  142. */
  143. if (EL_IS_OK(ecm_state,len))
  144. er->ecm_state = smc->mib.fddiSMTECMState ;
  145. if (EL_IS_OK(pcm_b_state,len)) {
  146. if (smc->s.sas == SMT_SAS) {
  147. er->pcm_a_state = smc->y[PS].mib->fddiPORTPCMState ;
  148. er->pcm_b_state = 0 ;
  149. }
  150. else {
  151. er->pcm_a_state = smc->y[PA].mib->fddiPORTPCMState ;
  152. er->pcm_b_state = smc->y[PB].mib->fddiPORTPCMState ;
  153. }
  154. }
  155. if (EL_IS_OK(cfm_state,len))
  156. er->cfm_state = smc->mib.fddiSMTCF_State ;
  157. if (EL_IS_OK(rmt_state,len))
  158. er->rmt_state = smc->mib.m[MAC0].fddiMACRMTState ;
  159. /*
  160. * smt error word low (we only need the low order 16 bits.)
  161. */
  162. st = smt_get_error_word(smc) & 0xffff ;
  163. if (EL_IS_OK(smt_error_low,len))
  164. er->smt_error_low = st ;
  165. if (EL_IS_OK(ucode_version_level,len))
  166. er->ucode_version_level = 0x0101 ;
  167. return(len) ;
  168. }