[IPoIB] This patch adds support for user-define mask for generic mac generation....
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 24 Sep 2008 17:48:31 +0000 (17:48 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 24 Sep 2008 17:48:31 +0000 (17:48 +0000)
Signed-off by: Alexander Naslednikov

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1606 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

inc/iba/ib_types.h
ulp/ipoib/kernel/ipoib_adapter.c
ulp/ipoib/kernel/ipoib_adapter.h
ulp/ipoib/kernel/ipoib_driver.c
ulp/ipoib/kernel/ipoib_port.c
ulp/ipoib/kernel/ipoib_xfr_mgr.h
ulp/ipoib/kernel/netipoib.inx
ulp/opensm/user/include/iba/ib_types.h
ulp/opensm/user/include/iba/ib_types_extended.h

index 0f43b12..9ad64a3 100644 (file)
@@ -8696,6 +8696,7 @@ typedef enum _ib_api_status_t
        IB_INVALID_GID,\r
        IB_INVALID_LID,\r
        IB_INVALID_GUID,\r
+       IB_INVALID_GUID_MASK,\r
        IB_INVALID_CA_HANDLE,\r
        IB_INVALID_AV_HANDLE,\r
        IB_INVALID_CQ_HANDLE,\r
index c51fc31..14a04ce 100644 (file)
@@ -344,7 +344,7 @@ adapter_init(
 \r
        /* Validate the port GUID and generate the MAC address. */\r
        status =\r
-               ipoib_mac_from_guid( p_adapter->guids.port_guid.guid, &p_adapter->mac );\r
+               ipoib_mac_from_guid( p_adapter->guids.port_guid.guid, p_adapter->params.guid_mask, &p_adapter->mac);\r
        if( status != IB_SUCCESS )\r
        {\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
index 72597fd..a9c022f 100644 (file)
@@ -77,6 +77,7 @@ typedef struct _ipoib_params
        uint32_t        xfer_block_size;\r
        mac_addr_t      conf_mac;\r
        uint32_t        mc_leave_rescan;\r
+       uint32_t        guid_mask;\r
 }      ipoib_params_t;\r
 /*\r
 * FIELDS\r
index cf28f65..04fa5bb 100644 (file)
@@ -128,6 +128,9 @@ static const unsigned char VENDOR_ID[] = {0x00, 0x06, 0x6A, 0x00};
 \r
 #define IB_INFINITE_SERVICE_LEASE      0xFFFFFFFF\r
 \r
+//The mask is 8 bit and can't contain more than 6 non-zero bits\r
+#define MAX_GUID_MAX 0xFC\r
+\r
 \r
 /* Global driver debug level */\r
 uint32_t               g_ipoib_dbg_level = TRACE_LEVEL_ERROR;\r
@@ -157,7 +160,10 @@ IPOIB_REG_ENTRY HCARegTable[] = {
        {NDIS_STRING_CONST("RecvRatio"),        1, IPOIB_OFFSET(recv_pool_ratio),       IPOIB_SIZE(recv_pool_ratio),    1,          1,      10},\r
        {NDIS_STRING_CONST("PayloadMtu"),       1, IPOIB_OFFSET(payload_mtu),           IPOIB_SIZE(payload_mtu),        2044,       60,   4092},\r
        {NDIS_STRING_CONST("lso"),              0, IPOIB_OFFSET(lso),                   IPOIB_SIZE(lso),                0,          0,      1},\r
-       {NDIS_STRING_CONST("MCLeaveRescan"),    1, IPOIB_OFFSET(mc_leave_rescan),       IPOIB_SIZE(mc_leave_rescan),    260,        1,    3600}\r
+       {NDIS_STRING_CONST("MCLeaveRescan"),    1, IPOIB_OFFSET(mc_leave_rescan),       IPOIB_SIZE(mc_leave_rescan),    260,        1,    3600},\r
+       {NDIS_STRING_CONST("GUIDMask"),         1, IPOIB_OFFSET(guid_mask),             IPOIB_SIZE(guid_mask),          0,          0,    MAX_GUID_MAX}\r
+       \r
+       \r
 };  \r
 \r
 #define IPOIB_NUM_REG_PARAMS (sizeof (HCARegTable) / sizeof(IPOIB_REG_ENTRY))\r
index 742e757..c226752 100644 (file)
@@ -1819,9 +1819,9 @@ __recv_get_endpts(
                {\r
                        status = ipoib_mac_from_guid(\r
 #if IPOIB_INLINE_RECV\r
-                               p_desc->buf.ib.grh.src_gid.unicast.interface_id, &mac );\r
+                               p_desc->buf.ib.grh.src_gid.unicast.interface_id, p_port->p_adapter->params.guid_mask, &mac );\r
 #else  /* IPOIB_INLINE_RECV */\r
-                               p_desc->p_buf->ib.grh.src_gid.unicast.interface_id, &mac );\r
+                               p_desc->p_buf->ib.grh.src_gid.unicast.interface_id, p_port->p_adapter->params.guid_mask, &mac );\r
 #endif /* IPOIB_INLINE_RECV */\r
                        if( status != IB_SUCCESS )\r
                        {\r
@@ -2315,7 +2315,7 @@ __recv_dhcp(
                cl_memcpy( &gid, &p_cid[7], sizeof(ib_gid_t) );\r
                p_cid[1] =  HW_ADDR_LEN +1;// CID length \r
                p_cid[2] =  DHCP_HW_TYPE_ETH;// CID type \r
-               status = ipoib_mac_from_guid( gid.unicast.interface_id, (mac_addr_t*)&p_cid[3] );\r
+               status = ipoib_mac_from_guid( gid.unicast.interface_id, p_port->p_adapter->params.guid_mask, (mac_addr_t*)&p_cid[3] );\r
                p_cid[HW_ADDR_LEN + 3] = DHCP_OPT_END; //terminate tag\r
        }\r
        IPOIB_EXIT( IPOIB_DBG_RECV );\r
@@ -2425,7 +2425,7 @@ __recv_arp(
        {\r
                /* Copy the src GID to allow aligned access */\r
                cl_memcpy( &gid, &p_ib_arp->src_hw.gid, sizeof(ib_gid_t) );\r
-               status = ipoib_mac_from_guid( gid.unicast.interface_id, &mac );\r
+               status = ipoib_mac_from_guid( gid.unicast.interface_id, p_port->p_adapter->params.guid_mask, &mac );\r
                if( status != IB_SUCCESS )\r
                {\r
                        IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
index 02baee2..e3e87b7 100644 (file)
@@ -274,12 +274,60 @@ ipoib_mac_from_dell_guid(
 *              The MAC address was successfully converted.\r
 *\r
 *********/\r
+\r
+\r
+/****f* IPOIB/ipoib_mac_from_general_guid\r
+* NAME\r
+*      ipoib_mac_from_dell_guid\r
+*\r
+* DESCRIPTION\r
+*      Generates an ethernet MAC address given general port GUID and a bitwise mask\r
+*\r
+* SYNOPSIS\r
+*/\r
+static inline ib_api_status_t\r
+ipoib_mac_from_general_guid(\r
+       IN              const   net64_t                                         port_guid,\r
+       IN                              uint32_t                                                guid_mask,\r
+               OUT                     mac_addr_t* const                       p_mac_addr )\r
+{\r
+#define MAC_ADDR_SIZE 6\r
+       uint8_t i;\r
+       const uint8_t   *p_guid = (const uint8_t*)&port_guid;\r
+       int digit_counter = 0;\r
+\r
+       //All non-zero bits of guid_mask indicates the number of an appropriate byte in\r
+       // port_guid, that will be used in MAC address construction\r
+       for (i = 7; guid_mask; guid_mask >>= 1, --i) {\r
+               if (guid_mask & 1 ) {\r
+                       ++digit_counter;\r
+                       if (digit_counter > MAC_ADDR_SIZE) {\r
+                               //to avoid negative index\r
+                               return IB_INVALID_GUID_MASK;\r
+                       }\r
+                       p_mac_addr->addr[MAC_ADDR_SIZE - digit_counter] = p_guid [i];\r
+               }\r
+       }\r
+               // check for the mask validity: it should have 6 non-zero bits\r
+               if (digit_counter != MAC_ADDR_SIZE) {\r
+                       return IB_INVALID_GUID_MASK;\r
+               }\r
+               \r
+       return IB_SUCCESS;\r
+}\r
+\r
+\r
 /*\r
 * PARAMETERS\r
 *      port_guid\r
 *              The port GUID, in network byte order, for which to generate a\r
 *              MAC address.\r
 *\r
+*      guid_mask\r
+*              Each BIT in the mask indicates whether to include the appropriate BYTE\r
+*              to the MAC address. Bit 0 corresponds to the less significant BYTE , i.e.\r
+*              highest index in the MAC array\r
+*\r
 *      p_mac_addr\r
 *              Pointer to a mac address in which to store the results.\r
 *\r
@@ -442,12 +490,23 @@ ipoib_mac_from_hp_guid(
 static inline ib_api_status_t\r
 ipoib_mac_from_guid(\r
        IN              const   net64_t                                         port_guid,\r
-               OUT                     mac_addr_t* const                       p_mac_addr )\r
+       IN                              uint32_t                                        guid_mask,\r
+               OUT                     mac_addr_t* const                       p_mac_addr\r
+               )\r
 {\r
+       static const guid_default_mask = 0xE7; //==0b 11100111\r
        ib_api_status_t status;\r
        const uint8_t   *p_guid = (const uint8_t*)&port_guid;\r
        uint32_t                laa;\r
 \r
+       if ( guid_mask ) \r
+       {\r
+               status = ipoib_mac_from_general_guid(port_guid, guid_mask, p_mac_addr);\r
+               if( status == IB_SUCCESS )\r
+                               return IB_SUCCESS;\r
+               //otherwise, mask was invalid, getting back to standard flow\r
+       }\r
+                       \r
        if( p_guid[0] == 0 ) \r
        {\r
                if( p_guid[1] == 0x02 && p_guid[2] == 0xc9 )\r
index 74f7686..3539f7a 100644 (file)
@@ -150,6 +150,13 @@ HKR, Ndi\Params\MCLeaveRescan,             Optional,       0, "0"
 HKR, Ndi\Params\MCLeaveRescan,         Min,            0, "1"\r
 HKR, Ndi\Params\MCLeaveRescan,         Max,            0, "3600"\r
 \r
+HKR, Ndi\Params\guid_mask,             ParamDesc,      0, "GUID bitwise mask"\r
+HKR, Ndi\Params\guid_mask,             Type,           0, "dword"\r
+HKR, Ndi\Params\guid_mask,             Default,        0, "0"\r
+HKR, Ndi\Params\guid_mask,             Optional,       0, "0"\r
+HKR, Ndi\Params\guid_mask,             Min,            0, "0"\r
+HKR, Ndi\Params\guid_mask,             Max,            0, "252"\r
+\r
 [IpoibService]\r
 DisplayName     = %IpoibServiceDispName%\r
 ServiceType     = 1 ;%SERVICE_KERNEL_DRIVER%\r
index 756c10e..165b261 100644 (file)
@@ -7928,6 +7928,7 @@ typedef enum _ib_api_status_t
        IB_INVALID_GID,\r
        IB_INVALID_LID,\r
        IB_INVALID_GUID,\r
+       IB_INVALID_GUID_MASK,\r
        IB_INVALID_CA_HANDLE,\r
        IB_INVALID_AV_HANDLE,\r
        IB_INVALID_CQ_HANDLE,\r
index 0e86637..a0f6268 100644 (file)
@@ -137,6 +137,7 @@ typedef enum _ib_api_status_t
        IB_INVALID_GID,\r
        IB_INVALID_LID,\r
        IB_INVALID_GUID,\r
+       IB_INVALID_GUID_MASK,\r
        IB_INVALID_CA_HANDLE,\r
        IB_INVALID_AV_HANDLE,\r
        IB_INVALID_CQ_HANDLE,\r