| 989 | } |
| 990 | |
| 991 | int |
| 992 | rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, |
| 993 | const struct timespec *ts) |
| 994 | { |
| 995 | int dir_fd, ret = -1; |
| 996 | DIR *mp_dir; |
| 997 | struct dirent *ent; |
| 998 | struct timespec now, end; |
| 999 | const struct internal_config *internal_conf = |
| 1000 | eal_get_internal_configuration(); |
| 1001 | |
| 1002 | RTE_LOG(DEBUG, EAL, "request: %s\n", req->name); |
| 1003 | |
| 1004 | reply->nb_sent = 0; |
| 1005 | reply->nb_received = 0; |
| 1006 | reply->msgs = NULL; |
| 1007 | |
| 1008 | if (check_input(req) != 0) |
| 1009 | goto end; |
| 1010 | |
| 1011 | if (internal_conf->no_shconf) { |
| 1012 | RTE_LOG(DEBUG, EAL, "No shared files mode enabled, IPC is disabled\n"); |
| 1013 | rte_errno = ENOTSUP; |
| 1014 | return -1; |
| 1015 | } |
| 1016 | |
| 1017 | if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) { |
| 1018 | RTE_LOG(ERR, EAL, "Failed to get current time\n"); |
| 1019 | rte_errno = errno; |
| 1020 | goto end; |
| 1021 | } |
| 1022 | |
| 1023 | end.tv_nsec = (now.tv_nsec + ts->tv_nsec) % 1000000000; |
| 1024 | end.tv_sec = now.tv_sec + ts->tv_sec + |
| 1025 | (now.tv_nsec + ts->tv_nsec) / 1000000000; |
| 1026 | |
| 1027 | /* for secondary process, send request to the primary process only */ |
| 1028 | if (rte_eal_process_type() == RTE_PROC_SECONDARY) { |
| 1029 | pthread_mutex_lock(&pending_requests.lock); |
| 1030 | ret = mp_request_sync(eal_mp_socket_path(), req, reply, &end); |
| 1031 | pthread_mutex_unlock(&pending_requests.lock); |
| 1032 | goto end; |
| 1033 | } |
| 1034 | |
| 1035 | /* for primary process, broadcast request, and collect reply 1 by 1 */ |
| 1036 | mp_dir = opendir(mp_dir_path); |
| 1037 | if (!mp_dir) { |
| 1038 | RTE_LOG(ERR, EAL, "Unable to open directory %s\n", mp_dir_path); |
| 1039 | rte_errno = errno; |
| 1040 | goto end; |
| 1041 | } |
| 1042 | |
| 1043 | dir_fd = dirfd(mp_dir); |
| 1044 | /* lock the directory to prevent processes spinning up while we send */ |
| 1045 | if (flock(dir_fd, LOCK_SH)) { |
| 1046 | RTE_LOG(ERR, EAL, "Unable to lock directory %s\n", |
| 1047 | mp_dir_path); |
| 1048 | rte_errno = errno; |
no test coverage detected