Lines Matching full:ocs

41 #include "ocs.h"
48 if (OCS_LOG_ENABLE_DOMAIN_SM_TRACE(domain->ocs)) \
49 ocs_log_info(domain->ocs, "[domain] %-20s %-20s\n", __func__, ocs_sm_event_name(evt)); \
54 if (OCS_LOG_ENABLE_DOMAIN_SM_TRACE(domain ? domain->ocs : NULL)) \
55 ocs_log_info(domain ? domain->ocs : NULL, fmt, ##__VA_ARGS__); \
60 ocs_log_info(domain ? domain->ocs : NULL, fmt, ##__VA_ARGS__); \
94 ocs_t *ocs = arg; in ocs_domain_cb() local
114 domain = ocs_domain_find(ocs, fcf_wwn); in ocs_domain_cb()
116 domain = ocs_domain_alloc(ocs, fcf_wwn); in ocs_domain_cb()
118 ocs_log_err(ocs, "ocs_domain_alloc() failed\n"); in ocs_domain_cb()
167 ocs_log_warn(ocs, "unsupported event %#x\n", event); in ocs_domain_cb()
179 * @param ocs Pointer to the OCS device.
186 ocs_domain_find(ocs_t *ocs, uint64_t fcf_wwn) in ocs_domain_find() argument
191 ocs_device_lock(ocs); in ocs_domain_find()
192 ocs_list_foreach(&ocs->domain_list, domain) { in ocs_domain_find()
197 ocs_device_unlock(ocs); in ocs_domain_find()
206 * \c ocs argument.
208 * @param ocs Pointer to the OCS device.
215 ocs_domain_alloc(ocs_t *ocs, uint64_t fcf_wwn) in ocs_domain_alloc() argument
219 ocs_assert(ocs, NULL); in ocs_domain_alloc()
221 domain = ocs_malloc(ocs, sizeof(*domain), OCS_M_NOWAIT | OCS_M_ZERO); in ocs_domain_alloc()
223 domain->ocs = ocs; in ocs_domain_alloc()
224 domain->instance_index = ocs->domain_instance_count++; in ocs_domain_alloc()
227 ocs_lock_init(ocs, &domain->lookup_lock, "Domain lookup[%d]", domain->instance_index); in ocs_domain_alloc()
230 domain->lookup = spv_new(ocs); in ocs_domain_alloc()
232 ocs_log_err(ocs, "spv_new() failed\n"); in ocs_domain_alloc()
233 ocs_free(ocs, domain, sizeof(*domain)); in ocs_domain_alloc()
239 ocs_log_debug(ocs, "Domain allocated: wwn %016" PRIX64 "\n", domain->fcf_wwn); in ocs_domain_alloc()
240 domain->femul_enable = (ocs->ctrlmask & OCS_CTRLMASK_ENABLE_FABRIC_EMULATION) != 0; in ocs_domain_alloc()
242 ocs_device_lock(ocs); in ocs_domain_alloc()
244 if (ocs_list_empty(&ocs->domain_list)) { in ocs_domain_alloc()
245 ocs->domain = domain; in ocs_domain_alloc()
247 ocs_list_add_tail(&ocs->domain_list, domain); in ocs_domain_alloc()
248 ocs_device_unlock(ocs); in ocs_domain_alloc()
252 ocs_log_err(ocs, "domain allocation failed\n"); in ocs_domain_alloc()
272 ocs_t *ocs; in ocs_domain_free() local
275 ocs_assert(domain->ocs); in ocs_domain_free()
280 ocs = domain->ocs; in ocs_domain_free()
282 ocs_log_debug(ocs, "Domain free: wwn %016" PRIX64 "\n", domain->fcf_wwn); in ocs_domain_free()
287 ocs_device_lock(ocs); in ocs_domain_free()
288 ocs_list_remove(&ocs->domain_list, domain); in ocs_domain_free()
289 if (domain == ocs->domain) { in ocs_domain_free()
291 ocs->domain = ocs_list_get_head(&ocs->domain_list); in ocs_domain_free()
292 if (ocs->domain) { in ocs_domain_free()
293 ocs_log_debug(ocs, "setting new domain, old=%p new=%p\n", in ocs_domain_free()
294 domain, ocs->domain); in ocs_domain_free()
298 if (ocs_list_empty(&ocs->domain_list) && ocs->domain_list_empty_cb ) { in ocs_domain_free()
299 (*ocs->domain_list_empty_cb)(ocs, ocs->domain_list_empty_cb_arg); in ocs_domain_free()
301 ocs_device_unlock(ocs); in ocs_domain_free()
305 ocs_free(ocs, domain, sizeof(*domain)); in ocs_domain_free()
335 ocs_hw_domain_force_free(&domain->ocs->hw, domain); in ocs_domain_force_free()
345 * @param ocs Pointer to a device object.
353 ocs_register_domain_list_empty_cb(ocs_t *ocs, void (*callback)(ocs_t *ocs, void *arg), void *arg) in ocs_register_domain_list_empty_cb() argument
355 ocs_device_lock(ocs); in ocs_register_domain_list_empty_cb()
356 ocs->domain_list_empty_cb = callback; in ocs_register_domain_list_empty_cb()
357 ocs->domain_list_empty_cb_arg = arg; in ocs_register_domain_list_empty_cb()
358 if (ocs_list_empty(&ocs->domain_list) && callback) { in ocs_register_domain_list_empty_cb()
359 (*callback)(ocs, arg); in ocs_register_domain_list_empty_cb()
361 ocs_device_unlock(ocs); in ocs_register_domain_list_empty_cb()
370 * @param ocs Pointer to the driver instance context.
377 ocs_domain_get_instance(ocs_t *ocs, uint32_t index) in ocs_domain_get_instance() argument
382 ocs_log_err(ocs, "invalid index: %d\n", index); in ocs_domain_get_instance()
385 ocs_device_lock(ocs); in ocs_domain_get_instance()
386 ocs_list_foreach(&ocs->domain_list, domain) { in ocs_domain_get_instance()
391 ocs_device_unlock(ocs); in ocs_domain_get_instance()
423 ocs_log_warn(domain->ocs, "%-20s %-20s not handled\n", funcname, ocs_sm_event_name(evt)); in __ocs_domain_common()
468 ocs_log_warn(domain->ocs, "%-20s %-20s not handled\n", funcname, ocs_sm_event_name(evt)); in __ocs_domain_common_shutdown()
477 ocs_t *ocs = NULL; \
482 ocs_assert(domain->ocs, NULL); \
483 ocs = domain->ocs; \
484 ocs_assert(ocs->xport, NULL);
519 uint64_t my_wwnn = ocs->xport->req_wwnn; in __ocs_domain_init()
520 uint64_t my_wwpn = ocs->xport->req_wwpn; in __ocs_domain_init()
528 ocs_log_debug(ocs, "using default hardware WWN configuration \n"); in __ocs_domain_init()
529 my_wwpn = ocs_get_wwn(&ocs->hw, OCS_HW_WWN_PORT); in __ocs_domain_init()
530 my_wwnn = ocs_get_wwn(&ocs->hw, OCS_HW_WWN_NODE); in __ocs_domain_init()
533 ocs_log_debug(ocs, "Creating base sport using WWPN %016" PRIx64 " WWNN %016" PRIx64 "\n", in __ocs_domain_init()
537 sport = ocs_sport_alloc(domain, my_wwpn, my_wwnn, UINT32_MAX, ocs->enable_ini, ocs->enable_tgt); in __ocs_domain_init()
540 ocs_log_err(ocs, "ocs_sport_alloc() failed\n"); in __ocs_domain_init()
549 ocs_log_err(ocs, "no VLAN id available (FCF=%d)\n", in __ocs_domain_init()
560 if (ocs_hw_port_alloc(&ocs->hw, sport, NULL, (uint8_t *)&be_wwpn)) { in __ocs_domain_init()
561 ocs_log_err(ocs, "Can't allocate port\n"); in __ocs_domain_init()
578 ocs_log_debug(ocs, "%s fc_id=%#x speed=%d\n", in __ocs_domain_init()
586 if (ocs->enable_ini) { in __ocs_domain_init()
588 ocs_log_debug(ocs, "%d position map entries\n", count); in __ocs_domain_init()
593 ocs_log_debug(ocs, "%#x -> %#x\n", in __ocs_domain_init()
597 ocs_log_err(ocs, "ocs_node_alloc() failed\n"); in __ocs_domain_init()
607 if (ocs_hw_domain_alloc(&ocs->hw, domain, drec->index, vlan)) { in __ocs_domain_init()
608 ocs_log_err(ocs, "Failed to initiate HW domain allocation\n"); in __ocs_domain_init()
682 ocs_log_info(ocs, "Overriding WWN\n"); in __ocs_domain_wait_alloc()
703 ocs_log_err(ocs, "Hmmmm ... Fabric Controller node already exists\n"); in __ocs_domain_wait_alloc()
708 ocs_log_err(ocs, "Error: ocs_node_alloc() failed\n"); in __ocs_domain_wait_alloc()
710 if (ocs->nodedb_mask & OCS_NODEDB_PAUSE_FABRIC_LOGIN) { in __ocs_domain_wait_alloc()
726 ocs_log_err(ocs, "%s recv'd waiting for DOMAIN_ALLOC_OK; shutting down domain\n", in __ocs_domain_wait_alloc()
737 …ocs_log_debug(ocs, "%s received while waiting for ocs_hw_domain_alloc() to complete\n", ocs_sm_eve… in __ocs_domain_wait_alloc()
780 ocs_log_debug(ocs, "Requesting hw domain attach fc_id x%x\n", fc_id); in __ocs_domain_allocated()
790 rc = ocs_hw_domain_attach(&ocs->hw, domain, fc_id); in __ocs_domain_allocated()
792 ocs_log_err(ocs, "ocs_hw_domain_attach failed: %d\n", rc); in __ocs_domain_allocated()
807 ocs_log_debug(ocs, "%s received while waiting for OCS_EVT_DOMAIN_REQ_ATTACH\n", in __ocs_domain_allocated()
824 rc = ocs_hw_domain_free(&ocs->hw, domain); in __ocs_domain_allocated()
826 ocs_log_err(ocs, "ocs_hw_domain_free() failed: %d\n", rc); in __ocs_domain_allocated()
875 if (ocs->enable_tgt) in __ocs_domain_wait_attach()
877 if (ocs->enable_ini) in __ocs_domain_wait_attach()
907 …ocs_log_debug(ocs, "%s received while waiting for hw attach to complete\n", ocs_sm_event_name(evt)… in __ocs_domain_wait_attach()
960 ocs_log_debug(domain->ocs, "ocs_vport_start() did not start all vports\n"); in __ocs_domain_ready()
981 rc = ocs_hw_domain_free(&ocs->hw, domain); in __ocs_domain_ready()
983 ocs_log_err(ocs, "ocs_hw_domain_free() failed: %d\n", rc); in __ocs_domain_ready()
1047 rc = ocs_hw_domain_free(&ocs->hw, domain); in __ocs_domain_wait_sports_free()
1049 ocs_log_err(ocs, "ocs_hw_domain_free() failed: %d\n", rc); in __ocs_domain_wait_sports_free()
1084 if (ocs->enable_ini) in __ocs_domain_wait_shutdown()
1086 if (ocs->enable_tgt) in __ocs_domain_wait_shutdown()
1098 ocs_log_debug(ocs, "Reallocating domain\n"); in __ocs_domain_wait_shutdown()
1100 domain = ocs_domain_alloc(ocs, fcf_wwn); in __ocs_domain_wait_shutdown()
1103 ocs_log_err(ocs, "ocs_domain_alloc() failed\n"); in __ocs_domain_wait_shutdown()
1170 rc = ocs_hw_domain_free(&ocs->hw, domain); in __ocs_domain_wait_domain_lost()
1172 ocs_log_err(ocs, "ocs_hw_domain_free() failed: %d\n", rc); in __ocs_domain_wait_domain_lost()
1180 ocs_log_err(ocs, "[domain] %-20s: failed\n", ocs_sm_event_name(evt)); in __ocs_domain_wait_domain_lost()