Hi Xie, (2014/11/08 5:43), Xie, Huawei wrote: >> -struct vhost_net_device_ops const *get_virtio_net_callbacks(void); >> +struct vhost_net_device_ops const *get_virtio_net_callbacks( >> + vhost_driver_type_t type); > Tetsuya: > I feel currently it is better we still keep the common > get_virtio_net_callbacks(). > For the message flow from control layer 1 (cuse ioctl or user sock message > recv/xmit)---> cuse/user local message handling layer 2-> common virtio > message handling layer 3 > Layer 1 and layer 2 belong to one module. It is that module's choice whether > to implement callbacks between internal layer1 and layer2. We don't need to > force that. > Besides, even that module wants to define the ops between layer 1 and layer2, > the interface could be different between cuse/user. > Refer to the following code for user: > > vhost-user-server.c: > case VHOST_USER_SET_MEM_TABLE: > user_set_mem_table(ctx, &msg) > > virtio-net-user.c: > user_set_mem_table(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg) > { > > .... > > ops->set_mem_table(ctx, regions, memory.nregions); > } > > I may misunderstand what you say, please let me know in the case. I guess it's difficult to remove 'vhost_driver_type_t' from 'get_virtio_net_callbacks()'. In original vhost example code, there are 2 layers related with initialization as you mentioned. + Layer1: cuse ioctl handling layer. + Layer2: vhost-cuse( = vhost-net) message handling layer.
Layer1 needs function pointers to call Layer2 functions. 'get_virtio_net_callbacks()' is used for that purpose. My RFC is based on above, but Layer1/2 are abstracted to hide vhost-cuse and vhost-user. + Layer1: device control abstraction layer. -- Layer1-a: cuse ioctl handling layer. -- Layer1-b: unix domain socket handling layer. + Layer2: message handling abstraction layer. -- Layer2-a: vhost-cuse(vhost-net) message handling layer. -- Layer2-b: vhost-user message handling layer. Still Layer1 needs function pointers of Layer2. So, anyway, we still need to implement 'get_virtio_net_callbacks()'. Also, as you mentioned, function definition and behavior are different between Layer2-a and Lanyer2-b like 'user_set_mem_table()'. Because of this, 'get_virtio_net_callbacks()' need to return collect function pointers to Layer1. So I guess 'get_virtio_net_callbacks()' needs 'vhost_driver_type_t' to know which function pointers are needed by Layer1. If someone wants to implement new vhost-backend, of course they can implement Layer2 implementation and Layer1 together. In the case, they doesn't need to call 'get_virtio_net_callbacks()'. Also they can reuse existing Layer2 implementation by calling 'get_virtio_net_callbacks()' with existing driver type, or they can implement a new Layer2 implementation for new vhost-backend. BTW, the name of 'vhost_driver_type_t' is redundant, I will change the name. Tetsuya