From: tzachid Date: Sun, 12 Oct 2008 09:21:52 +0000 (+0000) Subject: [ipoib]Improvements to ipoib guid creation algorithm. X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=7b2f3c2bba141d235fb6552ad40a809e248f4ff4;p=~shefty%2Frdma-win.git [ipoib]Improvements to ipoib guid creation algorithm. Signed off by: ftillier@windows.microsoft.com git-svn-id: svn://openib.tc.cornell.edu/gen1@1647 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/ulp/ipoib/kernel/ipoib_adapter.c b/trunk/ulp/ipoib/kernel/ipoib_adapter.c index d528069c..53014195 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_adapter.c +++ b/trunk/ulp/ipoib/kernel/ipoib_adapter.c @@ -364,26 +364,24 @@ adapter_init( return IB_ERROR; } - /* Validate the port GUID and generate the MAC address. */ status = ipoib_mac_from_guid( p_adapter->guids.port_guid.guid, p_adapter->params.guid_mask, &p_adapter->mac); - if (status == IB_INVALID_GUID_MASK) - { - IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ERROR, - ("Invalid GUID mask received, rejecting it") ); - ipoib_create_log(p_adapter->h_adapter, GUID_MASK_LOG_INDEX, EVENT_IPOIB_WRONG_PARAMETER_WRN); - } - else if( status != IB_SUCCESS ) + if( status != IB_SUCCESS ) { + if( status == IB_INVALID_GUID_MASK ) + { + IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ERROR, + ("Invalid GUID mask received, rejecting it") ); + ipoib_create_log(p_adapter->h_adapter, GUID_MASK_LOG_INDEX, EVENT_IPOIB_WRONG_PARAMETER_WRN); + } + IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, ("ipoib_mac_from_guid returned %s\n", p_adapter->p_ifc->get_err_str( status )) ); return status; } - - /* Open AL. */ status = p_adapter->p_ifc->open_al( &p_adapter->h_al ); if( status != IB_SUCCESS ) diff --git a/trunk/ulp/ipoib/kernel/ipoib_port.c b/trunk/ulp/ipoib/kernel/ipoib_port.c index 915c616e..d0944bb8 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_port.c +++ b/trunk/ulp/ipoib/kernel/ipoib_port.c @@ -1823,13 +1823,7 @@ __recv_get_endpts( #else /* IPOIB_INLINE_RECV */ p_desc->p_buf->ib.grh.src_gid.unicast.interface_id, p_port->p_adapter->params.guid_mask, &mac ); #endif /* IPOIB_INLINE_RECV */ - if (status == IB_INVALID_GUID_MASK) - { - IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ERROR, - ("Invalid GUID mask received, rejecting it") ); - ipoib_create_log(p_port->p_adapter->h_adapter, GUID_MASK_LOG_INDEX, EVENT_IPOIB_WRONG_PARAMETER_WRN); - } - else if( status != IB_SUCCESS ) + if( status != IB_SUCCESS ) { IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, ("ipoib_mac_from_guid returned %s\n", diff --git a/trunk/ulp/ipoib/kernel/ipoib_xfr_mgr.h b/trunk/ulp/ipoib/kernel/ipoib_xfr_mgr.h index 7738f6cb..ebdb2327 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_xfr_mgr.h +++ b/trunk/ulp/ipoib/kernel/ipoib_xfr_mgr.h @@ -276,9 +276,9 @@ ipoib_mac_from_dell_guid( *********/ -/****f* IPOIB/ipoib_mac_from_general_guid +/****f* IPOIB/ipoib_mac_from_guid_mask * NAME -* ipoib_mac_from_dell_guid +* ipoib_mac_from_guid_mask * * DESCRIPTION * Generates an ethernet MAC address given general port GUID and a bitwise mask @@ -286,33 +286,35 @@ ipoib_mac_from_dell_guid( * SYNOPSIS */ static inline ib_api_status_t -ipoib_mac_from_general_guid( - IN const net64_t port_guid, - IN uint32_t guid_mask, +ipoib_mac_from_guid_mask( + IN const uint8_t *p_guid, + IN uint32_t guid_mask, OUT mac_addr_t* const p_mac_addr ) { static const mac_addr_size = HW_ADDR_LEN; uint8_t i; - const uint8_t *p_guid = (const uint8_t*)&port_guid; int digit_counter = 0; - //All non-zero bits of guid_mask indicates the number of an appropriate byte in - // port_guid, that will be used in MAC address construction - for (i = 7; guid_mask; guid_mask >>= 1, --i) { - if (guid_mask & 1 ) { + // All non-zero bits of guid_mask indicates the number of an appropriate + // byte in port_guid, that will be used in MAC address construction + for (i = 7; guid_mask; guid_mask >>= 1, --i ) + { + if( guid_mask & 1 ) + { ++digit_counter; - if (digit_counter > mac_addr_size) { + if( digit_counter > mac_addr_size ) + { //to avoid negative index return IB_INVALID_GUID_MASK; } p_mac_addr->addr[mac_addr_size - digit_counter] = p_guid [i]; } } - // check for the mask validity: it should have 6 non-zero bits - if (digit_counter != mac_addr_size) { - return IB_INVALID_GUID_MASK; - } - + + // check for the mask validity: it should have 6 non-zero bits + if( digit_counter != mac_addr_size ) + return IB_INVALID_GUID_MASK; + return IB_SUCCESS; } @@ -388,26 +390,13 @@ ipoib_mac_from_guid( OUT mac_addr_t* const p_mac_addr ) { - static const guid_default_mask = 0xE7; //==0b 11100111 + static const uint32_t guid_default_mask = 0xE7; //==0b 11100111 ib_api_status_t status = IB_INVALID_GUID; - ib_api_status_t mask_status = IB_SUCCESS; const uint8_t *p_guid = (const uint8_t*)&port_guid; uint32_t laa; - if ( guid_mask ) - { - mask_status = ipoib_mac_from_general_guid(port_guid, guid_mask, p_mac_addr); - if( mask_status == IB_SUCCESS ) - return IB_SUCCESS; - //otherwise, mask was invalid, getting back to standard flow - /*if (status == IB_INVALID_GUID_MASK) - { - IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ERROR, - ("Invalid GUID mask received, rejecting it") ); - }*/ - } - - if( p_guid[0] == 0 ) + /* Port guid is in network byte order. OUI is in lower 3 bytes. */ + if( p_guid[0] == 0 ) { if( p_guid[1] == 0x02 && p_guid[2] == 0xc9 ) { @@ -420,36 +409,36 @@ ipoib_mac_from_guid( else if( p_guid[1] == 0x30 && p_guid[2] == 0x48 ) { //Supermicro GUID - status =ipoib_mac_from_general_guid(port_guid, guid_default_mask, p_mac_addr); + status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask, p_mac_addr ); } else if( p_guid[1] == 0x05 && p_guid[2] == 0xad ) { - //Cisco GUID - status =ipoib_mac_from_general_guid(port_guid, guid_default_mask, p_mac_addr); - } - /* Port guid is in network byte order. OUI is in lower 3 bytes. */ + //Cisco GUID + status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask, p_mac_addr ); + } else if( p_guid[1] == 0x06 && p_guid[2] == 0x6a ) { status = ipoib_mac_from_sst_guid( port_guid, p_mac_addr ); } - else if( p_guid[1] == 0x1a && p_guid[2] == 0x4b ) + else if( p_guid[1] == 0x1a && p_guid[2] == 0x4b || + p_guid[1] == 0x17 && p_guid[2] == 0x08 ) { //HP GUID - status =ipoib_mac_from_general_guid(port_guid, guid_default_mask, p_mac_addr); + status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask, p_mac_addr ); } else if( p_guid[1] == 0x18 && p_guid[2] == 0x8b ) { //DELL GUID - status =ipoib_mac_from_general_guid(port_guid, guid_default_mask, p_mac_addr); + status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask, p_mac_addr ); } - if (status == IB_SUCCESS ) - { - ASSERT ( mask_status == IB_SUCCESS || mask_status == IB_INVALID_GUID_MASK ); - return mask_status; - } + if( status == IB_SUCCESS ) + return status; } + if( guid_mask ) + return ipoib_mac_from_guid_mask( p_guid, guid_mask, p_mac_addr ); + /* Value of zero is reserved. */ laa = cl_atomic_inc( &g_ipoib.laa_idx ); @@ -463,7 +452,7 @@ ipoib_mac_from_guid( p_mac_addr->addr[4] = (uint8_t)(laa >> 8); p_mac_addr->addr[5] = (uint8_t)laa; - return mask_status; + return IB_SUCCESS; } /* * PARAMETERS