From owner-p4-projects@FreeBSD.ORG Sun Jul 11 18:49:34 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 869511065676; Sun, 11 Jul 2010 18:49:34 +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 4AA2C1065673 for ; Sun, 11 Jul 2010 18:49:34 +0000 (UTC) (envelope-from afiveg@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 381998FC12 for ; Sun, 11 Jul 2010 18:49:34 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o6BInYRm085166 for ; Sun, 11 Jul 2010 18:49:34 GMT (envelope-from afiveg@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o6BInYNE085164 for perforce@freebsd.org; Sun, 11 Jul 2010 18:49:34 GMT (envelope-from afiveg@FreeBSD.org) Date: Sun, 11 Jul 2010 18:49:34 GMT Message-Id: <201007111849.o6BInYNE085164@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to afiveg@FreeBSD.org using -f From: Alexandre Fiveg To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 180774 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: Sun, 11 Jul 2010 18:49:34 -0000 http://p4web.freebsd.org/@@180774?ac=10 Change 180774 by afiveg@cottonmouth on 2010/07/11 18:48:41 Cosmetic fixes Affected files ... .. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-bpf.c#9 edit .. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-int.h#9 edit .. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap.c#11 edit .. //depot/projects/soc2010/ringmap/current/contrib/libpcap/ringmap_pcap.c#16 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#24 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#23 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#21 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#13 edit .. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#27 edit .. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#27 edit .. //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#11 edit .. //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#12 edit .. //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#7 edit Differences ... ==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-bpf.c#9 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-int.h#9 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap.c#11 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/ringmap_pcap.c#16 (text+ko) ==== @@ -89,7 +89,7 @@ RINGMAP_ERROR(Can not read phys addr of ring from kernel); return (-1); } -#ifdef __RINGMAP_DEB +#if (__RINGMAP_DEB) printf("[%s] Phys addr of ring 0x%X\n", __func__, ring); #endif @@ -278,12 +278,11 @@ curr_slot = R_MODULO( SW_TAIL(ring) + 1 ); if (!(ring->slot[curr_slot].is_ok)) { -#ifdef __RINGMAP_DEB +#if (__RINGMAP_DEB) printf("Slot %d was not accepted by driver!\n", curr_slot); #endif goto out; } - ring->cur_slot_user = curr_slot; mb = (struct mbuf *)U_MBUF(ring, curr_slot); @@ -296,8 +295,8 @@ (*callback)(user, &pkthdr, datap); -#ifdef __RINGMAP_DEB - PRINT_SLOT(ring, ring->cur_slot_user); +#if (__RINGMAP_DEB) + PRINT_SLOT(ring, curr_slot); #endif out: @@ -350,141 +349,3 @@ return (err); } - -/* - * Levels : - * 0 - only received and lose pkts - * 1 - received pkts with pkts sizes and lose pkts - * >2 - full statistic - */ -//void -//print_hw_stats(int level, pcap_t *p) -//{ -// if (p->nic_statistics == NULL){ -// return; -// } -// -// printf("VALUES FROM HARDWARE REGISTERS:\n"); -// printf("------------------------------ \n"); -// if (level >= 0){ -// /* -// * Missed Packets Count: -// * Counts the number of missed packets. Packets are missed when -// * the receive FIFO has insufficient space to store the incoming -// * packet. This can be caused because of too few buffers allocated, -// * or because there is insufficient bandwidth on the PCI bus. -// * Events setting this counter cause RXO, the Receiver Overrun -// * Interrupt, to be set. This register does not increment if receives are -// * not enabled. -// */ -// printf("Missed Packets = %lld\n", -// (long long)p->nic_statistics->mpc); -// -// /* -// * Good Packets Received Count: -// * Counts the number of good packets received of any legal length. This -// * counter does not include received flow control packets and only counts -// * packets that pass hardware filtering. -// * -// * DOES NOT COUNT PACKETS COUNTED by the Missed Packet Count. -// */ -// printf("Good Packets Rcvd = %lld\n", -// (long long)p->nic_statistics->gprc); -// -// } -// if (level >= 1){ -// -// /* Will happen each time if RDH = RDT */ -// printf("Receive No Memory Buffers = %lld\n", -// (long long)p->nic_statistics->rnbc); -// -// /* -// * Packets Received (64 Bytes) Count: -// * Counts the number of good packets received that are exactly 64 bytes -// * in length. Packets that are counted in the Missed Packet Count are not -// * counted in this counter. This counter does not count received flow control -// * packets. -// */ -// printf("Packets Received (64 Bytes) Count = %lld\n", -// (long long)p->nic_statistics->prc64); -// -// /* -// * Packets Received (65-127 Bytes) Count: -// * Counts the number of good packets received that are 65-127 bytes in length. -// */ -// printf("Packets Received (65-127 Bytes) Count = %lld\n", -// (long long)p->nic_statistics->prc127); -// -// /* -// * Packets Received (128-255 Bytes) Count -// */ -// printf("Packets Received (128-255 Bytes) Count = %lld\n", -// (long long)p->nic_statistics->prc255); -// -// /* -// * Packets Received (256-511 Bytes) Count -// */ -// printf("Packets Received (256-511 Bytes) Count = %lld\n", -// (long long)p->nic_statistics->prc511); -// -// /* -// * Packets Received (512-1023 Bytes) Count -// */ -// printf("Packets Received (512-1023 Bytes) Count = %lld\n", -// (long long)p->nic_statistics->prc1023); -// -// /* -// * Packets Received (1024 to Max Bytes) Count -// */ -// printf("Packets Received (1024 to Max Bytes) Count = %lld\n", -// (long long)p->nic_statistics->prc1522); -// -// /* -// * Total Packets Received: -// * Counts the total number of all packets received. All packets received -// * are counted regardless of their length, whether they have errors, or whether -// * they are flow control packets. -// */ -// //printf("Total Packets Received = %lld\n", -// // (long long)p->nic_statistics->tpr); -// } -// -// if (level >= 2){ -// -// printf("Sequence errors = %lld\n", -// (long long)p->nic_statistics->sec); -// -// printf("Defer count = %lld\n", -// (long long)p->nic_statistics->dc); -// -// -// printf("Receive Length Errors = %lld\n", -// ((long long)p->nic_statistics->roc + (long long)p->nic_statistics->ruc)); -// -// printf("Receive errors = %lld\n", -// (long long)p->nic_statistics->rxerrc); -// -// printf("Crc errors = %lld\n", -// (long long)p->nic_statistics->crcerrs); -// -// printf("Alignment errors = %lld\n", -// (long long)p->nic_statistics->algnerrc); -// -// printf("Collision/Carrier extension errors = %lld\n", -// (long long)p->nic_statistics->cexterr); -// } -//} - -//int -//ringmap_stats(pcap_t *p, struct pcap_stat *ps) -//{ -// -// if ((ps == NULL) || (p->nic_statistics == NULL)){ -// return (-1); -// } -// -// ps->ps_recv = p->nic_statistics->gprc; -// ps->ps_drop = p->nic_statistics->mpc; -// -// return (0); -//} ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#24 (text+ko) ==== @@ -1382,7 +1382,7 @@ { struct adapter *adapter = context; struct ifnet *ifp = adapter->ifp; - struct capt_instance *ci = NULL; + struct capt_object *co = NULL; if (ifp->if_drv_flags & IFF_DRV_RUNNING) { #ifdef RINGMAP @@ -1394,9 +1394,9 @@ #ifdef RINGMAP adapter->rm->funcs->sync_head(adapter->dev); - SLIST_FOREACH(ci, &adapter->rm->instance_list, next_instance) { - if (RING_NOT_EMPTY(ci->ring)){ - wakeup(ci->ring); + SLIST_FOREACH(co, &adapter->rm->object_list, objects) { + if (RING_NOT_EMPTY(co->ring)){ + wakeup(co->ring); } } } ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#23 (text+ko) ==== @@ -26,7 +26,7 @@ int rm_8254_set_slot(struct ring *, device_t, unsigned int); void rm_8254_interrupt(void *); void rm_8254_delayed_interrupt(void *); -int rm_8254_print_ring_pointers(struct adapter *, struct ring *); +int rm_8254_print_ring_pointers(struct adapter *); void rm_8254_sync_head_tail(device_t); void rm_8254_sync_tail(device_t); void rm_8254_sync_head(device_t); @@ -37,7 +37,7 @@ extern void lem_enable_intr(struct adapter *); extern void lem_disable_intr(struct adapter *); extern void ringmap_print_slot(struct ring *, unsigned int); -extern void print_capt_inst(struct capt_instance *); +extern void print_capt_obj(struct capt_object *); struct ringmap_functions ringmap_f = { @@ -68,10 +68,8 @@ void rm_8254_sync_head_tail(device_t dev) { - RINGMAP_FUNC_DEBUG(start); rm_8254_sync_tail(dev); rm_8254_sync_head(dev); - RINGMAP_FUNC_DEBUG(end); } @@ -86,8 +84,8 @@ ring = rm_8254_find_next(adapter); -#ifdef __RINGMAP_DEB - printf("Next ring is 0x%X\n", (unsigned int)ring); +#if (__RINGMAP_DEB) + printf("Next ring->pid is %d\n", ring->pid); #endif RINGMAP_HW_SYNC_TAIL(adapter, ring); @@ -99,7 +97,7 @@ void rm_8254_sync_head(device_t dev) { - struct capt_instance *ci = NULL; + struct capt_object *co = NULL; struct adapter *adapter; RINGMAP_FUNC_DEBUG(start); @@ -108,12 +106,12 @@ RINGMAP_LOCK(adapter->rm); - SLIST_FOREACH(ci, &adapter->rm->instance_list, next_instance) { - if (ci->ring != NULL) { - RINGMAP_HW_SYNC_HEAD(adapter, ci->ring); /* SW_TAIL ==> HW_HEAD */ -#ifdef __RINGMAP_DEB - print_capt_inst(ci); - PRINT_RING_PTRS(ci->ring); + SLIST_FOREACH(co, &adapter->rm->object_list, objects) { + if (co->ring != NULL) { + RINGMAP_HW_SYNC_HEAD(adapter, co->ring); +#if (__RINGMAP_DEB) + print_capt_obj(co); + PRINT_RING_PTRS(co->ring); #endif } } @@ -133,7 +131,7 @@ { struct adapter *adapter = (struct adapter *) arg; - /* count interrupts */ + /* count interrupts only if there is capturing object */ if ( adapter->rm->open_cnt > 0 ) adapter->rm->interrupts_counter++; } @@ -143,21 +141,20 @@ rm_8254_delayed_interrupt(void *context) { struct adapter *adapter = (struct adapter *)context; - struct capt_instance *ci = NULL; + struct capt_object *co = NULL; RINGMAP_INTR(start); RINGMAP_LOCK(adapter->rm); - SLIST_FOREACH(ci, &adapter->rm->instance_list, next_instance) { -#ifdef __RINGMAP_DEB - printf("[%s] Ring Kernel Addr:0x%X\n", __func__, (unsigned int)ci->ring); + SLIST_FOREACH(co, &adapter->rm->object_list, objects) { + if (co->ring != NULL) { +#if (__RINGMAP_DEB) + PRINT_RING_PTRS(co->ring); #endif - if (ci->ring != NULL) { - /* TODO: find the next ring */ rm_8254_sync_tail(adapter->dev); #ifdef RINGMAP_TIMESTAMP - getmicrotime(&ci->ring->last_ts); + getmicrotime(&co->ring->last_ts); #endif } } @@ -167,58 +164,58 @@ RINGMAP_INTR(end); } +/* The ring which TAIL pointer is mostly near to to the HEAD(RDH) */ struct ring * rm_8254_find_next(struct adapter *adapter) { unsigned int rdh, rdt, dist, min_dist = SLOTS_NUMBER; struct ringmap *rm = adapter->rm; - struct capt_instance *ci = NULL, *min_ci = NULL; + struct capt_object *co = NULL, *min_co = NULL; rdh = RINGMAP_HW_READ_HEAD(adapter); - SLIST_FOREACH(ci, &rm->instance_list, next_instance) { - rdt = ci->ring->userrp; + SLIST_FOREACH(co, &rm->object_list, objects) { + rdt = co->ring->userrp; dist = R_DISTANCE(rdh, rdt); if (dist <= min_dist) { min_dist = dist; - min_ci = ci; + min_co = co; } } - return (min_ci->ring); + return (min_co->ring); } void rm_8254_delayed_interrupt_per_packet(device_t dev, int slot_num) { - struct capt_instance *ci = NULL; + struct capt_object *co = NULL; struct adapter *adapter = NULL; struct ringmap *rm = NULL; adapter = (struct adapter *)device_get_softc(dev); rm = adapter->rm; - //RINGMAP_INTR(start); + RINGMAP_INTR(start); RINGMAP_LOCK(rm); - SLIST_FOREACH(ci, &rm->instance_list, next_instance) { - if ( ci->ring != NULL ) { - ci->ring->cur_slot_kern = slot_num; - ci->ring->slot[slot_num].is_ok = 1; - ci->ring->slot[slot_num].intr_num = rm->interrupts_counter; + SLIST_FOREACH(co, &rm->object_list, objects) { + if ( co->ring != NULL ) { + co->ring->slot[slot_num].is_ok = 1; + co->ring->slot[slot_num].intr_num = rm->interrupts_counter; #ifdef RINGMAP_TIMESTAMP - ci->ring->slot[slot_num].ts = ci->ring->last_ts; + co->ring->slot[slot_num].ts = co->ring->last_ts; #endif -#ifdef __RINGMAP_DEB - PRINT_SLOT((ci->ring), (slot_num)); +#if (__RINGMAP_DEB) + PRINT_SLOT((co->ring), (slot_num)); #endif } } RINGMAP_UNLOCK(rm); - //RINGMAP_INTR(end); + RINGMAP_INTR(end); } @@ -238,11 +235,11 @@ goto fail; } if (GET_PACKET_P(adapter, slot_num) == NULL){ - RINGMAP_ERROR(pointer to packet is NULL); + RINGMAP_ERROR(Pointer to packet is NULL); goto fail; } if (GET_DESCRIPTOR_P(adapter, slot_num) == NULL){ - RINGMAP_ERROR(pointer to descriptor is NULL); + RINGMAP_ERROR(Pointer to descriptor is NULL); goto fail; } @@ -311,7 +308,7 @@ struct adapter *adapter; adapter = (struct adapter *)devclass_get_softc(em_devclass, dev2unit(cdev)); -#ifdef __RINGMAP_DEB +#if (__RINGMAP_DEB) if (adapter == NULL){ RINGMAP_WARN(Can not get pointer to adapter structure); } @@ -350,24 +347,14 @@ int -rm_8254_print_ring_pointers(struct adapter *adapter, struct ring *ring) +rm_8254_print_ring_pointers(struct adapter *adapter) { unsigned int rdt, rdh; struct ringmap *rm = NULL; rm = adapter->rm; - /* - * We should lock our data because while printing - * other process (for instance from other CPU) can - * free the memory regions that we are access in - * this functions - */ - - /* -> Critical Section: begin */ - RINGMAP_LOCK(rm); - - if ( (rm == NULL) || (ring == NULL) ) + if (rm == NULL) goto out; rdh = RINGMAP_HW_READ_HEAD(adapter); @@ -376,15 +363,8 @@ printf("\n== +++++++++ RING POINTERS ++++++++++++ \n"); printf("== + HW HEAD = %d (KERN POINTER)\n", rdh); printf("== + HW TAIL = %d (USER POINTER)\n", rdt); - printf("== +\n"); - printf("== + kernrp = %d \n", ring->kernrp); - printf("== + userrp = %d \n", ring->userrp); printf("== ++++++++++++++++++++++++++++++++++++++ \n\n"); out: - - RINGMAP_UNLOCK(rm); - /* -> Critical Section: end */ - return (0); } ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#21 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#13 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#27 (text+ko) ==== @@ -36,8 +36,8 @@ int ringmap_attach (device_t, struct ringmap_functions *); int ringmap_detach (device_t); void ringmap_close_cb (void *data); -void clear_capt_instance(void *); -void print_capt_inst(struct capt_instance *); +void clear_capt_object(void *); +void print_capt_obj(struct capt_object *); struct ringmap *(*get_ringmap_p)(device_t); device_t (*get_device_p)(struct cdev *); @@ -46,7 +46,6 @@ d_close_t ringmap_close; d_ioctl_t ringmap_ioctl; d_read_t ringmap_read; -//d_mmap_t ringmap_mmap; /* * Character Device for access on if_em driver structures @@ -57,7 +56,6 @@ .d_close = ringmap_close, .d_ioctl = ringmap_ioctl, .d_read = ringmap_read, -// .d_mmap = ringmap_mmap, .d_name = "ringmap_cdev" }; @@ -102,7 +100,7 @@ rm->dev = dev; /* Initialize the list of capturing instances */ - SLIST_INIT(&rm->instance_list); + SLIST_INIT(&rm->object_list); /* Init the mutex to protecting our data */ RINGMAP_LOCK_INIT(rm, device_get_nameunit(dev)); @@ -120,7 +118,7 @@ ringmap_detach(device_t dev) { struct ringmap *rm = NULL; - struct capt_instance *ci = NULL; + struct capt_object *co = NULL; RINGMAP_FUNC_DEBUG(start); @@ -130,10 +128,10 @@ return (-1); } - while (!SLIST_EMPTY(&rm->instance_list)) { - ci = SLIST_FIRST(&rm->instance_list); - SLIST_REMOVE_HEAD(&rm->instance_list, next_instance); - clear_capt_instance((void *)ci); + while (!SLIST_EMPTY(&rm->object_list)) { + co = SLIST_FIRST(&rm->object_list); + SLIST_REMOVE_HEAD(&rm->object_list, objects); + clear_capt_object((void *)co); } destroy_dev(rm->cdev); @@ -159,13 +157,12 @@ int err = 0, i = 0; struct ringmap *rm = NULL; struct ring *ring = NULL; - struct capt_instance *ci = NULL; + struct capt_object *co = NULL; RINGMAP_FUNC_DEBUG(start); -#ifdef __RINGMAP_DEB - printf("cdev = 0x%X, td = %d\n", - (unsigned int)cdev, - td->td_proc->p_pid); + +#if (__RINGMAP_DEB) + printf("[%s] pid = %d\n", __func__, td->td_proc->p_pid); #endif /* a little magic */ @@ -176,17 +173,15 @@ return (EIO); } - rm->funcs->disable_intr(rm->dev); RINGMAP_LOCK(rm); /* check: the current thread shouldn't open(2) more than one time */ if (rm->open_cnt) { - SLIST_FOREACH(ci, &rm->instance_list, next_instance) { - if (ci->td == td) { + SLIST_FOREACH(co, &rm->object_list, objects) { + if (co->td == td) { RINGMAP_ERROR(Device is opened!); - err = EIO; - goto out; + err = EIO; goto out; } } } @@ -200,61 +195,59 @@ if (ring == NULL) { RINGMAP_ERROR(Can not allocate space for ring); - err = EIO; - goto out; + err = EIO; goto out; } for (i = 0 ; i < SLOTS_NUMBER ; i++){ if (rm->funcs->set_slot(ring, rm->dev, i) == -1){ RINGMAP_ERROR(Ring initialization failed!); contigfree(ring, sizeof(struct ring), M_DEVBUF); - err = EIO; - goto out; + err = EIO; goto out; } } + ring->size = SLOTS_NUMBER; + ring->pid = td->td_proc->p_pid; + /* * create the capturing instance wich will represent * current thread and packets ring */ - MALLOC( ci, struct capt_instance *, - sizeof(struct capt_instance), M_DEVBUF, (M_ZERO | M_WAITOK)); - if ( ci == NULL ){ + MALLOC( co, struct capt_object *, + sizeof(struct capt_object), M_DEVBUF, (M_ZERO | M_WAITOK)); + if ( co == NULL ){ contigfree(ring, sizeof(struct ring), M_DEVBUF); - err = EIO; - goto out; + err = EIO; goto out; } - - ci->ring = ring; - ci->ring->size = SLOTS_NUMBER; - ci->td = td; - ci->rm = rm; + co->ring = ring; + co->td = td; + co->rm = rm; - ci->ring->pid = ci->td->td_proc->p_pid; + SLIST_INSERT_HEAD(&rm->object_list, co, objects); - SLIST_INSERT_HEAD(&rm->instance_list, ci, next_instance); - - if ( devfs_set_cdevpriv((void *)ci, clear_capt_instance) ) { - RINGMAP_ERROR(Can not store private data!); - FREE(ci, M_DEVBUF); + /* + * Store capturing object as private date. So we can access our capturing + * object in other syscalls, e.g. read, close, etc... + */ + if ( devfs_set_cdevpriv((void *)co, clear_capt_object) ) { + RINGMAP_ERROR(Can not set private data!); + FREE(co, M_DEVBUF); contigfree(ring, sizeof(struct ring), M_DEVBUF); - err = EIO; - goto out; + err = EIO; goto out; } rm->funcs->sync_head_tail(rm->dev); -#ifdef __RINGMAP_DEB - print_capt_inst(ci); - PRINT_RING_PTRS(ci->ring); +#if (__RINGMAP_DEB) + print_capt_obj(co); + PRINT_RING_PTRS(co->ring); #endif rm->open_cnt++; out: RINGMAP_UNLOCK(rm); - rm->funcs->enable_intr(rm->dev); RINGMAP_FUNC_DEBUG(end); @@ -264,37 +257,13 @@ int ringmap_close(struct cdev *cdev, int flag, int otyp, struct thread *td) { - struct capt_instance *ci = NULL; - struct capt_instance *ki = NULL; - struct ringmap *rm = NULL; RINGMAP_FUNC_DEBUG(start); -#ifdef __RINGMAP_DEB - printf("cdev = 0x%X, td = %d\n", - (unsigned int)cdev, - td->td_proc->p_pid); +#if (__RINGMAP_DEB) + printf("[%s] pid = %d\n", __func__, td->td_proc->p_pid); #endif - rm = get_ringmap_p(get_device_p(cdev)); - - RINGMAP_LOCK(rm); - - devfs_get_cdevpriv((void **)&ci); - -#ifdef __RINGMAP_DEB - print_capt_inst(ci); -#endif - -#ifdef __RINGMAP_DEB - SLIST_FOREACH(ki, &rm->instance_list, next_instance) { - printf("[%s] Aufter dealocation: ", __func__); - print_capt_inst(ki); - } -#endif - - RINGMAP_UNLOCK(rm); - RINGMAP_FUNC_DEBUG(end); return (0); @@ -304,7 +273,7 @@ ringmap_read(struct cdev *cdev, struct uio *uio, int ioflag) { struct ringmap *rm = NULL; - struct capt_instance *ci = NULL; + struct capt_object *co = NULL; vm_paddr_t phys_ring; RINGMAP_FUNC_DEBUG(end); @@ -312,23 +281,19 @@ /* Get pointer to the ringmap structure */ rm = get_ringmap_p(get_device_p(cdev)); - if (devfs_get_cdevpriv((void **)&ci)) { - SLIST_FOREACH(ci, &rm->instance_list, next_instance) { - if ( ci->td == curthread) - break; - } + if (devfs_get_cdevpriv((void **)&co)) { + RINGMAP_ERROR(Wrong capturing object!); + return(EIO); } - - if (ci->td != curthread ){ + if (co->td != curthread ){ RINGMAP_ERROR(Wrong capturing object!); return(EIO); } - phys_ring = vtophys(ci->ring); -#ifdef __RINGMAP_DEB - print_capt_inst(ci); - PRINT_RING_PTRS(ci->ring); - printf("[%s] phys addr of ring 0x%X\n", __func__, phys_ring); + phys_ring = vtophys(co->ring); +#if (__RINGMAP_DEB) + print_capt_obj(co); + PRINT_RING_PTRS(co->ring); #endif uiomove(&phys_ring, sizeof(phys_ring), uio); @@ -338,47 +303,6 @@ return (0); } -//int -//ringmap_mmap(struct cdev *cdev, vm_ooffset_t offset, vm_paddr_t *paddr, -// int nprot, vm_memattr_t *memattr) -//{ -// int err = 0; -// struct ringmap *rm = NULL; -// struct capt_instance *ci = NULL; -// pid_t pid = 0; -// -// pid = curthread->td_proc->p_pid; -// -// RINGMAP_FUNC_DEBUG(start); -// -// /* Get pointer to the ringmap structure */ -// rm = get_ringmap_p(get_device_p(cdev)); -// -// rm->funcs->disable_intr(rm->dev); -// RINGMAP_LOCK(rm); -// -// if (devfs_get_cdevpriv((void **)&ci)) { -// SLIST_FOREACH(ci, &rm->instance_list, next_instance) { -// if ( ci->td == curthread) -// break; -// } -// } -//#ifdef __RINGMAP_DEB -// print_capt_inst(ci); -// PRINT_RING_PTRS(ci->ring); -// printf("[%s] phys addr of ring 0x%X\n", __func__, vtophys(ci->ring)); -//#endif -// -// *paddr = vtophys(ci->ring); -// -// RINGMAP_UNLOCK(rm); -// rm->funcs->enable_intr(rm->dev); -// -// RINGMAP_FUNC_DEBUG(end); -// -// return(err); -//} - int ringmap_ioctl (struct cdev *cdev, u_long cmd, caddr_t data, @@ -386,14 +310,12 @@ { int err = 0, err_sleep = err_sleep; struct ringmap *rm = NULL; - struct capt_instance *ci; + struct capt_object *co; RINGMAP_IOCTL(start); -#ifdef __RINGMAP_DEB - printf("cdev = 0x%X, td = %d\n", - (unsigned int)cdev, - td->td_proc->p_pid); +#if (__RINGMAP_DEB) + printf("[%s] pid = %d\n", __func__, td->td_proc->p_pid); #endif /* Eliminate it */ @@ -406,16 +328,16 @@ } RINGMAP_LOCK(rm); - if ( devfs_get_cdevpriv((void **)&ci) ) { + if ( devfs_get_cdevpriv((void **)&co) ) { RINGMAP_IOCTL(Error! Can not get private date!) return (ENODEV); } - if (ci->td != curthread){ + if (co->td != curthread){ RINGMAP_IOCTL(Wrong private data!); - SLIST_FOREACH(ci, &rm->instance_list, next_instance) { - if ( ci->td == curthread) + SLIST_FOREACH(co, &rm->object_list, objects) { + if ( co->td == curthread) break; } } @@ -438,22 +360,22 @@ /* Sleep and wait for new packets */ case IOCTL_SLEEP_WAIT: - ci->ring->user_wait_kern++; + co->ring->user_wait_kern++; rm->funcs->sync_head_tail(rm->dev); -#ifdef __RINGMAP_DEB - print_capt_inst(ci); - PRINT_RING_PTRS(ci->ring); +#if (__RINGMAP_DEB) + print_capt_obj(co); + PRINT_RING_PTRS(co->ring); #endif /* * In the time: from user has called ioctl() until now could * come the new packets. It means, before we are going to sleep * it makes a sence to check if we really must do it :) */ - if (RING_IS_EMPTY(ci->ring)) { + if (RING_IS_EMPTY(co->ring)) { RINGMAP_IOCTL(Sleep and wait for new packets); - err_sleep = tsleep(ci->ring, (PRI_MIN) | PCATCH, "ioctl", 0); + err_sleep = tsleep(co->ring, (PRI_MIN) | PCATCH, "ioctl", 0); } break; @@ -478,32 +400,33 @@ void -clear_capt_instance(void * data) +clear_capt_object(void * data) { - struct capt_instance *ci = NULL; + struct capt_object *co = NULL; struct ringmap *rm = NULL; RINGMAP_FUNC_DEBUG(start); - if ( data != NULL ) { - ci = (struct capt_instance *)data; - rm = ci->rm; + if (data != NULL) { + co = (struct capt_object *)data; + rm = co->rm; RINGMAP_LOCK(rm); -#ifdef __RINGMAP_DEB - print_capt_inst(ci); +#if (__RINGMAP_DEB) + print_capt_obj(co); #endif - if ( ci->ring != NULL ){ - contigfree(ci->ring, sizeof(struct ring), M_DEVBUF); - SLIST_REMOVE(&ci->rm->instance_list, ci, capt_instance, next_instance); - FREE(ci, M_DEVBUF); - data = NULL; - } + if (co->ring != NULL) + contigfree(co->ring, sizeof(struct ring), M_DEVBUF); + + SLIST_REMOVE(&rm->object_list, co, capt_object, objects); + FREE(co, M_DEVBUF); + data = NULL; } else { RINGMAP_FUNC_DEBUG(NULL pointer to the capturing instance!); } - rm->open_cnt--; + if (rm->open_cnt) + rm->open_cnt--; RINGMAP_UNLOCK(rm); @@ -512,13 +435,13 @@ void -print_capt_inst(struct capt_instance *ci) +print_capt_obj(struct capt_object *co) { - if (ci != NULL) { - printf("[%s] ci->td->proc->pid: %d\n", - __func__, ci->td->td_proc->p_pid); + if (co != NULL) { + printf("[%s] co->td->proc->pid: %d\n", + __func__, co->td->td_proc->p_pid); printf("[%s] Ring Kernel Addr:0x%X\n", - __func__, (unsigned int)ci->ring); + __func__, (unsigned int)co->ring); } } ==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#27 (text+ko) ==== @@ -59,7 +59,7 @@ * Next fields are for statistics: */ - /* Time stamp of packet which placed in the slot */ + /* Time stamp of packet stored in this slot */ struct timeval ts; /* Interrupts number in which kontext the packet was received */ @@ -98,7 +98,7 @@ /* Number of slots (descriptors a.k.a memory areas for frames) */ unsigned int size; - /* Values from adapters statistic registers */ + /* Values from adapters statistic registers. Currently is not used */ struct address hw_stats; /* @@ -117,20 +117,7 @@ */ unsigned long long user_wait_kern; - /* - * Slot which currently processed by driver in context of - * delayed interupt - */ - unsigned int volatile cur_slot_kern; - - /* - * Slot which currently processed by user-space process - * in the pcap_read_ringmap() function (ringmap_pcap.c) - */ - unsigned int volatile cur_slot_user; - - /* * Number of received packets. This variable should be changed only in * user-space. We want to count the packets, that was seen by user-space * process. I am not sure we are need it :( @@ -139,6 +126,7 @@ struct timeval last_ts; + /* Ring identification. Should be initialized with process ID */ unsigned int pid; /* Array of slots */ @@ -149,13 +137,12 @@ #ifdef _KERNEL struct ringmap_functions; -struct capt_instance { +struct capt_object { struct thread *td; struct ring *ring; struct ringmap *rm; >>> TRUNCATED FOR MAIL (1000 lines) <<<