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

Go to the source code of this file.

Detailed Description

Implements the iSCSI interface functions.

Definition in file ocs_iscsi.c.

Macros

#define IDLE_TIMER_MS   (30 * 1000) /* 30 seconds */
 

Functions

static int32_t ocs_iscsi_hal_configure (ocs_iscsi_t *iscsi)
 Configure the HAL based on iSCSI compile parameters. More...
 
static int32_t ocs_iscsi_link_event_cb (void *arg, uint8_t isLinkUp)
 Function to receive the notification of link events. More...
 
static int32_t ocs_iscsi_cxn_event_cb (void *arg, ocs_hal_cxn_event_t *cxn_event)
 Function to receive connection events. More...
 
static int32_t ocs_iscsi_unsolicited_event_cb (void *arg, ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len, uint8_t code)
 Function to receive unsolicited PDUs. More...
 
static ocs_config_ctx_t * ocs_iscsi_ctx_alloc (ocs_iscsi_t *iscsi, ocs_config_ctx_e index)
 Allocates an iSCSI API context that provides a synchronous API when using a asynchronous mailbox command. More...
 
static int32_t ocs_iscsi_ctx_wait (ocs_iscsi_t *iscsi, ocs_config_ctx_e index, int timeout_usec)
 Waits on an iSCSI API context until the command completes or the timeout occurs. More...
 
static void ocs_iscsi_ctx_free (ocs_iscsi_t *iscsi, ocs_config_ctx_e index)
 Frees an iSCSI API context that provides a synchronous API when using a asynchronous mailbox command. More...
 
static void ocs_iscsi_ctx_post (ocs_config_ctx_t *ctx, int32_t status, uint32_t ext_status)
 Updates the status fields and post to the semaphore if it is still in use. More...
 
static void ocs_iscsi_ctx_teardown (ocs_iscsi_t *iscsi)
 Completes any active iSCSI API context when the device is being shut down. More...
 
ocs_hal_ip_type_e ocs_iscsi_convert_to_hal_ip_type (ocs_ip_type_e ip_type)
 Convert an iSCSI IP type to the HAL value. More...
 
ocs_ip_type_e ocs_iscsi_convert_to_ip_type (ocs_hal_ip_type_e ip_type)
 Convert an HAL IP type to the iSCSI API value. More...
 
void ocs_iscsi_convert_to_hal_ip (ocs_ip_address_t *ip, ocs_hal_ip_address_t *hal_ip)
 Convert an iSCSI IP address to the HAL IP address. More...
 
void ocs_iscsi_convert_to_ip (ocs_ip_address_t *ip, ocs_hal_ip_address_t *hal_ip)
 Convert an iSCSI IP address to the HAL IP address. More...
 
static void ocs_iscsi_convert_to_hal_ipsub (ocs_ip_address_subnet_t *ip, ocs_hal_ip_address_subnet_t *hal_ip)
 Convert an iSCSI IP address to the HAL IP address. More...
 
static void ocs_iscsi_convert_to_ipsub (ocs_ip_address_subnet_t *ip, ocs_hal_ip_address_subnet_t *hal_ip)
 Convert an iSCSI IP address to the HAL IP address. More...
 
void ocs_iscsi_ipsub_combine (ocs_ip_address_subnet_t *ipsub, ocs_ip_address_t *ip, ocs_ip_address_t *subnet)
 Combines an iSCSI IP address and subnet into the combined structure. More...
 
void ocs_iscsi_ipsub_split (ocs_ip_address_subnet_t *ipsub, ocs_ip_address_t *ip, ocs_ip_address_t *subnet)
 Splits an iSCSI IP address and subnet from the combined structure. More...
 
void format_ip_address (ocs_ip_type_e ip_type, uint8_t *address, char *buffer, int size)
 Format an IP address into a string. More...
 
int32_t ocs_iscsi_inet_pton4 (const char *src, ocs_ip_address_t *ip)
 Converts an IPv4 address from a string to the IP structure. More...
 
int32_t ocs_iscsi_inet_pton6 (const char *src, ocs_ip_address_t *ip)
 Converts an IPv6 address from a string to the IP structure. More...
 
void format_mac_address (uint8_t *address, char *buffer, int size)
 Format a MAC address into a string. More...
 
int32_t parse_mac_address (const char *src, uint8_t *dest)
 Parse a string into a MAC address. More...
 
static int32_t ocs_iscsi_cxn_request_logout (ocs_cxn_t *cxn)
 Attempts to send an asynchronous message to request the initiator to logout. More...
 
static void ocs_iscsi_idle_timeout (void *arg)
 This function is called to check for idle connections. More...
 
static void ocs_iscsi_ctx_general_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 This function is the callback a general API context command. More...
 
static void ocs_iscsi_isns_discover_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 This function is the callback for the iSNS server IP addresses. More...
 
static void ocs_iscsi_isns_send_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 This function is the callback for the iSNS send. More...
 
int32_t ocs_iscsi_isns_esi_listen_start (ocs_t *ocs, ocs_ip_address_t *ip, uint16_t tcp_port)
 Starts an iSNS ESI TCP listen socket. More...
 
int32_t ocs_iscsi_isns_esi_listen_stop (ocs_t *ocs, ocs_ip_address_t *ip, uint16_t tcp_port)
 Stops an iSNS ESI TCP listen socket. More...
 
int32_t ocs_iscsi_isns_discover (ocs_t *ocs, ocs_hal_portal_t portal, uint32_t max_entries, uint32_t *num_ips, ocs_ip_address_t *ip)
 Discovers the iSNS through the DHCP service. More...
 
int32_t ocs_iscsi_isns_send (ocs_t *ocs, ocs_ip_address_t *isns_server, uint32_t tcp_port, void *buffer, uint32_t *pkt_len, uint32_t buff_len)
 Sends an iSNS packet to a server to test the interface. More...
 
