X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Futils%2Fwirecheck.c;h=98aaee9adb8cccbf531f6b4e370350d4d4441f1b;hb=81fff75016dae08332d1a6cdd5137fc4e3097665;hp=17c57aab6a4f4c01785acb7bd91cdee92c9a9916;hpb=ba8500293ed9ec8421b17e510443d5f7cf58c997;p=fs%2Flustre-release.git diff --git a/lnet/utils/wirecheck.c b/lnet/utils/wirecheck.c index 17c57aa..98aaee9 100644 --- a/lnet/utils/wirecheck.c +++ b/lnet/utils/wirecheck.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -17,29 +15,33 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2014, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include #include +#include +#include +#include #include #include -#include - -#include +#include #ifndef HAVE_STRNLEN #define strnlen(s, i) strlen(s) @@ -59,12 +61,12 @@ do { \ #define CHECK_DEFINE(a) \ do { \ - printf (" CLASSERT ("#a" == "STRINGIFY(a)");\n"); \ + printf (" BUILD_BUG_ON("#a" != "STRINGIFY(a)");\n"); \ } while (0) -#define CHECK_VALUE(a) \ -do { \ - printf (" CLASSERT ("#a" == %d);\n", a); \ +#define CHECK_VALUE(a) \ +do { \ + printf (" BUILD_BUG_ON("#a" != %d);\n", a); \ } while (0) #define CHECK_MEMBER_OFFSET(s,m) \ @@ -91,68 +93,107 @@ do { \ } while (0) void -check_lnet_handle_wire (void) +check_lnet_handle_wire(void) { - CHECK_STRUCT (lnet_handle_wire_t); - CHECK_MEMBER (lnet_handle_wire_t, wh_interface_cookie); - CHECK_MEMBER (lnet_handle_wire_t, wh_object_cookie); + CHECK_STRUCT(struct lnet_handle_wire); + CHECK_MEMBER(struct lnet_handle_wire, wh_interface_cookie); + CHECK_MEMBER(struct lnet_handle_wire, wh_object_cookie); } void check_lnet_magicversion (void) { - CHECK_STRUCT (lnet_magicversion_t); - CHECK_MEMBER (lnet_magicversion_t, magic); - CHECK_MEMBER (lnet_magicversion_t, version_major); - CHECK_MEMBER (lnet_magicversion_t, version_minor); + CHECK_STRUCT(struct lnet_magicversion); + CHECK_MEMBER(struct lnet_magicversion, magic); + CHECK_MEMBER(struct lnet_magicversion, version_major); + CHECK_MEMBER(struct lnet_magicversion, version_minor); } void check_lnet_hdr (void) { - CHECK_STRUCT (lnet_hdr_t); - CHECK_MEMBER (lnet_hdr_t, dest_nid); - CHECK_MEMBER (lnet_hdr_t, src_nid); - CHECK_MEMBER (lnet_hdr_t, dest_pid); - CHECK_MEMBER (lnet_hdr_t, src_pid); - CHECK_MEMBER (lnet_hdr_t, type); - CHECK_MEMBER (lnet_hdr_t, payload_length); - CHECK_MEMBER (lnet_hdr_t, msg); + CHECK_STRUCT(struct lnet_hdr); + CHECK_MEMBER(struct lnet_hdr, dest_nid); + CHECK_MEMBER(struct lnet_hdr, src_nid); + CHECK_MEMBER(struct lnet_hdr, dest_pid); + CHECK_MEMBER(struct lnet_hdr, src_pid); + CHECK_MEMBER(struct lnet_hdr, type); + CHECK_MEMBER(struct lnet_hdr, payload_length); + CHECK_MEMBER(struct lnet_hdr, msg); BLANK_LINE (); COMMENT ("Ack"); - CHECK_MEMBER (lnet_hdr_t, msg.ack.dst_wmd); - CHECK_MEMBER (lnet_hdr_t, msg.ack.match_bits); - CHECK_MEMBER (lnet_hdr_t, msg.ack.mlength); + CHECK_MEMBER(struct lnet_hdr, msg.ack.dst_wmd); + CHECK_MEMBER(struct lnet_hdr, msg.ack.match_bits); + CHECK_MEMBER(struct lnet_hdr, msg.ack.mlength); BLANK_LINE (); COMMENT ("Put"); - CHECK_MEMBER (lnet_hdr_t, msg.put.ack_wmd); - CHECK_MEMBER (lnet_hdr_t, msg.put.match_bits); - CHECK_MEMBER (lnet_hdr_t, msg.put.hdr_data); - CHECK_MEMBER (lnet_hdr_t, msg.put.ptl_index); - CHECK_MEMBER (lnet_hdr_t, msg.put.offset); + CHECK_MEMBER(struct lnet_hdr, msg.put.ack_wmd); + CHECK_MEMBER(struct lnet_hdr, msg.put.match_bits); + CHECK_MEMBER(struct lnet_hdr, msg.put.hdr_data); + CHECK_MEMBER(struct lnet_hdr, msg.put.ptl_index); + CHECK_MEMBER(struct lnet_hdr, msg.put.offset); BLANK_LINE (); COMMENT ("Get"); - CHECK_MEMBER (lnet_hdr_t, msg.get.return_wmd); - CHECK_MEMBER (lnet_hdr_t, msg.get.match_bits); - CHECK_MEMBER (lnet_hdr_t, msg.get.ptl_index); - CHECK_MEMBER (lnet_hdr_t, msg.get.src_offset); - CHECK_MEMBER (lnet_hdr_t, msg.get.sink_length); + CHECK_MEMBER(struct lnet_hdr, msg.get.return_wmd); + CHECK_MEMBER(struct lnet_hdr, msg.get.match_bits); + CHECK_MEMBER(struct lnet_hdr, msg.get.ptl_index); + CHECK_MEMBER(struct lnet_hdr, msg.get.src_offset); + CHECK_MEMBER(struct lnet_hdr, msg.get.sink_length); BLANK_LINE (); COMMENT ("Reply"); - CHECK_MEMBER (lnet_hdr_t, msg.reply.dst_wmd); + CHECK_MEMBER(struct lnet_hdr, msg.reply.dst_wmd); BLANK_LINE (); COMMENT ("Hello"); - CHECK_MEMBER (lnet_hdr_t, msg.hello.incarnation); - CHECK_MEMBER (lnet_hdr_t, msg.hello.type); + CHECK_MEMBER(struct lnet_hdr, msg.hello.incarnation); + CHECK_MEMBER(struct lnet_hdr, msg.hello.type); +} + +void +check_lnet_ni_status(void) +{ + BLANK_LINE(); + COMMENT("Checks for struct lnet_ni_status and related constants"); + + CHECK_DEFINE(LNET_NI_STATUS_INVALID); + CHECK_DEFINE(LNET_NI_STATUS_UP); + CHECK_DEFINE(LNET_NI_STATUS_DOWN); + + CHECK_STRUCT(struct lnet_ni_status); + CHECK_MEMBER(struct lnet_ni_status, ns_nid); + CHECK_MEMBER(struct lnet_ni_status, ns_status); + CHECK_MEMBER(struct lnet_ni_status, ns_unused); +} + +void +check_lnet_ping_info(void) +{ + BLANK_LINE(); + COMMENT("Checks for struct lnet_ping_info and related constants"); + + CHECK_DEFINE(LNET_PROTO_PING_MAGIC); + CHECK_VALUE(LNET_PING_FEAT_INVAL); + CHECK_VALUE(LNET_PING_FEAT_BASE); + CHECK_VALUE(LNET_PING_FEAT_NI_STATUS); + CHECK_VALUE(LNET_PING_FEAT_RTE_DISABLED); + CHECK_VALUE(LNET_PING_FEAT_MULTI_RAIL); + CHECK_VALUE(LNET_PING_FEAT_DISCOVERY); + CHECK_VALUE(LNET_PING_FEAT_BITS); + + CHECK_STRUCT(struct lnet_ping_info); + CHECK_MEMBER(struct lnet_ping_info, pi_magic); + CHECK_MEMBER(struct lnet_ping_info, pi_features); + CHECK_MEMBER(struct lnet_ping_info, pi_pid); + CHECK_MEMBER(struct lnet_ping_info, pi_nnis); + CHECK_MEMBER(struct lnet_ping_info, pi_ni); } void -system_string (char *cmdline, char *str, int len) +system_string(char *cmdline, char *str, int len) { int fds[2]; int rc; @@ -193,7 +234,7 @@ system_string (char *cmdline, char *str, int len) WEXITSTATUS(rc) != 0) abort(); - if (strlen(str) == len) + if (strnlen(str, len) == len) str[len - 1] = 0; if (str[strlen(str) - 1] == '\n') @@ -223,7 +264,6 @@ main (int argc, char **argv) COMMENT ("Constants..."); - CHECK_DEFINE (LNET_PROTO_OPENIB_MAGIC); CHECK_DEFINE (LNET_PROTO_RA_MAGIC); CHECK_DEFINE (LNET_PROTO_TCP_MAGIC); @@ -236,9 +276,11 @@ main (int argc, char **argv) CHECK_VALUE (LNET_MSG_REPLY); CHECK_VALUE (LNET_MSG_HELLO); - check_lnet_handle_wire (); - check_lnet_magicversion (); - check_lnet_hdr (); + check_lnet_handle_wire(); + check_lnet_magicversion(); + check_lnet_hdr(); + check_lnet_ni_status(); + check_lnet_ping_info(); printf ("}\n\n");