+int
+add_host_channels(void)
+{
+ struct channel_info *chan_info;
+ char socket_path[PATH_MAX];
+ int num_channels_enabled = 0;
+ int ret;
+ struct core_info *ci;
+ struct channel_info *chan_infos[RTE_MAX_LCORE];
+ int i;
+
+ for (i = 0; i < RTE_MAX_LCORE; i++)
+ chan_infos[i] = NULL;
+
+ ci = get_core_info();
+ if (ci == NULL) {
+ RTE_LOG(ERR, CHANNEL_MANAGER, "Cannot allocate memory for core_info\n");
+ return 0;
+ }
+
+ for (i = 0; i < ci->core_count; i++) {
+ if (ci->cd[i].global_enabled_cpus == 0)
+ continue;
+
+ ret = fifo_path(socket_path, sizeof(socket_path), i);
+ if (ret < 0)
+ goto error;
+
+ ret = mkfifo(socket_path, 0660);
+ RTE_LOG(DEBUG, CHANNEL_MANAGER, "TRY CREATE fifo '%s'\n",
+ socket_path);
+ if ((errno != EEXIST) && (ret < 0)) {
+ RTE_LOG(ERR, CHANNEL_MANAGER, "Cannot create fifo '%s' error: "
+ "%s\n", socket_path, strerror(errno));
+ goto error;
+ }
+ chan_info = rte_malloc(NULL, sizeof(*chan_info), 0);
+ if (chan_info == NULL) {
+ RTE_LOG(ERR, CHANNEL_MANAGER, "Error allocating memory for "
+ "channel '%s'\n", socket_path);
+ goto error;
+ }
+ chan_infos[i] = chan_info;
+ strlcpy(chan_info->channel_path, socket_path,
+ sizeof(chan_info->channel_path));
+
+ if (setup_host_channel_info(&chan_info, i) < 0) {
+ rte_free(chan_info);
+ chan_infos[i] = NULL;
+ goto error;
+ }
+ num_channels_enabled++;
+ }
+
+ return num_channels_enabled;
+error:
+ /* Clean up the channels opened before we hit an error. */
+ for (i = 0; i < ci->core_count; i++) {
+ if (chan_infos[i] != NULL) {
+ remove_channel_from_monitor(chan_infos[i]);
+ close(chan_infos[i]->fd);
+ rte_free(chan_infos[i]);
+ }
+ }
+ return 0;
+}
+