static void ocs_iscsi_query_ip_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 This function is the callback for querying IP addresses. More...
 
int32_t ocs_iscsi_mac_set (ocs_t *ocs, uint8_t *mac_address)
 Sets the MAC address of the iSCSI device. More...
 
uint8_t * ocs_iscsi_mac_get (ocs_t *ocs)
 Gets the MAC address of the iSCSI device. More...
 
static void ocs_iscsi_print_module_params (ocs_iscsi_t *iscsi)
 This function prints the module parameters to the log for debugging purposes. More...
 
int32_t ocs_iscsi_interrupts_required (ocs_os_handle_t os, ocs_hal_t *hal)
 Returns the number of interrupts needed for this adapter. More...
 
int32_t ocs_iscsi_initialize (ocs_os_handle_t os, ocs_iscsi_t *iscsi, ocs_hal_t *hal, uint32_t device_instance)
 Initialize the iSCSI device by setting up the chip. More...
 
void ocs_iscsi_uninitialize (ocs_iscsi_t *iscsi)
 Indicate that HAL is not initialized. More...
 
int32_t ocs_iscsi_teardown (ocs_iscsi_t *iscsi)
 Shut down the device. More...
 
int32_t ocs_iscsi_mtu_set (ocs_t *ocs, uint8_t is_jumbo)
 Sets the TCP MTU size of the iSCSI device. More...
 
void ocs_iscsi_cluster_tgts_free (ocs_iscsi_t *iscsi)
 iscsi cluster targets free More...
 
static void ocs_iscsi_ctx_route_table_read_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 This function is the callback a add route table command. More...
 
int32_t ocs_iscsi_route_table_del_entry (ocs_t *ocs, ocs_ip_address_subnet_t *ipsub, ocs_ip_address_t *gateway)
 Deletes an entry from a routing table. More...
 
int32_t ocs_iscsi_route_table_add_entry (ocs_t *ocs, ocs_ip_address_subnet_t *ipsub, ocs_ip_address_t *gateway)
 Adds an entry to a routing table. More...
 
int32_t ocs_iscsi_route_table_read (ocs_t *ocs, ocs_route_table_t *route_table)
 
int32_t ocs_iscsi_ip_address_add (ocs_t *ocs, ocs_hal_portal_t portal, ocs_ip_address_subnet_t *ipsub)
 Adds the IP address to the specified interface. More...
 
int32_t ocs_iscsi_ip_address_remove (ocs_t *ocs, ocs_hal_portal_t portal, ocs_ip_address_subnet_t *ipsub)
 Remove the IP address to the specified interface. More...
 
int32_t ocs_iscsi_ip_address_query (ocs_t *ocs, ocs_hal_portal_t portal, ocs_ip_type_e ip_type, uint32_t max_entries, uint32_t *num_ips, ocs_ip_address_subnet_t *ipsub)
 Queries the IP addresses on the default interface. More...
 
int32_t ocs_iscsi_add_ip_to_tbl (ocs_t *ocs, char *desc, ocs_ip_address_subnet_t *ipsub, ocs_hal_portal_t portal)
 Adds an IP address to the table. More...
 
int32_t ocs_iscsi_remove_ip_from_tbl (ocs_t *ocs, ocs_ip_address_subnet_t *ipsub, ocs_hal_portal_t portal)
 Remove an IP address from the table. More...
 
int32_t ocs_iscsi_is_ip_in_tbl (ocs_t *ocs, ocs_ip_address_subnet_t *ipsub)
 Checks if an IP address/subnet is present in the table. More...
 
int32_t ocs_iscsi_gateway_set (ocs_t *ocs, ocs_ip_address_t *gateway)
 Sets the IP gateway address. More...
 
ocs_hal_portal_t ocs_iscsi_portal_get_default (ocs_t *ocs)
 Retrieves the default portal. More...
 
int32_t ocs_iscsi_portal_find_ip_address (ocs_t *ocs, ocs_hal_portal_t iface_handle, ocs_ip_address_t *ip, ocs_ip_address_t *subnet, uint16_t *tcp_port, int32_t *listening)
 Find IP address of interface handle If IP address is found for given interface handle, copy to ip and subnet params. More...
 
int32_t ocs_iscsi_portal_remove_ip_addresses (ocs_t *ocs, ocs_hal_portal_t iface_handle)
 Check and remove IP addresses of the corresponding interface. More...
 
int32_t ocs_iscsi_find_portal_from_vlan (ocs_t *ocs, uint32_t vlan_id, ocs_hal_portal_t *iface_handle)
 Helper function to find respective interface handle of VLAN id. More...
 
int32_t ocs_iscsi_portal_is_vlan_exists (ocs_t *ocs, uint32_t vlan_id)
 Check VLAN for duplicate. More...
 
int32_t ocs_iscsi_portal_add_vlan (ocs_t *ocs, ocs_hal_portal_t iface, uint32_t vlan_id)
 Add VLAN and iface handle to portal_list. More...
 
int32_t ocs_iscsi_portal_del_vlan (ocs_t *ocs, ocs_hal_portal_t iface)
 Delete iface handle and VLAN from portal_list. More...
 
int32_t ocs_iscsi_portal_read_vlan_ids (ocs_t *ocs, void *arg_out, uint32_t arg_out_length)
 Read VLAN IDs to provided buffer. More...
 
static void ocs_iscsi_portal_create_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 This function is the callback for creating an interface/portal. More...
 
int32_t ocs_iscsi_portal_create (ocs_t *ocs, unsigned int vlan_id, ocs_hal_portal_t *portal)
 Creates a portal for a VLAN. More...
 
int32_t ocs_iscsi_portal_delete (ocs_t *ocs, ocs_hal_portal_t portal)
 Removes a previously-created portal. More...
 
int32_t ocs_iscsi_listen_start (ocs_t *ocs, ocs_ip_address_t *ip, uint16_t tcp_port)
 Starts a TCP listen socket. More...
 
