2 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
4 * Copyright (c) 2012, Intel Corporation.
6 * Author: Zach Brown <zab@zabbo.net>
7 * Author: Peter J. Braam <braam@clusterfs.com>
8 * Author: Phil Schwan <phil@clusterfs.com>
9 * Author: Eric Barton <eric@bartonsoftware.com>
11 * This file is part of Portals, http://www.sf.net/projects/sandiaportals/
13 * Portals is free software; you can redistribute it and/or
14 * modify it under the terms of version 2 of the GNU General Public
15 * License as published by the Free Software Foundation.
17 * Portals is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
28 * pro_send_hello : send hello message
29 * pro_recv_hello : receive hello message
30 * pro_pack : pack message header
31 * pro_unpack : unpack message header
32 * pro_queue_tx_zcack() : Called holding BH lock: kss_lock
33 * return 1 if ACK is piggybacked, otherwise return 0
34 * pro_queue_tx_msg() : Called holding BH lock: kss_lock
35 * return the ACK that piggybacked by my message, or NULL
36 * pro_handle_zcreq() : handler of incoming ZC-REQ
37 * pro_handle_zcack() : handler of incoming ZC-ACK
38 * pro_match_tx() : Called holding glock
41 static struct ksock_tx *
42 ksocknal_queue_tx_msg_v1(struct ksock_conn *conn, struct ksock_tx *tx_msg)
44 /* V1.x, just enqueue it */
45 list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
50 ksocknal_next_tx_carrier(struct ksock_conn *conn)
52 struct ksock_tx *tx = conn->ksnc_tx_carrier;
54 /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
55 LASSERT(!list_empty(&conn->ksnc_tx_queue));
58 /* Next TX that can carry ZC-ACK or LNet message */
59 if (tx->tx_list.next == &conn->ksnc_tx_queue) {
60 /* no more packets queued */
61 conn->ksnc_tx_carrier = NULL;
63 conn->ksnc_tx_carrier = list_next_entry(tx, tx_list);
64 LASSERT(conn->ksnc_tx_carrier->tx_msg.ksm_type == tx->tx_msg.ksm_type);
69 ksocknal_queue_tx_zcack_v2(struct ksock_conn *conn,
70 struct ksock_tx *tx_ack, __u64 cookie)
72 struct ksock_tx *tx = conn->ksnc_tx_carrier;
75 tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
78 * Enqueue or piggyback tx_ack / cookie
79 * . no tx can piggyback cookie of tx_ack (or cookie), just
80 * enqueue the tx_ack (if tx_ack != NUL) and return NULL.
81 * . There is tx can piggyback cookie of tx_ack (or cookie),
82 * piggyback the cookie and return the tx.
86 list_add_tail(&tx_ack->tx_list,
87 &conn->ksnc_tx_queue);
88 conn->ksnc_tx_carrier = tx_ack;
93 if (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP) {
94 /* tx is noop zc-ack, can't piggyback zc-ack cookie */
96 list_add_tail(&tx_ack->tx_list,
97 &conn->ksnc_tx_queue);
101 LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_LNET);
102 LASSERT(!tx->tx_msg.ksm_zc_cookies[1]);
105 cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
107 /* piggyback the zc-ack cookie */
108 tx->tx_msg.ksm_zc_cookies[1] = cookie;
109 /* move on to the next TX which can carry cookie */
110 ksocknal_next_tx_carrier(conn);
115 static struct ksock_tx *
116 ksocknal_queue_tx_msg_v2(struct ksock_conn *conn, struct ksock_tx *tx_msg)
118 struct ksock_tx *tx = conn->ksnc_tx_carrier;
122 * . If there is no NOOP on the connection, just enqueue
123 * tx_msg and return NULL
124 * . If there is NOOP on the connection, piggyback the cookie
125 * and replace the NOOP tx, and return the NOOP tx.
127 if (!tx) { /* nothing on queue */
128 list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
129 conn->ksnc_tx_carrier = tx_msg;
133 if (tx->tx_msg.ksm_type == KSOCK_MSG_LNET) { /* nothing to carry */
134 list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
138 LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
140 /* There is a noop zc-ack can be piggybacked */
141 tx_msg->tx_msg.ksm_zc_cookies[1] = tx->tx_msg.ksm_zc_cookies[1];
142 ksocknal_next_tx_carrier(conn);
144 /* use new_tx to replace the noop zc-ack packet */
145 list_add(&tx_msg->tx_list, &tx->tx_list);
146 list_del(&tx->tx_list);
152 ksocknal_queue_tx_zcack_v3(struct ksock_conn *conn,
153 struct ksock_tx *tx_ack, __u64 cookie)
157 if (conn->ksnc_type != SOCKLND_CONN_ACK)
158 return ksocknal_queue_tx_zcack_v2(conn, tx_ack, cookie);
160 /* non-blocking ZC-ACK (to router) */
162 tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
164 tx = conn->ksnc_tx_carrier;
167 list_add_tail(&tx_ack->tx_list,
168 &conn->ksnc_tx_queue);
169 conn->ksnc_tx_carrier = tx_ack;
174 /* conn->ksnc_tx_carrier */
177 cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
179 if (cookie == SOCKNAL_KEEPALIVE_PING) /* ignore keepalive PING */
182 if (tx->tx_msg.ksm_zc_cookies[1] == SOCKNAL_KEEPALIVE_PING) {
183 /* replace the keepalive PING with a real ACK */
184 LASSERT(!tx->tx_msg.ksm_zc_cookies[0]);
185 tx->tx_msg.ksm_zc_cookies[1] = cookie;
189 if (cookie == tx->tx_msg.ksm_zc_cookies[0] ||
190 cookie == tx->tx_msg.ksm_zc_cookies[1]) {
191 CWARN("%s: duplicated ZC cookie: %llu\n",
192 libcfs_id2str(conn->ksnc_peer->ksnp_id), cookie);
193 return 1; /* XXX return error in the future */
196 if (!tx->tx_msg.ksm_zc_cookies[0]) {
197 /* NOOP tx has only one ZC-ACK cookie, can carry at least one more */
198 if (tx->tx_msg.ksm_zc_cookies[1] > cookie) {
199 tx->tx_msg.ksm_zc_cookies[0] = tx->tx_msg.ksm_zc_cookies[1];
200 tx->tx_msg.ksm_zc_cookies[1] = cookie;
202 tx->tx_msg.ksm_zc_cookies[0] = cookie;
205 if (tx->tx_msg.ksm_zc_cookies[0] - tx->tx_msg.ksm_zc_cookies[1] > 2) {
206 /* not likely to carry more ACKs, skip it to simplify logic */
207 ksocknal_next_tx_carrier(conn);
213 /* takes two or more cookies already */
215 if (tx->tx_msg.ksm_zc_cookies[0] > tx->tx_msg.ksm_zc_cookies[1]) {
218 /* two separated cookies: (a+2, a) or (a+1, a) */
219 LASSERT(tx->tx_msg.ksm_zc_cookies[0] -
220 tx->tx_msg.ksm_zc_cookies[1] <= 2);
222 if (tx->tx_msg.ksm_zc_cookies[0] -
223 tx->tx_msg.ksm_zc_cookies[1] == 2) {
224 if (cookie == tx->tx_msg.ksm_zc_cookies[1] + 1)
226 } else if (cookie == tx->tx_msg.ksm_zc_cookies[1] - 1) {
227 tmp = tx->tx_msg.ksm_zc_cookies[1];
228 } else if (cookie == tx->tx_msg.ksm_zc_cookies[0] + 1) {
229 tmp = tx->tx_msg.ksm_zc_cookies[0];
233 /* range of cookies */
234 tx->tx_msg.ksm_zc_cookies[0] = tmp - 1;
235 tx->tx_msg.ksm_zc_cookies[1] = tmp + 1;
240 /* ksm_zc_cookies[0] < ksm_zc_cookies[1], it is range of cookies */
241 if (cookie >= tx->tx_msg.ksm_zc_cookies[0] &&
242 cookie <= tx->tx_msg.ksm_zc_cookies[1]) {
243 CWARN("%s: duplicated ZC cookie: %llu\n",
244 libcfs_id2str(conn->ksnc_peer->ksnp_id), cookie);
245 return 1; /* XXX: return error in the future */
248 if (cookie == tx->tx_msg.ksm_zc_cookies[1] + 1) {
249 tx->tx_msg.ksm_zc_cookies[1] = cookie;
253 if (cookie == tx->tx_msg.ksm_zc_cookies[0] - 1) {
254 tx->tx_msg.ksm_zc_cookies[0] = cookie;
259 /* failed to piggyback ZC-ACK */
261 list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
262 /* the next tx can piggyback at least 1 ACK */
263 ksocknal_next_tx_carrier(conn);
270 ksocknal_match_tx(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)
274 #if SOCKNAL_VERSION_DEBUG
275 if (!*ksocknal_tunables.ksnd_typed_conns)
276 return SOCKNAL_MATCH_YES;
279 if (!tx || !tx->tx_lnetmsg) {
281 nob = offsetof(ksock_msg_t, ksm_u);
283 nob = tx->tx_lnetmsg->msg_len +
284 ((conn->ksnc_proto == &ksocknal_protocol_v1x) ?
285 sizeof(lnet_hdr_t) : sizeof(ksock_msg_t));
288 /* default checking for typed connection */
289 switch (conn->ksnc_type) {
291 CERROR("ksnc_type bad: %u\n", conn->ksnc_type);
293 case SOCKLND_CONN_ANY:
294 return SOCKNAL_MATCH_YES;
296 case SOCKLND_CONN_BULK_IN:
297 return SOCKNAL_MATCH_MAY;
299 case SOCKLND_CONN_BULK_OUT:
300 if (nob < *ksocknal_tunables.ksnd_min_bulk)
301 return SOCKNAL_MATCH_MAY;
303 return SOCKNAL_MATCH_YES;
305 case SOCKLND_CONN_CONTROL:
306 if (nob >= *ksocknal_tunables.ksnd_min_bulk)
307 return SOCKNAL_MATCH_MAY;
309 return SOCKNAL_MATCH_YES;
314 ksocknal_match_tx_v3(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)
318 if (!tx || !tx->tx_lnetmsg)
319 nob = offsetof(ksock_msg_t, ksm_u);
321 nob = tx->tx_lnetmsg->msg_len + sizeof(ksock_msg_t);
323 switch (conn->ksnc_type) {
325 CERROR("ksnc_type bad: %u\n", conn->ksnc_type);
327 case SOCKLND_CONN_ANY:
328 return SOCKNAL_MATCH_NO;
330 case SOCKLND_CONN_ACK:
332 return SOCKNAL_MATCH_YES;
333 else if (!tx || !tx->tx_lnetmsg)
334 return SOCKNAL_MATCH_MAY;
336 return SOCKNAL_MATCH_NO;
338 case SOCKLND_CONN_BULK_OUT:
340 return SOCKNAL_MATCH_NO;
341 else if (nob < *ksocknal_tunables.ksnd_min_bulk)
342 return SOCKNAL_MATCH_MAY;
344 return SOCKNAL_MATCH_YES;
346 case SOCKLND_CONN_CONTROL:
348 return SOCKNAL_MATCH_NO;
349 else if (nob >= *ksocknal_tunables.ksnd_min_bulk)
350 return SOCKNAL_MATCH_MAY;
352 return SOCKNAL_MATCH_YES;
356 /* (Sink) handle incoming ZC request from sender */
358 ksocknal_handle_zcreq(struct ksock_conn *c, __u64 cookie, int remote)
360 struct ksock_peer *peer = c->ksnc_peer;
361 struct ksock_conn *conn;
365 read_lock(&ksocknal_data.ksnd_global_lock);
367 conn = ksocknal_find_conn_locked(peer, NULL, !!remote);
369 struct ksock_sched *sched = conn->ksnc_scheduler;
371 LASSERT(conn->ksnc_proto->pro_queue_tx_zcack);
373 spin_lock_bh(&sched->kss_lock);
375 rc = conn->ksnc_proto->pro_queue_tx_zcack(conn, NULL, cookie);
377 spin_unlock_bh(&sched->kss_lock);
379 if (rc) { /* piggybacked */
380 read_unlock(&ksocknal_data.ksnd_global_lock);
385 read_unlock(&ksocknal_data.ksnd_global_lock);
387 /* ACK connection is not ready, or can't piggyback the ACK */
388 tx = ksocknal_alloc_tx_noop(cookie, !!remote);
392 rc = ksocknal_launch_packet(peer->ksnp_ni, tx, peer->ksnp_id);
396 ksocknal_free_tx(tx);
400 /* (Sender) handle ZC_ACK from sink */
402 ksocknal_handle_zcack(struct ksock_conn *conn, __u64 cookie1, __u64 cookie2)
404 struct ksock_peer *peer = conn->ksnc_peer;
406 struct ksock_tx *temp;
407 struct ksock_tx *tmp;
414 count = (cookie1 > cookie2) ? 2 : (cookie2 - cookie1 + 1);
416 if (cookie2 == SOCKNAL_KEEPALIVE_PING &&
417 conn->ksnc_proto == &ksocknal_protocol_v3x) {
418 /* keepalive PING for V3.x, just ignore it */
419 return count == 1 ? 0 : -EPROTO;
422 spin_lock(&peer->ksnp_lock);
424 list_for_each_entry_safe(tx, tmp, &peer->ksnp_zc_req_list,
426 __u64 c = tx->tx_msg.ksm_zc_cookies[0];
428 if (c == cookie1 || c == cookie2 || (cookie1 < c && c < cookie2)) {
429 tx->tx_msg.ksm_zc_cookies[0] = 0;
430 list_del(&tx->tx_zc_list);
431 list_add(&tx->tx_zc_list, &zlist);
438 spin_unlock(&peer->ksnp_lock);
440 list_for_each_entry_safe(tx, temp, &zlist, tx_zc_list) {
441 list_del(&tx->tx_zc_list);
442 ksocknal_tx_decref(tx);
445 return !count ? 0 : -EPROTO;
449 ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello)
451 struct socket *sock = conn->ksnc_sock;
453 lnet_magicversion_t *hmv;
457 CLASSERT(sizeof(lnet_magicversion_t) == offsetof(lnet_hdr_t, src_nid));
459 LIBCFS_ALLOC(hdr, sizeof(*hdr));
461 CERROR("Can't allocate lnet_hdr_t\n");
465 hmv = (lnet_magicversion_t *)&hdr->dest_nid;
468 * Re-organize V2.x message header to V1.x (lnet_hdr_t)
469 * header and send out
471 hmv->magic = cpu_to_le32(LNET_PROTO_TCP_MAGIC);
472 hmv->version_major = cpu_to_le16(KSOCK_PROTO_V1_MAJOR);
473 hmv->version_minor = cpu_to_le16(KSOCK_PROTO_V1_MINOR);
475 if (the_lnet.ln_testprotocompat) {
476 /* single-shot proto check */
478 if (the_lnet.ln_testprotocompat & 1) {
479 hmv->version_major++; /* just different! */
480 the_lnet.ln_testprotocompat &= ~1;
482 if (the_lnet.ln_testprotocompat & 2) {
483 hmv->magic = LNET_PROTO_MAGIC;
484 the_lnet.ln_testprotocompat &= ~2;
489 hdr->src_nid = cpu_to_le64(hello->kshm_src_nid);
490 hdr->src_pid = cpu_to_le32(hello->kshm_src_pid);
491 hdr->type = cpu_to_le32(LNET_MSG_HELLO);
492 hdr->payload_length = cpu_to_le32(hello->kshm_nips * sizeof(__u32));
493 hdr->msg.hello.type = cpu_to_le32(hello->kshm_ctype);
494 hdr->msg.hello.incarnation = cpu_to_le64(hello->kshm_src_incarnation);
496 rc = lnet_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout());
498 CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
499 rc, &conn->ksnc_ipaddr, conn->ksnc_port);
503 if (!hello->kshm_nips)
506 for (i = 0; i < (int)hello->kshm_nips; i++)
507 hello->kshm_ips[i] = __cpu_to_le32(hello->kshm_ips[i]);
509 rc = lnet_sock_write(sock, hello->kshm_ips,
510 hello->kshm_nips * sizeof(__u32),
511 lnet_acceptor_timeout());
513 CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n",
514 rc, hello->kshm_nips,
515 &conn->ksnc_ipaddr, conn->ksnc_port);
518 LIBCFS_FREE(hdr, sizeof(*hdr));
524 ksocknal_send_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello)
526 struct socket *sock = conn->ksnc_sock;
529 hello->kshm_magic = LNET_PROTO_MAGIC;
530 hello->kshm_version = conn->ksnc_proto->pro_version;
532 if (the_lnet.ln_testprotocompat) {
533 /* single-shot proto check */
535 if (the_lnet.ln_testprotocompat & 1) {
536 hello->kshm_version++; /* just different! */
537 the_lnet.ln_testprotocompat &= ~1;
542 rc = lnet_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
543 lnet_acceptor_timeout());
545 CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
546 rc, &conn->ksnc_ipaddr, conn->ksnc_port);
550 if (!hello->kshm_nips)
553 rc = lnet_sock_write(sock, hello->kshm_ips,
554 hello->kshm_nips * sizeof(__u32),
555 lnet_acceptor_timeout());
557 CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n",
558 rc, hello->kshm_nips,
559 &conn->ksnc_ipaddr, conn->ksnc_port);
566 ksocknal_recv_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello,
569 struct socket *sock = conn->ksnc_sock;
574 LIBCFS_ALLOC(hdr, sizeof(*hdr));
576 CERROR("Can't allocate lnet_hdr_t\n");
580 rc = lnet_sock_read(sock, &hdr->src_nid,
581 sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
584 CERROR("Error %d reading rest of HELLO hdr from %pI4h\n",
585 rc, &conn->ksnc_ipaddr);
586 LASSERT(rc < 0 && rc != -EALREADY);
590 /* ...and check we got what we expected */
591 if (hdr->type != cpu_to_le32(LNET_MSG_HELLO)) {
592 CERROR("Expecting a HELLO hdr, but got type %d from %pI4h\n",
593 le32_to_cpu(hdr->type),
599 hello->kshm_src_nid = le64_to_cpu(hdr->src_nid);
600 hello->kshm_src_pid = le32_to_cpu(hdr->src_pid);
601 hello->kshm_src_incarnation = le64_to_cpu(hdr->msg.hello.incarnation);
602 hello->kshm_ctype = le32_to_cpu(hdr->msg.hello.type);
603 hello->kshm_nips = le32_to_cpu(hdr->payload_length) /
606 if (hello->kshm_nips > LNET_MAX_INTERFACES) {
607 CERROR("Bad nips %d from ip %pI4h\n",
608 hello->kshm_nips, &conn->ksnc_ipaddr);
613 if (!hello->kshm_nips)
616 rc = lnet_sock_read(sock, hello->kshm_ips,
617 hello->kshm_nips * sizeof(__u32), timeout);
619 CERROR("Error %d reading IPs from ip %pI4h\n",
620 rc, &conn->ksnc_ipaddr);
621 LASSERT(rc < 0 && rc != -EALREADY);
625 for (i = 0; i < (int)hello->kshm_nips; i++) {
626 hello->kshm_ips[i] = __le32_to_cpu(hello->kshm_ips[i]);
628 if (!hello->kshm_ips[i]) {
629 CERROR("Zero IP[%d] from ip %pI4h\n",
630 i, &conn->ksnc_ipaddr);
636 LIBCFS_FREE(hdr, sizeof(*hdr));
642 ksocknal_recv_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello, int timeout)
644 struct socket *sock = conn->ksnc_sock;
648 if (hello->kshm_magic == LNET_PROTO_MAGIC)
653 rc = lnet_sock_read(sock, &hello->kshm_src_nid,
654 offsetof(ksock_hello_msg_t, kshm_ips) -
655 offsetof(ksock_hello_msg_t, kshm_src_nid),
658 CERROR("Error %d reading HELLO from %pI4h\n",
659 rc, &conn->ksnc_ipaddr);
660 LASSERT(rc < 0 && rc != -EALREADY);
664 if (conn->ksnc_flip) {
665 __swab32s(&hello->kshm_src_pid);
666 __swab64s(&hello->kshm_src_nid);
667 __swab32s(&hello->kshm_dst_pid);
668 __swab64s(&hello->kshm_dst_nid);
669 __swab64s(&hello->kshm_src_incarnation);
670 __swab64s(&hello->kshm_dst_incarnation);
671 __swab32s(&hello->kshm_ctype);
672 __swab32s(&hello->kshm_nips);
675 if (hello->kshm_nips > LNET_MAX_INTERFACES) {
676 CERROR("Bad nips %d from ip %pI4h\n",
677 hello->kshm_nips, &conn->ksnc_ipaddr);
681 if (!hello->kshm_nips)
684 rc = lnet_sock_read(sock, hello->kshm_ips,
685 hello->kshm_nips * sizeof(__u32), timeout);
687 CERROR("Error %d reading IPs from ip %pI4h\n",
688 rc, &conn->ksnc_ipaddr);
689 LASSERT(rc < 0 && rc != -EALREADY);
693 for (i = 0; i < (int)hello->kshm_nips; i++) {
695 __swab32s(&hello->kshm_ips[i]);
697 if (!hello->kshm_ips[i]) {
698 CERROR("Zero IP[%d] from ip %pI4h\n",
699 i, &conn->ksnc_ipaddr);
708 ksocknal_pack_msg_v1(struct ksock_tx *tx)
710 /* V1.x has no KSOCK_MSG_NOOP */
711 LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
712 LASSERT(tx->tx_lnetmsg);
714 tx->tx_iov[0].iov_base = &tx->tx_lnetmsg->msg_hdr;
715 tx->tx_iov[0].iov_len = sizeof(lnet_hdr_t);
717 tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(lnet_hdr_t);
718 tx->tx_resid = tx->tx_lnetmsg->msg_len + sizeof(lnet_hdr_t);
722 ksocknal_pack_msg_v2(struct ksock_tx *tx)
724 tx->tx_iov[0].iov_base = &tx->tx_msg;
726 if (tx->tx_lnetmsg) {
727 LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
729 tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr;
730 tx->tx_iov[0].iov_len = sizeof(ksock_msg_t);
731 tx->tx_nob = sizeof(ksock_msg_t) + tx->tx_lnetmsg->msg_len;
732 tx->tx_resid = sizeof(ksock_msg_t) + tx->tx_lnetmsg->msg_len;
734 LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
736 tx->tx_iov[0].iov_len = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr);
737 tx->tx_nob = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr);
738 tx->tx_resid = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr);
740 /* Don't checksum before start sending, because packet can be piggybacked with ACK */
744 ksocknal_unpack_msg_v1(ksock_msg_t *msg)
747 msg->ksm_type = KSOCK_MSG_LNET;
748 msg->ksm_zc_cookies[0] = 0;
749 msg->ksm_zc_cookies[1] = 0;
753 ksocknal_unpack_msg_v2(ksock_msg_t *msg)
755 return; /* Do nothing */
758 struct ksock_proto ksocknal_protocol_v1x = {
759 .pro_version = KSOCK_PROTO_V1,
760 .pro_send_hello = ksocknal_send_hello_v1,
761 .pro_recv_hello = ksocknal_recv_hello_v1,
762 .pro_pack = ksocknal_pack_msg_v1,
763 .pro_unpack = ksocknal_unpack_msg_v1,
764 .pro_queue_tx_msg = ksocknal_queue_tx_msg_v1,
765 .pro_handle_zcreq = NULL,
766 .pro_handle_zcack = NULL,
767 .pro_queue_tx_zcack = NULL,
768 .pro_match_tx = ksocknal_match_tx
771 struct ksock_proto ksocknal_protocol_v2x = {
772 .pro_version = KSOCK_PROTO_V2,
773 .pro_send_hello = ksocknal_send_hello_v2,
774 .pro_recv_hello = ksocknal_recv_hello_v2,
775 .pro_pack = ksocknal_pack_msg_v2,
776 .pro_unpack = ksocknal_unpack_msg_v2,
777 .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
778 .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v2,
779 .pro_handle_zcreq = ksocknal_handle_zcreq,
780 .pro_handle_zcack = ksocknal_handle_zcack,
781 .pro_match_tx = ksocknal_match_tx
784 struct ksock_proto ksocknal_protocol_v3x = {
785 .pro_version = KSOCK_PROTO_V3,
786 .pro_send_hello = ksocknal_send_hello_v2,
787 .pro_recv_hello = ksocknal_recv_hello_v2,
788 .pro_pack = ksocknal_pack_msg_v2,
789 .pro_unpack = ksocknal_unpack_msg_v2,
790 .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
791 .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v3,
792 .pro_handle_zcreq = ksocknal_handle_zcreq,
793 .pro_handle_zcack = ksocknal_handle_zcack,
794 .pro_match_tx = ksocknal_match_tx_v3