WO2001027781A2 - Low latency, high bandwidth multi-computer system interconnect - Google Patents

Low latency, high bandwidth multi-computer system interconnect Download PDF

Info

Publication number
WO2001027781A2
WO2001027781A2 PCT/US2000/026728 US0026728W WO0127781A2 WO 2001027781 A2 WO2001027781 A2 WO 2001027781A2 US 0026728 W US0026728 W US 0026728W WO 0127781 A2 WO0127781 A2 WO 0127781A2
Authority
WO
WIPO (PCT)
Prior art keywords
gt
set
status
padapter
data
Prior art date
Application number
PCT/US2000/026728
Other languages
French (fr)
Other versions
WO2001027781A9 (en
WO2001027781A3 (en
Inventor
Vince Bridgers
Original Assignee
Times N Systems, Inc.
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority to US15908699P priority Critical
Priority to US60/159,086 priority
Priority to US67290900A priority
Priority to US09/672,909 priority
Application filed by Times N Systems, Inc. filed Critical Times N Systems, Inc.
Publication of WO2001027781A2 publication Critical patent/WO2001027781A2/en
Publication of WO2001027781A3 publication Critical patent/WO2001027781A3/en
Publication of WO2001027781A9 publication Critical patent/WO2001027781A9/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L29/00Arrangements, apparatus, circuits or systems, not covered by a single one of groups H04L1/00 - H04L27/00
    • H04L29/02Communication control; Communication processing
    • H04L29/06Communication control; Communication processing characterised by a protocol

Abstract

Methods, systems and devices are described for a low latency, high bandwidth multi-computer system interconnect. A method includes passing a set of interconnect fabric data through a shim layer (420, 450) that is interposed between an interconnect fabric interface layer (410, 440) and a protocol layer (430, 460) including: receiving said set of interconnect fabric data with said shim layer (420, 450), classifying said set of interconnect fabric data with said shim layer (420, 450), and handling said set of interconnect fabric data with said shim layer (420, 450) as a function of a transport application program interface (435, 465) with which said set of interconnect fabric data is associated. The methods, systems and devices provide advantages because the speed and scalability of parallel processor systems is enhanced.

Description

LOW LATENCY, HIGH BANDWIDTH MULTI-COMPUTER SYSTEM

INTERCONNECT

REFERENCE TO APPENDIX An appendix is included in this application by way of attachment, the totality of which is hereby incorporated by reference as an integral part of this application. The appendix includes printed source code that is discussed below in more detail as a nonlimiting example of the invention.

BACKGROUND OF THE INVENTION 1. Field of the Invention

The invention relates generally to the field of computer systems which have multiple processing nodes and in which each processing node is provided with private, local memory and also in which each processing node has access to a range of memory which is shared with other processing nodes. More particularly, the invention relates to computer science techniques that utilize a low latency, high bandwidth multi-computer system interconnect. 2. Discussion of the Related Art

The clustering of workstations is a well-known art. In the most common cases, the clustering involves workstations that operate almost totally independently, utilizing the network only to share such services as a printer, license-limited applications, or shared files. In more-closely-coupled environments, some software packages (such as

NQS) allow a cluster of workstations to share work. In such cases the work arrives, typically as batch jobs, at an entry point to the cluster where it is queued and dispatched to the workstations on the basis of load.

In both of these cases, and all other known cases of clustering, the operating system and cluster subsystem are built around the concept of message-passing. The term message-passing means that a given workstation operates on some portion of a job until communications (to send or receive data, typically) with another workstation is necessary. Then, the first workstation prepares and communicates with the other workstation. Another well-known art is that of clustering processors within a machine, usually called a Massively Parallel Processor or MPP, in which the techniques are essentially identical to those of clustered workstations. Usually, the bandwidth and latency of the interconnect network of an MPP are more highly optimized, but the system operation is the same. In the general case, the passing of a message is an extremely expensive operation; expensive in the sense that many CPU cycles in the sender and receiver are consumed by the process of sending, receiving, bracketing, verifying, and routing the message, CPU cycles that are therefore not available for other operations. A highly streamlined message-passing subsystem can typically require 10,000 to 20,000 CPU cycles or more.

There are specific cases wherein the passing of a message requires significantly less overhead. However, none of these specific cases is adaptable to a general-purpose computer system.

Message-passing parallel processor systems have been offered commercially for years but have failed to capture significant market share because of poor performance and difficulty of programming for typical parallel applications. Message-passing parallel processor systems do have some advantages. In particular, because they share no resources, message-passing parallel processor systems are easier to provide with high-availability features. What is needed is a better approach to parallel processor systems.

There are alternatives to the passing of messages for closely-coupled cluster work. One such alternative is the use of shared memory for inter- processor communication.

Shared-memory systems, have been much more successful at capturing market share than message-passing systems because of the dramatically superior performance of shared-memory systems, up to about four-processor systems. In Search of Clusters, Gregory F. Pfister 2nd ed. (January 1998) Prentice Hall Computer Books, ISBN: 0138997098 describes a computing system with multiple processing nodes in which each processing node is provided with private, local memory and also has access to a range of memory which is shared with other processing nodes. The disclosure of this publication in its entirety is hereby expressly incoφorated herein by reference for the purpose of indicating the background of the invention and illustrating the state of the art.

However, providing high availability for traditional shared-memory systems has proved to be an elusive goal. The nature of these systems, which share all code and all data, including that data which controls the shared operating systems, is incompatible with the separation normally required for high availability. What is needed is an approach to shared-memory systems that improves availability.

Although the use of shared memory for inter-processor communication is a well-known art, prior to the teachings of U.S. Ser. No. 09/273,430, filed

March 19, 1999, entitled Shared Memory Apparatus and Method for Multiprocessing Systems, the processors shared a single copy of the operating system. The problem with such systems is that they cannot be efficiently scaled beyond four to eight way systems except in unusual circumstances. All known cases of said unusual circumstances are such that the systems are not good price-performance systems for general-purpose computing.

The entire contents of U.S. Patent Applications 09/273,430, filed March 19, 1999 and PCT/US00/01262, filed January 18, 2000 are hereby expressly incoφorated by reference herein for all puφoses. U.S. Ser. No. 09/273,430, improved upon the concept of shared memory by teaching the concept which will herein be referred to as a tight cluster. The concept of a tight cluster is that of individual computers, each with its own CPU(s), memory, I/O, and operating system, but for which collection of computers there is a portion of memory which is shared by all the computers and via which they can exchange information. U.S. Ser. No. 09/273,430 describes a system in which each processing node is provided with its own private copy of an operating system and in which the connection to shared memory is via a standard bus. The advantage of a tight cluster in comparison to an SMP is "scalability" which means that a much larger number of computers can be attached together via a tight cluster than an SMP with little loss of processing efficiency.

What is needed are improvements to the concept of the tight cluster. What is also needed is an expansion of the concept of the tight cluster. SUMMARY OF THE INVENTION A goal of the invention is to simultaneously satisfy the above-discussed requirements of improving and expanding the tight cluster concept which, in the case of the prior art, are not satisfied. One embodiment of the invention is based on a method comprising: passing a set of interconnect fabric data through a shim layer that is inteφosed between an interconnect fabric interface layer and a protocol layer including: receiving said set of interconnect fabric data with said shim layer, classifying said set of interconnect fabric data with said shim layer, and handling said set of interconnect fabric data with said shim layer as a function of a transport application program interface with which said set of interconnect fabric data is associated. Another embodiment of the invention is based on an apparatus, comprising: a shared memory unit; a first system coupled to said shared memory unit; and a second system coupled to said shared memory unit, wherein a data set transfered between said shared memory unit and at least one member selected from the group consisiting of said first system and said second system is received by a shim that is inteφosed between either i) a network device/driver and a protocol layer or ii) an interconnect fabric interface and said protocol layer, classified by said shim and handled by said shim as a function of a transport application program interface with which said data set is associated.

Another embodiment of the invention is based on an apparatus comprising: a switch; a first system coupled to said switch; and a second system node coupled to said switch, wherein a data set transfered from said first system to said second system through said switch is received by a shim that is inteφosed between either i) a network device/driver and a protocol layer or ii) an interconnect fabric interface and said protocol layer, classified by said shim and handled by said shim as a function of a transport application program interface with which said data set is associated.

These, and other, aspects of the present invention will be better appreciated and understood when considered in conjunction with the following description and the accompanying drawings. It should be understood, however, that the following description, while indicating preferred embodiments of the present invention and numerous specific details thereof, is given by way of illustration and not of limitation. Many changes and modifications may be made within the scope of the present invention without departing from the spirit thereof, and the invention includes all such modifications.

BRIEF DESCRIPTION OF THE DRAWINGS

A clear conception of the advantages and features constituting the present invention, and of the components and operation of model systems provided with the present invention, will become more readily apparent by referring to the exemplary, and therefore nonlimiting, embodiments illustrated in the drawings accompanying and forming a part of this specification, wherein like reference numerals designate the same elements. It should be noted that the features illustrated in the drawings are not necessarily drawn to scale.

FIG. 1 illustrates a block schematic diagram of a network, representing an embodiment of the invention. FIG. 2 illustrates a schematic diagram of a system architecture including a network switch, representing an embodiment of the invention.

FIG. 3 illustrates a block schematic diagram of a system architecture including a dedicated shared memory node device, representing an embodiment of the invention. FIG. 4 illustrates a block schematic diagram of an interconnect fabric, representing an embodiment of the invention.

DESCRIPTION OF PREFERRED EMBODIMENTS The present invention and the various features and advantageous details thereof are explained more fully with reference to the nonlimiting embodiments that are illustrated in the accompanying drawings and detailed in the following description. Descriptions of well known components and processing techniques are omitted so as not to unnecessarily obscure the present invention in detail. The teachings of U.S. Ser. No. 09/273,430 include a system which is a single entity; one large supercomputer. The invention is also applicable to a cluster of workstations, or even a network.

The invention is applicable to systems of the type of Pfister or the type of U.S. Ser. No. 09/273,430 in which each processing node has its own copy of an operating system. The invention is also applicable to other types of multiple processing node systems; even an interconnect fabric such as, for example, Infiniband.

The invention can be combined with a tight cluster as described in U.S. Ser. No. 09/273,430. A tight cluster is defined as a cluster of workstations or an arrangement within a single, multiple-processor machine in which the processors are connected by a high-speed, low-latency interconnection, and in which some but not all memory is shared among the processors. Within the scope of a given processor, accesses to a first set of ranges of memory addresses will be to local, private memory but accesses to a second set of memory address ranges will be to shared memory. The significant advantage to a tight cluster in comparison to a message-passing cluster is that, assuming the environment has been appropriately established, the exchange of information involves a single STORE instruction by the sending processor and a subsequent single LOAD instruction by the receiving processor.

The establishment of the environment, taught by U.S. Ser. No. 09/273,430 and more fully by companion disclosures (U.S. Provisional Application Ser. No. 60/220,794, filed July 26, 2000; U.S. Provisional Application Ser. No. 60/220,748, filed July 26, 2000; WSGR 15245-711; WSGR 15245-712; WSGR 15245-713; WSGR 15245-715; WSGR 15245-716;

WSGR 15245-717; WSGR 15245-718; WSGR 15245-719; WSGR 15245-720, the entire contents of all which are hereby expressly incoφorated herein by reference for all puφoses) can be performed in such a way as to require relatively little system overhead, and to be done once for many, many information exchanges. Therefore, a comparison of 10,000 instructions for message-passing to a pair of instructions for tight-clustering, is valid.

The invention can include systems software to implement a low latency, high bandwidth multi-computer using existing readily commercially available commodity computer hardware and network devices. The invention can include a method to implement system software support for harnessing multiple, independent compute nodes using existing readily commercially available systems and network equipment or an interconnect fabric.

In general, the invention can include the use of a network driver shim between a network driver layer, and a protocol software layer. The shim passes packets from the protocol software layer through to the network driver layer. Similarly, packets received from the network driver layer side are passed up to the protocol software layer. A particular packet type identification can be used to decide how to handle received packets. As an example, in the case of the TCP/IP protocol, the Ethernet type identifier is 0x80-0x00, and is used by the shim to decide to pass the packet up to the protocol software layer for proper handling. In the case of low-latency packets taught by this invention, the shim can decide how best to handle the packet. The invention can include transformation of a data set. For some cases, the shim can also implement a lightweight protocol in order to recover from errors encountered on the network media (such as CRC errors, hung network controllers, dropped packets, buffer errors, etc.). The advantages of the invention include improved cost/performance over existing proprietary solutions.

The shim can expose an API (application program interface) for transport middle-ware to use in order to transmit packets, obtain information on local and remote multi-computer nodes, to setup packet receive sinks, and to control the lightweight protocol. Fault tolerance can be achieved by ganging multiple network interface cards in a single system, and either duplicating traffic over multiple network interface cards in a single system, or failing over when a failed NIC or system is detected. Fast recovery methods can be implemented by using network cards which give media sense interrupt indications, or by using relatively frequent "heartbeat" packets across the media. Referring to FIG. 1, the invention can be implemented in the context of a network. A first network device/driver 110 is coupled to a network 100. A first shim 120 is coupled to the first network device/driver 110. A first protocol layer 130 is coupled to the first shim 120. The first shim 120 and the first protocol layer 130 can both interface with a first transport application program interface (API) 135.

Still referring to FIG. 1, a second network device/driver 140 is coupled to the network 100. A second shim 150 is coupled to the second network device/driver 140. A second protocol layer 160 is coupled to the second shim 150. The second shim 150 and the second protocol layer 160 can both interface with a second transport API 165.

The shims 120, 150 permit handling of data (e.g., routing and/or transformation) based on the type of data and/or the type of application associated with the transport APIs 135 and 165. The transport APIs may be for the same, or different, applications.

Referring to FIGS. 2-3, different types of system interconnects may be used. One example is the use of a true peer-to-peer interconnect through a network interconnect fabric (such as network switch). FIG. 2 depicts this arrangement. A system 0, a system 1, a system 2 and a system n-1 are all coupled to a network swich 200. System-to-system communication is accomplished through network communication provided by the network interface cards, media and network communications devices in the network. Another system architecture that makes use of this capability is comprised of multiple compute nodes interconnected through a dedicated shared memory device. This model utilizes a "load-store" approach to remote memory access rather than message passing. This method reduces the cost associated with using a network communications switching fabric, and provides each system with a low latency, high bandwidth path to memory that is accessible by each compute node present in a particular configuration. An example of such a system structure is depicted in FIG. 3. In this embodiment, the system 0, the system 1, the system 2 and the system n-1 are all coupled to a dedicated shared memory node device 300. The dedicated shared memory node device may be RAM and/or a disk. The system architecture of the invention may be used to implement any or all of the following subsystems:

1. Network access through shared memory.

2. A shared memory disk, where each system's backing store may be cached, and available in the dedicated shared memory node device. 3. Locking primitives for controlled access to shared regions of memory.

Having a portion of shared memory common to each system allows each of the individual systems to have access to their own memory without the normal overhead of cache coherency mechanisms usually used for tightly- coupled, shared memory multiprocessor systems.

Referring to FIG. 4, the invention can be implemented in the context of an interconnect fabric. A first interconnect fabric interface 410 is coupled to an interconnect fabric 400. A first shim 420 is coupled to the first interconnect fabric interface 410. A first protocol layer 430 is coupled to the first shim 420. The first shim 420 and the first protocol layer 430 can both interface with a first transport application program interface (API) 435.

Still referring to FIG. 4, a second interconnect fabric interface 440 is coupled to the network 400. A second shim 450 is coupled to the second interconnect fabric interface 440. A second protocol layer 460 is coupled to the second shim 450. The second shim 450 and the second protocol layer 460 can both interface with a second transport API 465.

Again, the shims 420, 450 permit handling of data (e.g., routing and/or transformation) based on the type of data and/or the type of application associated with the transport APIs 435 and 465. Again, the transport APIs may be for the same, or different, applications.

The context of the invention can include multi-computing. The context of the invention can include fault tolerance. The context of the invention can include shared-system network access. The context of the invention can include a shared network. The invention can include a network driver shim. The context of the invention can include an interconnect fabric, such as, for example, Infiniband.

The invention is an improvement over current clustering implementations in that traffic is intercepted and acted upon at the network device driver layer, and sent at the network device driver layer, and the invention also allows existing communication protocols to still use the same media. This provides a cost/performance benefit to the end customer. This invention can be primarily systems software. Hardware accelerations can be applied by selecting network interface cards, which provide programmable packet type identification, and automatic media sense detection indications.

The invention can be implemented in the context of an ethernet network. The ethernet can be connected to each of a plurality of PC machines by a NIC card (network interface card) inside each PC. A NIC has its own required appllication interface (API). NIC's are intended to pass messages between PC's. These messages tend to be somewhat long and somewhat infrequent, so are not well suited for shared memory, which is why the preferred design does not use

NIC's . Additionally, they tend to be very simple, which means that more processing is required in the software.

The invention can include a device driver which presents an API to the OS and also does all of the processing NICs require. The invention can then also present the data to the NIC using its require API (the "transport API"). The invention permit a shared-memory machine to be run over a standard network, albeit slower than the machine disclosed in U.S. Ser. No. 09/273,430. Certain applications may not have many LOADS and STORES to shared memory, in which case they will run about as well over a standard set of PC's with industry standard network interconnections as they will on the hardware disclosed in

U.S. Ser. No. 09/273,430.

The invention can also be implemented in the context of an interconnect fabric where a separate processor with some of its own memory is provided on a NIC. An example of an appropriate interconnect fabric is Infiniband. In this way, a much simpler method can be defined by which a main processor, when it needs to send or receive some data, just presents a special, short descriptor to the processor on the NIC and lets this NIC processor actually GET or PUT the data.

While not being limited to any particular performance indicator or diagnostic identifier, preferred embodiments of the invention can be identified one at a time by testing for the substantially highest performance. The test for the substantially highest performance can be carried out without undue experimentation by the use of a simple and conventional benchmark (speed) experiment. The term substantially, as used herein, is defined as at least approaching a given state (e.g., preferably within 10% of, more preferably within 1% of, and most preferably within 0.1% of). The term coupled, as used herein, is defined as connected, although not necessarily directly, and not necessarily mechanically. The term means, as used herein, is defined as hardware, firmware and/or software for achieving a result. The term program or phrase computer program, as used herein, is defined as a sequence of instructions designed for execution on a computer system. A program may include a subroutine, a function, a procedure, an object method, an object implementation, an executable application, an applet, a servlet, a source code, an object code, and/or other sequence of instructions designed for execution on a computer system.

EXAMPLE A specific embodiment of the present invention will now be further described by the following, nonlimiting example which will serve to illustrate in some detail various features of significance. The example is intended merely to facilitate an understanding of ways in which the present invention may be practiced and to further enable those of skill in the art to practice the present invention. Accordingly, the examples should not be construed as limiting the scope of the present invention.

The printed source code attached to this invention disclosure is an example of how this invention would be implemented on Windows NT 4.0 and an Intel or Intel compatible processor based personal computer, using the NDIS intermediate driver model. This example is intended to be exemplary, and does not preclude an implementation on a different system, operating system, or type of network. This example also does not exclude hardware accelerations for network controllers to enhance the capability of that controller for this application. A description of the attached software modules follows (this description is in the order that the files are presented in the appendix): 1. D:\nt4ddk\src\timesn\tnsdrvr\sources - A makefile description for creating the binary image.

2. D:\nt4ddk\src\timesn\tnsdrvr\tnsemul.rc - A file for describing the resource information to be embedded in the binary image.

3. D:\nt4ddk\arc\timesn\tnsdrvr\tnsemul.def - A file for describing the exported functions of the final binary image.

4. D:\nt4ddk\src\times\tnsdrvr\tnsif.h - Describes the constants and structures needed for an application to interface directly with the loaded, executing, binary image. 5. D:\nt4ddk\src\timesn\tnsdrvr\tnsdef.h - Times N Systems Specific macros and constants.

6. D:\nt4ddk\src\timesn\tnsdrvr\tnsdebug.h - Header file for describing function prototypes. Constants, structures, and macros needed for using debug services.

7. D:\nt4ddk\src\timesn\tnsdrvr\tnsapi.h - Header file for describing the exported Times N Systems services for emulating a high-speed interconnect.

8. D:\nt4ddk\src\timesn\tnsdrvr\tns.h - Structures, function prototypes, constants, and macros for the module in whole, including managing the object context, and interfacing to an existing, commodity network interface device.

9. D:\nt4ddk\src\timesn\tnsdrvr\tnsdebug.c - Debug services

10. D:\nt4ddk\src\timesn\tnsdrvr\tnsapi.c - Implementations for the Times N Systems application programming interfaces for an emulated high-speed interconnect. 11. D:\nt4ddk\src\timesn\tnsdrvr\tnsemul.c - Main initialization file, Driver entry, relatively infrequently used functions

12. D:\nt4ddk\src\timesn\tnsdrvr\recv.c - Receive packet processing, including high-speed interconnect transport processing

13. D :\nt4ddk\src\timesn\tnsdrvr\send.c -Send packet processing 1. D:\nt4ddk\src\timesn\tnsclien\tnsclien.h - Client driver header file

2. D:\nt4ddk\src\timesn\tnsclien\tnsclient.c - Client driver implementation

(an example of how interconnect transport services would be used).

An experimental system was prototyped using lOOMbit/sec full and half- duplex network equipment, and gave very good throughput numbers. Practical Applications of the Invention

A practical application of the invention that has value within the technological arts is waveform transformation. Further, the invention is useful in conjunction with data input and transformation (such as are used for the puφose of speech recognition), or in conjunction with transforming the appearance of a display (such as are used for the puφose of video games), or the like. There are virtually innumerable uses for the invention, all of which need not be detailed here. Advantages of the Invention A system, representing an embodiment of the invention, can be cost effective and advantageous for at least the following reasons. The invention improves the speed of parallel computing systems. The invention improves the scalability of parallel computing systems. The invention improves the overall system throughput for a system multi-computer implementation.

All the disclosed embodiments of the invention described herein can be realized and practiced without undue experimentation. Although the best mode of carrying out the invention contemplated by the inventor is disclosed above, practice of the invention is not limited thereto. Accordingly, it will be appreciated by those skilled in the art that the invention may be practiced otherwise than as specifically described herein.

For example, although the low latency, high bandwidth multi-computer system interconnect described herein can be a separate module, it will be manifest that the low latency, high bandwidth multi-computer system interconnect may be integrated into the system with which it is associated. Furthermore, all the disclosed elements and features of each disclosed embodiment can be combined with, or substituted for, the disclosed elements and features of every other disclosed embodiment except where such elements or features are mutually exclusive.

It will be manifest that various additions, modifications and rearrangements of the features of the invention may be made without deviating from the spirit and scope of the underlying inventive concept. It is intended that the scope of the invention as defined by the appended claims and their equivalents cover all such additions, modifications, and rearrangements.

The appended claims are not to be inteφreted as including means-plus- function limitations, unless such a limitation is explicitly recited in a given claim using the phrase "means for." Expedient embodiments of the invention are differentiated by the appended subclaims. Ap cb

File: D:\nt4DDK\src\timeen\tnsdrvr\so-jrces Page 1 of 1

1 ! IF 0

2 Copyright (c) 1989-1993 Microsoft Corporation 3

4 Module Name:

5 sources. 6

7 Abstract:

8 This file specifies the target component being built and the list of

9 sources files needed to build that component. Also specifies optional

10 compiler switches and libraries that are unique for the component being

11 built.

12 IENDIF 13

14 MAJORCOMP-ntos

15 MINORCOMP-ndis 16

17 TARGETNAME-tnsemul

18 TARGETTYPE-EXPORT_DRIVER

19 TARGETPATH-S(BASEDlR)\lib 20

21 TARGET IBS=S(BASEDIR)\lib\*\$(DDKBUILDENV)\ndis.lib

22

23 INC UDES-$ (BASEDIR) \inc; $ (BASEDIR) \src\network\inc; .. Unc

24

25 C_DEFINES-$ (C_DEFINES ) -DNDIS_MIN1P0RT_DRIVER

26 C_DEFINES=$ (C_DEFINES ) -DNDIS40

27 C DEFINES=$ (C_DEFINES ) -DNDIS40_MINIPORT

28 C~DEFINES-$ (C_DEFINES ) -DBINARΪ_COMPATIBLE=0 29

30 MSC_WARNING_ EVE -/W3 / X

31

32 SOURCES-tnsemul . c \

33 recv.c \

34 send.c \

35 tnsapi.c \

36 tnsdebug.c \

37 tnse ul . e

38

39

Prtnta«ι by CRISP VB-2-1. 9:04 am Thursday. 30 September 1999

File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.rc Page 1 of 1

1 #include <windows.h>

2 Iinclude <ntverp.h> 3

4 /. ./

5 /* the following lines are specific to this file */

6 /. ./

7

8 /* VER FILETYPE, VER_FILESUBTYPE, VER_FILEDESCRIPTION_STR

9 * and~VER_INTERNALNAME_STR must be defined before including COMMON.VER

10 * The strings don't need a '\0', since common.ver has them.

11 */

12 #define VER FILETYPE VFT_DRV

13 #define VER~FILESUBTYPE VFT2_DRV NETWORK

14 #define VER~FILEDESCRIPTION_STR ~~ "Times N Systems Emulation Layer"

15 #define VER_INTERNALNAME_STR "TNSEMUL.SYS" 16

17 ((include "common.ver"

18

19 #include "evtmsg.rc" printed CRISP vβ-2.ι. g:Oi am Thursday, 30 September 1 999

File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.def Page 1 of 1

1 ; DEF File for TNSEMUL.SYS

2

3 NAME TNSEMUL.SYS

4

5 DESCRIPTION 'TNSEMUL.SYS'

6

7 EXPORTS

P*Λ«I by CRISP vβ.2.1. Q-.OZ am Thursday, 30 September 1999

File: D:\nt4DDK\src\timesn\tnsdrvr\tnslf.h Page 1 of 1

Figure imgf000018_0001

57 Idefine FILE_DEVICE_TNS 0x00008301

58 Idefine TNS_IOCTL_HASE 0x830

59 Idefine IOCTL_TNS_SETDEBUGINFO CTL_C0DE (FILE_DEVICE_TNS, \

60 TNS_I0CTL BASE+0, \

61 METHOD_BUFFERED, \

62 (FILE_READ_ACCESS I FILE_WRITE_ACCESS) ) 63

64 typedef struct TNS IOCTLPACKET {

65 ULONG DebϋgLevel;

66 ULONG DebugMask;

67 ULONG DebugBreakFlag,

68 ) TNS_IOCTLPACKET, *pTNS_IOCTLPACKET; 69 70 71 lendif

Prtrttd by CRISP βjti. 9:01 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tn8def8.h Page 1 of 2

Figure imgf000019_0001
62 63 Idefine NTSTATUS_CUSTOMER_CODE 0x20000000 64 65 Idefine TNS_STATUS CODE (Severity, StatusCode) (\ 66 (NTSTATUS_CUSTOMER_CODE I (Severity « 30) I StatusCode)) 67 68
Figure imgf000019_0002
74 typedef enum ( 75 TNS SUCCESS-0, 76 TNS_NOT_IMPLEMENTED, 77 ) ; 7B 79 ♦define TNS_STATUS_SUCCESS TNS_STATUS_CODE (STATUS_SEVERITY_SUCCESS, TNS_SUCCESS) 80 81 Idefine TNS STATUS NOT IMPLEMENTED TNS STATUS CODE (STATUS SEVERITY ERROR, TNS NOT IMPLEMENTED) 82 rin -ml by CRISP ve_-.ι« 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tn8drvr\tnsdefs.h Page 2 of 2

83 84 prirad by CRISP βj2.ι. 9:02 am Thursday, 30 September 1999

File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.h Page 1 of 2

Figure imgf000021_0001

41

42 linclude "tnsif . h"

Figure imgf000021_0002

54 lifdef DBG 55

56 char *GetNDISOidString(NDIS_OID NdisOID, PULONG pFoundFlag);

57 char *GetNDISStatusString(NDIS_STATUS Status, PULONG pFoundFlag);

58 char *GetNDISEventString(NDIS_ERROR_CODE ErrorCode, PULONG pFoundFlag); 59

60 VOID

61 NdisDumpPacket (

62 PNDIS_PACKET Packet); 63

64 Idefine STATIC 65

66 VOID

67 DebugPrint (

68 ULONG DebugPrintLevel,

69 PCSZ DebugMessage, 70

71 ); 72

73 VOID

74 MaskDebugPrint (

75 ULONG DebugPrintLevel, •

76 ULONG DebugPrintMask,

77 PCSZ DebugMessage, 78

79 ); 80

81 extern ULONG _gDebugPrintLevel;

82 extern ULONG _gDebugPrintMask; mmd CRISP vβAi. 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.h Page 2 of 2

83 extern ULONG gDebugBreakFlag;

84

85 Idefine DEBUG_MODULE "DEBUG: "

86

87 Idefine DINFOIx, y) \

88 DebugPrintfx, "%s", DEBUG_MODULE) ; \

89 DebugPrintfx, "File => %s: ", FILE ) ; \

90 DebugPrint(x, "Line => %d: ", LINE ); \

91 DebugPrint y; 92

93 Idefine D(x) DebugPrint x; 94

95 Idefine DM(x) MaskDebugPrint x; 96

97 Idefine DUMP_PACKET ( ) NdisDumpPacket (x) 98