int32_t ocs_iscsi_listen_stop (ocs_t *ocs, ocs_ip_address_t *ip, uint16_t tcp_port)
 Stops a TCP listen socket. More...
 
int32_t ocs_iscsi_register_link_state_callback (ocs_t *ocs, ocs_link_state_cb_t cb)
 Register to receive link state change notifications. More...
 
void ocs_iscsi_unregister_link_state_callback (ocs_t *ocs, ocs_link_state_cb_t cb)
 Unregister a link state change callback. More...
 
static int32_t ocs_iscsi_cxn_event_invalid (ocs_iscsi_t *iscsi, ocs_cxn_t *cxn, uint32_t code)
 Function to process connection invalidation notifications. More...
 
static int32_t ocs_iscsi_cxn_event_data_digest (ocs_iscsi_t *iscsi, ocs_hal_tgt_data_digest_t *tgt_digest)
 Function to process a data digest error. More...
 
static uint32_t ocs_iscsi_decode_lun (uint8_t *lu)
 Decode a LU Number according to SAM. More...
 
static ocs_pdu_process_rtn_e ocs_iscsi_recv_cmd (ocs_iscsi_t *iscsi, ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len)
 Function to receive unsolicited command PDUs. More...
 
static int32_t ocs_iscsi_recv_tm_cb (ocs_io_t *io, ocs_scsi_io_status_e status, uint32_t flags, void *arg)
 Callback function used to free an IO for a rejected task management function. More...
 
static ocs_pdu_process_rtn_e ocs_iscsi_recv_tm (ocs_iscsi_t *iscsi, ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len)
 Function to receive unsolicited task management PDUs. More...
 
static int32_t ocs_iscsi_recv_tm_rsp (ocs_iscsi_t *iscsi, ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len)
 Function to receive unsolicited task management response PDUs. More...
 
ocs_pdu_process_rtn_e ocs_iscsi_tgt_process_cmd_sn (ocs_iscsi_t *iscsi, ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len, uint8_t code, uint8_t *reject_reason)
 Function to process unsolicited PDUs for a target. More...
 
static int32_t ocs_iscsi_unsolicited_event_ini (ocs_iscsi_t *iscsi, ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len, uint8_t code)
 Function to receive unsolicited PDUs for an initiator. More...
 
void ocs_iscsi_tracker_init (ocs_iscsi_mem_tracker_t *tracker)
 Initialize the memory tracker. More...
 
void ocs_iscsi_tracker_free (ocs_iscsi_t *iscsi, ocs_iscsi_mem_tracker_t *tracker)
 Free the memory associated with a memory tracker. More...
 
int32_t ocs_iscsi_tracker_alloc (ocs_iscsi_t *iscsi, ocs_iscsi_mem_tracker_t *tracker, uint8_t zero, uint32_t object_size, uint32_t alignment, uint32_t num_objects)
 Allocate a group of objects uses pages to minimize waste. More...
 
ocs_dma_t * ocs_iscsi_tracker_calc (ocs_iscsi_mem_tracker_t *tracker, uint32_t obj_offset)
 Helper to return the pointers for a specific object in the group. More...
 
void ocs_iscsi_rx_buffers_free (ocs_iscsi_t *iscsi, ocs_hal_rq_buffer_t *header, ocs_hal_rq_buffer_t *payload)
 Add a receive buffer pair to the Receive Queue, if an error is received, then queue the buffer. More...
 
void ocs_iscsi_cxn_req_invalidate (ocs_iscsi_t *iscsi)
 

Macro Details

#define IDLE_TIMER_MS   (30 * 1000) /* 30 seconds */

Definition at line 147 of file ocs_iscsi.c.

Function Details

void format_ip_address ( ocs_ip_type_e  ip_type,
uint8_t *  address,
char *  buffer,
int  size 
)

Format an IP address into a string.

Description
Given a pointer to an IP address and a buffer, this function writes the IP address into the buffer in human readable form.
Parameters
ip_typeEnumerated type indicating the type of IP address (IPV4, IPV6, etc).
addressPointer to an array containing the IP address to be formatted. 4 bytes for IPV4, 16 bytes for IPV6.
bufferPointer to the buffer into which the result will be placed.
sizeSize of the output buffer in bytes.
Returns
None.

Definition at line 460 of file ocs_iscsi.c.

void format_mac_address ( uint8_t *  address,
char *  buffer,
int  size 
)

Format a MAC address into a string.

Description
Given a pointer to a MAC address and a buffer, this function writes the MAC address into the buffer in human readable form.

Note: To avoid truncation, the output buffer must be at least 18 bytes long.
Parameters
addressPointer to an array of 6 bytes containing the MAC address.
bufferPointer to the buffer into which the result will be placed.
sizeSize of the output buffer in bytes.
Returns
None.

Definition at line 711 of file ocs_iscsi.c.

int32_t ocs_iscsi_add_ip_to_tbl ( ocs_t *  ocs,
char *  desc,
ocs_ip_address_subnet_t *  ipsub,
ocs_hal_portal_t  portal 
)

Adds an IP address to the table.

Parameters
ocsPointer to the ocs structure.
descA character description of the IP address being added.
ipsubPointer to the IP/subnet structure.
portalPortal that has the IP address.

Definition at line 2622 of file ocs_iscsi.c.

void ocs_iscsi_cluster_tgts_free ( ocs_iscsi_t *  iscsi)

iscsi cluster targets free

Definition at line 2211 of file ocs_iscsi.c.

void ocs_iscsi_convert_to_hal_ip ( ocs_ip_address_t *  ip,
ocs_hal_ip_address_t *  hal_ip 
)

Convert an iSCSI IP address to the HAL IP address.

Parameters
ipPointer to the iSCSI IP address.
hal_ipPointer to the HAL IP address.

Definition at line 359 of file ocs_iscsi.c.

