[TESTS] 1. added a new RegisterVarMemRegions test. It's an improved RegisterMemRegion...
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 13 Jul 2006 14:43:43 +0000 (14:43 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 13 Jul 2006 14:43:43 +0000 (14:43 +0000)
2. added a new ReregisterHca test: it causes driver to re-register itself with IBAL.

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

tests/alts/alts_common.h
tests/alts/alts_readme.txt
tests/alts/registermemregion.c
tests/alts/reregister_hca.c [new file with mode: 0644]
tests/alts/user/SOURCES
tests/alts/user/alts_main.c

index fce87c2..57baa91 100644 (file)
@@ -98,6 +98,8 @@ typedef enum alts_dev_ops
        QueryAndModifyCQ,\r
        AttachMultiCast,\r
        RegisterMemRegion,\r
+       RegisterVarMemRegions,\r
+       ReregisterHca,\r
        RegisterPhyMemRegion,\r
        CreateMemWindow,\r
        RegisterSharedMemRegion,\r
@@ -210,6 +212,12 @@ al_test_register_mem( void );
 ib_api_status_t\r
 al_test_create_mem_window( void );\r
 \r
+ib_api_status_t\r
+al_test_register_var_mem( void );\r
+\r
+ib_api_status_t\r
+al_test_reregister_hca( void );\r
+\r
 ib_api_status_t\r
 al_test_multi_send_recv( void );\r
 \r
index cc0519f..c5976df 100644 (file)
@@ -83,6 +83,8 @@ Running specific tests are as shown below.
        QueryAndModifyEEC\r
        AttachMultiCast\r
        RegisterMemRegion\r
+       RegisterVarMemRegions\r
+       ReregisterHca\r
        RegisterPhyMemRegion\r
        CreateMemWindow\r
        RegisterSharedMemRegion\r
index c563529..96eaff6 100644 (file)
  * $Id$\r
  */\r
 \r
-\r
 #include <iba/ib_types.h>\r
 #include <iba/ib_al.h>\r
 #include <complib/cl_memory.h>\r
+#include <complib/cl_timer.h>\r
 #include <alts_debug.h>\r
 #include <alts_common.h>\r
 \r
@@ -52,7 +52,6 @@
 /*\r
  * Test Case RegisterMemRegion\r
  */\r
-\r
 ib_api_status_t\r
 al_test_register_mem(\r
        void\r
@@ -221,6 +220,177 @@ al_test_register_mem(
        return ib_status;\r
 }\r
 \r
+\r
+\r
+/*\r
+ * Test Case RegisterVarMemRegions\r
+ */\r
+\r
+#define MIN_MEM_SIZE   1       // size of the first region\r
+#define N_SIZES                        27      // number of regions, each next one is twice the size of the previous one\r
+#define ITER_NUM               3       // each region will be re-/deregistered ITER_NUM times\r
+\r
+ib_api_status_t\r
+al_test_register_var_mem(\r
+       void\r
+       )\r
+{\r
+       ib_api_status_t ib_status = IB_SUCCESS;\r
+       ib_al_handle_t h_al = NULL;\r
+       ib_ca_handle_t h_ca = NULL;\r
+       ib_pd_handle_t h_pd = NULL;\r
+\r
+       ib_mr_create_t virt_mem;\r
+       char *ptr = NULL;\r
+       uint32_t        lkey;\r
+       uint32_t        rkey;\r
+       ib_mr_handle_t  h_mr = NULL;\r
+       ib_mr_attr_t    alts_mr_attr;\r
+\r
+       ALTS_ENTER( ALTS_DBG_VERBOSE );\r
+\r
+       /* Open AL */\r
+       ib_status = alts_open_al(&h_al);\r
+\r
+       if(ib_status != IB_SUCCESS)\r
+               goto done;\r
+\r
+       CL_ASSERT(h_al);\r
+\r
+       /* Open CA */\r
+       ib_status = alts_open_ca(h_al,&h_ca);\r
+       if(ib_status != IB_SUCCESS)\r
+               goto err_open_ca;\r
+\r
+       CL_ASSERT(h_ca);\r
+\r
+       /*\r
+        * Allocate a PD here\r
+        */\r
+       ib_status = ib_alloc_pd(h_ca, IB_PDT_NORMAL, NULL, &h_pd); //passing null context\r
+\r
+       if(ib_status != IB_SUCCESS) \r
+       {\r
+               ALTS_PRINT( ALTS_DBG_ERROR,\r
+                       ("ib_alloc_pd failed status = %s\n", ib_get_err_str(ib_status)) );\r
+               goto err_alloc_pd;;\r
+       }\r
+\r
+       /*\r
+        * Register the memory region\r
+        */\r
+       {\r
+               #define MAX_MEM_SIZE    (MIN_MEM_SIZE << N_SIZES)       // 1GB\r
+               #define MEM_OFFSET              1\r
+               #define PAGE_SIZE               4096\r
+               #define PAGE_MASK               (PAGE_SIZE - 1)\r
+               unsigned i, j, offset;\r
+               unsigned __int64 size;\r
+               unsigned __int64 sizea;\r
+               int reg_time[N_SIZES], dereg_time[N_SIZES];\r
+               int reg_tries[N_SIZES], dereg_tries[N_SIZES];\r
+               unsigned __int64  Start, End;\r
+\r
+               ALTS_PRINT( ALTS_DBG_ERROR, ("***** min_size %#x, max_size %#x, n_sizes %d \n",\r
+                       MIN_MEM_SIZE, MAX_MEM_SIZE, N_SIZES ));\r
+               \r
+\r
+               for (size = MIN_MEM_SIZE, j=0; size < MAX_MEM_SIZE; size <<= 1, ++j) \r
+               {\r
+\r
+                       /* Allocate the virtual memory which needs to be registered */\r
+                       sizea = size + MEM_OFFSET - 1;\r
+                       ptr = cl_malloc((size_t)sizea);\r
+                       if (!ptr) {\r
+                               ALTS_PRINT( ALTS_DBG_ERROR,\r
+                                       ("cl_malloc failed on %#x bytes\n", sizea) );\r
+                               continue;\r
+                       }\r
+                       offset = (int)((ULONG_PTR)ptr & PAGE_MASK);\r
+                       virt_mem.vaddr = ptr - offset;\r
+                       virt_mem.length = sizea + offset;\r
+                       virt_mem.access_ctrl = IB_AC_LOCAL_WRITE;\r
+                       \r
+                       reg_time[j] =dereg_time[j] =reg_tries[j] =dereg_tries[j] =0;\r
+                       for (i=0; i<ITER_NUM; ++i) {\r
+\r
+                               /* Register the memory region */\r
+                               Start = cl_get_time_stamp();\r
+                               ib_status = ib_reg_mem(h_pd, &virt_mem, &lkey, &rkey, &h_mr);\r
+                               End = cl_get_time_stamp();\r
+                               if(ib_status != IB_SUCCESS) {\r
+                                       ALTS_PRINT( ALTS_DBG_ERROR,\r
+                                               ("ib_reg_mem failed status = %s on size %#x\n", \r
+                                               ib_get_err_str(ib_status), virt_mem.length) );\r
+                                       break;\r
+                               }\r
+                               else {\r
+                               #if 0\r
+                                       ALTS_PRINT( ALTS_DBG_ERROR, ("ib_reg_mr: sz %#x in %d usec \n",\r
+                                               virt_mem.length, (int) (End - Start)));\r
+                               #endif\r
+                                       reg_time[j] += (int) (End - Start);\r
+                                       ++reg_tries[j];\r
+                               }\r
+\r
+                               /* De-register the memory region */\r
+                               Start = cl_get_time_stamp();\r
+                               ib_status = ib_dereg_mr(h_mr);\r
+                               End = cl_get_time_stamp();\r
+                               if(ib_status != IB_SUCCESS) {\r
+                                       ALTS_PRINT( ALTS_DBG_ERROR,\r
+                                               ("ib_dereg_mr failed status = %s\n", \r
+                                               ib_get_err_str(ib_status)) );\r
+                               }\r
+                               else {\r
+                               #if 0\r
+                                       ALTS_PRINT( ALTS_DBG_ERROR, ("ib_dereg_mr: sz %#x in %d usec \n",\r
+                                               virt_mem.length, (int) (End - Start)));\r
+                               #endif\r
+                                       dereg_time[j] += (int) (End - Start);\r
+                                       ++dereg_tries[j];\r
+                               }\r
+                       }\r
+\r
+                       if ( ptr )\r
+                               cl_free ( ptr );\r
+               }\r
+\r
+               /* results */\r
+               for (size = MIN_MEM_SIZE, j=0; j<N_SIZES; size <<= 1, ++j) \r
+               {\r
+                       ALTS_PRINT( ALTS_DBG_ERROR, ("sz %#x \treg %d \tdereg %d \t \n",\r
+                               size, \r
+                               (reg_tries[j]) ? reg_time[j]/reg_tries[j] : 0,\r
+                               (dereg_tries[j]) ? dereg_time[j]/dereg_tries[j] : 0\r
+                               ));\r
+               }\r
+               \r
+       }\r
+\r
+       /*\r
+        * Deallocate the PD\r
+        */\r
+\r
+       ib_status = ib_dealloc_pd(h_pd,alts_pd_destroy_cb);\r
+       if(ib_status != IB_SUCCESS) \r
+       {\r
+               ALTS_PRINT( ALTS_DBG_ERROR,\r
+                       ("ib_dealloc_pd failed status = %s\n",ib_get_err_str(ib_status)) );\r
+       }\r
+\r
+err_alloc_pd:\r
+       alts_close_ca(h_ca);\r
+err_open_ca:\r
+       /* Close AL */\r
+       if(h_al)\r
+               alts_close_al(h_al);\r
+done:\r
+       ALTS_EXIT( ALTS_DBG_VERBOSE);\r
+       return ib_status;\r
+}\r
+\r
+\r
 /*\r
  * Test Case RegisterPhyMemRegion\r
  */\r
diff --git a/tests/alts/reregister_hca.c b/tests/alts/reregister_hca.c
new file mode 100644 (file)
index 0000000..c1a6de5
--- /dev/null
@@ -0,0 +1,104 @@
+
+/*
+ * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. 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.
+ *
+ * $Id: registermemregion.c 689 2005-10-31 07:23:08Z sleybo $
+ */
+
+#include <iba/ib_types.h>
+#include <iba/ib_al.h>
+#include <complib/cl_memory.h>
+#include <complib/cl_timer.h>
+#include <alts_debug.h>
+#include <alts_common.h>
+#include <mthca/mthca_vc.h>
+
+
+/*
+ * Function prototypes
+ */
+
+
+/*
+ * Test Case RegisterMemRegion
+ */
+ib_api_status_t
+al_test_reregister_hca(
+       void
+       )
+{
+       ib_api_status_t ib_status = IB_SUCCESS;
+       ib_al_handle_t h_al = NULL;
+       ib_ca_handle_t h_ca = NULL;
+       ib_ci_op_t ci_op;
+
+       ALTS_ENTER( ALTS_DBG_VERBOSE );
+
+       while(1)
+       {
+               /* Open AL */
+               ib_status = alts_open_al(&h_al);
+
+               if(ib_status != IB_SUCCESS)
+                       break;
+
+               CL_ASSERT(h_al);
+
+               /* Open CA */
+               ib_status = alts_open_ca(h_al,&h_ca);
+               if(ib_status != IB_SUCCESS)
+                       break;
+
+               CL_ASSERT(h_ca);
+
+               /* send ioctl */
+               memset( &ci_op, 0, sizeof(ci_op) );
+               ci_op.command = FW_REREGISTER_HCA;
+
+               ib_status = ib_ci_call (h_ca, NULL, 0, &ci_op);
+               if(ib_status != IB_SUCCESS)
+                       ALTS_PRINT( ALTS_DBG_ERROR,
+                               ("ib_ci_call failed status = %s\n",
+                               ib_get_err_str(ib_status)) );
+               else
+                       ALTS_PRINT( ALTS_DBG_INFO, 
+                               ("ib_ci_call PASSED.\n") );
+               break;
+       }
+
+       if(h_ca)
+               alts_close_ca(h_ca);
+
+       if(h_al)
+               alts_close_al(h_al);
+
+       ALTS_EXIT( ALTS_DBG_VERBOSE);
+       return ib_status;
+}
+
index 499a534..934a86e 100644 (file)
@@ -4,7 +4,7 @@ TARGETTYPE=PROGRAM
 UMTYPE=console\r
 USE_CRTDLL=1\r
 \r
-SOURCES=alts_main.c                    \\r
+SOURCES=alts_main.c            \\r
        ..\allocdeallocpd.c             \\r
        ..\alts_misc.c                  \\r
        ..\cmtests.c                    \\r
@@ -18,6 +18,7 @@ SOURCES=alts_main.c                   \
        ..\openclose.c                  \\r
        ..\querycaattr.c                \\r
        ..\registermemregion.c  \\r
+       ..\reregister_hca.c             \\r
        ..\registerpnp.c                \\r
        ..\smatests.c\r
        \r
index d7dd1fd..929c8d8 100644 (file)
@@ -203,6 +203,12 @@ ib_api_status_t ib_status = IB_ERROR;
        case RegisterMemRegion:\r
                ib_status = al_test_register_mem();\r
                break;\r
+       case RegisterVarMemRegions:\r
+               ib_status = al_test_register_var_mem();\r
+               break;\r
+       case ReregisterHca:\r
+               ib_status = al_test_reregister_hca();\r
+               break;\r
        case RegisterPhyMemRegion:\r
                CL_PRINT( ALTS_DBG_VERBOSE, alts_dbg_lvl,\r
                        ("altsapp: RegisterPhyMemRegion not implemented.\n") );\r
@@ -398,6 +404,16 @@ boolean_t parse_cmd_line(
                        input_arg->pgm_to_run = RegisterMemRegion;\r
                        continue;\r
                }\r
+               if (strcasecmp(*argv, "--tc=RegisterVarMemRegions") == 0)\r
+               {\r
+                       input_arg->pgm_to_run = RegisterVarMemRegions;\r
+                       continue;\r
+               }\r
+               if (strcasecmp(*argv, "--tc=ReregisterHca") == 0)\r
+               {\r
+                       input_arg->pgm_to_run = ReregisterHca;\r
+                       continue;\r
+               }\r
                if (strcasecmp(*argv, "--tc=RegisterPhyMemRegion") == 0)\r
                {\r
                        input_arg->pgm_to_run = RegisterPhyMemRegion;\r