[ipoib] add guid2mac table instead of endless if statements.
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 25 Dec 2008 16:31:39 +0000 (16:31 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 25 Dec 2008 16:31:39 +0000 (16:31 +0000)
        Add full guid list of Mellanox HCAs cards.
Signed off by: Reuven@mellanox.co.il

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

ulp/ipoib/kernel/SOURCES
ulp/ipoib/kernel/ipoib_xfr_mgr.c [new file with mode: 0644]
ulp/ipoib/kernel/ipoib_xfr_mgr.h

index b6d7265..ffd58fe 100644 (file)
@@ -23,7 +23,8 @@ SOURCES=      ipoib_log.mc \
                ipoib_adapter.c \\r
                ipoib_endpoint.c \\r
                ipoib_port.c \\r
-               ipoib_ibat.c\r
+               ipoib_ibat.c \\r
+               ipoib_xfr_mgr.c\r
 \r
 INCLUDES=..;..\..\..\inc;..\..\..\inc\kernel;\r
 \r
diff --git a/ulp/ipoib/kernel/ipoib_xfr_mgr.c b/ulp/ipoib/kernel/ipoib_xfr_mgr.c
new file mode 100644 (file)
index 0000000..ce0650f
--- /dev/null
@@ -0,0 +1,74 @@
+/*\r
+ * Copyright (c) 2008 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: ipoib_xfr_mgr.c 3459 2008-11-12 16:48:21Z tzachid $\r
+ */\r
+\r
+\r
+#include "ipoib_xfr_mgr.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "ipoib_xfr_mgr.tmh"\r
+#endif\r
+\r
+\r
+const ipoib_guid2mac_translation_t guid2mac_table[] = {\r
+       {0x30, 0x48, 0xE7},\r
+       {0x05, 0xAD, 0xE7},\r
+       {0x18, 0x8B, 0xE7},\r
+       {0x1A, 0x4B, 0xE7},\r
+       {0x17, 0x08, 0xE7},\r
+       {0x1E, 0x0B, 0xE7},\r
+\r
+       {0x03, 0xBA, 0xE7},\r
+       {0x05, 0xAD, 0xE7},\r
+       {0x0D, 0x9D, 0xE7},\r
+       {0x11, 0x0A, 0xE7},\r
+       {0x11, 0x85, 0xE7},\r
+       {0x12, 0x79, 0xE7},\r
+       {0x13, 0x21, 0xE7},\r
+       {0x14, 0x38, 0xE7},\r
+       {0x16, 0x35, 0xE7},\r
+       {0x17, 0x08, 0xE7},\r
+       {0x17, 0xA4, 0xE7},\r
+       {0x18, 0x8B, 0xE7},\r
+       {0x18, 0xFE, 0xE7},\r
+       {0x19, 0xBB, 0xE7},\r
+       {0x1A, 0x4B, 0xE7},\r
+       {0x1B, 0x78, 0xE7},\r
+       {0x1E, 0x0B, 0xE7},\r
+       {0x22, 0x64, 0xE7},\r
+       {0x23, 0x7D, 0xE7},\r
+       {0x30, 0x48, 0xE7},\r
+       {0x80, 0x5F, 0xE7},\r
+\r
+       {0x00, 0x00, 0x00},\r
+};\r
+\r
index d96ff7b..b2a4cd5 100644 (file)
@@ -81,7 +81,39 @@ typedef struct _ipoib_hw_addr
 *********/\r
 #include <complib/cl_packoff.h>\r
 \r
+/****s* IPoIB Driver/ipoib_guid2mac_translation_t\r
+* NAME\r
+*   ipoib_guid2mac_translation_t\r
+*\r
+* DESCRIPTION\r
+*   The ipoib_guid2mac_translation_t structure defines a GUID to MAC translation.\r
+*   The structure holds map between known OUI to an appropriate GUID mask.\r
+*\r
+* SYNOPSIS\r
+*/\r
+typedef struct _ipoib_guid2mac_translation_\r
+{\r
+       uint8_t second_byte;\r
+       uint8_t third_byte;\r
+       uint8_t guid_mask;\r
+       \r
+}      ipoib_guid2mac_translation_t;\r
+/*\r
+* FIELDS\r
+*      second_byte\r
+*              second byte of OUI (located in lower three bytes of GUID).\r
+*\r
+*      third_byte\r
+*              third byte of OUI (located in lower three bytes of GUID).\r
+*\r
+*      guid_mask\r
+*              GUID mask that will be used to generate MAC from the GUID.      \r
+*\r
+* SEE ALSO\r
+*      IPoIB, ipoib_mac_from_guid_mask\r
+*********/\r
 \r
+extern const ipoib_guid2mac_translation_t guid2mac_table[];\r
 \r
 #ifdef __cplusplus\r
 extern "C"\r
@@ -363,10 +395,9 @@ ipoib_mac_from_guid(
                OUT                     mac_addr_t* const                       p_mac_addr\r
                )\r
 {\r
-       static const uint32_t guid_default_mask = 0xE7; //==0b 11100111\r
        ib_api_status_t status = IB_INVALID_GUID;\r
        const uint8_t   *p_guid = (const uint8_t*)&port_guid;\r
-       uint32_t                laa;\r
+       uint32_t                laa, idx = 0;\r
 \r
        /* Port guid is in network byte order.  OUI is in lower 3 bytes. */\r
        if( p_guid[0] == 0 )\r
@@ -379,33 +410,26 @@ ipoib_mac_from_guid(
                {\r
                        status = ipoib_mac_from_voltaire_guid( port_guid, p_mac_addr );\r
                }\r
-               else if( p_guid[1] == 0x30 && p_guid[2] == 0x48 )\r
-               {\r
-                       //Supermicro GUID\r
-                       status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask, p_mac_addr );\r
-               }\r
-               else if( p_guid[1] == 0x05 && p_guid[2] == 0xad )\r
-               {\r
-                       //Cisco GUID\r
-                       status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask, p_mac_addr );\r
-               }\r
                else if( p_guid[1] == 0x06 && p_guid[2] == 0x6a )\r
                {\r
                        status = ipoib_mac_from_sst_guid( port_guid, p_mac_addr );\r
                }\r
-               else if( p_guid[1] == 0x1a && p_guid[2] == 0x4b ||\r
-                                p_guid[1] == 0x17 && p_guid[2] == 0x08 ||\r
-                                p_guid[1] == 0x1e && p_guid[2] == 0x0b )\r
-               {\r
-                       //HP GUID\r
-                       status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask, p_mac_addr );\r
-               }\r
-               else if( p_guid[1] == 0x18 && p_guid[2] == 0x8b )\r
+               else\r
                {\r
-                       //DELL GUID\r
-                       status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask, p_mac_addr );\r
+                       while( guid2mac_table[idx].second_byte != 0x00 ||\r
+                                  guid2mac_table[idx].third_byte != 0x00 )\r
+                       {\r
+                               if( p_guid[1] == guid2mac_table[idx].second_byte &&\r
+                                       p_guid[2] == guid2mac_table[idx].third_byte )\r
+                               {\r
+                                       status = ipoib_mac_from_guid_mask(p_guid, guid2mac_table[idx].guid_mask,\r
+                                                                                                               p_mac_addr);\r
+                                       break;\r
+                               }\r
+                               ++idx;\r
+                       }\r
                }\r
-               \r
+\r
                if( status == IB_SUCCESS )\r
                        return status;\r
        }\r