2 * Copyright (C) 2009-2012 Cray, Inc.
4 * Author: Nic Henke <nic@cray.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef _GNILND_API_WRAP_H
23 #define _GNILND_API_WRAP_H
25 /* LNet is allocated failure locations 0xe000 to 0xffff */
27 /* GNILND has 0xf0XX */
28 #define CFS_FAIL_GNI 0xf000
29 #define CFS_FAIL_GNI_PHYS_MAP 0xf001
30 #define CFS_FAIL_GNI_VIRT_MAP 0xf002
31 #define CFS_FAIL_GNI_GET_UNMAP 0xf003
32 #define CFS_FAIL_GNI_PUT_UNMAP 0xf004
33 #define CFS_FAIL_GNI_MAP_TX 0xf005
34 #define CFS_FAIL_GNI_SMSG_SEND 0xf006
35 #define CFS_FAIL_GNI_CLOSE_SEND 0xf007
36 #define CFS_FAIL_GNI_CDM_CREATE 0xf008
37 #define CFS_FAIL_GNI_CDM_DESTROY 0xf009
38 #define CFS_FAIL_GNI_CDM_ATTACH 0xf00a
39 #define CFS_FAIL_GNI_CQ_CREATE 0xf00b
40 #define CFS_FAIL_GNI_CQ_DESTROY 0xf00c
41 #define CFS_FAIL_GNI_EP_BIND 0xf00d
42 #define CFS_FAIL_GNI_EP_UNBIND 0xf00e
43 #define CFS_FAIL_GNI_EP_SET_EVDATA 0xf00f
44 #define CFS_FAIL_GNI_SMSG_INIT 0xf010
45 #define CFS_FAIL_GNI_SMSG_RELEASE 0xf011
46 #define CFS_FAIL_GNI_POST_RDMA 0xf012
47 #define CFS_FAIL_GNI_GET_COMPLETED 0xf013
48 #define CFS_FAIL_GNI_EP_DESTROY 0xf015
49 #define CFS_FAIL_GNI_VIRT_UNMAP 0xf016
50 #define CFS_FAIL_GNI_MDD_RELEASE 0xf017
51 #define CFS_FAIL_GNI_NOOP_SEND 0xf018
52 #define CFS_FAIL_GNI_ERR_SUBSCRIBE 0xf01a
53 #define CFS_FAIL_GNI_QUIESCE_RACE 0xf01b
54 #define CFS_FAIL_GNI_DG_TERMINATE 0xf01c
55 #define CFS_FAIL_GNI_REG_QUIESCE 0xf01d
56 #define CFS_FAIL_GNI_IN_QUIESCE 0xf01e
57 #define CFS_FAIL_GNI_DELAY_RDMA 0xf01f
58 #define CFS_FAIL_GNI_SR_DOWN_RACE 0xf020
59 #define CFS_FAIL_GNI_ALLOC_TX 0xf021
60 #define CFS_FAIL_GNI_FMABLK_AVAIL 0xf022
61 #define CFS_FAIL_GNI_EP_CREATE 0xf023
62 #define CFS_FAIL_GNI_CQ_GET_EVENT 0xf024
63 #define CFS_FAIL_GNI_PROBE 0xf025
64 #define CFS_FAIL_GNI_EP_TEST 0xf026
65 #define CFS_FAIL_GNI_CONNREQ_DROP 0xf027
66 #define CFS_FAIL_GNI_CONNREQ_PROTO 0xf028
67 #define CFS_FAIL_GNI_CONND_PILEUP 0xf029
68 #define CFS_FAIL_GNI_PHYS_SETUP 0xf02a
69 #define CFS_FAIL_GNI_FIND_TARGET 0xf02b
70 #define CFS_FAIL_GNI_WC_DGRAM_FREE 0xf02c
71 #define CFS_FAIL_GNI_DROP_CLOSING 0xf02d
72 #define CFS_FAIL_GNI_RX_CLOSE_CLOSING 0xf02e
73 #define CFS_FAIL_GNI_RX_CLOSE_CLOSED 0xf02f
74 #define CFS_FAIL_GNI_EP_POST 0xf030
75 #define CFS_FAIL_GNI_PACK_SRCNID 0xf031
76 #define CFS_FAIL_GNI_PACK_DSTNID 0xf032
77 #define CFS_FAIL_GNI_PROBE_WAIT 0xf033
78 #define CFS_FAIL_GNI_SMSG_CKSUM1 0xf034
79 #define CFS_FAIL_GNI_SMSG_CKSUM2 0xf035
80 #define CFS_FAIL_GNI_SMSG_CKSUM3 0xf036
81 #define CFS_FAIL_GNI_DROP_DESTROY_EP 0xf037
82 #define CFS_FAIL_GNI_SMSG_GETNEXT 0xf038
83 #define CFS_FAIL_GNI_FINISH_PURG 0xf039
84 #define CFS_FAIL_GNI_PURG_REL_DELAY 0xf03a
85 #define CFS_FAIL_GNI_DONT_NOTIFY 0xf03b
86 #define CFS_FAIL_GNI_VIRT_SMALL_MAP 0xf03c
87 #define CFS_FAIL_GNI_DELAY_RDMAQ 0xf03d
88 #define CFS_FAIL_GNI_PAUSE_SHUTDOWN 0xf03e
89 #define CFS_FAIL_GNI_PAUSE_DGRAM_COMP 0xf03f
90 #define CFS_FAIL_GNI_NET_LOOKUP 0xf040
91 #define CFS_FAIL_GNI_RECV_TIMEOUT 0xf041
92 #define CFS_FAIL_GNI_SEND_TIMEOUT 0xf042
93 #define CFS_FAIL_GNI_ONLY_NOOP 0xf043
94 #define CFS_FAIL_GNI_FINISH_PURG2 0xf044
95 #define CFS_FAIL_GNI_RACE_RESET 0xf045
96 #define CFS_FAIL_GNI_GNP_CONNECTING1 0xf046
97 #define CFS_FAIL_GNI_GNP_CONNECTING2 0xf047
98 #define CFS_FAIL_GNI_GNP_CONNECTING3 0xf048
99 #define CFS_FAIL_GNI_PUT_ACK_AGAIN 0xf050
100 #define CFS_FAIL_GNI_GET_REQ_AGAIN 0xf051
104 _kgnilnd_api_rc_lbug(const char *rcstr, int rc, struct libcfs_debug_msg_data *data,
105 const char *fmt, ...)
106 __attribute__ ((format (printf, 4, 5)));
108 #define kgnilnd_api_rc_lbug(msgdata, rc, fmt, a...) \
110 CFS_CHECK_STACK(msgdata, D_ERROR, NULL); \
111 /* we don't mask this - it is always at D_ERROR */ \
112 _kgnilnd_api_rc_lbug(kgnilnd_api_rc2str(rc), (rc), msgdata, fmt, ##a); \
115 #define DO_RETCODE(x) case x: return #x;
116 static inline const char *
117 kgnilnd_api_rc2str(gni_return_t rrc)
121 DO_RETCODE(GNI_RC_SUCCESS)
122 DO_RETCODE(GNI_RC_NOT_DONE);
123 DO_RETCODE(GNI_RC_INVALID_PARAM);
124 DO_RETCODE(GNI_RC_ERROR_RESOURCE);
125 DO_RETCODE(GNI_RC_TIMEOUT);
126 DO_RETCODE(GNI_RC_PERMISSION_ERROR);
127 DO_RETCODE(GNI_RC_DESCRIPTOR_ERROR);
128 DO_RETCODE(GNI_RC_ALIGNMENT_ERROR);
129 DO_RETCODE(GNI_RC_INVALID_STATE);
130 DO_RETCODE(GNI_RC_NO_MATCH);
131 DO_RETCODE(GNI_RC_SIZE_ERROR);
132 DO_RETCODE(GNI_RC_TRANSACTION_ERROR);
133 DO_RETCODE(GNI_RC_ILLEGAL_OP);
134 DO_RETCODE(GNI_RC_ERROR_NOMEM);
140 /* log an error and LBUG for unhandled rc from gni api function
141 * the fmt should be something like:
142 * gni_api_call(arg1, arg2, arg3)
145 /* apick_fn and apick_fmt should be defined for each site */
149 #define GNILND_API_RC_LBUG(args...) \
151 LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_ERROR, NULL); \
152 kgnilnd_api_rc_lbug(&msgdata, rrc, apick_fn"("apick_fmt")", ##args); \
155 #define GNILND_API_SWBUG(args...) \
157 CERROR("likely SOFTWARE BUG "apick_fn"("apick_fmt") rc %s\n", \
158 ##args, kgnilnd_api_rc2str(rrc)); \
161 #define GNILND_API_EINVAL(args...) \
163 CERROR("invalid parameter to "apick_fn"("apick_fmt") rc %s\n", \
164 ##args, kgnilnd_api_rc2str(rrc)); \
167 #define GNILND_API_RESOURCE(args...) \
169 CERROR("no resources for "apick_fn"("apick_fmt") rc %s\n", \
170 ##args, kgnilnd_api_rc2str(rrc)); \
173 #define GNILND_API_BUSY(args...) \
175 CERROR("resources busy for "apick_fn"("apick_fmt") rc %s\n", \
176 ##args, kgnilnd_api_rc2str(rrc)); \
179 #undef DEBUG_SMSG_CREDITS
180 #ifdef DEBUG_SMSG_CREDITS
181 #define CRAY_CONFIG_GHAL_GEMINI
182 #include <gni_priv.h>
183 #define GNIDBG_SMSG_CREDS(level, conn) \
185 gni_ep_smsg_mbox_t *smsg = conn->gnc_ephandle->smsg; \
186 CDEBUG(level, "SMSGDBG: conn %p mcred %d/%d bcred %d/%d " \
187 "s_seq %d/%d/%d r_seq %d/%d/%d retr %d\n", \
188 conn, smsg->mbox_credits, smsg->back_mbox_credits, \
189 smsg->buffer_credits, smsg->back_buffer_credits, \
190 smsg->s_seqno, smsg->s_seqno_back_mbox_credits, \
191 smsg->s_seqno_back_buffer_credits, smsg->r_seqno, \
192 smsg->r_seqno_back_mbox_credits, \
193 smsg->r_seqno_back_buffer_credits, smsg->retransmit_count); \
196 #define GNIDBG_SMSG_CREDS(level, conn) do {} while(0)
199 /* these are all wrappers around gni_XXX functions.
200 * This allows us to handle all the return codes and api checks without
201 * dirtying up the logic code */
203 /* TODO: RETURN wrapper that translates integer to GNI API RC string */
205 #define apick_fn "kgnilnd_cdm_create"
206 #define apick_fmt "%u, %u, %u, %u, 0x%p"
207 static inline gni_return_t kgnilnd_cdm_create(
212 OUT gni_cdm_handle_t *cdm_hndl
217 /* Error injection */
218 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_CDM_CREATE)) {
219 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
221 rrc = gni_cdm_create(inst_id, ptag, cookie, modes, cdm_hndl);
227 case GNI_RC_ERROR_RESOURCE:
228 case GNI_RC_INVALID_PARAM:
229 /* Try to bail gracefully */
231 inst_id, ptag, cookie, modes, cdm_hndl);
235 inst_id, ptag, cookie, modes, cdm_hndl);
237 /* LBUG never returns, but just for style and consistency */
246 #define apick_fn "kgnilnd_cdm_attach"
247 #define apick_fmt "0x%p, %u, 0x%p, 0x%p"
248 static inline gni_return_t kgnilnd_cdm_attach(
249 IN gni_cdm_handle_t cdm_hndl,
250 IN uint32_t device_id,
251 OUT uint32_t *local_addr,
252 OUT gni_nic_handle_t *nic_hndl
257 /* Error injection */
258 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_CDM_ATTACH)) {
259 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
261 rrc = gni_cdm_attach(cdm_hndl, device_id, local_addr, nic_hndl);
267 case GNI_RC_NO_MATCH:
268 case GNI_RC_INVALID_PARAM:
270 cdm_hndl, device_id, local_addr, nic_hndl);
272 case GNI_RC_ERROR_RESOURCE:
273 case GNI_RC_INVALID_STATE:
275 cdm_hndl, device_id, local_addr, nic_hndl);
279 cdm_hndl, device_id, local_addr, nic_hndl);
281 /* LBUG never returns, but just for style and consistency */
289 #define apick_fn "kgnilnd_cdm_destroy"
290 #define apick_fmt "0x%p"
291 static inline gni_return_t kgnilnd_cdm_destroy(
292 IN gni_cdm_handle_t cdm_hndl
297 /* Error injection */
298 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_CQ_DESTROY)) {
299 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
301 rrc = gni_cdm_destroy(
308 case GNI_RC_INVALID_PARAM:
316 /* LBUG never returns, but just for style and consistency */
324 #define apick_fn "kgnilnd_subscribe_errors"
325 #define apick_fmt "0x%p,%x,%u,0x%p,0x%p,0x%p"
326 static inline gni_return_t kgnilnd_subscribe_errors(
327 IN gni_nic_handle_t nic_handle,
328 IN gni_error_mask_t mask,
329 IN uint32_t EEQ_size,
330 IN void (*EQ_new_event)(gni_err_handle_t),
331 IN void (*app_crit_err)(gni_err_handle_t),
332 OUT gni_err_handle_t *err_handle
337 /* Error injection */
338 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_ERR_SUBSCRIBE)) {
339 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
341 rrc = gni_subscribe_errors(
342 nic_handle, mask, EEQ_size, EQ_new_event, app_crit_err,
349 case GNI_RC_INVALID_PARAM:
351 nic_handle, mask, EEQ_size, EQ_new_event, app_crit_err,
354 case GNI_RC_ERROR_RESOURCE:
356 nic_handle, mask, EEQ_size, EQ_new_event, app_crit_err,
361 nic_handle, mask, EEQ_size, EQ_new_event, app_crit_err,
363 /* LBUG never returns, but just for style and consistency */
371 #define apick_fn "kgnilnd_release_errors"
372 #define apick_fmt "0x%p"
373 static inline gni_return_t kgnilnd_release_errors(
374 IN gni_err_handle_t err_handle
379 rrc = gni_release_errors(
385 case GNI_RC_INVALID_PARAM:
386 case GNI_RC_NOT_DONE:
393 /* LBUG never returns, but just for style and consistency */
401 #define apick_fn "kgnilnd_set_quiesce_callback"
402 #define apick_fmt "0x%p,0x%p"
403 static inline gni_return_t kgnilnd_set_quiesce_callback(
404 IN gni_nic_handle_t nic_handle,
405 IN void (*qsce_func)(gni_nic_handle_t, uint64_t msecs)
410 /* Error injection */
411 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_REG_QUIESCE)) {
412 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
414 rrc = gni_set_quiesce_callback(
415 nic_handle, qsce_func);
421 case GNI_RC_INVALID_STATE:
422 case GNI_RC_INVALID_PARAM:
424 nic_handle, qsce_func);
428 nic_handle, qsce_func);
429 /* LBUG never returns, but just for style and consistency */
437 #define apick_fn "kgnilnd_get_quiesce_status"
438 #define apick_fmt "0x%p"
439 static inline gni_return_t kgnilnd_get_quiesce_status(
440 IN gni_nic_handle_t nic_handle
445 /* this has weird RC -
446 * 0 - quiesce not in progress
447 * 1 - quiesce is turned on
450 /* Error injection */
451 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_IN_QUIESCE)) {
454 rrc = gni_get_quiesce_status(
465 /* LBUG never returns, but just for style and consistency */
473 #define apick_fn "kgnilnd_cq_create"
474 #define apick_fmt "0x%p, %u, %u, 0x%p, "LPX64", 0x%p"
475 static inline gni_return_t kgnilnd_cq_create(
476 IN gni_nic_handle_t nic_hndl,
477 IN uint32_t entry_count,
478 IN uint32_t delay_index,
479 IN gni_cq_event_hndlr_f *event_handler,
480 IN uint64_t usr_event_data,
481 OUT gni_cq_handle_t *cq_hndl
486 /* Error injection */
487 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_CQ_CREATE)) {
488 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
491 nic_hndl, entry_count, delay_index, event_handler,
492 usr_event_data, cq_hndl);
498 case GNI_RC_INVALID_PARAM:
500 nic_hndl, entry_count, delay_index, event_handler,
501 usr_event_data, cq_hndl);
503 case GNI_RC_ERROR_RESOURCE:
505 nic_hndl, entry_count, delay_index, event_handler,
506 usr_event_data, cq_hndl);
510 nic_hndl, entry_count, delay_index, event_handler,
511 usr_event_data, cq_hndl);
513 /* LBUG never returns, but just for style and consistency */
521 #define apick_fn "kgnilnd_cq_destroy"
522 #define apick_fmt "0x%p"
523 static inline gni_return_t kgnilnd_cq_destroy(
524 IN gni_cq_handle_t cq_hndl
529 /* Error injection */
530 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_CQ_DESTROY)) {
531 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
534 rrc = gni_cq_destroy(
541 case GNI_RC_INVALID_PARAM:
545 case GNI_RC_ERROR_RESOURCE:
553 /* LBUG never returns, but just for style and consistency */
561 #define apick_fn "kgnilnd_cq_get_event"
562 #define apick_fmt "0x%p, 0x%p"
563 static inline gni_return_t kgnilnd_cq_get_event(
564 IN gni_cq_handle_t cq_hndl,
565 OUT gni_cq_entry_t *event_data
570 /* no error injection - CQs are touchy about the data.
571 * where appropriate, we'll do this on the CQs that should be able to
572 * handle the various errors */
573 rrc = gni_cq_get_event(
574 cq_hndl, event_data);
578 case GNI_RC_NOT_DONE:
579 case GNI_RC_TRANSACTION_ERROR:
581 case GNI_RC_ERROR_RESOURCE:
582 LASSERTF(GNI_CQ_OVERRUN(*event_data),
583 "kgni returned ERROR_RESOURCE but cq_hndl 0x%p is not "
584 "overrun\n", cq_hndl);
586 case GNI_RC_INVALID_PARAM:
588 cq_hndl, event_data);
592 cq_hndl, event_data);
594 /* LBUG never returns, but just for style and consistency */
602 #define apick_fn "kgnilnd_smsg_init"
603 #define apick_fmt "0x%p, 0x%p, 0x%p"
604 static inline gni_return_t kgnilnd_smsg_init(
605 IN gni_ep_handle_t ep_hndl,
606 IN gni_smsg_attr_t *local_smsg_attr,
607 IN gni_smsg_attr_t *remote_smsg_attr
612 /* Error injection */
613 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_SMSG_INIT)) {
614 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_ERROR_RESOURCE;
617 ep_hndl, local_smsg_attr, remote_smsg_attr);
621 /* both of these are OK, upper SW needs to handle */
623 case GNI_RC_NOT_DONE:
625 case GNI_RC_INVALID_PARAM:
626 case GNI_RC_INVALID_STATE:
628 ep_hndl, local_smsg_attr, remote_smsg_attr);
630 case GNI_RC_ERROR_RESOURCE:
632 ep_hndl, local_smsg_attr, remote_smsg_attr);
636 ep_hndl, local_smsg_attr, remote_smsg_attr);
638 /* LBUG never returns, but just for style and consistency */
646 #define apick_fn "kgnilnd_smsg_send"
647 #define apick_fmt "0x%p, 0x%p, %d, 0x%p, %u %u"
648 static inline gni_return_t kgnilnd_smsg_send(
649 IN gni_ep_handle_t ep_hndl,
651 IN uint32_t header_length,
653 IN uint32_t data_length,
659 /* Error injection */
660 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_SMSG_SEND)) {
661 if (cfs_fail_loc & CFS_FAIL_RAND) {
662 rrc = GNI_RC_NOT_DONE;
664 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_NOT_DONE;
668 ep_hndl, header, header_length, data, data_length, msg_id);
672 /* both of these are OK, upper SW needs to handle */
674 case GNI_RC_NOT_DONE:
676 case GNI_RC_INVALID_PARAM:
678 ep_hndl, header, header_length, data, data_length, msg_id);
680 case GNI_RC_ERROR_RESOURCE:
682 ep_hndl, header, header_length, data, data_length, msg_id);
686 ep_hndl, header, header_length, data, data_length, msg_id);
688 /* LBUG never returns, but just for style and consistency */
696 #define apick_fn "kgnilnd_smsg_getnext"
697 #define apick_fmt "0x%p,0x%p"
698 static inline gni_return_t kgnilnd_smsg_getnext(
699 IN gni_ep_handle_t ep_hndl,
705 /* Error injection */
706 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_SMSG_RELEASE)) {
707 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_NOT_DONE;
709 rrc = gni_smsg_getnext(
714 /* both of these are OK, upper SW needs to handle */
716 case GNI_RC_NOT_DONE:
717 case GNI_RC_INVALID_STATE:
719 case GNI_RC_INVALID_PARAM:
727 /* LBUG never returns, but just for style and consistency */
735 #define apick_fn "kgnilnd_smsg_release"
736 #define apick_fmt "0x%p"
737 static inline gni_return_t kgnilnd_smsg_release(
738 IN gni_ep_handle_t ep_hndl
743 /* Error injection */
744 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_SMSG_RELEASE)) {
745 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
747 rrc = gni_smsg_release(
752 /* both of these are OK, upper SW needs to handle */
754 case GNI_RC_NOT_DONE:
756 case GNI_RC_INVALID_PARAM:
764 /* LBUG never returns, but just for style and consistency */
772 #define apick_fn "kgnilnd_ep_create"
773 #define apick_fmt "0x%p, 0x%p, 0x%p"
774 static inline gni_return_t kgnilnd_ep_create(
775 IN gni_nic_handle_t nic_hndl,
776 IN gni_cq_handle_t src_cq_hndl,
777 OUT gni_ep_handle_t *ep_hndl
782 /* error injection */
783 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_EP_CREATE)) {
784 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_ERROR_NOMEM;
787 nic_hndl, src_cq_hndl, ep_hndl);
793 case GNI_RC_INVALID_PARAM:
795 nic_hndl, src_cq_hndl, ep_hndl);
797 case GNI_RC_ERROR_NOMEM:
799 nic_hndl, src_cq_hndl, ep_hndl);
803 nic_hndl, src_cq_hndl, ep_hndl);
805 /* lbug never returns, but just for style and consistency */
813 #define apick_fn "kgnilnd_ep_bind"
814 #define apick_fmt "0x%p, %x, %x"
815 static inline gni_return_t kgnilnd_ep_bind(
816 IN gni_ep_handle_t ep_hndl,
817 IN uint32_t remote_addr,
818 IN uint32_t remote_id
823 /* error injection */
824 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_EP_BIND)) {
825 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_NOT_DONE;
828 ep_hndl, remote_addr, remote_id);
832 /* both of these are ok, upper sw needs to handle */
834 case GNI_RC_NOT_DONE:
836 case GNI_RC_INVALID_PARAM:
838 ep_hndl, remote_addr, remote_id);
842 ep_hndl, remote_addr, remote_id);
844 /* lbug never returns, but just for style and consistency */
852 #define apick_fn "kgnilnd_ep_set_eventdata"
853 #define apick_fmt "0x%p, %x, %x"
854 static inline gni_return_t kgnilnd_ep_set_eventdata(
855 IN gni_ep_handle_t ep_hndl,
856 IN uint32_t local_event,
857 IN uint32_t remote_event
862 /* Error injection */
863 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_EP_SET_EVDATA)) {
864 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
866 rrc = gni_ep_set_eventdata(
867 ep_hndl, local_event, remote_event);
873 case GNI_RC_INVALID_PARAM:
875 ep_hndl, local_event, remote_event);
879 ep_hndl, local_event, remote_event);
881 /* LBUG never returns, but just for style and consistency */
889 #define apick_fn "kgnilnd_ep_unbind"
890 #define apick_fmt "0x%p"
891 static inline gni_return_t kgnilnd_ep_unbind(
892 IN gni_ep_handle_t ep_hndl
897 /* Error injection */
898 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_EP_UNBIND)) {
899 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_NOT_DONE;
906 /* both of these are OK, upper SW needs to handle */
907 case GNI_RC_NOT_DONE:
910 case GNI_RC_INVALID_PARAM:
918 /* LBUG never returns, but just for style and consistency */
926 #define apick_fn "kgnilnd_ep_destroy"
927 #define apick_fmt "0x%p"
928 static inline gni_return_t kgnilnd_ep_destroy(
929 IN gni_ep_handle_t ep_hndl
934 /* Error injection */
935 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_EP_DESTROY)) {
936 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_NOT_DONE;
938 rrc = gni_ep_destroy(
945 case GNI_RC_INVALID_PARAM:
953 /* LBUG never returns, but just for style and consistency */
961 #define apick_fn "kgnilnd_ep_postdata_w_id"
962 #define apick_fmt "0x%p, 0x%p, %d, 0x%p, %d, "LPU64""
963 static inline gni_return_t kgnilnd_ep_postdata_w_id(
964 IN gni_ep_handle_t ep_hndl,
966 IN uint16_t data_len,
968 IN uint16_t buf_size,
969 IN uint64_t datagram_id
974 /* Error injection */
975 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_EP_POST)) {
976 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_SIZE_ERROR;
978 rrc = gni_ep_postdata_w_id(
979 ep_hndl, in_data, data_len, out_buf, buf_size,
985 case GNI_RC_ERROR_NOMEM:
986 case GNI_RC_ERROR_RESOURCE:
988 case GNI_RC_INVALID_PARAM:
989 case GNI_RC_SIZE_ERROR:
991 ep_hndl, in_data, data_len, out_buf, buf_size,
996 ep_hndl, in_data, data_len, out_buf, buf_size,
999 /* LBUG never returns, but just for style and consistency */
1007 #define apick_fn "kgnilnd_ep_postdata_test_by_id"
1008 #define apick_fmt "0x%p, "LPU64", 0x%p, 0x%p, 0x%p"
1009 static inline gni_return_t kgnilnd_ep_postdata_test_by_id(
1010 IN gni_ep_handle_t ep_hndl,
1011 IN uint64_t datagram_id,
1012 OUT gni_post_state_t *post_state,
1013 OUT uint32_t *remote_addr,
1014 OUT uint32_t *remote_id
1019 /* Error injection */
1020 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_EP_TEST)) {
1021 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_ERROR_NOMEM;
1023 rrc = gni_ep_postdata_test_by_id(
1024 ep_hndl, datagram_id, post_state, remote_addr,
1027 /* we want to lie, but we need to do the actual work first
1028 * so we don't keep getting the event saying a dgram is ready */
1029 if (rrc == GNI_RC_SUCCESS && CFS_FAIL_CHECK(CFS_FAIL_GNI_DG_TERMINATE)) {
1030 /* don't use fail_val, allows us to do FAIL_SOME */
1031 *post_state = GNI_POST_TERMINATED;
1036 case GNI_RC_SUCCESS:
1037 case GNI_RC_NO_MATCH:
1039 case GNI_RC_SIZE_ERROR:
1040 case GNI_RC_INVALID_PARAM:
1042 ep_hndl, datagram_id, post_state, remote_addr,
1045 case GNI_RC_ERROR_NOMEM:
1046 GNILND_API_RESOURCE(
1047 ep_hndl, datagram_id, post_state, remote_addr,
1052 ep_hndl, datagram_id, post_state, remote_addr,
1055 /* LBUG never returns, but just for style and consistency */
1063 #define apick_fn "kgnilnd_ep_postdata_cancel_by_id"
1064 #define apick_fmt "0x%p, "LPU64""
1065 static inline gni_return_t kgnilnd_ep_postdata_cancel_by_id(
1066 IN gni_ep_handle_t ep_hndl,
1067 IN uint64_t datagram_id
1072 /* no error injection as the only thing we'd do is LBUG */
1074 rrc = gni_ep_postdata_cancel_by_id(
1075 ep_hndl, datagram_id);
1078 case GNI_RC_SUCCESS:
1079 case GNI_RC_NO_MATCH:
1081 case GNI_RC_INVALID_PARAM:
1083 ep_hndl, datagram_id);
1087 ep_hndl, datagram_id);
1089 /* LBUG never returns, but just for style and consistency */
1097 #define apick_fn "kgnilnd_postdata_probe_by_id"
1098 #define apick_fmt "0x%p, 0x%p"
1099 static inline gni_return_t kgnilnd_postdata_probe_by_id(
1100 IN gni_nic_handle_t nic_hndl,
1101 OUT uint64_t *datagram_id
1106 /* Error injection */
1107 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_PROBE)) {
1108 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_NO_MATCH;
1110 rrc = gni_postdata_probe_by_id(
1111 nic_hndl, datagram_id);
1115 case GNI_RC_SUCCESS:
1116 case GNI_RC_NO_MATCH:
1118 case GNI_RC_INVALID_PARAM:
1120 nic_hndl, datagram_id);
1124 nic_hndl, datagram_id);
1126 /* LBUG never returns, but just for style and consistency */
1134 #define apick_fn "kgnilnd_postdata_probe_wait_by_id"
1135 #define apick_fmt "0x%p, %d, 0x%p"
1136 static inline gni_return_t kgnilnd_postdata_probe_wait_by_id(
1137 IN gni_nic_handle_t nic_hndl,
1138 IN uint32_t timeout,
1139 OUT uint64_t *datagram_id
1144 /* Error injection */
1145 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_PROBE_WAIT)) {
1146 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_TIMEOUT;
1148 rrc = gni_postdata_probe_wait_by_id(
1149 nic_hndl, timeout, datagram_id);
1153 case GNI_RC_SUCCESS:
1154 case GNI_RC_TIMEOUT:
1156 case GNI_RC_INVALID_PARAM:
1158 nic_hndl, timeout, datagram_id);
1162 nic_hndl, timeout, datagram_id);
1164 /* LBUG never returns, but just for style and consistency */
1172 #define apick_fn "kgnilnd_post_rdma"
1173 #define apick_fmt "0x%p, 0x%p"
1174 static inline gni_return_t kgnilnd_post_rdma(
1175 IN gni_ep_handle_t ep_hndl,
1176 IN gni_post_descriptor_t *post_descr
1181 /* Error injection */
1182 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_POST_RDMA)) {
1183 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
1185 rrc = gni_post_rdma(
1186 ep_hndl, post_descr);
1190 case GNI_RC_SUCCESS:
1192 case GNI_RC_ALIGNMENT_ERROR:
1193 case GNI_RC_INVALID_PARAM:
1195 ep_hndl, post_descr);
1197 case GNI_RC_ERROR_RESOURCE:
1198 GNILND_API_RESOURCE(
1199 ep_hndl, post_descr);
1203 ep_hndl, post_descr);
1205 /* LBUG never returns, but just for style and consistency */
1213 #define apick_fn "kgnilnd_get_completed"
1214 #define apick_fmt "0x%p,"LPX64",0x%p"
1215 static inline gni_return_t kgnilnd_get_completed(
1216 IN gni_cq_handle_t cq_hndl,
1217 IN gni_cq_entry_t event_data,
1218 OUT gni_post_descriptor_t **post_descr
1224 rrc = gni_get_completed(cq_hndl, event_data, post_descr);
1227 case GNI_RC_TRANSACTION_ERROR:
1228 case GNI_RC_SUCCESS:
1230 case GNI_RC_DESCRIPTOR_ERROR:
1231 case GNI_RC_INVALID_PARAM:
1232 GNILND_API_SWBUG(cq_hndl, event_data, post_descr);
1235 GNILND_API_RC_LBUG(cq_hndl, event_data, post_descr);
1236 /* LBUG never returns, but just for style and consistency */
1240 /* Error injection - we need a valid desc, so let kgni give us one
1242 if (rrc == GNI_RC_SUCCESS &&
1243 (CFS_FAIL_CHECK(CFS_FAIL_GNI_GET_COMPLETED))) {
1244 /* We only trigger TRANSACTION_ERROR for now */
1245 gni_post_descriptor_t *desc;
1246 rrc = GNI_RC_TRANSACTION_ERROR;
1249 /* recoverable decision made from cfs_fail_val in
1250 * kgnilnd_cq_error_str and
1251 * kgnilnd_cq_error_recoverable */
1258 #define apick_fn "kgnilnd_cq_error_str"
1259 #define apick_fmt LPX64",0x%p,%d"
1260 static inline gni_return_t kgnilnd_cq_error_str(
1261 IN gni_cq_entry_t entry,
1268 /* Error injection - set string if we injected a
1269 * TRANSACTION_ERROR earlier */
1270 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_GET_COMPLETED)) {
1271 /* if we just set persistent error, we can't ever
1272 * break in via ssh to clear, so use a count > 10 to indicate fatal */
1273 sprintf(buffer, "INJECT:%s", cfs_fail_val > 10 ?
1274 "FATAL" : "RECOVERABLE");
1275 rrc = GNI_RC_SUCCESS;
1277 rrc = gni_cq_error_str(
1278 entry, buffer, len);
1282 case GNI_RC_SUCCESS:
1284 case GNI_RC_SIZE_ERROR:
1285 case GNI_RC_INVALID_PARAM:
1287 entry, buffer, len);
1288 /* give them something to use */
1289 snprintf(buffer, len, "UNDEF:UNDEF");
1293 entry, buffer, len);
1295 /* LBUG never returns, but just for style and consistency */
1303 #define apick_fn "kgnilnd_cq_error_recoverable"
1304 #define apick_fmt LPX64",0x%p"
1305 static inline gni_return_t kgnilnd_cq_error_recoverable(
1306 IN gni_cq_entry_t entry,
1307 IN uint32_t *recoverable
1312 /* Error injection - set string if we injected a
1313 * TRANSACTION_ERROR earlier */
1314 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_GET_COMPLETED)) {
1315 *recoverable = cfs_fail_val > 10 ? 0 : 1;
1316 rrc = GNI_RC_SUCCESS;
1318 rrc = gni_cq_error_recoverable(
1319 entry, recoverable);
1323 case GNI_RC_SUCCESS:
1325 case GNI_RC_INVALID_STATE:
1326 case GNI_RC_INVALID_PARAM:
1328 entry, recoverable);
1333 entry, recoverable);
1335 /* LBUG never returns, but just for style and consistency */
1343 #define apick_fn "kgnilnd_mem_register_segments"
1344 #define apick_fmt "0x%p,0x%p,%u,0x%p,%x,0x%p"
1345 static inline gni_return_t
1346 kgnilnd_mem_register_segments(
1347 IN gni_nic_handle_t nic_hndl,
1348 IN gni_mem_segment_t *mem_segments,
1349 IN uint32_t segments_cnt,
1350 IN gni_cq_handle_t dst_cq_hndl,
1352 OUT gni_mem_handle_t *mem_hndl
1357 /* Error injection */
1358 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_PHYS_MAP)) {
1359 rrc = GNI_RC_ERROR_RESOURCE;
1361 rrc = gni_mem_register_segments(
1362 nic_hndl, mem_segments, segments_cnt,
1363 dst_cq_hndl, flags, mem_hndl);
1367 case GNI_RC_SUCCESS:
1368 case GNI_RC_ERROR_RESOURCE:
1370 case GNI_RC_INVALID_PARAM:
1372 nic_hndl, mem_segments, segments_cnt,
1373 dst_cq_hndl, flags, mem_hndl);
1377 nic_hndl, mem_segments, segments_cnt,
1378 dst_cq_hndl, flags, mem_hndl);
1380 /* LBUG never returns, but just for style and consistency */
1388 #define apick_fn "kgnilnd_mem_register"
1389 #define apick_fmt "0x%p,"LPX64","LPX64"0x%p,%u,0x%p"
1390 static inline gni_return_t kgnilnd_mem_register(
1391 IN gni_nic_handle_t nic_hndl,
1392 IN uint64_t address,
1394 IN gni_cq_handle_t dst_cq_hndl,
1396 OUT gni_mem_handle_t *mem_hndl
1401 /* Error injection */
1402 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_VIRT_MAP)) {
1403 rrc = GNI_RC_ERROR_RESOURCE;
1404 } else if (CFS_FAIL_CHECK(CFS_FAIL_GNI_VIRT_SMALL_MAP) &&
1405 length <= *kgnilnd_tunables.kgn_max_immediate) {
1406 rrc = GNI_RC_INVALID_PARAM;
1408 rrc = gni_mem_register(
1409 nic_hndl, address, length,
1410 dst_cq_hndl, flags, mem_hndl);
1414 case GNI_RC_SUCCESS:
1415 case GNI_RC_ERROR_RESOURCE:
1417 case GNI_RC_INVALID_PARAM:
1419 nic_hndl, address, length,
1420 dst_cq_hndl, flags, mem_hndl);
1424 nic_hndl, address, length,
1425 dst_cq_hndl, flags, mem_hndl);
1427 /* LBUG never returns, but just for style and consistency */
1435 #define apick_fn "kgnilnd_mem_deregister"
1436 #define apick_fmt "0x%p,0x%p,%d"
1437 static inline gni_return_t kgnilnd_mem_deregister(
1438 IN gni_nic_handle_t nic_hndl,
1439 IN gni_mem_handle_t *mem_hndl,
1445 /* Error injection */
1446 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_VIRT_UNMAP)) {
1447 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_INVALID_PARAM;
1449 rrc = gni_mem_deregister(
1450 nic_hndl, mem_hndl, hold_timeout);
1454 case GNI_RC_SUCCESS:
1456 case GNI_RC_INVALID_PARAM:
1458 nic_hndl, mem_hndl, hold_timeout);
1462 nic_hndl, mem_hndl, hold_timeout);
1464 /* LBUG never returns, but just for style and consistency */
1472 #define apick_fn "kgnilnd_mem_mdd_release"
1473 #define apick_fmt "0x%p,0x%p"
1474 static inline gni_return_t kgnilnd_mem_mdd_release(
1475 IN gni_nic_handle_t nic_hndl,
1476 IN gni_mem_handle_t *mem_hndl
1481 /* Error injection */
1482 if (CFS_FAIL_CHECK(CFS_FAIL_GNI_MDD_RELEASE)) {
1483 rrc = cfs_fail_val ? cfs_fail_val : GNI_RC_NO_MATCH;
1485 rrc = gni_mem_mdd_release(
1486 nic_hndl, mem_hndl);
1490 case GNI_RC_SUCCESS:
1491 case GNI_RC_NO_MATCH:
1495 nic_hndl, mem_hndl);
1497 /* LBUG never returns, but just for style and consistency */
1505 #endif /* _GNILND_API_WRAP_H */