1a3667aaeSNaresh Kumar Inna /*
2a3667aaeSNaresh Kumar Inna * This file is part of the Chelsio FCoE driver for Linux.
3a3667aaeSNaresh Kumar Inna *
4a3667aaeSNaresh Kumar Inna * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved.
5a3667aaeSNaresh Kumar Inna *
6a3667aaeSNaresh Kumar Inna * This software is available to you under a choice of one of two
7a3667aaeSNaresh Kumar Inna * licenses. You may choose to be licensed under the terms of the GNU
8a3667aaeSNaresh Kumar Inna * General Public License (GPL) Version 2, available from the file
9a3667aaeSNaresh Kumar Inna * COPYING in the main directory of this source tree, or the
10a3667aaeSNaresh Kumar Inna * OpenIB.org BSD license below:
11a3667aaeSNaresh Kumar Inna *
12a3667aaeSNaresh Kumar Inna * Redistribution and use in source and binary forms, with or
13a3667aaeSNaresh Kumar Inna * without modification, are permitted provided that the following
14a3667aaeSNaresh Kumar Inna * conditions are met:
15a3667aaeSNaresh Kumar Inna *
16a3667aaeSNaresh Kumar Inna * - Redistributions of source code must retain the above
17a3667aaeSNaresh Kumar Inna * copyright notice, this list of conditions and the following
18a3667aaeSNaresh Kumar Inna * disclaimer.
19a3667aaeSNaresh Kumar Inna *
20a3667aaeSNaresh Kumar Inna * - Redistributions in binary form must reproduce the above
21a3667aaeSNaresh Kumar Inna * copyright notice, this list of conditions and the following
22a3667aaeSNaresh Kumar Inna * disclaimer in the documentation and/or other materials
23a3667aaeSNaresh Kumar Inna * provided with the distribution.
24a3667aaeSNaresh Kumar Inna *
25a3667aaeSNaresh Kumar Inna * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26a3667aaeSNaresh Kumar Inna * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27a3667aaeSNaresh Kumar Inna * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28a3667aaeSNaresh Kumar Inna * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29a3667aaeSNaresh Kumar Inna * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30a3667aaeSNaresh Kumar Inna * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31a3667aaeSNaresh Kumar Inna * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32a3667aaeSNaresh Kumar Inna * SOFTWARE.
33a3667aaeSNaresh Kumar Inna */
34a3667aaeSNaresh Kumar Inna
35a3667aaeSNaresh Kumar Inna #ifndef __CSIO_INIT_H__
36a3667aaeSNaresh Kumar Inna #define __CSIO_INIT_H__
37a3667aaeSNaresh Kumar Inna
38a3667aaeSNaresh Kumar Inna #include <linux/pci.h>
39a3667aaeSNaresh Kumar Inna #include <linux/if_ether.h>
40a3667aaeSNaresh Kumar Inna #include <scsi/scsi.h>
41a3667aaeSNaresh Kumar Inna #include <scsi/scsi_device.h>
42a3667aaeSNaresh Kumar Inna #include <scsi/scsi_host.h>
43a3667aaeSNaresh Kumar Inna #include <scsi/scsi_transport_fc.h>
44a3667aaeSNaresh Kumar Inna
45a3667aaeSNaresh Kumar Inna #include "csio_scsi.h"
46a3667aaeSNaresh Kumar Inna #include "csio_lnode.h"
47a3667aaeSNaresh Kumar Inna #include "csio_rnode.h"
48a3667aaeSNaresh Kumar Inna #include "csio_hw.h"
49a3667aaeSNaresh Kumar Inna
50a3667aaeSNaresh Kumar Inna #define CSIO_DRV_AUTHOR "Chelsio Communications"
51a3667aaeSNaresh Kumar Inna #define CSIO_DRV_DESC "Chelsio FCoE driver"
52*054c62f5SVarun Prakash #define CSIO_DRV_VERSION "1.0.0-ko"
53a3667aaeSNaresh Kumar Inna
54a3667aaeSNaresh Kumar Inna extern struct fc_function_template csio_fc_transport_funcs;
55a3667aaeSNaresh Kumar Inna extern struct fc_function_template csio_fc_transport_vport_funcs;
56a3667aaeSNaresh Kumar Inna
57a3667aaeSNaresh Kumar Inna void csio_fchost_attr_init(struct csio_lnode *);
58a3667aaeSNaresh Kumar Inna
59a3667aaeSNaresh Kumar Inna /* INTx handlers */
60a3667aaeSNaresh Kumar Inna void csio_scsi_intx_handler(struct csio_hw *, void *, uint32_t,
61a3667aaeSNaresh Kumar Inna struct csio_fl_dma_buf *, void *);
62a3667aaeSNaresh Kumar Inna
63a3667aaeSNaresh Kumar Inna void csio_fwevt_intx_handler(struct csio_hw *, void *, uint32_t,
64a3667aaeSNaresh Kumar Inna struct csio_fl_dma_buf *, void *);
65a3667aaeSNaresh Kumar Inna
66a3667aaeSNaresh Kumar Inna /* Common os lnode APIs */
67a3667aaeSNaresh Kumar Inna void csio_lnodes_block_request(struct csio_hw *);
68a3667aaeSNaresh Kumar Inna void csio_lnodes_unblock_request(struct csio_hw *);
69a3667aaeSNaresh Kumar Inna void csio_lnodes_block_by_port(struct csio_hw *, uint8_t);
70a3667aaeSNaresh Kumar Inna void csio_lnodes_unblock_by_port(struct csio_hw *, uint8_t);
71a3667aaeSNaresh Kumar Inna
72a3667aaeSNaresh Kumar Inna struct csio_lnode *csio_shost_init(struct csio_hw *, struct device *, bool,
73a3667aaeSNaresh Kumar Inna struct csio_lnode *);
74a3667aaeSNaresh Kumar Inna void csio_shost_exit(struct csio_lnode *);
75a3667aaeSNaresh Kumar Inna void csio_lnodes_exit(struct csio_hw *, bool);
76a3667aaeSNaresh Kumar Inna
777cc16380SArvind Bhushan /* DebugFS helper routines */
787cc16380SArvind Bhushan void csio_add_debugfs_mem(struct csio_hw *, const char *,
797cc16380SArvind Bhushan unsigned int, unsigned int);
807cc16380SArvind Bhushan
81a3667aaeSNaresh Kumar Inna static inline struct Scsi_Host *
csio_ln_to_shost(struct csio_lnode * ln)82a3667aaeSNaresh Kumar Inna csio_ln_to_shost(struct csio_lnode *ln)
83a3667aaeSNaresh Kumar Inna {
84a3667aaeSNaresh Kumar Inna return container_of((void *)ln, struct Scsi_Host, hostdata[0]);
85a3667aaeSNaresh Kumar Inna }
86a3667aaeSNaresh Kumar Inna
87a3667aaeSNaresh Kumar Inna /* SCSI -- locking version of get/put ioreqs */
88a3667aaeSNaresh Kumar Inna static inline struct csio_ioreq *
csio_get_scsi_ioreq_lock(struct csio_hw * hw,struct csio_scsim * scsim)89a3667aaeSNaresh Kumar Inna csio_get_scsi_ioreq_lock(struct csio_hw *hw, struct csio_scsim *scsim)
90a3667aaeSNaresh Kumar Inna {
91a3667aaeSNaresh Kumar Inna struct csio_ioreq *ioreq;
92a3667aaeSNaresh Kumar Inna unsigned long flags;
93a3667aaeSNaresh Kumar Inna
94a3667aaeSNaresh Kumar Inna spin_lock_irqsave(&scsim->freelist_lock, flags);
95a3667aaeSNaresh Kumar Inna ioreq = csio_get_scsi_ioreq(scsim);
96a3667aaeSNaresh Kumar Inna spin_unlock_irqrestore(&scsim->freelist_lock, flags);
97a3667aaeSNaresh Kumar Inna
98a3667aaeSNaresh Kumar Inna return ioreq;
99a3667aaeSNaresh Kumar Inna }
100a3667aaeSNaresh Kumar Inna
101a3667aaeSNaresh Kumar Inna static inline void
csio_put_scsi_ioreq_lock(struct csio_hw * hw,struct csio_scsim * scsim,struct csio_ioreq * ioreq)102a3667aaeSNaresh Kumar Inna csio_put_scsi_ioreq_lock(struct csio_hw *hw, struct csio_scsim *scsim,
103a3667aaeSNaresh Kumar Inna struct csio_ioreq *ioreq)
104a3667aaeSNaresh Kumar Inna {
105a3667aaeSNaresh Kumar Inna unsigned long flags;
106a3667aaeSNaresh Kumar Inna
107a3667aaeSNaresh Kumar Inna spin_lock_irqsave(&scsim->freelist_lock, flags);
108a3667aaeSNaresh Kumar Inna csio_put_scsi_ioreq(scsim, ioreq);
109a3667aaeSNaresh Kumar Inna spin_unlock_irqrestore(&scsim->freelist_lock, flags);
110a3667aaeSNaresh Kumar Inna }
111a3667aaeSNaresh Kumar Inna
112a3667aaeSNaresh Kumar Inna /* Called in interrupt context */
113a3667aaeSNaresh Kumar Inna static inline void
csio_put_scsi_ioreq_list_lock(struct csio_hw * hw,struct csio_scsim * scsim,struct list_head * reqlist,int n)114a3667aaeSNaresh Kumar Inna csio_put_scsi_ioreq_list_lock(struct csio_hw *hw, struct csio_scsim *scsim,
115a3667aaeSNaresh Kumar Inna struct list_head *reqlist, int n)
116a3667aaeSNaresh Kumar Inna {
117a3667aaeSNaresh Kumar Inna unsigned long flags;
118a3667aaeSNaresh Kumar Inna
119a3667aaeSNaresh Kumar Inna spin_lock_irqsave(&scsim->freelist_lock, flags);
120a3667aaeSNaresh Kumar Inna csio_put_scsi_ioreq_list(scsim, reqlist, n);
121a3667aaeSNaresh Kumar Inna spin_unlock_irqrestore(&scsim->freelist_lock, flags);
122a3667aaeSNaresh Kumar Inna }
123a3667aaeSNaresh Kumar Inna
124a3667aaeSNaresh Kumar Inna /* Called in interrupt context */
125a3667aaeSNaresh Kumar Inna static inline void
csio_put_scsi_ddp_list_lock(struct csio_hw * hw,struct csio_scsim * scsim,struct list_head * reqlist,int n)126a3667aaeSNaresh Kumar Inna csio_put_scsi_ddp_list_lock(struct csio_hw *hw, struct csio_scsim *scsim,
127a3667aaeSNaresh Kumar Inna struct list_head *reqlist, int n)
128a3667aaeSNaresh Kumar Inna {
129a3667aaeSNaresh Kumar Inna unsigned long flags;
130a3667aaeSNaresh Kumar Inna
131a3667aaeSNaresh Kumar Inna spin_lock_irqsave(&hw->lock, flags);
132a3667aaeSNaresh Kumar Inna csio_put_scsi_ddp_list(scsim, reqlist, n);
133a3667aaeSNaresh Kumar Inna spin_unlock_irqrestore(&hw->lock, flags);
134a3667aaeSNaresh Kumar Inna }
135a3667aaeSNaresh Kumar Inna
136a3667aaeSNaresh Kumar Inna #endif /* ifndef __CSIO_INIT_H__ */
137