Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/ctl/ctl_frontend.c
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/condvar.h> | #include <sys/condvar.h> | ||||
#include <sys/endian.h> | #include <sys/endian.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/nv.h> | |||||
#include <sys/dnv.h> | |||||
#include <cam/scsi/scsi_all.h> | #include <cam/scsi/scsi_all.h> | ||||
#include <cam/scsi/scsi_da.h> | #include <cam/scsi/scsi_da.h> | ||||
#include <cam/ctl/ctl_io.h> | #include <cam/ctl/ctl_io.h> | ||||
#include <cam/ctl/ctl.h> | #include <cam/ctl/ctl.h> | ||||
#include <cam/ctl/ctl_frontend.h> | #include <cam/ctl/ctl_frontend.h> | ||||
#include <cam/ctl/ctl_backend.h> | #include <cam/ctl/ctl_backend.h> | ||||
/* XXX KDM move defines from ctl_ioctl.h to somewhere else */ | /* XXX KDM move defines from ctl_ioctl.h to somewhere else */ | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | error: | ||||
port->targ_port = -1; | port->targ_port = -1; | ||||
mtx_lock(&softc->ctl_lock); | mtx_lock(&softc->ctl_lock); | ||||
ctl_clear_mask(softc->ctl_port_mask, port_num); | ctl_clear_mask(softc->ctl_port_mask, port_num); | ||||
mtx_unlock(&softc->ctl_lock); | mtx_unlock(&softc->ctl_lock); | ||||
return (retval); | return (retval); | ||||
} | } | ||||
port->targ_port = port_num; | port->targ_port = port_num; | ||||
port->ctl_pool_ref = pool; | port->ctl_pool_ref = pool; | ||||
if (port->options.stqh_first == NULL) | if (port->options == NULL) | ||||
STAILQ_INIT(&port->options); | port->options = nvlist_create(0); | ||||
port->stats.item = port_num; | port->stats.item = port_num; | ||||
mtx_init(&port->port_lock, "CTL port", NULL, MTX_DEF); | mtx_init(&port->port_lock, "CTL port", NULL, MTX_DEF); | ||||
mtx_lock(&softc->ctl_lock); | mtx_lock(&softc->ctl_lock); | ||||
STAILQ_INSERT_TAIL(&port->frontend->port_list, port, fe_links); | STAILQ_INSERT_TAIL(&port->frontend->port_list, port, fe_links); | ||||
for (tport = NULL, nport = STAILQ_FIRST(&softc->port_list); | for (tport = NULL, nport = STAILQ_FIRST(&softc->port_list); | ||||
nport != NULL && nport->targ_port < port_num; | nport != NULL && nport->targ_port < port_num; | ||||
tport = nport, nport = STAILQ_NEXT(tport, links)) { | tport = nport, nport = STAILQ_NEXT(tport, links)) { | ||||
Show All 22 Lines | ctl_port_deregister(struct ctl_port *port) | ||||
STAILQ_REMOVE(&softc->port_list, port, ctl_port, links); | STAILQ_REMOVE(&softc->port_list, port, ctl_port, links); | ||||
STAILQ_REMOVE(&port->frontend->port_list, port, ctl_port, fe_links); | STAILQ_REMOVE(&port->frontend->port_list, port, ctl_port, fe_links); | ||||
softc->num_ports--; | softc->num_ports--; | ||||
ctl_clear_mask(softc->ctl_port_mask, port->targ_port); | ctl_clear_mask(softc->ctl_port_mask, port->targ_port); | ||||
softc->ctl_ports[port->targ_port] = NULL; | softc->ctl_ports[port->targ_port] = NULL; | ||||
mtx_unlock(&softc->ctl_lock); | mtx_unlock(&softc->ctl_lock); | ||||
ctl_pool_free(pool); | ctl_pool_free(pool); | ||||
ctl_free_opts(&port->options); | nvlist_destroy(port->options); | ||||
ctl_lun_map_deinit(port); | ctl_lun_map_deinit(port); | ||||
free(port->port_devid, M_CTL); | free(port->port_devid, M_CTL); | ||||
port->port_devid = NULL; | port->port_devid = NULL; | ||||
free(port->target_devid, M_CTL); | free(port->target_devid, M_CTL); | ||||
port->target_devid = NULL; | port->target_devid = NULL; | ||||
free(port->init_devid, M_CTL); | free(port->init_devid, M_CTL); | ||||
port->init_devid = NULL; | port->init_devid = NULL; | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | if (port->lun_map) { | ||||
STAILQ_FOREACH(lun, &softc->lun_list, links) | STAILQ_FOREACH(lun, &softc->lun_list, links) | ||||
port->lun_enable(port->targ_lun_arg, lun->lun); | port->lun_enable(port->targ_lun_arg, lun->lun); | ||||
} | } | ||||
} | } | ||||
if (port->port_online != NULL) | if (port->port_online != NULL) | ||||
port->port_online(port->onoff_arg); | port->port_online(port->onoff_arg); | ||||
mtx_lock(&softc->ctl_lock); | mtx_lock(&softc->ctl_lock); | ||||
if (softc->is_single == 0) { | if (softc->is_single == 0) { | ||||
value = ctl_get_opt(&port->options, "ha_shared"); | value = dnvlist_get_string(port->options, "ha_shared", NULL); | ||||
if (value != NULL && strcmp(value, "on") == 0) | if (value != NULL && strcmp(value, "on") == 0) | ||||
port->status |= CTL_PORT_STATUS_HA_SHARED; | port->status |= CTL_PORT_STATUS_HA_SHARED; | ||||
else | else | ||||
port->status &= ~CTL_PORT_STATUS_HA_SHARED; | port->status &= ~CTL_PORT_STATUS_HA_SHARED; | ||||
} | } | ||||
port->status |= CTL_PORT_STATUS_ONLINE; | port->status |= CTL_PORT_STATUS_ONLINE; | ||||
STAILQ_FOREACH(lun, &softc->lun_list, links) { | STAILQ_FOREACH(lun, &softc->lun_list, links) { | ||||
if (ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX) | if (ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX) | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |