Hi netdev mailing list and Michael,

I am having problem getting proper ptr_ring operation where one
ptr_ring entry (val1=2 for item_recv_pop) is missing from the void **
queue

Did I initialize the ring pointers (ptr_ring_init()) correctly ?

See the following for more context:

https://i.imgur.com/xWJOH1G.png
https://gist.github.com/promach/7716ee8addcaa33fda140d74d1ad94d6#file-riffa_driver-c-L663
https://gist.github.com/promach/65e9331d55a43a2815239430a28e29c6#file-circ_ring-c-L44


struct ptr_ring * init_circ_queue(int len)
{
        struct ptr_ring * q;

        q = kzalloc(sizeof(struct ptr_ring), GFP_KERNEL);
        if (q == NULL) {
                DEBUG_MSG(KERN_ERR "Not enough memory to allocate ptr_ring");
                return NULL;
        }

        // creates an array of length 'len' where each array location
can store a struct * item
        if(ptr_ring_init(q, len, GFP_KERNEL) != 0) {
                DEBUG_MSG(KERN_ERR "Not enough memory to allocate
ptr_ring array");
                return NULL;
        }

        return q;
}



                while ((nomsg = pop_circ_queue(sc->recv[chnl]->msgs,
&item_recv_pop))) {
                        prepare_to_wait(&sc->recv[chnl]->waitq, &wait,
TASK_INTERRUPTIBLE);
                        // Another check before we schedule.
                        if ((nomsg =
pop_circ_queue(sc->recv[chnl]->msgs, &item_recv_pop)))
                                tymeout = schedule_timeout(tymeout);
                        finish_wait(&sc->recv[chnl]->waitq, &wait);
                        if (signal_pending(current)) {
                                free_sg_buf(sc, sc->recv[chnl]->sg_map_0);
                                free_sg_buf(sc, sc->recv[chnl]->sg_map_1);
                                return -ERESTARTSYS;
                        }
                        if (!nomsg)
                                break;
                        if (tymeout == 0) {
                                printk(KERN_ERR "riffa: fpga:%d
chnl:%d, recv timed out\n", sc->id, chnl);
                                /*free_sg_buf(sc, sc->recv[chnl]->sg_map_0);
                                free_sg_buf(sc, sc->recv[chnl]->sg_map_1);
                                return (unsigned int)(recvd>>2);*/
                        }
                }
                tymeout = tymeouto;
                msg_type = item_recv_pop.val1;
                msg = item_recv_pop.val2;
                DEBUG_MSG(KERN_INFO "recv msg_type: %u\n", msg_type);


Regards,
Phung

Reply via email to