[IPoIB] Fix NDIS WHQL 2c_AddressChange test failures (6 remain)
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 11 May 2006 22:56:50 +0000 (22:56 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 11 May 2006 22:56:50 +0000 (22:56 +0000)
Based on patch submitted by Yossi Leybovich (sleybo@mellanox.co.il)

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

ulp/ipoib/ip_packet.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

index 7c6dead..60421ed 100644 (file)
 #define ETH_PROT_TYPE_ARP      CL_HTON16(0x806)\r
 \r
 \r
+#define ETH_IS_LOCALLY_ADMINISTERED(addr) \\r
+       (BOOLEAN)(((PUCHAR)(addr))[0] & ((UCHAR)0x02))\r
+\r
+\r
 #include <complib/cl_packon.h>\r
 /****s* IB Network Drivers/mac_addr_t\r
 * NAME\r
@@ -72,6 +76,9 @@ typedef struct _mac_addr
 *      to support various address lengths.  If not defined, the default length for\r
 *      ethernet (6 bytes) is used.\r
 *\r
+*      addr[0] & 0x1 indicates multicast\r
+*      addr[0] & 0x2 indicates LAA if not multicast\r
+*\r
 * SEE ALSO\r
 *      IB Network Drivers, arp_pkt_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t\r
 *********/\r
index 03c790c..d62345f 100644 (file)
@@ -114,12 +114,12 @@ ipoib_clear_mcast(
 NDIS_STATUS\r
 ipoib_get_adapter_guids(\r
        IN                              NDIS_HANDLE* const                      h_adapter,\r
-       IN      OUT                     ipoib_adapter_t                         *p_adapter  );\r
+       IN      OUT                     ipoib_adapter_t                         *p_adapter );\r
 \r
 NDIS_STATUS\r
 ipoib_get_adapter_params(\r
        IN                              NDIS_HANDLE* const                      wrapper_config_context,\r
-               OUT                     ipoib_params_t* const           p_params );\r
+       IN      OUT                     ipoib_adapter_t                         *p_adapter );\r
 \r
 \r
 /* Implementation */\r
@@ -173,17 +173,6 @@ ipoib_create_adapter(
                        p_adapter->guids.port_guid, p_adapter->guids.ca_guid,\r
                        p_adapter->guids.port_num) );\r
 \r
-       /* Read configuration parameters. */\r
-       status = ipoib_get_adapter_params( wrapper_config_context,\r
-               &p_adapter->params );\r
-       if( status != NDIS_STATUS_SUCCESS )\r
-       {\r
-               __adapter_free( &p_adapter->obj );\r
-               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
-                       ("ipoib_get_adapter_params returned 0x%.8x.\n", status) );\r
-               return status;\r
-       }\r
-\r
        cl_status = cl_obj_init( &p_adapter->obj, CL_DESTROY_SYNC,\r
                __adapter_destroying, NULL, __adapter_free );\r
        if( cl_status != CL_SUCCESS )\r
@@ -204,6 +193,17 @@ ipoib_create_adapter(
                return status;\r
        }\r
 \r
+       /* Read configuration parameters. */\r
+       status = ipoib_get_adapter_params( wrapper_config_context,\r
+               p_adapter );\r
+       if( status != NDIS_STATUS_SUCCESS )\r
+       {\r
+               cl_obj_destroy( &p_adapter->obj );\r
+               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                       ("ipoib_get_adapter_params returned 0x%.8x.\n", status) );\r
+               return status;\r
+       }\r
+\r
        *pp_adapter = p_adapter;\r
 \r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
index 35cf017..717948b 100644 (file)
@@ -71,6 +71,8 @@ typedef struct _ipoib_params
        uint32_t        sa_retry_cnt;\r
        uint32_t        recv_pool_ratio;\r
        boolean_t       recv_growth;\r
+       mac_addr_t      conf_mac;\r
+\r
 }      ipoib_params_t;\r
 /*\r
 * FIELDS\r
index 80f777b..51857cc 100644 (file)
@@ -393,12 +393,14 @@ ipoib_unload(
 NDIS_STATUS\r
 ipoib_get_adapter_params(\r
        IN                              NDIS_HANDLE* const                      wrapper_config_context,\r
-               OUT                     ipoib_params_t* const           p_params )\r
+       IN      OUT                     ipoib_adapter_t                         *p_adapter )\r
 {\r
        NDIS_STATUS                                             status;\r
        NDIS_HANDLE                                             h_config;\r
        NDIS_CONFIGURATION_PARAMETER    *p_param;\r
        NDIS_STRING                                             keyword;\r
+       PUCHAR                                                  mac;\r
+       UINT                                                    len;\r
 \r
        IPOIB_ENTER( IPOIB_DBG_INIT );\r
 \r
@@ -420,7 +422,7 @@ ipoib_get_adapter_params(
                        ("Receive Queue Depth parameter missing.\n") );\r
                return status;\r
        }\r
-       p_params->rq_depth = p_param->ParameterData.IntegerData;\r
+       p_adapter->params.rq_depth = p_param->ParameterData.IntegerData;\r
 \r
        /* Required: Send queue depth. */\r
        RtlInitUnicodeString( &keyword, L"SqDepth" );\r
@@ -432,16 +434,16 @@ ipoib_get_adapter_params(
                        ("Send Queue Depth parameter missing.\n") );\r
                return status;\r
        }\r
-       p_params->sq_depth = p_param->ParameterData.IntegerData;\r
+       p_adapter->params.sq_depth = p_param->ParameterData.IntegerData;\r
        /* Send queue depth needs to be a power of two. */\r
-       if( p_params->sq_depth <= 128 )\r
-               p_params->sq_depth = 128;\r
-       else if( p_params->sq_depth <= 256 )\r
-               p_params->sq_depth = 256;\r
-       else if( p_params->sq_depth <= 512 )\r
-               p_params->sq_depth = 512;\r
+       if( p_adapter->params.sq_depth <= 128 )\r
+               p_adapter->params.sq_depth = 128;\r
+       else if( p_adapter->params.sq_depth <= 256 )\r
+               p_adapter->params.sq_depth = 256;\r
+       else if( p_adapter->params.sq_depth <= 512 )\r
+               p_adapter->params.sq_depth = 512;\r
        else\r
-               p_params->sq_depth = 1024;\r
+               p_adapter->params.sq_depth = 1024;\r
 \r
        /* Required: Send Checksum Offload. */\r
        RtlInitUnicodeString( &keyword, L"SendChksum" );\r
@@ -453,25 +455,25 @@ ipoib_get_adapter_params(
                        ("Send Checksum Offload parameter missing.\n") );\r
                return status;\r
        }\r
-       p_params->send_chksum_offload = (p_param->ParameterData.IntegerData != 0);\r
+       p_adapter->params.send_chksum_offload = (p_param->ParameterData.IntegerData != 0);\r
 \r
        /* Optional: WSDP support. */\r
        RtlInitUnicodeString( &keyword, L"WsdpEnabled" );\r
        NdisReadConfiguration(\r
                &status, &p_param, h_config, &keyword, NdisParameterInteger );\r
        if( status != NDIS_STATUS_SUCCESS )\r
-               p_params->wsdp_enabled = DEF_WSDP_ENABLED;\r
+               p_adapter->params.wsdp_enabled = DEF_WSDP_ENABLED;\r
        else\r
-               p_params->wsdp_enabled = (p_param->ParameterData.IntegerData != 0);\r
+               p_adapter->params.wsdp_enabled = (p_param->ParameterData.IntegerData != 0);\r
 \r
        /* Optional: Static LID assignment if SM is not up. */\r
        RtlInitUnicodeString( &keyword, L"StaticLid" );\r
        NdisReadConfiguration(\r
                &status, &p_param, h_config, &keyword, NdisParameterInteger );\r
        if( status != NDIS_STATUS_SUCCESS )\r
-               p_params->static_lid = DEF_STATIC_LID;\r
+               p_adapter->params.static_lid = DEF_STATIC_LID;\r
        else\r
