/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * mtip32xx.h - Header file for the P320 SSD Block Driver * Copyright (C) 2011 Micron Technology, Inc. * * Portions of this code were derived from works subjected to the * following copyright: * Copyright (C) 2009 Integrated Device Technology, Inc.
*/
/* Macro to extract the tag bit number from a tag value. */ #define MTIP_TAG_BIT(tag) (tag & 0x1F)
/* * Macro to extract the tag index from a tag value. The index * is used to access the correct s_active/Command Issue register based * on the tag value.
*/ #define MTIP_TAG_INDEX(tag) (tag >> 5)
/* * Maximum number of scatter gather entries * a single command may have.
*/ #define MTIP_MAX_SG 504
/* * Maximum number of slot groups (Command Issue & s_active registers) * NOTE: This is the driver maximum; check dd->slot_groups for actual value.
*/ #define MTIP_MAX_SLOT_GROUPS 8
/* Driver name and version strings */ #define MTIP_DRV_NAME "mtip32xx" #define MTIP_DRV_VERSION "1.3.1"
/* Maximum number of minor device numbers per device. */ #define MTIP_MAX_MINORS 16
/* Maximum number of supported command slots. */ #define MTIP_MAX_COMMAND_SLOTS (MTIP_MAX_SLOT_GROUPS * 32)
/* * Per-tag bitfield size in longs. * Linux bit manipulation functions * (i.e. test_and_set_bit, find_next_zero_bit) * manipulate memory in longs, so we try to make the math work. * take the slot groups and find the number of longs, rounding up. * Careful! i386 and x86_64 use different size longs!
*/ #define U32_PER_LONG (sizeof(long) / sizeof(u32)) #define SLOTBITS_IN_LONGS ((MTIP_MAX_SLOT_GROUPS + \
(U32_PER_LONG-1))/U32_PER_LONG)
/* BAR number used to access the HBA registers. */ #define MTIP_ABAR 5
/* Command header structure. */ struct mtip_cmd_hdr { /* * Command options. * - Bits 31:16 Number of PRD entries. * - Bits 15:8 Unused in this implementation. * - Bit 7 Prefetch bit, informs the drive to prefetch PRD entries. * - Bit 6 Write bit, should be set when writing data to the device. * - Bit 5 Unused in this implementation. * - Bits 4:0 Length of the command FIS in DWords (DWord = 4 bytes).
*/
__le32 opts; /* This field is unsed when using NCQ. */ union {
__le32 byte_count;
__le32 status;
}; /* * Lower 32 bits of the command table address associated with this * header. The command table addresses must be 128 byte aligned.
*/
__le32 ctba; /* * If 64 bit addressing is used this field is the upper 32 bits * of the command table address associated with this command.
*/
__le32 ctbau; /* Reserved and unused. */
u32 res[4];
};
/* Command scatter gather structure (PRD). */ struct mtip_cmd_sg { /* * Low 32 bits of the data buffer address. For P320 this * address must be 8 byte aligned signified by bits 2:0 being * set to 0.
*/
__le32 dba; /* * When 64 bit addressing is used this field is the upper * 32 bits of the data buffer address.
*/
__le32 dba_upper; /* Unused. */
__le32 reserved; /* * Bit 31: interrupt when this data block has been transferred. * Bits 30..22: reserved * Bits 21..0: byte count (minus 1). For P320 the byte count must be * 8 byte aligned signified by bits 2:0 being set to 1.
*/
__le32 info;
}; struct mtip_port;
struct mtip_int_cmd;
/* Structure used to describe a command. */ struct mtip_cmd { void *command; /* ptr to command table entry */
int scatter_ents; /* Number of scatter list entries used */
int unaligned; /* command is unaligned on 4k boundary */
union { struct scatterlist sg[MTIP_MAX_SG]; /* Scatter list entries */ struct mtip_int_cmd *icmd;
};
int retries; /* The number of retries left for this command. */
int direction; /* Data transfer direction */
blk_status_t status;
};
/* Structure used to describe a port. */ struct mtip_port { /* Pointer back to the driver data for this port. */ struct driver_data *dd; /* * Used to determine if the data pointed to by the * identify field is valid.
*/ unsignedlong identify_valid; /* Base address of the memory mapped IO for the port. */ void __iomem *mmio; /* Array of pointers to the memory mapped s_active registers. */ void __iomem *s_active[MTIP_MAX_SLOT_GROUPS]; /* Array of pointers to the memory mapped completed registers. */ void __iomem *completed[MTIP_MAX_SLOT_GROUPS]; /* Array of pointers to the memory mapped Command Issue registers. */ void __iomem *cmd_issue[MTIP_MAX_SLOT_GROUPS]; /* * Pointer to the beginning of the command header memory as used * by the driver.
*/ void *command_list; /* * Pointer to the beginning of the command header memory as used * by the DMA.
*/
dma_addr_t command_list_dma; /* * Pointer to the beginning of the RX FIS memory as used * by the driver.
*/ void *rxfis; /* * Pointer to the beginning of the RX FIS memory as used * by the DMA.
*/
dma_addr_t rxfis_dma; /* * Pointer to the DMA region for RX Fis, Identify, RLE10, and SMART
*/ void *block1; /* * DMA address of region for RX Fis, Identify, RLE10, and SMART
*/
dma_addr_t block1_dma; /* * Pointer to the beginning of the identify data memory as used * by the driver.
*/
u16 *identify; /* * Pointer to the beginning of the identify data memory as used * by the DMA.
*/
dma_addr_t identify_dma; /* * Pointer to the beginning of a sector buffer that is used * by the driver when issuing internal commands.
*/
u16 *sector_buffer; /* * Pointer to the beginning of a sector buffer that is used * by the DMA when the driver issues internal commands.
*/
dma_addr_t sector_buffer_dma;
u16 *log_buf;
dma_addr_t log_buf_dma;
u8 *smart_buf;
dma_addr_t smart_buf_dma;
/* * used to queue commands when an internal command is in progress * or error handling is active
*/ unsignedlong cmds_to_issue[SLOTBITS_IN_LONGS]; /* Used by mtip_service_thread to wait for an event */
wait_queue_head_t svc_wait; /* * indicates the state of the port. Also, helps the service thread * to determine its action on wake up.
*/ unsignedlong flags; /* * Timer used to complete commands that have been active for too long.
*/ unsignedlong ic_pause_timer;
/* Counter to control queue depth of unaligned IOs */
atomic_t cmd_slot_unal;
/* Spinlock for working around command-issue bug. */
spinlock_t cmd_issue_lock[MTIP_MAX_SLOT_GROUPS];
};
/* * Driver private data structure. * * One structure is allocated per probed device.
*/ struct driver_data { void __iomem *mmio; /* Base address of the HBA registers. */
int major; /* Major device number. */
int instance; /* Instance number. First device probed is 0, ... */
struct gendisk *disk; /* Pointer to our gendisk structure. */
struct pci_dev *pdev; /* Pointer to the PCI device structure. */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.