MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vdev_action

Function vdev_action

dpdk/drivers/bus/vdev/vdev.c:408–463  ·  view source on GitHub ↗

* This function works as the action for both primary and secondary process * for static vdev discovery when a secondary process is booting. * * step 1, secondary process sends a sync request to ask for vdev in primary; * step 2, primary process receives the request, and send vdevs one by one; * step 3, primary process sends back reply, which indicates how many vdevs * are sent. */

Source from the content-addressed store, hash-verified

406 * are sent.
407 */
408static int
409vdev_action(const struct rte_mp_msg *mp_msg, const void *peer)
410{
411 struct rte_vdev_device *dev;
412 struct rte_mp_msg mp_resp;
413 struct vdev_param *ou = (struct vdev_param *)&mp_resp.param;
414 const struct vdev_param *in = (const struct vdev_param *)mp_msg->param;
415 const char *devname;
416 int num;
417 int ret;
418
419 strlcpy(mp_resp.name, VDEV_MP_KEY, sizeof(mp_resp.name));
420 mp_resp.len_param = sizeof(*ou);
421 mp_resp.num_fds = 0;
422
423 switch (in->type) {
424 case VDEV_SCAN_REQ:
425 ou->type = VDEV_SCAN_ONE;
426 ou->num = 1;
427 num = 0;
428
429 rte_spinlock_recursive_lock(&vdev_device_list_lock);
430 TAILQ_FOREACH(dev, &vdev_device_list, next) {
431 devname = rte_vdev_device_name(dev);
432 if (strlen(devname) == 0) {
433 VDEV_LOG(INFO, "vdev with no name is not sent");
434 continue;
435 }
436 VDEV_LOG(INFO, "send vdev, %s", devname);
437 strlcpy(ou->name, devname, RTE_DEV_NAME_MAX_LEN);
438 if (rte_mp_sendmsg(&mp_resp) < 0)
439 VDEV_LOG(ERR, "send vdev, %s, failed, %s",
440 devname, strerror(rte_errno));
441 num++;
442 }
443 rte_spinlock_recursive_unlock(&vdev_device_list_lock);
444
445 ou->type = VDEV_SCAN_REP;
446 ou->num = num;
447 if (rte_mp_reply(&mp_resp, peer) < 0)
448 VDEV_LOG(ERR, "Failed to reply a scan request");
449 break;
450 case VDEV_SCAN_ONE:
451 VDEV_LOG(INFO, "receive vdev, %s", in->name);
452 ret = insert_vdev(in->name, NULL, NULL, false);
453 if (ret == -EEXIST)
454 VDEV_LOG(DEBUG, "device already exist, %s", in->name);
455 else if (ret < 0)
456 VDEV_LOG(ERR, "failed to add vdev, %s", in->name);
457 break;
458 default:
459 VDEV_LOG(ERR, "vdev cannot recognize this message");
460 }
461
462 return 0;
463}
464
465static int

Callers

nothing calls this directly

Calls 7

rte_vdev_device_nameFunction · 0.85
insert_vdevFunction · 0.85
rte_mp_replyClass · 0.70
strlcpyFunction · 0.50
rte_mp_sendmsgFunction · 0.50

Tested by

no test coverage detected