#ifndef _ISER_XFER_H
#define _ISER_XFER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#include <sys/ib/ibtl/ibti.h>
#include <sys/ib/ibtl/ibtl_types.h>
#include <sys/iscsi_protocol.h>
#pragma pack(1)
typedef struct iser_private_data_s {
uint8_t ip_pvt[IBT_IP_HDR_PRIV_DATA_SZ];
#if defined(_BIT_FIELDS_LTOH)
uint32_t rsvd1 :30,
sie :1,
zbvae :1;
#elif defined(_BIT_FIELDS_HTOL)
uint32_t zbvae :1,
sie :1,
rsvd1 :30;
#else
#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
#endif
uint8_t rsvd2[52];
} iser_private_data_t;
#define ISER_OPCODE_CTRL_TYPE_PDU 1
#define ISER_OPCODE_HELLO_MSG 2
#define ISER_OPCODE_HELLOREPLY_MSG 3
typedef struct iser_ctrl_hdr_s {
#if defined(_BIT_FIELDS_LTOH)
uint8_t rsvd1: 2,
rsv_flag: 1,
wsv_flag: 1,
opcode: 4;
uint8_t rsvd[3];
#elif defined(_BIT_FIELDS_HTOL)
uint8_t opcode: 4,
wsv_flag: 1,
rsv_flag: 1,
rsvd1: 2;
uint8_t rsvd[3];
#else
#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
#endif
uint32_t wstag;
uint64_t wva;
uint32_t rstag;
uint64_t rva;
} iser_ctrl_hdr_t;
typedef struct iser_hello_hdr_s {
#if defined(_BIT_FIELDS_LTOH)
uint8_t rsvd1 : 4,
opcode : 4;
uint8_t minver : 4,
maxver : 4;
#elif defined(_BIT_FIELDS_HTOL)
uint8_t opcode : 4,
rsvd1 : 4;
uint8_t maxver : 4,
minver : 4;
#else
#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
#endif
uint16_t iser_ird;
uint32_t rsvd2[2];
} iser_hello_hdr_t;
typedef struct iser_helloreply_hdr_s {
#if defined(_BIT_FIELDS_LTOH)
uint8_t flag : 1,
rsvd1 : 3,
opcode : 4;
uint8_t curver : 4,
maxver : 4;
#elif defined(_BIT_FIELDS_HTOL)
uint8_t opcode : 4,
rsvd1 : 3,
flag : 1;
uint8_t maxver : 4,
curver : 4;
#else
#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
#endif
uint16_t iser_ord;
uint32_t rsvd2[2];
} iser_helloreply_hdr_t;
#pragma pack()
struct iser_state_s;
int iser_xfer_hello_msg(iser_chan_t *chan);
int iser_xfer_helloreply_msg(iser_chan_t *chan);
int iser_xfer_ctrlpdu(iser_chan_t *chan, idm_pdu_t *pdu);
int iser_xfer_buf_to_ini(idm_task_t *idt, idm_buf_t *buf);
int iser_xfer_buf_from_ini(idm_task_t *idt, idm_buf_t *buf);
#ifdef __cplusplus
}
#endif
#endif