linux/drivers/staging/lustre/lnet/selftest/console.h
<<
>>
Prefs
   1/*
   2 * GPL HEADER START
   3 *
   4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License version 2 only,
   8 * as published by the Free Software Foundation.
   9 *
  10 * This program is distributed in the hope that it will be useful, but
  11 * WITHOUT ANY WARRANTY; without even the implied warranty of
  12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13 * General Public License version 2 for more details (a copy is included
  14 * in the LICENSE file that accompanied this code).
  15 *
  16 * You should have received a copy of the GNU General Public License
  17 * version 2 along with this program; If not, see
  18 * http://www.gnu.org/licenses/gpl-2.0.html
  19 *
  20 * GPL HEADER END
  21 */
  22/*
  23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  24 * Use is subject to license terms.
  25 *
  26 * Copyright (c) 2011, 2012, Intel Corporation.
  27 */
  28/*
  29 * This file is part of Lustre, http://www.lustre.org/
  30 * Lustre is a trademark of Sun Microsystems, Inc.
  31 *
  32 * lnet/selftest/console.h
  33 *
  34 * kernel structure for LST console
  35 *
  36 * Author: Liang Zhen <liangzhen@clusterfs.com>
  37 */
  38
  39#ifndef __LST_CONSOLE_H__
  40#define __LST_CONSOLE_H__
  41
  42#include "../../include/linux/libcfs/libcfs.h"
  43#include "../../include/linux/lnet/lnet.h"
  44#include "../../include/linux/lnet/lib-types.h"
  45#include "../../include/linux/lnet/lnetst.h"
  46#include "selftest.h"
  47#include "conrpc.h"
  48
  49/* node descriptor */
  50struct lstcon_node {
  51        lnet_process_id_t nd_id;      /* id of the node */
  52        int               nd_ref;     /* reference count */
  53        int               nd_state;   /* state of the node */
  54        int               nd_timeout; /* session timeout */
  55        unsigned long     nd_stamp;   /* timestamp of last replied RPC */
  56        struct lstcon_rpc nd_ping;    /* ping rpc */
  57};
  58
  59/* node link descriptor */
  60struct lstcon_ndlink {
  61        struct list_head ndl_link;    /* chain on list */
  62        struct list_head ndl_hlink;   /* chain on hash */
  63        struct lstcon_node      *ndl_node;      /* pointer to node */
  64};
  65
  66/* (alias of nodes) group descriptor */
  67struct lstcon_group {
  68        struct list_head grp_link;                /* chain on global group list
  69                                                   */
  70        int              grp_ref;                 /* reference count */
  71        int              grp_userland;            /* has userland nodes */
  72        int              grp_nnode;               /* # of nodes */
  73        char             grp_name[LST_NAME_SIZE]; /* group name */
  74
  75        struct list_head grp_trans_list;          /* transaction list */
  76        struct list_head grp_ndl_list;            /* nodes list */
  77        struct list_head grp_ndl_hash[0];         /* hash table for nodes */
  78};
  79
  80#define LST_BATCH_IDLE    0xB0      /* idle batch */
  81#define LST_BATCH_RUNNING 0xB1      /* running batch */
  82
  83struct lstcon_tsb_hdr {
  84        lst_bid_t        tsb_id;         /* batch ID */
  85        int              tsb_index;      /* test index */
  86};
  87
  88/* (tests ) batch descriptor */
  89struct lstcon_batch {
  90        struct lstcon_tsb_hdr   bat_hdr;        /* test_batch header */
  91        struct list_head bat_link;        /* chain on session's batches list */
  92        int              bat_ntest;       /* # of test */
  93        int              bat_state;       /* state of the batch */
  94        int              bat_arg;         /* parameter for run|stop, timeout
  95                                           * for run, force for stop */
  96        char             bat_name[LST_NAME_SIZE];/* name of batch */
  97
  98        struct list_head bat_test_list;   /* list head of tests (struct lstcon_test)
  99                                           */
 100        struct list_head bat_trans_list;  /* list head of transaction */
 101        struct list_head bat_cli_list;    /* list head of client nodes
 102                                           * (struct lstcon_node) */
 103        struct list_head *bat_cli_hash;   /* hash table of client nodes */
 104        struct list_head bat_srv_list;    /* list head of server nodes */
 105        struct list_head *bat_srv_hash;   /* hash table of server nodes */
 106};
 107
 108/* a single test descriptor */
 109struct lstcon_test {
 110        struct lstcon_tsb_hdr   tes_hdr;        /* test batch header */
 111        struct list_head tes_link;       /* chain on batch's tests list */
 112        struct lstcon_batch     *tes_batch;      /* pointer to batch */
 113
 114        int              tes_type;       /* type of the test, i.e: bulk, ping */
 115        int              tes_stop_onerr; /* stop on error */
 116        int              tes_oneside;    /* one-sided test */
 117        int              tes_concur;     /* concurrency */
 118        int              tes_loop;       /* loop count */
 119        int              tes_dist;       /* nodes distribution of target group */
 120        int              tes_span;       /* nodes span of target group */
 121        int              tes_cliidx;     /* client index, used for RPC creating */
 122
 123        struct list_head tes_trans_list; /* transaction list */
 124        struct lstcon_group     *tes_src_grp;   /* group run the test */
 125        struct lstcon_group     *tes_dst_grp;   /* target group */
 126
 127        int              tes_paramlen;   /* test parameter length */
 128        char             tes_param[0];   /* test parameter */
 129};
 130
 131#define LST_GLOBAL_HASHSIZE 503      /* global nodes hash table size */
 132#define LST_NODE_HASHSIZE   239      /* node hash table (for batch or group) */
 133
 134#define LST_SESSION_NONE    0x0      /* no session */
 135#define LST_SESSION_ACTIVE  0x1      /* working session */
 136
 137#define LST_CONSOLE_TIMEOUT 300      /* default console timeout */
 138
 139struct lstcon_session {
 140        struct mutex        ses_mutex;        /* only 1 thread in session */
 141        lst_sid_t           ses_id;           /* global session id */
 142        int                 ses_key;          /* local session key */
 143        int                 ses_state;        /* state of session */
 144        int                 ses_timeout;      /* timeout in seconds */
 145        time64_t            ses_laststamp;    /* last operation stamp (seconds)
 146                                               */
 147        unsigned            ses_features;     /* tests features of the session
 148                                               */
 149        unsigned            ses_feats_updated:1; /* features are synced with
 150                                                  * remote test nodes */
 151        unsigned            ses_force:1;      /* force creating */
 152        unsigned            ses_shutdown:1;   /* session is shutting down */
 153        unsigned            ses_expired:1;    /* console is timedout */
 154        __u64               ses_id_cookie;    /* batch id cookie */
 155        char                ses_name[LST_NAME_SIZE];/* session name */
 156        struct lstcon_rpc_trans *ses_ping;              /* session pinger */
 157        struct stt_timer         ses_ping_timer;   /* timer for pinger */
 158        lstcon_trans_stat_t ses_trans_stat;   /* transaction stats */
 159
 160        struct list_head    ses_trans_list;   /* global list of transaction */
 161        struct list_head    ses_grp_list;     /* global list of groups */
 162        struct list_head    ses_bat_list;     /* global list of batches */
 163        struct list_head    ses_ndl_list;     /* global list of nodes */
 164        struct list_head    *ses_ndl_hash;    /* hash table of nodes */
 165
 166        spinlock_t          ses_rpc_lock;     /* serialize */
 167        atomic_t            ses_rpc_counter;  /* # of initialized RPCs */
 168        struct list_head    ses_rpc_freelist; /* idle console rpc */
 169}; /* session descriptor */
 170
 171extern struct lstcon_session     console_session;
 172
 173static inline lstcon_trans_stat_t *
 174lstcon_trans_stat(void)
 175{
 176        return &console_session.ses_trans_stat;
 177}
 178
 179static inline struct list_head *
 180lstcon_id2hash(lnet_process_id_t id, struct list_head *hash)
 181{
 182        unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
 183
 184        return &hash[idx];
 185}
 186
 187int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
 188int lstcon_console_init(void);
 189int lstcon_console_fini(void);
 190int lstcon_session_match(lst_sid_t sid);
 191int lstcon_session_new(char *name, int key, unsigned version,
 192                       int timeout, int flags, lst_sid_t __user *sid_up);
 193int lstcon_session_info(lst_sid_t __user *sid_up, int __user *key,
 194                        unsigned __user *verp, lstcon_ndlist_ent_t __user *entp,
 195                        char __user *name_up, int len);
 196int lstcon_session_end(void);
 197int lstcon_session_debug(int timeout, struct list_head __user *result_up);
 198int lstcon_session_feats_check(unsigned feats);
 199int lstcon_batch_debug(int timeout, char *name,
 200                       int client, struct list_head __user *result_up);
 201int lstcon_group_debug(int timeout, char *name,
 202                       struct list_head __user *result_up);
 203int lstcon_nodes_debug(int timeout, int nnd, lnet_process_id_t __user *nds_up,
 204                       struct list_head __user *result_up);
 205int lstcon_group_add(char *name);
 206int lstcon_group_del(char *name);
 207int lstcon_group_clean(char *name, int args);
 208int lstcon_group_refresh(char *name, struct list_head __user *result_up);
 209int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t __user *nds_up,
 210                     unsigned *featp, struct list_head __user *result_up);
 211int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t __user *nds_up,
 212                        struct list_head __user *result_up);
 213int lstcon_group_info(char *name, lstcon_ndlist_ent_t __user *gent_up,
 214                      int *index_p, int *ndent_p,
 215                      lstcon_node_ent_t __user *ndents_up);
 216int lstcon_group_list(int idx, int len, char __user *name_up);
 217int lstcon_batch_add(char *name);
 218int lstcon_batch_run(char *name, int timeout,
 219                     struct list_head __user *result_up);
 220int lstcon_batch_stop(char *name, int force,
 221                      struct list_head __user *result_up);
 222int lstcon_test_batch_query(char *name, int testidx,
 223                            int client, int timeout,
 224                            struct list_head __user *result_up);
 225int lstcon_batch_del(char *name);
 226int lstcon_batch_list(int idx, int namelen, char __user *name_up);
 227int lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up,
 228                      int server, int testidx, int *index_p,
 229                      int *ndent_p, lstcon_node_ent_t __user *dents_up);
 230int lstcon_group_stat(char *grp_name, int timeout,
 231                      struct list_head __user *result_up);
 232int lstcon_nodes_stat(int count, lnet_process_id_t __user *ids_up,
 233                      int timeout, struct list_head __user *result_up);
 234int lstcon_test_add(char *batch_name, int type, int loop,
 235                    int concur, int dist, int span,
 236                    char *src_name, char *dst_name,
 237                    void *param, int paramlen, int *retp,
 238                    struct list_head __user *result_up);
 239#endif
 240