Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jun 2010 21:04:37 GMT
From:      Alexandre Fiveg <afiveg@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 180124 for review
Message-ID:  <201006222104.o5ML4bVq083001@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@180124?ac=10

Change 180124 by afiveg@cottonmouth on 2010/06/22 21:04:14

	Begin to port ringmap-libpcap to current. + tests

Affected files ...

.. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-bpf.c#2 edit
.. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-int.h#2 edit
.. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap.c#2 edit
.. //depot/projects/soc2010/ringmap/current/lib/libpcap/Makefile#3 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#9 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.h#7 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#7 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#5 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#7 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#11 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#11 edit
.. //depot/projects/soc2010/ringmap/tests/libpcap/Makefile#1 add
.. //depot/projects/soc2010/ringmap/tests/libpcap/easy_pcap.c#1 add
.. //depot/projects/soc2010/ringmap/tests/libpcap/test_pcap.c#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/close.c#2 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/ioctl.c#2 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/main.c#3 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/mmap.c#3 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/open.c#3 edit

Differences ...

==== //depot/projects/soc2010/ringmap/current/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>
+#include "../../sys/net/ringmap.h"
+#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);
@@ -1330,6 +1335,10 @@
 	struct bpf_program total_prog;
 	struct utsname osinfo;
 
+#ifdef RINGMAP
+	RINGMAP_FUNC_DEBUG (start);
+#endif
+
 #ifdef HAVE_DAG_API
 	if (strstr(device, "dag")) {
 		return dag_open_live(device, snaplen, promisc, to_ms, ebuf);
@@ -1349,6 +1358,9 @@
 		status = fd;
 		goto bad;
 	}
+#ifdef RINGMAP
+	RINGMAP_FUNC_DEBUG(BPF device is opened);
+#endif 
 
 	p->fd = fd;
 
@@ -1467,6 +1479,11 @@
 	}
 #endif /* __APPLE__ */
 #ifdef HAVE_ZEROCOPY_BPF
+
+#ifdef RINGMAP
+	/* only for debug goals */
+	RINGMAP_FUNC_DEBUG(have zerocopy BPF);
+#endif
 	/*
 	 * If the BPF extension to set buffer mode is present, try setting
 	 * the mode to zero-copy.  If that fails, use regular buffering.  If
@@ -1624,6 +1641,10 @@
 		goto bad;
 	}
 
+#ifdef RINGMAP
+	RINGMAP_FUNC_DEBUG(BIOCGDLT syscall done);
+#endif
+
 #ifdef _AIX
 	/*
 	 * AIX's BPF returns IFF_ types, not DLT_ types, in BIOCGDLT.
@@ -1778,6 +1799,9 @@
 		}
 	}
 #elif defined(HAVE_BSD_IEEE80211)
+#ifdef RINGMAP
+	RINGMAP_FUNC_DEBUG(2);
+#endif
 	/*
 	 * *BSD with the new 802.11 ioctls.
 	 * Do we want monitor mode?
@@ -2064,8 +2088,14 @@
 	p->stats_op = pcap_stats_bpf;
 	p->cleanup_op = pcap_cleanup_bpf;
 
+#ifdef RINGMAP
+	RINGMAP_FUNC_DEBUG(end: Ok);
+#endif
 	return (status);
  bad:
+#ifdef RINGMAP
+	RINGMAP_FUNC_DEBUG(failed);
+#endif
  	pcap_cleanup_bpf(p);
 	return (status);
 }

==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-int.h#2 (text+ko) ====

@@ -331,6 +331,10 @@
 	u_int *dlt_list;
 
 	struct pcap_pkthdr pcap_header;	/* This is needed for the pcap_next_ex() to work */
