[openib-general] is wc valid if ib_poll_cq() returns zero

somenath somenath at veritas.com
Fri Jul 14 12:53:18 PDT 2006


Sean Hefty wrote:

> Can you also post your code, including the completion handler routines 
> and QP creation / initialization sections?
>
> - Sean


curretnly this is what I am trying to test, just to get one notification 
successfully with a proper wc element.
thanks, som.


int
recvio_complete(
        struct  ib_cq *cq,
        void *passed_arg) {
    io_complete(cq, passed_arg);
}

int
sendio_complete(
        struct  ib_cq *cq,
        void *passed_arg) {
    io_complete(cq, passed_arg);
}

int
io_complete(
        struct  ib_cq *cq,
        void *passed_arg)
{
    xxx_connection_t    *arg = passed_arg;
    xxx_status_t    stat = xxx_st_ok;
    struct ib_wc wc;
    int count = 0;

    if (count = ib_poll_cq(cq, 1, &wc) < 0) {
        stat = xxx_st_error;
        arg = NULL;
        goto error;
    }
    if(stat = ib_req_notify_cq(cq, IB_CQ_NEXT_COMP)) {
        stat = xxx_st_error;
        goto error;
    }
    if (count == 0) {
        stat = xxx_st_ok;
        goto error;
    }


    if ((arg != NULL) && (cq != NULL)) {
        io_process(conn_handle);
    } else {
        stat = xxx_st_error;
        goto error;
    }
error:
    return stat;
}

xxx_status_t
xxx_create_qpairs(
                                              xxx_connection_t *conn_handle)
{
    xxx_status_t        xxx_stat = xxx_st_ok;
    int                 ib_stat = 0;
    int entries_send, entries_recv;
    struct ib_qp_init_attr qp_attr =  { 0 };
    unsigned    long    flags;

    conn_handle->llp_send_cq =
    ib_create_cq(
            xxx_openib.xxx_device,
            sendio_complete,
            xxx_async_cb,
            conn_handle,
            XXX_SEND_CQ_DEPTH);
    if (IS_ERR(conn_handle->llp_send_cq)) {
        ib_stat = PTR_ERR(conn_handle->llp_send_cq);
        xxx_stat = map_ib_to_xxx_stat(ib_stat);
        goto free_out;
    }

    conn_handle->llp_recv_cq =
    ib_create_cq(
            xxx_openib.xxx_device,
            recvio_complete,
            xxx_async_cb,
            conn_handle,
            XXX_RECV_CQ_DEPTH);
    if (IS_ERR(conn_handle->llp_recv_cq)) {
        ib_stat = PTR_ERR(conn_handle->llp_recv_cq);
        xxx_stat = map_ib_to_xxx_stat(ib_stat);
        ib_destroy_cq(conn_handle->llp_send_cq);
        goto free_out;
    }
    if(ib_stat = ib_req_notify_cq(conn_handle->llp_send_cq, 
IB_CQ_NEXT_COMP)) {
        xxx_stat = map_ib_to_xxx_stat(ib_stat);
        ib_destroy_cq(conn_handle->llp_send_cq);
        ib_destroy_cq(conn_handle->llp_recv_cq);
        goto free_out;
    }
    if(ib_stat = ib_req_notify_cq(conn_handle->llp_recv_cq, 
IB_CQ_NEXT_COMP)) {
        xxx_stat = map_ib_to_xxx_stat(ib_stat);
        ib_destroy_cq(conn_handle->llp_recv_cq);
        goto free_out;
    }

    memset(&qp_attr, 0, sizeof qp_attr);
    qp_attr.event_handler = xxx_qevent_cb;
    qp_attr.qp_context = conn_handle;
    qp_attr.send_cq = conn_handle->llp_send_cq;
    qp_attr.recv_cq = conn_handle->llp_recv_cq;
                                                             
qp_attr.cap.max_send_wr = XXX_SENDQ_DEPTH;
    qp_attr.cap.max_recv_wr = XXX_RECVQ_DEPTH;
    qp_attr.cap.max_send_sge = 1;
    qp_attr.cap.max_recv_sge = 1;
    qp_attr.sq_sig_type = IB_SIGNAL_ALL_WR;
    qp_attr.qp_type = IB_QPT_RC;
    qp_attr.port_num = HCA_PRM_PORT; /* special QP types only */

    conn_handle->llp_qp =
        ib_create_qp(
            xxx_openib.xxx_global_pd,
            &qp_attr);
    if (IS_ERR(conn_handle->llp_qp)) {
        ib_destroy_cq(conn_handle->llp_send_cq);
        ib_destroy_cq(conn_handle->llp_recv_cq);
        ib_stat = PTR_ERR(conn_handle->llp_qp);
        xxx_stat = map_ib_to_xxx_stat(ib_stat);
        goto free_out;
    }
    xxx_modifyqp_init(conn_handle);

 free_out:
  return (xxx_stat);
}       102,1         68%
                      1,1           Top





More information about the general mailing list