-               p_params->static_lid = (uint16_t)p_param->ParameterData.IntegerData;\r
+               p_adapter->params.static_lid = (uint16_t)p_param->ParameterData.IntegerData;\r
 \r
        /* Required: SA query timeout, in milliseconds. */\r
        RtlInitUnicodeString( &keyword, L"SaTimeout" );\r
@@ -483,7 +485,7 @@ ipoib_get_adapter_params(
                        ("SA query timeout parameter missing.\n") );\r
                return status;\r
        }\r
-       p_params->sa_timeout = p_param->ParameterData.IntegerData;\r
+       p_adapter->params.sa_timeout = p_param->ParameterData.IntegerData;\r
 \r
        /* Required: SA query retry count. */\r
        RtlInitUnicodeString( &keyword, L"SaRetries" );\r
@@ -495,7 +497,7 @@ ipoib_get_adapter_params(
                        ("SA query retry count parameter missing.\n") );\r
                return status;\r
        }\r
-       p_params->sa_retry_cnt = p_param->ParameterData.IntegerData;\r
+       p_adapter->params.sa_retry_cnt = p_param->ParameterData.IntegerData;\r
 \r
        /* Required: Receive pool to queue depth ratio. */\r
        RtlInitUnicodeString( &keyword, L"RecvRatio" );\r
@@ -507,16 +509,37 @@ ipoib_get_adapter_params(
                        ("Receive pool to queue depth ratio parameter missing.\n") );\r
                return status;\r
        }\r
-       p_params->recv_pool_ratio = p_param->ParameterData.IntegerData;\r
+       p_adapter->params.recv_pool_ratio = p_param->ParameterData.IntegerData;\r
 \r
        /* Required: Receive pool growth threshold. */\r
        RtlInitUnicodeString( &keyword, L"RecvGrowth" );\r
        NdisReadConfiguration(\r
                &status, &p_param, h_config, &keyword, NdisParameterInteger );\r
        if( status != NDIS_STATUS_SUCCESS )\r
-               p_params->recv_growth = DEF_RECV_GROWTH;\r
+               p_adapter->params.recv_growth = DEF_RECV_GROWTH;\r
        else\r
-               p_params->recv_growth = (p_param->ParameterData.IntegerData != 0);\r
+               p_adapter->params.recv_growth = (p_param->ParameterData.IntegerData != 0);\r
+\r
+       NdisReadNetworkAddress( &status, &mac, &len, h_config );\r
+\r
+       ETH_COPY_NETWORK_ADDRESS( p_adapter->params.conf_mac.addr, p_adapter->mac.addr );\r
+       /* If there is a NetworkAddress override in registry, use it */\r
+       if( (status == NDIS_STATUS_SUCCESS) && (len == HW_ADDR_LEN) )\r
+       {\r
+               if( ETH_IS_MULTICAST(mac) || ETH_IS_BROADCAST(mac) ||\r
+                       !ETH_IS_LOCALLY_ADMINISTERED(mac) )\r
+               {\r
+                       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_INIT,\r
+                               ("Overriding NetworkAddress is invalid - "\r
+                               "%02x-%02x-%02x-%02x-%02x-%02x\n",\r
+                               mac[0], mac[1], mac[2],\r
+                               mac[3], mac[4], mac[5]) );\r
+               }\r
+               else\r
+               {\r
+                       ETH_COPY_NETWORK_ADDRESS( p_adapter->params.conf_mac.addr, mac );\r
+               }\r
+       }\r
 \r
        NdisCloseConfiguration( h_config );\r
 \r
@@ -1148,23 +1171,19 @@ ipoib_query_info(
 \r
        /* Required Ethernet operational characteristics */\r
        case OID_802_3_PERMANENT_ADDRESS:\r
-       case OID_802_3_CURRENT_ADDRESS:\r
-#if defined( _DEBUG_ )\r
-               if( oid == OID_802_3_PERMANENT_ADDRESS )\r
-               {\r
-                       IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
-                               ("Port %d received query for OID_802_3_PERMANENT_ADDRESS\n", port_num) );\r
-               }\r
-               else\r
-               {\r
-                       IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
-                               ("Port %d received query for OID_802_3_CURRENT_ADDRESS\n", port_num) );\r
-               }\r
-#endif /* defined( _DEBUG_ )*/\r
+               IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
+                       ("Port %d received query for OID_802_3_PERMANENT_ADDRESS\n", port_num) );\r
                src_buf = &p_adapter->mac;\r
                buf_len = sizeof(p_adapter->mac);\r
                break;\r
 \r
