Blame psm_stats.h

Packit 961e70
/*
Packit 961e70
Packit 961e70
  This file is provided under a dual BSD/GPLv2 license.  When using or
Packit 961e70
  redistributing this file, you may do so under either license.
Packit 961e70
Packit 961e70
  GPL LICENSE SUMMARY
Packit 961e70
Packit 961e70
  Copyright(c) 2015 Intel Corporation.
Packit 961e70
Packit 961e70
  This program is free software; you can redistribute it and/or modify
Packit 961e70
  it under the terms of version 2 of the GNU General Public License as
Packit 961e70
  published by the Free Software Foundation.
Packit 961e70
Packit 961e70
  This program is distributed in the hope that it will be useful, but
Packit 961e70
  WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 961e70
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 961e70
  General Public License for more details.
Packit 961e70
Packit 961e70
  Contact Information:
Packit 961e70
  Intel Corporation, www.intel.com
Packit 961e70
Packit 961e70
  BSD LICENSE
Packit 961e70
Packit 961e70
  Copyright(c) 2015 Intel Corporation.
Packit 961e70
Packit 961e70
  Redistribution and use in source and binary forms, with or without
Packit 961e70
  modification, are permitted provided that the following conditions
Packit 961e70
  are met:
Packit 961e70
Packit 961e70
    * Redistributions of source code must retain the above copyright
Packit 961e70
      notice, this list of conditions and the following disclaimer.
Packit 961e70
    * Redistributions in binary form must reproduce the above copyright
Packit 961e70
      notice, this list of conditions and the following disclaimer in
Packit 961e70
      the documentation and/or other materials provided with the
Packit 961e70
      distribution.
Packit 961e70
    * Neither the name of Intel Corporation nor the names of its
Packit 961e70
      contributors may be used to endorse or promote products derived
Packit 961e70
      from this software without specific prior written permission.
Packit 961e70
Packit 961e70
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 961e70
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 961e70
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 961e70
  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 961e70
  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 961e70
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 961e70
  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 961e70
  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 961e70
  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 961e70
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 961e70
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 961e70
Packit 961e70
*/
Packit 961e70
Packit 961e70
/* Copyright (c) 2003-2014 Intel Corporation. All rights reserved. */
Packit 961e70
Packit 961e70
#ifndef _PSMI_IN_USER_H
Packit 961e70
#error psm_stats.h not meant to be included directly, include psm_user.h instead
Packit 961e70
#endif
Packit 961e70
Packit 961e70
#ifndef _PSM_STATS_H
Packit 961e70
#define _PSM_STATS_H
Packit 961e70
Packit 961e70
#include "mpspawn_stats.h"
Packit 961e70
Packit 961e70
#define PSMI_STATSTYPE_MQ	    0x00001
Packit 961e70
#define PSMI_STATSTYPE_RCVTHREAD    0x00100	/* num_wakups, ratio, etc. */
Packit 961e70
#define PSMI_STATSTYPE_IPSPROTO	    0x00200	/* acks,naks,err_chks */
Packit 961e70
#define PSMI_STATSTYPE_TIDS	    0x00400
Packit 961e70
#define PSMI_STATSTYPE_MEMORY	    0x01000
Packit 961e70
#define PSMI_STATSTYPE_HFI	    (PSMI_STATSTYPE_RCVTHREAD|	\
Packit 961e70
				     PSMI_STATSTYPE_IPSPROTO |  \
Packit 961e70
				     PSMI_STATSTYPE_MEMORY |  \
Packit 961e70
				     PSMI_STATSTYPE_TIDS)
Packit 961e70
#define PSMI_STATSTYPE_P2P	    0x00800	/* ep-to-ep details */
Packit 961e70
#define PSMI_STATSTYPE_DEVCOUNTERS  0x10000
Packit 961e70
#define PSMI_STATSTYPE_DEVSTATS	    0x20000
Packit 961e70
#define PSMI_STATSTYPE_ALL	    0xfffff
Packit 961e70
#define _PSMI_STATSTYPE_DEVMASK	    0xf0000
Packit 961e70
Packit 961e70
/* Used to determine how many stats in static array decl. */
Packit 961e70
#define PSMI_STATS_HOWMANY(entries)	    \
Packit 961e70
	    (sizeof(entries)/sizeof(entries[0]))
Packit 961e70
Packit 961e70
#define PSMI_STATS_NO_HEADING    NULL
Packit 961e70
Packit 961e70
#define PSMI_STATS_DECL(_desc, _flags, _getfn, _val)   \
Packit 961e70
	{  .desc  = _desc,			    \
Packit 961e70
	   .flags = _flags,			    \
Packit 961e70
	   .getfn = _getfn,			    \
Packit 961e70
	   .u.val = _val,			    \
Packit 961e70
	}
Packit 961e70
Packit 961e70
#define PSMI_STATS_DECLU64(_desc, _val)					  \
Packit 961e70
	    PSMI_STATS_DECL(_desc,					  \
Packit 961e70
		MPSPAWN_STATS_REDUCTION_ALL | MPSPAWN_STATS_SKIP_IF_ZERO, \
Packit 961e70
		NULL,							  \
Packit 961e70
		_val)
Packit 961e70
Packit 961e70
struct psmi_stats_entry {
Packit 961e70
	const char *desc;
Packit 961e70
	uint16_t flags;
Packit 961e70
	uint64_t(*getfn) (void *context); /* optional fn ptr to get value */
Packit 961e70
	union {
Packit 961e70
		uint64_t *val;	/* where value is stored if getfn is NULL */
Packit 961e70
		uint64_t off;	/* of offset if that makes more sense */
Packit 961e70
	} u;
Packit 961e70
};
Packit 961e70
Packit 961e70
/*
Packit 961e70
 * Copy the array of entries and keep track of the context
Packit 961e70
 */
Packit 961e70
psm2_error_t
Packit 961e70
psmi_stats_register_type(const char *heading,
Packit 961e70
			 uint32_t statstype,
Packit 961e70
			 const struct psmi_stats_entry *entries,
Packit 961e70
			 int num_entries, void *context);
Packit 961e70
Packit 961e70
psm2_error_t psmi_stats_deregister_all(void);
Packit 961e70
Packit 961e70
#endif /* PSM_STATS_H */