99 Idefine INT3 ( asm int 3 ) 100

101 Idefine Breakpoint!) \

102 ( DbgPrint ("Debug Break in file => %s, at line %d\n", FILE , LINE ); \

103 if (_gDebugBreakFlag) ( _asm int 3 ) ; ) 104

105 Idefine MyAssert(c) if (!(c)) (\

106 ( DbgPrint ("Assertion failure: Debug Break in file => *s, at line %d\n", FILE , LINE ); \

107 if (_gDebugBreakFlag) ( _asm int 3 ) ; ) ) 108

109 lelse ^7j35BG 110

111 Idefine STATIC static

112 Idefine DINFOIx, y)

113 Idefine D(x)

114 Idefine DM(x)

115 idefine Breakpoint!)

116 Idefine INT3

117 Idefine MyAssert(c)

118 idefine DUMP PACKE (x) 119

120 iendif SSiSfSBG

121 iendif "*'

122 123

124

Prtnt-o y CRISP vβj-.ι. 9:03 am Thursday, SO September 1999

File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsapi.h Page 1 of 11

Figure imgf000023_0001

PrtnMd by CRISP vβj-.1a 9:03 am Thursday, 30 September 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapl.h Page 2 of 11

Figure imgf000024_0001
Figure imgf000024_0002
162 DECLSPEC_EXPORT 163 TNS_WRITE_REGISTER BUFFER_ULONG( 164 IN PVOID DeviceHandle,

Prtnod by CRISP vO 1« 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page 3 of 11

Figure imgf000025_0001
181 DECLSPEC_EXPORT 182 TNS_READ_REGISTER_BUFFER USHORT ( 183 IN PVOID DeviceHandle, 184 IN PUSHORT Register, 185 IN PUSHORT pusBuffer, 186 IN ULONG Count ) ;

Figure imgf000025_0002

Printed by CRISP αa.1* 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapl.h Page 4 of 11

Figure imgf000026_0001

Pπntad by CRISP vβ-2.1 • θ:03 am Thursday, 30 September 1888 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page S of 1

Figure imgf000027_0001

Printed by CRI8P vβ-2.1* 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page β of 11 «"« - rt>^»a«> »~*v»

Figure imgf000028_0001

Pπi—d by CRISP v«-L1» 9:03 am Thursday, 30 September 1999 File: D:\πt4DDK\src\tlmθsn\tnsdrvΛtnsapi.h Page 7 of 1

Figure imgf000029_0001

PHKid by CRI8P vα-z. a 9:03 am Thursday, 30 September 1991 File: D:\nt4DDK\8rc\timesn\tnsdrvr\tnsapl.h Page β of 11

Figure imgf000030_0001

Prtπ-M by CRISP vβ-2.1a 9:03 am Thursday, 30 September 1989 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page 9 of 11

Figure imgf000031_0001

Priπb by CRI8P vβ-2.1» 9 03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\time8n\tnsdrvr\tnsapi.h Page lO of 11

Figure imgf000032_0001

Priπlad by CRISP vβ-Z.1* 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page 11 of 11

Figure imgf000033_0001

853 TNS_STATUS

854 DECLSPEC_EXPORT

855 TNSGetNextDevicelnstance (

856 PVOID pDevicelnstance,

857 PVOID *ppDeviceInstance) ; 858

Pri M by CRISP vβΛ.ι. S:03 am Thursday, 30 September 1 999

File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 1 of 1 1

Figure imgf000034_0001

31 (tifndef _TNS_H_

32 #define _TNS_H_

33 dinclude <ntddk.h>

34 dinclude <ndis.h>

35 dinclude <ntddndis.h>

36 ((include <tdikrnl.h>

37 dinclude "tnsstats.h" 38

39 ((define MIN_PACKET POOL_SIZE Oxff

40 (Idefine MAX_PACKET >OOL_SIZE Oxffff 41 3 U BSSSBBBSBBB 4 t

45

Figure imgf000034_0002

74 ddefine MPNAME_EXTENSION SIZE ( 3 * sizeof (WCHAR) )

75

76

77 ddefine MAX_COMPUTER_NAME_SIZE 16

78

79 typedef struct _SMNNodeTable (

80 int LocationSet;

81 unsigned char TNMacAddress[HARDWARE_ADDRESS_LENGTH] ;

82 unsigned long TNNodelD; prixad b CRISP βjti. Q.OA am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvΛtns.h Page 2 of 11

83 unsigned char TNComputerName [MAX_COMPUTER_NAME_SIZE) ;

84 ) SMNNodeTable, -pSMNNodeTable;

Figure imgf000035_0001

PitnM by CRISP vβ.2.1* 9:04 am Thursday, 30 September 1999 File: D:\nt4DDK\8rc\timesn\tri8drvr\tns.h Page 3 of 11

LENGTH] ;

i

Figure imgf000036_0001

Ptlπtad by CRISP vα_2.1« 9:04 am Thursday, 30 September 1999 File: D :\nt4DD K\src\tl mesnNtnsd rvr\tns. Page 4 of 11

247 PULONG BytesNeeded; 248 PULONG BytesReadOrWrittent 249 BOOLEAN LocalRequest; 250 251 252 PVOID TNSSharedMemoryPtr; 253 ULONG TNSSharedMemorySize; 254 255 ddefine VIRTUAL_MEMORY 1 256 ddefine NONPAGED_MEMORY 2 257

Figure imgf000037_0001
301 ) TNS_PACKET_CONTEXT, *PTNS_PACKET_CONTEXT; 302 303 ddefine PACKET_CONTEXT_FROM_PACKET(_pkt ) ( (PTNS_PACKET_CONTEXT) ( (_pkt)->ProtocolReserved) ) 304 305 306 ddefine MEDIA INFO SIZE (sizeof! MEDIA SPECIFIC INFORMATION ) + sizeof ( ULONG )) 307

Figure imgf000037_0002
328 typedef struct _CONFIG_DATA (

Printed by CRISP vA-t-l* 9:04 am Thursday, 30 September 1999 File: D:\nt4DDK\8rc\timesn\tnsdrvr\tns.h Page 5 of 11

0x00010000 0x00020000 P_DEVICE 0x00040000 0x00060000 0x00070000 0x00080000 0x00090000 OxOOOAOOOO 0X000B0000 OxOOOCOOOO OxOOODOOOO 0XO0OFO0OO

Figure imgf000038_0001

354 ddefine TNS_ERROR_INVALID_IMSAMP_MP_INSTANCE 0x00000004

355

356 tj

357 ?yι§aaε^ ^®s ^ESB^aaι^^ t@sgjr )-

358 ti ™" *"

359 extern ULONG TNSSharedMemoryNodeEmulation; 360

361 extern LIST ENTRY AdapterList;

362 extern NDIS~SPIN_LOCK AdapterListLock;

363 extern NDIS_HANDLE ClientProtocolHandle;

364 extern NDIS HANDLE MPWrapperHandle;

365 extern NDIS IANDLE LMDriverHandle;

366 extern PDRIVER_OBJECT IMDriverObject;

367 extern PDEVICE_OBJECT IMDeviceOb]ect; 368

369 extern CONFIG_DATA ConfigData; 370

371 extern NDIS_STRING IMSymbolicName

372 extern NDIS_STRING IMDπverName;

373 extern NDIS_STRING IMMPNaπie; 374

375

376 VOID

377 MPSendPackets (

378 IN NDIS HANDLE MiniportAdapterContext,

379 IN PPNDIS PACKET PacketArray,

380 IN UINT NumberOfPackets) ;

381

382 VOID

383 CLSendComplete (

384 IN NDIS HANDLE ProtocolBindingContext,

385 IN PNDIS PACKET Packet,

386 IN NDIS STATUS Status) ;

387

388 VOID

389 PacketCompletion (

390 IN PADAPTER Adapter,

391 IN PNDIS_PACKET Packet,

392 IN NDIS STATUS Status); 393

394 INT

395 CLReceivePacket (

396 IN NDIS_HANDLE ProtocolBindingContext,

397 IN PNDIS_PACKET Packet); 398

399 VOID

400 MPReturnPacket (

401 IN NDIS_HANDLE MiniportAdapterContext,

402 IN PNDIS_PACKET Packet ) ; 403

404 NDIS_STATUS

405 CLReceivelndication (

406 IN NDIS_HANDLE ProtocolBindingContext,

407 IN NDIS_HANDLE MacReceiveContext,

408 IN PVOID HeaderBuffer,

409 IN UINT HeaderBufferSize,

410 IN PVOID LooAheadBuffer,

Piiπtad by CRISP vβ.S.1* 9:04 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tns.h Page 6 of 11

411 IN UINT LookaheadBufferSize,

412 IN UINT PacketSize) ;

413

414 VOID

415 CLReceiveComplete (

416 IN NDIS_HANDLE ProtocolBindingContext) ;

417

418 NDIS_STATUS

419 MPTransferData (

420 OUT PNDIS PACKET Packet,

421 OUT PUINT BytesTransferred,

422 IN NDIS HANDLE MiniportAdapterContext,

423 IN NDIS HANDLE MlniportReceiveContext,

424 IN UINT ByteOffset,

425 IN UINT BytesToTransfer) ;

426

427 VOID

428 CLTransferDataComplete (

429 IN NDIS HANDLE ProtocolBindingContext,

430 IN PNDIS PACKET pNdisPacket,

431 IN NDIS STATUS Status,

432 IN UINT BytesTransferred) ;

433

434 VOID

435 BindToLowerMP (

436 OUT PNDIS STATUS Status,

437 IN NDIS HANDLE BindContext,

438 IN PNDIS STRING MPDeviceNa e,

439 IN PVOID SystemSpecifid,

440 IN PVOID SystemSpec fιc2) ;

441

442 VOID

443 Lo erMPOpenAdapterComplete (

444 IN NDIS_HANDLE ProtocolBindingContext, 445 IN NDIS_STATUS Status,

446 IN NDIS_STATUS OpenErrorStatus); 447

448 NDIS STATUS

449 MPInitializel

450 OUT PNDIS STATUS OpenErrorStatus,

451 OUT PUINT SelectedMediumlndex,

452 IN PNDIS MEDIUM MediumArray,

453 IN UINT MediumArraySize,

454 IN NDIS HANDLE MiniportAdapterHandle,

455 IN NDISJIANDLE WrapperConfigurationContext )

456

457 PADAPTER

458 FindAdapterByNa e (

459 PWCHAR AdapterName) ;

460

461 VOID

462 UnbindFromLo erMP (

463 OUT PNDIS STATUS Status,

464 IN NDISjΪANDLE ProtocolBindingContext,

465 IN NDISJIANDLE UnbindContext ) ;

466

467 VOID

468 DerefAdapter (

469 PADAPTER Adapter) ;

470

471 VOID

472 CleanupAdapter (

473 PADAPTER Adapter); 474

475 VOID

476 LowerMPCloseAdapterComplete (

477 IN NDISJiANDLE ProtocolBindingContext,

478 IN NDISJ3TATUS Status) ; 479

480 VOID

481 CLUnloadProtocol (

482 VOID); 483

484 VOID

485 MPHaltl

486 IN NDISJIANDLE MiniportAdapterContext) ; 487

488 NDIS 3TATUS 489 MPResetl 490 OUT PBOOLEAN AddressingReset, 491 IN NDISJIANDLE MiniportAdapterContext ) ; 492

Printed by CRISP vβj>.1« 9:04 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 7 of 11

493 494 NDISJ3TATUS 495 MPQueryInformat on ( 496 IN NDIS HANDLE MiniportAdapterContext, 497 IN NDIS OID Oid, 498 IN PVOID InformationBuffer, 499 IN ULONG InformationBufferLength, 500 OUT PULONG BytesWritten, 501 OUT PULONG BytesNeeded) ; 502 503 NDISJ3TATUS 504 MPSetlnformation ( 505 IN NDIS HANDLE MiniportAdapterContext, 506 IN NDIS~OID Oid, 507 IN PVOID InformationBuffer, 508 IN ULONG InformationBufferLength, 509 OUT PULONG BytesRead, 510 OUT PULONG BytesNeeded) ; 511 512 VOID 513 CLRequestComplete ( 514 IN NDIS HANDLE ProtocolBindingContext, 515 IN PNDIS REQUEST NdisRequestBuf, 516 IN NDIS STATUS Status) ; 517 518 NDIS 3TATUS 519 MakeLocalNdisRequest ( 520 PADAPTER Adapter, 521 NDIS OID Oid, 522 PVOID Buffer, 523 ULONG BufferSize); 524 525 NDISJ5TATUS 526 MakeLocalNdisRequestSet ( 527 PADAPTER Adapter, 528 NDIS OID Oid, 529 PVOID Buffer, 530 ULONG BufferSize); 531 532 533 NTSTATUS 534 WDMInitializel 535 PDRIVERJ3BJECT DriverObject, 536 PULONG InltShutdownMask); 537 538 VOID 539 WDMCleanup ( 540 ULONG ShutdownMask) ; 541 542 NTSTATUS 543 ConfigureDriver ( 544 IN PUNICODEJ3TRING RegistryPath, 545 IN PCONFIGJ3ATA Configurationlnfo) ; 546 547 VOID 548 CLStatusIndication ( 549 IN NDISJIANDLE ProtocolBindingContext, 550 IN NDIS 3TATUS GeneralStatus, 551 IN PVOID StatusBuffer, 552 IN UINT StatusBufferSize); 553 554 VOID 555 CLStatusIndicationComplete ( 556 IN NDISJIANDLE BindingContext ) ; 557 558 VOID 559 CLResetComplete ( 560 IN NDISJIANDLE ProtocolBindingContext, 561 IN NDIS STATUS Status); 562 563 564 VOID 565 TNSClientWorkerThread! PVOID Context) ; 566 567 VOID 568 TNSServerWorkerThreadlPVOID Context) ;

Figure imgf000040_0001

Printed by CRISP vβ-2.1* θ:04 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 8 of 11 .cool

Figure imgf000041_0001

626 typedef struct JTNSPacketHeader (

627 unsigned char MACDstAddress [ETHJU3DRESSJ.EN) ;

628 unsigned char MACSrcAddress [ETHJU)DRESSJEN] ;

629 unsigned short MACEtherType;

630 unsigned short TNSCommandReply; 631

632 ) TNSPacketHeader, *PTNSPacketHeader; 633

634 typedef struct TNSPacketHelloBroadcast {

635 unsigned char MACDstAddress[ETHJ\DDRESSJ,EN] ;

636 unsigned char MACSrcAddress [ETH .DDRESSJ.EN] ;

637 unsigned short MACEtherType;

638 unsigned short TNSCommandReply; 639

640 unsigned long RequestTag;

641 LARGE INTEGER RequestStartTSC;

642 unsigned char ClientMacAddress [HARDWARE .DDRESSJ.ENGTH] ;

643 unsigned char ClientMachineName[MAX :OMPUTERJJAME 3IZE] ; 644

645 ) TNSPacketHelloBroadcast, *PTNSPacketHelloBroadcast;

646

647

648 typedef struct J'NSPacketHelloReply {

649 unsigned char MACDstAddress [ETHJU3DRESSJ.EN] ;

650 unsigned char MACSrcAddress (ETHJ\DDRESSJ,EN) ;

651 unsigned short MACEtherType; ~~

652 unsigned short TNSCommandReply; 653

654 unsigned long RequestTag;

655 unsigned char SMNServerMacAddress tHARDWAREJUDDRESSJ.ENGTHJ ;

656 ULONG TNSClientNodelD;

Printed by CRISP vβ 2 1. 9:04 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 9 of 11

657 ULONG TNSSharedMemorySize; 658 LARGEJ:NTEGER RequestStartTSC; 659 ULONG SMNMachineNameSize; 660 unsigned char SMNMachιneName[MAX_COMPUTERJAME_SIZE] ; 661 662 ) TNSPacketHelloReply, *PTNSPacketHelloReply; 663 664 665 typedef struct JTNSPacketReadRequest ( 666 unsigned char MACDstAddress [ETH \DDRESSJ,EN] ; 667 unsigned char MACSrcAddress [ETHJU3DRESSJ.EN] j 668 unsigned short MACEtherType; 669 unsigned short TNSCommandReply; 670 671 unsigned long RequestTag; 672 unsigned long RequestWidth; 673 unsigned long RequestLength; 674 ULONG RequestOffset; 675 LARGE INTEGER RequestStartTSC; 676 677 ) TNSPacketReadRequest, *PTNSPacketReadRequest; 678 679 680 typedef struct JTNSPacketReadReply ( 681 unsigned char MACDstAddress [ETHJ\DDRESSJ,EN] ; 682 unsigned char MACSrcAddress [ETHJU3DRESSJ,EN] ; 683 unsigned short MACEtherType; 684 unsigned short TNSCommandReply; 685 686 unsigned long RequestTag; 687 unsigned long RequestLength; 688 LARGE_INTEGER RequestStartTSC; 689 ULONG dwData; 690 691 ) TNSPacketReadReply, *PTNSPacketReadReply; 692 693 typedef struct JTNSPacketWriteRequest ( 694 unsigned char MACDstAddress [ETHJU3DRESSJ.EN] ; 695 unsigned char MACSrcAddress [ETHJU3DRESSJ.EN] ; 696 unsigned short MACEtherType; 697 unsigned short TNSCommandReply; 698 699 unsigned long RequestTag,- 700 unsigned long RequestWi t ; 701 unsigned long RequestLength; 702 ULONG RequestOffset; 703 ULONG dwData; 704 USHORT wData; 705 UCHAR bData; 706 LARGE INTEGER RequestStartTSC, 707 708 ) TNSPacketWriteRequest, *PTNSPacketWπteRequest; 709 ; ;

Figure imgf000042_0001
717 unsigned long RequestTag; 718 unsigned long RequestWidth; 719 unsigned long RequestLength; 720 ULONG RequestOffset; 721 ULONG dwData; 722 USHORT wData; 723 UCHAR bData; 724 LARGE INTEGER RequestStartTSC; 725 726 ) TNSPacketWriteReply, *PTNSPacketWriteReply; 727 728 729 typedef struct TNSPacketQueryStats ( 730 unsigned char MACDstAddress [ETHJU3DRESSJ.EN] ; 731 unsigned char MACSrcAddress [ETHJU3DRESSJ.EN] ; 732 unsigned short MACEtherType; 733 unsigned short TNSCommandReply; 734 735 unsigned long RequestTag; 736 LARGE INTEGER RequestStartTSC; 737 738 ) TNSPacketQueryStats, 'PTNSPacketQueryStats;

Printed by CRISP vβ 2 1» 9:04 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 10 of 11

739

740 typedef struct TNSPacketQueryStatsReply (

741 unsigned char MACDstAddress [ETHJ\DDRESSJ,EN) ;

742 unsigned char MACSrcAddress [ETHJUJDRESSJ^EN] ; 743 unsigned short MACEtherType;

744 unsigned short TNSCommandReply; 745

ply;

Figure imgf000043_0001
Figure imgf000043_0002

785 ) TNSPacketQueryNodelnfoReply, *PTNSPacketQueryNodeInfoReply;

786

787 typedef struct TNSPacketClearStats (

788 unsigned char MACDstAddress [ETHJ-DDRESSJ.EN] ;

789 unsigned char MACSrcAddress [ETHJiDDRESSJ-EN] ;

790 unsigned short MACEtherType;

791 unsigned short TNSCommandReply; 792

793 unsigned long RequestTag;

794 LARGE NTEGER RequestStartTSC;

795 ) TNSPacketClearStats, *PTNSPacketClearStats;

796

797 ddefine TNSJ?ACKETJ3IZE (x) ( (sizeof (struct Jldx) <= 60) ? 60 : sizeof (struct ddx) )

798

799 typedef struct J*EQUEST_DATA (

800 ULONG requestOpcode;

801 LISTJOTRY Linkage;

802 unsigned char TnsPacket [2000] ;

803 PNDISJ>ACKET pNdisPacket;

804 ) REQUESTJDATA, *PREQUEΞT_DATA; 805

806 void

807 TNSBuildBroadcastReplyAndSend (

808 PADAPTER pAdapter,

809 PVOID pTnsPacket,

810 unsigned char *pHeader) ; 811

812 unsigned long

813 TNSGetSharedMemoryNodeNodelD!

814 PADAPTER pAdapter,

815 unsigned char *pHeader) ; 816

817 VOID

818 TnsDumpTnsPacket (

819 PUCHAR pucBuffer,

820 ULONG bu ength);

Printe by CRISP ve.2.1. 9:04 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 11 of 11

821 822 NTSYSAPI 823 NTSTATUS 824 NTAPI 825 ZwAllocateVirtualMemory ( 826 IN HANDLE ProcessHandle, 827 IN OUT PVOID *BaseAddress, 828 IN ULONG ZeroBits, 829 IN OUT PULONG RegionSize, 830 IN ULONG AllocationType, 831 IN ULONG Protect ) ; 832 833 NTSYSAPI 834 ULONG 835 NTAPI 836 ZwYieldExecution(VOID) ; 837 838 NTSYSAPI 839 NTSTATUS 840 NTAPI 841 ZwFreeVirtualMemory ( 842 IN HANDLE ProcessHandle, 843 IN PVOID *BaseAddress, 844 IN PULONG RegionSize, 845 IN ULONG FreeType) ; 846 847 VOID 848 TNSSendPackets ( 849 IN NDISJIANDLE NdisBindmgHandle, 850 IN PPNDISJPACKET PacketArray, 851 IN UINT NumberOfPackets) ; 852 853 NTSTATUS 854 TNSImtializeClientNodeSendPacket ( 855 IN PADAPTER pAdapter, 856 IN OUT PNDISJ?ACKET *ppNdisPacket, 857 IN OUT PVOID *ppTnsBuffer, 858 IN ULONG PacketLength); 859 860 NDIS 3TATUΞ 861 TnsGetNICStatsl 862 PADAPTER pAdapter, 863 pMPSTATS pMpStats); 864 865 int 866 sprιntf(char *s, const char *format, ... 867 868 VOID 869 TnsIncrementStat ( 870 PADAPTER pAdapter, 871 PLARGEJINTEGER pLi); 872 873 VOID 874 TnsAddStatsUlong ( 875 PADAPTER pAdapter, 876 PLARGEJINTEGER pLi, 877 ULONG Added); 878 879 void

0xC0080002L )

Figure imgf000044_0001

Printed by CRISP vβ.2. * 9:04 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsdebug.c Page 1 of 8

Figure imgf000045_0001

35 dinclude <stdarg h>

36 dinclude <stdιo.h>

37 dinclude <ndιs h>

38 dinclude "tnsdebug h"

39 dinclude "x86.h"

Figure imgf000045_0002

46 NTHALAPI

47 BOOLEAN

48 Hal akeBeep (ULONG Freq) , 49 50

51 d ifdef DBG

Figure imgf000045_0003

78 typedef struct JIDIS01dTable (

79 NDIS_OID NdisOID,

80 char *OιdStrιng,

81 ) NDISOidTable, *pNDISOιdTable. 82

Prim__ by CRISP „2 i. c, 03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\tirnesn\tnsdrvr\tnsdebug.c Page 2 of 8

JIDISOidTable) )

Figure imgf000046_0001

Printed by CRISP vβ-2 1β 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.c Page 3 of 8

Figure imgf000047_0001

Printed by CRISP ve.2 1- 9:03 am Thursday. 30 September 1 999 File: D:\nt4DDK\src\time8n\tnsdrvr\tnsdebug.c Page 4 of 8 PENJSRROR", ) , le / sizeof (struct JJDISStatusTable

***** *****

FALSE i „not.

Figure imgf000048_0001

279 //--

280 //*********** ****** ****-**•**-**** **.**-***-*****•*_****-*************<***+* *******-*****-*

281 ( "* * * """ "*' *""" "1*"" "

282 int i; 283

284 π _____

285 //"Hake* *stτuct!_re ϊle ^an aβie with~in"scope of this 'function only,

286 // Λot module -scope..

287 //

288 typedef struct JJDISEventTable l

289 NDISJSRROR__CODE ErrorCode;

290 char *ErrorCodeStπng;

291 ) NDISEventTable, *pNDISEventTable, 292

293 static NDISEventTable NDISEventStringTable [ ] = (

294 ( NDISJ)RROR :ODEJLES0URCE :0NFLICT, "NDIS J!RRORJ_ODEJTESOURCEJ:ONFLICT" , ) ,

