PERFORCE change 179884 for review

Alexandre Fiveg afiveg at FreeBSD.org
Sat Jun 19 22:55:47 UTC 2010


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

Change 179884 by afiveg at cottonmouth on 2010/06/19 22:55:00

	Refactoring in order to make ringmap portable to other controllers: 
	- now implemented function only for 8254* controllers: e1000/ringmap_8254.c
	- begining the work in order to reach multithreading on ringmap: ring structure will now  allocated in the open(2), and deallocated in close. I think it could be possible to allocate to allocate new ring per open() syscall.

Affected files ...

.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_hw.h#5 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#6 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.h#6 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#4 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#2 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#5 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#8 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#8 edit
.. //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/tests.h#2 edit

Differences ...

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


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

@@ -81,6 +81,9 @@
 #include <dev/pci/pcireg.h>
 
 #include "e1000_api.h"
+#ifdef RINGMAP
+#include <net/ringmap.h>
+#endif
 #include "if_lem.h"
 
 /*********************************************************************
@@ -191,8 +194,13 @@
 static void	lem_initialize_transmit_unit(struct adapter *);
 static int	lem_setup_receive_structures(struct adapter *);
 static void	lem_initialize_receive_unit(struct adapter *);
+#ifndef RINGMAP
 static void	lem_enable_intr(struct adapter *);
 static void	lem_disable_intr(struct adapter *);
+#else
+void	lem_enable_intr(struct adapter *);
+void	lem_disable_intr(struct adapter *);
+#endif
 static void	lem_free_transmit_structures(struct adapter *);
 static void	lem_free_receive_structures(struct adapter *);
 static void	lem_update_stats_counters(struct adapter *);
@@ -3833,7 +3841,10 @@
 }
 #endif
 
-static void
+#ifndef RINGMAP
+static 
+#endif
+void
 lem_enable_intr(struct adapter *adapter)
 {
 	struct e1000_hw *hw = &adapter->hw;
@@ -3846,7 +3857,10 @@
 	E1000_WRITE_REG(hw, E1000_IMS, ims_mask);
 }
 
-static void
+#ifndef RINGMAP
+static 
+#endif
+void
 lem_disable_intr(struct adapter *adapter)
 {
 	struct e1000_hw *hw = &adapter->hw;

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

@@ -71,8 +71,13 @@
  */
 #define EM_MIN_RXD		80
 #define EM_MAX_RXD_82543	256
-#define EM_MAX_RXD		4096
+#ifndef RINGMAP
+#define EM_MAX_RXD		2048
 #define EM_DEFAULT_RXD	EM_MAX_RXD_82543
