PERFORCE change 179497 for review
Alexandre Fiveg
afiveg at FreeBSD.org
Fri Jun 11 21:45:20 UTC 2010
http://p4web.freebsd.org/@@179497?ac=10
Change 179497 by afiveg at cottonmouth on 2010/06/11 21:44:30
ringmap is integrated with em driver. Compiling runs without errors/warnings,
but ld can not link compiled em files with ringmap.o , because ld tries to
search ringmap.o in sys/net/. But ringmap.o will placed in modules/em/
after compiling. I am trying to fix this issue.
Affected files ...
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_em.c#2 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_em.h#2 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#2 edit
.. //depot/projects/soc2010/ringmap/current/sys/modules/em/Makefile#4 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#3 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#3 edit
Differences ...
==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_em.c#2 (text+ko) ====
@@ -81,6 +81,11 @@
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
+#ifdef __RINGMAP__
+#include <net/ringmap.h>
+#endif
+
+
#include "e1000_api.h"
#include "e1000_82571.h"
#include "if_em.h"
@@ -95,7 +100,6 @@
*********************************************************************/
char em_driver_version[] = "7.0.5";
-
/*********************************************************************
* PCI Device ID Table
*
@@ -191,7 +195,13 @@
static int em_suspend(device_t);
static int em_resume(device_t);
static void em_start(struct ifnet *);
+
+#ifndef __RINGMAP__
static void em_start_locked(struct ifnet *, struct tx_ring *);
+#else
+void em_start_locked(struct ifnet *, struct tx_ring *);
+#endif
+
#ifdef EM_MULTIQUEUE
static int em_mq_start(struct ifnet *, struct mbuf *);
static int em_mq_start_locked(struct ifnet *,
@@ -230,8 +240,15 @@
static void em_enable_intr(struct adapter *);
static void em_disable_intr(struct adapter *);
static void em_update_stats_counters(struct adapter *);
+
+#ifndef __RINGMAP__
static bool em_txeof(struct tx_ring *);
static int em_rxeof(struct rx_ring *, int);
+#else
+int em_rxeof(struct rx_ring *, int);
+bool em_txeof(struct tx_ring *);
+#endif
+
#ifndef __NO_STRICT_ALIGNMENT
static int em_fixup_rx(struct rx_ring *);
#endif
@@ -252,7 +269,13 @@
static int em_dma_malloc(struct adapter *, bus_size_t,
struct em_dma_alloc *, int);
static void em_dma_free(struct adapter *, struct em_dma_alloc *);
+
+#ifndef __RINGMAP__
static void em_print_debug_info(struct adapter *);
+#else
+void em_print_debug_info(struct adapter *);
+#endif
+
static void em_print_nvm_info(struct adapter *);
static int em_is_valid_ether_addr(u8 *);
static int em_sysctl_stats(SYSCTL_HANDLER_ARGS);
@@ -287,6 +310,16 @@
static poll_handler_t em_poll;
#endif /* POLLING */
+
+#ifdef __RINGMAP__
+extern int ringmap_attach(struct adapter *);
+extern int ringmap_detach(struct adapter *);
+extern int ringmap_print_ring_pointers(struct adapter *);
+extern void ringmap_handle_que(void *context, int pending);
+#endif
+
+
+
/*********************************************************************
* FreeBSD Device Interface Entry Points
*********************************************************************/
@@ -302,14 +335,29 @@
{0, 0}
};
+#ifndef __RINGMAP__
static driver_t em_driver = {
"em", em_methods, sizeof(struct adapter),
};
+#else
+static driver_t em_driver = {
+ "ringmap", em_methods, sizeof(struct adapter),
+};
+#endif
+
devclass_t em_devclass;
+
+
+#ifndef __RINGMAP__
DRIVER_MODULE(em, pci, em_driver, em_devclass, 0, 0);
MODULE_DEPEND(em, pci, 1, 1, 1);
MODULE_DEPEND(em, ether, 1, 1, 1);
+#else
+DRIVER_MODULE(ringmap, pci, em_driver, em_devclass, 0, 0);
+MODULE_DEPEND(ringmap, pci, 1, 1, 1);
+MODULE_DEPEND(ringmap, ether, 1, 1, 1);
+#endif
/*********************************************************************
* Tunable default values.
@@ -405,6 +453,34 @@
pci_subvendor_id = pci_get_subvendor(dev);
pci_subdevice_id = pci_get_subdevice(dev);
+//TODO: Fix it. Dirty implemented
+#ifdef __RINGMAP__
+ if (DEV_ID) {
+ if (pci_device_id == DEV_ID)
+ return 0;
+ else
+ return 1;
+ } else {
+ ent = em_vendor_info_array;
+ while (ent->vendor_id != 0) {
+ if ((pci_vendor_id == ent->vendor_id) &&
+ (pci_device_id == ent->device_id) &&
+
+ ((pci_subvendor_id == ent->subvendor_id) ||
+ (ent->subvendor_id == PCI_ANY_ID)) &&
+
+ ((pci_subdevice_id == ent->subdevice_id) ||
+ (ent->subdevice_id == PCI_ANY_ID))) {
+ sprintf(adapter_name, "%s %s",
+ em_strings[ent->index],
+ em_driver_version);
+ device_set_desc_copy(dev, adapter_name);
+ return (BUS_PROBE_DEFAULT);
+ }
+ ent++;
+ }
+ }
+#else
ent = em_vendor_info_array;
while (ent->vendor_id != 0) {
if ((pci_vendor_id == ent->vendor_id) &&
@@ -423,7 +499,7 @@
}
ent++;
}
-
+#endif
return (ENXIO);
}
@@ -668,6 +744,23 @@
INIT_DEBUGOUT("em_attach: end");
+
+#ifdef __RINGMAP__
+ if (ringmap_attach(adapter) < 0)
+ return (EIO);
+
+#if (__RINGMAP_DEB)
+ printf("\n\n[%s] DEBUG INFO FOR INTERFACE %s\n", __func__, device_get_nameunit(dev));
+ printf("=============================================================\n\n");
+ em_print_debug_info(adapter);
+ printf("\n=============================================================\n\n");
+ INIT_DEBUGOUT2("[%s]:%s END.",__func__, device_get_nameunit(dev));
+#endif
+
+#endif /* __RINGMAP__ */
+
+
+
return (0);
err_late:
@@ -699,6 +792,22 @@
INIT_DEBUGOUT("em_detach: begin");
+
+#ifdef __RINGMAP__
+ ringmap_detach(adapter);
+
+#if (__RINGMAP_DEB)
+ printf("\n\n[%s] DEBUG INFO FOR INTERFACE %s\n", __func__, device_get_nameunit(dev));
+ printf("=============================================================\n\n");
+ em_print_debug_info(adapter);
+ printf("\n=============================================================\n\n");
+ INIT_DEBUGOUT2("[%s]:%s END.",__func__, device_get_nameunit(dev));
+#endif
+
+#endif
+
+
+
/* Make sure VLANS are not using driver */
if (adapter->ifp->if_vlantrunk != NULL) {
device_printf(dev,"Vlan in use, detach first\n");
@@ -907,7 +1016,11 @@
#endif /* EM_MULTIQUEUE */
+#ifndef __RINGMAP__
static void
+#else
+void
+#endif
em_start_locked(struct ifnet *ifp, struct tx_ring *txr)
{
struct adapter *adapter = ifp->if_softc;
@@ -1427,6 +1540,20 @@
return FILTER_STRAY;
em_disable_intr(adapter);
+
+
+#ifdef __RINGMAP__
+ /* Print it if interrupt debugging is enabled */
+ RINGMAP_INTR(NOW SET rxtx_task IN QUEUE);
+
+ /* Count interuppts. (for statistics) */
+ adapter->rm->ring->interrupts_counter++;
+
+ /* Compute the time stamp */
+ getmicrotime(&adapter->intr_ts);
+#endif
+
+
taskqueue_enqueue(adapter->tq, &adapter->que_task);
/* Link status change */
@@ -1440,6 +1567,7 @@
return FILTER_HANDLED;
}
+#ifndef __RINGMAP__
/* Combined RX/TX handler, used by Legacy and MSI */
static void
em_handle_que(void *context, int pending)
@@ -1473,6 +1601,7 @@
em_enable_intr(adapter);
return;
}
+#endif
/*********************************************************************
@@ -2285,6 +2414,8 @@
device_t dev = adapter->dev;
int error, rid = 0;
+ RINGMAP_FUNC_DEBUG(start);
+
/* Manually turn off all interrupts */
E1000_WRITE_REG(&adapter->hw, E1000_IMC, 0xffffffff);
@@ -2303,7 +2434,12 @@
* Allocate a fast interrupt and the associated
* deferred processing contexts.
*/
+#ifndef __RINGMAP__
TASK_INIT(&adapter->que_task, 0, em_handle_que, adapter);
+#else
+ TASK_INIT(&adapter->que_task, 0, ringmap_handle_que, adapter);
+#endif
+
TASK_INIT(&adapter->link_task, 0, em_handle_link, adapter);
adapter->tq = taskqueue_create_fast("em_taskq", M_NOWAIT,
taskqueue_thread_enqueue, &adapter->tq);
@@ -3565,7 +3701,11 @@
* tx_buffer is put back on the free queue.
*
**********************************************************************/
+#ifndef __RINGMAP__
static bool
+#else
+bool
+#endif
em_txeof(struct tx_ring *txr)
{
struct adapter *adapter = txr->adapter;
@@ -4048,7 +4188,11 @@
E1000_WRITE_REG(hw, E1000_RDBAL(i), (u32)bus_addr);
/* Setup the Head and Tail Descriptor Pointers */
E1000_WRITE_REG(hw, E1000_RDH(i), 0);
- E1000_WRITE_REG(hw, E1000_RDT(i), adapter->num_rx_desc - 1);
+#ifndef __RINGMAP__
+ E1000_WRITE_REG(hw, E1000_RDT(i), adapter->num_rx_desc - 1);
+#else
+ E1000_WRITE_REG(hw, E1000_RDT(i), adapter->num_rx_desc - RING_SAFETY_MARGIN);
+#endif
}
/* Setup the Receive Control Register */
@@ -4087,7 +4231,11 @@
*
* For polling we also now return the number of cleaned packets
*********************************************************************/
+#ifndef __RINGMAP__
static int
+#else
+int
+#endif
em_rxeof(struct rx_ring *rxr, int count)
{
struct adapter *adapter = rxr->adapter;
@@ -4099,6 +4247,28 @@
bool eop;
struct e1000_rx_desc *cur;
+
+#ifdef __RINGMAP__
+ struct ringmap *rm = adapter->rm;
+
+ RINGMAP_INTR(start);
+
+ /* Set RDT (user pointer aka. TAIL) */
+ if (rm->procp != NULL) {
+ SET_RDT(adapter);
+ }
+ else {
+ RINGMAP_WARN("No process want capture!");
+ }
+
+ /* Print dubugging info if INTR_DEB set */
+#if (INTR_DEB)
+ printf("[%s] Print Ring Pointers\n", __func__);
+ ringmap_print_ring_pointers(adapter);
+#endif
+#endif /* __RINGMAP__ */
+
+
EM_RX_LOCK(rxr);
for (i = rxr->next_to_check, processed = 0; count != 0;) {
@@ -4116,6 +4286,7 @@
if ((status & E1000_RXD_STAT_DD) == 0)
break;
+
len = le16toh(cur->length);
eop = (status & E1000_RXD_STAT_EOP) != 0;
count--;
@@ -4188,6 +4359,11 @@
++rxdone; /* cumulative for POLL */
++processed;
+#ifdef __RINGMAP__
+ /* Time stamp */
+ rm->ring->slot[i].ts = adapter->intr_ts;
+#endif
+
/* Advance our pointers to the next descriptor. */
if (++i == adapter->num_rx_desc)
i = 0;
@@ -4195,17 +4371,43 @@
/* Send to the stack */
if (sendmp != NULL) {
rxr->next_to_check = i;
+
+#ifndef __RINGMAP__
+/* ******************************************************
+ * We dont want to do now with protocol stack We want
+ * only to map mbufs, pkts and descriptors into space of
+ * user process.
+ * ******************************************************/
+
EM_RX_UNLOCK(rxr);
(*ifp->if_input)(ifp, sendmp);
EM_RX_LOCK(rxr);
+
+#else
+ /* Set kern pointer in ring structure */
+ rm->ring->kernrp = rxr->next_to_check;
+ rm->pkts_counter++;
+#endif
+
+
i = rxr->next_to_check;
}
+/*
+ * RINGMAP: I don't whether we need to refrash mbufs. Refreshing
+ * causes memory allocation - it is expensive in term of CPU cycles.
+ * Probably we can use old mbufs ???
+ */
/* Only refresh mbufs every 8 descriptors */
if (processed == 8) {
em_refresh_mbufs(rxr, i);
processed = 0;
}
+
+#ifndef __RINGMAP__
+ E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), i);
+#endif
+
}
/* Catch any remaining refresh work */
@@ -4879,8 +5081,13 @@
* maintained by the driver and hardware.
*
**********************************************************************/
+#ifndef __RINGMAP__
static void
em_print_debug_info(struct adapter *adapter)
+#else
+void
+#endif
+em_print_debug_info(struct adapter *adapter)
{
device_t dev = adapter->dev;
u8 *hw_addr = adapter->hw.hw_addr;
==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_em.h#2 (text+ko) ====
@@ -69,9 +69,16 @@
* (num_tx_desc * sizeof(struct e1000_tx_desc)) % 128 == 0
*/
#define EM_MIN_RXD 80
+
+#ifndef __RINGMAP__
#define EM_MAX_RXD 4096
#define EM_DEFAULT_RXD 1024
+#else
+#define EM_MAX_RXD SLOTS_NUMBER
+#define EM_DEFAULT_RXD SLOTS_NUMBER
+#endif
+
/*
* EM_TIDV - Transmit Interrupt Delay Value
* Valid Range: 0-65535 (0=off)
@@ -412,6 +419,11 @@
unsigned long link_irq;
struct e1000_hw_stats stats;
+
+#ifdef __RINGMAP__
+ struct ringmap *rm;
+ struct timeval intr_ts;
+#endif
};
/********************************************************************************
==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#2 (text+ko) ====
@@ -1,3 +1,4 @@
+#define __DRIVER_VERSION 705
#ifdef _KERNEL
#define RINGMAP_HW_WRITE_REG E1000_WRITE_REG
@@ -63,19 +64,28 @@
} while(0);
+#if (__DRIVER_VERSION == 705)
+#define DESC_AREA(adapter) (adapter)->rx_rings->rx_base
+#define MBUF_AREA(adapter) (adapter)->rx_rings->rx_buffers
+#elif (__DRIVER_VERSION == 696)
+#define DESC_AREA(adapter) (adapter)->rx_desc_base
+#define MBUF_AREA(adapter) (adapter)->rx_buffer_area
+#endif
+
+
/* Kernel address of mbuf wich placed in the slot "i" */
#define RINGMAP_GET_MBUF_P(adapter, i) \
- ((adapter)->rx_buffer_area[(i)].m_head)
+ (MBUF_AREA(adapter)[(i)].m_head)
/* Kernel address of the packet wich placed in the slot "i" */
#define RINGMAP_GET_PACKET_P(adapter, i) \
- ((adapter)->rx_buffer_area[(i)].m_head->m_data)
+ (MBUF_AREA(adapter)[(i)].m_head->m_data)
/* Kernel address of the descriptor wich placed in the slot "i" */
#define RINGMAP_GET_DESCRIPTOR_P(adapter, i) \
- (&((adapter)->rx_desc_base[(i)]))
+ (&(DESC_AREA(adapter)[(i)]))
/*
==== //depot/projects/soc2010/ringmap/current/sys/modules/em/Makefile#4 (text+ko) ====
@@ -1,7 +1,7 @@
# $FreeBSD: src/sys/modules/em/Makefile,v 1.16 2010/03/29 23:36:34 jfv Exp $
.PATH: ${.CURDIR}/../../dev/e1000
-.if defined(RINGMAP)
+.if defined(KERNEL_RINGMAP)
KMOD = if_ringmap
.else
KMOD = if_em
@@ -12,8 +12,8 @@
SRCS += $(COMMON_SHARED) $(LEGACY_SHARED) $(PCIE_SHARED)
.if defined(KERNEL_RINGMAP)
-CFLAGS += -D__RINGMAP__ -I
-SRC += ${.CURDIR}/../../net/ringmap.c
+CFLAGS += -D__RINGMAP__ -D__E1000_RINGMAP__
+SRCS += ${.CURDIR}/../../net/ringmap.c
.endif
CORE_SRC = if_em.c e1000_osdep.c
==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#3 (text+ko) ====
@@ -32,8 +32,10 @@
#include "if_em.h"
extern devclass_t em_devclass;
-extern int em_rxeof(struct adapter *, int);
+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"
@@ -48,8 +50,14 @@
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);
+
d_open_t ringmap_open;
d_close_t ringmap_close;
d_ioctl_t ringmap_ioctl;
@@ -208,13 +216,13 @@
RINGMAP_INIT(rm->ring, adapter);
for (i = 0 ; i < SLOTS_NUMBER ; i ++) {
- if (rm->adapter->rx_buffer_area[i].m_head == NULL) {
+ 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);
}
- rm->adapter->rx_desc_base[i].status = 0;
+ 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));
@@ -267,9 +275,8 @@
return (0);
}
-
int
-ringmap_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
+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;
@@ -362,6 +369,53 @@
}
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;
@@ -389,7 +443,7 @@
wakeup(rm);
}
}
-
+#endif
struct adapter*
get_adapter_struct(struct cdev *dev)
==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#3 (text+ko) ====
More information about the p4-projects
mailing list