summaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack/lwip_src/common/spl_rti.c
blob: d15d25f8176ea4ad6c40e3d692efe42b14d4cbed (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
80
81
82
83
84
85
86
87
88
89
90
91
/*
*
* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <stdlib.h>
#include "types.h"
#include "nstack_securec.h"
#include "nsfw_init_api.h"
#include "nstack_log.h"
#include "nsfw_maintain_api.h"
#include "nsfw_mem_api.h"
#include "nsfw_rti.h"
#include "nsfw_msg.h"
#ifdef HAL_LIB
#else
#include "common_pal_bitwide_adjust.h"
#endif

#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C"{
/* *INDENT-ON* */
#endif /* __cplusplus */

char g_dfx_switch = 1;

struct rti_queue *g_nsfw_rti_primary_stat = NULL;

void nsfw_rti_stat(nsfw_rti_stat_type_t statType, const data_com_msg * m)
{
    if (!g_nsfw_rti_primary_stat || !m)
    {
        return;
    }

    struct rti_queue *primary_stat = ADDR_SHTOL(g_nsfw_rti_primary_stat);

    switch (statType)
    {
        case NSFW_STAT_PRIMARY_DEQ:
            if ((m->param.major_type >= MAX_MAJOR_TYPE)
                || (m->param.minor_type >= MAX_MINOR_TYPE))
            {
                return;
            }
            /*call_msg_fun() is only called in nStackMain, no reentrance risk, ++ operation is ok */
            primary_stat->tcpip_msg_deq[m->param.major_type]++;
            if (0 == m->param.major_type)       //SPL_TCPIP_NEW_MSG_API
            {
                primary_stat->api_msg_deq[m->param.minor_type]++;
            }
            break;
        case NSFW_STAT_PRIMARY_ENQ_FAIL:
            if ((m->param.major_type >= MAX_MAJOR_TYPE)
                || (m->param.minor_type >= MAX_MINOR_TYPE))
            {
                return;
            }
            __sync_fetch_and_add(&primary_stat->tcpip_msg_enq_fail
                                 [m->param.major_type], 1);
            if (0 == m->param.major_type)       //SPL_TCPIP_NEW_MSG_API
            {
                __sync_fetch_and_add(&primary_stat->api_msg_enq_fail
                                     [m->param.minor_type], 1);
            }
            break;
        case NSFW_STAT_PRIMARY_ENQ:
            //not use
            break;
        default:
            break;
    }
}

#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif /* __cplusplus */