Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is part of the Chelsio FCoE driver for Linux.
0003  *
0004  * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved.
0005  *
0006  * This software is available to you under a choice of one of two
0007  * licenses.  You may choose to be licensed under the terms of the GNU
0008  * General Public License (GPL) Version 2, available from the file
0009  * COPYING in the main directory of this source tree, or the
0010  * OpenIB.org BSD license below:
0011  *
0012  *     Redistribution and use in source and binary forms, with or
0013  *     without modification, are permitted provided that the following
0014  *     conditions are met:
0015  *
0016  *      - Redistributions of source code must retain the above
0017  *        copyright notice, this list of conditions and the following
0018  *        disclaimer.
0019  *
0020  *      - Redistributions in binary form must reproduce the above
0021  *        copyright notice, this list of conditions and the following
0022  *        disclaimer in the documentation and/or other materials
0023  *        provided with the distribution.
0024  *
0025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0026  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0027  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0028  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0029  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0030  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0031  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0032  * SOFTWARE.
0033  */
0034 
0035 #ifndef __CSIO_INIT_H__
0036 #define __CSIO_INIT_H__
0037 
0038 #include <linux/pci.h>
0039 #include <linux/if_ether.h>
0040 #include <scsi/scsi.h>
0041 #include <scsi/scsi_device.h>
0042 #include <scsi/scsi_host.h>
0043 #include <scsi/scsi_transport_fc.h>
0044 
0045 #include "csio_scsi.h"
0046 #include "csio_lnode.h"
0047 #include "csio_rnode.h"
0048 #include "csio_hw.h"
0049 
0050 #define CSIO_DRV_AUTHOR         "Chelsio Communications"
0051 #define CSIO_DRV_DESC           "Chelsio FCoE driver"
0052 #define CSIO_DRV_VERSION        "1.0.0-ko"
0053 
0054 extern struct fc_function_template csio_fc_transport_funcs;
0055 extern struct fc_function_template csio_fc_transport_vport_funcs;
0056 
0057 void csio_fchost_attr_init(struct csio_lnode *);
0058 
0059 /* INTx handlers */
0060 void csio_scsi_intx_handler(struct csio_hw *, void *, uint32_t,
0061                    struct csio_fl_dma_buf *, void *);
0062 
0063 void csio_fwevt_intx_handler(struct csio_hw *, void *, uint32_t,
0064                 struct csio_fl_dma_buf *, void *);
0065 
0066 /* Common os lnode APIs */
0067 void csio_lnodes_block_request(struct csio_hw *);
0068 void csio_lnodes_unblock_request(struct csio_hw *);
0069 void csio_lnodes_block_by_port(struct csio_hw *, uint8_t);
0070 void csio_lnodes_unblock_by_port(struct csio_hw *, uint8_t);
0071 
0072 struct csio_lnode *csio_shost_init(struct csio_hw *, struct device *, bool,
0073                     struct csio_lnode *);
0074 void csio_shost_exit(struct csio_lnode *);
0075 void csio_lnodes_exit(struct csio_hw *, bool);
0076 
0077 /* DebugFS helper routines */
0078 void csio_add_debugfs_mem(struct csio_hw *, const char *,
0079         unsigned int, unsigned int);
0080 
0081 static inline struct Scsi_Host *
0082 csio_ln_to_shost(struct csio_lnode *ln)
0083 {
0084     return container_of((void *)ln, struct Scsi_Host, hostdata[0]);
0085 }
0086 
0087 /* SCSI -- locking version of get/put ioreqs  */
0088 static inline struct csio_ioreq *
0089 csio_get_scsi_ioreq_lock(struct csio_hw *hw, struct csio_scsim *scsim)
0090 {
0091     struct csio_ioreq *ioreq;
0092     unsigned long flags;
0093 
0094     spin_lock_irqsave(&scsim->freelist_lock, flags);
0095     ioreq = csio_get_scsi_ioreq(scsim);
0096     spin_unlock_irqrestore(&scsim->freelist_lock, flags);
0097 
0098     return ioreq;
0099 }
0100 
0101 static inline void
0102 csio_put_scsi_ioreq_lock(struct csio_hw *hw, struct csio_scsim *scsim,
0103              struct csio_ioreq *ioreq)
0104 {
0105     unsigned long flags;
0106 
0107     spin_lock_irqsave(&scsim->freelist_lock, flags);
0108     csio_put_scsi_ioreq(scsim, ioreq);
0109     spin_unlock_irqrestore(&scsim->freelist_lock, flags);
0110 }
0111 
0112 /* Called in interrupt context */
0113 static inline void
0114 csio_put_scsi_ioreq_list_lock(struct csio_hw *hw, struct csio_scsim *scsim,
0115                   struct list_head *reqlist, int n)
0116 {
0117     unsigned long flags;
0118 
0119     spin_lock_irqsave(&scsim->freelist_lock, flags);
0120     csio_put_scsi_ioreq_list(scsim, reqlist, n);
0121     spin_unlock_irqrestore(&scsim->freelist_lock, flags);
0122 }
0123 
0124 /* Called in interrupt context */
0125 static inline void
0126 csio_put_scsi_ddp_list_lock(struct csio_hw *hw, struct csio_scsim *scsim,
0127                   struct list_head *reqlist, int n)
0128 {
0129     unsigned long flags;
0130 
0131     spin_lock_irqsave(&hw->lock, flags);
0132     csio_put_scsi_ddp_list(scsim, reqlist, n);
0133     spin_unlock_irqrestore(&hw->lock, flags);
0134 }
0135 
0136 #endif /* ifndef __CSIO_INIT_H__ */