+
+#ifdef RINGMAP
+	struct ring *ring;
+#endif
 };
 
 /*

==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap.c#2 (text+ko) ====

@@ -71,6 +71,15 @@
 #include <dagapi.h>
 #endif
 
+#ifdef RINGMAP
+#include <machine/bus.h>
+#include "../../sys/net/ringmap.h"
+
+extern int check_module(const char *);
+extern int init_mmapped_capturing(const char *device, pcap_t *);
+#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);
@@ -241,6 +254,11 @@
 	status = pcap_set_timeout(p, to_ms);
 	if (status < 0)
 		goto fail;
+
+#ifdef RINGMAP
+	RINGMAP_FUNC_DEBUG(pcap is allocated);
+#endif
+
 	/*
 	 * Mark this as opened with pcap_open_live(), so that, for
 	 * example, we show the full list of DLT_ values, rather
@@ -255,6 +273,16 @@
 	status = pcap_activate(p);
 	if (status < 0)
 		goto fail;
+
+#ifdef RINGMAP
+	if (check_module(source) < 0){
+		goto fail;
+	}
+	if (init_mmapped_capturing(source, p) < 0){
+		goto fail;
+	}
+#endif
+
 	return (p);
 fail:
 	if (status == PCAP_ERROR || status == PCAP_ERROR_NO_SUCH_DEVICE ||

==== //depot/projects/soc2010/ringmap/current/lib/libpcap/Makefile#3 (text+ko) ====

@@ -12,8 +12,8 @@
 	scanner.l version.c
 
 .if defined(LIBPCAP_RINGMAP)
-CFLAGS+=-D__RINGMAP__ -D__E1000_RINGMAP__ 
-SRC+=ringmap_pcap.c
+CFLAGS+=-g -DRINGMAP 
+SRCS+=ringmap_pcap.c
 .endif 
 
 # Old compatibility headers

==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#9 (text+ko) ====

@@ -1382,9 +1382,18 @@
 	struct ifnet	*ifp = adapter->ifp;
 
 	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+#ifdef RINGMAP
+		if ((adapter->rm != NULL) && (adapter->rm->ring != NULL))
+			adapter->rm->funcs->delayed_interrupt(context);
+#endif
 		if (lem_rxeof(adapter, adapter->rx_process_limit) != 0)
 			taskqueue_enqueue(adapter->tq, &adapter->rxtx_task);
 
+#ifdef RINGMAP
+		if (adapter->rm != NULL) 
+			wakeup(adapter->rm);
+#endif 
+
 #if (RINGMAP_TX_ENABLE)
 		EM_TX_LOCK(adapter);
 		lem_txeof(adapter);

==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.h#7 (text+ko) ====


==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#7 (text+ko) ====

@@ -26,14 +26,31 @@
 int rm_8254_set_slot(struct ring *, struct adapter *, unsigned int);
 void rm_8254_print_slot(struct ring *, unsigned int);
 void rm_8254_interrupt(void *);
+void rm_8254_delayed_interrupt(void *);
 int rm_8254_print_ring_pointers(struct adapter *);
+void rm_8254_sync_head_tail(device_t, struct ring *);
 
 extern devclass_t em_devclass;
 extern void	lem_enable_intr(struct adapter *);
 extern void	lem_disable_intr(struct adapter *);
 
 
+void 
+rm_8254_sync_head_tail(device_t dev, struct ring *ring)
+{
+	struct adapter *adapter;
+	adapter = (struct adapter *)device_get_softc(dev);
+
+	ring->kernrp = RINGMAP_HW_READ_HEAD(adapter);
+	RINGMAP_HW_WRITE_TAIL(adapter, ring);
+	adapter->rm->ring->hw_RDT = ring->userrp;
+}
+
 
+/* 
+ * This should be called from ISR. Other interrupts are disallowed!
+ * It means the functions must be as small as possible 
+ */
 void 
 rm_8254_interrupt(void *arg)
 {
@@ -47,6 +64,29 @@
 }
 
 
