PERFORCE change 181463 for review
Alexandre Fiveg
afiveg at FreeBSD.org
Wed Jul 28 08:21:36 UTC 2010
http://p4web.freebsd.org/@@181463?ac=10
Change 181463 by afiveg at ringmap-2 on 2010/07/25 17:02:26
ringmap is ported to 10GbE (integrated with ixgbe driver). Restrictions: 1. only one predefined queue is used (DEFAULT_QUEUE ringmap.h) - all incoming traffic on the adapter is posted into this predefined queue. 2. Currently no packet filtering - whole traffic will be captured. I am not sure if it is good idea to filter the packets in the user-space. If we want later write the packets into the disk from kernel, then filtering should be done using kernel-BPF.
Affected files ...
.. //depot/projects/soc2010/ringmap/current/contrib/libpcap/ringmap_pcap.c#22 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ixgbe.c#7 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ixgbe.h#6 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ringmap_8259.h#5 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ringmap_ixgbe.c#6 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#36 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#36 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap_kernel.h#6 edit
.. //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#17 edit
.. //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#18 edit
.. //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#12 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/close.c#5 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/ioctl.c#5 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/main.c#7 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/mmap.c#7 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/open.c#7 edit
.. //depot/projects/soc2010/ringmap/tests/ringmap/tests.h#5 edit
Differences ...
==== //depot/projects/soc2010/ringmap/current/contrib/libpcap/ringmap_pcap.c#22 (text+ko) ====
@@ -60,7 +60,7 @@
}
/*
- * Open mem device for mmaping of kernel memory regions in space of our
+ * Open mem device for mmaping of kernel memory regions into space of our
* process
*/
if ((devmem_fd = open("/dev/mem", O_RDWR)) == -1){
@@ -78,6 +78,7 @@
RINGMAP_ERROR(Can not read phys addr of ring from kernel);
return (-1);
}
+
#if (__RINGMAP_DEB)
printf("[%s] Phys addr of ring 0x%X\n", __func__, ring);
#endif
@@ -116,10 +117,7 @@
#endif
/*
- * Mapping mbufs from kern to userspace.
- * mbufs internal pointers contain kernel space addresses -
- * it means, we schould notice kernel space addresses of mbufs
- * to be able to get correct mbufs from mbufs chain
+ * Mapping mbufs and packet buffers from kern into userspace.
*/
for (i = 0; i < SLOTS_NUMBER; i++){
@@ -128,7 +126,7 @@
tmp_addr =
mmap (
0, /* System will choose the addrress */
- sizeof(struct mbuf), /* Size of mapped region = mbuf */
+ sizeof(struct mbuf), /* Size of mapped region (mbuf) */
PROT_WRITE|PROT_READ, /* protection: write & read */
MAP_SHARED, /* shared maping */
devmem_fd, /* device is /dev/mem */
@@ -183,11 +181,17 @@
RINGMAP_FUNC_DEBUG(start);
- if ( (p == NULL) || (p->ring == NULL) ){
- RINGMAP_FUNC_DEBUG(NULL pointer. Debugging is needed!);
+ if (p == NULL) {
+ RINGMAP_FUNC_DEBUG(NULL pointer to pcap structure);
+ goto out;
+ }
+
+ if (p->ring == NULL) {
+ RINGMAP_FUNC_DEBUG(NULL pointer to ringstructure);
goto out;
}
+ /* Unmap slots */
for (i = 0; i < SLOTS_NUMBER; i++){
tmp_res = munmap((void *)p->ring->slot[i].mbuf.user,
sizeof(struct mbuf));
@@ -202,6 +206,7 @@
__func__, i);
}
+ /* Unmap ring */
tmp_res = munmap(p->ring, sizeof(struct ring));
if (tmp_res == -1) {
RINGMAP_ERROR(Unmaping the ring pointer);
@@ -245,8 +250,11 @@
again:
if ( RING_IS_EMPTY(ring) ) {
+
+#if (__RINGMAP_DEB)
RINGMAP_FUNC_DEBUG(Ring is empty. Sleep...);
PRINT_RING_PTRS(ring);
+#endif
/* Sleep and wait for new incoming packets */
ioctl(ringmap_cdev_fd, IOCTL_SLEEP_WAIT);
goto again;
@@ -292,6 +300,7 @@
SW_INCR_TAIL(ring);
ring->slot[curr_slot].filtered = 0;
+ ring->slot[curr_slot].is_ok = 0;
}
RINGMAP_FUNC_DEBUG(end);
==== //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ixgbe.c#7 (text+ko) ====
@@ -160,6 +160,8 @@
#ifndef RINGMAP
static void ixgbe_refresh_mbufs(struct rx_ring *, int);
+#else
+void ixgbe_refresh_mbufs(struct rx_ring *, int);
#endif
static int ixgbe_xmit(struct tx_ring *, struct mbuf **);
@@ -657,6 +659,9 @@
#ifdef RINGMAP
+#if (__RINGMAP_DEB)
+ printf(RINGMAP_PREFIX" Descriptors Number: %d\n", adapter->num_rx_desc);
+#endif
ringmap_attach(dev, &ringmap_8259_f);
#endif
@@ -1319,6 +1324,8 @@
#ifdef RINGMAP
struct capt_object *co = NULL;
+
+ adapter->rm->funcs->delayed_isr(que);
#endif
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
@@ -1336,14 +1343,14 @@
IXGBE_TX_UNLOCK(txr);
#ifdef RINGMAP
- adapter->rm->funcs->sync_head(que);
+ adapter->rm->funcs->sync_head(que);
- /* Wakeup threads with not empty rings */
- SLIST_FOREACH(co, &adapter->rm->object_list, objects) {
- if (RING_NOT_EMPTY(co->ring)){
- wakeup(co->ring);
- }
+ /* TODO: don't wake up the all threads, only our thread! */
+ SLIST_FOREACH(co, &adapter->rm->object_list, objects) {
+ if (RING_NOT_EMPTY(co->ring)){
+ wakeup(co->ring);
}
+ }
#endif
if (more) {
@@ -1426,11 +1433,12 @@
bool more_tx, more_rx;
u32 newitr = 0;
+ ++que->irqs;
+
#ifdef RINGMAP
struct capt_object *co = NULL;
adapter->rm->funcs->delayed_isr(que);
#endif
- ++que->irqs;
more_rx = ixgbe_rxeof(que, adapter->rx_process_limit);
@@ -1443,7 +1451,7 @@
#ifdef RINGMAP
adapter->rm->funcs->sync_head(que);
- /* Wakeup threads with not empty rings */
+ /* TODO: Only our co not all */
SLIST_FOREACH(co, &adapter->rm->object_list, objects) {
if (RING_NOT_EMPTY(co->ring)){
wakeup(co->ring);
@@ -3432,20 +3440,31 @@
*
**********************************************************************/
#ifndef RINGMAP
-static void
+static
+#else
+void
+#endif
ixgbe_refresh_mbufs(struct rx_ring *rxr, int limit)
{
struct adapter *adapter = rxr->adapter;
+#ifndef RINGMAP
bus_dma_segment_t hseg[1];
+#endif
bus_dma_segment_t pseg[1];
struct ixgbe_rx_buf *rxbuf;
+#ifndef RINGMAP
struct mbuf *mh, *mp;
+#else
+ struct mbuf *mp;
+#endif
+
int i, nsegs, error, cleaned;
i = rxr->next_to_refresh;
cleaned = -1; /* Signify no completions */
while (i != limit) {
rxbuf = &rxr->rx_buffers[i];
+#ifndef RINGMAP
if ((rxbuf->m_head == NULL) && (rxr->hdr_split)) {
mh = m_gethdr(M_DONTWAIT, MT_DATA);
if (mh == NULL)
@@ -3470,9 +3489,13 @@
htole64(hseg[0].ds_addr);
}
+ /* RINGMAP: Don't allocate new buffers! */
if (rxbuf->m_pack == NULL) {
mp = m_getjcl(M_DONTWAIT, MT_DATA,
M_PKTHDR, adapter->rx_mbuf_sz);
+#else
+ mp = rxbuf->m_pack;
+#endif
if (mp == NULL)
goto update;
mp->m_pkthdr.len = mp->m_len = adapter->rx_mbuf_sz;
@@ -3490,7 +3513,9 @@
BUS_DMASYNC_PREREAD);
rxr->rx_base[i].read.pkt_addr =
htole64(pseg[0].ds_addr);
+#ifndef RINGMAP
}
+#endif
cleaned = i;
/* Calculate next index */
@@ -3500,12 +3525,14 @@
rxr->next_to_refresh = i;
}
update:
+
+#ifndef RINGMAP
if (cleaned != -1) /* If we refreshed some, bump tail */
IXGBE_WRITE_REG(&adapter->hw,
IXGBE_RDT(rxr->me), cleaned);
+#endif
return;
}
-#endif /* !RINGMAP */
/*********************************************************************
*
@@ -3927,6 +3954,7 @@
/* Set up the redirection table */
for (i = 0, j = 0; i < 128; i++, j++) {
if (j == adapter->num_queues) j = 0;
+ /* TODO: do it more beautiful */
#ifndef RINGMAP
reta = (reta << 8) | (j * 0x11);
#else
@@ -4288,8 +4316,9 @@
** that determines what we are
*/
sendmp = rbuf->fmp;
+#ifndef RINGMAP
rbuf->m_pack = rbuf->fmp = NULL;
-
+#endif
if (sendmp != NULL) /* secondary frag */
sendmp->m_pkthdr.len += mp->m_len;
else {
@@ -4335,7 +4364,7 @@
#ifndef RINGMAP
-/* RINGMAP: Do not send packet to the IP-stack. Andd do not refresh */
+/* RINGMAP: Do not send packet to the IP-stack. And do not refresh */
/* Now send to the stack or do LRO */
if (sendmp != NULL)
==== //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ixgbe.h#6 (text+ko) ====
==== //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ringmap_8259.h#5 (text+ko) ====
@@ -27,17 +27,20 @@
#define HW_WRITE_REG(que, reg, val) \
RINGMAP_HW_WRITE_REG(HW_STRUCT(que), (reg), (val))
-#define RINGMAP_HW_READ_HEAD(que) \
+
+#define HW_READ_HEAD(que) \
HW_READ_REG((que), HW_RDH(que))
-#define RINGMAP_HW_SYNC_HEAD(que, ring) \
- SW_HEAD(ring) = RINGMAP_HW_READ_HEAD(que);
+#define HW_READ_TAIL(que) \
+ HW_READ_REG((que), HW_RDT(que))
-#define RINGMAP_HW_WRITE_TAIL(que, val) \
+#define HW_WRITE_TAIL(que, val) \
HW_WRITE_REG((que), HW_RDT(que), (val))
+
+#define RINGMAP_HW_SYNC_HEAD(que, ring) \
+ SW_HEAD(ring) = HW_READ_HEAD(que);
+
#define RINGMAP_HW_SYNC_TAIL(que, ring) \
- RINGMAP_HW_WRITE_TAIL((que), SW_TAIL(ring))
+ HW_WRITE_TAIL((que), SW_TAIL(ring))
-#define RINGMAP_HW_READ_TAIL(que) \
- HW_READ_REG((que), HW_RDT(que))
==== //depot/projects/soc2010/ringmap/current/sys/dev/ixgbe/ringmap_ixgbe.c#6 (text+ko) ====
@@ -18,6 +18,19 @@
#include "ixgbe.h"
#include "ringmap_8259.h"
+
+/* External things */
+extern devclass_t ixgbe_devclass;
+
+extern void ixgbe_enable_intr(struct adapter *);
+extern void ixgbe_disable_intr(struct adapter *);
+extern void ixgbe_refresh_mbufs(struct rx_ring *, int);
+
+extern void ringmap_print_slot(struct ring *, unsigned int);
+extern void print_capt_obj(struct capt_object *);
+/*******************/
+
+
int rm_8259_set_ringmap_to_adapter(device_t, struct ringmap *);
struct ringmap * rm_8259_get_ringmap_p(device_t);
device_t rm_8259_get_device_p(struct cdev *);
@@ -28,7 +41,6 @@
void rm_8259_interrupt(void *);
void rm_8259_delayed_interrupt(void *);
int rm_8259_print_ring_pointers(void *);
-void rm_8259_sync_head_tail(void *);
void rm_8259_sync_tail(void *);
void rm_8259_sync_head(void *);
void rm_8259_delayed_interrupt_per_packet(void *, int);
@@ -37,12 +49,6 @@
struct ix_queue * rm_8259_get_free_queue(device_t);
struct capt_object * get_capt_obj(void *context);
-extern devclass_t ixgbe_devclass;
-extern void ixgbe_enable_intr(struct adapter *);
-extern void ixgbe_disable_intr(struct adapter *);
-extern void ringmap_print_slot(struct ring *, unsigned int);
-extern void print_capt_obj(struct capt_object *);
-
struct ringmap_functions ringmap_8259_f = {
rm_8259_set_ringmap_to_adapter,
@@ -51,7 +57,6 @@
rm_8259_interrupt,
rm_8259_delayed_interrupt,
rm_8259_delayed_interrupt_per_packet,
- rm_8259_sync_head_tail,
rm_8259_sync_tail,
rm_8259_sync_head,
rm_8259_set_slot,
@@ -61,6 +66,7 @@
};
+
/*
* Set pointer to ringmap in the adapter structure.
*/
@@ -80,36 +86,18 @@
}
-/*
- * This function synchronize the tail and head hardware registers
- * with head and tail software varibles, that are visible from
- * software process.
- *
- * Synchronisation rules:
- * 1. SYNC_HEAD: ring->kernrp = RDH
- * 2. SYNC_TAIL: RDT = ring->userrp
- */
void
-rm_8259_sync_head_tail(void *context)
-{
- rm_8259_sync_tail(context);
- rm_8259_sync_head(context);
-}
-
-
-void
rm_8259_sync_tail(void *context)
{
struct ix_queue *que = (struct ix_queue *)context;
struct adapter *adapter = que->adapter;
struct capt_object *co = NULL;
-
+
RINGMAP_LOCK(adapter->rm);
- if (adapter->rm->open_cnt) {
- co = get_capt_obj(que);
- if (co != NULL) {
- RINGMAP_HW_SYNC_TAIL(que, co->ring);
- }
+ co = get_capt_obj(que);
+ if (co != NULL) {
+ ixgbe_refresh_mbufs(que->rxr, SW_TAIL(co->ring));
+ RINGMAP_HW_SYNC_TAIL(que, co->ring);
}
RINGMAP_UNLOCK(adapter->rm);
}
@@ -123,35 +111,14 @@
struct capt_object *co = NULL;
RINGMAP_LOCK(adapter->rm);
- if (adapter->rm->open_cnt) {
- co = get_capt_obj(que);
- if (co != NULL) {
- RINGMAP_HW_SYNC_HEAD(que, co->ring);
- } else {
- RINGMAP_ERROR(There is no capturing object associated with queue);
- }
- }
+ co = get_capt_obj(que);
+ if (co != NULL) {
+ RINGMAP_HW_SYNC_HEAD(que, co->ring);
+ }
RINGMAP_UNLOCK(adapter->rm);
}
-struct capt_object *
-get_capt_obj(void *queue)
-{
- struct ix_queue *que = (struct ix_queue *)queue;
- struct adapter *adapter = que->adapter;
- struct ringmap *rm = adapter->rm;
- struct capt_object *co = NULL;
-
- SLIST_FOREACH(co, &rm->object_list, objects) {
- if (co->que == que)
- return (co);
- }
-
- return (co);
-}
-
-
/*
* This should be called from ISR. Other interrupts are disallowed!
* It means the functions must be as small as possible
@@ -172,19 +139,18 @@
{
struct ix_queue *que = (struct ix_queue *)context;
struct adapter *adapter = (struct adapter *)que->adapter;
- struct timeval last_ts;
struct capt_object *co = NULL;
RINGMAP_LOCK(adapter->rm);
+
+ adapter->rm->interrupts_counter++;
+
if ( adapter->rm->open_cnt > 0 ) {
co = get_capt_obj(que);
if (co != NULL) {
- adapter->rm->interrupts_counter++;
- getmicrotime(&last_ts);
- co->ring->last_ts = last_ts;
+ co->ring->intr_num = que->irqs;
+ getmicrotime(&co->ring->last_ts);
rm_8259_sync_tail(context);
- } else {
- RINGMAP_ERROR(There is no capturing object associated with queue);
}
}
RINGMAP_UNLOCK(adapter->rm);
@@ -203,19 +169,28 @@
RINGMAP_LOCK(rm);
-#if (RINGMAP_INTR_DEB)
- rm_8259_print_ring_pointers(que);
-#endif
+ if (slot_num >= SLOTS_NUMBER){
+ RINGMAP_ERROR(STOP! ERROR! Unallowed slot Number!);
+ goto out;
+ }
+
if (adapter->rm->open_cnt) {
co = get_capt_obj(que);
if (co != NULL) {
- co->ring->slot[slot_num].intr_num = que->irqs;
+
+#if (RINGMAP_INTR_DEB)
+ printf(RINGMAP_PREFIX"[%s] Slot = %d\n", __func__, slot_num);
+ rm_8259_print_ring_pointers(que);
+ PRINT_RING_PTRS(co->ring);
+#endif
+ co->ring->slot[slot_num].intr_num = co->ring->intr_num;
co->ring->slot[slot_num].ts = co->ring->last_ts;
- } else {
- RINGMAP_ERROR(There is no capturing object associated with queue);
+ co->ring->slot[slot_num].is_ok = 1;
}
}
+out:
+
RINGMAP_UNLOCK(rm);
RINGMAP_INTR(end);
@@ -231,12 +206,11 @@
printf("[%s] Set slot: %d\n", __func__, slot_num);
#endif
+ /* First check the pointers */
if (que == NULL) {
RINGMAP_ERROR(Null pointer to the queue);
goto fail;
}
- /* First check pointers */
-//TODO;
if (GET_MBUF_P(que, slot_num) == NULL){
RINGMAP_ERROR(Pointer to mbuf is NULL);
goto fail;
@@ -246,7 +220,7 @@
goto fail;
}
- /* Now if everything is Ok, we can initialize ring pointers */
+ /* Now if everything is Ok, we can initialize slots variables */
ring->slot[slot_num].mbuf.kern =
(vm_offset_t)GET_MBUF_P(que, slot_num);
ring->slot[slot_num].mbuf.phys =
@@ -316,8 +290,6 @@
}
-
-
/*
* Returns pointer to ringmap structure
*/
@@ -361,6 +333,7 @@
}
+/* Return a queue that is not associate with any capturing objects */
struct ix_queue *
rm_8259_get_free_queue(device_t dev)
{
@@ -374,9 +347,6 @@
que = adapter->queues;
rm = adapter->rm;
- /*
- * Look for the queue that is not used by any capturing object (co)
- */
for (i = 0; (i < adapter->num_queues); i++, que++) {
j = 0;
SLIST_FOREACH(co, &rm->object_list, objects) {
@@ -390,6 +360,7 @@
}
+/* Associate the capturing object with the queue */
int
rm_8259_set_queue(struct capt_object *co, unsigned int queue_num)
{
@@ -397,12 +368,18 @@
struct adapter *adapter;
int err = -1;
+ RINGMAP_FUNC_DEBUG(start);
+
if (co->rm != NULL) {
dev = co->rm->dev;
adapter = (struct adapter *)device_get_softc(dev);
+#if (__RINGMAP_DEB)
+ printf("[%s] Before initialization\n", __func__);
+ print_capt_obj(co);
+#endif
if (queue_num < adapter->num_queues) {
- co->que = &adapter->queues[queue_num];
+ co->que = &(adapter->queues[queue_num]);
err = 0;
} else {
RINGMAP_ERROR(Wrong queue number);
@@ -411,24 +388,48 @@
RINGMAP_ERROR(Capturing object is not associated with ringmap);
}
+#if (__RINGMAP_DEB)
+ printf("[%s] After initialization\n", __func__);
+ print_capt_obj(co);
+#endif
+
+ RINGMAP_FUNC_DEBUG(end);
+
return (err);
}
-
+
+struct capt_object *
+get_capt_obj(void *queue)
+{
+ struct ix_queue *que = (struct ix_queue *)queue;
+ struct adapter *adapter = que->adapter;
+ struct ringmap *rm = adapter->rm;
+ struct capt_object *co = NULL;
+
+ SLIST_FOREACH(co, &rm->object_list, objects) {
+ if (co->que == queue)
+ return (co);
+ }
+
+ return (co);
+}
+
+
int
rm_8259_print_ring_pointers(void *context)
{
struct ix_queue *que = (struct ix_queue *)context;
unsigned int rdt, rdh;
- rdh = RINGMAP_HW_READ_HEAD(que);
- rdt = RINGMAP_HW_READ_TAIL(que);
+ rdt = HW_READ_TAIL(que);
+ rdh = HW_READ_HEAD(que);
printf("\n== +++++++++ RING POINTERS ++++++++++++ \n");
- printf("== + Queue Number: %d\n", que->rxr->me);
+ printf("== + Queue Number: %d\n", que->rxr->me);
printf("== + \n");
+ printf("== + HW TAIL = %d (USER POINTER)\n", rdt);
printf("== + HW HEAD = %d (KERN POINTER)\n", rdh);
- printf("== + HW TAIL = %d (USER POINTER)\n", rdt);
printf("== ++++++++++++++++++++++++++++++++++++++ \n\n");
return (0);
==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#36 (text+ko) ====
@@ -177,7 +177,7 @@
RINGMAP_LOCK(rm);
/* TODO: set max number of threads in the ringmap struct as a variable */
- if (rm->open_cnt == RINGMAP_MAX_THREADS){
+ if (rm->open_cnt == RINGMAP_MAX_THREADS) {
RINGMAP_ERROR(Can not open device!);
err = EIO; goto out;
@@ -227,7 +227,15 @@
/* The next should be probably done in the ioctl() */
#ifdef DEFAULT_QUEUE
- rm->funcs->set_queue(co, DEFAULT_QUEUE);
+ /* Associate the capturing object with a queue */
+ if (rm->funcs->set_queue(co, DEFAULT_QUEUE) == -1) {
+ RINGMAP_ERROR(Can not associate que with the capturing object!);
+ contigfree(ring, sizeof(struct ring), M_DEVBUF);
+
+ err = EIO; goto out;
+ }
+
+ /* Init ring-slots with mbufs and packets adrresses */
for (i = 0 ; i < SLOTS_NUMBER ; i++){
if (rm->funcs->set_slot(ring, co->que, i) == -1){
RINGMAP_ERROR(Ring initialization failed!);
@@ -241,6 +249,10 @@
}
#endif
+ /*
+ * Insert the capturing object in the single linked list
+ * the head of the list is in the ringmap structure
+ */
SLIST_INSERT_HEAD(&rm->object_list, co, objects);
/*
@@ -255,7 +267,7 @@
err = EIO; goto out;
}
- rm->funcs->sync_head_tail(co->que);
+ rm->funcs->sync_tail(co->que);
rm->open_cnt++;
#if (__RINGMAP_DEB)
@@ -272,7 +284,6 @@
}
-
int
ringmap_close(struct cdev *cdev, int flag, int otyp, struct thread *td)
{
@@ -289,6 +300,42 @@
}
+void
+clear_capt_object(void * data)
+{
+ struct capt_object *co = NULL;
+ struct ringmap *rm = NULL;
+
+ RINGMAP_FUNC_DEBUG(start);
+
+ if (data != NULL) {
+ co = (struct capt_object *)data;
+ rm = co->rm;
+
+ RINGMAP_LOCK(rm);
+#if (__RINGMAP_DEB)
+ printf("[%s] Object to delete:\n", __func__);
+ print_capt_obj(co);
+#endif
+ if (co->ring != NULL)
+ contigfree(co->ring, sizeof(struct ring), M_DEVBUF);
+
+ SLIST_REMOVE(&rm->object_list, co, capt_object, objects);
+ FREE(co, M_DEVBUF);
+ data = NULL;
+ } else {
+ RINGMAP_FUNC_DEBUG(NULL pointer to the capturing object!);
+ }
+
+ if (rm->open_cnt)
+ rm->open_cnt--;
+
+ RINGMAP_UNLOCK(rm);
+
+ RINGMAP_FUNC_DEBUG(end);
+}
+
+
int
ringmap_mmap_single(struct cdev *cdev, vm_ooffset_t *offset,
vm_size_t size, struct vm_object **object, int nprot)
@@ -349,29 +396,31 @@
{
struct ringmap *rm = NULL;
struct capt_object *co = NULL;
- vm_paddr_t phys_ring;
+ vm_paddr_t phys_ring_addr;
- RINGMAP_FUNC_DEBUG(end);
+ RINGMAP_FUNC_DEBUG(start);
/* Get pointer to the ringmap structure */
rm = get_ringmap_p(get_device_p(cdev));
if (devfs_get_cdevpriv((void **)&co)) {
- RINGMAP_ERROR(Wrong capturing object!);
+ RINGMAP_ERROR(Can not get capturing object);
return(EIO);
}
+
if (co->td != curthread ){
RINGMAP_ERROR(Wrong capturing object!);
return(EIO);
}
- phys_ring = vtophys(co->ring);
+ phys_ring_addr = vtophys(co->ring);
+
#if (__RINGMAP_DEB)
print_capt_obj(co);
PRINT_RING_PTRS(co->ring);
#endif
- uiomove(&phys_ring, sizeof(phys_ring), uio);
+ uiomove(&phys_ring_addr, sizeof(phys_ring_addr), uio);
RINGMAP_FUNC_DEBUG(end);
@@ -393,9 +442,9 @@
printf("[%s] pid = %d\n", __func__, td->td_proc->p_pid);
#endif
- /* Eliminate it */
+ /* Eliminate it. Use devfs_* funcs */
rm = get_ringmap_p(get_device_p(cdev));
- if ( rm == NULL ){
+ if (rm == NULL) {
RINGMAP_ERROR(NULL pointer. ioctl can not be accomplished);
/* TODO: look whether ENODEV is a correctly for this case */
@@ -431,12 +480,15 @@
rm->funcs->disable_intr(rm->dev);
RINGMAP_IOCTL(interrupts schould be disabled);
break;
-
+
/* Sleep and wait for new packets */
case IOCTL_SLEEP_WAIT:
+ /* Count how many times we should wait for new packets */
co->ring->user_wait_kern++;
- rm->funcs->sync_head_tail(co->que);
+
+ /* Set adapter TAIL register */
+ rm->funcs->sync_tail(co->que);
#if (__RINGMAP_DEB)
print_capt_obj(co);
@@ -450,14 +502,10 @@
if (RING_IS_EMPTY(co->ring)) {
RINGMAP_IOCTL(Sleep and wait for new packets);
- err_sleep = tsleep(co->ring, (PRI_MIN) | PCATCH, "ioctl", 0);
+ err_sleep = tsleep(co->ring, (PRI_MAX_ITHD) | PCATCH, "ioctl", 0);
}
break;
- case IOCTL_SYNC_HEAD_TAIL:
- rm->funcs->sync_head_tail(co->que);
- break;
-
/* Synchronize sowftware ring-tail with hardware-ring-tail (RDT) */
case IOCTL_SYNC_TAIL:
rm->funcs->sync_tail(co->que);
@@ -467,59 +515,24 @@
RINGMAP_ERROR("Undefined command!");
return (ENODEV);
}
-
+
RINGMAP_IOCTL(end);
-
+
return (err);
}
void
-clear_capt_object(void * data)
-{
- struct capt_object *co = NULL;
- struct ringmap *rm = NULL;
-
- RINGMAP_FUNC_DEBUG(start);
-
- if (data != NULL) {
- co = (struct capt_object *)data;
- rm = co->rm;
-
- RINGMAP_LOCK(rm);
-#if (__RINGMAP_DEB)
- print_capt_obj(co);
-#endif
- if (co->ring != NULL)
- contigfree(co->ring, sizeof(struct ring), M_DEVBUF);
-
- SLIST_REMOVE(&rm->object_list, co, capt_object, objects);
- FREE(co, M_DEVBUF);
- data = NULL;
- } else {
- RINGMAP_FUNC_DEBUG(NULL pointer to the capturing instance!);
- }
-
- if (rm->open_cnt)
- rm->open_cnt--;
-
- RINGMAP_UNLOCK(rm);
-
- RINGMAP_FUNC_DEBUG(end);
-}
-
-
-void
print_capt_obj(struct capt_object *co)
{
if (co != NULL) {
- printf("=== co->td->proc->pid: %d\n",
+ printf("\n=== co->td->proc->pid: %d\n",
co->td->td_proc->p_pid);
printf("=== Ring Kernel Addr:0x%X\n",
(unsigned int)co->ring);
- printf("=== Queue Kernel Addr:0x%X\n",
+ printf("=== Queue Kernel Addr:0x%X\n\n",
(unsigned int)co->que);
}
}
==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#36 (text+ko) ====
@@ -1,7 +1,7 @@
/*
* value for number of descriptors (a.k.a. slots in the ringbuffer)
*/
-#define SLOTS_NUMBER 16
+#define SLOTS_NUMBER 64
/*
* Prefix for name of device (for example /dev/ringmap0 will full name)
@@ -246,19 +246,19 @@
* DEBUG OUTPUT
*/
#ifndef RINGMAP_IOCTL_DEB
-#define RINGMAP_IOCTL_DEB 1
+#define RINGMAP_IOCTL_DEB 0
#else
#define RINGMAP_IOCTL_DEB 1
#endif
#ifndef RINGMAP_INTR_DEB
-#define RINGMAP_INTR_DEB 1
+#define RINGMAP_INTR_DEB 0
#else
#define RINGMAP_INTR_DEB 1
#endif
#ifndef __RINGMAP_DEB
-#define __RINGMAP_DEB 1
+#define __RINGMAP_DEB 0
#endif
#define RINGMAP_PREFIX "--> RINGMAP: "
@@ -304,14 +304,6 @@
(unsigned int)ring->slot[i].mbuf.kern); \
} while (0);
-#define PRINT_DECRIPTOR_ADDR(ring, i) \
- do { \
- printf("=+= descr.user=0x%X, descr.phys=0x%X, descr.kern=0x%X\n", \
- (unsigned int)ring->slot[i].descriptor.user, \
- (unsigned int)ring->slot[i].descriptor.phys, \
- (unsigned int)ring->slot[i].descriptor.kern); \
- } while (0);
-
#define PRINT_SLOT(ring, i) \
if (((ring) != NULL) && ((i) < SLOTS_NUMBER)){ \
printf("\n=+= ==================================\n"); \
@@ -322,7 +314,6 @@
(ring)->slot[(i)].ts.tv_usec))); \
printf("=+= Accepted: %d\n", (ring)->slot[(i)].is_ok); \
printf("=+= -------------------------\n"); \
- PRINT_DECRIPTOR_ADDR(ring, i); \
PRINT_MBUF_ADDR(ring, i); \
PRINT_PACKET_ADDR(ring, i); \
printf("=+= -------------------------\n"); \
@@ -339,13 +330,13 @@
#define PRINT_RING_PTRS(ring) \
do { \
- printf("=+= [%s] pid = %d\n", __func__, ring->pid); \
+ printf("\n=+= [%s] pid = %d\n", __func__, ring->pid); \
PRINT_TAIL(ring) \
PRINT_HEAD(ring) \
+ printf("\n"); \
} while (0);
-
#ifdef _KERNEL
#include <net/ringmap_kernel.h>
#endif
==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap_kernel.h#6 (text+ko) ====
@@ -100,7 +100,6 @@
* the value of ring->userrp. Kernel will check this value and set it
* into the hardware TAIL-register.
*/
- void (*sync_head_tail)(void *);
void (*sync_tail)(void *);
void (*sync_head)(void *);
==== //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#17 (text+ko) ====
@@ -3,18 +3,6 @@
RINGMAP_BUILD_DIR=../current/sys/modules/ringmap/
LIBPCAP_BUILD_DIR=../current/lib/libpcap/
-check_make_vars() {
- cat /etc/make.conf | grep "RINGMAP" >/dev/null
- if [ $? -eq 1 ]
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list