From owner-p4-projects@FreeBSD.ORG Mon Jun 21 21:37:51 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1112A106566C; Mon, 21 Jun 2010 21:37:51 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C99A3106566B for ; Mon, 21 Jun 2010 21:37:50 +0000 (UTC) (envelope-from afiveg@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id AE6C98FC1B for ; Mon, 21 Jun 2010 21:37:50 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o5LLboZS088486 for ; Mon, 21 Jun 2010 21:37:50 GMT (envelope-from afiveg@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o5LLboGR088484 for perforce@freebsd.org; Mon, 21 Jun 2010 21:37:50 GMT (envelope-from afiveg@FreeBSD.org) Date: Mon, 21 Jun 2010 21:37:50 GMT Message-Id: <201006212137.o5LLboGR088484@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to afiveg@FreeBSD.org using -f From: Alexandre Fiveg To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 180051 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2010 21:37:51 -0000 http://p4web.freebsd.org/@@180051?ac=10 Change 180051 by afiveg@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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + + + +#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 #include +#include #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);