[ofw] RE: [PATCH] IPoIB - add guid2mac table

Tzachi Dar tzachid at mellanox.co.il
Thu Dec 25 08:30:14 PST 2008


applied on 1802.
 
Thanks
Tzachi


________________________________

	From: Reuven Amitai 
	Sent: Sunday, December 07, 2008 4:20 PM
	To: Tzachi Dar
	Cc: ofw at lists.openfabrics.org
	Subject: [PATCH] IPoIB - add guid2mac table
	
	
	Hi,
	 
	The following patch adds guid2mac table to ipoib_xfr_mgr files.
	The idea is to have one table which holds all GUIDs with their
guid mask used in the GUID to MAC transformation.
	The code will replace almost all if sections with one loop over
the table.
	Another advantage is in future addition of GUIDs, one need only
to add a row in the table (The OUI bytes and the corresponding guid
mask)
	Please note that Mellanox, SST and Voltaire GUIDs are not in the
table (the current transformation can't be represented by guid mask)
	SuperMicro, Cisco, HP and DELL GUIDs moved to the table.
	 
	Thanks, Reuven.
	 
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	 
	Index: ulp/ipoib/kernel/ipoib_xfr_mgr.c
	
===================================================================
	--- ulp/ipoib/kernel/ipoib_xfr_mgr.c (revision 0)
	+++ ulp/ipoib/kernel/ipoib_xfr_mgr.c (revision 0)
	@@ -0,0 +1,52 @@
	+/*
	+ * Copyright (c) 2008 Mellanox Technologies.  All rights
reserved.
	+ *
	+ * This software is available to you under the OpenIB.org BSD
license
	+ * below:
	+ *
	+ *     Redistribution and use in source and binary forms, with
or
	+ *     without modification, are permitted provided that the
following
	+ *     conditions are met:
	+ *
	+ *      - Redistributions of source code must retain the above
	+ *        copyright notice, this list of conditions and the
following
	+ *        disclaimer.
	+ *
	+ *      - Redistributions in binary form must reproduce the
above
	+ *        copyright notice, this list of conditions and the
following
	+ *        disclaimer in the documentation and/or other
materials
	+ *        provided with the distribution.
	+ *
	+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND,
	+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF
	+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
	+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS
	+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN
	+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN
	+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE
	+ * SOFTWARE.
	+ *
	+ * $Id: ipoib_xfr_mgr.c 3459 2008-11-12 16:48:21Z tzachid $
	+ */
	+
	+
	+#include "ipoib_xfr_mgr.h"
	+#if defined(EVENT_TRACING)
	+#ifdef offsetof
	+#undef offsetof
	+#endif
	+#include "ipoib_xfr_mgr.tmh"
	+#endif
	+
	+
	+const ipoib_guid2mac_translation_t guid2mac_table[] = {
	+ {0x30, 0x48, 0xE7},
	+ {0x05, 0xAD, 0xE7},
	+ {0x18, 0x8B, 0xE7},
	+ {0x1A, 0x4B, 0xE7},
	+ {0x17, 0x08, 0xE7},
	+ {0x1E, 0x0B, 0xE7},
	+
	+ {0x00, 0x00, 0x00},
	+};
	+
	Index: ulp/ipoib/kernel/ipoib_xfr_mgr.h
	
===================================================================
	--- ulp/ipoib/kernel/ipoib_xfr_mgr.h (revision 1777)
	+++ ulp/ipoib/kernel/ipoib_xfr_mgr.h (working copy)
	@@ -81,7 +81,39 @@
	 *********/
	 #include <complib/cl_packoff.h>
	 
	+/****s* IPoIB Driver/ipoib_guid2mac_translation_t
	+* NAME
	+*   ipoib_guid2mac_translation_t
	+*
	+* DESCRIPTION
	+*   The ipoib_guid2mac_translation_t structure defines a GUID
to MAC translation.
	+*   The structure holds map between known OUI to an appropriate
GUID mask.
	+*
	+* SYNOPSIS
	+*/
	+typedef struct _ipoib_guid2mac_translation_
	+{
	+ uint8_t second_byte;
	+ uint8_t third_byte;
	+ uint8_t guid_mask;
	+ 
	+} ipoib_guid2mac_translation_t;
	+/*
	+* FIELDS
	+* second_byte
	+*  second byte of OUI (located in lower three bytes of GUID).
	+*
	+* third_byte
	+*  third byte of OUI (located in lower three bytes of GUID).
	+*
	+* guid_mask
	+*  GUID mask that will be used to generate MAC from the GUID.

	+*
	+* SEE ALSO
	+* IPoIB, ipoib_mac_from_guid_mask
	+*********/
	 
	+extern const ipoib_guid2mac_translation_t guid2mac_table[];
	 
	 #ifdef __cplusplus
	 extern "C"
	@@ -363,10 +395,9 @@
	   OUT   mac_addr_t* const   p_mac_addr
	   )
	 {
	- static const uint32_t guid_default_mask = 0xE7; //==0b
11100111
	  ib_api_status_t status = IB_INVALID_GUID;
	  const uint8_t *p_guid = (const uint8_t*)&port_guid;
	- uint32_t  laa;
	+ uint32_t  laa, idx = 0;
	 
	  /* Port guid is in network byte order.  OUI is in lower 3
bytes. */
	  if( p_guid[0] == 0 )
	@@ -379,33 +410,26 @@
	   {
	    status = ipoib_mac_from_voltaire_guid( port_guid, p_mac_addr
);
	   }
	-  else if( p_guid[1] == 0x30 && p_guid[2] == 0x48 )
	-  {
	-   //Supermicro GUID
	-   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_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 ||
	-     p_guid[1] == 0x17 && p_guid[2] == 0x08 ||
	-     p_guid[1] == 0x1e && p_guid[2] == 0x0b )
	+  else
	   {
	-   //HP GUID
	-   status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask,
p_mac_addr );
	+   while( guid2mac_table[idx].second_byte != 0x00 ||
	+       guid2mac_table[idx].third_byte != 0x00 )
	+   {
	+    if( p_guid[1] == guid2mac_table[idx].second_byte &&
	+     p_guid[2] == guid2mac_table[idx].third_byte )
	+    {
	+     status = ipoib_mac_from_guid_mask(p_guid,
guid2mac_table[idx].guid_mask,
	+              p_mac_addr);
	+     break;
	+    }
	+    ++idx;
	+   }
	   }
	-  else if( p_guid[1] == 0x18 && p_guid[2] == 0x8b )
	-  {
	-   //DELL GUID
	-   status =ipoib_mac_from_guid_mask( p_guid, guid_default_mask,
p_mac_addr );
	-  }
	-  
	+
	   if( status == IB_SUCCESS )
	    return status;
	  }
	Index: ulp/ipoib/kernel/SOURCES
	
===================================================================
	--- ulp/ipoib/kernel/SOURCES (revision 1777)
	+++ ulp/ipoib/kernel/SOURCES (working copy)
	@@ -23,7 +23,8 @@
	   ipoib_adapter.c \
	   ipoib_endpoint.c \
	   ipoib_port.c \
	-  ipoib_ibat.c
	+  ipoib_ibat.c \
	+  ipoib_xfr_mgr.c
	 
	 INCLUDES=..;..\..\..\inc;..\..\..\inc\kernel;
	 
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20081225/702344d1/attachment.html>


More information about the ofw mailing list