[Openib-windows] [PATCH] WPP support in IPoIB

Yossi Leybovich sleybo at mellanox.co.il
Tue Dec 20 07:11:53 PST 2005


Fab
 
Attached is patch that enable WPP in the IPoIB module
 
The WPP is controlled in compilation (ENABLING_EVENT_TRACING)
If  this Macro is enable then IPoIB will use IPOIB_PRINT to print to the
WPP. 
otherwise, in check build it will use the the regular prints and in free
will print nothing.
BTW WPP can redirect its prints to the Kernel debugger or to WinDbg so
even with traces we can use these WinDbg .
(we used traceview and found it very powerful)
For the patch I kept the regular IPOIB_TRACE I hope to replace them with
IPOIB_PRINT
 
The WPP is controlled its output with both level and flags
I used the common WIndows level (FATAL,ERROR,..VERBOSE), and use the
already defined flags.
 
I suggest to move all our macros (IPOIB_TRACE ,AL_TRACE....) to use WPP
, 
We can do it with simple script that will remove the parentheses from
the macros and maybe change some formats type mismatches (the WPP check
format string more carefully then print).
I did it for the SDP and its not too much work.
 
The SDP code already was changed to use WPP and we did some tests over
the code.
We got really nice results.
    - if there is no consumer we hardly notice any change on the
performance ( maybe 1-2%).
    - if we set the verbose mode and full flags which print each packet,
we slow the test in 40% (from 500Mbs to 360Mbs while with prints its
down to 2Mbs).
The nice thing that you control the trace in run time and change
flags/levels on run time.
You also get PID and TID and many more info each msg.
 
We can also add enter/exit traces to function I add these to SDP code
(and we can also declare only the enter and leave the exit empty)
 
pls review and let me know weather to continue and move all our msg to
use WPP.
 
I will be happy to answer any question 
10x
Yossi
 
Singed-off-by: Yossi Leybovich (sleybo at mellanox.co.il)
Index: ulp/ipoib/kernel/ipoib_debug.c
===================================================================
--- ulp/ipoib/kernel/ipoib_debug.c	(revision 0)
+++ ulp/ipoib/kernel/ipoib_debug.c	(revision 0)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2005 Mellanox Technologies LTD.  All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+// Author: Yossi Leybovich 
+
+#include "ipoib_debug.h"
+#include <stdio.h> 
+#include <stdarg.h>
+#include  <ntstrsafe.h>
+
+#if !defined(EVENT_TRACING)
+
+
+#if DBG 
+uint32_t g_ipoib_dbg_level = TRACE_LEVEL_INFORMATION;
+uint32_t g_ipoib_dbg_flags= IPOIB_DBG_OID;
+#endif
+
+VOID
+_IPOIB_PRINT(
+    IN ULONG   lvl,
+    IN ULONG   flags,
+    IN PCCHAR  msg,
+    ...
+    )
+
+ {
+#if DBG
+#define     TEMP_BUFFER_SIZE        1024
+    va_list    list;
+    UCHAR      debugMessageBuffer[TEMP_BUFFER_SIZE];
+    NTSTATUS status;
+    
+    va_start(list, msg);
+    
+    if (msg) {
+
+        //
+        // Using new safe string functions instead of _vsnprintf. This
function takes
+        // care of NULL terminating if the message is longer than the
buffer.
+        //
+        
+        status =
RtlStringCbVPrintfA((NTSTRSAFE_PSTR)debugMessageBuffer,
sizeof(debugMessageBuffer), 
+                                    msg, list);
+        if(!NT_SUCCESS(status)) {
+            
+            KdPrint ((": RtlStringCbVPrintfA failed %x\n", status));
+            return;
+        }
+        if (lvl <= g_ipoib_dbg_level && 
+                ((flags & g_ipoib_dbg_flags) == flags)) {
+            if(lvl == TRACE_LEVEL_ERROR) KdPrint (("ERROR - "));
+            KdPrint ((" %s", debugMessageBuffer));
+        }        
+    }
+    va_end(list);
+
+    return;
+#endif //DBG
+}
+
+#endif //EVENT_TRACING
+
Index: ulp/ipoib/kernel/ipoib_debug.h
===================================================================
--- ulp/ipoib/kernel/ipoib_debug.h	(revision 836)
+++ ulp/ipoib/kernel/ipoib_debug.h	(working copy)
@@ -43,6 +43,56 @@
 #define IPOIB_OBJ_ENDPOINT		3
 
 
