[ofw][patches][ibbus] added support to logging to System Event Log.

Leonid Keller leonid at mellanox.co.il
Mon Jun 1 09:02:07 PDT 2009


Thanks, i'll add.


________________________________

	From: Smith, Stan [mailto:stan.smith at intel.com] 
	Sent: Monday, June 01, 2009 7:00 PM
	To: Leonid Keller
	Cc: ofw at lists.openfabrics.org
	Subject: RE: [ofw][patches][ibbus] added support to logging to
System Event Log.
	
	
	Hello,
	  Does the InfiniHost mthca.sys driver not support ibbus logging
system events? I did not find mthca.inx mods?
	 
	stan.

________________________________

	From: ofw-bounces at lists.openfabrics.org
[mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Leonid Keller
	Sent: Monday, June 01, 2009 1:37 AM
	To: ofw at lists.openfabrics.org
	Subject: [ofw][patches][ibbus] added support to logging to
System Event Log.
	
	
	Added macro CL_PRINT_TO_EVENT_LOG, sending a string to System
Event Log.
	 
	    CL_PRINT_TO_EVENT_LOG(_obj_,_event_id_,_msg_)
	       obj - FDO of IBBUS
	       event_id - EVENT_IBBUS_ANY_ERROR, EVENT_IBBUS_ANY_WARN,
EVENT_IBBUS_ANY_INFO
	       msg - (<format_string>[,param_list])
	 
	FDO is stored in CA object.
	 
	 
	 
	Index: V:/svn/winib/trunk/core/complib/kernel/cl_log.c
	
===================================================================
	--- V:/svn/winib/trunk/core/complib/kernel/cl_log.c (revision
4394)
	+++ V:/svn/winib/trunk/core/complib/kernel/cl_log.c (revision
4395)
	@@ -29,10 +29,123 @@
	  * $Id$
	  */
	 
	-
	+#include <stdarg.h>
	 #include "complib/cl_log.h"
	 
	+WCHAR g_cl_wlog[ CL_LOG_BUF_LEN ]; 
	+UCHAR g_cl_slog[ CL_LOG_BUF_LEN ]; 
	 
	+
	+VOID
	+cl_event_log_write(
	+ PVOID p_io_object,
	+ ULONG p_error_code,
	+ ULONG p_unique_error_code,
	+ ULONG p_final_status,
	+ PWCHAR p_insertion_string,
	+ ULONG p_n_data_items,
	+ ...
	+ )
	+/*++
	+
	+Routine Description:
	+    Writes an event log entry to the event log.
	+
	+Arguments:
	+
	+ p_io_object......... The IO object ( driver object or device
object ).
	+ p_error_code......... The error code.
	+ p_unique_error_code... A specific error code.
	+ p_final_status....... The final status.
	+ p_n_data_items........ Number of data items.
	+ .
	+ . data items values
	+ .
	+
	+Return Value:
	+
	+ None .
	+
	+--*/
	+{ /* WriteEventLogEntryStr */
	+
	+ /* Variable argument list */    
	+ va_list     l_Argptr;
	+ /* Pointer to an error log entry */
	+ PIO_ERROR_LOG_PACKET l_pErrorLogEntry; 
	+ /* sizeof insertion string */
	+ int  l_Size = (int)((p_insertion_string) ?
((wcslen(p_insertion_string) + 1) * sizeof( WCHAR )) : 0);
	+ int l_PktSize
=sizeof(IO_ERROR_LOG_PACKET)+p_n_data_items*sizeof(ULONG);
	+ int l_TotalSize =l_PktSize +l_Size;
	+
	+ if (p_io_object == NULL) {
	+  ASSERT(p_io_object != NULL);
	+  return;
	+ }
	+
	+ /* Init the variable argument list */   
	+ va_start(l_Argptr, p_n_data_items);
	+
	+ /* Allocate an error log entry */ 
	+ if (l_TotalSize >= ERROR_LOG_MAXIMUM_SIZE - 2) 
	+  l_TotalSize = ERROR_LOG_MAXIMUM_SIZE - 2;
	+ l_pErrorLogEntry =
(PIO_ERROR_LOG_PACKET)IoAllocateErrorLogEntry(
	+  p_io_object,  (UCHAR)l_TotalSize );
	+
	+ /* Check allocation */
	+ if ( l_pErrorLogEntry != NULL) 
	+ { /* OK */
	+
	+  /* Data item index */
	+  USHORT l_nDataItem ;
	+
	+  /* Set the error log entry header */
	+  l_pErrorLogEntry->ErrorCode   = p_error_code; 
	+  l_pErrorLogEntry->DumpDataSize  = (USHORT)
(p_n_data_items*sizeof(ULONG)); 
	+  l_pErrorLogEntry->SequenceNumber = 0; 
	+  l_pErrorLogEntry->MajorFunctionCode = 0; 
	+  l_pErrorLogEntry->IoControlCode  = 0; 
	+  l_pErrorLogEntry->RetryCount  = 0; 
	+  l_pErrorLogEntry->UniqueErrorValue = p_unique_error_code; 
	+  l_pErrorLogEntry->FinalStatus  = p_final_status; 
	+
	+  /* Insert the data items */
	+  for (l_nDataItem = 0; l_nDataItem < p_n_data_items;
l_nDataItem++) 
	+  { /* Inset a data item */
	+
	+   /* Current data item */
	+   int l_CurDataItem ;
	+    
	+   /* Get next data item */
	+   l_CurDataItem = va_arg( l_Argptr, int);
	+
	+   /* Put it into the data array */
	+   l_pErrorLogEntry->DumpData[l_nDataItem] = l_CurDataItem ;
	+
	+  } /* Inset a data item */
	+
	+  /* add insertion string */
	+  if (p_insertion_string) {
	+   char *ptr; 
	+   int sz = min( l_TotalSize - l_PktSize, l_Size );
	+   l_pErrorLogEntry->NumberOfStrings = 1;
	+   l_pErrorLogEntry->StringOffset = sizeof(IO_ERROR_LOG_PACKET)
+ l_pErrorLogEntry->DumpDataSize;
	+   ptr = (char*)l_pErrorLogEntry +
l_pErrorLogEntry->StringOffset;
	+   memcpy( ptr, p_insertion_string, sz );
	+   *(WCHAR*)&ptr[sz - 2] = (WCHAR)0;
	+  }
	+  
	+  /* Write the packet */
	+  IoWriteErrorLogEntry(l_pErrorLogEntry);
	+
	+ } /* OK */
	+
	+ /* Term the variable argument list */   
	+ va_end(l_Argptr);
	+
	+} /* WriteEventLogEntry */
	+
	+
	 /*
	  * The IO Object required to allocate an event log entry is
passed in
	  * via the "name" parameter.
	Index: V:/svn/winib/trunk/core/bus/kernel/bus_ev_log.mc
	
===================================================================
	--- V:/svn/winib/trunk/core/bus/kernel/bus_ev_log.mc (revision
0)
	+++ V:/svn/winib/trunk/core/bus/kernel/bus_ev_log.mc (revision
4395)
	@@ -0,0 +1,56 @@
	+;/*++
	
+;======================================================================
=======
	+;Copyright (c) 2009 Mellanox Technologies
	+;
	+;Module Name:
	+;
	+;    bus_ev_log.mc
	+;
	+;Abstract:
	+;
	+;    IB Driver event log messages
	+;
	+;Authors:
	+;
	+;    Leonid Keller
	+;
	+;Environment:
	+;
	+;   Kernel Mode .
	+;
	
+;======================================================================
=======
	+;--*/
	+;
	+MessageIdTypedef = NTSTATUS
	+
	+SeverityNames = (
	+ Success   = 0x0:STATUS_SEVERITY_SUCCESS
	+ Informational = 0x1:STATUS_SEVERITY_INFORMATIONAL
	+ Warning   = 0x2:STATUS_SEVERITY_WARNING
	+ Error   = 0x3:STATUS_SEVERITY_ERROR
	+ )
	+
	+FacilityNames = (
	+ System   = 0x0
	+ RpcRuntime  = 0x2:FACILITY_RPC_RUNTIME
	+ RpcStubs  = 0x3:FACILITY_RPC_STUBS
	+ Io    = 0x4:FACILITY_IO_ERROR_CODE
	+ IBBUS   = 0x9:FACILITY_IB_ERROR_CODE
	+ )
	+
	+
	+MessageId=0x0001 Facility=IBBUS Severity=Informational
SymbolicName=EVENT_IBBUS_ANY_INFO
	+Language=English
	+%2
	+.
	+
	+MessageId=0x0002 Facility=IBBUS Severity=Warning
SymbolicName=EVENT_IBBUS_ANY_WARN
	+Language=English
	+%2
	+.
	+
	+MessageId=0x0003 Facility=IBBUS Severity=Error
SymbolicName=EVENT_IBBUS_ANY_ERROR
	+Language=English
	+%2
	+.
	+
	Index: V:/svn/winib/trunk/core/bus/kernel/SOURCES
	
===================================================================
	--- V:/svn/winib/trunk/core/bus/kernel/SOURCES (revision 4394)
	+++ V:/svn/winib/trunk/core/bus/kernel/SOURCES (revision 4395)
	@@ -10,16 +10,18 @@
	 
	 
	 SOURCES= ibbus.rc  \
	+ bus_ev_log.mc  \
	  bus_driver.c  \
	  bus_pnp.c   \
	  bus_port_mgr.c  \
	  bus_iou_mgr.c
	 
	
-INCLUDES=..\..\..\inc;..\..\..\inc\kernel;..\..\al;..\..\al\kernel;
	
+INCLUDES=..\..\..\inc;..\..\..\inc\kernel;..\..\al;..\..\al\kernel;..\.
.\bus\kernel\$O;
	 
	 C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS
-DNEED_CL_OBJ
	 
	 TARGETLIBS= \
	+    $(DDK_LIB_PATH)\ntstrsafe.lib \
	  $(TARGETPATH)\*\complib.lib \
	  $(TARGETPATH)\*\ibal.lib
	  
	Index: V:/svn/winib/trunk/core/bus/kernel/ibbus.rc
	
===================================================================
	--- V:/svn/winib/trunk/core/bus/kernel/ibbus.rc (revision 4394)
	+++ V:/svn/winib/trunk/core/bus/kernel/ibbus.rc (revision 4395)
	@@ -44,4 +44,6 @@
	 #define VER_INTERNALNAME_STR  "ibbus.sys"
	 #define VER_ORIGINALFILENAME_STR "ibbus.sys"
	 
	+#include "bus_ev_log.rc"
	+
	 #include <common.ver>
	Index: V:/svn/winib/trunk/core/al/kernel/al_mgr.c
	
===================================================================
	--- V:/svn/winib/trunk/core/al/kernel/al_mgr.c (revision 4394)
	+++ V:/svn/winib/trunk/core/al/kernel/al_mgr.c (revision 4395)
	@@ -257,7 +257,8 @@
	 ib_api_status_t
	 ib_register_ca(
	  IN  const ci_interface_t*    p_ci,
	- IN  const PDEVICE_OBJECT    p_hca_dev
	+ IN  const PDEVICE_OBJECT    p_hca_dev,
	+ IN  const PDEVICE_OBJECT    p_fdo
	  )
	 {
	  ib_api_status_t  status;
	@@ -285,7 +286,7 @@
	  }
	 
	  /* Construct and initialize the CA structure. */
	- status = create_ci_ca( &gp_al_mgr->obj, p_ci, p_hca_dev );
	+ status = create_ci_ca( &gp_al_mgr->obj, p_ci, p_hca_dev, p_fdo
);
	  if( status != IB_SUCCESS )
	  {
	   AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
	Index: V:/svn/winib/trunk/core/al/kernel/SOURCES
	
===================================================================
	--- V:/svn/winib/trunk/core/al/kernel/SOURCES (revision 4394)
	+++ V:/svn/winib/trunk/core/al/kernel/SOURCES (revision 4395)
	@@ -56,12 +56,13 @@
	  ..\ib_common.c   \
	  ..\ib_statustext.c
	 
	-INCLUDES=..;..\..\..\inc;..\..\..\inc\kernel;
	
+INCLUDES=..;..\..\..\inc;..\..\..\inc\kernel;..\..\bus\kernel\$O;
	 
	 C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS \
	  -DEXPORT_AL_SYMBOLS
	 
	 TARGETLIBS= \
	+    $(DDK_LIB_PATH)\ntstrsafe.lib \
	  $(TARGETPATH)\*\complib.lib
	 
	 !IFDEF ENABLE_EVENT_TRACING
	Index: V:/svn/winib/trunk/core/al/kernel/al_ci_ca.c
	
===================================================================
	--- V:/svn/winib/trunk/core/al/kernel/al_ci_ca.c (revision 4394)
	+++ V:/svn/winib/trunk/core/al/kernel/al_ci_ca.c (revision 4395)
	@@ -85,7 +85,8 @@
	 create_ci_ca(
	  IN    al_obj_t     *p_parent_obj,
	  IN  const ci_interface_t*    p_ci,
	- IN  const PDEVICE_OBJECT    p_hca_dev
	+ IN  const PDEVICE_OBJECT    p_hca_dev,
	+ IN  const PDEVICE_OBJECT    p_fdo
	  )
	 {
	  ib_api_status_t   status;
	@@ -189,8 +190,10 @@
	   return status;
	  }
	 
	+
	  /* store HCA device object into CA object */
	  p_ci_ca->h_ca->p_hca_dev = p_hca_dev;
	+ p_ci_ca->h_ca->p_fdo = p_fdo;
	  
	  /* Get a list of the port GUIDs on this CI CA. */
	  status = get_port_info( p_ci_ca );
	Index: V:/svn/winib/trunk/core/al/al_ca.h
	
===================================================================
	--- V:/svn/winib/trunk/core/al/al_ca.h (revision 4394)
	+++ V:/svn/winib/trunk/core/al/al_ca.h (revision 4395)
	@@ -51,6 +51,7 @@
	 #if defined(CL_KERNEL)
	  ib_ca_handle_t   h_um_ca;
	  PDEVICE_OBJECT   p_hca_dev;
	+ PDEVICE_OBJECT   p_fdo;
	 #endif
	 
	 } ib_ca_t;
	Index: V:/svn/winib/trunk/core/al/al_ci_ca.h
	
===================================================================
	--- V:/svn/winib/trunk/core/al/al_ci_ca.h (revision 4394)
	+++ V:/svn/winib/trunk/core/al/al_ci_ca.h (revision 4395)
	@@ -57,7 +57,8 @@
	 create_ci_ca(
	  IN    al_obj_t     *p_parent_obj,
	  IN  const ci_interface_t*    p_ci,
	- IN  const PDEVICE_OBJECT    p_hca_dev
	+ IN  const PDEVICE_OBJECT    p_hca_dev,
	+ IN  const PDEVICE_OBJECT    p_fdo
	  );
	 
	 DEVICE_OBJECT*
	Index: V:/svn/winib/trunk/inc/kernel/iba/ib_ci_ifc.h
	
===================================================================
	--- V:/svn/winib/trunk/inc/kernel/iba/ib_ci_ifc.h (revision
4394)
	+++ V:/svn/winib/trunk/inc/kernel/iba/ib_ci_ifc.h (revision
4395)
	@@ -56,7 +56,8 @@
	 typedef ib_api_status_t
	 (*ib_pfn_register_ca_t)(
	  IN  const ci_interface_t* const  p_ci,
	- IN  const PDEVICE_OBJECT    p_hca_dev
	+ IN  const PDEVICE_OBJECT    p_hca_dev,
	+ IN  const PDEVICE_OBJECT    p_fdo
	  );
	 
	 
	Index: V:/svn/winib/trunk/inc/complib/cl_log.h
	
===================================================================
	--- V:/svn/winib/trunk/inc/complib/cl_log.h (revision 4394)
	+++ V:/svn/winib/trunk/inc/complib/cl_log.h (revision 4395)
	@@ -43,7 +43,6 @@
	 #ifndef _CL_LOG_H_
	 #define _CL_LOG_H_
	 
	-
	 #include <complib/cl_types.h>
	 
	 
	@@ -147,9 +146,99 @@
	 *********/
	 
	 
	+/****f* Component Library: Debug Output/cl_msg_out
	+* NAME
	+* cl_event_log_write
	+*
	+* DESCRIPTION
	+* The cl_event_log_write function sends a message to System
Event Logger.
	+*
	+* SYNOPSIS
	+*/
	+CL_EXPORT void
	+cl_event_log_write(
	+ PVOID p_io_object,
	+ ULONG p_error_code,
	+ ULONG p_unique_error_code,
	+ ULONG p_final_status,
	+ PWCHAR p_insertion_string,
	+ ULONG p_n_data_items,
	+  ...
	+  );
	+/*
	+* PARAMETERS
	+* p_io_object
	+*  [in] The IO object ( driver object or device object ).
	+* 
	+* p_error_code
	+*  [in] The error code.
	+*
	+* p_unique_error_code
	+*  [in] A specific error code.
	+*
	+* p_final_status
	+*  [in] The final status.
	+*
	+* p_insertion_string
	+*  [in] String to print.
	+*
	+* p_n_data_items
	+*  [in] Number of data items
	+*
	+* ...
	+*  [in] data items values
	+*
	+* RETURN VALUE
	+* This function does not return a value.
	+*
	+* NOTES
	+* cl_event_log_write is available in both debug and release
builds.
	+*
	+* The function uses IoAllocateErrorLogEntry and
IoWriteErrorLogEntry
	+* functions to send data to System Event Log.
	+*
	+* SEE ALSO
	+* 
	+*********/
	+
	 #ifdef __cplusplus
	 }
	 #endif
	 
	+#ifdef CL_KERNEL
	+#include <ntddk.h>
	+#define NTSTRSAFE_LIB
	+#include <ntstrsafe.h>
	 
	+#define CL_LOG_BUF_LEN  512
	+extern WCHAR g_cl_wlog[ CL_LOG_BUF_LEN ]; 
	+extern UCHAR g_cl_slog[ CL_LOG_BUF_LEN ]; 
	+
	+static void __build_str( const char * format, ... )
	+{
	+ NTSTATUS status;
	+ va_list p_arg;
	+ va_start(p_arg, format);
	+ status = RtlStringCbVPrintfA((char *)g_cl_slog,
sizeof(g_cl_slog), format , p_arg);
	+ if (status)
	+  goto end;
	+ status = RtlStringCchPrintfW(g_cl_wlog,
sizeof(g_cl_wlog)/sizeof(g_cl_wlog[0]), L"%S", g_cl_slog);
	+ if (status)
	+  goto end;
	+end:
	+ va_end(p_arg);
	+}
	+
	+#define CL_PRINT_TO_EVENT_LOG(_obj_,_event_id_,_msg_)  \
	+ { \
	+  NTSTATUS event_id = _event_id_; \
	+  __build_str _msg_; \
	+  cl_event_log_write( _obj_, (ULONG)event_id, 0, 0, g_cl_wlog,
0, 0 ); \
	+ }
	+#else
	+
	+#define CL_PRINT_TO_EVENT_LOG(_obj_,_event_id_,_msg_)
	+
	+#endif
	+
	 #endif /* _CL_LOG_H_ */
	Index: V:/svn/winib/trunk/inc/iba/ib_ci.h
	
