Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_openiscsi_ini.c File Reference
#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsi_transport.h>
#include <scsi/libiscsi.h>
#include <scsi/scsi_transport_iscsi.h>
#include <linux/if_ether.h>
#include "ocs.h"
#include "ocs_ini_template.h"
#include "ocs_scsi_ini.h"
#include "ocs_iscsi_spec.h"
#include "ocs_iscsi_api.h"
#include "ocs_session.h"

Go to the source code of this file.

Detailed Description

Copyright (C) 2013-2015 Emulex All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. The full GNU General Public License can be found at http://www.gnu.org/licenses/.

Written by: Chris Moore (chris.nosp@m..moo.nosp@m.re@em.nosp@m.ulex.nosp@m..com)

Emulex 3333 Susan Street Costa Mesa, CA 92626

This file contains the linkage to functions that implement the separately loadable back end initiator.

Load sequence:

Definition in file ocs_openiscsi_ini.c.

Data Structures

struct  ocs_lnx_iscsi_arg_t
 

Macros

#define ocs_scsi_midlayer_result(host_code, scsi_code)   (((host_code) << 16) | scsi_code)
 
#define SCSI_ISCSI_XPORT_ATTR_IS_VISIBLE_V1
 

Functions

int32_t ocs_scsi_cmd_cb (ocs_io_t *io, ocs_scsi_io_status_e status, ocs_scsi_cmd_resp_t *rsp, uint32_t flags, void *arg)
 SCSI IO callback function. More...
 
static int32_t ocs_lnx_xport_unsol_cb (void *arg, ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *bhs, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len, uint8_t code)
 Unsolicited event handler. More...
 
static void ocs_lnx_xport_link_state (ocs_t *ocs, ocs_link_state_e link_state)
 Called when the link changes state. More...
 
int32_t ocs_scsi_map_sgl (ocs_t *ocs, struct scsi_cmnd *scsi_cmd, ocs_scsi_sgl_t *sgl, uint32_t *sgl_cnt)
 Map mid-layer SGLs to ocs SGLs. More...
 
static int ocs_conn_update_context (struct iscsi_conn *conn)
 
int ocs_scsi_abort_io (ocs_hal_t *hal, ocs_hal_io_t *hio, ocs_hal_abort_type_e abort_type)
 
static int ocs_eh_abort (struct scsi_cmnd *sc)
 
int32_t ocs_ramlog_printf (void *os, const char *fmt,...)
 
void ocs_print_stack (void)
 
int32_t ocs_scsi_ini_driver_init (int32_t initiator)
 Initialize initiator client. More...
 
int32_t ocs_scsi_ini_driver_exit (int32_t initiator)
 initiator client exit More...
 
int32_t ocs_scsi_ini_new_device (ocs_t *ocs)
 Initializes any initiator fields on the ocs structure. More...
 
int32_t ocs_scsi_ini_del_device (ocs_t *ocs)
 Tears down initiator members of ocs structure. More...
 
int32_t ocs_scsi_ini_new_domain (ocs_domain_t *domain)
 Accept new domain notification. More...
 
void ocs_scsi_ini_del_domain (ocs_domain_t *domain)
 Accept domain lost notification. More...
 
int32_t ocs_scsi_ini_new_sport (ocs_sport_t *sport)
 Process creation of a new SPORT. More...
 
void ocs_scsi_ini_del_sport (ocs_sport_t *sport)
 Process deletion of a SPORT. More...
 
int32_t ocs_scsi_new_target (ocs_node_t *node)
 Receive notification of a new SCSI target node. More...
 
int32_t ocs_scsi_del_target (ocs_node_t *node, ocs_scsi_del_target_reason_e reason)
 Delete a SCSI target node. More...
 
void ocs_scsi_ini_ddump (ocs_textbuf_t *textbuf, ocs_scsi_ddump_type_e type, void *obj)
 Generate driver dump data for debugging. More...
 
static void ocs_scsi_cmnd_result_chk_cond (struct scsi_cmnd *scsi_cmd)
 Set scsi_cmnd check condition. More...
 
static void ocs_lnx_xport_fail_session (struct iscsi_cls_session *cls_session)
 Helper function for marking sessions as failed. More...
 
static int32_t ocs_lnx_xport_io_cb (ocs_io_t *io, ocs_scsi_io_status_e status, ocs_scsi_cmd_resp_t *rsp, uint32_t flags, void *arg)
 IO completion handler for iSCSI initiator. More...
 
struct iscsi_cls_session * ocs_session_create (struct iscsi_endpoint *ep, u16 cmds_max, u16 qdepth, u32 initial_cmdsn)
 Create a new iscsi session. More...
 