+#if defined(EVENT_TRACING)
+//
+// Software Tracing Definitions 
+//
+#define WPP_CONTROL_GUIDS \
+	WPP_DEFINE_CONTROL_GUID(IPOIBCtlGuid,(3F9BC73D, EB03, 453a,
B27B, 20F9A664211A),  \
+	WPP_DEFINE_BIT( IPOIB_DBG_INIT) \
+	WPP_DEFINE_BIT( IPOIB_DBG_PNP) \
+	WPP_DEFINE_BIT( IPOIB_DBG_SEND) \
+	WPP_DEFINE_BIT( IPOIB_DBG_RECV) \
+	WPP_DEFINE_BIT( IPOIB_DBG_ENDPT) \
+	WPP_DEFINE_BIT( IPOIB_DBG_IB) \
+	WPP_DEFINE_BIT( IPOIB_DBG_BUF) \
+	WPP_DEFINE_BIT( IPOIB_DBG_MCAST) \
+	WPP_DEFINE_BIT( IPOIB_DBG_ALLOC) \
+	WPP_DEFINE_BIT( IPOIB_DBG_OID)\
+	WPP_DEFINE_BIT( IPOIB_DBG_IOCTL))
+
+
+#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags)
&& WPP_CONTROL(WPP_BIT_ ## flags).Level  >= lvl)
+#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)
+#define WPP_FLAG_ENABLED(flags)(WPP_LEVEL_ENABLED(flags) &&
WPP_CONTROL(WPP_BIT_ ## flags).Level  >= TRACE_LEVEL_VERBOSE)
+#define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags)
+
+
+// begin_wpp config
+// IPOIP_PRINT(LEVEL,FLAGS,MSG,...)
+// USEPREFIX(IPOIP_PRINT, "%!FUNC!")
+// end_wpp
+
+
+
+
+//for complation of old MACROS
+
+#define IPOIB_DBG_FUNC	(1 << 28)	/* For function entry/exit */
+#define IPOIB_DBG_INFO	(1 << 29)	/* For verbose information */
+#define IPOIB_DBG_WARN	(1 << 30)	/* For warnings. */
+#define IPOIB_DBG_ERROR	CL_DBG_ERROR
+
+#define IPOIB_ENTER( lvl )
+#define IPOIB_EXIT( lvl )
+#define IPOIB_TRACE( lvl, msg )
+#define IPOIB_TRACE_EXIT( lvl, msg )
+
+#else
+
+
+#include <evntrace.h>
+
 /*
  * Debug macros
  */
@@ -96,6 +146,21 @@
 	}
 
 
+
+VOID
+	_IPOIB_PRINT(
+	IN ULONG lvl, 
+	IN ULONG flags, 
+	IN PCCHAR msg,
+	...);
+
+#define IPOIB_PRINT\
+	KdPrint(("%s():",__FUNCTION__)); _IPOIB_PRINT
+
+
+#endif //EVENT_TRACING
+
+
 enum ipoib_perf_counters
 {
 	SendBundle,
Index: ulp/ipoib/kernel/ipoib_driver.c
===================================================================
--- ulp/ipoib/kernel/ipoib_driver.c	(revision 836)
+++ ulp/ipoib/kernel/ipoib_driver.c	(working copy)
@@ -32,6 +32,12 @@
 
 #include "ipoib_driver.h"
 #include "ipoib_debug.h"
+#if defined(EVENT_TRACING)
+#ifdef offsetof
+#undef offsetof
+#endif
+#include "ipoib_driver.tmh"
+#endif
 #include "ipoib_port.h"
 #include "ipoib_ibat.h"
 #include <complib/cl_bus_ifc.h>
@@ -248,7 +254,9 @@
 #ifdef _DEBUG_
 	PAGED_CODE();
 #endif
-
+#if defined(EVENT_TRACING)
+	WPP_INIT_TRACING(p_drv_obj, p_registry_path);
+#endif
 	status = CL_INIT;
 	if( !NT_SUCCESS( status ) )
 	{
@@ -358,6 +366,10 @@
 	IN				PDRIVER_OBJECT
p_drv_obj )
 {
 	IPOIB_ENTER( IPOIB_DBG_INIT );
+	#if defined(EVENT_TRACING)
+	WPP_CLEANUP(p_drv_obj);
+	#endif
+
 	UNREFERENCED_PARAMETER( p_drv_obj );
 	CL_DEINIT;
 	IPOIB_EXIT( IPOIB_DBG_INIT );
@@ -730,7 +742,7 @@
 	uint8_t				port_num;
 
 	IPOIB_ENTER( IPOIB_DBG_OID );
-
+	IPOIB_PRINT(TRACE_LEVEL_ERROR, IPOIB_DBG_OID, "=======enter to
function \n");
 	oid_info.oid = oid;
 	oid_info.p_buf = info_buf;
 	oid_info.buf_len = info_buf_len;
Index: ulp/ipoib/kernel/SOURCES
===================================================================
--- ulp/ipoib/kernel/SOURCES	(revision 836)
+++ ulp/ipoib/kernel/SOURCES	(working copy)
@@ -2,8 +2,11 @@
 TARGETPATH=..\..\..\bin\kernel\obj$(BUILD_ALT_DIR)
 TARGETTYPE=DRIVER
 
+ENABLE_EVENT_TRACING=1
+
 SOURCES= 	ipoib_log.mc \
 		ipoib.rc \
+		ipoib_debug.c \
 		ipoib_driver.c \
 		ipoib_adapter.c \
 		ipoib_endpoint.c \
@@ -27,4 +30,13 @@
 TARGETLIBS= $(TARGETLIBS) $(DDK_LIB_PATH)\ntstrsafe.lib
 !endif
 
+!IFDEF ENABLE_EVENT_TRACING
+
+C_DEFINES = $(C_DEFINES) -DEVENT_TRACING
+
+RUN_WPP= -ext:.c.h $(SOURCES) -km \
+	-scan:ipoib_debug.h \
+	-func:IPOIB_PRINT(LEVEL,FLAGS,MSG,...) 
+!ENDIF
+
 MSC_WARNING_LEVEL= /W4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipoib_WPP.patch
Type: application/octet-stream
Size: 7068 bytes
Desc: ipoib_WPP.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20051220/d88b7cec/attachment.obj>


More information about the ofw mailing list