/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* onc720 src/oncplus/kernext/include/nfs4/nfs4_stats.h 1.10              */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* Restricted Materials of IBM                                            */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2003,2008              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)77	1.10  src/oncplus/kernext/include/nfs4/nfs4_stats.h, nfs4, onc720 3/27/08 09:08:42  */
/*
 *   COMPONENT_NAME: nfs4
 *
 *   FUNCTIONS: none
 *
 *   ORIGINS: 27
 *
 *                    -- (                            when
 *   combined with the aggregated modules for this product)
 *   OBJECT CODE ONLY SOURCE MATERIALS
 *
 *   (C) COPYRIGHT International Business Machines Corp. 2003
 *   All Rights Reserved
 *   US Government Users Restricted Rights - Use, duplication or
 *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 */


#ifndef _NFS4_STATS_H
#define	_NFS4_STATS_H

#include <sys/corralid.h>

/*
 * Server Statistics
 * Stats for number of compound RPC calls received
 */
struct ns4_compound_stats {
	int ns4_null_calls;
	int ns4_compound_calls;
	int ns4_bad_calls;
	int ns4_bad_ops;
};



/*
 * Server Statistics
 * Stats for number of NFS V4 operations received
 */
struct ns4_compound_stats_0 {
	int ns4_op_access;
	int ns4_op_close;
	int ns4_op_commit;
	int ns4_op_create;
	int ns4_op_delegpurge;
	int ns4_op_delegreturn;
	int ns4_op_getattr;
	int ns4_op_getfh;
	int ns4_op_link;
	int ns4_op_lock;
	int ns4_op_lockt;
	int ns4_op_locku;
	int ns4_op_lookup;
	int ns4_op_lookupp;
	int ns4_op_nverify;
	int ns4_op_open;
	int ns4_op_openattr;
	int ns4_op_open_confirm;
	int ns4_op_open_downgrade;
	int ns4_op_putfh;
	int ns4_op_putpubfh;
	int ns4_op_putrootfh;
	int ns4_op_read;
	int ns4_op_readdir;
	int ns4_op_readlink;
	int ns4_op_remove;
	int ns4_op_rename;
	int ns4_op_renew;
	int ns4_op_restorefh;
	int ns4_op_savefh;
	int ns4_op_secinfo;
	int ns4_op_setattr;
	int ns4_op_setclientid;
	int ns4_op_setclientid_confirm;
	int ns4_op_verify;
	int ns4_op_write;
	int ns4_op_release_lockowner;
	int reserved;
};



/*
 * Server Statictics
 * Stats for memory allocations
 */
struct ns4_allocation_stats {
	int ns4_mem_allocations;
	int ns4_rddir_buf_hits;
	int ns4_rddir_buf_miss;
	int ns4_rddir_buf_toobig;
	int ns4_reply_toobig;
	int reserverd;
};



/*
 * Server Statictics
 * Stats for attribute processing
 */
struct ns4_attr_stats {
	int ns4_odd_getattrs;
	int ns4_odd_nverifies;
	int ns4_odd_rddir_attrs;
	int reserved;
};



/*
 * Server Statistics
 * Stats for exported filesystem state management
*/
struct ns4_state_stats {
	int ns4_sm_resource;
	int ns4_sm_serverfault;
	int ns4_sm_inval;
	int ns4_reg_vfs_calls;
	int ns4_unreg_vfs_calls;
	int ns4_xvfs_cookies;
	int ns4_xvfs_cookie_revoked;
	int ns4_xvfs_cookie_bad;
	int ns4_xvfs_bad;
	int ns4_lease_time;
	int ns4_no_grace;
	int ns4_reclaim_conflict;
};



/*
 * Server Statistics
 * Stats for client state management
 */
struct ns4_client_stats {
	int ns4_clid_active;
	int ns4_clid_inuse;
	int ns4_clid_bad;
	int ns4_clid_stale;
	int ns4_clid_revoked_expire;
	int ns4_clid_revoked_admin;
	int ns4_clid_revoked_resource;
	int ns4_clid_dead_reclaim;
	int ns4_cb_update_req;
	int ns4_cb_update_conf;
	int ns4_cb_upd_destroy;
	int reserved;
};








