1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 #define UT_MSG_MODULE_NAME "utcli "
9 module_param(pkt_size,int,S_IRUGO);
11 module_param(get,int,S_IRUGO);
13 module_param(put,int,S_IRUGO);
15 module_param(auto_unlink,int,S_IRUGO);
17 module_param(nid,charp,S_IRUGO);
19 static int __init utcli_init(void)
22 lnet_process_id_t target;
23 lnet_process_id_t mypid;
29 * Put and get really control the same thing
33 if(!put && !get)get=1;
35 PJK_UT_MSG("utcli_init %s\n",get==0?"PUT":"GET");
36 PJK_UT_MSG("pkt_size=%d\n",pkt_size);
37 PJK_UT_MSG("auto_unlink=%d\n",auto_unlink);
38 PJK_UT_MSG("nid=%s\n",nid);
41 CERROR("NID Must be specified\n");
45 PJK_UT_MSG("LIBCFS_ALLOC\n");
46 LIBCFS_ALLOC (buffer, pkt_size);
49 CERROR ("Unable to allocate out_buf (%d bytes)\n", pkt_size);
53 PJK_UT_MSG("LNetNiInit()\n");
57 CERROR ("LNetNIInit: error %d\n", rc);
63 PJK_UT_MSG("my.nid="LPX64"\n",mypid.nid);
64 PJK_UT_MSG("my.pid=0x%x\n",mypid.pid);
67 PJK_UT_MSG("LNetEQAlloc\n");
69 64, /* max number of envents why 64? */
70 handler, /* handler callback */
71 &eqh); /* output handle */
73 CERROR("LNetEQAlloc failed %d\n",rc);
79 md.threshold = auto_unlink ? (get ? 2 : 1) : 15;
83 md.options |= LNET_MD_OP_GET;
85 md.options |= LNET_MD_OP_PUT;
86 md.options |= LNET_MD_ACK_DISABLE;
91 PJK_UT_MSG("LNetMDBind()\n");
95 &mdh))) /* out handle */
97 CERROR ("LNetMDBind error %d\n", rc);
102 target.nid = libcfs_str2nid(nid);
104 PJK_UT_MSG("target.nid="LPX64"\n",target.nid);
109 PJK_UT_MSG("LNetGet()\n");
113 target, /* peer "address" */
114 UT_PORTAL, /* portal */
116 0))) /* header data */
118 CERROR("LNetGet %d error %d\n",i, rc);
123 PJK_UT_MSG("LNetPut()\n");
127 LNET_ACK_REQ, /* we want ack */
128 target, /* peer "address" */
129 UT_PORTAL, /* portal */
132 0))) /* header data */
134 CERROR("LNetPut %d error %d\n",i, rc);
141 PJK_UT_MSG("------------Waiting for SEND_END()------------\n");
143 while(i++ < 10 && seen == 0)
144 cfs_pause(cfs_time_seconds(1));
146 PJK_UT_MSG("------------------TIMEDOUT--------------------\n");
150 PJK_UT_MSG("------------Waiting for REPLY()------------\n");
152 while(i++ < 10 && seen == 1)
153 cfs_pause(cfs_time_seconds(1));
160 PJK_UT_MSG("------------------COMPLETE--------------------\n");
162 PJK_UT_MSG("------------------TIMEDOUT--------------------\n");
168 PJK_UT_MSG("LNetEQWait()\n");
169 rc = LNetEQWait(eqh,&ev);
175 PJK_UT_MSG("LNetMDUnlink()\n");
179 PJK_UT_MSG("------------Waiting for UNLINK ------------\n");
181 while(i++ < 120 && seen_unlink == 0)
182 cfs_pause(cfs_time_seconds(1));
185 cfs_pause(cfs_time_seconds(1));
187 PJK_UT_MSG("LNetEQFree()\n");
190 PJK_UT_MSG("LNetNiFini()\n");
194 LIBCFS_FREE(buffer,pkt_size);
200 static void /*__exit*/ utcli_cleanup(void)
204 } /* utcli_cleanup() */
207 MODULE_AUTHOR("PJ Kirner (CFS)");
208 MODULE_DESCRIPTION("A simple LNET Unit Test module");
209 MODULE_LICENSE("GPL");
211 cfs_module(ut_cli, "1.0.0", utcli_init, utcli_cleanup);