+       case OID_802_3_CURRENT_ADDRESS:\r
+               IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
+                       ("Port %d received query for OID_802_3_CURRENT_ADDRESS\n", port_num) );\r
+               src_buf = &p_adapter->params.conf_mac;\r
+               buf_len = sizeof(p_adapter->params.conf_mac);\r
+               break;\r
+\r
        case OID_802_3_MULTICAST_LIST:\r
                IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
                        ("Port %d received query for OID_802_3_MULTICAST_LIST\n", port_num) );\r
index 0bb9cd5..489ce7e 100644 (file)
@@ -1797,8 +1797,8 @@ __recv_mgr_filter(
                if( p_src )\r
                {\r
                        /* Don't report loopback traffic - we requested SW loopback. */\r
-                       if( !cl_memcmp( &p_port->p_adapter->mac, &p_src->mac,\r
-                               sizeof(p_port->p_adapter->mac) ) )\r
+                       if( !cl_memcmp( &p_port->p_adapter->params.conf_mac,\r
+                               &p_src->mac, sizeof(p_port->p_adapter->params.conf_mac) ) )\r
                        {\r
                                /*\r
                                 * "This is not the packet you're looking for" - don't update\r
@@ -3079,9 +3079,10 @@ __send_mgr_filter_dhcp(
                if( p_cid )\r
                {\r
                        /* do we need to replace it ?  len eq ETH MAC sz 'and' MAC is mine */\r
-                       if( p_cid[1] == HW_ADDR_LEN+1 && !cl_memcmp( &p_cid[3], &p_port->p_adapter->mac.addr, HW_ADDR_LEN  ) )\r
+                       if( p_cid[1] == HW_ADDR_LEN+1 && !cl_memcmp( &p_cid[3],\r
+                               &p_port->p_adapter->params.conf_mac.addr, HW_ADDR_LEN ) )\r
                        {\r
-                                /* Make sure there's room to extend it.  23 is the size of\r
+                               /* Make sure there's room to extend it.  23 is the size of\r
                                 * the CID option for IPoIB.\r
                                 */\r
                                if( buf_len + 23 - p_cid[1] > sizeof(dhcp_pkt_t) )\r
@@ -3093,7 +3094,7 @@ __send_mgr_filter_dhcp(
                                /* Move the existing options down, and add a new CID option */\r
                                len = p_option - ( p_cid + p_cid[1] + 2 );\r
                                p_option = p_cid + p_cid[1] + 2;\r
-                               cl_memcpy ( p_cid, p_option, len );\r
+                               RtlMoveMemory( p_cid, p_option, len );\r
                                \r
                                p_cid += len;\r
                                p_cid[0] = DHCP_OPT_CLIENT_ID;\r
@@ -4047,7 +4048,7 @@ __endpt_mgr_ref(
 \r
        IPOIB_ENTER( IPOIB_DBG_ENDPT );\r
 \r
-       if( !cl_memcmp( &mac, &p_port->p_adapter->mac, sizeof(mac) ) )\r
+       if( !cl_memcmp( &mac, &p_port->p_adapter->params.conf_mac, sizeof(mac) ) )\r
        {\r
                /* Discard loopback traffic. */\r
                IPOIB_PRINT(TRACE_LEVEL_WARNING, IPOIB_DBG_ENDPT,\r
@@ -4499,7 +4500,7 @@ __endpt_mgr_add_local(
 \r
        /* __endpt_mgr_insert expects *one* reference to be held. */\r
        cl_atomic_inc( &p_port->endpt_rdr );\r
-       __endpt_mgr_insert( p_port, p_port->p_adapter->mac, p_endpt );\r
+       __endpt_mgr_insert( p_port, p_port->p_adapter->params.conf_mac, p_endpt );\r
        cl_atomic_dec( &p_port->endpt_rdr );\r
 \r
        p_port->p_local_endpt = p_endpt;\r