linux/drivers/scsi/cxgb3i/cxgb3i.h
<<
>>
Prefs
   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>
  23#include <linux/skbuff.h>
  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
  37#define CXGB3I_SCSI_HOST_QDEPTH 1024
  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
  43struct cxgb3i_adapter;
  44struct cxgb3i_hba;
  45struct 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 */
  54struct 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
  69 * @flags:      bit flag for adapter event/status
  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 */
  74#define CXGB3I_ADAPTER_FLAG_RESET       0x1
  75struct 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
  83        unsigned int flags;
  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 */
  99struct 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 */
 114struct cxgb3i_endpoint {
 115        struct s3_conn *c3cn;
 116        struct cxgb3i_hba *hba;
 117        struct cxgb3i_conn *cconn;
 118};
 119
 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)
 131struct 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
 140int cxgb3i_iscsi_init(void);
 141void cxgb3i_iscsi_cleanup(void);
 142
 143struct cxgb3i_adapter *cxgb3i_adapter_find_by_tdev(struct t3cdev *);
 144void cxgb3i_adapter_open(struct t3cdev *);
 145void cxgb3i_adapter_close(struct t3cdev *);
 146
 147struct cxgb3i_hba *cxgb3i_hba_host_add(struct cxgb3i_adapter *,
 148                                       struct net_device *);
 149void cxgb3i_hba_host_remove(struct cxgb3i_hba *);
 150
 151int cxgb3i_pdu_init(void);
 152void cxgb3i_pdu_cleanup(void);
 153void cxgb3i_conn_cleanup_task(struct iscsi_task *);
 154int cxgb3i_conn_alloc_pdu(struct iscsi_task *, u8);
 155int cxgb3i_conn_init_pdu(struct iscsi_task *, unsigned int, unsigned int);
 156int cxgb3i_conn_xmit_pdu(struct iscsi_task *);
 157
 158void cxgb3i_release_itt(struct iscsi_task *task, itt_t hdr_itt);
 159int cxgb3i_reserve_itt(struct iscsi_task *task, itt_t *hdr_itt);
 160
 161#endif
 162