[MTHCA] 1. another implementation of atomic functions, which works around MS compiler...
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 28 Mar 2006 09:23:02 +0000 (09:23 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 28 Mar 2006 09:23:02 +0000 (09:23 +0000)
2. fix of small bugs in debug macro (mlnx_uvp_debug.h).
3. changes for using of WPP in release version.
4. compiler warning fixes (for /W4).

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@257 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/kernel/SOURCES
hw/mthca/kernel/mt_atomic.h
hw/mthca/kernel/mt_uverbsmem.c
hw/mthca/user/SOURCES
hw/mthca/user/mlnx_uvp_cq.c
hw/mthca/user/mlnx_uvp_debug.h
hw/mthca/user/mlnx_uvp_qp.c
hw/mthca/user/mlnx_uvp_verbs.c

index 9bc19b1..3c9fe3c 100644 (file)
@@ -4,7 +4,11 @@ TARGETNAME=mthca
 TARGETPATH=$(TRUNK)\bin\kernel\obj$(BUILD_ALT_DIR)\r
 TARGETTYPE=DRIVER\r
 \r
+!if $(FREEBUILD)\r
+ENABLE_EVENT_TRACING=1\r
+!else\r
 #ENABLE_EVENT_TRACING=1\r
+!endif\r
 \r
 SOURCES= \\r
        mthca_log.mc            \\r
@@ -67,17 +71,18 @@ TARGETLIBS= \
        $(DDK_LIB_PATH)\wdmguid.lib\r
 \r
 \r
+#LINKER_FLAGS=/MAP /MAPINFO:LINES\r
 \r
 !IFDEF ENABLE_EVENT_TRACING\r
 \r
 C_DEFINES = $(C_DEFINES) -DEVENT_TRACING\r
 \r
-RUN_WPP= -ext:.c.h $(SOURCES) -km \\r
+RUN_WPP= $(SOURCES) -km -ext: .c .h .C .H \\r
        -scan:hca_debug.h \\r
        -func:HCA_PRINT(LEVEL,FLAGS,(MSG,...)) \\r
        -func:HCA_PRINT_EV(LEVEL,FLAGS,(MSG,...)) \\r
        -func:HCA_PRINT_EXIT(LEVEL,FLAGS,(MSG,...)) \r
 !ENDIF\r
 \r
-\r
+MSC_OPTIMIZATION=/Oi\r
 MSC_WARNING_LEVEL= /W4\r
index 4dcf5f3..883e690 100644 (file)
@@ -1,27 +1,21 @@
 #ifndef MT_ATOMIC_H
 #define MT_ATOMIC_H
 
-// atomic
-typedef LONG atomic_t;
+#include "cl_atomic.h"
 
-static inline void atomic_inc(atomic_t *pval)
-{
-       InterlockedIncrement(pval);     
-}
+typedef atomic32_t atomic_t;
 
-static inline void atomic_dec(atomic_t *pval)
-{
-       InterlockedDecrement(pval);     
-}
+#define atomic_inc     cl_atomic_inc
+#define atomic_dec     cl_atomic_dec
 
-static inline atomic_t atomic_read(atomic_t *pval)
+static inline atomic_t atomic_read(atomic_t *pval) 
 {
-       return (atomic_t)InterlockedOr (pval,0);        
+       return *pval;   
 }
 
 static inline void atomic_set(atomic_t *pval, long val)
 {
-       InterlockedExchange(pval, val); 
+       *pval = (atomic_t)val;
 }
 
 /**
@@ -35,8 +29,7 @@ static inline void atomic_set(atomic_t *pval, long val)
 static inline int
 atomic_inc_and_test(atomic_t *pval)
 { 
-       LONG val = InterlockedIncrement(pval);
-       return (val == 0);
+       return cl_atomic_inc(pval) == 0;
 }
 
 /**
@@ -50,9 +43,7 @@ atomic_inc_and_test(atomic_t *pval)
 static inline int
 atomic_dec_and_test(atomic_t *pval)
 { 
-       LONG  val = InterlockedDecrement(pval);
-       return (val == 0);
+       return cl_atomic_dec(pval) == 0;
 }
 
-
 #endif
index d67f3d6..3fbc005 100644 (file)
 
 #include "ib_verbs.h"
 
+#if defined(EVENT_TRACING)
+#ifdef offsetof
+#undef offsetof
+#endif
+#include "mt_uverbsmem.tmh"
+#endif
+
 void ibv_umem_release(struct ib_device *dev, struct ib_umem *umem)
 {
        struct ib_umem_chunk *chunk, *tmp;
@@ -81,7 +88,7 @@ int ibv_umem_get(struct ib_device *dev, struct ib_umem *mem,
                list_add_tail(&chunk->list, &mem->chunk_list);
 
                /* fill the chunk */
-               for (i=0; i < IB_UMEM_MAX_PAGE_CHUNK; i++) {
+               for (i=0; i < (int)IB_UMEM_MAX_PAGE_CHUNK; i++) {
 
                        /* map a one page */
                        ret = get_user_pages((struct mthca_dev *)dev, cur_base,
index 48d292e..5ff4f7b 100644 (file)
@@ -12,7 +12,11 @@ DLLDEF=$(O)\mlnx_uvp.def
 USE_MSVCRT=1\r
 DLLENTRY=DllMain\r
 \r
+!if $(FREEBUILD)\r
+ENABLE_EVENT_TRACING=1\r
+!else\r
 #ENABLE_EVENT_TRACING=1\r
+!endif\r
 \r
 SOURCES= \\r
        mlnx_uvp.rc \\r
@@ -42,7 +46,7 @@ INCLUDES= \
        $(TRUNK)\inc\user\complib; \\r
        $(TRUNK)\inc;   \\r
 \r
-USER_C_FLAGS=$(USER_C_FLAGS) /DCL_NO_TRACK_MEM\r
+USER_C_FLAGS=$(USER_C_FLAGS) /DCL_NO_TRACK_MEM \r
 \r
 TARGETLIBS=\\r
        $(SDK_LIB_PATH)\user32.lib \\r
@@ -56,14 +60,16 @@ TARGETLIBS=\
        $(TARGETPATH)\*\ibald.lib\r
 !endif\r
 \r
+#LINKER_FLAGS=/MAP /MAPINFO:LINES\r
 \r
 !IFDEF ENABLE_EVENT_TRACING\r
 \r
 C_DEFINES = $(C_DEFINES) -DEVENT_TRACING\r
 \r
-RUN_WPP= -ext:.c.h $(SOURCES) \\r
+RUN_WPP= $(SOURCES) -ext:.c.h \\r
        -scan:mlnx_uvp_debug.h \\r
-       -func:UVP_PRINT(LEVEL,FLAGS,(MSG,...)) \r
+       -func:UVP_PRINT(LEVEL,FLAGS,(MSG,...)) \\r
+       -func:UVP_PRINT_EXIT(LEVEL,FLAGS,(MSG,...)) \r
 !ENDIF\r
 \r
 MSC_WARNING_LEVEL= /W3\r
index 26776ec..c98ab2d 100644 (file)
  */
 
 #include <mt_l2w.h>
-
 #include <opcode.h>
-
 #include "mlnx_uvp.h"
-#include "mlnx_uvp_debug.h"
+#include "mlnx_uvp_doorbell.h"
+
 #if defined(EVENT_TRACING)
 #include "mlnx_uvp_cq.tmh"
 #endif
 
-#include "mlnx_uvp_doorbell.h"
 
 enum {
        MTHCA_CQ_DOORBELL       = 0x20
index 58e2b47..94ae762 100644 (file)
@@ -76,7 +76,6 @@ extern uint32_t               g_mlnx_dbg_flags;
 // end_wpp\r
 \r
 \r
-\r
 #else\r
 \r
 #include <wmistr.h>\r
@@ -109,10 +108,9 @@ VOID
 #if DBG\r
 \r
 #define UVP_PRINT(_level_,_flags_,_msg_)  \\r
-       if (_level_ <= g_mlnx_dbg_level && \\r
-                ((_flags_ & g_mlnx_dbg_flags) == _flags_)){\\r
+       if ((_level_) <= g_mlnx_dbg_level && (_flags_) & g_mlnx_dbg_flags) {\\r
                 _UVP_PRINT("[UVP] %s():",__FUNCTION__);\\r
-                if(_level_ == TRACE_LEVEL_ERROR) _UVP_PRINT ("***ERROR***  ");\\r
+                if((_level_) == TRACE_LEVEL_ERROR) _UVP_PRINT ("***ERROR***  ");\\r
                _UVP_PRINT _msg_  ;     \\r
        }\r
        \r
index ed2b9a2..c0ea26e 100644 (file)
@@ -177,6 +177,13 @@ int mthca_tavor_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
                prev_wqe = qp->sq.last;
                qp->sq.last = wqe;
                opcode = conv_ibal_wr_opcode(wr);
+               if (opcode == MTHCA_OPCODE_INVALID) {
+                       UVP_PRINT(TRACE_LEVEL_ERROR  ,UVP_DBG_QP ,("SQ %06x opcode invalid\n",ibqp->qp_num));
+                       ret = -EINVAL;
+                       *bad_wr = wr;
+                       goto out;
+               }
+
 
                ((struct mthca_next_seg *) wqe)->nda_op = 0;
                ((struct mthca_next_seg *) wqe)->ee_nds = 0;
@@ -328,13 +335,6 @@ int mthca_tavor_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
 
                qp->wrid[ind + qp->rq.max] = wr->wr_id;
 
-               if (opcode == MTHCA_OPCODE_INVALID) {
-                       UVP_PRINT(TRACE_LEVEL_ERROR  ,UVP_DBG_QP ,("SQ %06x opcode invalid\n",ibqp->qp_num));
-                       ret = -EINVAL;
-                       *bad_wr = wr;
-                       goto out;
-               }
-
                ((struct mthca_next_seg *) prev_wqe)->nda_op =
                        cl_hton32(((ind << qp->sq.wqe_shift) +
                        qp->send_wqe_offset) |opcode);
index c155995..ca2af0b 100644 (file)
 #include "mlnx_uvp.h"
 #include "mx_abi.h"
 
+#if defined(EVENT_TRACING)
+#include "mlnx_uvp_verbs.tmh"
+#endif
+
 struct ibv_pd *mthca_alloc_pd(struct ibv_context *context, struct ibv_alloc_pd_resp *resp)
 {
        struct mthca_pd           *pd;