- /*
- * Initialise the socket to communicate with the secondary
- * process.
- */
- ret = socket(AF_UNIX, SOCK_STREAM, 0);
- if (ret < 0) {
- rte_errno = errno;
- WARN("secondary process not supported: %s", strerror(errno));
- goto error;
- }
- priv->primary_socket = ret;
- flags = fcntl(priv->primary_socket, F_GETFL, 0);
- if (flags == -1) {
- rte_errno = errno;
- goto error;
- }
- ret = fcntl(priv->primary_socket, F_SETFL, flags | O_NONBLOCK);
- if (ret < 0) {
- rte_errno = errno;
- goto error;
- }
- snprintf(sun.sun_path, sizeof(sun.sun_path), "/var/tmp/%s_%d",
- MLX5_DRIVER_NAME, priv->primary_socket);
- ret = stat(sun.sun_path, &file_stat);
- if (!ret)
- claim_zero(remove(sun.sun_path));
- ret = bind(priv->primary_socket, (const struct sockaddr *)&sun,
- sizeof(sun));
- if (ret < 0) {
- rte_errno = errno;
- WARN("cannot bind socket, secondary process not supported: %s",
- strerror(errno));
- goto close;
- }
- ret = listen(priv->primary_socket, 0);
- if (ret < 0) {
- rte_errno = errno;
- WARN("Secondary process not supported: %s", strerror(errno));
- goto close;
- }
- return 0;
-close:
- remove(sun.sun_path);
-error:
- claim_zero(close(priv->primary_socket));
- priv->primary_socket = 0;
- return -rte_errno;
-}