Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * libcxgbi.h: Chelsio common library for T3/T4 iSCSI driver.
0003  *
0004  * Copyright (c) 2010-2015 Chelsio Communications, Inc.
0005  *
0006  * This program is free software; you can redistribute it and/or modify
0007  * it under the terms of the GNU General Public License as published by
0008  * the Free Software Foundation.
0009  *
0010  * Written by: Karen Xie (kxie@chelsio.com)
0011  * Written by: Rakesh Ranjan (rranjan@chelsio.com)
0012  */
0013 
0014 #ifndef __LIBCXGBI_H__
0015 #define __LIBCXGBI_H__
0016 
0017 #include <linux/kernel.h>
0018 #include <linux/errno.h>
0019 #include <linux/types.h>
0020 #include <linux/debugfs.h>
0021 #include <linux/list.h>
0022 #include <linux/netdevice.h>
0023 #include <linux/if_vlan.h>
0024 #include <linux/scatterlist.h>
0025 #include <linux/skbuff.h>
0026 #include <linux/vmalloc.h>
0027 #include <linux/version.h>
0028 #include <scsi/scsi_device.h>
0029 #include <scsi/libiscsi_tcp.h>
0030 
0031 #include <libcxgb_ppm.h>
0032 
0033 enum cxgbi_dbg_flag {
0034     CXGBI_DBG_ISCSI,
0035     CXGBI_DBG_DDP,
0036     CXGBI_DBG_TOE,
0037     CXGBI_DBG_SOCK,
0038 
0039     CXGBI_DBG_PDU_TX,
0040     CXGBI_DBG_PDU_RX,
0041     CXGBI_DBG_DEV,
0042 };
0043 
0044 #define log_debug(level, fmt, ...)  \
0045     do {    \
0046         if (dbg_level & (level)) \
0047             pr_info(fmt, ##__VA_ARGS__); \
0048     } while (0)
0049 
0050 #define pr_info_ipaddr(fmt_trail,                   \
0051             addr1, addr2, args_trail...)            \
0052 do {                                    \
0053     if (!((1 << CXGBI_DBG_SOCK) & dbg_level))           \
0054         break;                          \
0055     pr_info("%pISpc - %pISpc, " fmt_trail,              \
0056         addr1, addr2, args_trail);              \
0057 } while (0)
0058 
0059 /* max. connections per adapter */
0060 #define CXGBI_MAX_CONN      16384
0061 
0062 /* always allocate rooms for AHS */
0063 #define SKB_TX_ISCSI_PDU_HEADER_MAX \
0064     (sizeof(struct iscsi_hdr) + ISCSI_MAX_AHS_SIZE)
0065 
0066 #define ISCSI_PDU_NONPAYLOAD_LEN    312 /* bhs(48) + ahs(256) + digest(8)*/
0067 
0068 /*
0069  * align pdu size to multiple of 512 for better performance
0070  */
0071 #define cxgbi_align_pdu_size(n) do { n = (n) & (~511); } while (0)
0072 
0073 #define ULP2_MODE_ISCSI     2
0074 
0075 #define ULP2_MAX_PKT_SIZE   16224
0076 #define ULP2_MAX_PDU_PAYLOAD    \
0077     (ULP2_MAX_PKT_SIZE - ISCSI_PDU_NONPAYLOAD_LEN)
0078 
0079 #define CXGBI_ULP2_MAX_ISO_PAYLOAD  65535
0080 
0081 #define CXGBI_MAX_ISO_DATA_IN_SKB   \
0082     min_t(u32, MAX_SKB_FRAGS << PAGE_SHIFT, CXGBI_ULP2_MAX_ISO_PAYLOAD)
0083 
0084 #define cxgbi_is_iso_config(csk)    ((csk)->cdev->skb_iso_txhdr)
0085 #define cxgbi_is_iso_disabled(csk)  ((csk)->disable_iso)
0086 
0087 /*
0088  * For iscsi connections HW may inserts digest bytes into the pdu. Those digest
0089  * bytes are not sent by the host but are part of the TCP payload and therefore
0090  * consume TCP sequence space.
0091  */
0092 static const unsigned int ulp2_extra_len[] = { 0, 4, 4, 8 };
0093 static inline unsigned int cxgbi_ulp_extra_len(int submode)
0094 {
0095     return ulp2_extra_len[submode & 3];
0096 }
0097 
0098 #define CPL_RX_DDP_STATUS_DDP_SHIFT 16 /* ddp'able */
0099 #define CPL_RX_DDP_STATUS_PAD_SHIFT 19 /* pad error */
0100 #define CPL_RX_DDP_STATUS_HCRC_SHIFT    20 /* hcrc error */
0101 #define CPL_RX_DDP_STATUS_DCRC_SHIFT    21 /* dcrc error */
0102 
0103 /*
0104  * sge_opaque_hdr -
0105  * Opaque version of structure the SGE stores at skb->head of TX_DATA packets
0106  * and for which we must reserve space.
0107  */
0108 struct sge_opaque_hdr {
0109     void *dev;
0110     dma_addr_t addr[MAX_SKB_FRAGS + 1];
0111 };
0112 
0113 struct cxgbi_sock {
0114     struct cxgbi_device *cdev;
0115 
0116     int tid;
0117     int atid;
0118     unsigned long flags;
0119     unsigned int mtu;
0120     unsigned short rss_qid;
0121     unsigned short txq_idx;
0122     unsigned short advmss;
0123     unsigned int tx_chan;
0124     unsigned int rx_chan;
0125     unsigned int mss_idx;
0126     unsigned int smac_idx;
0127     unsigned char port_id;
0128     int wr_max_cred;
0129     int wr_cred;
0130     int wr_una_cred;
0131 #ifdef CONFIG_CHELSIO_T4_DCB
0132     u8 dcb_priority;
0133 #endif
0134     unsigned char hcrc_len;
0135     unsigned char dcrc_len;
0136 
0137     void *l2t;
0138     struct sk_buff *wr_pending_head;
0139     struct sk_buff *wr_pending_tail;
0140     struct sk_buff *cpl_close;
0141     struct sk_buff *cpl_abort_req;
0142     struct sk_buff *cpl_abort_rpl;
0143     struct sk_buff *skb_ulp_lhdr;
0144     spinlock_t lock;
0145     struct kref refcnt;
0146     unsigned int state;
0147     unsigned int csk_family;
0148     union {
0149         struct sockaddr_in saddr;
0150         struct sockaddr_in6 saddr6;
0151     };
0152     union {
0153         struct sockaddr_in daddr;
0154         struct sockaddr_in6 daddr6;
0155     };
0156     struct dst_entry *dst;
0157     struct sk_buff_head receive_queue;
0158     struct sk_buff_head write_queue;
0159     struct timer_list retry_timer;
0160     struct completion cmpl;
0161     int err;
0162     rwlock_t callback_lock;
0163     void *user_data;
0164 
0165     u32 rcv_nxt;
0166     u32 copied_seq;
0167     u32 rcv_wup;
0168     u32 snd_nxt;
0169     u32 snd_una;
0170     u32 write_seq;
0171     u32 snd_win;
0172     u32 rcv_win;
0173 
0174     bool disable_iso;
0175     u32 no_tx_credits;
0176     unsigned long prev_iso_ts;
0177 };
0178 
0179 /*
0180  * connection states
0181  */
0182 enum cxgbi_sock_states{
0183     CTP_CLOSED,
0184     CTP_CONNECTING,
0185     CTP_ACTIVE_OPEN,
0186     CTP_ESTABLISHED,
0187     CTP_ACTIVE_CLOSE,
0188     CTP_PASSIVE_CLOSE,
0189     CTP_CLOSE_WAIT_1,
0190     CTP_CLOSE_WAIT_2,
0191     CTP_ABORTING,
0192 };
0193 
0194 /*
0195  * Connection flags -- many to track some close related events.
0196  */
0197 enum cxgbi_sock_flags {
0198     CTPF_ABORT_RPL_RCVD,    /*received one ABORT_RPL_RSS message */
0199     CTPF_ABORT_REQ_RCVD,    /*received one ABORT_REQ_RSS message */
0200     CTPF_ABORT_RPL_PENDING, /* expecting an abort reply */
0201     CTPF_TX_DATA_SENT,  /* already sent a TX_DATA WR */
0202     CTPF_ACTIVE_CLOSE_NEEDED,/* need to be closed */
0203     CTPF_HAS_ATID,      /* reserved atid */
0204     CTPF_HAS_TID,       /* reserved hw tid */
0205     CTPF_OFFLOAD_DOWN,  /* offload function off */
0206     CTPF_LOGOUT_RSP_RCVD,   /* received logout response */
0207 };
0208 
0209 struct cxgbi_skb_rx_cb {
0210     __u32 ddigest;
0211     __u32 pdulen;
0212 };
0213 
0214 struct cxgbi_skb_tx_cb {
0215     void *handle;
0216     void *arp_err_handler;
0217     struct sk_buff *wr_next;
0218     u16 iscsi_hdr_len;
0219     u8 ulp_mode;
0220 };
0221 
0222 enum cxgbi_skcb_flags {
0223     SKCBF_TX_NEED_HDR,  /* packet needs a header */
0224     SKCBF_TX_MEM_WRITE,     /* memory write */
0225     SKCBF_TX_FLAG_COMPL,    /* wr completion flag */
0226     SKCBF_RX_COALESCED, /* received whole pdu */
0227     SKCBF_RX_HDR,       /* received pdu header */
0228     SKCBF_RX_DATA,      /* received pdu payload */
0229     SKCBF_RX_STATUS,    /* received ddp status */
0230     SKCBF_RX_ISCSI_COMPL,   /* received iscsi completion */
0231     SKCBF_RX_DATA_DDPD, /* pdu payload ddp'd */
0232     SKCBF_RX_HCRC_ERR,  /* header digest error */
0233     SKCBF_RX_DCRC_ERR,  /* data digest error */
0234     SKCBF_RX_PAD_ERR,   /* padding byte error */
0235     SKCBF_TX_ISO,       /* iso cpl in tx skb */
0236 };
0237 
0238 struct cxgbi_skb_cb {
0239     union {
0240         struct cxgbi_skb_rx_cb rx;
0241         struct cxgbi_skb_tx_cb tx;
0242     };
0243     unsigned long flags;
0244     unsigned int seq;
0245 };
0246 
0247 #define CXGBI_SKB_CB(skb)   ((struct cxgbi_skb_cb *)&((skb)->cb[0]))
0248 #define cxgbi_skcb_flags(skb)       (CXGBI_SKB_CB(skb)->flags)
0249 #define cxgbi_skcb_tcp_seq(skb)     (CXGBI_SKB_CB(skb)->seq)
0250 #define cxgbi_skcb_rx_ddigest(skb)  (CXGBI_SKB_CB(skb)->rx.ddigest)
0251 #define cxgbi_skcb_rx_pdulen(skb)   (CXGBI_SKB_CB(skb)->rx.pdulen)
0252 #define cxgbi_skcb_tx_wr_next(skb)  (CXGBI_SKB_CB(skb)->tx.wr_next)
0253 #define cxgbi_skcb_tx_iscsi_hdrlen(skb) (CXGBI_SKB_CB(skb)->tx.iscsi_hdr_len)
0254 #define cxgbi_skcb_tx_ulp_mode(skb) (CXGBI_SKB_CB(skb)->tx.ulp_mode)
0255 
0256 static inline void cxgbi_skcb_set_flag(struct sk_buff *skb,
0257                     enum cxgbi_skcb_flags flag)
0258 {
0259     __set_bit(flag, &(cxgbi_skcb_flags(skb)));
0260 }
0261 
0262 static inline void cxgbi_skcb_clear_flag(struct sk_buff *skb,
0263                     enum cxgbi_skcb_flags flag)
0264 {
0265     __clear_bit(flag, &(cxgbi_skcb_flags(skb)));
0266 }
0267 
0268 static inline int cxgbi_skcb_test_flag(const struct sk_buff *skb,
0269                        enum cxgbi_skcb_flags flag)
0270 {
0271     return test_bit(flag, &(cxgbi_skcb_flags(skb)));
0272 }
0273 
0274 static inline void cxgbi_sock_set_flag(struct cxgbi_sock *csk,
0275                     enum cxgbi_sock_flags flag)
0276 {
0277     __set_bit(flag, &csk->flags);
0278     log_debug(1 << CXGBI_DBG_SOCK,
0279         "csk 0x%p,%u,0x%lx, bit %d.\n",
0280         csk, csk->state, csk->flags, flag);
0281 }
0282 
0283 static inline void cxgbi_sock_clear_flag(struct cxgbi_sock *csk,
0284                     enum cxgbi_sock_flags flag)
0285 {
0286     __clear_bit(flag, &csk->flags);
0287     log_debug(1 << CXGBI_DBG_SOCK,
0288         "csk 0x%p,%u,0x%lx, bit %d.\n",
0289         csk, csk->state, csk->flags, flag);
0290 }
0291 
0292 static inline int cxgbi_sock_flag(struct cxgbi_sock *csk,
0293                 enum cxgbi_sock_flags flag)
0294 {
0295     if (csk == NULL)
0296         return 0;
0297     return test_bit(flag, &csk->flags);
0298 }
0299 
0300 static inline void cxgbi_sock_set_state(struct cxgbi_sock *csk, int state)
0301 {
0302     log_debug(1 << CXGBI_DBG_SOCK,
0303         "csk 0x%p,%u,0x%lx, state -> %u.\n",
0304         csk, csk->state, csk->flags, state);
0305     csk->state = state;
0306 }
0307 
0308 static inline void cxgbi_sock_free(struct kref *kref)
0309 {
0310     struct cxgbi_sock *csk = container_of(kref,
0311                         struct cxgbi_sock,
0312                         refcnt);
0313     if (csk) {
0314         log_debug(1 << CXGBI_DBG_SOCK,
0315             "free csk 0x%p, state %u, flags 0x%lx\n",
0316             csk, csk->state, csk->flags);
0317         kfree(csk);
0318     }
0319 }
0320 
0321 static inline void __cxgbi_sock_put(const char *fn, struct cxgbi_sock *csk)
0322 {
0323     log_debug(1 << CXGBI_DBG_SOCK,
0324         "%s, put csk 0x%p, ref %u-1.\n",
0325         fn, csk, kref_read(&csk->refcnt));
0326     kref_put(&csk->refcnt, cxgbi_sock_free);
0327 }
0328 #define cxgbi_sock_put(csk) __cxgbi_sock_put(__func__, csk)
0329 
0330 static inline void __cxgbi_sock_get(const char *fn, struct cxgbi_sock *csk)
0331 {
0332     log_debug(1 << CXGBI_DBG_SOCK,
0333         "%s, get csk 0x%p, ref %u+1.\n",
0334         fn, csk, kref_read(&csk->refcnt));
0335     kref_get(&csk->refcnt);
0336 }
0337 #define cxgbi_sock_get(csk) __cxgbi_sock_get(__func__, csk)
0338 
0339 static inline int cxgbi_sock_is_closing(struct cxgbi_sock *csk)
0340 {
0341     return csk->state >= CTP_ACTIVE_CLOSE;
0342 }
0343 
0344 static inline int cxgbi_sock_is_established(struct cxgbi_sock *csk)
0345 {
0346     return csk->state == CTP_ESTABLISHED;
0347 }
0348 
0349 static inline void cxgbi_sock_purge_write_queue(struct cxgbi_sock *csk)
0350 {
0351     struct sk_buff *skb;
0352 
0353     while ((skb = __skb_dequeue(&csk->write_queue)))
0354         __kfree_skb(skb);
0355 }
0356 
0357 static inline unsigned int cxgbi_sock_compute_wscale(unsigned int win)
0358 {
0359     unsigned int wscale = 0;
0360 
0361     while (wscale < 14 && (65535 << wscale) < win)
0362         wscale++;
0363     return wscale;
0364 }
0365 
0366 static inline struct sk_buff *alloc_wr(int wrlen, int dlen, gfp_t gfp)
0367 {
0368     struct sk_buff *skb = alloc_skb(wrlen + dlen, gfp);
0369 
0370     if (skb) {
0371         __skb_put(skb, wrlen);
0372         memset(skb->head, 0, wrlen + dlen);
0373     } else
0374         pr_info("alloc cpl wr skb %u+%u, OOM.\n", wrlen, dlen);
0375     return skb;
0376 }
0377 
0378 
0379 /*
0380  * The number of WRs needed for an skb depends on the number of fragments
0381  * in the skb and whether it has any payload in its main body.  This maps the
0382  * length of the gather list represented by an skb into the # of necessary WRs.
0383  * The extra two fragments are for iscsi bhs and payload padding.
0384  */
0385 #define SKB_WR_LIST_SIZE     (MAX_SKB_FRAGS + 2)
0386 
0387 static inline void cxgbi_sock_reset_wr_list(struct cxgbi_sock *csk)
0388 {
0389     csk->wr_pending_head = csk->wr_pending_tail = NULL;
0390 }
0391 
0392 static inline void cxgbi_sock_enqueue_wr(struct cxgbi_sock *csk,
0393                       struct sk_buff *skb)
0394 {
0395     cxgbi_skcb_tx_wr_next(skb) = NULL;
0396     /*
0397      * We want to take an extra reference since both us and the driver
0398      * need to free the packet before it's really freed.
0399      */
0400     skb_get(skb);
0401 
0402     if (!csk->wr_pending_head)
0403         csk->wr_pending_head = skb;
0404     else
0405         cxgbi_skcb_tx_wr_next(csk->wr_pending_tail) = skb;
0406     csk->wr_pending_tail = skb;
0407 }
0408 
0409 static inline int cxgbi_sock_count_pending_wrs(const struct cxgbi_sock *csk)
0410 {
0411     int n = 0;
0412     const struct sk_buff *skb = csk->wr_pending_head;
0413 
0414     while (skb) {
0415         n += skb->csum;
0416         skb = cxgbi_skcb_tx_wr_next(skb);
0417     }
0418     return n;
0419 }
0420 
0421 static inline struct sk_buff *cxgbi_sock_peek_wr(const struct cxgbi_sock *csk)
0422 {
0423     return csk->wr_pending_head;
0424 }
0425 
0426 static inline struct sk_buff *cxgbi_sock_dequeue_wr(struct cxgbi_sock *csk)
0427 {
0428     struct sk_buff *skb = csk->wr_pending_head;
0429 
0430     if (likely(skb)) {
0431         csk->wr_pending_head = cxgbi_skcb_tx_wr_next(skb);
0432         cxgbi_skcb_tx_wr_next(skb) = NULL;
0433     }
0434     return skb;
0435 }
0436 
0437 void cxgbi_sock_check_wr_invariants(const struct cxgbi_sock *);
0438 void cxgbi_sock_purge_wr_queue(struct cxgbi_sock *);
0439 void cxgbi_sock_skb_entail(struct cxgbi_sock *, struct sk_buff *);
0440 void cxgbi_sock_fail_act_open(struct cxgbi_sock *, int);
0441 void cxgbi_sock_act_open_req_arp_failure(void *, struct sk_buff *);
0442 void cxgbi_sock_closed(struct cxgbi_sock *);
0443 void cxgbi_sock_established(struct cxgbi_sock *, unsigned int, unsigned int);
0444 void cxgbi_sock_rcv_abort_rpl(struct cxgbi_sock *);
0445 void cxgbi_sock_rcv_peer_close(struct cxgbi_sock *);
0446 void cxgbi_sock_rcv_close_conn_rpl(struct cxgbi_sock *, u32);
0447 void cxgbi_sock_rcv_wr_ack(struct cxgbi_sock *, unsigned int, unsigned int,
0448                 int);
0449 unsigned int cxgbi_sock_select_mss(struct cxgbi_sock *, unsigned int);
0450 void cxgbi_sock_free_cpl_skbs(struct cxgbi_sock *);
0451 
0452 struct cxgbi_hba {
0453     struct net_device *ndev;
0454     struct net_device *vdev;    /* vlan dev */
0455     struct Scsi_Host *shost;
0456     struct cxgbi_device *cdev;
0457     __be32 ipv4addr;
0458     unsigned char port_id;
0459 };
0460 
0461 struct cxgbi_ports_map {
0462     unsigned int max_connect;
0463     unsigned int used;
0464     unsigned short sport_base;
0465     spinlock_t lock;
0466     unsigned int next;
0467     struct cxgbi_sock **port_csk;
0468 };
0469 
0470 #define CXGBI_FLAG_DEV_T3       0x1
0471 #define CXGBI_FLAG_DEV_T4       0x2
0472 #define CXGBI_FLAG_ADAPTER_RESET    0x4
0473 #define CXGBI_FLAG_IPV4_SET     0x10
0474 #define CXGBI_FLAG_USE_PPOD_OFLDQ       0x40
0475 #define CXGBI_FLAG_DDP_OFF      0x100
0476 #define CXGBI_FLAG_DEV_ISO_OFF      0x400
0477 
0478 struct cxgbi_device {
0479     struct list_head list_head;
0480     struct list_head rcu_node;
0481     unsigned int flags;
0482     struct net_device **ports;
0483     void *lldev;
0484     struct cxgbi_hba **hbas;
0485     const unsigned short *mtus;
0486     unsigned char nmtus;
0487     unsigned char nports;
0488     struct pci_dev *pdev;
0489     struct dentry *debugfs_root;
0490     struct iscsi_transport *itp;
0491     struct module *owner;
0492 
0493     unsigned int pfvf;
0494     unsigned int rx_credit_thres;
0495     unsigned int skb_tx_rsvd;
0496     u32 skb_iso_txhdr;
0497     unsigned int skb_rx_extra;  /* for msg coalesced mode */
0498     unsigned int tx_max_size;
0499     unsigned int rx_max_size;
0500     unsigned int rxq_idx_cntr;
0501     struct cxgbi_ports_map pmap;
0502 
0503     void (*dev_ddp_cleanup)(struct cxgbi_device *);
0504     struct cxgbi_ppm* (*cdev2ppm)(struct cxgbi_device *);
0505     int (*csk_ddp_set_map)(struct cxgbi_ppm *, struct cxgbi_sock *,
0506                    struct cxgbi_task_tag_info *);
0507     void (*csk_ddp_clear_map)(struct cxgbi_device *cdev,
0508                   struct cxgbi_ppm *,
0509                   struct cxgbi_task_tag_info *);
0510     int (*csk_ddp_setup_digest)(struct cxgbi_sock *,
0511                     unsigned int, int, int);
0512     int (*csk_ddp_setup_pgidx)(struct cxgbi_sock *,
0513                    unsigned int, int);
0514 
0515     void (*csk_release_offload_resources)(struct cxgbi_sock *);
0516     int (*csk_rx_pdu_ready)(struct cxgbi_sock *, struct sk_buff *);
0517     u32 (*csk_send_rx_credits)(struct cxgbi_sock *, u32);
0518     int (*csk_push_tx_frames)(struct cxgbi_sock *, int);
0519     void (*csk_send_abort_req)(struct cxgbi_sock *);
0520     void (*csk_send_close_req)(struct cxgbi_sock *);
0521     int (*csk_alloc_cpls)(struct cxgbi_sock *);
0522     int (*csk_init_act_open)(struct cxgbi_sock *);
0523 
0524     void *dd_data;
0525 };
0526 #define cxgbi_cdev_priv(cdev)   ((cdev)->dd_data)
0527 
0528 struct cxgbi_conn {
0529     struct cxgbi_endpoint *cep;
0530     struct iscsi_conn *iconn;
0531     struct cxgbi_hba *chba;
0532     u32 task_idx_bits;
0533     unsigned int ddp_full;
0534     unsigned int ddp_tag_full;
0535 };
0536 
0537 struct cxgbi_endpoint {
0538     struct cxgbi_conn *cconn;
0539     struct cxgbi_hba *chba;
0540     struct cxgbi_sock *csk;
0541 };
0542 
0543 struct cxgbi_task_data {
0544 #define CXGBI_TASK_SGL_CHECKED  0x1
0545 #define CXGBI_TASK_SGL_COPY 0x2
0546     u8 flags;
0547     unsigned short nr_frags;
0548     struct page_frag frags[MAX_SKB_FRAGS];
0549     struct sk_buff *skb;
0550     unsigned int dlen;
0551     unsigned int offset;
0552     unsigned int count;
0553     unsigned int sgoffset;
0554     u32 total_count;
0555     u32 total_offset;
0556     u32 max_xmit_dlength;
0557     struct cxgbi_task_tag_info ttinfo;
0558 };
0559 #define iscsi_task_cxgbi_data(task) \
0560     ((task)->dd_data + sizeof(struct iscsi_tcp_task))
0561 
0562 struct cxgbi_iso_info {
0563 #define CXGBI_ISO_INFO_FSLICE       0x1
0564 #define CXGBI_ISO_INFO_LSLICE       0x2
0565 #define CXGBI_ISO_INFO_IMM_ENABLE   0x4
0566     u8 flags;
0567     u8 op;
0568     u8 ahs;
0569     u8 num_pdu;
0570     u32 mpdu;
0571     u32 burst_size;
0572     u32 len;
0573     u32 segment_offset;
0574     u32 datasn_offset;
0575     u32 buffer_offset;
0576 };
0577 
0578 static inline void cxgbi_set_iscsi_ipv4(struct cxgbi_hba *chba, __be32 ipaddr)
0579 {
0580     if (chba->cdev->flags & CXGBI_FLAG_IPV4_SET)
0581         chba->ipv4addr = ipaddr;
0582     else
0583         pr_info("set iscsi ipv4 NOT supported, using %s ipv4.\n",
0584             chba->ndev->name);
0585 }
0586 
0587 struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int);
0588 void cxgbi_device_unregister(struct cxgbi_device *);
0589 void cxgbi_device_unregister_all(unsigned int flag);
0590 struct cxgbi_device *cxgbi_device_find_by_lldev(void *);
0591 struct cxgbi_device *cxgbi_device_find_by_netdev(struct net_device *, int *);
0592 struct cxgbi_device *cxgbi_device_find_by_netdev_rcu(struct net_device *,
0593                              int *);
0594 int cxgbi_hbas_add(struct cxgbi_device *, u64, unsigned int,
0595             struct scsi_host_template *,
0596             struct scsi_transport_template *);
0597 void cxgbi_hbas_remove(struct cxgbi_device *);
0598 
0599 int cxgbi_device_portmap_create(struct cxgbi_device *cdev, unsigned int base,
0600             unsigned int max_conn);
0601 void cxgbi_device_portmap_cleanup(struct cxgbi_device *cdev);
0602 
0603 void cxgbi_conn_tx_open(struct cxgbi_sock *);
0604 void cxgbi_conn_pdu_ready(struct cxgbi_sock *);
0605 int cxgbi_conn_alloc_pdu(struct iscsi_task *, u8);
0606 int cxgbi_conn_init_pdu(struct iscsi_task *, unsigned int , unsigned int);
0607 int cxgbi_conn_xmit_pdu(struct iscsi_task *);
0608 
0609 void cxgbi_cleanup_task(struct iscsi_task *task);
0610 
0611 umode_t cxgbi_attr_is_visible(int param_type, int param);
0612 void cxgbi_get_conn_stats(struct iscsi_cls_conn *, struct iscsi_stats *);
0613 int cxgbi_set_conn_param(struct iscsi_cls_conn *,
0614             enum iscsi_param, char *, int);
0615 int cxgbi_get_ep_param(struct iscsi_endpoint *ep, enum iscsi_param, char *);
0616 struct iscsi_cls_conn *cxgbi_create_conn(struct iscsi_cls_session *, u32);
0617 int cxgbi_bind_conn(struct iscsi_cls_session *,
0618             struct iscsi_cls_conn *, u64, int);
0619 void cxgbi_destroy_session(struct iscsi_cls_session *);
0620 struct iscsi_cls_session *cxgbi_create_session(struct iscsi_endpoint *,
0621             u16, u16, u32);
0622 int cxgbi_set_host_param(struct Scsi_Host *,
0623             enum iscsi_host_param, char *, int);
0624 int cxgbi_get_host_param(struct Scsi_Host *, enum iscsi_host_param, char *);
0625 struct iscsi_endpoint *cxgbi_ep_connect(struct Scsi_Host *,
0626             struct sockaddr *, int);
0627 int cxgbi_ep_poll(struct iscsi_endpoint *, int);
0628 void cxgbi_ep_disconnect(struct iscsi_endpoint *);
0629 
0630 int cxgbi_iscsi_init(struct iscsi_transport *,
0631             struct scsi_transport_template **);
0632 void cxgbi_iscsi_cleanup(struct iscsi_transport *,
0633             struct scsi_transport_template **);
0634 void cxgbi_parse_pdu_itt(struct iscsi_conn *, itt_t, int *, int *);
0635 int cxgbi_ddp_init(struct cxgbi_device *, unsigned int, unsigned int,
0636             unsigned int, unsigned int);
0637 int cxgbi_ddp_cleanup(struct cxgbi_device *);
0638 void cxgbi_ddp_page_size_factor(int *);
0639 void cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *,
0640                 struct cxgbi_task_tag_info *,
0641                 struct scatterlist **sg_pp, unsigned int *sg_off);
0642 int cxgbi_ddp_ppm_setup(void **ppm_pp, struct cxgbi_device *cdev,
0643             struct cxgbi_tag_format *tformat,
0644             unsigned int iscsi_size, unsigned int llimit,
0645             unsigned int start, unsigned int rsvd_factor,
0646             unsigned int edram_start, unsigned int edram_size);
0647 #endif  /*__LIBCXGBI_H__*/