295 ( NDIS__ERROR_C0DE__OUTJ3FJ?ES0URCES , "NDIS J RROR_CODE_OUT_0FJ^ES0URCES" ,

296 ( NDISJ RROR_C0DE__HARDWAREJRAILURE, "NDIS__ERR0R_C0DEJ1ARDWAREJ^AILURE" ,

297 ( NDISJΪRRORJΪODEJVDAPTERJJOTJROUND, "NDISJJRRORJXJDEJIDAPTERJJOTJFOUND" , ) ,

298 ( NDISJ:RRORJ ODEJNTERRUPTJ ONNECT, "NDISJ:RRORJ ODE_INTERRUPTJ:ONNECT", ) ,

299 ( NDISJ:RROR_CODE_DRIVERJΓAILURE, " DISJΞRRORJ DEJJRIVERJ^AILURE" , ) ,

300 ( NDISJ:RROR_CODEJ3AD_VERSION, "NDISJ-RROR__CODEJ3AD_VERSION" , ) ,

301 ( NDISJ:RROR_CODE_TIMEOUT, "NDISJ:RRORJ ODEJΓIMEOUT" , ) ,

302 ( NDISJSRRORJΗDEJIETWORKJVDDRESS, "NDISJ-RRORJRODEJJETWORK ADDRESS" , ) ,

303 ( NDISJ:RROR_CODE_UNSUPPORTED CONFIGURATION, "NDISJ:RROR__CODE_UNSUPPORTED_CONFIGURATION" , ) ,

304 ( NDISJ:RROR_CODEJ[NVALID_VALUEJRROMJ DAPTER, "NDIS_ERROR_C0DEJ'NVALID_VALUEJ?ROM_ADAPTER" , ) ,

305 ( NDISJ:RRORJ:ODEJ4ISSINGJ;ONFIGURATIONJ?ARAMETER, "NDISJSRRORJ:ODEJIISSINGJ:ONFIGURATIONJ>ARAMET

-2 ER", ) ,

306 { NDIS :RR0R_C0DE__BAD__I0J3ASE_ADDRESS, "NDISJ:RR0R_C0DEJ3AD_I0J3ASE_ADDRESS" , ) ,

307 { NDISj RROR_CODEJ«;CEIVEJΪPACEJ3MALL, "NDISj:RROR_CODEJ^ECEIVEJΪPACEJ3MALL", ) ,

308 ( NDISJiRRORJΪODEJtfJAPTERjπSABLED, "NDIS J2RROR :ODEJ\DAPTERJDISABLED", ) ,

309 ) ; 310

311 ddefine NUMJJDIS :VENT_STRINGj:NTRIES (sizeof NDISEventStringTable / sizeof (struct NDISEventTable))

312 ddefine NDISJSVENTJJOT OUND ΪTR "NDIS Event Code Not Found" 313

314 'pFoundFlag = FALSE,

315 for (1=0; KNUMJJDISJΛTENTJΪTRINGJJNTRIES; 1++) (

316 if (ErrorCode — NDISEventStringTable [l] .ErrorCode) (

317 'pFoundFlag = TRUE;

318 return NDISEventStringTable [l] . ErrorCodeString;

319 )

320 ) 321

322 return NDISJWENTJJOTJTOUND ΪTR;

323 ) 324

325 //**************-*■***_■*******+****■********+***+******-*'**** **-*****+* *************

326 //-+ '

Printed by CRISP vβ 2 1. 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\time8n\tnsdrvr\tnsdebug.c Page 5 of 8

Figure imgf000049_0001
rintLevel == DEBUG_ERROR) ) (

Figure imgf000049_0002

Printed by CRISP V6.2.1* 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.c Page 6 of 8

******.***-*********************************'*******

Figure imgf000050_0001

417 TNSMakeBeep(voιd)

418 It

419 // Description!

420 // . Performs "if 100ms beep at 400Hz, using the undocumented HalMakeBeep

421 It ' function- The way that thing jworks is to call it with "the

422 // requency you want 'to use ior the speaker, wait the desired amount

423 II _ of,time, then ΛallJLt again with a frequency of 0.

424 //—*■"" --- - - 25 / *************■****-*****-************-*****<*******************-**<*****-*-***********

426 ( ~" - _. - . „__ ..

427

428 //

429 // Start"the Φ'eep

430 //

431 HalMakeBeep (400);

432 //

433 // 'Stall so theT-'bee fs ^perceptible

434 //

435 KeStallExecutionProcessor (1000 * 100),

436 II

437 // Stop the beep by setting the frequency to„0

438 //

439 HalMakeBeep (0),

440 ) 441

442 ((define NUMCLOCKSPEEDSAMPLES 100

443

444 typedef struct _ProcSpeedData (

445 ULONG ProcSpeed;

446 ULONG Occurence;

447 ) ProcSpeedData, *pProcSpeedData;

448

449 __ 50 J /ΦΦΦΦΦΦΦΦΦΦΦΦΦ- Φ A'Λ Φ k <**^-^******^A*»»T ^**-*^*»*-*****-*»-**»*'**l****-8r3>-*-T^**-***-*******

451 //-+ ~ * ~ ~**~* " ~ - -~

452 VOID

453 NdisDumpBuffer ( ___ ____

454 PUCHAR vaBuffer, /7-^_m>OT.:T_r .t«""C01hrAg_c4_9"T r£ual_ space

455 ULONG buf ferLength) glNEQT; J&agth of .space S OiφrAn

456 *//

457 // iDescrdptioήi 58 / ~ This function dui-ps—the-contenics of a pool of cόnt"iguous"»virt_al^Λemory.

459 /_* Z For αiow, we are not dumping the .ascii representations*

460 // ~ * _. „„*_. „~ "

461 // Eήviroήraeπt?

462 tt>~ Kernel mode only-

463 II *""

464 // ' "" e urn r alue:

465 If Hone.

466 //

467 VI—

Δ fifi 7 ^**-*^******^^-**^*^***'********^****'*»''**********-****'***_-*-^*-^f***''****'*-***^*****'*

469 (

470 ULONG i, 471

Figure imgf000050_0002

486 ) 487

488 //*********♦***************■*********•**************-***<*****•**-*"**--*"*—**<**-'*******

489 //-+

490 VOID

Pri te by CRISP vβj_ι. 9.03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\-imesn\tnsdrvr\tnsdebug.c Page 7 of 8

; fferCount => %d, BufferC

i, va

(

Figure imgf000051_0001

544 NdisGetNextBuffer (NextBuffer, SNextBuffer) ;

545 )

546 ) 547 548

549 VOID

550 TnsDumpTnsPacket (

551 PUCHAR pucBuffer,

552 ULONG bufLength)

553 (

554 Wi __ _

555 /^fD ϊrffiόεaestϊ-^Cil^Haa i ess

556 |U '"" - ' ■■ -'" —'

557 D((0, "Tns Packet Dest => %02x-%02x-%02x-%02x-%02x-%02x\n",

558 pucBuffer [0],

559 pucBuffertl],

560 pucBuffer (2],

561 pucBuffer [3],

562 pucBuffer [4],

563 pucBuffer[5])); 564

565 D((0, "Tns Packet Source => %02x-*02x-%02x-%02x-*02x-%02x\n",

566 pucBuffer [6] ,

567 pucBuffer(7],

568 pucBuffer(8] ,

569 pucBuffer[9],

570 pucBuffer(10], printed y CRISP vβ.2.ι. 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.c Page 8 of 8

571 pucBuffer [11] )); 572

573 D((0, "Tns packet Type => I02x%02x\n", pucBuffer [12) , pucBuffer [13] )) ;

574 ) 575 576

577 Oendif I'P&βS

578

579 rinted by CRiβPvβ 2.ι_ 9:03 am Thursday, 30 September 1 999

File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 1 of 39

Figure imgf000053_0001

37 ((include <ntddk. h>

38 ((include <tnsdefs . h>

39 #include "tns .h"

40 ((include "tnsioctl . h"

41 #include "tnsdebug . h"

42 ((include "tnsapi.h"

43 (finclude "x86.h" 44

45

46 #undef BINARY_COMPATIBLE

47 ((define BINARΪ_COMPATIBLE 0

48

49

50 NTSTATUS

51 WDMInitialize(

52 PDRIVER_OBJECT DriverObject,

53 PULONG InitShutdownMask

54 ) ; 55

56 VOID

57 WDMCleanupf

58 ULONG ShutdownMask

59 ); 60

61 STATIC NTSTATUS

62 TNSProcessIOCTLs (

63 IN PDEVICE_OBJECT DeviceObject,

64 IN PIRP Irp

65 ); 66

67

68 VOID

Figure imgf000053_0002
Printed by cmspvβ__ι. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\time8n\tnsdrvr\tnsapi.c Page 2 of 39

83 7/Λh seTcaϊia? ln"general^ιwel% .ls6Sly'^xρort functloήalιty*,-€hat

Figure imgf000054_0001

88 NTSTATUS

89 WDMInitialize l

90 PDRIVER DBJECT DriverObject,

91 PULONG InitShutdownMask)

92 (

93 NTSTATUS Status;

94 UINT Funclndex; 95

96 It

97 /y^Ia-rTia-l-e*'tfie3d_rj^»_i-3^eβt_,'s"«ntry^points

98 μ ~ ~ " ~"

99 100 DriverObject->FastIoDιspatch = NULL; 101

102 for (Funclndex = 0; Funclndex <= IRP_MJ_MAXIMUM_FUNCTION; Funclndex++) (

103 DrιverOb3βct->Ma]orFunctιon [Funclndex] = TNSProcessIOCTLs;

104 ) 105

106 Status = IoCreateDevice (DriverObject,

107 0,

108 SIMDπverName,

109 FILE_DEVICE_NET ORK,

110 0,

111 FALSE,

112 SIMDeviceObject) ; 113

114 If ( NT_SUCCESS( Status )) (

115 "InitShutdownMask |= SHUTDOWN_DELETE_DEVICE; 116

117 IMDevιceObject->Flags 1= DO_BUFFERED_IO;

118

119 Status - IoCreateSymbolιcLιnk( SIMSymbolicName, slMDriverName ),

120

121 if ( NT_SUCCESS ( Status ) ) (

122 'InitShutdownMask |= SHUTDOWN_DELETE_SY LINK;

123 ) else (

124 D((0, "IoCreateSymbolic Link Failed (I08X): %ls -> %ls\n". Status, IMSymbolicName.Buffer, -2 riverNarae. Buffer) ) ;

125 )

126 ) else (

127 D((0, "IoCreateDevice Failed - %08x\n". Status ) ) ;

128 Breakpoint!); 129

130 IMDeviceObject = NULL;

131 ) 132

133 return Status;

134 ) 135

136 STATIC NTSTATUS

137 TNSProcessIOCTLs!

138 IN PDEVICE_OBJECT DevιceOb3ect,

139 IN PIRP Irp)

140 (

141 PIO_STACK_LOCATION lrpStack;

142 pTNS_IOCTLPACKET loBuffer;

143 ULONG inputBufferLength;

144 ULONG outputBufferLength;

145 ULONG loControlCode;

146 NTSTATUS Status = STATUΞ_SUCCESS; 147

Figure imgf000054_0002

Printe y CRISP vβ-_.ι. 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\-imesn\tnsdrvr\tnsapi.c Page 3 of 39

164 // 165

166 loBuffer = (pTNS_IOCTLPACKET) Irp->AssocιatedIrp.SystemBuffer;

167 inputBufferLength = irpStack->Parameters. DeviceloControl. InputBufferLength;

168 outputBufferLength = ιrpStack->Parameters. DeviceloControl. OutputBufferLength; 169

170 switch (ιrpStack->MajorFunctιon) (

171 case IRP_MJ_CREATE:

172 D((0, "IRP Createλn") ) ;

173 break; 174

175 case IRP_MJ_CLOSE:

176 D((0, "IRP Close\n") );

177 break; 178

179 case I P_MJ_CLEANUP:

180 D((0, "IRP Cleanup\n") );

181 break; 182

183 case IRP_MJ_SHUTDOWN:

184 D((0, "IRP ShutdownXn") );

185 break; 186

187 case IRP MJ_DEVICE_CONTROL: 188

189 •//

190 .^tΛόritfQ-^όdeϊrm'stack'an ^e-iorin.th opera-ion

191 ft " *"

192

) ) ;

) ) ;

Figure imgf000055_0001

225 Irp->IoStatus. Status = Status;

226 Irp->IoStatus. Information = outputBufferLength; 227

228 IoCompleteRequest(Irp, IO_NO_INCREMENT) ;

229

230 return Status;

Figure imgf000055_0002

235 WDMCleanupl

236 ULONG ShutdownMask)

237 (

238 if ( ShutdownMask S SHUTDOWN_DELETE_SYMLINK ) (

239 IoDeleteSymbolicLink ( SIMSymbolicName ) ;

240 ) 241

242 if ( ShutdownMask S SHUTDOWN_DELETE_DEVICE ) {

243 IoDeleteDevice l IMDeviceObject ) ;

244 )

245 )

Printed by CRISP vβ._.ι. 9:03 am Thursday, SO September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 4 of 39

er; ed on request, and ly (the packet structure length this variable). E (TNSPacketHelloReply) ;

Figure imgf000056_0001

269 Status = TNSInitializeClientNodeSendPacket (pAdapter,

270 SMyPacket,

271 SpTnsBuffer,

272 PacketLength); 273

274 // ___

275 //" Set-trie, -destination address appropriately

276 //

277 RtlCopyMemory (pTnsBuffer, spHeader[6], 6); 278

279 //

280 / -^ iϊl^inΛela en packet information/ here ~Z ".".

281 // """

282 pTnsBuffer->TNSCommandReply = wswap (TNS_HELLO_REPLY) ; 283

284 pTnsBuffer->RequestTag = dwswap l ( (PTNSPacketHelloBroadcast ) pTnsPacket ) ->RequestTag) ;

285 for ( 1=0, KHARDWARE_ADDRESS_LENGTH; 1++) (

286 pTnsBuffer->SMNServerMacAddress [ι] = pAdapter->LowerMPMacAddress [ι] ;

287 )

288 pTnsBuffer->RequestStartTSC = ( (PTNSPacketHelloBroadcast )pTnsPacket)->RequestStartTSC;

289 pTnsBuffer->TNSClιentNodeID = TNSGetSharedMemoryNodeNodeID(pAdapter, pHeader);

290 pTnsBuffer->TNSSharedMemorySize = dwswap(pAdapter->TNSSharedMemorySιze) ; 291

292 D((0, "SRV: TNSSharedMemorySize => %x\n", pTnsBuffer->TNSSharedMemorySize) ) ; 293

294 // _ „. » ,„» .„„ r « » . „

295 //-Copy •the Jmn -ma'cKine nameto"'t e~>reply packeE.

296 //

297 for ( 1=0; KMAX_COMPUTER_NAME_SIZE; i++) (

298 pTnsBuffer->SMNMachιneName [ι] = pAdapter->LocalComputerName [ι ] ,

299 ) 300

301 // _

302 II Dequeue ^ street-element" rόϊn our available object queue

303 It, '

304 pRequestObj « ExInterlockedRemoveHeadList (

305 SpAdapter->WorkerListEntryPool,

306 spAdapter->LιstEntryPoolLock) ; 307

308 pRqstData = CONTAINING_RECORD (pRequestOb3 ,

309 REQUEST_DATA,

310 Linkage) ; 311

312 //

313 //Steirfthβ -serverΕhfead what-' to" "do

314 // " 315

316 pRqstData->requestOpcode = TNS_HELLO_REPLY;

317 pRqstData->pNdisPacket = MyPacket; 318

319 //

320 // Insert""3object„onto 'server thread object queue

321 //

322 ExInterlockedlnsertTailList (

323 SpAdapter->ServerWorkerLιstEntry,

324 SpRqstData->Lιnkage,

325 SpAdapter->ServerWorkerLιstSpinLock) ; 326

327 // pπ M by CRISP vβ 2 1- 9:θ3 am Thursday. 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsapi.c Page 5 of 39

Figure imgf000057_0001

330 KeReleaseSemaphore (

331 spAdapter->ServerWorkerRequestSemaphore,

332 (KPRIORITY) 0,

333 (LONG) 1,

334 FALSE) ; 335

336 return;

337 ) 338

339 ddefine MAX_HELLO_RETRIES 20 340

341 VOID

342 TNSClientWorkerThreadl 343 PVOID Context

344 )

345 (

346 NTSTATUS waitStatus;

347 LARGE_INTEGER queueWait,

348 LARGE_INTEGER waittime;

349 PADAPTER serverContext = (PADAPTER) Context;

350 PADAPTER pAdapter = (PADAPTER) Context;

351 int HelloRetryCount;

352 mt HelloReceivedReply = FALSE; 353

354 PLIST_ENTRY clientRequest;

355 PREQUEST_DATA pClientRequestData, 356

357 ULONG RegisterData=0xbaddc0de;

358 NTSTATUS Status;

359 KIRQL Oldlrql;

360 PNDIS_PACKET MyPacket;

361 ULONG PacketLength;

362 PTNSPacketHelloBroadcast pTnsBuffer;

363 int i; 364

365 queueWait.QuadPart = -(3*1000*10000);

366 waittime.QuadPart = -(3*10000),

Figure imgf000057_0002
punted by CRISP vβ-n. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\8rc\time8n\tnsdrvr\tnsapi.c Page 6 of 39

410 HelloRetryCount = 0;

411

412 while ( ( HelloRetryCount++ < MAX_HELLO_RETRIES ) S S ( HelloReceivedReply == FALSE) ) [

413

414 PacketLength = TNS_PACKET_SIZE (TNSPacketHelloBroadcast ) ;

415 Status = TNSInitializeClientNodeSendPacket (pAdapter,

416 SMyPacket,

417 spTnsBuffer,

418 PacketLength); 419

cAddress [ i ] ; calComputerName, MAX_COMPUTER_NAME_S

;

Figure imgf000058_0001
Semaphore,

Figure imgf000058_0002

466 clientRequest = ExInterlockedRemoveHeadList (

467 SserverContext->ClientWorkerListEntry,

468 SserverContext->ClιentWorkerListSpιnLock) ;

469

470 MyAssert (clientRequest != NULL);

471

472 pClientRequestData = CONTAINING_RECORD(clιentRequest,

473 REQUEST_DATA,

474 Linkage ) ; 475

476 MyAssert (pClientRequestData != NULL);

477

478 if (pClientRequestData->requestOpcode != TNS_HELLO_REPLY) (

479 MyAssert (0) ;

480 ) else {

481 D ( ( 0, "We got a hello reply\n" ) ) ; 482 HelloReceivedReply » TRUE;

483 )

Figure imgf000058_0003

Printed by CRiβp vβ.2.1. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 7 of 39

491

492 )

493 1

494 } 495

496 while ( 1 ) (

497 KeDelayExecutionThread(

498 KernelMode,

499 FALSE,

500 SqueueWait); 501

502 TnsGetNICStats (pAdapter, SpAdapter->mpStats) ;

503 )

504 ) 505

506 507

508 PsTerminateSystemThread(STATUS_SUCCESS) ;

509 ) 510 511 512

513 VOID

514 TNSServerWorkerThreadl

515 PVOID Context

516 )

517 (

518 NTSTATUS waitStatus;

519 LARGE_INTEGER queueWait;

520 PADAPTER serverContext = (PADAPTER) Context;

521 PADAPTER pAdapter = (PADAPTER) Context;

522 PLIST_ENTRY serverRequest;

523 PREQUEST_DATA pServerRequestData;

524 NTSTATUS Status; 525

526 queueWait.QuadPart = -(3*1000*10000);

527

( 4;

Figure imgf000059_0001

546 Status - ZwAllocateVirtualMemory (

547 (HANDLE) NtCurrentProcess ( ) ,

548 (PVOID *) spAdapter->TNSSharedMemoryPtr, 549 (ULONG) 0,

550 (PULONG) spAdapter->TNSSharedMemorySize,

551 (ULONG) MEM_COMMIT,

552 (ULONG) PAGE_READWRITE) ; 553

554 if (Status != STATUS_SUCCESS ) f

555 D((0, "Virtual memory allocation failed\n"));

556 _asm int 3

557 ) else (

558 D((0, "Virtual memory allocation succeededVn") ) ;

559 RtlZeroMemory (pAdapter->TNSSharedMemoryPtr, pAdapter->TNSSharedMemorySize) ;

560 ) (

Figure imgf000059_0002

568 pAdapter->TNSSharedMemoryPtr =

569 ExAllocatePool (

570 NonPagedPool,

571 pAdapter->TNSSharedMemorySize) ; 572

Printe y CRISP vα-2.1. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsapi.c Page 8 of 39

) ; ->TNSSharedMemorySιze) ;

Figure imgf000060_0001

581 ) 582

583 )

584 KeSetPrιorιtyThread(KeGetCurrentThreadt) , L0W_REALTIME_PRI0RITY+7 ) ; 585

586 do (

587 waitStatus = KeWaitForSingleObjec (

588 (PVOID) sserverContext->ServerWorkerRequestSemaphore,

589 Executive,

590 KernelMode,

591 FALSE,

592 SqueueWait), 593

594

Ssel&ϊl,

Figure imgf000060_0002

634 Status = TNSInitializeClientNodeSendPacket (pAdapter,

635 SMyPacket,

636 SpTnsBuffer,

637 PacketLength); 638

639 RtlCopyMemory (pTnsBuffer, ( (PTNSPacketReadRequest) (pServerRequestData- TnsPacket) ) -> -2 MACSrcAddress, 6);

640 f f „ _

641 //_,Fil.d i^ eiav^ϊΛ~ acket n_o__-i -oϊ*#Ie».7.

642 /

643 pTnsBuffer-XTNSCommandReply = wswap (TNS_READ_REPLY) ; 644

645 pTnsBuffer->RequestTag = ( ( PTNSPacketReadReques ) (pServerRequestData->TnsPacket ) ) ->Re -2 questTag;

646 pTnsBuffer->RequestStartTSC = ( ( PTNSPacketReadRequest) (pServerRequestData->TnsPacket ) -2 ) ->RequestStartTSC;

647 vBuffer = (PUCHAR) ( (ULONG) vBuffer+ ( ULONG ) dwswap ( ( (PTNSPacketReadRequest ) (pServerReque -2 stData->TnsPacket ) ) ->RequestOffset ) ) ;

648

649 if (dwswap l ( ( PTNSPacketReadRequest ) (pServerRequestData->TnsPacket ) ) ->RequestOff set )

-2 <= pAdapter->TNSSharedMemorySιze ) (

Printed by CRISP vβ 2 1- 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 9 of 39

650 pTnsBuffer->dwData = *( (PULONG) vBuffer) ;

651 ) else (

652 _asm int 3

653 ) 654

655 TNSSendPackets(pAdapter->LowerMPHandle, SMyPacket, 1); 656

657 break;

658 )

659 case TNS_WRITE_REQUEST: (

660 PNDIS_PACKET MyPacket;

661 ULONG PacketLength;

662 NTSTATUS Status;

663 PUCHAR vBuffer; 664

6 66656 '/D.ftOT" "Pr.o.cessing s.erv.er". write*"request\ri*'} ),-

667 vBuffer = pAdapter->TNSSharedMemoryPtr; 668

669 vBuffer = ( PUCHAR) ( (ULONG) vBuffer+ ( ULONG ) wswap ( ( ( PTNSPacketWriteRequest ) (pServerReq

-2 uestData->TnsPacket ) ) ->RequestO f se ) ) ; 670

671 if (dwswap ( ( ( PTNSPacketWriteRequest ) (pServerRequestData->TnsPacket) ) ->RequestOf fset) -2 <= pAdapter->TNSSharedMemorySιze ) (

672 * ( ( PULONG) vBuffer) = ( ( PTNSPacketWriteRequest ) (pServerRequestData->TnsPacket ) ) ->d -2 wData;

673 ) else (

674 _asm int 3

675 ) 676

677 break;

678 )

679 case TNS_HELLO_REPLY -

680 MyAssert (TNSSharedMemoryNodeEmulation ) ;

681 II

682 // Sβhd hello reply

683 //

684 D((0, "Processing server hello reply\n")); 685

686 TNSSendPackets (pAdapter->LowerMPHandle, SpServerRequestData->pNdιsPacket, 1);

687

688 break;

689 default:

690 MyAssert (0);

691 break;

692 )

693 '//

694 //ϊHecycle* he queue-ϊbject

695 if

696 ExInterlockedlnsertTailList (sserverContext->WorkerListEntryPool,

697 spServerRequestData->Lιnkage,

698 SserverContext->LιstEntryPoolLock) ;

699 )

700 ( while (TRUE) ; 701

702 PsTermιnateSystemThread(STATUS_SUCCESS) ;

703 ) 704

705 VOID

706 TNSEmulSetPacketHeaderl

707 PADAPTER pAdapter,

708 PVOID pTnsPacket,

709 UINT PacketLength)

710 (

711 UINT l;

712 ULONG *pulData; 713

714 pulData = (PULONG) pTnsPacket; 715

716 π

1X1 ,//r^ero^emory"J(t_ke^€his -όut^lateri

718 hi

719 RtlZeroMemory (pTnsPacket, PacketLength); 720

721 // _

722 / PuE:a reco iz-J-le"pat%mint;o» acke"Tb ffer 123 II '

724 for (ι=0; i<PacketLength/4; ι++) (

725 *pulData++ = Oxcafebabe;

726 1 727

728 //

Printed by CRISP vβ 21. 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page lO of 39

729 // Set 'the destination and source 'addresses for the packet

730 //

731 for ( ι=0; 1<HARDWARE_ADDRESS_LENGTH; ι++ ) (

732 ( ( PTNSPacketHeader) pTnsPacket ) ->MACDstAddress [ ι] = pAdapter->SMNMacAddress [ i ] ;

733 ( ( PTNSPacketHeader) pTnsPacket ) ->MACSrcAddress [ ι ] = pAdapter->LowerMPMacAddress [ ι] ;

734 I

735 //_

736 // Set the -βthertype to' our~etπertype

737 //

738 ( ( PTNSPacketHeader) pTnsPacket ) ->MACEtherType = wswap (TNS_EMULATION_ETHERTYPE) ; 739

740 ) 741

742 //

743 // Initialized to H, incremented yil .each time we'ϋse it . Tie use

744 // this to help up keep, track, of outstanding requests to the SMN.

745 //

746 unsigned long _gRequestTag = 0;

747 unsigned long

748 TNSGetRequestTag(voιd)

749 (

750 return _gRequestTag++;

751 ) 752 753

754 //

755 // Initialized to O, incremented by 1 each time we use it. we use

756 // this to"help up kee -track, of outstanding requests -sto the SMR.

757 //

758 unsigned long _gSharedMemoryNodeNodeID = 0,

759 unsigned long

760 TNSGetSharedMemoryNodeNodelDI

761 PADAPTER pAdapter,

762 unsigned char *pHeader)

763 (

764 ULONG 1;

765 ULONG NextFreeSpace=0xfffff ff;

766 ULONG NewTeamNodelD;

767 PTNSPacketHelloBroadcast pTnsPacket = (PTNSPacketHelloBroadcast) pHeader; 768

769 for ( 1=0; KMAX_TEAM_NODES ; ι++ ) (

770 if (pAdapter->TeamNodeTable [ ι ] . LocationSet ) (

771 if ( RtlCompareMemory ( pHeader [ 6] , pAdapter->TeamNodeTable [ l ] . TNMacAddress , 6) == 6 ) (

772 return pAdapter->TeamNodeTable [l ] . TNNodelD;

773 )

774 ) else (

775 if (NextFreeSpace == Oxffffffff) (

776 NextFreeSpace = ι;

777 )

778 )

779 ) 780

781 //

782 //*'lf^e: iaBe'"itτ-tΛls''7far," e-_ia, όt md" an wenϊry-

783 // Set- an 'entry in our itable ~;for , this mac address.

784 //

785 NewTeamNodelD = _gΞharedMemoryNodeNodeID++;

786 RtlCopyMemory (pAdapter->TeamNodeTable [NextFreeSpace] -TNMacAddress, SpHeader[6], 6);

787 RtlCopyMemory (pAdapter->TeamNodeTable [NextFreeSpace] .TNComputerName, pTnsPacket->ClιentMachιneName, M -2 AX_COMPUTER_NAME_SIZE) ;

788 pAdapter->TeamNodeTable [NextFreeSpace] .LocationSet = TRUE;

789 pAdapter->TeamNodeTable [NextFreeSpace] TNNodelD - NewTeamNodelD; 790

791 return NewTeamNodelD;

792 ) 793 794

795 LARGE_INTEGER diffTime; 796

797 NTSTATUS

798 TNSInitializeClientNodeSendPacket (

799 IN PADAPTER pAdapter,

800 IN OUT PNDIS_PACKET *ppNdlsPacket,

801 IN OUT PVOID *ppTnsBuffer,

802 IN ULONG PacketLength)

803 (

804 NTSTATUS Status=STATUS_SUCCESS ;

805 PTNS_PACKET_CONTEXT PktContext ;

806 PNDIS_PACKET MyPacket ;

807 PNDIS_BUFFER MyNdlsBuffer;

808 PVOID vBuffer;

809 NDIS_PHYSICAL_ADDRESS HighAddress = NDIS_PHYSICAL_ADDRESS_CONST ( -1 , -1 ) ;

Printed by CRISP vβ a i. 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 11 of 39

810 PVOID pTnsPacket;

811 LARGE_INTEGER startTime, endTime; 812

813 71 ____ _________ __ _ _ „ _„ .„„

814 //fMlocate\a iac_Bt^rom:our^ aTial^e« ac e ~po

815 '// check status", rei-ni-£* the^packet_<and^get^-the,

816 //; context* context area

817 /_/

818 startTime - rdtscO;

819 NdisAllocatePacket (SStatus, SMyPacket, pAdapter->PacketPoolHandle) ;

820 endTime = rdtscO; 821

822 diffTime.QuadPart = endTime.QuadPart - startTime.QuadPart; 823

824 if (diffTime.LowPart > 0x400) (

825 Its{'(W, ~'"MiAlloc_tfiPacket ~τ£m&"~-> *%TxΛTΪ"^oi£_T_me.-LoW a t);ia"

826 ) 827

828 //

829 //"Hack hack worκoή >errόr?handling

830 //

831 If (Status '= STATUS_SUCCEΞS) (

Figure imgf000063_0001
tus;

834 )

835 NdisReinitializePacke (MyPacket) ; 836

837 PktContext = PACKET_CONTEXT_FROM_PACKET (MyPacket ) ; 838

839 PktContext->OriginalPacket = NULL;

840 PktContext->LookaheadBuffer = NULL;

841 PktContext->SMNEmulatιonPacket = TRUE; 842

843 // _. _ „

844 /7ΛT)ow,~alT;ό_aie;3r" ___.elf"-fcδ chain (<to the *ϊJac_St

845 <U " " ~ "~~~ '

846 Status = NdisAllocateMemory ( svBuffer, PacketLength, 0, HighAddress ) ; 847

(

Figure imgf000063_0002

0)

vBuf

PacketLength);

Figure imgf000063_0003

883 NdisAd3ustBu ferLength (MyNdisBuffer, PacketLength); 884

885 '// ___

886 μ--chaia- mk^harfe ϊ <^^£s)^acke ' d^&m!e

887 // "

888 NdisChainBufferAtFront (MyPacket, MyNdisBuffer) ;

889 NdisRecalculatePacketCounts (MyPacket) ; 890

891 *ppNdιsPacket = MyPacket;

Printed by CRISP vβj> ι. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 12 of 39

892 *ppTnsBuffer = pTnsPacket;

893

894 return Status;

895 ) 896

897 VOID

898 TNSFlushReadReplyQueue (

899 PADAPTER pAdapter)

