Path: blob/master/drivers/infiniband/ulp/srp/ib_srp.h
15112 views
/*1* Copyright (c) 2005 Cisco Systems. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*/3132#ifndef IB_SRP_H33#define IB_SRP_H3435#include <linux/types.h>36#include <linux/list.h>37#include <linux/mutex.h>38#include <linux/scatterlist.h>3940#include <scsi/scsi_host.h>41#include <scsi/scsi_cmnd.h>4243#include <rdma/ib_verbs.h>44#include <rdma/ib_sa.h>45#include <rdma/ib_cm.h>46#include <rdma/ib_fmr_pool.h>4748enum {49SRP_PATH_REC_TIMEOUT_MS = 1000,50SRP_ABORT_TIMEOUT_MS = 5000,5152SRP_PORT_REDIRECT = 1,53SRP_DLID_REDIRECT = 2,54SRP_STALE_CONN = 3,5556SRP_MAX_LUN = 512,57SRP_DEF_SG_TABLESIZE = 12,5859SRP_RQ_SHIFT = 6,60SRP_RQ_SIZE = 1 << SRP_RQ_SHIFT,6162SRP_SQ_SIZE = SRP_RQ_SIZE,63SRP_RSP_SQ_SIZE = 1,64SRP_REQ_SQ_SIZE = SRP_SQ_SIZE - SRP_RSP_SQ_SIZE,65SRP_TSK_MGMT_SQ_SIZE = 1,66SRP_CMD_SQ_SIZE = SRP_REQ_SQ_SIZE - SRP_TSK_MGMT_SQ_SIZE,6768SRP_TAG_NO_REQ = ~0U,69SRP_TAG_TSK_MGMT = 1U << 31,7071SRP_FMR_SIZE = 512,72SRP_FMR_MIN_SIZE = 128,73SRP_FMR_POOL_SIZE = 1024,74SRP_FMR_DIRTY_SIZE = SRP_FMR_POOL_SIZE / 4,7576SRP_MAP_ALLOW_FMR = 0,77SRP_MAP_NO_FMR = 1,78};7980enum srp_target_state {81SRP_TARGET_LIVE,82SRP_TARGET_CONNECTING,83SRP_TARGET_DEAD,84SRP_TARGET_REMOVED85};8687enum srp_iu_type {88SRP_IU_CMD,89SRP_IU_TSK_MGMT,90SRP_IU_RSP,91};9293struct srp_device {94struct list_head dev_list;95struct ib_device *dev;96struct ib_pd *pd;97struct ib_mr *mr;98struct ib_fmr_pool *fmr_pool;99u64 fmr_page_mask;100int fmr_page_size;101int fmr_max_size;102};103104struct srp_host {105struct srp_device *srp_dev;106u8 port;107struct device dev;108struct list_head target_list;109spinlock_t target_lock;110struct completion released;111struct list_head list;112};113114struct srp_request {115struct list_head list;116struct scsi_cmnd *scmnd;117struct srp_iu *cmd;118struct ib_pool_fmr **fmr_list;119u64 *map_page;120struct srp_direct_buf *indirect_desc;121dma_addr_t indirect_dma_addr;122short nfmr;123short index;124};125126struct srp_target_port {127/* These are RW in the hot path, and commonly used together */128struct list_head free_tx;129struct list_head free_reqs;130spinlock_t lock;131s32 req_lim;132133/* These are read-only in the hot path */134struct ib_cq *send_cq ____cacheline_aligned_in_smp;135struct ib_cq *recv_cq;136struct ib_qp *qp;137u32 lkey;138u32 rkey;139enum srp_target_state state;140unsigned int max_iu_len;141unsigned int cmd_sg_cnt;142unsigned int indirect_size;143bool allow_ext_sg;144145/* Everything above this point is used in the hot path of146* command processing. Try to keep them packed into cachelines.147*/148149__be64 id_ext;150__be64 ioc_guid;151__be64 service_id;152__be64 initiator_ext;153u16 io_class;154struct srp_host *srp_host;155struct Scsi_Host *scsi_host;156char target_name[32];157unsigned int scsi_id;158unsigned int sg_tablesize;159160struct ib_sa_path_rec path;161__be16 orig_dgid[8];162struct ib_sa_query *path_query;163int path_query_id;164165struct ib_cm_id *cm_id;166167int max_ti_iu_len;168169int zero_req_lim;170171struct srp_iu *tx_ring[SRP_SQ_SIZE];172struct srp_iu *rx_ring[SRP_RQ_SIZE];173struct srp_request req_ring[SRP_CMD_SQ_SIZE];174175struct work_struct work;176177struct list_head list;178struct completion done;179int status;180int qp_in_error;181182struct completion tsk_mgmt_done;183u8 tsk_mgmt_status;184};185186struct srp_iu {187struct list_head list;188u64 dma;189void *buf;190size_t size;191enum dma_data_direction direction;192};193194struct srp_map_state {195struct ib_pool_fmr **next_fmr;196struct srp_direct_buf *desc;197u64 *pages;198dma_addr_t base_dma_addr;199u32 fmr_len;200u32 total_len;201unsigned int npages;202unsigned int nfmr;203unsigned int ndesc;204struct scatterlist *unmapped_sg;205int unmapped_index;206dma_addr_t unmapped_addr;207};208209#endif /* IB_SRP_H */210211212