PERFORCE change 180133 for review

Alexandre Fiveg afiveg at FreeBSD.org
Tue Jun 22 23:42:32 UTC 2010


http://p4web.freebsd.org/@@180133?ac=10

Change 180133 by afiveg at cottonmouth on 2010/06/22 23:42:15

	ringmap is ported to current.

Affected files ...

.. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap-bpf.c#3 edit
.. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap.c#3 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#8 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#6 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#12 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#12 edit
.. //depot/projects/soc2010/ringmap/tests/libpcap/easy_pcap.c#2 edit
.. //depot/projects/soc2010/ringmap/tests/libpcap/test_pcap.c#2 edit

Differences ...

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

@@ -164,6 +164,8 @@
 #ifdef RINGMAP
 #include <machine/bus.h>
 #include "../../sys/net/ringmap.h"
+extern void	uninit_mmapped_capturing(pcap_t *);
+extern int pcap_read_ringmap(pcap_t *, int, pcap_handler, u_char *);
 #endif 
 
 static int pcap_can_set_rfmon_bpf(pcap_t *p);
@@ -214,6 +216,9 @@
 static void
 pcap_cleanup_zbuf(pcap_t *p)
 {
+#ifdef RINGMAP
+	RINGMAP_FUNC_DEBUG(start);
+#endif
 	/*
 	 * Delete the mappings.  Note that p->buffer gets initialized to one
 	 * of the mmapped regions in this case, so do not try and free it
@@ -1140,6 +1145,11 @@
 	struct ifreq ifr;
 #endif
 
+#ifdef RINGMAP
+	RINGMAP_FUNC_DEBUG(start);
+
+	uninit_mmapped_capturing(p);
+#endif 
 	if (p->md.must_clear != 0) {
 		/*
 		 * There's something we have to do when closing this
@@ -1641,9 +1651,6 @@
 		goto bad;
 	}
 
-#ifdef RINGMAP
-	RINGMAP_FUNC_DEBUG(BIOCGDLT syscall done);
-#endif
 
 #ifdef _AIX
 	/*
@@ -1799,9 +1806,6 @@
 		}
 	}
 #elif defined(HAVE_BSD_IEEE80211)
-#ifdef RINGMAP
-	RINGMAP_FUNC_DEBUG(2);
-#endif
 	/*
 	 * *BSD with the new 802.11 ioctls.
 	 * Do we want monitor mode?
@@ -2078,7 +2082,11 @@
 		}
 	}
 
+#ifndef RINGMAP
 	p->read_op = pcap_read_bpf;
+#else 
+	p->read_op = pcap_read_ringmap;
+#endif 
 	p->inject_op = pcap_inject_bpf;
 	p->setfilter_op = pcap_setfilter_bpf;
 	p->setdirection_op = pcap_setdirection_bpf;

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


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

@@ -42,7 +42,7 @@
 	adapter = (struct adapter *)device_get_softc(dev);
 
 	ring->kernrp = RINGMAP_HW_READ_HEAD(adapter);
-	RINGMAP_HW_WRITE_TAIL(adapter, ring);
+	RINGMAP_HW_SYNC_TAIL(adapter, ring);
 	adapter->rm->ring->hw_RDT = ring->userrp;
 }
 
@@ -126,8 +126,11 @@
 	ring->kern_wait_user = 0;	
     ring->user_wait_kern = 0;	
     ring->interrupts_counter = 0;	
+	RINGMAP_HW_WRITE_TAIL(adapter, SLOTS_NUMBER - 1); 
+	ring->userrp = RINGMAP_HW_READ_TAIL(adapter);
 	ring->size = SLOTS_NUMBER;		
 
+
 	/* Set ring pointers */
 	for (slot_num = 0 ; slot_num < SLOTS_NUMBER ; slot_num ++){
 		if (rm_8254_set_slot(ring, adapter, slot_num) == -1){

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

@@ -20,12 +20,17 @@
 #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)				\
+#define RINGMAP_HW_SYNC_TAIL(adapter, ring)				\
 		RINGMAP_HW_WRITE_REG(&adapter->hw, E1000_RDT(0), ring->userrp)
-	
+
+#define RINGMAP_HW_WRITE_TAIL(adapter, val)				\
+		RINGMAP_HW_WRITE_REG(&adapter->hw, E1000_RDT(0), val)
+
 #define RINGMAP_HW_READ_TAIL(adapter)						\
 		RINGMAP_HW_READ_REG(&adapter->hw, E1000_RDT(0))
 

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


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

@@ -206,11 +206,20 @@
 
 /* Distance from KERN to USER pointer */
 #define KERN_TO_USER_RING_DISTANCE(ringp)								\
-	(((ringp)->userrp == (ringp)->kernrp) ?  SLOTS_NUMBER : R_DISTANCE((ringp)->kernrp, (ringp)->userrp, SLOTS_NUMBER))
+	(((ringp)->userrp == (ringp)->kernrp) ?  0 : R_DISTANCE((ringp)->kernrp, (ringp)->userrp, SLOTS_NUMBER))
 
 /* Distance from USER to KERN pointer */
 #define USER_TO_KERN_RING_DISTANCE(ringp)	\
-	(R_DISTANCE((ringp)->userrp, (ringp)->kernrp, SLOTS_NUMBER))
+	(((ringp)->userrp == (ringp)->kernrp) ? SLOTS_NUMBER : R_DISTANCE((ringp)->userrp, (ringp)->kernrp, SLOTS_NUMBER))
+
+#define RING_IS_EMPTY(ringp)				\
+	((USER_TO_KERN_RING_DISTANCE(ringp)) == 1)
+
+#define RING_NOT_EMPTY(ringp)				\
+	((USER_TO_KERN_RING_DISTANCE(ringp)) > 1)
+
+#define RING_IS_FULL(ringp)					\
+	((KERN_TO_USER_RING_DISTANCE(ringp)) == 0)
 
 /* Increment of USER pointer. (KERN pointer is incremented by Hardware) */
 #define INC_USER_POINTER(ringp)											\

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

@@ -17,11 +17,15 @@
 
 
 int capture_pkts (const char*);
+void got_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
 
 
 pcap_t *handle;
 
 
+#define HOWMANY 20
+
+
 int
 main(int argc, char **argv)
 {
@@ -49,9 +53,20 @@
 		fprintf(stderr, "pcap handle = NULL!: %s\n", errbuf);
 		return (-1);	
 	}
+
+	pcap_loop(handle, HOWMANY, got_packet, NULL);
 	
 	if (handle != NULL)
 		pcap_close(handle);	
 	
 	return (0);
 }
+
+/*
+ * Callback function. Will called for each captured packet
+ */
+void
+got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet)
+{
+	printf("got :)  \n");
+}

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



More information about the p4-projects mailing list