42#define NET_REFRESH_LATENCY 1000000
44#define NET_PROC_FILE "/proc/net/dev"
49#define NET_PROC_MAX_LINE (IFNAMSIZ + 16 * (20 + 1) + 16)
51#define NET_INVALID_RESULT -1
57#define HANDLE_STRING_ERROR {fprintf(stderr,"%s:%i unexpected string function error.\n",__FILE__,__LINE__); exit(-1);}
76#define NET_INTERFACE_COUNTERS 16
83 {
"rx:bytes",
"receive bytes"},
84 {
"rx:packets",
"receive packets"},
85 {
"rx:errors",
"receive errors"},
86 {
"rx:dropped",
"receive dropped"},
87 {
"rx:fifo",
"receive fifo"},
88 {
"rx:frame",
"receive frame"},
89 {
"rx:compressed",
"receive compressed"},
90 {
"rx:multicast",
"receive multicast"},
92 {
"tx:bytes",
"transmit bytes"},
93 {
"tx:packets",
"transmit packets"},
94 {
"tx:errors",
"transmit errors"},
95 {
"tx:dropped",
"transmit dropped"},
96 {
"tx:fifo",
"transmit fifo"},
97 {
"tx:colls",
"transmit colls"},
98 {
"tx:carrier",
"transmit carrier"},
99 {
"tx:compressed",
"transmit compressed"},
123 SUBDBG(
"Can't find %s, are you sure the /proc file-system is mounted?\n",
126 "Failed to find /proc file-system.");
132 for (
i=0;
i<2;
i++) {
147 retval = strstr(line,
":");
149 SUBDBG(
"Wrong line format <%s>\n", line);
155 while (isspace(*ifname)) { ifname++; }
165 "%s failed to allocate %lu bytes for temp_event.", __func__,
sizeof(
struct temp_event));
178 PAPIERROR(
"This shouldn't be possible\n");
180 "%s Error navigating linked list.", __func__);
188 snprintf(temp->
name, str_len,
"%s:%s",
225 char *
retval, *ifname, *data;
230 SUBDBG(
"Can't find %s, are you sure the /proc file-system is mounted?\n",
236 for (
i=0;
i<2;
i++) {
248 retval = strstr(line,
":");
250 SUBDBG(
"Wrong line format <%s>\n", line);
257 while (isspace(*ifname)) { ifname++; }
261 SUBDBG(
"Interface <%s> not found\n", ifname);
264 "%lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld\n",
275 "%lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld\n",
287 SUBDBG(
"/proc line with wrong number of fields\n");
415 long long **
events,
int flags )
565 switch ( modifier ) {
577 *EventCode = *EventCode + 1;
618 int index = EventCode;
635 int index = EventCode;
652 int index = EventCode;
674 .description =
"Linux network driver statistics",
684 .fast_real_timer = 0,
685 .fast_virtual_timer = 0,
687 .attach_must_ptrace = 0,
get real time counter value in microseconds
struct papi_vectors * _papi_hwd[]
char events[MAX_EVENTS][BUFSIZ]
static long long values[NUM_EVENTS]
static struct temp_event * last
static int _net_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _net_ntv_code_to_descr(unsigned int EventCode, char *name, int len)
static long long _net_register_current[NET_MAX_COUNTERS]
static int _net_ntv_enum_events(unsigned int *EventCode, int modifier)
#define NET_REFRESH_LATENCY
static struct temp_event * root
static int read_net_counters(long long *values)
#define NET_INTERFACE_COUNTERS
static int _net_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
static int _net_init_control_state(hwd_control_state_t *ctl)
static const struct net_counters _net_counter_info[NET_INTERFACE_COUNTERS]
int _net_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _net_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _net_ntv_name_to_code(const char *name, unsigned int *EventCode)
static int is_initialized
static int _net_ntv_code_to_bits(unsigned int EventCode, hwd_register_t *bits)
static int generateNetEventList(void)
#define NET_INVALID_RESULT
static int _net_set_domain(hwd_control_state_t *ctl, int domain)
static int getInterfaceBaseIndex(const char *ifname)
papi_vector_t _net_vector
static int _net_init_thread(hwd_context_t *ctx)
#define NET_PROC_MAX_LINE
static int _net_shutdown_component(void)
static int _net_shutdown_thread(hwd_context_t *ctx)
static long long _net_register_start[NET_MAX_COUNTERS]
static int _net_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
static int _net_init_component(int cidx)
static int _net_ntv_code_to_name(unsigned int EventCode, char *name, int len)
static int _net_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
#define HANDLE_STRING_ERROR
static NET_native_event_entry_t * _net_native_events
net component This file contains the source code for a component that enables PAPI-C to access networ...
Return codes and api definitions.
#define SUBDBG(format, args...)
int fclose(FILE *__stream)
void PAPIERROR(char *format,...)
long long values[NET_MAX_COUNTERS]
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
PAPI_component_info_t cmp_info
char description[PAPI_MAX_STR_LEN]
char name[PAPI_MAX_STR_LEN]