kern_poll.c (142517) | kern_poll.c (148887) |
---|---|
1/*- 2 * Copyright (c) 2001-2002 Luigi Rizzo 3 * 4 * Supported by: the Xorp Project (www.xorp.org) 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001-2002 Luigi Rizzo 3 * 4 * Supported by: the Xorp Project (www.xorp.org) 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/kern/kern_poll.c 142517 2005-02-25 22:07:51Z trhodes $"); | 29__FBSDID("$FreeBSD: head/sys/kern/kern_poll.c 148887 2005-08-09 10:20:02Z rwatson $"); |
30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/kernel.h> 34#include <sys/socket.h> /* needed by net/if.h */ 35#include <sys/sysctl.h> 36 37#include <net/if.h> /* for IFF_* flags */ --- 23 unchanged lines hidden (view full) --- 61 * The command can be one of the following: 62 * POLL_ONLY: quick move of "count" packets from input/output queues. 63 * POLL_AND_CHECK_STATUS: as above, plus check status registers or do 64 * other more expensive operations. This command is issued periodically 65 * but less frequently than POLL_ONLY. 66 * POLL_DEREGISTER: deregister and return to interrupt mode. 67 * 68 * The first two commands are only issued if the interface is marked as | 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/kernel.h> 34#include <sys/socket.h> /* needed by net/if.h */ 35#include <sys/sysctl.h> 36 37#include <net/if.h> /* for IFF_* flags */ --- 23 unchanged lines hidden (view full) --- 61 * The command can be one of the following: 62 * POLL_ONLY: quick move of "count" packets from input/output queues. 63 * POLL_AND_CHECK_STATUS: as above, plus check status registers or do 64 * other more expensive operations. This command is issued periodically 65 * but less frequently than POLL_ONLY. 66 * POLL_DEREGISTER: deregister and return to interrupt mode. 67 * 68 * The first two commands are only issued if the interface is marked as |
69 * 'IFF_UP and IFF_RUNNING', the last one only if IFF_RUNNING is set. | 69 * 'IFF_UP and IFF_DRV_RUNNING', the last one only if IFF_DRV_RUNNING is set. |
70 * 71 * The count limit specifies how much work the handler can do during the 72 * call -- typically this is the number of packets to be received, or 73 * transmitted, etc. (drivers are free to interpret this number, as long 74 * as the max time spent in the function grows roughly linearly with the 75 * count). 76 * 77 * Deregistration can be requested by the driver itself (typically in the --- 168 unchanged lines hidden (view full) --- 246{ 247 int i; 248 249 mtx_lock(&Giant); 250 251 if (count > poll_each_burst) 252 count = poll_each_burst; 253 for (i = 0 ; i < poll_handlers ; i++) | 70 * 71 * The count limit specifies how much work the handler can do during the 72 * call -- typically this is the number of packets to be received, or 73 * transmitted, etc. (drivers are free to interpret this number, as long 74 * as the max time spent in the function grows roughly linearly with the 75 * count). 76 * 77 * Deregistration can be requested by the driver itself (typically in the --- 168 unchanged lines hidden (view full) --- 246{ 247 int i; 248 249 mtx_lock(&Giant); 250 251 if (count > poll_each_burst) 252 count = poll_each_burst; 253 for (i = 0 ; i < poll_handlers ; i++) |
254 if (pr[i].handler && (IFF_UP|IFF_RUNNING) == 255 (pr[i].ifp->if_flags & (IFF_UP|IFF_RUNNING)) ) | 254 if (pr[i].handler && 255 (pr[i].ifp->if_flags & IFF_UP) && 256 (pr[i].ifp->if_drv_flags & IFF_DRV_RUNNING)) |
256 pr[i].handler(pr[i].ifp, 0, count); /* quick check */ 257 mtx_unlock(&Giant); 258} 259 260/* 261 * netisr_pollmore is called after other netisr's, possibly scheduling 262 * another NETISR_POLL call, or adapting the burst size for the next cycle. 263 * --- 104 unchanged lines hidden (view full) --- 368 residual_burst = poll_burst; 369 } 370 cycles = (residual_burst < poll_each_burst) ? 371 residual_burst : poll_each_burst; 372 residual_burst -= cycles; 373 374 if (polling) { 375 for (i = 0 ; i < poll_handlers ; i++) | 257 pr[i].handler(pr[i].ifp, 0, count); /* quick check */ 258 mtx_unlock(&Giant); 259} 260 261/* 262 * netisr_pollmore is called after other netisr's, possibly scheduling 263 * another NETISR_POLL call, or adapting the burst size for the next cycle. 264 * --- 104 unchanged lines hidden (view full) --- 369 residual_burst = poll_burst; 370 } 371 cycles = (residual_burst < poll_each_burst) ? 372 residual_burst : poll_each_burst; 373 residual_burst -= cycles; 374 375 if (polling) { 376 for (i = 0 ; i < poll_handlers ; i++) |
376 if (pr[i].handler && (IFF_UP|IFF_RUNNING) == 377 (pr[i].ifp->if_flags & (IFF_UP|IFF_RUNNING)) ) | 377 if (pr[i].handler && 378 (pr[i].ifp->if_flags & IFF_UP) && 379 (pr[i].ifp->if_drv_flags & IFF_DRV_RUNNING)) |
378 pr[i].handler(pr[i].ifp, arg, cycles); 379 } else { /* unregister */ 380 for (i = 0 ; i < poll_handlers ; i++) { 381 if (pr[i].handler && | 380 pr[i].handler(pr[i].ifp, arg, cycles); 381 } else { /* unregister */ 382 for (i = 0 ; i < poll_handlers ; i++) { 383 if (pr[i].handler && |
382 pr[i].ifp->if_flags & IFF_RUNNING) { | 384 pr[i].ifp->if_drv_flags & IFF_DRV_RUNNING) { |
383 pr[i].ifp->if_flags &= ~IFF_POLLING; 384 pr[i].handler(pr[i].ifp, POLL_DEREGISTER, 1); 385 } 386 pr[i].handler=NULL; 387 } 388 residual_burst = 0; 389 poll_handlers = 0; 390 } --- 128 unchanged lines hidden --- | 385 pr[i].ifp->if_flags &= ~IFF_POLLING; 386 pr[i].handler(pr[i].ifp, POLL_DEREGISTER, 1); 387 } 388 pr[i].handler=NULL; 389 } 390 residual_burst = 0; 391 poll_handlers = 0; 392 } --- 128 unchanged lines hidden --- |