18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * libcxgbi.h: Chelsio common library for T3/T4 iSCSI driver.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2010-2015 Chelsio Communications, Inc.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
78c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
88c2ecf20Sopenharmony_ci * the Free Software Foundation.
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * Written by: Karen Xie (kxie@chelsio.com)
118c2ecf20Sopenharmony_ci * Written by: Rakesh Ranjan (rranjan@chelsio.com)
128c2ecf20Sopenharmony_ci */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#ifndef	__LIBCXGBI_H__
158c2ecf20Sopenharmony_ci#define	__LIBCXGBI_H__
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <linux/kernel.h>
188c2ecf20Sopenharmony_ci#include <linux/errno.h>
198c2ecf20Sopenharmony_ci#include <linux/types.h>
208c2ecf20Sopenharmony_ci#include <linux/debugfs.h>
218c2ecf20Sopenharmony_ci#include <linux/list.h>
228c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
238c2ecf20Sopenharmony_ci#include <linux/if_vlan.h>
248c2ecf20Sopenharmony_ci#include <linux/scatterlist.h>
258c2ecf20Sopenharmony_ci#include <linux/skbuff.h>
268c2ecf20Sopenharmony_ci#include <linux/vmalloc.h>
278c2ecf20Sopenharmony_ci#include <linux/version.h>
288c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h>
298c2ecf20Sopenharmony_ci#include <scsi/libiscsi_tcp.h>
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#include <libcxgb_ppm.h>
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cienum cxgbi_dbg_flag {
348c2ecf20Sopenharmony_ci	CXGBI_DBG_ISCSI,
358c2ecf20Sopenharmony_ci	CXGBI_DBG_DDP,
368c2ecf20Sopenharmony_ci	CXGBI_DBG_TOE,
378c2ecf20Sopenharmony_ci	CXGBI_DBG_SOCK,
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	CXGBI_DBG_PDU_TX,
408c2ecf20Sopenharmony_ci	CXGBI_DBG_PDU_RX,
418c2ecf20Sopenharmony_ci	CXGBI_DBG_DEV,
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define log_debug(level, fmt, ...)	\
458c2ecf20Sopenharmony_ci	do {	\
468c2ecf20Sopenharmony_ci		if (dbg_level & (level)) \
478c2ecf20Sopenharmony_ci			pr_info(fmt, ##__VA_ARGS__); \
488c2ecf20Sopenharmony_ci	} while (0)
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define pr_info_ipaddr(fmt_trail,					\
518c2ecf20Sopenharmony_ci			addr1, addr2, args_trail...)			\
528c2ecf20Sopenharmony_cido {									\
538c2ecf20Sopenharmony_ci	if (!((1 << CXGBI_DBG_SOCK) & dbg_level))			\
548c2ecf20Sopenharmony_ci		break;							\
558c2ecf20Sopenharmony_ci	pr_info("%pISpc - %pISpc, " fmt_trail,				\
568c2ecf20Sopenharmony_ci		addr1, addr2, args_trail);				\
578c2ecf20Sopenharmony_ci} while (0)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* max. connections per adapter */
608c2ecf20Sopenharmony_ci#define CXGBI_MAX_CONN		16384
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/* always allocate rooms for AHS */
638c2ecf20Sopenharmony_ci#define SKB_TX_ISCSI_PDU_HEADER_MAX	\
648c2ecf20Sopenharmony_ci	(sizeof(struct iscsi_hdr) + ISCSI_MAX_AHS_SIZE)
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define	ISCSI_PDU_NONPAYLOAD_LEN	312 /* bhs(48) + ahs(256) + digest(8)*/
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/*
698c2ecf20Sopenharmony_ci * align pdu size to multiple of 512 for better performance
708c2ecf20Sopenharmony_ci */
718c2ecf20Sopenharmony_ci#define cxgbi_align_pdu_size(n) do { n = (n) & (~511); } while (0)
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define ULP2_MODE_ISCSI		2
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define ULP2_MAX_PKT_SIZE	16224
768c2ecf20Sopenharmony_ci#define ULP2_MAX_PDU_PAYLOAD	\
778c2ecf20Sopenharmony_ci	(ULP2_MAX_PKT_SIZE - ISCSI_PDU_NONPAYLOAD_LEN)
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define CXGBI_ULP2_MAX_ISO_PAYLOAD	65535
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define CXGBI_MAX_ISO_DATA_IN_SKB	\
828c2ecf20Sopenharmony_ci	min_t(u32, MAX_SKB_FRAGS << PAGE_SHIFT, CXGBI_ULP2_MAX_ISO_PAYLOAD)
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define cxgbi_is_iso_config(csk)	((csk)->cdev->skb_iso_txhdr)
858c2ecf20Sopenharmony_ci#define cxgbi_is_iso_disabled(csk)	((csk)->disable_iso)
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/*
888c2ecf20Sopenharmony_ci * For iscsi connections HW may inserts digest bytes into the pdu. Those digest
898c2ecf20Sopenharmony_ci * bytes are not sent by the host but are part of the TCP payload and therefore
908c2ecf20Sopenharmony_ci * consume TCP sequence space.
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_cistatic const unsigned int ulp2_extra_len[] = { 0, 4, 4, 8 };
938c2ecf20Sopenharmony_cistatic inline unsigned int cxgbi_ulp_extra_len(int submode)
948c2ecf20Sopenharmony_ci{
958c2ecf20Sopenharmony_ci	return ulp2_extra_len[submode & 3];
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define CPL_RX_DDP_STATUS_DDP_SHIFT	16 /* ddp'able */
998c2ecf20Sopenharmony_ci#define CPL_RX_DDP_STATUS_PAD_SHIFT	19 /* pad error */
1008c2ecf20Sopenharmony_ci#define CPL_RX_DDP_STATUS_HCRC_SHIFT	20 /* hcrc error */
1018c2ecf20Sopenharmony_ci#define CPL_RX_DDP_STATUS_DCRC_SHIFT	21 /* dcrc error */
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci/*
1048c2ecf20Sopenharmony_ci * sge_opaque_hdr -
1058c2ecf20Sopenharmony_ci * Opaque version of structure the SGE stores at skb->head of TX_DATA packets
1068c2ecf20Sopenharmony_ci * and for which we must reserve space.
1078c2ecf20Sopenharmony_ci */
1088c2ecf20Sopenharmony_cistruct sge_opaque_hdr {
1098c2ecf20Sopenharmony_ci	void *dev;
1108c2ecf20Sopenharmony_ci	dma_addr_t addr[MAX_SKB_FRAGS + 1];
1118c2ecf20Sopenharmony_ci};
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_cistruct cxgbi_sock {
1148c2ecf20Sopenharmony_ci	struct cxgbi_device *cdev;
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci	int tid;
1178c2ecf20Sopenharmony_ci	int atid;
1188c2ecf20Sopenharmony_ci	unsigned long flags;
1198c2ecf20Sopenharmony_ci	unsigned int mtu;
1208c2ecf20Sopenharmony_ci	unsigned short rss_qid;
1218c2ecf20Sopenharmony_ci	unsigned short txq_idx;
1228c2ecf20Sopenharmony_ci	unsigned short advmss;
1238c2ecf20Sopenharmony_ci	unsigned int tx_chan;
1248c2ecf20Sopenharmony_ci	unsigned int rx_chan;
1258c2ecf20Sopenharmony_ci	unsigned int mss_idx;
1268c2ecf20Sopenharmony_ci	unsigned int smac_idx;
1278c2ecf20Sopenharmony_ci	unsigned char port_id;
1288c2ecf20Sopenharmony_ci	int wr_max_cred;
1298c2ecf20Sopenharmony_ci	int wr_cred;
1308c2ecf20Sopenharmony_ci	int wr_una_cred;
1318c2ecf20Sopenharmony_ci#ifdef CONFIG_CHELSIO_T4_DCB
1328c2ecf20Sopenharmony_ci	u8 dcb_priority;
1338c2ecf20Sopenharmony_ci#endif
1348c2ecf20Sopenharmony_ci	unsigned char hcrc_len;
1358c2ecf20Sopenharmony_ci	unsigned char dcrc_len;
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci	void *l2t;
1388c2ecf20Sopenharmony_ci	struct sk_buff *wr_pending_head;
1398c2ecf20Sopenharmony_ci	struct sk_buff *wr_pending_tail;
1408c2ecf20Sopenharmony_ci	struct sk_buff *cpl_close;
1418c2ecf20Sopenharmony_ci	struct sk_buff *cpl_abort_req;
1428c2ecf20Sopenharmony_ci	struct sk_buff *cpl_abort_rpl;
1438c2ecf20Sopenharmony_ci	struct sk_buff *skb_ulp_lhdr;
1448c2ecf20Sopenharmony_ci	spinlock_t lock;
1458c2ecf20Sopenharmony_ci	struct kref refcnt;
1468c2ecf20Sopenharmony_ci	unsigned int state;
1478c2ecf20Sopenharmony_ci	unsigned int csk_family;
1488c2ecf20Sopenharmony_ci	union {
1498c2ecf20Sopenharmony_ci		struct sockaddr_in saddr;
1508c2ecf20Sopenharmony_ci		struct sockaddr_in6 saddr6;
1518c2ecf20Sopenharmony_ci	};
1528c2ecf20Sopenharmony_ci	union {
1538c2ecf20Sopenharmony_ci		struct sockaddr_in daddr;
1548c2ecf20Sopenharmony_ci		struct sockaddr_in6 daddr6;
1558c2ecf20Sopenharmony_ci	};
1568c2ecf20Sopenharmony_ci	struct dst_entry *dst;
1578c2ecf20Sopenharmony_ci	struct sk_buff_head receive_queue;
1588c2ecf20Sopenharmony_ci	struct sk_buff_head write_queue;
1598c2ecf20Sopenharmony_ci	struct timer_list retry_timer;
1608c2ecf20Sopenharmony_ci	struct completion cmpl;
1618c2ecf20Sopenharmony_ci	int err;
1628c2ecf20Sopenharmony_ci	rwlock_t callback_lock;
1638c2ecf20Sopenharmony_ci	void *user_data;
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci	u32 rcv_nxt;
1668c2ecf20Sopenharmony_ci	u32 copied_seq;
1678c2ecf20Sopenharmony_ci	u32 rcv_wup;
1688c2ecf20Sopenharmony_ci	u32 snd_nxt;
1698c2ecf20Sopenharmony_ci	u32 snd_una;
1708c2ecf20Sopenharmony_ci	u32 write_seq;
1718c2ecf20Sopenharmony_ci	u32 snd_win;
1728c2ecf20Sopenharmony_ci	u32 rcv_win;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	bool disable_iso;
1758c2ecf20Sopenharmony_ci	u32 no_tx_credits;
1768c2ecf20Sopenharmony_ci	unsigned long prev_iso_ts;
1778c2ecf20Sopenharmony_ci};
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/*
1808c2ecf20Sopenharmony_ci * connection states
1818c2ecf20Sopenharmony_ci */
1828c2ecf20Sopenharmony_cienum cxgbi_sock_states{
1838c2ecf20Sopenharmony_ci	CTP_CLOSED,
1848c2ecf20Sopenharmony_ci	CTP_CONNECTING,
1858c2ecf20Sopenharmony_ci	CTP_ACTIVE_OPEN,
1868c2ecf20Sopenharmony_ci	CTP_ESTABLISHED,
1878c2ecf20Sopenharmony_ci	CTP_ACTIVE_CLOSE,
1888c2ecf20Sopenharmony_ci	CTP_PASSIVE_CLOSE,
1898c2ecf20Sopenharmony_ci	CTP_CLOSE_WAIT_1,
1908c2ecf20Sopenharmony_ci	CTP_CLOSE_WAIT_2,
1918c2ecf20Sopenharmony_ci	CTP_ABORTING,
1928c2ecf20Sopenharmony_ci};
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci/*
1958c2ecf20Sopenharmony_ci * Connection flags -- many to track some close related events.
1968c2ecf20Sopenharmony_ci */
1978c2ecf20Sopenharmony_cienum cxgbi_sock_flags {
1988c2ecf20Sopenharmony_ci	CTPF_ABORT_RPL_RCVD,	/*received one ABORT_RPL_RSS message */
1998c2ecf20Sopenharmony_ci	CTPF_ABORT_REQ_RCVD,	/*received one ABORT_REQ_RSS message */
2008c2ecf20Sopenharmony_ci	CTPF_ABORT_RPL_PENDING,	/* expecting an abort reply */
2018c2ecf20Sopenharmony_ci	CTPF_TX_DATA_SENT,	/* already sent a TX_DATA WR */
2028c2ecf20Sopenharmony_ci	CTPF_ACTIVE_CLOSE_NEEDED,/* need to be closed */
2038c2ecf20Sopenharmony_ci	CTPF_HAS_ATID,		/* reserved atid */
2048c2ecf20Sopenharmony_ci	CTPF_HAS_TID,		/* reserved hw tid */
2058c2ecf20Sopenharmony_ci	CTPF_OFFLOAD_DOWN,	/* offload function off */
2068c2ecf20Sopenharmony_ci	CTPF_LOGOUT_RSP_RCVD,   /* received logout response */
2078c2ecf20Sopenharmony_ci};
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistruct cxgbi_skb_rx_cb {
2108c2ecf20Sopenharmony_ci	__u32 ddigest;
2118c2ecf20Sopenharmony_ci	__u32 pdulen;
2128c2ecf20Sopenharmony_ci};
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistruct cxgbi_skb_tx_cb {
2158c2ecf20Sopenharmony_ci	void *handle;
2168c2ecf20Sopenharmony_ci	void *arp_err_handler;
2178c2ecf20Sopenharmony_ci	struct sk_buff *wr_next;
2188c2ecf20Sopenharmony_ci	u16 iscsi_hdr_len;
2198c2ecf20Sopenharmony_ci	u8 ulp_mode;
2208c2ecf20Sopenharmony_ci};
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_cienum cxgbi_skcb_flags {
2238c2ecf20Sopenharmony_ci	SKCBF_TX_NEED_HDR,	/* packet needs a header */
2248c2ecf20Sopenharmony_ci	SKCBF_TX_MEM_WRITE,     /* memory write */
2258c2ecf20Sopenharmony_ci	SKCBF_TX_FLAG_COMPL,    /* wr completion flag */
2268c2ecf20Sopenharmony_ci	SKCBF_RX_COALESCED,	/* received whole pdu */
2278c2ecf20Sopenharmony_ci	SKCBF_RX_HDR,		/* received pdu header */
2288c2ecf20Sopenharmony_ci	SKCBF_RX_DATA,		/* received pdu payload */
2298c2ecf20Sopenharmony_ci	SKCBF_RX_STATUS,	/* received ddp status */
2308c2ecf20Sopenharmony_ci	SKCBF_RX_ISCSI_COMPL,   /* received iscsi completion */
2318c2ecf20Sopenharmony_ci	SKCBF_RX_DATA_DDPD,	/* pdu payload ddp'd */
2328c2ecf20Sopenharmony_ci	SKCBF_RX_HCRC_ERR,	/* header digest error */
2338c2ecf20Sopenharmony_ci	SKCBF_RX_DCRC_ERR,	/* data digest error */
2348c2ecf20Sopenharmony_ci	SKCBF_RX_PAD_ERR,	/* padding byte error */
2358c2ecf20Sopenharmony_ci	SKCBF_TX_ISO,		/* iso cpl in tx skb */
2368c2ecf20Sopenharmony_ci};
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_cistruct cxgbi_skb_cb {
2398c2ecf20Sopenharmony_ci	union {
2408c2ecf20Sopenharmony_ci		struct cxgbi_skb_rx_cb rx;
2418c2ecf20Sopenharmony_ci		struct cxgbi_skb_tx_cb tx;
2428c2ecf20Sopenharmony_ci	};
2438c2ecf20Sopenharmony_ci	unsigned long flags;
2448c2ecf20Sopenharmony_ci	unsigned int seq;
2458c2ecf20Sopenharmony_ci};
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci#define CXGBI_SKB_CB(skb)	((struct cxgbi_skb_cb *)&((skb)->cb[0]))
2488c2ecf20Sopenharmony_ci#define cxgbi_skcb_flags(skb)		(CXGBI_SKB_CB(skb)->flags)
2498c2ecf20Sopenharmony_ci#define cxgbi_skcb_tcp_seq(skb)		(CXGBI_SKB_CB(skb)->seq)
2508c2ecf20Sopenharmony_ci#define cxgbi_skcb_rx_ddigest(skb)	(CXGBI_SKB_CB(skb)->rx.ddigest)
2518c2ecf20Sopenharmony_ci#define cxgbi_skcb_rx_pdulen(skb)	(CXGBI_SKB_CB(skb)->rx.pdulen)
2528c2ecf20Sopenharmony_ci#define cxgbi_skcb_tx_wr_next(skb)	(CXGBI_SKB_CB(skb)->tx.wr_next)
2538c2ecf20Sopenharmony_ci#define cxgbi_skcb_tx_iscsi_hdrlen(skb)	(CXGBI_SKB_CB(skb)->tx.iscsi_hdr_len)
2548c2ecf20Sopenharmony_ci#define cxgbi_skcb_tx_ulp_mode(skb)	(CXGBI_SKB_CB(skb)->tx.ulp_mode)
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_cistatic inline void cxgbi_skcb_set_flag(struct sk_buff *skb,
2578c2ecf20Sopenharmony_ci					enum cxgbi_skcb_flags flag)
2588c2ecf20Sopenharmony_ci{
2598c2ecf20Sopenharmony_ci	__set_bit(flag, &(cxgbi_skcb_flags(skb)));
2608c2ecf20Sopenharmony_ci}
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_cistatic inline void cxgbi_skcb_clear_flag(struct sk_buff *skb,
2638c2ecf20Sopenharmony_ci					enum cxgbi_skcb_flags flag)
2648c2ecf20Sopenharmony_ci{
2658c2ecf20Sopenharmony_ci	__clear_bit(flag, &(cxgbi_skcb_flags(skb)));
2668c2ecf20Sopenharmony_ci}
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_cistatic inline int cxgbi_skcb_test_flag(const struct sk_buff *skb,
2698c2ecf20Sopenharmony_ci				       enum cxgbi_skcb_flags flag)
2708c2ecf20Sopenharmony_ci{
2718c2ecf20Sopenharmony_ci	return test_bit(flag, &(cxgbi_skcb_flags(skb)));
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistatic inline void cxgbi_sock_set_flag(struct cxgbi_sock *csk,
2758c2ecf20Sopenharmony_ci					enum cxgbi_sock_flags flag)
2768c2ecf20Sopenharmony_ci{
2778c2ecf20Sopenharmony_ci	__set_bit(flag, &csk->flags);
2788c2ecf20Sopenharmony_ci	log_debug(1 << CXGBI_DBG_SOCK,
2798c2ecf20Sopenharmony_ci		"csk 0x%p,%u,0x%lx, bit %d.\n",
2808c2ecf20Sopenharmony_ci		csk, csk->state, csk->flags, flag);
2818c2ecf20Sopenharmony_ci}
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_cistatic inline void cxgbi_sock_clear_flag(struct cxgbi_sock *csk,
2848c2ecf20Sopenharmony_ci					enum cxgbi_sock_flags flag)
2858c2ecf20Sopenharmony_ci{
2868c2ecf20Sopenharmony_ci	__clear_bit(flag, &csk->flags);
2878c2ecf20Sopenharmony_ci	log_debug(1 << CXGBI_DBG_SOCK,
2888c2ecf20Sopenharmony_ci		"csk 0x%p,%u,0x%lx, bit %d.\n",
2898c2ecf20Sopenharmony_ci		csk, csk->state, csk->flags, flag);
2908c2ecf20Sopenharmony_ci}
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_cistatic inline int cxgbi_sock_flag(struct cxgbi_sock *csk,
2938c2ecf20Sopenharmony_ci				enum cxgbi_sock_flags flag)
2948c2ecf20Sopenharmony_ci{
2958c2ecf20Sopenharmony_ci	if (csk == NULL)
2968c2ecf20Sopenharmony_ci		return 0;
2978c2ecf20Sopenharmony_ci	return test_bit(flag, &csk->flags);
2988c2ecf20Sopenharmony_ci}
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_cistatic inline void cxgbi_sock_set_state(struct cxgbi_sock *csk, int state)
3018c2ecf20Sopenharmony_ci{
3028c2ecf20Sopenharmony_ci	log_debug(1 << CXGBI_DBG_SOCK,
3038c2ecf20Sopenharmony_ci		"csk 0x%p,%u,0x%lx, state -> %u.\n",
3048c2ecf20Sopenharmony_ci		csk, csk->state, csk->flags, state);
3058c2ecf20Sopenharmony_ci	csk->state = state;
3068c2ecf20Sopenharmony_ci}
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_cistatic inline void cxgbi_sock_free(struct kref *kref)
3098c2ecf20Sopenharmony_ci{
3108c2ecf20Sopenharmony_ci	struct cxgbi_sock *csk = container_of(kref,
3118c2ecf20Sopenharmony_ci						struct cxgbi_sock,
3128c2ecf20Sopenharmony_ci						refcnt);
3138c2ecf20Sopenharmony_ci	if (csk) {
3148c2ecf20Sopenharmony_ci		log_debug(1 << CXGBI_DBG_SOCK,
3158c2ecf20Sopenharmony_ci			"free csk 0x%p, state %u, flags 0x%lx\n",
3168c2ecf20Sopenharmony_ci			csk, csk->state, csk->flags);
3178c2ecf20Sopenharmony_ci		kfree(csk);
3188c2ecf20Sopenharmony_ci	}
3198c2ecf20Sopenharmony_ci}
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_cistatic inline void __cxgbi_sock_put(const char *fn, struct cxgbi_sock *csk)
3228c2ecf20Sopenharmony_ci{
3238c2ecf20Sopenharmony_ci	log_debug(1 << CXGBI_DBG_SOCK,
3248c2ecf20Sopenharmony_ci		"%s, put csk 0x%p, ref %u-1.\n",
3258c2ecf20Sopenharmony_ci		fn, csk, kref_read(&csk->refcnt));
3268c2ecf20Sopenharmony_ci	kref_put(&csk->refcnt, cxgbi_sock_free);
3278c2ecf20Sopenharmony_ci}
3288c2ecf20Sopenharmony_ci#define cxgbi_sock_put(csk)	__cxgbi_sock_put(__func__, csk)
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_cistatic inline void __cxgbi_sock_get(const char *fn, struct cxgbi_sock *csk)
3318c2ecf20Sopenharmony_ci{
3328c2ecf20Sopenharmony_ci	log_debug(1 << CXGBI_DBG_SOCK,
3338c2ecf20Sopenharmony_ci		"%s, get csk 0x%p, ref %u+1.\n",
3348c2ecf20Sopenharmony_ci		fn, csk, kref_read(&csk->refcnt));
3358c2ecf20Sopenharmony_ci	kref_get(&csk->refcnt);
3368c2ecf20Sopenharmony_ci}
3378c2ecf20Sopenharmony_ci#define cxgbi_sock_get(csk)	__cxgbi_sock_get(__func__, csk)
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_cistatic inline int cxgbi_sock_is_closing(struct cxgbi_sock *csk)
3408c2ecf20Sopenharmony_ci{
3418c2ecf20Sopenharmony_ci	return csk->state >= CTP_ACTIVE_CLOSE;
3428c2ecf20Sopenharmony_ci}
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_cistatic inline int cxgbi_sock_is_established(struct cxgbi_sock *csk)
3458c2ecf20Sopenharmony_ci{
3468c2ecf20Sopenharmony_ci	return csk->state == CTP_ESTABLISHED;
3478c2ecf20Sopenharmony_ci}
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_cistatic inline void cxgbi_sock_purge_write_queue(struct cxgbi_sock *csk)
3508c2ecf20Sopenharmony_ci{
3518c2ecf20Sopenharmony_ci	struct sk_buff *skb;
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci	while ((skb = __skb_dequeue(&csk->write_queue)))
3548c2ecf20Sopenharmony_ci		__kfree_skb(skb);
3558c2ecf20Sopenharmony_ci}
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_cistatic inline unsigned int cxgbi_sock_compute_wscale(unsigned int win)
3588c2ecf20Sopenharmony_ci{
3598c2ecf20Sopenharmony_ci	unsigned int wscale = 0;
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci	while (wscale < 14 && (65535 << wscale) < win)
3628c2ecf20Sopenharmony_ci		wscale++;
3638c2ecf20Sopenharmony_ci	return wscale;
3648c2ecf20Sopenharmony_ci}
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_cistatic inline struct sk_buff *alloc_wr(int wrlen, int dlen, gfp_t gfp)
3678c2ecf20Sopenharmony_ci{
3688c2ecf20Sopenharmony_ci	struct sk_buff *skb = alloc_skb(wrlen + dlen, gfp);
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci	if (skb) {
3718c2ecf20Sopenharmony_ci		__skb_put(skb, wrlen);
3728c2ecf20Sopenharmony_ci		memset(skb->head, 0, wrlen + dlen);
3738c2ecf20Sopenharmony_ci	} else
3748c2ecf20Sopenharmony_ci		pr_info("alloc cpl wr skb %u+%u, OOM.\n", wrlen, dlen);
3758c2ecf20Sopenharmony_ci	return skb;
3768c2ecf20Sopenharmony_ci}
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci/*
3808c2ecf20Sopenharmony_ci * The number of WRs needed for an skb depends on the number of fragments
3818c2ecf20Sopenharmony_ci * in the skb and whether it has any payload in its main body.  This maps the
3828c2ecf20Sopenharmony_ci * length of the gather list represented by an skb into the # of necessary WRs.
3838c2ecf20Sopenharmony_ci * The extra two fragments are for iscsi bhs and payload padding.
3848c2ecf20Sopenharmony_ci */
3858c2ecf20Sopenharmony_ci#define SKB_WR_LIST_SIZE	 (MAX_SKB_FRAGS + 2)
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_cistatic inline void cxgbi_sock_reset_wr_list(struct cxgbi_sock *csk)
3888c2ecf20Sopenharmony_ci{
3898c2ecf20Sopenharmony_ci	csk->wr_pending_head = csk->wr_pending_tail = NULL;
3908c2ecf20Sopenharmony_ci}
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_cistatic inline void cxgbi_sock_enqueue_wr(struct cxgbi_sock *csk,
3938c2ecf20Sopenharmony_ci					  struct sk_buff *skb)
3948c2ecf20Sopenharmony_ci{
3958c2ecf20Sopenharmony_ci	cxgbi_skcb_tx_wr_next(skb) = NULL;
3968c2ecf20Sopenharmony_ci	/*
3978c2ecf20Sopenharmony_ci	 * We want to take an extra reference since both us and the driver
3988c2ecf20Sopenharmony_ci	 * need to free the packet before it's really freed.
3998c2ecf20Sopenharmony_ci	 */
4008c2ecf20Sopenharmony_ci	skb_get(skb);
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci	if (!csk->wr_pending_head)
4038c2ecf20Sopenharmony_ci		csk->wr_pending_head = skb;
4048c2ecf20Sopenharmony_ci	else
4058c2ecf20Sopenharmony_ci		cxgbi_skcb_tx_wr_next(csk->wr_pending_tail) = skb;
4068c2ecf20Sopenharmony_ci	csk->wr_pending_tail = skb;
4078c2ecf20Sopenharmony_ci}
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_cistatic inline int cxgbi_sock_count_pending_wrs(const struct cxgbi_sock *csk)
4108c2ecf20Sopenharmony_ci{
4118c2ecf20Sopenharmony_ci	int n = 0;
4128c2ecf20Sopenharmony_ci	const struct sk_buff *skb = csk->wr_pending_head;
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	while (skb) {
4158c2ecf20Sopenharmony_ci		n += skb->csum;
4168c2ecf20Sopenharmony_ci		skb = cxgbi_skcb_tx_wr_next(skb);
4178c2ecf20Sopenharmony_ci	}
4188c2ecf20Sopenharmony_ci	return n;
4198c2ecf20Sopenharmony_ci}
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_cistatic inline struct sk_buff *cxgbi_sock_peek_wr(const struct cxgbi_sock *csk)
4228c2ecf20Sopenharmony_ci{
4238c2ecf20Sopenharmony_ci	return csk->wr_pending_head;
4248c2ecf20Sopenharmony_ci}
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_cistatic inline struct sk_buff *cxgbi_sock_dequeue_wr(struct cxgbi_sock *csk)
4278c2ecf20Sopenharmony_ci{
4288c2ecf20Sopenharmony_ci	struct sk_buff *skb = csk->wr_pending_head;
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci	if (likely(skb)) {
4318c2ecf20Sopenharmony_ci		csk->wr_pending_head = cxgbi_skcb_tx_wr_next(skb);
4328c2ecf20Sopenharmony_ci		cxgbi_skcb_tx_wr_next(skb) = NULL;
4338c2ecf20Sopenharmony_ci	}
4348c2ecf20Sopenharmony_ci	return skb;
4358c2ecf20Sopenharmony_ci}
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_civoid cxgbi_sock_check_wr_invariants(const struct cxgbi_sock *);
4388c2ecf20Sopenharmony_civoid cxgbi_sock_purge_wr_queue(struct cxgbi_sock *);
4398c2ecf20Sopenharmony_civoid cxgbi_sock_skb_entail(struct cxgbi_sock *, struct sk_buff *);
4408c2ecf20Sopenharmony_civoid cxgbi_sock_fail_act_open(struct cxgbi_sock *, int);
4418c2ecf20Sopenharmony_civoid cxgbi_sock_act_open_req_arp_failure(void *, struct sk_buff *);
4428c2ecf20Sopenharmony_civoid cxgbi_sock_closed(struct cxgbi_sock *);
4438c2ecf20Sopenharmony_civoid cxgbi_sock_established(struct cxgbi_sock *, unsigned int, unsigned int);
4448c2ecf20Sopenharmony_civoid cxgbi_sock_rcv_abort_rpl(struct cxgbi_sock *);
4458c2ecf20Sopenharmony_civoid cxgbi_sock_rcv_peer_close(struct cxgbi_sock *);
4468c2ecf20Sopenharmony_civoid cxgbi_sock_rcv_close_conn_rpl(struct cxgbi_sock *, u32);
4478c2ecf20Sopenharmony_civoid cxgbi_sock_rcv_wr_ack(struct cxgbi_sock *, unsigned int, unsigned int,
4488c2ecf20Sopenharmony_ci				int);
4498c2ecf20Sopenharmony_ciunsigned int cxgbi_sock_select_mss(struct cxgbi_sock *, unsigned int);
4508c2ecf20Sopenharmony_civoid cxgbi_sock_free_cpl_skbs(struct cxgbi_sock *);
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_cistruct cxgbi_hba {
4538c2ecf20Sopenharmony_ci	struct net_device *ndev;
4548c2ecf20Sopenharmony_ci	struct net_device *vdev;	/* vlan dev */
4558c2ecf20Sopenharmony_ci	struct Scsi_Host *shost;
4568c2ecf20Sopenharmony_ci	struct cxgbi_device *cdev;
4578c2ecf20Sopenharmony_ci	__be32 ipv4addr;
4588c2ecf20Sopenharmony_ci	unsigned char port_id;
4598c2ecf20Sopenharmony_ci};
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_cistruct cxgbi_ports_map {
4628c2ecf20Sopenharmony_ci	unsigned int max_connect;
4638c2ecf20Sopenharmony_ci	unsigned int used;
4648c2ecf20Sopenharmony_ci	unsigned short sport_base;
4658c2ecf20Sopenharmony_ci	spinlock_t lock;
4668c2ecf20Sopenharmony_ci	unsigned int next;
4678c2ecf20Sopenharmony_ci	struct cxgbi_sock **port_csk;
4688c2ecf20Sopenharmony_ci};
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci#define CXGBI_FLAG_DEV_T3		0x1
4718c2ecf20Sopenharmony_ci#define CXGBI_FLAG_DEV_T4		0x2
4728c2ecf20Sopenharmony_ci#define CXGBI_FLAG_ADAPTER_RESET	0x4
4738c2ecf20Sopenharmony_ci#define CXGBI_FLAG_IPV4_SET		0x10
4748c2ecf20Sopenharmony_ci#define CXGBI_FLAG_USE_PPOD_OFLDQ       0x40
4758c2ecf20Sopenharmony_ci#define CXGBI_FLAG_DDP_OFF		0x100
4768c2ecf20Sopenharmony_ci#define CXGBI_FLAG_DEV_ISO_OFF		0x400
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_cistruct cxgbi_device {
4798c2ecf20Sopenharmony_ci	struct list_head list_head;
4808c2ecf20Sopenharmony_ci	struct list_head rcu_node;
4818c2ecf20Sopenharmony_ci	unsigned int flags;
4828c2ecf20Sopenharmony_ci	struct net_device **ports;
4838c2ecf20Sopenharmony_ci	void *lldev;
4848c2ecf20Sopenharmony_ci	struct cxgbi_hba **hbas;
4858c2ecf20Sopenharmony_ci	const unsigned short *mtus;
4868c2ecf20Sopenharmony_ci	unsigned char nmtus;
4878c2ecf20Sopenharmony_ci	unsigned char nports;
4888c2ecf20Sopenharmony_ci	struct pci_dev *pdev;
4898c2ecf20Sopenharmony_ci	struct dentry *debugfs_root;
4908c2ecf20Sopenharmony_ci	struct iscsi_transport *itp;
4918c2ecf20Sopenharmony_ci	struct module *owner;
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci	unsigned int pfvf;
4948c2ecf20Sopenharmony_ci	unsigned int rx_credit_thres;
4958c2ecf20Sopenharmony_ci	unsigned int skb_tx_rsvd;
4968c2ecf20Sopenharmony_ci	u32 skb_iso_txhdr;
4978c2ecf20Sopenharmony_ci	unsigned int skb_rx_extra;	/* for msg coalesced mode */
4988c2ecf20Sopenharmony_ci	unsigned int tx_max_size;
4998c2ecf20Sopenharmony_ci	unsigned int rx_max_size;
5008c2ecf20Sopenharmony_ci	unsigned int rxq_idx_cntr;
5018c2ecf20Sopenharmony_ci	struct cxgbi_ports_map pmap;
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_ci	void (*dev_ddp_cleanup)(struct cxgbi_device *);
5048c2ecf20Sopenharmony_ci	struct cxgbi_ppm* (*cdev2ppm)(struct cxgbi_device *);
5058c2ecf20Sopenharmony_ci	int (*csk_ddp_set_map)(struct cxgbi_ppm *, struct cxgbi_sock *,
5068c2ecf20Sopenharmony_ci			       struct cxgbi_task_tag_info *);
5078c2ecf20Sopenharmony_ci	void (*csk_ddp_clear_map)(struct cxgbi_device *cdev,
5088c2ecf20Sopenharmony_ci				  struct cxgbi_ppm *,
5098c2ecf20Sopenharmony_ci				  struct cxgbi_task_tag_info *);
5108c2ecf20Sopenharmony_ci	int (*csk_ddp_setup_digest)(struct cxgbi_sock *,
5118c2ecf20Sopenharmony_ci				    unsigned int, int, int);
5128c2ecf20Sopenharmony_ci	int (*csk_ddp_setup_pgidx)(struct cxgbi_sock *,
5138c2ecf20Sopenharmony_ci				   unsigned int, int);
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci	void (*csk_release_offload_resources)(struct cxgbi_sock *);
5168c2ecf20Sopenharmony_ci	int (*csk_rx_pdu_ready)(struct cxgbi_sock *, struct sk_buff *);
5178c2ecf20Sopenharmony_ci	u32 (*csk_send_rx_credits)(struct cxgbi_sock *, u32);
5188c2ecf20Sopenharmony_ci	int (*csk_push_tx_frames)(struct cxgbi_sock *, int);
5198c2ecf20Sopenharmony_ci	void (*csk_send_abort_req)(struct cxgbi_sock *);
5208c2ecf20Sopenharmony_ci	void (*csk_send_close_req)(struct cxgbi_sock *);
5218c2ecf20Sopenharmony_ci	int (*csk_alloc_cpls)(struct cxgbi_sock *);
5228c2ecf20Sopenharmony_ci	int (*csk_init_act_open)(struct cxgbi_sock *);
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_ci	void *dd_data;
5258c2ecf20Sopenharmony_ci};
5268c2ecf20Sopenharmony_ci#define cxgbi_cdev_priv(cdev)	((cdev)->dd_data)
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_cistruct cxgbi_conn {
5298c2ecf20Sopenharmony_ci	struct cxgbi_endpoint *cep;
5308c2ecf20Sopenharmony_ci	struct iscsi_conn *iconn;
5318c2ecf20Sopenharmony_ci	struct cxgbi_hba *chba;
5328c2ecf20Sopenharmony_ci	u32 task_idx_bits;
5338c2ecf20Sopenharmony_ci	unsigned int ddp_full;
5348c2ecf20Sopenharmony_ci	unsigned int ddp_tag_full;
5358c2ecf20Sopenharmony_ci};
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_cistruct cxgbi_endpoint {
5388c2ecf20Sopenharmony_ci	struct cxgbi_conn *cconn;
5398c2ecf20Sopenharmony_ci	struct cxgbi_hba *chba;
5408c2ecf20Sopenharmony_ci	struct cxgbi_sock *csk;
5418c2ecf20Sopenharmony_ci};
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_cistruct cxgbi_task_data {
5448c2ecf20Sopenharmony_ci#define CXGBI_TASK_SGL_CHECKED	0x1
5458c2ecf20Sopenharmony_ci#define CXGBI_TASK_SGL_COPY	0x2
5468c2ecf20Sopenharmony_ci	u8 flags;
5478c2ecf20Sopenharmony_ci	unsigned short nr_frags;
5488c2ecf20Sopenharmony_ci	struct page_frag frags[MAX_SKB_FRAGS];
5498c2ecf20Sopenharmony_ci	struct sk_buff *skb;
5508c2ecf20Sopenharmony_ci	unsigned int dlen;
5518c2ecf20Sopenharmony_ci	unsigned int offset;
5528c2ecf20Sopenharmony_ci	unsigned int count;
5538c2ecf20Sopenharmony_ci	unsigned int sgoffset;
5548c2ecf20Sopenharmony_ci	u32 total_count;
5558c2ecf20Sopenharmony_ci	u32 total_offset;
5568c2ecf20Sopenharmony_ci	u32 max_xmit_dlength;
5578c2ecf20Sopenharmony_ci	struct cxgbi_task_tag_info ttinfo;
5588c2ecf20Sopenharmony_ci};
5598c2ecf20Sopenharmony_ci#define iscsi_task_cxgbi_data(task) \
5608c2ecf20Sopenharmony_ci	((task)->dd_data + sizeof(struct iscsi_tcp_task))
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_cistruct cxgbi_iso_info {
5638c2ecf20Sopenharmony_ci#define CXGBI_ISO_INFO_FSLICE		0x1
5648c2ecf20Sopenharmony_ci#define CXGBI_ISO_INFO_LSLICE		0x2
5658c2ecf20Sopenharmony_ci#define CXGBI_ISO_INFO_IMM_ENABLE	0x4
5668c2ecf20Sopenharmony_ci	u8 flags;
5678c2ecf20Sopenharmony_ci	u8 op;
5688c2ecf20Sopenharmony_ci	u8 ahs;
5698c2ecf20Sopenharmony_ci	u8 num_pdu;
5708c2ecf20Sopenharmony_ci	u32 mpdu;
5718c2ecf20Sopenharmony_ci	u32 burst_size;
5728c2ecf20Sopenharmony_ci	u32 len;
5738c2ecf20Sopenharmony_ci	u32 segment_offset;
5748c2ecf20Sopenharmony_ci	u32 datasn_offset;
5758c2ecf20Sopenharmony_ci	u32 buffer_offset;
5768c2ecf20Sopenharmony_ci};
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_cistatic inline void cxgbi_set_iscsi_ipv4(struct cxgbi_hba *chba, __be32 ipaddr)
5798c2ecf20Sopenharmony_ci{
5808c2ecf20Sopenharmony_ci	if (chba->cdev->flags & CXGBI_FLAG_IPV4_SET)
5818c2ecf20Sopenharmony_ci		chba->ipv4addr = ipaddr;
5828c2ecf20Sopenharmony_ci	else
5838c2ecf20Sopenharmony_ci		pr_info("set iscsi ipv4 NOT supported, using %s ipv4.\n",
5848c2ecf20Sopenharmony_ci			chba->ndev->name);
5858c2ecf20Sopenharmony_ci}
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_cistruct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int);
5888c2ecf20Sopenharmony_civoid cxgbi_device_unregister(struct cxgbi_device *);
5898c2ecf20Sopenharmony_civoid cxgbi_device_unregister_all(unsigned int flag);
5908c2ecf20Sopenharmony_cistruct cxgbi_device *cxgbi_device_find_by_lldev(void *);
5918c2ecf20Sopenharmony_cistruct cxgbi_device *cxgbi_device_find_by_netdev(struct net_device *, int *);
5928c2ecf20Sopenharmony_cistruct cxgbi_device *cxgbi_device_find_by_netdev_rcu(struct net_device *,
5938c2ecf20Sopenharmony_ci						     int *);
5948c2ecf20Sopenharmony_ciint cxgbi_hbas_add(struct cxgbi_device *, u64, unsigned int,
5958c2ecf20Sopenharmony_ci			struct scsi_host_template *,
5968c2ecf20Sopenharmony_ci			struct scsi_transport_template *);
5978c2ecf20Sopenharmony_civoid cxgbi_hbas_remove(struct cxgbi_device *);
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ciint cxgbi_device_portmap_create(struct cxgbi_device *cdev, unsigned int base,
6008c2ecf20Sopenharmony_ci			unsigned int max_conn);
6018c2ecf20Sopenharmony_civoid cxgbi_device_portmap_cleanup(struct cxgbi_device *cdev);
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_civoid cxgbi_conn_tx_open(struct cxgbi_sock *);
6048c2ecf20Sopenharmony_civoid cxgbi_conn_pdu_ready(struct cxgbi_sock *);
6058c2ecf20Sopenharmony_ciint cxgbi_conn_alloc_pdu(struct iscsi_task *, u8);
6068c2ecf20Sopenharmony_ciint cxgbi_conn_init_pdu(struct iscsi_task *, unsigned int , unsigned int);
6078c2ecf20Sopenharmony_ciint cxgbi_conn_xmit_pdu(struct iscsi_task *);
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_civoid cxgbi_cleanup_task(struct iscsi_task *task);
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_ciumode_t cxgbi_attr_is_visible(int param_type, int param);
6128c2ecf20Sopenharmony_civoid cxgbi_get_conn_stats(struct iscsi_cls_conn *, struct iscsi_stats *);
6138c2ecf20Sopenharmony_ciint cxgbi_set_conn_param(struct iscsi_cls_conn *,
6148c2ecf20Sopenharmony_ci			enum iscsi_param, char *, int);
6158c2ecf20Sopenharmony_ciint cxgbi_get_ep_param(struct iscsi_endpoint *ep, enum iscsi_param, char *);
6168c2ecf20Sopenharmony_cistruct iscsi_cls_conn *cxgbi_create_conn(struct iscsi_cls_session *, u32);
6178c2ecf20Sopenharmony_ciint cxgbi_bind_conn(struct iscsi_cls_session *,
6188c2ecf20Sopenharmony_ci			struct iscsi_cls_conn *, u64, int);
6198c2ecf20Sopenharmony_civoid cxgbi_destroy_session(struct iscsi_cls_session *);
6208c2ecf20Sopenharmony_cistruct iscsi_cls_session *cxgbi_create_session(struct iscsi_endpoint *,
6218c2ecf20Sopenharmony_ci			u16, u16, u32);
6228c2ecf20Sopenharmony_ciint cxgbi_set_host_param(struct Scsi_Host *,
6238c2ecf20Sopenharmony_ci			enum iscsi_host_param, char *, int);
6248c2ecf20Sopenharmony_ciint cxgbi_get_host_param(struct Scsi_Host *, enum iscsi_host_param, char *);
6258c2ecf20Sopenharmony_cistruct iscsi_endpoint *cxgbi_ep_connect(struct Scsi_Host *,
6268c2ecf20Sopenharmony_ci			struct sockaddr *, int);
6278c2ecf20Sopenharmony_ciint cxgbi_ep_poll(struct iscsi_endpoint *, int);
6288c2ecf20Sopenharmony_civoid cxgbi_ep_disconnect(struct iscsi_endpoint *);
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ciint cxgbi_iscsi_init(struct iscsi_transport *,
6318c2ecf20Sopenharmony_ci			struct scsi_transport_template **);
6328c2ecf20Sopenharmony_civoid cxgbi_iscsi_cleanup(struct iscsi_transport *,
6338c2ecf20Sopenharmony_ci			struct scsi_transport_template **);
6348c2ecf20Sopenharmony_civoid cxgbi_parse_pdu_itt(struct iscsi_conn *, itt_t, int *, int *);
6358c2ecf20Sopenharmony_ciint cxgbi_ddp_init(struct cxgbi_device *, unsigned int, unsigned int,
6368c2ecf20Sopenharmony_ci			unsigned int, unsigned int);
6378c2ecf20Sopenharmony_ciint cxgbi_ddp_cleanup(struct cxgbi_device *);
6388c2ecf20Sopenharmony_civoid cxgbi_ddp_page_size_factor(int *);
6398c2ecf20Sopenharmony_civoid cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *,
6408c2ecf20Sopenharmony_ci			    struct cxgbi_task_tag_info *,
6418c2ecf20Sopenharmony_ci			    struct scatterlist **sg_pp, unsigned int *sg_off);
6428c2ecf20Sopenharmony_ciint cxgbi_ddp_ppm_setup(void **ppm_pp, struct cxgbi_device *cdev,
6438c2ecf20Sopenharmony_ci			struct cxgbi_tag_format *tformat,
6448c2ecf20Sopenharmony_ci			unsigned int iscsi_size, unsigned int llimit,
6458c2ecf20Sopenharmony_ci			unsigned int start, unsigned int rsvd_factor,
6468c2ecf20Sopenharmony_ci			unsigned int edram_start, unsigned int edram_size);
6478c2ecf20Sopenharmony_ci#endif	/*__LIBCXGBI_H__*/
648