Skip to main content

Operations

Trait Operations 

Source
pub trait Operations:
    Sized
    + Send
    + Sync
    + 'static {
    type RegistrationData<'a>: Send + Sync + 'a
       where Self: 'a;

    const DEVICE_TYPE: DeviceType;

    // Required methods
    fn open<'a>(
        device: &Device<Self>,
        reg_data: &Self::RegistrationData<'a>,
    ) -> impl PinInit<Self, Error>;
    fn fw_rpc<'a>(
        this: Pin<&Self>,
        device: &Device<Self>,
        reg_data: &Self::RegistrationData<'a>,
        scope: RpcScope,
        rpc_buf: &mut [u8],
        max_output_len: usize,
    ) -> Result<FwRpcResponse, Error>;

    // Provided methods
    fn close<'a>(
        _this: Pin<&mut Self>,
        _device: &Device<Self>,
        _reg_data: &Self::RegistrationData<'a>,
    ) { ... }
    fn info<'a>(
        _this: Pin<&Self>,
        _device: &Device<Self>,
        _reg_data: &Self::RegistrationData<'a>,
    ) -> Result<KVec<u8>, Error> { ... }
}
Expand description

Trait implemented by each Rust driver that integrates with the fwctl subsystem.

The implementing type is the per-FD user context: one instance is created for each open() call and dropped when the FD is closed.

Each implementation corresponds to a specific device type and provides the vtable used by the core fwctl layer to manage per-FD user contexts and handle RPC requests.

Required Associated Constants§

Source

const DEVICE_TYPE: DeviceType

fwctl device type identifier.

Required Associated Types§

Source

type RegistrationData<'a>: Send + Sync + 'a where Self: 'a

Data owned by the Registration and accessible during callbacks.

The lifetime 'a is tied to the Registration scope (which lives within the parent bus device binding scope). Drivers use it to store references to resources bound to this scope, such as PCI BARs or typed bus device references.

Required Methods§

Source

fn open<'a>( device: &Device<Self>, reg_data: &Self::RegistrationData<'a>, ) -> impl PinInit<Self, Error>

Called when a new user context is opened.

Returns a PinInit initializer for Self. The instance is dropped automatically when the FD is closed (after close).

Source

fn fw_rpc<'a>( this: Pin<&Self>, device: &Device<Self>, reg_data: &Self::RegistrationData<'a>, scope: RpcScope, rpc_buf: &mut [u8], max_output_len: usize, ) -> Result<FwRpcResponse, Error>

Handle a userspace RPC request.

max_output_len is the size of the userspace output buffer. A driver may return a larger response to report the required size; the fwctl core copies only the bytes that fit and reports the full response length to userspace.

Provided Methods§

Source

fn close<'a>( _this: Pin<&mut Self>, _device: &Device<Self>, _reg_data: &Self::RegistrationData<'a>, )

Called when the user context is closed.

The driver may perform additional cleanup here that requires access to the owning Device. Self is dropped automatically after this returns.

Source

fn info<'a>( _this: Pin<&Self>, _device: &Device<Self>, _reg_data: &Self::RegistrationData<'a>, ) -> Result<KVec<u8>, Error>

Return device information to userspace.

The default implementation returns no device-specific data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§