+#else 
+#define EM_MAX_RXD		SLOTS_NUMBER
+#define EM_DEFAULT_RXD 	SLOTS_NUMBER
+#endif
 
 /*
  * EM_TIDV - Transmit Interrupt Delay Value

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

@@ -15,17 +15,180 @@
 
 #include "e1000_api.h"
 #include "if_lem.h"
+#include "ringmap_8254.h"
 
 int rm_8254_set_ringmap_to_adapter(device_t, struct ringmap *);
+int rm_8254_init_slots(struct ring *, device_t);
 struct ringmap * rm_8254_get_ringmap_p(device_t);
 device_t rm_8254_get_device_p(struct cdev *);
+void rm_8254_enable_intr(device_t);
+void rm_8254_disable_intr(device_t);
+int rm_8254_set_slot(struct ring *, struct adapter *, unsigned int);
+void rm_8254_print_slot(struct ring *, unsigned int);
 
 
 extern devclass_t em_devclass;
+extern void	lem_enable_intr(struct adapter *);
+extern void	lem_disable_intr(struct adapter *);
+
 
 /*
+ * Get adapter structure of device and initialize the 
+ * pointers in ring (mbufs, packets, decriptors) with values 
+ * got from adapters structure.
+ * Returns 0 by success, -1 otherwise.
+ */
+int 
+rm_8254_init_slots(struct ring *ring, device_t dev)
+{
+	unsigned int slot_num;
+	struct adapter *adapter;
+
+	RINGMAP_FUNC_DEBUG(start);
+
+	adapter = (struct adapter *)device_get_softc(dev);
+
+	/* Check some pointers in the adapter structure */
+	if (adapter == NULL){
+		RINGMAP_ERROR(Adapter structure is not allocated!);
+		RINGMAP_ERROR(Probably driver is not loaded.);
+		return (-1);
+	}
+	if (adapter->rx_buffer_area == NULL){
+		RINGMAP_ERROR(mbufs array is not allocated)
+		return (-1);
+	}
+	if (adapter->rx_desc_base == NULL){
+		RINGMAP_ERROR(descriptors array is not allocated)
+		return (-1);
+	}
+	if (adapter->num_rx_desc != SLOTS_NUMBER){
+		RINGMAP_ERROR(SLOTS_NUMBER should be equal to the num_rx_desc);
+		return (-1);
+	}
+
+	for (slot_num = 0 ; slot_num < SLOTS_NUMBER ; slot_num ++){
+		if (rm_8254_set_slot(ring, adapter, slot_num) == -1){
+			RINGMAP_ERROR(Ring initialization failed!);
+			return (-1);
+		}
+	}
+
+	RINGMAP_FUNC_DEBUG(end);
+
+	return (0);
+}
+
+int
+rm_8254_set_slot(struct ring *ring, struct adapter *adapter, 
+		unsigned int slot_num)
+{
+
+#if (__RINGMAP_DEB)
+	printf("[%s] Set slot: %d\n", __func__, slot_num);
+#endif
+
+	/* First check pointers */
+	if (GET_MBUF_P(adapter, slot_num) == NULL){
+		RINGMAP_ERROR(Pointer to mbuf is NULL);
+		goto fail;
+	}
+	if (GET_PACKET_P(adapter, slot_num) == 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);
+		goto fail;
+	}
+
+	/* Now if everything is Ok, we can initialize ring pointers */
+	ring->slot[slot_num].mbuf.kern = 
+		(vm_offset_t)GET_MBUF_P(adapter, slot_num);
+	ring->slot[slot_num].mbuf.phys = 
+		(bus_addr_t)vtophys(GET_MBUF_P(adapter, slot_num));
+
+	ring->slot[slot_num].packet.kern = 
+		(vm_offset_t)GET_PACKET_P(adapter, slot_num);
+	ring->slot[slot_num].packet.phys = 
+		(bus_addr_t)vtophys(GET_PACKET_P(adapter, slot_num));
+
+	ring->slot[slot_num].descriptor.kern = 
+		(vm_offset_t)GET_DESCRIPTOR_P(adapter, slot_num);
+	ring->slot[slot_num].descriptor.phys = 
+		(bus_addr_t)vtophys(GET_DESCRIPTOR_P(adapter, slot_num));
+
+#if (__RINGMAP_DEB)
+		rm_8254_print_slot(ring, slot_num);
+#endif
+	return (0);
+
+fail:
+	RINGMAP_ERROR(Probably you have to do: ifconfig up);
+	return (-1);
+}
+
+void
+rm_8254_print_slot(struct ring *ring, unsigned int slot_number)
+{
+	printf("\n[%s] Slot Number: %d\n", __func__,  slot_number);
+	printf("---------------- \n");
+
+	printf("physical addr of descriptor[%d] = 0x%X\n", slot_number, 
+			(unsigned int) ring->slot[slot_number].descriptor.phys);
+
+	printf("kernel addr of descriptor[%d] = 0x%X\n", slot_number, 
+			(unsigned int) ring->slot[slot_number].descriptor.kern);
+
+	printf("physical addr of mbuf[%d] = 0x%X\n", slot_number, 
+			(unsigned int) ring->slot[slot_number].mbuf.phys);
+
+	printf("kernel addr of mbuf[%d] = 0x%X\n", slot_number, 
+			(unsigned int) ring->slot[slot_number].mbuf.kern);
+
+	printf("physical addr of packet_buffer[%d] = 0x%X\n", slot_number, 
+			(unsigned int) ring->slot[slot_number].packet.phys);
+
+	printf("kernel addr of packet_buffer[%d] = 0x%X\n", slot_number, 
+			(unsigned int) ring->slot[slot_number].packet.kern);
+
+	printf("---------------- \n");
+}
+
+
+/*
+ * Disable interrupts on adapter 
+ */
+void 
+rm_8254_disable_intr(device_t dev)
+{
+	
+	struct adapter *adapter;
+	adapter = (struct adapter *)device_get_softc(dev);
+
+	/*Use function implemeted in native (em) driver */
+	lem_disable_intr(adapter);
+}
+
+
+/*
+ * Enable interrupts on adapter 
+ */
+void 
+rm_8254_enable_intr(device_t dev)
+{
+	
+	struct adapter *adapter;
+	adapter = (struct adapter *)device_get_softc(dev);
+
+	/*Use function implemeted in native (em) driver */
+	lem_enable_intr(adapter);
+}
+
+
+/*
  * Get pointer to device structure of adapter using our ringmap char device. 
- * This is a trick :) Our cdev must have the same unit number as dev of adapter.
+ * This is a trick. Our cdev must have the same unit number as dev of adapter.
  * Look in ringmap.c: ringmap_attach() where we create our cdev. 
  */
 device_t 

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

