36 #include "ocs_params.h"
47 void *arg_out, uint32_t arg_out_length,
void *driver);
59 #define P(type, name, value, desc) type name = value;
84 ocs_log_err(NULL,
"ocs_scsi_tgt_init failed rc=%d\n", rc);
93 ocs_log_err(NULL,
"ocs_scsi_ini_init failed rc=%d\n", rc);
163 return ocs->instance_index;
185 ocs = ocs_malloc(NULL,
sizeof(ocs_t), OCS_M_NOWAIT | OCS_M_ZERO);
187 ocs_log_err(ocs,
"memory allocation failed for ocs_t\n");
200 if (ocs->ramlog == NULL) {
206 if (ddump_saved_size) {
208 ocs_log_err(ocs,
"failed to allocate memory for saved ddump\n");
214 #if defined(ENABLE_LOCK_DEBUG)
215 ocs_lock_init(NULL, &ocs->ocs_os.locklist_lock,
"locklist_lock[%d]", ocs->instance_index);
220 ocs->drv_ocs.uspace_thread_per_port = (uspacemask & (1U << 0)) == 0;
221 ocs->drv_ocs.uspace_threads_block = (uspacemask & (1U << 1)) == 0;
234 #if defined(ENABLE_LOCK_DEBUG)
236 ocs_os_t *os = &ocs->ocs_os;
240 ocs_log_test(os,
"%s not freed\n", l->name);
244 ocs_log_debug(ocs,
"all lock objects freed\n");
249 ocs_free(NULL, ocs,
sizeof(*ocs));
264 ocs->enable_ini = initiator;
265 ocs->enable_tgt = target;
276 ocs->enable_ini = initiator;
277 ocs->enable_tgt = target;
281 snprintf(ocs->display_name,
sizeof(ocs->display_name),
"[%s%d] ",
"i", ocs->instance_index);
284 ocs->ctrlmask = ctrlmask;
285 ocs->num_cxns = num_cxns;
286 ocs->num_tgts = num_tgts;
287 ocs->global_ramdisc = global_ramdisc;
288 ocs->num_scsi_ios = num_scsi_ios;
289 ocs_strcpy(ocs->local_ip, local_ip);
290 ocs_strcpy(ocs->local_subnet, local_subnet);
291 ocs_strcpy(ocs->gateway, gateway);
292 ocs->tcp_window_size = tcp_window_size;
293 ocs->tcp_window_scale = tcp_window_scale;
294 ocs->enable_sgl_chaining = (enable_sgl_chaining == 0 ? FALSE : TRUE);
295 ocs->enable_immediate_data = (enable_immediate_data == 0 ? FALSE : TRUE);
296 ocs->enable_hdr_digest = (enable_hdr_digest == 0 ? FALSE : TRUE);
297 ocs->enable_data_digest = (enable_data_digest == 0 ? FALSE : TRUE);
298 ocs->enable_jumbo_frame = (enable_jumbo_frame == 0 ? FALSE : TRUE);
301 ocs->hal_war_version = hal_war_version;
304 ocs->target_io_timer_sec = 0;
306 if (max_sge_size < 1024 &&
307 max_sge_size > 65536) {
308 ocs_log_test(ocs,
"Ignoring invalid max_sge_size\n");
310 ocs->max_sge_size = max_sge_size;
312 ocs->post_sgl_config = post_sgl_config;
316 ocs_log_err(ocs,
"ocs_iscsi_initialize failed\n");
339 if (ocs->enable_tgt) {
342 if (ocs->enable_ini) {
348 ocs_log_err(ocs,
"ocs_iscsi_teardown() failed: %d\n", rc);
359 if (ocs_strcmp(prop_name,
"num_tgts") == 0)
360 ocs_snprintf(buffer, buffer_len,
"%d", num_tgts);
361 else if (ocs_strcmp(prop_name,
"global_ramdisc") == 0)
362 ocs_snprintf(buffer, buffer_len,
"%d", global_ramdisc);
363 else if (ocs_strcmp(prop_name,
"ramdisc_size") == 0)
364 ocs_strncpy(buffer, ramdisc_size, buffer_len);
365 else if (ocs_strcmp(prop_name,
"ramdisc_blocksize") == 0)
366 ocs_snprintf(buffer, buffer_len,
"%d", ramdisc_blocksize);
367 else if (ocs_strcmp(prop_name,
"num_luns") == 0)
368 ocs_snprintf(buffer, buffer_len,
"%d", num_luns);
369 else if (ocs_strcmp(prop_name,
"initiator") == 0)
370 ocs_snprintf(buffer, buffer_len,
"%d", initiator);
371 else if (ocs_strcmp(prop_name,
"target") == 0)
372 ocs_snprintf(buffer, buffer_len,
"%d", target);
373 else if (ocs_strcmp(prop_name,
"p_type") == 0)
374 ocs_snprintf(buffer, buffer_len,
"%d", p_type);
375 else if (ocs_strcmp(prop_name,
"dif_separate") == 0)
376 ocs_snprintf(buffer, buffer_len,
"%d", 1);
378 printf(
"Error: %s: unknown property %s\n", __func__, prop_name);
379 ocs_snprintf(buffer, buffer_len,
"%s",
"");
389 return ocs->display_name;
432 snprintf(qualifier,
sizeof(qualifier),
"%s/driver", parent);
435 if (ocs_strncmp(name, qualifier, strlen(qualifier)) == 0) {
436 char *unqualified_name = name + strlen(qualifier) +1;
439 if (ocs_strcmp(unqualified_name,
"ctrlmask") == 0) {
442 }
else if (ocs_strcmp(unqualified_name,
"num_cxns") == 0) {
445 }
else if (ocs_strcmp(unqualified_name,
"enable_sgl_chaining") == 0) {
448 }
else if (ocs_strcmp(unqualified_name,
"enable_immediate_data") == 0) {
451 }
else if (ocs_strcmp(unqualified_name,
"enable_hdr_digest") == 0) {
454 }
else if (ocs_strcmp(unqualified_name,
"enable_data_digest") == 0) {
457 }
else if (ocs_strcmp(unqualified_name,
"enable_jumbo_frame") == 0) {
460 }
else if (ocs_strcmp(unqualified_name,
"max_sge_size") == 0) {
463 }
else if (ocs_strcmp(unqualified_name,
"post_sgl_config") == 0) {
466 }
else if (ocs_strcmp(unqualified_name,
"local_ip") == 0) {
469 }
else if (ocs_strcmp(unqualified_name,
"local_subnet") == 0) {
472 }
else if (ocs_strcmp(unqualified_name,
"gateway") == 0) {
475 }
else if (ocs_strcmp(unqualified_name,
"tcp_window_size") == 0) {
478 }
else if (ocs_strcmp(unqualified_name,
"tcp_window_scale") == 0) {
481 }
else if (ocs_strcmp(unqualified_name,
"num_tgts") == 0) {
484 }
else if (ocs_strcmp(unqualified_name,
"initiator") == 0) {
487 }
else if (ocs_strcmp(unqualified_name,
"target") == 0) {
490 }
else if (ocs_strcmp(unqualified_name,
"global_ramdisc") == 0) {
493 }
else if (ocs_strcmp(unqualified_name,
"ramdisc_size") == 0) {
496 }
else if (ocs_strcmp(unqualified_name,
"ramdisc_blocksize") == 0) {
499 }
else if (ocs_strcmp(unqualified_name,
"num_luns") == 0) {
502 }
else if (ocs_strcmp(unqualified_name,
"p_type") == 0) {
505 }
else if (ocs_strcmp(unqualified_name,
"num_scsi_ios") == 0) {
554 uint32_t arg_in_length,
void *arg_out, uint32_t arg_out_length,
void *
object)
int32_t ocs_device_detach(ocs_t *ocs)
Remove the PCI device instance.
int32_t ocs_scsi_tgt_del_device(ocs_t *ocs)
Tears down the target members of the ocs structure.
const char * ocs_display_name(void *os)
int32_t ocs_scsi_tgt_driver_init(void)
Driver-wide initialization for the target-server.
int32_t ocs_get_property(const char *prop_name, char *buffer, uint32_t buffer_len)
ocs_t * ocs_get_instance(uint32_t index)
Returns a pointer to the ocs structure given the instance index.
void ocs_device_shutdown(void)
Perform driver-wide shut down actions.
int32_t ocs_scsi_ini_driver_init(int32_t initiator)
Initialize initiator client.
void ocs_mgmt_emit_int(ocs_textbuf_t *textbuf, int mode, const char *name, const char *fmt,...)
Generate a property with an integer value in a management XML document.
static ocs_mgmt_functions_t driver_mgmt_functions
static void ocs_device_lock_init(ocs_t *ocs)
ocs_t * ocs_devices[MAX_OCS_DEVICES]
void * ocs_device_alloc(uint32_t nid)
Instantiate the PCI device.
void ocs_device_free(ocs_t *ocs)
int ocs_mgmt_driver_exec(char *parent, char *action, void *arg_in, uint32_t arg_in_length, void *arg_out, uint32_t arg_out_length, void *driver)
void ocs_mgmt_start_unnumbered_section(ocs_textbuf_t *textbuf, const char *name)
Generate the beginning of an unnumbered section in a management XML document.
int32_t ocs_device_interrupts_required(ocs_t *ocs)
Returns the number of interrupts required per HBA.
void ocs_textbuf_free(ocs_t *ocs, ocs_textbuf_t *textbuf)
int const char const char void ocs_mgmt_emit_boolean(ocs_textbuf_t *textbuf, int access, const char *name, const int value)
Generate a property with a boolean value in a management XML document.
int32_t ocs_device_attach(ocs_t *ocs)
void ocs_ramlog_free(ocs_t *ocs, ocs_ramlog_t *ramlog)
Free a ramlog buffer.
void ocs_device_shutdown_complete(void)
Perform driver-wide shutdown complete actions.
#define ocs_list_init(head, type, link)
int ocs_mgmt_driver_set(char *parent, char *name, char *value)
int32_t ocs_scsi_ini_del_device(ocs_t *ocs)
Tears down initiator members of ocs structure.
void ocs_mgmt_end_unnumbered_section(ocs_textbuf_t *textbuf, const char *name)
Generate the end of a section in a management XML document.
void ocs_mgmt_driver_list(ocs_textbuf_t *textbuf, void *driver)
PARAM_LIST int32_t ocs_device_init(void)
Perform driver-wide initialization.
uint32_t ocs_instance(void *os)
Return the instance index of an opaque ocs structure.
ocs_mgmt_get_list_handler get_list_handler
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.
int32_t ocs_iscsi_teardown(ocs_iscsi_t *iscsi)
Shut down the device.
#define OCS_RAMLOG_DEFAULT_BUFFERS
int32_t ocs_iscsi_interrupts_required(ocs_os_handle_t os, ocs_hal_t *hal)
Returns the number of interrupts needed for this adapter.
void ocs_mgmt_driver_get_all(ocs_textbuf_t *textbuf, void *driver)
void ocs_xport_free(ocs_xport_t *xport)
free a transport object
#define ocs_assert(cond,...)
int32_t ocs_device_init_complete(void)
Perform device initialization complete.
int32_t ocs_textbuf_alloc(ocs_t *ocs, ocs_textbuf_t *textbuf, uint32_t length)
void ocs_mgmt_emit_string(ocs_textbuf_t *textbuf, int access, const char *name, const char *value)
Generate a property with a string value in a management XML document.
#define ocs_list_foreach(list, item)
Iterate a linked list.
#define OCS_ISCSI_MAX_CXNS_PER_SESSION
ocs_ramlog_t * ocs_ramlog_init(ocs_t *ocs, uint32_t buffer_len, uint32_t buffer_count)
Allocate a ramlog buffer.
void ocs_mgmt_emit_property_name(ocs_textbuf_t *textbuf, int access, const char *name)
Generate a property, with no value, in a management XML document.
int ocs_mgmt_driver_get(ocs_textbuf_t *textbuf, char *parent, char *name, void *driver)
uint32_t ocs_instance_count