===================================================================
	--- V:/svn/winib/trunk/inc/iba/ib_ci.h (revision 4394)
	+++ V:/svn/winib/trunk/inc/iba/ib_ci.h (revision 4395)
	@@ -2937,7 +2937,8 @@
	 AL_EXPORT ib_api_status_t
	 ib_register_ca (
	  IN  const ci_interface_t*    p_ci,
	- IN  const PDEVICE_OBJECT    p_hca_dev
	+ IN  const PDEVICE_OBJECT    p_hca_dev,
	+ IN  const PDEVICE_OBJECT    p_fdo
	  );
	 /*
	 * DESCRIPTION
	@@ -2954,6 +2955,8 @@
	 *  vector to support verbs functionality.
	 * p_hca_dev
	 *  PDO of HCA device
	+* p_fdo
	+*  FDO of IBBUS device
	 *
	 * RETURN VALUE
	 * IB_SUCCESS
	Index: V:/svn/winib/trunk/hw/mlx4/kernel/hca/mlx4_hca.inx
	
===================================================================
	--- V:/svn/winib/trunk/hw/mlx4/kernel/hca/mlx4_hca.inx (revision
4394)
	+++ V:/svn/winib/trunk/hw/mlx4/kernel/hca/mlx4_hca.inx (revision
4395)
	@@ -177,19 +177,19 @@
	 
	 [MLX4HCA.DDInstall.ntx86.Services]
	 AddService =
mlx4_hca,%SPSVCINST_ASSOCSERVICE%,MLX4HCA.ServiceInstall,MLX4HCA.EventLo
g
	-AddService = ibbus,,Ibbus.ServiceInstall
	+AddService = ibbus,,Ibbus.ServiceInstall,IBBUS.EventLog
	 AddService = WinVerbs,,WinVerbs.ServiceInstall
	 AddService = WinMad,,WinMad.ServiceInstall
	 
	 [MLX4HCA.DDInstall.ntamd64.Services]
	 AddService =
mlx4_hca,%SPSVCINST_ASSOCSERVICE%,MLX4HCA.ServiceInstall,MLX4HCA.EventLo
g
	-AddService = ibbus,,Ibbus.ServiceInstall
	+AddService = ibbus,,Ibbus.ServiceInstall,IBBUS.EventLog
	 AddService = WinVerbs,,WinVerbs.ServiceInstall
	 AddService = WinMad,,WinMad.ServiceInstall
	 
	 [MLX4HCA.DDInstall.ntia64.Services]
	 AddService =
mlx4_hca,%SPSVCINST_ASSOCSERVICE%,MLX4HCA.ServiceInstall,MLX4HCA.EventLo
g
	-AddService = ibbus,,Ibbus.ServiceInstall
	+AddService = ibbus,,Ibbus.ServiceInstall,IBBUS.EventLog
	 AddService = WinVerbs,,WinVerbs.ServiceInstall
	 AddService = WinMad,,WinMad.ServiceInstall
	 
	@@ -282,6 +282,14 @@
	 AddReg          = Ibbus.ParamsReg
	 Dependencies = mlx4_hca
	 
	+[IBBUS.EventLog]
	+AddReg = IBBUS.AddEventLogReg
	+
	+[IBBUS.AddEventLogReg]
	+HKR, , EventMessageFile, 0x00020000,
"%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\ib
bus.sys"
	+HKR, , TypesSupported,   0x00010001, 7
	+
	+
	 [Ibbus.ParamsReg]
	 HKR,"Parameters","IbalDebugLevel",%REG_DWORD%,2
	 HKR,"Parameters","IbalDebugFlags",%REG_DWORD%,0x00ffffff
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090601/30433b0b/attachment.html>


More information about the ofw mailing list