900 (

901 LARGE_INTEGER queueWait;

902 NTSTATUS Status;

903 PLIST_ENTRY clientRequest;

904 PREQUEST_DATA pClientRequestData; 905

906 do (

907 queueWait.QuadPart = -(0); 908

909 Status = KeWaitForSingleObject (

910 (PVOID) SpAdapter->ClientWorkerRequestSemaphore,

911 Executive,

912 KernelMode,

913 FALSE,

914 SqueueWait) ; 915

916 if (Status == STATUS_SUCCESS) ( 917

918 clientRequest = ExInterlockedRemoveHeadList (

919 spAdapter->ClientWorkerListEntry,

920 spAdapter->ClientWorkerLιstSpinLock) ; 921

922 MyAssert (clientRequest != NULL);

923

924 pClientRequestData = CONTAINING_REC0RD (clientRequest,

925 REQUEST_DATA,

926 Linkage) ; 927

928 MyAssert (pClientRequestData) ;

929

930 TnsIncrementStat (pAdapter, spAdapter->MyStats.numDiscardedTnsRecvs) ;

Figure imgf000064_0001

948 ((define MAX_REQUEST_RESPONSE_RETRIES 50

949

951 ΦfJ~*

952 ULONG

Figure imgf000064_0002

970 KIRQL Oldlrql;

971 PNDIS_PACKET MyPacket;

972 ULONG PacketLength;

973 PTNSPacketReadRequest pTnsBuffer;

Printed by c vβ- i. 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 13 of 39

974 PLIST_ENTRY clientRequest;

975 PREQUEST_DATA pClientRequestData,

976 ULONG requestTag;

977 ULONG retrιes=0;

978 int noreply - TRUE;

979 ULONG returnRequestTag,

980 LARGE INTEGER startTime, endTime, diffTime;

981

982

983 yy?ΛaB iftac .."r'We"τeally wanna use €heTdevice^coπtext givgE BP

984 //sbysthetcaller- ~" * ~ *""

985 IJ " ~~"~

986 PAdapter = CONTAINING_REC0RD(AdapterList .Flink, ADAPTER, Linkage);

987

988 'I A

989 l"13lai_se*SlEQE*ito">preveπt *taSk,-swapp3lng*Jwhile e caaisjleteϊprocessing

990 //"i∑gr this packerT.

991 //"

;

Figure imgf000065_0001

1014 PacketLength = TNS_PACKET_SIZE (TNSPacketReadRequest ) ;

1015

1016 requestTag = TNSGetRequestTag ( ) ;

1017

1018 while (noreply SS (retrιes++ < MAX_REQUEST_RESPONSE_RETRIES) ) (

1019

1020 Status = TNSInitializeClientNodeSendPacket (pAdapter,

1021 SMyPacket,

1022 spTnsBuffer,

1023 PacketLength) ;

1024

1025

1026 I/' flX, in r lavfffit .packet:* lnfψήii l9n"hei .»__

1027 //,

1028 pTnsBuffer->TNSCommandReply = wswap (TNS_READ_REQUEST) ,

1029

1030 pTnsBuffer->RequestTag = dwswap (requestTag) ;

1031 pTnsBuffer->RequestWιdth = dwswap(4);

1032 pTnsBuffer->RequestLength = dwswap(l);

1033 pTnsBuffer->RequestOffset = dwswap ( (unsigned long) Register) ,

1034 pTnsBuffer->RequestStartTSC = rdtscO;

1035

1036 if (NT_SUCCESS (Status) ) (

1037 PLIST_ENTRY wrkrRequest;

1038 PREQUEST_DATA pWrkrRequestData;

1039 LARGE_INTEGER queueWait;

1040 int timeout = FALSE;

1041 int ltimeout = FALSE;

1042 int timeoutcount = 0;

Figure imgf000065_0002

1049 TNSFlushReadReplyQueue (pAdapter) ;

1050

1051 startTime = rdtscO,

1052 IJ

1053 I / 'Send .rβ'qϋest packet' to 'SMN

1054 //

1055 TNSSendPackets (pAdapter->LowerMPHandle, SMyPacket, 1),

Printed by CRISP ve.2 1- 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 14 of 39

1056

1057 It _ _

1058 // Thϊs is a" eadϊoperation so we expect a response.

1059 // ,Block waitmg for the response from the SMN.

1060 11''-

1061 // th'is is iOOm ecs

1062 IJ 1063

1064 queueWait.QuadPart = -(1000000),

1065

1066 Status = KeWaitForSingleObnect (

1067 (PVOID) SpAdapter->ClιentWorkerRequestSemaphore,

1068 Executive,

1069 KernelMode,

1070 FALSE,

1071 SqueueWait); 1072

1073 if (Status '= STATUS TIMEOUT) (

1074 PTNSPacketReadReply pTnsPacketReadReply; 1075

1076 clientRequest = ExInterlockedRemoveHeadList (

1077 SpAdapter->ClιentWorkerLιstEntry,

1078 spAdapter->ClιentWorkerLιstSpιnLock) ; 1079

1080 MyAsser (clientRequest '= NULL);

1081

1082 pClientRequestData = C0NTAIN1NG_REC0RD(clientRequest,

1083 REQUEST_DATA,

1084 Linkage); 1085

1086 MyAssert (pClientRequestData '= NULL);

1087 pTnsPacketReadReply = (PTNSPacketReadReply) SpClientRequestData->TnsPacket; 1088

1089 RegisterData = pTnsPacketReadReply->dwData;

1090 returnRequestTag = dwswap(pTnsPacketReadReply->RequestTag) ,

1091 ___ ____ ____

1092 I ' /HyAss*eri. reCurnSequestTag — ~ requestTag) ";

1093 *~

1094 if (returnRequestTag == requestTag) (

1095 noreply - FALSE,

1096 endTime = rdtsc O ,

1097 ) 1098

1099 //

1100 //>^nly___mai-nta'in*,.stats if'we did not^retry "the operation lioi i - ~ , -

1102 if ( (retries == 1) S (noreply==FALSE) ) (

1103 diffTime.QuadPart = endTime.QuadPart - startTime.QuadPart;

1104 if (pAdapter->MyStats.maxReadTimeSingle.QuadPart == 0) (

1105 pAdapter->MyStats.maxReadTimeSingle.QuadPart = diffTime.QuadPart,

1106 ) else (

1107 if (diffTime.QuadPart > pAdapter->MyStats.maxReadTimeSingle.QuadPart ) (

1108 pAdapter->MyStats.maxReadTimeSingle.QuadPart = diffTime.QuadPart;

1109 )

1110 )

1111 if (pAdapter->MyStats.mιnReadTιmeSιngle.QuadPart == 0) (

1112 pAdapter->MyStats.mιnReadTimeSιngle.QuadPart = diffTime.QuadPart,

1113 ) else (

1114 if (diffTime QuadPart < pAdapter- >MyStats .mιnReadTιmeSιngle. QuadPart ) (

1115 pAdapter->MyStats .mιnReadTιmeSιngle . QuadPart = diff Time . QuadPart ;

1116 )

1117 )

1118 if (pAdapter->MyStats numReadTimeSingleSamples . QuadPart < 30000) (

1119 pAdapter- >MyStats cumReadTimeSingle . QuadPart += diff Time. QuadPart;

1120 TnsIncrementStat (pAdapter, SpAdapter->MyStats . numReadTimeSingleSamples ) ;

1121 ) else (

1122 pAdapter->MyStats. cumReadTimeSingle.QuadPart = di Time.QuadPart,

1123 pAdapter->MyStats numReadTimeSingleSamples.QuadPart = 1,

1124 )

1125 ) 1126

1127 It _

1128 // Recycle tfie 'queue object

1129 //

1130 ExInterlockedlnsertTailList (SpAdapter->WorkerLιstEntryPool,

1131 SpClιentRequestData->Lιnkage,

1132 spAdapter->LιstEntryPoolLock) ;

1133 ) else (

1134 TnsIncrementSta (pAdapter, SpAdapter->MyStats . numReadRequestTιmeouts) ;

1135 )

1136 )

1137 ) rinted by CRISP vβ 2 i. 9"03 am Thursday. 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 15 of 39

1138

1139 KeLowerlrql (Oldlrql);

1140

1141 if (retries > 1) (

1142 TnsAddStatsUlong (pAdapter, spAdapter->MyStats.numWrιteRequestRetrιes, retrιes-1);

1143 ) 1144

1145 if (noreply == TRUE) (

1146 RegisterData = OxFFFFFFFF, 1147

1148 TnsIncrementStat (pAdapter, spAdapter->MyStats.numReadRequestNoReplιes) ;

1149 //

1150 / Throw'aή exceptiorF to our client ,,. .".

1151 if

1152 I PSBP

1153 ) 1154

1155 return RegisterData;

1156 ) 1157 1158 1159

1160 y/*************************************-****************************"*'***************

1161 11-*

1162 VOID

1163 DECLSPEC_E PORT

1164 TNS_WRITE_REGISTER_ULONG(

1165 IN PVOID DeviceHandle,

1166 IN PULONG Register,

1167 IN ULONG RegisterData)

1168 71

1169 //*DescriptiBή":

1170 »// " ""

1171 //-"Environmeήf:

1172 //

1173 /Return, Value:

1174 //,

1175 //—

1176 y/-****-*******^"**************-**********************************'***"-™**^f*'**+*******

1177 ( " "~~ ~" "" " " ■*----• <■-**- — ~=

1178 PADAPTER pAdapter = (PADAPTER) DeviceHandle;

1179 NTSTATUS Status;

1180 KIRQL Oldlrql;

1181 PNDIS_PACKET MyPacket;

1182 ULONG PacketLength;

1183 PTNSPacketWriteRequest pTnsBuffer,

1184 ULONG requestTag,

1185 ULONG retrιes=0;

1186 int noreply = TRUE;

1187 PLIST_ENTRY clientRequest;

1188 PREQUEST_DATA pClientRequestData,

1189 ULONG returnRequestTag,

1190 LARGE_INTEGER startTime, endTime, diffTime; 1191

1192

1193 //DUO, "TNS_WRIti;_REGISTER_ϋL0NG\ή")J

1194

1195 // „ „

1196 // hack "hackT We* reall^ wanna 'use-*the -device context given up

1197 /Λby~the caller.

1198 //

1199 pAdapter = CONTAINING_RECORD(AdapterLιst . Flink, ADAPTER, Linkage); 1200

1201 11

1202 // 'Raise TRQL to pirevent task" "swapping while we complete processing

1203 //-.for this packet.

1204 //

1205 KeRaιseIrql(DISPATCH_LEVEL, SOldlrql); 1206

1207 // _

1208 // Make~sure driver dϊas been "ϋϊtialized properly (this is

1209 // an assertion, this case should never ,happen ) .

1210 //

1211 //

1212 // nack hack work on «rror handling

1213 //

1214 if ( 'pAdapter->TNSDriverInιtιalιzed) (

1215 Breakpoint ();

1216 KeLowerlrql (Oldlrql);

1217 return,

1218 ) 1219

Printed by CRISP vβ 2 1. 9-03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 16 of 39

1220 TnsIncrementStat (pAdapter, spAdapter->MyStats.numWrιteRequests) ; 1221 1222 17 ___ m 1223 7V«2δϊ£m£Kϊpacker !aengtK*',-b^seT_-'on,-rfe _esC,^and 1224 //" se '-it e'ϊwariable^acόor ingly^ he^ ac e -s ruc€Tire^reήgth 1225 7/, tfillliget -set^accάrding $o ~ h_^_, -fgri-jble) __ 1226 1227 1228 PacketLength = TNS_PACKET_SIZE (TNSPacketWriteRequest ) ; 1229 requestTag = TNSGetRequestTag O ; 1230 1231 while (noreply SS (retrιes++ < MAX_REQUEST_RESPONSE_RETRIES) ) ( 1232 1233 Status = TNSInitializeClientNodeSendPacket (pAdapter, 1234 SMyPacket , 1235 SpTnsBuffer, 1236 PacketLength) ; 1237 1238 77 _____ ____ ___ 1239 ^^ilUϊlήJSreSyβnt ,packetl nfoSKarl.dn*fiereTSS? 1240 1241 pTnsBuffer->TNSCommandReply = wswap(TNS_WRITE_REQUEST) ; 1242 1243 pTnsBuffer->RequestTag = dwswap (requestTag ) ; 1244 pTnsBuffer->RequestWιdth = dwswa (4); 1245 pTnsBuffer->RequestLength = dwswap (1); 1246 pTnsBuffer->RequestOffset = dwswap! (unsigned long) Register) ; 1247 ρTnsBuffer->dwData = RegisterData; 1248 pTnsBuf er->RequestStartTSC = rdtsc ( ) ; 1249 1250 if (NT_SUCCESS (Status)) ( 1251 PLIST_ENTRY wrkrRequest; 1252 PREQUEST_DATA pWrkrRequestData; 1253 LARGE_INTEGER queueWait; 1254

Figure imgf000068_0001
1263 queueWait.QuadPart = -(1000000); 1264 1265 Status = KeWaitForSingleOb-ject ( 1266 (PVOID) SpAdapter->ClιentWorkerRequestSemaphore, 1267 Executive, 1268 KernelMode, 1269 FALSE, 1270 SqueueWait) ; 1271 1272 if (Status '= STATUΞ TIMEOUT) ( 1273 PTNSPacketWriteReply pTnsWriteReplyPacket; 1274 1275 clientRequest = ExInterlockedRemoveHeadLis ( 1276 SpAdapter->ClιentWorkerLιstEntry, 1277 spAdapter->ClιentWorkerListSpinLock) ; 1278 1279 MyAssert (clientRequest NULL) ; 1280 1281 pClientRequestData = CONTAINING_RECORD (clientRequest, 1282 REQUEST_DATA, 1283 Linkage) ; 1284 1285 MyAssert (pClientRequestData ' = NULL) ; 1286 1287 pTnsWriteReplyPacket = (PTNSPacketWriteReply) SpClιentRequestData->TnsPacket; 1288 1289 returnRequestTag = dwswap (pTnsWrιteReplyPacket->RequestTag) ; 1290 1291 1292 1293 if (returnRequestTag == requestTag ) ( 1294 noreply = FALSE; 1295 endTime = rdtsc O ; 1296 ) 1297 1298 if ( (retries == 1) SS (noreply==FALSE) ) ( 1299 diffTime. QuadPart = endTime. QuadPart - startTime.QuadPart; 1300 if (pAdapter->MyStats.maxWrιteTιmeSιngle.QuadPart == 0) ( 1301 pAdapter->MyStats.maxWriteTιmeSιngle.QuadPart = diffTime.QuadPart;

Printed by CRISP vβ 2 1β 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\_imesn\tnsdrvr\tnsapi.c Page 17 of 39

1302 ) else (

1303 if (diffTime.QuadPart > pAdapter->MyStats.maxWrιteTimeSιngle.QuadPart) (

1304 pAdapter->MyStats.maxWπteTιmeSιngle.QuadPart = diffTime.QuadPart;

1305 )

1306 )

1307 if (pAdapter->MyStats.mιnWπteTιmeSιngle.QuadPart == 0) (

1308 pAdapter->MyStats.mιnWrιteTιmeSιngle.QuadPart = dif Time.QuadPart,

1309 ) else (

1310 if (diffTime. QuadPart < pAdapter->MyStats.mιnWrιteTιmeSmgle.QuadPart) f

1311 pAdapter->MyStats.mιnWrιteTιmeSιngle.QuadPart = diffTime.QuadPart;

1312 )

1313 ) 1314

1315 if (pAdapter->MyStats.numWπteTimeSιngleSamples QuadPart < 30000) (

1316 pAdapter->MyStats.cumWrιteTιmeSιngle. QuadPart += diffTime.QuadPart;

1317 TnsIncrementStat (pAdapter, spAdapter->MyStats.numWπteTιmeSιngleSamples) ;

1318 ) else (

1319 pAdapter->MyStats.cumWπteTιmeSιngle.QuadPart = diffTime.QuadPart;

1320 pAdapter->MyStats.numWrιteTιmeSιngleSamples.QuadPart = 1;

1321 )

1322 ) 1323

1324 //

1325 // r"Recycle "the queue object

1326 //

1327 ExInterlockedlnsertTailList (SpAdapter->WorkerLιstEntryPool,

1328 SpClientRequestData->Lιnkage,

1329 SpAdapter->LιstEntryPoolLock) , 1330

1331 ) else (

1332

1333 TnsIncrementStat (pAdapter, spAdapter->MyStats.numWrιteRequestTιmeouts) ;

1334

1335 )

1336 )

1337 ) 1338

1339 if (retries > 1) (

1340 TnsAddStatsUlong (pAdapter, spAdapter->MyStats.numWrιteRequestRetrιes, retrιes-1);

1341 ) 1342

1343

1344 if (noreply == TRUE) (

1345 //

1346 //^Throw aή^exceptioή-'to" ur-client TJ3DQ

1347 //

1348

1349

1350 TnsIncrementStat (pAdapter, spAdapter->MyStats.numWrιteRequestNoReplιes) ;

1351 ) 1352

1353 KeLowerlrql (Oldlrql); 1354

1355 return;

1356 ) 1357

1358 y/*********-*******-*****-***************-****-****-**'*+**********-**********************

1359 *//-+'

1360 USHORT

1361 DECLSPEC_EXPORT

1362 TNS_READ_REGISTER_USHORT(

1363 IN PVOID DeviceHandle,

1364 IN PUSHORT Register)

1365 //

1366 / Descrip€iόn:

1367 //

1368 71 Environment:

1369 //

1370 // Return Value:

1371 '// £_.--

1372 '//—

1373 II*Φ*Φ-ΦΦΦΦ*Φ*ΦΦΦΦΦ**Φ ****#-*-#'*-#*♦•*********-***-*** *****"****•***■*********-#-#******-***

1374 { ~ " ~ ' ' *■'"' *■

1375 USHORT RegιsterData=0xbadd, 1376

1377 return RegisterData;

1378 ) 1379

1380 //**************************1****************************************************

1381 //-+

1382 VOID

1383 DECLSPEC_EXPORT

Printe by CRISP vβ 2 i. 9-0)3 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tirnesn\tnsdrvr\tnsapi.c Page 18 of 39

Figure imgf000070_0001

Figure imgf000070_0002

1465 //****"**************************************■************************************

PHm_ byCRisPvβ 2 i. 9.03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsapi.c Page 19 of 39

Figure imgf000071_0001
print-- by CRISP vβ_Li. 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 20 of 39

1548 'y^*^*^***^**^

1549 1 "" " i~m^ °~~1" "-*"""* '>■■«•- -— ^--—~ ~——- .— ~ - ..-__..._.....-. —

Figure imgf000072_0001

Printed by CRISP vβ.2.1* 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 21 of 39

1630 return TNS_STATUS_NOT_IMPLEMENTED;

1631 ) 1632 1633

Figure imgf000073_0001

Printed by CRISP vβ.2.1. 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 22 of 39

1712 // __ _______

1713 // >Εnvirohϊιen :

1714 tl "~ " " "___

1715 / <eturn""J/alue;

1716 It J"

1717 //--"

1718 //

1719 (

1720 return TNS_STATUS_NOT_IMPLEMENTED;

1721 ) 1722 1723

1 24 ***"***»****** ********^**^*****^***« *********************************** ***********

1725 U→ *"- "" *** "3, t-u "^ •*—*- «-- - - -- -*- - >

1726 TNS_STATUS

1727 DECLSPEC_EXPORT

1728 TNSQueryNotιfyStatus(

1729 IN PVOID DeviceHandle,

1730 IN TNSCPUID CpuID,

1731 IN OUT PTNSNOTIFYSTATUS pCpuNotifylnfo)

1732 //

1733 //'TJescript-oήr

1734 //

1735 // lEήvAronment:

1736 If

1737 //*fBet_ιrn£va_Sβ-

1738 //__-„*,

1739 11--' 17dn //*** ******"******■************ *"**»»*********** ***»•*"***!-**»************'***** ******

1741 (

1742 return TNS_STATUS_NOT_IMPLEMENTED,

1743 ) 1744

Figure imgf000074_0001

Printed by CRISP vβ 21. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 23 of 39

1794 //*******************♦***♦******************************************************

1795 //-+ - ' ' —' - - """ -- - - 1796 TNΞ_STATUS

1797 DECLSPEC_EXPORT

1798 TNSDeRegisterNotificationCallbac

1799 IN PVOID DeviceHandle

1800 IN PVOID pCallBack)

1801 IJ

1802 '//'Description:

1803 'It

1804 //^Environment:

1805 //

1806 /y^Re€urn' ral e*:

1807 //.

1808 11—

1809 If*'

1810 {

1811 return TNS STATUS NOT IMPLEMENTED,

1812 )

1813

1814

1 DK /

1816 71-*

1817 TNSCPUID

Figure imgf000075_0001

1837 DECLSPEC_EXPORT

1838 TNSReadOrdinalCounter (

1839 IN PVOID DeviceHandle)

1840 tl

1841 !/Z~rjesci_ptio

1842 //

1843 ^/'^En ironment::

1844 VI ___

1845 '//ϊiReturn Value;

1846 W*

1847 '//— l fl- ft //************** **************************************-***********.*>***-*>**** ******

1849 (

1850 return 0;

1851 ) 1852 1853

I P - //*«************»*******************************»***»**'*******■******-***********

1855 It→

1856 TNS_STATUS

1857 DECLSPEC_EXPORT

1858 TNSAllocateSharedMemory!

1859 IN PVOID DeviceHandle,

1860 IN TNSKEY Key,

1861 IN TNSMEMFLAGS Flags,

1862 IN TNSMEMSIZE Size,

1863 IN OUT PVOID *ppBuffer)

1864 //

1865 // Description:

1866 //

1867 // Environment:

1868 //

1869 // Return Value:

1870 //

1871 II—

1 R7? //***»*********************************************************************.*****

1873 (

1874 return TNS_ΞTATUS_NOT_IMPLEMENTED;

1875 )

Printed by vβ 2 i. 9O3 am Thurβday. 30 September 1 999 File: D:\nt4DDK\src\tirnesn\tnsdrvr\tnsapi.c Page 24 of 39

1876

1877 V/******************************************************************************

1878 I '/-* "" » - <*"■* •""

1879 TNS_STATUS

1880 DECLSPEC_EXPORT

1881 TNSFreeSharedMemoryl

1882 IN PVOID DeviceHandle, 1883 IN TNSKEY Key, 1884 IN PVOID Ptr, 1885 IN TNSMEMSIZE Size)

1886 It

1887 /'/"Description:

1888 If

1889 I ' Environment:

1890 71

1891 // -Re- rS sValue:

1892 // "-£_ . ,,

1893 VI— I R Q- ij /*********-******************************************>************** *************

1895 (

1896 return TNS_STATUS_NOT_IMPLEMENTED,

1897 ) 1898

1899 //************************** ******************************** ********************

1900 //-+ "^ " "- - ~ r -

1901 TNS_STATUS

1902 DECLSPEC_EXPORT

1903 TNSReadSharedMemory (

1904 IN PVOID DeviceHandle,

1905 IN PVOID pSharedMemoryAddress,

1906 IN ULONG Length,

1907 IN PVOID pBuffer)

1908 *//

1909 VI Descriptions

1910 // _

1911 //' Environment:

1912 //

1913 ^y Re βriFVllue:

1914 It ,.

1915 It— _

1 91 6 */ /*************-*****'******************************H^Λ**Hy**^*^**********Hr***H>*****

1917 (

1918 return TNS_STATUS_NOT_IMPLEMENTED,

1919 ) 1920

Figure imgf000076_0001
1946 TNS_STATUS

1947 DECLS PEC_EXPORT

1948 TNSDmaReadSharedMemory !

1949 IN PVOID DeviceHandle,

1950 IN PVOID pSharedMemoryAddress,

1951 IN ULONG Length,

1952 IN PVOID pBuffer,

1953 IN PVOID pCallback,

1954 IN PVOID DMAReadCompleteComtextl,

1955 IN PVOID DMAReadCompleteComtext2 )

1956 //

1957 II -Description:

Printed by vβ 2 1. g 03 _____ Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 25 of 39

1958 /__ „.,___., 1959 !/^"Environment":: 1960 1961 Ky:ϊftϊ'-rn;Vfa_ue"ϊ' 1962 vim rn- 1963 urn 1964 .^7,****.*'*'*'*'^ 1965

Figure imgf000077_0001
1991 return TNS STATUS NOT IMPLEMENTED; 1992 )
Figure imgf000077_0002

Printed by CRISP vβ.z.1* 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 26 of 39

2040 TNS_STATUS

2041 DECLSPEC_EXPORT

2042 TNSInterlockedEnqueueToDoP (

2043 IN PVOID DeviceHandle,

2044 IN PTNSQUEUE pTNSQueue,

2045 IN PVOID pltem,

2046 IN ULONG Length)

2047 71

2048 / ".Description

2049 It

2050 //'(Environment:

2051 IJ

2052 /Re u n"Value;

2053 It rl

2054 71—

2056 (

2057 return TNS_STATUS_NOT_IMPLEMENTED,

2058 ) 2059 2060

2061 I/HP*****************************************************************************

2062 //-+ " " ~ »* - »«,

2063 TNS_STATUS

2064 DECLSPEC_EXPORT

2065 TNSInterlockedDequeueToDoP (

2066 IN PVOID DeviceHandle,

2067 IN PTNSQUEUE pTNSQueue,

2068 IN PVOID pltem,

2069 IN PULONG pLength)

2070 //

2071 // ltes_rip__όn:

2072 '// _____

2073 //3__ιv±ronπιe t:

2074 »//

2075 / Tte€Sfn JVa ue:

2076 // **; *•

2077 II—

2078 //**************************»*********************•* * ** ******************** ******

2079 (* **""*"" ■**"*"" *"*~~J"*"" " * "*"' - * -* -* - " *• ■'' v «- < - __

2080 return TNS_STATUS_NOT_IMPLEMENTED,

2081 ) 2082 2083 2084

2085 TNS_STATUS

2086 DECLSPEC_EXPORT

2087 TNSQueryQLengthP (

2088 IN PVOID DeviceHandle,

2089 IN PTNSQUEUE pTNSQueue,

2090 IN PULONG pLength)

2091 7/

2092 J'/'iJSescrϊp ϊ nϊ

2093 It _____

2094 7/Environment:

2095 IJ

2096 yV-Reta nl, Value:

2097 Iff1- ~_£

2098 It—

2099 IT

2100 f

2101 return TNS_STATUS_NOT_IMPLEMENTED,

2102 ) 2103 2104 105 *******************************'************************************************

2106 It-*

2107 TNS_STATUS

2108 DECLSPEC_EXPORT

2109 TNSQueueHeadPI

2110 IN PVOID DeviceHandle,

2111 IN PTNSQUEUE pTNSQueue,

2112 IN OUT PTNSQUEUE *ppTNSQueue)

2113 //

2114 // Description:

2115 // __

211671 Environment:

2117 // "

2118 '/^Ret-rn Value;

2119 tr-"

2120 It—

?1 ?ι //******************************************************************************

P nted y CRISP vβ 2 i. g Q3 am Thursday. 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 27 of 39

Figure imgf000079_0001
2145 return TNS STATUS NOT IMPLEMENTED, 2146 2147 2148 2149 2150 //-+ 2151 TNS_STATUS 2152 DECLSPEC_EXPORT 2153 TNSQueuePayloadP ( 2154 IN PVOID DeviceHandle , 2155 IN PTNSQUEUE pTNSQueue, 2156 IN PVOID pltem, 2157 IN PULONG pLength ) 2158 II 2159 IP", 2160 sm

It 2161 // '-UrvlirόpmentT; 2162 Jl 2163 II Return ffflRtt 2164 2165 tt— 2166 2167 2168 return TNS STATUS NOT IMPLEMENTED, 2169 2170 2171 2172 2173 //-+ 2174 TNS_STATUS 2175 DECLSPEC_EXPORT 2176 TNSQueueNextP ( 2177 IN PVOID DeviceHandle, 2178 IN PTNSQUEUE pTNSQueue , 2179 IN OUT PTNSQUEUE "ppTNSQueue ) 2180 // 2181 /-Λescέϊ E iS 2182 2183 t //t Εnvl 'r ZoB "-BeKZ; 2184 // "* " " 2185 2186 II __& 2187 / 2188 //_Λ—*****^***^^*-**—****+****.**** ****»**"****<**#**** .**!***** ^**'*.***.****<*^.**- ***** 2189 2190 return TNS STATUS NOT IMPLEMENTED, 2191 2192 2193 //-*■** »U^**^******* ^^*>*^* ********-fr*^*********H**^ 2194 //-+ 2195 TNS_STATUS 2196 DECLSPEC_EXPORT 2197 TNSInterlockedlnsertQueueltemP ( 2198 IN PVOID DeviceHandle, 2199 IN PTNSQUEUE pTNSQueue, 2200 IN PTNSQUEUE pTNSQueuelnsert ) 2201 // 2202 // Description: 2203 //

Printed by CRISP ve 2 1* 9 03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 28 of 39

2204 '//"'Environment.

2205 //

2206 ^Re-urn-Value:

2207 tf~ i Λ,«

2208 71— "

2209 /******************************************************************************

2210 (

2211 return TNS_STATUS_NOT_IMPLEMENTED,

2212 ) 2213 2214

2215 A*"*****************************************************************************

2216 //-+

2217 TNS_STATUS

2218 DECLSPEC_EXPORT

2219 TNSInterlockedDeleteQueueltemP (

2220 IN PVOID DeviceHandle,

2221 IN PTNSQUEUE pTNSQueue,

2222 IN PTNSQUEUE pTNSQueueDelete)

2223 //

2224 // Description:

2225 //

222677 Environment-

2227 tt

2228 // Return "Value:

2229 // ™

2230 //— "*

73TI / ******»*********************************♦*♦******************** ***************

2232 (

2233 return TNS_STATUS_NOT_IMPLEMENTED,

2234 ) 2235

2236 I/****************************************v**************************************

2237 //-+ ~ - ~ _ _~ _ ~ _ _

2238 TNS_STATUS

2239 DECLSPEC_EXPORT

2240 TNSQueueltemlnfoPI

2241 IN PVOID DeviceHandle,

2242 IN PTNSQUEUE pTNSQueue,

2243 IN PTNSQUEUEINFO pTNSQueuelnfo)

2244 It

2245 /£l)e%cription.:

2246 If ____ "__

2247 //^Environment:

2248 //

2249 IJ iRetarn?Value:

2250 // _ „,._

2251 //—"

2252 //******************************************************************************

2253 { — -*-" - -._-- - _-. -. -

2254 return TNS_STATUS_NOT_IMPLEMENTED,

2255 ) 2256 2257

2258 V/************■*-****-**************************************************************

2259 //-+" " " * "'

2260 TNS_STATUS

2261 DECLSPEC_EXPORT

2262 TNSGetFιrstDevιceInstance(

2263 PVOID *ppDeviceInstance)

2264 '//

2265 71 T-ScrlptiOtt-

2266 //

2267 // Environment:

2268 It

2269 // Return^Value:

2270 »// J*

2271 jt—

2272 //*****************************************************************************'*

2273 ( "*""" ~" " *

2274 return TNS_STATUS_NOT_IMPLEMENTED,

2275 ) 2276

2277 ¥ ************************♦*****************************************************

2278 //-+

2279 TNS_STATUS

2280 DECLSPEC_EXPORT

2281 TNSGetNextDevicelnstancel

2282 PVOID pDevicelnstance,

2283 PVOID *ppDevιceInstance)

2284 //

2285 // .Description.

Printed by CRISP vβ 2 i. 9 03 am Thursday, SO September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 29 of 39

Figure imgf000081_0001
2363 PacketLength » TNS_PACKET_SIZE (TNSPacketQueryStats) ; 2364 2365 requestTag = TNSGetRequestTag ( ) ; 2366 2367 while (noreply -S (retries++ < MAX_REQUEΞT_RESPONSE RETRIES ) ) (

Printed by CRISP vβ.2.1- 9:03 am Thursday, 30 September 1999

Figure imgf000082_0001

FIGURE 1

Figure imgf000083_0001

FIGURE 2

Figure imgf000083_0002

FIGURE 3

File: D:\nt4DDK\src\timosn\tns rvr\tnsapi.c Page 30 of 39

2368 2369 Status = TNSInitializeClientNodeSendPacke (pAdapter, 2370 SMyPacket, 2371 SpTnsBuffer, 2372 PacketLength) , 2373

Figure imgf000084_0001
2377 pTnsBuffer->TNSCommandReply » wswap(TNS_QUERY_STATS) , 2378 2379 pTnsBuffer->RequestTag = dwswap ( requestTag) , 2380 pTnsBuffer->RequestStartTSC = rdtscO, 2381

st timed out, for

Figure imgf000084_0002
2408 queueWait QuadPart = -(1000000), 2409 2410 Status = KeWaitForSmgleObject ( 2411 (PVOID) 4pAdapter->ClientWorkerRequestSemaphore, 2412 Executive, 2413 KernelMode , 2414 FALSE, 2415 SqueueWait ) , 2416 2417 if ( Status ' = STATUS TIMEOUT) ( 2418 PTNSPacketQueryStatsReply pTnsPacketQueryStatsReply, 2419 2420 clientRequest = ExInterlockedRemoveHeadList ( 2421 -pAdapter->ClιentWorkerLιst Entry, 2422 SpAdapter->ClientWorkerListSpinLock) , 2423 2424 MyAssert (clientRequest NULL) , 2425 2426 pClientRequestData = CONTAINING_RECORD ( clientRequest , 2427 REQUEST_DATA, 2428 Linkage ) , 2429 2430 MyAssert (pClientRequestData ' = NULL) , 2431 2432 pTnsPacketQueryStatsReply - ( PTNSPacketQueryStatsReply) .pClιentRequestData->TnsPacke 2433 2434 returnRequestTag = dwswap (pTnsPacketQueryStatsReply->RequestTag ) , 2435 MyAssert ( returnRequestTag == requestTag ) , 2436 2437 if ( returnRequestTag «- requestTag ) ( 2438 noreply = FALSE, 2439 RtlCopyMemory (pStatistics, 4pTnsPacketQueryStatsReply->TnsNodeStatιstιcs, sizeof ( -2 ISTICS) ), 2440 RtlCopyMemory (pMpStats, SpTnsPacketQueryStatsReply->MpStats, sizeof (MPSTATS) ), 2441 I 2442 // 2443 / ^-scycle^e^ueue-o jeib 2444 // 2445 ExInterlockedlnsertTailList ( &pAdapter->WorkerLιstEntryPool , 2446 SpClιentRequestData->Lιnkage, 2447 &pAdapter->LιstEntryPoolLock) , 2448 else (

Printed by CFUSP vβ Z 1* 9 OS am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 31 of 39

Figure imgf000085_0001
2465 return 0; 2466 2467 2468
Figure imgf000085_0002
2472 ULONG

0) (

Figure imgf000085_0003

Pi lilted by CRISP ve.2.1 • 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 32 of 39

;

Figure imgf000086_0001
2611 2612 if (Status ! = STATUS_TIMEOUT) (

9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 33 of 39

2613 PTNSPacketQueryStatsReply pTnsPacketQueryStatsReply;

2614

2615 clientRequest = ExInterlockedRemoveHeadList (

2616 SpAdapter->ClιentWorkerLιst Entry,

2617 SpAdapter->ClιentWorkerLιstSpιnLock) ; 2618

2619 MyAssert (ClientRequest ' = NULL) ,

2620

2621 pClientRequestData = CONTAINING_RECORD ( clientRequest,

2622 REQUEST_DATA,

2623 Linkage); 2624

2625 MyAssert (pClientRequestData '= NULL);

2626

2627 pTnsPacketQueryStatsReply = (PTNSPacketQueryStatsReply) SpClientRequestData-XTnsPacke

-2 t, 2628

2629 returnRequestTag = dwswap (pTnsPacketQueryStatsReply->RequestTag) ,

2630 //MyAssert (returnRequestTag — requestTag); 2631

2632 if (returnRequestTag == requestTag) (

2633 noreply = FALSE;

2634 RtlCopyMemory (pStatistics, SpTnsPacketQueryStatsReply->TnsNodeStatιstιcs, sizeofl -2 STATISTICS) );

2635 RtlCopyMemory (pMpStats, SpTnsPacketQueryStatsReply->MpStats, sizeof (MPSTATS) );

2636 retValue - 1;

2637 )

2638 //

2639 // .Recycle*the queue"" "object

2640 //

2641 ExInterlockedlnsertTailList (SpAdapter->WorkerLιstEntryPool,

2642 SpClιentRequestData->Linkage,

2643 spAdapter->LιstEntryPoolLock) ;

2644 ) else (

2645 If ___

2646 // do somethin ^useful ?

2647 //

2648 )

2649 )

2650 ) 2651

2652 KeLowerlrql (Oldlrql); 2653

2654 if (noreply -- TRUE) (

2655 //

2656 // Thro an exception!to-ourlclient _ ..

2657 //

2658 /./."--DO

2659 )

2660 ) else (

2661 ) 2662

2663 return 0;

2664 } 2665 2666

2667 //-+

2668 ULONG

2669 DECLSPEC_EXPORT

2670 TNS_GET_SMN_INFORMATI0N (

2671 IN PVOID DeviceHandle,

Figure imgf000087_0001

2688 RtlCopyMemory (pMacAddress, spAdapter->SMNMacAddress, HARDWARE_ADDRESS_LENGTH) ,

2689 RtlCopyMemory (pNodeNa e, spAdapter->SMNMachιneName, 16),

2690 *pSharedMemorySιze = pAdapter-XTNSSharedMemorySize;

2691 return 0;

2692 )

Printed y CRISP vβ 2 1. 9O3 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\tirnesn\tnsdrvr\tnsapi.c Page 34 of 39

2693

2 2669945 _^,*^-^■'■'*™^i**"'*•' *■*s*^'"*"^'^'•*" , " 5"•: "'«"•1'''*,'-'■ ' -.-■«»<-»—.-^—.-..»—»»-,,„.„ ,,,,,:,..»,„.«,*,,„M,.-.„«,^.«..„. ,,.,*.,.,,.,

2696 ULONG

Figure imgf000088_0001

2716 RtlCopyMemory (pMacAddress, SpAdapter->LowerMPMacAddress, HARDWARE_ADDRESS_LENGTH) ;

2717 RtlCopyMemory (pNodeName, 4pAdapter->LocalComputerName, 16);

2718 *pNodeID - pAdapter->TNSClientNodeID;

2719 return 0;

2720 ) 2721

2722 ;/^M* i*5^ '^* *^^

2723 ^^;-*~^™~*"----s'"-"t-~'------"-a""----'--- ~--.-.~^.».

2724 ULONG

Figure imgf000088_0002

2741 RtlZeroMemory (spAdapter->MyStats, sizeof (STATISTICS) ) ;

2742 RtlZeroMemory (spAdapter->mpStats, sizeof (MPSTATS) ) ;

2743 GetProcessorSpeed (pAdapter) ;

2744 return 0;

2745 ) 2746 2747

Figure imgf000088_0003

Prin»d by CRISP vβ.2.ι. 9:θ3 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\-nsdrvr\tnsapi.c Page 35 of 39

2775 *//

2776 retValue = 1 ,

2777 for ( i=0; KMAX_TEAM_NODES , ι++) (

2778 pSMNInfo->LocatιonSet = pAdapter->TeamNodeTable [ι ) LocationSet ;

2779 for ( ] =0, : <6 , 3 ++ ) (

2780 pSMNInfo->MacAddress [ ] ] = pAdapter->TeamNodeTable ) . TNMacAddress [ ] ] ,

