From owner-p4-projects@FreeBSD.ORG Tue Aug 17 18:54:31 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2467810656A4; Tue, 17 Aug 2010 18:54:31 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D93931065695 for ; Tue, 17 Aug 2010 18:54:30 +0000 (UTC) (envelope-from afiveg@FreeBSD.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id C604C8FC16 for ; Tue, 17 Aug 2010 18:54:30 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id o7HIsUHJ064690 for ; Tue, 17 Aug 2010 18:54:30 GMT (envelope-from afiveg@FreeBSD.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id o7HIsUOe064687 for perforce@freebsd.org; Tue, 17 Aug 2010 18:54:30 GMT (envelope-from afiveg@FreeBSD.org) Date: Tue, 17 Aug 2010 18:54:30 GMT Message-Id: <201008171854.o7HIsUOe064687@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to afiveg@FreeBSD.org using -f From: Alexandre Fiveg To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 182531 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Aug 2010 18:54:31 -0000 http://p4web.freebsd.org/@@182531?ac=10 Change 182531 by afiveg@cottonmouth on 2010/08/17 18:53:38 Cosmetic fixes: eliminating unneeded functions, improving the comments. Affected files ... .. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-bpf.c#17 edit .. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-int.h#17 edit .. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap.c#20 edit .. //depot/projects/soc2010/ringmap/current/contrib/libpcap/ringmap_pcap.c#32 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#33 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#32 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#30 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#22 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ringmap_8259.h#15 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ringmap_ixgbe.c#16 edit .. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#46 edit .. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#46 edit .. //depot/projects/soc2010/ringmap/current/sys/net/ringmap_kernel.h#16 edit .. //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#28 edit .. //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#29 edit .. //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#23 edit .. //depot/projects/soc2010/ringmap/tests/libpcap/easy_pcap.c#14 edit Differences ... ==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-bpf.c#17 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-int.h#17 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap.c#20 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/ringmap_pcap.c#32 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#33 (text+ko) ==== @@ -3498,11 +3498,7 @@ } #ifdef RINGMAP - /* Call our ringmap-isr only in case any process captures (open_cnt > 0) */ - RINGMAP_LOCK(adapter->rm); - if (adapter->rm->open_cnt > 0) adapter->rm->funcs->delayed_isr(adapter); - RINGMAP_UNLOCK(adapter->rm); #endif while ((current_desc->status & E1000_RXD_STAT_DD) && ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#32 (text+ko) ==== @@ -18,8 +18,6 @@ #include "if_lem.h" #include "ringmap_8254.h" -struct ringmap * rm_8254_get_ringmap_p(device_t); -device_t rm_8254_get_device_p(struct cdev *); int rm_8254_set_slot(struct capt_object *, unsigned int); void rm_8254_interrupt(void *); void rm_8254_delayed_interrupt(void *); @@ -97,24 +95,28 @@ RINGMAP_INTR(start); - getmicrotime(&last_ts); + RINGMAP_LOCK(adapter->rm); + /* Do the next steps only if there is capturing process */ + if (adapter->rm->open_cnt > 0) { + getmicrotime(&last_ts); + rm_8254_sync_tail(rm_8254_find_next(adapter)); - rm_8254_sync_tail(rm_8254_find_next(adapter)); - - SLIST_FOREACH(co, &adapter->rm->object_list, objects) { - if (co->ring != NULL) { + SLIST_FOREACH(co, &adapter->rm->object_list, objects) { + if (co->ring != NULL) { #if (RINGMAP_INTR_DEB) - PRINT_RING_PTRS(co->ring); + PRINT_RING_PTRS(co->ring); #endif - co->ring->last_ts = last_ts; - ++co->ring->intr_num; + co->ring->last_ts = last_ts; + ++co->ring->intr_num; + } } } + RINGMAP_UNLOCK(adapter->rm); RINGMAP_INTR(end); } -/* The ring which TAIL pointer is mostly near to to the HEAD(RDH) */ +/* Returns the ring which TAIL pointer is mostly near to to the HEAD(RDH) */ struct capt_object * rm_8254_find_next(struct adapter *adapter) { @@ -229,40 +231,6 @@ } -/* - * Get pointer to device structure of adapter using our ringmap char device. - * This is a trick. Our cdev must have the same unit number as dev of adapter. - * Look in ringmap.c: ringmap_attach() where we create our cdev. - */ -device_t -rm_8254_get_device_p(struct cdev *cdev) -{ - struct adapter *adapter; - - adapter = (struct adapter *)devclass_get_softc(em_devclass, dev2unit(cdev)); -#if (__RINGMAP_DEB) - if (adapter == NULL){ - RINGMAP_WARN(Can not get pointer to adapter structure); - } -#endif - - return (adapter->dev); -} - - -/* - * Returns pointer to ringmap structure - */ -struct ringmap * -rm_8254_get_ringmap_p(device_t dev) -{ - struct adapter *adapter; - - adapter = (struct adapter *)device_get_softc(dev); - return (adapter->rm); -} - - /* Print the values from RDT and RDH */ int rm_8254_print_ring_pointers(struct adapter *adapter) ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#30 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#22 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ringmap_8259.h#15 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ringmap_ixgbe.c#16 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#46 (text+ko) ==== @@ -55,16 +55,14 @@ .d_open = ringmap_open, .d_close = ringmap_close, .d_ioctl = ringmap_ioctl, - .d_read = ringmap_read, - .d_mmap_single = ringmap_mmap_single, + .d_read = ringmap_read, /* Tell to user ring physical addr */ + .d_mmap_single = ringmap_mmap_single, /* Doesn't work yet */ .d_name = "ringmap_cdev" }; - static struct ringmap_global_list ringmap_list_head = SLIST_HEAD_INITIALIZER(ringmap_list_head); - /* * Will called from if_em.c before returning from * em_attach() function. @@ -169,8 +167,9 @@ /****************************************************************** * This func will called as result of open(2). Here we allocate - * the memory for the new packets ring that will associated with - * current thread. + * the memory for the new ring and capt_object structure (so called + * capturing object). Capturing object represents the thread with + * its ring. ******************************************************************/ int ringmap_open(struct cdev *cdev, int flag, int otyp, struct thread *td) @@ -303,18 +302,19 @@ int ringmap_close(struct cdev *cdev, int flag, int otyp, struct thread *td) { - RINGMAP_FUNC_DEBUG(start); - + RINGMAP_FUNC_DEBUG(The last capturing object is gone); #if (__RINGMAP_DEB) printf(RINGMAP_PREFIX"[%s] pid = %d\n", __func__, td->td_proc->p_pid); #endif - - RINGMAP_FUNC_DEBUG(end); - return (0); } +/* + * Callback of ringmap_close() + * Free memory allocated for capturing object and remove the + * capturing object from the list. + */ void clear_capt_object(void * data) { @@ -398,10 +398,8 @@ object = &obj; - RINGMAP_FUNC_DEBUG(start); - return (0); } @@ -458,7 +456,7 @@ #endif if ( devfs_get_cdevpriv((void **)&co) ) { - RINGMAP_IOCTL(Error! Can not get private date!); + RINGMAP_IOCTL(Error! Can not get private data!); return (ENODEV); } @@ -469,7 +467,7 @@ /* Sleep and wait for new packets */ case IOCTL_SLEEP_WAIT: - /* Count how many times we should wait for new packets */ + /* Count how many times we wait for new packets */ co->ring->user_wait_kern++; /* Set adapter TAIL register */ @@ -494,7 +492,9 @@ /* Synchronize sowftware ring-tail with hardware-ring-tail (RDT) */ case IOCTL_SYNC_TAIL: - rm->funcs->sync_tail(co->que); + RINGMAP_LOCK(rm); + rm->funcs->sync_tail(co); + RINGMAP_UNLOCK(rm); break; default: @@ -518,8 +518,12 @@ printf("=== Ring Kernel Addr:0x%X\n", (unsigned int)co->ring); - printf("=== Queue Kernel Addr:0x%X\n\n", - (unsigned int)co->que); + /* Print addr of que only if multiqueue supported */ + if (co->que != NULL) + printf("=== Queue Kernel Addr:0x%X\n\n", + (unsigned int)co->que); + } else { + RINGMAP_WARN(NULL pointer: capturing object); } } ==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#46 (text+ko) ==== @@ -248,13 +248,13 @@ * DEBUG OUTPUT */ #ifndef RINGMAP_IOCTL_DEB -#define RINGMAP_IOCTL_DEB 1 +#define RINGMAP_IOCTL_DEB 0 #else #define RINGMAP_IOCTL_DEB 1 #endif #ifndef RINGMAP_INTR_DEB -#define RINGMAP_INTR_DEB 1 +#define RINGMAP_INTR_DEB 0 #else #define RINGMAP_INTR_DEB 1 #endif ==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap_kernel.h#16 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#28 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#29 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#23 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/tests/libpcap/easy_pcap.c#14 (text+ko) ====