#ifndef _SYS_FIBRE_CHANNEL_ULP_FCIP_H
#define _SYS_FIBRE_CHANNEL_ULP_FCIP_H
#include <sys/kstat.h>
#include <sys/socket.h>
#include <netinet/arp.h>
#ifdef __cplusplus
extern "C" {
#endif
#define FCIPIDNUM (77)
#define FCIPNAME "fcip"
#define FCIPMINPSZ (0)
#define FCIPMAXPSZ 1514
#define FCIPHIWAT (32 * 1024)
#define FCIPLOWAT (1)
#define FCIPMTU 65280
#define FCIPMIN (ETHERMIN + sizeof (llc_snap_hdr_t) + \
sizeof (fcph_network_hdr_t))
#define NMCHASH 64
#define INIT_BUCKET_SIZE 16
struct fcipstr {
struct fcipstr *sl_nextp;
queue_t *sl_rq;
struct fcip *sl_fcip;
t_uscalar_t sl_state;
t_uscalar_t sl_sap;
uint32_t sl_flags;
uint32_t sl_minor;
la_wwn_t *sl_mctab[NMCHASH];
uint_t sl_mccount[NMCHASH];
uint_t sl_mcsize[NMCHASH];
ushort_t sl_ladrf[4];
ushort_t sl_ladrf_refcnt[64];
kmutex_t sl_lock;
};
#define FCIP_SLFAST 0x01
#define FCIP_SLRAW 0x02
#define FCIP_SLALLPHYS 0x04
#define FCIP_SLALLMULTI 0x08
#define FCIP_SLALLSAP 0x10
#define FCIPMAXMC 64
#define FCIPMCALLOC (FCIPMAXMC * sizeof (la_wwn_t))
#define FCIPADDRL (sizeof (ushort_t) + sizeof (struct ether_addr))
typedef struct fcip_port_info {
struct fcip_port_info *fcipp_next;
opaque_t *fcipp_handle;
struct modlinkage fcipp_linkage;
dev_info_t *fcipp_dip;
uint32_t fcipp_topology;
uint32_t fcipp_pstate;
la_wwn_t fcipp_pwwn;
la_wwn_t fcipp_nwwn;
uchar_t fcipp_naa;
int fcipp_fca_pkt_size;
ddi_dma_attr_t fcipp_cmd_dma_attr;
ddi_dma_attr_t fcipp_resp_dma_attr;
ddi_device_acc_attr_t fcipp_fca_acc_attr;
fc_portid_t fcipp_sid;
struct fcip *fcipp_fcip;
} fcip_port_info_t;
#define FCIP_SUCCESS (0)
#define FCIP_FAILURE (1)
#define FCIP_FARP_TIMEOUT 10
#define FCIP_WAIT_CMDS 5
#define FCIP_NUM_INSTANCES 5
#define FCIP_UB_NBUFS 60
#define FCIP_UB_SIZE 65535
#define FCIP_UB_DECREMENT 4
#define FCIP_UB_MINBUFS 8
#define FCIP_INIT_DELAY 10000000
#define FCIP_PKT_TTL 120
#define FCIP_TIMEOUT_INTERVAL 10
#define FCIP_OFFLINE_TIMEOUT 60
#define FCIP_MAX_PORTS 127
#define FCIP_RTE_TIMEOUT 60
#define ETHERSTRL ((2 * ETHERADDRL) + 1)
#define FCIP_RT_HASH_ELEMS 32
#define FCIP_DEST_HASH_ELEMS 16
#define FCIP_RT_HASH(x) ((x[2] + x[3] + x[4] + x[5] + x[6] + x[7]) \
& (FCIP_RT_HASH_ELEMS - 1))
#define FCIP_DEST_HASH(x) ((x[2] + x[3] + x[4] + x[5] + x[6] + x[7]) \
& (FCIP_DEST_HASH_ELEMS - 1))
#define FCIP_HDR_SIZE 8
#define FCIP_RT_INVALID (-1)
#define FCIP_RT_RETIRED (-2)
#define FCIP_RT_SUSPENDED (-3)
#define FCIP_RT_LOGIN_PROGRESS (-4)
#define FCIP_RTE_UNAVAIL(state) (((state) == FCIP_RT_INVALID) || \
((state) == FCIP_RT_RETIRED) || \
((state) == FCIP_RT_SUSPENDED)) ? 1 : 0
#define FCIP_NUM_THREADS 4
#define FCIP_MIN_TASKS 12
#define FCIP_MAX_TASKS 32
struct fcip {
dev_info_t *fcip_dip;
int fcip_instance;
struct fcip *fcip_sibling;
uint32_t fcip_flags;
uint32_t fcip_port_state;
fcip_port_info_t *fcip_port_info;
struct fcip *fcip_next;
kcondvar_t fcip_farp_cv;
int fcip_farp_rsp_flag;
kmutex_t fcip_mutex;
kmutex_t fcip_ub_mutex;
uint32_t fcip_ub_nbufs;
uint32_t fcip_ub_upstream;
kcondvar_t fcip_ub_cv;
timeout_id_t fcip_timeout_id;
uint32_t fcip_timeout_ticks;
uint32_t fcip_mark_offline;
uint64_t *fcip_ub_tokens;
kmutex_t fcip_dest_mutex;
struct fcip_dest *fcip_dest[FCIP_DEST_HASH_ELEMS];
kmutex_t fcip_rt_mutex;
struct fcip_routing_table *fcip_rtable[FCIP_RT_HASH_ELEMS];
int fcip_intr_flag;
uint32_t fcip_addrflags;
struct ether_addr fcip_factmacaddr;
struct ether_addr fcip_macaddr;
la_wwn_t fcip_ouraddr;
uchar_t fcip_ouripaddr[16];
struct kmem_cache *fcip_xmit_cache;
uint32_t fcip_wantw;
queue_t *fcip_ipq;
taskq_t *fcip_tq;
int fcip_sendup_thr_initted;
kmutex_t fcip_sendup_mutex;
kcondvar_t fcip_sendup_cv;
struct fcip_sendup_elem *fcip_sendup_head;
struct fcip_sendup_elem *fcip_sendup_tail;
struct kmem_cache *fcip_sendup_cache;
uint32_t fcip_sendup_cnt;
uint32_t fcip_broadcast_did;
kstat_t *fcip_intrstats;
kstat_t *fcip_kstatp;
callb_cpr_t fcip_cpr_info;
ulong_t fcip_ipackets;
ulong_t fcip_ierrors;
ulong_t fcip_opackets;
ulong_t fcip_oerrors;
ulong_t fcip_collisions;
ulong_t fcip_defer;
ulong_t fcip_fram;
ulong_t fcip_crc;
ulong_t fcip_oflo;
ulong_t fcip_uflo;
ulong_t fcip_missed;
ulong_t fcip_tlcol;
ulong_t fcip_trtry;
ulong_t fcip_tnocar;
ulong_t fcip_inits;
ulong_t fcip_notbufs;
ulong_t fcip_norbufs;
ulong_t fcip_nocanput;
ulong_t fcip_allocbfail;
int fcip_tx_lbolt;
int fcip_rx_lbolt;
ulong_t fcip_rcvbytes;
ulong_t fcip_xmtbytes;
ulong_t fcip_multircv;
ulong_t fcip_multixmt;
ulong_t fcip_brdcstrcv;
ulong_t fcip_brdcstxmt;
ulong_t fcip_norcvbuf;
ulong_t fcip_noxmtbuf;
ulong_t fcip_num_ipkts_pending;
};
#define FCIP_FACTADDR_PRESENT 0x01
#define FCIP_FACTADDR_USE 0x02
#define FCIP_RUNNING 0x01
#define FCIP_INITED 0x02
#define FCIP_PROMISC 0x04
#define FCIP_SUSPENDED 0x08
#define FCIP_NOTIMEOUTS 0x10
#define FCIP_DETACHING 0x20
#define FCIP_DETACHED 0x40
#define FCIP_ATTACHING 0x80
#define FCIP_LINK_DOWN 0x100
#define FCIP_IN_SC_CB 0x200
#define FCIP_IN_DATA_CB 0x400
#define FCIP_IN_ELS_CB 0x800
#define FCIP_IN_TIMEOUT 0x1000
#define FCIP_POWER_DOWN 0x2000
#define FCIP_RTE_REMOVING 0x4000
#define FCIP_REG_INPROGRESS 0x8000
#define FCIP_IN_CALLBACK (FCIP_IN_SC_CB | FCIP_IN_DATA_CB | \
FCIP_IN_ELS_CB)
#define FCIP_PORT_BUSY (FCIP_ATTACHING | \
FCIP_REG_INPROGRESS | FCIP_DETACHING)
struct fcip_routing_table {
struct fcip_routing_table *fcipr_next;
la_wwn_t fcipr_pwwn;
la_wwn_t fcipr_nwwn;
fc_portid_t fcipr_d_id;
void *fcipr_pd;
uchar_t fcipr_ipaddr[16];
int fcipr_state;
clock_t fcipr_invalid_timeout;
opaque_t fcipr_fca_dev;
};
#define FCIP_COMPARE_NWWN 0x001
#define FCIP_COMPARE_PWWN 0x010
#define FCIP_COMPARE_BROADCAST 0x100
#define IS_BROADCAST_ADDR(wwn) (((wwn)->raw_wwn[2] == 0xff) && \
((wwn)->raw_wwn[3] == 0xff) && \
((wwn)->w.wwn_lo == 0xffffffff))
typedef struct fcip_pkt {
mblk_t *fcip_pkt_mp;
queue_t *fcip_pkt_wq;
uint32_t fcip_pkt_ttl;
uint32_t fcip_pkt_retries;
fc_packet_t *fcip_pkt_fcpktp;
struct fcip_dest *fcip_pkt_dest;
struct fcip *fcip_pkt_fptr;
struct fcip_pkt *fcip_pkt_next;
struct fcip_pkt *fcip_pkt_prev;
uint32_t fcip_pkt_state;
uint32_t fcip_pkt_reason;
uint32_t fcip_pkt_flags;
uint32_t fcip_pkt_dma_flags;
fc_packet_t fcip_pkt_fcpkt;
struct fcip_routing_table *fcip_pkt_frp;
} fcip_pkt_t;
#define FCIP_CMD_DMA_MEM 0x01
#define FCIP_CMD_DMA_BOUND 0x02
#define FCIP_RESP_DMA_MEM 0x04
#define FCIP_RESP_DMA_BOUND 0x08
#define FCIP_PKT_INTERNAL 0x01
#define FCIP_PKT_IN_TIMEOUT 0x02
#define FCIP_PKT_RETURNED 0x04
#define FCIP_PKT_IN_LIST 0x08
#define FCIP_PKT_IN_ABORT 0x10
#define FCIP_PKT_TO_FC_PKT(fcip_pkt) &(fcip_pkt)->fcip_pkt_fcpkt
struct fcip_dest {
struct fcip_dest *fcipd_next;
fcip_pkt_t *fcipd_head;
kmutex_t fcipd_mutex;
uint32_t fcipd_refcnt;
struct fcip_routing_table *fcipd_rtable;
#define fcipd_nwwn fcipd_rtable->fcipr_nwwn
#define fcipd_pwwn fcipd_rtable->fcipr_pwwn
#define fcipd_did fcipd_rtable->fcipr_d_id
#define fcipd_pd fcipd_rtable->fcipr_pd
#define fcipd_state fcipd_rtable->fcipr_state
#define fcipd_fca_dev fcipd_rtable->fcipr_fca_dev;
uint32_t fcipd_retries;
uint32_t fcipd_flags;
ulong_t fcipd_ncmds;
};
#define FCIP_PORT_OFFLINE 0
#define FCIP_PORT_ONLINE 1
#define FCIP_PORT_NOTLOGGED 2
#define FCIP_INVALID_WWN -1
#define SLFAST 0x01
#define SLRAW 0x02
#define SLALLPHYS 0x04
#define SLALLMULTI 0x05
#define SLALLSAP 0x10
struct fcipdladdr {
struct ether_addr dl_phys;
uint16_t dl_sap;
};
typedef struct llc_snap_hdr {
uchar_t dsap;
uchar_t ssap;
uchar_t ctrl;
uchar_t oui[3];
ushort_t pid;
} llc_snap_hdr_t;
struct fcipstat {
struct kstat_named fcips_ipackets;
struct kstat_named fcips_ierrors;
struct kstat_named fcips_opackets;
struct kstat_named fcips_oerrors;
struct kstat_named fcips_collisions;
struct kstat_named fcips_defer;
struct kstat_named fcips_fram;
struct kstat_named fcips_crc;
struct kstat_named fcips_oflo;
struct kstat_named fcips_uflo;
struct kstat_named fcips_missed;
struct kstat_named fcips_tlcol;
struct kstat_named fcips_trtry;
struct kstat_named fcips_tnocar;
struct kstat_named fcips_inits;
struct kstat_named fcips_notmds;
struct kstat_named fcips_notbufs;
struct kstat_named fcips_norbufs;
struct kstat_named fcips_nocanput;
struct kstat_named fcips_allocbfail;
struct kstat_named fcips_rcvbytes;
struct kstat_named fcips_xmtbytes;
struct kstat_named fcips_multircv;
struct kstat_named fcips_multixmt;
struct kstat_named fcips_brdcstrcv;
struct kstat_named fcips_brdcstxmt;
struct kstat_named fcips_norcvbuf;
struct kstat_named fcips_noxmtbuf;
};
#define FC_OFF 0x00
#define DA_OFF 0x01
#define SA_OFF 0x07
#define DLSAP_OFF 0x0D
#define SLSAP_OFF 0x0E
#define ORG_OFF 0x0F
#define TYPE_OFF 0x13
#define FCIP_IPV4_LEN 0x04;
#define FCIP_CP_IN(s, d, handle, len) (ddi_rep_get8((handle), \
(uint8_t *)(d), (uint8_t *)(s), \
(len), DDI_DEV_AUTOINCR))
#define FCIP_CP_OUT(s, d, handle, len) (ddi_rep_put8((handle), \
(uint8_t *)(s), (uint8_t *)(d), \
(len), DDI_DEV_AUTOINCR))
#define LA_ELS_FARP_REQ 0x54
#define LA_ELS_FARP_REPLY 0x55
#define FARP_MATCH_RSVD 0x00
#define FARP_MATCH_WW_PN 0x01
#define FARP_MATCH_WW_NN 0x02
#define FARP_MATCH_WW_PN_NN 0x03
#define FARP_MATCH_IPv4 0x04
#define FARP_MATCH_WW_PN_IPv4 0x05
#define FARP_MATCH_WW_NN_IPv4 0x06
#define FARP_MATCH_WW_PN_NN_IPv4 0x07
#define FARP_INIT_P_LOGI 0x0
#define FARP_INIT_REPLY 0x1
typedef struct la_els_farp {
ls_code_t ls_code;
uchar_t match_addr;
fc_portid_t req_id;
uchar_t resp_flags;
fc_portid_t dest_id;
la_wwn_t req_pwwn;
la_wwn_t req_nwwn;
la_wwn_t resp_pwwn;
la_wwn_t resp_nwwn;
uchar_t req_ip[16];
uchar_t resp_ip[16];
} la_els_farp_t;
struct farp_resp_list {
struct farp_resp_list *farpl_next;
struct farp_resp_list *farpl_prev;
la_els_farp_t *farpl_resp;
};
typedef struct network_header {
la_wwn_t net_dest_addr;
la_wwn_t net_src_addr;
} fcph_network_hdr_t;
typedef struct fcip_inarp {
fcph_network_hdr_t fcip_inarp_nh;
llc_snap_hdr_t fcip_inarp_snap;
struct ether_arp fcip_inarp_data;
} fcip_inarp_t;
struct inarp_resp_list {
struct inarp_resp_list *inarpl_next;
struct inarp_resp_list *inarpl_prev;
fcip_inarp_t *inarpl_resp;
};
struct fcip_esballoc_arg {
fc_unsol_buf_t *buf;
opaque_t phandle;
frtn_t *frtnp;
};
struct fcip_sendup_elem {
struct fcip_sendup_elem *fcipsu_next;
mblk_t *fcipsu_mp;
struct fcipstr *(*fcipsu_func)();
};
#define FC4_TYPE_WORD_POS(x) ((uchar_t)(x) >> 5)
#define FC4_TYPE_BIT_POS(x) ((uchar_t)(x) & 0x1F)
#ifdef __cplusplus
}
#endif
#endif