ocs_hal_ip_type_e ocs_iscsi_convert_to_hal_ip_type ( ocs_ip_type_e  ip_type)

Convert an iSCSI IP type to the HAL value.

Parameters
ip_typeiSCSI IP type to convert.
Returns
Returns the HAL IP type or OCS_HAL_IP_TYPE_V4 if an invalid value is passed.

Definition at line 296 of file ocs_iscsi.c.

static void ocs_iscsi_convert_to_hal_ipsub ( ocs_ip_address_subnet_t *  ip,
ocs_hal_ip_address_subnet_t *  hal_ip 
)
static

Convert an iSCSI IP address to the HAL IP address.

Parameters
ipPointer to the iSCSI IP address.
hal_ipPointer to the HAL IP address.

Definition at line 385 of file ocs_iscsi.c.

void ocs_iscsi_convert_to_ip ( ocs_ip_address_t *  ip,
ocs_hal_ip_address_t *  hal_ip 
)

Convert an iSCSI IP address to the HAL IP address.

Parameters
ipPointer to the iSCSI IP address.
hal_ipPointer to the HAL IP address.

Definition at line 372 of file ocs_iscsi.c.

ocs_ip_type_e ocs_iscsi_convert_to_ip_type ( ocs_hal_ip_type_e  ip_type)

Convert an HAL IP type to the iSCSI API value.

Parameters
ip_typeHAL IP type to convert.
Returns
Returns the iSCSI IP type or OCS_IP_TYPE_V4 if an invalid value is passed.

Definition at line 327 of file ocs_iscsi.c.

static void ocs_iscsi_convert_to_ipsub ( ocs_ip_address_subnet_t *  ip,
ocs_hal_ip_address_subnet_t *  hal_ip 
)
static

Convert an iSCSI IP address to the HAL IP address.

Parameters
ipPointer to the iSCSI IP address.
hal_ipPointer to the HAL IP address.

Definition at line 399 of file ocs_iscsi.c.

static ocs_config_ctx_t* ocs_iscsi_ctx_alloc ( ocs_iscsi_t *  iscsi,
ocs_config_ctx_e  index 
)
static

Allocates an iSCSI API context that provides a synchronous API when using a asynchronous mailbox command.

Parameters
iscsiPointer to the iSCSI object.
indexIndex of the context to allocate.
Returns
Returns pointer to the context if available, or NULL if it is in use.

Definition at line 174 of file ocs_iscsi.c.

static void ocs_iscsi_ctx_free ( ocs_iscsi_t *  iscsi,
ocs_config_ctx_e  index 
)
static

Frees an iSCSI API context that provides a synchronous API when using a asynchronous mailbox command.

Parameters
iscsiPointer to the iSCSI object.
indexIndex of the context to free.

Definition at line 238 of file ocs_iscsi.c.

static void ocs_iscsi_ctx_general_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

This function is the callback a general API context command.

Parameters
ul_argPointer to the iscsi object.
statusStatus of the command.
ext_statusExtended status of the command.
paramsPoints to the command parameters.

Definition at line 927 of file ocs_iscsi.c.

static void ocs_iscsi_ctx_post ( ocs_config_ctx_t *  ctx,
int32_t  status,
uint32_t  ext_status 
)
static

Updates the status fields and post to the semaphore if it is still in use.

Parameters
ctxPointer to the command context.
statusStatus of the command.
ext_statusExtended status of the command.

Definition at line 251 of file ocs_iscsi.c.

static void ocs_iscsi_ctx_route_table_read_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

This function is the callback a add route table command.

Parameters
ul_argPointer to the iscsi object.
statusStatus of the command.
ext_statusExtended status of the command.
paramsPoints to the command parameters.

Definition at line 2233 of file ocs_iscsi.c.

static void ocs_iscsi_ctx_teardown ( ocs_iscsi_t *  iscsi)
static

Completes any active iSCSI API context when the device is being shut down.

Parameters
iscsiPointer to the iSCSI object.
Returns
Returns the pointer to the context if available, or NULL if it is in use.

Definition at line 273 of file ocs_iscsi.c.

static int32_t ocs_iscsi_ctx_wait ( ocs_iscsi_t *  iscsi,
ocs_config_ctx_e  index,
int  timeout_usec 
)
static

Waits on an iSCSI API context until the command completes or the timeout occurs.

Parameters
iscsiPointer to the iSCSI object.
indexIndex of the context to free.
timeout_usecTimeout in microseconds.
Returns
Returns 0 for success, or a negative value if the semaphore was not acquired.

Definition at line 199 of file ocs_iscsi.c.

static int32_t ocs_iscsi_cxn_event_cb ( void *  arg,
ocs_hal_cxn_event_t *  cxn_event 
)
static

Function to receive connection events.

Parameters
argPointer to the iSCSI structure that represents this device.
cxn_eventIdentifies the event that was received.
Returns
Returns 0 on success.

Definition at line 3601 of file ocs_iscsi.c.

static int32_t ocs_iscsi_cxn_event_data_digest ( ocs_iscsi_t *  iscsi,
ocs_hal_tgt_data_digest_t *  tgt_digest 
)
static

Function to process a data digest error.

Parameters
iscsiPointer to the iSCSI structure that represents this device.
tgt_digestPointer to the data digest error fields.
Returns
Returns 0 on success.

Definition at line 3555 of file ocs_iscsi.c.

static int32_t ocs_iscsi_cxn_event_invalid ( ocs_iscsi_t *  iscsi,
ocs_cxn_t *  cxn,
uint32_t  code 
)
static

Function to process connection invalidation notifications.

Parameters
iscsiPointer to the iSCSI structure that represents this device.
cxnPointer to the connection object.
codeError code.
Returns
Returns 0 on success.

Definition at line 3490 of file ocs_iscsi.c.

void ocs_iscsi_cxn_req_invalidate ( ocs_iscsi_t *  iscsi)

