- /* Wire protocol assertions generated by 'wirecheck'
- * running on Linux mdevi 2.4.21-p4smp-55chaos #1 SMP Tue Jun 8 14:38:44 PDT 2004 i686 i686 i
- * with gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34) */
-
-
- /* Constants... */
- LASSERT (PORTALS_PROTO_MAGIC == 0xeebc0ded);
- LASSERT (PORTALS_PROTO_VERSION_MAJOR == 1);
- LASSERT (PORTALS_PROTO_VERSION_MINOR == 0);
- LASSERT (PTL_MSG_ACK == 0);
- LASSERT (PTL_MSG_PUT == 1);
- LASSERT (PTL_MSG_GET == 2);
- LASSERT (PTL_MSG_REPLY == 3);
- LASSERT (PTL_MSG_HELLO == 4);
-
- /* Checks for struct ptl_handle_wire_t */
- LASSERT ((int)sizeof(ptl_handle_wire_t) == 16);
- LASSERT ((int)offsetof(ptl_handle_wire_t, wh_interface_cookie) == 0);
- LASSERT ((int)sizeof(((ptl_handle_wire_t *)0)->wh_interface_cookie) == 8);
- LASSERT ((int)offsetof(ptl_handle_wire_t, wh_object_cookie) == 8);
- LASSERT ((int)sizeof(((ptl_handle_wire_t *)0)->wh_object_cookie) == 8);
-
- /* Checks for struct ptl_magicversion_t */
- LASSERT ((int)sizeof(ptl_magicversion_t) == 8);
- LASSERT ((int)offsetof(ptl_magicversion_t, magic) == 0);
- LASSERT ((int)sizeof(((ptl_magicversion_t *)0)->magic) == 4);
- LASSERT ((int)offsetof(ptl_magicversion_t, version_major) == 4);
- LASSERT ((int)sizeof(((ptl_magicversion_t *)0)->version_major) == 2);
- LASSERT ((int)offsetof(ptl_magicversion_t, version_minor) == 6);
- LASSERT ((int)sizeof(((ptl_magicversion_t *)0)->version_minor) == 2);
-
- /* Checks for struct ptl_hdr_t */
- LASSERT ((int)sizeof(ptl_hdr_t) == 72);
- LASSERT ((int)offsetof(ptl_hdr_t, dest_nid) == 0);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->dest_nid) == 8);
- LASSERT ((int)offsetof(ptl_hdr_t, src_nid) == 8);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->src_nid) == 8);
- LASSERT ((int)offsetof(ptl_hdr_t, dest_pid) == 16);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->dest_pid) == 4);
- LASSERT ((int)offsetof(ptl_hdr_t, src_pid) == 20);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->src_pid) == 4);
- LASSERT ((int)offsetof(ptl_hdr_t, type) == 24);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->type) == 4);
- LASSERT ((int)offsetof(ptl_hdr_t, payload_length) == 28);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->payload_length) == 4);
- LASSERT ((int)offsetof(ptl_hdr_t, msg) == 32);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg) == 40);
-
- /* Ack */
- LASSERT ((int)offsetof(ptl_hdr_t, msg.ack.dst_wmd) == 32);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.ack.dst_wmd) == 16);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.ack.match_bits) == 48);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.ack.match_bits) == 8);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.ack.mlength) == 56);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.ack.mlength) == 4);
-
- /* Put */
- LASSERT ((int)offsetof(ptl_hdr_t, msg.put.ack_wmd) == 32);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.ack_wmd) == 16);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.put.match_bits) == 48);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.match_bits) == 8);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.put.hdr_data) == 56);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.hdr_data) == 8);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.put.ptl_index) == 64);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.ptl_index) == 4);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.put.offset) == 68);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.offset) == 4);
-
- /* Get */
- LASSERT ((int)offsetof(ptl_hdr_t, msg.get.return_wmd) == 32);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.return_wmd) == 16);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.get.match_bits) == 48);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.match_bits) == 8);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.get.ptl_index) == 56);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.ptl_index) == 4);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.get.src_offset) == 60);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.src_offset) == 4);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.get.sink_length) == 64);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.sink_length) == 4);
-
- /* Reply */
- LASSERT ((int)offsetof(ptl_hdr_t, msg.reply.dst_wmd) == 32);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.reply.dst_wmd) == 16);
-
- /* Hello */
- LASSERT ((int)offsetof(ptl_hdr_t, msg.hello.incarnation) == 32);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.hello.incarnation) == 8);
- LASSERT ((int)offsetof(ptl_hdr_t, msg.hello.type) == 40);
- LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.hello.type) == 4);
+#ifdef __KERNEL__
+ return 0;
+#else
+ lnet_ni_t *ni;
+ lnet_remotenet_t *rnet;
+ struct list_head *tmp;
+ lnet_route_t *route;
+ lnet_nid_t *nids;
+ int nnids;
+ int maxnids = 256;
+ int rc = 0;
+ int rc2;
+
+ /* Target on a local network? */
+
+ ni = lnet_net2ni(LNET_NIDNET(id.nid));
+ if (ni != NULL) {
+ if (ni->ni_lnd->lnd_setasync != NULL)
+ rc = (ni->ni_lnd->lnd_setasync)(ni, id, nasync);
+ lnet_ni_decref(ni);
+ return rc;
+ }
+
+ /* Target on a remote network: apply to routers */
+ again:
+ LIBCFS_ALLOC(nids, maxnids * sizeof(*nids));
+ if (nids == NULL)
+ return -ENOMEM;
+ nnids = 0;
+
+ /* Snapshot all the router NIDs */
+ LNET_LOCK();
+ rnet = lnet_find_net_locked(LNET_NIDNET(id.nid));
+ if (rnet != NULL) {
+ list_for_each(tmp, &rnet->lrn_routes) {
+ if (nnids == maxnids) {
+ LNET_UNLOCK();
+ LIBCFS_FREE(nids, maxnids * sizeof(*nids));
+ maxnids *= 2;
+ goto again;
+ }
+
+ route = list_entry(tmp, lnet_route_t, lr_list);
+ nids[nnids++] = route->lr_gateway->lp_nid;
+ }
+ }
+ LNET_UNLOCK();
+
+ /* set async on all the routers */
+ while (nnids-- > 0) {
+ id.pid = LUSTRE_SRV_LNET_PID;
+ id.nid = nids[nnids];
+
+ ni = lnet_net2ni(LNET_NIDNET(id.nid));
+ if (ni == NULL)
+ continue;
+
+ if (ni->ni_lnd->lnd_setasync != NULL) {
+ rc2 = (ni->ni_lnd->lnd_setasync)(ni, id, nasync);
+ if (rc2 != 0)
+ rc = rc2;
+ }
+ lnet_ni_decref(ni);
+ }
+
+ LIBCFS_FREE(nids, maxnids * sizeof(*nids));
+ return rc;
+#endif