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

Function vhost_user_msg_handler

dpdk/lib/vhost/vhost_user.c:3063–3311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3061}
3062
3063int
3064vhost_user_msg_handler(int vid, int fd)
3065{
3066 struct virtio_net *dev;
3067 struct vhu_msg_context ctx;
3068 vhost_message_handler_t *msg_handler;
3069 struct rte_vdpa_device *vdpa_dev;
3070 int msg_result = RTE_VHOST_MSG_RESULT_OK;
3071 int ret;
3072 int unlock_required = 0;
3073 bool handled;
3074 uint32_t request;
3075 uint32_t i;
3076 uint16_t blk_call_fd;
3077
3078 dev = get_device(vid);
3079 if (dev == NULL)
3080 return -1;
3081
3082 if (!dev->notify_ops) {
3083 dev->notify_ops = vhost_driver_callback_get(dev->ifname);
3084 if (!dev->notify_ops) {
3085 VHOST_LOG_CONFIG(dev->ifname, ERR,
3086 "failed to get callback ops for driver\n");
3087 return -1;
3088 }
3089 }
3090
3091 ctx.msg.request.frontend = VHOST_USER_NONE;
3092 ret = read_vhost_message(dev, fd, &ctx);
3093 if (ret == 0) {
3094 VHOST_LOG_CONFIG(dev->ifname, INFO, "vhost peer closed\n");
3095 return -1;
3096 }
3097
3098 request = ctx.msg.request.frontend;
3099 if (request > VHOST_USER_NONE && request < RTE_DIM(vhost_message_handlers))
3100 msg_handler = &vhost_message_handlers[request];
3101 else
3102 msg_handler = NULL;
3103
3104 if (ret < 0) {
3105 VHOST_LOG_CONFIG(dev->ifname, ERR, "vhost read message %s%s%sfailed\n",
3106 msg_handler != NULL ? "for " : "",
3107 msg_handler != NULL ? msg_handler->description : "",
3108 msg_handler != NULL ? " " : "");
3109 return -1;
3110 }
3111
3112 if (msg_handler != NULL && msg_handler->description != NULL) {
3113 if (request != VHOST_USER_IOTLB_MSG)
3114 VHOST_LOG_CONFIG(dev->ifname, INFO,
3115 "read message %s\n",
3116 msg_handler->description);
3117 else
3118 VHOST_LOG_CONFIG(dev->ifname, DEBUG,
3119 "read message %s\n",
3120 msg_handler->description);

Callers 1

vhost_user_read_cbFunction · 0.85

Calls 12

get_deviceFunction · 0.85
read_vhost_messageFunction · 0.85
send_vhost_replyFunction · 0.85
validate_msg_fdsFunction · 0.85
close_msg_fdsFunction · 0.85
vq_is_readyFunction · 0.85
virtio_is_readyFunction · 0.85

Tested by

no test coverage detected