/*
 * Server Statistics
 * Stats for client open owner state management
 */
struct ns4_open_stats {
	int ns4_oo_active;
	int ns4_oo_bad_seqid;
	int ns4_oo_dup_seqid;	
	int ns4_oo_cleanups;
	int ns4_oo_revoked;
	int ns4_open_files;
	int ns4_share_denies;
	int reserved;
};



/*
 * Server Statistics
 * Stats for client lock owner state management
 */
struct ns4_lock_stats {
	int ns4_lo_cleanups;
	int ns4_lo_active;
	int ns4_locks_active;
	int ns4_close_ops_with_locks;
	int ns4_lo_conflict;
	int ns4_lock_range_con;
	int ns4_lock_denied;
	int ns4_deadlocks;
	int ns4_lo_revoked;
	int ns4_lo_dup_seqid;
	int ns4_lo_bad_seqid;
	int reserved;
};



/*
 * Server Statistics
 * Stats for stateid management
 */
struct ns4_stateid_stats {
	int ns4_stid_revoked;
	int ns4_stid_bad_seqid;
	int ns4_stid_bad;
	int ns4_stid_stale;
	int ns4_stid_old;
	int reserved;
};



/*
 * Server Statistics
 * Delegation counts
 */
struct ns4_deleg_stats {
	int ns4_deleg_granted;
	int ns4_deleg_outstanding;
	int ns4_deleg_callbacks;
	int ns4_deleg_bad_callback;
	int ns4_deleg_returned;
	int ns4_deleg_long_callbacks;
	int ns4_deleg_admin_revoked;
	int ns4_deleg_resource_recalls;
};
/* Helpers for the state manager */
#define RFS4_INC_DELEG_ADMIN_REVOKE() \
	fetch_and_add(&GV(rfs4_deleg_stats)->ns4_deleg_admin_revoked, 1)
#define RFS4_INC_DELEG_RESOURCE_RECALL() \
	fetch_and_add(&GV(rfs4_deleg_stats)->ns4_deleg_resource_recalls, 1)




/*
 * Server Statistics
 * Structure returned for NFS4_GET_SRV_STATS nfscntl system call
 */
struct nfs_srv_stats4 {
	int ns4_minor_version;
	int ns4_serverfault;
	int ns4_resource;
	int reserved;
	struct ns4_compound_stats ns4_compound;
	union {
		struct ns4_compound_stats_0 _mv0;
	} ns4_ops_u;
	struct ns4_allocation_stats ns4_allocations;
	struct ns4_attr_stats ns4_attrs;
	struct ns4_state_stats ns4_state;
	struct ns4_client_stats ns4_client;
	struct ns4_open_stats ns4_open;
	struct ns4_lock_stats ns4_lock;
	struct ns4_stateid_stats ns4_stateid;
	struct ns4_deleg_stats ns4_deleg;
};



/*
 * Server Statistics
 * File operations statistics
 */
#define NFS4_FO_STAT_ACCESS          0
#define NFS4_FO_STAT_CLOSE           1
#define NFS4_FO_STAT_COMMIT          2
#define NFS4_FO_STAT_CREATE          3
#define NFS4_FO_STAT_GETATTR         4
#define NFS4_FO_STAT_LINK            5
#define NFS4_FO_STAT_LOCK            6
#define NFS4_FO_STAT_LOCKT           7
#define NFS4_FO_STAT_LOCKU           8
#define NFS4_FO_STAT_LOOKUP          9
#define NFS4_FO_STAT_LOOKUPP        10
#define NFS4_FO_STAT_NVERIFY        11
#define NFS4_FO_STAT_OPEN           12
#define NFS4_FO_STAT_OPENATTR       13
#define NFS4_FO_STAT_OPEN_DOWNGRADE 14
#define NFS4_FO_STAT_READ           15
#define NFS4_FO_STAT_READDIR        16
#define NFS4_FO_STAT_READLINK       17
#define NFS4_FO_STAT_REMOVE         18
#define NFS4_FO_STAT_RENAME         19
#define NFS4_FO_STAT_SECINFO        20
#define NFS4_FO_STAT_SETATTR        21
#define NFS4_FO_STAT_VERIFY         22
#define NFS4_FO_STAT_WRITE          23
#define NFS4_FO_STAT_DELEGRET	    24
#define N_NFS4_FO_STATS             25