+void 
+rm_8254_delayed_interrupt(void *context)
+{
+	struct adapter	*adapter = (struct adapter *)context;
+
+	RINGMAP_INTR(start);
+
+	/* 
+	 * synchronize HEAD and TAIL with userrp and kernrp 
+	 * TODO: we want multithreading, it means we should later 
+	 * sync not one ring but many rings, each per thread
+	 */
+	rm_8254_sync_head_tail(adapter->dev, adapter->rm->ring);
+
+
+#ifdef RINGMAP_TIMESTAMP
+
+#endif
+
+	RINGMAP_INTR(end);
+}
+
+
 /*
  * Get adapter structure of device and initialize the 
  * pointers in ring (mbufs, packets, decriptors) with values 
@@ -101,6 +141,7 @@
 	return (0);
 }
 
+
 int
 rm_8254_set_slot(struct ring *ring, struct adapter *adapter, 
 		unsigned int slot_num)
@@ -150,6 +191,7 @@
 	return (-1);
 }
 
+
 void
 rm_8254_print_slot(struct ring *ring, unsigned int slot_number)
 {
@@ -243,6 +285,7 @@
 	return (0);
 }
 
+
 /*
  * Returns pointer to ringmap structure
  */

==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#5 (text+ko) ====

@@ -18,10 +18,14 @@
 
 /* Registers access */
 #define RINGMAP_HW_READ_REG E1000_READ_REG
+#define RINGMAP_HW_WRITE_REG E1000_WRITE_REG
 
 #define RINGMAP_HW_READ_HEAD(adapter)						\
 		RINGMAP_HW_READ_REG(&adapter->hw, E1000_RDH(0))	
 
+#define RINGMAP_HW_WRITE_TAIL(adapter, ring)				\
+		RINGMAP_HW_WRITE_REG(&adapter->hw, E1000_RDT(0), ring->userrp)
+	
 #define RINGMAP_HW_READ_TAIL(adapter)						\
 		RINGMAP_HW_READ_REG(&adapter->hw, E1000_RDT(0))
 

==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#7 (text+ko) ====


==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#11 (text+ko) ====

@@ -11,6 +11,7 @@
 #include <sys/proc.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
+#include <sys/kernel.h>
 
 #include <machine/bus.h>
 #include <machine/atomic.h>
@@ -30,13 +31,6 @@
 #include <dev/pci/pcivar.h>   /* For pci_get macros! */
 #include <dev/pci/pcireg.h>
 
-//extern devclass_t em_devclass;
-//extern int	em_rxeof(struct rx_ring *, int);
-//extern bool	em_txeof(struct tx_ring *);
-//extern void	em_print_debug_info(struct adapter *);
-//extern void	em_start_locked(struct ifnet *, struct tx_ring *);
-//#endif
-
 #include "ringmap.h"
 
 int ringmap_attach (device_t);
@@ -54,26 +48,15 @@
 extern device_t rm_8254_get_device_p(struct cdev *);
 extern void rm_8254_enable_intr(device_t);
 extern void rm_8254_disable_intr(device_t);
-extern void rm_8254_interrupt(struct ringmap *);
+extern void rm_8254_interrupt(void *);
+extern void rm_8254_delayed_interrupt(void *);
+extern void rm_8254_sync_head_tail(device_t, struct ring *);
 
-//struct adapter* get_adapter_struct(struct cdev *dev);
-//int ringmap_print_ring_pointers(struct adapter *);
-//void ringmap_print_ring (struct adapter *adapter, int level);
-//void ringmap_print_slot(struct adapter *adapter, unsigned int slot_number);
-
-//#if (__DRIVER_VERSION == 696)
-//void ringmap_handle_rxtx(void *context, int pending);
-//#endif
-//
-///* For CURRENT */
-//void ringmap_handle_que(void *context, int pending);
-//
 d_open_t	ringmap_open;
 d_close_t	ringmap_close;
 d_ioctl_t	ringmap_ioctl;
 d_mmap_t	ringmap_mmap;
 
