dmidecode-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dmidecode] [PATCH v2 3/4] dmioem: Use product name to determine Generat


From: Jerry Hoemann
Subject: [dmidecode] [PATCH v2 3/4] dmioem: Use product name to determine Generation.
Date: Sun, 29 Nov 2020 21:08:55 -0700

Generally, HPE OEM records are extended by adding additional
fields at the end or record and increasing the length.  But,
this isn't always the case and will less likely be so going
into the future.

Determine the generation of the HPE OEM records by examining
the "Product Name" string.

Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
---
 dmioem.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/dmioem.c b/dmioem.c
index 36820e4..4798f89 100644
--- a/dmioem.c
+++ b/dmioem.c
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include "types.h"
+#include "util.h"
 #include "dmidecode.h"
 #include "dmioem.h"
 #include "dmioutput.h"
@@ -150,12 +151,43 @@ static void dmi_print_hp_net_iface_rec(u8 id, u8 bus, u8 
dev, const u8 *mac)
        }
 }
 
+typedef enum { G6 = 6, G7, G8, G9, G10, G10P } dmi_hpegen_t;
+
+static int dmi_hpegen(const char *s)
+{
+       struct { const char *name; dmi_hpegen_t gen; } table[] = {
+               { "Gen10 Plus", G10P },
+               { "Gen10",      G10 },
+               { "Gen9",       G9 },
+               { "Gen8",       G8 },
+               { "G7",         G7 },
+               { "G6",         G6 },
+       };
+       unsigned int i;
+
+       if (!strstr(s, "ProLiant") && !strstr(s, "Apollo") &&
+           !strstr(s, "Synergy")  && !strstr(s, "Edgeline"))
+               return -1;
+
+       for (i = 0; i < ARRAY_SIZE(table); i++) {
+               if (strstr(s, table[i].name))
+                       return(table[i].gen);
+       }
+
+       return (dmi_vendor == VENDOR_HPE) ? G10P : G6;
+}
+
 static int dmi_decode_hp(const struct dmi_header *h)
 {
        u8 *data = h->data;
        int nic, ptr;
        u32 feat;
        const char *company = (dmi_vendor == VENDOR_HP) ? "HP" : "HPE";
+       int gen;
+
+       gen = dmi_hpegen(dmi_product);
+       if (gen < 0)
+               return 0;
 
        switch (h->type)
        {
-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]