@@ -1,0 +1,17 @@
+#define DESC_AREA(adapter)	(adapter)->rx_desc_base
+#define MBUF_AREA(adapter)	(adapter)->rx_buffer_area
+
+/* Kernel address of mbuf wich placed in the slot "i" */
+#define GET_MBUF_P(adapter, i)		\
+	(MBUF_AREA(adapter)[(i)].m_head)
+
+
+/* Kernel address of the packet wich placed in the slot "i" */
+#define GET_PACKET_P(adapter, i)		\
+	(MBUF_AREA(adapter)[(i)].m_head->m_data)
+
+
+/* Kernel address of the descriptor wich placed in the slot "i" */
+#define GET_DESCRIPTOR_P(adapter, i)	\
+	(&(DESC_AREA(adapter)[(i)]))
+

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


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

@@ -41,16 +41,19 @@
 
 int ringmap_attach (device_t);
 int ringmap_detach (device_t);
-int is_supported (unsigned int pci_dev_id);
-int set_ringmap_funcs (struct ringmap *rm, unsigned int controller_type);
+int is_supported (unsigned int);
+int set_ringmap_funcs (struct ringmap *, unsigned int);
 void ringmap_close_cb (void *data);
 
 struct ringmap *(*get_ringmap_p)(device_t);
 device_t 		(*get_device_p)(struct cdev *);
 
 extern int rm_8254_set_ringmap_to_adapter(device_t, struct ringmap *);
+extern int rm_8254_init_slots(struct ring *, device_t);
 extern struct ringmap * rm_8254_get_ringmap_p(device_t);
 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);
 
 //struct adapter* get_adapter_struct(struct cdev *dev);
 //int ringmap_print_ring_pointers(struct adapter *);
@@ -125,6 +128,10 @@
 			/* 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;
+
 			get_ringmap_p = rm_8254_get_ringmap_p;
 			get_device_p  =	rm_8254_get_device_p;
 		break;
@@ -149,8 +156,7 @@
 ringmap_attach(device_t dev) 
 {	
 	struct ringmap *rm;
-	struct ring *ring;
-	struct ringmap_functions *ringmap_functions;
+	struct ringmap_functions *funcs;
 	unsigned int pci_dev_id = 0;
 	unsigned int controller_type = 0;
 
@@ -163,11 +169,6 @@
 	if (!(controller_type))
 		return (-1);
 
-	/* 
-	 * Allocate memory for ringmap structures: ringmap and ring. 
-	 * Use contigmalloc(9) to get PAGE_SIZE alignment that is needed 
-	 * for memory mapping.  
-	 */
 	rm = (struct ringmap *) contigmalloc (sizeof(struct ringmap), 
 			M_DEVBUF, M_ZERO, 0, -1L, PAGE_SIZE, 0);
 
@@ -176,23 +177,19 @@
 		return (-1); 
 	}
 
-	ring = (struct ring *) contigmalloc (sizeof(struct ring), 
-			M_DEVBUF, M_ZERO, 0, -1L, PAGE_SIZE, 0);
-	if (ring == NULL) { 
-		RINGMAP_ERROR(Can not allocate space for ring structure); 
-		return (-1); 
-	}
 
