Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_iscsi_api.c File Reference
#include "ocs.h"
#include "ocs_iscsi_spec.h"
#include "ocs_isns.h"

Go to the source code of this file.

Detailed Description

Implements the iSCSI API interface functions.

Definition in file ocs_iscsi_api.c.

Macros

#define OCS_ISCSI_API_INIT_DELAY_MS   100
 
#define OCS_EXPORT(...)
 

Functions

static int32_t ocs_iscsi_api_link_configure_thread (ocs_thread_t *mythread)
 Configures the link on initial link up. More...
 
ocs_sport_t * ocs_iscsi_tgt_get_free_sport (ocs_t *ocs)
 Get a next free sport object index. More...
 
int32_t ocs_iscsi_tgt_add_sport (ocs_t *ocs, ocs_sport_t *sport)
 Add sport to iscsi target. More...
 
void ocs_iscsi_tgt_del_sport (ocs_t *ocs, uint32_t sport_index)
 Delete sport from iscsi target. More...
 
int32_t ocs_iscsi_tgt_add (ocs_t *ocs, char *name, char *alias)
 Adds a target. More...
 
char * ocs_iscsi_tgt_get_names (ocs_t *ocs, uint32_t index)
 Returns the target name based on the index. More...
 
char * ocs_iscsi_tgt_get_alias (ocs_t *ocs, uint32_t index)
 Returns the target alias based on the index. More...
 
ocs_ip_address_t * ocs_iscsi_tgt_get_ip_address (ocs_t *ocs, char *tgt_name, uint32_t index)
 Returns the IP address of the target name based on the index. More...
 
uint32_t ocs_iscsi_tgt_get_portal_group (ocs_t *ocs, char *tgt_name, ocs_ip_address_t *ip_address)
 Returns the portal group of an IP address of the target name. More...
 
uint8_t ocs_iscsi_tgt_require_chap (ocs_t *ocs, char *tgt_name, ocs_session_type_e type)
 Returns TRUE if CHAP is required for the session type. More...
 
uint32_t ocs_iscsi_tgt_is_access_allowed (ocs_t *ocs, char *tgt_name, char *ini_name)
 Checks if this initiator is allowed access to a target. More...
 
char * ocs_iscsi_ini_get_name (ocs_t *ocs)
 Return this initiator's name. More...
 
char * ocs_iscsi_ini_get_alias (ocs_t *ocs)
 Returns the initiator alias. More...
 
int32_t ocs_iscsi_api_initialize (ocs_t *ocs)
 Initialize the higher level iSCSI software. More...
 
int32_t ocs_iscsi_api_shutdown (ocs_t *ocs)
 Initialize the higher level iSCSI software. More...
 
static uint8_t ocs_iscsi_api_not_local_target (ocs_t *ocs, char *remote_name)
 Checks to see if the target name is this target. More...
 
static void ocs_iscsi_api_isns_connect (ocs_t *ocs, void *ret, uint16_t nodes_count)
 Logs into any remote targets discovered through iSNS that are not this device. More...
 
static void ocs_iscsi_isns_configure (ocs_t *ocs, ocs_hal_portal_t portal, ocs_ip_address_t *isns_servers)
 Register/query the iSNS server. More...
 
static void ocs_iscsi_api_non_mgmt_config (ocs_t *ocs, ocs_hal_portal_t portal)
 
static void ocs_iscsi_api_link_configure (ocs_t *ocs)
 Configures the link on initial link up. More...
 
void ocs_iscsi_api_link_state (ocs_t *ocs, ocs_link_state_e link_state)
 Notifies the higher level iSCSI software of the link state. More...
 
uint32_t ocs_iscsi_get_max_cxns (ocs_t *ocs, char *tgt_name, char *ini_name)
 Returns the maximum number of connections allowed per session. More...
 
char * ocs_iscsi_get_chap_name (ocs_t *ocs, uint8_t sess_type, uint32_t mode, uint32_t type)
 Returns the CHAP user name of corresponding type. More...
 
char * ocs_iscsi_get_chap_secret (ocs_t *ocs, char *name, uint32_t mode, uint32_t type, uint32_t *secret_len)
 Returns the unenctypted CHAP secret for a specific user name. Note: Passwords should be at least 16 characters. More...
 
int32_t ocs_iscsi_chap_user_add (ocs_t *ocs, char *username, char *secret, uint32_t type, uint32_t mode)
 Add CHAP user. If CHAP user of same type is already exists, return error. More...
 
int32_t ocs_iscsi_chap_user_del (ocs_t *ocs, char *username, uint32_t type, uint32_t mode)
 Delete CHAP user. More...
 
