| 202 | } |
| 203 | |
| 204 | static int |
| 205 | start_vdpa(struct vdpa_port *vport) |
| 206 | { |
| 207 | uint32_t device_type = 0; |
| 208 | int ret; |
| 209 | char *socket_path = vport->ifname; |
| 210 | |
| 211 | if (client_mode) |
| 212 | vport->flags |= RTE_VHOST_USER_CLIENT; |
| 213 | |
| 214 | vport->flags |= RTE_VHOST_USER_IOMMU_SUPPORT; |
| 215 | |
| 216 | if (access(socket_path, F_OK) != -1 && !client_mode) { |
| 217 | RTE_LOG(ERR, VDPA, |
| 218 | "%s exists, please remove it or specify another file and try again.\n", |
| 219 | socket_path); |
| 220 | return -1; |
| 221 | } |
| 222 | ret = rte_vhost_driver_register(socket_path, vport->flags); |
| 223 | if (ret != 0) |
| 224 | rte_exit(EXIT_FAILURE, |
| 225 | "register driver failed: %s\n", |
| 226 | socket_path); |
| 227 | |
| 228 | ret = rte_vhost_driver_callback_register(socket_path, |
| 229 | &vdpa_sample_devops); |
| 230 | if (ret != 0) |
| 231 | rte_exit(EXIT_FAILURE, |
| 232 | "register driver ops failed: %s\n", |
| 233 | socket_path); |
| 234 | |
| 235 | ret = rte_vhost_driver_attach_vdpa_device(socket_path, vport->dev); |
| 236 | if (ret != 0) |
| 237 | rte_exit(EXIT_FAILURE, |
| 238 | "attach vdpa device failed: %s\n", |
| 239 | socket_path); |
| 240 | |
| 241 | ret = rte_vhost_driver_get_vdpa_dev_type(socket_path, &device_type); |
| 242 | if (ret == 0 && device_type == RTE_VHOST_VDPA_DEVICE_TYPE_BLK) { |
| 243 | RTE_LOG(NOTICE, VDPA, "%s is a blk device\n", socket_path); |
| 244 | ret = vdpa_blk_device_set_features_and_protocol(socket_path); |
| 245 | if (ret != 0) |
| 246 | rte_exit(EXIT_FAILURE, |
| 247 | "set vhost blk driver features and protocol features failed: %s\n", |
| 248 | socket_path); |
| 249 | } |
| 250 | |
| 251 | if (rte_vhost_driver_start(socket_path) < 0) |
| 252 | rte_exit(EXIT_FAILURE, |
| 253 | "start vhost driver failed: %s\n", |
| 254 | socket_path); |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | static void |
| 259 | close_vdpa(struct vdpa_port *vport) |
no test coverage detected