pointer arithmetic on void *
I'm working on understanding the final result of this code from ahci.c (it's libahci.c in newer kernels):
struct ata_queued_cmd {
...
unsigned int tag;
...
};struct ahci_port_priv {
...
void *cmd_tbl;
dma_addr_t cmd_tbl_dma;
...
};static void ahci_qc_prep( struct ata_queued_cmd *qc)
{
...
cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ;
...
}qc is a struct ata_queued_cmd object. I'm assuming qc->tag is the PxCI slot number which was found to be free for this command. Please correct me if I'm wrong. Furthermore, AHCI_CMD_TBL_SZ is defined as
enum {
...
AHCI_MAX_SG = 168, /* hardware max is 64K */
...
AHCI_CMD_TBL_HDR_SZ = 0x80,
AHCI_CMD_TBL_SZ = AHCI_CMD_TBL_HDR_SZ + (AHCI_MAX_SG * 16),
...
}The first question is, given the above definition for AHCI_MAX_SG, is this a limitation from within the Linux kernel? The comment alludes to this and the spec says 64k are allowed.
Next, is qc->tag the PxCI slot (open command slot)? Second, is this arithmetic supposed to get me to the start of a new command?
Andy