int32_t ocs_iscsi_chap_list_count (ocs_t *ocs)
 Returns the count of chap_list. More...
 
int32_t ocs_iscsi_chap_list_get (ocs_t *ocs, char *userbuf, int32_t buflen)
 Return CHAP list items. More...
 
static int32_t ocs_iscsi_unassisted_pdu_cb (struct ocs_hal_io_s *io, ocs_cxn_t *cxn, int32_t status, ocs_ini_cmpl_fields_t *ini_fields, void *ul_arg)
 
int32_t ocs_iscsi_unassisted_pdu_send (ocs_t *ocs, ocs_io_t *io, ocs_cxn_t *cxn, void *bhs, void *data, uint32_t data_size, bool is_login, bool set_dm, ocs_iscsi_pdu_cb_t cb)
 
int32_t ocs_iscsi_login_cb (ocs_hal_io_t *io, ocs_cxn_t *cxn, int32_t status, ocs_ini_cmpl_fields_t *ini_fields, void *ul_arg)
 
static int32_t ocs_iscsi_send_context_udpate_cb (ocs_hal_io_t *io, ocs_cxn_t *cxn, int32_t status, ocs_ini_cmpl_fields_t *ini_fields, void *ul_arg)
 Function to receieve the callback for a context update. More...
 
int32_t ocs_iscsi_send_context_udpate (ocs_cxn_t *cxn)
 Sends the login parameters to the FW. More...
 
 OCS_EXPORT (ocs_iscsi_unassisted_pdu_send)
 
 OCS_EXPORT (ocs_iscsi_ini_get_name)
 
 OCS_EXPORT (ocs_iscsi_mac_get)
 
 OCS_EXPORT (ocs_iscsi_rx_buffers_free)
 
 OCS_EXPORT (ocs_xport_control)
 
 OCS_EXPORT (ocs_iscsi_register_link_state_callback)
 
 OCS_EXPORT (ocs_iscsi_unregister_link_state_callback)
 
 OCS_EXPORT (ocs_iscsi_send_context_udpate)
 

Macro Details

#define OCS_EXPORT (   ...)

Definition at line 1392 of file ocs_iscsi_api.c.

#define OCS_ISCSI_API_INIT_DELAY_MS   100

Definition at line 46 of file ocs_iscsi_api.c.

Function Details

OCS_EXPORT ( ocs_iscsi_ini_get_name  )
OCS_EXPORT ( ocs_iscsi_mac_get  )
OCS_EXPORT ( ocs_iscsi_rx_buffers_free  )
OCS_EXPORT ( ocs_xport_control  )
int32_t ocs_iscsi_api_initialize ( ocs_t *  ocs)

Initialize the higher level iSCSI software.

Parameters
ocsPointer to the ocs structure
Returns
0 for success

Definition at line 364 of file ocs_iscsi_api.c.

static void ocs_iscsi_api_isns_connect ( ocs_t *  ocs,
void *  ret,
uint16_t  nodes_count 
)
static

Logs into any remote targets discovered through iSNS that are not this device.

Parameters
ocsPointer to the ocs structure
retPointer from the iSNS query
nodes_countThe number of nodes discovered

Definition at line 640 of file ocs_iscsi_api.c.

static void ocs_iscsi_api_link_configure ( ocs_t *  ocs)
static

Configures the link on initial link up.

Parameters
ocsPointer to the ocs structure

Definition at line 835 of file ocs_iscsi_api.c.

static int32_t ocs_iscsi_api_link_configure_thread ( ocs_thread_t *  mythread)
static

Configures the link on initial link up.

Parameters
mythreadpointer to thread object

Definition at line 921 of file ocs_iscsi_api.c.

void ocs_iscsi_api_link_state ( ocs_t *  ocs,
ocs_link_state_e  link_state 
)

Notifies the higher level iSCSI software of the link state.

Parameters
ocsPointer to the ocs structure
link_stateProvides the status of the link

Definition at line 953 of file ocs_iscsi_api.c.

static void ocs_iscsi_api_non_mgmt_config ( ocs_t *  ocs,
ocs_hal_portal_t  portal 
)
static

Definition at line 750 of file ocs_iscsi_api.c.

static uint8_t ocs_iscsi_api_not_local_target ( ocs_t *  ocs,
char *  remote_name 
)
static

Checks to see if the target name is this target.

Parameters
ocsPointer to the ocs structure
remote_namePointer to the target name
Returns
0 if this is a local target, 1 if is not a local target

Definition at line 611 of file ocs_iscsi_api.c.

int32_t ocs_iscsi_api_shutdown ( ocs_t *  ocs)

