PERFORCE change 180984 for review

Alexandre Fiveg afiveg at FreeBSD.org
Thu Jul 15 10:27:52 UTC 2010


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

Change 180984 by afiveg at cottonmouth on 2010/07/15 10:27:11

	ringmap.h now splitted out in two files: ringmap.h and ringmap_kernel.h. ringmap_kernel.h contains only the code that should be included into the code running in the kernel. ringmap.h - should included in both user-space and kernelspace code.

Affected files ...

.. //depot/projects/soc2010/ringmap/current/contrib/libpcap/pcap.c#14 edit
.. //depot/projects/soc2010/ringmap/current/contrib/libpcap/ringmap_pcap.c#19 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#30 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#30 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap_kernel.h#1 add
.. //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#14 edit
.. //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#15 edit

Differences ...

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

@@ -72,8 +72,8 @@
 #endif
 
 #ifdef RINGMAP
-#include <machine/bus.h>
 #include "../../sys/net/ringmap.h"
+#include <sys/ioccom.h>
 
 extern int init_mmapped_capturing(const char *device, pcap_t *);
 #endif 

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

@@ -6,26 +6,19 @@
 #include <strings.h>
 #include <stdlib.h>
 #include <limits.h>
-#include <kvm.h>
-#include <nlist.h>
 
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/malloc.h>
-#include <sys/bus.h>
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <sys/proc.h>
-
 #include <sys/mbuf.h>
 #include <sys/linker.h>
 #include <sys/errno.h>
-#include <sys/_bus_dma.h>
-#include <sys/_iovec.h>
+#include <sys/ioccom.h>
 
-#include <machine/bus.h>
-
 #include "pcap.h"
 #include "pcap-int.h"
 
@@ -49,15 +42,11 @@
 int
 init_mmapped_capturing(const char *device, pcap_t *p)
 {
-	struct ring_slot sl; 
 	int devmem_fd, i;
-	long num_of_bytes;
 	void *tmp_addr;
 	char dev_path[1024];
-	struct ring tmp_ring;
 	off_t memoffset = 0; 
 	vm_paddr_t ring;
-	bus_addr_t 	rspp;
 
 	RINGMAP_FUNC_DEBUG(start);
 

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

@@ -12,6 +12,7 @@
 #include <sys/systm.h>
 #include <sys/conf.h>
 #include <sys/kernel.h>
+#include <sys/ioccom.h>
 
 #include <machine/bus.h>
 #include <machine/atomic.h>
@@ -58,7 +59,6 @@
 	.d_name 	= "ringmap_cdev"
 };
 
