summaryrefslogtreecommitdiff
path: root/common/include/tfe_packet_io_fs.h
blob: 01c395e83ba3562414f443bd76b0d96eb2850033 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef _TFE_PACKET_IO_FS_H
#define _TFE_PACKET_IO_FS_H

#ifdef __cpluscplus
extern "C"
{
#endif

#include "tfe_utils.h"
#include <tfe_fieldstat.h>

struct throughput_metrics
{
    uint64_t n_pkts;
    uint64_t n_bytes;
};

struct packet_io_fs
{
    struct throughput_metrics raw_pkt_rx;           // 累计值
    struct throughput_metrics raw_pkt_tx;           // 累计值

    struct throughput_metrics decrypt_tx;           // 累计值
    struct throughput_metrics decrypt_rx;           // 累计值

    struct throughput_metrics dup_bypass;           // 累计值
    struct throughput_metrics raw_bypass;           // 累计值
    struct throughput_metrics decrypt_rxdrop;       // 累计值

    struct throughput_metrics ctrl_pkt_rx;          // 累计值
    struct throughput_metrics ctrl_pkt_tx;          // 累计值

    struct throughput_metrics keepalived_pkt_rx;    // 累计值
    struct throughput_metrics keepalived_pkt_tx;    // 累计值

    struct throughput_metrics tap_pkt_rx;           // 累计值
    struct throughput_metrics tap_pkt_tx;           // 累计值
    struct throughput_metrics tap_pkt_rxdrop;       // 累计值
    struct throughput_metrics tap_c_pkt_rx;         // 累计值
    struct throughput_metrics tap_c_pkt_tx;         // 累计值
    struct throughput_metrics tap_s_pkt_rx;         // 累计值
    struct throughput_metrics tap_s_pkt_tx;         // 累计值

    uint64_t ctrl_pkt_opening_num;  // 累计值
    uint64_t ctrl_pkt_active_num;   // 累计值
    uint64_t ctrl_pkt_closing_num;  // 累计值
    uint64_t ctrl_pkt_resetall_num; // 累计值
    uint64_t ctrl_pkt_error_num;    // 累计值

    uint64_t hit_intercept_num;     // 累计值
    uint64_t hit_no_intercept_num;  // 累计值
    uint64_t can_intercept_num;     // 累计值

    uint64_t asymmetric_num;        // 累计值
    uint64_t tunnel_num;            // 累计值
    uint64_t tcp_pcy_inval_num;     // 累计值

    uint64_t session_num;   // 瞬时值
    uint64_t session_log;   // 瞬时值

    struct fieldstat_easy *fs_handle;
    int fs_id[128];
};

struct packet_io_fs *packet_io_fs_create(const char *profile);
void packet_io_fs_destory(struct packet_io_fs *handle);
void packet_io_fs_dump(struct packet_io_fs *handle);

void inline throughput_metrics_inc(struct throughput_metrics *iterm, uint64_t n_pkts, uint64_t n_bytes)
{
    iterm->n_bytes += n_bytes;
    iterm->n_pkts += n_pkts;
}

#ifdef __cpluscplus
}
#endif

#endif