Definition at line 4456 of file ocs_iscsi.c.

static int32_t ocs_iscsi_cxn_request_logout ( ocs_cxn_t *  cxn)
static

Attempts to send an asynchronous message to request the initiator to logout.

Parameters
cxnPointer to the connection object.
Returns
Returns 0 on success.

Definition at line 782 of file ocs_iscsi.c.

static uint32_t ocs_iscsi_decode_lun ( uint8_t *  lu)
static

Decode a LU Number according to SAM.

Parameters
luPointer to LU data
Note
Only handles single level LU.
Returns
Returns LU number or max int on error.

Definition at line 3644 of file ocs_iscsi.c.

int32_t ocs_iscsi_find_portal_from_vlan ( ocs_t *  ocs,
uint32_t  vlan_id,
ocs_hal_portal_t *  iface_handle 
)

Helper function to find respective interface handle of VLAN id.

Parameters
ocsPointer to the ocs structure that represents this device.
vlan_tagThe vlan id
iface_handle
Returns
Returns 0 if interface handle is found, otherwise a negative value.

Definition at line 2921 of file ocs_iscsi.c.

int32_t ocs_iscsi_gateway_set ( ocs_t *  ocs,
ocs_ip_address_t *  gateway 
)

Sets the IP gateway address.

Parameters
ocsPointer to the ocs structure that represents this device.
gatewayIP address of the gateway.
Returns
Returns 0 on success.

Definition at line 2771 of file ocs_iscsi.c.

static int32_t ocs_iscsi_hal_configure ( ocs_iscsi_t *  iscsi)
static

Configure the HAL based on iSCSI compile parameters.

Parameters
iscsiPointer to the iSCSI structure that represents this device.
Returns
Returns 0 on success.

Definition at line 2015 of file ocs_iscsi.c.

static void ocs_iscsi_idle_timeout ( void *  arg)
static

This function is called to check for idle connections.

Parameters
argPointer to the iscsi object.

Definition at line 818 of file ocs_iscsi.c.

int32_t ocs_iscsi_inet_pton4 ( const char *  src,
ocs_ip_address_t *  ip 
)

Converts an IPv4 address from a string to the IP structure.

Parameters
srcPointer to the ASCII IP address.
ipPointer to a IP address structure.
Returns
Returns 0 for a valid IP address.

Definition at line 513 of file ocs_iscsi.c.

int32_t ocs_iscsi_inet_pton6 ( const char *  src,
ocs_ip_address_t *  ip 
)

Converts an IPv6 address from a string to the IP structure.

Parameters
srcPointer to the ASCII IP address.
ipPointer to an IP address structure.
Returns
Returns 0 for a valid IP address.

Definition at line 574 of file ocs_iscsi.c.

int32_t ocs_iscsi_ip_address_add ( ocs_t *  ocs,
ocs_hal_portal_t  portal,
ocs_ip_address_subnet_t *  ipsub 
)

Adds the IP address to the specified interface.

Parameters
ocsPointer to the ocs structure that represents this device.
portalPortal to use.
ipsubIP Address and subnet to add.
Returns
Returns 0 on success.

Definition at line 2417 of file ocs_iscsi.c.

int32_t ocs_iscsi_ip_address_query ( ocs_t *  ocs,
ocs_hal_portal_t  portal,
ocs_ip_type_e  ip_type,
uint32_t  max_entries,
uint32_t *  num_ips,
ocs_ip_address_subnet_t *  ipsub 
)

Queries the IP addresses on the default interface.

Parameters
ocsPointer to the ocs structure that represents this device.
portalPortal to use.
ip_typeEnumerated type indicating the type of IP address (IPV4, IPV6, etc).
max_entriesMaximum number of entries to be returned.
num_ipsActual number of entries returned.
ipsubUsed to return queried IP addresses.
Returns
Returns 0 on success.

Definition at line 2567 of file ocs_iscsi.c.

int32_t ocs_iscsi_ip_address_remove ( ocs_t *  ocs,
ocs_hal_portal_t  portal,
ocs_ip_address_subnet_t *  ipsub 
)

Remove the IP address to the specified interface.

Parameters
ocsPointer to the ocs structure that represents this device.
portalPortal to use.
ipsubIP Address and subnet to remove.
Returns
Returns 0 on success.

Definition at line 2510 of file ocs_iscsi.c.

void ocs_iscsi_ipsub_combine ( ocs_ip_address_subnet_t *  ipsub,
ocs_ip_address_t *  ip,
ocs_ip_address_t *  subnet 
)

Combines an iSCSI IP address and subnet into the combined structure.

Parameters
ipsubPointer to the combined iSCSI IP/subnet address.
ipPointer to the IP address.
subnetPointer to the IP subnet address.

Definition at line 414 of file ocs_iscsi.c.

void ocs_iscsi_ipsub_split ( ocs_ip_address_subnet_t *  ipsub,
ocs_ip_address_t *  ip,
ocs_ip_address_t *  subnet 
)

Splits an iSCSI IP address and subnet from the combined structure.

Parameters
ipsubPointer to the combined iSCSI IP/subnet address.
ipPointer to the IP address.
subnetPointer to the IP subnet address.

Definition at line 431 of file ocs_iscsi.c.

int32_t ocs_iscsi_is_ip_in_tbl ( ocs_t *  ocs,
ocs_ip_address_subnet_t *  ipsub 
)

Checks if an IP address/subnet is present in the table.

Parameters
ocsPointer to the ocs structure.
ipsubPointer to the IP address/subnet structure to check.
Returns
Returns TRUE if the IP address is found.

Definition at line 2742 of file ocs_iscsi.c.

int32_t ocs_iscsi_isns_discover ( ocs_t *  ocs,
ocs_hal_portal_t  portal,
uint32_t  max_entries,
uint32_t *  num_ips,
ocs_ip_address_t *  ip 
)

