| Karen Xie | c367346 | 2008-12-09 14:15:32 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * cxgb3i.h: Chelsio S3xx iSCSI driver. | 
|  | 3 | * | 
|  | 4 | * Copyright (c) 2008 Chelsio Communications, Inc. | 
|  | 5 | * | 
|  | 6 | * This program is free software; you can redistribute it and/or modify | 
|  | 7 | * it under the terms of the GNU General Public License as published by | 
|  | 8 | * the Free Software Foundation. | 
|  | 9 | * | 
|  | 10 | * Written by: Karen Xie (kxie@chelsio.com) | 
|  | 11 | */ | 
|  | 12 |  | 
|  | 13 | #ifndef __CXGB3I_H__ | 
|  | 14 | #define __CXGB3I_H__ | 
|  | 15 |  | 
|  | 16 | #include <linux/module.h> | 
|  | 17 | #include <linux/moduleparam.h> | 
|  | 18 | #include <linux/errno.h> | 
|  | 19 | #include <linux/types.h> | 
|  | 20 | #include <linux/list.h> | 
|  | 21 | #include <linux/netdevice.h> | 
|  | 22 | #include <linux/scatterlist.h> | 
| Karen Xie | 949847d | 2009-02-13 21:38:49 -0800 | [diff] [blame] | 23 | #include <linux/skbuff.h> | 
| Karen Xie | c367346 | 2008-12-09 14:15:32 -0800 | [diff] [blame] | 24 | #include <scsi/libiscsi_tcp.h> | 
|  | 25 |  | 
|  | 26 | /* from cxgb3 LLD */ | 
|  | 27 | #include "common.h" | 
|  | 28 | #include "t3_cpl.h" | 
|  | 29 | #include "t3cdev.h" | 
|  | 30 | #include "cxgb3_ctl_defs.h" | 
|  | 31 | #include "cxgb3_offload.h" | 
|  | 32 | #include "firmware_exports.h" | 
|  | 33 |  | 
|  | 34 | #include "cxgb3i_offload.h" | 
|  | 35 | #include "cxgb3i_ddp.h" | 
|  | 36 |  | 
| Mike Christie | dd0af9f | 2009-04-21 15:32:33 -0500 | [diff] [blame] | 37 | #define CXGB3I_SCSI_HOST_QDEPTH 1024 | 
| Karen Xie | c367346 | 2008-12-09 14:15:32 -0800 | [diff] [blame] | 38 | #define CXGB3I_MAX_TARGET	CXGB3I_MAX_CONN | 
|  | 39 | #define CXGB3I_MAX_LUN		512 | 
|  | 40 | #define ISCSI_PDU_NONPAYLOAD_MAX \ | 
|  | 41 | (sizeof(struct iscsi_hdr) + ISCSI_MAX_AHS_SIZE + 2*ISCSI_DIGEST_SIZE) | 
|  | 42 |  | 
|  | 43 | struct cxgb3i_adapter; | 
|  | 44 | struct cxgb3i_hba; | 
|  | 45 | struct cxgb3i_endpoint; | 
|  | 46 |  | 
|  | 47 | /** | 
|  | 48 | * struct cxgb3i_hba - cxgb3i iscsi structure (per port) | 
|  | 49 | * | 
|  | 50 | * @snic:	cxgb3i adapter containing this port | 
|  | 51 | * @ndev:	pointer to netdev structure | 
|  | 52 | * @shost:	pointer to scsi host structure | 
|  | 53 | */ | 
|  | 54 | struct cxgb3i_hba { | 
|  | 55 | struct cxgb3i_adapter *snic; | 
|  | 56 | struct net_device *ndev; | 
|  | 57 | struct Scsi_Host *shost; | 
|  | 58 | }; | 
|  | 59 |  | 
|  | 60 | /** | 
|  | 61 | * struct cxgb3i_adapter - cxgb3i adapter structure (per pci) | 
|  | 62 | * | 
|  | 63 | * @listhead:	list head to link elements | 
|  | 64 | * @lock:	lock for this structure | 
|  | 65 | * @tdev:	pointer to t3cdev used by cxgb3 driver | 
|  | 66 | * @pdev:	pointer to pci dev | 
|  | 67 | * @hba_cnt:	# of hbas (the same as # of ports) | 
|  | 68 | * @hba:	all the hbas on this adapter | 
| Karen Xie | 515f1c8 | 2009-04-01 13:11:23 -0500 | [diff] [blame] | 69 | * @flags:	bit flag for adapter event/status | 
| Karen Xie | c367346 | 2008-12-09 14:15:32 -0800 | [diff] [blame] | 70 | * @tx_max_size: max. tx packet size supported | 
|  | 71 | * @rx_max_size: max. rx packet size supported | 
|  | 72 | * @tag_format: ddp tag format settings | 
|  | 73 | */ | 
| Karen Xie | 515f1c8 | 2009-04-01 13:11:23 -0500 | [diff] [blame] | 74 | #define CXGB3I_ADAPTER_FLAG_RESET	0x1 | 
| Karen Xie | c367346 | 2008-12-09 14:15:32 -0800 | [diff] [blame] | 75 | struct cxgb3i_adapter { | 
|  | 76 | struct list_head list_head; | 
|  | 77 | spinlock_t lock; | 
|  | 78 | struct t3cdev *tdev; | 
|  | 79 | struct pci_dev *pdev; | 
|  | 80 | unsigned char hba_cnt; | 
|  | 81 | struct cxgb3i_hba *hba[MAX_NPORTS]; | 
|  | 82 |  | 
| Karen Xie | 515f1c8 | 2009-04-01 13:11:23 -0500 | [diff] [blame] | 83 | unsigned int flags; | 
| Karen Xie | c367346 | 2008-12-09 14:15:32 -0800 | [diff] [blame] | 84 | unsigned int tx_max_size; | 
|  | 85 | unsigned int rx_max_size; | 
|  | 86 |  | 
|  | 87 | struct cxgb3i_tag_format tag_format; | 
|  | 88 | }; | 
|  | 89 |  | 
|  | 90 | /** | 
|  | 91 | * struct cxgb3i_conn - cxgb3i iscsi connection | 
|  | 92 | * | 
|  | 93 | * @listhead:	list head to link elements | 
|  | 94 | * @cep:	pointer to iscsi_endpoint structure | 
|  | 95 | * @conn:	pointer to iscsi_conn structure | 
|  | 96 | * @hba:	pointer to the hba this conn. is going through | 
|  | 97 | * @task_idx_bits: # of bits needed for session->cmds_max | 
|  | 98 | */ | 
|  | 99 | struct cxgb3i_conn { | 
|  | 100 | struct list_head list_head; | 
|  | 101 | struct cxgb3i_endpoint *cep; | 
|  | 102 | struct iscsi_conn *conn; | 
|  | 103 | struct cxgb3i_hba *hba; | 
|  | 104 | unsigned int task_idx_bits; | 
|  | 105 | }; | 
|  | 106 |  | 
|  | 107 | /** | 
|  | 108 | * struct cxgb3i_endpoint - iscsi tcp endpoint | 
|  | 109 | * | 
|  | 110 | * @c3cn:	the h/w tcp connection representation | 
|  | 111 | * @hba:	pointer to the hba this conn. is going through | 
|  | 112 | * @cconn:	pointer to the associated cxgb3i iscsi connection | 
|  | 113 | */ | 
|  | 114 | struct cxgb3i_endpoint { | 
|  | 115 | struct s3_conn *c3cn; | 
|  | 116 | struct cxgb3i_hba *hba; | 
|  | 117 | struct cxgb3i_conn *cconn; | 
|  | 118 | }; | 
|  | 119 |  | 
| Karen Xie | 949847d | 2009-02-13 21:38:49 -0800 | [diff] [blame] | 120 | /** | 
|  | 121 | * struct cxgb3i_task_data - private iscsi task data | 
|  | 122 | * | 
|  | 123 | * @nr_frags:	# of coalesced page frags (from scsi sgl) | 
|  | 124 | * @frags:	coalesced page frags (from scsi sgl) | 
|  | 125 | * @skb:	tx pdu skb | 
|  | 126 | * @offset:	data offset for the next pdu | 
|  | 127 | * @count:	max. possible pdu payload | 
|  | 128 | * @sgoffset:	offset to the first sg entry for a given offset | 
|  | 129 | */ | 
|  | 130 | #define MAX_PDU_FRAGS	((ULP2_MAX_PDU_PAYLOAD + 512 - 1) / 512) | 
|  | 131 | struct cxgb3i_task_data { | 
|  | 132 | unsigned short nr_frags; | 
|  | 133 | skb_frag_t frags[MAX_PDU_FRAGS]; | 
|  | 134 | struct sk_buff *skb; | 
|  | 135 | unsigned int offset; | 
|  | 136 | unsigned int count; | 
|  | 137 | unsigned int sgoffset; | 
|  | 138 | }; | 
|  | 139 |  | 
| Karen Xie | c367346 | 2008-12-09 14:15:32 -0800 | [diff] [blame] | 140 | int cxgb3i_iscsi_init(void); | 
|  | 141 | void cxgb3i_iscsi_cleanup(void); | 
|  | 142 |  | 
| Karen Xie | 515f1c8 | 2009-04-01 13:11:23 -0500 | [diff] [blame] | 143 | struct cxgb3i_adapter *cxgb3i_adapter_find_by_tdev(struct t3cdev *); | 
| Mike Christie | ed6f774 | 2009-04-01 13:11:25 -0500 | [diff] [blame] | 144 | void cxgb3i_adapter_open(struct t3cdev *); | 
| Karen Xie | 515f1c8 | 2009-04-01 13:11:23 -0500 | [diff] [blame] | 145 | void cxgb3i_adapter_close(struct t3cdev *); | 
| Karen Xie | c367346 | 2008-12-09 14:15:32 -0800 | [diff] [blame] | 146 |  | 
| Karen Xie | c367346 | 2008-12-09 14:15:32 -0800 | [diff] [blame] | 147 | struct cxgb3i_hba *cxgb3i_hba_host_add(struct cxgb3i_adapter *, | 
|  | 148 | struct net_device *); | 
|  | 149 | void cxgb3i_hba_host_remove(struct cxgb3i_hba *); | 
|  | 150 |  | 
|  | 151 | int cxgb3i_pdu_init(void); | 
|  | 152 | void cxgb3i_pdu_cleanup(void); | 
|  | 153 | void cxgb3i_conn_cleanup_task(struct iscsi_task *); | 
|  | 154 | int cxgb3i_conn_alloc_pdu(struct iscsi_task *, u8); | 
|  | 155 | int cxgb3i_conn_init_pdu(struct iscsi_task *, unsigned int, unsigned int); | 
|  | 156 | int cxgb3i_conn_xmit_pdu(struct iscsi_task *); | 
|  | 157 |  | 
|  | 158 | void cxgb3i_release_itt(struct iscsi_task *task, itt_t hdr_itt); | 
|  | 159 | int cxgb3i_reserve_itt(struct iscsi_task *task, itt_t *hdr_itt); | 
|  | 160 |  | 
|  | 161 | #endif |