Imported Upstream version 16.07-rc1
[deb_dpdk.git] / debian / patches / ubuntu-backport-40-linking-fixes-stage-2-4.patch
1 Description: backport of dpdk 16.07 fix for library underlinking - stage 2/4
2
3 This is a merge of related upstream fixes:
4 - a3f34a98 log: deprecate history dump
5 - 3037e5e2 eal: remove useless includes of mempool and ring
6
7 Forwarded: yes (in DPDK 16.07)
8 Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
9 Last-Update: 2016-06-14
10
11 Index: dpdk/app/test-pmd/cmdline.c
12 ===================================================================
13 --- dpdk.orig/app/test-pmd/cmdline.c
14 +++ dpdk/app/test-pmd/cmdline.c
15 @@ -7191,8 +7191,6 @@ static void cmd_dump_parsed(void *parsed
16                 rte_dump_physmem_layout(stdout);
17         else if (!strcmp(res->dump, "dump_memzone"))
18                 rte_memzone_dump(stdout);
19 -       else if (!strcmp(res->dump, "dump_log_history"))
20 -               rte_log_dump_history(stdout);
21         else if (!strcmp(res->dump, "dump_struct_sizes"))
22                 dump_struct_sizes();
23         else if (!strcmp(res->dump, "dump_ring"))
24 @@ -7207,7 +7205,6 @@ cmdline_parse_token_string_t cmd_dump_du
25         TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
26                 "dump_physmem#"
27                 "dump_memzone#"
28 -               "dump_log_history#"
29                 "dump_struct_sizes#"
30                 "dump_ring#"
31                 "dump_mempool#"
32 Index: dpdk/app/test/autotest_data.py
33 ===================================================================
34 --- dpdk.orig/app/test/autotest_data.py
35 +++ dpdk/app/test/autotest_data.py
36 @@ -88,12 +88,6 @@ parallel_test_group_list = [
37                  "Report" :     None,
38                 },
39                 {
40 -                "Name" :       "Dump log history",
41 -                "Command" :    "dump_log_history",
42 -                "Func" :       dump_autotest,
43 -                "Report" :     None,
44 -               },
45 -               {
46                  "Name" :       "Dump rings",
47                  "Command" :    "dump_ring",
48                  "Func" :       dump_autotest,
49 Index: dpdk/app/test/autotest_test_funcs.py
50 ===================================================================
51 --- dpdk.orig/app/test/autotest_test_funcs.py
52 +++ dpdk/app/test/autotest_test_funcs.py
53 @@ -151,12 +151,6 @@ def logs_autotest(child, test_name):
54                 "TESTAPP2: this is a info level message",
55                 "TESTAPP2: this is a warning level message",
56                 "TESTAPP1: this is a debug level message",
57 -               "TESTAPP1: this is a debug level message",
58 -               "TESTAPP1: this is a info level message",
59 -               "TESTAPP1: this is a warning level message",
60 -               "TESTAPP2: this is a info level message",
61 -               "TESTAPP2: this is a warning level message",
62 -               "TESTAPP1: this is a debug level message",
63         ]
64  
65         for log_msg in log_list:
66 Index: dpdk/app/test/commands.c
67 ===================================================================
68 --- dpdk.orig/app/test/commands.c
69 +++ dpdk/app/test/commands.c
70 @@ -150,8 +150,6 @@ static void cmd_dump_parsed(void *parsed
71                 rte_dump_physmem_layout(stdout);
72         else if (!strcmp(res->dump, "dump_memzone"))
73                 rte_memzone_dump(stdout);
74 -       else if (!strcmp(res->dump, "dump_log_history"))
75 -               rte_log_dump_history(stdout);
76         else if (!strcmp(res->dump, "dump_struct_sizes"))
77                 dump_struct_sizes();
78         else if (!strcmp(res->dump, "dump_ring"))
79 @@ -164,7 +162,7 @@ static void cmd_dump_parsed(void *parsed
80  
81  cmdline_parse_token_string_t cmd_dump_dump =
82         TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
83 -                                "dump_physmem#dump_memzone#dump_log_history#"
84 +                                "dump_physmem#dump_memzone#"
85                                  "dump_struct_sizes#dump_ring#dump_mempool#"
86                                  "dump_devargs");
87  
88 Index: dpdk/app/test/test_logs.c
89 ===================================================================
90 --- dpdk.orig/app/test/test_logs.c
91 +++ dpdk/app/test/test_logs.c
92 @@ -85,8 +85,6 @@ test_logs(void)
93         RTE_LOG(DEBUG, TESTAPP1, "this is a debug level message\n");
94         RTE_LOG(DEBUG, TESTAPP2, "debug level message (not displayed)\n");
95  
96 -       rte_log_dump_history(stdout);
97 -
98         return 0;
99  }
100  
101 Index: dpdk/doc/guides/prog_guide/mempool_lib.rst
102 ===================================================================
103 --- dpdk.orig/doc/guides/prog_guide/mempool_lib.rst
104 +++ dpdk/doc/guides/prog_guide/mempool_lib.rst
105 @@ -38,9 +38,7 @@ In the DPDK, it is identified by name an
106  It provides some other optional services such as a per-core object cache and
107  an alignment helper to ensure that objects are padded to spread them equally on all DRAM or DDR3 channels.
108  
109 -This library is used by the
110 -:ref:`Mbuf Library <Mbuf_Library>` and the
111 -:ref:`Environment Abstraction Layer <Environment_Abstraction_Layer>` (for logging history).
112 +This library is used by the :ref:`Mbuf Library <Mbuf_Library>`.
113  
114  Cookies
115  -------
116 Index: dpdk/doc/guides/rel_notes/deprecation.rst
117 ===================================================================
118 --- dpdk.orig/doc/guides/rel_notes/deprecation.rst
119 +++ dpdk/doc/guides/rel_notes/deprecation.rst
120 @@ -8,6 +8,9 @@ API and ABI deprecation notices are to b
121  Deprecation Notices
122  -------------------
123  
124 +* The log history is deprecated.
125 +  It is voided in 16.07 and will be removed in release 16.11.
126 +
127  * The ethdev hotplug API is going to be moved to EAL with a notification
128    mechanism added to crypto and ethdev libraries so that hotplug is now
129    available to both of them. This API will be stripped of the device arguments
130 Index: dpdk/lib/librte_eal/bsdapp/eal/Makefile
131 ===================================================================
132 --- dpdk.orig/lib/librte_eal/bsdapp/eal/Makefile
133 +++ dpdk/lib/librte_eal/bsdapp/eal/Makefile
134 @@ -40,8 +40,6 @@ VPATH += $(RTE_SDK)/lib/librte_eal/commo
135  CFLAGS += -I$(SRCDIR)/include
136  CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common
137  CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common/include
138 -CFLAGS += -I$(RTE_SDK)/lib/librte_ring
139 -CFLAGS += -I$(RTE_SDK)/lib/librte_mempool
140  CFLAGS += $(WERROR_FLAGS) -O3
141  
142  LDLIBS += -lexecinfo
143 Index: dpdk/lib/librte_eal/bsdapp/eal/eal_debug.c
144 ===================================================================
145 --- dpdk.orig/lib/librte_eal/bsdapp/eal/eal_debug.c
146 +++ dpdk/lib/librte_eal/bsdapp/eal/eal_debug.c
147 @@ -77,9 +77,6 @@ void __rte_panic(const char *funcname, c
148  {
149         va_list ap;
150  
151 -       /* disable history */
152 -       rte_log_set_history(0);
153 -
154         rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname);
155         va_start(ap, format);
156         rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap);
157 @@ -98,9 +95,6 @@ rte_exit(int exit_code, const char *form
158  {
159         va_list ap;
160  
161 -       /* disable history */
162 -       rte_log_set_history(0);
163 -
164         if (exit_code != 0)
165                 RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n"
166                                 "  Cause: ", exit_code);
167 Index: dpdk/lib/librte_eal/common/eal_common_log.c
168 ===================================================================
169 --- dpdk.orig/lib/librte_eal/common/eal_common_log.c
170 +++ dpdk/lib/librte_eal/common/eal_common_log.c
171 @@ -31,54 +31,16 @@
172   *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
173   */
174  
175 -#include <string.h>
176  #include <stdio.h>
177  #include <stdint.h>
178  #include <stdarg.h>
179 -#include <sys/types.h>
180  #include <stdlib.h>
181 -#include <unistd.h>
182 -#include <inttypes.h>
183 -#include <errno.h>
184 -#include <sys/queue.h>
185  
186  #include <rte_log.h>
187 -#include <rte_memory.h>
188 -#include <rte_memzone.h>
189 -#include <rte_launch.h>
190 -#include <rte_common.h>
191 -#include <rte_cycles.h>
192 -#include <rte_eal.h>
193  #include <rte_per_lcore.h>
194 -#include <rte_lcore.h>
195 -#include <rte_atomic.h>
196 -#include <rte_debug.h>
197 -#include <rte_spinlock.h>
198 -#include <rte_branch_prediction.h>
199 -#include <rte_ring.h>
200 -#include <rte_mempool.h>
201  
202  #include "eal_private.h"
203  
204 -#define LOG_ELT_SIZE     2048
205 -
206 -#define LOG_HISTORY_MP_NAME "log_history"
207 -
208 -STAILQ_HEAD(log_history_list, log_history);
209 -
210 -/**
211 - * The structure of a message log in the log history.
212 - */
213 -struct log_history {
214 -       STAILQ_ENTRY(log_history) next;
215 -       unsigned size;
216 -       char buf[0];
217 -};
218 -
219 -static struct rte_mempool *log_history_mp = NULL;
220 -static unsigned log_history_size = 0;
221 -static struct log_history_list log_history;
222 -
223  /* global log structure */
224  struct rte_logs rte_logs = {
225         .type = ~0,
226 @@ -86,10 +48,7 @@ struct rte_logs rte_logs = {
227         .file = NULL,
228  };
229  
230 -static rte_spinlock_t log_dump_lock = RTE_SPINLOCK_INITIALIZER;
231 -static rte_spinlock_t log_list_lock = RTE_SPINLOCK_INITIALIZER;
232  static FILE *default_log_stream;
233 -static int history_enabled = 1;
234  
235  /**
236   * This global structure stores some informations about the message
237 @@ -105,59 +64,16 @@ static struct log_cur_msg log_cur_msg[RT
238  /* default logs */
239  
240  int
241 -rte_log_add_in_history(const char *buf, size_t size)
242 +rte_log_add_in_history(const char *buf __rte_unused, size_t size __rte_unused)
243  {
244 -       struct log_history *hist_buf = NULL;
245 -       static const unsigned hist_buf_size = LOG_ELT_SIZE - sizeof(*hist_buf);
246 -       void *obj;
247 -
248 -       if (history_enabled == 0)
249 -               return 0;
250 -
251 -       rte_spinlock_lock(&log_list_lock);
252 -
253 -       /* get a buffer for adding in history */
254 -       if (log_history_size > RTE_LOG_HISTORY) {
255 -               hist_buf = STAILQ_FIRST(&log_history);
256 -               if (hist_buf) {
257 -                       STAILQ_REMOVE_HEAD(&log_history, next);
258 -                       log_history_size--;
259 -               }
260 -       }
261 -       else {
262 -               if (rte_mempool_mc_get(log_history_mp, &obj) < 0)
263 -                       obj = NULL;
264 -               hist_buf = obj;
265 -       }
266 -
267 -       /* no buffer */
268 -       if (hist_buf == NULL) {
269 -               rte_spinlock_unlock(&log_list_lock);
270 -               return -ENOBUFS;
271 -       }
272 -
273 -       /* not enough room for msg, buffer go back in mempool */
274 -       if (size >= hist_buf_size) {
275 -               rte_mempool_mp_put(log_history_mp, hist_buf);
276 -               rte_spinlock_unlock(&log_list_lock);
277 -               return -ENOBUFS;
278 -       }
279 -
280 -       /* add in history */
281 -       memcpy(hist_buf->buf, buf, size);
282 -       hist_buf->buf[size] = hist_buf->buf[hist_buf_size-1] = '\0';
283 -       hist_buf->size = size;
284 -       STAILQ_INSERT_TAIL(&log_history, hist_buf, next);
285 -       log_history_size++;
286 -       rte_spinlock_unlock(&log_list_lock);
287 -
288         return 0;
289  }
290  
291  void
292  rte_log_set_history(int enable)
293  {
294 -       history_enabled = enable;
295 +       if (enable)
296 +               RTE_LOG(WARNING, EAL, "The log history is deprecated.\n");
297  }
298  
299  /* Change the stream that will be used by logging system */
300 @@ -224,44 +140,8 @@ int rte_log_cur_msg_logtype(void)
301  
302  /* Dump log history to file */
303  void
304 -rte_log_dump_history(FILE *out)
305 +rte_log_dump_history(FILE *out __rte_unused)
306  {
307 -       struct log_history_list tmp_log_history;
308 -       struct log_history *hist_buf;
309 -       unsigned i;
310 -
311 -       /* only one dump at a time */
312 -       rte_spinlock_lock(&log_dump_lock);
313 -
314 -       /* save list, and re-init to allow logging during dump */
315 -       rte_spinlock_lock(&log_list_lock);
316 -       tmp_log_history = log_history;
317 -       STAILQ_INIT(&log_history);
318 -       log_history_size = 0;
319 -       rte_spinlock_unlock(&log_list_lock);
320 -
321 -       for (i=0; i<RTE_LOG_HISTORY; i++) {
322 -
323 -               /* remove one message from history list */
324 -               hist_buf = STAILQ_FIRST(&tmp_log_history);
325 -
326 -               if (hist_buf == NULL)
327 -                       break;
328 -
329 -               STAILQ_REMOVE_HEAD(&tmp_log_history, next);
330 -
331 -               /* write on stdout */
332 -               if (fwrite(hist_buf->buf, hist_buf->size, 1, out) == 0) {
333 -                       rte_mempool_mp_put(log_history_mp, hist_buf);
334 -                       break;
335 -               }
336 -
337 -               /* put back message structure in pool */
338 -               rte_mempool_mp_put(log_history_mp, hist_buf);
339 -       }
340 -       fflush(out);
341 -
342 -       rte_spinlock_unlock(&log_dump_lock);
343  }
344  
345  /*
346 @@ -308,29 +188,11 @@ rte_log(uint32_t level, uint32_t logtype
347  }
348  
349  /*
350 - * called by environment-specific log init function to initialize log
351 - * history
352 + * called by environment-specific log init function
353   */
354  int
355  rte_eal_common_log_init(FILE *default_log)
356  {
357 -       STAILQ_INIT(&log_history);
358 -
359 -       /* reserve RTE_LOG_HISTORY*2 elements, so we can dump and
360 -        * keep logging during this time */
361 -       log_history_mp = rte_mempool_create(LOG_HISTORY_MP_NAME, RTE_LOG_HISTORY*2,
362 -                               LOG_ELT_SIZE, 0, 0,
363 -                               NULL, NULL,
364 -                               NULL, NULL,
365 -                               SOCKET_ID_ANY, 0);
366 -
367 -       if ((log_history_mp == NULL) &&
368 -           ((log_history_mp = rte_mempool_lookup(LOG_HISTORY_MP_NAME)) == NULL)){
369 -               RTE_LOG(ERR, EAL, "%s(): cannot create log_history mempool\n",
370 -                       __func__);
371 -               return -1;
372 -       }
373 -
374         default_log_stream = default_log;
375         rte_openlog_stream(default_log);
376         return 0;
377 Index: dpdk/lib/librte_eal/common/eal_private.h
378 ===================================================================
379 --- dpdk.orig/lib/librte_eal/common/eal_private.h
380 +++ dpdk/lib/librte_eal/common/eal_private.h
381 @@ -49,9 +49,6 @@ int rte_eal_memzone_init(void);
382  /**
383   * Common log initialization function (private to eal).
384   *
385 - * Called by environment-specific log initialization function to initialize
386 - * log history.
387 - *
388   * @param default_log
389   *   The default log stream to be used.
390   * @return
391 Index: dpdk/lib/librte_eal/common/include/rte_log.h
392 ===================================================================
393 --- dpdk.orig/lib/librte_eal/common/include/rte_log.h
394 +++ dpdk/lib/librte_eal/common/include/rte_log.h
395 @@ -42,6 +42,8 @@
396   * This file provides a log API to RTE applications.
397   */
398  
399 +#include "rte_common.h" /* for __rte_deprecated macro */
400 +
401  #ifdef __cplusplus
402  extern "C" {
403  #endif
404 @@ -179,22 +181,27 @@ int rte_log_cur_msg_loglevel(void);
405  int rte_log_cur_msg_logtype(void);
406  
407  /**
408 + * @deprecated
409   * Enable or disable the history (enabled by default)
410   *
411   * @param enable
412   *   true to enable, or 0 to disable history.
413   */
414 +__rte_deprecated
415  void rte_log_set_history(int enable);
416  
417  /**
418 + * @deprecated
419   * Dump the log history to a file
420   *
421   * @param f
422   *   A pointer to a file for output
423   */
424 +__rte_deprecated
425  void rte_log_dump_history(FILE *f);
426  
427  /**
428 + * @deprecated
429   * Add a log message to the history.
430   *
431   * This function can be called from a user-defined log stream. It adds
432 @@ -209,6 +216,7 @@ void rte_log_dump_history(FILE *f);
433   *   - 0: Success.
434   *   - (-ENOBUFS) if there is no room to store the message.
435   */
436 +__rte_deprecated
437  int rte_log_add_in_history(const char *buf, size_t size);
438  
439  /**
440 Index: dpdk/lib/librte_eal/linuxapp/eal/eal_debug.c
441 ===================================================================
442 --- dpdk.orig/lib/librte_eal/linuxapp/eal/eal_debug.c
443 +++ dpdk/lib/librte_eal/linuxapp/eal/eal_debug.c
444 @@ -77,9 +77,6 @@ void __rte_panic(const char *funcname, c
445  {
446         va_list ap;
447  
448 -       /* disable history */
449 -       rte_log_set_history(0);
450 -
451         rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname);
452         va_start(ap, format);
453         rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap);
454 @@ -98,9 +95,6 @@ rte_exit(int exit_code, const char *form
455  {
456         va_list ap;
457  
458 -       /* disable history */
459 -       rte_log_set_history(0);
460 -
461         if (exit_code != 0)
462                 RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n"
463                                 "  Cause: ", exit_code);
464 Index: dpdk/lib/librte_eal/linuxapp/eal/eal_log.c
465 ===================================================================
466 --- dpdk.orig/lib/librte_eal/linuxapp/eal/eal_log.c
467 +++ dpdk/lib/librte_eal/linuxapp/eal/eal_log.c
468 @@ -50,8 +50,7 @@
469  #include "eal_private.h"
470  
471  /*
472 - * default log function, used once mempool (hence log history) is
473 - * available
474 + * default log function
475   */
476  static ssize_t
477  console_log_write(__attribute__((unused)) void *c, const char *buf, size_t size)
478 @@ -60,9 +59,6 @@ console_log_write(__attribute__((unused)
479         ssize_t ret;
480         uint32_t loglevel;
481  
482 -       /* add this log in history */
483 -       rte_log_add_in_history(buf, size);
484 -
485         /* write on stdout */
486         ret = fwrite(buf, 1, size, stdout);
487         fflush(stdout);
488 @@ -110,8 +106,7 @@ rte_eal_log_init(const char *id, int fac
489  /* early logs */
490  
491  /*
492 - * early log function, used during boot when mempool (hence log
493 - * history) is not available
494 + * early log function, used before rte_eal_log_init
495   */
496  static ssize_t
497  early_log_write(__attribute__((unused)) void *c, const char *buf, size_t size)
498 Index: dpdk/lib/librte_eal/linuxapp/eal/Makefile
499 ===================================================================
500 --- dpdk.orig/lib/librte_eal/linuxapp/eal/Makefile
501 +++ dpdk/lib/librte_eal/linuxapp/eal/Makefile
502 @@ -44,9 +44,12 @@ VPATH += $(RTE_SDK)/lib/librte_eal/commo
503  CFLAGS += -I$(SRCDIR)/include
504  CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common
505  CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common/include
506 +ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
507 +# workaround for circular dependency eal -> ivshmem -> ring/mempool -> eal
508  CFLAGS += -I$(RTE_SDK)/lib/librte_ring
509  CFLAGS += -I$(RTE_SDK)/lib/librte_mempool
510  CFLAGS += -I$(RTE_SDK)/lib/librte_ivshmem
511 +endif
512  CFLAGS += $(WERROR_FLAGS) -O3
513  
514  LDLIBS += -ldl
515 Index: dpdk/lib/librte_eal/linuxapp/eal/eal_interrupts.c
516 ===================================================================
517 --- dpdk.orig/lib/librte_eal/linuxapp/eal/eal_interrupts.c
518 +++ dpdk/lib/librte_eal/linuxapp/eal/eal_interrupts.c
519 @@ -57,10 +57,8 @@
520  #include <rte_lcore.h>
521  #include <rte_atomic.h>
522  #include <rte_branch_prediction.h>
523 -#include <rte_ring.h>
524  #include <rte_debug.h>
525  #include <rte_log.h>
526 -#include <rte_mempool.h>
527  #include <rte_pci.h>
528  #include <rte_malloc.h>
529  #include <rte_errno.h>
530 Index: dpdk/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
531 ===================================================================
532 --- dpdk.orig/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
533 +++ dpdk/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
534 @@ -49,7 +49,6 @@
535  #include <rte_string_fns.h>
536  #include <rte_errno.h>
537  #include <rte_ring.h>
538 -#include <rte_mempool.h>
539  #include <rte_malloc.h>
540  #include <rte_common.h>
541  #include <rte_ivshmem.h>
542 Index: dpdk/lib/librte_ivshmem/Makefile
543 ===================================================================
544 --- dpdk.orig/lib/librte_ivshmem/Makefile
545 +++ dpdk/lib/librte_ivshmem/Makefile
546 @@ -46,7 +46,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_IVSHMEM) := rte
547  # install includes
548  SYMLINK-$(CONFIG_RTE_LIBRTE_IVSHMEM)-include := rte_ivshmem.h
549  
550 -# this lib needs eal
551 +# this lib needs EAL, ring and mempool
552 +DEPDIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += lib/librte_eal
553 +DEPDIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += lib/librte_ring
554  DEPDIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += lib/librte_mempool
555  
556  include $(RTE_SDK)/mk/rte.lib.mk