Discovers the iSNS through the DHCP service.

Parameters
ocsPointer to the ocs structure that represents this device.
portalPortal to use.
max_entriesMaximum number of entries to be returned.
num_ipsActual number of entries returned.
ipIP address to listen on.
Returns
Returns 0 on success.

Definition at line 1138 of file ocs_iscsi.c.

static void ocs_iscsi_isns_discover_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

This function is the callback for the iSNS server IP addresses.

Parameters
ul_argPointer to the iscsi object.
statusStatus of the command.
ext_statusExtended status of the command.
paramsPointer to ocs_hal_ip_address_subnet_t.

Definition at line 946 of file ocs_iscsi.c.

int32_t ocs_iscsi_isns_esi_listen_start ( ocs_t *  ocs,
ocs_ip_address_t *  ip,
uint16_t  tcp_port 
)

Starts an iSNS ESI TCP listen socket.

Parameters
ocsPointer to the ocs structure that represents this device.
ipIP address to listen on.
tcp_portTCP port number to listen on.
Returns
Returns 0 on success.

Definition at line 1037 of file ocs_iscsi.c.

int32_t ocs_iscsi_isns_esi_listen_stop ( ocs_t *  ocs,
ocs_ip_address_t *  ip,
uint16_t  tcp_port 
)

Stops an iSNS ESI TCP listen socket.

Parameters
ocsPointer to the ocs structure that represents this device.
ipIP address to listen on.
tcp_portTCP port number to listen on.
Returns
Returns 0 on success.

Definition at line 1087 of file ocs_iscsi.c.

int32_t ocs_iscsi_isns_send ( ocs_t *  ocs,
ocs_ip_address_t *  isns_server,
uint32_t  tcp_port,
void *  buffer,
uint32_t *  pkt_len,
uint32_t  buff_len 
)

Sends an iSNS packet to a server to test the interface.

Parameters
ocsPointer to the ocs structure that represents this device.
isns_serverIP address of the iSNS server.
tcp_portTCP port number.
bufferPointer to the virtual address of the iSNS buffer. This buffer is used for both the request and response.
pkt_lenLength of the packet and returns the length of the response.
buff_lenLength of the buffer. Used to truncate the response if required.
Returns
Returns 0 on success.

Definition at line 1196 of file ocs_iscsi.c.

static void ocs_iscsi_isns_send_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

This function is the callback for the iSNS send.

Parameters
ul_argPointer to the iscsi object.
statusStatus of the command.
ext_statusExtended status of the command.
paramsPointer to ocs_hal_ip_address_subnet_t.

Definition at line 986 of file ocs_iscsi.c.

static int32_t ocs_iscsi_link_event_cb ( void *  arg,
uint8_t  isLinkUp 
)
static

Function to receive the notification of link events.

Parameters
argPointer to the iSCSI structure that represents this device.
isLinkUpNon-zero means the link is up.
Returns
Returns 0 on success.

Definition at line 3385 of file ocs_iscsi.c.

int32_t ocs_iscsi_listen_start ( ocs_t *  ocs,
ocs_ip_address_t *  ip,
uint16_t  tcp_port 
)

Starts a TCP listen socket.

Parameters
ocsPointer to the ocs structure that represents this device.
ipIP address to listen on.
tcp_portTCP port number to listen on.
Returns
Returns 0 on success.

Definition at line 3227 of file ocs_iscsi.c.

int32_t ocs_iscsi_listen_stop ( ocs_t *  ocs,
ocs_ip_address_t *  ip,
uint16_t  tcp_port 
)

Stops a TCP listen socket.

Parameters
ocsPointer to the ocs structure that represents this device.
ipIP address to listen on.
tcp_portTCP port number to listen on.
Returns
Returns 0 on success.

Definition at line 3275 of file ocs_iscsi.c.

uint8_t* ocs_iscsi_mac_get ( ocs_t *  ocs)

Gets the MAC address of the iSCSI device.

Parameters
ocsPointer to the ocs structure that represents this device.
Returns
Returns a pointer to an array of 6 bytes containing the MAC address of the interface.

Definition at line 1323 of file ocs_iscsi.c.

int32_t ocs_iscsi_mac_set ( ocs_t *  ocs,
uint8_t *  mac_address 
)

Sets the MAC address of the iSCSI device.

Parameters
ocsPointer to the ocs structure that represents this device.
mac_addressPointer to the MAC address value.
Returns
Returns 0 on success.

Definition at line 1281 of file ocs_iscsi.c.

int32_t ocs_iscsi_mtu_set ( ocs_t *  ocs,
uint8_t  is_jumbo 
)

Sets the TCP MTU size of the iSCSI device.

Parameters
ocsPointer to the ocs structure that represents this device
is_jumboIf TRUE, then the portal will be set for jumbo, otherwise set for the standard 1500 bytes.
Returns
Returns 0 on success.

Definition at line 2173 of file ocs_iscsi.c.

int32_t ocs_iscsi_portal_add_vlan ( ocs_t *  ocs,
ocs_hal_portal_t  iface,
uint32_t  vlan_id 
)

Add VLAN and iface handle to portal_list.

Parameters
ocsPointer to the ocs structure that represents this device.
ifaceThe interface handle to add
vlan_tagThe vlan id to add
Returns
Returns 0 on success, otherwise a negative value

Definition at line 2976 of file ocs_iscsi.c.

int32_t ocs_iscsi_portal_create ( ocs_t *  ocs,
unsigned int  vlan_id,
ocs_hal_portal_t *  portal 
)

Creates a portal for a VLAN.

Parameters
ocsPointer to the ocs structure that represents this device.
vlan_tagThe vlan to create.
portalPortal to create.
Returns
Returns 0 on success.

Definition at line 3125 of file ocs_iscsi.c.

static void ocs_iscsi_portal_create_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

This function is the callback for creating an interface/portal.

