- /*
- * Initialise the socket to communicate with the secondary
- * process.
- */
- ret = socket(AF_UNIX, SOCK_STREAM, 0);
- if (ret < 0) {
- rte_errno = errno;
- DRV_LOG(WARNING, "port %u secondary process not supported: %s",
- dev->data->port_id, 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);
- remove(sun.sun_path);
- ret = bind(priv->primary_socket, (const struct sockaddr *)&sun,
- sizeof(sun));
- if (ret < 0) {
- rte_errno = errno;
- DRV_LOG(WARNING,
- "port %u cannot bind socket, secondary process not"
- " supported: %s",
- dev->data->port_id, strerror(errno));
- goto close;
- }
- ret = listen(priv->primary_socket, 0);
- if (ret < 0) {
- rte_errno = errno;
- DRV_LOG(WARNING, "port %u secondary process not supported: %s",
- dev->data->port_id, 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;
-}