Whamcloud - gitweb
LU-2335 lnet: remove unnecessary libcfs include
[fs/lustre-release.git] / lnet / selftest / rpc.h
index 5cd7b32..d9cdca5 100644 (file)
@@ -1,6 +1,39 @@
-/* -*- 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.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * 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.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ */
+
 #ifndef __SELFTEST_RPC_H__
 #define __SELFTEST_RPC_H__
 
@@ -32,6 +65,11 @@ typedef enum {
         SRPC_MSG_JOIN_REPLY     = 17,
 } srpc_msg_type_t;
 
+#ifdef __WINNT__
+#include <libcfs/libcfs_pack.h>
+#include <libcfs/libcfs_unpack.h>
+#endif
+
 /* CAVEAT EMPTOR:
  * All srpc_*_reqst_t's 1st field must be matchbits of reply buffer,
  * and 2nd field matchbits of bulk buffer if any.
@@ -142,32 +180,44 @@ typedef struct {
 } WIRE_ATTR test_bulk_req_t;
 
 typedef struct {
-        __u32                   png_size;       /* size of ping message */
-        __u32                   png_flags;      /* reserved flags */
+       /** bulk operation code */
+       __u16                   blk_opc;
+       /** data check flags */
+       __u16                   blk_flags;
+       /** data length */
+       __u32                   blk_len;
+       /** reserved: offset */
+       __u32                   blk_offset;
+} WIRE_ATTR test_bulk_req_v1_t;
+
+typedef struct {
+       __u32                   png_size;       /* size of ping message */
+       __u32                   png_flags;      /* reserved flags */
 } WIRE_ATTR test_ping_req_t;
 
 typedef struct {
-        __u64                   tsr_rpyid;      /* reply buffer matchbits */
-        __u64                  tsr_bulkid;     /* bulk buffer matchbits */
-        lst_sid_t               tsr_sid;        /* session id */
-        lst_bid_t               tsr_bid;        /* batch id */
-        __u32                   tsr_service;    /* test type: bulk|ping|... */
-        /* test client loop count or # server buffers needed */
-        __u32                   tsr_loop;       
-        __u32                   tsr_concur;     /* concurrency of test */
-        __u8                    tsr_is_client;  /* is test client or not */
-        __u8                    tsr_stop_onerr; /* stop on error */
-        __u32                   tsr_ndest;      /* # of dest nodes */
+       __u64                   tsr_rpyid;      /* reply buffer matchbits */
+       __u64                   tsr_bulkid;     /* bulk buffer matchbits */
+       lst_sid_t               tsr_sid;        /* session id */
+       lst_bid_t               tsr_bid;        /* batch id */
+       __u32                   tsr_service;    /* test type: bulk|ping|... */
+       /* test client loop count or # server buffers needed */
+       __u32                   tsr_loop;
+       __u32                   tsr_concur;     /* concurrency of test */
+       __u8                    tsr_is_client;  /* is test client or not */
+       __u8                    tsr_stop_onerr; /* stop on error */
+       __u32                   tsr_ndest;      /* # of dest nodes */
 
        union {
-               test_bulk_req_t bulk;
-               test_ping_req_t ping;
-       }                       tsr_u;
+               test_ping_req_t         ping;
+               test_bulk_req_t         bulk_v0;
+               test_bulk_req_v1_t      bulk_v1;
+       }               tsr_u;
 } WIRE_ATTR srpc_test_reqst_t;
 
 typedef struct {
-        __u32                   tsr_status;     /* returned code */
-        lst_sid_t               tsr_sid;        
+       __u32                   tsr_status;     /* returned code */
+       lst_sid_t               tsr_sid;
 } WIRE_ATTR srpc_test_reply_t;
 
 /* TEST RPCs */
@@ -199,13 +249,18 @@ typedef struct {
 
 #define SRPC_MSG_MAGIC                  0xeeb0f00d
 #define SRPC_MSG_VERSION                1
-typedef struct {
-       __u32   msg_magic;              /* magic */
-       __u32   msg_version;            /* # version */
-        __u32  msg_type;               /* what's in msg_body? srpc_msg_type_t */
-        __u32   msg_reserved0;          /* reserved seats */
-        __u32   msg_reserved1;
-        __u32   msg_reserved2;
+
+typedef struct srpc_msg {
+       /** magic number */
+       __u32   msg_magic;
+       /** message version number */
+       __u32   msg_version;
+       /** type of message body: srpc_msg_type_t */
+       __u32   msg_type;
+       __u32   msg_reserved0;
+       __u32   msg_reserved1;
+       /** test session features */
+       __u32   msg_ses_feats;
         union {
                 srpc_generic_reqst_t reqst;
                 srpc_generic_reply_t reply;
@@ -232,4 +287,20 @@ typedef struct {
         }     msg_body;
 } WIRE_ATTR srpc_msg_t;
 
+static inline void
+srpc_unpack_msg_hdr(srpc_msg_t *msg)
+{
+       if (msg->msg_magic == SRPC_MSG_MAGIC)
+               return; /* no flipping needed */
+
+       /* We do not swap the magic number here as it is needed to
+          determine whether the body needs to be swapped. */
+       /* __swab32s(&msg->msg_magic); */
+       __swab32s(&msg->msg_type);
+       __swab32s(&msg->msg_version);
+       __swab32s(&msg->msg_ses_feats);
+       __swab32s(&msg->msg_reserved0);
+       __swab32s(&msg->msg_reserved1);
+}
+
 #endif /* __SELFTEST_RPC_H__ */