| 2065 | } |
| 2066 | |
| 2067 | static int |
| 2068 | vhost_user_set_vring_kick(struct virtio_net **pdev, |
| 2069 | struct vhu_msg_context *ctx, |
| 2070 | int main_fd __rte_unused) |
| 2071 | { |
| 2072 | struct virtio_net *dev = *pdev; |
| 2073 | struct vhost_vring_file file; |
| 2074 | struct vhost_virtqueue *vq; |
| 2075 | int expected_fds; |
| 2076 | |
| 2077 | expected_fds = (ctx->msg.payload.u64 & VHOST_USER_VRING_NOFD_MASK) ? 0 : 1; |
| 2078 | if (validate_msg_fds(dev, ctx, expected_fds) != 0) |
| 2079 | return RTE_VHOST_MSG_RESULT_ERR; |
| 2080 | |
| 2081 | file.index = ctx->msg.payload.u64 & VHOST_USER_VRING_IDX_MASK; |
| 2082 | if (ctx->msg.payload.u64 & VHOST_USER_VRING_NOFD_MASK) |
| 2083 | file.fd = VIRTIO_INVALID_EVENTFD; |
| 2084 | else |
| 2085 | file.fd = ctx->fds[0]; |
| 2086 | VHOST_LOG_CONFIG(dev->ifname, INFO, |
| 2087 | "vring kick idx:%d file:%d\n", |
| 2088 | file.index, file.fd); |
| 2089 | |
| 2090 | /* Interpret ring addresses only when ring is started. */ |
| 2091 | vq = dev->virtqueue[file.index]; |
| 2092 | translate_ring_addresses(&dev, &vq); |
| 2093 | *pdev = dev; |
| 2094 | |
| 2095 | /* |
| 2096 | * When VHOST_USER_F_PROTOCOL_FEATURES is not negotiated, |
| 2097 | * the ring starts already enabled. Otherwise, it is enabled via |
| 2098 | * the SET_VRING_ENABLE message. |
| 2099 | */ |
| 2100 | if (!(dev->features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) { |
| 2101 | vq->enabled = true; |
| 2102 | } |
| 2103 | |
| 2104 | if (vq->ready) { |
| 2105 | vq->ready = false; |
| 2106 | vhost_user_notify_queue_state(dev, vq, 0); |
| 2107 | } |
| 2108 | |
| 2109 | if (vq->kickfd >= 0) |
| 2110 | close(vq->kickfd); |
| 2111 | vq->kickfd = file.fd; |
| 2112 | |
| 2113 | if (vq_is_packed(dev)) { |
| 2114 | if (vhost_check_queue_inflights_packed(dev, vq)) { |
| 2115 | VHOST_LOG_CONFIG(dev->ifname, ERR, |
| 2116 | "failed to inflights for vq: %d\n", |
| 2117 | file.index); |
| 2118 | return RTE_VHOST_MSG_RESULT_ERR; |
| 2119 | } |
| 2120 | } else { |
| 2121 | if (vhost_check_queue_inflights_split(dev, vq)) { |
| 2122 | VHOST_LOG_CONFIG(dev->ifname, ERR, |
| 2123 | "failed to inflights for vq: %d\n", |
| 2124 | file.index); |
nothing calls this directly
no test coverage detected