From owner-svn-src-head@FreeBSD.ORG Sun Jun 14 17:15:18 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0151106566C; Sun, 14 Jun 2009 17:15:18 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AD7B98FC1C; Sun, 14 Jun 2009 17:15:18 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5EHFILc055242; Sun, 14 Jun 2009 17:15:18 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5EHFIrD055238; Sun, 14 Jun 2009 17:15:18 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200906141715.n5EHFIrD055238@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 14 Jun 2009 17:15:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194201 - in head: share/man/man9 sys/net X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jun 2009 17:15:19 -0000 Author: bz Date: Sun Jun 14 17:15:18 2009 New Revision: 194201 URL: http://svn.freebsd.org/changeset/base/194201 Log: Add an optional callback function that will be invoked when a per-CPU queue was drained. It will never fire for a directly dispatched packet. You will most likely never want to use this for any ordinary netisr usage and you will never blame netisr in case you try to use it and it does not work as expected. Reviewed by: rwatson Modified: head/share/man/man9/netisr.9 head/sys/net/netisr.c head/sys/net/netisr.h Modified: head/share/man/man9/netisr.9 ============================================================================== --- head/share/man/man9/netisr.9 Sun Jun 14 17:05:54 2009 (r194200) +++ head/share/man/man9/netisr.9 Sun Jun 14 17:15:18 2009 (r194201) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 7, 2009 +.Dd June 14, 2009 .Dt NETISR 9 .Os .Sh NAME @@ -137,6 +137,13 @@ Will be used only with Protocol function to determine what CPU a packet should be processed on. Will be used only with .Dv NETISR_POLICY_CPU . +.It Vt netisr_drainedcpu_t Va nh_drainedcpu +Optional callback function that will be invoked when a per-CPU queue +was drained. +It will never fire for directly dispatched packets. +Unless fully understood, this special-purpose function should not be used. +.\" In case you intend to use this please send 50 chocolate bars to each +.\" of rwatson and bz and wait for an answer. .It Vt u_int Va nh_proto Protocol number used by both protocols to identify themselves to .Nm , Modified: head/sys/net/netisr.c ============================================================================== --- head/sys/net/netisr.c Sun Jun 14 17:05:54 2009 (r194200) +++ head/sys/net/netisr.c Sun Jun 14 17:15:18 2009 (r194201) @@ -197,6 +197,7 @@ struct netisr_proto { netisr_handler_t *np_handler; /* Protocol handler. */ netisr_m2flow_t *np_m2flow; /* Query flow for untagged packet. */ netisr_m2cpuid_t *np_m2cpuid; /* Query CPU to process packet on. */ + netisr_drainedcpu_t *np_drainedcpu; /* Callback when drained a queue. */ u_int np_qlimit; /* Maximum per-CPU queue depth. */ u_int np_policy; /* Work placement policy. */ }; @@ -380,6 +381,7 @@ netisr_register(const struct netisr_hand np[proto].np_handler = nhp->nh_handler; np[proto].np_m2flow = nhp->nh_m2flow; np[proto].np_m2cpuid = nhp->nh_m2cpuid; + np[proto].np_drainedcpu = nhp->nh_drainedcpu; if (nhp->nh_qlimit == 0) np[proto].np_qlimit = netisr_defaultqlimit; else if (nhp->nh_qlimit > netisr_maxqlimit) { @@ -705,6 +707,8 @@ netisr_process_workstream_proto(struct n } KASSERT(local_npw.nw_len == 0, ("%s(%u): len %u", __func__, proto, local_npw.nw_len)); + if (np[proto].np_drainedcpu) + np[proto].np_drainedcpu(nwsp->nws_cpu); NWS_LOCK(nwsp); npwp->nw_handled += handled; return (handled); Modified: head/sys/net/netisr.h ============================================================================== --- head/sys/net/netisr.h Sun Jun 14 17:05:54 2009 (r194200) +++ head/sys/net/netisr.h Sun Jun 14 17:15:18 2009 (r194201) @@ -88,6 +88,7 @@ typedef void netisr_handler_t (struct typedef struct mbuf *netisr_m2cpuid_t(struct mbuf *m, uintptr_t source, u_int *cpuid); typedef struct mbuf *netisr_m2flow_t(struct mbuf *m, uintptr_t source); +typedef void netisr_drainedcpu_t(u_int cpuid); #define NETISR_POLICY_SOURCE 1 /* Maintain source ordering. */ #define NETISR_POLICY_FLOW 2 /* Maintain flow ordering. */ @@ -101,6 +102,7 @@ struct netisr_handler { netisr_handler_t *nh_handler; /* Protocol handler. */ netisr_m2flow_t *nh_m2flow; /* Query flow for untagged packet. */ netisr_m2cpuid_t *nh_m2cpuid; /* Query CPU to process mbuf on. */ + netisr_drainedcpu_t *nh_drainedcpu; /* Callback when drained a queue. */ u_int nh_proto; /* Integer protocol ID. */ u_int nh_qlimit; /* Maximum per-CPU queue depth. */ u_int nh_policy; /* Work placement policy. */