PERFORCE change 180051 for review

Alexandre Fiveg afiveg at FreeBSD.org
Mon Jun 21 21:37:51 UTC 2010


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

Change 180051 by afiveg at cottonmouth on 2010/06/21 21:36:51

	Porting ringmap to current "em". Interruots and mmory mapping work correctly.

Affected files ...

.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#8 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#6 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#4 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#10 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#10 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/ioctl.c#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/main.c#2 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/mmap.c#2 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/open.c#2 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/test#2 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/tests.h#3 edit

Differences ...

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

@@ -3567,11 +3567,14 @@
 		}
 
 		if (accept_frame) {
+
+#ifndef RINGMAP
+		/* Do not allocate memory for new mbufs and packets. Work in ring */
 			if (lem_get_buf(adapter, i) != 0) {
 				ifp->if_iqdrops++;
 				goto discard;
 			}
-
+#endif
 			/* Assign correct length to the current fragment */
 			mp->m_len = len;
 
@@ -3629,7 +3632,9 @@
 			}
 		} else {
 			ifp->if_ierrors++;
+#ifndef RINGMAP
 discard:
+#endif
 			/* Reuse loaded DMA map and just update mbuf chain */
 			mp = adapter->rx_buffer_area[i].m_head;
 			mp->m_len = mp->m_pkthdr.len = MCLBYTES;
@@ -3657,9 +3662,13 @@
 		/* Call into the stack */
 		if (m != NULL) {
 			adapter->next_rx_desc_to_check = i;
+
+#ifndef RINGMAP
+/* Do not send packet to the IP-stack */
 			EM_RX_UNLOCK(adapter);
 			(*ifp->if_input)(ifp, m);
 			EM_RX_LOCK(adapter);
+#endif 
 			rx_sent++;
 			i = adapter->next_rx_desc_to_check;
 		}
@@ -3670,7 +3679,12 @@
 	/* Advance the E1000's Receive Queue #0  "Tail Pointer". */
 	if (--i < 0)
 		i = adapter->num_rx_desc - 1;
+
+#ifndef RINGMAP
+	/* Tail pointer will be with userrp synchronized */
 	E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), i);
+#endif 
+
 	EM_RX_UNLOCK(adapter);
 	return (rx_sent);
 }

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


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


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

@@ -355,26 +355,35 @@
 	atomic_readandclear_int(&rm->open_cnt); 
 
 	RINGMAP_FUNC_DEBUG(end);
+
     return (0);
 }
 
+
 int
-ringmap_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, 
+ringmap_mmap(struct cdev *cdev, vm_ooffset_t offset, vm_paddr_t *paddr, 
 				int nprot, vm_memattr_t *memattr)
 {
-//	struct adapter *adapter = (struct adapter *)get_adapter_struct(dev);
-//	struct ringmap *rm = adapter->rm;
-//
+	struct ringmap *rm = NULL;
+
 	RINGMAP_FUNC_DEBUG(start);
-//
-//	if (nprot & PROT_EXEC) {
-//		RINGMAP_WARN("PROT_EXEC ist set");
-//		return (ERESTART);
-//	}
-//
-//	/* We want to map ring in user-space. offset is not needed! */
-//	offset = 0;
-//	*paddr = vtophys((rm->ring) + offset);
+	
+	rm = get_ringmap_p(get_device_p(cdev));
+
+	if (rm == NULL){
+		RINGMAP_ERROR(Can not get pointer to ringmap structure);
+		return (ENXIO);
+	}
+	if (rm->ring == NULL){
+		RINGMAP_ERROR(Can not get pointer to ring structure);
+		return (ENXIO);
+	}
+	if (nprot & PROT_EXEC) {
+		RINGMAP_WARN("PROT_EXEC ist set");
+		return (ERESTART);
+	}
+
+	*paddr = vtophys(rm->ring);
 
 	RINGMAP_FUNC_DEBUG(end);
 
@@ -576,27 +585,3 @@
 //			(unsigned int) rm->ring->slot[slot_number].packet.kern);
 //	printf(" \n");
 //}
-//
-//
-//int 
-//ringmap_print_ring_pointers(struct adapter *adapter)
-//{
-//	unsigned int rdt, rdh;
-//	struct ringmap *rm = adapter->rm;
-//
-//	rdh = RINGMAP_HW_READ_HEAD(adapter);
-//	rdt = RINGMAP_HW_READ_TAIL(adapter);
-//
-//	printf("\n  +++++++++  RING POINTERS  ++++++++++++ \n");
-//	printf("  +  RDH = %d (KERN POINTER)\n", rdh);
-//	printf("  +  RDT = %d (USER POINTER)\n", rdt);
-//	printf("  +\n");
-//	printf("  +  kernrp = %d \n", rm->ring->kernrp);
-//	printf("  +  userrp = %d \n", rm->ring->userrp);
-//	printf("  ++++++++++++++++++++++++++++++++++++++ \n\n");
-//
-//	return (0);
-//}
-
-
-

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


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

@@ -4,8 +4,9 @@
 
 int main ()
 {
-	// rm_mmap();
-	rm_close(rm_open());
+	int fd = rm_open();
+	rm_mmap(fd);
+	rm_close(fd);
 
 	return (0);
 }

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

@@ -1,0 +1,51 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <string.h>
+#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 <machine/bus.h>
+
+
+
+#include "ringmap.h"
+
+int 
+rm_mmap(int fd)
+{
+	void *addr;
+	struct ring *r;
+
+	addr = mmap(0, sizeof(struct ring), 
+			PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0);	
+	if (addr == MAP_FAILED){
+		printf("mapping failed \n");
+		return (-1);
+	}
+
+	r = (struct ring *)addr;
+
+	printf("Size of ring = %d \n", r->size);
+
+	return (0);
+}

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

@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <fcntl.h>
+#include <unistd.h>
 #include "tests.h"
 
 /*
@@ -14,5 +15,6 @@
 	if (fd < 0)
 		perror("Error while opening device! ");
 
+	// sleep(20);
 	return (fd);
 }

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

@@ -1,8 +1,10 @@
-ELF	---¶ƒÀ„Òt€ú/uñ£–¶ƒÀ„Òuì¸,–…Àt4‹E‰$èNÿÿÿÇ$L…èBÿÿÿèÙþÿÿ‰|$‰\$‰4$è™--ƒƒ*ƒ:ƒJƒZƒ--\ No newline at end of file
+ELF	+++¶ƒÀ„Òt€ú/uñ£t—¶ƒÀ„Òu츄—…Àt4‹E‰$èVÿÿÿÇ$|†èJÿÿÿè±þÿÿ‰|$‰\$‰4$è™+‡è­ýÿÿ‹EüÉАU‰åSƒì¡4˜ƒøÿt1ÛÿЋƒ0˜ƒëƒøÿuðƒÄ[]Аƒìè<þÿÿƒÄÃ+++++\ No newline at end of file

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

@@ -3,4 +3,4 @@
 
 int rm_open(void);
 int rm_close(int);
-int rm_mmap(void);
+int rm_mmap(int);


More information about the p4-projects mailing list