SIM Registration Routines

As alluded to previously, registering a SIM with the CAM subsystem involves three functions:

  • cam_simq_alloc

  • cam_sim_alloc

  • xpt_bus_register

cam_simq_alloc Function

The cam_simq_alloc function allocates a SIM queue.

#include <cam/cam_sim.h>
#include <cam/cam_queue.h>

struct cam_devq *
cam_simq_alloc(u_int32_t max_sim_transactions);

Here, max_sim_transactions denotes the size of the SIM queue. Normally, it is calculated like so:

max_sim_transactions = number_of_supported_devices *
    number_of_commands_that_can_be_concurrently_processed_per_device;

cam_sim_alloc Function

The cam_sim_alloc function allocates a SIM (or bus) descriptor.

Note

If an HBA implements multiple buses (or channels), each bus requires its own descriptor.

#include <sys/param.h>
#include <sys/lock.h>
#include <sys/mutex.h>

#include <cam/cam_sim.h>
#include <cam/cam_queue.h>

struct cam_sim *
cam_sim_alloc(sim_action_func sim_action, sim_poll_func sim_poll,
    const char *sim_name, void *softc, u_int32_t unit, struct mtx *mtx,
    int max_dev_transactions, int max_tagged_dev_transactions,
    struct cam_devq *queue);

Because the first six arguments to cam_sim_alloc are fairly obvious—they’re exactly what their name implies—I’ll omit discussing them.

The max_dev_transactions argument specifies the maximum number of concurrent transactions per device. This argument applies only to devices that do not support SCSI Tagged Command Queuing (SCSI TCQ). Generally, max_dev_transactions is always set to 1.

The max_tagged_dev_transactions argument is identical to max_dev_transactions, but it applies only to devices that support SCSI TCQ.

The queue argument expects a pointer to a SIM queue (that is, cam_simq_alloc’s return value).

xpt_bus_register Function

The xpt_bus_register function registers a SIM with the CAM subsystem.

#include <cam/cam_sim.h>
#include <cam/cam_xpt_sim.h>

int32_t
xpt_bus_register(struct cam_sim *sim, device_t parent, u_int32_t bus)

Here, sim specifies the SIM to register (that is, cam_sim_alloc’s return value) and bus denotes its bus number. The parent argument is currently unused.

Note

If an HBA implements multiple buses (or channels), each bus needs its own unique bus number.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.52.86