xref: /freebsd/share/man/man9/netisr.9 (revision 45c203fce2d02381f76b2abf80edaea8cf7bc7f8)
16b8eb655SRobert Watson.\"
26b8eb655SRobert Watson.\" Copyright (c) 2009 Robert N. M. Watson
36b8eb655SRobert Watson.\" All rights reserved.
46b8eb655SRobert Watson.\"
56b8eb655SRobert Watson.\" Redistribution and use in source and binary forms, with or without
66b8eb655SRobert Watson.\" modification, are permitted provided that the following conditions
76b8eb655SRobert Watson.\" are met:
86b8eb655SRobert Watson.\" 1. Redistributions of source code must retain the above copyright
96b8eb655SRobert Watson.\"    notice(s), this list of conditions and the following disclaimer as
106b8eb655SRobert Watson.\"    the first lines of this file unmodified other than the possible
116b8eb655SRobert Watson.\"    addition of one or more copyright notices.
126b8eb655SRobert Watson.\" 2. Redistributions in binary form must reproduce the above copyright
136b8eb655SRobert Watson.\"    notice(s), this list of conditions and the following disclaimer in the
146b8eb655SRobert Watson.\"    documentation and/or other materials provided with the distribution.
156b8eb655SRobert Watson.\"
166b8eb655SRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
176b8eb655SRobert Watson.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
186b8eb655SRobert Watson.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
196b8eb655SRobert Watson.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
206b8eb655SRobert Watson.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
216b8eb655SRobert Watson.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
226b8eb655SRobert Watson.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
236b8eb655SRobert Watson.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
246b8eb655SRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
256b8eb655SRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
266b8eb655SRobert Watson.\" DAMAGE.
276b8eb655SRobert Watson.\"
286b8eb655SRobert Watson.\" $FreeBSD$
296b8eb655SRobert Watson.\"
30497c391cSRobert Watson.Dd February 22, 2010
316b8eb655SRobert Watson.Dt NETISR 9
326b8eb655SRobert Watson.Os
336b8eb655SRobert Watson.Sh NAME
346b8eb655SRobert Watson.Nm netisr
356b8eb655SRobert Watson.Nd Kernel network dispatch service
366b8eb655SRobert Watson.Sh SYNOPSIS
376b8eb655SRobert Watson.In net/netisr.h
386b8eb655SRobert Watson.Ft void
396b8eb655SRobert Watson.Fn netisr_register "const struct netisr_handler *nhp"
406b8eb655SRobert Watson.Ft void
416b8eb655SRobert Watson.Fn netisr_unregister "const struct netisr_handler *nhp"
426b8eb655SRobert Watson.Ft int
436b8eb655SRobert Watson.Fn netisr_dispatch "u_int proto" "struct mbuf *m"
446b8eb655SRobert Watson.Ft int
456b8eb655SRobert Watson.Fn netisr_dispatch_src "u_int proto" "uintptr_t source" "struct mbuf *m"
466b8eb655SRobert Watson.Ft int
476b8eb655SRobert Watson.Fn netisr_queue "u_int proto" "struct mbuf *m"
486b8eb655SRobert Watson.Ft int
496b8eb655SRobert Watson.Fn netisr_queue_src "u_int proto" "uintptr_t source" "struct mbuf *m"
506b8eb655SRobert Watson.Ft void
516b8eb655SRobert Watson.Fn netisr_clearqdrops "const struct netisr_handler *nhp"
526b8eb655SRobert Watson.Ft void
536b99842aSEd Schouten.Fn netisr_getqdrops "const struct netisr_handler *nhp" "uint64_t *qdropsp"
5444549f13SBjoern A. Zeeb.Ft void
556b8eb655SRobert Watson.Fn netisr_getqlimit "const struct netisr_handler *nhp" "u_int *qlimitp"
566b8eb655SRobert Watson.Ft int
576b8eb655SRobert Watson.Fn netisr_setqlimit "const struct netisr_handler *nhp" "u_int qlimit"
586b8eb655SRobert Watson.Ft u_int
596b8eb655SRobert Watson.Fn netisr_default_flow2cpu "u_int flowid"
606b8eb655SRobert Watson.Ft u_int
616b8eb655SRobert Watson.Fn netisr_get_cpucount "void"
626b8eb655SRobert Watson.Ft u_int
636b8eb655SRobert Watson.Fn netisr_get_cpuid "u_int cpunumber"
646b8eb655SRobert Watson.Sh DESCRIPTION
656b8eb655SRobert WatsonThe
666b8eb655SRobert Watson.Nm
676b8eb655SRobert Watsonkernel interface suite allows device drivers (and other packet sources) to
686b8eb655SRobert Watsondirect packets to protocols for directly dispatched or deferred processing.
69497c391cSRobert WatsonProtocol registration and work stream statistics may be monitored using
70497c391cSRobert Watson.Xr netstat 1 .
716b8eb655SRobert Watson.Ss Protocol registration
726b8eb655SRobert WatsonProtocols register and unregister handlers using
736b8eb655SRobert Watson.Fn netisr_register
746b8eb655SRobert Watsonand
756b8eb655SRobert Watson.Fn netisr_unregister ,
766b8eb655SRobert Watsonand may also manage queue limits and statistics using the
776b8eb655SRobert Watson.Fn netisr_clearqdrops ,
786b8eb655SRobert Watson.Fn netisr_getqdrops ,
796b8eb655SRobert Watson.Fn netisr_getqlimit ,
806b8eb655SRobert Watsonand
816b8eb655SRobert Watson.Fn netisr_setqlimit .
826b8eb655SRobert Watson.Pp
836b8eb655SRobert Watson.Nm
846b8eb655SRobert Watsonsupports multi-processor execution of handlers, and relies on a combination
856b8eb655SRobert Watsonof source ordering and protocol-specific ordering and work-placement
86f0e6364eSMark Johnstonpolicies to decide how to distribute work across one or more worker
876b8eb655SRobert Watsonthreads.
886b8eb655SRobert WatsonRegistering protocols will declare one of three policies:
896b8eb655SRobert Watson.Bl -tag -width NETISR_POLICY_SOURCE
906b8eb655SRobert Watson.It Dv NETISR_POLICY_SOURCE
916b8eb655SRobert Watson.Nm
926b8eb655SRobert Watsonshould maintain source ordering without advice from the protocol.
936b8eb655SRobert Watson.Nm
946b8eb655SRobert Watsonwill ignore any flow IDs present on
956b8eb655SRobert Watson.Vt mbuf
966b8eb655SRobert Watsonheaders for the purposes of work placement.
976b8eb655SRobert Watson.It Dv NETISR_POLICY_FLOW
986b8eb655SRobert Watson.Nm
996b8eb655SRobert Watsonshould maintain flow ordering as defined by the
1006b8eb655SRobert Watson.Vt mbuf
1016b8eb655SRobert Watsonheader flow ID field.
1026b8eb655SRobert WatsonIf the protocol implements
1036b8eb655SRobert Watson.Va nh_m2flow ,
1046b8eb655SRobert Watsonthen
1056b8eb655SRobert Watson.Nm
106c2025a76SJoel Dahlwill query the protocol in the event that the
1076b8eb655SRobert Watson.Vt mbuf
1086b8eb655SRobert Watsondoesn't have a flow ID, falling back on source ordering.
1096b8eb655SRobert Watson.It NETISR_POLICY_CPU
1106b8eb655SRobert Watson.Nm
1116b8eb655SRobert Watsonwill entirely delegate all work placement decisions to the protocol,
1126b8eb655SRobert Watsonquerying
1136b8eb655SRobert Watson.Va nh_m2cpuid
1146b8eb655SRobert Watsonfor each packet.
1156b8eb655SRobert Watson.El
1166b8eb655SRobert Watson.Pp
1176b8eb655SRobert WatsonRegistration is declared using
1186b8eb655SRobert Watson.Vt "struct netisr_handler" ,
1196b8eb655SRobert Watsonwhose fields are defined as follows:
1206b8eb655SRobert Watson.Bl -tag -width "netisr_handler_t nh_handler"
1216b8eb655SRobert Watson.It Vt "const char *" Va nh_name
1226b8eb655SRobert WatsonUnique character string name of the protocol, which may be included in
123c2025a76SJoel Dahl.Xr sysctl 2
1246b8eb655SRobert WatsonMIB names, so should not contain whitespace.
1256b8eb655SRobert Watson.It Vt netisr_handler_t Va nh_handler
1266b8eb655SRobert WatsonProtocol handler function that will be invoked on each packet received for
1276b8eb655SRobert Watsonthe protocol.
1286b8eb655SRobert Watson.It Vt netisr_m2flow_t Va nh_m2flow
1296b8eb655SRobert WatsonOptional protocol function to generate a flow ID and set
1306b8eb655SRobert Watson.Dv M_FLOWID
1316b8eb655SRobert Watsonfor packets that do not enter
1326b8eb655SRobert Watson.Nm
1336b8eb655SRobert Watsonwith
1346b8eb655SRobert Watson.Dv M_FLOWID
1356b8eb655SRobert Watsondefined.
1366b8eb655SRobert WatsonWill be used only with
1376b8eb655SRobert Watson.Dv NETISR_POLICY_FLOW .
1386b8eb655SRobert Watson.It Vt netisr_m2cpuid_t Va nh_m2cpuid
1396b8eb655SRobert WatsonProtocol function to determine what CPU a packet should be processed on.
1406b8eb655SRobert WatsonWill be used only with
1416b8eb655SRobert Watson.Dv NETISR_POLICY_CPU .
142ed655c8cSBjoern A. Zeeb.It Vt netisr_drainedcpu_t Va nh_drainedcpu
143ed655c8cSBjoern A. ZeebOptional callback function that will be invoked when a per-CPU queue
144ed655c8cSBjoern A. Zeebwas drained.
145ed655c8cSBjoern A. ZeebIt will never fire for directly dispatched packets.
146ed655c8cSBjoern A. ZeebUnless fully understood, this special-purpose function should not be used.
147ed655c8cSBjoern A. Zeeb.\" In case you intend to use this please send 50 chocolate bars to each
148ed655c8cSBjoern A. Zeeb.\" of rwatson and bz and wait for an answer.
1496b8eb655SRobert Watson.It Vt u_int Va nh_proto
1506b8eb655SRobert WatsonProtocol number used by both protocols to identify themselves to
1516b8eb655SRobert Watson.Nm ,
1526b8eb655SRobert Watsonand by packet sources to select what handler will be used to process
1536b8eb655SRobert Watsonpackets.
1546b8eb655SRobert WatsonA table of supported protocol numbers appears below.
1556b8eb655SRobert WatsonFor implementation reasons, protocol numbers great than 15 are currently
1566b8eb655SRobert Watsonunsupported.
1576b8eb655SRobert Watson.It Vt u_int Va nh_qlimit
1586b8eb655SRobert WatsonThe maximum per-CPU queue depth for the protocol; due to internal
1596b8eb655SRobert Watsonimplementation details, the effective queue depth may be as much as twice
1606b8eb655SRobert Watsonthis number.
1616b8eb655SRobert Watson.It Vt u_int Va nh_policy
1626b8eb655SRobert WatsonThe ordering and work placement policy for the protocol, as described
1636b8eb655SRobert Watsonearlier.
1646b8eb655SRobert Watson.El
1656b8eb655SRobert Watson.Ss Packet source interface
1666b8eb655SRobert WatsonPacket sources, such as network interfaces, may request protocol processing
1676b8eb655SRobert Watsonusing the
1686b8eb655SRobert Watson.Fn netisr_dispatch
1696b8eb655SRobert Watsonand
1706b8eb655SRobert Watson.Fn netisr_queue
1716b8eb655SRobert Watsoninterfaces.
1726b8eb655SRobert WatsonBoth accept a protocol number and
1736b8eb655SRobert Watson.Vt mbuf
1746b8eb655SRobert Watsonargument, but while
1756b8eb655SRobert Watson.Fn netisr_queue
176b06cfd40SJoel Dahlwill always execute the protocol handler asynchronously in a deferred
1776b8eb655SRobert Watsoncontext,
1786b8eb655SRobert Watson.Fn netisr_dispatch
1796b8eb655SRobert Watsonwill optionally direct dispatch if permitted by global and per-protocol
1806b8eb655SRobert Watsonpolicy.
1816b8eb655SRobert Watson.Pp
1826b8eb655SRobert WatsonIn order to provide additional load balancing and flow information,
1836b8eb655SRobert Watsonpacket sources may also specify an opaque source identifier, which in
1846b8eb655SRobert Watsonpractice might be a network interface number or socket pointer, using
1856b8eb655SRobert Watsonthe
1866b8eb655SRobert Watson.Fn netisr_dispatch_src
1876b8eb655SRobert Watsonand
1886b8eb655SRobert Watson.Fn netisr_queue_src
1896b8eb655SRobert Watsonvariants.
1906b8eb655SRobert Watson.Ss Protocol number constants
1916b8eb655SRobert WatsonThe follow protocol numbers are currently defined:
192*45c203fcSGleb Smirnoff.Bl -tag -width NETISR_ROUTE
1936b8eb655SRobert Watson.It Dv NETISR_IP
1946b8eb655SRobert WatsonIPv4
1956b8eb655SRobert Watson.It Dv NETISR_IGMP
1966b8eb655SRobert WatsonIGMPv3 loopback
1976b8eb655SRobert Watson.It Dv NETISR_ROUTE
1986b8eb655SRobert WatsonRouting socket loopback
1996b8eb655SRobert Watson.It Dv NETISR_ARP
2006b8eb655SRobert WatsonARP
2016b8eb655SRobert Watson.It Dv NETISR_IPV6
2026b8eb655SRobert WatsonIPv6
2036b8eb655SRobert Watson.It Dv NETISR_NATM
2046b8eb655SRobert WatsonATM
205d0ea4743SBjoern A. Zeeb.It Dv NETISR_EPAIR
206497c391cSRobert Watson.Xr netstat 1 ,
207d0ea4743SBjoern A. Zeeb.Xr epair 4
2086b8eb655SRobert Watson.El
2096b8eb655SRobert Watson.Sh AUTHORS
2106b8eb655SRobert WatsonThis manual page and the
2116b8eb655SRobert Watson.Nm
2126b8eb655SRobert Watsonimplementation were written by
2136b8eb655SRobert Watson.An Robert N. M. Watson .
214