X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lnet%2Fklnds%2Fsocklnd%2Fsocklnd_proto.c;h=dff1166a520c571b9369a322ccd94496b2880c45;hp=c60383e08f56ab3642c7939f79103ba144d4a2cd;hb=d8792a7dab933def57f6069296234ad48ea0da09;hpb=9fb46705ae86aa2c0ac29427f0ff24f923560eb7 diff --git a/lnet/klnds/socklnd/socklnd_proto.c b/lnet/klnds/socklnd/socklnd_proto.c index c60383e..dff1166 100644 --- a/lnet/klnds/socklnd/socklnd_proto.c +++ b/lnet/klnds/socklnd/socklnd_proto.c @@ -1,12 +1,14 @@ /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * + * Copyright (c) 2012, Intel Corporation. + * * Author: Zach Brown * Author: Peter J. Braam * Author: Phil Schwan * Author: Eric Barton * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ + * This file is part of Lustre, https://wiki.hpdd.intel.com/ * * Portals is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -43,7 +45,7 @@ static ksock_tx_t * ksocknal_queue_tx_msg_v1(ksock_conn_t *conn, ksock_tx_t *tx_msg) { /* V1.x, just enqueue it */ - cfs_list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue); + list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue); return NULL; } @@ -53,17 +55,18 @@ ksocknal_next_tx_carrier(ksock_conn_t *conn) ksock_tx_t *tx = conn->ksnc_tx_carrier; /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */ - LASSERT (!cfs_list_empty(&conn->ksnc_tx_queue)); - LASSERT (tx != NULL); + LASSERT(!list_empty(&conn->ksnc_tx_queue)); + LASSERT(tx != NULL); /* Next TX that can carry ZC-ACK or LNet message */ if (tx->tx_list.next == &conn->ksnc_tx_queue) { /* no more packets queued */ conn->ksnc_tx_carrier = NULL; } else { - conn->ksnc_tx_carrier = cfs_list_entry(tx->tx_list.next, + conn->ksnc_tx_carrier = list_entry(tx->tx_list.next, ksock_tx_t, tx_list); - LASSERT (conn->ksnc_tx_carrier->tx_msg.ksm_type == tx->tx_msg.ksm_type); + LASSERT(conn->ksnc_tx_carrier->tx_msg.ksm_type == + tx->tx_msg.ksm_type); } } @@ -85,7 +88,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn, */ if (tx == NULL) { if (tx_ack != NULL) { - cfs_list_add_tail(&tx_ack->tx_list, + list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue); conn->ksnc_tx_carrier = tx_ack; } @@ -95,7 +98,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn, if (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP) { /* tx is noop zc-ack, can't piggyback zc-ack cookie */ if (tx_ack != NULL) - cfs_list_add_tail(&tx_ack->tx_list, + list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue); return 0; } @@ -127,13 +130,13 @@ ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg) * and replace the NOOP tx, and return the NOOP tx. */ if (tx == NULL) { /* nothing on queue */ - cfs_list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue); + list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue); conn->ksnc_tx_carrier = tx_msg; return NULL; } if (tx->tx_msg.ksm_type == KSOCK_MSG_LNET) { /* nothing to carry */ - cfs_list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue); + list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue); return NULL; } @@ -144,8 +147,8 @@ ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg) ksocknal_next_tx_carrier(conn); /* use new_tx to replace the noop zc-ack packet */ - cfs_list_add(&tx_msg->tx_list, &tx->tx_list); - cfs_list_del(&tx->tx_list); + list_add(&tx_msg->tx_list, &tx->tx_list); + list_del(&tx->tx_list); return tx; } @@ -165,7 +168,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, if ((tx = conn->ksnc_tx_carrier) == NULL) { if (tx_ack != NULL) { - cfs_list_add_tail(&tx_ack->tx_list, + list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue); conn->ksnc_tx_carrier = tx_ack; } @@ -189,7 +192,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, if (cookie == tx->tx_msg.ksm_zc_cookies[0] || cookie == tx->tx_msg.ksm_zc_cookies[1]) { - CWARN("%s: duplicated ZC cookie: "LPU64"\n", + CWARN("%s: duplicated ZC cookie: %llu\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), cookie); return 1; /* XXX return error in the future */ } @@ -216,7 +219,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, if (tx->tx_msg.ksm_zc_cookies[0] > tx->tx_msg.ksm_zc_cookies[1]) { __u64 tmp = 0; - /* two seperated cookies: (a+2, a) or (a+1, a) */ + /* two separated cookies: (a+2, a) or (a+1, a) */ LASSERT (tx->tx_msg.ksm_zc_cookies[0] - tx->tx_msg.ksm_zc_cookies[1] <= 2); @@ -241,7 +244,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, /* ksm_zc_cookies[0] < ksm_zc_cookies[1], it is range of cookies */ if (cookie >= tx->tx_msg.ksm_zc_cookies[0] && cookie <= tx->tx_msg.ksm_zc_cookies[1]) { - CWARN("%s: duplicated ZC cookie: "LPU64"\n", + CWARN("%s: duplicated ZC cookie: %llu\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), cookie); return 1; /* XXX: return error in the future */ } @@ -259,7 +262,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, /* failed to piggyback ZC-ACK */ if (tx_ack != NULL) { - cfs_list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue); + list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue); /* the next tx can piggyback at least 1 ACK */ ksocknal_next_tx_carrier(conn); } @@ -279,11 +282,11 @@ ksocknal_match_tx(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) if (tx == NULL || tx->tx_lnetmsg == NULL) { /* noop packet */ - nob = offsetof(ksock_msg_t, ksm_u); + nob = offsetof(struct ksock_msg, ksm_u); } else { nob = tx->tx_lnetmsg->msg_len + ((conn->ksnc_proto == &ksocknal_protocol_v1x) ? - sizeof(lnet_hdr_t) : sizeof(ksock_msg_t)); + sizeof(lnet_hdr_t) : sizeof(struct ksock_msg)); } /* default checking for typed connection */ @@ -317,9 +320,9 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) int nob; if (tx == NULL || tx->tx_lnetmsg == NULL) - nob = offsetof(ksock_msg_t, ksm_u); + nob = offsetof(struct ksock_msg, ksm_u); else - nob = tx->tx_lnetmsg->msg_len + sizeof(ksock_msg_t); + nob = tx->tx_lnetmsg->msg_len + sizeof(struct ksock_msg); switch (conn->ksnc_type) { default: @@ -358,14 +361,14 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) static int ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote) { - ksock_peer_t *peer = c->ksnc_peer; + ksock_peer_ni_t *peer_ni = c->ksnc_peer; ksock_conn_t *conn; ksock_tx_t *tx; int rc; read_lock(&ksocknal_data.ksnd_global_lock); - conn = ksocknal_find_conn_locked(peer, NULL, !!remote); + conn = ksocknal_find_conn_locked(peer_ni, NULL, !!remote); if (conn != NULL) { ksock_sched_t *sched = conn->ksnc_scheduler; @@ -390,7 +393,7 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote) if (tx == NULL) return -ENOMEM; - if ((rc = ksocknal_launch_packet(peer->ksnp_ni, tx, peer->ksnp_id)) == 0) + if ((rc = ksocknal_launch_packet(peer_ni->ksnp_ni, tx, peer_ni->ksnp_id)) == 0) return 0; ksocknal_free_tx(tx); @@ -401,10 +404,10 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote) static int ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2) { - ksock_peer_t *peer = conn->ksnc_peer; + ksock_peer_ni_t *peer_ni = conn->ksnc_peer; ksock_tx_t *tx; ksock_tx_t *tmp; - CFS_LIST_HEAD (zlist); + struct list_head zlist = LIST_HEAD_INIT(zlist); int count; if (cookie1 == 0) @@ -418,27 +421,27 @@ ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2) return count == 1 ? 0 : -EPROTO; } - spin_lock(&peer->ksnp_lock); + spin_lock(&peer_ni->ksnp_lock); - cfs_list_for_each_entry_safe(tx, tmp, - &peer->ksnp_zc_req_list, tx_zc_list) { + list_for_each_entry_safe(tx, tmp, + &peer_ni->ksnp_zc_req_list, tx_zc_list) { __u64 c = tx->tx_msg.ksm_zc_cookies[0]; if (c == cookie1 || c == cookie2 || (cookie1 < c && c < cookie2)) { tx->tx_msg.ksm_zc_cookies[0] = 0; - cfs_list_del(&tx->tx_zc_list); - cfs_list_add(&tx->tx_zc_list, &zlist); + list_del(&tx->tx_zc_list); + list_add(&tx->tx_zc_list, &zlist); if (--count == 0) break; } } - spin_unlock(&peer->ksnp_lock); + spin_unlock(&peer_ni->ksnp_lock); - while (!cfs_list_empty(&zlist)) { - tx = cfs_list_entry(zlist.next, ksock_tx_t, tx_zc_list); - cfs_list_del(&tx->tx_zc_list); + while (!list_empty(&zlist)) { + tx = list_entry(zlist.next, ksock_tx_t, tx_zc_list); + list_del(&tx->tx_zc_list); ksocknal_tx_decref(tx); } @@ -446,9 +449,9 @@ ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2) } static int -ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello) +ksocknal_send_hello_v1 (ksock_conn_t *conn, struct ksock_hello_msg *hello) { - cfs_socket_t *sock = conn->ksnc_sock; + struct socket *sock = conn->ksnc_sock; lnet_hdr_t *hdr; lnet_magicversion_t *hmv; int rc; @@ -491,11 +494,10 @@ ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello) hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype); hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation); - rc = libcfs_sock_write(sock, hdr, sizeof(*hdr),lnet_acceptor_timeout()); - + rc = lnet_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout()); if (rc != 0) { - CNETERR("Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n", - rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n", + rc, &conn->ksnc_ipaddr, conn->ksnc_port); goto out; } @@ -506,13 +508,13 @@ ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello) hello->kshm_ips[i] = __cpu_to_le32 (hello->kshm_ips[i]); } - rc = libcfs_sock_write(sock, hello->kshm_ips, + rc = lnet_sock_write(sock, hello->kshm_ips, hello->kshm_nips * sizeof(__u32), lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO payload (%d)" - " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + " to %pI4h/%d\n", rc, hello->kshm_nips, + &conn->ksnc_ipaddr, conn->ksnc_port); } out: LIBCFS_FREE(hdr, sizeof(*hdr)); @@ -521,9 +523,9 @@ out: } static int -ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello) +ksocknal_send_hello_v2 (ksock_conn_t *conn, struct ksock_hello_msg *hello) { - cfs_socket_t *sock = conn->ksnc_sock; + struct socket *sock = conn->ksnc_sock; int rc; hello->kshm_magic = LNET_PROTO_MAGIC; @@ -539,34 +541,34 @@ ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello) LNET_UNLOCK(); } - rc = libcfs_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips), + rc = lnet_sock_write(sock, hello, offsetof(struct ksock_hello_msg, kshm_ips), lnet_acceptor_timeout()); if (rc != 0) { - CNETERR("Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n", - rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n", + rc, &conn->ksnc_ipaddr, conn->ksnc_port); return rc; } if (hello->kshm_nips == 0) return 0; - rc = libcfs_sock_write(sock, hello->kshm_ips, + rc = lnet_sock_write(sock, hello->kshm_ips, hello->kshm_nips * sizeof(__u32), lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO payload (%d)" - " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + " to %pI4h/%d\n", rc, hello->kshm_nips, + &conn->ksnc_ipaddr, conn->ksnc_port); } return rc; } static int -ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) +ksocknal_recv_hello_v1(ksock_conn_t *conn, struct ksock_hello_msg *hello,int timeout) { - cfs_socket_t *sock = conn->ksnc_sock; + struct socket *sock = conn->ksnc_sock; lnet_hdr_t *hdr; int rc; int i; @@ -577,22 +579,22 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) return -ENOMEM; } - rc = libcfs_sock_read(sock, &hdr->src_nid, - sizeof (*hdr) - offsetof (lnet_hdr_t, src_nid), - timeout); - if (rc != 0) { - CERROR ("Error %d reading rest of HELLO hdr from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); - goto out; - } + rc = lnet_sock_read(sock, &hdr->src_nid, + sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid), + timeout); + if (rc != 0) { + CERROR("Error %d reading rest of HELLO hdr from %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); + goto out; + } /* ...and check we got what we expected */ if (hdr->type != cpu_to_le32 (LNET_MSG_HELLO)) { CERROR ("Expecting a HELLO hdr," - " but got type %d from %u.%u.%u.%u\n", + " but got type %d from %pI4h\n", le32_to_cpu (hdr->type), - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); rc = -EPROTO; goto out; } @@ -605,8 +607,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) sizeof (__u32); if (hello->kshm_nips > LNET_MAX_INTERFACES) { - CERROR("Bad nips %d from ip %u.%u.%u.%u\n", - hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Bad nips %d from ip %pI4h\n", + hello->kshm_nips, &conn->ksnc_ipaddr); rc = -EPROTO; goto out; } @@ -614,12 +616,12 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) if (hello->kshm_nips == 0) goto out; - rc = libcfs_sock_read(sock, hello->kshm_ips, + rc = lnet_sock_read(sock, hello->kshm_ips, hello->kshm_nips * sizeof(__u32), timeout); if (rc != 0) { - CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); + CERROR("Error %d reading IPs from ip %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); goto out; } @@ -627,8 +629,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) hello->kshm_ips[i] = __le32_to_cpu(hello->kshm_ips[i]); if (hello->kshm_ips[i] == 0) { - CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n", - i, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Zero IP[%d] from ip %pI4h\n", + i, &conn->ksnc_ipaddr); rc = -EPROTO; break; } @@ -640,9 +642,10 @@ out: } static int -ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout) +ksocknal_recv_hello_v2(ksock_conn_t *conn, struct ksock_hello_msg *hello, + int timeout) { - cfs_socket_t *sock = conn->ksnc_sock; + struct socket *sock = conn->ksnc_sock; int rc; int i; @@ -651,14 +654,14 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou else conn->ksnc_flip = 1; - rc = libcfs_sock_read(sock, &hello->kshm_src_nid, - offsetof(ksock_hello_msg_t, kshm_ips) - - offsetof(ksock_hello_msg_t, kshm_src_nid), + rc = lnet_sock_read(sock, &hello->kshm_src_nid, + offsetof(struct ksock_hello_msg, kshm_ips) - + offsetof(struct ksock_hello_msg, kshm_src_nid), timeout); if (rc != 0) { - CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); + CERROR("Error %d reading HELLO from %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); return rc; } @@ -674,20 +677,20 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou } if (hello->kshm_nips > LNET_MAX_INTERFACES) { - CERROR("Bad nips %d from ip %u.%u.%u.%u\n", - hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Bad nips %d from ip %pI4h\n", + hello->kshm_nips, &conn->ksnc_ipaddr); return -EPROTO; } if (hello->kshm_nips == 0) return 0; - rc = libcfs_sock_read(sock, hello->kshm_ips, - hello->kshm_nips * sizeof(__u32), timeout); + rc = lnet_sock_read(sock, hello->kshm_ips, + hello->kshm_nips * sizeof(__u32), timeout); if (rc != 0) { - CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); + CERROR("Error %d reading IPs from ip %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); return rc; } @@ -696,8 +699,8 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou __swab32s(&hello->kshm_ips[i]); if (hello->kshm_ips[i] == 0) { - CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n", - i, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Zero IP[%d] from ip %pI4h\n", + i, &conn->ksnc_ipaddr); return -EPROTO; } } @@ -727,19 +730,19 @@ ksocknal_pack_msg_v2(ksock_tx_t *tx) LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP); tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr; - tx->tx_iov[0].iov_len = sizeof(ksock_msg_t); - tx->tx_resid = tx->tx_nob = sizeof(ksock_msg_t) + tx->tx_lnetmsg->msg_len; + tx->tx_iov[0].iov_len = sizeof(struct ksock_msg); + tx->tx_resid = tx->tx_nob = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len; } else { LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP); - tx->tx_iov[0].iov_len = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr); - tx->tx_resid = tx->tx_nob = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr); + tx->tx_iov[0].iov_len = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr); + tx->tx_resid = tx->tx_nob = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr); } /* Don't checksum before start sending, because packet can be piggybacked with ACK */ } static void -ksocknal_unpack_msg_v1(ksock_msg_t *msg) +ksocknal_unpack_msg_v1(struct ksock_msg *msg) { msg->ksm_csum = 0; msg->ksm_type = KSOCK_MSG_LNET; @@ -747,7 +750,7 @@ ksocknal_unpack_msg_v1(ksock_msg_t *msg) } static void -ksocknal_unpack_msg_v2(ksock_msg_t *msg) +ksocknal_unpack_msg_v2(struct ksock_msg *msg) { return; /* Do nothing */ }