Parameters
ul_argPointer to the iscsi object.
statusStatus of the command.
ext_statusExtended status of the command.
paramsNULL for this function.

Definition at line 3103 of file ocs_iscsi.c.

int32_t ocs_iscsi_portal_del_vlan ( ocs_t *  ocs,
ocs_hal_portal_t  iface 
)

Delete iface handle and VLAN from portal_list.

Parameters
ocsPointer to the ocs structure that represents this device.
ifaceThe interface handle to delete
vlan_tagThe vlan id to delete
Returns
Returns 0 on success, otherwise a negative value

Definition at line 3011 of file ocs_iscsi.c.

int32_t ocs_iscsi_portal_delete ( ocs_t *  ocs,
ocs_hal_portal_t  portal 
)

Removes a previously-created portal.

Parameters
ocsPointer to the ocs structure that represents this device.
portalPortal to remove.
Returns
Returns 0 on success.

Definition at line 3183 of file ocs_iscsi.c.

int32_t ocs_iscsi_portal_find_ip_address ( ocs_t *  ocs,
ocs_hal_portal_t  iface_handle,
ocs_ip_address_t *  ip,
ocs_ip_address_t *  subnet,
uint16_t *  tcp_port,
int32_t *  listening 
)

Find IP address of interface handle If IP address is found for given interface handle, copy to ip and subnet params.

Returns
Returns TRUE if IP addresses are found for given interface handle, otherwise FALSE

Definition at line 2830 of file ocs_iscsi.c.

ocs_hal_portal_t ocs_iscsi_portal_get_default ( ocs_t *  ocs)

Retrieves the default portal.

Parameters
ocsPointer to the ocs structure that represents this device.
Returns
Returns the default portal.

Definition at line 2816 of file ocs_iscsi.c.

int32_t ocs_iscsi_portal_is_vlan_exists ( ocs_t *  ocs,
uint32_t  vlan_id 
)

Check VLAN for duplicate.

Parameters
ocsPointer to the ocs structure that represents this device.
vlan_tagThe vlan to check for duplicates.
Returns
Returns TRUE if VLAN is not exists, otherwise FALSE.

Definition at line 2949 of file ocs_iscsi.c.

int32_t ocs_iscsi_portal_read_vlan_ids ( ocs_t *  ocs,
void *  arg_out,
uint32_t  arg_out_length 
)

Read VLAN IDs to provided buffer.

Parameters
ocsPointer to the ocs structure that represents this device.
arg_outPointer to output buffer
arg_out_lengthLength of output buffer
Returns
Returns 0 on success, otherwise a negative value

Definition at line 3041 of file ocs_iscsi.c.

int32_t ocs_iscsi_portal_remove_ip_addresses ( ocs_t *  ocs,
ocs_hal_portal_t  iface_handle 
)

Check and remove IP addresses of the corresponding interface.

Parameters
ocsPointer to the OCS context
iface_handleInterface handle to check for IP addresses
Returns
Returns 0 on success, otherwise a negative value

Definition at line 2862 of file ocs_iscsi.c.

static void ocs_iscsi_print_module_params ( ocs_iscsi_t *  iscsi)
static

This function prints the module parameters to the log for debugging purposes.

Parameters
iscsiPointer to the iSCSI structure that represents this device

Definition at line 1334 of file ocs_iscsi.c.

static void ocs_iscsi_query_ip_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

This function is the callback for querying IP addresses.

Parameters
ul_argPointer to the iSCSI object.
statusStatus of the command.
ext_statusExtended status of the command.
paramsPointer to ocs_hal_ip_address_subnet_t.

Definition at line 1253 of file ocs_iscsi.c.

static ocs_pdu_process_rtn_e ocs_iscsi_recv_cmd ( ocs_iscsi_t *  iscsi,
ocs_cxn_t *  cxn,
ocs_hal_rq_buffer_t *  hdr,
uint32_t  hdr_len,
ocs_hal_rq_buffer_t *  data,
uint32_t  data_len 
)
static

Function to receive unsolicited command PDUs.

Parameters
iscsiPointer to the iSCSI structure that represents this device.
cxnPointer to the connection object.
hdrDMA memory information for the header.
hdr_lenLength of the header received.
dataDMA memory information for the data.
data_lenLength of the data received.
Returns
Returns 0 on success.

Definition at line 3705 of file ocs_iscsi.c.

static ocs_pdu_process_rtn_e ocs_iscsi_recv_tm ( ocs_iscsi_t *  iscsi,
ocs_cxn_t *  cxn,
ocs_hal_rq_buffer_t *  hdr,
uint32_t  hdr_len 
)
static

Function to receive unsolicited task management PDUs.

Parameters
iscsiPointer to the iSCSI structure that represents this device.
cxnPointer to the connection object.
hdrDMA memory information for the header.
hdr_lenLength of the header received.
Returns
Returns 0 on success.

Definition at line 3838 of file ocs_iscsi.c.

static int32_t ocs_iscsi_recv_tm_cb ( ocs_io_t *  io,
ocs_scsi_io_status_e  status,
uint32_t  flags,
void *  arg 
)
static

Callback function used to free an IO for a rejected task management function.

Parameters
ioPointer to the OS io object.
statusStatus of the command.
flagsFlags.
argPoints to the io object.
Returns
Returns 0 on success.

Definition at line 3818 of file ocs_iscsi.c.

static int32_t ocs_iscsi_recv_tm_rsp ( ocs_iscsi_t *  iscsi,
ocs_cxn_t *  cxn,
ocs_hal_rq_buffer_t *  hdr,
uint32_t  hdr_len 
)
static

Function to receive unsolicited task management response PDUs.

Parameters
iscsiPointer to the iSCSI structure that represents this device.
cxnPointer to the connection object.
hdrDMA memory information for the header.
hdr_lenLength of the header received.
Returns
Returns 0 on success.

