From db797b394dd13645e14edc39e221a9507e689c59 Mon Sep 17 00:00:00 2001 From: ftillier Date: Tue, 25 Apr 2006 18:33:56 +0000 Subject: [PATCH] [IPoIB] Add support for generating unique MACs from Voltaire port GUIDS. Submitted by Guy Corem (guyc@voltaire.com) git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@327 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- ulp/ipoib/kernel/ipoib_xfr_mgr.h | 56 +++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/ulp/ipoib/kernel/ipoib_xfr_mgr.h b/ulp/ipoib/kernel/ipoib_xfr_mgr.h index b29fa413..2796194b 100644 --- a/ulp/ipoib/kernel/ipoib_xfr_mgr.h +++ b/ulp/ipoib/kernel/ipoib_xfr_mgr.h @@ -244,9 +244,51 @@ ipoib_mac_from_mlx_guid( * IB_INVALID_GUID * The port GUID provided was not a known GUID format. * -* NOTES -* The algorithm to convert portGuid to MAC address is as per DN0074, and -* assumes a 2 port HCA. +* SEE ALSO +* IPOIB +*********/ + + +/****f* IPOIB/ipoib_mac_from_voltaire_guid +* NAME +* ipoib_mac_from_voltaire_guid +* +* DESCRIPTION +* Generates an ethernet MAC address given a Voltaire port GUID. +* +* SYNOPSIS +*/ +static inline ib_api_status_t +ipoib_mac_from_voltaire_guid( + IN const net64_t port_guid, + OUT mac_addr_t* const p_mac_addr ) +{ + const uint8_t *p_guid = (const uint8_t*)&port_guid; + + /* Port guid is in network byte order. OUI is in lower 3 bytes. */ + ASSERT( p_guid[0] == 0x00 && p_guid[1] == 0x08 && p_guid[2] == 0xf1 ); + + p_mac_addr->addr[0] = p_guid[0]; + p_mac_addr->addr[1] = p_guid[1]; + p_mac_addr->addr[2] = p_guid[2]; + p_mac_addr->addr[3] = p_guid[4] ^ p_guid[6]; + p_mac_addr->addr[4] = p_guid[5] ^ p_guid[7]; + p_mac_addr->addr[5] = p_guid[5] + p_guid[6] + p_guid[7]; + + 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. * * SEE ALSO * IPOIB @@ -278,12 +320,18 @@ ipoib_mac_from_guid( if( status == IB_SUCCESS ) return IB_SUCCESS; } - if( p_guid[0] == 0x00 && p_guid[1] == 0x02 && p_guid[2] == 0xc9 ) + else if( p_guid[0] == 0x00 && p_guid[1] == 0x02 && p_guid[2] == 0xc9 ) { status = ipoib_mac_from_mlx_guid( port_guid, p_mac_addr ); if( status == IB_SUCCESS ) return IB_SUCCESS; } + else if( p_guid[0] == 0x00 && p_guid[1] == 0x08 && p_guid[2] == 0xf1 ) + { + status = ipoib_mac_from_voltaire_guid( port_guid, p_mac_addr ); + if( status == IB_SUCCESS ) + return IB_SUCCESS; + } /* Value of zero is reserved. */ laa = cl_atomic_inc( &g_ipoib.laa_idx ); -- 2.17.1