| 165 | } |
| 166 | |
| 167 | static int |
| 168 | mlx5_test_extend_devargs(char *identifier, char *extend) |
| 169 | { |
| 170 | struct sockaddr_un un = { |
| 171 | .sun_family = AF_UNIX, |
| 172 | }; |
| 173 | int cmd_fd; |
| 174 | int pd_handle; |
| 175 | struct iovec iov = { |
| 176 | .iov_base = &pd_handle, |
| 177 | .iov_len = sizeof(int), |
| 178 | }; |
| 179 | union { |
| 180 | char buf[CMSG_SPACE(sizeof(int))]; |
| 181 | struct cmsghdr align; |
| 182 | } control; |
| 183 | struct msghdr msgh = { |
| 184 | .msg_iov = NULL, |
| 185 | .msg_iovlen = 0, |
| 186 | }; |
| 187 | struct cmsghdr *cmsg; |
| 188 | const char *path = mlx5_test_get_socket_path(extend + 1); |
| 189 | size_t len = 1; |
| 190 | int socket_fd; |
| 191 | int ret; |
| 192 | |
| 193 | if (path == NULL) { |
| 194 | TESTPMD_LOG(ERR, "Invalid devargs extension is specified\n"); |
| 195 | return -1; |
| 196 | } |
| 197 | |
| 198 | /* Initialize IPC channel. */ |
| 199 | socket_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); |
| 200 | if (socket_fd < 0) { |
| 201 | TESTPMD_LOG(ERR, "Failed to create unix socket: %s\n", |
| 202 | strerror(errno)); |
| 203 | return -1; |
| 204 | } |
| 205 | rte_strlcpy(un.sun_path, path, sizeof(un.sun_path)); |
| 206 | if (connect(socket_fd, (struct sockaddr *)&un, sizeof(un)) < 0) { |
| 207 | TESTPMD_LOG(ERR, "Failed to connect %s: %s\n", un.sun_path, |
| 208 | strerror(errno)); |
| 209 | close(socket_fd); |
| 210 | return -1; |
| 211 | } |
| 212 | |
| 213 | /* Send the request message. */ |
| 214 | do { |
| 215 | ret = sendmsg(socket_fd, &msgh, 0); |
| 216 | } while (ret < 0 && errno == EINTR); |
| 217 | if (ret < 0) { |
| 218 | TESTPMD_LOG(ERR, "Failed to send request to (%s): %s\n", path, |
| 219 | strerror(errno)); |
| 220 | close(socket_fd); |
| 221 | return -1; |
| 222 | } |
| 223 | |
| 224 | msgh.msg_iov = &iov; |
no test coverage detected