1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (C) 2017 Intel Corporation. 3 * All rights reserved. 4 */ 5 6 #ifndef SPDK_VHOST_INTERNAL_H 7 #define SPDK_VHOST_INTERNAL_H 8 #include <linux/virtio_config.h> 9 10 #include "spdk/stdinc.h" 11 12 #include <rte_vhost.h> 13 14 #include "spdk_internal/vhost_user.h" 15 #include "spdk/bdev.h" 16 #include "spdk/log.h" 17 #include "spdk/util.h" 18 #include "spdk/rpc.h" 19 #include "spdk/config.h" 20 21 #define SPDK_VHOST_MAX_VQUEUES 256 22 #define SPDK_VHOST_MAX_VQ_SIZE 1024 23 24 #define SPDK_VHOST_SCSI_CTRLR_MAX_DEVS 8 25 26 #define SPDK_VHOST_IOVS_MAX 129 27 28 #define SPDK_VHOST_VQ_MAX_SUBMISSIONS 32 29 30 /* 31 * Rate at which stats are checked for interrupt coalescing. 32 */ 33 #define SPDK_VHOST_STATS_CHECK_INTERVAL_MS 10 34 /* 35 * Default threshold at which interrupts start to be coalesced. 36 */ 37 #define SPDK_VHOST_VQ_IOPS_COALESCING_THRESHOLD 60000 38 39 /* 40 * Currently coalescing is not used by default. 41 * Setting this to value > 0 here or by RPC will enable coalescing. 42 */ 43 #define SPDK_VHOST_COALESCING_DELAY_BASE_US 0 44 45 #define SPDK_VHOST_FEATURES ((1ULL << VHOST_F_LOG_ALL) | \ 46 (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \ 47 (1ULL << VIRTIO_F_VERSION_1) | \ 48 (1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \ 49 (1ULL << VIRTIO_RING_F_EVENT_IDX) | \ 50 (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \ 51 (1ULL << VIRTIO_F_RING_PACKED) | \ 52 (1ULL << VIRTIO_F_ANY_LAYOUT)) 53 54 #define SPDK_VHOST_DISABLED_FEATURES ((1ULL << VIRTIO_RING_F_EVENT_IDX) | \ 55 (1ULL << VIRTIO_F_NOTIFY_ON_EMPTY)) 56 57 #define VRING_DESC_F_AVAIL (1ULL << VRING_PACKED_DESC_F_AVAIL) 58 #define VRING_DESC_F_USED (1ULL << VRING_PACKED_DESC_F_USED) 59 #define VRING_DESC_F_AVAIL_USED (VRING_DESC_F_AVAIL | VRING_DESC_F_USED) 60 61 typedef struct rte_vhost_resubmit_desc spdk_vhost_resubmit_desc; 62 typedef struct rte_vhost_resubmit_info spdk_vhost_resubmit_info; 63 typedef struct rte_vhost_inflight_desc_packed spdk_vhost_inflight_desc; 64 65 struct spdk_vhost_virtqueue { 66 struct rte_vhost_vring vring; 67 struct rte_vhost_ring_inflight vring_inflight; 68 uint16_t last_avail_idx; 69 uint16_t last_used_idx; 70 71 struct { 72 /* To mark a descriptor as available in packed ring 73 * Equal to avail_wrap_counter in spec. 74 */ 75 uint8_t avail_phase : 1; 76 /* To mark a descriptor as used in packed ring 77 * Equal to used_wrap_counter in spec. 78 */ 79 uint8_t used_phase : 1; 80 uint8_t padding : 5; 81 bool packed_ring : 1; 82 } packed; 83 84 void *tasks; 85 86 /* Request count from last stats check */ 87 uint32_t req_cnt; 88 89 /* Request count from last event */ 90 uint16_t used_req_cnt; 91 92 /* How long interrupt is delayed */ 93 uint32_t irq_delay_time; 94 95 /* Next time when we need to send event */ 96 uint64_t next_event_time; 97 98 /* Associated vhost_virtqueue in the virtio device's virtqueue list */ 99 uint32_t vring_idx; 100 101 struct spdk_vhost_session *vsession; 102 103 struct spdk_interrupt *intr; 104 } __attribute((aligned(SPDK_CACHE_LINE_SIZE))); 105 106 struct spdk_vhost_session { 107 struct spdk_vhost_dev *vdev; 108 109 /* rte_vhost connection ID. */ 110 int vid; 111 112 /* Unique session ID. */ 113 uint64_t id; 114 /* Unique session name. */ 115 char *name; 116 117 bool started; 118 bool interrupt_mode; 119 120 struct rte_vhost_memory *mem; 121 122 int task_cnt; 123 124 uint16_t max_queues; 125 126 uint64_t negotiated_features; 127 128 /* Local copy of device coalescing settings. */ 129 uint32_t coalescing_delay_time_base; 130 uint32_t coalescing_io_rate_threshold; 131 132 /* Next time when stats for event coalescing will be checked. */ 133 uint64_t next_stats_check_time; 134 135 /* Interval used for event coalescing checking. */ 136 uint64_t stats_check_interval; 137 138 /* Session's stop poller will only try limited times to destroy the session. */ 139 uint32_t stop_retry_count; 140 141 struct spdk_vhost_virtqueue virtqueue[SPDK_VHOST_MAX_VQUEUES]; 142 143 TAILQ_ENTRY(spdk_vhost_session) tailq; 144 }; 145 146 struct spdk_vhost_user_dev { 147 struct spdk_vhost_dev *vdev; 148 149 const struct spdk_vhost_user_dev_backend *user_backend; 150 151 /* Saved original values used to setup coalescing to avoid integer 152 * rounding issues during save/load config. 153 */ 154 uint32_t coalescing_delay_us; 155 uint32_t coalescing_iops_threshold; 156 157 bool registered; 158 159 /* Use this lock to protect multiple sessions. */ 160 pthread_mutex_t lock; 161 162 /* Current connections to the device */ 163 TAILQ_HEAD(, spdk_vhost_session) vsessions; 164 165 /* Increment-only session counter */ 166 uint64_t vsessions_num; 167 168 /* Number of pending asynchronous operations */ 169 uint32_t pending_async_op_num; 170 }; 171 172 struct spdk_vhost_dev { 173 char *name; 174 char *path; 175 176 struct spdk_thread *thread; 177 178 uint64_t virtio_features; 179 uint64_t disabled_features; 180 uint64_t protocol_features; 181 bool packed_ring_recovery; 182 183 const struct spdk_vhost_dev_backend *backend; 184 185 /* Context passed from transport */ 186 void *ctxt; 187 188 TAILQ_ENTRY(spdk_vhost_dev) tailq; 189 }; 190 191 static inline struct spdk_vhost_user_dev * 192 to_user_dev(struct spdk_vhost_dev *vdev) 193 { 194 assert(vdev != NULL); 195 return vdev->ctxt; 196 } 197 198 /** 199 * \param vdev vhost device. 200 * \param vsession vhost session. 201 * \param arg user-provided parameter. 202 * 203 * \return negative values will break the foreach call, meaning 204 * the function won't be called again. Return codes zero and 205 * positive don't have any effect. 206 */ 207 typedef int (*spdk_vhost_session_fn)(struct spdk_vhost_dev *vdev, 208 struct spdk_vhost_session *vsession, 209 void *arg); 210 211 /** 212 * \param vdev vhost device. 213 * \param arg user-provided parameter. 214 */ 215 typedef void (*spdk_vhost_dev_fn)(struct spdk_vhost_dev *vdev, void *arg); 216 217 struct spdk_vhost_user_dev_backend { 218 /** 219 * Size of additional per-session context data 220 * allocated whenever a new client connects. 221 */ 222 size_t session_ctx_size; 223 224 spdk_vhost_session_fn start_session; 225 spdk_vhost_session_fn stop_session; 226 int (*alloc_vq_tasks)(struct spdk_vhost_session *vsession, uint16_t qid); 227 void (*register_vq_interrupt)(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *vq); 228 }; 229 230 enum vhost_backend_type { 231 VHOST_BACKEND_BLK = 0, 232 VHOST_BACKEND_SCSI, 233 }; 234 235 struct spdk_vhost_dev_backend { 236 enum vhost_backend_type type; 237 238 int (*vhost_get_config)(struct spdk_vhost_dev *vdev, uint8_t *config, uint32_t len); 239 int (*vhost_set_config)(struct spdk_vhost_dev *vdev, uint8_t *config, 240 uint32_t offset, uint32_t size, uint32_t flags); 241 242 void (*dump_info_json)(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w); 243 void (*write_config_json)(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w); 244 int (*remove_device)(struct spdk_vhost_dev *vdev); 245 int (*set_coalescing)(struct spdk_vhost_dev *vdev, uint32_t delay_base_us, 246 uint32_t iops_threshold); 247 void (*get_coalescing)(struct spdk_vhost_dev *vdev, uint32_t *delay_base_us, 248 uint32_t *iops_threshold); 249 }; 250 251 void *vhost_gpa_to_vva(struct spdk_vhost_session *vsession, uint64_t addr, uint64_t len); 252 253 uint16_t vhost_vq_avail_ring_get(struct spdk_vhost_virtqueue *vq, uint16_t *reqs, 254 uint16_t reqs_len); 255 256 /** 257 * Get a virtio split descriptor at given index in given virtqueue. 258 * The descriptor will provide access to the entire descriptor 259 * chain. The subsequent descriptors are accessible via 260 * \c spdk_vhost_vring_desc_get_next. 261 * \param vsession vhost session 262 * \param vq virtqueue 263 * \param req_idx descriptor index 264 * \param desc pointer to be set to the descriptor 265 * \param desc_table descriptor table to be used with 266 * \c spdk_vhost_vring_desc_get_next. This might be either 267 * default virtqueue descriptor table or per-chain indirect 268 * table. 269 * \param desc_table_size size of the *desc_table* 270 * \return 0 on success, -1 if given index is invalid. 271 * If -1 is returned, the content of params is undefined. 272 */ 273 int vhost_vq_get_desc(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *vq, 274 uint16_t req_idx, struct vring_desc **desc, struct vring_desc **desc_table, 275 uint32_t *desc_table_size); 276 277 /** 278 * Get a virtio packed descriptor at given index in given virtqueue. 279 * The descriptor will provide access to the entire descriptor 280 * chain. The subsequent descriptors are accessible via 281 * \c vhost_vring_packed_desc_get_next. 282 * \param vsession vhost session 283 * \param vq virtqueue 284 * \param req_idx descriptor index 285 * \param desc pointer to be set to the descriptor 286 * \param desc_table descriptor table to be used with 287 * \c spdk_vhost_vring_desc_get_next. This might be either 288 * \c NULL or per-chain indirect table. 289 * \param desc_table_size size of the *desc_table* 290 * \return 0 on success, -1 if given index is invalid. 291 * If -1 is returned, the content of params is undefined. 292 */ 293 int vhost_vq_get_desc_packed(struct spdk_vhost_session *vsession, 294 struct spdk_vhost_virtqueue *virtqueue, 295 uint16_t req_idx, struct vring_packed_desc **desc, 296 struct vring_packed_desc **desc_table, uint32_t *desc_table_size); 297 298 int vhost_inflight_queue_get_desc(struct spdk_vhost_session *vsession, 299 spdk_vhost_inflight_desc *desc_array, 300 uint16_t req_idx, spdk_vhost_inflight_desc **desc, 301 struct vring_packed_desc **desc_table, uint32_t *desc_table_size); 302 303 /** 304 * Send IRQ/call client (if pending) for \c vq. 305 * \param vsession vhost session 306 * \param vq virtqueue 307 * \return 308 * 0 - if no interrupt was signalled 309 * 1 - if interrupt was signalled 310 */ 311 int vhost_vq_used_signal(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *vq); 312 313 /** 314 * Send IRQs for the queue that need to be signaled. 315 * \param vq virtqueue 316 */ 317 void vhost_session_vq_used_signal(struct spdk_vhost_virtqueue *virtqueue); 318 319 void vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession, 320 struct spdk_vhost_virtqueue *vq, 321 uint16_t id, uint32_t len); 322 323 /** 324 * Enqueue the entry to the used ring when device complete the request. 325 * \param vsession vhost session 326 * \param vq virtqueue 327 * \req_idx descriptor index. It's the first index of this descriptor chain. 328 * \num_descs descriptor count. It's the count of the number of buffers in the chain. 329 * \buffer_id descriptor buffer ID. 330 * \length device write length. Specify the length of the buffer that has been initialized 331 * (written to) by the device 332 * \inflight_head the head idx of this IO inflight desc chain. 333 */ 334 void vhost_vq_packed_ring_enqueue(struct spdk_vhost_session *vsession, 335 struct spdk_vhost_virtqueue *virtqueue, 336 uint16_t num_descs, uint16_t buffer_id, 337 uint32_t length, uint16_t inflight_head); 338 339 /** 340 * Get subsequent descriptor from given table. 341 * \param desc current descriptor, will be set to the 342 * next descriptor (NULL in case this is the last 343 * descriptor in the chain or the next desc is invalid) 344 * \param desc_table descriptor table 345 * \param desc_table_size size of the *desc_table* 346 * \return 0 on success, -1 if given index is invalid 347 * The *desc* param will be set regardless of the 348 * return value. 349 */ 350 int vhost_vring_desc_get_next(struct vring_desc **desc, 351 struct vring_desc *desc_table, uint32_t desc_table_size); 352 static inline bool 353 vhost_vring_desc_is_wr(struct vring_desc *cur_desc) 354 { 355 return !!(cur_desc->flags & VRING_DESC_F_WRITE); 356 } 357 358 int vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov, 359 uint16_t *iov_index, const struct vring_desc *desc); 360 361 bool vhost_vq_packed_ring_is_avail(struct spdk_vhost_virtqueue *virtqueue); 362 363 /** 364 * Get subsequent descriptor from vq or desc table. 365 * \param desc current descriptor, will be set to the 366 * next descriptor (NULL in case this is the last 367 * descriptor in the chain or the next desc is invalid) 368 * \req_idx index of current desc, will be set to the next 369 * index. If desc_table != NULL the req_idx is the the vring index 370 * or the req_idx is the desc_table index. 371 * \param desc_table descriptor table 372 * \param desc_table_size size of the *desc_table* 373 * \return 0 on success, -1 if given index is invalid 374 * The *desc* param will be set regardless of the 375 * return value. 376 */ 377 int vhost_vring_packed_desc_get_next(struct vring_packed_desc **desc, uint16_t *req_idx, 378 struct spdk_vhost_virtqueue *vq, 379 struct vring_packed_desc *desc_table, 380 uint32_t desc_table_size); 381 382 bool vhost_vring_packed_desc_is_wr(struct vring_packed_desc *cur_desc); 383 384 int vhost_vring_packed_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov, 385 uint16_t *iov_index, const struct vring_packed_desc *desc); 386 387 bool vhost_vring_inflight_desc_is_wr(spdk_vhost_inflight_desc *cur_desc); 388 389 int vhost_vring_inflight_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov, 390 uint16_t *iov_index, const spdk_vhost_inflight_desc *desc); 391 392 uint16_t vhost_vring_packed_desc_get_buffer_id(struct spdk_vhost_virtqueue *vq, uint16_t req_idx, 393 uint16_t *num_descs); 394 395 static inline bool 396 __attribute__((always_inline)) 397 vhost_dev_has_feature(struct spdk_vhost_session *vsession, unsigned feature_id) 398 { 399 return vsession->negotiated_features & (1ULL << feature_id); 400 } 401 402 int vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *mask_str, 403 const struct spdk_json_val *params, 404 const struct spdk_vhost_dev_backend *backend, 405 const struct spdk_vhost_user_dev_backend *user_backend); 406 int vhost_dev_unregister(struct spdk_vhost_dev *vdev); 407 408 void vhost_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w); 409 410 /* 411 * Set vhost session to run in interrupt or poll mode 412 */ 413 void vhost_user_session_set_interrupt_mode(struct spdk_vhost_session *vsession, 414 bool interrupt_mode); 415 416 /* 417 * Memory registration functions used in start/stop device callbacks 418 */ 419 void vhost_session_mem_register(struct rte_vhost_memory *mem); 420 void vhost_session_mem_unregister(struct rte_vhost_memory *mem); 421 422 /* 423 * Call a function for each session of the provided vhost device. 424 * The function will be called one-by-one on each session's thread. 425 * 426 * \param vdev vhost device 427 * \param fn function to call on each session's thread 428 * \param cpl_fn function to be called at the end of the iteration on 429 * the vhost management thread. 430 * Optional, can be NULL. 431 * \param arg additional argument to the both callbacks 432 */ 433 void vhost_user_dev_foreach_session(struct spdk_vhost_dev *dev, 434 spdk_vhost_session_fn fn, 435 spdk_vhost_dev_fn cpl_fn, 436 void *arg); 437 438 /** 439 * Finish a blocking vhost_user_wait_for_session_stop() call and finally 440 * stop the session. This must be called on the session's lcore which 441 * used to receive all session-related messages (e.g. from 442 * vhost_user_dev_foreach_session()). After this call, the session- 443 * related messages will be once again processed by any arbitrary thread. 444 * 445 * Must be called under the vhost user device's session access lock. 446 * 447 * \param vsession vhost session 448 * \param response return code 449 */ 450 void vhost_user_session_stop_done(struct spdk_vhost_session *vsession, int response); 451 452 struct spdk_vhost_session *vhost_session_find_by_vid(int vid); 453 void vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession); 454 int vhost_register_unix_socket(const char *path, const char *ctrl_name, 455 uint64_t virtio_features, uint64_t disabled_features, uint64_t protocol_features); 456 int vhost_driver_unregister(const char *path); 457 int vhost_get_mem_table(int vid, struct rte_vhost_memory **mem); 458 int vhost_get_negotiated_features(int vid, uint64_t *negotiated_features); 459 460 int remove_vhost_controller(struct spdk_vhost_dev *vdev); 461 462 struct spdk_io_channel *vhost_blk_get_io_channel(struct spdk_vhost_dev *vdev); 463 void vhost_blk_put_io_channel(struct spdk_io_channel *ch); 464 465 /* The spdk_bdev pointer should only be used to retrieve 466 * the device properties, ex. number of blocks or I/O type supported. */ 467 struct spdk_bdev *vhost_blk_get_bdev(struct spdk_vhost_dev *vdev); 468 469 /* Function calls from vhost.c to rte_vhost_user.c, 470 * shall removed once virtio transport abstraction is complete. */ 471 int vhost_user_session_set_coalescing(struct spdk_vhost_dev *dev, 472 struct spdk_vhost_session *vsession, void *ctx); 473 int vhost_user_dev_set_coalescing(struct spdk_vhost_user_dev *user_dev, uint32_t delay_base_us, 474 uint32_t iops_threshold); 475 int vhost_user_dev_register(struct spdk_vhost_dev *vdev, const char *name, 476 struct spdk_cpuset *cpumask, const struct spdk_vhost_user_dev_backend *user_backend); 477 int vhost_user_dev_unregister(struct spdk_vhost_dev *vdev); 478 int vhost_user_init(void); 479 void vhost_user_fini(spdk_vhost_fini_cb vhost_cb); 480 int vhost_user_set_coalescing(struct spdk_vhost_dev *vdev, uint32_t delay_base_us, 481 uint32_t iops_threshold); 482 void vhost_user_get_coalescing(struct spdk_vhost_dev *vdev, uint32_t *delay_base_us, 483 uint32_t *iops_threshold); 484 485 int virtio_blk_construct_ctrlr(struct spdk_vhost_dev *vdev, const char *address, 486 struct spdk_cpuset *cpumask, const struct spdk_json_val *params, 487 const struct spdk_vhost_user_dev_backend *user_backend); 488 int virtio_blk_destroy_ctrlr(struct spdk_vhost_dev *vdev); 489 490 struct spdk_vhost_blk_task; 491 492 typedef void (*virtio_blk_request_cb)(uint8_t status, struct spdk_vhost_blk_task *task, 493 void *cb_arg); 494 495 struct spdk_vhost_blk_task { 496 struct spdk_bdev_io *bdev_io; 497 virtio_blk_request_cb cb; 498 void *cb_arg; 499 500 volatile uint8_t *status; 501 502 /* for io wait */ 503 struct spdk_bdev_io_wait_entry bdev_io_wait; 504 struct spdk_io_channel *bdev_io_wait_ch; 505 struct spdk_vhost_dev *bdev_io_wait_vdev; 506 507 /** Number of bytes that were written. */ 508 uint32_t used_len; 509 uint16_t iovcnt; 510 struct iovec iovs[SPDK_VHOST_IOVS_MAX]; 511 512 /** Size of whole payload in bytes */ 513 uint32_t payload_size; 514 }; 515 516 int virtio_blk_process_request(struct spdk_vhost_dev *vdev, struct spdk_io_channel *ch, 517 struct spdk_vhost_blk_task *task, virtio_blk_request_cb cb, void *cb_arg); 518 519 typedef void (*bdev_event_cb_complete)(struct spdk_vhost_dev *vdev, void *ctx); 520 521 #define SPDK_VIRTIO_BLK_TRSTRING_MAX_LEN 32 522 523 struct spdk_virtio_blk_transport_ops { 524 /** 525 * Transport name 526 */ 527 char name[SPDK_VIRTIO_BLK_TRSTRING_MAX_LEN]; 528 529 /** 530 * Create a transport for the given transport opts 531 */ 532 struct spdk_virtio_blk_transport *(*create)(const struct spdk_json_val *params); 533 534 /** 535 * Dump transport-specific opts into JSON 536 */ 537 void (*dump_opts)(struct spdk_virtio_blk_transport *transport, struct spdk_json_write_ctx *w); 538 539 /** 540 * Destroy the transport 541 */ 542 int (*destroy)(struct spdk_virtio_blk_transport *transport, 543 spdk_vhost_fini_cb cb_fn); 544 545 /** 546 * Create vhost block controller 547 */ 548 int (*create_ctrlr)(struct spdk_vhost_dev *vdev, struct spdk_cpuset *cpumask, 549 const char *address, const struct spdk_json_val *params, 550 void *custom_opts); 551 552 /** 553 * Destroy vhost block controller 554 */ 555 int (*destroy_ctrlr)(struct spdk_vhost_dev *vdev); 556 557 /* 558 * Signal removal of the bdev. 559 */ 560 void (*bdev_event)(enum spdk_bdev_event_type type, struct spdk_vhost_dev *vdev, 561 bdev_event_cb_complete cb, void *cb_arg); 562 563 /** 564 * Set coalescing parameters. 565 */ 566 int (*set_coalescing)(struct spdk_vhost_dev *vdev, uint32_t delay_base_us, 567 uint32_t iops_threshold); 568 569 /** 570 * Get coalescing parameters. 571 */ 572 void (*get_coalescing)(struct spdk_vhost_dev *vdev, uint32_t *delay_base_us, 573 uint32_t *iops_threshold); 574 }; 575 576 struct spdk_virtio_blk_transport { 577 const struct spdk_virtio_blk_transport_ops *ops; 578 TAILQ_ENTRY(spdk_virtio_blk_transport) tailq; 579 }; 580 581 struct virtio_blk_transport_ops_list_element { 582 struct spdk_virtio_blk_transport_ops ops; 583 TAILQ_ENTRY(virtio_blk_transport_ops_list_element) link; 584 }; 585 586 void virtio_blk_transport_register(const struct spdk_virtio_blk_transport_ops *ops); 587 int virtio_blk_transport_create(const char *transport_name, const struct spdk_json_val *params); 588 int virtio_blk_transport_destroy(struct spdk_virtio_blk_transport *transport, 589 spdk_vhost_fini_cb cb_fn); 590 struct spdk_virtio_blk_transport *virtio_blk_transport_get_first(void); 591 struct spdk_virtio_blk_transport *virtio_blk_transport_get_next( 592 struct spdk_virtio_blk_transport *transport); 593 void virtio_blk_transport_dump_opts(struct spdk_virtio_blk_transport *transport, 594 struct spdk_json_write_ctx *w); 595 struct spdk_virtio_blk_transport *virtio_blk_tgt_get_transport(const char *transport_name); 596 const struct spdk_virtio_blk_transport_ops *virtio_blk_get_transport_ops( 597 const char *transport_name); 598 599 void vhost_session_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w); 600 601 /* 602 * Macro used to register new transports. 603 */ 604 #define SPDK_VIRTIO_BLK_TRANSPORT_REGISTER(name, transport_ops) \ 605 static void __attribute__((constructor)) _virtio_blk_transport_register_##name(void) \ 606 { \ 607 virtio_blk_transport_register(transport_ops); \ 608 } 609 610 #endif /* SPDK_VHOST_INTERNAL_H */ 611