[ipoib]Improvements to ipoib guid creation algorithm.
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 12 Oct 2008 09:21:52 +0000 (09:21 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 12 Oct 2008 09:21:52 +0000 (09:21 +0000)
Signed off by: ftillier@windows.microsoft.com

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

ulp/ipoib/kernel/ipoib_adapter.c
ulp/ipoib/kernel/ipoib_port.c
ulp/ipoib/kernel/ipoib_xfr_mgr.h

index d528069..5301419 100644 (file)
@@ -364,26 +364,24 @@ adapter_init(
                return IB_ERROR;\r
        }\r
 \r
-\r
        /* Validate the port GUID and generate the MAC address. */\r
        status =\r
                ipoib_mac_from_guid( p_adapter->guids.port_guid.guid, p_adapter->params.guid_mask, &p_adapter->mac);\r
-       if (status == IB_INVALID_GUID_MASK)\r
-       {\r
-               IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ERROR,\r
-                       ("Invalid GUID mask received, rejecting it") );\r
-               ipoib_create_log(p_adapter->h_adapter, GUID_MASK_LOG_INDEX, EVENT_IPOIB_WRONG_PARAMETER_WRN);\r
-       }\r
-       else if( status != IB_SUCCESS )\r
+       if( status != IB_SUCCESS )\r
        {\r
+               if( status == IB_INVALID_GUID_MASK )\r
+               {\r
+                       IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ERROR,\r
+                               ("Invalid GUID mask received, rejecting it") );\r
+                       ipoib_create_log(p_adapter->h_adapter, GUID_MASK_LOG_INDEX, EVENT_IPOIB_WRONG_PARAMETER_WRN);\r
+               }\r
+\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                        ("ipoib_mac_from_guid returned %s\n", \r
                        p_adapter->p_ifc->get_err_str( status )) );\r
                return status;\r
        }\r
 \r
-       \r
-       \r
        /* Open AL. */\r
        status = p_adapter->p_ifc->open_al( &p_adapter->h_al );\r
        if( status != IB_SUCCESS )\r
index 915c616..d0944bb 100644 (file)
@@ -1823,13 +1823,7 @@ __recv_get_endpts(
 #else  /* IPOIB_INLINE_RECV */\r
                                p_desc->p_buf->ib.grh.src_gid.unicast.interface_id, p_port->p_adapter->params.guid_mask, &mac );\r
 #endif /* IPOIB_INLINE_RECV */\r
