linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pointer arithmetic on void *
@ 2015-12-11  0:42 Andy Falanga (afalanga)
  0 siblings, 0 replies; only message in thread
From: Andy Falanga (afalanga) @ 2015-12-11  0:42 UTC (permalink / raw)
  To: linux-ide@vger.kernel.org

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-11  0:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-11  0:42 pointer arithmetic on void * Andy Falanga (afalanga)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).