[Openib-windows] Static MAC for Mellanox GUIDs
Yossi Leybovich
sleybo at mellanox.co.il
Mon Dec 5 05:20:41 PST 2005
Fab
The following patch create permanent MAC from Mellanox GUIDs .
BTW
The macros that get port number from adapter are valid only for SST
cards ( where the port number is in the 3rd byte)
Maybe we should keep the port number in the adapter structure and not
use guid conversion.
10x
Yossi
Index: ulp/ipoib/kernel/ipoib_xfr_mgr.h
===================================================================
--- ulp/ipoib/kernel/ipoib_xfr_mgr.h (revision 788)
+++ ulp/ipoib/kernel/ipoib_xfr_mgr.h (working copy)
@@ -190,7 +190,64 @@
* IPOIB
*********/
+/****f* IPOIB/ipoib_mac_from_mlx_guid
+* NAME
+* ipoib_mac_from_sst_guid
+*
+* DESCRIPTION
+* Generates an ethernet MAC address given a Mellanox port GUID.
+*
+* SYNOPSIS
+*/
+static inline ib_api_status_t
+ipoib_mac_from_mlx_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;
+ uint32_t low24;
+ /* Port guid is in network byte order. OUI is in lower 3 bytes.
*/
+ ASSERT( p_guid[0] == 0x00 && p_guid[1] == 0x02 && p_guid[2] ==
0xc9 );
+
+ if( (port_guid & CL_HTON64( 0x000000ffff0000 )) !=
CL_HTON64(0x00000002000000))
+ return IB_INVALID_GUID;
+
+ low24 = ((uint32_t)cl_ntoh64( port_guid ) & 0x00FFFFFF);
+
+ 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] = (uint8_t)(low24 >> 16);
+ p_mac_addr->addr[4] = (uint8_t)(low24 >> 8);
+ p_mac_addr->addr[5] = (uint8_t)low24;
+
+ 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
+* 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_guid
* NAME
* ipoib_mac_from_guid
@@ -216,7 +273,13 @@
if( status == IB_SUCCESS )
return IB_SUCCESS;
}
-
+ 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;
+ }
+
/* Value of zero is reserved. */
laa = cl_atomic_inc( &g_ipoib.laa_idx );
@@ -256,9 +319,9 @@
*********/
-/****f* IPOIB/ipoib_guid_from_mac
+/****f* IPOIB/ipoib_sst_guid_from_mac
* NAME
-* ipoib_guid_from_mac
+* ipoib_sst_guid_from_mac
*
* DESCRIPTION
* Generates a port GUID given an ethernet MAC address.
@@ -266,7 +329,7 @@
* SYNOPSIS
*/
static inline ib_api_status_t
-ipoib_guid_from_mac(
+ipoib_sst_guid_from_mac(
IN const mac_addr_t
mac,
OUT net64_t* const
p_port_guid )
{
@@ -328,9 +391,74 @@
* IPOIB
*********/
+/****f* IPOIB/ipoib_mlx_guid_from_mac
+* NAME
+* ipoib_mlx_guid_from_mac
+*
+* DESCRIPTION
+* Generates a port GUID given an ethernet MAC address.
+*
+* SYNOPSIS
+*/
+static inline ib_api_status_t
+ipoib_mlx_guid_from_mac(
+ IN const mac_addr_t
mac,
+ OUT net64_t* const
p_port_guid )
+{
+ uint8_t *p_guid = (uint8_t*)p_port_guid;
+ uint32_t low24;
+ /* MAC address is in network byte order. OUI is in lower 3
bytes. */
+ if( mac.addr[0] != 0x00 ||
+ mac.addr[1] != 0x02 ||
+ mac.addr[2] != 0xc9 )
+ {
+ return IB_INVALID_GUID;
+ }
+ low24 = mac.addr[3] << 16 || mac.addr[4] << 8 || mac.addr[5];
+
+ /* OUI */
+ p_guid[0] = mac.addr[0];
+ p_guid[1] = mac.addr[1];
+ p_guid[2] = mac.addr[2];
+ p_guid[3] = 0x02;
+ p_guid[4] = 0x00;
+ /* Serial Number */
+ p_guid[5] = (uint8_t)(low24 >> 16);
+ p_guid[6] = (uint8_t)(low24 >> 8);
+ p_guid[7] = (uint8_t)low24;
+
+ 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
+* The algorithm to convert portGuid to MAC address is as
+*
+* SEE ALSO
+* IPOIB
+*********/
+
+
+
+
+
#ifdef __cplusplus
}
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mlx_mac.patch
Type: application/octet-stream
Size: 4215 bytes
Desc: mlx_mac.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20051205/cc83a7c7/attachment.obj>
More information about the ofw
mailing list