PERFORCE change 187081 for review

Alexandre Fiveg afiveg at FreeBSD.org
Mon Dec 20 17:57:37 UTC 2010


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

Change 187081 by afiveg at cottonmouth on 2010/12/20 17:57:14

	The interface to the userspace applications will be in the
	libringmap implemented. In the libringmap.h are data structures 
	and functions defined. It is a first draft.

Affected files ...

.. //depot/projects/soc2010/ringmap/current/contrib/libringmap/libringmap.c#1 add
.. //depot/projects/soc2010/ringmap/current/contrib/libringmap/libringmap.h#1 add
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#37 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.h#23 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#38 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#54 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#53 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap_kernel.h#22 edit
.. //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#36 edit
.. //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#37 edit
.. //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#31 edit
.. //depot/projects/soc2010/ringmap/stable_8/lib/libpcap/Makefile#2 edit

Differences ...

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

@@ -310,7 +310,11 @@
 static int lem_rx_int_delay_dflt = EM_TICKS_TO_USECS(EM_RDTR);
 static int lem_tx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_TADV);
 static int lem_rx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_RADV);
+#ifndef RINGMAP
 static int lem_rxd = EM_DEFAULT_RXD;
+#else
+static int lem_rxd = SLOTS_NUMBER;
+#endif
 static int lem_txd = EM_DEFAULT_TXD;
 static int lem_smart_pwr_down = FALSE;
 

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

@@ -70,15 +70,17 @@
  *      (num_tx_desc * sizeof(struct e1000_tx_desc)) % 128 == 0
  */
 #define EM_MIN_RXD		80
+#ifndef RINGMAP
 #define EM_MAX_RXD_82543	256
-#ifndef RINGMAP
 #define EM_MAX_RXD		2048
 #define EM_DEFAULT_RXD	EM_MAX_RXD_82543
-#else 
+#else
+#define EM_MAX_RXD_82543	SLOTS_NUMBER
 #define EM_MAX_RXD		SLOTS_NUMBER
-#define EM_DEFAULT_RXD 	SLOTS_NUMBER
+#define EM_DEFAULT_RXD	SLOTS_NUMBER
 #endif
 
+
 /*
  * EM_TIDV - Transmit Interrupt Delay Value
  * Valid Range: 0-65535 (0=off)

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

@@ -25,6 +25,8 @@
 void rm_8254_receive_enable (struct ringmap *rm);
 void rm_8254_intr_disable (struct ringmap *rm);
 void rm_8254_intr_enable (struct ringmap *rm);
+unsigned int rm_8254_get_slotsnum(struct ring *);
+void rm_8254_set_slotsnum(struct ring *);
 
 
 extern devclass_t em_devclass;
@@ -47,6 +49,8 @@
 	.receive_enable = rm_8254_receive_enable,
 	.intr_disable = rm_8254_intr_disable,
 	.intr_enable = rm_8254_intr_enable,
+	.get_slotsnum = rm_8254_get_slotsnum,
+	.set_slotsnum = rm_8254_set_slotsnum,
 };
 
 
@@ -170,3 +174,15 @@
 
 	return (0);
 }
+
+
+unsigned int rm_8254_get_slotsnum(struct ring *ring)
+{
+	return (ring->size);	
+}
+
+
+void rm_8254_set_slotsnum(struct ring *ring)
+{
+	ring->size = SLOTS_NUMBER;
+}

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

@@ -252,7 +252,13 @@
 		err = EIO; 
 		goto out;
 	}
-	ring->size = SLOTS_NUMBER;
+	rm->funcs->set_slotsnum(ring);
+	if (ring->size == 0) {
+		RINGMAP_ERROR(Could not get the number of buffers in the ring);
+		contigfree(ring, sizeof(struct ring), M_DEVBUF);
+		err = EIO; 
+		goto out;
+	}
 
 	/* 
 	 * create the capturing object wich will represent current thread and
@@ -260,9 +266,10 @@
 	 */
 	MALLOC(co, struct capt_object *, 
 			sizeof(struct capt_object), M_DEVBUF, (M_ZERO | M_WAITOK));
-	if ( co == NULL ) {
+	if (co == NULL) {
 		contigfree(ring, sizeof(struct ring), M_DEVBUF);
-		err = EIO; goto out;
+		err = EIO; 
+		goto out;
 	}
 	co->ring = ring;
 	co->td = td;

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

@@ -19,12 +19,14 @@
  */
 #define DEFAULT_QUEUE	1
 
-/* TODO: eliminate it.  1 - enable time stamping in the driver */
+/*   1 - enable time stamping in the driver
+ * 	TODO: eliminate it.
+ */
 #define RINGMAP_TIMESTAMP 1
 
 /* 
- * TODO: should not be as macro: Max number of user threads that capture 
- * using ringmap 
+ * TODO: should not be as macro
+ * Max number of user threads that capture using ringmap 
  */
 #define RINGMAP_MAX_THREADS 8
 
@@ -34,9 +36,9 @@
  * I am looking how to eliminate it. 
  */
 struct address {
-	vm_paddr_t 	volatile phys;
-	vm_offset_t	volatile kern;
-	vm_offset_t	volatile user;
+	vm_paddr_t 	 phys;
+	vm_offset_t	 kern;
+	vm_offset_t	 user;
 };
 
 /*
@@ -93,7 +95,7 @@
 	unsigned int volatile userrp;
 
 	/* Number of slots (descriptors a.k.a memory areas for frames) */
-	unsigned int size;
+	int size;
 
 	/* Values from adapters statistic registers. Currently is not used */
 	struct address 	hw_stats;
@@ -126,7 +128,7 @@
 	unsigned long long intr_num;
 
 	/* Array of slots (A.K.A packet buffers) */
-	struct ring_slot volatile slot[SLOTS_NUMBER];
+	struct ring_slot slot[SLOTS_NUMBER];
 }; 
 
 /* For libpcap. To be set in the pcap structure */
