Skip to content
bgoglin edited this page May 29, 2012 · 6 revisions

Things you should know when creating/updating a CTP

Starting

Copy the template directory and modify it

Plugin structure

Priority should be 30 for software devices and 50 for hardware-based devices so that hardware is used when available.

There is no get_devices() callback anymore.

CTP init()

Takes the plugin as a parameter.

If globals->configfile is not set, the CTP should create default device(s) automatically. Otherwise, the CTP should traverse the configfile_devs TAILQ, find devices that it owns, and dequeue them.

Once we have a device (either dequeued or created), we must:

  • set dev->plugin = plugin
  • if globals->configfile is not set
  • set dev->priority to plugin priority
  • set device->transport to the driver name
  • otherwise, only set it to plugin priority if dev->priority is -1 (not specified in the configfile)
  • initialize up/default fields if needed
  • initialize pci info if known (or keep all fields -1 if unknown)
  • initialize rate if known (or keep it 0 if unknown)
  • last step: call cci__add_dev() to enqueue the device in the main TAILQ

CTP finalize()

Takes the plugin as a parameter.

Must traverse the device list and free dev->priv if device->transport equals the transport name

Connections

CTP must set conn->plugin = ep->plugin before returning connections to the application

Const changes (2012/03/16 + fix on 2012/04/03)

Most prototypes were changed with proper const attributes. Most public typedefs (cci_device_t, cci_endpoint_t, cci_connection_t, cci_event_t) now embed a const attribute. This means the application manipulates const things without having to specify it. Internally, CTPs should rather use struct foo instead of foo_t so that things are not const and can be modified.