-
 /*
  *	Character Device for access on if_em driver structures
  */
@@ -129,10 +112,12 @@
 			/* Set ringmap pointer in the drivrs structure of adapter */
 			rm->funcs->set_ringmap_to_adapter = 
 				rm_8254_set_ringmap_to_adapter;
-			rm->funcs->enable_intr  = rm_8254_enable_intr;
-			rm->funcs->disable_intr = rm_8254_disable_intr;
-			rm->funcs->init_slots = rm_8254_init_slots;
-			rm->funcs->interrupt = rm_8254_interrupt;
+			rm->funcs->enable_intr  		= rm_8254_enable_intr;
+			rm->funcs->disable_intr 		= rm_8254_disable_intr;
+			rm->funcs->init_slots 			= rm_8254_init_slots;
+			rm->funcs->interrupt 			= rm_8254_interrupt;
+			rm->funcs->sync_head_tail 		= rm_8254_sync_head_tail;
+			rm->funcs->delayed_interrupt	= rm_8254_delayed_interrupt;
 
 			get_ringmap_p = rm_8254_get_ringmap_p;
 			get_device_p  =	rm_8254_get_device_p;
@@ -368,8 +353,10 @@
 
 	RINGMAP_FUNC_DEBUG(start);
 	
+	/* Get pointer to the ringmap structure */
 	rm = get_ringmap_p(get_device_p(cdev));
 
+	/* Check pointers: rm and rm->ring should be allocated */
 	if (rm == NULL){
 		RINGMAP_ERROR(Can not get pointer to ringmap structure);
 		return (ENXIO);
@@ -378,6 +365,8 @@
 		RINGMAP_ERROR(Can not get pointer to ring structure);
 		return (ENXIO);
 	}