2781 )

2782 for (]=0, 3<MAX_COMPUTER_NAME_SIZE, ]++) (

2783 pSMNInfo->ComputerName[]] = pAdapter->TeamNodeTable (1] .TNComputerName [3] ,

2784 )

2785 pSMNInfo->NodeID = pAdapter->TeamNodeTable [1] TNNodelD,

2786 pSMNInfo++;

2787 )

2788 ) 2789

2790 return retValue,

2791 ) 2792

2793 If Φ****■*-***"****+-*+**#**+*#** **•**.*♦***4**M***«_l^*^**«MitlH)*«*****+**+*J,*****

2794 11-+

2795 ULONG

2796 DECLSPEC_EXPORT

2797 TNS_CLEAR_ΞMN_STATISTICS (

2798 IN PVOID DeviceHandle)

2799 // __ _ _

2800 // Description:

2801 //

2802 // Environment J

2803 //

2804 // Return Value:

2805 ι f~,r.

2806 II—

2807 //**■*******-***************"*********-****-***-****-*+*-*-***<****-*#*-****#+******-***

2808 (

2809 PADAPTER pAdapter = (PADAPTER) DeviceHandle;

2810 NTSTATUS Status,

2811 KIRQL Oldlrql,

2812 PNDIS_PACKET MyPacket,

2813 ULONG PacketLength,

2814 PTNSPacketClearStats pTnsBuffer,

2815 PLIST_ENTRY clientRequest,

2816 PREQUEST_DATA pClientRequestData;

2817 ULONG requestTag;

2818 ULONG retrιes=0,

2819 int noreply - TRUE,

2820 ULONG returnRequestTag, 2821

2822 _

2823 //ξhacfc ϊack- "*»e*%eally" wanήa -use the' evice ^context giveϊTup

2824 It ϊ the^ealXer.

2825 //

2826 pAdapter = CONTAINING_RECORD (AdapterList. Flink, ADAPTER, Linkage), 2827

2828 //

2829 //, Rai3e*'ϊ$r_-"t6~preveπt task swapping -while we complete processing

2830 // jforsthis ' acket,.^

2831 //

2832 KeRaiselrql (DISPATCH_LEVEL, SOldlrql ) , 2833

2834 //

2835 / «όk .s_ϊe*"dr'iver3has"beeri" _ntiaT.__ed properly^ £hϊs "*L-s

2836 // an ass-_rtion,__t is_case should never happen)..

2837 // " ~ " " "~

2838 //

2839 / ^aclT acJ work. on error handling

2840 //

2841 if ( 'pAdapter->TNSDriverInιtιalιzed) (

2842 Breakpoint () ,

2843 KeLowerlrql (Oldlrql),

2844 return 0,

2845 ) 2846

2847 17 _ „ „

2848 //-compute" acket length, baaed on equest .>ind

2849 // set thejvarlable accordingly (the -packet structure length

2850 11 * t"XX, get .pet according to this variable).

2851 // 2852

2853 PacketLength = TNS_PACKET_SIZE (TNSPacketClearStats ) ,

2854

2855 requestTag = TNSGetRequestTag ( ) ,

2856

Printed by CRISP vβ 2 i. 9 03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 36 of 39

2857 while (noreply SS (retries++ < MAX_REQUEST_RESPONSE_RETRIES) ) ( 2858 2859 Status = TNSInitializeClientNodeSendPacket (pAdapter, 2860 SMyPacket, 2861 SpTnsBuffer, 2862 PacketLength) ; 2863 2864 2865 _ 2866 2867 pTnsBuffer->TNSCommandReply = wswap(TNS_CLEAR_STATS) ; 2868 2869 pTnsBuffer->RequestTag = dwswap (requestTa ) ; 2870 pTnsBuffer->RequestStartTSC - rdtsc ( ) ; 2871 2872 if (NT_SUCCESS (Status)) ( 2873 PLIST_ENTRY wrkrRequest; 2874 PREQUEST_DATA pWrkrRequestData; 2875 LARGE_INTEGER queueWait; 2876 int timeout - FALSE; 2877 int ltimeout = FALSE; 2878 int timeoutcount = 0;

SMyPacket, 1);

Figure imgf000090_0001
2888 return 0; 2889 2890 2891

Figure imgf000090_0002
2929 ) 2930 if( (*pMpStatsSize >= sizeof (MPSTATS)) SS (pMpStats) ) ( 2931 TnsGetNICStats (pAdapter, pMpStats) ; 2932 ) else { 2933 pMpStatsSize = sizeof (MPSTATS) ; 2934 return 0; 2935 } 2936 2937 return 1; 2938

Printed by CRISP vβ-2.1 - 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 37 of 39

2939

2940

2941

2942

2943 unsigned char zerobuffer [6] = ( 0, 0, 0, 0, 0, 0 );

2944

2945 VOID

2946 TNSSendPackets!

2947 IN NDIS_HANDLE NdisBindingHandle, 2948 IN PPNDIS_PACKET PacketArray,

2949 IN UINT NumberOf Packets )

2950 (

2951 UINT PhysBufferCount, BufferCount, PacketLength;

2952 PNDIS_BUFFER FirstBuffer, NextBuffer;

2953 PUCHAR va;

2954 UINT bufferLength;

2955 unsigned short *pEtherType;

2956 unsigned int i,];

2957 NDIS_STATUS Status;

2958 int Found; 2959

2960

2961 for (i=0; ι<NumberOfPackets; ι++) (

2962

2963 difdef DBG

2964 NdisQueryPacke ( PacketArray [i] , SPhysBuf ferCount, SBufferCount, SFirstBuffer, SPacketLength) ; 2965

2966 NextBuffer - FirstBuffer;

2967 for (j=0; NextBuffer!= NULL; j++) (

2968 NdisQueryBuffer (NextBuffer, sva, Sbu ferLength) ; 2969

2970 if (j==0) (

2971 MyAssert (bufferLength != 0) ;

2972 if (bufferLength >= 14) (

2973 pEtherType = (unsigned short *)Sva[12);

2974 MyAssert (wswap(*pEtherType) »- TNS_EMULATION_ETHERTYPE) ;

2975 MyAssert (RtlCompareMemory (va, zerobuffer, 6) != 6);

2976 MyAssert (RtlCompareMemory (sva[6] , zerobuffer, 6) != 6);

2977 )

2978 )

2979 NdisGetNextBuffer (NextBuffer, SNextBuffer) ;

2980 )

2981 (fendif

2982 NdisSendl SStatus, NdisBindingHandle, PacketArray [i] ) ; 2983

2984 (tifdef DBG

2985 switch (Status) (

2986 case NDIS_STATUS_SUCCESS :

2987 break;

2988 case NDIS_STATUS_PENDING:

2989 break;

2990 case NDIS_STATUS_INVALID_PACKET:

2991 MyAssert (0);

2992 break;

2993 case NDIS_STATUS_CLOSING: 2994 MyAssert (0);

2995 break;

2996 case NDIS_STATUS_RESET_IN_PROGREΞS:

2997 MyAssert (0);

2998 break;

2999 case NDIS_STATUΞ_FAILURE:

3000 MyAssert (0);

3001 break;

3002 default:

3003 MyAssert (0) ;

3004 D((0, "Status => %x, %s\n". Status, GetNDISStatusString (Status, sFound) ));

3005 break;

3006 )

3007 (Iendif 3008

3009 ) __ ___

3010 X S_i%SendPackets (NdisBlndrngHand e," ' Pad-β-Srray, iNu berOf Eacke€s'β

3011 ) 3012

3013 NDIS_STATUS

3014 TnsGetNICStatsl

3015 PADAPTER pAdapter,

3016 pMPSTATS pMpStats)

3017 (

3018 NDIS_STATUS NdisStatus; 3019

3020 NdisStatus = MakeLocalNdisRequest (

Pri ted by CRISP vβ.2.1. 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 38 of 39

3021 pAdapter, 3022 OID_GEN_XMIT_0K, 3023 SpMpStats->XmitOK, 3024 sizeof (ULONG)); 3025 if (NdisStatus !- NDIS STATUS_SUCCESS) ( 3026 3027 _asm int 3 3028 ) 3029 3030 NdisStatus - MakeLocalNdisRequestl 3031 pAdapter, 3032 OID_GEN_RCV_OK, 3033 SpMpStats->RcvOK, 3034 sizeof (ULONG ) ) ; 3035 if (NdisStatus !- NDIS_STATUS_SUCCESS) ( 3036 asm int 3 ~ 3037 W Ms s&s& ≡s- 3038 ) 3039 3040 NdisStatus - MakeLocalNdisRequestl 3041 pAdapter, 3042 OID_GEN_XMIT_ERROR, 3043 sρMpStats->XmitError, 3044 sizeof (ULONG)); 3045 if (NdisStatus !» NDIS_STATUS_SUCCESS) ( 3046 asm int 3 3047 3048 ) 3049 3050 NdisStatus » MakeLocalNdisRequest ( 3051 pAdapter, 3052 OID_GEN_RCV_ERROR, 3053 SpMpStats->RcvError, 3054 sizeof (ULONG) ) ; 3055 if (NdisStatus !- NDIS_STATUS_SUCCESS) ( 3056 asm int 3 3057 3058 3059 3060 NdisStatus - MakeLocalNdisRequest ( 3061 pAdapter, 3062 OID_GEN_RCV_NO_BUFFER, 3063 SpMpStats->RcvNoBuffer, 3064 sizeof (ULONG)); 3065 if (NdisStatus !- NDIS_STATUS_SUCCESS) ( 3066 asm int 3 3067 3068 3069 3070 NdisStatus - MakeLocalNdisRequest ( 3071 pAdapter, 3072 OID_GEN_RCV_CRC_ERR0R, 3073 spMpStats->RcvCrcError, 3074 sizeof (ULONG)); 3075 if (NdisStatus !- NDIS_STATUS_SUCCESS) ( 3076 asm int 3 3077 3078 ) 3079 3080 3081 return NDIS_STATUS_SUCCESS; 3082 3083 3084 3085 VOID 3086 TnsAddStatsUlong! 3087 PADAPTER pAdapter, 3088 PLARGE_INTEGER pLi, 3089 ULONG Addend) 3090 ( 3091 LARGE_INTEGER AddendPart; 3092 3093 AddendPart. Hig Part » 0; 3094 AddendPart . LowPart = Addend; 3095 3096 (void) ExInterlockedAddLargelnteger(pLi, AddendPart, spAdapter->MyStatsLock) ; 3097 ) 3098 3099 VOID 3100 TnsIncrementStat ( 3101 PADAPTER pAdapter, 3102 PLARGE_INTEGER pLi)

Printed by CRISP vβ-2. 9 9:03 am Thursday, SO September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 39 of 39

3103 3104 LARGE_INTEGER Addend; 3105 3106 Addend.QuadPart - 1; 3107 3108 (void)ExInterlockedAddLargelnteger (pLi, Addend, SpAdapter->MyStatsLock) ; 3109 3110 3111 unsigned long _fltused; 3112 3113 void 3114 GetProcessorSpeed ( 3115 PADAPTER pAdapter) 3116 ( 3117 LARGE INTEGER qPerfCounterl , qPerfCounter2, qPerfDiff, qPerfFreq; 3118 E_fi____£i£------£ 3119 3120 LARGE_INTEGER qPerflnc - (65536, 0); 3121 LARGE_INTEGER qrdtscl, qrdtsc2, qrdtscdiff; 3122 3123 qPerfCounterl » KeQueryPerformanceCounter (sqPerfFreq) ; 3124 3125 qPerfCounter2.QuadPart - qPerfCounterl.QuadPart + qPerflnc.QuadPart; 3126 3127 qrdtscl - rdtscO ; 3128 do I 3129 qPerfCounterl » KeQueryPerformanceCounter (NULL) ; 3130 qrdtsc∑ - rdtsc ( ) ; 3131 ) while (qPerfCounterl.QuadPart < qPerfCounter2.QuadPart) ; 3132 3133 qPerfDif .QuadPart » qPerfCounterl.QuadPart - (qPerfCounter2.QuadPart - qPerfInc.QuadPart) ; 3134 qrdtscdif .QuadPart - qrdtsc2.QuadPart - qrdtscl.QuadPart; 3135 3136 3137 3138 pAdapter->MyStats . rdtscDiff qrdtscdiff.LowPart; 3139 pAdapter->MyStats.perfFreq qPerfFreq.LowPart; 3140 pAdapter->MyStats.perfDiff qPerfDiff.LowPart; 3141 3142 DUO, "qrdtscdiff.LowPart => *x\n", qrdtscdiff.LowPart 3143 D((0, "qPerfFreq.LowPart -> %x\n", qPerfFreq. owPart )); 3144 D((0, "qPerfDiff.LowPart ■=> »x\n", qPerfDiff.LowPart )); 3145 3146 3147

Printed by CRISP vβ-Z.1. 9:03 am Thursday, 30 September 1999

File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 1 of 20

Figure imgf000094_0001
70 NTSTATUS 71 DπverEntry ( 72 IN PDRIVER_OBJECT DriverObject, 73 IN PUNICODE_STRING RegistryPath) ; 74 75 STATIC NDIS_STATUS 76 GetAdapterRegistryData ( 77 PNDIS_STRING IMParamsKey, 78 PADAPTER pAdapter) ; 79 80 STATIC VOID 81 ProcessLowerMPOpenAdapter ( 82 IN PADAPTER pAdapter,

9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsemul.c Page 2 of 20

83 IN NDIS_STATUS Status); 84

Figure imgf000095_0001
113 ♦ifdef ALLOC_PRAGMA 114 ♦pragma alloc_text (INIT, ConfigureDriver) 115 ♦pragma alloc_text (INIT, ReadSingleParameter) 116 ♦pragma allocJ;ext(INIT, WriteSingleParameter) 117 ♦endif

Figure imgf000095_0002
130 DriverEntry! 131 IN PDRIVER_OB ECT DriverObject, 132 IN PUNICODE_STRING RegistryPath) 133 ( 134 NDIS_STATUS Status; 135 NDIS_PROTOCOL_CHARACTERISTICS ProtocolChars; 136 NDIS MINIPORT_CHARACTERISTICS MiniportChars; 137 NDIS~STRING IMNa e - NDIS_STRING CONST ( "IM") ; 138 ULONG InitShutdownMask; _ 139 PWCHAR EventLogString - IMDriverName.Buffer; 140 PVOID DumpData; 141 142 ♦ifdef DBG 143 TNSMakeBeepO ; 144 ♦endif 145 D ( (0, "TNSEmul DriverEntry\n") ) ; 146 D( (0, "TNSEMUL, Built »s at %s\n", _DATE , TIME ) ) ; 147 148 149 IMDriverObject « DriverObject; 150 151 152 InitializeListHeadt (AdapterList ) ; 153 NdisAllocateSpinLock t SAdapterListLock ) ; 154 155 NdisMInitializeWrapper l SMPWrapperHandle, DriverObject, RegistryPath, NULL ) / 156 157 InitShutdownMask - SHUTDOWN_TERMINATE_WRAPPER; 158 159 Status - ConfigureDriver! RegistryPath, SConfigData ) ; 160 161 if ( !NT_SUCCESS( Status )) ( 162 D((0, "ConfigureDriver - Status: 0x%x\n" Status ) ) ; 163 goto DriverEntryError; 164 )

Printed by CRISP vβ-_1_ 9:02 am Thurβday, SO September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsemui.c Page 3 of 20

165 166

167 NdisZeroMemory (SProtocolChars, sizeof (NDIS R0TOC0L_CHARACTERISTICS) ) ;

168 ProtocolChars.Name.Length - IMName. ength; ~

169 ProtocolChars.Name.Buffer - (PVOID) IMName. Buffer; 170

171 ProtocolChars. ajorNdisVersion = 4;

172 ProtocolChars. inorNdisVersion - 0; 173

174 ProtocolChars.OpenAdapterCompleteHandler - LowerMPOpenAdapterComplete;

175 ProtocolChars.CloseAdapterCompleteHandler - LowerMPCloseAdapterComplete;

176 ProtocolChars.SendCompleteHandler = CLSendComplete;

177 ProtocolChars.TransferDataCompleteHandler CLTransferDataComplete;

178 ProtocolChars. esetCompleteHandler - CLResetComplete;

179 ProtocolChars . RequestCompleteHandler - CLRequestComplete,

180 ProtocolChars. ReceiveHandler - CLReceivelndication;

181 ProtocolChars . ReceiveCompleteHandler = CLReceiveComplete;

182 ProtocolChars. StatusHandler - CLStatusIndication;

183 ProtocolChars. StatusCompleteHandler » CLStatusIndicationComplete;

184 tyj^t cpl^ &' ψ^i ef^ac^i;^nS_l r»,";C ϊce|TOP^'^

