Date: Mon, 21 Jun 2010 18:13:57 GMT From: Alexandre Fiveg <afiveg@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 180043 for review Message-ID: <201006211813.o5LIDvIJ059742@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@180043?ac=10 Change 180043 by afiveg@cottonmouth on 2010/06/21 18:13:17 Port ringmap to current "em". Begin to work with interrupt functions. New functions pointer: ringmap->(*interrupt)(). Must be initialized in set_ringmap_funcs(). The hardware dependent interrupt function for 8254-cotroller is rm_8254_ringmap, will called from lem_handle_rxtx(). Affected files ... .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#7 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#5 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#6 edit .. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#9 edit .. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#9 edit Differences ... ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#7 (text+ko) ==== @@ -1381,15 +1381,17 @@ struct adapter *adapter = context; struct ifnet *ifp = adapter->ifp; - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { if (lem_rxeof(adapter, adapter->rx_process_limit) != 0) taskqueue_enqueue(adapter->tq, &adapter->rxtx_task); + +#if (RINGMAP_TX_ENABLE) EM_TX_LOCK(adapter); lem_txeof(adapter); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) lem_start_locked(ifp); EM_TX_UNLOCK(adapter); +#endif } lem_enable_intr(adapter); @@ -1431,6 +1433,16 @@ * MSI message reordering errata on certain systems. */ lem_disable_intr(adapter); + +#ifdef RINGMAP + if ((adapter->rm != NULL) && /* ringmap structure should be allocated */ + (adapter->rm->ring != NULL) && + (adapter->rm->ring->td != NULL)) + { + adapter->rm->funcs->interrupt(arg); + } +#endif + taskqueue_enqueue(adapter->tq, &adapter->rxtx_task); /* Link status change */ ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#5 (text+ko) ==== @@ -25,13 +25,28 @@ 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); - +void rm_8254_interrupt(void *); +int rm_8254_print_ring_pointers(struct adapter *); extern devclass_t em_devclass; extern void lem_enable_intr(struct adapter *); extern void lem_disable_intr(struct adapter *); + +void +rm_8254_interrupt(void *arg) +{ + struct adapter *adapter = (struct adapter *) arg; + /* count interrupts */ + adapter->rm->ring->interrupts_counter++; + +#if (RINGMAP_INTR_DEB) + rm_8254_print_ring_pointers(adapter); +#endif +} + + /* * Get adapter structure of device and initialize the * pointers in ring (mbufs, packets, decriptors) with values @@ -66,7 +81,14 @@ RINGMAP_ERROR(SLOTS_NUMBER should be equal to the num_rx_desc); return (-1); } + + /* Set ring fields in the initial state */ + ring->kern_wait_user = 0; + ring->user_wait_kern = 0; + ring->interrupts_counter = 0; + ring->size = SLOTS_NUMBER; + /* Set ring pointers */ 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!); @@ -232,3 +254,24 @@ adapter = (struct adapter *)device_get_softc(dev); return (adapter->rm); } + + +int +rm_8254_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(" + HW HEAD = %d (KERN POINTER)\n", rdh); + printf(" + HW TAIL = %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/dev/e1000/ringmap_8254.h#3 (text+ko) ==== @@ -15,3 +15,13 @@ #define GET_DESCRIPTOR_P(adapter, i) \ (&(DESC_AREA(adapter)[(i)])) + +/* Registers access */ +#define RINGMAP_HW_READ_REG E1000_READ_REG + +#define RINGMAP_HW_READ_HEAD(adapter) \ + RINGMAP_HW_READ_REG(&adapter->hw, E1000_RDH(0)) + +#define RINGMAP_HW_READ_TAIL(adapter) \ + RINGMAP_HW_READ_REG(&adapter->hw, E1000_RDT(0)) + ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#6 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#9 (text+ko) ==== @@ -54,6 +54,7 @@ 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); +extern void rm_8254_interrupt(struct ringmap *); //struct adapter* get_adapter_struct(struct cdev *dev); //int ringmap_print_ring_pointers(struct adapter *); @@ -131,6 +132,7 @@ rm->funcs->enable_intr = rm_8254_enable_intr; rm->funcs->disable_intr = rm_8254_disable_intr; rm->funcs->init_slots = rm_8254_init_slots; + rm->funcs->interrupt = rm_8254_interrupt; get_ringmap_p = rm_8254_get_ringmap_p; get_device_p = rm_8254_get_device_p; @@ -245,14 +247,15 @@ /****************************************************************** - * Open device and get the pointer of user process structure!!! + * Open device and get the pointer of user process structure. * We will use the address space of this process to map there - * the mbufs and buffers with packet data. So it all will - * be placed and accesseble in this user proccess. + * the mbufs and buffers with packets data. So it all will + * be accesseble in this user proccess. ******************************************************************/ int ringmap_open(struct cdev *cdev, int flag, int otyp, struct thread *td) { + int err = 0; struct ringmap *rm = NULL; struct ring *ring = NULL; @@ -275,15 +278,14 @@ **/ 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); + err = ENODEV; + goto end; } - if (rm->dev == NULL) { + if (rm->dev == NULL){ RINGMAP_ERROR(Null pointer to device structure of adapter); - atomic_readandclear_int(&rm->open_cnt); - return (ENODEV); + err = ENODEV; + goto end; } /* @@ -295,40 +297,33 @@ 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); + err = ENODEV; + goto end; } 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!); + if (rm->funcs->init_slots(rm->ring, rm->dev) == -1){ + RINGMAP_ERROR(The ring is not initialized. Device will not be opened!); contigfree(rm->ring, sizeof(struct ring), M_DEVBUF); - atomic_readandclear_int(&rm->open_cnt); - return (ENODEV); + err = ENODEV; } -// rm->ring->hw_stats.kern = (vm_offset_t)(&adapter->stats); -// rm->ring->hw_stats.phys = (bus_addr_t)vtophys(&adapter->stats); + rm->funcs->enable_intr(rm->dev); - rm->funcs->enable_intr(rm->dev); +end: + atomic_readandclear_int(&rm->open_cnt); RINGMAP_FUNC_DEBUG(end); - return (0); + return (err); + } @@ -352,6 +347,7 @@ if (rm->ring != NULL){ contigfree(rm->ring, sizeof(struct ring), M_DEVBUF); + rm->ring = NULL; } else { RINGMAP_ERROR(The pointer to ring structure is NULL); } @@ -363,7 +359,8 @@ } int -ringmap_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr) +ringmap_mmap(struct cdev *dev, 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; ==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#9 (text+ko) ==== @@ -24,6 +24,9 @@ */ #define DEV_ID 0 +/* Enable/Disable Transiv */ +#define RINGMAP_TX_ENABLE 0 + struct address { bus_addr_t phys; @@ -140,6 +143,7 @@ void (*enable_intr)(device_t); void (*disable_intr)(device_t); int (*init_slots)(struct ring *, device_t); + void (*interrupt)(struct ringmap*); }; #endif /* _KERNEL */ @@ -242,10 +246,10 @@ #define IOCTL_DEB 1 #endif -#ifndef INTR_DEB -#define INTR_DEB 0 +#ifndef RINGMAP_INTR_DEB +#define RINGMAP_INTR_DEB 1 #else -#define INTR_DEB 1 +#define RINGMAP_INTR_DEB 1 #endif #ifndef __RINGMAP_DEB
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006211813.o5LIDvIJ059742>