+
+	/* Check protections */
 	if (nprot & PROT_EXEC) {
 		RINGMAP_WARN("PROT_EXEC ist set");
 		return (ERESTART);
@@ -392,18 +381,21 @@
 
 
 int
-ringmap_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
+ringmap_ioctl (struct cdev *cdev, u_long cmd, caddr_t data, 
+				int fflag, struct thread *td)
 {
 	int err = 0, err_sleep = err_sleep;
+	struct ringmap *ringmap = NULL;
+
 //	struct adapter *adapter = (struct adapter *)get_adapter_struct(dev);
 //	struct ringmap *rm = adapter->rm;
 //
 //	unsigned int *userp = NULL;
 //
-	RINGMAP_FUNC_DEBUG(start);
+	RINGMAP_IOCTL(start);
+
+	switch( cmd ){
 //
-//	switch( cmd ){
-//
 //		/* Tell to user number of descriptors */
 //		case IOCTL_G_DNUM:
 //			RINGMAP_OUTPUT(IOCTL_G_DNUM);
@@ -439,149 +431,44 @@
 //			RINGMAP_HW_DISABLE_FLOWCONTR(adapter);
 //		break;
 //
-//		/* Sleep and wait for new frames */
-//		case IOCTL_SLEEP_WAIT:
-//			rm->ring->user_wait_kern++;
-//			RINGMAP_HW_SYNC_TAIL(adapter);
-//			err_sleep = tsleep(rm, (PRI_MIN) | PCATCH, "ioctl", hz);
-//		break;
-//
-//		/* Synchronize sowftware ring-tail with hardware-ring-tail (RDT) */
-//		case IOCTL_SET_RDT:
-//			SET_RDT(adapter);
-//		break;
-//
-//		default:
-//			RINGMAP_ERROR("Undefined command!");
-//			return (ENODEV);
-//	}   	
+		/* Sleep and wait for new frames */
+		case IOCTL_SLEEP_WAIT:
+			/* TODO: use private data to set and get ring from curr. thread */
+			ringmap = get_ringmap_p(get_device_p(cdev));
+			if ((ringmap != NULL) && (ringmap->ring != NULL)){
+				ringmap->ring->user_wait_kern++;
+				ringmap->funcs->sync_head_tail(get_device_p(cdev), 
+												ringmap->ring);
+				err_sleep = tsleep(ringmap, (PRI_MIN) | PCATCH, "ioctl", 0);
+			} else {
+				RINGMAP_ERROR(NULL pointer. ioctl can not be accomplished);
+
+				/* TODO: look if ENODEV is a correctly for this case */
+				return(ENODEV);
+			}
+		break;
+
+		/* Synchronize sowftware ring-tail with hardware-ring-tail (RDT) */
+		case IOCTL_SYNC_HEAD_TAIL:
+			/* TODO: use private data to set and get ring from curr. thread */
+			ringmap = get_ringmap_p(get_device_p(cdev));
+			if ((ringmap != NULL) && (ringmap->ring != NULL)){
+				ringmap->funcs->sync_head_tail(get_device_p(cdev), 
+												ringmap->ring);
+			} else {
+				RINGMAP_ERROR(NULL pointer. ioctl can not be accomplished);
+
+				/* TODO: look if ENODEV is a correctly for this case */
+				return(ENODEV);
+			}
+		break;
+
+		default:
+			RINGMAP_ERROR("Undefined command!");
+			return (ENODEV);
+	}   	
         	
-	RINGMAP_FUNC_DEBUG(end);
+	RINGMAP_IOCTL(end);
         	
 	return (err);
 }
-
-//void
-//ringmap_handle_que(void *context, int pending)
-//{
-//	struct adapter	*adapter = context;
-//	struct ringmap 	*rm = adapter->rm;
-//	struct ifnet	*ifp = adapter->ifp;
-//	struct tx_ring	*txr = adapter->tx_rings;
-//	struct rx_ring	*rxr = adapter->rx_rings;
-//	bool		more_rx;
-//
-//#if (INTR_DEB) 	
-//	printf("########################################################################\n");
-//#endif
-//
-//	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-//		more_rx = em_rxeof(rxr, adapter->rx_process_limit);
-//
-//		EM_TX_LOCK(txr);
-//		em_txeof(txr);
-//#ifdef EM_MULTIQUEUE
-//		if (!drbr_empty(ifp, txr->br))
-//			em_mq_start_locked(ifp, txr, NULL);
-//#else
-//		if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
-//			em_start_locked(ifp, txr);
-//#endif
-//		EM_TX_UNLOCK(txr);
-//		if (more_rx) {
-//			taskqueue_enqueue(adapter->tq, &adapter->que_task);
-//			return;
-//		}
-//	}
-//
-//#if (INTR_DEB) 	
-//	printf("########################################################################\n");
-//#endif
-//
-//	RINGMAP_HW_ENABLE_INTR(adapter);
-//
-//	if (rm->procp != NULL) {
-//		wakeup(rm);
-//	}
-//
-//	return;
-//}
-//
-//#if (__DRIVER_VERSION == 696)
-//void
-//ringmap_handle_rxtx(void *context, int pending)
-//{
-//	struct adapter	*adapter = context;
-//	struct ifnet	*ifp = adapter->ifp;
-//	struct ringmap 	*rm = adapter->rm;
-//
-//#if (INTR_DEB) 	
-//	printf("########################################################################\n");
-//#endif
-//
-//	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-//#ifdef __E1000_RINGMAP__
-//		if (em_rxeof(adapter, adapter->rx_process_limit) != 0)
-//			taskqueue_enqueue(adapter->tq, &adapter->rxtx_task);
-//#endif
-//	}
-//
-//#if (INTR_DEB) 	
-//	printf("########################################################################\n\n");
-//#endif
-//
-//	RINGMAP_HW_ENABLE_INTR(adapter);
-//
-//	if (rm->procp != NULL) {
-//		wakeup(rm);
-//	}
-//}
-//#endif 
-//
-//struct adapter*
-//
-//get_adapter_struct(struct cdev *dev)
-//{
-//	struct adapter *adapter;
-//
-//	adapter = RINGMAP_GET_ADAPTER_STRUCT(adapter);
-//	return (adapter);
-//}
-//
-//
-//void
-//ringmap_print_ring (struct adapter *adapter, int level)
-//{
-//	struct ringmap *rm = adapter->rm;
-//
-//	printf("Ring Size = %d \n",rm->ring->size );	
-//	printf("Times Kern wait for User = %llu \n",rm->ring->kern_wait_user);	
-//	printf("Times User wait for Kern = %llu \n",rm->ring->user_wait_kern);	
-//	printf("Interrupts Counter = %llu \n",rm->ring->interrupts_counter);	
-//
-//	ringmap_print_ring_pointers(adapter);
-//}
-//
-//
-//void 
-//ringmap_print_slot(struct adapter *adapter, unsigned int slot_number)
-//{
-//	struct ringmap *rm = adapter->rm;
-//
-//	printf("Slot Number: %d \n", slot_number);
-//	printf("---------------- \n");
-//
-//	printf("[%s] physical addr of descriptor[%d] = 0x%X\n", __func__, slot_number, 
-//			(unsigned int) rm->ring->slot[slot_number].descriptor.phys);
-//	printf("[%s] kernel addr of descriptor[%d] = 0x%X\n", __func__, slot_number, 
-//			(unsigned int) rm->ring->slot[slot_number].descriptor.kern);
-//	printf("[%s] physical addr of mbuf[%d] = 0x%X\n", __func__, slot_number, 
-//			(unsigned int) rm->ring->slot[slot_number].mbuf.phys);
-//	printf("[%s] kernel addr of mbuf[%d] = 0x%X\n", __func__, slot_number, 
-//			(unsigned int) rm->ring->slot[slot_number].mbuf.kern);
-//	printf("[%s] physical addr of packet_buffer[%d] = 0x%X\n", __func__, slot_number, 
-//			(unsigned int) rm->ring->slot[slot_number].packet.phys);
-//	printf("[%s] kernel addr of packet_buffer[%d] = 0x%X\n", __func__, slot_number, 
-//			(unsigned int) rm->ring->slot[slot_number].packet.kern);
-//	printf(" \n");
-//}

==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#11 (text+ko) ====

@@ -43,9 +43,12 @@
 	struct address 	mbuf;
 	struct address	packet;
 
-	/** 
-	 ** Next fields are for statistics:
-	 **/
+	/* 1 - if accepted by (bpf) filter */
+	int filtered;
+
+	/* 
+	 * Next fields are for statistics:
+	 */
 
 	/* Time stamp of packet which placed in the slot */
 	struct timeval	ts;
@@ -143,7 +146,9 @@
 	void (*enable_intr)(device_t);
 	void (*disable_intr)(device_t);
 	int (*init_slots)(struct ring *, device_t);
-	void (*interrupt)(struct ringmap*);
+	void (*interrupt)(void *);
+	void (*delayed_interrupt)(void *);
+	void (*sync_head_tail)(device_t, struct ring *);
 };
 
 #endif /* _KERNEL */
