Re: [RFC] rdma/uverbs: Sketch for an ioctl framework

Jason Gunthorpe
2016-05-25T20:51:56Z

On Wed, May 25, 2016 at 07:59:29PM +0000, Hefty, Sean wrote:
> > It is time for the people who are hand waving about non-verbs, non-qp,
> > 'new data transfers' to sit down and specify what they want to see out
> > of the kernel uABI.
>
> I want the core ioctl framework to do this:
>
> 1. Map user objects to/from the kernel to validate pointers.
> 2. Provide reference counting on such objects, in order to protect against the user attempting to destroy objects that are in use.
> 3. Provide protection that the state of an object is not driven in two different directions.
> 4. Safely process the removal of the underlying driver or device.
> 5. Support driver specific operations to the kernel.
> 6. Report events from multiple sources to a single file descriptor.
> 7. Minimize the kernel footprint for allocated kernel objects.
> 8. Minimize the code path needed to process any ioctl, without greatly affecting maintainability.
> 9. Copy ioctl input/output data to/from the kernel.

I agree with all of this as a suitable goal for the common
dispatch/marshal framework.

I like the idea of the generic uobject stuff in your patches.

#6 seems 'not like the others' - seems like a reasonable concrete
thing to consider as we build the objects on the
framework. [understanding that compat operation is still required]

> I started re-working my patch to address the rdma cm. The original
> proposal wasn't generic enough and provided a poor fit, because the
> rdma cm has a single object and 25 versions of 'modify'.

I was imagining that all objects would be able to have a set of object
specific functions beyond the common set. IIRC some verbs objects will
need this as well, and I expect drivers to want it.

This is why I wasn't thinking of using the ioctl # to dispatch the
method. It is best if the driver specific calls have globally unique
identifiers of some sort to protect against calling a method on the
wrong driver.

I would encourage you to go as far as Mellanox's series does and
demonstrate the verbs context object in this framework ...

Jason