[ofw] RE: ndinstall patch

Smith, Stan stan.smith at intel.com
Thu Jul 16 15:00:17 PDT 2009


Hefty, Sean wrote:
>>> +   printf("\t\t<blank> use the default ND provider '%s'\n",
>>> ND_DEFAULT_PROVIDER);
>>
>> ND_DEFAULT_PROVIDER would become provider_name[index]
>
> Hmm... I take that back.  This needs to be provider_name[0].  index
> could change before detecting an error parsing the command line that
> results in showing the usage.
>
> Of course, this leads us to wanting to define some constant so we can
> still change the default provider in a single location...  something
> like this would work:
>
> #define DEFAULT_INDEX IBAL_INDEX
>
> static int index = DEFAULT_INDEX;
>
> which you can argue whether or not that's better than the original
> patch...  My previous comments were based on being able to eliminate
> the #define, versus replacing it.  The index view matches up a little
> better with the other #define INDEX values, I guess.
>
> - Sean

Round #2

--- C:/Documents and Settings/scsmith/Local Settings/Temp/installsp-revBASE.svn002.tmp.c        Thu Jul 16 14:56:29 2009
+++ C:/Documents and Settings/scsmith/My Documents/openIB-windows/SVN/gen1/branches/WOF2-1/tools/ndinstall/user/installsp.c     Thu Jul 16 14:55:58 2009
@@ -52,14 +52,16 @@
 #define PFL_NETWORKDIRECT_PROVIDER          0x00000010
 #endif

-/* Initialize the LSP's provider path for Infiband Service Provider dll */
+/* Initialize the LSP's provider path for Infiniband Service Provider dll */
 #define IBAL_INDEX                     0
 #define IBAL_DEBUG_INDEX       1
 #define WV_INDEX                       2
 #define WV_DEBUG_INDEX         3
 #define MAX_INDEX                      4

-int index;
+#define DEFAULT_PROVIDER_INDEX IBAL_INDEX
+
+int index=DEFAULT_PROVIDER_INDEX;

 static const char * const provider_name[MAX_INDEX] = {
        "IBAL", "IBAL (debug)", "WinVerbs", "WinVerbs (debug)"
@@ -97,14 +99,26 @@
 static void
 show_usage (char *progname)
 {
-       printf("usage: %s\n", progname);
-       printf("\tRemove, install, and list OFA NetworkDirect providers\n\n");
-       printf("\t[-[i|r] provider_name]  Install/remove the specified provider\n");
-       printf("\t[-d]                    Install/remove debug version of provider\n");
-       printf("\t[-l]                    list OFA ND providers\n");
-       printf("\tprovider_name must be one of the following:\n");
+       char drv[_MAX_DRIVE];
+       char dir[_MAX_DIR];
+       char fname[_MAX_FNAME];
+       char ext[_MAX_EXT];
+
+       _splitpath(progname,drv,dir,fname,ext); // sad basename() equivalent.
+
+       printf("usage: %s%s\n",fname,ext);
+       printf("\tRemove, install and list OFA NetworkDirect providers\n\n");
+       printf("\t[-[i|r] [provider]] Install/remove the specified/default"
+                       " provider\n");
+       printf("\t[-d]                Install/remove debug version of provider\n");
+       printf("\t[-l]                list OFA ND providers\n");
+       printf("\t[-q]                Suppress default listing of providers\n");
+       printf("\t[-h]                This text\n");
+       printf("\tprovider must be one of the following names:\n");
        printf("\t\tibal\n");
        printf("\t\twinverbs\n");
+       printf("\t\t<blank> use the default ND provider '%s'\n",
+               provider_name[DEFAULT_PROVIDER_INDEX]);
 }


@@ -257,6 +271,9 @@
 {
        int i;

+       if ( !name )
+               return 0; /* assumes global 'index' set to default provider index. */
+
        for (i = 0; i < MAX_INDEX; i++) {
                if (!_stricmp(provider_name[i], name)) {
                        index = i;
@@ -269,20 +286,22 @@
 int __cdecl main (int argc, char *argv[])
 {
        int ret=0, op;
-       int install = 0, remove = 0, debug = 0;
+       int install = 0, remove = 0, debug = 0, quiet = 0;
        WSADATA wsd;
        char *prov;

-       while ((op = getopt(argc, argv, "i:r:dl")) != -1) {
+       while ((op = getopt(argc, argv, "hi::r::dlq")) != -1) {
                switch (op) {
+               case 'h':
+                               goto usage;
                case 'i':
-                       if (install || remove || get_prov_index(optarg)) {
+                       if (install || remove || (optarg && get_prov_index(optarg))) {
                                goto usage;
                        }
                        install = 1;
                        break;
                case 'r':
-                       if (install || remove || get_prov_index(optarg)) {
+                       if (install || remove || (optarg && get_prov_index(optarg))) {
                                goto usage;
                        }
                        remove = 1;
@@ -291,6 +310,10 @@
                        debug = 1;
                        break;
                case 'l':
+                       quiet = 0;
+                       break;
+               case 'q':
+                       quiet = 1;
                        break;
                default:
                        goto usage;
@@ -317,7 +340,8 @@
                ret = remove_provider();
        }

-       print_providers();
+       if (quiet == 0)
+               print_providers();

 exit:
        WSACleanup();



More information about the ofw mailing list