[ofw] [PATCH 1/4] Clean up MAC generation, add support for HP GUIDs
Fab Tillier
ftillier at windows.microsoft.com
Tue Sep 30 11:20:05 PDT 2008
- Rename ipoib_mac_from_general_guid to ipoib_mac_from_guid_mask, to more accurately reflect what it does.
- Change input parameters to ipoib_mac_from_guid_mask to take as input the pointer to the port GUID byte array since that's what it works on and the ipoib_mac_from_guid function already has the pointer.
- Remove trailing whitespace
- Delete dead code
- Fix whitespace
- Fix style to match existing (curly brace, parenthesis spacing)
- Eliminate use of IB_INVALID_GUID_MASK since no code checks for that actual value, and use IB_INVALID_GUID instead.
Signed-off-by: Fab Tillier <ftillier at microsoft.com>
--- \dev\openib\gen1\branches\WOF2-0\trunk\ulp\ipoib\kernel\ipoib_xfr_mgr.h Tue Sep 30 11:07:49 2008
+++ ulp\ipoib\kernel\ipoib_xfr_mgr.h Tue Sep 30 11:08:49 2008
@@ -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;
+ return IB_INVALID_GUID;
}
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;
+
return IB_SUCCESS;
}
@@ -394,20 +396,15 @@ ipoib_mac_from_guid(
const uint8_t *p_guid = (const uint8_t*)&port_guid;
uint32_t laa;
- if ( guid_mask )
+ if( guid_mask )
{
- mask_status = ipoib_mac_from_general_guid(port_guid, guid_mask, p_mac_addr);
+ mask_status = ipoib_mac_from_guid_mask( p_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") );
- }*/
+ return IB_SUCCESS;
}
-
- 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,14 +417,13 @@ 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 );
@@ -435,18 +431,18 @@ ipoib_mac_from_guid(
else if( p_guid[1] == 0x1a && p_guid[2] == 0x4b )
{
//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 )
+ if( status == IB_SUCCESS )
{
- ASSERT ( mask_status == IB_SUCCESS || mask_status == IB_INVALID_GUID_MASK );
- return mask_status;
+ ASSERT ( mask_status == IB_SUCCESS || mask_status == IB_INVALID_GUID );
+ return mask_status;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipoib_mac.1.patch
Type: application/octet-stream
Size: 4482 bytes
Desc: ipoib_mac.1.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080930/c15d6614/attachment.obj>
More information about the ofw
mailing list