void ocs_session_destroy (struct iscsi_cls_session *cls_session)
 Destroy an iSCSI session. More...
 
struct iscsi_cls_conn * ocs_conn_create (struct iscsi_cls_session *cls_session, u32 cid)
 Create an instance of iSCSI connection. More...
 
int ocs_conn_bind (struct iscsi_cls_session *cls_session, struct iscsi_cls_conn *cls_conn, u64 transport_fd, int is_leading)
 Binds an iSCSI connection to an endpoint. More...
 
int ocs_iface_set_param (struct Scsi_Host *shost, void *data, uint32_t dt_len)
 
int ocs_iface_get_param (struct iscsi_iface *iface, enum iscsi_param_type param_type, int param, char *buf)
 
int ocs_ep_get_param (struct iscsi_endpoint *ep, enum iscsi_param param, char *buf)
 
int ocs_conn_get_param (struct iscsi_cls_conn *cls_conn, enum iscsi_param param, char *buf)
 
int ocs_session_get_param (struct iscsi_cls_session *cls_session, enum iscsi_param param, char *buf)
 
int ocs_set_param (struct iscsi_cls_conn *cls_conn, enum iscsi_param param, char *buf, int buflen)
 
int ocs_set_host_param (struct Scsi_Host *shost, enum iscsi_host_param param, char *buf, int buflen)
 
int ocs_get_host_param (struct Scsi_Host *shost, enum iscsi_host_param param, char *buf)
 
void ocs_conn_get_stats (struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats)
 
void ocs_set_update_ctx_options (ocs_hal_io_param_t *iparam, struct iscsi_conn *conn)
 Set UPDATE CONTEXT options. More...
 
int ocs_conn_start (struct iscsi_cls_conn *cls_conn)
 Offload of session to chip. More...
 
static int ocs_sockaddr_to_hal_ip (struct sockaddr *addr, ocs_hal_ip_address_t *hal_ip, uint16_t *port)
 
struct iscsi_endpoint * ocs_ep_connect (struct Scsi_Host *shost, struct sockaddr *dst_addr, int non_blocking)
 Ask the chip to create TCP connection. More...
 
int ocs_ep_poll (struct iscsi_endpoint *ep, int timeout_ms)
 Poll to see if a connection is established. More...
 
void ocs_ep_disconnect (struct iscsi_endpoint *ep)
 Tears down the TCP connection. More...
 
int32_t ocs_iscsi_mtask_cb_tcp_ack_wait_rsp (ocs_io_t *io, uint32_t exp_cmdsn, uint32_t max_cmdsn, uint8_t response)
 Completion handler for non-SCSI initiator tasks that complete on TCP ACK. More...
 
int32_t ocs_iscsi_mtask_cb_tcp_ack_no_rsp (ocs_io_t *io, uint32_t exp_cmdsn, uint32_t max_cmdsn, uint8_t response)
 Completion handler for non-SCSI initiator tasks that complete on TCP ACK. More...
 
int32_t ocs_iscsi_mtask_cb_with_rsp (ocs_io_t *io, uint32_t exp_cmdsn, uint32_t max_cmdsn, uint8_t response)
 Completion handler for non-SCSI initiator tasks. More...
 
static int ocs_xmit_mtask (struct iscsi_task *task)
 Transmit a management task. More...
 
static void ocs_task_cleanup (struct iscsi_task *task)
 Clean up an iSCSI task. More...
 
static int ocs_task_xmit (struct iscsi_task *task)
 Transmit an iSCSI task. More...
 
void ocs_cleanup_task (struct iscsi_task *task)
 
static int ocs_alloc_pdu (struct iscsi_task *task, uint8_t opcode)
 Allocate a new PDU. More...
 
umode_t ocs_attr_is_visible (int param_type, int param)
 Return sysfs visibility for a parameter. More...
 

Variables

static struct
scsi_transport_template * 
transport_template
 
struct iscsi_transport ocs_lnx_xport_iscsi
 iSCSI transport entry points. More...
 
ocs_scsi_ini_template_t ocs_iscsi_ini_template
 
struct scsi_host_template host_template
 Host Template. More...
 

Macro Details

#define ocs_scsi_midlayer_result (   host_code,
  scsi_code 
)    (((host_code) << 16) | scsi_code)

Definition at line 76 of file ocs_openiscsi_ini.c.

#define SCSI_ISCSI_XPORT_ATTR_IS_VISIBLE_V1

Definition at line 79 of file ocs_openiscsi_ini.c.

Function Details

static int ocs_eh_abort ( struct scsi_cmnd *  sc)
static

Definition at line 124 of file ocs_openiscsi_ini.c.

