Lines Matching +full:rpc +full:- +full:if
2 * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
16 * - Redistributions of source code must retain the above
20 * - Redistributions in binary form must reproduce the above
36 #if HAVE_CONFIG_H
52 #define DEBUG if (ibdebug) IBWARN
66 if (!trid) { in mad_trid()
78 srcport->timeout ? srcport->timeout : madrpc_timeout); in mad_get_timeout()
83 return (srcport->retries ? srcport->retries : madrpc_retries); in mad_get_retries()
86 void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath, void *data) in mad_encode() argument
88 int is_resp = rpc->method & IB_MAD_RESPONSE; in mad_encode()
92 mad_set_field(buf, 0, IB_MAD_METHOD_F, rpc->method); in mad_encode()
94 mgtclass = rpc->mgtclass & 0xff; in mad_encode()
95 if (mgtclass == IB_SA_CLASS || mgtclass == IB_CC_CLASS) in mad_encode()
99 mad_set_field(buf, 0, IB_MAD_MGMTCLASS_F, rpc->mgtclass & 0xff); in mad_encode()
103 if ((rpc->mgtclass & 0xff) == IB_SMI_DIRECT_CLASS) { in mad_encode()
104 if (!drpath) { in mad_encode()
109 if (drpath->cnt >= IB_SUBNET_PATH_HOPS_MAX) { in mad_encode()
110 IBWARN("dr path with hop count %d", drpath->cnt); in mad_encode()
114 mad_set_field(buf, 0, IB_DRSMP_HOPCNT_F, drpath->cnt); in mad_encode()
116 is_resp ? drpath->cnt + 1 : 0x0); in mad_encode()
117 mad_set_field(buf, 0, IB_DRSMP_STATUS_F, rpc->rstatus); in mad_encode()
120 mad_set_field(buf, 0, IB_MAD_STATUS_F, rpc->rstatus); in mad_encode()
123 if (!rpc->trid) in mad_encode()
124 rpc->trid = mad_trid(); in mad_encode()
126 mad_set_field64(buf, 0, IB_MAD_TRID_F, rpc->trid); in mad_encode()
127 mad_set_field(buf, 0, IB_MAD_ATTRID_F, rpc->attr.id); in mad_encode()
128 mad_set_field(buf, 0, IB_MAD_ATTRMOD_F, rpc->attr.mod); in mad_encode()
131 mad_set_field64(buf, 0, IB_MAD_MKEY_F, rpc->mkey); in mad_encode()
133 if ((rpc->mgtclass & 0xff) == IB_SMI_DIRECT_CLASS) { in mad_encode()
136 drpath->drdlid ? drpath->drdlid : 0xffff); in mad_encode()
138 drpath->drslid ? drpath->drslid : 0xffff); in mad_encode()
140 /* bytes 128 - 256 - by default should be zero due to memset */ in mad_encode()
141 if (is_resp) in mad_encode()
142 mad_set_array(buf, 0, IB_DRSMP_RPATH_F, drpath->p); in mad_encode()
144 mad_set_array(buf, 0, IB_DRSMP_PATH_F, drpath->p); in mad_encode()
147 if ((rpc->mgtclass & 0xff) == IB_SA_CLASS) in mad_encode()
148 mad_set_field64(buf, 0, IB_SA_COMPMASK_F, rpc->mask); in mad_encode()
150 if ((rpc->mgtclass & 0xff) == IB_CC_CLASS) { in mad_encode()
151 ib_rpc_cc_t *rpccc = (ib_rpc_cc_t *)rpc; in mad_encode()
152 mad_set_field64(buf, 0, IB_CC_CCKEY_F, rpccc->cckey); in mad_encode()
155 if (data) in mad_encode()
156 memcpy((char *)buf + rpc->dataoffs, data, rpc->datasz); in mad_encode()
159 if (mad_is_vendor_range2(rpc->mgtclass & 0xff)) in mad_encode()
160 mad_set_field(buf, 0, IB_VEND2_OUI_F, rpc->oui); in mad_encode()
165 int mad_build_pkt(void *umad, ib_rpc_t * rpc, ib_portid_t * dport, in mad_build_pkt() argument
169 int lid_routed = (rpc->mgtclass & 0xff) != IB_SMI_DIRECT_CLASS; in mad_build_pkt()
170 int is_smi = ((rpc->mgtclass & 0xff) == IB_SMI_CLASS || in mad_build_pkt()
171 (rpc->mgtclass & 0xff) == IB_SMI_DIRECT_CLASS); in mad_build_pkt()
174 if (!is_smi) in mad_build_pkt()
175 umad_set_addr(umad, dport->lid, dport->qp, dport->sl, in mad_build_pkt()
176 dport->qkey); in mad_build_pkt()
177 else if (lid_routed) in mad_build_pkt()
178 umad_set_addr(umad, dport->lid, dport->qp, 0, 0); in mad_build_pkt()
179 else if ((dport->drpath.drslid != 0xffff) && (dport->lid > 0)) in mad_build_pkt()
180 umad_set_addr(umad, dport->lid, 0, 0, 0); in mad_build_pkt()
184 if (dport->grh_present && !is_smi) { in mad_build_pkt()
186 memcpy(addr.gid, dport->gid, 16); in mad_build_pkt()
193 umad_set_pkey(umad, is_smi ? 0 : dport->pkey_idx); in mad_build_pkt()
196 p = mad_encode(mad, rpc, lid_routed ? 0 : &dport->drpath, data); in mad_build_pkt()
197 if (!p) in mad_build_pkt()
198 return -1; in mad_build_pkt()
200 if (!is_smi && rmpp) { in mad_build_pkt()
202 mad_set_field(mad, 0, IB_SA_RMPP_TYPE_F, rmpp->type); in mad_build_pkt()
204 mad_set_field(mad, 0, IB_SA_RMPP_FLAGS_F, rmpp->flags); in mad_build_pkt()
205 mad_set_field(mad, 0, IB_SA_RMPP_STATUS_F, rmpp->status); in mad_build_pkt()
206 mad_set_field(mad, 0, IB_SA_RMPP_D1_F, rmpp->d1.u); in mad_build_pkt()
207 mad_set_field(mad, 0, IB_SA_RMPP_D2_F, rmpp->d2.u); in mad_build_pkt()
210 return ((int)(p - mad)); in mad_build_pkt()