-	ringmap_functions = 
-		(struct ringmap_functions *) contigmalloc (sizeof (struct ringmap_functions),
-				M_DEVBUF, M_ZERO, 0, -1L, PAGE_SIZE, 0);
-	if (ringmap_functions == NULL) { 
+	funcs = (struct ringmap_functions *) contigmalloc 
+			(
+				sizeof (struct ringmap_functions),
+				M_DEVBUF, M_ZERO, 0, -1L, PAGE_SIZE, 0
+			);
+	if (funcs == NULL) { 
 		RINGMAP_ERROR(Can not allocate space for ringmap_functions structure); 
 		return (-1); 
 	}
-
-	rm->ring 	= ring;
-	rm->funcs 	= ringmap_functions;
+	rm->funcs 	= funcs;
+	/* Set functions for ringmap functionality depending on controller type */
+	set_ringmap_funcs(rm, controller_type);
 
 	/* 
 	 * Create char device for communication with user space. User space process
@@ -204,17 +201,16 @@
 	 * -	controll packet capturing: start, stop, sleep to wait for packets.
 	 */
 	rm->cdev = make_dev(&ringmap_devsw, device_get_unit(dev),
-						UID_ROOT, GID_WHEEL, 0666, RINGMAP_DEVICE);
+						UID_ROOT, GID_WHEEL, 0666, 
+						RINGMAP_DEVICE"%d", device_get_unit(dev));
 
-	/* Device open counter */
-	rm->open_cnt = 1;
+	/* Device open counter. Should count how many times the char device was
+	 * opened */
+	rm->open_cnt = 0;
 
-	/* Pointer to structure of process wich has opened the device */	
-	rm->td = NULL;
+	/* Store adapters device structure */
+	rm->dev = dev;
 
-	/* Set functions for ringmap functionality depending on controller type */
-	set_ringmap_funcs(rm, controller_type);
-
 	/* set the pointer to ringmap in the adapters structure */
 	rm->funcs->set_ringmap_to_adapter(dev, rm);
 
@@ -239,7 +235,6 @@
 
 	destroy_dev(rm->cdev);
 
-	contigfree(rm->ring, sizeof(struct ring), M_DEVBUF);
 	contigfree(rm->funcs, sizeof(struct ringmap_functions), M_DEVBUF);
 	contigfree(rm, sizeof(struct ringmap), M_DEVBUF);
 	
@@ -258,10 +253,8 @@
 int
 ringmap_open(struct cdev *cdev, int flag, int otyp, struct thread *td)
 {
-//	unsigned int i; 
-//	struct ring_slot; 
-//	struct adapter *adapter = (struct adapter *)get_adapter_struct(dev);
 	struct ringmap *rm = NULL;
+	struct ring *ring = NULL;
 
 	RINGMAP_FUNC_DEBUG(start);
 
@@ -270,60 +263,69 @@
 			__func__, dev2udev(cdev), flag, otyp);
 #endif
 
-	/* Now magic */
+	/* a little magic */
 	rm = get_ringmap_p(get_device_p(cdev));
