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.\" 306b8eb655SRobert Watson.Dd June 7, 2009 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 536b8eb655SRobert Watson.Fn netisr_getqdrops "const struct netisr_handler *nhp" "u_int64_t *qdropsp" 546b8eb655SRobert Watson.Ft 556b8eb655SRobert Watsonvoid 566b8eb655SRobert Watson.Fn netisr_getqlimit "const struct netisr_handler *nhp" "u_int *qlimitp" 576b8eb655SRobert Watson.Ft int 586b8eb655SRobert Watson.Fn netisr_setqlimit "const struct netisr_handler *nhp" "u_int qlimit" 596b8eb655SRobert Watson.Ft u_int 606b8eb655SRobert Watson.Fn netisr_default_flow2cpu "u_int flowid" 616b8eb655SRobert Watson.Ft u_int 626b8eb655SRobert Watson.Fn netisr_get_cpucount "void" 636b8eb655SRobert Watson.Ft u_int 646b8eb655SRobert Watson.Fn netisr_get_cpuid "u_int cpunumber" 656b8eb655SRobert Watson.Sh DESCRIPTION 666b8eb655SRobert WatsonThe 676b8eb655SRobert Watson.Nm 686b8eb655SRobert Watsonkernel interface suite allows device drivers (and other packet sources) to 696b8eb655SRobert Watsondirect packets to protocols for directly dispatched or deferred processing. 706b8eb655SRobert Watson.Ss Protocol registration 716b8eb655SRobert WatsonProtocols register and unregister handlers using 726b8eb655SRobert Watson.Fn netisr_register 736b8eb655SRobert Watsonand 746b8eb655SRobert Watson.Fn netisr_unregister , 756b8eb655SRobert Watsonand may also manage queue limits and statistics using the 766b8eb655SRobert Watson.Fn netisr_clearqdrops , 776b8eb655SRobert Watson.Fn netisr_getqdrops , 786b8eb655SRobert Watson.Fn netisr_getqlimit , 796b8eb655SRobert Watsonand 806b8eb655SRobert Watson.Fn netisr_setqlimit. 816b8eb655SRobert Watson.Pp 826b8eb655SRobert Watson.Nm 836b8eb655SRobert Watsonsupports multi-processor execution of handlers, and relies on a combination 846b8eb655SRobert Watsonof source ordering and protocol-specific ordering and work-placement 856b8eb655SRobert Watsonpolicies to decide how do distribute work across one or more worker 866b8eb655SRobert Watsonthreads. 876b8eb655SRobert WatsonRegistering protocols will declare one of three policies: 886b8eb655SRobert Watson.Bl -tag -width NETISR_POLICY_SOURCE 896b8eb655SRobert Watson.It Dv NETISR_POLICY_SOURCE 906b8eb655SRobert Watson.Nm 916b8eb655SRobert Watsonshould maintain source ordering without advice from the protocol. 926b8eb655SRobert Watson.Nm 936b8eb655SRobert Watsonwill ignore any flow IDs present on 946b8eb655SRobert Watson.Vt mbuf 956b8eb655SRobert Watsonheaders for the purposes of work placement. 966b8eb655SRobert Watson.It Dv NETISR_POLICY_FLOW 976b8eb655SRobert Watson.Nm 986b8eb655SRobert Watsonshould maintain flow ordering as defined by the 996b8eb655SRobert Watson.Vt mbuf 1006b8eb655SRobert Watsonheader flow ID field. 1016b8eb655SRobert WatsonIf the protocol implements 1026b8eb655SRobert Watson.Va nh_m2flow , 1036b8eb655SRobert Watsonthen 1046b8eb655SRobert Watson.Nm 1056b8eb655SRobert Watsonwill query the protocol in the evet that the 1066b8eb655SRobert Watson.Vt mbuf 1076b8eb655SRobert Watsondoesn't have a flow ID, falling back on source ordering. 1086b8eb655SRobert Watson.It NETISR_POLICY_CPU 1096b8eb655SRobert Watson.Nm 1106b8eb655SRobert Watsonwill entirely delegate all work placement decisions to the protocol, 1116b8eb655SRobert Watsonquerying 1126b8eb655SRobert Watson.Va nh_m2cpuid 1136b8eb655SRobert Watsonfor each packet. 1146b8eb655SRobert Watson.El 1156b8eb655SRobert Watson.Pp 1166b8eb655SRobert WatsonRegistration is declared using 1176b8eb655SRobert Watson.Vt "struct netisr_handler" , 1186b8eb655SRobert Watsonwhose fields are defined as follows: 1196b8eb655SRobert Watson.Bl -tag -width "netisr_handler_t nh_handler" 1206b8eb655SRobert Watson.It Vt "const char *" Va nh_name 1216b8eb655SRobert WatsonUnique character string name of the protocol, which may be included in 1226b8eb655SRobert Watson.Xr 2 sysctl 1236b8eb655SRobert WatsonMIB names, so should not contain whitespace. 1246b8eb655SRobert Watson.It Vt netisr_handler_t Va nh_handler 1256b8eb655SRobert WatsonProtocol handler function that will be invoked on each packet received for 1266b8eb655SRobert Watsonthe protocol. 1276b8eb655SRobert Watson.It Vt netisr_m2flow_t Va nh_m2flow 1286b8eb655SRobert WatsonOptional protocol function to generate a flow ID and set 1296b8eb655SRobert Watson.Dv M_FLOWID 1306b8eb655SRobert Watsonfor packets that do not enter 1316b8eb655SRobert Watson.Nm 1326b8eb655SRobert Watsonwith 1336b8eb655SRobert Watson.Dv M_FLOWID 1346b8eb655SRobert Watsondefined. 1356b8eb655SRobert WatsonWill be used only with 1366b8eb655SRobert Watson.Dv NETISR_POLICY_FLOW . 1376b8eb655SRobert Watson.It Vt netisr_m2cpuid_t Va nh_m2cpuid 1386b8eb655SRobert WatsonProtocol function to determine what CPU a packet should be processed on. 1396b8eb655SRobert WatsonWill be used only with 1406b8eb655SRobert Watson.Dv NETISR_POLICY_CPU . 1416b8eb655SRobert Watson.It Vt u_int Va nh_proto 1426b8eb655SRobert WatsonProtocol number used by both protocols to identify themselves to 1436b8eb655SRobert Watson.Nm , 1446b8eb655SRobert Watsonand by packet sources to select what handler will be used to process 1456b8eb655SRobert Watsonpackets. 1466b8eb655SRobert WatsonA table of supported protocol numbers appears below. 1476b8eb655SRobert WatsonFor implementation reasons, protocol numbers great than 15 are currently 1486b8eb655SRobert Watsonunsupported. 1496b8eb655SRobert Watson.It Vt u_int Va nh_qlimit 1506b8eb655SRobert WatsonThe maximum per-CPU queue depth for the protocol; due to internal 1516b8eb655SRobert Watsonimplementation details, the effective queue depth may be as much as twice 1526b8eb655SRobert Watsonthis number. 1536b8eb655SRobert Watson.It Vt u_int Va nh_policy 1546b8eb655SRobert WatsonThe ordering and work placement policy for the protocol, as described 1556b8eb655SRobert Watsonearlier. 1566b8eb655SRobert Watson.El 1576b8eb655SRobert Watson.Ss Packet source interface 1586b8eb655SRobert WatsonPacket sources, such as network interfaces, may request protocol processing 1596b8eb655SRobert Watsonusing the 1606b8eb655SRobert Watson.Fn netisr_dispatch 1616b8eb655SRobert Watsonand 1626b8eb655SRobert Watson.Fn netisr_queue 1636b8eb655SRobert Watsoninterfaces. 1646b8eb655SRobert WatsonBoth accept a protocol number and 1656b8eb655SRobert Watson.Vt mbuf 1666b8eb655SRobert Watsonargument, but while 1676b8eb655SRobert Watson.Fn netisr_queue 1686b8eb655SRobert Watsonwill always execute the protocol handler asynchonously in a deferred 1696b8eb655SRobert Watsoncontext, 1706b8eb655SRobert Watson.Fn netisr_dispatch 1716b8eb655SRobert Watsonwill optionally direct dispatch if permitted by global and per-protocol 1726b8eb655SRobert Watsonpolicy. 1736b8eb655SRobert Watson.Pp 1746b8eb655SRobert WatsonIn order to provide additional load balancing and flow information, 1756b8eb655SRobert Watsonpacket sources may also specify an opaque source identifier, which in 1766b8eb655SRobert Watsonpractice might be a network interface number or socket pointer, using 1776b8eb655SRobert Watsonthe 1786b8eb655SRobert Watson.Fn netisr_dispatch_src 1796b8eb655SRobert Watsonand 1806b8eb655SRobert Watson.Fn netisr_queue_src 1816b8eb655SRobert Watsonvariants. 1826b8eb655SRobert Watson.Ss Protocol number constants 1836b8eb655SRobert WatsonThe follow protocol numbers are currently defined: 1846b8eb655SRobert Watson.Bl -tag -width NETISR_ATALK1 1856b8eb655SRobert Watson.It Dv NETISR_IP 1866b8eb655SRobert WatsonIPv4 1876b8eb655SRobert Watson.It Dv NETISR_IGMP 1886b8eb655SRobert WatsonIGMPv3 loopback 1896b8eb655SRobert Watson.It Dv NETISR_ROUTE 1906b8eb655SRobert WatsonRouting socket loopback 1916b8eb655SRobert Watson.It Dv NETISR_AARP 1926b8eb655SRobert WatsonAppletalk AARP 1936b8eb655SRobert Watson.It Dv NETISR_ATALK1 1946b8eb655SRobert WatsonAppletalk phase 1 1956b8eb655SRobert Watson.It Dv NETISR_ATALK2 1966b8eb655SRobert WatsonAppletalk phase 2 1976b8eb655SRobert Watson.It Dv NETISR_ARP 1986b8eb655SRobert WatsonARP 1996b8eb655SRobert Watson.It Dv NETISR_IPX 2006b8eb655SRobert WatsonIPX/SPX 2016b8eb655SRobert Watson.It Dv NETISR_IPV6 2026b8eb655SRobert WatsonIPv6 2036b8eb655SRobert Watson.It Dv NETISR_NATM 2046b8eb655SRobert WatsonATM 2056b8eb655SRobert Watson.El 2066b8eb655SRobert Watson.Sh AUTHORS 2076b8eb655SRobert WatsonThis manual page and the 2086b8eb655SRobert Watson.Nm 2096b8eb655SRobert Watsonimplementation were written by 2106b8eb655SRobert Watson.An Robert N. M. Watson . 211