* We receive the negotiated features supported by us and the virtio device. */
| 328 | * We receive the negotiated features supported by us and the virtio device. |
| 329 | */ |
| 330 | static int |
| 331 | vhost_user_set_features(struct virtio_net **pdev, |
| 332 | struct vhu_msg_context *ctx, |
| 333 | int main_fd __rte_unused) |
| 334 | { |
| 335 | struct virtio_net *dev = *pdev; |
| 336 | uint64_t features = ctx->msg.payload.u64; |
| 337 | uint64_t vhost_features = 0; |
| 338 | struct rte_vdpa_device *vdpa_dev; |
| 339 | |
| 340 | rte_vhost_driver_get_features(dev->ifname, &vhost_features); |
| 341 | if (features & ~vhost_features) { |
| 342 | VHOST_LOG_CONFIG(dev->ifname, ERR, "received invalid negotiated features.\n"); |
| 343 | dev->flags |= VIRTIO_DEV_FEATURES_FAILED; |
| 344 | dev->status &= ~VIRTIO_DEVICE_STATUS_FEATURES_OK; |
| 345 | |
| 346 | return RTE_VHOST_MSG_RESULT_ERR; |
| 347 | } |
| 348 | |
| 349 | if (dev->flags & VIRTIO_DEV_RUNNING) { |
| 350 | if (dev->features == features) |
| 351 | return RTE_VHOST_MSG_RESULT_OK; |
| 352 | |
| 353 | /* |
| 354 | * Error out if frontend tries to change features while device is |
| 355 | * in running state. The exception being VHOST_F_LOG_ALL, which |
| 356 | * is enabled when the live-migration starts. |
| 357 | */ |
| 358 | if ((dev->features ^ features) & ~(1ULL << VHOST_F_LOG_ALL)) { |
| 359 | VHOST_LOG_CONFIG(dev->ifname, ERR, |
| 360 | "features changed while device is running.\n"); |
| 361 | return RTE_VHOST_MSG_RESULT_ERR; |
| 362 | } |
| 363 | |
| 364 | if (dev->notify_ops->features_changed) |
| 365 | dev->notify_ops->features_changed(dev->vid, features); |
| 366 | } |
| 367 | |
| 368 | dev->features = features; |
| 369 | if (dev->features & |
| 370 | ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | |
| 371 | (1ULL << VIRTIO_F_VERSION_1) | |
| 372 | (1ULL << VIRTIO_F_RING_PACKED))) { |
| 373 | dev->vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf); |
| 374 | } else { |
| 375 | dev->vhost_hlen = sizeof(struct virtio_net_hdr); |
| 376 | } |
| 377 | VHOST_LOG_CONFIG(dev->ifname, INFO, |
| 378 | "negotiated Virtio features: 0x%" PRIx64 "\n", |
| 379 | dev->features); |
| 380 | VHOST_LOG_CONFIG(dev->ifname, DEBUG, |
| 381 | "mergeable RX buffers %s, virtio 1 %s\n", |
| 382 | (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? "on" : "off", |
| 383 | (dev->features & (1ULL << VIRTIO_F_VERSION_1)) ? "on" : "off"); |
| 384 | |
| 385 | if ((dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET) && |
| 386 | !(dev->features & (1ULL << VIRTIO_NET_F_MQ))) { |
| 387 | /* |
nothing calls this directly
no test coverage detected