app/crypto-perf: support lookaside IPsec
[dpdk.git] / lib / vhost / socket.c
index 0169d36..c654860 100644 (file)
@@ -42,6 +42,7 @@ struct vhost_user_socket {
        bool extbuf;
        bool linearbuf;
        bool async_copy;
+       bool net_compliant_ol_flags;
 
        /*
         * The "supported_features" indicates the feature bits the
@@ -224,7 +225,8 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
        size = strnlen(vsocket->path, PATH_MAX);
        vhost_set_ifname(vid, vsocket->path, size);
 
-       vhost_set_builtin_virtio_net(vid, vsocket->use_builtin_virtio_net);
+       vhost_setup_virtio_net(vid, vsocket->use_builtin_virtio_net,
+               vsocket->net_compliant_ol_flags);
 
        vhost_attach_vdpa_device(vid, vsocket->vdpa_dev);
 
@@ -241,7 +243,7 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
                        dev->async_copy = 1;
        }
 
-       VHOST_LOG_CONFIG(INFO, "new device, handle is %d\n", vid);
+       VHOST_LOG_CONFIG(INFO, "new device, handle is %d, path is %s\n", vid, vsocket->path);
 
        if (vsocket->notify_ops->new_connection) {
                ret = vsocket->notify_ops->new_connection(vid);
@@ -877,6 +879,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
        vsocket->extbuf = flags & RTE_VHOST_USER_EXTBUF_SUPPORT;
        vsocket->linearbuf = flags & RTE_VHOST_USER_LINEARBUF_SUPPORT;
        vsocket->async_copy = flags & RTE_VHOST_USER_ASYNC_COPY;
+       vsocket->net_compliant_ol_flags = flags & RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
 
        if (vsocket->async_copy &&
                (flags & (RTE_VHOST_USER_IOMMU_SUPPORT |
@@ -1020,66 +1023,65 @@ again:
 
        for (i = 0; i < vhost_user.vsocket_cnt; i++) {
                struct vhost_user_socket *vsocket = vhost_user.vsockets[i];
+               if (strcmp(vsocket->path, path))
+                       continue;
 
-               if (!strcmp(vsocket->path, path)) {
-                       pthread_mutex_lock(&vsocket->conn_mutex);
-                       for (conn = TAILQ_FIRST(&vsocket->conn_list);
-                            conn != NULL;
-                            conn = next) {
-                               next = TAILQ_NEXT(conn, next);
-
-                               /*
-                                * If r/wcb is executing, release vsocket's
-                                * conn_mutex and vhost_user's mutex locks, and
-                                * try again since the r/wcb may use the
-                                * conn_mutex and mutex locks.
-                                */
-                               if (fdset_try_del(&vhost_user.fdset,
-                                                 conn->connfd) == -1) {
-                                       pthread_mutex_unlock(
-                                                       &vsocket->conn_mutex);
-                                       pthread_mutex_unlock(&vhost_user.mutex);
-                                       goto again;
-                               }
-
-                               VHOST_LOG_CONFIG(INFO,
-                                       "free connfd = %d for device '%s'\n",
-                                       conn->connfd, path);
-                               close(conn->connfd);
-                               vhost_destroy_device(conn->vid);
-                               TAILQ_REMOVE(&vsocket->conn_list, conn, next);
-                               free(conn);
-                       }
-                       pthread_mutex_unlock(&vsocket->conn_mutex);
-
-                       if (vsocket->is_server) {
-                               /*
-                                * If r/wcb is executing, release vhost_user's
-                                * mutex lock, and try again since the r/wcb
-                                * may use the mutex lock.
-                                */
-                               if (fdset_try_del(&vhost_user.fdset,
-                                               vsocket->socket_fd) == -1) {
-                                       pthread_mutex_unlock(&vhost_user.mutex);
-                                       goto again;
-                               }
-
-                               close(vsocket->socket_fd);
-                               unlink(path);
-                       } else if (vsocket->reconnect) {
-                               vhost_user_remove_reconnect(vsocket);
+               if (vsocket->is_server) {
+                       /*
+                        * If r/wcb is executing, release vhost_user's
+                        * mutex lock, and try again since the r/wcb
+                        * may use the mutex lock.
+                        */
+                       if (fdset_try_del(&vhost_user.fdset, vsocket->socket_fd) == -1) {
+                               pthread_mutex_unlock(&vhost_user.mutex);
+                               goto again;
                        }
+               } else if (vsocket->reconnect) {
+                       vhost_user_remove_reconnect(vsocket);
+               }
 
-                       pthread_mutex_destroy(&vsocket->conn_mutex);
-                       vhost_user_socket_mem_free(vsocket);
+               pthread_mutex_lock(&vsocket->conn_mutex);
+               for (conn = TAILQ_FIRST(&vsocket->conn_list);
+                        conn != NULL;
+                        conn = next) {
+                       next = TAILQ_NEXT(conn, next);
 
-                       count = --vhost_user.vsocket_cnt;
-                       vhost_user.vsockets[i] = vhost_user.vsockets[count];
-                       vhost_user.vsockets[count] = NULL;
-                       pthread_mutex_unlock(&vhost_user.mutex);
+                       /*
+                        * If r/wcb is executing, release vsocket's
+                        * conn_mutex and vhost_user's mutex locks, and
+                        * try again since the r/wcb may use the
+                        * conn_mutex and mutex locks.
+                        */
+                       if (fdset_try_del(&vhost_user.fdset,
+                                         conn->connfd) == -1) {
+                               pthread_mutex_unlock(&vsocket->conn_mutex);
+                               pthread_mutex_unlock(&vhost_user.mutex);
+                               goto again;
+                       }
 
-                       return 0;
+                       VHOST_LOG_CONFIG(INFO,
+                               "free connfd = %d for device '%s'\n",
+                               conn->connfd, path);
+                       close(conn->connfd);
+                       vhost_destroy_device(conn->vid);
+                       TAILQ_REMOVE(&vsocket->conn_list, conn, next);
+                       free(conn);
+               }
+               pthread_mutex_unlock(&vsocket->conn_mutex);
+
+               if (vsocket->is_server) {
+                       close(vsocket->socket_fd);
+                       unlink(path);
                }
+
+               pthread_mutex_destroy(&vsocket->conn_mutex);
+               vhost_user_socket_mem_free(vsocket);
+
+               count = --vhost_user.vsocket_cnt;
+               vhost_user.vsockets[i] = vhost_user.vsockets[count];
+               vhost_user.vsockets[count] = NULL;
+               pthread_mutex_unlock(&vhost_user.mutex);
+               return 0;
        }
        pthread_mutex_unlock(&vhost_user.mutex);