Motr  M0
at_ut.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2016-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_UT
24 #include "lib/trace.h"
25 
26 #include "lib/memory.h"
27 #include "fop/fom.h"
28 #include "fop/fom_generic.h"
29 #include "reqh/reqh.h"
30 #include "reqh/reqh_service.h"
31 #include "rpc/rpc_opcodes.h"
32 #include "net/net.h"
33 #include "net/buffer_pool.h"
34 #include "ut/ut.h"
35 #include "rpc/rpc.h"
36 #include "rpc/rpclib.h"
37 #include "rpc/at.h"
38 #include "rpc/ut/at/at_ut.h"
39 #include "rpc/ut/at/at_ut_xc.h"
40 
41 struct atut_reqh {
44  struct m0_reqh aur_reqh;
46 };
47 
48 struct atut_clctx {
51 };
52 
53 #define SERVER_ENDPOINT_ADDR "0@lo:12345:34:1"
54 #define CLIENT_ENDPOINT_ADDR "0@lo:12345:34:2"
55 
56 static struct atut_reqh atreqh;
57 static struct atut_clctx at_cctx;
58 static struct m0_reqh_service *atsvc;
61 static const struct m0_fom_ops atfom_ops;
64 
65 /*************************************************/
66 /* RPC AT UT service */
67 /*************************************************/
68 
69 static int atsvc_start(struct m0_reqh_service *svc);
70 static void atsvc_stop(struct m0_reqh_service *svc);
71 static void atsvc_fini(struct m0_reqh_service *svc);
72 
73 static const struct m0_reqh_service_ops atsvc_ops = {
75  .rso_start = &atsvc_start,
76  .rso_stop = &atsvc_stop,
77  .rso_fini = &atsvc_fini
78 };
79 
80 static int atsvc_start(struct m0_reqh_service *svc)
81 {
82  return 0;
83 }
84 
85 static void atsvc_stop(struct m0_reqh_service *svc)
86 {
87 }
88 
89 static void atsvc_fini(struct m0_reqh_service *svc)
90 {
91  m0_free(svc);
92 }
93 
95  const struct m0_reqh_service_type *stype)
96 {
97  M0_ALLOC_PTR(*svc);
98  M0_ASSERT(*svc != NULL);
99  (*svc)->rs_type = stype;
100  (*svc)->rs_ops = &atsvc_ops;
101  return 0;
102 }
103 
106 };
107 
109  .rst_name = "at_ut",
110  .rst_ops = &atsvc_type_ops,
111  .rst_level = M0_RS_LEVEL_NORMAL,
112  .rst_typecode = M0_CST_DS1
113 };
114 
115 /*************************************************/
116 /* Helpers */
117 /*************************************************/
118 
119 static struct m0_fop *g_reqfop;
120 
121 static void req_fini(void)
122 {
124  g_reqfop = NULL;
125 }
126 
127 static void req_send(struct atut__req *req,
128  struct atut__rep **rep)
129 {
130  int rc;
131 
138  M0_ASSERT(rc == 0);
139  *rep = (struct atut__rep *)m0_fop_data(
141 }
142 
143 M0_INTERNAL void atut__bufdata_alloc(struct m0_buf *buf, size_t size,
144  struct m0_rpc_machine *rmach)
145 {
146  int rc;
148  rmach->rm_tm.ntm_dom);
149 
151  if (size < seg_size) {
152  rc = m0_buf_alloc(buf, size);
153  M0_UT_ASSERT(rc == 0);
154  } else {
156  M0_UT_ASSERT(buf->b_addr != NULL);
157  buf->b_nob = size;
158  }
159  memset(buf->b_addr, DATA_PATTERN, size);
160 }
161 
162 static struct m0_rpc_conn *client_conn(void)
163 {
165 }
166 
167 /*************************************************/
168 /* FOM/FOP */
169 /*************************************************/
170 
175 };
176 
177 static struct m0_sm_state_descr atfom_phases[] = {
178  [AT_LOAD] = {
179  .sd_name = "load",
180  .sd_allowed = M0_BITS(AT_LOAD_DONE)
181  },
182  [AT_LOAD_DONE] = {
183  .sd_name = "load-done",
184  .sd_allowed = M0_BITS(AT_REP_PREP, M0_FOPH_SUCCESS)
185  },
186  [AT_REP_PREP] = {
187  .sd_name = "prepare-reply",
188  .sd_allowed = M0_BITS(M0_FOPH_SUCCESS)
189  },
190 };
191 
192 static size_t atfom_home_locality(const struct m0_fom *fom)
193 {
194  return 1;
195 }
196 
197 static bool atdata_is_correct(const struct m0_buf *buf, uint32_t len)
198 {
199  return buf->b_nob == len &&
200  m0_forall(i, buf->b_nob,
201  ((char *)buf->b_addr)[i] == DATA_PATTERN);
202 }
203 
204 
205 static bool atbuf_check(const struct m0_rpc_at_buf *ab,
206  uint32_t len,
207  enum m0_rpc_at_type type)
208 {
209  bool ret = true;
210  const struct m0_buf *buf;
211 
212  if (ab->ab_type != type)
213  return false;
214 
215  switch (ab->ab_type) {
216  case M0_RPC_AT_EMPTY:
217  M0_UT_ASSERT(len == 0);
218  break;
219  case M0_RPC_AT_INLINE:
220  buf = &ab->u.ab_buf;
221  ret = atdata_is_correct(buf, len);
222  break;
223  case M0_RPC_AT_BULK_SEND:
224  ret = ab->u.ab_send.bdd_used == len;
225  break;
226  case M0_RPC_AT_BULK_RECV:
227  ret = ab->u.ab_recv.bdd_used == len;
228  break;
229  case M0_RPC_AT_BULK_REP:
230  ret = ab->u.ab_rep.abr_len == len;
231  break;
232  default:
233  M0_IMPOSSIBLE("Invalid AT type");
234  }
235  return ret;
236 }
237 
238 static void reqbuf_check(uint32_t test_id, const struct m0_buf *buf, int rc)
239 {
240  switch (test_id) {
241  case AT_TEST_INLINE_SEND:
242  M0_UT_ASSERT(rc == 0);
244  break;
245  case AT_TEST_INBULK_SEND:
246  M0_UT_ASSERT(rc == 0);
248  break;
249  case AT_TEST_INLINE_RECV:
252  case AT_TEST_INBULK_RECV:
253  M0_UT_ASSERT(rc == -EPROTO);
254  break;
255  default:
256  M0_IMPOSSIBLE("Unknown test id");
257  }
258 }
259 
260 static void load_check(uint32_t test_id, const struct m0_rpc_at_buf *ab,
261  int result)
262 {
263  switch (test_id) {
264  case AT_TEST_INLINE_SEND:
265  M0_UT_ASSERT(result == M0_FSO_AGAIN);
267  break;
268  case AT_TEST_INBULK_SEND:
269  M0_UT_ASSERT(result == M0_FSO_WAIT);
271  break;
272  case AT_TEST_INLINE_RECV:
275  M0_UT_ASSERT(result == M0_FSO_AGAIN);
277  break;
278  case AT_TEST_INBULK_RECV:
279  M0_UT_ASSERT(result == M0_FSO_AGAIN);
281  break;
282  default:
283  M0_IMPOSSIBLE("unknown test id");
284  }
285 }
286 
287 static void repbuf_fill(uint32_t test_id, struct m0_buf *buf)
288 {
289  struct m0_rpc_machine *rmach;
290 
292 
293  switch (test_id) {
294  case AT_TEST_INLINE_SEND:
295  case AT_TEST_INBULK_SEND:
296  *buf = M0_BUF_INIT0;
297  break;
298  case AT_TEST_INLINE_RECV:
301  break;
303  case AT_TEST_INBULK_RECV:
305  break;
306  default:
307  M0_IMPOSSIBLE("Unknown test id");
308  }
309 }
310 
311 static void reply_check(uint32_t test_id, const struct m0_rpc_at_buf *ab,
312  int result)
313 {
314  switch (test_id) {
315  case AT_TEST_INLINE_RECV:
317  M0_UT_ASSERT(result == M0_FSO_AGAIN);
319  break;
321  M0_UT_ASSERT(result == M0_FSO_AGAIN);
323  break;
324  case AT_TEST_INBULK_RECV:
325  M0_UT_ASSERT(result == M0_FSO_WAIT);
327  break;
328  default:
329  M0_IMPOSSIBLE("Unknown test id");
330  }
331 }
332 
333 static void reply_rc_check(uint32_t test_id, const struct m0_rpc_at_buf *ab,
334  int rc)
335 {
336  switch (test_id) {
337  case AT_TEST_INLINE_RECV:
339  M0_UT_ASSERT(rc == 0);
341  break;
343  M0_UT_ASSERT(rc == -ENOMSG);
345  break;
346  case AT_TEST_INBULK_RECV:
347  M0_UT_ASSERT(rc == 0);
349  break;
350  default:
351  M0_IMPOSSIBLE("Unknown test id");
352  }
353 }
354 
356 {
357  return test_id >= AT_TEST_INLINE_RECV;
358 }
359 
360 static int atfom_tick(struct m0_fom *fom0)
361 {
362  struct atut__req *req = m0_fop_data(fom0->fo_fop);
363  struct atut__rep *rep = m0_fop_data(fom0->fo_rep_fop);
364  struct m0_buf req_buf = M0_BUF_INIT0;
365  struct m0_buf rep_buf = M0_BUF_INIT0;
366  int phase = m0_fom_phase(fom0);
367  int result = M0_FSO_AGAIN;
368  uint32_t test_id = req->arq_test_id;
369  int rc;
370 
371  switch (phase) {
372  case M0_FOPH_INIT...M0_FOPH_NR - 1:
373  result = m0_fom_tick_generic(fom0);
374  break;
375  case AT_LOAD:
376  result = m0_rpc_at_load(&req->arq_buf, fom0, AT_LOAD_DONE);
377  load_check(test_id, &req->arq_buf, result);
378  break;
379  case AT_LOAD_DONE:
380  rc = m0_rpc_at_get(&req->arq_buf, &req_buf);
381  reqbuf_check(test_id, &req_buf, rc);
382  m0_rpc_at_init(&rep->arp_buf);
383  repbuf_fill(test_id, &rep_buf);
385  result = m0_rpc_at_reply(&req->arq_buf, &rep->arp_buf,
386  &rep_buf, fom0, AT_REP_PREP);
387  reply_check(test_id, &rep->arp_buf, result);
388  } else {
389  rep->arp_rc = 0;
391  }
392  break;
393  case AT_REP_PREP:
394  rc = m0_rpc_at_reply_rc(&rep->arp_buf);
395  reply_rc_check(test_id, &rep->arp_buf, rc);
396  rep->arp_rc = rc;
398  break;
399  }
400  return result;
401 }
402 
403 static void atfom_fini(struct m0_fom *fom0)
404 {
405  struct atut__req *req = m0_fop_data(fom0->fo_fop);
406 
407  m0_rpc_at_fini(&req->arq_buf);
408  m0_fom_fini(fom0);
409  m0_free(fom0);
410 }
411 
412 static int atfom_create(struct m0_fop *fop,
413  struct m0_fom **out, struct m0_reqh *reqh)
414 {
415  struct m0_fop *repfop;
416 
417  M0_ALLOC_PTR(*out);
418  M0_ASSERT(*out != NULL);
420  M0_ASSERT(repfop != NULL);
422  fop, repfop, reqh);
423  return 0;
424 }
425 
426 static struct m0_sm_conf at_sm_conf = {
427  .scf_name = "atfom",
428  .scf_nr_states = ARRAY_SIZE(atfom_phases),
429  .scf_state = atfom_phases,
430 };
431 
432 static const struct m0_fom_ops atfom_ops = {
433  .fo_tick = atfom_tick,
434  .fo_home_locality = atfom_home_locality,
435  .fo_fini = atfom_fini
436 };
437 
438 static const struct m0_fom_type_ops atfom_type_ops = {
440 };
441 
442 static void at_fops_init(void)
443 {
446  m0_xc_rpc_ut_at_at_ut_init();
447 
449  .name = "atbuf-req",
451  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST,
452  .xt = atut__req_xc,
453  .fom_ops = &atfom_type_ops,
454  .sm = &at_sm_conf,
455  .svc_type = &atsvc_type);
457  .name = "atbuf-rep",
459  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY,
460  .xt = atut__rep_xc,
461  .svc_type = &atsvc_type);
462 }
463 
464 static void at_fops_fini(void)
465 {
468  m0_xc_rpc_ut_at_at_ut_fini();
469 }
470 
471 /*************************************************/
472 /* Test initialisation/finalisation */
473 /*************************************************/
474 
475 static void client_start(void)
476 {
477  struct m0_rpc_client_ctx *cl_rpc_ctx = &at_cctx.acl_rpc_ctx;
478  int rc;
479 
481  M0_UT_ASSERT(rc == 0);
482 
483  cl_rpc_ctx->rcx_net_dom = &at_cctx.acl_ndom;
484  cl_rpc_ctx->rcx_local_addr = CLIENT_ENDPOINT_ADDR;
486  cl_rpc_ctx->rcx_max_rpcs_in_flight = 10;
487  cl_rpc_ctx->rcx_fid = &g_process_fid;
488 
489  rc = m0_rpc_client_start(cl_rpc_ctx);
490  M0_UT_ASSERT(rc == 0);
492 }
493 
494 static void client_stop(void)
495 {
496  int rc;
497 
499  M0_UT_ASSERT(rc == 0);
501 }
502 
503 static void reqh_start(void)
504 {
505  struct m0_reqh *reqh = &atreqh.aur_reqh;
506  int rc;
507 
509  M0_UT_ASSERT(rc == 0);
510  at_fops_init();
514 }
515 
516 static void reqh_stop(void)
517 {
518  struct m0_reqh *reqh = &atreqh.aur_reqh;
519 
524  at_fops_fini();
525 }
526 
527 static void reqh_init(void)
528 {
529  int rc;
530 
531  M0_SET0(&atreqh);
533  M0_UT_ASSERT(rc == 0);
541  1);
542  M0_UT_ASSERT(rc == 0);
544  .rhia_dtm = (void *)1,
545  .rhia_mdstore = (void *)1,
546  .rhia_fid = &g_process_fid);
547  M0_UT_ASSERT(rc == 0);
555  M0_UT_ASSERT(rc == 0);
556 }
557 
558 static void reqh_fini(void)
559 {
565 }
566 
567 static void init(void)
568 {
569  reqh_init();
570  reqh_start();
571  client_start();
572 }
573 
574 static void fini(void)
575 {
576  client_stop();
577  reqh_stop();
578  reqh_fini();
579 }
580 
581 /*************************************************/
582 /* Test cases */
583 /*************************************************/
584 
585 static void init_fini(void)
586 {
587  struct m0_rpc_at_buf ab;
588 
589  m0_rpc_at_init(&ab);
590  m0_rpc_at_fini(&ab);
591 }
592 
593 static void inline_send(void)
594 {
595  struct atut__req *req;
596  struct atut__rep *rep;
597  struct m0_rpc_at_buf *ab;
598  struct m0_buf data = M0_BUF_INIT0;
599  struct m0_rpc_machine *rmach;
600  int rc;
601 
602  init();
603  M0_ALLOC_PTR(req);
604  M0_UT_ASSERT(req != NULL);
605  req->arq_test_id = AT_TEST_INLINE_SEND;
606  ab = &req->arq_buf;
607  m0_rpc_at_init(ab);
610  rc = m0_rpc_at_add(ab, &data, client_conn());
611  M0_UT_ASSERT(rc == 0);
612  req_send(req, &rep);
613  M0_UT_ASSERT(rep->arp_rc == 0);
614  M0_UT_ASSERT(!m0_rpc_at_is_set(&rep->arp_buf));
615  m0_rpc_at_fini(&req->arq_buf);
616  m0_rpc_at_fini(&rep->arp_buf);
617  req_fini();
618  fini();
619 }
620 
621 static void inbulk_send(void)
622 {
623  struct atut__req *req;
624  struct atut__rep *rep;
625  struct m0_rpc_at_buf *ab;
626  struct m0_buf data = M0_BUF_INIT0;
627  struct m0_rpc_machine *rmach;
628  int rc;
629 
630  init();
631  M0_ALLOC_PTR(req);
632  M0_UT_ASSERT(req != NULL);
633  req->arq_test_id = AT_TEST_INBULK_SEND;
634  ab = &req->arq_buf;
635  m0_rpc_at_init(ab);
638  rc = m0_rpc_at_add(ab, &data, client_conn());
639  M0_UT_ASSERT(rc == 0);
640  req_send(req, &rep);
641  M0_UT_ASSERT(rep->arp_rc == 0);
642  M0_UT_ASSERT(!m0_rpc_at_is_set(&rep->arp_buf));
643  m0_rpc_at_fini(&req->arq_buf);
644  m0_rpc_at_fini(&rep->arp_buf);
645  req_fini();
646  fini();
647 }
648 
649 static void inline__recv(uint32_t test_id, uint32_t len)
650 {
651  struct atut__req *req;
652  struct atut__rep *rep;
653  struct m0_rpc_at_buf *ab;
654  struct m0_buf data;
655  int rc;
656 
657  init();
658  M0_ALLOC_PTR(req);
659  M0_UT_ASSERT(req != NULL);
660  req->arq_test_id = test_id;
661  ab = &req->arq_buf;
662  m0_rpc_at_init(ab);
663  rc = m0_rpc_at_recv(ab, client_conn(), len, false);
664  M0_UT_ASSERT(rc == 0);
666  req_send(req, &rep);
667  M0_UT_ASSERT(rep->arp_rc == 0);
668  M0_UT_ASSERT(m0_rpc_at_is_set(&rep->arp_buf));
669  rc = m0_rpc_at_rep_get(ab, &rep->arp_buf, &data);
670  M0_UT_ASSERT(rc == 0);
671  M0_UT_ASSERT(m0_rpc_at_is_set(&rep->arp_buf));
673  m0_rpc_at_fini(&req->arq_buf);
674  m0_rpc_at_fini(&rep->arp_buf);
675  req_fini();
676  fini();
677 }
678 
679 static void inline_recv(void)
680 {
682 }
683 
684 static void inline_recv_unk(void)
685 {
687 }
688 
689 static void inbulk_recv_unk(void)
690 {
691  struct atut__req *req;
692  struct atut__rep *rep;
693  struct m0_rpc_at_buf *ab;
694  struct m0_buf data;
695  int rc;
696 
697  init();
698  M0_ALLOC_PTR(req);
699  M0_UT_ASSERT(req != NULL);
700  req->arq_test_id = AT_TEST_INBULK_RECV_UNK;
701  ab = &req->arq_buf;
702  m0_rpc_at_init(ab);
704  M0_UT_ASSERT(rc == 0);
706  req_send(req, &rep);
707  M0_UT_ASSERT(rep->arp_rc == -ENOMSG);
708  M0_UT_ASSERT(m0_rpc_at_is_set(&rep->arp_buf));
709  rc = m0_rpc_at_rep_get(ab, &rep->arp_buf, &data);
710  M0_UT_ASSERT(rc == -ENOMSG);
711  M0_UT_ASSERT(m0_rpc_at_is_set(&rep->arp_buf));
714  m0_rpc_at_fini(&req->arq_buf);
715  m0_rpc_at_fini(&rep->arp_buf);
716  req_fini();
717  fini();
718 }
719 
720 static void inbulk_recv(void)
721 {
722  struct atut__req *req;
723  struct atut__rep *rep;
724  struct m0_rpc_at_buf *ab;
725  struct m0_buf data;
726  int rc;
727 
728  init();
729  M0_ALLOC_PTR(req);
730  M0_UT_ASSERT(req != NULL);
731  req->arq_test_id = AT_TEST_INBULK_RECV;
732  ab = &req->arq_buf;
733  m0_rpc_at_init(ab);
734  rc = m0_rpc_at_recv(ab, client_conn(), at_buf_size, false);
735  M0_UT_ASSERT(rc == 0);
737  req_send(req, &rep);
738  M0_UT_ASSERT(rep->arp_rc == 0);
739  M0_UT_ASSERT(m0_rpc_at_is_set(&rep->arp_buf));
740  rc = m0_rpc_at_rep_get(ab, &rep->arp_buf, &data);
741  M0_UT_ASSERT(rc == 0);
742  M0_UT_ASSERT(m0_rpc_at_is_set(&rep->arp_buf));
746  m0_rpc_at_fini(&req->arq_buf);
747  m0_rpc_at_fini(&rep->arp_buf);
748  req_fini();
749  fini();
750 }
751 
753  .ts_name = "rpc-at",
754  .ts_owners = "Egor",
755  .ts_init = NULL,
756  .ts_fini = NULL,
757  .ts_tests = {
758  { "init-fini", init_fini, "Egor" },
759  { "inline-send", inline_send, "Egor" },
760  { "inbulk-send", inbulk_send, "Egor" },
761  { "inline-recv", inline_recv, "Egor" },
762  { "inline-recv-unk", inline_recv_unk, "Egor" },
763  { "inbulk-recv-unk", inbulk_recv_unk, "Egor" },
764  { "inbulk-recv", inbulk_recv, "Egor" },
765  { NULL, NULL }
766  }
767 };
768 
769 #undef M0_TRACE_SUBSYSTEM
770 
771 /*
772  * Local variables:
773  * c-indentation-style: "K&R"
774  * c-basic-offset: 8
775  * tab-width: 8
776  * fill-column: 80
777  * scroll-step: 1
778  * End:
779  */
780 /*
781  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
782  */
static m0_bcount_t seg_size
Definition: net.c:118
M0_INTERNAL m0_bcount_t m0_net_domain_get_max_buffer_segment_size(struct m0_net_domain *dom)
static struct m0_rpc_conn * client_conn(void)
Definition: at_ut.c:162
void m0_rpc_machine_fini(struct m0_rpc_machine *machine)
Definition: rpc_machine.c:233
M0_INTERNAL int m0_reqh_service_start(struct m0_reqh_service *service)
Definition: reqh_service.c:343
bool reply_is_necessary(uint32_t test_id)
Definition: at_ut.c:355
M0_INTERNAL void m0_reqh_services_terminate(struct m0_reqh *reqh)
Definition: reqh.c:675
struct m0_net_domain aur_net_dom
Definition: at_ut.c:42
void m0_net_domain_fini(struct m0_net_domain *dom)
Definition: domain.c:71
static void init(void)
Definition: at_ut.c:567
struct m0_fop * fo_fop
Definition: fom.h:490
static void req_send(struct atut__req *req, struct atut__rep **rep)
Definition: at_ut.c:127
M0_INTERNAL void m0_reqh_service_stop(struct m0_reqh_service *service)
Definition: reqh_service.c:402
#define NULL
Definition: misc.h:38
static bool atdata_is_correct(const struct m0_buf *buf, uint32_t len)
Definition: at_ut.c:197
#define M0_FOP_TYPE_INIT(ft,...)
Definition: fop.h:307
#define M0_REQH_INIT(reqh,...)
Definition: reqh.h:262
Definition: sm.h:350
static struct io_request req
Definition: file.c:100
int(* fo_tick)(struct m0_fom *fom)
Definition: fom.h:663
M0_INTERNAL void m0_fop_init(struct m0_fop *fop, struct m0_fop_type *fopt, void *data, void(*fop_release)(struct m0_ref *))
Definition: fop.c:79
M0_INTERNAL void m0_rpc_at_init(struct m0_rpc_at_buf *ab)
Definition: at.c:433
M0_INTERNAL void m0_reqh_service_prepare_to_stop(struct m0_reqh_service *service)
Definition: reqh_service.c:375
M0_INTERNAL bool m0_rpc_at_is_set(const struct m0_rpc_at_buf *ab)
Definition: at.c:492
M0_INTERNAL void atut__bufdata_alloc(struct m0_buf *buf, size_t size, struct m0_rpc_machine *rmach)
Definition: at_ut.c:143
static struct m0_uint128 test_id
Definition: example.c:32
int(* fto_create)(struct m0_fop *fop, struct m0_fom **out, struct m0_reqh *reqh)
Definition: fom.h:650
struct m0_bufvec data
Definition: di.c:40
static struct m0_sm_state_descr atfom_phases[]
Definition: at_ut.c:177
static const struct m0_fom_type_ops atfom_type_ops
Definition: at_ut.c:438
struct m0_net_domain * ntm_dom
Definition: net.h:853
void * m0_fop_data(const struct m0_fop *fop)
Definition: fop.c:220
void m0_fop_type_fini(struct m0_fop_type *fopt)
Definition: fop.c:232
M0_INTERNAL void m0_sm_conf_extend(const struct m0_sm_state_descr *base, struct m0_sm_state_descr *sub, uint32_t nr)
Definition: sm.c:763
M0_INTERNAL int m0_rpc_at_add(struct m0_rpc_at_buf *ab, const struct m0_buf *buf, const struct m0_rpc_conn *conn)
Definition: at.c:462
#define M0_BITS(...)
Definition: misc.h:236
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL int m0_pageshift_get(void)
Definition: memory.c:238
struct m0_rpc_client_ctx acl_rpc_ctx
Definition: at_ut.c:50
static struct m0_fop * g_reqfop
Definition: at_ut.c:119
m0_rpc_at_type
Definition: at.h:214
static int void * buf
Definition: dir.c:1019
M0_INTERNAL int m0_rpc_at_load(struct m0_rpc_at_buf *ab, struct m0_fom *fom, int next_phase)
Definition: at.c:414
#define M0_SET0(obj)
Definition: misc.h:64
static struct m0_xcode_type ** xt[]
Definition: protocol.c:64
Definition: ut.h:77
M0_INTERNAL void m0_reqh_fini(struct m0_reqh *reqh)
Definition: reqh.c:320
static int atfom_tick(struct m0_fom *fom0)
Definition: at_ut.c:360
const struct m0_sm_conf m0_generic_conf
Definition: fom_generic.c:838
struct m0_fop_getxattr_rep * rep
Definition: dir.c:455
m0_fom_phase
Definition: fom.h:372
Definition: sock.c:887
static struct atut_reqh atreqh
Definition: at_ut.c:56
static void req_fini(void)
Definition: at_ut.c:121
M0_INTERNAL int m0_rpc_at_reply(struct m0_rpc_at_buf *in, struct m0_rpc_at_buf *out, struct m0_buf *repbuf, struct m0_fom *fom, int next_phase)
Definition: at.c:528
struct m0_fom_type ft_fom_type
Definition: fop.h:232
struct m0_ut_suite rpc_at_ut
Definition: at_ut.c:752
static void at_fops_fini(void)
Definition: at_ut.c:464
M0_INTERNAL int m0_rpc_at_rep_get(struct m0_rpc_at_buf *sent, struct m0_rpc_at_buf *rcvd, struct m0_buf *out)
Definition: at.c:606
struct m0_rpc_machine aur_rmachine
Definition: at_ut.c:45
Definition: buf.h:37
int opcode
Definition: crate.c:301
void m0_fom_init(struct m0_fom *fom, const struct m0_fom_type *fom_type, const struct m0_fom_ops *ops, struct m0_fop *fop, struct m0_fop *reply, struct m0_reqh *reqh)
Definition: fom.c:1372
int i
Definition: dir.c:1033
struct m0_fop_type * f_type
Definition: fop.h:81
m0_bcount_t rm_bulk_cutoff
Definition: rpc_machine.h:157
static void inbulk_recv_unk(void)
Definition: at_ut.c:689
atfom_phase
Definition: at_ut.c:171
static struct m0_fop_type atbuf_req_fopt
Definition: at_ut.c:59
const char * name
Definition: trace.c:110
static void fini(void)
Definition: at_ut.c:574
static const struct socktype stype[]
Definition: sock.c:1156
static void atsvc_stop(struct m0_reqh_service *svc)
Definition: at_ut.c:85
int m0_fom_tick_generic(struct m0_fom *fom)
Definition: fom_generic.c:848
static void inline_send(void)
Definition: at_ut.c:593
void m0_fom_fini(struct m0_fom *fom)
Definition: fom.c:1324
struct m0_net_transfer_mc rm_tm
Definition: rpc_machine.h:88
#define M0_ASSERT(cond)
const char * scf_name
Definition: sm.h:352
static m0_bcount_t at_seg_size
Definition: at_ut.c:62
static int atfom_create(struct m0_fop *fop, struct m0_fom **out, struct m0_reqh *reqh)
Definition: at_ut.c:412
static int atsvc_start(struct m0_reqh_service *svc)
Definition: at_ut.c:80
M0_INTERNAL int m0_rpc_net_buffer_pool_setup(struct m0_net_domain *ndom, struct m0_net_buffer_pool *app_pool, uint32_t bufs_nr, uint32_t tm_nr)
Definition: rpc.c:229
const char * rst_name
Definition: reqh_service.h:447
M0_INTERNAL void m0_reqh_service_fini(struct m0_reqh_service *service)
Definition: reqh_service.c:457
#define CLIENT_ENDPOINT_ADDR
Definition: at_ut.c:54
uint32_t scf_nr_states
Definition: sm.h:354
struct m0_rpc_conn rcx_connection
Definition: rpclib.h:146
M0_INTERNAL uint32_t m0_rpc_bufs_nr(uint32_t len, uint32_t tms_nr)
Definition: rpc.c:271
#define M0_BUF_INIT0
Definition: buf.h:71
int m0_rpc_client_stop(struct m0_rpc_client_ctx *cctx)
Definition: rpclib.c:217
M0_INTERNAL int m0_rpc_at_get(const struct m0_rpc_at_buf *ab, struct m0_buf *buf)
Definition: at.c:399
M0_INTERNAL int m0_rpc_machine_init(struct m0_rpc_machine *machine, struct m0_net_domain *net_dom, const char *ep_addr, struct m0_reqh *reqh, struct m0_net_buffer_pool *receive_pool, uint32_t colour, m0_bcount_t msg_size, uint32_t queue_len)
Definition: rpc_machine.c:123
struct m0_net_xprt * m0_net_xprt_default_get(void)
Definition: net.c:151
int m0_rpc_client_start(struct m0_rpc_client_ctx *cctx)
Definition: rpclib.c:160
static void inbulk_send(void)
Definition: at_ut.c:621
struct m0_rpc_item * ri_reply
Definition: item.h:163
M0_INTERNAL int m0_buf_alloc(struct m0_buf *buf, size_t size)
Definition: buf.c:43
M0_INTERNAL int m0_rpc_at_reply_rc(struct m0_rpc_at_buf *out)
Definition: at.c:583
int m0_rpc_post_sync(struct m0_fop *fop, struct m0_rpc_session *session, const struct m0_rpc_item_ops *ri_ops, m0_time_t deadline)
Definition: rpclib.c:284
M0_INTERNAL int m0_reqh_service_allocate(struct m0_reqh_service **out, const struct m0_reqh_service_type *stype, struct m0_reqh_context *rctx)
Definition: reqh_service.c:185
Definition: reqh.h:94
union m0_rpc_at_buf::@447 u
static void repbuf_fill(uint32_t test_id, struct m0_buf *buf)
Definition: at_ut.c:287
Definition: dump.c:103
M0_INTERNAL m0_bcount_t m0_net_domain_get_max_buffer_size(struct m0_net_domain *dom)
static void reqh_init(void)
Definition: at_ut.c:527
M0_INTERNAL void m0_reqh_service_init(struct m0_reqh_service *service, struct m0_reqh *reqh, const struct m0_fid *fid)
Definition: reqh_service.c:428
struct m0_fid * rcx_fid
Definition: rpclib.h:161
#define SERVER_ENDPOINT_ADDR
Definition: at_ut.c:53
struct m0_net_domain * rcx_net_dom
Definition: rpclib.h:128
static void inline_recv_unk(void)
Definition: at_ut.c:684
static struct m0_fop_type atbuf_rep_fopt
Definition: at_ut.c:60
int m0_reqh_service_async_start_simple(struct m0_reqh_service_start_async_ctx *asc)
Definition: reqh_service.c:601
struct m0_fop * m0_fop_reply_alloc(struct m0_fop *req, struct m0_fop_type *rept)
Definition: fop.c:129
static void atsvc_fini(struct m0_reqh_service *svc)
Definition: at_ut.c:89
uint64_t rcx_max_rpcs_in_flight
Definition: rpclib.h:136
#define m0_forall(var, nr,...)
Definition: misc.h:112
Definition: fom.h:481
const char * ts_name
Definition: ut.h:99
M0_INTERNAL void m0_reqh_start(struct m0_reqh *reqh)
Definition: reqh.c:711
static struct atut_clctx at_cctx
Definition: at_ut.c:57
static void client_stop(void)
Definition: at_ut.c:494
struct m0_reqh reqh
Definition: rm_foms.c:48
const char * sd_name
Definition: sm.h:383
int(* rsto_service_allocate)(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: reqh_service.h:435
int m0_net_domain_init(struct m0_net_domain *dom, const struct m0_net_xprt *xprt)
Definition: domain.c:36
static void client_start(void)
Definition: at_ut.c:475
struct m0_sm_state_descr * scf_state
Definition: sm.h:356
static const struct m0_reqh_service_ops atsvc_ops
Definition: at_ut.c:73
struct m0_rpc_session rcx_session
Definition: rpclib.h:147
static void inline_recv(void)
Definition: at_ut.c:679
static void at_fops_init(void)
Definition: at_ut.c:442
static void reply_rc_check(uint32_t test_id, const struct m0_rpc_at_buf *ab, int rc)
Definition: at_ut.c:333
struct m0_reqh aur_reqh
Definition: at_ut.c:44
struct m0_net_buffer_pool aur_buf_pool
Definition: at_ut.c:43
M0_INTERNAL void m0_fop_release(struct m0_ref *ref)
Definition: fop.c:148
static void reqh_start(void)
Definition: at_ut.c:503
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
static void init_fini(void)
Definition: at_ut.c:585
static struct m0_net_test_service svc
Definition: service.c:34
const char * rcx_remote_addr
Definition: rpclib.h:134
m0_bcount_t size
Definition: di.c:39
static size_t atfom_home_locality(const struct m0_fom *fom)
Definition: at_ut.c:192
M0_INTERNAL void m0_rpc_at_fini(struct m0_rpc_at_buf *ab)
Definition: at.c:441
void m0_fop_put_lock(struct m0_fop *fop)
Definition: fop.c:199
static struct m0_fop * fop
Definition: item.c:57
static int atsvc_type_allocate(struct m0_reqh_service **svc, const struct m0_reqh_service_type *stype)
Definition: at_ut.c:94
M0_INTERNAL void m0_reqh_idle_wait_for(struct m0_reqh *reqh, struct m0_reqh_service *service)
Definition: reqh.c:591
static struct m0_sm_conf at_sm_conf
Definition: at_ut.c:426
struct m0_fop * m0_rpc_item_to_fop(const struct m0_rpc_item *item)
Definition: fop.c:346
static void reqbuf_check(uint32_t test_id, const struct m0_buf *buf, int rc)
Definition: at_ut.c:238
static void reply_check(uint32_t test_id, const struct m0_rpc_at_buf *ab, int result)
Definition: at_ut.c:311
const char * rcx_local_addr
Definition: rpclib.h:131
struct m0_fop * fo_rep_fop
Definition: fom.h:492
struct m0_rpc_machine rcx_rpc_machine
Definition: rpclib.h:145
struct m0_net_domain acl_ndom
Definition: at_ut.c:49
#define out(...)
Definition: gen.c:41
static void load_check(uint32_t test_id, const struct m0_rpc_at_buf *ab, int result)
Definition: at_ut.c:260
void m0_fom_phase_set(struct m0_fom *fom, int phase)
Definition: fom.c:1688
int type
Definition: dir.c:1031
static void reqh_fini(void)
Definition: at_ut.c:558
static void atfom_fini(struct m0_fom *fom0)
Definition: at_ut.c:403
void m0_rpc_net_buffer_pool_cleanup(struct m0_net_buffer_pool *app_pool)
Definition: rpc.c:264
M0_INTERNAL void * m0_alloc_aligned(size_t size, unsigned shift)
Definition: memory.c:168
static const struct m0_reqh_service_type_ops atsvc_type_ops
Definition: at_ut.c:104
void m0_free(void *data)
Definition: memory.c:146
static void reqh_stop(void)
Definition: at_ut.c:516
struct m0_rpc_item f_item
Definition: fop.h:83
static bool atbuf_check(const struct m0_rpc_at_buf *ab, uint32_t len, enum m0_rpc_at_type type)
Definition: at_ut.c:205
int32_t rc
Definition: trigger_fop.h:47
int(* rso_start_async)(struct m0_reqh_service_start_async_ctx *asc)
Definition: reqh_service.h:341
#define ARRAY_SIZE(a)
Definition: misc.h:45
struct m0_fid g_process_fid
Definition: ut.c:689
#define M0_UT_ASSERT(a)
Definition: ut.h:46
static struct m0_reqh_service * atsvc
Definition: at_ut.c:58
const m0_time_t M0_TIME_IMMEDIATELY
Definition: time.c:107
Definition: fop.h:79
Definition: at_ut.c:172
static m0_bcount_t at_buf_size
Definition: at_ut.c:63
static struct m0_reqh_service_type atsvc_type
Definition: at_ut.c:108
static void inbulk_recv(void)
Definition: at_ut.c:720
static void inline__recv(uint32_t test_id, uint32_t len)
Definition: at_ut.c:649
M0_INTERNAL int m0_rpc_at_recv(struct m0_rpc_at_buf *ab, const struct m0_rpc_conn *conn, uint32_t len, bool force_bulk)
Definition: at.c:508
uint32_t ab_type
Definition: at.h:251
#define M0_IMPOSSIBLE(fmt,...)
static const struct m0_fom_ops atfom_ops
Definition: at_ut.c:61