Imported Upstream version 16.07-rc1
[deb_dpdk.git] / debian / patches / ubuntu-backport-43-fix-level-type-retrieving.patch
1 Index: dpdk/lib/librte_eal/common/eal_common_log.c
2 ===================================================================
3 --- dpdk.orig/lib/librte_eal/common/eal_common_log.c
4 +++ dpdk/lib/librte_eal/common/eal_common_log.c
5 @@ -57,9 +57,10 @@ static FILE *default_log_stream;
6  struct log_cur_msg {
7         uint32_t loglevel; /**< log level - see rte_log.h */
8         uint32_t logtype;  /**< log type  - see rte_log.h */
9 -} __rte_cache_aligned;
10 -static struct log_cur_msg log_cur_msg[RTE_MAX_LCORE]; /**< per core log */
11 +};
12  
13 + /* per core log */
14 +static RTE_DEFINE_PER_LCORE(struct log_cur_msg, log_cur_msg);
15  
16  /* default logs */
17  
18 @@ -121,21 +122,13 @@ rte_get_log_type(void)
19  /* get the current loglevel for the message beeing processed */
20  int rte_log_cur_msg_loglevel(void)
21  {
22 -       unsigned lcore_id;
23 -       lcore_id = rte_lcore_id();
24 -       if (lcore_id >= RTE_MAX_LCORE)
25 -               return rte_get_log_level();
26 -       return log_cur_msg[lcore_id].loglevel;
27 +       return RTE_PER_LCORE(log_cur_msg).loglevel;
28  }
29  
30  /* get the current logtype for the message beeing processed */
31  int rte_log_cur_msg_logtype(void)
32  {
33 -       unsigned lcore_id;
34 -       lcore_id = rte_lcore_id();
35 -       if (lcore_id >= RTE_MAX_LCORE)
36 -               return rte_get_log_type();
37 -       return log_cur_msg[lcore_id].logtype;
38 +       return RTE_PER_LCORE(log_cur_msg).logtype;
39  }
40  
41  /* Dump log history to file */
42 @@ -153,17 +146,13 @@ rte_vlog(uint32_t level, uint32_t logtyp
43  {
44         int ret;
45         FILE *f = rte_logs.file;
46 -       unsigned lcore_id;
47  
48         if ((level > rte_logs.level) || !(logtype & rte_logs.type))
49                 return 0;
50  
51         /* save loglevel and logtype in a global per-lcore variable */
52 -       lcore_id = rte_lcore_id();
53 -       if (lcore_id < RTE_MAX_LCORE) {
54 -               log_cur_msg[lcore_id].loglevel = level;
55 -               log_cur_msg[lcore_id].logtype = logtype;
56 -       }
57 +       RTE_PER_LCORE(log_cur_msg).loglevel = level;
58 +       RTE_PER_LCORE(log_cur_msg).logtype = logtype;
59  
60         ret = vfprintf(f, format, ap);
61         fflush(f);