1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * * Based on ksocknal, qswnal, and gmnal
6 * * Copyright (C) 2003 LANL
7 * * Author: HB Chen <hbchen@lanl.gov>
8 * * Los Alamos National Lab
10 * * Portals is free software; you can redistribute it and/or
11 * * modify it under the terms of version 2 of the GNU General Public
12 * * License as published by the Free Software Foundation.
14 * * Portals is distributed in the hope that it will be useful,
15 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * * GNU General Public License for more details.
19 * * You should have received a copy of the GNU General Public License
20 * * along with Portals; if not, write to the Free Software
21 * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 VAPI_ret_t ibnal_send_recv_self_testing()
32 VAPI_sr_desc_t sr_desc;
33 VAPI_sg_lst_entry_t sr_sg;
40 int buf_length = KB_32;
41 VAPI_wc_desc_t comp_desc;
46 printk("ibnal_send_recv_self_testing\n");
48 memset(&sbuf, 'a', KB_32);
49 memset(&rbuf, ' ', KB_32);
56 sr_desc.opcode = VAPI_SEND;
57 sr_desc.comp_type = VAPI_SIGNALED;
59 // scatter and gather info
61 sr_sg.lkey = MSbuf_list[buf_id].mr.l_key; // use send MR
62 sr_sg.addr = (VAPI_virt_addr_t)(MT_virt_addr_t) MSbuf_list[buf_id].buf_addr;
64 // copy data to register send buffer
65 memcpy(&sr_sg.addr, &buf, buf_length);
67 sr_desc.sg_lst_p = &sr_sg;
68 sr_desc.sg_lst_len = 1; // only 1 entry is used
70 sr_desc.set_se = FALSE;
73 // call VAPI_post_sr to send out this data
74 vstat = VAPI_post_sr(qp->hca_hndl, qp->qp_hndl, &sr_desc);
76 if (vstat != VAPI_OK) {
77 printk("VAPI_post_sr failed (%s).\n",VAPI_strerror(vstat));
80 printk("VAPI_post_sr success.\n");
82 // poll for completion
84 while( loop_count < 100 ){
85 vstat = VAPI_poll_cq(qp->hca_hndl, qp->cq_hndl, &comp_desc);
86 if( vstat == VAPI_OK ) {
87 if(comp_desc.opcode == VAPI_CQE_SQ_SEND_DATA ) {
89 printk("received SQ completion\n");
92 if(comp_desc.opcode == VAPI_CQE_RQ_SEND_DATA ) {
93 /* RECEIVE completion */
94 printk("received RQ completion\n");
95 memcpy(&rbuf, (char *) MRbuf_list[buf_id].buf_addar, KB_32);
99 n = memcmp($sbuf, &rbuf, KB_32);
100 printk("compare sbuf and rbuf n = %d\n", n);
104 printk("unexpected completion opcode %d \n", comp_desc.opcode);
110 schedule_timeout(500);
113 printk("end of ibnal_self_send_recv_testing\n");