46#include <sys/kernel.h>
48#include <sys/malloc.h>
51#include <sys/condvar.h>
52#include <sys/endian.h>
54#include <sys/sysctl.h>
79 KASSERT(softc != NULL, (
"CTL is not initialized"));
83 STAILQ_FOREACH(fe_tmp, &softc->fe_list, links) {
84 if (strcmp(fe_tmp->
name, fe->
name) == 0) {
90 STAILQ_INIT(&fe->port_list);
93 if (fe->
init != NULL) {
94 if ((error = fe->
init()) != 0) {
95 printf(
"%s frontend init error: %d\n",
103 STAILQ_INSERT_TAIL(&softc->fe_list, fe, links);
116 if ((error = fe->
shutdown()) != 0) {
117 printf(
"%s frontend shutdown error: %d\n",
124 STAILQ_REMOVE(&softc->fe_list, fe,
ctl_frontend, links);
137 STAILQ_FOREACH(fe, &softc->fe_list, links) {
138 if (strcmp(fe->
name, frontend_name) == 0) {
156 KASSERT(softc != NULL, (
"CTL is not initialized"));
165 if ((port_num < 0) ||
178 M_CTL, M_NOWAIT | M_ZERO);
206 port->
options = nvlist_create(0);
208 mtx_init(&port->
port_lock,
"CTL port", NULL, MTX_DEF);
211 STAILQ_INSERT_TAIL(&port->
frontend->port_list, port, fe_links);
212 for (tport = NULL, nport = STAILQ_FIRST(&softc->port_list);
213 nport != NULL && nport->
targ_port < port_num;
214 tport = nport, nport = STAILQ_NEXT(tport, links)) {
217 STAILQ_INSERT_AFTER(&softc->port_list, tport, port, links);
219 STAILQ_INSERT_HEAD(&softc->port_list, port, links);
237 STAILQ_REMOVE(&softc->port_list, port,
ctl_port, links);
264 int wwpn_valid, uint64_t wwpn)
285 M_CTL, M_WAITOK | M_ZERO);
302 M_CTL, M_WAITOK | M_ZERO);
330 STAILQ_FOREACH(
lun, &softc->lun_list, links)
338 value = dnvlist_get_string(port->
options,
"ha_shared", NULL);
339 if (value != NULL && strcmp(value,
"on") == 0)
342 port->
status &= ~CTL_PORT_STATUS_HA_SHARED;
345 STAILQ_FOREACH(
lun, &softc->lun_list, links) {
348 mtx_lock(&
lun->lun_lock);
350 mtx_unlock(&
lun->lun_lock);
374 STAILQ_FOREACH(
lun, &softc->lun_list, links)
379 port->
status &= ~CTL_PORT_STATUS_ONLINE;
380 STAILQ_FOREACH(
lun, &softc->lun_list, links) {
383 mtx_lock(&
lun->lun_lock);
385 mtx_unlock(&
lun->lun_lock);
uint32_t ctl_lun_map_to_port(struct ctl_port *port, uint32_t lun_id)
int ctl_lun_map_deinit(struct ctl_port *port)
int ctl_ffz(uint32_t *mask, uint32_t first, uint32_t last)
int ctl_set_mask(uint32_t *mask, uint32_t bit)
void ctl_est_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua)
int ctl_clear_mask(uint32_t *mask, uint32_t bit)
void ctl_pool_free(struct ctl_io_pool *pool)
uint32_t ctl_lun_map_from_port(struct ctl_port *port, uint32_t lun_id)
void ctl_isc_announce_port(struct ctl_port *port)
int ctl_pool_create(struct ctl_softc *ctl_softc, const char *pool_name, uint32_t total_ctl_io, void **npool)
int ctl_port_deregister(struct ctl_port *port)
struct ctl_softc * control_softc
void ctl_port_set_wwns(struct ctl_port *port, int wwnn_valid, uint64_t wwnn, int wwpn_valid, uint64_t wwpn)
int ctl_frontend_deregister(struct ctl_frontend *fe)
struct ctl_frontend * ctl_frontend_find(char *frontend_name)
void ctl_port_offline(struct ctl_port *port)
void ctl_port_online(struct ctl_port *port)
int ctl_port_register(struct ctl_port *port)
int ctl_frontend_register(struct ctl_frontend *fe)
@ CTL_PORT_STATUS_HA_SHARED
#define CTL_MAX_INIT_PER_PORT
#define SVPD_ID_ASSOC_TARGET
#define SVPD_ID_CODESET_BINARY
#define SVPD_ID_ASSOC_PORT
static __inline void scsi_u64to8b(u_int64_t val, u_int8_t *bytes)
char name[CTL_DRIVER_NAME_LEN]
struct ctl_frontend * frontend
struct ctl_devid * port_devid
struct ctl_io_stats stats
struct ctl_softc * ctl_softc
struct ctl_devid * init_devid
struct ctl_devid * target_devid
struct ctl_wwpn_iid * wwpn_iid
struct ctl_port ** ctl_ports