Definition at line 3956 of file ocs_iscsi.c.

int32_t ocs_iscsi_register_link_state_callback ( ocs_t *  ocs,
ocs_link_state_cb_t  cb 
)

Register to receive link state change notifications.

Description
This function is used by upper level drivers to register a function which should be called when the link state changes.
Returns
Returns 0 on success, or a negative error code value on failure.

Definition at line 3324 of file ocs_iscsi.c.

int32_t ocs_iscsi_remove_ip_from_tbl ( ocs_t *  ocs,
ocs_ip_address_subnet_t *  ipsub,
ocs_hal_portal_t  portal 
)

Remove an IP address from the table.

Parameters
ocsPointer to the ocs structure.
ipsubPointer to the IP/subnet structure.
portalPortal that has the IP address.
Returns
Returns 0 if the address was removed, or -1 if the address was not found.

Definition at line 2696 of file ocs_iscsi.c.

int32_t ocs_iscsi_route_table_add_entry ( ocs_t *  ocs,
ocs_ip_address_subnet_t *  ipsub,
ocs_ip_address_t *  gateway 
)

Adds an entry to a routing table.

Parameters
ocsPointer to the ocs structure that represents this device.
ipsubIP Address, subnet and gateway to add.
Returns
Returns 0 on success.

Definition at line 2328 of file ocs_iscsi.c.

int32_t ocs_iscsi_route_table_del_entry ( ocs_t *  ocs,
ocs_ip_address_subnet_t *  ipsub,
ocs_ip_address_t *  gateway 
)

Deletes an entry from a routing table.

Parameters
ocsPointer to the ocs structure that represents this device.
ipsubIP Address, subnet and gateway to delete.
Returns
Returns 0 on success.

Definition at line 2276 of file ocs_iscsi.c.

int32_t ocs_iscsi_route_table_read ( ocs_t *  ocs,
ocs_route_table_t *  route_table 
)

Definition at line 2371 of file ocs_iscsi.c.

void ocs_iscsi_rx_buffers_free ( ocs_iscsi_t *  iscsi,
ocs_hal_rq_buffer_t *  header,
ocs_hal_rq_buffer_t *  payload 
)

Add a receive buffer pair to the Receive Queue, if an error is received, then queue the buffer.

Parameters
iscsiPointer to the iSCSI object.
headerDMA memory for the unsolicited header.
payloadDMA memory for the unsolicited payload.

Definition at line 4447 of file ocs_iscsi.c.

ocs_pdu_process_rtn_e ocs_iscsi_tgt_process_cmd_sn ( ocs_iscsi_t *  iscsi,
ocs_cxn_t *  cxn,
ocs_hal_rq_buffer_t *  hdr,
uint32_t  hdr_len,
ocs_hal_rq_buffer_t *  data,
uint32_t  data_len,
uint8_t  code,
uint8_t *  reject_reason 
)

Function to process unsolicited PDUs for a target.

Parameters
iscsiPointer to the iSCSI structure that represents this device.
cxnPointer to the connection object.
hdrDMA memory information for the header.
hdr_lenLength of the header received.
dataDMA memory information for the data.
data_lenLength of the data received.
codeType of callback received from the chip (i.e. SLI_STATUS_UNSOL_DATA_DIGEST_ERROR).
reject_reasonReturns the reject reason.
Returns
Returns 0 on success.

Definition at line 4042 of file ocs_iscsi.c.

void ocs_iscsi_unregister_link_state_callback ( ocs_t *  ocs,
ocs_link_state_cb_t  cb 
)

Unregister a link state change callback.

Description
This function is used by upper level drivers to remove the registration of a link state callback function.
Returns
None.

Definition at line 3360 of file ocs_iscsi.c.

static int32_t ocs_iscsi_unsolicited_event_cb ( void *  arg,
ocs_cxn_t *  cxn,
ocs_hal_rq_buffer_t *  hdr,
uint32_t  hdr_len,
ocs_hal_rq_buffer_t *  data,
uint32_t  data_len,
uint8_t  code 
)
static

Function to receive unsolicited PDUs.

Parameters
argPointer to the iSCSI structure that represents this device.
cxnPointer to the connection object.
hdrDMA memory information for the header.
hdr_lenLength of the header received.
dataDMA memory information for the data.
data_lenLength of the data received.
codeType of callback received from the chip (i.e. SLI_STATUS_UNSOL_DATA_DIGEST_ERROR).
Returns
Returns 0 on success.

Definition at line 4210 of file ocs_iscsi.c.

static int32_t ocs_iscsi_unsolicited_event_ini ( ocs_iscsi_t *  iscsi,
ocs_cxn_t *  cxn,
ocs_hal_rq_buffer_t *  hdr,
uint32_t  hdr_len,
ocs_hal_rq_buffer_t *  data,
uint32_t  data_len,
uint8_t  code 
)
static

Function to receive unsolicited PDUs for an initiator.

Parameters
iscsiPointer to the iSCSI structure that represents this device.
cxnPointer to the connection object.
hdrDMA memory information for the header.
hdr_lenLength of the header received.
dataDMA memory information for the data.
data_lenLength of the data received.
codeType of callback received from the chip (i.e. SLI_STATUS_UNSOL_DATA_DIGEST_ERROR).
Returns
Returns 0 on success.

Definition at line 4116 of file ocs_iscsi.c.

int32_t parse_mac_address ( const char *  src,
uint8_t *  dest 
)

Parse a string into a MAC address.

Description
This function parses a human readable MAC address into an array of 6 bytes.

The input should be a string of six two-digit hex numbers, optionally separated by - or :. If the input string is not in one of these formats the results are undefined.
Parameters
srcPointer to the input string.
destPointer to an array of at least 6 bytes in which the MAC address will be stored.
Returns
Returns 0 on success; or -1 if the string does not represent a valid MAC address.

Definition at line 737 of file ocs_iscsi.c.