Date: Wed, 16 Jun 2010 12:08:15 GMT From: Alexandre Fiveg <afiveg@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 179676 for review Message-ID: <201006161208.o5GC8FbH096401@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@179676?ac=10 Change 179676 by afiveg@cottonmouth on 2010/06/16 12:08:08 Working on new ringmap design. Still refactoring and adapting to current "em" add new files ringmap_8254.[ch]. These should contain the code for accessing registers of 8254* controller and accessing of structures of conventional "em" driver: now if_lem Submitted by: Alexander Fiveg Affected files ... .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/LICENSE#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/README#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_80003es2lan.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_80003es2lan.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82540.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82541.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82541.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82542.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82543.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82543.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82571.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82571.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82575.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82575.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_api.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_api.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_defines.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_hw.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_ich8lan.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_ich8lan.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_mac.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_mac.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_manage.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_manage.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_nvm.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_nvm.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_osdep.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_osdep.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_phy.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_phy.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_regs.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_em.c#6 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_em.h#5 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_igb.c#5 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_igb.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#1 add .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.h#1 add .. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#3 edit .. //depot/projects/soc2010/ringmap/current/sys/modules/em/Makefile#9 edit .. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#5 edit .. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#5 edit Differences ... ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/LICENSE#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/README#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_80003es2lan.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_80003es2lan.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82540.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82541.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82541.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82542.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82543.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82543.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82571.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82571.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82575.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_82575.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_api.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_api.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_defines.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_hw.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_ich8lan.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_ich8lan.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_mac.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_mac.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_manage.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_manage.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_nvm.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_nvm.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_osdep.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_osdep.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_phy.c#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_phy.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/e1000_regs.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_em.c#6 (text+ko) ==== @@ -85,6 +85,13 @@ #include "e1000_82571.h" #include "if_em.h" +#ifdef RINGMAP +#include <net/ringmap.h> + +extern int ringmap_attach (struct ringmap **); +extern int ringmap_detach (struct ringmap *); +#endif + /********************************************************************* * Set this to one to display debug statistics *********************************************************************/ ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_em.h#5 (text+ko) ==== @@ -209,7 +209,7 @@ #define EM_MSIX_BAR 3 /* On 82575 */ /* Defines for printing debug information */ -#define DEBUG_INIT 0 +#define DEBUG_INIT 1 #define DEBUG_IOCTL 0 #define DEBUG_HW 0 @@ -411,6 +411,10 @@ unsigned long watchdog_events; unsigned long link_irq; +#ifdef RINGMAP + struct ringmap *rm; +#endif + struct e1000_hw_stats stats; }; ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_igb.c#5 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_igb.h#3 (text+ko) ==== ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#3 (text+ko) ==== @@ -262,6 +262,14 @@ const char *, int *, int); #endif /* ~EM_LEGACY_IRQ */ + +#ifdef RINGMAP +#include <net/ringmap.h> + +extern int ringmap_attach (struct ringmap **, device_t); +extern int ringmap_detach (struct ringmap *); +#endif + #ifdef DEVICE_POLLING static poll_handler_t lem_poll; #endif /* POLLING */ @@ -282,13 +290,23 @@ }; static driver_t lem_driver = { +#ifndef RINGMAP "em", lem_methods, sizeof(struct adapter), +#else + "ringmap", lem_methods, sizeof(struct adapter), +#endif }; extern devclass_t em_devclass; +#ifndef RINGMAP DRIVER_MODULE(lem, pci, lem_driver, em_devclass, 0, 0); MODULE_DEPEND(lem, pci, 1, 1, 1); MODULE_DEPEND(lem, ether, 1, 1, 1); +#else +DRIVER_MODULE(ringmap, pci, lem_driver, em_devclass, 0, 0); +MODULE_DEPEND(ringmap, pci, 1, 1, 1); +MODULE_DEPEND(ringmap, ether, 1, 1, 1); +#endif /********************************************************************* * Tunable default values. @@ -357,7 +375,7 @@ u16 pci_subdevice_id = 0; em_vendor_info_t *ent; - INIT_DEBUGOUT("em_probe: begin"); + INIT_DEBUGOUT("lem_probe: begin"); pci_vendor_id = pci_get_vendor(dev); if (pci_vendor_id != EM_VENDOR_ID) @@ -658,6 +676,10 @@ adapter->led_dev = led_create(lem_led_func, adapter, device_get_nameunit(dev)); +#ifdef RINGMAP + ringmap_attach (dev); +#endif + INIT_DEBUGOUT("lem_attach: end"); return (0); @@ -698,6 +720,10 @@ INIT_DEBUGOUT("em_detach: begin"); +#ifdef RINGMAP + ringmap_detach (adapter->rm); +#endif + /* Make sure VLANS are not using driver */ #if __FreeBSD_version >= 700000 if (adapter->ifp->if_vlantrunk != NULL) { ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.h#3 (text+ko) ==== @@ -218,7 +218,7 @@ #define EM_MSIX_BAR 3 /* On 82575 */ /* Defines for printing debug information */ -#define DEBUG_INIT 0 +#define DEBUG_INIT 1 #define DEBUG_IOCTL 0 #define DEBUG_HW 0 @@ -421,6 +421,9 @@ boolean_t pcix_82544; boolean_t in_detach; +#ifdef RINGMAP + struct ringmap *rm; +#endif struct e1000_hw_stats stats; }; ==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#3 (text+ko) ==== @@ -51,7 +51,7 @@ RINGMAP_HW_READ_REG(&adapter->hw, E1000_RDT(0)) -#define RINGMAP_GET_ADAPTER_STRUCT(adapter) \ +#define RINGMAP_GET_ADAPTER_STRUCT() \ (struct adapter *)devclass_get_softc(em_devclass, dev2unit(dev)) ==== //depot/projects/soc2010/ringmap/current/sys/modules/em/Makefile#9 (text+ko) ==== @@ -1,9 +1,5 @@ # $FreeBSD: src/sys/modules/em/Makefile,v 1.16 2010/03/29 23:36:34 jfv Exp $ -.if defined(KERNEL_RINGMAP) -.PATH: ${.CURDIR}/../../dev/e1000 : ${.CURDIR}/../../net -.else .PATH: ${.CURDIR}/../../dev/e1000 -.endif KMOD = if_em SRCS = device_if.h bus_if.h pci_if.h opt_inet.h ==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#5 (text+ko) ==== @@ -23,46 +23,47 @@ #include <vm/vm.h> #include <vm/pmap.h> #include <vm/vm_map.h> + #include <vm/vm_param.h> #include <vm/vm_kern.h> -#ifdef __E1000_RINGMAP__ -#include "e1000_api.h" -#include "if_em.h" +//#ifdef __E1000_RINGMAP__ +//#include "e1000_api.h" +//#include "if_em.h" +// +//extern devclass_t em_devclass; +//extern int em_rxeof(struct rx_ring *, int); +//extern bool em_txeof(struct tx_ring *); +//extern void em_print_debug_info(struct adapter *); +//extern void em_start_locked(struct ifnet *, struct tx_ring *); +//#endif -extern devclass_t em_devclass; -extern int em_rxeof(struct rx_ring *, int); -extern bool em_txeof(struct tx_ring *); -extern void em_print_debug_info(struct adapter *); -extern void em_start_locked(struct ifnet *, struct tx_ring *); -#endif - #include "ringmap.h" -/* DON'T TOUCH IT */ -int fiveg_da_2009 = 1; - /* F U N C T I O N S */ -int ringmap_attach(struct adapter *); -int ringmap_detach(struct adapter*); -struct adapter* get_adapter_struct(struct cdev *dev); -int ringmap_print_ring_pointers(struct adapter *); -void ringmap_print_ring (struct adapter *adapter, int level); -void ringmap_print_slot(struct adapter *adapter, unsigned int slot_number); +int ringmap_attach(device_t); +int ringmap_detach(device_t); +int set_ringmap_to_adapter (device_t, ringmap *); +//struct adapter* get_adapter_struct(struct cdev *dev); +//int ringmap_print_ring_pointers(struct adapter *); +//void ringmap_print_ring (struct adapter *adapter, int level); +//void ringmap_print_slot(struct adapter *adapter, unsigned int slot_number); -#if (__DRIVER_VERSION == 696) -void ringmap_handle_rxtx(void *context, int pending); -#endif - -/* For CURRENT */ -void ringmap_handle_que(void *context, int pending); - +//#if (__DRIVER_VERSION == 696) +//void ringmap_handle_rxtx(void *context, int pending); +//#endif +// +///* For CURRENT */ +//void ringmap_handle_que(void *context, int pending); +// d_open_t ringmap_open; d_close_t ringmap_close; d_ioctl_t ringmap_ioctl; d_mmap_t ringmap_mmap; +void ringmap_close_cb (void *data); + /* * Character Device for access on if_em driver structures */ @@ -79,16 +80,12 @@ * Will called from if_em.c before returning from * em_attach() function. */ -int ringmap_attach(struct adapter *a) { - struct adapter *adapter = a; +int ringmap_attach(device_t devt) { struct ringmap *rm; struct ring *ring; RINGMAP_FUNC_DEBUG(begin); - /* Disable interrupts while we set our structures */ - RINGMAP_HW_DISABLE_INTR(adapter); - rm = (struct ringmap *) contigmalloc (sizeof(struct ringmap), M_DEVBUF, M_ZERO, 0, -1L, PAGE_SIZE, 0); @@ -96,21 +93,13 @@ RINGMAP_ERROR(Can not allocate space for ringmap structure); return (-1); } - if ((vm_offset_t)(rm) & PAGE_MASK){ - RINGMAP_ERROR(rm is not allined to PAGE_MASK); - 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 ringmap structure); + RINGMAP_ERROR(Can not allocate space for ring structure); return (-1); } - if ((vm_offset_t)(ring) & PAGE_MASK){ - RINGMAP_ERROR(rm is not allined to PAGE_MASK); - return (-1); - } rm->ring = ring; @@ -123,18 +112,17 @@ * * - controll packet capturing: start, stop, sleep to wait for packets. */ - rm->ringmap_dev = make_dev(&ringmap_devsw, device_get_unit(adapter->dev), - UID_ROOT, GID_WHEEL, 0666, RINGMAP_DEVICE"%s", - device_get_nameunit(adapter->dev)); + rm->ringmap_dev = make_dev(&ringmap_devsw, device_get_unit(adapter_dev), + UID_ROOT, GID_WHEEL, 0666, RINGMAP_DEVICE); - /* Counts how many times the device will opened */ + /* Device open counter */ rm->open_cnt = 0; - /* Pointer to structure of process wich opened the device */ + /* Pointer to structure of process wich has opened the device */ rm->procp = NULL; - adapter->rm = rm; - rm->adapter = adapter; + /* set the pointer to ringmap in the adapters structure */ + RINGMAP_FUNC_DEBUG(end); @@ -143,29 +131,16 @@ int -ringmap_detach(struct adapter *adapter) +ringmap_detach(struct ringmap *rm) { - struct ringmap *rm; RINGMAP_FUNC_DEBUG(start); - if (adapter == NULL){ - RINGMAP_ERROR(NUll pointer to adapter structure); - return (1); - } + destroy_dev(rm->ringmap_dev); - rm = adapter->rm; - - /* Disable pkts receive and interrupts while we set our structures */ - RINGMAP_HW_DISABLE_INTR(adapter); - RINGMAP_HW_DISABLE_RECEIVE(adapter); + contigfree(rm->ring, sizeof(struct ring), M_DEVBUF); - /* May be any tasks in queue */ - taskqueue_free(adapter->tq); - - destroy_dev(rm->ringmap_dev); - - // FREE(rm, M_DEVBUF); + contigfree(rm, sizeof(struct ring), M_DEVBUF); RINGMAP_FUNC_DEBUG(end); @@ -182,67 +157,68 @@ int ringmap_open(struct cdev *dev, 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 = adapter->rm; +// unsigned int i; +// struct ring_slot; +// struct adapter *adapter = (struct adapter *)get_adapter_struct(dev); +// struct ringmap *rm = adapter->rm; RINGMAP_FUNC_DEBUG(start); #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)); + printf("[%s]: dev_t=%d, flag=%x, otyp=%x\n", + __func__, dev2udev(dev), flag, otyp); #endif - /** - ** 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); - +// +// /** +// ** 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); +// RINGMAP_FUNC_DEBUG(end); return (0); @@ -252,25 +228,25 @@ int ringmap_close(struct cdev *dev, int flag, int otyp, struct thread *td) { - struct adapter *adapter = (struct adapter *)get_adapter_struct(dev); - struct ringmap *rm = adapter->rm; - +// struct adapter *adapter = (struct adapter *)get_adapter_struct(dev); +// struct ringmap *rm = adapter->rm; +// 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; +// +// /* 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); - atomic_readandclear_int(&rm->open_cnt); - RINGMAP_FUNC_DEBUG(end); return (0); } @@ -278,19 +254,19 @@ int 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; - +// struct adapter *adapter = (struct adapter *)get_adapter_struct(dev); +// struct ringmap *rm = adapter->rm; +// 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); +// +// 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); RINGMAP_FUNC_DEBUG(end); @@ -301,214 +277,215 @@ int ringmap_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td) { - int err = 0, err_sleep; - struct adapter *adapter = (struct adapter *)get_adapter_struct(dev); - struct ringmap *rm = adapter->rm; - - unsigned int *userp = NULL; - + int err = 0, err_sleep = err_sleep; +// struct adapter *adapter = (struct adapter *)get_adapter_struct(dev); +// struct ringmap *rm = adapter->rm; +// +// unsigned int *userp = NULL; +// RINGMAP_FUNC_DEBUG(start); - - switch( cmd ){ - - /* Tell to user number of descriptors */ - case IOCTL_G_DNUM: - RINGMAP_OUTPUT(IOCTL_G_DNUM); - - userp = (unsigned int *)(*(unsigned int *)data); - if (userp == NULL){ - RINGMAP_ERROR(NULL pointer by ioctl IOCTL_G_DNUM); - return (EINVAL); - } - - unsigned int dn = (unsigned int)adapter->num_rx_desc; - copyout(&dn, userp, sizeof(unsigned int)); - - break; - - /* Enable Receive and Interrupts */ - case IOCTL_ENABLE_RECEIVE: - RINGMAP_IOCTL(IOCTL_ENABLE_RECEIVE); - RINGMAP_HW_ENABLE_INTR(adapter); - RINGMAP_HW_ENABLE_RECEIVE(adapter); - break; - - /* Disable Receive and Interrupts */ - case IOCTL_DISABLE_RECEIVE: - RINGMAP_IOCTL(IOCTL_DISABLE_RECEIVE); - RINGMAP_HW_DISABLE_INTR(adapter); - RINGMAP_HW_DISABLE_RECEIVE(adapter); - break; - - /* Disable Flow Control */ - case IOCTL_DISABLE_FLOWCNTR: - RINGMAP_IOCTL(IOCTL_DISABLE_FLOWCNTR); - RINGMAP_HW_DISABLE_FLOWCONTR(adapter); - break; - - /* Sleep and wait for new frames */ - case IOCTL_SLEEP_WAIT: - rm->ring->user_wait_kern++; - RINGMAP_HW_SYNC_TAIL(adapter); - err_sleep = tsleep(rm, (PRI_MIN) | PCATCH, "ioctl", hz); - break; - - /* Synchronize sowftware ring-tail with hardware-ring-tail (RDT) */ - case IOCTL_SET_RDT: - SET_RDT(adapter); - break; - - default: - RINGMAP_ERROR("Undefined command!"); - return (ENODEV); - } +// +// switch( cmd ){ +// +// /* Tell to user number of descriptors */ +// case IOCTL_G_DNUM: +// RINGMAP_OUTPUT(IOCTL_G_DNUM); +// +// userp = (unsigned int *)(*(unsigned int *)data); +// if (userp == NULL){ +// RINGMAP_ERROR(NULL pointer by ioctl IOCTL_G_DNUM); +// return (EINVAL); +// } +// +// unsigned int dn = (unsigned int)adapter->num_rx_desc; +// copyout(&dn, userp, sizeof(unsigned int)); +// +// break; +// +// /* Enable Receive and Interrupts */ +// case IOCTL_ENABLE_RECEIVE: +// RINGMAP_IOCTL(IOCTL_ENABLE_RECEIVE); +// RINGMAP_HW_ENABLE_INTR(adapter); +// RINGMAP_HW_ENABLE_RECEIVE(adapter); +// break; +// +// /* Disable Receive and Interrupts */ +// case IOCTL_DISABLE_RECEIVE: +// RINGMAP_IOCTL(IOCTL_DISABLE_RECEIVE); +// RINGMAP_HW_DISABLE_INTR(adapter); +// RINGMAP_HW_DISABLE_RECEIVE(adapter); +// break; +// +// /* Disable Flow Control */ +// case IOCTL_DISABLE_FLOWCNTR: +// RINGMAP_IOCTL(IOCTL_DISABLE_FLOWCNTR); +// RINGMAP_HW_DISABLE_FLOWCONTR(adapter); +// break; +// +// /* Sleep and wait for new frames */ +// case IOCTL_SLEEP_WAIT: +// rm->ring->user_wait_kern++; +// RINGMAP_HW_SYNC_TAIL(adapter); +// err_sleep = tsleep(rm, (PRI_MIN) | PCATCH, "ioctl", hz); +// break; +// +// /* Synchronize sowftware ring-tail with hardware-ring-tail (RDT) */ +// case IOCTL_SET_RDT: +// SET_RDT(adapter); +// break; +// +// default: +// RINGMAP_ERROR("Undefined command!"); +// return (ENODEV); +// } RINGMAP_FUNC_DEBUG(end); return (err); } -void -ringmap_handle_que(void *context, int pending) -{ - struct adapter *adapter = context; - struct ringmap *rm = adapter->rm; - struct ifnet *ifp = adapter->ifp; - struct tx_ring *txr = adapter->tx_rings; - struct rx_ring *rxr = adapter->rx_rings; - bool more_rx; - -#if (INTR_DEB) - printf("########################################################################\n"); -#endif - - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - more_rx = em_rxeof(rxr, adapter->rx_process_limit); - - EM_TX_LOCK(txr); - em_txeof(txr); -#ifdef EM_MULTIQUEUE - if (!drbr_empty(ifp, txr->br)) - em_mq_start_locked(ifp, txr, NULL); -#else - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - em_start_locked(ifp, txr); -#endif - EM_TX_UNLOCK(txr); - if (more_rx) { - taskqueue_enqueue(adapter->tq, &adapter->que_task); - return; - } - } - -#if (INTR_DEB) - printf("########################################################################\n"); -#endif - - RINGMAP_HW_ENABLE_INTR(adapter); - - if (rm->procp != NULL) { - wakeup(rm); - } - - return; -} - -#if (__DRIVER_VERSION == 696) -void -ringmap_handle_rxtx(void *context, int pending) -{ - struct adapter *adapter = context; - struct ifnet *ifp = adapter->ifp; - struct ringmap *rm = adapter->rm; - -#if (INTR_DEB) - printf("########################################################################\n"); -#endif - - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { -#ifdef __E1000_RINGMAP__ - if (em_rxeof(adapter, adapter->rx_process_limit) != 0) - taskqueue_enqueue(adapter->tq, &adapter->rxtx_task); -#endif - } - -#if (INTR_DEB) - printf("########################################################################\n\n"); -#endif - - RINGMAP_HW_ENABLE_INTR(adapter); - - if (rm->procp != NULL) { - wakeup(rm); - } -} -#endif - -struct adapter* -get_adapter_struct(struct cdev *dev) -{ - struct adapter *adapter; - - adapter = RINGMAP_GET_ADAPTER_STRUCT(adapter); - return (adapter); -} - - -void -ringmap_print_ring (struct adapter *adapter, int level) -{ - struct ringmap *rm = adapter->rm; - - printf("Ring Size = %d \n",rm->ring->size ); - printf("Times Kern wait for User = %llu \n",rm->ring->kern_wait_user); - printf("Times User wait for Kern = %llu \n",rm->ring->user_wait_kern); - printf("Interrupts Counter = %llu \n",rm->ring->interrupts_counter); - - ringmap_print_ring_pointers(adapter); -} - - -void -ringmap_print_slot(struct adapter *adapter, unsigned int slot_number) -{ - struct ringmap *rm = adapter->rm; - - printf("Slot Number: %d \n", slot_number); - printf("---------------- \n"); - - printf("[%s] physical addr of descriptor[%d] = 0x%X\n", __func__, slot_number, - (unsigned int) rm->ring->slot[slot_number].descriptor.phys); - printf("[%s] kernel addr of descriptor[%d] = 0x%X\n", __func__, slot_number, - (unsigned int) rm->ring->slot[slot_number].descriptor.kern); - printf("[%s] physical addr of mbuf[%d] = 0x%X\n", __func__, slot_number, - (unsigned int) rm->ring->slot[slot_number].mbuf.phys); - printf("[%s] kernel addr of mbuf[%d] = 0x%X\n", __func__, slot_number, - (unsigned int) rm->ring->slot[slot_number].mbuf.kern); - printf("[%s] physical addr of packet_buffer[%d] = 0x%X\n", __func__, slot_number, - (unsigned int) rm->ring->slot[slot_number].packet.phys); - printf("[%s] kernel addr of packet_buffer[%d] = 0x%X\n", __func__, slot_number, - (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); -} +//void +//ringmap_handle_que(void *context, int pending) +//{ +// struct adapter *adapter = context; +// struct ringmap *rm = adapter->rm; +// struct ifnet *ifp = adapter->ifp; +// struct tx_ring *txr = adapter->tx_rings; +// struct rx_ring *rxr = adapter->rx_rings; +// bool more_rx; +// +//#if (INTR_DEB) +// printf("########################################################################\n"); +//#endif +// +// if (ifp->if_drv_flags & IFF_DRV_RUNNING) { +// more_rx = em_rxeof(rxr, adapter->rx_process_limit); +// +// EM_TX_LOCK(txr); +// em_txeof(txr); +//#ifdef EM_MULTIQUEUE +// if (!drbr_empty(ifp, txr->br)) +// em_mq_start_locked(ifp, txr, NULL); +//#else +// if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) +// em_start_locked(ifp, txr); +//#endif +// EM_TX_UNLOCK(txr); +// if (more_rx) { +// taskqueue_enqueue(adapter->tq, &adapter->que_task); +// return; +// } +// } +// +//#if (INTR_DEB) +// printf("########################################################################\n"); >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006161208.o5GC8FbH096401>