@@ -157,9 +162,6 @@
  * *************************************/
 #define RINGMAP_IOC_MAGIC	'T'
 
-/* Number of descs (a.k.a. slots in ring buffer) */
-#define IOCTL_G_DNUM	_IOWR(RINGMAP_IOC_MAGIC, 1, unsigned int)
-
 /* Start capturing. Enable packets receive and interrupts on NIC */
 #define IOCTL_ENABLE_RECEIVE	_IO(RINGMAP_IOC_MAGIC, 3)
 
@@ -173,7 +175,7 @@
 #define IOCTL_DISABLE_FLOWCNTR	_IO(RINGMAP_IOC_MAGIC, 6) 
 
 /* RDT = (userrp - RING_SAFETY_MARGIN) mod SLOTS_NUMBER */
-#define IOCTL_SET_RDT			_IO(RINGMAP_IOC_MAGIC, 2) 
+#define IOCTL_SYNC_HEAD_TAIL	_IO(RINGMAP_IOC_MAGIC, 2) 
 
 /**********************************************
  *  	Arithmetic in Ring Buffer	
@@ -240,10 +242,10 @@
 /*
  *		DEBUG OUTPUT
  */
-#ifndef IOCTL_DEB
-#define IOCTL_DEB 0
+#ifndef RINGMAP_IOCTL_DEB
+#define RINGMAP_IOCTL_DEB 1
 #else 	
