- conf->uio_driver_name = format (0, "uio_pci_generic%c", 0);
-
- /*
- * Use 1G huge pages if available.
- */
- if (!no_huge && !huge_dir)
- {
- u32 x, *mem_by_socket = 0;
- uword c = 0;
- u8 use_1g = 1;
- u8 use_2m = 1;
- u8 less_than_1g = 1;
- int rv;
-
- umount (DEFAULT_HUGE_DIR);
-
- /* Process "socket-mem" parameter value */
- if (vec_len (socket_mem))
- {
- unformat_input_t in;
- unformat_init_vector (&in, socket_mem);
- while (unformat_check_input (&in) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (&in, "%u,", &x))
- ;
- else if (unformat (&in, "%u", &x))
- ;
- else if (unformat (&in, ","))
- x = 0;
- else
- break;
-
- vec_add1 (mem_by_socket, x);
-
- if (x > 1023)
- less_than_1g = 0;
- }
- /* Note: unformat_free vec_frees(in.buffer), aka socket_mem... */
- unformat_free (&in);
- socket_mem = 0;
- }
- else
- {
- /* *INDENT-OFF* */
- clib_bitmap_foreach (c, tm->cpu_socket_bitmap, (
- {
- vec_validate(mem_by_socket, c);
- mem_by_socket[c] = 256; /* default per-socket mem */
- }
- ));
- /* *INDENT-ON* */
- }
-
- /* check if available enough 1GB pages for each socket */
- /* *INDENT-OFF* */
- clib_bitmap_foreach (c, tm->cpu_socket_bitmap, (
- {
- int pages_avail, page_size, mem;
-
- vec_validate(mem_by_socket, c);
- mem = mem_by_socket[c];
-
- page_size = 1024;
- pages_avail = vlib_sysfs_get_free_hugepages(c, page_size * 1024);
-
- if (pages_avail < 0 || page_size * pages_avail < mem)
- use_1g = 0;
-
- page_size = 2;
- pages_avail = vlib_sysfs_get_free_hugepages(c, page_size * 1024);
-
- if (pages_avail < 0 || page_size * pages_avail < mem)
- use_2m = 0;
- }));
- /* *INDENT-ON* */
-
- if (mem_by_socket == 0)
- {
- error = clib_error_return (0, "mem_by_socket NULL");
- goto done;
- }
- _vec_len (mem_by_socket) = c + 1;
-
- /* regenerate socket_mem string */
- vec_foreach_index (x, mem_by_socket)
- socket_mem = format (socket_mem, "%s%u",
- socket_mem ? "," : "", mem_by_socket[x]);
- socket_mem = format (socket_mem, "%c", 0);