void ocs_print_stack ( void  )

Definition at line 167 of file ocs_openiscsi_ini.c.

int32_t ocs_ramlog_printf ( void *  os,
const char *  fmt,
  ... 
)

Definition at line 162 of file ocs_openiscsi_ini.c.

int ocs_scsi_abort_io ( ocs_hal_t *  hal,
ocs_hal_io_t *  hio,
ocs_hal_abort_type_e  abort_type 
)

Definition at line 2342 of file ocs_scsi.c.

int32_t ocs_scsi_cmd_cb ( ocs_io_t *  io,
ocs_scsi_io_status_e  status,
ocs_scsi_cmd_resp_t *  rsp,
uint32_t  flags,
void *  arg 
)

SCSI IO callback function.

Description
This function is called back by the base driver to indicate that the given IO has completed.
Parameters
ioPointer to IO that has completed.
statusStatus of IO.
rspPointer to response.
flagsFlags.
argPointer to argument passed when sending IO.

Definition at line 542 of file ocs_openiscsi_ini.c.

static void ocs_scsi_cmnd_result_chk_cond ( struct scsi_cmnd *  scsi_cmd)
static

Set scsi_cmnd check condition.

Description
This function is called by the LLD to indicate that the given scsi_cmnd resulted in a check condition. Sense data will be filled out independently.
Parameters
scsi_cmdCommand for which to set check condition.

Definition at line 521 of file ocs_openiscsi_ini.c.

int32_t ocs_scsi_ini_driver_exit ( int32_t  initiator)

initiator client exit

Description
Called by OS driver-wide clean-up/exit code to clean up initiator client.
Parameters
initiatorTRUE for initiator mode
Returns
Returns 0 on success, or a negative error code value on failure.

Definition at line 214 of file ocs_openiscsi_ini.c.

int32_t ocs_scsi_ini_driver_init ( int32_t  initiator)

Initialize initiator client.

Description
Called by OS initialization code to initialize initiator client. This is called prior to any PCI device enumeration.

Registers with open-iscsi as a transport.
Parameters
initiatorTRUE for initiator mode
Returns
Returns 0 on success, or a negative error code value on failure.

Definition at line 187 of file ocs_openiscsi_ini.c.

int32_t ocs_scsi_map_sgl ( ocs_t *  ocs,
struct scsi_cmnd *  scsi_cmd,
ocs_scsi_sgl_t *  sgl,
uint32_t *  sgl_cnt 
)

Map mid-layer SGLs to ocs SGLs.

Description
This function is called by ocs_queuecommand() to map the SGL received from the mid-layer to an ocs SGL that can be used by the SCSI API.
Parameters
ocsThe ocs pointer associated with this request.
scsi_cmdCommand received from mid-layer.
sglResulting ocs SGL.
sgl_cnt[in] - Maximum number of SGLs that sgl can accommodate; [out] - The resulting number of SGL entries.

Definition at line 611 of file ocs_openiscsi_ini.c.

Variable Details

ocs_scsi_ini_template_t ocs_iscsi_ini_template
Initial value:
= {
.ocs_scsi_ini_new_domain = ocs_scsi_ini_new_domain,
.ocs_scsi_ini_del_domain = ocs_scsi_ini_del_domain,
.ocs_scsi_ini_new_sport = ocs_scsi_ini_new_sport,
.ocs_scsi_ini_del_sport = ocs_scsi_ini_del_sport,
.ocs_scsi_new_target = ocs_scsi_new_target,
.ocs_scsi_del_target = ocs_scsi_del_target,
.ocs_scsi_ini_ddump = ocs_scsi_ini_ddump,
}
int32_t ocs_scsi_ini_new_sport(ocs_sport_t *sport)
Process creation of a new SPORT.
int32_t ocs_scsi_ini_new_domain(ocs_domain_t *domain)
Accept new domain notification.
void ocs_scsi_ini_ddump(ocs_textbuf_t *textbuf, ocs_scsi_ddump_type_e type, void *obj)
Generate driver dump data for debugging.
int32_t ocs_scsi_new_target(ocs_node_t *node)
Receive notification of a new SCSI target node.
void ocs_scsi_ini_del_sport(ocs_sport_t *sport)
Process deletion of a SPORT.
int32_t ocs_scsi_del_target(ocs_node_t *node, ocs_scsi_del_target_reason_e reason)
Delete a SCSI target node.
void ocs_scsi_ini_del_domain(ocs_domain_t *domain)
Accept domain lost notification.

Definition at line 85 of file ocs_openiscsi_ini.c.

struct scsi_transport_template* transport_template
static

Definition at line 51 of file ocs_openiscsi_ini.c.