Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[fs/lustre-release.git] / lustre / portals / knals / ibnal / ibnal_send_recv_self_testing.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *  *
4  *  * Based on ksocknal, qswnal, and gmnal
5  *  *
6  *  * Copyright (C) 2003 LANL
7  *  *   Author: HB Chen <hbchen@lanl.gov>
8  *  *   Los Alamos National Lab
9  *  *
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.
13  *  *
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.
18  *  *
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.
22  *  *
23  *  */
24
25 #include "ibnal.h"
26
27
28
29 VAPI_ret_t ibnal_send_recv_self_testing()
30 {
31  VAPI_ret_t           vstat;
32  VAPI_sr_desc_t       sr_desc;
33  VAPI_sg_lst_entry_t  sr_sg;
34  QP_info              *qp;
35  VAPI_wr_id_t         send_id;
36  int                  buf_id;
37  char                 sbuf[KB_32];
38  char                 rbuf[KB_32];
39  int                  i;
40  int                  buf_length = KB_32;
41  VAPI_wc_desc_t       comp_desc;
42  int                  num_send = 1;
43  int                  loop_count = 0;
44
45
46  printk("ibnal_send_recv_self_testing\n");
47
48  memset(&sbuf, 'a', KB_32);
49  memset(&rbuf, ' ', KB_32);
50  
51  send_id = 2222; 
52  buf_id = 0;
53
54  qp = &QP_list[0];
55
56  sr_desc.opcode    = VAPI_SEND;
57  sr_desc.comp_type = VAPI_SIGNALED;
58
59  // scatter and gather info
60  sr_sg.len  = KB_32;
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;
63
64  // copy data to register send buffer
65  memcpy(&sr_sg.addr, &buf, buf_length);
66
67  sr_desc.sg_lst_p = &sr_sg;
68  sr_desc.sg_lst_len = 1; // only 1 entry is used
69  sr_desc.fence = TRUE;
70  sr_desc.set_se = FALSE;
71
72
73  // call VAPI_post_sr to send out this data
74  vstat = VAPI_post_sr(qp->hca_hndl, qp->qp_hndl, &sr_desc);
75
76  if (vstat != VAPI_OK) {
77    printk("VAPI_post_sr failed (%s).\n",VAPI_strerror(vstat));
78  }
79
80  printk("VAPI_post_sr success.\n");
81
82  // poll for completion
83
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 ) {
88           /* SEND completion */
89          printk("received SQ completion\n");
90        }
91        else { 
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);
96             
97             int n;
98
99             n = memcmp($sbuf, &rbuf, KB_32);
100             printk("compare sbuf and rbuf  n = %d\n", n); 
101             
102           }
103           else  {
104             printk("unexpected completion opcode %d \n", comp_desc.opcode);
105           }
106        }
107    }
108
109    loop_count++; 
110    schedule_timeout(500);
111  }
112
113  printk("end of ibnal_self_send_recv_testing\n");
114
115
116 }