185 ProtocolChars. eceivePacketHandler = NULL; " """"

186 ProtocolChars. BindAdapterHandler - BindToLowerMP;

187 ProtocolChars.UnbindAdapterHandler - UnbindFromLowerMP;

188 ProtocolChars. UnloadHandler - CLUnloadProtocol; 189

190 NdisRegisterProtocol ( Status,

191 sClientProtocolHandle,

192 SProtocolChars,

193 sizeof (NDIS_PROTOCOL_CHARACTERISTICS) + ProtocolChars.Name. ength) ; 194

195 if ( !NT_SUCCESS( Status )) (

196 D((θ7 "DoProtocolInit: couldn't register client handlers *08X\n", Status ) ) ;

197 ) 198

199

200 if ( !NT SUCCESS! Status )) (

201

202 D((0, "DoProtocolInit Failed! Status: 0x%x\n", Status));

203

204 DumpData - SStatus;

205 NdisWriteErrorLogEπtryUMDriverObject,

206 EVENT_TRANSPORT_REGISTER_FAILED,

207 TNS_ERROR_PROTOCOL_INIT,

208 1,

209 SEventLogString,

210 sizeof ( Status ),

211 DumpData); 212

213 goto DriverEntryError;

214 ) 215

216 InitShutdownMask I- SHUTDOWN_DEREGISTER PROTOCOL; 217

218 NdisZeroMemory (sMiniportChars, sizeof (NDIS_MINIPORT_CHARACTERISTICS) ) ;

219 MiniportChars. ajorNdisVersion » 4; ~

220 MiniportChars.MinorNdisVersion - 0; 221

222 MiniportChars . Reserved = 0;

223 MiniportChars.HaltHandler = MPHalt;

224 MiniportChars. InitializeHandler - MPInitialize;

225 MiniportChars.QuerylnformationHandler - MPQuerylnformation;

226 MiniportChars.ResetHandler - MPReset;

227 MiniportChars.SetlnformationHandler - MPSetlnformation;

228 MiniportChars.TransferDataHandler ■ MPTransferData; 229

230 MiniportChars. econfigureHandler » NULL;

231 MiniportChars.DisablelnterruptHandler - NULL;

232 MiniportChars.EnablelnterruptHandler » NULL;

233 MiniportChars. HandlelnterruptHandler ■= NULL;

234 MiniportChars . ISRHandler - NULL;

235 MiniportChars.CheckForHangHandler = NULL; 236

237

238 MiniportChars. ReturnPacketHandler - MPReturnPacket;

239 MiniportChars. SendPacketsHandler « MPSendPackets;

240 MiniportChars .AllocateCompleteHandler - NULL;

241 MiniportChars.SendHandler - NULL; 242

243 Status - NdisIMRegisterLayeredMiniport (MPWrapperHandle,

244 SMiniportChars,

245 sizeof(MiniportChars),

246 SLMDriverHandle) ;

Printed by CRISP «β__ι- 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 4 of 20

247

248 if ( !NT_SUCCESS( Status )) (

249

250 D((0, "DoMiniportlnit Failed! Status: 0x%x\n", Status));

251

252 DumpData - SStatus;

253 NdisWriteErrorLogEntrydMDrlverObject,

254 (ULONG) TNS_EVENT_MINIPORT_REGISTER_FAILED,

255 0,

e ) ; s));

tatus));

Figure imgf000097_0001

311 CLStatusIndication (

312 IN NDIS HANDLE ProtocolBindingContext,

313 IN NDIS~STATUS GeneralStatus,

314 IN PVOID StatusBuffer,

315 IN UINT StatusBufferSize)

316 (

317 PADAPTER pAdapter » (PADAPTER) ProtocolBindingContext; 318

319 D((0, "( 08X) CLStatusIndication: Status %08X\n", pAdapter, GeneralStatus));

321 &ms&meB BEBBBffiSBmzs

322 1 '£

323 if (pAdapter->TNSDriverInitialized) (

32 NdisMIndicateStatus! pAdapter->TNSNdisHandle, GeneralStatus, StatusBuffer, StatusBufferSize )

325 ) 326

3 32278 ) iiQg^S^® - ll2.4^!∞¥ "?--Pn ri te b CRISP vβ.2.1. 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsemul.c Page 5 of 20

329 VOID

330 CLStatusIndicationComplete (

331 IN NDISJIANDLE ProtocolBindingContext)

332 (

333 PADAPTER pAdapter - (PADAPTER) ProtocolBindingContext;

334 D((0, "(%08X) CLStatusIndicatlonCompleteNn", pAdapter)); 335

336 if (pAdapter->TNSDriverInitialized) (

337 NdisMIndicateStatusComplete(pAdapter->TNSNdisHandle) ;

338 )

339 > m m m

340 341 342

343 NTSTATUS

344 ConfigureDriver (

345 IN PUNICODE STRING RegistryPath, 346 IN PCONFIG DATA Configurationlnfo)

347 (

348 NDISJIANDLE ConfigHandle; 349 NDIS STATUS Status;

350 NDIS~STRING TnsBlahBlah - NDIS__STRING_CONST("BlahBlah") ;

351 PNDIS_CONFIGURATION PARAMETER pCon igParameter; 352

353 NdisOpenProtocolCon iguration ( SStatus, SConfigHandle, RegistryPath );

354

355

Figure imgf000098_0001

362 ConfigurationInfo->DebugLevel - 10;

363 ConfigurationInfo->DebugMask « Oxffffffff; 364

365 if ( NT SUCCESS! Status )) ( 366

367 READ_HIDDEN_CONFIG ( PacketPoolSize, NdisParameterlnteger );

368 NdisCloseConfiguration ( ConfigHandle );

369 ) 370

371 return STATUS SUCCESS;

3 2 ) w

373

374 STATIC ULONG

375 ReadSingleParameter)

376 IN HANDLE ConfigHandle,

377 IN PWCHAR ValueName,

378 IN ULONG DefaultValue,

379 IN NDIS_PARAMETER_TYPE NdisParamType)

380 {

381 UNICODE_STRING ValueKeyName;

382 ULONG ReturnValue;

383 NDIS_STATUS Status;

384 PNDIS CONFIGURATION_PARAMETER ConfigParam; 385

386 MyAssert! NdisParamType ~ NdisParameterlnteger II NdisParamType — NdisParameterHexInteger );

387

388 NdisInitUnicodeString ( ValueKeyName, ValueName );

389

390 NdisReadConfiguration (SStatus,

391 sConfigPara ,

392 ConfigHandle,

393 (ValueKeyName,

394 NdisParamType) ; 395

396 if ( NT_SUCCESS( Status )) I

397 ReturnValue - Con igParam->ParameterData.IntegerData;

398 ) else (

399 ReturnValue - DefaultValue;

400 ) 401

402 return ReturnValue;

403 ) 404

405 VOID

406 BindToLowerMP (

407 OUT PNDIS_STATUS Status,

408 IN NDISJIANDLE BindContext,

409 IN PNDISJ3TRING MPDeviceName,

410 IN PVOID SystemSpecificl,

Prtπte bycRisPAi. θ:θ2 βm Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 6 of 20

411 IN PVOID SystemSpecificΣ )

412 (

413 PADAPTER pAdapter;

414 int i;

415 NDIS_STATUS OpenAdapterStatus;

416 NDIS 3TATUS OpenErrorStatus;

417 NDISJ3TATUS LocalStatus;

418 NDISJ4EDIUM MediumArray [ ] - (

419 NdisMediumFddi,

420 NdisMedιum802J),

421 NdisMedium802_3,

422 NdisMediumWan ); 423

424 UINT MediumArraySize » sizeof! MediumArray ) / sizeof( NDIS_MEDIUM ) ;

425 UINT Medialndex;

426 ULONG AdapterStructSize;

427 ULONG NdisPacketTypes;

Figure imgf000099_0001

430 D ( (0, "BindToLowerMP: %s\n", MPDeviceName->Buffer ) ) ;

Figure imgf000099_0002

445 *Status = NdisAllocateMemory( spAdapter, AdapterStructSize, 0, HighAddress) ; 446

447 if ( pAdapter — NULL ) (

448 PWCHAR StringData [2] , 449

450 StringDatatO] - IMDriverName. Buffer;

451 StringData [1] - L"Adapter";

452 NdisWriteErrorLogEntry(IMDriverObject,

453 (ULONG) EVENT_TRANSPORT_RESOURCE_POOL,

454 0,

455 2,

456 SStringData,

457 0,

458 NULL); 459

460 'Status - NDIS_STATUS_RESOURCES;

461 return;

462 ) 463

464 NdisZeroMemory (pAdapter, AdapterStructSize) ;

465

chineWSystemWCurrentControlSetWControlWComputerName

Figure imgf000099_0003
punted by CRISP van. 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 7 of 20

491 SntNameString, 492 TRUE) ; 493 494 if (Status — STATUS_SUCCESS) ( 495 496 (VOID)sprintf (nameBuf, "ComputerName") ; 497 RtllnitString (SntNameString, nameBuf) ; 498 499 Status - RtlAnsiStringToUnicodeStringt 500 sValueNameU, 501 SntNameString, 502 TRUE); 503

Figure imgf000100_0001
+ pKeyInfo->DataOffset) ;
Figure imgf000100_0002
542 while (*pwString SS (i<MAX COMPUTER NAME SIZE) ) ( 543 544 pAdapter->LocalComputerName[ι++] - (unsigned char) *ρwString; 545 pwString++; 546 ) 547 ) ) ;

) 0x00;

Figure imgf000100_0003

Printed by CRISP vβ-2. . 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tn8drvr\tnsemul.c Page 8 of 20

Figure imgf000101_0001
591 KeInitializeSemaphore(spAdapter->ClientWorkerRequestSemaphore, 592 0, 593 MAXLONG); 594 KeInitializeSemaphore(SpAdapter->ClientWorkerResponseSemaphore, 595 0, 596 MAXLONG); 597 KeInitializeSemaphore(SpAdapter->ServerWorkerRequestSemaphore, 598 0, 599 MAXLONG); 600 KeInitιalizeSpinLock(spAdapter->ClientWorkerListSpinLock) ; 601 KeInitialιzeSpinLock(SpAdapter->ServerWorkerListSpinLock) ; 602 KeInitializeSpinLock(SpAdapter->ListEntryPoolLock); 603 604 KeInitializeSpinLock(SpAdapter->MyStatsLock) ; 605 606 pAdapter->ListEntryItems = 50; 607 608 for (i-0; i<(int)pAdapter->ListEntryItems; i++) ( 609 PREQUEST_DATA pRqstData; 610 611 pRqstData - (PREQUEST_DATA) ExAllocatePool (NonPagedPool, sizeof (REQUESTJ3ATA) ); 612 613 if (pRqstData != NULL) { 614 ExInterlockedlnsertTailList (spAdapter->WorkerListEntryPool, 615 SpRqstData->Linkage, 616 SpAdapter->ListEntryPoolLock) ; 617 618 ) else ( 619 D((0, "Cannot allocate worker queue pool\n")); 620 _asm int 3 621 ) 622 623

Figure imgf000101_0002

Printed by CRISP ve.2.1- 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 9 of 20

653

Figure imgf000102_0001

661 'Status - NDIS_STATUS_FAILURE;

662 NdisFreeMemory(pAdapter, (sizeof (ADAPTER) +MPDeviceName->Length+MPDeviceName->Length+4*sizeof (UNIC -2 ODEJJULD) , 0);

663 return;

Figure imgf000102_0002

690 if ( OpenAdapterStatus — NDIS_STATUS_PENDING ) I

691 NdisWaitEvent ( SpAdapter->BlockingEvent, 0 );

692 NdisResetEvent ( SpAdapter->BlockingEvent ) ;

693 ) else {

694 pAdapter->FinalStatus = OpenAdapterStatus;

695 ) 696

697 if ( NT_SUCCESS ( pAdapter->FinalStatus ) ) (

698

699 pAdapter->MediaType - MediumArray ! Medialndex ] ;

700

701 if (pAdapter->MediaType - NdisMediumWan)

702 pAdapter->MediaType » NdisMedium802_3;

703 )

704 ProcessLowerMPOpenAdapter ( pAdapter, pAdapter->FinalStatus );

705 pAdapter->TNSClientNodeID = Oxffffffff; 706

707 if (TNSSharedMemoryNodeEmulation — FALSE) (

708 if (PsCreateSystemThreadl

709 SpAdapter->ClientWorkerThreadHandle,

710 (ACCESS_MASK) 0,

711 (POBJECT_ATTRIBUTES) NULL,

712 (HANDLE) NULL,

713 (PCLIENT_ID) NULL,

714 TNSClientWorkerThread,

715 (PVOID) pAdapter) !- STATUS SUCCESS) ( 716

717 D((0, "Could not create client thread\n") ) ;

718 _asm int 3

719 )

720 ) else {

721 if (PsCreateSystemThreadl

722 spAdapter->ServerWorkerThreadHandle,

723 (ACCESS_MASK) 0,

724 (POBJECT_ATTRIBUTES) NULL,

725 (HANDLE) NULL,

726 (PCLIENT_ID) NULL,

727 TNSServerWorkerThread,

728 (PVOID) pAdapter) !- STATUS_SUCCESS) ( 729

730 D((0, "Could not Server worker thread\n") ) ;

731 _asm int 3

732 )

733 )

Printed by CRISP ve_z.ι- 9:02 am Thurβday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page lO of 20 er->FinalStatus;

Figure imgf000103_0001

739 STATIC NDIS_STATUS

740 GetAdapterRegistryData!

741 PNDIS_STRING IMParamsKey,

742 PADAPTER pAdapter)

743 (

744 NDIS_STATUS Status;

745 NDIS HANDLE ConfigHandle;

746 NDIS~STRING IMInstanceNumberKey = NDIS_STRING_CONST ( "InstanceNu ber" ) ;

747 PNDIS_CONFIGURATION_PARAMETER Conf lgPara ;

748

749 NdisOpenProtocolConf iguration ! SStatus , SConfigHandle, IMParamsKey ) ;

750

751 if ( !NT_SUCCESS ( Status ) ) (

752 D ( ( 0, " ( *08X) GetAdapterRegistryData : can ' t open key %s ( %08X) \n" , pAdapter, IMParamsKey->Buffer, -2 Status ) ) ;

753 Breakpoint!);

754 return Status,-

755 }

Figure imgf000103_0002

767 if ( ! NT_SUCCESS ( Status ) ) (

768 D ( ( 0, " ( %08X) GetAdapterRegistryData : Missing InstanceNumber key\n", pAdapter) ) ; 769

770 Status = NDIS JTATUS_FAILURE;

771 goto CloseConfig;

772 ) 773

774 pAdapter->DevInstance - (USHORT) ConfigParam->ParameterData . IntegerData;

775

776 NdisMoveMemory (pAdapter- >TNSDeviceName . Buffer, IMMPName . Bu fer, IMMPName . Length ) ;

777

778 pAdapter->TNSDeviceName.Buffer! IMMPName. ength / sizeof ( WCHAR ) ] = L'0' + pAdapter->DevInstance;

779

780

781 CloseConfig :

782 NdisCloseConf iguration ! ConfigHandle ) ; 783

784 return Status;

785

786 )

787

788 STATIC VOID

789 ProcessLowerMPOpenAdapter! 790 IN PADAPTER pAdapter,

791 IN NDIS STATUS Status)

792 (

793 NTSTATUS EventStatus;

794 NDIS_HARDWARE_STATUS HWStatus;

795 NDIS_MEDIA_STATE MediaState - OxFFFFFFFF;

796 NDIS_STRING IMDevName;

797 ULONG MacOptions;

798 ULONG ErrorLogData [2] ;

799 PWCHAR StringData [2] ;

800 PVOID DumpData; 801 802 D((0, "( 08X) ProcessLowerMPOpenAdapter\n", pAdapter));

803 m

804

805 g"

806

807 if ( !NT_SUCCESS( Status )) (

808 D((0, "( 0ΘX) ProcessLowerMPOpenAdapter: binding failed %08X\n", pAdapter, Status));

809 if ( Status — NDIS_STATUS_ADAPTER_NOT_FOUND ) (

810 EventStatus - EVENT_TRANSPORT_ADAPTER_NOT_FOUND;

811 ) else (

812 EventStatus = EVENT_TRANSPORT_BINDING_FAILED;

813 ) 814

Printed by CRISP vβ.2.1- 9:02 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tn8emul.c Page 11 of 20

815 StringData [0] - pAdapter->TNSDeviceName.Buffer;

816 StringDataϊlj = pAdapter->MPDeviceName.Buffer,

817 DumpData * SStatus; 818

819 NdisWriteErrorLogEntry(IMDriverObject,

820 EventStatus,

821 0,

822 2,

823 SΞtringData,

824 sizeof ) status ) ,

825 DumpData) ; 826

827 NdisFreeMemory (pAdapter, pAdapter->AdapterStructSize, 0) ;

828 return;

829 ] 830

831 DUO, "(%08X) =1 Adapter\n", pAdapter ) ) ;

832 initializeListHeadl spAdapter->ClιentList ) ;

833 pAdapter->ShutdownMask = 0; 834

835

836 NdisInterlockedlnsertTailList (SAdapterList, SpAdapter->Linkage, SAdapterListLock) ;

837

838 Status - MakeLocalNdisRequest (pAdapter,

839 OID_GEN_HARDWARE_STATUS,

840 SHWStatύs,

841 sizeof (HWStatus) ); 842

843 if ( Status NDIS_STATUS_INVALID OID I I HWStatus — NdisHardwareStatusReady ) ( 844

845 Status - MakeLocalNdisRequest (pAdapter,

846 OID_GEN_MEDIA_CONNECT_STATUS,

847 SMediaState,

848 sizeof! MediaState ) ) ; 849

850 if ( Status ~ NDIS_STATUS INVALID_OID I I MediaState ■>« NdisMediaStateConnected ) ( 851

852 Status - MakeLocalNdisRequest (pAdapter,

853 OID_GEN_LINK_SPEED,

854 spAdapter->LinkSpeed,

855 sizeof ( pAdapter->LinkSpeed )); 856

857 if ( !NT_SUCCESS( Status )) (

858

859 D((0, "(%08X) ProcessLowerMPOpenAdapter: Can't get link speed - Status *08X\n", pAdapter,

-2 Status)); 860

861 ErrorLogData [ 0 ] - TNS_ERROR_MISSING_OID;

862 ErrorLogData [ 1 ] - OID_GEN_LINK_SPEED; 863

864 NdisWriteErrorLogEntry (pAdapter->LowerMPHandle,

865 NDIS_ERROR_CODE MISSING_CONFIGURATION_PARAMETER,

866 2,

867 ErrorLogData); 868

869 return;

870 ) 871

872 ) else { 873

874 D((0, "(*08X) ProcessLowerMPOpenAdapter: Media not connected\n", pAdapter ) ) ;

875 )

876 } else { 877

878 D((0, "(%08X) ProcessLowerMPOpenAdapter: HW Status not ready (%d)\n", HWStatus));

879 ) 880

881 Status - MakeLocalNdisRequest (

882 pAdapter,

883 OID_802_3_CURRENT_ADDRESS,

884 spAdapter->LowerMPMacAddress,

885 HARDWARE_ADDRESS_LENGTH) ; 886

887 if ( NT_SUCCESS( Status )) (

888 D((0, "ProcessLowerMPOpenAdapter: got hardware address => %02x %02x *02x *02x %02x %02x \n",

889 pAdapter->LowerMPMacAddress[0] ,

890 pAdapter->LowerMPMacAddress[l] ,

891 pAdapter->LowerMPMacAddress [2] ,

892 pAdapter->LowerMPMacAddress [3] ,

893 pAdapter->LowerMPMacAddress [4] ,

894 pAdapter->LowerMPMacAddress [5] ) ) ;

895 ) else ( rinte by CRISP vβ-j.ι. 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 12 of 20

Figure imgf000105_0001

965 STATIC NDISJ3TATUS

966 AllocatePacketPool (

967 PADAPTER pAdapter)

968 (

969 NDIS STATUS Status;

970 ULONG ProtoReservedSize;

Figure imgf000105_0002

975 ProtoReservedSize = sizeo (TNS_PACKET_CONTEXT) ;

976

977 NdisAllocatePacketPool ( SStatus,

Printed y CRISP vej..ι_ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 13 of 20

get frame size - Status %08X\n", pAdapter, Status) ION_PARAMETER; ;

Figure imgf000106_0001
get total size - Status %08X\n" pAdapter, Status)

-2 ); 1026 1027 ErrorCode - NDIS ERROR CODE_MISSING_CONFIGURATION PARAMETER; 1028 ErrorLogData ! 0 J - TNS_ERROR_MISSING_OID; 1029 ErrorLogData ! 1 ] - OID GEN ttXIMUM_TOTAL_SIZE; 1030 1031 goto ErrorExit; 1032 ) 1033 1034 1035 1036 1037 I HteaderSize = pAdapter->TotalSize - FrameSize; 1038 D ( (0, "FrameSize -> %d, HeaderSize -> %d, TotalSize -> %d\n", FrameSize, HeaderSize, pAdaρter->TotalS

-2 ize) ) ; 1039

1040 Status ■= MakeLocalNdisRequest (pAdapter, 1041 OID_GEN_MAXIMUM_LOOKAHEAD, 1042 spAdaρter->LookaheadBufferSize, 1043 sizeof (pAdapter->LookaheadBufferSize) ) ; 1044 1045 if ( !NT_SUCCESS( Status )) ( 1046 1047 D( (0, " (»08X) AllocateReceiveBufferPool : Can ' t get lookahead size - Status *08X\n", pAdapter, Sta

-2 tus)) 1048 1049 ErrorCode - NDIS_ERROR_CODE_MISSING_CONFIGURATION_PARAMETER; 1050 ErrorLogData ! 0 ] - TNS_ERR0R_MISSING_OID; 1051 ErrorLogData ! 1 ] - OID_GEN_MAXIMUM_LOOKAHEAD; 1052 goto ErrorExit; 1053 ) 1054 1055 pAdapter->LookaheadBufferSize +- HeaderSize;

Printed by CRISP vβ.2.1- 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\-nsemu .c Page 14 of 20

1056 1057 1058 1059 Yd- 1060 NdisAllocateBufferPool ( SStatus, spAdapter->LookaheadPoolHandle, ConfigData . PacketPoolSize) ; 1061 1062 return Status; 1063 1064 ErrorExit : 1065 1066 NdisWriteErrorLogEntry ( 1067 pAdapter- >LowerMPHandle, 1068 ErrorCode, 1069 2, 1070 ErrorLogData ) ; 1071 1072 return Status; 1073 1074 > W ^* ^^&We£ ®: 1075 1076 1077 NDIS_STATUS 1078 MPInitialize( 1079 OUT PNDIS_STATUS OpenErrorStatus, 1080 OUT PUINT SelectedMediumlndex, 1081 IN PNDIS_MEDIUM MediumArray, 1082 IN UINT MediumArraySize, 1083 IN NDISJIANDLE MiniportAdapterHandle, 1084 IN NDIS HANDLE WrapperConfigurationContext ) 1085 1086 NDIS_STRING LowerAdapterKey - NDIS STRING_CONST ( "LowerAdapter" ) ; 1087 PADAPTER pAdapterlnList; 1088 ULONG ErrorLogData [2) ; 1089 PNDIS MINIPORT_BLOCK Mp » (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle; 1090 NDIS_STATUS Status; 1091 NDISJIANDLE ConfigHandle; 1092 PNDIS CONFIGURATIONJARAMETER pConfigParameter; 1093 NDIS_STRING TnsS nModeString - NDIS STRING_CONST("TNSSMNEmulationMode") ; 1094 1095 1096 D((0, "MPInitialize: EnterNn")); 1097 D((0, "Miniportlnitialize Miniport->BaseName %ws\n",Mp->MiniportName. Buffer n ; 1098 1099 pλdapterlnList FindAdapterByName (Mp->MiniportName.Bu fer) ; 1100 1101 1102 NdisOpenConfiguration ( 1103 SStatus, 1104 SConfigHandle, 1105 WrapperConfigurationContext) ; 1106 1107 if (Status !- STATUS_SUCCESS) ! 1108 D((0, "Cannot open miniport config data\n")); 1109 ) else ( 1110 NdisReadConfiguration ( llll SStatus, 1112 SpConfigParameter, 1113 ConfigHandle, 1114 STnsS nModeS ring, 1115 NdisParameterHexInteger) ; 1116 1117 if (Status !- STATUS 3UCCESS) ( 1118 D((0, "Can't read reg, Status »> %x\n". Status)); 1119 ) else ( 1120 D((0, "read reg, value -> %x\n", pConfigParameter->ParameterData.IntegerData) ) ; 1121 TNSSharedMemoryNodeEmulation - pConfigParameter->ParameterData.IntegerData; 1122 1123

p->MiniportName. Buffer) ) ;

Figure imgf000107_0001
1132 ErrorLogData ! 0 ] - TNS_ERROR BAD_REGISTRY_DATA; 1133 ErrorLogData ! 1 ] = TNS :RR0R__INVALID_IMSAMP_MP_INSTANCE; 1134 1135 NdisWriteErrorLogEntry (MiniportAdapterHandle, 1136 NDIS_ERROR_CODE_MISSING_CONFIGURATION_PARAMETER, 1137 2,

Printed by CRISP vα.3.1- 9:02 am Thurβday, 30 September 1999 File: D:\nt4DDK\src\time8n\tnsdrvr\tnsenriul.c Page 15 of 20

1138 ErrorLogData) ; 1139 1140 Breakpoint!); 1141 return NDIS STATUS FAILURE; 1142 1143 1144 1145 1146 HA 1147 for (—MediumArraySize ; MediumArraySize > 0; ) ( 1148 if ( MediumArray! MediumArraySize ) — pAdapterInList->MediaType ) 1149 break; 1150 ) 1151 if ( MediumArraySize 0 ) ( 1152 break; 1153 ) 1154 —MediumArraySize; 1155 1156 1157 if ( MediumArraySize 0 SS MediumArray ! 0 ] ! «■ pAdapterInList->MediaType ) ( 1158 Breakpoint ( ) ; 1159 return NDISJ3TATUS_UNSUPP0RTED_MEDIA; 1160 ) 1161 1162 SelectedMediumlndex - MediumArraySize; 1163 1164 1165 w 1166 1167 pAdapterInList->TNSNdisHandle - MiniportAdapterHandle; 1168 1169 DM( (DEBUG :NFO, DEBUG_MASKEN_INIT, "AdapterInList->TNSNdisHandle ■=> »x\n", pAdapterInList->TNSNdisHan -2 die) ) ; 1170 1171 . _ 1172 1173 NdisMSe ~tAttributesE ~x~("Mi""n"i"por*tAdapt*e""r"H"and"le"", " " '"*"""* 1174 pAdapte InList, 1175 0, 1176 NDIS_ATTRIBUTE_DESERIALIZE I 1177 NDIS ATTRIBUTE_IGNORE_PACKET_TIMEOUT I 1178 NDIS~ATTRIBUTE_IGNORE_REQUEST_TIMEOUT I 1179 NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER , 1180 0); 1181 1182 1183 WL 1184 1185 pAdapterInList->TNSDriverInitialized » TRUE; 1186 1187 return NDIS STATUS SUCCESS; 1188 1189 1190 1191 PADAPTER 1192 FindAdapterByName ( 1193 PWCHAR AdapterName) 1194 ! 1195 PLIST_ENTRY NextAdapter; 1196 PADAPTER pAdapterlnList; 1197 ULONG NameLength - 0; 1198 PWCHAR pw - AdapterName; 1199 1200 while ( *pw++ !- 0 &s NameLength < 64 ) ( 1201 ++NameLength; 1202 ) 1203 1204 NameLength *«■ sizeof ( WCHAR ) ; 1205 1206 NdisAcquireSpinLockl SAdapterListLock ) ; 1207 1208 NextAdapter - AdapterList. Flink; 1209 while ( NextAdapter !- AdapterList ) ( 1210 1211 pAdapterlnList - CONTAINING_REC0RD( NextAdapter, ADAPTER, Linkage ); 1212 1213 1214 1215 if ( pAdapterInList->TNSDeviceName.Length ■»- (NameLength+2) ) ( 1216 if ( NdisEqualMemory!pAdapterInList->TNSDevιceName.Buffer, AdapterName, NameLength)) ( 1217 break; 1218 )

9:02 am Thurβday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnserriul.c Page 16 of 20

1219 )

1220

1221 NextAdapter - NextAdapter->Flink;

1222 )

1223

1224 if ( NextAdapter != SAdapterList ) (

1225 ) else (

1226 pAdapterlnList - NULL;

1227 )

1228

1229 NdisReleaseSpinLoc ( SAdapterListLock );

1230

1231 return pAdapterlnList;

1232 )

1233

1234 VOID

1235 UnbindFromLowerMPf

1236 OUT PNDIS_STATUS Status,

1237 IN NDISJIANDLE ProtocolBindingContext,

1238 IN NDIS HANDLE UnbindContext )

1239 (

1240 PADAPTER pAdapter - (PADAPTER) ProtocolBindingContext;

1241 NDIS_STATUS LocalStatus;

1242

1243 D((0, "(%08X) UnbindFromLowerMP\n", pAdapter));

1244

1245 if ( pAdapter->ShutdownMask S SHUTDOWN_DEINIT_DEV_INSTANCE ) (

1246

1247 LocalStatus - NdisIMDeInitializeDeviceInstance(pAdapter->TNSNdisHandle) ;

1248 MyAssert (NT_SUCCESS (LocalStatus) ) ;

1249

1250 pAdapter->ShutdownMask S- -SHUTDOWN_DEINIT_DEV_INSTANCE;

1251 )

1252

1253 pAdapter->BindContext - UnbindContext;

1254

1255 •Status - NDIS STATUS PENDING;

1256

1257 )

1258

1259 VOID

1260 LowerMPCloseAdapterComplete)

1261 IN NDIS HANDLE ProtocolBindingContext,

1262 IN NDIS~STATUS Status)

1263 ( 1264 PADAPTER pAdapter = (PADAPTER) ProtocolBindingContext; 1265 1266 D((0, "(%08X) LowerMPCloseAdapterCompleteVn", pAdapter)); 1267 1268 MyAssert ( NT_SUCCESS ( Status ) ) ; 1269 1270 if ( pAdapter->BindContext ) ( 1271 NdisCompleteUnbindAdapterl pAdapter->BindContext, Status ); 1272 ) 1273 1274 NdisAcquireSpinLock ( SAdapterListLock ) ; 1275 RemoveEntryListl spAdapter->Linkage ) ; 1276 NdisReleaseSpinLock ( SAdapterListLock ) ; 1277 1278 if ( pAdapter->ShutdownMask S SHUTD0W _DEALL0C_PACKET_PO0L ) { 1279 lHandle ) ;

Figure imgf000109_0001
1287 if ( pAdapter->ShutdownMask S SHUTD0WN_DEALLOC_LOOKAHEAD_POOL ) ( 1288 1289 NdisFreeBufferPool ( pAdapter->LookaheadPoolHandle ); 1290 ) 1291 1292 1293 NdisFreeSpinLock ( SpAdapter->Lock ) ; 1294 1295 NdisFreeMemory (pAdapter, pAdapter->AdapterStructSize, 0) ; 1296 1297 ) 1298

1299 VOID

1300 CLUnloadProtocol (

Pilmd by CRISP vβ-2.1. 9:02 am Thursday. 30 September 1999 File: D:\nt4DDK\src\tlme8n\tnsdrvr\tnsemul.c Page 17 of 20

1301 VOID) 1302 ( 1303 Breakpoint ( ) ,___ 1304 ) ' .y g ϋnloadP'rδtocόl 1305 1306

Figure imgf000110_0001
1338 NDIS_STATUS 1339 MakeLocalNdisRequest ( 1340 PADAPTER pAdapter, 1341 NDIS_OID Oid, 1342 PVOID Buffer, 1343 ULONG BufferSize) 1344 1345 NDIS_STATUS Status; 1346 ULONG BytesNeeded, BytesWritten; 1347 1348 pAdapter->Request.RequestType - NdisRequestQuerylnformation; fer = Buffer; ferLength = BufferSize;

->Request ) ;

Figure imgf000110_0002
1377 return Status; 1378 1379 1380 1381 1382

Printed by CRI8P vβj_ _ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvrΛtnsemul.c Page 18 of 20

1383 NDIS_STATUS

1384 MakeLocalNdisRequestSet (

1385 PADAPTER pAdapter,

1386 NDIS_0ID Oid,

1387 PVOID Buffer,

1388 ULONG BufferSize)

1389 (

1390 NDIS_STATUS Status;

1391 ULONG BytesNeeded, BytesWritten; 1392

1393 pAdapter->Request . RequestType - NdisRequestSetlnformation;

1394 pAdapter->Request .DATA.QUERY_INFORMATION.Oid - Oid;

1395 pAdapter->Request. DATA.QUERY_INFORMATION. InformationBuffer = Buffer;

1396 pAdapter->Request. DATA.QUERY_INFORMATION. InformationBufferLength » BufferSize;

1397 pAdapter->BytesNeeded = SBytesNeeded;

1398 pAdapter->BytesReadOrWritten - SBytesWritten;

1399 pAdapter->LocalRequest - TRUE; 1400

1401 NdisResetEvent! SpAdapter->BlockingEvent ) ;

1402

1403 NdisRequest (SStatus, pAdapter->LowerMPHandle, SpAdapter->Request) ;

1404

1405 77 _____^ __

1406 S#53q_g3j£3^^3^^

1407 μ

1408 if (Status — NDIS STATUSJΕNDING) ( 1409

1410 NdisWaitEvent ( SpAdapter->BlockingEvent, 0 );

1411 NdisResetEvent! SpAdapter->BlockingEvent );

1412 Status ■= pAdapter->FinalStatus;

1413 ) 1414

1415 if ( Status — STATUS NOT_SUPPORTED ) (

1416 Status - NDIS_STATUS INVALID_OID;

1417 } Status));

Figure imgf000111_0001

1424 NDIS_STATUS

1425 MPSetlnformation!

Figure imgf000111_0002
Printed by CRISP vβ_tι. 9:02 am Thursday. 30 September 1999 File: D:\nt4DDK\src\time8n\tnsdrvr\tnsemul.c Page 19 of 20

