From: ftillier Date: Fri, 27 May 2005 18:42:08 +0000 (+0000) Subject: Merged with trunk to pickup IPoIB changes X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=932c42ca3dea8c5636bcf08f4e9f49565a5ffb7e;p=~shefty%2Frdma-win.git Merged with trunk to pickup IPoIB changes git-svn-id: svn://openib.tc.cornell.edu/gen1@17 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/branches/fab_cm_branch/ulp/ipoib/kernel/ipoib_driver.c b/branches/fab_cm_branch/ulp/ipoib/kernel/ipoib_driver.c index 4e0b5842..72cb514d 100644 --- a/branches/fab_cm_branch/ulp/ipoib/kernel/ipoib_driver.c +++ b/branches/fab_cm_branch/ulp/ipoib/kernel/ipoib_driver.c @@ -119,8 +119,8 @@ static const unsigned char VENDOR_ID[] = {0x00, 0x06, 0x6A, 0x00}; /* Global driver debug level */ -//uint32_t g_ipoib_dbg_lvl = IPOIB_DBG_ALL & ~(IPOIB_DBG_ALLOC | IPOIB_DBG_FUNC | IPOIB_DBG_SEND | IPOIB_DBG_RECV); uint32_t g_ipoib_dbg_lvl = IPOIB_DBG_ERROR; +atomic32_t g_laa_idx = 0; NTSTATUS diff --git a/branches/fab_cm_branch/ulp/ipoib/kernel/ipoib_xfr_mgr.h b/branches/fab_cm_branch/ulp/ipoib/kernel/ipoib_xfr_mgr.h index cee836b8..b7e0fd87 100644 --- a/branches/fab_cm_branch/ulp/ipoib/kernel/ipoib_xfr_mgr.h +++ b/branches/fab_cm_branch/ulp/ipoib/kernel/ipoib_xfr_mgr.h @@ -88,6 +88,10 @@ extern "C" { #endif +/* Global counter for generating LAA MACs */ +extern atomic32_t g_laa_idx; + + /* * Address accessors */ @@ -125,17 +129,17 @@ ipoib_addr_set_qpn( } -/****f* IPOIB/ipoib_mac_from_guid +/****f* IPOIB/ipoib_mac_from_sst_guid * NAME -* ipoib_mac_from_guid +* ipoib_mac_from_sst_guid * * DESCRIPTION -* Generates an ethernet MAC address given a port GUID. +* Generates an ethernet MAC address given a SilverStorm port GUID. * * SYNOPSIS */ static inline ib_api_status_t -ipoib_mac_from_guid( +ipoib_mac_from_sst_guid( IN const net64_t port_guid, OUT mac_addr_t* const p_mac_addr ) { @@ -143,8 +147,7 @@ ipoib_mac_from_guid( uint32_t low24; /* Port guid is in network byte order. OUI is in lower 3 bytes. */ - if( p_guid[0] != 0x00 || p_guid[1] != 0x06 || p_guid[2] != 0x6a ) - return IB_INVALID_GUID; + ASSERT( p_guid[0] == 0x00 && p_guid[1] == 0x06 && p_guid[2] == 0x6a ); /* * We end up using only the lower 23-bits of the GUID. Trap that @@ -191,6 +194,71 @@ ipoib_mac_from_guid( *********/ +/****f* IPOIB/ipoib_mac_from_guid +* NAME +* ipoib_mac_from_guid +* +* DESCRIPTION +* Generates an ethernet MAC address given a port GUID. +* +* SYNOPSIS +*/ +static inline ib_api_status_t +ipoib_mac_from_guid( + IN const net64_t port_guid, + OUT mac_addr_t* const p_mac_addr ) +{ + ib_api_status_t status; + const uint8_t *p_guid = (const uint8_t*)&port_guid; + uint32_t laa; + + /* Port guid is in network byte order. OUI is in lower 3 bytes. */ + if( p_guid[0] == 0x00 && p_guid[1] == 0x06 && p_guid[2] == 0x6a ) + { + status = ipoib_mac_from_sst_guid( port_guid, p_mac_addr ); + if( status == IB_SUCCESS ) + return IB_SUCCESS; + } + + /* Value of zero is reserved. */ + laa = cl_atomic_inc( &g_laa_idx ); + + if( !laa ) + return IB_INVALID_GUID; + + p_mac_addr->addr[0] = 2; /* LAA bit */ + p_mac_addr->addr[1] = 0; + p_mac_addr->addr[2] = (uint8_t)(laa >> 24); + p_mac_addr->addr[3] = (uint8_t)(laa >> 16); + p_mac_addr->addr[4] = (uint8_t)(laa >> 8); + p_mac_addr->addr[5] = (uint8_t)laa; + + return IB_SUCCESS; +} +/* +* PARAMETERS +* port_guid +* The port GUID, in network byte order, for which to generate a +* MAC address. +* +* p_mac_addr +* Pointer to a mac address in which to store the results. +* +* RETURN VALUES +* IB_SUCCESS +* The MAC address was successfully converted. +* +* IB_INVALID_GUID +* The port GUID provided was not a known GUID format. +* +* NOTES +* Creates a locally administered address using a global incrementing counter. +* +* SEE ALSO +* IPOIB +*********/ + + /****f* IPOIB/ipoib_guid_from_mac * NAME * ipoib_guid_from_mac