-                       if (status == IB_INVALID_GUID_MASK)\r
-                       {\r
-                               IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ERROR,\r
-                                       ("Invalid GUID mask received, rejecting it") );\r
-                               ipoib_create_log(p_port->p_adapter->h_adapter, GUID_MASK_LOG_INDEX, EVENT_IPOIB_WRONG_PARAMETER_WRN);\r
-                       }\r
-                       else if( status != IB_SUCCESS )\r
+                       if( status != IB_SUCCESS )\r
                        {\r
                                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                                        ("ipoib_mac_from_guid returned %s\n",\r
index 7738f6c..ebdb232 100644 (file)
@@ -276,9 +276,9 @@ ipoib_mac_from_dell_guid(
 *********/\r
 \r
 \r
-/****f* IPOIB/ipoib_mac_from_general_guid\r
+/****f* IPOIB/ipoib_mac_from_guid_mask\r
 * NAME\r
-*      ipoib_mac_from_dell_guid\r
+*      ipoib_mac_from_guid_mask\r
 *\r
 * DESCRIPTION\r
 *      Generates an ethernet MAC address given general port GUID and a bitwise mask\r
@@ -286,33 +286,35 @@ ipoib_mac_from_dell_guid(
 * SYNOPSIS\r
 */\r
 static inline ib_api_status_t\r
-ipoib_mac_from_general_guid(\r
-       IN              const   net64_t                                         port_guid,\r
-       IN                              uint32_t                                                guid_mask,\r
+ipoib_mac_from_guid_mask(\r
+       IN              const   uint8_t                                         *p_guid,\r
+       IN                              uint32_t                                        guid_mask,\r
                OUT                     mac_addr_t* const                       p_mac_addr )\r
 {\r
        static const mac_addr_size =  HW_ADDR_LEN;\r
        uint8_t i;\r
-       const uint8_t   *p_guid = (const uint8_t*)&port_guid;\r
        int digit_counter = 0;\r
 \r
-       //All non-zero bits of guid_mask indicates the number of an appropriate byte in\r
-       // port_guid, that will be used in MAC address construction\r
-       for (i = 7; guid_mask; guid_mask >>= 1, --i) {\r
-               if (guid_mask & 1 ) {\r
+       // All non-zero bits of guid_mask indicates the number of an appropriate\r
+       // byte in port_guid, that will be used in MAC address construction\r
+       for (i = 7; guid_mask; guid_mask >>= 1, --i )\r
+       {\r
+               if( guid_mask & 1 )\r
+               {\r
                        ++digit_counter;\r
-                       if (digit_counter > mac_addr_size) {\r
+                       if( digit_counter > mac_addr_size )\r
+                       {\r
                                //to avoid negative index\r
                                return IB_INVALID_GUID_MASK;\r
                        }\r
                        p_mac_addr->addr[mac_addr_size - digit_counter] = p_guid [i];\r
                }\r
        }\r
-               // check for the mask validity: it should have 6 non-zero bits\r
-               if (digit_counter != mac_addr_size) {\r
-                       return IB_INVALID_GUID_MASK;\r
-               }\r
-               \r
+\r
+       // check for the mask validity: it should have 6 non-zero bits\r
+       if( digit_counter != mac_addr_size )\r
+               return IB_INVALID_GUID_MASK;\r
+\r
        return IB_SUCCESS;\r
 }\r
 \r
@@ -388,26 +390,13 @@ ipoib_mac_from_guid(
                OUT                     mac_addr_t* const                       p_mac_addr\r
                )\r
 {\r
-       static const guid_default_mask = 0xE7; //==0b 11100111\r
+       static const uint32_t guid_default_mask = 0xE7; //==0b 11100111\r
        ib_api_status_t status = IB_INVALID_GUID;\r
-       ib_api_status_t mask_status = IB_SUCCESS;\r
        const uint8_t   *p_guid = (const uint8_t*)&port_guid;\r
        uint32_t                laa;\r
 \r
-       if ( guid_mask ) \r
-       {\r
-               mask_status = ipoib_mac_from_general_guid(port_guid, guid_mask, p_mac_addr);\r
-               if( mask_status == IB_SUCCESS )\r
-                               return IB_SUCCESS;\r
-               //otherwise, mask was invalid, getting back to standard flow\r
-               /*if (status == IB_INVALID_GUID_MASK)\r
-               {\r
-                       IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ERROR,\r
-                       ("Invalid GUID mask received, rejecting it") );\r
-               }*/\r
-       }\r
-                       \r
-       if( p_guid[0] == 0 ) \r
+       /* Port guid is in network byte order.  OUI is in lower 3 bytes. */\r
+       if( p_guid[0] == 0 )\r
        {\r
                if( p_guid[1] == 0x02 && p_guid[2] == 0xc9 )\r
                {\r
@@ -420,36 +409,36 @@ ipoib_mac_from_guid(
                else if( p_guid[1] == 0x30 && p_guid[2] == 0x48 )\r
                {\r
                        //Supermicro GUID\r
-                       status =ipoib_mac_from_general_guid(port_guid, guid_default_mask, p_mac_addr);\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_general_guid(port_guid, guid_default_mask, p_mac_addr);\r
-               }        \r
-               /* Port guid is in network byte order.  OUI is in lower 3 bytes. */\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
+               else if( p_guid[1] == 0x1a && p_guid[2] == 0x4b ||\r
+                                p_guid[1] == 0x17 && p_guid[2] == 0x08 )\r
                {\r
                        //HP GUID\r
-                       status =ipoib_mac_from_general_guid(port_guid, guid_default_mask, p_mac_addr);\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
                {\r
                        //DELL GUID\r
-                       status =ipoib_mac_from_general_guid(port_guid, guid_default_mask, p_mac_addr);\r
+                       status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask, p_mac_addr );\r
                }\r
                \r
-               if (status == IB_SUCCESS )\r
-               {\r
-                       ASSERT ( mask_status == IB_SUCCESS || mask_status == IB_INVALID_GUID_MASK );\r
-                       return mask_status; \r
-               }\r
+               if( status == IB_SUCCESS )\r
+                       return status;\r
        }\r
 \r
+       if( guid_mask )\r
+               return ipoib_mac_from_guid_mask( p_guid, guid_mask, p_mac_addr );\r
+\r
        /* Value of zero is reserved. */\r
        laa = cl_atomic_inc( &g_ipoib.laa_idx );\r
 \r
@@ -463,7 +452,7 @@ ipoib_mac_from_guid(
        p_mac_addr->addr[4] = (uint8_t)(laa >> 8);\r
        p_mac_addr->addr[5] = (uint8_t)laa;\r
        \r
-       return mask_status;\r
+       return IB_SUCCESS;\r
 }\r
 /*\r
 * PARAMETERS\r