1464 IN NDIS_0ID Oid, 1465 IN PVOID InformationBuffer, dString (Oid ;

Figure imgf000112_0001
1496 return (Status) ; 1497 1498 1499 1500 VOID 1501 CLRequestComplete ( 1502 IN NDISJIANDLE ProtocolBindingContext, 1503 IN PNDIS REQUEST NdisRequest, 1504 IN NDIS STATUS Status) 1505 1506 PADAPTER pAdapter - (PADAPTER) ProtocolBindingContext,- 1507 NDIS OID Oid = pAdapter->Request .DATA. SET_INFORMATION.Oid; 1508 ULONG FoundFlag;

en;

Figure imgf000112_0002
1522 pAdapter->BytesNeeded - NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded; 1523 1524 D((0, "CLRequest Complete, TNSNdisHandle -> *x, Status -> %x, (*x) Oid -> s\n", 1525 pAdapter->TNSNdisHandle, 1526 Status, 1527 Oid, 1528 GetNDISOidString (Oid, SFoundFlag) ) ) ; 1529 1530 NdisMQuerylnformationComplete (pAdapter->TNSNdisHandle, Status) ; 1531 1532 break; 1533 1534 case NdisRequestSetlnformation: 1535 1536 *pAdapter->BytesReadOrWritten - NdisRequest->DATA.SET_INFORMATION.BytesRead; 1537 *pAdapter->BytesNeeded - NdisRequest->DATA.SET_INFORMATION. BytesNeeded; 1538 1539 NdisMSetlnformationComplete (pAdapter->TNSNdisHandle, Status) ; 1540 break; 1541 1542 default: 1543 ASSERT (0), 1544 break;

Printed by CRISP vβJ2.1_ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\-nsdrvr\tnsemul.c Page 20 of 20

1545 )

1546 )

1547 ) μ gl3&φesψlS£®ES

1548 *"" ~ " "" *" 1549

1550 1551

Printed by CRISP vβ_i.ι_ 9:02 am Thursday, 30 September 1999

File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 1 of 12

Figure imgf000114_0001

35 #include "tns . h"

36 ((include "tnsdebug . h"

37 #include "x86. h" 38

39 VOID

40 MPReturnPacket (

41 IN NDISJIANDLE MiniportAdapterContext ,

42 IN PNDIS PACKET Packet ) ; 43

44 NDIS JTATUS

45 CLReceivelndication !

46 IN NDIS HANDLE ProtocolBindingContext,

47 IN NDIS HANDLE MacReceiveContext,

48 IN PVOID HeaderBuffer,

49 IN UINT HeaderBufferSize,

50 IN PVOID LookAheadBuffer,

51 IN UINT LookaheadBufferSize,

52 IN UINT PacketSize) ; 53 54 VOID

55 CLReceiveComplete (

56 IN NDISJIANDLE ProtocolBindingContext ) 57 58 NDIS_STATUS

59 MPTransferData (

60 OUT PNDIS PACKET Packet,

61 OUT PUINT BytesTransferred,

62 IN NDIS HANDLE MiniportAdapterContext,

63 IN NDIS HANDLE MiniportReceiveContext,

64 IN UINT ByteOffset,

65 IN UINT BytesToTransfer) ; 66 67 VOID

68 CLTransferDataComplete (

69 IN NDIS HANDLE ProtocolBindingContext,

70 IN PNDIS PACKET pNdisPacket,

71 IN NDIS STATUS Status,

72 IN UINT BytesTransferred) ; 73

74 75 VOID

76 MPReturnPacket (

77 IN NDIS HANDLE MiniportAdapterContext,

78 IN PNDIS_PACKET Packet) 79 ( 80 PADAPTER pAdapter = ( PADAPTERlMiniportAdapterContex

81 PTNS PACKET CONTEXT PktContext;

82 PNDIS PACKET MPPacket;

Printed by CRISP vβ__l_ 9:OS am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 2 of 12

pAdapter, Packet)); );

6 ) ~ 0)

Figure imgf000115_0001

Printed by CRISP vβ__ι. 9:OS am Thursday. 30 September 1 999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\recv.c Page 3 of 12

165 pEtherType = (unsigned short *) spHeaderBuf er[12] ; 166 167 168 169 M 170 if ( TNS_EMULATION__ETHERTYPE-_ wswap ('pEtherType) ) ( 171 return TRUE;

Figure imgf000116_0001
181 NDIS STATUS 182 CLReceivelndication ( 183 IN NDIS HANDLE ProtocolBindingContext, 184 IN NDIS HANDLE MacReceiveContext, 185 IN PVOID HeaderBuffer, 186 IN UINT HeaderBufferSize, 187 IN PVOID LookaheadBuffer, 188 IN UINT LookaheadBufferSize, 189 IN UINT PacketSize) 190 191 PADAPTER pAdapter (PADAPTER) ProtocolBindingContext; 192 PSINGLE_LIST ENTRY ResidualEntry NULL; 193 PTNS_PACKET_CONTEXT PktContext; 194 PNDIS_BUFFER LookaheadNdisBuffer; 195 PNDIS_PACKET OurPacket; 196 NDIS_STATUS Status; 197 NDIS_STATUS OurPacketStatus-NDIS_STATUS_SUCCESS; 198 PVOID vBuffer; 199 NDIS ΗYSICAL ADDRESS HighAddress - NDIS_PHYSICAL_ADDRESS_CONST ( -1, -1 ) 200 int i; 201 202 DM( (DEBUG VERBOSE, DEBUG MASKEN ENTRYEXIT, "CLReceivelndication ->\n")); 203 204

Figure imgf000116_0002
242 MyAssert (pTnsPacket !- NULL); 243 244 245

Printed by CRISP v--_1- 9:05 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 4 of 12 ;

) ;

Figure imgf000117_0001

Printe by CRISP vβ__ι_ 9:OS am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 5 of 12

sts) ;

Figure imgf000118_0001

356 MyAssert (pRequestObj ) ;

357

358 pRqstData - C0NTAINING_RECORD (pRequestObj,

359 REQUEST_DATA,

360 Linkage); 361

362 MyAssert (pRqstData) ;

363 364 365 366

367 pRqstData->pNdisPacket = NULL;

368 pRqstData->requestOpcode - TNSJXEADJIEQUEST;

369 pBuffer = (unsigned char * ) pRqstData->TnsPacket;

370 RtlCopyMemory (pBuffer, HeaderBuffer, HeaderBufferSize) ;

371 RtlCopyMemory UpBuffer l HeaderBufferSize ] , LookaheadBuffer, LookaheadBufferSiz -2 e) ;

372

373 ffl-

37 f m s^ sm ? 5 m

376 ExInterlockedlnsertTailList!

377 SpAdapter->ServerWorkerListEntry,

378 SpRqstData->Linkage,

379 SpAdapter->ServerWorkerListSpinLock) ; 380

381 382 383

384 KeReleaseSemaphore (

385 spAdapter->ServerWorkerRequestSemaphore,

386 (KPRIORITY) 0,

387 (LONG) 1,

388 FALSE) ;

389 ) 390

391 if (pAdapter->TNSMemoryType — NONPAGED_MEMORY) !

392 PNDIS_PACKET MyPacket;

393 ULONG PacketLength;

394 PVOID pTnsBuffer;

395 NTSTATUS Status;

396 PUCHAR vBuffer; 397

398 vBuffer = pAdapter- >TNSSharedMemoryPtr; 399

400 PacketLength = TNS_PACKET_SIZE (TNSPacketReadReply) ; 401

402 Status - TNSInitializeClientNodeSendPacket (pAdapter,

403 SMyPacket,

404 SpTnsBuffer,

405 PacketLength) ;

Printed by CRISP vβ_Li. 9:05 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 6 of 12 6) ;

st st (PTNSPacketReadRequestIpTnsP <= pAdapter->T vBuffer) ; ) ;

, LookaheadBu ferSize) ;

Figure imgf000119_0001

P1 --U by CRISP ___-1- 9:05 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 7 of 12 sts) ;

Figure imgf000120_0001
510 pRqstData - CONTAINING JXECORD (pRequestObj , 511 REQUESTJ3ATA, 512 Linkage) ; 513 514 515 516 517 pRqstData->pNdisPacket - NULL; 518 pRqstData->requestOpcode - TNS »RITEJ__3UEST; 519 pBuffer - (unsigned char * ) spRqstData->TnsPacket; 520 RtlCopyMemory (pBuffer, HeaderBuffer, HeaderBufferSize ) ; 521 RtlCopyMemory (spBuffer [HeaderBufferSize] , LookaheadBuffer, LookaheadBufferSiz

-2 e) ; 522 523 524 525 526 ExInterlockedlnsertTailList ( 527 spAdapter->ServerWorkerListEntry, 528 SpRqstData- -Linkage, 529 SpAdapter->ServerWorkerListSpinLock) 530 531 532 533 534 KeReleaseSemaphore ( 535 SpAdapter->ServerWorkerRequestSemaphore, 536 (KPRIORITY) 0, 537 (LONG) 1, 538 FALSE) ; 539 i 540 541 if (pAdapter->TNSMemoryType — NONPAGEDJffiMORY) ( 542 543 PNDIS J'ACKET MyPacket; 544 ULONG PacketLength; 545 PVOID pTnsBuffer; 546 NTSTATUS Status; 547 PUCHAR vBuffer; 548 549 is 550 551 vBuffer - pAdapter->TNSSharedMemoryPtr; 552 553 vBuffer - (PUCHAR) ( (ULONG)vBuffer+(ULONG)dwswap( ((PTNSPacketWriteRequest)pTn

-2 sPacket ) ->RequestOf f set ) ) ; 554 555 if (dwswa ( ( (PTNSPacketWriteRequest)pTnsPacket)->RequestOffset) <= pAdapter-

-2 >TNSSharedMemorySize ) ( 556 *( (PULONG)vBuffer) - ( (PTNSPacketWriteRequest)pTnsPacket)->dwData; 557 ) else ( 558 _asm int 3 559 ) 560 561 562

Printed by CRISP vβ__1. θ:05 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 8 of 12

563 564 565 PacketLength = TNSJΑCKET__SIZE(TNSPacketWriteReply) ; 566 Status =• TNSInitializeClientNodeSendPacket (pAdapter, 567 SMyPacket, 568 SpTnsBuffer, 569 PacketLength) ; 570 571 RtlCopyMemory (pTnsBuffer, S ( (PTNSPacketWriteRequest) pTnsPacket ) ->MACSrcAddres

-2 s, 6) ; 572 ΨJ 573 574 "p" ' "' ~"~ 575 ( (PTNSPacketWriteReply)pTnsBuffer)->TNSCommandReply - wswap(TNS »RITE_ACK) ; 576 ( (PTNSPacketWriteReply)pTnsBuffer) --RequestTag = ( (PTNSPacketWriteReques

-2 t ) pTnsPacket ) --RequestTag; 577 ( (PTNSPacketWriteReply)pTnsBuffer)->RequestStartTSC = ( (PTNSPacketWriteReques

-2 t)pTnsPacket) ->RequestStartTSC; 578

LookaheadBufferSize) ;

Figure imgf000121_0001
629 spAdapter->ClientWorkerListEntry, 630 SpRqstData--Linkage, 631 SpAdapter->ClientWorkerListSpinLock) ; 632 633 634 635 636 KeReleaseSemaphore ( 637 SpAdapter->ClientWorkerRequestSemaphore, 638 (KPRIORITY) 0, 639 (LONG) 1, 640 FALSE) ; 641

Printed by CRISP vβ-2.1- 9:05 am Thurβday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 9 of 12

642 r^_^_^@ii__-^___-^°^^__i-^ ^_?'- ^^_ 643 644 __f ""* 645 break; 646 case TNS QUERY_STATS : ( 647 648 ' PLISTJ-NTRY pRequestόb] ; 649 PREQUEST _DATA pRqstData; 650 unsigned char *pBuffer; 651 652 PNDIS_PACKET MyPacket; 653 ULONG PacketLength; 654 PTNSPacketQueryStatsReply pTnsBuffer; 655 NTSTATUS Status; 656 NDIS_STATUS NdisStatus; 657 PUCHAR vBuffer; 658 659 TnsIncrementStat (pAdapter, spAdapter->MyStats . numSrvQueryStats ) ; 660 661 vBuffer - pAdapter->TNSSharedMemoryPtr; 662 663 PacketLength = TNS_PACKET_SIZE (TNSPacketQueryStatsReply) ; 664 665 Status - TNSInitializeClientNodeSendPacket (pAdapter, 666 SMyPacket, 667 SpTnsBuffer, 668 PacketLength) ; 669 670 RtlCopyMemory (pTnsBuffer, ( (PTNSPacketHeader) pTnsPacket ) ->MACSrcAddress, 6) j 671 672 673 674 pTnsBuffer->TNSCommandReply - wswap (TNS_QUERY_STATS_REPLY) ; 675 676 pTnsBuffer->RequestTag - ( ( PTNSPacketQueryStats ) pTnsPacket ) ->RequestTag; 677 pTnsBuffer->RequestStartTSC = ( ( PTNSPacketQueryStats ) pTnsPacket ( -- RequestStartTSC

-2 678 679 RtlCopyMemory ( SpTnsBuffer->TnsNodeStatistics , SpAdapter->MyStats , sizeof (STATISTI

-2 CS) ) ; 680 RtlCopyMemory ( spTnsBuffer->MpStats , spAdapter->mpStats, sizeo (MPSTATS ) ) ; 681 682 pTnsBuffer->NdisStatus - STATUS_SUCCESS ; 683 684 TNSSendPackets (pAdapter->LowerMPHandle, SMyPacket , 1 ) ; 685 686 ) 687 break; 688 689 case TNS CLEAR STATS: 690 691 692 RtlZeroMemory (SpAdapter->MyStats, sizeof (STATISTICS) 693 RtlZeroMemory (spAdapter->mpStats, sizeof (MPSTATS) ); 694 695 break; 696

Figure imgf000122_0001

Printed by CRISP wβ__l_ 9:OS am Thursday. 30 September 1999 File: D:\nt4DDK\src\time8n\tn8drvr\recv.c Page lO of 12 ; rSize) ; eadBuffer, LookaheadBuf ferSize) ;

Figure imgf000123_0001

747

748 case TNS_STRING_WRITE_REQUEST:

749 D( (0, "TNS_STRING_WRITE_REQUEST\n") ) ;

750 MyAssert (0);

751 if (TNSSharedMemoryNodeEmulation) (

752 ) else (

753 )

754 break;

HeaderBuffer, HeaderBufferSize)) LookaheadBuffer, LookaheadBuffer

Figure imgf000123_0002

7 77776 ) m sBB semtsm

778

779 ) else (

780 D ( (0, "HeaderBufferSize not equal to or gt than 14 , HeaderBufferSize -> *d\n", HeaderBufferSize) ) -2 ;

781 _asm int 3

782 ) 783

784 DM((DEBUG_VERBOSE, DEBUG_MASKEN_RECV, "HeaderBuffer -> *x, HeaderBufferSize -> »x, LookaheadBuffer => -2 %x, LookaheadBufferSize -> %x\n",

785 HeaderBuffer,

786 HeaderBufferSize,

787 LookaheadBuffer,

788 LookaheadBufferSize) ) ; 789

790 NdisAllocatePacket (SStatus, SOurPacket, pAdapter-- PacketPoolHandle) ;

791

792 NdisReinitializePacket (OurPacket) ;

793

794 DM ( ( DEBUG ERBOSE, DEBUG MASKEN_RECV, "CLReceivelndication: OurPacket => *x\n", OurPacket ) ) ;

795

796 MyAssert (OurPacket->Private. Head — NULL) ;

797

798 NDIS 3ETJ?ACKET STATUS (OurPacket, OurPacketStatus) ;

799

Printed by CRISP «β__ι. 9:05 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 11 of 12

800 Status - NdisAllocateMemoryfSvBuffer, 2000, 0, HighAddress); 801

802 if (Status !- NDIS_STATUS_SUCCESS) (

803 Breakpoint ();

804 ) 805

806 NdisAllocateBuffer! SStatus,

807 SLookaheadNdisBuffer,

808 pAdapter->LookaheadPoolHandle,

809 vBuffer,

810 2000); 811

812 if (Status != NDIS_STATUS_SUCCESS) (

813 Breakpoint ();

814 } 815

816 DM( (DEBUG VERBOSE, DEBUG_MASKEN RECV, "CLReceivelndication: LookaheadNdisBuffer ■=> %x\n", LookaheadNd

-2 isBuffer) ) ; 817

818 PktContext - PACKET_CONTEXT_FROM_PACKET (OurPacket ) ;

819

820 DM( (DEBUG_VERBOSE, DEBUG_MASKEN_RECV, " (%08X) CLReceivelndication : Packet *08X PacketSize *d »s\n",

821 pAdapter, OurPacket, PacketSize,

822 (PacketSize != LookaheadBufferSize ? " (RD) " : "") ) ) ; 823

824 PktContext->OriginalPacket = NULL;

825

826 if (pAdapter->CopyLookaheadData) (

827 NdisMoveMemory (vBuffer, HeaderBuffer, HeaderBufferSize) ;

828 NdisMoveMemory ( (CHAR * ) vBuffer+HeaderBuf ferSize, LookaheadBuffer, LookaheadBufferSize ) ;

829 ) else (

830 TdiCopyLookaheadData (vBuffer, HeaderBuffer, HeaderBufferSize, 0) ;

831 TdiCopyLookaheadData ! (CHAR ' ) vBuff er-fHeaderBuf ferSize, LookaheadBuffer, LookaheadBufferSize, 0) ;

832 ) 833

834 NdisAdjustBufferLength (LookaheadNdisBuffer, HeaderBufferSize+LookaheadBufferSize) ;

835 NDIS_SET_PACKET_HEADER_SIZE (OurPacket, HeaderBufferSize) ;

836 NdisChainBufferAtFront (OurPacket, LookaheadNdisBuffer) ; 837

838 DUMPJΑCKET (OurPacket) ;

839

840 DM( (DEBUG_VERBOSE, DEBUG_MASKEN RECV, "Adapter->TNSNdisHandle -> %x, OurPacket ?> %x\n", pAdapter- >TN -2 SNdisHandle, OurPacket ) ) ;

841 NDIS SET_PACKET_STATUS (OurPacket, NDIS STATUS_RESOURCES ) ; 842

843 NdisMIndicateReceivePacket (pAdapter- - TNSNdisHandle, SOurPacket, 1 ) ;

844

845 if ( NDIS GET PACKET_STATUS (OurPacket) != NDIS STATUS JPENDING) (

846 MPReturnPacket * (NDISJlANDLE)pAdapter, OurPacket ) ;

847 ) 848

849 DM( (DEBUG_VERBOSE, DEBUG_MASKEN_ENTRYEXIT, "CLReceivelndication <=\n") ) ;

850 return NDIS_STATUS SUCCESS; 851

8 β5s32 ) immsasβsBEm 854

855 VOID

856 CLReceiveComplete (

857 IN NDIS_HANDLE ProtocolBindingContext)

858 (

859 PADAPTER pAdapter ■= (PADAPTER) ProtocolBindingContext ; 860

861 . DM( (DEBUG_VERBOSE, DEBUG JiASKENJOTRYEXIT, "CLReceiveComplete ->\n" ) ) ;

862

863 if (pAdapter->TNSDriverInitialized) (

864

865 switch ! pAdapter- -MediaType ) (

866 case NdisMediumβ02_3 :

867 DM( (DEBUG_VERBOSE, DEBUG_MASKEN_RECV, " (%08X) CLReceiveComplete : 802_3\n", pAdapter) ) ;

868 NdisMEthlndicateReceiveComplete ! pAdapter->TNSNdisHandle ) ;

869 break; 870

871 case NdisMedium802_5:

872 D( (0, " (%08X) CLReceiveComplete: 802 5\n", pAdapter) ) ;

873 Breakpoint ! ) ;

874 NdisMTrlndicateReceiveCoiαplete! pAdapter-- NSNdisHandle ) ;

875 break; 876

877 case NdisMediumFddi:

878 D((0, "(%08X) CLReceiveComplete: FDDIXn", pAdapter));

879 Breakpoint!); pπnted by CRISP vβ_j.ι. 9:05 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 12 of 12

880 NdisMFddilndicateReceiveCompletel pAdapter--TNSNdisHandle );

881 break; 882

883 default:

884 MyAssert! FALSE );

885 )

886 ) else {

887 Breakpoint ( ) ;

888 ) 889

890 DM( (DEBUG_VERBOSE, DEBUG MASKEN_ENTRYEXIT, "CLReceiveComplete <=\n") ) ;