-
 /*
  * Will called from if_em.c before returning from 
  * em_attach() function.  

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

@@ -28,7 +28,7 @@
 
 
 struct address {
-	bus_addr_t 	phys;
+	vm_paddr_t 	phys;
 	vm_offset_t	kern;
 	vm_offset_t	user;
 };
@@ -136,133 +136,6 @@
 };
 
 
-#ifdef _KERNEL
-struct ringmap_functions;
-
-struct capt_object {
-	struct thread *td;
-	struct ring *ring;
-	struct ringmap *rm;
-
-	SLIST_ENTRY(capt_object) objects;
-};
-
-
-/*
- * This structure will be visible only in the kernel. It contains 
- * the pointers to the ring that should be mapped in user-space, 
- * to the functions for accessing the ring and for accessing to the 
- * device and driver structures
- */
-struct ringmap {
-	/* Device structure of network adapter */
-	device_t dev;
-
-	/* Char device for communications between user and kernel spaces */
-	struct 	cdev 	*cdev;
-
-	/* 
-	 * Number of processes that opened cdev. 
-	 * A.K.A. number of capturing objects  
-	 */
-	uint32_t volatile open_cnt;
-	
-	/* Hardware dependent functions */
-	struct ringmap_functions *funcs;
-
-	/* Mutex that should protect the data allocated in the ring */
-	struct mtx	ringmap_mtx;
-
-	SLIST_HEAD(object_list, capt_object) object_list;
-
-	/* Counts number of hardware interrupts */
-	unsigned long long interrupts_counter;
-};
-
-struct ringmap_functions {
-
-	/* 
-	 * Set pointer to the ringmap structure into the adapters
-	 * driver structure. 
-	 */
-	int (*set_ringmap_to_adapter)(device_t, struct ringmap*);
-
-	/*
-	 * In some situations it is safe to disable 
-	 * interrupts on adapter. 
-	 */
-	void (*enable_intr)(device_t);
-	void (*disable_intr)(device_t);
-
-	/*
-	 * This function should be calld from ISR. It should contain 
-	 * the very fast executable operations (don't sleep!). 
-	 */
-	void (*isr)(void *);
-
-	/*
-	 * This function should be calld from delayed interrupt 
-	 * function. It can contain operations that must not be 
-	 * very fast.
-	 */
-	void (*delayed_isr)(void *);
-
-	/*
-	 * The native driver should have cycle for checking 
-	 * the packets that was transfered in the RAM from 
-	 * network adapter. The function delayed_isr_per_packet()
-	 * should be called from this cycle, so it will be called 
-	 * per packet.
-	 */
-	void (*delayed_isr_per_packet)(device_t, int);
-
-	/* 
-	 * Next functions synchronize the tail and head hardware registers
-	 * with head and tail software varibles which are also visible from 
-	 * user-space process. 
-	 *
-	 * Synchronisation rules:
-	 * 1. SYNC_HEAD: HARDWARE_HEAD => SOFTWARE_HEAD
-	 * 		set value from hardware HEAD register into the software visible
-	 * 		HEAD-variable: ring->kernrp.  The User-space process shouldn't
-	 * 		touch the ring->kernrp variable. Only hardware increment the value
-	 * 		in the HEAD register onto adapters chip while receiving new
-	 * 		packets, and only driver (kernel) synchronize then hardware HEAD
-	 * 		with ring->kernrp.
-	 *
-	 * 2. SYNC_TAIL: SOFTWARE_TAIL => HARDWARE_TAIL
-	 *		set value from software TAIL-variable: ring->userrp into the
-	 *		hardware TAIL-register. Hardware shouldn't change the content of
-	 *		TAIL-register.  Software after reading one packet in RAM increments
-	 *		the value of ring->userrp. Kernel will check this value and set it
-	 *		into the hardware TAIL-register.
-	 */
-	void (*sync_head_tail)(device_t);
-	void (*sync_tail)(device_t);
-	void (*sync_head)(device_t);
-
-	/* Initialize the ring slot */
-	int (*set_slot)(struct ring *, device_t, unsigned int);
-
-	struct ringmap *(*dev_to_ringmap)(device_t);
-	device_t (*cdev_to_dev)(struct cdev *);
-};
-
-/* MUTEX */
-#define	RINGMAP_LOCK_INIT(rm, _name) 	\
-	mtx_init(&(rm)->ringmap_mtx, _name, "RINGMAP Lock", MTX_DEF)
-#define	RINGMAP_LOCK_DESTROY(rm)		mtx_destroy(&(rm)->ringmap_mtx)
-#define	RINGMAP_LOCK(rm)			mtx_lock(&(rm)->ringmap_mtx)
-#define	RINGMAP_TRYLOCK(rm)		mtx_trylock(&(rm)->ringmap_mtx)
-#define	RINGMAP_UNLOCK(rm)		mtx_unlock(&(rm)->ringmap_mtx)
-
-
-#endif /* _KERNEL */
-
-
-#include <sys/ioccom.h>
-
-
 /* *************************************
  * IOCTL ' s  system calls             *
  * *************************************/
@@ -458,3 +331,9 @@
 	PRINT_TAIL(ring)				\
 	PRINT_HEAD(ring)				\
 	printf("=+= [%s] pid = %d\n", __func__, ring->pid);
+
+
+
+#ifdef _KERNEL
+#include <net/ringmap_kernel.h>
+#endif

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


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



More information about the p4-projects mailing list