[ofw] [IPoIB][patch 2/3] Adding support to dell guid and user-define mask for guid generation - revisited
Alex Naslednikov
xalex at mellanox.co.il
Mon Sep 22 09:06:30 PDT 2008
This patch adds support for user-define mask for generic mac generation
Signed-off by: Alexander Naslednikov (xalex at mellanox.co.il)
Index: D:/Windows/MLNX_WINOF/ulp/opensm/user/include/iba/ib_types.h
===================================================================
--- D:/Windows/MLNX_WINOF/ulp/opensm/user/include/iba/ib_types.h
(revision 3214)
+++ D:/Windows/MLNX_WINOF/ulp/opensm/user/include/iba/ib_types.h
(revision 3215)
@@ -7928,6 +7928,7 @@
IB_INVALID_GID,
IB_INVALID_LID,
IB_INVALID_GUID,
+ IB_INVALID_GUID_MASK,
IB_INVALID_CA_HANDLE,
IB_INVALID_AV_HANDLE,
IB_INVALID_CQ_HANDLE,
Index:
D:/Windows/MLNX_WINOF/ulp/opensm/user/include/iba/ib_types_extended.h
===================================================================
---
D:/Windows/MLNX_WINOF/ulp/opensm/user/include/iba/ib_types_extended.h
(revision 3214)
+++
D:/Windows/MLNX_WINOF/ulp/opensm/user/include/iba/ib_types_extended.h
(revision 3215)
@@ -137,6 +137,7 @@
IB_INVALID_GID,
IB_INVALID_LID,
IB_INVALID_GUID,
+ IB_INVALID_GUID_MASK,
IB_INVALID_CA_HANDLE,
IB_INVALID_AV_HANDLE,
IB_INVALID_CQ_HANDLE,
Index: D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_adapter.c
===================================================================
--- D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_adapter.c
(revision 3214)
+++ D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_adapter.c
(revision 3215)
@@ -344,7 +344,7 @@
/* Validate the port GUID and generate the MAC address. */
status =
- ipoib_mac_from_guid( p_adapter->guids.port_guid.guid,
&p_adapter->mac );
+ ipoib_mac_from_guid( p_adapter->guids.port_guid.guid,
p_adapter->params.guid_mask, &p_adapter->mac);
if( status != IB_SUCCESS )
{
IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
Index: D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_port.c
===================================================================
--- D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_port.c (revision 3214)
+++ D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_port.c (revision 3215)
@@ -1819,9 +1819,9 @@
{
status = ipoib_mac_from_guid(
#if IPOIB_INLINE_RECV
-
p_desc->buf.ib.grh.src_gid.unicast.interface_id, &mac );
+
p_desc->buf.ib.grh.src_gid.unicast.interface_id,
p_port->p_adapter->params.guid_mask, &mac );
#else /* IPOIB_INLINE_RECV */
-
p_desc->p_buf->ib.grh.src_gid.unicast.interface_id, &mac );
+
p_desc->p_buf->ib.grh.src_gid.unicast.interface_id,
p_port->p_adapter->params.guid_mask, &mac );
#endif /* IPOIB_INLINE_RECV */
if( status != IB_SUCCESS )
{
@@ -2315,7 +2315,7 @@
cl_memcpy( &gid, &p_cid[7], sizeof(ib_gid_t) );
p_cid[1] = HW_ADDR_LEN +1;// CID length
p_cid[2] = DHCP_HW_TYPE_ETH;// CID type
- status = ipoib_mac_from_guid( gid.unicast.interface_id,
(mac_addr_t*)&p_cid[3] );
+ status = ipoib_mac_from_guid( gid.unicast.interface_id,
p_port->p_adapter->params.guid_mask, (mac_addr_t*)&p_cid[3] );
p_cid[HW_ADDR_LEN + 3] = DHCP_OPT_END; //terminate tag
}
IPOIB_EXIT( IPOIB_DBG_RECV );
@@ -2425,7 +2425,7 @@
{
/* Copy the src GID to allow aligned access */
cl_memcpy( &gid, &p_ib_arp->src_hw.gid, sizeof(ib_gid_t)
);
- status = ipoib_mac_from_guid( gid.unicast.interface_id,
&mac );
+ status = ipoib_mac_from_guid( gid.unicast.interface_id,
p_port->p_adapter->params.guid_mask, &mac );
if( status != IB_SUCCESS )
{
IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,
Index: D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_adapter.h
===================================================================
--- D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_adapter.h
(revision 3214)
+++ D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_adapter.h
(revision 3215)
@@ -77,6 +77,7 @@
uint32_t xfer_block_size;
mac_addr_t conf_mac;
uint32_t mc_leave_rescan;
+ uint32_t guid_mask;
} ipoib_params_t;
/*
* FIELDS
Index: D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_driver.c
===================================================================
--- D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_driver.c
(revision 3214)
+++ D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_driver.c
(revision 3215)
@@ -128,7 +128,10 @@
#define IB_INFINITE_SERVICE_LEASE 0xFFFFFFFF
+//The mask is 8 bit and can't contain more than 6 non-zero bits
+#define MAX_GUID_MAX 0xFC
+
/* Global driver debug level */
uint32_t g_ipoib_dbg_level = TRACE_LEVEL_ERROR;
uint32_t g_ipoib_dbg_flags = 0x00000fff;
@@ -157,7 +160,10 @@
{NDIS_STRING_CONST("RecvRatio"), 1,
IPOIB_OFFSET(recv_pool_ratio), IPOIB_SIZE(recv_pool_ratio), 1,
1, 10},
{NDIS_STRING_CONST("PayloadMtu"), 1,
IPOIB_OFFSET(payload_mtu), IPOIB_SIZE(payload_mtu),
2044, 60, 4092},
{NDIS_STRING_CONST("lso"), 0, IPOIB_OFFSET(lso),
IPOIB_SIZE(lso), 0, 0, 1},
- {NDIS_STRING_CONST("MCLeaveRescan"), 1,
IPOIB_OFFSET(mc_leave_rescan), IPOIB_SIZE(mc_leave_rescan),
260, 1, 3600}
+ {NDIS_STRING_CONST("MCLeaveRescan"), 1,
IPOIB_OFFSET(mc_leave_rescan), IPOIB_SIZE(mc_leave_rescan),
260, 1, 3600},
+ {NDIS_STRING_CONST("GUIDMask"), 1,
IPOIB_OFFSET(guid_mask), IPOIB_SIZE(guid_mask), 0,
0, MAX_GUID_MAX}
+
+
};
#define IPOIB_NUM_REG_PARAMS (sizeof (HCARegTable) /
sizeof(IPOIB_REG_ENTRY))
Index: D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/netipoib.inx
===================================================================
--- D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/netipoib.inx (revision 3214)
+++ D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/netipoib.inx (revision 3215)
@@ -152,6 +152,13 @@
HKR, Ndi\Params\MCLeaveRescan, Max, 0, "3600"
+HKR, Ndi\Params\guid_mask, ParamDesc, 0, "GUID bitwise
mask"
+HKR, Ndi\Params\guid_mask, Type, 0, "dword"
+HKR, Ndi\Params\guid_mask, Default, 0, "0"
+HKR, Ndi\Params\guid_mask, Optional, 0, "0"
+HKR, Ndi\Params\guid_mask, Min, 0, "0"
+HKR, Ndi\Params\guid_mask, Max, 0, "252"
+
[IpoibService]
DisplayName = %IpoibServiceDispName%
ServiceType = 1 ;%SERVICE_KERNEL_DRIVER%
Index: D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_xfr_mgr.h
===================================================================
--- D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_xfr_mgr.h
(revision 3214)
+++ D:/Windows/MLNX_WINOF/ulp/ipoib/kernel/ipoib_xfr_mgr.h
(revision 3215)
@@ -274,12 +274,60 @@
* The MAC address was successfully converted.
*
*********/
+
+
+/****f* IPOIB/ipoib_mac_from_general_guid
+* NAME
+* ipoib_mac_from_dell_guid
+*
+* DESCRIPTION
+* Generates an ethernet MAC address given general port GUID and a
bitwise mask
+*
+* SYNOPSIS
+*/
+static inline ib_api_status_t
+ipoib_mac_from_general_guid(
+ IN const net64_t
port_guid,
+ IN uint32_t
guid_mask,
+ OUT mac_addr_t* const
p_mac_addr )
+{
+#define MAC_ADDR_SIZE 6
+ 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 ) {
+ ++digit_counter;
+ if (digit_counter > MAC_ADDR_SIZE) {
+ //to avoid negative index
+ return IB_INVALID_GUID_MASK;
+ }
+ 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;
+ }
+
+ return IB_SUCCESS;
+}
+
+
/*
* PARAMETERS
* port_guid
* The port GUID, in network byte order, for which to
generate a
* MAC address.
*
+* guid_mask
+* Each BIT in the mask indicates whether to include the
appropriate BYTE
+* to the MAC address. Bit 0 corresponds to the less
significant BYTE , i.e.
+* highest index in the MAC array
+*
* p_mac_addr
* Pointer to a mac address in which to store the results.
*
@@ -442,12 +490,23 @@
static inline ib_api_status_t
ipoib_mac_from_guid(
IN const net64_t
port_guid,
- OUT mac_addr_t* const
p_mac_addr )
+ IN uint32_t
guid_mask,
+ OUT mac_addr_t* const
p_mac_addr
+ )
{
+ static const guid_default_mask = 0xE7; //==0b 11100111
ib_api_status_t status;
const uint8_t *p_guid = (const uint8_t*)&port_guid;
uint32_t laa;
+ if ( guid_mask )
+ {
+ status = ipoib_mac_from_general_guid(port_guid,
guid_mask, p_mac_addr);
+ if( status == IB_SUCCESS )
+ return IB_SUCCESS;
+ //otherwise, mask was invalid, getting back to standard
flow
+ }
+
if( p_guid[0] == 0 )
{
if( p_guid[1] == 0x02 && p_guid[2] == 0xc9 )
Index: D:/Windows/MLNX_WINOF/inc/iba/ib_types.h
===================================================================
--- D:/Windows/MLNX_WINOF/inc/iba/ib_types.h (revision 3214)
+++ D:/Windows/MLNX_WINOF/inc/iba/ib_types.h (revision 3215)
@@ -8696,6 +8696,7 @@
IB_INVALID_GID,
IB_INVALID_LID,
IB_INVALID_GUID,
+ IB_INVALID_GUID_MASK,
IB_INVALID_CA_HANDLE,
IB_INVALID_AV_HANDLE,
IB_INVALID_CQ_HANDLE,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipoib_guid2.diff
Type: application/octet-stream
Size: 9147 bytes
Desc: ipoib_guid2.diff
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080922/37f5d3e5/attachment.obj>
More information about the ofw
mailing list