@@ -137,13 +139,14 @@
 	struct ring *ring;
 };
 
-/* *************************************
- * IOCTL ' s  system calls             *
- * *************************************/
+
+/** 
+ ** IOCTLs
+ **/
 #define RINGMAP_IOC_MAGIC	'T'
 
 /* 
- * Should call the function that synchtonizes hardware TAIL 
+ * Should call the function that synchronizes hardware TAIL 
  * with SW_TAIL(ring)
  */
 #define IOCTL_SYNC_TAIL			_IO(RINGMAP_IOC_MAGIC, 1) 
@@ -153,7 +156,7 @@
 
 /* 
  * Disable interrupts on NIC. In some cases it is safe 
- * to disable interrupts in order to avoid kernel panics 
+ * to disable interrupts. 
  */
 #define IOCTL_DISABLE_INTR		_IO(RINGMAP_IOC_MAGIC, 3)
 
@@ -188,10 +191,10 @@
 
 
 /**********************************************
- *  	Arithmetic in Ring Buffer	
+ *  	Arithmetic in ring buffer	
  **********************************************/
 
-/* Software HEAD and TAIL ring pointers */
+/* HEAD and TAIL ring pointers */
 #define SW_TAIL(ringp)	((ringp)->userrp)
 #define SW_HEAD(ringp)  ((ringp)->kernrp)
 
@@ -208,11 +211,11 @@
 #define R_DISTANCE(a, b)					\
 	RING_DISTANCE((a), (b), (SLOTS_NUMBER))
 
-/* Distance from head to tail in ring */
+/* Distance from head to tail in the ring */
 #define SW_HEAD_TO_TAIL_DIST(ringp)				\
 	R_DISTANCE(SW_HEAD(ringp), SW_TAIL(ringp))
 
-/* Distance from tail to head in ring */
+/* Distance from tail to head in the ring */
 #define SW_TAIL_TO_HEAD_DIST(ringp)							\
 	((SW_TAIL(ringp) == SW_HEAD(ringp)) ? SLOTS_NUMBER : 	\
 	R_DISTANCE(SW_TAIL(ringp), SW_HEAD(ringp)))
@@ -221,7 +224,7 @@
 	(SW_TAIL(ringp)) = R_MODULO(SW_TAIL(ringp) + 1);
 
 #define RING_IS_EMPTY(ringp)				\
-	((SW_TAIL_TO_HEAD_DIST(ringp)) <= 1)
+	((SW_TAIL_TO_HEAD_DIST(ringp)) == 1)
 
 #define RING_NOT_EMPTY(ringp)				\
 	((SW_TAIL_TO_HEAD_DIST(ringp)) > 1)
@@ -229,6 +232,10 @@
 #define RING_IS_FULL(ringp)					\
 	((SW_HEAD_TO_TAIL_DIST(ringp)) == 0)
 
+
+/**
+ ** Access to the ring members 
+ **/
 #define RING_SLOT(ringp, i)					\
 	((ringp)->slot[(i)])
 
@@ -250,23 +257,23 @@
 #define K_PACKET(ringp, i)					\
 	RING_SLOT((ringp), (i)).packet.kern
 
-/*
- *		DEBUG OUTPUT
- */
+/**
+ **		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
 
 #ifndef __RINGMAP_DEB
-#define __RINGMAP_DEB 1
+#define __RINGMAP_DEB 0
 #elif
 #define __RINGMAP_DEB 1
 #endif

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

@@ -4,6 +4,7 @@
 struct ring;
 
 struct capt_object {
+	/* Slots number in the ring buffer */
 	struct 	ringmap *rm;
 	struct 	thread *td;
 
@@ -134,6 +135,10 @@
 
 	void (*receive_enable)(struct ringmap *rm);
 	void (*intr_enable)(struct ringmap *rm);
+
+	/* Slots number in the ring buffer */
+	void (*set_slotsnum)(struct ring *);
+	unsigned int (*get_slotsnum)(struct ring *);
 };
 
 

==== //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#36 (text+ko) ====


==== //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#37 (text+ko) ====


==== //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#31 (text+ko) ====


==== //depot/projects/soc2010/ringmap/stable_8/lib/libpcap/Makefile#2 (text+ko) ====

@@ -11,6 +11,11 @@
 	etherent.c savefile.c bpf_filter.c bpf_image.c bpf_dump.c \
 	scanner.l version.c
 
+.if defined(LIBPCAP_RINGMAP)
+CFLAGS+=-g -DRINGMAP 
+SRCS+=ringmap_pcap.c
+.endif 
+
 # Old compatibility headers
 INCS=	pcap.h pcap-int.h pcap-namedb.h pcap-bpf.h
 


More information about the p4-projects mailing list