18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is part of the Chelsio FCoE driver for Linux.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
78c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
88c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
98c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
108c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
138c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
148c2ecf20Sopenharmony_ci *     conditions are met:
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
178c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
188c2ecf20Sopenharmony_ci *        disclaimer.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
218c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
228c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
238c2ecf20Sopenharmony_ci *        provided with the distribution.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
268c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
278c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
288c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
298c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
308c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
318c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
328c2ecf20Sopenharmony_ci * SOFTWARE.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#ifndef __CSIO_INIT_H__
368c2ecf20Sopenharmony_ci#define __CSIO_INIT_H__
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#include <linux/pci.h>
398c2ecf20Sopenharmony_ci#include <linux/if_ether.h>
408c2ecf20Sopenharmony_ci#include <scsi/scsi.h>
418c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h>
428c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h>
438c2ecf20Sopenharmony_ci#include <scsi/scsi_transport_fc.h>
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#include "csio_scsi.h"
468c2ecf20Sopenharmony_ci#include "csio_lnode.h"
478c2ecf20Sopenharmony_ci#include "csio_rnode.h"
488c2ecf20Sopenharmony_ci#include "csio_hw.h"
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define CSIO_DRV_AUTHOR			"Chelsio Communications"
518c2ecf20Sopenharmony_ci#define CSIO_DRV_DESC			"Chelsio FCoE driver"
528c2ecf20Sopenharmony_ci#define CSIO_DRV_VERSION		"1.0.0-ko"
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciextern struct fc_function_template csio_fc_transport_funcs;
558c2ecf20Sopenharmony_ciextern struct fc_function_template csio_fc_transport_vport_funcs;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_civoid csio_fchost_attr_init(struct csio_lnode *);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* INTx handlers */
608c2ecf20Sopenharmony_civoid csio_scsi_intx_handler(struct csio_hw *, void *, uint32_t,
618c2ecf20Sopenharmony_ci			       struct csio_fl_dma_buf *, void *);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_civoid csio_fwevt_intx_handler(struct csio_hw *, void *, uint32_t,
648c2ecf20Sopenharmony_ci				struct csio_fl_dma_buf *, void *);
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* Common os lnode APIs */
678c2ecf20Sopenharmony_civoid csio_lnodes_block_request(struct csio_hw *);
688c2ecf20Sopenharmony_civoid csio_lnodes_unblock_request(struct csio_hw *);
698c2ecf20Sopenharmony_civoid csio_lnodes_block_by_port(struct csio_hw *, uint8_t);
708c2ecf20Sopenharmony_civoid csio_lnodes_unblock_by_port(struct csio_hw *, uint8_t);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cistruct csio_lnode *csio_shost_init(struct csio_hw *, struct device *, bool,
738c2ecf20Sopenharmony_ci					struct csio_lnode *);
748c2ecf20Sopenharmony_civoid csio_shost_exit(struct csio_lnode *);
758c2ecf20Sopenharmony_civoid csio_lnodes_exit(struct csio_hw *, bool);
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* DebugFS helper routines */
788c2ecf20Sopenharmony_civoid csio_add_debugfs_mem(struct csio_hw *, const char *,
798c2ecf20Sopenharmony_ci		unsigned int, unsigned int);
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistatic inline struct Scsi_Host *
828c2ecf20Sopenharmony_cicsio_ln_to_shost(struct csio_lnode *ln)
838c2ecf20Sopenharmony_ci{
848c2ecf20Sopenharmony_ci	return container_of((void *)ln, struct Scsi_Host, hostdata[0]);
858c2ecf20Sopenharmony_ci}
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/* SCSI -- locking version of get/put ioreqs  */
888c2ecf20Sopenharmony_cistatic inline struct csio_ioreq *
898c2ecf20Sopenharmony_cicsio_get_scsi_ioreq_lock(struct csio_hw *hw, struct csio_scsim *scsim)
908c2ecf20Sopenharmony_ci{
918c2ecf20Sopenharmony_ci	struct csio_ioreq *ioreq;
928c2ecf20Sopenharmony_ci	unsigned long flags;
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	spin_lock_irqsave(&scsim->freelist_lock, flags);
958c2ecf20Sopenharmony_ci	ioreq = csio_get_scsi_ioreq(scsim);
968c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&scsim->freelist_lock, flags);
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	return ioreq;
998c2ecf20Sopenharmony_ci}
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_cistatic inline void
1028c2ecf20Sopenharmony_cicsio_put_scsi_ioreq_lock(struct csio_hw *hw, struct csio_scsim *scsim,
1038c2ecf20Sopenharmony_ci			 struct csio_ioreq *ioreq)
1048c2ecf20Sopenharmony_ci{
1058c2ecf20Sopenharmony_ci	unsigned long flags;
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci	spin_lock_irqsave(&scsim->freelist_lock, flags);
1088c2ecf20Sopenharmony_ci	csio_put_scsi_ioreq(scsim, ioreq);
1098c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&scsim->freelist_lock, flags);
1108c2ecf20Sopenharmony_ci}
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci/* Called in interrupt context */
1138c2ecf20Sopenharmony_cistatic inline void
1148c2ecf20Sopenharmony_cicsio_put_scsi_ioreq_list_lock(struct csio_hw *hw, struct csio_scsim *scsim,
1158c2ecf20Sopenharmony_ci			      struct list_head *reqlist, int n)
1168c2ecf20Sopenharmony_ci{
1178c2ecf20Sopenharmony_ci	unsigned long flags;
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	spin_lock_irqsave(&scsim->freelist_lock, flags);
1208c2ecf20Sopenharmony_ci	csio_put_scsi_ioreq_list(scsim, reqlist, n);
1218c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&scsim->freelist_lock, flags);
1228c2ecf20Sopenharmony_ci}
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci/* Called in interrupt context */
1258c2ecf20Sopenharmony_cistatic inline void
1268c2ecf20Sopenharmony_cicsio_put_scsi_ddp_list_lock(struct csio_hw *hw, struct csio_scsim *scsim,
1278c2ecf20Sopenharmony_ci			      struct list_head *reqlist, int n)
1288c2ecf20Sopenharmony_ci{
1298c2ecf20Sopenharmony_ci	unsigned long flags;
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	spin_lock_irqsave(&hw->lock, flags);
1328c2ecf20Sopenharmony_ci	csio_put_scsi_ddp_list(scsim, reqlist, n);
1338c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&hw->lock, flags);
1348c2ecf20Sopenharmony_ci}
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#endif /* ifndef __CSIO_INIT_H__ */
137