hardware: add device ids for QCA9984, 88W8887 and 88W8964 radios
[project/iwinfo.git] / iwinfo_cli.c
index 891f77e..49c9035 100644 (file)
@@ -280,7 +280,7 @@ static char * format_hwmodes(int modes)
 
 static char * format_assocrate(struct iwinfo_rate_entry *r)
 {
-       static char buf[40];
+       static char buf[80];
        char *p = buf;
        int l = sizeof(buf);
 
@@ -293,13 +293,21 @@ static char * format_assocrate(struct iwinfo_rate_entry *r)
                p += snprintf(p, l, "%s", format_rate(r->rate));
                l = sizeof(buf) - (p - buf);
 
-               if (r->mcs >= 0)
+               if (r->is_ht)
                {
-                       p += snprintf(p, l, ", MCS %d, %dMHz", r->mcs, 20 + r->is_40mhz*20);
+                       p += snprintf(p, l, ", MCS %d, %dMHz", r->mcs, r->mhz);
+                       l = sizeof(buf) - (p - buf);
+               }
+               else if (r->is_vht)
+               {
+                       p += snprintf(p, l, ", VHT-MCS %d, %dMHz", r->mcs, r->mhz);
                        l = sizeof(buf) - (p - buf);
 
-                       if (r->is_short_gi)
-                               p += snprintf(p, l, ", short GI");
+                       if (r->nss)
+                       {
+                               p += snprintf(p, l, ", VHT-NSS %d", r->nss);
+                               l = sizeof(buf) - (p - buf);
+                       }
                }
        }
 
@@ -692,10 +700,13 @@ static void print_assoclist(const struct iwinfo_ops *iw, const char *ifname)
                        e->rx_packets
                );
 
-               printf("        TX: %-38s  %8d Pkts.\n\n",
+               printf("        TX: %-38s  %8d Pkts.\n",
                        format_assocrate(&e->tx_rate),
                        e->tx_packets
                );
+
+               printf("        expected throughput: %s\n\n",
+                       format_rate(e->thr));
        }
 }
 
@@ -744,10 +755,46 @@ static void print_countrylist(const struct iwinfo_ops *iw, const char *ifname)
        }
 }
 
+static void print_htmodelist(const struct iwinfo_ops *iw, const char *ifname)
+{
+       int i, htmodes = 0;
+
+       if (iw->htmodelist(ifname, &htmodes))
+       {
+               printf("No HT mode information available\n");
+               return;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(IWINFO_HTMODE_NAMES); i++)
+               if (htmodes & (1 << i))
+                       printf("%s ", IWINFO_HTMODE_NAMES[i]);
+
+       printf("\n");
+}
+
+static void lookup_phy(const struct iwinfo_ops *iw, const char *section)
+{
+       char buf[IWINFO_BUFSIZE];
+
+       if (!iw->lookup_phy)
+       {
+               fprintf(stderr, "Not supported\n");
+               return;
+       }
+
+       if (iw->lookup_phy(section, buf))
+       {
+               fprintf(stderr, "Phy not found\n");
+               return;
+       }
+
+       printf("%s\n", buf);
+}
+
 
 int main(int argc, char **argv)
 {
-       int i;
+       int i, rv = 0;
        char *p;
        const struct iwinfo_ops *iw;
        glob_t globbuf;
@@ -762,6 +809,8 @@ int main(int argc, char **argv)
                        "       iwinfo <device> freqlist\n"
                        "       iwinfo <device> assoclist\n"
                        "       iwinfo <device> countrylist\n"
+                       "       iwinfo <device> htmodelist\n"
+                       "       iwinfo <backend> phyname <section>\n"
                );
 
                return 1;
@@ -791,49 +840,81 @@ int main(int argc, char **argv)
                return 0;
        }
 
-       iw = iwinfo_backend(argv[1]);
-
-       if (!iw)
+       if (argc > 3)
        {
-               fprintf(stderr, "No such wireless device: %s\n", argv[1]);
-               return 1;
-       }
+               iw = iwinfo_backend_by_name(argv[1]);
+
+               if (!iw)
+               {
+                       fprintf(stderr, "No such wireless backend: %s\n", argv[1]);
+                       rv = 1;
+               }
+               else
+               {
+                       switch (argv[2][0])
+                       {
+                       case 'p':
+                               lookup_phy(iw, argv[3]);
+                               break;
 
-       for (i = 2; i < argc; i++)
+                       default:
+                               fprintf(stderr, "Unknown command: %s\n", argv[2]);
+                               rv = 1;
+                       }
+               }
+       }
+       else
        {
-               switch(argv[i][0])
+               iw = iwinfo_backend(argv[1]);
+
+               if (!iw)
+               {
+                       fprintf(stderr, "No such wireless device: %s\n", argv[1]);
+                       rv = 1;
+               }
+               else
                {
-               case 'i':
-                       print_info(iw, argv[1]);
-                       break;
+                       for (i = 2; i < argc; i++)
+                       {
+                               switch(argv[i][0])
+                               {
+                               case 'i':
+                                       print_info(iw, argv[1]);
+                                       break;
+
+                               case 's':
+                                       print_scanlist(iw, argv[1]);
+                                       break;
 
-               case 's':
-                       print_scanlist(iw, argv[1]);
-                       break;
+                               case 't':
+                                       print_txpwrlist(iw, argv[1]);
+                                       break;
 
-               case 't':
-                       print_txpwrlist(iw, argv[1]);
-                       break;
+                               case 'f':
+                                       print_freqlist(iw, argv[1]);
+                                       break;
 
-               case 'f':
-                       print_freqlist(iw, argv[1]);
-                       break;
+                               case 'a':
+                                       print_assoclist(iw, argv[1]);
+                                       break;
 
-               case 'a':
-                       print_assoclist(iw, argv[1]);
-                       break;
+                               case 'c':
+                                       print_countrylist(iw, argv[1]);
+                                       break;
 
-               case 'c':
-                       print_countrylist(iw, argv[1]);
-                       break;
+                               case 'h':
+                                       print_htmodelist(iw, argv[1]);
+                                       break;
 
-               default:
-                       fprintf(stderr, "Unknown command: %s\n", argv[i]);
-                       return 1;
+                               default:
+                                       fprintf(stderr, "Unknown command: %s\n", argv[i]);
+                                       rv = 1;
+                               }
+                       }
                }
        }
 
        iwinfo_finish();
 
-       return 0;
+       return rv;
 }