-	printf("[%s] open counter: %d\n", __func__, rm->open_cnt);
+	if (rm == NULL) {
+		RINGMAP_ERROR(Null pointer to ringmap structure);
+		return (ENODEV);
+	}
+	
+	/**
+	 **	Currently only one process only one time can open our device !!!
+	 **/
+	if (!atomic_cmpset_int(&rm->open_cnt, 0, 1)){
+		RINGMAP_ERROR(Sorry! Can not open device more then one time!);
+		contigfree(rm->ring, sizeof(struct ring), M_DEVBUF);
+		atomic_readandclear_int(&rm->open_cnt);
+		return (ENODEV);
+	}
+
+	if (rm->dev == NULL) {
+		RINGMAP_ERROR(Null pointer to device structure of adapter);
+		atomic_readandclear_int(&rm->open_cnt);
+		return (ENODEV);
+	}
+
+	/* 
+	 * Allocate memory for ring structure 
+	 * Use contigmalloc(9) to get PAGE_SIZE alignment that is needed 
+	 * for memory mapping.  
+	 */
+	ring = (struct ring *) contigmalloc (sizeof(struct ring), 
+			M_DEVBUF, M_ZERO, 0, -1L, PAGE_SIZE, 0);
+	if (ring == NULL) { 
+		RINGMAP_ERROR(Can not allocate space for ring structure); 
+		atomic_readandclear_int(&rm->open_cnt);
+		return (ENODEV); 
+	}
+	rm->ring 	= ring;
+
+
+	/* Store pointer to the thread */
+	rm->ring->td = td;
+
+	/* Disable interrupts of adapter */
+	rm->funcs->disable_intr(rm->dev);
+
+	/* Prepare ring for caputure  */
+	rm->ring->kern_wait_user = 0;	
+    rm->ring->user_wait_kern = 0;	
+    rm->ring->interrupts_counter = 0;	
+	rm->ring->size = SLOTS_NUMBER;		
+
+	if (rm->funcs->init_slots(rm->ring, rm->dev) == -1){
+		RINGMAP_ERROR(Can not initialize ring slots. Device is not opened!);
+		contigfree(rm->ring, sizeof(struct ring), M_DEVBUF);
+		atomic_readandclear_int(&rm->open_cnt);
+		return (ENODEV);
+	}	
 
-//
-//	/**
-//	 **	Only one process only one time can open our device !!!
-//	 **/
-//	if (!atomic_cmpset_int(&rm->open_cnt, 0, 1)){
-//		RINGMAP_ERROR(Sorry! Device is opened!);
-//		return (ENODEV);
-//	}
-//	
-//	/* Disable interrupts of adapter */
-//	RINGMAP_HW_DISABLE_INTR(adapter);
-//
-//	/* Disable Flow Control */
-//	RINGMAP_HW_DISABLE_FLOWCONTR(adapter);
-//
-//	/*
-//	 * Prepare ring for caputure 
-//	 */
-//    rm->procp = (struct proc *)td->td_proc;
-//	rm->td = td;
-//	RINGMAP_INIT(rm->ring, adapter);
-//
-//	for (i = 0 ; i < SLOTS_NUMBER ; i ++) {
-//		if (MBUF_AREA(rm->adapter)[i].m_head == NULL) {
-//			printf(ERR_PREFIX"[%s] mbuf for descriptor=%d is not allocated\n", __func__, i);
-//			printf(ERR_PREFIX"[%s] The reason may be: ifnet structure for our network device not present or not initialized\n", __func__);
-//			return (EFAULT);
-//		}
-//
-//		DESC_AREA(rm->adapter)[i].status = 0;
-//
-//		rm->ring->slot[i].mbuf.kern = (vm_offset_t) RINGMAP_GET_MBUF_P(rm->adapter, i);
-//		rm->ring->slot[i].mbuf.phys = (bus_addr_t) vtophys(RINGMAP_GET_MBUF_P(rm->adapter, i));
-//
-//		rm->ring->slot[i].packet.kern = (vm_offset_t) RINGMAP_GET_PACKET_P(rm->adapter, i);
-//		rm->ring->slot[i].packet.phys = (bus_addr_t)	vtophys(RINGMAP_GET_PACKET_P(rm->adapter, i));
-//
-//		rm->ring->slot[i].descriptor.kern = (vm_offset_t) RINGMAP_GET_DESCRIPTOR_P(rm->adapter, i);
-//		rm->ring->slot[i].descriptor.phys = (bus_addr_t)	vtophys(RINGMAP_GET_DESCRIPTOR_P(rm->adapter, i));
-//
-//#if (__RINGMAP_DEB)
-//		ringmap_print_slot(adapter, i);
-//#endif
-//	}
 //	rm->ring->hw_stats.kern = (vm_offset_t)(&adapter->stats);
 //	rm->ring->hw_stats.phys = (bus_addr_t)vtophys(&adapter->stats);
-//
-//
-//	RINGMAP_HW_ENABLE_INTR(adapter);
-//
+
+	rm->funcs->enable_intr(rm->dev); 
+
+
 	RINGMAP_FUNC_DEBUG(end);
 
 	return (0);