struct ns4_file_op_stats_0 {
	int ns4_ops[N_NFS4_FO_STATS];
};



/*
 * Server Statictics
 * Structure returned for NFS4_CNTL_GET_EXPORT_STATS nfscntl system call
 */
struct nfs_srv_export_stats4 {
	int nse4_id;
	int nse4_minor_version;
	int nse4_flavors;
	int nse4_anon;
	union {
		struct ns4_file_op_stats_0 _mv0;
	} nse4_ops_u;
	char nse4_local_path[256];
	char nse4_exported_path[256];
};

#define NFS4_EXPORT_FLAVOR_NONE   0x1
#define NFS4_EXPORT_FLAVOR_SYS    0x2
#define NFS4_EXPORT_FLAVOR_DES    0x4
#define NFS4_EXPORT_FLAVOR_KRB5   0x8
#define NFS4_EXPORT_FLAVOR_KRB5I 0x10
#define NFS4_EXPORT_FLAVOR_KRB5P 0x20

/*
 * client stuff starts from here
 */
enum nfs4_procedure {
	NFS4_NULL,
	NFS4_GETATTR,
	NFS4_SETATTR,
	NFS4_LOOKUP,
	NFS4_ACCESS,
	NFS4_READLINK,
	NFS4_READ,
	NFS4_WRITE,
	NFS4_CREATE,
	NFS4_MKDIR,
	NFS4_SYMLINK,
	NFS4_MKNOD,
	NFS4_REMOVE,
	NFS4_RMDIR,
	NFS4_RENAME,
	NFS4_LINK,
	NFS4_READDIR,
	NFS4_STATFS,
	NFS4_FINFO,
	NFS4_COMMIT,
	NFS4_OPEN,
	NFS4_OPEN_CONFIRM,
	NFS4_OPEN_DOWNGRADE,
	NFS4_CLOSE,
	NFS4_LOCK,
	NFS4_UNLOCK,
	NFS4_LOCK_TEST,
	NFS4_SET_CLIENTID,
	NFS4_RENEW,
	NFS4_CLIENT_CONFIRM,
	NFS4_SECINFO,
	NFS4_RELEASE_LOCKOWNER,
	NFS4_REPLICATE,
	NFS4_AIXC_PCL_STAT,
	NFS4_AIXC_STAT_LONG,
	NFS4_PCL_STAT_LONG,
	NFS4_AIXC_READ,
	NFS4_PCL_READ,
	NFS4_AIXC_WRITE,
	NFS4_PCL_WRITE,
	NFS4_DELEGRETURN,
	NFS4_BACKCHANNEL_CTL,
	NFS4_BIND_CONN_TO_SESSION,
	NFS4_EXCHANGE_ID,
	NFS4_CREATE_SESSION,
	NFS4_DESTROY_SESSION,
	NFS4_FREE_STATEID,
	NFS4_GET_DIR_DELEGATION,
	NFS4_GETDEVICEINFO,
	NFS4_GETDEVICELIST,
	NFS4_LAYOUTCOMMIT,
	NFS4_LAYOUTGET,
	NFS4_LAYOUTRETURN,
	NFS4_SECINFO_NO_NAME,
	NFS4_SEQUENCE,
	NFS4_SET_SSV,
	NFS4_TEST_STATEID,
	NFS4_WANT_DELEGATION,
	NFS4_PROC_END
};
typedef enum nfs4_procedure nfs4_procedure;
#define NFS4_CLNT_NUM_STATS (NFS4_PROC_END)

typedef uint32_t clnt4_stats[NFS4_CLNT_NUM_STATS];


/*
 * Client Statistics
 * Delegation counts
 */
struct nc4_deleg_stats {
	int nc4_deleg_granted;
	int nc4_deleg_outstanding;
	int nc4_deleg_recalled;
	int nc4_deleg_returned;
	int nc4_deleg_getattr;
};
extern void nfs4_get_deleg_stats(struct nc4_deleg_stats *, cid_t,
				 struct nfs_wpar_vars_struct *);



#endif /* !_NFS4_STATS_H */
