]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[TOOLS] add installer for WND
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 10 Apr 2007 10:44:30 +0000 (10:44 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 10 Apr 2007 10:44:30 +0000 (10:44 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@628 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

branches/RDMA/tools/dirs
branches/RDMA/tools/wndinstall/dirs [new file with mode: 0644]
branches/RDMA/tools/wndinstall/user/SOURCES [new file with mode: 0644]
branches/RDMA/tools/wndinstall/user/WndInstallsp.c [new file with mode: 0644]
branches/RDMA/tools/wndinstall/user/WndInstallsp.rc [new file with mode: 0644]
branches/RDMA/tools/wndinstall/user/makefile [new file with mode: 0644]

index 50d31f7965ed5afa62b9797744c355d1b3bc2d06..d38f5048375c2075d22501390e828a36951ba06e 100644 (file)
@@ -2,6 +2,7 @@ DIRS=\
        coinstaller     \\r
        fwupdate        \\r
        wsdinstall      \\r
+       wndinstall      \\r
        vstat       \\r
        mtcr        \\r
        flint       \\r
diff --git a/branches/RDMA/tools/wndinstall/dirs b/branches/RDMA/tools/wndinstall/dirs
new file mode 100644 (file)
index 0000000..389156f
--- /dev/null
@@ -0,0 +1,2 @@
+DIRS=\\r
+       user\r
diff --git a/branches/RDMA/tools/wndinstall/user/SOURCES b/branches/RDMA/tools/wndinstall/user/SOURCES
new file mode 100644 (file)
index 0000000..0421159
--- /dev/null
@@ -0,0 +1,24 @@
+TARGETNAME=WndInstallsp\r
+TARGETPATH=..\..\..\bin\user\obj$(BUILD_ALT_DIR)\r
+TARGETTYPE=PROGRAM\r
+UMTYPE=console\r
+USE_CRTDLL=1\r
+\r
+INCLUDES=..\..\..\inc;\\r
+       ..\..\..\inc\user;\\r
+       $(PLATFORM_SDK_PATH)\include;\r
+\r
+SOURCES= \\r
+       WndInstallsp.rc \\r
+       WndInstallsp.c\r
+\r
+#USER_C_FLAGS=$(USER_C_FLAGS) -DPERFMON_ENABLED\r
+USER_C_FLAGS=$(USER_C_FLAGS) \r
+\r
+TARGETLIBS=\\r
+       $(SDK_LIB_PATH)\ws2_32.lib \\r
+       $(SDK_LIB_PATH)\LoadPerf.lib \r
+\r
+MSC_WARNING_LEVEL= /W3\r
+\r
+LINKER_FLAGS=$(LINKER_FLAGS)\r
diff --git a/branches/RDMA/tools/wndinstall/user/WndInstallsp.c b/branches/RDMA/tools/wndinstall/user/WndInstallsp.c
new file mode 100644 (file)
index 0000000..f04565b
--- /dev/null
@@ -0,0 +1,740 @@
+/*\r
+ * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ * $Id: installsp.c 388 2006-06-22 07:01:21Z tzachid $\r
+ */\r
+\r
+/*\r
+ *     Module Name: installsp.c\r
+ *     Description: This module installs/removes a winsock service provider for infiniband. \r
+ *     execute:\r
+ *     To install the service provider\r
+ *             installsp -i        \r
+ *     To remove the service provider\r
+ *             installsp -r\r
+ */\r
+\r
+#include <winsock2.h>\r
+#include <ws2spi.h>\r
+#include <stdio.h>\r
+\r
+/* Initialize the LSP's provider path for Infiband Service Provider dll */\r
+static const WCHAR provider_path[] = L"%SYSTEMROOT%\\system32\\ibwnd.dll";\r
+static const WCHAR provider_name[] = L"OpenIB Windows Network Direct for InfiniBand";\r
+static const char wnd_key_path[] =\r
+       "System\\CurrentControlSet\\Services\\Winsock\\Parameters\\TCP on SAN";\r
+static const char openib_key_name[] = "OpenIB Alliance";\r
+\r
+/* {43F32EDB-798C-4b81-8EBF-01BE35D2C5FF} */\r
+static GUID provider_guid  = \r
+{ 0x43f32edb, 0x798c, 0x4b81, { 0x8e, 0xbf, 0x1, 0xbe, 0x35, 0xd2, 0xc5, 0xff } };\r
+\r
+#ifdef _WIN64\r
+#define WSCInstallProvider     WSCInstallProvider64_32\r
+#endif /* _WIN64 */\r
+\r
+#ifdef PERFMON_ENABLED\r
+#include <Loadperf.h>\r
+#include "wnd/ibsp_regpath.h"\r
+\r
+\r
+typedef struct _pm_symbol_def\r
+{\r
+       DWORD   name_def;\r
+       CHAR    name_str[40];\r
+       CHAR    name_desc[40];\r
+       CHAR    help_desc[256];\r
+\r
+} pm_symbol_def_t;\r
+\r
+static pm_symbol_def_t  _pm_symbols[]=\r
+{\r
+       { IBSP_PM_OBJ,\r
+       "IBSP_PM_OBJ",\r
+       "IB Winsock Direct",\r
+       "InfiniBand Windows Sockets Direct Provider."\r
+       },\r
+       { IBSP_PM_COUNTER(BYTES_SEND),\r
+       "IBSP_PM_BYTES_TX_SEC",\r
+       "Send bytes/sec",\r
+       "Send bytes/second, excluding RDMA Write."\r
+       },\r
+       { IBSP_PM_COUNTER(BYTES_RECV),\r
+       "IBSP_PM_BYTES_RX_SEC",\r
+       "Recv bytes/sec",\r
+       "Receive bytes/second, excluding RDMA Read."\r
+       },\r
+       { IBSP_PM_COUNTER(BYTES_WRITE),\r
+       "IBSP_PM_RDMA_WR_SEC",\r
+       "RDMA Write bytes/sec",\r
+       "RDMA Write bytes/second."\r
+       },\r
+       { IBSP_PM_COUNTER(BYTES_READ),\r
+       "IBSP_PM_RDMA_RD_SEC",\r
+       "RDMA Read bytes/sec",\r
+       "RDMA Read bytes/second."\r
+       },\r
+       { IBSP_PM_COUNTER(BYTES_TOTAL),\r
+       "IBSP_PM_BYTES_SEC",\r
+       "Total bytes/sec",\r
+       "Total bytes transmitted per second, including send, "\r
+       "receive, RDMA Write, and RDMA Read."\r
+       },\r
+       { IBSP_PM_COUNTER(COMP_SEND),\r
+       "IBSP_PM_SEND_COMPLETIONS_SEC",\r
+       "Send Completions/sec",\r
+       "Send and RDMA Write Completions/sec."\r
+       },\r
+       { IBSP_PM_COUNTER(COMP_RECV),\r
+       "IBSP_PM_RECV_COMPLETIONS_SEC",\r
+       "Recv Completions/sec",\r
+       "Recv and RDMA Read Completions/sec."\r
+       },\r
+       { IBSP_PM_COUNTER(COMP_TOTAL),\r
+       "IBSP_PM_COMPLETIONS_SEC",\r
+       "Total Completions/sec",\r
+       "Total Completions processed per second."\r
+       },\r
+       { IBSP_PM_COUNTER(INTR_TOTAL),\r
+       "IBSP_PM_COMPLETIONS_INTR",\r
+       "Total Interrupts/sec",\r
+       "Completion Queue events per second."\r
+       }\r
+};\r
+\r
+#define IBSP_PM_NUM_SYMBOLS  (sizeof(_pm_symbols)/sizeof(pm_symbol_def_t))\r
+#define IBSP_PM_LANGUAGE "009" /* good for English */\r
+\r
+static CHAR *\r
+_IBSPGenerateFileName(char *header,    char *file )\r
+{\r
+       DWORD size1, size;\r
+       CHAR *full_file_name;\r
+       int header_len = header == NULL ? 0 : strlen(header);\r
+\r
+       size = GetTempPath(0, NULL);\r
+       if (size == 0)\r
+       {\r
+               fprintf( stderr, "GetTempPath  failed\n" );\r
+               return NULL;\r
+       }\r
+       size1 = size + strlen(file) + header_len;\r
+       full_file_name = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, size1);\r
+       if ( full_file_name == NULL )\r
+       {\r
+               fprintf( stderr, "GetTempPath  failed\n" );\r
+               return NULL;\r
+       }\r
+       size1 = GetTempPath(size, full_file_name + header_len);\r
+       if (size != size1 + 1) \r
+       {\r
+               fprintf( stderr, "Very strange, GetTempPath  returned something different\n" );\r
+               HeapFree (GetProcessHeap (), 0, full_file_name);\r
+               return NULL;\r
+       }\r
+       if (header_len != 0)\r
+       {\r
+               memcpy(full_file_name, header, header_len);\r
+       }\r
+       strcat(full_file_name, file);\r
+       return full_file_name;\r
+}\r
+\r
+\r
+static DWORD\r
+_IBSPPerfmonIniFilesGenerate( void )\r
+{\r
+       FILE    *f_handle;\r
+       DWORD   num;\r
+       DWORD ret = ERROR_SUCCESS;\r
+       char *ibsp_pm_sym_file = NULL;\r
+       char *ibsp_pm_ini_file = NULL;\r
+\r
+       /* create ".h" file first */\r
+       ibsp_pm_sym_file = _IBSPGenerateFileName(NULL, IBSP_PM_SYM_H_FILE);\r
+       if( !ibsp_pm_sym_file )\r
+       {\r
+               fprintf( stderr, "_IBSPGenerateFileName  failed\n" );\r
+               ret = ERROR_NOT_ENOUGH_MEMORY;\r
+               goto Cleanup;\r
+       }\r
+\r
+       f_handle = fopen( ibsp_pm_sym_file, "w+" );\r
+\r
+       if( !f_handle )\r
+       {\r
+               fprintf( stderr, "Create Header file %s failed\n", ibsp_pm_sym_file );\r
+               ret = ERROR_FILE_INVALID;\r
+               goto Cleanup;\r
+       }\r
+\r
+       fprintf(\r
+               f_handle, "/* %s Generated by program */ \r\n", ibsp_pm_sym_file );\r
+               \r
+       \r
+       for( num = 0; num < IBSP_PM_NUM_SYMBOLS; num++ )\r
+       {\r
+               fprintf( f_handle, "#define\t%s\t%d\r\n",\r
+                       _pm_symbols[num].name_str, _pm_symbols[num].name_def );\r
+       }\r
+\r
+       fflush( f_handle );\r
+       fclose( f_handle );\r
+\r
+       /* create 'ini' file next */\r
+       ibsp_pm_ini_file = _IBSPGenerateFileName(NULL, IBSP_PM_INI_FILE);\r
+       if( !ibsp_pm_sym_file )\r
+       {\r
+               fprintf( stderr, "_IBSPGenerateFileName  failed\n" );\r
+               ret = ERROR_NOT_ENOUGH_MEMORY;\r
+               goto Cleanup;\r
+       }\r
+       f_handle = fopen( ibsp_pm_ini_file, "w+" );\r
+\r
+       if( !f_handle )\r
+       {\r
+               fprintf( stderr, "Create INI file %s  failed\n", ibsp_pm_ini_file );\r
+               ret = ERROR_FILE_INVALID;\r
+               goto Cleanup;\r
+       }\r
+       \r
+       fprintf( f_handle, "[info]\r\ndrivername=" IBSP_PM_SUBKEY_NAME\r
+               "\r\nsymbolfile=%s\r\n\r\n", ibsp_pm_sym_file );\r
+       fprintf( f_handle,"[languages]\r\n" IBSP_PM_LANGUAGE\r
+               "=language" IBSP_PM_LANGUAGE "\r\n\r\n" );\r
+\r
+       fprintf( f_handle, \r
+               "[objects]\r\n%s_" IBSP_PM_LANGUAGE "_NAME=%s\r\n\r\n[text]\r\n",\r
+               _pm_symbols[0].name_str, _pm_symbols[0].name_desc );\r
+       \r
+       for( num = 0; num < IBSP_PM_NUM_SYMBOLS; num++ )\r
+       {\r
+               fprintf( f_handle,"%s_" IBSP_PM_LANGUAGE "_NAME=%s\r\n",\r
+                       _pm_symbols[num].name_str, _pm_symbols[num].name_desc );\r
+               fprintf( f_handle,"%s_" IBSP_PM_LANGUAGE "_HELP=%s\r\n",\r
+                       _pm_symbols[num].name_str, _pm_symbols[num].help_desc );\r
+       }\r
+\r
+       fflush( f_handle );\r
+       fclose( f_handle );\r
+\r
+Cleanup:\r
+       if ( ibsp_pm_sym_file )\r
+       {\r
+               HeapFree (GetProcessHeap (), 0, ibsp_pm_sym_file);\r
+       }\r
+       if ( ibsp_pm_ini_file )\r
+       {\r
+               HeapFree (GetProcessHeap (), 0, ibsp_pm_ini_file);\r
+       }\r
+       return ret;\r
+}\r
+\r
+\r
+static void\r
+_IBSPPerfmonIniFilesRemove( void )\r
+{\r
+       char *ibsp_pm_sym_file = NULL;\r
+       char *ibsp_pm_ini_file = NULL;\r
+\r
+       ibsp_pm_sym_file = _IBSPGenerateFileName(NULL, IBSP_PM_SYM_H_FILE);\r
+       if( !ibsp_pm_sym_file )\r
+       {\r
+               fprintf( stderr, "_IBSPGenerateFileName  failed\n" );\r
+               goto Cleanup;\r
+       }\r
+\r
+       ibsp_pm_ini_file = _IBSPGenerateFileName(NULL, IBSP_PM_INI_FILE);\r
+       if( !ibsp_pm_sym_file )\r
+       {\r
+               fprintf( stderr, "_IBSPGenerateFileName  failed\n" );\r
+               goto Cleanup;\r
+       }\r
+\r
+       if( !DeleteFile( ibsp_pm_ini_file ) )\r
+       {\r
+               fprintf( stderr, "Delete file %s failed status %d\n",\r
+                       ibsp_pm_ini_file, GetLastError() );\r
+       }\r
+       if( !DeleteFile( ibsp_pm_sym_file ) )\r
+       {\r
+               fprintf( stderr,"Delete file %s failed status %d\n",\r
+                       ibsp_pm_sym_file, GetLastError() );\r
+       }\r
+\r
+Cleanup:       \r
+       if ( ibsp_pm_sym_file )\r
+       {\r
+               HeapFree (GetProcessHeap (), 0, ibsp_pm_sym_file);\r
+       }\r
+       if ( ibsp_pm_ini_file )\r
+       {\r
+               HeapFree (GetProcessHeap (), 0, ibsp_pm_ini_file);\r
+       }\r
+       \r
+}\r
+\r
+\r
+/* Try to create IB WSD Performance Register Keys */\r
+static LONG\r
+_IBSPPerfmonRegisterKeys( void )\r
+{\r
+       LONG    reg_status;\r
+       HKEY    pm_hkey;\r
+       DWORD   typesSupp = 7;\r
+\r
+       reg_status = RegCreateKeyEx( HKEY_LOCAL_MACHINE,\r
+               IBSP_PM_REGISTRY_PATH IBSP_PM_SUBKEY_PERF, 0, NULL,\r
+               REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &pm_hkey, NULL );\r
+\r
+       if( reg_status != ERROR_SUCCESS )\r
+       {\r
+               fprintf( stderr,\r
+                       "_IBSPPerfmonRegisterKeys Create Key %s failed with %d\n",\r
+                       IBSP_PM_REGISTRY_PATH IBSP_PM_SUBKEY_PERF, reg_status );\r
+               return reg_status;\r
+       }\r
+\r
+       /* create/assign values to the key */\r
+       RegSetValueExW( pm_hkey, L"Library", 0, REG_EXPAND_SZ,\r
+               (LPBYTE)provider_path, sizeof(provider_path) );\r
+\r
+       RegSetValueEx( pm_hkey, TEXT("Open"), 0, REG_SZ,\r
+               (LPBYTE)TEXT("IBSPPmOpen"), sizeof(TEXT("IBSPPmOpen")) );\r
+\r
+       RegSetValueEx( pm_hkey, TEXT("Collect"), 0, REG_SZ,\r
+               (LPBYTE)TEXT("IBSPPmCollectData"), sizeof(TEXT("IBSPPmCollectData")) );\r
+\r
+       RegSetValueEx( pm_hkey, TEXT("Close"), 0, REG_SZ,\r
+               (LPBYTE)TEXT("IBSPPmClose"), sizeof(TEXT("IBSPPmClose")) );\r
+\r
+       RegFlushKey( pm_hkey );\r
+       RegCloseKey( pm_hkey );\r
+\r
+       reg_status = RegCreateKeyEx( HKEY_LOCAL_MACHINE,\r
+               IBSP_PM_EVENTLOG_PATH, 0, NULL,\r
+               REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &pm_hkey, NULL );\r
+\r
+       if( reg_status != ERROR_SUCCESS )\r
+       {\r
+               fprintf(stderr, "Create EventLog Key failed with %d\n", reg_status );\r
+               return reg_status;\r
+       }\r
+\r
+       /* create/assign values to the key */\r
+       RegSetValueExW( pm_hkey, L"EventMessageFile", 0, REG_EXPAND_SZ,\\r
+               (LPBYTE)provider_path, sizeof(provider_path) );\r
+\r
+       RegSetValueEx( pm_hkey, TEXT("TypesSupported"), 0, REG_DWORD,\r
+               (LPBYTE)&typesSupp, sizeof(typesSupp) );\r
+\r
+       RegFlushKey( pm_hkey );\r
+       RegCloseKey( pm_hkey );\r
+\r
+       return reg_status;\r
+}\r
+\r
+\r
+/* Try to destroy IB WSD Performance Register Keys */\r
+static LONG\r
+_IBSPPerfmonDeregisterKeys( void )\r
+{\r
+       LONG    reg_status;\r
+\r
+       reg_status = RegDeleteKeyEx( HKEY_LOCAL_MACHINE,\r
+               IBSP_PM_REGISTRY_PATH IBSP_PM_SUBKEY_PERF,\r
+               (KEY_WOW64_32KEY | KEY_WOW64_64KEY), 0 );\r
+\r
+       if( reg_status != ERROR_SUCCESS )\r
+       {\r
+               fprintf( stderr,\r
+                       "_IBSPPerfmonRegisterKeys Remove SubKey failed with %d\n",\r
+                       GetLastError() );\r
+       }\r
+\r
+       reg_status = RegDeleteKeyEx( HKEY_LOCAL_MACHINE,\r
+               IBSP_PM_REGISTRY_PATH, (KEY_WOW64_32KEY | KEY_WOW64_64KEY), 0 );\r
+\r
+       if( reg_status != ERROR_SUCCESS )\r
+       {\r
+               fprintf( stderr,\r
+                       "_IBSPPerfmonRegisterKeys Remove SubKey failed with %d\n",\r
+                       GetLastError() );\r
+       }\r
+\r
+       reg_status = RegDeleteKeyEx( HKEY_LOCAL_MACHINE,\r
+               IBSP_PM_EVENTLOG_PATH, (KEY_WOW64_32KEY | KEY_WOW64_64KEY), 0 );\r
+\r
+       if( reg_status != ERROR_SUCCESS )\r
+       {\r
+               fprintf( stderr,\r
+                       "_IBSPPerfmonRegisterKeys Remove SubKey failed with %d\n",\r
+                       GetLastError() );\r
+       }\r
+\r
+       return reg_status;\r
+}\r
+\r
+\r
+/*\r
+ * functions will try to register performance counters\r
+ * definitions with PerfMon application.\r
+ * API externally called by lodctr.exe/unlodctr.exe utilities.\r
+ */\r
+static DWORD\r
+_IBSPPerfmonRegisterCounters( void )\r
+{\r
+       DWORD status;\r
+       char *ibsp_pm_ini_file = NULL;\r
+\r
+       ibsp_pm_ini_file = _IBSPGenerateFileName("unused ", IBSP_PM_INI_FILE);\r
+       if( !ibsp_pm_ini_file )\r
+       {\r
+               fprintf( stderr, "_IBSPGenerateFileName  failed\n" );\r
+               status = ERROR_NOT_ENOUGH_MEMORY;\r
+               goto Cleanup;\r
+       }\r
+\r
+       /*\r
+        * format commandline string, as per SDK :\r
+        *      Pointer to a null-terminated string that consists of one or more \r
+        *      arbitrary letters, a space, and then the name of the initialization\r
+        *      file.\r
+        */\r
+       status = LoadPerfCounterTextStrings( ibsp_pm_ini_file, TRUE );\r
+       if( status != ERROR_SUCCESS )\r
+       {\r
+               status = GetLastError();\r
+               fprintf( stderr,\r
+                       "IBSPPerfmonRegisterCounters install failed status %d\n", status );\r
+       }\r
+Cleanup:       \r
+       if ( ibsp_pm_ini_file )\r
+       {\r
+               HeapFree (GetProcessHeap (), 0, ibsp_pm_ini_file);\r
+       }\r
+\r
+       return status;\r
+}\r
+\r
+\r
+/*\r
+ * functions will try to unregister performance counters\r
+ * definitions with PerfMon application.\r
+ * API externally called by lodctr.exe/unlodctr.exe utilities.\r
+ */\r
+static DWORD\r
+_IBSPPerfmonDeregisterCounters( void )\r
+{\r
+       DWORD status;\r
+\r
+       /*\r
+        * format commandline string, as per SDK :\r
+        *      Pointer to a null-terminated string that consists of one or more \r
+        *      arbitrary letters, a space, and then the name of the initialization\r
+        *      file.\r
+        */\r
+       status = UnloadPerfCounterTextStrings(\r
+               TEXT("unused ") TEXT(IBSP_PM_SUBKEY_NAME), TRUE );\r
+       if( status != ERROR_SUCCESS )\r
+       {\r
+               fprintf( stderr,\r
+                       "IBSPPerfmonDeregisterCounters remove failed status %d\n",\r
+                       status );\r
+       }\r
+       return status;\r
+}\r
+\r
+#endif /* PERFMON_ENABLED */\r
+\r
+\r
+/*\r
+ * Function: usage\r
+ *   Description: Prints usage information.\r
+ */\r
+static void\r
+usage (char *progname)\r
+{\r
+       printf ("usage: %s [-i/-r [-p]]\n", progname);\r
+       printf ("    -i   Install the service provider\n"\r
+                       "    -r   Remove the OpenIB service provider\n"\r
+                       "    -r <name>   Remove the specified service provider\n"\r
+                       "    -l   List service providers\n");\r
+}\r
+\r
+\r
+/* Function: print_providers\r
+ *   Description: \r
+ *     This function prints out each entry in the Winsock catalog.\r
+*/\r
+static void print_providers(void)\r
+{\r
+       WSAPROTOCOL_INFOW *protocol_info;\r
+       unsigned int protocol_count;\r
+       unsigned int i;\r
+       DWORD protocol_size;\r
+       INT errno;\r
+       int rc;\r
+\r
+       /* Find the size of the buffer */\r
+       protocol_size = 0;\r
+       rc = WSCEnumProtocols (NULL, NULL, &protocol_size, &errno);\r
+       if (rc == SOCKET_ERROR && errno != WSAENOBUFS) {\r
+               printf("WSCEnumProtocols() returned error (%d)\n", errno);\r
+               return;\r
+       }\r
+\r
+       /* Allocate the buffer */\r
+       protocol_info = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, protocol_size);\r
+       if (protocol_info == NULL) {\r
+               printf("HeapAlloc() failed\n");\r
+               return;\r
+       }\r
+\r
+       /* Enumerate the catalog for real */\r
+       rc = WSCEnumProtocols (NULL, protocol_info, &protocol_size, &errno);\r
+       if (rc == SOCKET_ERROR) {\r
+               printf("WSCEnumProtocols returned error for real enumeration (%d)\n",\r
+                        errno);\r
+               HeapFree (GetProcessHeap (), 0, protocol_info);\r
+               return;\r
+       }\r
+\r
+       protocol_count = rc;\r
+\r
+       for (i = 0; i < protocol_count; i++) {\r
+               printf ("%010d - %S\n", protocol_info[i].dwCatalogEntryId,\r
+                               protocol_info[i].szProtocol);\r
+       }\r
+\r
+       HeapFree (GetProcessHeap (), 0, protocol_info);\r
+\r
+       return;\r
+}\r
+\r
+/*\r
+ * Function: install_provider\r
+ *   Description: installs the service provider\r
+ *\r
+ * Note: most of the information setup here comes from "MSDN Home >\r
+ * MSDN Library > Windows Development > Network Devices and\r
+ * Protocols > Design Guide > System Area Networks > Windows Sockets\r
+ * Direct > Windows Sockets Direct Component Operation > Installing\r
+ * Windows Sockets Direct Components".\r
+ * The direct link is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/network/hh/network/wsdp_2xrb.asp\r
+ */\r
+static void install_provider(void)\r
+{\r
+       int rc;\r
+       INT errno;\r
+       LONG reg_error;\r
+       WSAPROTOCOL_INFOW provider;\r
+       HKEY hkey;\r
+\r
+       /* Now setup the key. */\r
+       reg_error = RegCreateKeyExA( HKEY_LOCAL_MACHINE, wnd_key_path,\r
+               0, NULL, REG_OPTION_NON_VOLATILE, (KEY_WRITE | KEY_READ), NULL,\r
+               &hkey, NULL );\r
+       if( reg_error == ERROR_SUCCESS )\r
+       {\r
+               reg_error = RegSetValueExA( hkey, openib_key_name, 0, REG_BINARY,\r
+                       (PBYTE)&provider_guid, sizeof(GUID) );\r
+               if( reg_error == ERROR_SUCCESS )\r
+               {\r
+                       /* Force the system to write the new key now. */\r
+                       RegFlushKey(hkey);\r
+               }\r
+               else\r
+               {\r
+                       fprintf(stderr, "RegSetValueEx failed with %d\n", GetLastError());\r
+               }\r
+\r
+               RegCloseKey(hkey);\r
+       }\r
+       else\r
+       {\r
+               fprintf(stderr, "Could not get a handle on Winsock registry (%d)\n", GetLastError());\r
+       }\r
+\r
+       /* Setup the values in PROTOCOL_INFO */\r
+       provider.dwServiceFlags1 = \r
+               XP1_GUARANTEED_DELIVERY | \r
+               XP1_GUARANTEED_ORDER | \r
+               XP1_MESSAGE_ORIENTED |\r
+               XP1_GRACEFUL_CLOSE;\r
+       provider.dwServiceFlags2 = 0;   /* Reserved */\r
+       provider.dwServiceFlags3 = 0;   /* Reserved */\r
+       provider.dwServiceFlags4 = 0;   /* Reserved */\r
+       provider.dwProviderFlags = PFL_HIDDEN;\r
+       provider.ProviderId = provider_guid;    /* Service Provider ID provided by vendor. Need to be changed later */\r
+       provider.dwCatalogEntryId = 0;\r
+       provider.ProtocolChain.ChainLen = 1;    /* Base Protocol Service Provider */\r
+       provider.iVersion = 1;  /* don't know what it is */\r
+       provider.iAddressFamily = AF_INET;\r
+       provider.iMaxSockAddr = 16;\r
+       provider.iMinSockAddr = 16;\r
+       provider.iSocketType = -1;\r
+       provider.iProtocol = 0; /*IPPROTO_IP*/\r
+       provider.iProtocolMaxOffset = 0;\r
+       provider.iNetworkByteOrder = BIGENDIAN;\r
+       provider.iSecurityScheme = SECURITY_PROTOCOL_NONE;\r
+       provider.dwMessageSize = 0xFFFFFFFF; /* IB supports 32-bit lengths for data transfers on RC */\r
+       provider.dwProviderReserved = 0;\r
+       wcscpy( provider.szProtocol, provider_name );\r
+\r
+       rc = WSCInstallProvider(&provider_guid, provider_path, &provider, 1, &errno );\r
+       if( rc == SOCKET_ERROR )\r
+       {\r
+               if( errno == WSANO_RECOVERY )\r
+                       printf("The provider is already installed\n");\r
+               else\r
+                       printf("install_provider: WSCInstallProvider failed: %d\n", errno);\r
+       }\r
+}\r
+\r
+/*\r
+ * Function: remove_provider\r
+ *   Description: removes our provider.\r
+ */\r
+static void remove_provider( const char* const provider_name )\r
+{\r
+       int rc;\r
+       int errno;\r
+       LONG reg_error;\r
+       HKEY hkey;\r
+\r
+       /* Remove our key */\r
+       reg_error = RegOpenKeyExA(HKEY_LOCAL_MACHINE,\r
+                                                        wnd_key_path,\r
+                                                        0,\r
+                                                        (KEY_WRITE | KEY_READ),\r
+                                                        &hkey);\r
+       if (reg_error == ERROR_SUCCESS) {\r
+\r
+               reg_error = RegDeleteValueA(hkey, provider_name);\r
+               if (reg_error == ERROR_SUCCESS) {\r
+                       /* Force the system to remove the key now. */\r
+                       RegFlushKey(hkey);\r
+               } else {\r
+                       fprintf(stderr, "RegDeleteValue failed with %d\n", GetLastError());\r
+               }\r
+\r
+               RegCloseKey(hkey);\r
+       }\r
+\r
+       /* Remove from the catalog */\r
+       rc = WSCDeinstallProvider(&provider_guid, &errno);\r
+       if (rc == SOCKET_ERROR) {\r
+               printf ("WSCDeinstallProvider failed: %d\n", errno);\r
+       }\r
+\r
+#ifdef _WIN64\r
+       /* Remove from the 32-bit catalog too! */\r
+       rc = WSCDeinstallProvider32(&provider_guid, &errno);\r
+       if (rc == SOCKET_ERROR) {\r
+               printf ("WSCDeinstallProvider32 failed: %d\n", errno);\r
+       }\r
+#endif /* _WIN64 */\r
+}\r
+\r
+/* Function: main\r
+ *\r
+ *  Description:\r
+ *    Parse the command line arguments and call either the install or remove\r
+ *    routine.\r
+ */\r
+int __cdecl main (int argc, char *argv[])\r
+{\r
+       WSADATA wsd;\r
+\r
+       /* Load Winsock */\r
+       if (WSAStartup (MAKEWORD (2, 2), &wsd) != 0) {\r
+               printf ("InstallSP: Unable to load Winsock: %d\n", GetLastError ());\r
+               return -1;\r
+       }\r
+\r
+       /* Confirm that the WinSock DLL supports 2.2. Note that if the\r
+        * DLL supports versions greater than 2.2 in addition to 2.2, it\r
+        * will still return 2.2 in wVersion since that is the version we\r
+        * requested. */\r
+       if (LOBYTE (wsd.wVersion) != 2 || HIBYTE (wsd.wVersion) != 2) {\r
+\r
+               /* Tell the user that we could not find a usable WinSock DLL. */\r
+               WSACleanup ();\r
+               printf\r
+                       ("InstallSP: Unable to find a usable version of Winsock DLL\n");\r
+               return -1;\r
+       }\r
+       if (argc < 2) {\r
+               usage (argv[0]);\r
+               return -1;\r
+       }\r
+       if ((strlen (argv[1]) != 2) && (argv[1][0] != '-')\r
+               && (argv[1][0] != '/')) {\r
+               usage (argv[0]);\r
+               return -1;\r
+       }\r
+       switch (tolower (argv[1][1])) {\r
+\r
+       case 'i':\r
+               /* Install the Infiniband Service Provider */\r
+               install_provider ();\r
+#ifdef PERFMON_ENABLED\r
+               _IBSPPerfmonIniFilesGenerate();\r
+               if ( _IBSPPerfmonRegisterKeys() == ERROR_SUCCESS )\r
+                               _IBSPPerfmonRegisterCounters();\r
+#endif\r
+               break;\r
+\r
+       case 'r':\r
+               /* Remove the service provider */\r
+               if( argc == 2 )\r
+                       remove_provider( openib_key_name );\r
+               else\r
+                       remove_provider( argv[2] );\r
+#ifdef PERFMON_ENABLED\r
+               _IBSPPerfmonIniFilesRemove();\r
+               if ( _IBSPPerfmonDeregisterCounters() == ERROR_SUCCESS )\r
+                       _IBSPPerfmonDeregisterKeys();\r
+#endif\r
+               break;\r
+\r
+       case 'l':\r
+               /* List existing providers */\r
+               print_providers();\r
+               break;\r
+       \r
+       default:\r
+               usage (argv[0]);\r
+               break;\r
+       }\r
+\r
+       WSACleanup ();\r
+\r
+       return 0;\r
+}\r
diff --git a/branches/RDMA/tools/wndinstall/user/WndInstallsp.rc b/branches/RDMA/tools/wndinstall/user/WndInstallsp.rc
new file mode 100644 (file)
index 0000000..f92b5c8
--- /dev/null
@@ -0,0 +1,47 @@
+/*\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ * $Id: WndInstallsp.rc 474 2006-08-31 08:57:19Z sleybo $\r
+ */\r
+\r
+\r
+#include <oib_ver.h>\r
+\r
+#define VER_FILETYPE                           VFT_APP\r
+#define VER_FILESUBTYPE                                VFT2_UNKNOWN\r
+\r
+#ifdef _DEBUG_\r
+#define VER_FILEDESCRIPTION_STR                "Windows Network Direct for InfiniBand installer (Debug)"\r
+#else\r
+#define VER_FILEDESCRIPTION_STR                "Windows Network Direct for InfiniBand installer "\r
+#endif\r
+\r
+#define VER_INTERNALNAME_STR           "WndInstallsp.exe"\r
+#define VER_ORIGINALFILENAME_STR       "WndInstallsp.exe"\r
+\r
+#include <common.ver>\r
diff --git a/branches/RDMA/tools/wndinstall/user/makefile b/branches/RDMA/tools/wndinstall/user/makefile
new file mode 100644 (file)
index 0000000..bffacaa
--- /dev/null
@@ -0,0 +1,7 @@
+#\r
+# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source\r
+# file to this component.  This file merely indirects to the real make file\r
+# that is shared by all the driver components of the OpenIB Windows project.\r
+#\r
+\r
+!INCLUDE ..\..\..\inc\openib.def\r