Index: head/share/man/man4/ahc.4 =================================================================== --- head/share/man/man4/ahc.4 (revision 82327) +++ head/share/man/man4/ahc.4 (revision 82328) @@ -1,298 +1,298 @@ .\" .\" Copyright (c) 1995, 1996, 1997, 1998, 2000 .\" Justin T. Gibbs. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. The name of the author may not be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd February 13, 2000 .Dt AHC 4 .Os .Sh NAME .Nm ahc .Nd Adaptec VL/EISA/PCI SCSI host adapter driver .Sh SYNOPSIS For one or more VL/EISA cards: .Cd device eisa .Cd device ahc .Pp For one or more PCI cards: .Cd device pci .Cd device ahc .Pp To allow PCI adapters to use memory mapped I/O if enabled: .Cd options AHC_ALLOW_MEMIO .Pp To configure one or more controllers to assume the target role: .Cd options AHC_TMODE_ENABLE .Pp For one or more SCSI busses: .Cd device scbus0 at ahc0 .Sh DESCRIPTION This driver provides access to the .Tn SCSI bus(es) connected to Adaptec .Tn AIC7770 , .Tn AIC7850 , .Tn AIC7860 , .Tn AIC7870 , .Tn AIC7880 , .Tn AIC7890 , .Tn AIC7891 , .Tn AIC7892 , .Tn AIC7895 , .Tn AIC7896 , .Tn AIC7897 and .Tn AIC7899 host adapter chips. These chips are found on many motherboards as well as the following Adaptec SCSI controller cards: .Tn 274X(W) , .Tn 274X(T) , .Tn 284X , .Tn 2910 , .Tn 2915 , .Tn 2920 , .Tn 2930C , .Tn 2930U2 , .Tn 2940 , .Tn 2940U , .Tn 2940AU , .Tn 2940UW , .Tn 2940UW Dual , .Tn 2940UW Pro , .Tn 2940U2W , .Tn 2940U2B , .Tn 2950U2W , .Tn 2950U2B , .Tn 19160B , .Tn 29160B , .Tn 29160N , .Tn 3940 , .Tn 3940U , .Tn 3940AU , .Tn 3940UW , .Tn 3940AUW , .Tn 3940U2W , .Tn 3950U2 , .Tn 3960 , .Tn 39160 , .Tn 3985 , and .Tn 4944UW . .Pp Driver features include support for twin and wide busses, fast, ultra or ultra2 synchronous transfers depending on controller type, -tagged queuing, SCB paging, and target mode. +tagged queueing, SCB paging, and target mode. .Pp Memory mapped I/O can be enabled for PCI devices with the .Dq Dv AHC_ALLOW_MEMIO configuration option. Memory mapped I/O is more efficient than the alternative, programmed I/O. Most PCI BIOSes will map devices so that either technique for communicating with the card is available. In some cases, usually when the PCI device is sitting behind a PCI->PCI bridge, the BIOS may fail to properly initialize the chip for memory mapped I/O. The typical symptom of this problem is a system hang if memory mapped I/O is attempted. Most modern motherboards perform the initialization correctly and work fine with this option enabled. .Pp Individual controllers may be configured to operate in the target role through the .Dq Dv AHC_TMODE_ENABLE configuration option. The value assigned to this option should be a bitmap of all units where target mode is desired. For example, a value of 0x25, would enable target mode on units 0, 2, and 5. .Pp Per target configuration performed in the .Tn SCSI-Select menu, accessible at boot in .No non- Ns Tn EISA models, or through an .Tn EISA configuration utility for .Tn EISA models, is honored by this driver. This includes synchronous/asynchronous transfers, maximum synchronous negotiation rate, wide transfers, disconnection, the host adapter's SCSI ID, and, in the case of .Tn EISA Twin Channel controllers, the primary channel selection. For systems that store non-volatile settings in a system specific manner rather than a serial eeprom directly connected to the aic7xxx controller, the .Tn BIOS must be enabled for the driver to access this information. This restriction applies to all .Tn EISA and many motherboard configurations. .Pp Note that I/O addresses are determined automatically by the probe routines, but care should be taken when using a 284x .Pq Tn VESA No local bus controller in an .Tn EISA system. The jumpers setting the I/O area for the 284x should match the .Tn EISA slot into which the card is inserted to prevent conflicts with other .Tn EISA cards. .Pp Performance and feature sets vary throughout the aic7xxx product line. The following table provides a comparison of the different chips supported by the .Nm driver. Note that wide and twin channel features, although always supported by a particular chip, may be disabled in a particular motherboard or card design. .Pp .Bd -ragged -offset indent .Bl -column "aic7770 " "10 " "EISA/VL " "10MHz " "16bit " "SCBs " Features .Em "Chip MIPS Bus MaxSync MaxWidth SCBs Features" aic7770 10 EISA/VL 10MHz 16Bit 4 1 aic7850 10 PCI/32 10MHz 8Bit 3 aic7860 10 PCI/32 20MHz 8Bit 3 aic7870 10 PCI/32 10MHz 16Bit 16 aic7880 10 PCI/32 20MHz 16Bit 16 aic7890 20 PCI/32 40MHz 16Bit 16 3 4 5 6 7 8 aic7891 20 PCI/64 40MHz 16Bit 16 3 4 5 6 7 8 aic7892 20 PCI/64 80MHz 16Bit 16 3 4 5 6 7 8 aic7895 15 PCI/32 20MHz 16Bit 16 2 3 4 5 aic7895C 15 PCI/32 20MHz 16Bit 16 2 3 4 5 8 aic7896 20 PCI/32 40MHz 16Bit 16 2 3 4 5 6 7 8 aic7897 20 PCI/64 40MHz 16Bit 16 2 3 4 5 6 7 8 aic7899 20 PCI/64 80MHz 16Bit 16 2 3 4 5 6 7 8 .El .Pp .Bl -enum -compact .It Multiplexed Twin Channel Device - One controller servicing two busses. .It Multi-function Twin Channel Device - Two controllers on one chip. .It Command Channel Secondary DMA Engine - Allows scatter gather list and SCB prefetch. .It 64 Byte SCB Support - SCSI CDB is embedded in the SCB to eliminate an extra DMA. .It Block Move Instruction Support - Doubles the speed of certain sequencer operations. .It .Sq Bayonet style Scatter Gather Engine - Improves S/G prefetch performance. .It -Queuing Registers - Allows queuing of new transactions without pausing the +Queuing Registers - Allows queueing of new transactions without pausing the sequencer. .It Multiple Target IDs - Allows the controller to respond to selection as a target on multiple SCSI IDs. .El .Ed .Sh SCSI CONTROL BLOCKS (SCBs) Every transaction sent to a device on the SCSI bus is assigned a .Sq SCSI Control Block (SCB). The SCB contains all of the information required by the controller to process a transaction. The chip feature table lists the number of SCBs that can be stored in on-chip memory. All chips with model numbers greater than or equal to 7870 allow for the on chip SCB space to be augmented with external SRAM up to a maximum of 255 SCBs. Very few Adaptec controller configurations have external SRAM. .Pp If external SRAM is not available, SCBs are a limited resource. Using the SCBs in a straight forward manner would only allow the dirver to handle as many concurrent transactions as there are physical SCBs. To fully utilize the SCSI bus and the devices on it, requires much more concurrency. The solution to this problem is .Em SCB Paging , a concept similar to memory paging. SCB paging takes advantage of the fact that devices usually disconnect from the SCSI bus for long periods of time without talking to the controller. The SCBs for disconnected transactions are only of use to the controller when the transfer is resumed. When the host queues another transaction for the controller to execute, the controller firmware will use a free SCB if one is available. Otherwise, the state of the most recently disconnected (and therefor most likely to stay disconnected) SCB is saved, via dma, to host memory, and the local SCB reused to start the new transaction. This allows the controller to queue up to 255 transactions regardless of the amount of SCB space. Since the local SCB space serves as a cache for disconnected transactions, the more SCB space available, the less host bus traffic consumed saving and restoring SCB data. .Sh BUGS Some Quantum drives (at least the Empire 2100 and 1080s) will not run on an .Tn AIC7870 Rev B in synchronous mode at 10MHz. Controllers with this problem have a 42 MHz clock crystal on them and run slightly above 10MHz. This confuses the drive and hangs the bus. Setting a maximum synchronous negotiation rate of 8MHz in the .Tn SCSI-Select utility will allow normal operation. .Pp Double Transition clocking is not yet supported for Ultra160 controllers. This limits these controllers to 40MHz or 80MB/s. .Pp Although the Ultra2 and Ultra160 products have sufficient instruction ram space to support both the initiator and target roles concurrently, this configuration is disabled in favor of allowing the target role to respond on multiple target ids. A method for configuring dual role mode should be provided. .Pp Tagged Queuing is not supported in target mode. .Pp Reselection in target mode fails to function correctly on all high voltage differential boards as shipped by Adaptec. Information on how to modify HVD board to work correctly in target mode is available from Adaptec. .Sh SEE ALSO .Xr aha 4 , .Xr ahb 4 , .Xr cd 4 , .Xr da 4 , .Xr sa 4 , .Xr scsi 4 .Sh AUTHORS The .Nm driver, the .Tn AIC7xxx sequencer-code assembler, and the firmware running on the aic7xxx chips was written by .An Justin T. Gibbs . .Sh HISTORY The .Nm driver appeared in .Fx 2.0 . Index: head/share/man/man4/da.4 =================================================================== --- head/share/man/man4/da.4 (revision 82327) +++ head/share/man/man4/da.4 (revision 82328) @@ -1,297 +1,297 @@ .\" Copyright (c) 1996 .\" Julian Elischer . All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd October 15, 1998 .Dt DA 4 .Os .Sh NAME .Nm da .Nd SCSI Direct Access device driver .Sh SYNOPSIS .Cd device da .Cd device da1 at scbus0 target 4 unit 0 .Sh DESCRIPTION The .Nm driver provides support for all .Tn SCSI devices of the direct access class that are attached to the system through a supported .Tn SCSI Host Adapter. The direct access class includes disk, magneto-optical, and solid-state devices. .Pp A .Tn SCSI Host adapter must also be separately configured into the system before a .Tn SCSI direct access device can be configured. .Sh PARTITIONING The .Nm driver allows the disk to have two levels of partitioning. One layer, called the .Dq slice layer , is used to separate the .Fx areas of the disk from areas used by other operating systems. The second layer is the native .Bx 4.4 partitioning scheme, .Xr disklabel 5 , which is used to subdivide the .Fx slices into areas for individual filesystems and swap spaces. For more information, see .Xr fdisk 8 and .Xr disklabel 8 , respectively. .Pp If an uninitialized disk is opened, the slice table will be initialized with a fictitious .Fx slice spanning the entire disk. Similarly, if an uninitialized (or .No non- Ns Fx ) slice is opened, its disklabel will be initialized with parameters returned by the drive and a single .Sq Li c partition encompassing the entire slice. .Sh CACHE EFFECTS Many direct access devices are equipped with read and/or write caches. Parameters affecting the device's cache are stored in mode page 8, the caching control page. Mode pages can be examined and modified via the .Xr camcontrol 8 utility. .Pp The read cache is used to store data from device-initiated read ahead operations as well as frequently used data. The read cache is transparent to the user and can be enabled without any adverse effect. Most devices with a read cache come from the factory with it enabled. The read cache can be disabled by setting the .Tn RCD (Read Cache Disable) bit in the caching control mode page. .Pp The write cache can greatly decrease the latency of write operations and allows the device to reorganize writes to increase efficiency and performance. This performance gain comes at a price. Should the device lose power while its cache contains uncommitted write operations, these writes will be lost. The effect of a loss of write transactions on a file system is non-deterministic and can cause corruption. Most devices age write transactions to limit vulnerability to a few transactions recently reported as complete, but it is none-the-less recommended that systems with write cache enabled devices reside on an Uninterruptible Power Supply (UPS). The .Nm device driver ensures that the cache and media are synchronized upon final close of the device or an unexpected shutdown (panic) event. This ensures that it is safe to disconnect power once the operating system has reported that it has halted. The write cache can be enabled by setting the .Tn WCE (Write Cache Enable) bit in the caching control mode page. .Sh TAGGED QUEUING The .Nm device driver will take full advantage of the SCSI feature known as tagged -queuing. Tagged queuing allows the device to process multiple transactions +queueing. Tagged queueing allows the device to process multiple transactions concurrently, often re-ordering them to reduce the number and length of seeks. To ensure that transactions to distant portions of the media, which may be deferred indefinitely by servicing requests nearer the current head position, are completed in a timely fashion, an ordered tagged transaction is sent every 15 seconds during continuous device operation. .Sh BAD BLOCK RECOVERY Direct Access devices have the capability of mapping out portions of defective media. Media recovery parameters are located in mode page 1, the Read-Write Error Recovery mode page. The most important media remapping features are 'Auto Write Reallocation' and 'Auto Read Reallocation' which can be enabled via the AWRE and ARRE bits, respectively, of the Read-Write Error Recovery page. Many devices do not ship from the factory with these feature enabled. Mode pages can be examined and modifie via the .Xr camcontrol 8 utility. .Sh KERNEL CONFIGURATION It is only necessary to explicitly configure one .Nm device; data structures are dynamically allocated as disks are found on the .Tn SCSI bus. .Sh IOCTLS The following .Xr ioctl 2 calls apply to .Tn SCSI disks as well as to other disks. They are defined in the header file .Aq Pa sys/disklabel.h . .Pp .Bl -tag -width DIOCSDINFO .It Dv DIOCSBAD Usually used to set up a bad-block mapping system on the disk. .Tn SCSI drives incorporate their own bad-block mapping so this command is not implemented. .It Dv DIOCGDINFO Read, from the kernel, the in-core copy of the disklabel for the drive. This may be a fictitious disklabel if the drive has never been initialized, in which case it will contain information read from the .Tn SCSI inquiry commands. .It Dv DIOCSDINFO Give the driver a new disklabel to use. The driver .Em will not write the new disklabel to the disk. .It Dv DIOCWLABEL Enable or disable the driver's software write protect of the disklabel on the disk. .It Dv DIOCWDINFO Give the driver a new disklabel to use. The driver .Em will write the new disklabel to the disk. .El .Sh NOTES If a device becomes invalidated (media is removed, device becomes unresponsive) the disklabel and information held within the kernel about the device will be invalidated. To avoid corruption of a newly inserted piece of media or a replacement device, all accesses to the device will be discarded until the last file descriptor referencing the old device is closed. During this period, all new open attempts will be rejected. .Sh FILES .Bl -tag -width /dev/rsdXXXXX -compact .It Pa /dev/rda Ns Ar u raw mode .Tn SCSI disk unit .Ar u , accessed as an unpartitioned device .Sm off .It Pa /dev/da Ar u Pa s Ar n .Sm on block mode .Tn SCSI disk unit .Ar u , slice .Ar n , accessed as an unpartitioned device .Sm off .It Pa /dev/rda Ar u Pa s Ar n .Sm on raw mode .Tn SCSI disk unit .Ar u , slice .Ar n , accessed as an unpartitioned device .It Pa /dev/da Ns Ar u Ns Ar p block mode .Tn SCSI disk unit .Ar u , first .Fx slice, partition .Ar p .It Pa /dev/rda Ns Ar u Ns Ar p raw mode .Tn SCSI disk unit .Ar u , first .Fx slice, partition .Ar p .Sm off .It Xo .Pa /dev/da .Ar u .Pa s .Ar n .Ar p .Xc .Sm on block mode .Tn SCSI disk unit .Ar u , .Ar n Ns th slice, partition .Ar p .Sm off .It Xo .Pa /dev/rda .Ar u .Pa s .Ar n .Ar p .Xc .Sm on raw mode .Tn SCSI disk unit .Ar u , .Ar n Ns th slice, partition .Ar p .El .Sh DIAGNOSTICS None. .Sh SEE ALSO .Xr ad 4 , .Xr disklabel 5 , .Xr disklabel 8 , .Xr fdisk 8 .Sh HISTORY The .Nm driver was written for the .Tn CAM .Tn SCSI subsystem by .An Justin T. Gibbs . Many ideas were gleaned from the .Nm sd device driver written and ported from .Tn Mach 2.5 by .An Julian Elischer . Support for slices was written by .An Bruce Evans . Index: head/share/man/man4/netgraph.4 =================================================================== --- head/share/man/man4/netgraph.4 (revision 82327) +++ head/share/man/man4/netgraph.4 (revision 82328) @@ -1,1372 +1,1372 @@ .\" Copyright (c) 1996-1999 Whistle Communications, Inc. .\" All rights reserved. .\" .\" Subject to the following obligations and disclaimer of warranty, use and .\" redistribution of this software, in source or object code forms, with or .\" without modifications are expressly permitted by Whistle Communications; .\" provided, however, that: .\" 1. Any and all reproductions of the source or object code must include the .\" copyright notice above and the following disclaimer of warranties; and .\" 2. No rights are granted, in any manner or form, to use Whistle .\" Communications, Inc. trademarks, including the mark "WHISTLE .\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as .\" such appears in the above copyright notice or in the software. .\" .\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, .\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. .\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY .\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS .\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. .\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES .\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING .\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, .\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR .\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY .\" OF SUCH DAMAGE. .\" .\" Authors: Julian Elischer .\" Archie Cobbs .\" .\" $FreeBSD$ .\" $Whistle: netgraph.4,v 1.7 1999/01/28 23:54:52 julian Exp $ .\" .Dd January 19, 1999 .Dt NETGRAPH 4 .Os .Sh NAME .Nm netgraph .Nd graph based kernel networking subsystem .Sh DESCRIPTION The .Nm system provides a uniform and modular system for the implementation of kernel objects which perform various networking functions. The objects, known as .Em nodes , can be arranged into arbitrarily complicated graphs. Nodes have .Em hooks which are used to connect two nodes together, forming the edges in the graph. Nodes communicate along the edges to process data, implement protocols, etc. .Pp The aim of .Nm is to supplement rather than replace the existing kernel networking infrastructure. It provides: .Pp .Bl -bullet -compact -offset 2n .It A flexible way of combining protocol and link level drivers .It A modular way to implement new protocols .It A common framework for kernel entities to inter-communicate .It A reasonably fast, kernel-based implementation .El .Sh Nodes and Types The most fundamental concept in .Nm is that of a .Em node . All nodes implement a number of predefined methods which allow them to interact with other nodes in a well defined manner. .Pp Each node has a .Em type , which is a static property of the node determined at node creation time. A node's type is described by a unique .Tn ASCII type name. The type implies what the node does and how it may be connected to other nodes. .Pp In object-oriented language, types are classes and nodes are instances of their respective class. All node types are subclasses of the generic node type, and hence inherit certain common functionality and capabilities (e.g., the ability to have an .Tn ASCII name). .Pp Nodes may be assigned a globally unique .Tn ASCII name which can be used to refer to the node. The name must not contain the characters .Dq .\& or .Dq \&: and is limited to .Dv "NG_NODELEN + 1" characters (including NUL byte). .Pp Each node instance has a unique .Em ID number which is expressed as a 32-bit hex value. This value may be used to refer to a node when there is no .Tn ASCII name assigned to it. .Sh Hooks Nodes are connected to other nodes by connecting a pair of .Em hooks , one from each node. Data flows bidirectionally between nodes along connected pairs of hooks. A node may have as many hooks as it needs, and may assign whatever meaning it wants to a hook. .Pp Hooks have these properties: .Pp .Bl -bullet -compact -offset 2n .It A hook has an .Tn ASCII name which is unique among all hooks on that node (other hooks on other nodes may have the same name). The name must not contain a .Dq .\& or a .Dq \&: and is limited to .Dv "NG_HOOKLEN + 1" characters (including NUL byte). .It A hook is always connected to another hook. That is, hooks are created at the time they are connected, and breaking an edge by removing either hook destroys both hooks. .It A hook can be set into a state where incoming packets are always queued -by the input queuing system, rather than being delivered directly. This +by the input queueing system, rather than being delivered directly. This is used when the two joined nodes need to be decoupled, e.g. if they are running at different processor priority levels. (spl) .It A hook may supply over-riding receive data and receive message functions which should be used for data and messages received through that hook in preference to the general node-wide methods. .El .Pp A node may decide to assign special meaning to some hooks. For example, connecting to the hook named .Dq debug might trigger the node to start sending debugging information to that hook. .Sh Data Flow Two types of information flow between nodes: data messages and control messages. Data messages are passed in mbuf chains along the edges in the graph, one edge at a time. The first mbuf in a chain must have the .Dv M_PKTHDR flag set. Each node decides how to handle data coming in on its hooks. .Pp Control messages are type-specific C structures sent from one node directly to some arbitrary other node. Control messages have a common header format, followed by type-specific data, and are binary structures for efficiency. However, node types also may support conversion of the type specific data between binary and .Tn ASCII for debugging and human interface purposes (see the .Dv NGM_ASCII2BINARY and .Dv NGM_BINARY2ASCII generic control messages below). Nodes are not required to support these conversions. .Pp There are three ways to address a control message. If there is a sequence of edges connecting the two nodes, the message may be .Dq source routed by specifying the corresponding sequence of .Tn ASCII hook names as the destination address for the message (relative addressing). If the destination is adjacent to the source, then the source node may simply specify (as a pointer in the code) the hook across which the message should be sent. Otherwise, the recipient node global .Tn ASCII name (or equivalent ID based name) is used as the destination address for the message (absolute addressing). The two types of .Tn ASCII addressing may be combined, by specifying an absolute start node and a sequence of hooks. Only the .Tn ASCII addressing modes are available to control programs outside the kernel, as use of direct pointers is limited of course to kernel modules. .Pp Messages often represent commands that are followed by a reply message in the reverse direction. To facilitate this, the recipient of a control message is supplied with a .Dq return address that is suitable for addressing a reply. .Pp Each control message contains a 32 bit value called a .Em typecookie indicating the type of the message, i.e., how to interpret it. Typically each type defines a unique typecookie for the messages that it understands. However, a node may choose to recognize and implement more than one type of message. .Pp If a message is delivered to an address that implies that it arrived at that node through a particular hook, (as opposed to having been directly addressed using its ID or global name), then that hook is identified to the receiving node. This allows a message to be rerouted or passed on, should a node decide that this is required, in much the same way that data packets are passed around between nodes. A set of standard messages for flow control and link management purposes are defined by the base system that are usually passed around in this manner. Flow control message would usually travel in the opposite direction to the data to which they pertain. .Sh Netgraph is (usually) Functional In order to minimize latency, most .Nm operations are functional. That is, data and control messages are delivered by making function calls rather than by using queues and mailboxes. For example, if node A wishes to send a data mbuf to neighboring node B, it calls the generic .Nm data delivery function. This function in turn locates node B and calls B's .Dq receive data method. There are exceptions to this. .Pp Each node has an input queue, and some operations can be considered to be 'writers' in that they alter the state of the node. Obviously in an SMP world it would be bad if the state of a node were changed while another data packet were transiting the node. For this purpose, the input queue implements a .Em reader/writer semantic so that when there is a writer in the node, all other requests are queued, and while there are readers, a writer, and any following packets are queued. In the case where there is no reason to queue the data, the input method is called directly, as mentionned above. .Pp A node may declare that all requests should be considered as writers, or that requests coming in over a particular hook should be considered to be a writer, or even that packets leaving or entering across a particular hook should always be queued, rather than delivered directly (often useful for interrupt routines who want to get back to the hardware quickly). By default, all controll message packets are considered to be writers unless specifically declared to be a reader in their definition. (see NGM_READONLY in ng_message.h) .Pp While this mode of operation results in good performance, it has a few implications for node developers: .Pp .Bl -bullet -compact -offset 2n .It Whenever a node delivers a data or control message, the node may need to allow for the possibility of receiving a returning message before the original delivery function call returns. .It Netgraph nodes and support routines generally run at .Fn splnet . However, some nodes may want to send data and control messages from a different priority level. Netgraph supplies a mechanism which utilizes the NETISR system to move message and data delivery to .Fn splnet . Nodes that run at other priorities (e.g. interfaces) can be directly linked to other nodes so that the combination runs at the other priority, however any interaction with nodes running at splnet MUST be achieved via the queueing functions, (which use the .Fn netisr feature of the kernel). Note that messages are always received at .Fn splnet . .It It's possible for an infinite loop to occur if the graph contains cycles. .El .Pp So far, these issues have not proven problematical in practice. .Sh Interaction With Other Parts of the Kernel A node may have a hidden interaction with other components of the kernel outside of the .Nm subsystem, such as device hardware, kernel protocol stacks, etc. In fact, one of the benefits of .Nm is the ability to join disparate kernel networking entities together in a consistent communication framework. .Pp An example is the node type .Em socket which is both a netgraph node and a .Xr socket 2 .Bx socket in the protocol family .Dv PF_NETGRAPH . Socket nodes allow user processes to participate in .Nm . Other nodes communicate with socket nodes using the usual methods, and the node hides the fact that it is also passing information to and from a cooperating user process. .Pp Another example is a device driver that presents a node interface to the hardware. .Sh Node Methods Nodes are notified of the following actions via function calls to the following node methods (all at .Fn splnet ) and may accept or reject that action (by returning the appropriate error code): .Bl -tag -width xxx .It Creation of a new node The constructor for the type is called. If creation of a new node is allowed, the constructor must call the generic node creation function (in object-oriented terms, the superclass constructor) and then allocate any special resources it needs. For nodes that correspond to hardware, this is typically done during the device attach routine. Often a global .Tn ASCII name corresponding to the device name is assigned here as well. .It Creation of a new hook The hook is created and tentatively linked to the node, and the node is told about the name that will be used to describe this hook. The node sets up any special data structures it needs, or may reject the connection, based on the name of the hook. .It Successful connection of two hooks After both ends have accepted their hooks, and the links have been made, the nodes get a chance to find out who their peer is across the link and can then decide to reject the connection. Tear-down is automatic. This is also the time at which a node may decide whether to set a particular hook (or its peer) into -.Em queuing +.Em queueing mode. .It Destruction of a hook The node is notified of a broken connection. The node may consider some hooks to be critical to operation and others to be expendable: the disconnection of one hook may be an acceptable event while for another it may affect a total shutdown for the node. .It Shutdown of a node This method allows a node to clean up and to ensure that any actions that need to be performed at this time are taken. The method is called by the generic (i.e., superclass) node destructor which will get rid of the generic components of the node. Some nodes (usually associated with a piece of hardware) may be .Em persistent in that a shutdown breaks all edges and resets the node, but doesn't remove it. In this case the shutdown method should not free its resources, but rather, clean up and then clear the .Em NG_INVALID flag to signal the generic code that the shutdown is aborted. In the case where the shutdown is started by the node itself due to hardware removal or unloading, (via ng_rmnode_self()) it should set the .Em NG_REALLY_DIE flag to signal to its own shutdown method that it is not to persist. .El .Sh Sending and Receiving Data Two other methods are also supported by all nodes: .Bl -tag -width xxx .It Receive data message A .Em Netgraph queueable reqest item , usually refered to as an .Em item , is recieved by the function. The item contains a pointer to an mbuf and metadata about the packet. .Pp The node is notified on which hook the item arrived, and can use this information in its processing decision. The receiving node must always .Fn NG_FREE_M the mbuf chain on completion or error, or pass it on to another node (or kernel module) which will then be responsible for freeing it. Similarly the .Em item must be freed if it is not to be passed on to another node, by using the .Fn NG_FREE_ITEM macro. If the item still holds references to mbufs or metadata at the time of freeing then they will also be appropriatly freed. Therefore, if there is any chance that the mbuf or metadata will be changed or freed separatly from the item, it is very important that these fields be retrieved using the .Fn NGI_GET_M and .Fn NGI_GET_META macros that also remove the reference within the item. (or multiple frees of the same object will occur). .Pp If it is only required to examine the contents of the mbufs or the metadata, then it is possible to use the .Fn NGI_M and .Fn NGI_META macros to both read and rewrite these fields. .Pp In addition to the mbuf chain itself there may also be a pointer to a structure describing meta-data about the message (e.g. priority information). This pointer may be .Dv NULL if there is no additional information. The format for this information is described in .Pa sys/netgraph/netgraph.h . The memory for meta-data must allocated via .Fn malloc with type .Dv M_NETGRAPH_META . As with the data itself, it is the receiver's responsibility to .Fn free the meta-data. If the mbuf chain is freed the meta-data must be freed at the same time. If the meta-data is freed but the real data on is passed on, then a .Dv NULL pointer must be substituted. It is also the duty of the receiver to free the request item itself, or to use it to pass the message on further. .Pp The receiving node may decide to defer the data by queueing it in the .Nm NETISR system (see below). It achieves this by setting the .Dv HK_QUEUE flag in the flags word of the hook on which that data will arrive. The infrastructure will respect that bit and queue the data for delivery at a later time, rather than deliver it directly. A node may decide to set the bit on the .Em peer node, so that its own output packets are queued. This is used by device drivers running at different processor priorities to transfer packet delivery to the splnet() level at which the bulk of .Nm runs. .Pp The structure and use of meta-data is still experimental, but is presently used in frame-relay to indicate that management packets should be queued for transmission at a higher priority than data packets. This is required for conformance with Frame Relay standards. .Pp The node may elect to nominate a different receive data function for data received on a particular hook, to simplify coding. It uses the .Fn NG_HOOK_SET_RCVDATA hook fn macro to do this. The function receives the same arguments in every way other than it will receive all (and only) packets from that hook. .It Receive control message This method is called when a control message is addressed to the node. As with the received data, an .Em item is reveived, with a pointer to the control message. The message can be examined using the .Fn NGI_MSG macro, or completely extracted from the item using the .Fn NGI_GET_MSG which also removes the reference within the item. If the Item still holds a reference to the message when it is freed (using the .Fn NG_FREE_ITEM macro), then the message will also be freed appropriatly. If the reference has been removed the node must free the message itself using the .Fn NG_FREE_MSG macro. A return address is always supplied, giving the address of the node that originated the message so a reply message can be sent anytime later. The return address is retrieved from the .Em item using the .Fn NGI_RETADDR macro and is of type .Em ng_ID_t . All control messages and replies are allocated with .Fn malloc type .Dv M_NETGRAPH_MSG , however it is more usual to use the .Fn NG_MKMESSAGE and .Fn NG_MKRESPONSE macros to allocate and fill out a message. Messages must be freed using the .Fn NG_FREE_MSG macro. .Pp If the message was delivered via a specific hook, that hook will also be made known, which allows the use of such things as flow-control messages, and status change messages, where the node may want to forward the message out another hook to that on which it arrived. .Pp The node may elect to nominate a different receive message function for messages received on a particular hook, to simplify coding. It uses the .Fn NG_HOOK_SET_RCVMSG hook fn macro to do this. The function receives the same arguments in every way other than it will receive all (and only) messages from that hook. .El .Pp Much use has been made of reference counts, so that nodes being free'd of all references are automatically freed, and this behaviour has been tested and debugged to present a consistent and trustworthy framework for the .Dq type module writer to use. .Sh Addressing The .Nm framework provides an unambiguous and simple to use method of specifically addressing any single node in the graph. The naming of a node is independent of its type, in that another node, or external component need not know anything about the node's type in order to address it so as to send it a generic message type. Node and hook names should be chosen so as to make addresses meaningful. .Pp Addresses are either absolute or relative. An absolute address begins with a node name, (or ID), followed by a colon, followed by a sequence of hook names separated by periods. This addresses the node reached by starting at the named node and following the specified sequence of hooks. A relative address includes only the sequence of hook names, implicitly starting hook traversal at the local node. .Pp There are a couple of special possibilities for the node name. The name .Dq .\& (referred to as .Dq \&.: ) always refers to the local node. Also, nodes that have no global name may be addressed by their ID numbers, by enclosing the hex representation of the ID number within square brackets. Here are some examples of valid netgraph addresses: .Bd -literal -offset 4n -compact .: [3f]: foo: .:hook1 foo:hook1.hook2 [d80]:hook1 .Ed .Pp Consider the following set of nodes might be created for a site with a single physical frame relay line having two active logical DLCI channels, with RFC-1490 frames on DLCI 16 and PPP frames over DLCI 20: .Pp .Bd -literal [type SYNC ] [type FRAME] [type RFC1490] [ "Frame1" ](uplink)<-->(data)[](dlci16)<-->(mux)[ ] [ A ] [ B ](dlci20)<---+ [ C ] | | [ type PPP ] +>(mux)[] [ D ] .Ed .Pp One could always send a control message to node C from anywhere by using the name .Em "Frame1:uplink.dlci16" . In this case, node C would also be notified that the message reached it via its hook .Dq mux . Similarly, .Em "Frame1:uplink.dlci20" could reliably be used to reach node D, and node A could refer to node B as .Em ".:uplink" , or simply .Em "uplink" . Conversely, B can refer to A as .Em "data" . The address .Em "mux.data" could be used by both nodes C and D to address a message to node A. .Pp Note that this is only for .Em control messages . In each of these cases, where a relative addressing mode is used, the recipient is notified of the hook on which the message arrived, as well as the originating node. This allows the option of hop-by-hop distibution of messages and state information. Data messages are .Em only routed one hop at a time, by specifying the departing hook, with each node making the next routing decision. So when B receives a frame on hook .Dq data it decodes the frame relay header to determine the DLCI, and then forwards the unwrapped frame to either C or D. .Pp In a similar way, flow control messages may be routed in the reverse direction to outgoing data. For example a "buffer nearly full" message from .Em "Frame1: would be passed to node .Em B which might decide to send similar messages to both nodes .Em C and .Em D . The nodes would use .Em "Direct hook pointer" addressing to route the messages. The message may have travelled from .Em "Frame1: to .Em B as a synchronous reply, saving time and cycles. .Pp A similar graph might be used to represent multi-link PPP running over an ISDN line: .Pp .Bd -literal [ type BRI ](B1)<--->(link1)[ type MPP ] [ "ISDN1" ](B2)<--->(link2)[ (no name) ] [ ](D) <-+ | +----------------+ | +->(switch)[ type Q.921 ](term1)<---->(datalink)[ type Q.931 ] [ (no name) ] [ (no name) ] .Ed .Sh Netgraph Structures Structures are defined in .Pa sys/netgraph/netgraph.h (for kernel sructures only of interest to nodes) and .Pa sys/netgraph/ng_message.h (for message definitions also of interest to user programs). .Pp The two basic object types that are of interest to node authors are .Em nodes and .Em hooks . These two objects have the following properties that are also of interest to the node writers. .Bl -tag -width xxx .It struct ng_node Node authors should always use the following typedef to declare their pointers, and should never actually declare the structure. .Pp typedef struct ng_node *node_p; .Pp The following properties are associated with a node, and can be accessed in the following manner: .Bl -bullet -compact -offset 2n .Pp .It Validity .Pp A driver or interrupt routine may want to check whether the node is still valid. It is assumed that the caller holds a reference on the node so it will not have been freed, however it may have been disabled or otherwise shut down. Using the .Fn NG_NODE_IS_VALID "node" macro will return this state. Eventually it should be almost impossible for code to run in an invalid node but at this time that work has not been completed. .Pp .It node ID .Pp Of type .Em ng_ID_t , This property can be retrieved using the macro .Fn NG_NODE_ID "node" . .Pp .It node name .Pp Optional globally unique name, null terminated string. If there is a value in here, it is the name of the node. .Pp if .Fn ( NG_NODE_NAME "node" [0]) .... .Pp if (strncmp( .Fn NG_NODE_NAME "node" , "fred", NG_NODELEN)) ... .Pp .It A node dependent opaque cookie .Pp You may place anything of type .Em pointer here. Use the macros .Fn NG_NODE_SET_PRIVATE node value and .Fn NG_NODE_PRIVATE "node" to set and retrieve this property. .Pp .It number of hooks .Pp Use .Fn NG_NODE_NUMHOOKS "node" to retrieve this value. .Pp .It hooks .Pp The node may have a number of hooks. A traversal method is provided to allow all the hooks to be tested for some condition. .Fn NG_NODE_FOREACH_HOOK node fn arg rethook where fn is a function that will be called for each hook with the form .Fn fn hook arg and returning 0 to terminate the search. If the search is terminated, then .Em rethook will be set to the hook at which the search was terminated. .El .It struct ng_hook Node authors should always use the following typedef to declare their hook pointers. .Pp typedef struct ng_hook *hook_p; .Pp The following properties are associated with a hook, and can be accessed in the following manner: .Bl -bullet -compact -offset 2n .Pp .It A node dependent opaque cookie. .Pp You may place anything of type .Em pointer here. Use the macros .Fn NG_HOOK_SET_PRIVATE hook value and .Fn NG_HOOK_PRIVATE "hook" to set and retrieve this property. .Pp .It An associate node. .Pp You may use the macro .Fn NG_HOOK_NODE "hook" to find the associated node. .Pp .It A peer hook .Pp The other hook in this connected pair. Of type hook_p. You can use .Fn NG_HOOK_PEER "hook" to find the peer. .Pp .It references .Pp .Fn NG_HOOK_REF "hook" and .Fn NG_HOOK_UNREF "hook" increment and decrement the hook reference count accordingly. After decrement you should always assume the hook has been freed unless you have another reference still valid. .Pp .It Over-ride receive functions. .Pp The .Fn NG_HOOK_SET_RCVDATA hook fn and .Fn NG_HOOK_SET_RCVMSG hook fn macros can be used to set over-ride methods that will be used in preference to the generic receive data and reveive message functions. To unset these use the macros to set them to NULL. They will only be used for data and messages received on the hook on which they are set. .El .Pp The maintenance of the names, reference counts, and linked list of hooks for each node is handled automatically by the .Nm subsystem. Typically a node's private info contains a back-pointer to the node or hook structure, which counts as a new reference that must be included in the reference count for the node. When the node constructor is called there is already a reference for this calculated in, so that when the node is destroyed, it should remember to do a .Fn NG_NODE_UNREF on the node. .Pp From a hook you can obtain the corresponding node, and from a node, it is possible to traverse all the active hooks. .Pp A current example of how to define a node can always be seen in .Em sys/netgraph/ng_sample.c and should be used as a starting point for new node writers. .El .Sh Netgraph Message Structure Control messages have the following structure: .Bd -literal #define NG_CMDSTRLEN 15 /* Max command string (16 with null) */ struct ng_mesg { struct ng_msghdr { u_char version; /* Must equal NG_VERSION */ u_char spare; /* Pad to 2 bytes */ u_short arglen; /* Length of cmd/resp data */ u_long flags; /* Message status flags */ u_long token; /* Reply should have the same token */ u_long typecookie; /* Node type understanding this message */ u_long cmd; /* Command identifier */ u_char cmdstr[NG_CMDSTRLEN+1]; /* Cmd string (for debug) */ } header; char data[0]; /* Start of cmd/resp data */ }; #define NG_ABI_VERSION 5 /* Netgraph kernel ABI version */ #define NG_VERSION 4 /* Netgraph message version */ #define NGF_ORIG 0x0000 /* Command */ #define NGF_RESP 0x0001 /* Response */ .Ed .Pp Control messages have the fixed header shown above, followed by a variable length data section which depends on the type cookie and the command. Each field is explained below: .Bl -tag -width xxx .It Dv version Indicates the version of the netgraph message protocol itself. The current version is .Dv NG_VERSION . .It Dv arglen This is the length of any extra arguments, which begin at .Dv data . .It Dv flags Indicates whether this is a command or a response control message. .It Dv token The .Dv token is a means by which a sender can match a reply message to the corresponding command message; the reply always has the same token. .Pp .It Dv typecookie The corresponding node type's unique 32-bit value. If a node doesn't recognize the type cookie it must reject the message by returning .Er EINVAL . .Pp Each type should have an include file that defines the commands, argument format, and cookie for its own messages. The typecookie insures that the same header file was included by both sender and receiver; when an incompatible change in the header file is made, the typecookie .Em must be changed. The de facto method for generating unique type cookies is to take the seconds from the epoch at the time the header file is written (i.e., the output of .Dv "date -u +'%s'" ) . .Pp There is a predefined typecookie .Dv NGM_GENERIC_COOKIE for the .Dq generic node type, and a corresponding set of generic messages which all nodes understand. The handling of these messages is automatic. .It Dv command The identifier for the message command. This is type specific, and is defined in the same header file as the typecookie. .It Dv cmdstr Room for a short human readable version of .Dq command (for debugging purposes only). .El .Pp Some modules may choose to implement messages from more than one of the header files and thus recognize more than one type cookie. .Sh Control Message ASCII Form Control messages are in binary format for efficiency. However, for debugging and human interface purposes, and if the node type supports it, control messages may be converted to and from an equivalent .Tn ASCII form. The .Tn ASCII form is similar to the binary form, with two exceptions: .Pp .Bl -tag -compact -width xxx .It o The .Dv cmdstr header field must contain the .Tn ASCII name of the command, corresponding to the .Dv cmd header field. .It o The .Dv args field contains a NUL-terminated .Tn ASCII string version of the message arguments. .El .Pp In general, the arguments field of a control messgage can be any arbitrary C data type. Netgraph includes parsing routines to support some pre-defined datatypes in .Tn ASCII with this simple syntax: .Pp .Bl -tag -compact -width xxx .It o Integer types are represented by base 8, 10, or 16 numbers. .It o Strings are enclosed in double quotes and respect the normal C language backslash escapes. .It o IP addresses have the obvious form. .It o Arrays are enclosed in square brackets, with the elements listed consecutively starting at index zero. An element may have an optional index and equals sign preceding it. Whenever an element does not have an explicit index, the index is implicitly the previous element's index plus one. .It o Structures are enclosed in curly braces, and each field is specified in the form .Dq fieldname=value . .It o Any array element or structure field whose value is equal to its .Dq default value may be omitted. For integer types, the default value is usually zero; for string types, the empty string. .It o Array elements and structure fields may be specified in any order. .El .Pp Each node type may define its own arbitrary types by providing the necessary routines to parse and unparse. .Tn ASCII forms defined for a specific node type are documented in the documentation for that node type. .Sh Generic Control Messages There are a number of standard predefined messages that will work for any node, as they are supported directly by the framework itself. These are defined in .Pa ng_message.h along with the basic layout of messages and other similar information. .Bl -tag -width xxx .It Dv NGM_CONNECT Connect to another node, using the supplied hook names on either end. .It Dv NGM_MKPEER Construct a node of the given type and then connect to it using the supplied hook names. .It Dv NGM_SHUTDOWN The target node should disconnect from all its neighbours and shut down. Persistent nodes such as those representing physical hardware might not disappear from the node namespace, but only reset themselves. The node must disconnect all of its hooks. This may result in neighbors shutting themselves down, and possibly a cascading shutdown of the entire connected graph. .It Dv NGM_NAME Assign a name to a node. Nodes can exist without having a name, and this is the default for nodes created using the .Dv NGM_MKPEER method. Such nodes can only be addressed relatively or by their ID number. .It Dv NGM_RMHOOK Ask the node to break a hook connection to one of its neighbours. Both nodes will have their .Dq disconnect method invoked. Either node may elect to totally shut down as a result. .It Dv NGM_NODEINFO Asks the target node to describe itself. The four returned fields are the node name (if named), the node type, the node ID and the number of hooks attached. The ID is an internal number unique to that node. .It Dv NGM_LISTHOOKS This returns the information given by .Dv NGM_NODEINFO , but in addition includes an array of fields describing each link, and the description for the node at the far end of that link. .It Dv NGM_LISTNAMES This returns an array of node descriptions (as for .Dv NGM_NODEINFO ")" where each entry of the array describes a named node. All named nodes will be described. .It Dv NGM_LISTNODES This is the same as .Dv NGM_LISTNAMES except that all nodes are listed regardless of whether they have a name or not. .It Dv NGM_LISTTYPES This returns a list of all currently installed netgraph types. .It Dv NGM_TEXT_STATUS The node may return a text formatted status message. The status information is determined entirely by the node type. It is the only "generic" message that requires any support within the node itself and as such the node may elect to not support this message. The text response must be less than .Dv NG_TEXTRESPONSE bytes in length (presently 1024). This can be used to return general status information in human readable form. .It Dv NGM_BINARY2ASCII This message converts a binary control message to its .Tn ASCII form. The entire control message to be converted is contained within the arguments field of the .Dv NGM_BINARY2ASCII message itself. If successful, the reply will contain the same control message in .Tn ASCII form. A node will typically only know how to translate messages that it itself understands, so the target node of the .Dv NGM_BINARY2ASCII is often the same node that would actually receive that message. .It Dv NGM_ASCII2BINARY The opposite of .Dv NGM_BINARY2ASCII . The entire control message to be converted, in .Tn ASCII form, is contained in the arguments section of the .Dv NGM_ASCII2BINARY and need only have the .Dv flags , .Dv cmdstr , and .Dv arglen header fields filled in, plus the NUL-terminated string version of the arguments in the arguments field. If successful, the reply contains the binary version of the control message. .El .Sh Flow Control Messages In addition to the control messages that affect nodes with respect to the graph, there are also a number of .Em Flow-control messages defined. At present these are .Em NOT handled automatically by the system, so nodes need to handle them if they are going to be used in a graph utilising flow control, and will be in the likely path of these messages. The default action of a node that doesn't understand these messages should be to pass them onto the next node. Hopefully some helper functions will assist in this eventually. These messages are also defined in .Pa sys/netgraph/ng_message.h and have a separate cookie .Em NG_FLOW_COOKIE to help identify them. They will not be covered in depth here. .Sh Metadata Data moving through the .Nm system can be accompanied by meta-data that describes some aspect of that data. The form of the meta-data is a fixed header, which contains enough information for most uses, and can optionally be supplemented by trailing .Em option structures, which contain a .Em cookie (see the section on control messages), an identifier, a length and optional data. If a node does not recognize the cookie associated with an option, it should ignore that option. .Pp Meta data might include such things as priority, discard eligibility, or special processing requirements. It might also mark a packet for debug status, etc. The use of meta-data is still experimental. .Sh INITIALIZATION The base .Nm code may either be statically compiled into the kernel or else loaded dynamically as a KLD via .Xr kldload 8 . In the former case, include .Pp .Dl options NETGRAPH .Pp in your kernel configuration file. You may also include selected node types in the kernel compilation, for example: .Bd -literal -offset indent options NETGRAPH options NETGRAPH_SOCKET options NETGRAPH_ECHO .Ed .Pp Once the .Nm subsystem is loaded, individual node types may be loaded at any time as KLD modules via .Xr kldload 8 . Moreover, .Nm knows how to automatically do this; when a request to create a new node of unknown type .Em type is made, .Nm will attempt to load the KLD module .Pa ng_type.ko . .Pp Types can also be installed at boot time, as certain device drivers may want to export each instance of the device as a netgraph node. .Pp In general, new types can be installed at any time from within the kernel by calling .Fn ng_newtype , supplying a pointer to the type's .Dv struct ng_type structure. .Pp The .Fn NETGRAPH_INIT macro automates this process by using a linker set. .Sh EXISTING NODE TYPES Several node types currently exist. Each is fully documented in its own man page: .Bl -tag -width xxx .It SOCKET The socket type implements two new sockets in the new protocol domain .Dv PF_NETGRAPH . The new sockets protocols are .Dv NG_DATA and .Dv NG_CONTROL , both of type .Dv SOCK_DGRAM . Typically one of each is associated with a socket node. When both sockets have closed, the node will shut down. The .Dv NG_DATA socket is used for sending and receiving data, while the .Dv NG_CONTROL socket is used for sending and receiving control messages. Data and control messages are passed using the .Xr sendto 2 and .Xr recvfrom 2 calls, using a .Dv struct sockaddr_ng socket address. .Pp .It HOLE Responds only to generic messages and is a .Dq black hole for data, Useful for testing. Always accepts new hooks. .Pp .It ECHO Responds only to generic messages and always echoes data back through the hook from which it arrived. Returns any non generic messages as their own response. Useful for testing. Always accepts new hooks. .Pp .It TEE This node is useful for .Dq snooping . It has 4 hooks: .Dv left , .Dv right , .Dv left2right , and .Dv right2left . Data entering from the right is passed to the left and duplicated on .Dv right2left , and data entering from the left is passed to the right and duplicated on .Dv left2right . Data entering from .Dv left2right is sent to the right and data from .Dv right2left to left. .Pp .It RFC1490 MUX Encapsulates/de-encapsulates frames encoded according to RFC 1490. Has a hook for the encapsulated packets .Pq Dq downstream and one hook for each protocol (i.e., IP, PPP, etc.). .Pp .It FRAME RELAY MUX Encapsulates/de-encapsulates Frame Relay frames. Has a hook for the encapsulated packets .Pq Dq downstream and one hook for each DLCI. .Pp .It FRAME RELAY LMI Automatically handles frame relay .Dq LMI (link management interface) operations and packets. Automatically probes and detects which of several LMI standards is in use at the exchange. .Pp .It TTY This node is also a line discipline. It simply converts between mbuf frames and sequential serial data, allowing a tty to appear as a netgraph node. It has a programmable .Dq hotkey character. .Pp .It ASYNC This node encapsulates and de-encapsulates asynchronous frames according to RFC 1662. This is used in conjunction with the TTY node type for supporting PPP links over asynchronous serial lines. .Pp .It INTERFACE This node is also a system networking interface. It has hooks representing each protocol family (IP, AppleTalk, IPX, etc.) and appears in the output of .Xr ifconfig 8 . The interfaces are named .Em ng0 , .Em ng1 , etc. .It ONE2MANY This node implements a simple round-robin multiplexer. It can be used for example to make several LAN ports act together to get a higher speed link between two machines. .It Various PPP related nodes. There is a full multilink PPP implementation that runs in Netgraph. The .Em Mpd port can use these modules to make a very low latency high capacity ppp system. It also supports .Em PPTP vpns using the .Em PPTP node. .It PPPOE A server and client side implememtation of PPPoE. Used in conjunction with either .Xr ppp 8 or the .Em mpd port . .It BRIDGE This node, togther with the ethernet nodes allows a very flexible bridging system to be implemented. .It KSOCKET This intriguing node looks like a socket to the system but diverts all data to and from the netgraph system for further processing. This allows such things as UDP tunnels to be almost trivially implemented from the command line. .El .Pp Refer to the section at the end of this man page for more nodes types. .Sh NOTES Whether a named node exists can be checked by trying to send a control message to it (e.g., .Dv NGM_NODEINFO ) . If it does not exist, .Er ENOENT will be returned. .Pp All data messages are mbuf chains with the M_PKTHDR flag set. .Pp Nodes are responsible for freeing what they allocate. There are three exceptions: .Bl -tag -width xxxx .It 1 Mbufs sent across a data link are never to be freed by the sender. In the case of error, they should be considered freed. .It 2 Any meta-data information traveling with the data has the same restriction. It might be freed by any node the data passes through, and a .Dv NULL passed onwards, but the caller will never free it. Two macros .Fn NG_FREE_META "meta" and .Fn NG_FREE_M "m" should be used if possible to free data and meta data (see .Pa netgraph.h ) . .It 3 Messages sent using .Fn ng_send_message are freed by the recipient. As in the case above, the addresses associated with the message are freed by whatever allocated them so the recipient should copy them if it wants to keep that information. .It 4 Both control mesages and data are delivered and queued with a netgraph .Em item . The item must be freed using .Fn NG_FREE_ITEM "item" or passed on to another node. .El .Sh FILES .Bl -tag -width xxxxx -compact .It Pa /sys/netgraph/netgraph.h Definitions for use solely within the kernel by .Nm nodes. .It Pa /sys/netgraph/ng_message.h Definitions needed by any file that needs to deal with .Nm messages. .It Pa /sys/netgraph/ng_socket.h Definitions needed to use .Nm socket type nodes. .It Pa /sys/netgraph/ng_{type}.h Definitions needed to use .Nm {type} nodes, including the type cookie definition. .It Pa /modules/netgraph.ko Netgraph subsystem loadable KLD module. .It Pa /modules/ng_{type}.ko Loadable KLD module for node type {type}. .It Pa /sys/netgraph/ng_sample.c Skeleton netgraph node. Use this as a starting point for new node types. .El .Sh USER MODE SUPPORT There is a library for supporting user-mode programs that wish to interact with the netgraph system. See .Xr netgraph 3 for details. .Pp Two user-mode support programs, .Xr ngctl 8 and .Xr nghook 8 , are available to assist manual configuration and debugging. .Pp There are a few useful techniques for debugging new node types. First, implementing new node types in user-mode first makes debugging easier. The .Em tee node type is also useful for debugging, especially in conjunction with .Xr ngctl 8 and .Xr nghook 8 . .Pp Also look in /usr/share/examples/netgraph for solutions to several common networking problems, solved using .Nm . .Sh SEE ALSO .Xr socket 2 , .Xr netgraph 3 , .Xr ng_async 4 , .Xr ng_bpf 4 , .Xr ng_bridge 4 , .Xr ng_cisco 4 , .Xr ng_echo 4 , .Xr ng_ether 4 , .Xr ng_ether 4 , .Xr ng_frame_relay 4 , .Xr ng_hole 4 , .Xr ng_iface 4 , .Xr ng_ksocket 4 , .Xr ng_lmi 4 , .Xr ng_mppc 4 , .Xr ng_ppp 4 , .Xr ng_pppoe 4 , .Xr ng_pptpgre 4 , .Xr ng_rfc1490 4 , .Xr ng_socket 4 , .Xr ng_tee 4 , .Xr ng_tty 4 , .Xr ng_UI 4 , .Xr ng_vjc 4 , .Xr ngctl 8 , .Xr nghook 8 .Sh HISTORY The .Nm system was designed and first implemented at Whistle Communications, Inc.\& in a version of .Fx 2.2 customized for the Whistle InterJet. It first made its debut in the main tree in .Fx 3.4 . .Sh AUTHORS .An -nosplit .An Julian Elischer Aq julian@FreeBSD.org , with contributions by .An Archie Cobbs Aq archie@FreeBSD.org . Index: head/share/man/man4/sym.4 =================================================================== --- head/share/man/man4/sym.4 (revision 82327) +++ head/share/man/man4/sym.4 (revision 82328) @@ -1,314 +1,314 @@ .\" .\" Device driver optimized for the Symbios/LSI 53C896/53C895A/53C1010 .\" PCI SCSI controllers. .\" .\" Copyright (C) 1999-2000 Gerard Roudier .\" .\" This driver also supports the following Symbios/LSI PCI SCSI chips: .\" 53C810A, 53C825A, 53C860, 53C875, 53C876, 53C885, 53C895, .\" 53C810, 53C815, 53C825 and the 53C1510D is 53C8XX mode. .\" .\" .\" This driver for FreeBSD-CAM is derived from the Linux sym53c8xx driver. .\" Copyright (C) 1998-1999 Gerard Roudier .\" .\" The sym53c8xx driver is derived from the ncr53c8xx driver that had been .\" a port of the FreeBSD ncr driver to Linux-1.2.13. .\" .\" The original ncr driver has been written for 386bsd and FreeBSD by .\" Wolfgang Stanglmeier .\" Stefan Esser .\" Copyright (C) 1994 Wolfgang Stanglmeier .\" .\" The initialization code, and part of the code that addresses .\" FreeBSD-CAM services is based on the aic7xxx driver for FreeBSD-CAM .\" written by Justin T. Gibbs. .\" .\" Other major contributions: .\" .\" NVRAM detection and reading. .\" Copyright (C) 1997 Richard Waltham .\" .\" ---------------------------------------------------------------------------- .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. The name of the author may not be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR .\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd January 12, 2000 .Dt SYM 4 .Os .Sh NAME .Nm sym .Nd NCR/Symbios/LSI Logic 53C8XX PCI SCSI host adapter driver .Sh SYNOPSIS For any number of cards: .Cd device sym .Pp To disable PCI parity checking (needed for broken bridges) .Cd options SYM_SETUP_PCI_PARITY= .Pp To control driver probing against HVD buses .Cd options SYM_SETUP_SCSI_DIFF= .Pp To control chip attachment balancing between the ncr driver and this driver .Cd options SYM_SETUP_LP_PROBE_MAP= .Sh DESCRIPTION This driver provides support for the Symbios/LSI Logic .Tn 53C810 , .Tn 53C815 , .Tn 53C825 , .Tn 53C810A , .Tn 53C825A , .Tn 53C860 , .Tn 53C875 , .Tn 53C876 , .Tn 53C895 , .Tn 53C895A , .Tn 53C896 , .Tn 53C897 , .Tn 53C1510D , and .Tn 53C1010 PCI SCSI controllers. .Pp Driver features include support for wide SCSI busses and fast10, fast20, fast40 and fast80-dt synchronous data transfers depending on controller capabilities. It also provides generic SCSI features such as tagged command -queuing and auto-request sense. +queueing and auto-request sense. This driver is configured by default for a maximum of 446 outstanding commands per bus, 8 LUNs per target and 64 tagged tasks per LUN. These numbers are not so much limited by design as they are considered reasonable values for current SCSI technology. These values can be increased by changing appropriate constants in driver header files (not recommended). .Pp This driver supports the entire Symbios 53C8XX family of PCI SCSI controllers. It also offers the advantage of architectural improvements available only with newer chips. .Pp .Nm notably handles phase mismatch from SCRIPTS for the 53C896, 53C895A, and 53C1010 cores. As a result, it guarantees that no more than 1 interrupt per IO completion is delivered to the CPU, and that the SCRIPTS processor is never stalled waiting for CPU attention in normal situations. .Pp .Nm also uses LOAD/STORE SCRIPTS instructions for chips that support it. Only the early 810, 815 and 825 NCR chips do not support LOAD/STORE. Use of LOAD/STORE instead of MEMORY MOVE allows SCRIPTS to access IO registers internal to the chip (no external PCI cycles). As a result, the driver guarantees that no PCI self-mastering will occur for chips that support LOAD/STORE. .Pp LOAD/STORE instructions are also faster than MEMORY MOVE because they do not involve the chip DMA FIFO and are coded on 2 DWORDs instead of 3. .Pp For the early NCR 810, 815 and 825 chips, the driver uses a separate SCRIPTS set that uses MEMORY MOVE instructions for data movements. This is because LOAD/STORE are not supported by these chips. .Pp HVD/LVD capable controllers (895, 895A, 896, and 897) report the actual bus mode in the STEST4 chip IO registers. This feature allows the driver to safely probe against bus mode and to set up the chip accordingly. By default the driver only supports HVD for these chips. For other chips that can support HVD but not LVD, the driver has to probe implementation dependent registers (GPIO) in order to detect HVD bus mode. Only HVD implementations that conform with Symbios Logic recommendations can be detected by the driver. When the .Ar SYM_SETUP_SCSI_DIFF kernel option is assigned a value of 1, the driver will also probe against HVD for 825a, 875, 876 and 885 chips, assuming Symbios Logic compatible implementation of HVD. .Pp When the .Ar SYM_SETUP_PCI_PARITY is assigned a value of 0, the driver will not enable PCI parity checking for 53C8XX devices. PCI parity checking should not be an option for PCI SCSI controllers, but some systems have been reported to fail using 53C8XX chips, due to spurious or permanent PCI parity errors detected. This option is supplied for convenience but it is neither recommended nor supported. .Pp The generic .Xr ncr 4 driver also supports SYM53C8XX based PCI SCSI controllers, except for the SYM53C1010, which is only supported by the .Nm driver. .Pp By default, when both the .Xr ncr 4 and .Nm drivers are configured, the .Nm driver takes precedence over the .Xr ncr 4 driver. The user can indicate a balancing of chip types between the two drivers by defining the .Ar SYM_SETUP_LP_PROBE_MAP kernel configuration option as follows: .Bl -column "0x40" .It Em "Bit Devices to be attached by ncr instead" .It "0x01 53C810a, 53C860" .It "0x02 53C825a, 53C875, 53C876, 53C885, 53C895" .It "0x04 53C895a, 53C896, 53C897, 53C1510d" .It "0x40 53C810, 53C815, 53C825" .El .Pp For example, if .Ar SYM_SETUP_LP_PROBE_MAP is supplied with the value 0x41, the .Xr ncr 4 driver will attach to 53C810, 53C815, 53C825, 53C810a, and 53C860 based controllers, and the .Nm driver will attach to all other 53C8XX based controllers. .Pp When only the .Nm driver is configured, the .Ar SYM_SETUP_LP_PROBE_MAP option has no effect. Thus, in this case, the .Nm driver will attach all 53C8XX based controllers present in the system. .Pp This driver offers other options that are not currently exported to the user. They are defined and documented in the .Pa sym_conf.h driver file. Changing these options is not recommended unless absolutely necessary. Some of these options are planned to be exported through .Xr sysctl 3 or an equivalent mechanism in a future driver releases and therefore, no compatibility is guaranteed. .Pp At initialization, the driver tries to detect and read user settings from controller NVRAM. The Symbios/Logic NVRAM layout and the Tekram NVRAM layout are currently supported. If the reading of the NVRAM succeeds, the following settings are taken into account and reported to CAM: .Pp .Bl -column "SCSI parity checking" "Symbios" .It Em "Host settings Symbios Tekram" .It "SCSI parity checking Y N" .It "Host SCSI ident Y Y" .It "Verbose messages Y N" .It "Scan targets hi-lo Y N" .It "Avoid SCSI bus reset Y N" .El .Bl -column "Synchronous period" "Symbios" .It Em "Device settings Symbios Tekram" .It "Synchronous period Y Y" .It "SCSI bus width Y Y" .It "Queue tag enable Y Y" .It "Number of tags NA Y" .It "Disconnect enable Y Y" .It "Scan at boot time Y N" .It "Scan LUN Y N" .El .Pp Devices that are configured as disabled for 'scan' in the NVRAM are not reported to CAM at system start-up. They can be discovered later using the .Ql camcontrol rescan command. .Pp The table below summarizes the main features and capabilities of the NCR/Symbios/LSI Logic 53C8XX family of PCI SCSI controllers. .Pp .Bl -column sym53c1510d "80MHz" "Width" "SRAM" "PCI64" .It Em "Chip Sync Width SRAM PCI64 Supported" .It "sym53c810 10MHz 8Bit N N Y" .It "sym53c810a 10MHz 8Bit N N Y" .It "sym53c815 10MHz 8Bit N N Y" .It "sym53c825 10MHz 16Bit N N Y" .It "sym53c825a 10MHz 16Bit 4KB N Y" .It "sym53c860 20MHz 8Bit N N Y" .It "sym53c875 20MHz 16Bit 4KB N Y" .It "sym53c876 20MHz 16Bit 4KB N Y" .It "sym53c885 20MHz 16Bit 4KB N Y" .It "sym53c895 40MHz 16Bit 4KB N Y" .It "sym53c895A 40MHz 16Bit 8KB N Y" .It "sym53c896 40MHz 16Bit 8KB Y Y" .It "sym53c897 40MHz 16Bit 8KB Y Y" .It "sym53c1510D 40MHz 16Bit 4KB Y Y" .It "sym53c1010 80MHz 16Bit 8KB Y Y" .El .Sh BUGS No known bugs. .Sh SEE ALSO .Xr cd 4 , .Xr da 4 , .Xr ncr 4 , .Xr sa 4 , .Xr scsi 4 , .Xr camcontrol 8 .Sh AUTHORS .An -nosplit The .Nm driver was written by .An Gerard Roudier and is derived from the Linux sym53c8xx driver from the same author. The sym53c8xx driver is derived from the ncr53c8xx driver, which was ported from the .Fx .Xr ncr 4 driver to Linux-1.2.13. The original .Xr ncr 4 driver was written for .Bx 386 and .Fx by .An Wolfgang Stanglmeier and .An Stefan Esser . .Sh HISTORY The .Nm driver appeared in .Fx 4.0 .