Initialize the higher level iSCSI software.

Parameters
ocsPointer to the ocs structure
Returns
0 for success

Definition at line 469 of file ocs_iscsi_api.c.

int32_t ocs_iscsi_chap_list_count ( ocs_t *  ocs)

Returns the count of chap_list.

Definition at line 1155 of file ocs_iscsi_api.c.

int32_t ocs_iscsi_chap_list_get ( ocs_t *  ocs,
char *  userbuf,
int32_t  buflen 
)

Return CHAP list items.

Parameters
ocsOCS context
userbufUser buffer to which chap_list items are copied
buflenUser buffer length

zero on success, otherwise a negative value

Definition at line 1180 of file ocs_iscsi_api.c.

int32_t ocs_iscsi_chap_user_add ( ocs_t *  ocs,
char *  username,
char *  secret,
uint32_t  type,
uint32_t  mode 
)

Add CHAP user. If CHAP user of same type is already exists, return error.

Parameters
ocsPointer to the ocs structure
usernameUsername to add
secretSecret to add
typeCHAP type is incoming or outgoing
modeTarget or Initiator mode

Return zero on success, otherwise a negative value

Definition at line 1043 of file ocs_iscsi_api.c.

int32_t ocs_iscsi_chap_user_del ( ocs_t *  ocs,
char *  username,
uint32_t  type,
uint32_t  mode 
)

Delete CHAP user.

Parameters
ocsPointer to the ocs structure
usernameUsername to delete
typeCHAP type is incoming or outgoing
modeTarget or Initiator mode

Return zero on success, otherwise a negative value

Definition at line 1095 of file ocs_iscsi_api.c.

char* ocs_iscsi_get_chap_name ( ocs_t *  ocs,
uint8_t  sess_type,
uint32_t  mode,
uint32_t  type 
)

Returns the CHAP user name of corresponding type.

Parameters
ocsPointer to the ocs structure
sess_typeEither discovery or nomal session
modeUsername for Target mode or Initaitor mode
typeCHAP incoming or outgoing

Definition at line 983 of file ocs_iscsi_api.c.

char* ocs_iscsi_get_chap_secret ( ocs_t *  ocs,
char *  name,
uint32_t  mode,
uint32_t  type,
uint32_t *  secret_len 
)

Returns the unenctypted CHAP secret for a specific user name. Note: Passwords should be at least 16 characters.

Parameters
ocsPointer to the ocs structure
nameUsername to which the secret to be identified
secret_lenLength of the secret code

Definition at line 1009 of file ocs_iscsi_api.c.

uint32_t ocs_iscsi_get_max_cxns ( ocs_t *  ocs,
char *  tgt_name,
char *  ini_name 
)

Returns the maximum number of connections allowed per session.

Parameters
ocsPointer to the ocs structure
tgt_nameThe iSCSI target name
ini_nameThe iSCSI initiator name

Definition at line 970 of file ocs_iscsi_api.c.

char* ocs_iscsi_ini_get_alias ( ocs_t *  ocs)

Returns the initiator alias.

Parameters
ocsPointer to the ocs structure
Returns
Pointer to the initiator alias or NULL

Definition at line 350 of file ocs_iscsi_api.c.

char* ocs_iscsi_ini_get_name ( ocs_t *  ocs)

Return this initiator's name.

Parameters
ocsPointer to the ocs structure.
Returns
Pointer to the initiator name.

Definition at line 325 of file ocs_iscsi_api.c.

static void ocs_iscsi_isns_configure ( ocs_t *  ocs,
ocs_hal_portal_t  portal,
ocs_ip_address_t *  isns_servers 
)
static

Register/query the iSNS server.

Parameters
ocsPointer to the ocs structure
portalThe portal to use for iSNS
isns_serversThe table allocated to query the iSNS addresses

Definition at line 679 of file ocs_iscsi_api.c.

int32_t ocs_iscsi_login_cb ( ocs_hal_io_t *  io,
ocs_cxn_t *  cxn,
int32_t  status,
ocs_ini_cmpl_fields_t *  ini_fields,
void *  ul_arg 
)
static int32_t ocs_iscsi_send_context_udpate_cb ( ocs_hal_io_t *  io,
ocs_cxn_t *  cxn,
int32_t  status,
ocs_ini_cmpl_fields_t *  ini_fields,
void *  ul_arg 
)
static

Function to receieve the callback for a context update.

Parameters
iopointer to the io object
cxnpointer to the connection object
statusthe status of the IO (1 = good)
ini_fieldspointer to the initiator completion fields
ul_argpointer to the login memory structure
Returns
Returns 0 on success.

