[VNIC]Added support for new remote features flags, corrected adapter state change...
authoraestrin <aestrin@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 27 Oct 2006 12:58:59 +0000 (12:58 +0000)
committeraestrin <aestrin@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 27 Oct 2006 12:58:59 +0000 (12:58 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@530 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/inic/kernel/inic.rc
ulp/inic/kernel/vnic_adapter.c
ulp/inic/kernel/vnic_adapter.h
ulp/inic/kernel/vnic_controlpkt.h
ulp/inic/kernel/vnic_data.c
ulp/inic/kernel/vnic_debug.h
ulp/inic/kernel/vnic_driver.c

index c407fe4..93bede1 100644 (file)
@@ -33,7 +33,7 @@
 #include <oib_ver.h>\r
 \r
 #define VER_FILETYPE                           VFT_DRV\r
-#define VER_FILESUBTYPE                                VFT2_UNKNOWN\r
+#define VER_FILESUBTYPE                                VFT2_DRV_NETWORK\r
 \r
 #ifdef _DEBUG_\r
 #define VER_FILEDESCRIPTION_STR                "Virtual Nic NDIS Miniport (Debug)"\r
index 8e6508a..87d98dc 100644 (file)
@@ -179,7 +179,7 @@ vnic_destroy_adapter(
        if( p_adapter->h_pnp )\r
        {\r
                ib_status =\r
-                       p_adapter->ifc.dereg_pnp( p_adapter->h_pnp, ib_sync_destroy );\r
+                       p_adapter->ifc.dereg_pnp( p_adapter->h_pnp, NULL );\r
        }\r
 \r
        vnic_viport_cleanup( p_adapter );\r
@@ -1002,7 +1002,10 @@ vnic_viport_cleanup(
        VNIC_ENTER( VNIC_DBG_ADAPTER );\r
 \r
        if ( p_adapter->p_viport )\r
+       {\r
+               InterlockedExchange( (volatile LONG *)&p_adapter->p_viport->disconnect, TRUE );\r
                viport_cleanup(p_adapter->p_viport );\r
+       }\r
        p_adapter->p_viport = NULL;\r
 \r
        VNIC_EXIT( VNIC_DBG_ADAPTER );\r
index ca271ee..16b1379 100644 (file)
@@ -109,7 +109,6 @@ typedef struct _vnic_adapter {
        LIST_ENTRY                              list_entry;\r
        NDIS_HANDLE                             h_handle;\r
        DEVICE_OBJECT                   *p_pdo;\r
-//     cl_obj_t                                obj;\r
        NDIS_SPIN_LOCK                  lock;\r
        ib_al_ifc_t                             ifc;\r
        ioc_ifc_data_t                  ifc_data;\r
@@ -135,7 +134,6 @@ typedef struct _vnic_adapter {
        uint32_t                                packet_filter;\r
        int                                             hung;\r
        BOOLEAN                                 reset;\r
-       //BOOLEAN                                       pending_set;\r
        int                                             pending_set;\r
        BOOLEAN                                 pending_query;\r
        pending_oid_t                   query_oid;\r
index 378d792..2c8b430 100644 (file)
 #define _VNIC_CONTROLPKT_H_\r
 \r
 #include <complib/cl_packon.h>\r
+#define MAX_HOST_NAME_SIZE     64\r
+\r
 typedef struct Inic_ConnectionData {\r
        uint64_t        pathId;\r
        uint8_t         inicInstance;\r
        uint8_t         pathNum;\r
-       uint8_t         nodename[65];\r
+       uint8_t         nodename[MAX_HOST_NAME_SIZE+1];\r
        uint8_t         reserved;\r
        uint32_t        featuresSupported;\r
 } Inic_ConnectionData_t;\r
@@ -281,4 +283,4 @@ typedef struct _mac_addr
 */\r
 #include <complib/cl_packoff.h>\r
 \r
-#endif /* _VNIC_CONTROLPKT_H_ */
\ No newline at end of file
+#endif /* _VNIC_CONTROLPKT_H_ */\r
index fed40da..3c9196c 100644 (file)
@@ -980,6 +980,12 @@ data_rdmaPacket(
        }\r
        pWrq->send_opt = IB_SEND_OPT_SIGNALED;\r
 \r
+       if( pData->p_viport->featuresSupported & INIC_FEAT_RDMA_IMMED )\r
+       {\r
+               pWrq->send_opt |= IB_SEND_OPT_IMMEDIATE;\r
+               pWrq->immediate_data = 0;\r
+       }\r
+\r
        if( ibqp_postSend( &pData->qp, &pRdmaIo->io ) != IB_SUCCESS )\r
        {\r
                VNIC_TRACE(VNIC_DBG_ERROR,\r
@@ -1040,7 +1046,8 @@ _data_recv_to_ndis_pkt(
        NdisChainBufferAtFront( p_packet, pRdmaDest->p_buf );\r
        pRdmaDest->p_packet = p_packet;\r
 \r
-       if ( pTrailer->pktFlags & PF_VLAN_INSERT )\r
+       if ( pTrailer->pktFlags & PF_VLAN_INSERT &&\r
+               !( pData->p_viport->featuresSupported & INIC_FEAT_IGNORE_VLAN ) )\r
        {\r
                /*      TODO:\r
                 *      add OID_GEN_VLAN_ID\r
index bb8b6b9..37b2252 100644 (file)
@@ -66,7 +66,7 @@ extern uint32_t               g_vnic_dbg_lvl;
 #define VNIC_DBG_ERROR         CL_DBG_ERROR\r
 #define VNIC_DBG_ALL           CL_DBG_ALL\r
 \r
-#define VNIC_DEBUG_FLAGS ( VNIC_DBG_ERROR | VNIC_DBG_WARN |    VNIC_DBG_INFO )\r
+#define VNIC_DEBUG_FLAGS ( VNIC_DBG_ERROR | VNIC_DBG_WARN )\r
 /* Enter and exit macros automatically add VNIC_DBG_FUNC bit */\r
 #define VNIC_ENTER( lvl )      \\r
        CL_ENTER( (lvl | VNIC_DBG_FUNC), g_vnic_dbg_lvl )\r
index e9b0678..8ea0aad 100644 (file)
@@ -394,6 +394,13 @@ vnic_oid_query_info(
        src_buf = &info32;\r
        buf_len = sizeof(info32);\r
 \r
+       if( !p_adapter->p_viport ||\r
+               !p_adapter->p_currentPath->carrier )\r
+       {\r
+               status = NDIS_STATUS_NOT_ACCEPTED;\r
+               goto complete;\r
+       }\r
+\r
        switch( oid )\r
        {\r
        /* Required General */\r
@@ -463,12 +470,7 @@ vnic_oid_query_info(
                        ("received query for OID_GEN_TRANSMIT_BUFFER_SPACE\n") );\r
                if ( !p_adapter->p_currentPath->carrier )\r
                {\r
-                       p_adapter->pending_query = TRUE;\r
-                       p_adapter->query_oid = oid_info;\r
-\r
-                       VNIC_TRACE( VNIC_DBG_OID,\r
-                               ("returning NDIS_STATUS_PENDING\n") );\r
-                       status = NDIS_STATUS_PENDING;\r
+                       status= NDIS_STATUS_NOT_ACCEPTED;\r
                }\r
                else\r
                {\r
@@ -483,12 +485,7 @@ vnic_oid_query_info(
                        "or OID_GEN_RECEIVE_BUFFER_SPACE\n") );\r
                if ( !p_adapter->p_currentPath->carrier )\r
                {\r
-                       p_adapter->pending_query = TRUE;\r
-                       p_adapter->query_oid = oid_info;\r
-\r
-                       VNIC_TRACE( VNIC_DBG_OID,\r
-                               ("returning NDIS_STATUS_PENDING\n") );\r
-                       status = NDIS_STATUS_PENDING;\r
+                       status = NDIS_STATUS_NOT_ACCEPTED;\r
                }\r
                else\r
                {\r
@@ -662,7 +659,6 @@ vnic_oid_query_info(
                VNIC_TRACE( VNIC_DBG_OID,\r
                        ("  received query for OID_GEN_RCV_NO_BUFFER\n" ) );\r
                info32 = 0;\r
-               status = NDIS_STATUS_SUCCESS;\r
                break;\r
 \r
        case OID_GEN_DIRECTED_BYTES_XMIT:\r
@@ -806,7 +802,6 @@ vnic_oid_query_info(
                {\r
                        info32 = 0;\r
                }\r
-\r
                else\r
                {\r
                info64 = p_adapter->p_viport->stats.ifInMulticastPkts;\r
@@ -860,6 +855,13 @@ vnic_oid_query_info(
                                ("  received query for OID_802_3_CURRENT_ADDRESS\n" ) );\r
                }\r
 #endif /* defined( _DEBUG_ )*/\r
+               if( !p_adapter->p_viport ||\r
+                       p_adapter->p_viport->errored ||\r
+                       p_adapter->p_viport->disconnect )\r
+               {\r
+                       status = NDIS_STATUS_NOT_ACCEPTED;\r
+                       break;\r
+               }\r
                if ( !p_adapter->macSet )\r
                {\r
                        p_adapter->pending_query = TRUE;\r
@@ -981,6 +983,7 @@ vnic_oid_query_info(
         * Note that this requires the QueryInformation entry point to always\r
         * return NDIS_STATUS_PENDING\r
         */\r
+complete:\r
        if( status != NDIS_STATUS_PENDING )\r
        {\r
                _vnic_complete_query(\r
@@ -1482,13 +1485,11 @@ vnic_send_packets(
        IN                              UINT                                            num_packets )\r
 {\r
        vnic_adapter_t*  const  p_adapter =(vnic_adapter_t* const )adapter_context;\r
-       viport_t                        *p_viport = p_adapter->p_viport;\r
        UINT                            packet_num;\r
 \r
        VNIC_ENTER( VNIC_DBG_SEND );\r
 \r
        CL_ASSERT( adapter_context );\r
-       CL_ASSERT( p_viport );\r
 \r
        for( packet_num = 0; packet_num < num_packets; ++packet_num )\r
        {\r
@@ -1629,6 +1630,13 @@ vnic_resume_oids(
         * Set the status depending on our state.  Fail OID requests that\r
         * are pending while we reset the adapter.\r
         */\r
+       if( !p_adapter->p_viport ||\r
+               p_adapter->p_viport->disconnect == TRUE ||\r
+               p_adapter->p_viport->errored == TRUE )\r
+       {\r
+               status = NDIS_STATUS_NOT_ACCEPTED;\r
+       }\r
+\r
        switch( p_adapter->pnp_state )\r
        {\r
        case IB_PNP_IOC_ADD:\r
@@ -1662,7 +1670,10 @@ vnic_resume_oids(
                {\r
                case OID_802_3_CURRENT_ADDRESS:\r
                case OID_802_3_PERMANENT_ADDRESS:\r
-                       cl_memcpy( mac, p_adapter->p_viport->hwMacAddress, HW_ADDR_LEN );\r
+                       if ( status == NDIS_STATUS_SUCCESS )\r
+                       {\r
+                               cl_memcpy( mac, p_adapter->p_viport->hwMacAddress, HW_ADDR_LEN );\r
+                       }\r
                        _vnic_complete_query( p_adapter,\r
                                                        &query_oid,\r
                                                        status,\r
@@ -1852,40 +1863,33 @@ _vnic_process_packet_filter(
 \r
        ASSERT( (p_adapter->p_viport->updates & ~MCAST_OVERFLOW) == 0 );\r
 \r
-       if( pkt_filter == 0 )\r
-       {       /* gateway will disable forwarding for associated viport */\r
-               p_adapter->p_viport->newFlags &= ~INIC_FLAG_ENABLE_NIC;\r
+       if( !( p_adapter->p_viport->flags & INIC_FLAG_ENABLE_NIC ) )\r
+       {\r
+               p_adapter->p_viport->newFlags &= ~INIC_FLAG_DISABLE_NIC;\r
+               p_adapter->p_viport->newFlags |= INIC_FLAG_ENABLE_NIC;\r
                InterlockedOr( &p_adapter->p_viport->updates, NEED_LINK_CONFIG );\r
        }\r
-       else\r
-       {\r
-               if( !( p_adapter->p_viport->flags & INIC_FLAG_ENABLE_NIC ) )\r
-               {\r
-                       p_adapter->p_viport->newFlags &= ~INIC_FLAG_DISABLE_NIC;\r
-                       p_adapter->p_viport->newFlags |= INIC_FLAG_ENABLE_NIC;\r
-                       InterlockedOr( &p_adapter->p_viport->updates, NEED_LINK_CONFIG );\r
-               }\r
 \r
-               if( pkt_filter & NDIS_PACKET_TYPE_ALL_MULTICAST )\r
+       if( pkt_filter & NDIS_PACKET_TYPE_ALL_MULTICAST )\r
+       {\r
+               if( !( p_adapter->p_viport->flags & INIC_FLAG_ENABLE_MCAST_ALL ) )\r
                {\r
-                       if( !( p_adapter->p_viport->flags & INIC_FLAG_ENABLE_MCAST_ALL ) )\r
-                       {\r
-                               p_adapter->p_viport->newFlags |= INIC_FLAG_ENABLE_MCAST_ALL;\r
-                               // TODO: Shouldn't MCAST_OVERFLOW be a flag bit, not an update bit?\r
-                               InterlockedOr( &p_adapter->p_viport->updates,\r
+                       p_adapter->p_viport->newFlags |= INIC_FLAG_ENABLE_MCAST_ALL;\r
+                       // TODO: Shouldn't MCAST_OVERFLOW be a flag bit, not an update bit?\r
+                       InterlockedOr( &p_adapter->p_viport->updates,\r
                                NEED_LINK_CONFIG | MCAST_OVERFLOW );\r
-                       }\r
                }\r
+       }\r
 \r
-               if ( pkt_filter & NDIS_PACKET_TYPE_PROMISCUOUS )\r
+       if ( pkt_filter & NDIS_PACKET_TYPE_PROMISCUOUS )\r
+       {\r
+               if( !( p_adapter->p_viport->flags & INIC_FLAG_ENABLE_PROMISC ) )\r
                {\r
-                       if( !( p_adapter->p_viport->flags & INIC_FLAG_ENABLE_PROMISC ) )\r
-                       {\r
-                               p_adapter->p_viport->newFlags |= INIC_FLAG_ENABLE_PROMISC;\r
-                               InterlockedOr( &p_adapter->p_viport->updates, NEED_LINK_CONFIG );\r
-                       }\r
+                       p_adapter->p_viport->newFlags |= INIC_FLAG_ENABLE_PROMISC;\r
+                       InterlockedOr( &p_adapter->p_viport->updates, NEED_LINK_CONFIG );\r
                }\r
        }\r
+\r
        /* ENABLE NIC, BROADCAST and MULTICAST flags set on start */\r
 \r
        ++p_adapter->pending_set;\r