@@ -331,26 +333,30 @@
 
 
 int
-ringmap_close(struct cdev *dev, int flag, int otyp, struct thread *td)
+ringmap_close(struct cdev *cdev, int flag, int otyp, struct thread *td)
 {
-//	struct adapter *adapter = (struct adapter *)get_adapter_struct(dev);
-//	struct ringmap *rm = adapter->rm;
-//
+	struct ringmap *rm = NULL;
+
 	RINGMAP_FUNC_DEBUG(start);
-//	
-//	/* Disable interrupts while we set our structures */
-//	RINGMAP_HW_DISABLE_INTR(adapter);
-//
-//#if (__RINGMAP_DEB) 
-//	printf("[%s]: dev_t=%d, flag=%x, otyp=%x, iface=%s\n", __func__,
-//	      dev2udev(dev), flag, otyp, device_get_nameunit(adapter->dev));
-//#endif 
-//
-//	/* After close there is no capturing process */
-//	rm->procp = NULL;
-//	rm->td = NULL;
-//
-//	atomic_readandclear_int(&rm->open_cnt); 
+
+	rm = get_ringmap_p(get_device_p(cdev));
+	if (rm == NULL){
+		RINGMAP_ERROR(Can not get pointer to ringmap structure);
+
+		/* TODO: Fix it! */
+		return (0);
+	}
+
+	/* Disable interrupts of adapter */
+	rm->funcs->disable_intr(rm->dev);
+
+	if (rm->ring != NULL){
+		contigfree(rm->ring, sizeof(struct ring), M_DEVBUF);
+	} else {
+		RINGMAP_ERROR(The pointer to ring structure is NULL);
+	}
+
+	atomic_readandclear_int(&rm->open_cnt); 
 
 	RINGMAP_FUNC_DEBUG(end);
     return (0);

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

@@ -1,4 +1,3 @@
-
 /* Minimum distance to be kept between the userrp and RDT to provide a
  * guarantee  to userspace processes that the previous n buffer positions
  * behind userrp will  not be overwritten */
@@ -64,13 +63,13 @@
 	 * kernrp - ring HEAD. Should be changed ONLY in driver. And should be
 	 * synchronized with the hardware ring HEAD register (RDH).
 	 */
-	unsigned int kernrp;
+	unsigned int volatile kernrp;
 
 	/* 
 	 * userrp - ring TAIL. Should be incremented by user space software after
 	 * reading the slots with a new received packets
 	 */
-	unsigned int userrp;
+	unsigned int volatile userrp;
 
 	/* This variable represents the value of Hardware TAIL register */
 	unsigned int hw_RDT;
@@ -78,10 +77,12 @@
 	/* Number of slots (descriptors a.k.a memory areas for frames) */
 	unsigned int size;
 
-
 	/* Values from adapters statistic registers */
 	struct address 	hw_stats;
 
+	/* Capturing thread */
+	struct 	thread 	*td;
+
 	/* 
 	 * Number of times kernel (hardware) waits for user process. More
 	 * specifically, this is the number of times that the write pointer (RDT)
@@ -116,16 +117,13 @@
 
 struct ringmap {
 	/* Device structure of network adapters */
-	device_t devt;
+	device_t dev;
 
 	/* Char device for communications between user and kernel spaces */
 	struct 	cdev 	*cdev;
 
-	/* Capturing thread */
-	struct 	thread 	*td;
-
 	/* Now only one process can only one time open device */
-	uint32_t	open_cnt;
+	uint32_t volatile open_cnt;
 	
 	/* How many packets have counted driver in RAM */
 	unsigned long long 	pkts_counter;
@@ -139,7 +137,11 @@
 
 struct ringmap_functions {
 	int (*set_ringmap_to_adapter)(device_t, struct ringmap*);
+	void (*enable_intr)(device_t);
+	void (*disable_intr)(device_t);
+	int (*init_slots)(struct ring *, device_t);
 };
+
 #endif /* _KERNEL */
 
 

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

@@ -1,4 +1,4 @@
-#define CDEV "/dev/ringmap_cdev"
+#define CDEV "/dev/ringmap_cdev1"
 
 
 int rm_open(void);


More information about the p4-projects mailing list