From: tzachid Date: Tue, 28 Mar 2006 09:23:02 +0000 (+0000) Subject: [MTHCA] 1. another implementation of atomic functions, which works around MS compiler... X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=c89e47545dbefbd5e88b53bc1533ec68bc446ead;p=~shefty%2Frdma-win.git [MTHCA] 1. another implementation of atomic functions, which works around MS compiler bug in InterlockedOr (mt_atomic.h). 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@257 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/hw/mthca/kernel/SOURCES b/trunk/hw/mthca/kernel/SOURCES index 9bc19b14..3c9fe3c2 100644 --- a/trunk/hw/mthca/kernel/SOURCES +++ b/trunk/hw/mthca/kernel/SOURCES @@ -4,7 +4,11 @@ TARGETNAME=mthca TARGETPATH=$(TRUNK)\bin\kernel\obj$(BUILD_ALT_DIR) TARGETTYPE=DRIVER +!if $(FREEBUILD) +ENABLE_EVENT_TRACING=1 +!else #ENABLE_EVENT_TRACING=1 +!endif SOURCES= \ mthca_log.mc \ @@ -67,17 +71,18 @@ TARGETLIBS= \ $(DDK_LIB_PATH)\wdmguid.lib +#LINKER_FLAGS=/MAP /MAPINFO:LINES !IFDEF ENABLE_EVENT_TRACING C_DEFINES = $(C_DEFINES) -DEVENT_TRACING -RUN_WPP= -ext:.c.h $(SOURCES) -km \ +RUN_WPP= $(SOURCES) -km -ext: .c .h .C .H \ -scan:hca_debug.h \ -func:HCA_PRINT(LEVEL,FLAGS,(MSG,...)) \ -func:HCA_PRINT_EV(LEVEL,FLAGS,(MSG,...)) \ -func:HCA_PRINT_EXIT(LEVEL,FLAGS,(MSG,...)) !ENDIF - +MSC_OPTIMIZATION=/Oi MSC_WARNING_LEVEL= /W4 diff --git a/trunk/hw/mthca/kernel/mt_atomic.h b/trunk/hw/mthca/kernel/mt_atomic.h index 4dcf5f30..883e690e 100644 --- a/trunk/hw/mthca/kernel/mt_atomic.h +++ b/trunk/hw/mthca/kernel/mt_atomic.h @@ -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 diff --git a/trunk/hw/mthca/kernel/mt_uverbsmem.c b/trunk/hw/mthca/kernel/mt_uverbsmem.c index d67f3d64..3fbc0056 100644 --- a/trunk/hw/mthca/kernel/mt_uverbsmem.c +++ b/trunk/hw/mthca/kernel/mt_uverbsmem.c @@ -36,6 +36,13 @@ #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, diff --git a/trunk/hw/mthca/user/SOURCES b/trunk/hw/mthca/user/SOURCES index 48d292ed..5ff4f7bf 100644 --- a/trunk/hw/mthca/user/SOURCES +++ b/trunk/hw/mthca/user/SOURCES @@ -12,7 +12,11 @@ DLLDEF=$(O)\mlnx_uvp.def USE_MSVCRT=1 DLLENTRY=DllMain +!if $(FREEBUILD) +ENABLE_EVENT_TRACING=1 +!else #ENABLE_EVENT_TRACING=1 +!endif SOURCES= \ mlnx_uvp.rc \ @@ -42,7 +46,7 @@ INCLUDES= \ $(TRUNK)\inc\user\complib; \ $(TRUNK)\inc; \ -USER_C_FLAGS=$(USER_C_FLAGS) /DCL_NO_TRACK_MEM +USER_C_FLAGS=$(USER_C_FLAGS) /DCL_NO_TRACK_MEM TARGETLIBS=\ $(SDK_LIB_PATH)\user32.lib \ @@ -56,14 +60,16 @@ TARGETLIBS=\ $(TARGETPATH)\*\ibald.lib !endif +#LINKER_FLAGS=/MAP /MAPINFO:LINES !IFDEF ENABLE_EVENT_TRACING C_DEFINES = $(C_DEFINES) -DEVENT_TRACING -RUN_WPP= -ext:.c.h $(SOURCES) \ +RUN_WPP= $(SOURCES) -ext:.c.h \ -scan:mlnx_uvp_debug.h \ - -func:UVP_PRINT(LEVEL,FLAGS,(MSG,...)) + -func:UVP_PRINT(LEVEL,FLAGS,(MSG,...)) \ + -func:UVP_PRINT_EXIT(LEVEL,FLAGS,(MSG,...)) !ENDIF MSC_WARNING_LEVEL= /W3 diff --git a/trunk/hw/mthca/user/mlnx_uvp_cq.c b/trunk/hw/mthca/user/mlnx_uvp_cq.c index 26776ecd..c98ab2d7 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_cq.c +++ b/trunk/hw/mthca/user/mlnx_uvp_cq.c @@ -34,16 +34,14 @@ */ #include - #include - #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 diff --git a/trunk/hw/mthca/user/mlnx_uvp_debug.h b/trunk/hw/mthca/user/mlnx_uvp_debug.h index 58e2b474..94ae762e 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_debug.h +++ b/trunk/hw/mthca/user/mlnx_uvp_debug.h @@ -76,7 +76,6 @@ extern uint32_t g_mlnx_dbg_flags; // end_wpp - #else #include @@ -109,10 +108,9 @@ VOID #if DBG #define UVP_PRINT(_level_,_flags_,_msg_) \ - if (_level_ <= g_mlnx_dbg_level && \ - ((_flags_ & g_mlnx_dbg_flags) == _flags_)){\ + if ((_level_) <= g_mlnx_dbg_level && (_flags_) & g_mlnx_dbg_flags) {\ _UVP_PRINT("[UVP] %s():",__FUNCTION__);\ - if(_level_ == TRACE_LEVEL_ERROR) _UVP_PRINT ("***ERROR*** ");\ + if((_level_) == TRACE_LEVEL_ERROR) _UVP_PRINT ("***ERROR*** ");\ _UVP_PRINT _msg_ ; \ } diff --git a/trunk/hw/mthca/user/mlnx_uvp_qp.c b/trunk/hw/mthca/user/mlnx_uvp_qp.c index ed2b9a23..c0ea26e4 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_qp.c +++ b/trunk/hw/mthca/user/mlnx_uvp_qp.c @@ -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); diff --git a/trunk/hw/mthca/user/mlnx_uvp_verbs.c b/trunk/hw/mthca/user/mlnx_uvp_verbs.c index c1559950..ca2af0b1 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_verbs.c +++ b/trunk/hw/mthca/user/mlnx_uvp_verbs.c @@ -38,6 +38,10 @@ #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;