Date: Tue, 21 Dec 2010 17:36:11 GMT From: Alexandre Fiveg <afiveg@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 187104 for review Message-ID: <201012211736.oBLHaBg5079627@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@187104?ac=10 Change 187104 by afiveg@cottonmouth on 2010/12/21 17:35:15 ringmap is ported to -STABLE. One BUG is still remain: The userspace process is not awoken after receive a first packet. Affected files ... .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#38 edit .. //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#37 edit .. //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#38 edit .. //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#32 edit .. //depot/projects/soc2010/ringmap/stable_8/contrib/libpcap/pcap-bpf.c#2 edit .. //depot/projects/soc2010/ringmap/stable_8/contrib/libpcap/pcap-int.h#2 edit .. //depot/projects/soc2010/ringmap/stable_8/contrib/libpcap/pcap.c#2 edit .. //depot/projects/soc2010/ringmap/stable_8/contrib/libpcap/ringmap_pcap.c#2 edit .. //depot/projects/soc2010/ringmap/stable_8/lib/libpcap/Makefile#3 edit .. //depot/projects/soc2010/ringmap/stable_8/sys/dev/e1000/if_lem.c#2 edit .. //depot/projects/soc2010/ringmap/stable_8/sys/dev/e1000/if_lem.h#2 edit .. //depot/projects/soc2010/ringmap/stable_8/sys/dev/e1000/ringmap_8254.c#2 edit .. //depot/projects/soc2010/ringmap/stable_8/sys/i386/conf/I686_STABLE#2 edit .. //depot/projects/soc2010/ringmap/stable_8/sys/modules/ringmap/Makefile#1 add .. //depot/projects/soc2010/ringmap/stable_8/sys/modules/ringmap/Makefile.em#1 add .. //depot/projects/soc2010/ringmap/stable_8/sys/net/ringmap.c#2 edit .. //depot/projects/soc2010/ringmap/stable_8/sys/net/ringmap.h#2 edit .. //depot/projects/soc2010/ringmap/stable_8/sys/net/ringmap_kernel.h#2 edit Differences ... ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#38 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#37 (text+ko) ==== @@ -1,7 +1,21 @@ #!/usr/local/bin/bash -RINGMAP_BUILD_DIR=../current/sys/modules/ringmap/ -LIBPCAP_BUILD_DIR=../current/lib/libpcap/ +# wich system release +uname -r | grep STABLE | grep 8 +if [ $? -eq 0 ] +then + echo "Building ringmap for FreeBSD-STABLE..." + echo + sleep 1 + RINGMAP_BUILD_DIR=../stable_8/sys/modules/ringmap/ + LIBPCAP_BUILD_DIR=../stable_8/lib/libpcap/ +else + echo "Building ringmap for FreeBSD-CURRENT..." + echo + sleep 1 + RINGMAP_BUILD_DIR=../current/sys/modules/ringmap/ + LIBPCAP_BUILD_DIR=../current/lib/libpcap/ +fi make_ringmap() { cd ${RINGMAP_BUILD_DIR} @@ -50,12 +64,12 @@ exit 1; fi +sync + echo echo Everything seems to be Ok. echo For loading ringmap driver and for installing libpcap do: echo sudo ./set_ringmap.sh echo -sync - exit 0 ==== //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#38 (text+ko) ==== @@ -1,7 +1,21 @@ #!/bin/sh -RINGMAP_BUILD_DIR=../current/sys/modules/ringmap/ -LIBPCAP_BUILD_DIR=../current/lib/libpcap/ +# wich system release +uname -r | grep STABLE | grep 8 +if [ $? -eq 0 ] +then + echo "Installing ringmap for FreeBSD-STABLE..." + echo + sleep 1 + RINGMAP_BUILD_DIR=../stable_8/sys/modules/ringmap/ + LIBPCAP_BUILD_DIR=../stable_8/lib/libpcap/ +else + echo "Installing ringmap for FreeBSD-CURRENT..." + echo + sleep 1 + RINGMAP_BUILD_DIR=../current/sys/modules/ringmap/ + LIBPCAP_BUILD_DIR=../current/lib/libpcap/ +fi check_module() { @@ -46,4 +60,7 @@ echo sync + +echo "Before using ringmap set the network interface in monitoring mode" +echo exit 0 ==== //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#32 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/stable_8/contrib/libpcap/pcap-bpf.c#2 (text+ko) ==== @@ -161,6 +161,11 @@ #define DLT_IEEE802_11_RADIO_AVS 163 #endif +#ifdef RINGMAP +#include <machine/bus.h> +extern void uninit_mmapped_capturing(pcap_t *); +#endif + static int pcap_can_set_rfmon_bpf(pcap_t *p); static int pcap_activate_bpf(pcap_t *p); static int pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp); @@ -1135,6 +1140,11 @@ struct ifreq ifr; #endif +#ifdef RINGMAP + if (p->rp.status == 1) { + uninit_mmapped_capturing(p); + } +#endif if (p->md.must_clear != 0) { /* * There's something we have to do when closing this ==== //depot/projects/soc2010/ringmap/stable_8/contrib/libpcap/pcap-int.h#2 (text+ko) ==== @@ -56,6 +56,10 @@ #include <io.h> #endif +#ifdef RINGMAP +#include "../../sys/net/ringmap.h" +#endif + #if (defined(_MSC_VER) && (_MSC_VER <= 1200)) /* we are compiling with Visual Studio 6, that doesn't support the LL suffix*/ /* @@ -331,6 +335,10 @@ u_int *dlt_list; struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */ + +#ifdef RINGMAP + struct pcap_ringmap rp; +#endif }; /* ==== //depot/projects/soc2010/ringmap/stable_8/contrib/libpcap/pcap.c#2 (text+ko) ==== @@ -71,6 +71,15 @@ #include <dagapi.h> #endif +#ifdef RINGMAP +#include <sys/ioccom.h> + +extern int init_mmapped_capturing(const char *device, pcap_t *); +extern void ringmap_setfilter(struct bpf_program *, pcap_t *); +extern int pcap_read_ringmap(pcap_t *, int , pcap_handler , u_char *); +#endif + + int pcap_not_initialized(pcap_t *pcap) { @@ -229,6 +238,10 @@ pcap_t *p; int status; +#ifdef RINGMAP + RINGMAP_FUNC_DEBUG(start); +#endif + p = pcap_create(source, errbuf); if (p == NULL) return (NULL); @@ -255,6 +268,27 @@ status = pcap_activate(p); if (status < 0) goto fail; + +#ifdef RINGMAP + /* + * The setting of ringmap flags should be done in enother function. Why ? + * We want be able to switch on\off ringmap functionality by setting + * ringmap_flags. In order to do it, the external libpcap application + * should first call the function for setting ringmap_flags. But this + * requires the modification of these application. Thats why I set + * ringmap_flags staticaly here + */ + p->rp.status = set_ringmap_status(1, p); + + /* Replace 1 with RINGMAP_ACTIVE macro */ + if (p->rp.status == 1) { + if (init_mmapped_capturing(source, p) < 0) + goto fail; + p->read_op = pcap_read_ringmap; + } +#endif + + return (p); fail: if (status == PCAP_ERROR || status == PCAP_ERROR_NO_SUCH_DEVICE || @@ -984,7 +1018,18 @@ int pcap_setfilter(pcap_t *p, struct bpf_program *fp) { +#ifdef RINGMAP + int err = p->setfilter_op(p, fp); + + if (p->rp.status == 1) { + if (err == 0) + ringmap_setfilter(fp, p); + } + + return (err); +#else return p->setfilter_op(p, fp); +#endif } /* ==== //depot/projects/soc2010/ringmap/stable_8/contrib/libpcap/ringmap_pcap.c#2 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/stable_8/lib/libpcap/Makefile#3 (text+ko) ==== @@ -12,7 +12,7 @@ scanner.l version.c .if defined(LIBPCAP_RINGMAP) -CFLAGS+=-g -DRINGMAP +CFLAGS+=-g -DRINGMAP -D__RINGMAP_DEB SRCS+=ringmap_pcap.c .endif ==== //depot/projects/soc2010/ringmap/stable_8/sys/dev/e1000/if_lem.c#2 (text+ko) ==== @@ -81,6 +81,14 @@ #include <dev/pci/pcireg.h> #include "e1000_api.h" + +#ifdef RINGMAP +#include <net/ringmap.h> +extern struct ringmap * ringmap_attach(device_t, struct ringmap_functions *); +extern int ringmap_detach (struct ringmap *); +extern struct ringmap_functions ringmap_8254_functions; +#endif + #include "if_lem.h" /********************************************************************* @@ -658,6 +666,14 @@ adapter->led_dev = led_create(lem_led_func, adapter, device_get_nameunit(dev)); +#ifdef RINGMAP + adapter->rm = ringmap_attach (dev, &ringmap_8254_functions); + if (adapter->rm == NULL) { + goto err_rx_struct; + } +#endif + + INIT_DEBUGOUT("lem_attach: end"); return (0); @@ -698,6 +714,10 @@ INIT_DEBUGOUT("em_detach: begin"); +#ifdef RINGMAP + ringmap_detach (adapter->rm); +#endif + /* Make sure VLANS are not using driver */ #if __FreeBSD_version >= 700000 if (adapter->ifp->if_vlantrunk != NULL) { @@ -3459,6 +3479,10 @@ int i, rx_sent = 0; struct e1000_rx_desc *current_desc; +#ifdef RINGMAP + struct capt_object *co = NULL; +#endif + EM_RX_LOCK(adapter); i = adapter->next_rx_desc_to_check; current_desc = &adapter->rx_desc_base[i]; @@ -3472,6 +3496,10 @@ return (FALSE); } +#ifdef RINGMAP + co = adapter->rm->funcs->delayed_isr(adapter, adapter->rm); +#endif + while ((current_desc->status & E1000_RXD_STAT_DD) && (count != 0) && (ifp->if_drv_flags & IFF_DRV_RUNNING)) { @@ -3524,10 +3552,25 @@ } if (accept_frame) { + +#ifdef RINGMAP + RINGMAP_LOCK(adapter->rm); + if ((co != NULL) && (co->ring != NULL)) + adapter->rm->funcs->per_packet_iteration(co, i); + else { +#endif + if (lem_get_buf(adapter, i) != 0) { ifp->if_iqdrops++; +#ifdef RINGMAP + RINGMAP_UNLOCK(adapter->rm); +#endif goto discard; } +#ifdef RINGMAP + } + RINGMAP_UNLOCK(adapter->rm); +#endif /* Assign correct length to the current fragment */ mp->m_len = len; @@ -3614,20 +3657,50 @@ /* Call into the stack */ if (m != NULL) { adapter->next_rx_desc_to_check = i; + +#ifdef RINGMAP + RINGMAP_LOCK(adapter->rm); + if ((co == NULL) || (co->ring == NULL)) { +#endif EM_RX_UNLOCK(adapter); (*ifp->if_input)(ifp, m); EM_RX_LOCK(adapter); + +#ifdef RINGMAP + } + RINGMAP_UNLOCK(adapter->rm); +#endif + rx_sent++; i = adapter->next_rx_desc_to_check; } current_desc = &adapter->rx_desc_base[i]; } + +#ifdef RINGMAP + RINGMAP_LOCK(adapter->rm); + if ((co != NULL) && (co->ring != NULL) && (RING_NOT_EMPTY(co->ring))) + wakeup(co->ring); + RINGMAP_UNLOCK(adapter->rm); +#endif + adapter->next_rx_desc_to_check = i; /* Advance the E1000's Receive Queue #0 "Tail Pointer". */ if (--i < 0) i = adapter->num_rx_desc - 1; - E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), i); + + /* RINGMAP: Don't write RDT. We'll do it after user has read packet */ +#ifdef RINGMAP + RINGMAP_LOCK(adapter->rm); + if ((co == NULL) || (co->ring == NULL)) { +#endif + E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), i); +#ifdef RINGMAP + } + RINGMAP_UNLOCK(adapter->rm); +#endif + if (done != NULL) *done = rx_sent; EM_RX_UNLOCK(adapter); ==== //depot/projects/soc2010/ringmap/stable_8/sys/dev/e1000/if_lem.h#2 (text+ko) ==== @@ -70,9 +70,15 @@ * (num_tx_desc * sizeof(struct e1000_tx_desc)) % 128 == 0 */ #define EM_MIN_RXD 80 +#ifndef RINGMAP #define EM_MAX_RXD_82543 256 -#define EM_MAX_RXD 4096 +#define EM_MAX_RXD 2048 #define EM_DEFAULT_RXD EM_MAX_RXD_82543 +#else +#define EM_MAX_RXD_82543 SLOTS_NUMBER +#define EM_MAX_RXD SLOTS_NUMBER +#define EM_DEFAULT_RXD SLOTS_NUMBER +#endif /* * EM_TIDV - Transmit Interrupt Delay Value @@ -421,6 +427,9 @@ boolean_t pcix_82544; boolean_t in_detach; +#ifdef RINGMAP + struct ringmap *rm; +#endif struct e1000_hw_stats stats; }; ==== //depot/projects/soc2010/ringmap/stable_8/sys/dev/e1000/ringmap_8254.c#2 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/stable_8/sys/i386/conf/I686_STABLE#2 (text+ko) ==== @@ -202,7 +202,7 @@ # PCI Ethernet NICs. #device de # DEC/Intel DC21x4x (``Tulip'') -device em # Intel PRO/1000 Gigabit Ethernet Family +#device em # Intel PRO/1000 Gigabit Ethernet Family #device igb # Intel PRO/1000 PCIE Server Gigabit Family #device ixgb # Intel PRO/10GbE Ethernet Card #device le # AMD Am7900 LANCE and Am79C9xx PCnet ==== //depot/projects/soc2010/ringmap/stable_8/sys/net/ringmap.c#2 (text+ko) ==== @@ -338,6 +338,7 @@ CAPT_OBJECT_DEB(co); rm = co->rm; + /* TODO: wake up if we are currently sleeping */ contigfree(co->ring, sizeof(struct ring), M_DEVBUF); co->ring = NULL; ==== //depot/projects/soc2010/ringmap/stable_8/sys/net/ringmap.h#2 (text+ko) ==== @@ -274,7 +274,7 @@ #ifndef __RINGMAP_DEB #define __RINGMAP_DEB 0 -#elif +#else #define __RINGMAP_DEB 1 #endif ==== //depot/projects/soc2010/ringmap/stable_8/sys/net/ringmap_kernel.h#2 (text+ko) ====
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012211736.oBLHaBg5079627>