891 """

892

893 NDIS_STATUS

894 MPTransferData (

895 OUT PNDIS_PACKET Packet,

896 OUT PUINT BytesTransferred,

897 IN NDISJIANDLE MiniportAdapterContext,

898 IN NDISJIANDLE MiniportReceiveContext,

899 IN UINT ByteOffset,

900 IN UINT BytesToTransfer)

901 (

902 PADAPTER Adapter - ( PADAPTER) MiniportAdapterContext; 903

904 D( (0, " ( %08X) MPTransferData: \n", Adapter) ) ;

905 Breakpoint ( > ;

906 return NDIS STATUS_FAILURE;

907 } g8Si_S-_it_-li

908

909 VOID

910 CLTransferDataComplete (

911 IN NDISJIANDLE ProtocolBindingContext,

912 IN PNDISJ?ACKET Packet,

913 IN NDIS_STATUS Status,

914 IN UINT BytesTransferred)

915 (

916 PADAPTER pAdapter - (PADAPTER) ProtocolBindingContext;

917 PTNS PACKET_CONTEXT PktContext; 918

919 DM( (DEBUG_VERBOSE, DEBUG_MASKEN ENTRYEXIT, "CLTransferComplete «=>\n") ) ;

920 D( (0, " (»08X) CLTransferDataComplete: Packet %08X Status %08X Bytes xfer'ed %d\n",

921 pAdapter, Packet, Status, BytesTransferred) ) ; 922

923 PktContext - PACKET JXJNTEXT "RO JΑCKET ( Packet ) ;

924

925 NdisChalnBuf ferAtFront (Packet, PktContext->LookaheadBu er) ;

926

927 NdisMIndicateReceivePacket (pAdapter->TNSNdisHandle, SPacket, 1 ) ;

928

929 if ( NDIS_GET_PACKET_STATUS (Packet) !- NDIS STATUS J?ENDING) (

930 MPReturnPacket ( (NDISJIANDLE) pAdapter, Packet) ;

931 ) 932

933 DM((DEBUG VERBOSE, DEBUG_MASKEN ENTRYEXIT, "CLTransferComplete <-\n"));

934 ) 935 936

Pri ted _ CRiβPvβ__i- 9:θ5 am Thursday, 30 September 1999

File: D:\nt40DK\src\time8n\tnsdrvr\send.c Page 1 of 3

Figure imgf000126_0001
34 # include "tnsdebug.h" 35 •include "x86.h" 36 37 #define MAX_LOCAL_PACKET_ARRAY 10 38 39 VOID 40 MPSendPackets ( 41 IN NDISJIANDLE MiniportAdapterContext, 42 IN PPNDISJ?ACKET PacketArray, 43 IN UINT NumberOfPackets 44 ) ; 45 46 47 VOID 48 CLSendComplete ( 49 IN NDISJIANDLE ProtocolBindingContext, 50 IN PNDIS_PACKET Packet, 51 IN NDISJ3TATUS Status 52 ); 53 54 VOID 55 MPSendPackets ( 56 IN NDISJIANDLE MiniportAdapterContext, 57 IN PPNDIS_PACKET PacketArray, 58 IN UINT NumberOfPackets) 59 < 60 PADAPTER pAdapter" (PADAPTER)MiniportAdapterContext; 61 PNDIS_PACKET Packet; 62 PNDIS_PACKET MyPacket; 63 PNDIS_PACKET MyPacketArray[MAX_LOCAL_PACKET_ARRAY] ; 64 65 PSINGLE LIST_ENTRY PacketEntry - NULL; 66 PTNS PACKET CONTEXT PktContext; 67 PNDIS_BUFFER FirstBuffer; 68 PNDIS_PACKET COB DATA MyOOBData; 69 PNDIS_PACKET__OOB__DATA OOBData; 70 ULONG PacketLength, i; 71 ULONG NumMyPackets-0; 72 NDIS_STATUS Status; 73 74 DM((DEBUG_VERBOSE, DEBUG_MASKEN_ENTRYEXI , "MPSendPackets ->\n") ) ; 75 DM((DEBUG_VERBOSE, DEBUG_MASKEN_SEND, "(*08X) MPSendPackets: %d XPORT packetsNn", pAdapter, Numt -2 ackets)); 76
Figure imgf000126_0002

Printed by CRISP vβ__1 • 9:OS am Thursday, 30 September 1999 File: D:\nt4DDK\src\tlmesn\-nsdrvr\send.c Page 2 of 3

82 Breakpoint ( ) ;

PacketEntry) ) ;

Figure imgf000127_0001
108 109 NdisQueryPacket ( Packet, NULL, NULL, SFirstBuffer, SPacketLength ) ; 110 111 NdisChainBuf ferAtFront (MyPacket , FirstBuffer) ; 112 113 NdisSetPacketFlags (MyPacket , NdisGet Packet Flags ( Packet ) ) ; ) ) ;

Figure imgf000127_0002
130 131 132 133 134 DUMP_PACKET (MyPacket ) ; 135 MyPacketArray[NumMyPackets++] - MyPacket; 136 ) 137 138 if (NumMyPackets ) ( 139 int FoundFlag; 140 for ( i-0; KNumMyPackets; i++) ( 141 DM ( (DEBUG_VERBOSE, DEBUG MASKEN_SEND, "MPSendPackets, Packet Status -> %x, %s\n", 142 NDIS GET PACKET_STATUS (MyPacketArray [i] ) , 143 GetNDISStatusString (NDIS_GET_PACKET_STATUS (MyPacketArray [i] ) , SFoundFlag) ) ) ; 144 ) 145 NdisSendPackets (pAdapter->LowerMPHandle, SMyPacketArray [0] , NumMyPackets) j 146 ) 147 148 DM( (DEBUG VERBOSE, DEBUG_MASKEN_ENTRYEXIT, "MPSendPackets <-\n") ) 149 ) 150

151 int printbuftime 152

153 VOID

154 CLSendComplete (

155 IN NDISJIANDLE ProtocolBindingContext ,

156 IN PNDIS_PACKET Packet,

157 IN NDIS STATUS Status)

158 {

159 PADAPTER pAdapter = ( PADAPTER) ProtocolBindingContext;

160 PTNS_PACKET_CONTEXT PktContext;

161 int FoundFlag;

162 int SMNEmulationPacket;

163 PNDIS BUFFER MyBuffer;

9:OS am Thurβday, 30 September 1999 File: D:\nt4DDK\src\time8n\tnsdrvr\send.c Page 3 of 3

164 PTNSPacketReadRequest BufContext;

165 UINT Length; 166

167 DM( (DEBUG_VERBOSE, DEBUG_MASKEN ENTRYEXIT, "CLSendComplete =>\n" ) ) ;

168

169 DM( (DEBUG ERBOSE, DEBUG 1ASKEN_SEND, "CLSendComplete, Packet Status => %x, *s\n",

170 NDIS GET_PACKET_STATUS ( Packet ) ,

171 GetNDISStatusString (NDIS GET_PACKET_STATUS ( Packet ) , SFoundFlag) ) ) ; 172

173 PktContext - PACKET_CONTEXTJTROMJ>ACKET ( Packet ) ;

174 SMNEmulationPacket - PktContext->SMNEmulationPacket; 175

176 DUMP_PACKET ( Packet ) ;

177 if (PktContext->OriginalPacket) (

178 DUMP_PACKET (PktContext->OriginalPacket) ;

179 DM( (DEBUG_VERBOSE, DEBUG MASKEN_SEND, "CLSendComplete, Packet Status -> *x, %s\n",

180 NDIS_GET_PACKET_STATUS (PktContext->OriginalPacket) ,

181 GetNDISStatusString (NDIS_GET_PACKET_STATUS ( PktContext->OriginalPacke ) , SFoundFlag) ) ) ;

182 ) 183

184 if (SMNEmulationPacket) (

185 NdisUnchainBufferAtFron (Packet, SMyBuffer);

186 NdisQueryBufferlMyBuffer, SBufContext, SLength) ;

187 NdisFreeBuffer(MyBuffer);

188 NdisFreeMemory(BufContext, Length, 0) ;

189 )

Figure imgf000128_0001

197 if (SMNEmulationPacket — FALSE) (

198 NdisMSendComplete (pAdapter- >TNSNdisHandle, PktContext->OriginalPacket, Status) ;

199 ) 200

201 D ( (DEBUG VERBOSE, DEBUG_MASKEN_ENTRYEXIT, "CLSendComplete <=\n" ) ) ;

202 i »@m__»iii

203 204 205

Printed by CRISP vβ__ι_ 9:05 am Thursday, 30 September 1999

File: D:\nt4DDK\src\timesn\tnsclien\tnsclien.h Page 1 of 2

Figure imgf000129_0001
40 •define FILE DEVICE TNSCLIENT 0x00008300 41 42

Figure imgf000129_0002
50 Idefine TNSCLIENT IOCTL INDEX 0x830 51 52 53 54 55 Idefine I0CTL_TNSCLIENT_HELL0 CTL_CODE(FILE_DEVICE_TNSCLIENT, \ 56 TNSCLIENT_IOCTL_INDEX, \ 57 METHOD_BUFFERED, \ 58 FILE_ANY_ACCESS) 59 60 Idefine IOCTL TNSCLIENT_GET LOCAL_STATS CTL_CODE(FILE_DEVICE_TNSCLIENT, \ 61 TNSCLIENT_IOCTL_INDEX+l, \ 62 METHODJ3UFFERED, \ 63 FILE NY_ACCESS) 64 65 Idefine IOCTL_TNSCLIENT_GET SMN STATS CTL_CODE(FILE DEVICE_TNSCLIENT, \ 66 TNSCLIENT_I0CTL_INDEX+2, \ 67 METHOD_BUFFERED, \ 68 FILE_ANY_ACCESS) 69 70 71 Idefine IOCTL TNSCLIENT_GET_SMN_INFO CTL_CODE(FILE_DEVICE_TNSCLIENT, \ 72 TNSCLIENT_IOCTL_INDEX+3, \ 73 METHOD BUFFERED, 74 FILE_ANY_ACCESS) 75 76 Idefine IOCTL TNSCLIENT_GET LOCAL_INFO CTL CODE(FILEJDEVICEJTNSCLIENT, \ 77 TNSCLIENT IOCTL_INDEX+4 , \ 78 METHOD_BUFFERED, \ 79 FILE_ANY ACCESS) 80 81 82 Idefine IOCTL TNSCLIENT DOTEST CTL_CODE(FILE_DEVICE_TNSCLIENT, \

Printed by CRISP vβ-_.l_ Θ:S8 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsciien\tnsclien.h Page 2 of 2

83 TNSCLIENT_IOCTL INDEX+5, \

84 METHOD_BUFFERED7 \

85 FILE_ANY_ACCESS)

86

87 Idefine IOCTL TNSCLIENT_CLEAR_STATS CTL CODE ( FILEJJEVICE TNSCLIENT, \

88 ~ TNSCLIENT_IOCTL NDEX+6, \

89 METHOD_BUFFERED, \

90 FILE_ANY ACCESS ) 91

92

93 Idefine IOCTL_TNSCLIENT_GET_SMN TABLE_INFO CTL_CODE(FILE_DEVICE_TNSC IENT, \

94 ~ TNSCLIENT_IOCTL_INDEX+7, \

95 METHOD_BUFFERED, \

96 FILE_ANY ACCESS) 97

98 Idefine IOCTL TNSCLIENT GET_NODE_INFO CTL_CODE(FILE_DEVICE TNSCLIENT, \

99 " TNSCLIENT_IOCTL_INDEX+8, \

100 METHOD_BUFFERED, \

101 FILE_ANY_ACCESS) 102

103 104 105

Figure imgf000130_0001

114 int MaxNu Reads;

115 int MaxNumReadWrites; 116

117 STATISTICS Stats;

118 MPSTATS MpStats; 119

120 unsigned char MacAddress [ETHERNET ADDRESSJ.EN] ;

121 unsigned char ComputerName [MAX_COMPUTER_NAME_LEN] ;

122 unsigned long TeamNodelD;

123 unsigned long TNSSharedMemorySize; 124

125 unsigned long TestStatus; 126

127 unsigned long DebugPrintFlag;

128 unsigned long DebugPrintMask; 129

130 SMNTablelnfo SMNInfo[MAX TEAMJTODES] ;

131

132 ) IO_DRIVER_PACKET, *pIO_DRIVERJΑCKET;

133

134

135

136

137

Prtnt- y cRiβpvβ__ι. 8:58 am Thursday, 30 September 1999

File: D:\nt4DDK\src\timesn\tnsclien\_nscllen.c Page 1 of 9

Figure imgf000131_0001

31 include <ntddk.h>

32 Iinclude <stdarg.h>

33 linclude <stdio.h>

34 linclude "tnsstats.h"

35 linclude "tnsclien.h"

36 linclude -xββ.h"

Figure imgf000131_0002

43 typedef struct DEVICE_EXTENSION (

44 ULONG S tat -Variable,

45 ) DEVICEJXTENSION, *PDEVICEJ_XTENSION;

46

47

48 VOID GetSidt (PVOID) ;

49

50

51 ULONG GTestFlag-10;

52 ULONG _gPrintStats = 0; 53

54

55 extern unsigned char *MyTrap0E;

56

57

58 NTSTATUS

59 TNSClientDrvDispatch(

60 IN PDEVICEJ3BJECT DeviceObject,

61 IN PIRP Irp

62 ); 63

64 VOID

65 TNSClientDrvUnload(

Figure imgf000131_0003

Printed by CRISP vα__1_ 8:58 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsclien\tnsclien.c Page 2 of 9

g aaaft _.__a_-r_____i __.

Figure imgf000132_0001
β:5β am Thursday, 30 September 1999 File: D:\nt4DDK\src\time8n\tnscllen\tnsclien.c Page 3 of 9

165 ( ^iiafϊ i ^

Figure imgf000133_0001
199 NTSTATUS

TNSCLIEN-.- ces\\TNSCLIEN";

Figure imgf000133_0002

Printed by CRISP vβ__1 • 8:58 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsclien\tnsclien.c Page 4 of 9

Figure imgf000134_0001
255 256

; SdeviceName odeString) ;

- TNSClien

Figure imgf000134_0002

Figure imgf000134_0003
328

Pri ted by CRISP vβjti- 8:58 am Thursday, 30 September 1999 File: D:\nt4DDK\src\time8n\tn8cllen\tnsclien.c Page 5 of 9

329 330 ULONG 331 _declspec (dllimpor ) 332 TNS_WRITE_REGISTER_ULONG ( 333 PVOID DeviceContext, 334 PULONG Register, 335 ULONG RegisterData) ; 336 337 338 ULONG 339 _declspec (dllimport ) 340 TNS_GET_SMN_STATISTICS ( 341 IN PVOID DeviceHandle, 342 IN OUT PSTATISTICS pStatistics, 343 IN OUT PULONG pStatsStructSize, 344 IN OUT pMPSTATS pMpStats, 345 IN OUT PULONG pMpStatsSize); 346 347 ULONG 348 _declspec (dllimport ) 349 TNS GET_NODE_STATISTICS ( 350 IN PVOID DeviceHandle, 351 IN OUT PSTATISTICS pStatistics, 352 IN OUT PULONG pStatsStructSize, 353 IN OUT pMPSTATS pMpStats, 354 IN OUT PULONG pMpStatsSize); 355 356 357 358 ULONG 359 _declspec (dllimport ) 360 TNS CLEAR_NODE_STATISTICS ( 361 IN PVOID DeviceHandle) ; 362 363 ULONG 364 _declspec (dllimport) 365 TNSJ__EAR_SMN STATISTICS ( 366 IN PVOΪD DeviceHandle); 367 368 ULONG 369 declspec (dllimport) 370 _TNS GET_SMN_INFORMATION( 371 IN PVOID DeviceHandle, 372 IN OUT unsigned char 'pMacAddress, 373 IN OUT unsigned char *pNodeName, 374 IN OUT unsigned long 'pSharedMemorySize) i 375 376 ULONG 377 _declspec (dllimport ) 378 TNS GET_SMN_TABLE_INFO( 379 IN PVOID DeviceHandle, 380 IN OUT pSMNTablelnfo pSMNInfo) ; 381 382 ULONG 383 _declspec (dllimport ) 384 TNS GET_SMN STATISTICS_BY_NODEID ( 385 IN PVOID DeviceHandle, 386 IN ULONG NodelD, 387 IN OUT PSTATISTICS pStatistics, 388 IN OUT PULONG pStatsStructSize, 389 IN OUT pMPSTATS pMpStats, 390 IN OUT PULONG pMpStatsSize); 391

Figure imgf000135_0001

Printed by CRISP vβ__l. 8:58 am Thurβday, 30 September 1999 Fil

Figure imgf000136_0001
429 NTSTATUS ntStatus; 430 int i; 431 432 ULONG ReturnCode; 433 434 435 Irp->IoStatus.Status STATUS SUCCESS; 436 Irp->IoStatus . Information 0; 437

Figure imgf000136_0002
452 deviceExtension - DeviceObject->DeviceExtension; 453 454 u fer; ferLength; fferLength;
Figure imgf000136_0003
464 465 466 switch (irpStack->MajorFunction) { 467 case IRP_MJ_CREATE: 468 469 break; 470 471 case IRP W_CLOSE: 472 473 break; 474 475 case IRP_MJ_DEVICE_CONTROL: 476 477 loControlCode - irpStack->Parameters . DeviceloControl . loControlCode; 478 479 switch (loControlCode) ( 480 481 case IOCTL_TNSCLIENT_GET_NODE_INFO: ( 482 ULONG StatsLen, mpStatsLen; 483 484 mpStatsLen = sizeof(MPSTATS) ; 485 StatsLen - sizeof(STATISTICS) ; 486 487 _TNS_GET SMN STATISTICS BY_NODEID( 488 NULL," 489 ioBuffer->TeamNodeID, 490 sioBuffer->Stats, 491 .StatsLen, 492 -ioBuffer->MpStats, rlnted By CRISP vβ__l- 8:58 am Thursday, 30 September 1999 File: D:\nt4DDK\src\time8n\tn8clien\tnsclien.c Page 7 of 9

493 .mpStatsLen ) ;

494

495 Irp->IoStatus . Information - sizeof ( IO_DRIVER_PACKET) ;

496 break; ~

497 )

498

499 case IOCTL rNSCLIENT_GET_SMN_TABLEJNEO: (

500 TNS_GET_SMN_TABLE_INFO (

501 NULL,

502 ioBuffer->SMNInfo); 503

504 Irp->IoStatus. Information = sizeof (IO_DRIVER_PACKET) ;

505 break;

506 )

507 case IOCTLJTNSCLIENT GET__SMN__INFO: (

508 TNS_GET_SMN INFORMATION !

509 NULL,

510 ioBuffer->MacAddress,

511 ioBuffer->ComputerName,

512 _ioBuffer->TNSSharedMemorySize) ; 513

514 Irp->IoStatus. Information - sizeof (IO_DRIVER_PACKET) ;

515 break;

516 ) 517

518 case IOCTLJTNSCLIENT CLEAR STATS: (

519 TNSJ-LEAR_NODE~STATISTICS (

520 NULL) ;

521 TNS_CLEARJ3MN STATISTICS !

522 NULL) ;

523 Irp->IoStatus . Information = sizeof ( IO_DRIVER_PACKET) ;

524 break;

525 ) 526

527 case IOCTL _TNSCLIENT_GET_LOCAL_INFO: (

528 TNS_GET_NODE_INFORMATION (

529 NULL,

530 ioBuffer->MacAddress,

531 ioBuf fer- - ComputerName,

532 _ioBuffer->TeamNodeID) ;

533 Irp->IoStatus . Information - sizeof ( IO_DRIVER_PACKET) ;

534 break;

535 ) 536

537 case IOCTL_TNSCLIENT_DOTEST : (

538 int i;

539 unsigned long randdata;

540 unsigned long randaddress;

541 unsigned long returndata; 542

543 if (ioBuffer-.MaxNumWrites) (

544 for (i-0; i<ioBuffer->MaxNumWrites; i++) (

545 randdata myrand32();

546 randaddress - myrand32n(ioBuffer->TNSSharedMemorySize) ;

547 TNS_WRITE_REGISTER_ULONG(NULL, (PULONG) randaddress, randdata);

548 )

549 ) 550

551 if (ioBuffer->MaxNumReads) (

552 for (i-0; i<ioBu fer->MaxNumReads; i++) (

553 randaddress = myrand32n(ioBuffer->TNSSharedMemorySize) ;

554 returndata = TNS READ_REGISTER_ULONG(NULL, (PULONG) randaddress);

555 )

556 ) 557

558 if ( ioBuffer->MaxNumReadWrites) (

559 for ( i-0; i <ioBuffer->MaxNumReadWrites; i++) (

560 randdata = myrand32 ( ) ;

561 randaddress - myrand32n (ioBuffer->TNSSharedMemorySize) ; 562

563 TNS_WRITE_REGISTER_ULONG (NULL, ( PULONG) randaddress, randdata ) ;

564 returndata - TNS_READ_REGISTER_ULONG (NULL, ( PULONG) randaddress ) ;

565 if (randdata ! - returndata ) {

566 DbgPrint ( "randdata ! - returndata, randdata -> *x, returndata «> %x\n" , ra -2 nddata, returndata ) ;

567 break;

568 )

569 )

570 ) 571

572 Irp->IoStatus . Information - sizeof ( IO DRIVE J?ACKET ) ;

573 break; pri te by CRISP -_.ι« 8:58 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsclien\tnsclien.c Page 8 of 9

574 ) 575 576 case IOCTLJΓNSCLIENT_GET_LOCAL 3TATS : 577 ULONG StatsLen, mpStatsLen? 578 579 mpStatsLen - sizeof (MPSTATS) ; 580 StatsLen - sizeof (STATISTICS) ; 581 582 TNS_GET_NODE_STATISTICS ( 583 NULL, 584 -ioBuffer->Stats, 585 -StatsLen, 586 tioBuffer->MpStats, 587 .mpStatsLen) ; 588 589 Irp->IoStatus . Information sizeof (IO DRIVER PACKET); 590 break; 591 592 593 case IOCTL_TNSCLIENT_GET_SMN_STATS : 594 ULONG StatsLen, mpStatsLen; 595 596 mpStatsLen = sizeof (MPSTATS) ; 597 StatsLen - sizeof (STATISTICS) ; 598 599 TNS_GET_SMN STATISTICS ( 600 NULL, 601 _ioBuffer->Stats, 602 .StatsLen, 603 &ioBuffer->MpStats, 604 .mpStatsLen) ; 605 606 Irp->IoStatus . Information sizeof (10 DRIVERJΑCKET) ; 607 break; 608 ) 609 610 default: 611 612 Irp->IoStatus.Status STATUS INVALID PARAMETER; 613 614 break; 615 616 617 break; 618 619

Figure imgf000138_0001
627 ntStatus - Irp->IoStatus. Status; 628 629 IoCompleteRequest (Irp, 630 IO_NO_INCREMENT 631 ) ; 632

Figure imgf000138_0002

Printed by CRISP vβ__1 • 8:58 am Thursday, SO September 1999 File: D:\nt4DDK\src\timesn\tnsclien\tnsclien.c Page 9 of 9

Figure imgf000139_0001
671 RtllnitUnicodeString (SdeviceLinkUnicodeString, deviceLinkBuffer) ; 672 673 loDeleteSymbolicLink (SdeviceLinkUnicodeString) ; 674 675 676 m

Z _Je=el-" -:tie;-__yl_:§|,-fil_ct 677 w - -» ■ -- 678 679 IoDeleteDevice (DriverObject->DeviceObject ) ; 680 )

Printed by CRISP vβ.2.1 • 8:58 am Thursday, 30 September 1999

Claims

CLAIMSWhat is claimed is:
1. A method, comprising: passing a set of interconnect fabric data through a shim layer that is interposed between an interconnect fabric interface layer and a protocol layer including: receiving said set of interconnect fabric data with said shim layer, classifying said set of interconnect fabric data with said shim layer, and handling said set of interconnect fabric data with said shim layer as a function of a transport application program interface with which said set of interconnect fabric data is associated.
2. The method of claim 1 , wherein said set of interconnect fabric data includes a packet.
3. The method of claim 1 , wherein classifying said set of interconnect fabric data includes classifying said set of interconnect fabric data as a function of said transport application program interface.
4. The method of claim 1, wherein said set of interconnect fabric data is received and then classified and then passed.
5. The method of claim 1, wherein passing includes transforming said set of interconnect fabric data.
6. The method of claim 1 , further comprising monitoring passage of said set of interconnect fabric data with a heartbeat function to expedite recovery in the event of an error.
7. The method of claim 1 , further comprising monitoring passage of said set of interconnect fabric data with sense interrupt indications to expidite recovery in the event of an error.
8. A method, comprising: passing a set of network data through a shim layer that is inteφosed between a network interface layer and a protocol layer including: receiving said set of network data with said shim layer, classifying said set of network data with said shim layer, and handling said set of network data with said shim layer as a function of a transport application program interface with which said set of network data is associated.
9. The method of claim 8, wherein said set of network data includes a packet.
10. The method of claim 8, wherein classifying said set of network data includes classifying said set of network data as a function of said transport application program interface.
11. The method of claim 8, wherein said set of network data is received and then classified and then handled.
12. The method of claim 8, wherein passing includes transforming said said of network data.
13. The method of claim 8, further comprising monitoring passage of said set of network data with a heartbeat function to expedite recovery in the event of an error.
14. The method of claim 8, further comprising monitoring passage of said set of network data with sense interrupt indications to expedite recovery in the event of an error.
15. The method of claim 8, wherein said shim hosts network middleware to handle at least one function selected from the group consisting of transmitting packets, obtaining information on local and remote multi-computer nodes, setting up packet receive sinks and controlling a protocol.
16. An apparatus, comprising: a shared memory unit; a first system coupled to said shared memory unit; and a second system coupled to said shared memory unit, wherein a data set transfered between said shared memory unit and at least one member selected from the group consisiting of said first system and said second system is received by a shim that is interposed between either i) a network device/driver and a protocol layer or ii) an interconnect fabric interface and said protocol layer, classified by said shim and handled by said shim as a function of a transport application program interface with which said data set is associated.
17. A computer system comprising the apparatus of claim 16.
18. The apparatus of claim 16, wherein the shim is inteφosed between said network device/driver and said protocol layer, and said at least one member includes a network interface card.
19. The apparatus of claim 18, wherein the network interface card provides a heartbeat function to facilitate error recovery.
20. The apparatus of claim 18, wherein the network interface card provides programable packet type identification.
21. The apparatus of claim 18, wherein the network interface card provides media sense interrupt indications to facilitate error recovery.
22. The apparatus of claim 16, wherein the shim is inteφosed between said interconnect fabric interface and said protocol layer.
23. The apparatus of claim 22, wherein said at least one member provides a heartbeat function to facilitate error recovery.
24. The apparatus of claim 22, wherein said at least one member provides programable packet type identification.
25. The apparatus of claim 22, wherein said at least one member provides media sense interrupt indications to facilitate error recovery.
26. An apparatus, comprising: a switch; a first system coupled to said switch; and a second system node coupled to said switch, wherein a data set transfered from said first system to said second system through said switch is received by a shim that is inteφosed between either i) a network device/driver and a protocol layer or ii) an interconnect fabric interface and said protocol layer, classified by said shim and handled by said shim as a function of a transport application program interface with which said data set is associated.
27. A computer system comprising the apparatus of claim 26.
28. The apparatus of claim 26, wherein the shim is inteφosed between said network device/driver and said protocol layer, and said at least one member includes a network interface card.
29. The apparatus of claim 28, wherein the network interface card provides a heartbeat function to facilitate error recovery.
30. The apparatus of claim 28, wherein the network interface card provides programable packet type identification.
31. The apparatus of claim 28, wherein the network interface card provides media sense interrupt indications to facilitate error recovery.
32. The apparatus of claim 26, wherein the shim is inteφosed between said interconnect fabric interface and said protocol layer.
33. The apparatus of claim 32, wherein said at least one member provides a heartbeat function to facilitate error recovery.
34. The apparatus of claim 32, wherein said at least one member provides programable packet type identification.
35. The apparatus of claim 32, wherein said at least one member provides media sense interrupt indications to facilitate error recovery.
36. An electronic media, comprising: a computer program adapted to pass a set of interconnect fabric data through a shim layer that is inteφosed between an interconnect fabric interface layer and a protocol layer including: receiving said set of interconnect fabric data with said shim layer, classifying said set of interconnect fabric data with said shim layer, and handling said set of interconnect fabric data with said shim layer as a function of a transport application program interface with which said set of interconnect fabric data is associated.
37. A computer program comprising computer program means adapted to perform the steps of passing a set of interconnect fabric data through a shim layer that is inteφosed between an interconnect fabric interface layer and a protocol layer including: receiving said set of interconnect fabric data with said shim layer, classifying said set of interconnect fabric data with said shim layer, and handling said set of interconnect fabric data with said shim layer as a function of a transport application program interface with which said set of interconnect fabric data is associated when said computer program is run on a computer.
38. A computer program as claimed in claim 37, embodied on a computer- readable medium.
39. An electronic media, comprising: a computer program adapted to pass a set of network data through a shim layer that is inteφosed between a network interface layer and a protocol layer including: receiving said set of network data with said shim layer, classifying said set of network data with said shim layer, and handling said set of network data with said shim layer as a function of a transport application program interface with which said set of network data is associated.
40. A computer program comprising computer program means adapted to perform the steps of passing a set of network data through a shim layer that is inteφosed between a network interface layer and a protocol layer including: receiving said set of network data with said shim layer, classifying said set of network data with said shim layer, and handling said set of network data with said shim layer as a function of a transport application program interface with which said set of network data is associated when said computer program is run on a computer.
41. A computer program as claimed in claim 40, embodied on a computer- readable medium.
PCT/US2000/026728 1999-10-13 2000-09-29 Low latency, high bandwidth multi-computer system interconnect WO2001027781A2 (en)

Priority Applications (4)

Application Number Priority Date Filing Date Title
US15908699P true 1999-10-13 1999-10-13
US60/159,086 1999-10-13
US67290900A true 2000-09-28 2000-09-28
US09/672,909 2000-09-28

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
AU76215/00A AU7621500A (en) 1999-10-13 2000-09-29 Low latency, high bandwidth multi-computer system interconnect
EP20000965512 EP1224560A2 (en) 1999-10-13 2000-09-29 Low latency, high bandwidth multi-computer system interconnect
CA 2382836 CA2382836A1 (en) 1999-10-13 2000-09-29 Low latency, high bandwidth multi-computer system interconnect

Publications (3)

Publication Number Publication Date
WO2001027781A2 true WO2001027781A2 (en) 2001-04-19
WO2001027781A3 WO2001027781A3 (en) 2001-11-29
WO2001027781A9 WO2001027781A9 (en) 2002-09-26

Family

ID=26855641

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/US2000/026728 WO2001027781A2 (en) 1999-10-13 2000-09-29 Low latency, high bandwidth multi-computer system interconnect

Country Status (4)

Country Link
EP (1) EP1224560A2 (en)
AU (1) AU7621500A (en)
CA (1) CA2382836A1 (en)
WO (1) WO2001027781A2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6920485B2 (en) 2001-10-04 2005-07-19 Hewlett-Packard Development Company, L.P. Packet processing in shared memory multi-computer systems
US6999998B2 (en) 2001-10-04 2006-02-14 Hewlett-Packard Development Company, L.P. Shared memory coupling of network infrastructure devices

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0694850A2 (en) * 1994-07-19 1996-01-31 International Business Machines Corporation Method and apparatus for distributing control messages between interconnected processing elements
US5515508A (en) * 1993-12-17 1996-05-07 Taligent, Inc. Client server system and method of operation including a dynamically configurable protocol stack
US5742607A (en) * 1995-12-20 1998-04-21 Intel Corporation Method and apparatus for controlling two way communication via disparate physical media
EP0884873A2 (en) * 1997-05-20 1998-12-16 AT&amp;T Corp. Internet protocol relay network
US6061796A (en) * 1997-08-26 2000-05-09 V-One Corporation Multi-access virtual private network
WO2000057286A1 (en) * 1999-03-19 2000-09-28 Times N Systems, Inc. Shared memory apparatus and method for multiprocessor systems

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5515508A (en) * 1993-12-17 1996-05-07 Taligent, Inc. Client server system and method of operation including a dynamically configurable protocol stack
EP0694850A2 (en) * 1994-07-19 1996-01-31 International Business Machines Corporation Method and apparatus for distributing control messages between interconnected processing elements
US5742607A (en) * 1995-12-20 1998-04-21 Intel Corporation Method and apparatus for controlling two way communication via disparate physical media
EP0884873A2 (en) * 1997-05-20 1998-12-16 AT&amp;T Corp. Internet protocol relay network
US6061796A (en) * 1997-08-26 2000-05-09 V-One Corporation Multi-access virtual private network
WO2000057286A1 (en) * 1999-03-19 2000-09-28 Times N Systems, Inc. Shared memory apparatus and method for multiprocessor systems

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6920485B2 (en) 2001-10-04 2005-07-19 Hewlett-Packard Development Company, L.P. Packet processing in shared memory multi-computer systems
US6999998B2 (en) 2001-10-04 2006-02-14 Hewlett-Packard Development Company, L.P. Shared memory coupling of network infrastructure devices

Also Published As

Publication number Publication date
WO2001027781A3 (en) 2001-11-29
WO2001027781A9 (en) 2002-09-26
EP1224560A2 (en) 2002-07-24
CA2382836A1 (en) 2001-04-19
AU7621500A (en) 2001-04-23

Similar Documents

Publication Publication Date Title
Pfister An introduction to the infiniband architecture
US8611351B2 (en) Marked packet forwarding
US9100371B2 (en) Highly scalable architecture for application network appliances
US7146431B2 (en) Virtual network environment
US7715428B2 (en) Multicore communication processing
US7478173B1 (en) Method and system for sharing a network connection in a virtual computer system
Buonadonna et al. An implementation and analysis of the virtual interface architecture
US6904519B2 (en) Method and computer program product for offloading processing tasks from software to hardware
US5640394A (en) System and method for running multiple incompatible network protocol stacks
US7257817B2 (en) Virtual network with adaptive dispatcher
US20110173295A1 (en) Offload stack for network, block and file input and output
US6678734B1 (en) Method for intercepting network packets in a computing device
US6950879B2 (en) Using virtual network address information during communications
US7634608B2 (en) Bridging network components
US6570884B1 (en) Receive filtering for communication interface
Dittia et al. The APIC approach to high performance network interface design: Protected DMA and other techniques
EP1514191B1 (en) A network device driver architecture
US7551567B2 (en) Interpreting an application message at a network element using sampling and heuristics
Wang et al. XenLoop: a transparent high performance inter-vm network loopback
US7502884B1 (en) Resource virtualization switch
US20020059517A1 (en) Filtered application-to-application communication
Schildt et al. IBR-DTN: A lightweight, modular and highly portable Bundle Protocol implementation
US6678746B1 (en) Processing network packets
US20070027966A1 (en) Network based device for providing RFID middleware functionality
US7840700B2 (en) Dynamically adding application logic and protocol adapters to a programmable network element

Legal Events

Date Code Title Description
AL Designated countries for regional patents

Kind code of ref document: A2

Designated state(s): GH GM KE LS MW MZ SD SL SZ TZ UG ZW AM AZ BY KG KZ MD RU TJ TM AT BE CH CY DE DK ES FI FR GB GR IE IT LU MC NL PT SE BF BJ CF CG CI CM GA GN GW ML MR NE SN TD TG

AK Designated states

Kind code of ref document: A2

Designated state(s): AE AG AL AM AT AU AZ BA BB BG BR BY BZ CA CH CN CR CU CZ DE DK DM DZ EE ES FI GB GD GE GH GM HR HU ID IL IN IS JP KE KG KP KR KZ LC LK LR LS LT LU LV MA MD MG MK MN MW MX MZ NO NZ PL PT RO RU SD SE SG SI SK SL TJ TM TR TT TZ UA UG US US UZ VN YU ZA ZW

121 Ep: the epo has been informed by wipo that ep was designated in this application
DFPE Request for preliminary examination filed prior to expiration of 19th month from priority date (pct application filed before 20040101)
AL Designated countries for regional patents

Kind code of ref document: A3

Designated state(s): GH GM KE LS MW MZ SD SL SZ TZ UG ZW AM AZ BY KG KZ MD RU TJ TM AT BE CH CY DE DK ES FI FR GB GR IE IT LU MC NL PT SE BF BJ CF CG CI CM GA GN GW ML MR NE SN TD TG

AK Designated states

Kind code of ref document: A3

Designated state(s): AE AG AL AM AT AU AZ BA BB BG BR BY BZ CA CH CN CR CU CZ DE DK DM DZ EE ES FI GB GD GE GH GM HR HU ID IL IN IS JP KE KG KP KR KZ LC LK LR LS LT LU LV MA MD MG MK MN MW MX MZ NO NZ PL PT RO RU SD SE SG SI SK SL TJ TM TR TT TZ UA UG US US UZ VN YU ZA ZW

WWE Wipo information: entry into national phase

Ref document number: 2382836

Country of ref document: CA

WWE Wipo information: entry into national phase

Ref document number: 2000965512

Country of ref document: EP

WWP Wipo information: published in national office

Ref document number: 2000965512

Country of ref document: EP

WWW Wipo information: withdrawn in national office

Ref document number: 2000965512

Country of ref document: EP

COP Corrected version of pamphlet

Free format text: PAGES 14-138, DESCRIPTION, REPLACED BY NEW PAGES 14-185; PAGES 139-144, CLAIMS, REPLACED BY NEW PAGES 186-191; DUE TO LATE TRANSMITTAL BY THE RECEIVING OFFICE

AL Designated countries for regional patents

Kind code of ref document: C2

Designated state(s): GH GM KE LS MW MZ SD SL SZ TZ UG ZW AM AZ BY KG KZ MD RU TJ TM AT BE CH CY DE DK ES FI FR GB GR IE IT LU MC NL PT SE BF BJ CF CG CI CM GA GN GW ML MR NE SN TD TG

AK Designated states

Kind code of ref document: C2

Designated state(s): AE AG AL AM AT AU AZ BA BB BG BR BY BZ CA CH CN CR CU CZ DE DK DM DZ EE ES FI GB GD GE GH GM HR HU ID IL IN IS JP KE KG KP KR KZ LC LK LR LS LT LU LV MA MD MG MK MN MW MX MZ NO NZ PL PT RO RU SD SE SG SI SK SL TJ TM TR TT TZ UA UG US US UZ VN YU ZA ZW

NENP Non-entry into the national phase in:

Ref country code: JP