The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/pms/freebsd/driver/ini/src/agtiapi.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*******************************************************************************
    2 **
    3 *Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved. 
    4 *
    5 *Redistribution and use in source and binary forms, with or without modification, are permitted provided 
    6 *that the following conditions are met: 
    7 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
    8 *2. Redistributions in binary form must reproduce the above copyright notice, 
    9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
   10 *
   11 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
   12 *
   13 *INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
   14 *ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
   15 *SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
   16 *OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   17 *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
   18 *THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
   19 **
   20 * $FreeBSD$
   21 **
   22 *******************************************************************************/
   23 
   24 #include <dev/pms/freebsd/driver/common/osenv.h>
   25 #include <dev/pms/freebsd/driver/common/ostypes.h>
   26 #include <dev/pms/freebsd/driver/common/osdebug.h>
   27 #include <dev/pms/freebsd/driver/ini/src/agdef.h>
   28 #include <dev/pms/freebsd/driver/common/lxcommon.h>
   29 #ifdef AGTIAPI_ISCSI
   30 #include "cmtypes.h"
   31 #include "bktypes.h"
   32 #endif
   33 #ifdef FDS_DM
   34 #include <dev/pms/RefTisa/discovery/api/dm.h>
   35 #endif
   36 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
   37 #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
   38 #include <dev/pms/RefTisa/tisa/api/titypes.h>
   39 #include <vm/uma.h>
   40 
   41 typedef u_int32_t atomic_t;
   42 
   43 #define atomic_set(p,v)         (*(p) = (v))
   44 #define atomic_read(p)          (*(p))
   45 #define atomic_inc(p)           atomic_add_int(p,1)
   46 #define atomic_dec(p)           atomic_subtract_int(p,1)
   47 #define atomic_add(n,p)         atomic_add_int(p,n)
   48 #define atomic_sub(n,p)         atomic_subtract_int(p,n)
   49 
   50 #define AGSCSI_INIT_XCHG_LEN  sizeof(tiScsiInitiatorRequest_t)
   51 #define AGSMP_INIT_XCHG_LEN   sizeof(tiSMPFrame_t)  
   52 #define CMND_DMA_UNMAP( pCard, cmnd )
   53 
   54 
   55 // define PMC lean flags used for bit operations to track dev listing state
   56 #define DPMC_LEANFLAG_NOAGDEVYT     2  // agDev handle not present yet
   57 #define DPMC_LEANFLAG_NOWWNLIST     4  // WWNList entry not present
   58 #define DPMC_LEANFLAG_AGDEVUSED     8  // agDev handle used
   59 #define DPMC_LEANFLAG_PDEVSUSED    16  // pDevice slot used
   60 
   61 typedef bus_dmamap_t dma_addr_t; // ##
   62 
   63 #define timer_list callout
   64 
   65 typedef struct ccb_hdr_s {
   66   void *next;
   67 } ccb_hdr_t;
   68 
   69 
   70 typedef struct _CCB {
   71   U32               targetId;
   72   U32               lun;
   73   U32               channel;
   74   U16               ccbStatus;
   75   U16               scsiStatus;
   76   U32               dataLen;
   77   U08               senseLen;
   78   U08               addrMode;
   79   U08               retryCount;
   80   U16               numSgElements;
   81   U32               flags;
   82   U32_64            dmaHandle;
   83   caddr_t           pSenseData;   // auto request sense data
   84   tiSgl_t          *sgList;           // [AGTIAPI_MAX_DMA_SEGS]
   85   bus_addr_t        tisgl_busaddr;
   86   //  dma_addr_t        sglDmaHandle;      // ## dmaHandle for sgList
   87   tiDeviceHandle_t *devHandle;
   88   struct _CCB      *pccbNext;
   89   struct _CCB      *pccbChainNext;    // forward link pointers
   90   struct scsi_cmnd *cmd;              // call back owner pointer
   91   struct _CCB      *pccbIO;           // for TM TARGET_RESET
   92   U32_64            startTime;
   93   tiIORequest_t     tiIORequest;
   94   tdIORequestBody_t tdIOReqBody;
   95   tiSuperScsiInitiatorRequest_t tiSuperScsiRequest;
   96   tiSMPFrame_t            tiSMPFrame;
   97 #ifdef CCBUILD_TEST_EPL
   98   caddr_t           epl_ptr;
   99   dma_addr_t        epl_dma_ptr;
  100 #endif
  101 
  102 #ifdef CCBUILD_TEST_DPL
  103   caddr_t           dplPtr;
  104   dma_addr_t        dplDma;
  105 #endif
  106 
  107 #if defined (PERF_COUNT)
  108   u64               startCmnd;         // temp var to hold cmnd arrival
  109 #endif
  110 #ifdef ENABLE_NONSTANDARD_SECTORS
  111   caddr_t           metaPtr;
  112   dma_addr_t        dmaHandleMeta;
  113 #endif
  114 #ifdef ENABLE_SATA_DIF
  115   caddr_t           holePtr;
  116   dma_addr_t        dmaHandleHole;
  117   int               scaling_done;
  118 #endif
  119 
  120 #ifdef SUPER_FAST_IO_TEST 
  121   agsaIORequest_t      IoContext;
  122   agsaSASRequestBody_t sasRequestBody;
  123   u32                  reqType;
  124   u32                  queueId;
  125   agsaSgl_t           *sgl; // Used for esgl
  126 #endif
  127   //new
  128   bus_dmamap_t          CCB_dmamap;
  129   union ccb           *ccb; /* replacement of struct scsi_cmnd */
  130   struct agtiapi_softc *pmcsc;
  131  
  132 } ccb_t, *pccb_t;
  133 
  134 
  135 #define AGTIAPI_CCB_SIZE  sizeof(struct _CCB)
  136 
  137 /*
  138 typedef struct _ag_portal_data
  139 {
  140   ag_portal_info_t    portalInfo;
  141   void                *pCard;
  142 } ag_portal_data_t;
  143 */
  144 
  145 typedef enum {
  146         DEK_TABLE_0 = 0,
  147         DEK_TABLE_1 = 1,
  148         DEK_TABLE_INVALID = DEK_MAX_TABLES,
  149      } dek_table_e;
  150 
  151 typedef struct ag_encrypt_map_s {
  152         unsigned long long lbaMin;
  153         unsigned long long lbaMax;
  154         dek_table_e        dekTable;
  155         bit32              dekIndex;
  156         bit32              kekIndex;
  157         bit32              kekTagCheck;
  158         bit32              kekTag[2];
  159         struct list_head   *list;
  160     } ag_encrypt_map_t;
  161 
  162 typedef struct ag_kek_table_s {
  163  #define KEK_TABLE_MAX_ENTRY  8
  164         bit32              wrapperIndex;
  165         tiEncryptKekBlob_t kekBlob;
  166    } ag_kek_table_t;
  167 
  168 typedef struct ag_dek_kek_map_s {
  169         bit32             kekIndex;
  170    } ag_dek_kek_map_t;
  171 
  172 /*
  173 ** There is no LUN filed for the device structure.
  174 ** The reason is if the device is a single lun device, it
  175 ** will be lun 0.  If is a multi-lun device such as EMC 
  176 ** or Galaxi, only one device structure is associated with
  177 ** the device since only one device handler is provided.
  178 */
  179 typedef struct _ag_device {
  180 //#ifdef HOTPLUG_SUPPORT 
  181   /* used for hot-plug, temporarily either in new or removed devices list */
  182   LINK_NODE           devLink;  
  183 //#endif
  184   U32                 targetId;
  185   U32                 flags;
  186   U16                 devType;
  187   U16                 resetCount;
  188   U32                 portalId;
  189   void               *pCard;
  190   U32                 sector_size;
  191   U32                 CCBCount;
  192 #ifdef HOTPLUG_SUPPORT
  193   struct scsi_device *sdev;
  194 #endif
  195   tiDeviceHandle_t   *pDevHandle;
  196   tiDeviceInfo_t      devInfo;
  197   ag_portal_info_t   *pPortalInfo;
  198   U08                 targetName[AGTIAPI_MAX_NAME];
  199   U16                 targetLen;
  200   U32                     qbusy;
  201   U32                     qdepth;
  202 } ag_device_t;
  203 
  204 
  205 /*      
  206 ** Use an array of these structures to map from assigned
  207 ** device target id (which is the index into the array) to
  208 ** the entry in the bd_devlist.
  209 **
  210 ** Please note that an extra entry has been added to both
  211 ** the bd_devlist array and the bd_WWN_list.  This last
  212 ** entry is the "no mapping" entry -- used for initialization
  213 ** and to indicate an inactive entry.
  214 */
  215 typedef struct _ag_tgt_map { 
  216   U16      devListIndex;
  217   U16      flags;
  218   U08      targetName[AGTIAPI_MAX_NAME];
  219   U16      targetLen;
  220   U08      portId;
  221   int      sasLrIdx; // Index into SAS Local/Remote list (part of extend-portID)
  222   uint32_t devRemoved; // when set, ghost target device is timing out
  223 } ag_tgt_map_t;
  224 
  225 
  226 // use an array of this struct to map local/remote dyads to ag_tgt_map_t
  227 // entries
  228 typedef struct _ag_slr_map {
  229   U08  localeName[AGTIAPI_MIN_NAME];
  230   U08  remoteName[AGTIAPI_MAX_NAME];
  231   int  localeNameLen;
  232   int  remoteNameLen;
  233 } ag_slr_map_t;
  234 
  235 
  236 #ifdef LINUX_PERBI_SUPPORT
  237 // Use a list of these structures to hold target-WWN
  238 // mapping assignments on the boot line during driver
  239 // loading.
  240 typedef struct _ag_mapping_s 
  241 {
  242   struct _ag_mapping_s *next;
  243   U16                   targetId;
  244   U08                   cardNo;
  245   U08                   targetLen;
  246   U08                   targetName[AGTIAPI_MAX_NAME];
  247 } ag_mapping_t;
  248 #endif
  249 
  250 typedef struct _ag_portal_data
  251 {
  252   ag_portal_info_t    portalInfo;
  253   void               *pCard;
  254 } ag_portal_data_t;
  255 
  256 
  257 // The softc holds our per-instance data
  258 struct agtiapi_softc {
  259   device_t            my_dev;
  260   struct cdev        *my_cdev;
  261   struct cam_sim     *sim;
  262   struct cam_path    *path;
  263   struct resource    *resirq;
  264   void               *intr_cookie;
  265 
  266   int                 rscID[MAX_MSIX_NUM_VECTOR];
  267   struct resource    *irq[MAX_MSIX_NUM_VECTOR];
  268   void               *intrcookie[MAX_MSIX_NUM_VECTOR];
  269 
  270   // timer stuff; mc lean
  271   bus_dma_tag_t       buffer_dmat;
  272   struct cam_devq    *devq;
  273   struct callout      OS_timer;
  274   struct mtx          OS_timer_lock;
  275   struct callout      IO_timer;
  276   struct mtx          IO_timer_lock;
  277   struct callout      devRmTimer;
  278   struct mtx          devRmTimerLock;
  279   uint16_t            rmChkCt;
  280 
  281   // for tiSgl_t memory
  282   tiSgl_t            *tisgl_mem;
  283   bus_addr_t          tisgl_busaddr;
  284   bus_dma_tag_t       tisgl_dmat;
  285   bus_dmamap_t        tisgl_map;
  286 
  287   // for ostiAllocMemory() pre allocation pool
  288   void               *osti_mem;
  289   bus_addr_t          osti_busaddr;
  290   bus_dma_tag_t       osti_dmat;
  291   bus_dmamap_t        osti_mapp;
  292 
  293   // pre-allocation pool
  294   U32                 typhn; // size needed
  295   void               *typh_mem;
  296   bus_addr_t          typh_busaddr;
  297   bus_dma_tag_t       typh_dmat;
  298   bus_dmamap_t        typh_mapp;
  299   U32                 typhIdx;
  300   U32                 tyPhsIx;
  301 
  302 
  303   // begin ag_card_t references (AKA pCard)
  304   struct Scsi_Host   *pHost;
  305   tiRoot_t            tiRoot;             // tiRoot for the card
  306   U32                 VidDid;
  307   U32                 SVID_SSID;
  308   U32                 flags;              // keep track of state
  309   U32                 freezeSim;
  310   U32                 up_count;
  311   U32                 down_count;
  312   U08                 hostNo;             // host number signed by OS
  313   U08                 cardNo;             // host no signed by driver
  314   U16                 tgtCount;           // total target devices
  315   U16                 badTgtCount;        // total bad target devices
  316   U16                 activeCCB;          // number of active CCB
  317   U32                 ccbTotal;           // total # of CCB allocated
  318   U32                 devDiscover;        // # of device to be discovered
  319   U32                 resetCount;
  320   U32                 timeoutTicks;
  321   U32                 portCount;          // portal count
  322   U32                 SimQFrozen;         // simq frozen state
  323   U32                 devq_flag;      //device busy flag 
  324   U32                 dev_scan;           //device ready 
  325   pccb_t              ccbSendHead;        // CCB send list head
  326   pccb_t              ccbSendTail;        // CCB send list tail
  327   pccb_t              ccbDoneHead;        // CCB done list head
  328   pccb_t              ccbDoneTail;        // CCB done list tail
  329   pccb_t              smpSendHead;        // CCB send list head
  330   pccb_t              smpSendTail;        // CCB send list tail
  331   pccb_t              smpDoneHead;        // CCB done list head
  332   pccb_t              smpDoneTail;        // CCB done list tail
  333   caddr_t            *ccbChainList;       // ccb chain list head
  334   caddr_t            *ccbFreeList;        // free ccb list head
  335   ccb_hdr_t          *ccbAllocList;       // ### ccb allocation chain list head
  336   struct pci_pool    *sglPool;            // for SGL pci_alloc_consistent
  337   struct timer_list   osTimerList;        // card timer list
  338 #ifdef TD_TIMER
  339   struct timer_list   tdTimerList;        // tdlayer timer list
  340 #endif
  341   struct timer_list   tiTimerList;        // tilayer timer list
  342   ag_portal_data_t   *pPortalData;        // wrapper
  343   ag_card_info_t     *pCardInfo;
  344   ag_device_t        *pDevList;
  345 
  346 #define CIPHER_MODE_INVALID 0xffffffffUL
  347 #define DEK_INDEX_INVALID   0xffffffffUL
  348 #define KEK_INDEX_INVALID   0xffffffffUL
  349   int                 encrypt;            // enable/disable encryption flag
  350   bit32               dek_size;           // size of dek
  351   void               *ioctl_data;         // encryption ioctl data pointer
  352 
  353   struct list_head   *encrypt_map;        // encryption map
  354   ag_kek_table_t      kek_table[KEK_TABLE_MAX_ENTRY];
  355   // KEK table
  356   ag_dek_kek_map_t    dek_kek_map[DEK_MAX_TABLES][DEK_MAX_TABLE_ITEMS];
  357   // storage for dek index in tables (sysfs)
  358   int                 dek_index[2];
  359 #define DEK_SIZE_PLAIN   72
  360 #define DEK_SIZE_ENCRYPT 80
  361 #define ENCRYPTION_MAP_MEMPOOL_SIZE 64
  362   char                map_cache_name[32]; // name of mapping memory pool
  363   struct kmem_cache  *map_cache;          // handle to mapping cache
  364   bit32               cipher_mode;        // storage of cipher mode
  365 #define ENCRYPTION_IO_ERR_MEMPOOL_SIZE 256
  366   struct mtx          ioerr_queue_lock;
  367   char                ioerr_cache_name[32];
  368   struct kmem_cache  *ioerr_cache;        // handle to IO error cache
  369 
  370 //#ifdef LINUX_PERBI_SUPPORT
  371   ag_tgt_map_t       *pWWNList;
  372   ag_slr_map_t       *pSLRList;           // SAS Local/Remote map list
  373   U32                 numTgtHardMapped;   // hard mapped target number
  374 //#endif
  375   struct sema            *pIoctlSem;         // for ioctl sync.
  376   U32_64              osLockFlag;         // flag for oslayer spin lock TBU
  377 #ifdef AGTIAPI_LOCAL_LOCK
  378   struct mtx          sendLock;           // local queue lock
  379   struct mtx          doneLock;           // local queue lock
  380   struct mtx          sendSMPLock;        // local queue lock
  381   struct mtx          doneSMPLock;        // local queue lock
  382   struct mtx          ccbLock;            // ccb list lock
  383   struct mtx         *STLock;             // Low Level & TD locks
  384   unsigned long      *STLockFlags;        // Low Level & TD locks flags
  385   struct mtx          memLock;            // dynamic memory allocation lock
  386   struct mtx          freezeLock;
  387 #endif
  388 #ifdef AGTIAPI_DPC                        // card deferred intr process tasklet
  389   struct callout      tasklet_dpc[MAX_MSIX_NUM_DPC];
  390 #endif
  391 //#ifdef HOTPLUG_SUPPORT
  392   struct mtx          devListLock;        // device lists lock
  393 //#endif
  394 
  395 };
  396 
  397 int agtiapi_getdevlist( struct agtiapi_softc *pCard,
  398                         tiIOCTLPayload_t *agIOCTLPayload );
  399 int agtiapi_getCardInfo ( struct agtiapi_softc      *pCard,
  400                           U32_64                        size,
  401                           void                        *buffer );
  402 
  403 #ifndef LINUX_PERBI_SUPPORT
  404 #define INDEX(_pCard, _T)   (_T)
  405 #else
  406 #define INDEX(_pCard, _T)   (((_pCard)->pWWNList + (_T))->devListIndex)
  407 #endif
  408 

Cache object: ae4cda3ef8bfefc24fe2157470e2f163


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.