-#define IOCTL_DEB 1
+#define RINGMAP_IOCTL_DEB 1
 #endif
 
 #ifndef RINGMAP_INTR_DEB
@@ -260,12 +262,26 @@
 #define ERR_PREFIX 		"--> RINGMAP ERROR: " 
 #define WARN_PREFIX 	"--> RINGMAP WARN: "
 
-#define RINGMAP_ERROR(x) 	printf("---> RINGMAP ERROR: [%s]: "  #x "\n", __func__);
-#define RINGMAP_IOCTL(x)	if (IOCTL_DEB) 	printf(" --> RINGMAP IOCTL: " #x "\n");
-#define RINGMAP_INTR(x)  	if (INTR_DEB) 	printf("[%s] --> RINGMAP INTR: " #x "\n", __func__);
-#define RINGMAP_FUNC_DEBUG(x) if (__RINGMAP_DEB) printf("[%s] --> RINGMAP FUNC: " #x "\n", __func__);
-#define RINGMAP_OUTPUT(x) if (__RINGMAP_DEB) printf("--> RINGMAP: [%s]: "  #x "\n", __func__);
-#define RINGMAP_WARN(x) 	if (__RINGMAP_DEB) printf("--> WARN: [%s]: "  #x "\n", __func__);
+#define RINGMAP_ERROR(x) 	\
+	printf("---> RINGMAP ERROR: [%s]: "  #x "\n", __func__);
+
+#define RINGMAP_IOCTL(x)	\
+	if (RINGMAP_IOCTL_DEB) 	printf(" --> RINGMAP IOCTL: " #x "\n");
+
+#define RINGMAP_INTR(x)  	\
+	if (RINGMAP_INTR_DEB) 	\
+		printf("[%s] --> RINGMAP INTR: " #x "\n", __func__);
+
+#define RINGMAP_FUNC_DEBUG(x) \
+	if (__RINGMAP_DEB) printf("[%s] --> RINGMAP FUNC: " #x "\n", __func__);
+
+#define RINGMAP_OUTPUT(x) \
+	if (__RINGMAP_DEB) printf("--> RINGMAP: [%s]: "  #x "\n", __func__);
+
+#define RINGMAP_WARN(x) 	\
+	if (__RINGMAP_DEB) printf("--> WARN: [%s]: "  #x "\n", __func__);
+
+
 
 #ifdef _KERNEL
 #define RINGMAP_PRINT_DESC(i)	\

==== //depot/projects/soc2010/ringmap/tests/ringmap/close.c#2 (text+ko) ====


==== //depot/projects/soc2010/ringmap/tests/ringmap/ioctl.c#2 (text+ko) ====


==== //depot/projects/soc2010/ringmap/tests/ringmap/main.c#3 (text+ko) ====


==== //depot/projects/soc2010/ringmap/tests/ringmap/mmap.c#3 (text+ko) ====

@@ -47,5 +47,7 @@
 
 	printf("Size of ring = %d \n", r->size);
 
+	sleep(20);
+
 	return (0);
 }

==== //depot/projects/soc2010/ringmap/tests/ringmap/open.c#3 (text+ko) ====




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006222104.o5ML4bVq083001>