Definition at line 1330 of file ocs_iscsi_api.c.

int32_t ocs_iscsi_tgt_add ( ocs_t *  ocs,
char *  name,
char *  alias 
)

Adds a target.

Parameters
ocsPointer to the ocs structure.
nameTarget name.
aliasTarget alias.
Returns
Returns 0 on success.

Definition at line 155 of file ocs_iscsi_api.c.

int32_t ocs_iscsi_tgt_add_sport ( ocs_t *  ocs,
ocs_sport_t *  sport 
)

Add sport to iscsi target.

Parameters
ocsPointer to the ocs structure.
scst_tgtPointer to SCST target
sportSPORT that associates SCST target
Returns
Returns 0 on success.

Definition at line 85 of file ocs_iscsi_api.c.

void ocs_iscsi_tgt_del_sport ( ocs_t *  ocs,
uint32_t  sport_index 
)

Delete sport from iscsi target.

Parameters
ocsPointer to the ocs structure
sport_indexSPORT index to be deleted

Definition at line 127 of file ocs_iscsi_api.c.

char* ocs_iscsi_tgt_get_alias ( ocs_t *  ocs,
uint32_t  index 
)

Returns the target alias based on the index.

Parameters
ocsPointer to the ocs structure.
indexIndex into the target name list.
Returns
Returns pointer to the target name, or NULL if the index exceeds the list.

Definition at line 215 of file ocs_iscsi_api.c.

ocs_sport_t* ocs_iscsi_tgt_get_free_sport ( ocs_t *  ocs)

Get a next free sport object index.

Parameters
ocsPointer to the ocs structure.
Returns
Returns sport inx on success.

Definition at line 57 of file ocs_iscsi_api.c.

ocs_ip_address_t* ocs_iscsi_tgt_get_ip_address ( ocs_t *  ocs,
char *  tgt_name,
uint32_t  index 
)

Returns the IP address of the target name based on the index.

Parameters
ocsPointer to the ocs structure.
tgt_nameThe iSCSI target name.
indexIndex into the IP Address list.
Returns
Pointer to the IP address, or NULL if the index exceeds the list.

Definition at line 244 of file ocs_iscsi_api.c.

char* ocs_iscsi_tgt_get_names ( ocs_t *  ocs,
uint32_t  index 
)

Returns the target name based on the index.

Parameters
ocsPointer to the ocs structure.
indexIndex into the target name list.
Returns
Returns pointer to the target name, or NULL if the index exceeds the list.

Definition at line 186 of file ocs_iscsi_api.c.

uint32_t ocs_iscsi_tgt_get_portal_group ( ocs_t *  ocs,
char *  tgt_name,
ocs_ip_address_t *  ip_address 
)

Returns the portal group of an IP address of the target name.

Parameters
ocsPointer to the ocs structure.
tgt_nameThe iSCSI target name.
ip_addressIP address.
Returns
Returns the target portal group tag.

Definition at line 276 of file ocs_iscsi_api.c.

uint32_t ocs_iscsi_tgt_is_access_allowed ( ocs_t *  ocs,
char *  tgt_name,
char *  ini_name 
)

Checks if this initiator is allowed access to a target.

Parameters
ocsPointer to the ocs structure.
tgt_nameThe iSCSI target name.
ini_nameThe iSCSI initiator name.
Returns
Returns TRUE if access is allowed.

Definition at line 310 of file ocs_iscsi_api.c.

uint8_t ocs_iscsi_tgt_require_chap ( ocs_t *  ocs,
char *  tgt_name,
ocs_session_type_e  type 
)

Returns TRUE if CHAP is required for the session type.

Parameters
ocsPointer to the ocs structure.
tgt_nameThe iSCSI target name.
typeEither discovery or normal sessions.
Returns
Returns TRUE if CHAP is required.

Definition at line 293 of file ocs_iscsi_api.c.

static int32_t ocs_iscsi_unassisted_pdu_cb ( struct ocs_hal_io_s *  io,
ocs_cxn_t *  cxn,
int32_t  status,
ocs_ini_cmpl_fields_t *  ini_fields,
void *  ul_arg 
)
static

Definition at line 1218 of file ocs_iscsi_api.c.

int32_t ocs_iscsi_unassisted_pdu_send ( ocs_t *  ocs,
ocs_io_t *  io,
ocs_cxn_t *  cxn,
void *  bhs,
void *  data,
uint32_t  data_size,
bool  is_login,
bool  set_dm,
ocs_iscsi_pdu_cb_t  cb 
)

Definition at line 1258 of file ocs_iscsi_api.c.