Separate concepts of frontend and port.

Before iSCSI implementation CTL had no knowledge about frontend drivers,
it had only frontends, which really were ports (alike to LUNs, if comparing
to backends).  But iSCSI added there ioctl() method, which does not belong
to frontend as a port, but belongs to a frontend driver.
This commit is contained in:
Alexander Motin 2014-07-04 19:27:06 +00:00
parent 2f5be87a14
commit 92168f4c01
9 changed files with 438 additions and 412 deletions

View File

@ -466,6 +466,11 @@ static moduledata_t ctl_moduledata = {
DECLARE_MODULE(ctl, ctl_moduledata, SI_SUB_CONFIGURE, SI_ORDER_THIRD);
MODULE_VERSION(ctl, 1);
static struct ctl_frontend ioctl_frontend =
{
.name = "ioctl",
};
static void
ctl_isc_handler_finish_xfer(struct ctl_softc *ctl_softc,
union ctl_ha_msg *msg_info)
@ -926,7 +931,7 @@ ctl_init(void)
{
struct ctl_softc *softc;
struct ctl_io_pool *internal_pool, *emergency_pool, *other_pool;
struct ctl_frontend *fe;
struct ctl_port *port;
uint8_t sc_id =0;
int i, error, retval;
//int isc_retval;
@ -1006,6 +1011,7 @@ ctl_init(void)
STAILQ_INIT(&softc->lun_list);
STAILQ_INIT(&softc->pending_lun_queue);
STAILQ_INIT(&softc->fe_list);
STAILQ_INIT(&softc->port_list);
STAILQ_INIT(&softc->be_list);
STAILQ_INIT(&softc->io_pools);
@ -1083,23 +1089,25 @@ ctl_init(void)
/*
* Initialize the ioctl front end.
*/
fe = &softc->ioctl_info.fe;
sprintf(softc->ioctl_info.port_name, "CTL ioctl");
fe->port_type = CTL_PORT_IOCTL;
fe->num_requested_ctl_io = 100;
fe->port_name = softc->ioctl_info.port_name;
fe->port_online = ctl_ioctl_online;
fe->port_offline = ctl_ioctl_offline;
fe->onoff_arg = &softc->ioctl_info;
fe->lun_enable = ctl_ioctl_lun_enable;
fe->lun_disable = ctl_ioctl_lun_disable;
fe->targ_lun_arg = &softc->ioctl_info;
fe->fe_datamove = ctl_ioctl_datamove;
fe->fe_done = ctl_ioctl_done;
fe->max_targets = 15;
fe->max_target_id = 15;
ctl_frontend_register(&ioctl_frontend);
port = &softc->ioctl_info.port;
port->frontend = &ioctl_frontend;
sprintf(softc->ioctl_info.port_name, "ioctl");
port->port_type = CTL_PORT_IOCTL;
port->num_requested_ctl_io = 100;
port->port_name = softc->ioctl_info.port_name;
port->port_online = ctl_ioctl_online;
port->port_offline = ctl_ioctl_offline;
port->onoff_arg = &softc->ioctl_info;
port->lun_enable = ctl_ioctl_lun_enable;
port->lun_disable = ctl_ioctl_lun_disable;
port->targ_lun_arg = &softc->ioctl_info;
port->fe_datamove = ctl_ioctl_datamove;
port->fe_done = ctl_ioctl_done;
port->max_targets = 15;
port->max_target_id = 15;
if (ctl_frontend_register(&softc->ioctl_info.fe,
if (ctl_port_register(&softc->ioctl_info.port,
(softc->flags & CTL_FLAG_MASTER_SHELF)) != 0) {
printf("ctl: ioctl front end registration failed, will "
"continue anyway\n");
@ -1125,7 +1133,7 @@ ctl_shutdown(void)
softc = (struct ctl_softc *)control_softc;
if (ctl_frontend_deregister(&softc->ioctl_info.fe) != 0)
if (ctl_port_deregister(&softc->ioctl_info.port) != 0)
printf("ctl: ioctl front end deregistration failed\n");
mtx_lock(&softc->ctl_lock);
@ -1140,6 +1148,8 @@ ctl_shutdown(void)
mtx_unlock(&softc->ctl_lock);
ctl_frontend_deregister(&ioctl_frontend);
/*
* This will rip the rug out from under any FETDs or anyone else
* that has a pool allocated. Since we increment our module
@ -1204,7 +1214,7 @@ int
ctl_port_enable(ctl_port_type port_type)
{
struct ctl_softc *softc;
struct ctl_frontend *fe;
struct ctl_port *port;
if (ctl_is_single == 0) {
union ctl_ha_msg msg_info;
@ -1233,13 +1243,13 @@ ctl_port_enable(ctl_port_type port_type)
softc = control_softc;
STAILQ_FOREACH(fe, &softc->fe_list, links) {
if (port_type & fe->port_type)
STAILQ_FOREACH(port, &softc->port_list, links) {
if (port_type & port->port_type)
{
#if 0
printf("port %d\n", fe->targ_port);
printf("port %d\n", port->targ_port);
#endif
ctl_frontend_online(fe);
ctl_port_online(port);
}
}
@ -1250,13 +1260,13 @@ int
ctl_port_disable(ctl_port_type port_type)
{
struct ctl_softc *softc;
struct ctl_frontend *fe;
struct ctl_port *port;
softc = control_softc;
STAILQ_FOREACH(fe, &softc->fe_list, links) {
if (port_type & fe->port_type)
ctl_frontend_offline(fe);
STAILQ_FOREACH(port, &softc->port_list, links) {
if (port_type & port->port_type)
ctl_port_offline(port);
}
return (0);
@ -1274,7 +1284,7 @@ ctl_port_list(struct ctl_port_entry *entries, int num_entries_alloced,
ctl_port_type port_type, int no_virtual)
{
struct ctl_softc *softc;
struct ctl_frontend *fe;
struct ctl_port *port;
int entries_dropped, entries_filled;
int retval;
int i;
@ -1287,14 +1297,14 @@ ctl_port_list(struct ctl_port_entry *entries, int num_entries_alloced,
i = 0;
mtx_lock(&softc->ctl_lock);
STAILQ_FOREACH(fe, &softc->fe_list, links) {
STAILQ_FOREACH(port, &softc->port_list, links) {
struct ctl_port_entry *entry;
if ((fe->port_type & port_type) == 0)
if ((port->port_type & port_type) == 0)
continue;
if ((no_virtual != 0)
&& (fe->virtual_port != 0))
&& (port->virtual_port != 0))
continue;
if (entries_filled >= num_entries_alloced) {
@ -1303,13 +1313,13 @@ ctl_port_list(struct ctl_port_entry *entries, int num_entries_alloced,
}
entry = &entries[i];
entry->port_type = fe->port_type;
strlcpy(entry->port_name, fe->port_name,
entry->port_type = port->port_type;
strlcpy(entry->port_name, port->port_name,
sizeof(entry->port_name));
entry->physical_port = fe->physical_port;
entry->virtual_port = fe->virtual_port;
entry->wwnn = fe->wwnn;
entry->wwpn = fe->wwpn;
entry->physical_port = port->physical_port;
entry->virtual_port = port->virtual_port;
entry->wwnn = port->wwnn;
entry->wwpn = port->wwpn;
i++;
entries_filled++;
@ -2134,7 +2144,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
break;
}
io = ctl_alloc_io(softc->ioctl_info.fe.ctl_pool_ref);
io = ctl_alloc_io(softc->ioctl_info.port.ctl_pool_ref);
if (io == NULL) {
printf("ctl_ioctl: can't allocate ctl_io!\n");
retval = ENOSPC;
@ -2158,7 +2168,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
/*
* The user sets the initiator ID, target and LUN IDs.
*/
io->io_hdr.nexus.targ_port = softc->ioctl_info.fe.targ_port;
io->io_hdr.nexus.targ_port = softc->ioctl_info.port.targ_port;
io->io_hdr.flags |= CTL_FLAG_USER_REQ;
if ((io->io_hdr.io_type == CTL_IO_SCSI)
&& (io->scsiio.tag_type != CTL_TAG_UNTAGGED))
@ -2181,20 +2191,20 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
case CTL_ENABLE_PORT:
case CTL_DISABLE_PORT:
case CTL_SET_PORT_WWNS: {
struct ctl_frontend *fe;
struct ctl_port *port;
struct ctl_port_entry *entry;
entry = (struct ctl_port_entry *)addr;
mtx_lock(&softc->ctl_lock);
STAILQ_FOREACH(fe, &softc->fe_list, links) {
STAILQ_FOREACH(port, &softc->port_list, links) {
int action, done;
action = 0;
done = 0;
if ((entry->port_type == CTL_PORT_NONE)
&& (entry->targ_port == fe->targ_port)) {
&& (entry->targ_port == port->targ_port)) {
/*
* If the user only wants to enable or
* disable or set WWNs on a specific port,
@ -2202,7 +2212,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
*/
action = 1;
done = 1;
} else if (entry->port_type & fe->port_type) {
} else if (entry->port_type & port->port_type) {
/*
* Compare the user's type mask with the
* particular frontend type to see if we
@ -2237,21 +2247,21 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
STAILQ_FOREACH(lun, &softc->lun_list,
links) {
fe->lun_enable(fe->targ_lun_arg,
port->lun_enable(port->targ_lun_arg,
lun->target,
lun->lun);
}
ctl_frontend_online(fe);
ctl_port_online(port);
} else if (cmd == CTL_DISABLE_PORT) {
struct ctl_lun *lun;
ctl_frontend_offline(fe);
ctl_port_offline(port);
STAILQ_FOREACH(lun, &softc->lun_list,
links) {
fe->lun_disable(
fe->targ_lun_arg,
port->lun_disable(
port->targ_lun_arg,
lun->target,
lun->lun);
}
@ -2260,7 +2270,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
mtx_lock(&softc->ctl_lock);
if (cmd == CTL_SET_PORT_WWNS)
ctl_frontend_set_wwns(fe,
ctl_port_set_wwns(port,
(entry->flags & CTL_PORT_WWNN_VALID) ?
1 : 0, entry->wwnn,
(entry->flags & CTL_PORT_WWPN_VALID) ?
@ -2273,7 +2283,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
break;
}
case CTL_GET_PORT_LIST: {
struct ctl_frontend *fe;
struct ctl_port *port;
struct ctl_port_list *list;
int i;
@ -2293,7 +2303,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
list->dropped_num = 0;
i = 0;
mtx_lock(&softc->ctl_lock);
STAILQ_FOREACH(fe, &softc->fe_list, links) {
STAILQ_FOREACH(port, &softc->port_list, links) {
struct ctl_port_entry entry, *list_entry;
if (list->fill_num >= list->alloc_num) {
@ -2301,15 +2311,15 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
continue;
}
entry.port_type = fe->port_type;
strlcpy(entry.port_name, fe->port_name,
entry.port_type = port->port_type;
strlcpy(entry.port_name, port->port_name,
sizeof(entry.port_name));
entry.targ_port = fe->targ_port;
entry.physical_port = fe->physical_port;
entry.virtual_port = fe->virtual_port;
entry.wwnn = fe->wwnn;
entry.wwpn = fe->wwpn;
if (fe->status & CTL_PORT_STATUS_ONLINE)
entry.targ_port = port->targ_port;
entry.physical_port = port->physical_port;
entry.virtual_port = port->virtual_port;
entry.wwnn = port->wwnn;
entry.wwpn = port->wwpn;
if (port->status & CTL_PORT_STATUS_ONLINE)
entry.online = 1;
else
entry.online = 0;
@ -2844,6 +2854,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
}
case CTL_DUMP_STRUCTS: {
int i, j, k;
struct ctl_port *port;
struct ctl_frontend *fe;
printf("CTL IID to WWPN map start:\n");
@ -2881,26 +2892,25 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
}
}
printf("CTL Persistent Reservation information end\n");
printf("CTL Frontends:\n");
printf("CTL Ports:\n");
/*
* XXX KDM calling this without a lock. We'd likely want
* to drop the lock before calling the frontend's dump
* routine anyway.
*/
STAILQ_FOREACH(port, &softc->port_list, links) {
printf("Port %s Frontend %s Type %u pport %d vport %d WWNN "
"%#jx WWPN %#jx\n", port->port_name,
port->frontend->name, port->port_type,
port->physical_port, port->virtual_port,
(uintmax_t)port->wwnn, (uintmax_t)port->wwpn);
}
printf("CTL Port information end\n");
printf("CTL Frontends:\n");
STAILQ_FOREACH(fe, &softc->fe_list, links) {
printf("Frontend %s Type %u pport %d vport %d WWNN "
"%#jx WWPN %#jx\n", fe->port_name, fe->port_type,
fe->physical_port, fe->virtual_port,
(uintmax_t)fe->wwnn, (uintmax_t)fe->wwpn);
/*
* Frontends are not required to support the dump
* routine.
*/
if (fe->fe_dump == NULL)
continue;
fe->fe_dump();
printf("Frontend %s\n", fe->name);
if (fe->fe_dump != NULL)
fe->fe_dump();
}
printf("CTL Frontend information end\n");
break;
@ -3112,14 +3122,15 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
mtx_lock(&softc->ctl_lock);
STAILQ_FOREACH(fe, &softc->fe_list, links) {
if (strcmp(fe->port_name, "iscsi") == 0)
if (strcmp(fe->name, "iscsi") == 0)
break;
}
mtx_unlock(&softc->ctl_lock);
if (fe == NULL) {
ci->status = CTL_ISCSI_ERROR;
snprintf(ci->error_str, sizeof(ci->error_str), "Backend \"iscsi\" not found.");
snprintf(ci->error_str, sizeof(ci->error_str),
"Frontend \"iscsi\" not found.");
break;
}
@ -3378,7 +3389,6 @@ ctl_pool_create(struct ctl_softc *ctl_softc, ctl_pool_type pool_type,
#if 0
if ((pool_type != CTL_POOL_EMERGENCY)
&& (pool_type != CTL_POOL_INTERNAL)
&& (pool_type != CTL_POOL_IOCTL)
&& (pool_type != CTL_POOL_4OTHERSC))
MOD_INC_USE_COUNT;
#endif
@ -3432,7 +3442,7 @@ ctl_pool_release(struct ctl_io_pool *pool)
#if 0
if ((pool->type != CTL_POOL_EMERGENCY)
&& (pool->type != CTL_POOL_INTERNAL)
&& (pool->type != CTL_POOL_IOCTL))
&& (pool->type != CTL_POOL_4OTHERSC))
MOD_DEC_USE_COUNT;
#endif
@ -4138,7 +4148,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun,
struct ctl_be_lun *const be_lun, struct ctl_id target_id)
{
struct ctl_lun *nlun, *lun;
struct ctl_frontend *fe;
struct ctl_port *port;
int lun_number, i, lun_malloced;
if (be_lun == NULL)
@ -4287,17 +4297,17 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun,
* already. Enable the target ID if it hasn't been enabled, and
* enable this particular LUN.
*/
STAILQ_FOREACH(fe, &ctl_softc->fe_list, links) {
STAILQ_FOREACH(port, &ctl_softc->port_list, links) {
int retval;
retval = fe->lun_enable(fe->targ_lun_arg, target_id,lun_number);
retval = port->lun_enable(port->targ_lun_arg, target_id,lun_number);
if (retval != 0) {
printf("ctl_alloc_lun: FETD %s port %d returned error "
"%d for lun_enable on target %ju lun %d\n",
fe->port_name, fe->targ_port, retval,
port->port_name, port->targ_port, retval,
(uintmax_t)target_id.id, lun_number);
} else
fe->status |= CTL_PORT_STATUS_LUN_ONLINE;
port->status |= CTL_PORT_STATUS_LUN_ONLINE;
}
return (0);
}
@ -4313,7 +4323,7 @@ ctl_free_lun(struct ctl_lun *lun)
{
struct ctl_softc *softc;
#if 0
struct ctl_frontend *fe;
struct ctl_port *port;
#endif
struct ctl_lun *nlun;
int i;
@ -4337,7 +4347,7 @@ ctl_free_lun(struct ctl_lun *lun)
* XXX KDM this scheme only works for a single target/multiple LUN
* setup. It needs to be revamped for a multiple target scheme.
*
* XXX KDM this results in fe->lun_disable() getting called twice,
* XXX KDM this results in port->lun_disable() getting called twice,
* once when ctl_disable_lun() is called, and a second time here.
* We really need to re-think the LUN disable semantics. There
* should probably be several steps/levels to LUN removal:
@ -4349,37 +4359,37 @@ ctl_free_lun(struct ctl_lun *lun)
* the front end ports, at least for individual LUNs.
*/
#if 0
STAILQ_FOREACH(fe, &softc->fe_list, links) {
STAILQ_FOREACH(port, &softc->port_list, links) {
int retval;
retval = fe->lun_disable(fe->targ_lun_arg, lun->target,
retval = port->lun_disable(port->targ_lun_arg, lun->target,
lun->lun);
if (retval != 0) {
printf("ctl_free_lun: FETD %s port %d returned error "
"%d for lun_disable on target %ju lun %jd\n",
fe->port_name, fe->targ_port, retval,
port->port_name, port->targ_port, retval,
(uintmax_t)lun->target.id, (intmax_t)lun->lun);
}
if (STAILQ_FIRST(&softc->lun_list) == NULL) {
fe->status &= ~CTL_PORT_STATUS_LUN_ONLINE;
port->status &= ~CTL_PORT_STATUS_LUN_ONLINE;
retval = fe->targ_disable(fe->targ_lun_arg,lun->target);
retval = port->targ_disable(port->targ_lun_arg,lun->target);
if (retval != 0) {
printf("ctl_free_lun: FETD %s port %d "
"returned error %d for targ_disable on "
"target %ju\n", fe->port_name,
fe->targ_port, retval,
"target %ju\n", port->port_name,
port->targ_port, retval,
(uintmax_t)lun->target.id);
} else
fe->status &= ~CTL_PORT_STATUS_TARG_ONLINE;
port->status &= ~CTL_PORT_STATUS_TARG_ONLINE;
if ((fe->status & CTL_PORT_STATUS_TARG_ONLINE) != 0)
if ((port->status & CTL_PORT_STATUS_TARG_ONLINE) != 0)
continue;
#if 0
fe->port_offline(fe->onoff_arg);
fe->status &= ~CTL_PORT_STATUS_ONLINE;
port->port_offline(port->onoff_arg);
port->status &= ~CTL_PORT_STATUS_ONLINE;
#endif
}
}
@ -4434,7 +4444,7 @@ int
ctl_enable_lun(struct ctl_be_lun *be_lun)
{
struct ctl_softc *ctl_softc;
struct ctl_frontend *fe, *nfe;
struct ctl_port *port, *nport;
struct ctl_lun *lun;
int retval;
@ -4456,8 +4466,8 @@ ctl_enable_lun(struct ctl_be_lun *be_lun)
lun->flags &= ~CTL_LUN_DISABLED;
mtx_unlock(&lun->lun_lock);
for (fe = STAILQ_FIRST(&ctl_softc->fe_list); fe != NULL; fe = nfe) {
nfe = STAILQ_NEXT(fe, links);
for (port = STAILQ_FIRST(&ctl_softc->port_list); port != NULL; port = nport) {
nport = STAILQ_NEXT(port, links);
/*
* Drop the lock while we call the FETD's enable routine.
@ -4465,18 +4475,18 @@ ctl_enable_lun(struct ctl_be_lun *be_lun)
* case of the internal initiator frontend.
*/
mtx_unlock(&ctl_softc->ctl_lock);
retval = fe->lun_enable(fe->targ_lun_arg, lun->target,lun->lun);
retval = port->lun_enable(port->targ_lun_arg, lun->target,lun->lun);
mtx_lock(&ctl_softc->ctl_lock);
if (retval != 0) {
printf("%s: FETD %s port %d returned error "
"%d for lun_enable on target %ju lun %jd\n",
__func__, fe->port_name, fe->targ_port, retval,
__func__, port->port_name, port->targ_port, retval,
(uintmax_t)lun->target.id, (intmax_t)lun->lun);
}
#if 0
else {
/* NOTE: TODO: why does lun enable affect port status? */
fe->status |= CTL_PORT_STATUS_LUN_ONLINE;
port->status |= CTL_PORT_STATUS_LUN_ONLINE;
}
#endif
}
@ -4490,7 +4500,7 @@ int
ctl_disable_lun(struct ctl_be_lun *be_lun)
{
struct ctl_softc *ctl_softc;
struct ctl_frontend *fe;
struct ctl_port *port;
struct ctl_lun *lun;
int retval;
@ -4508,7 +4518,7 @@ ctl_disable_lun(struct ctl_be_lun *be_lun)
lun->flags |= CTL_LUN_DISABLED;
mtx_unlock(&lun->lun_lock);
STAILQ_FOREACH(fe, &ctl_softc->fe_list, links) {
STAILQ_FOREACH(port, &ctl_softc->port_list, links) {
mtx_unlock(&ctl_softc->ctl_lock);
/*
* Drop the lock before we call the frontend's disable
@ -4517,13 +4527,13 @@ ctl_disable_lun(struct ctl_be_lun *be_lun)
* XXX KDM what happens if the frontend list changes while
* we're traversing it? It's unlikely, but should be handled.
*/
retval = fe->lun_disable(fe->targ_lun_arg, lun->target,
retval = port->lun_disable(port->targ_lun_arg, lun->target,
lun->lun);
mtx_lock(&ctl_softc->ctl_lock);
if (retval != 0) {
printf("ctl_alloc_lun: FETD %s port %d returned error "
"%d for lun_disable on target %ju lun %jd\n",
fe->port_name, fe->targ_port, retval,
port->port_name, port->targ_port, retval,
(uintmax_t)lun->target.id, (intmax_t)lun->lun);
}
}
@ -9475,16 +9485,16 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len)
struct scsi_vpd_id_t10 *t10id;
struct ctl_softc *ctl_softc;
struct ctl_lun *lun;
struct ctl_frontend *fe;
struct ctl_port *port;
char *val;
int data_len, devid_len;
ctl_softc = control_softc;
fe = ctl_softc->ctl_ports[ctl_port_idx(ctsio->io_hdr.nexus.targ_port)];
port = ctl_softc->ctl_ports[ctl_port_idx(ctsio->io_hdr.nexus.targ_port)];
if (fe->devid != NULL)
return ((fe->devid)(ctsio, alloc_len));
if (port->devid != NULL)
return ((port->devid)(ctsio, alloc_len));
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
@ -9547,7 +9557,7 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len)
/*
* For Fibre channel,
*/
if (fe->port_type == CTL_PORT_FC)
if (port->port_type == CTL_PORT_FC)
{
desc->proto_codeset = (SCSI_PROTO_FC << 4) |
SVPD_ID_CODESET_ASCII;
@ -9596,7 +9606,7 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len)
desc1->identifier[7] += ctsio->io_hdr.nexus.targ_port;
#endif
be64enc(desc1->identifier, fe->wwpn);
be64enc(desc1->identifier, port->wwpn);
/*
* desc2 is for the Relative Target Port(type 4h) identifier

View File

@ -66,7 +66,60 @@ __FBSDID("$FreeBSD$");
extern struct ctl_softc *control_softc;
int
ctl_frontend_register(struct ctl_frontend *fe, int master_shelf)
ctl_frontend_register(struct ctl_frontend *fe)
{
struct ctl_frontend *fe_tmp;
KASSERT(control_softc != NULL, ("CTL is not initialized"));
/*
* Sanity check, make sure this isn't a duplicate registration.
*/
mtx_lock(&control_softc->ctl_lock);
STAILQ_FOREACH(fe_tmp, &control_softc->fe_list, links) {
if (strcmp(fe_tmp->name, fe->name) == 0) {
mtx_unlock(&control_softc->ctl_lock);
return (-1);
}
}
mtx_unlock(&control_softc->ctl_lock);
STAILQ_INIT(&fe->port_list);
/*
* Call the frontend's initialization routine.
*/
if (fe->init != NULL)
fe->init();
mtx_lock(&control_softc->ctl_lock);
control_softc->num_frontends++;
STAILQ_INSERT_TAIL(&control_softc->fe_list, fe, links);
mtx_unlock(&control_softc->ctl_lock);
return (0);
}
int
ctl_frontend_deregister(struct ctl_frontend *fe)
{
if (!STAILQ_EMPTY(&fe->port_list))
return (-1);
mtx_lock(&control_softc->ctl_lock);
STAILQ_REMOVE(&control_softc->fe_list, fe, ctl_frontend, links);
control_softc->num_frontends--;
mtx_unlock(&control_softc->ctl_lock);
/*
* Call the frontend's shutdown routine.
*/
if (fe->shutdown != NULL)
fe->shutdown();
return (0);
}
int
ctl_port_register(struct ctl_port *port, int master_shelf)
{
struct ctl_io_pool *pool;
int port_num;
@ -80,13 +133,13 @@ ctl_frontend_register(struct ctl_frontend *fe, int master_shelf)
port_num = ctl_ffz(&control_softc->ctl_port_mask, CTL_MAX_PORTS);
if ((port_num == -1)
|| (ctl_set_mask(&control_softc->ctl_port_mask, port_num) == -1)) {
fe->targ_port = -1;
port->targ_port = -1;
mtx_unlock(&control_softc->ctl_lock);
return (1);
}
control_softc->num_frontends++;
control_softc->num_ports++;
mtx_unlock(&control_softc->ctl_lock);
/*
* We add 20 to whatever the caller requests, so he doesn't get
* burned by queueing things back to the pending sense queue. In
@ -95,36 +148,30 @@ ctl_frontend_register(struct ctl_frontend *fe, int master_shelf)
* pending sense queue on the next command, whether or not it is
* a REQUEST SENSE.
*/
retval = ctl_pool_create(control_softc,
(fe->port_type != CTL_PORT_IOCTL) ?
CTL_POOL_FETD : CTL_POOL_IOCTL,
fe->num_requested_ctl_io + 20, &pool);
retval = ctl_pool_create(control_softc, CTL_POOL_FETD,
port->num_requested_ctl_io + 20, &pool);
if (retval != 0) {
fe->targ_port = -1;
port->targ_port = -1;
mtx_lock(&control_softc->ctl_lock);
ctl_clear_mask(&control_softc->ctl_port_mask, port_num);
mtx_unlock(&control_softc->ctl_lock);
return (retval);
}
port->ctl_pool_ref = pool;
mtx_lock(&control_softc->ctl_lock);
/* For now assume master shelf */
//fe->targ_port = port_num;
fe->targ_port = port_num + (master_shelf!=0 ? 0 : CTL_MAX_PORTS);
fe->max_initiators = CTL_MAX_INIT_PER_PORT;
STAILQ_INSERT_TAIL(&control_softc->fe_list, fe, links);
control_softc->ctl_ports[port_num] = fe;
port->targ_port = port_num + (master_shelf != 0 ? 0 : CTL_MAX_PORTS);
port->max_initiators = CTL_MAX_INIT_PER_PORT;
STAILQ_INSERT_TAIL(&port->frontend->port_list, port, links);
STAILQ_INSERT_TAIL(&control_softc->port_list, port, links);
control_softc->ctl_ports[port_num] = port;
mtx_unlock(&control_softc->ctl_lock);
fe->ctl_pool_ref = pool;
return (retval);
}
int
ctl_frontend_deregister(struct ctl_frontend *fe)
ctl_port_deregister(struct ctl_port *port)
{
struct ctl_io_pool *pool;
int port_num;
@ -132,18 +179,19 @@ ctl_frontend_deregister(struct ctl_frontend *fe)
retval = 0;
pool = (struct ctl_io_pool *)fe->ctl_pool_ref;
pool = (struct ctl_io_pool *)port->ctl_pool_ref;
if (fe->targ_port == -1) {
if (port->targ_port == -1) {
retval = 1;
goto bailout;
}
mtx_lock(&control_softc->ctl_lock);
STAILQ_REMOVE(&control_softc->fe_list, fe, ctl_frontend, links);
control_softc->num_frontends--;
port_num = (fe->targ_port < CTL_MAX_PORTS) ? fe->targ_port :
fe->targ_port - CTL_MAX_PORTS;
STAILQ_REMOVE(&control_softc->port_list, port, ctl_port, links);
STAILQ_REMOVE(&port->frontend->port_list, port, ctl_port, fe_links);
control_softc->num_ports--;
port_num = (port->targ_port < CTL_MAX_PORTS) ? port->targ_port :
port->targ_port - CTL_MAX_PORTS;
ctl_clear_mask(&control_softc->ctl_port_mask, port_num);
control_softc->ctl_ports[port_num] = NULL;
mtx_unlock(&control_softc->ctl_lock);
@ -155,30 +203,30 @@ ctl_frontend_deregister(struct ctl_frontend *fe)
}
void
ctl_frontend_set_wwns(struct ctl_frontend *fe, int wwnn_valid, uint64_t wwnn,
ctl_port_set_wwns(struct ctl_port *port, int wwnn_valid, uint64_t wwnn,
int wwpn_valid, uint64_t wwpn)
{
if (wwnn_valid)
fe->wwnn = wwnn;
port->wwnn = wwnn;
if (wwpn_valid)
fe->wwpn = wwpn;
port->wwpn = wwpn;
}
void
ctl_frontend_online(struct ctl_frontend *fe)
ctl_port_online(struct ctl_port *port)
{
fe->port_online(fe->onoff_arg);
port->port_online(port->onoff_arg);
/* XXX KDM need a lock here? */
fe->status |= CTL_PORT_STATUS_ONLINE;
port->status |= CTL_PORT_STATUS_ONLINE;
}
void
ctl_frontend_offline(struct ctl_frontend *fe)
ctl_port_offline(struct ctl_port *port)
{
fe->port_offline(fe->onoff_arg);
port->port_offline(port->onoff_arg);
/* XXX KDM need a lock here? */
fe->status &= ~CTL_PORT_STATUS_ONLINE;
port->status &= ~CTL_PORT_STATUS_ONLINE;
}
/*

View File

@ -39,6 +39,8 @@
#ifndef _CTL_FRONTEND_H_
#define _CTL_FRONTEND_H_
#define CTL_FE_NAME_LEN 32
typedef enum {
CTL_PORT_STATUS_NONE = 0x00,
CTL_PORT_STATUS_ONLINE = 0x01,
@ -46,6 +48,8 @@ typedef enum {
CTL_PORT_STATUS_LUN_ONLINE = 0x04
} ctl_port_status;
typedef int (*fe_init_t)(void);
typedef void (*fe_shutdown_t)(void);
typedef void (*port_func_t)(void *onoff_arg);
typedef int (*targ_func_t)(void *arg, struct ctl_id targ_id);
typedef int (*lun_func_t)(void *arg, struct ctl_id targ_id, int lun_id);
@ -53,6 +57,31 @@ typedef int (*fe_ioctl_t)(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
struct thread *td);
typedef int (*fe_devid_t)(struct ctl_scsiio *ctsio, int alloc_len);
#define CTL_FRONTEND_DECLARE(name, driver) \
static int name ## _modevent(module_t mod, int type, void *data) \
{ \
switch (type) { \
case MOD_LOAD: \
ctl_frontend_register( \
(struct ctl_frontend *)data); \
break; \
case MOD_UNLOAD: \
printf(#name " module unload - not possible for this module type\n"); \
return EINVAL; \
default: \
return EOPNOTSUPP; \
} \
return 0; \
} \
static moduledata_t name ## _mod = { \
#name, \
name ## _modevent, \
(void *)&driver \
}; \
DECLARE_MODULE(name, name ## _mod, SI_SUB_CONFIGURE, SI_ORDER_FOURTH); \
MODULE_DEPEND(name, ctl, 1, 1, 1); \
MODULE_DEPEND(name, cam, 1, 1, 1)
/*
* The ctl_frontend structure is the registration mechanism between a FETD
* (Front End Target Driver) and the CTL layer. Here is a description of
@ -179,7 +208,8 @@ typedef int (*fe_devid_t)(struct ctl_scsiio *ctsio, int alloc_len);
* links: Linked list pointers, used by CTL. The FETD
* shouldn't touch this field.
*/
struct ctl_frontend {
struct ctl_port {
struct ctl_frontend *frontend;
ctl_port_type port_type; /* passed to CTL */
int num_requested_ctl_io; /* passed to CTL */
char *port_name; /* passed to CTL */
@ -190,12 +220,10 @@ struct ctl_frontend {
void *onoff_arg; /* passed to CTL */
lun_func_t lun_enable; /* passed to CTL */
lun_func_t lun_disable; /* passed to CTL */
fe_ioctl_t ioctl; /* passed to CTL */
fe_devid_t devid; /* passed to CTL */
void *targ_lun_arg; /* passed to CTL */
void (*fe_datamove)(union ctl_io *io); /* passed to CTL */
void (*fe_done)(union ctl_io *io); /* passed to CTL */
void (*fe_dump)(void); /* passed to CTL */
int max_targets; /* passed to CTL */
int max_target_id; /* passed to CTL */
int32_t targ_port; /* passed back to FETD */
@ -204,6 +232,17 @@ struct ctl_frontend {
uint64_t wwnn; /* set by CTL before online */
uint64_t wwpn; /* set by CTL before online */
ctl_port_status status; /* used by CTL */
STAILQ_ENTRY(ctl_port) fe_links; /* used by CTL */
STAILQ_ENTRY(ctl_port) links; /* used by CTL */
};
struct ctl_frontend {
char name[CTL_FE_NAME_LEN]; /* passed to CTL */
fe_init_t init; /* passed to CTL */
fe_ioctl_t ioctl; /* passed to CTL */
void (*fe_dump)(void); /* passed to CTL */
fe_shutdown_t shutdown; /* passed to CTL */
STAILQ_HEAD(, ctl_port) port_list; /* used by CTL */
STAILQ_ENTRY(ctl_frontend) links; /* used by CTL */
};
@ -211,7 +250,7 @@ struct ctl_frontend {
* This may block until resources are allocated. Called at FETD module load
* time. Returns 0 for success, non-zero for failure.
*/
int ctl_frontend_register(struct ctl_frontend *fe, int master_SC);
int ctl_frontend_register(struct ctl_frontend *fe);
/*
* Called at FETD module unload time.
@ -219,21 +258,33 @@ int ctl_frontend_register(struct ctl_frontend *fe, int master_SC);
*/
int ctl_frontend_deregister(struct ctl_frontend *fe);
/*
* This may block until resources are allocated. Called at FETD module load
* time. Returns 0 for success, non-zero for failure.
*/
int ctl_port_register(struct ctl_port *fe, int master_SC);
/*
* Called at FETD module unload time.
* Returns 0 for success, non-zero for failure.
*/
int ctl_port_deregister(struct ctl_port *fe);
/*
* Called to set the WWNN and WWPN for a particular frontend.
*/
void ctl_frontend_set_wwns(struct ctl_frontend *fe, int wwnn_valid,
void ctl_port_set_wwns(struct ctl_port *port, int wwnn_valid,
uint64_t wwnn, int wwpn_valid, uint64_t wwpn);
/*
* Called to bring a particular frontend online.
*/
void ctl_frontend_online(struct ctl_frontend *fe);
void ctl_port_online(struct ctl_port *fe);
/*
* Called to take a particular frontend offline.
*/
void ctl_frontend_offline(struct ctl_frontend *fe);
void ctl_port_offline(struct ctl_port *fe);
/*
* This routine queues I/O and task management requests from the FETD to the

View File

@ -74,13 +74,12 @@ struct cfcs_io {
};
struct cfcs_softc {
struct ctl_frontend fe;
struct ctl_port port;
char port_name[32];
struct cam_sim *sim;
struct cam_devq *devq;
struct cam_path *path;
struct mtx lock;
char lock_desc[32];
uint64_t wwnn;
uint64_t wwpn;
uint32_t cur_tag_num;
@ -97,7 +96,6 @@ struct cfcs_softc {
CAM_SENSE_PHYS)
int cfcs_init(void);
void cfcs_shutdown(void);
static void cfcs_poll(struct cam_sim *sim);
static void cfcs_online(void *arg);
static void cfcs_offline(void *arg);
@ -122,25 +120,19 @@ SYSCTL_NODE(_kern_cam, OID_AUTO, ctl2cam, CTLFLAG_RD, 0,
SYSCTL_INT(_kern_cam_ctl2cam, OID_AUTO, max_sense, CTLFLAG_RW,
&cfcs_max_sense, 0, "Maximum sense data size");
static int cfcs_module_event_handler(module_t, int /*modeventtype_t*/, void *);
static moduledata_t cfcs_moduledata = {
"ctlcfcs",
cfcs_module_event_handler,
NULL
static struct ctl_frontend cfcs_frontend =
{
.name = "camsim",
.init = cfcs_init,
};
DECLARE_MODULE(ctlcfcs, cfcs_moduledata, SI_SUB_CONFIGURE, SI_ORDER_FOURTH);
MODULE_VERSION(ctlcfcs, 1);
MODULE_DEPEND(ctlcfi, ctl, 1, 1, 1);
MODULE_DEPEND(ctlcfi, cam, 1, 1, 1);
CTL_FRONTEND_DECLARE(ctlcfcs, cfcs_frontend);
int
cfcs_init(void)
{
struct cfcs_softc *softc;
struct ccb_setasync csa;
struct ctl_frontend *fe;
struct ctl_port *port;
#ifdef NEEDTOPORT
char wwnn[8];
#endif
@ -149,32 +141,32 @@ cfcs_init(void)
softc = &cfcs_softc;
retval = 0;
bzero(softc, sizeof(*softc));
sprintf(softc->lock_desc, "ctl2cam");
mtx_init(&softc->lock, softc->lock_desc, NULL, MTX_DEF);
fe = &softc->fe;
mtx_init(&softc->lock, "ctl2cam", NULL, MTX_DEF);
port = &softc->port;
fe->port_type = CTL_PORT_INTERNAL;
port->frontend = &cfcs_frontend;
port->port_type = CTL_PORT_INTERNAL;
/* XXX KDM what should the real number be here? */
fe->num_requested_ctl_io = 4096;
snprintf(softc->port_name, sizeof(softc->port_name), "ctl2cam");
fe->port_name = softc->port_name;
fe->port_online = cfcs_online;
fe->port_offline = cfcs_offline;
fe->onoff_arg = softc;
fe->lun_enable = cfcs_lun_enable;
fe->lun_disable = cfcs_lun_disable;
fe->targ_lun_arg = softc;
fe->fe_datamove = cfcs_datamove;
fe->fe_done = cfcs_done;
port->num_requested_ctl_io = 4096;
snprintf(softc->port_name, sizeof(softc->port_name), "camsim");
port->port_name = softc->port_name;
port->port_online = cfcs_online;
port->port_offline = cfcs_offline;
port->onoff_arg = softc;
port->lun_enable = cfcs_lun_enable;
port->lun_disable = cfcs_lun_disable;
port->targ_lun_arg = softc;
port->fe_datamove = cfcs_datamove;
port->fe_done = cfcs_done;
/* XXX KDM what should we report here? */
/* XXX These should probably be fetched from CTL. */
fe->max_targets = 1;
fe->max_target_id = 15;
port->max_targets = 1;
port->max_target_id = 15;
retval = ctl_frontend_register(fe, /*master_SC*/ 1);
retval = ctl_port_register(port, /*master_SC*/ 1);
if (retval != 0) {
printf("%s: ctl_frontend_register() failed with error %d!\n",
printf("%s: ctl_port_register() failed with error %d!\n",
__func__, retval);
mtx_destroy(&softc->lock);
return (retval);
@ -186,30 +178,30 @@ cfcs_init(void)
#ifdef NEEDTOPORT
ddb_GetWWNN((char *)wwnn);
softc->wwnn = be64dec(wwnn);
softc->wwpn = softc->wwnn + (softc->fe.targ_port & 0xff);
softc->wwpn = softc->wwnn + (softc->port.targ_port & 0xff);
#endif
/*
* If the CTL frontend didn't tell us what our WWNN/WWPN is, go
* ahead and set something random.
*/
if (fe->wwnn == 0) {
if (port->wwnn == 0) {
uint64_t random_bits;
arc4rand(&random_bits, sizeof(random_bits), 0);
softc->wwnn = (random_bits & 0x0000000fffffff00ULL) |
/* Company ID */ 0x5000000000000000ULL |
/* NL-Port */ 0x0300;
softc->wwpn = softc->wwnn + fe->targ_port + 1;
fe->wwnn = softc->wwnn;
fe->wwpn = softc->wwpn;
softc->wwpn = softc->wwnn + port->targ_port + 1;
port->wwnn = softc->wwnn;
port->wwpn = softc->wwpn;
} else {
softc->wwnn = fe->wwnn;
softc->wwpn = fe->wwpn;
softc->wwnn = port->wwnn;
softc->wwpn = port->wwpn;
}
mtx_lock(&softc->lock);
softc->devq = cam_simq_alloc(fe->num_requested_ctl_io);
softc->devq = cam_simq_alloc(port->num_requested_ctl_io);
if (softc->devq == NULL) {
printf("%s: error allocating devq\n", __func__);
retval = ENOMEM;
@ -218,7 +210,7 @@ cfcs_init(void)
softc->sim = cam_sim_alloc(cfcs_action, cfcs_poll, softc->port_name,
softc, /*unit*/ 0, &softc->lock, 1,
fe->num_requested_ctl_io, softc->devq);
port->num_requested_ctl_io, softc->devq);
if (softc->sim == NULL) {
printf("%s: error allocating SIM\n", __func__);
retval = ENOMEM;
@ -269,26 +261,6 @@ cfcs_poll(struct cam_sim *sim)
}
void
cfcs_shutdown(void)
{
}
static int
cfcs_module_event_handler(module_t mod, int what, void *arg)
{
switch (what) {
case MOD_LOAD:
return (cfcs_init());
case MOD_UNLOAD:
return (EBUSY);
default:
return (EOPNOTSUPP);
}
}
static void
cfcs_onoffline(void *arg, int online)
{
@ -570,7 +542,7 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
return;
}
io = ctl_alloc_io(softc->fe.ctl_pool_ref);
io = ctl_alloc_io(softc->port.ctl_pool_ref);
if (io == NULL) {
printf("%s: can't allocate ctl_io\n", __func__);
ccb->ccb_h.status = CAM_BUSY | CAM_DEV_QFRZN;
@ -589,7 +561,7 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
*/
io->io_hdr.io_type = CTL_IO_SCSI;
io->io_hdr.nexus.initid.id = 1;
io->io_hdr.nexus.targ_port = softc->fe.targ_port;
io->io_hdr.nexus.targ_port = softc->port.targ_port;
/*
* XXX KDM how do we handle target IDs?
*/
@ -665,7 +637,7 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
return;
}
io = ctl_alloc_io(softc->fe.ctl_pool_ref);
io = ctl_alloc_io(softc->port.ctl_pool_ref);
if (io == NULL) {
ccb->ccb_h.status = CAM_BUSY | CAM_DEV_QFRZN;
xpt_freeze_devq(ccb->ccb_h.path, 1);
@ -680,7 +652,7 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
io->io_hdr.io_type = CTL_IO_TASK;
io->io_hdr.nexus.initid.id = 1;
io->io_hdr.nexus.targ_port = softc->fe.targ_port;
io->io_hdr.nexus.targ_port = softc->port.targ_port;
io->io_hdr.nexus.targ_target.id = ccb->ccb_h.target_id;
io->io_hdr.nexus.targ_lun = ccb->ccb_h.target_lun;
io->taskio.task_action = CTL_TASK_ABORT_TASK;
@ -737,7 +709,7 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
fc->bitrate = 800000;
fc->wwnn = softc->wwnn;
fc->wwpn = softc->wwpn;
fc->port = softc->fe.targ_port;
fc->port = softc->port.targ_port;
fc->valid |= CTS_FC_VALID_WWNN | CTS_FC_VALID_WWPN |
CTS_FC_VALID_PORT;
ccb->ccb_h.status = CAM_REQ_CMP;
@ -760,7 +732,7 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
return;
}
io = ctl_alloc_io(softc->fe.ctl_pool_ref);
io = ctl_alloc_io(softc->port.ctl_pool_ref);
if (io == NULL) {
ccb->ccb_h.status = CAM_BUSY | CAM_DEV_QFRZN;
xpt_freeze_devq(ccb->ccb_h.path, 1);
@ -775,7 +747,7 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
io->io_hdr.io_type = CTL_IO_TASK;
io->io_hdr.nexus.initid.id = 0;
io->io_hdr.nexus.targ_port = softc->fe.targ_port;
io->io_hdr.nexus.targ_port = softc->port.targ_port;
io->io_hdr.nexus.targ_target.id = ccb->ccb_h.target_id;
io->io_hdr.nexus.targ_lun = ccb->ccb_h.target_lun;
if (ccb->ccb_h.func_code == XPT_RESET_BUS)
@ -829,7 +801,7 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
cpi->transport_version = 0;
cpi->xport_specific.fc.wwnn = softc->wwnn;
cpi->xport_specific.fc.wwpn = softc->wwpn;
cpi->xport_specific.fc.port = softc->fe.targ_port;
cpi->xport_specific.fc.port = softc->port.targ_port;
cpi->xport_specific.fc.bitrate = 8 * 1000 * 1000;
cpi->ccb_h.status = CAM_REQ_CMP;
break;

View File

@ -173,7 +173,7 @@ typedef enum {
} cfi_flags;
struct cfi_softc {
struct ctl_frontend fe;
struct ctl_port port;
char fe_name[40];
struct mtx lock;
cfi_flags flags;
@ -214,28 +214,24 @@ static void cfi_metatask_io_done(union ctl_io *io);
static void cfi_err_recovery_done(union ctl_io *io);
static void cfi_lun_io_done(union ctl_io *io);
static int cfi_module_event_handler(module_t, int /*modeventtype_t*/, void *);
static moduledata_t cfi_moduledata = {
"ctlcfi",
cfi_module_event_handler,
NULL
static struct ctl_frontend cfi_frontend =
{
.name = "kernel",
.init = cfi_init,
.shutdown = cfi_shutdown,
};
DECLARE_MODULE(ctlcfi, cfi_moduledata, SI_SUB_CONFIGURE, SI_ORDER_FOURTH);
MODULE_VERSION(ctlcfi, 1);
MODULE_DEPEND(ctlcfi, ctl, 1, 1, 1);
CTL_FRONTEND_DECLARE(ctlcfi, cfi_frontend);
int
cfi_init(void)
{
struct cfi_softc *softc;
struct ctl_frontend *fe;
struct ctl_port *port;
int retval;
softc = &fetd_internal_softc;
fe = &softc->fe;
port = &softc->port;
retval = 0;
@ -252,22 +248,23 @@ cfi_init(void)
STAILQ_INIT(&softc->lun_list);
STAILQ_INIT(&softc->metatask_list);
sprintf(softc->fe_name, "CTL internal");
fe->port_type = CTL_PORT_INTERNAL;
fe->num_requested_ctl_io = 100;
fe->port_name = softc->fe_name;
fe->port_online = cfi_online;
fe->port_offline = cfi_offline;
fe->onoff_arg = softc;
fe->lun_enable = cfi_lun_enable;
fe->lun_disable = cfi_lun_disable;
fe->targ_lun_arg = softc;
fe->fe_datamove = cfi_datamove;
fe->fe_done = cfi_done;
fe->max_targets = 15;
fe->max_target_id = 15;
sprintf(softc->fe_name, "kernel");
port->frontend = &cfi_frontend;
port->port_type = CTL_PORT_INTERNAL;
port->num_requested_ctl_io = 100;
port->port_name = softc->fe_name;
port->port_online = cfi_online;
port->port_offline = cfi_offline;
port->onoff_arg = softc;
port->lun_enable = cfi_lun_enable;
port->lun_disable = cfi_lun_disable;
port->targ_lun_arg = softc;
port->fe_datamove = cfi_datamove;
port->fe_done = cfi_done;
port->max_targets = 15;
port->max_target_id = 15;
if (ctl_frontend_register(fe, (softc->flags & CTL_FLAG_MASTER_SHELF)) != 0)
if (ctl_port_register(port, (softc->flags & CTL_FLAG_MASTER_SHELF)) != 0)
{
printf("%s: internal frontend registration failed\n", __func__);
return (0);
@ -291,27 +288,13 @@ cfi_shutdown(void)
/*
* XXX KDM need to clear out any I/O pending on each LUN.
*/
if (ctl_frontend_deregister(&softc->fe) != 0)
if (ctl_port_deregister(&softc->port) != 0)
printf("%s: ctl_frontend_deregister() failed\n", __func__);
uma_zdestroy(cfi_lun_zone);
uma_zdestroy(cfi_metatask_zone);
}
static int
cfi_module_event_handler(module_t mod, int what, void *arg)
{
switch (what) {
case MOD_LOAD:
return (cfi_init());
case MOD_UNLOAD:
return (EBUSY);
default:
return (EOPNOTSUPP);
}
}
static void
cfi_online(void *arg)
{
@ -718,7 +701,7 @@ cfi_init_io(union ctl_io *io, struct cfi_lun *lun,
struct cfi_lun_io *lun_io;
io->io_hdr.nexus.initid.id = 7;
io->io_hdr.nexus.targ_port = lun->softc->fe.targ_port;
io->io_hdr.nexus.targ_port = lun->softc->port.targ_port;
io->io_hdr.nexus.targ_target.id = lun->target_id.id;
io->io_hdr.nexus.targ_lun = lun->lun_id;
io->io_hdr.retries = retries;
@ -779,7 +762,7 @@ cfi_done(union ctl_io *io)
union ctl_io *new_io;
struct cfi_lun_io *new_lun_io;
new_io = ctl_alloc_io(softc->fe.ctl_pool_ref);
new_io = ctl_alloc_io(softc->port.ctl_pool_ref);
if (new_io == NULL) {
printf("%s: unable to allocate ctl_io for "
"error recovery\n", __func__);
@ -985,7 +968,7 @@ cfi_lun_probe(struct cfi_lun *lun, int have_lock)
struct cfi_lun_io *lun_io;
union ctl_io *io;
io = ctl_alloc_io(lun->softc->fe.ctl_pool_ref);
io = ctl_alloc_io(lun->softc->port.ctl_pool_ref);
if (io == NULL) {
printf("%s: unable to alloc ctl_io for target %ju "
"lun %d probe\n", __func__,
@ -1032,7 +1015,7 @@ cfi_lun_probe(struct cfi_lun *lun, int have_lock)
uint8_t *dataptr;
union ctl_io *io;
io = ctl_alloc_io(lun->softc->fe.ctl_pool_ref);
io = ctl_alloc_io(lun->softc->port.ctl_pool_ref);
if (io == NULL) {
printf("%s: unable to alloc ctl_io for target %ju "
"lun %d probe\n", __func__,
@ -1413,7 +1396,7 @@ cfi_action(struct cfi_metatask *metatask)
if (SID_TYPE(&lun->inq_data) != T_DIRECT)
continue;
da_luns++;
io = ctl_alloc_io(softc->fe.ctl_pool_ref);
io = ctl_alloc_io(softc->port.ctl_pool_ref);
if (io != NULL) {
ios_allocated++;
STAILQ_INSERT_TAIL(&tmp_io_list, &io->io_hdr,
@ -1567,7 +1550,7 @@ cfi_action(struct cfi_metatask *metatask)
}
io = ctl_alloc_io(softc->fe.ctl_pool_ref);
io = ctl_alloc_io(softc->port.ctl_pool_ref);
if (io == NULL) {
metatask->status = CFI_MT_ERROR;
metatask->taskinfo.bbrread.status = CFI_BBR_NO_MEM;

View File

@ -170,18 +170,13 @@ static void cfiscsi_session_delete(struct cfiscsi_session *cs);
static struct cfiscsi_softc cfiscsi_softc;
extern struct ctl_softc *control_softc;
static int cfiscsi_module_event_handler(module_t, int /*modeventtype_t*/, void *);
static moduledata_t cfiscsi_moduledata = {
"ctlcfiscsi",
cfiscsi_module_event_handler,
NULL
static struct ctl_frontend cfiscsi_frontend =
{
.name = "iscsi",
.init = cfiscsi_init,
.ioctl = cfiscsi_ioctl,
};
DECLARE_MODULE(ctlcfiscsi, cfiscsi_moduledata, SI_SUB_CONFIGURE, SI_ORDER_FOURTH);
MODULE_VERSION(ctlcfiscsi, 1);
MODULE_DEPEND(ctlcfiscsi, ctl, 1, 1, 1);
MODULE_DEPEND(ctlcfiscsi, icl, 1, 1, 1);
CTL_FRONTEND_DECLARE(ctlcfiscsi, cfiscsi_frontend);
static struct icl_pdu *
cfiscsi_pdu_new_response(struct icl_pdu *request, int flags)
@ -541,7 +536,7 @@ cfiscsi_pdu_handle_scsi_command(struct icl_pdu *request)
cfiscsi_session_terminate(cs);
return;
}
io = ctl_alloc_io(cs->cs_target->ct_softc->fe.ctl_pool_ref);
io = ctl_alloc_io(cs->cs_target->ct_softc->port.ctl_pool_ref);
if (io == NULL) {
CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io; "
"dropping connection");
@ -553,7 +548,7 @@ cfiscsi_pdu_handle_scsi_command(struct icl_pdu *request)
io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = request;
io->io_hdr.io_type = CTL_IO_SCSI;
io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_softc->fe.targ_port;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_softc->port.targ_port;
io->io_hdr.nexus.targ_target.id = 0;
io->io_hdr.nexus.targ_lun = cfiscsi_decode_lun(bhssc->bhssc_lun);
io->io_hdr.nexus.lun_map_fn = cfiscsi_map_lun;
@ -607,7 +602,7 @@ cfiscsi_pdu_handle_task_request(struct icl_pdu *request)
cs = PDU_SESSION(request);
bhstmr = (struct iscsi_bhs_task_management_request *)request->ip_bhs;
io = ctl_alloc_io(cs->cs_target->ct_softc->fe.ctl_pool_ref);
io = ctl_alloc_io(cs->cs_target->ct_softc->port.ctl_pool_ref);
if (io == NULL) {
CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io;"
"dropping connection");
@ -619,7 +614,7 @@ cfiscsi_pdu_handle_task_request(struct icl_pdu *request)
io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = request;
io->io_hdr.io_type = CTL_IO_TASK;
io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_softc->fe.targ_port;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_softc->port.targ_port;
io->io_hdr.nexus.targ_target.id = 0;
io->io_hdr.nexus.targ_lun = cfiscsi_decode_lun(bhstmr->bhstmr_lun);
io->io_hdr.nexus.lun_map_fn = cfiscsi_map_lun;
@ -1041,7 +1036,7 @@ cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs)
int error, last;
#ifdef notyet
io = ctl_alloc_io(cs->cs_target->ct_softc->fe.ctl_pool_ref);
io = ctl_alloc_io(cs->cs_target->ct_softc->port.ctl_pool_ref);
if (io == NULL) {
CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io");
return;
@ -1050,7 +1045,7 @@ cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs)
io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = NULL;
io->io_hdr.io_type = CTL_IO_TASK;
io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_softc->fe.targ_port;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_softc->port.targ_port;
io->io_hdr.nexus.targ_target.id = 0;
io->io_hdr.nexus.targ_lun = lun;
io->taskio.tag_type = CTL_TAG_SIMPLE; /* XXX */
@ -1069,7 +1064,7 @@ cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs)
CFISCSI_SESSION_LOCK(cs);
TAILQ_FOREACH_SAFE(cdw,
&cs->cs_waiting_for_data_out, cdw_next, tmpcdw) {
io = ctl_alloc_io(cs->cs_target->ct_softc->fe.ctl_pool_ref);
io = ctl_alloc_io(cs->cs_target->ct_softc->port.ctl_pool_ref);
if (io == NULL) {
CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io");
return;
@ -1079,7 +1074,7 @@ cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs)
io->io_hdr.io_type = CTL_IO_TASK;
io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
io->io_hdr.nexus.targ_port =
cs->cs_target->ct_softc->fe.targ_port;
cs->cs_target->ct_softc->port.targ_port;
io->io_hdr.nexus.targ_target.id = 0;
//io->io_hdr.nexus.targ_lun = lun; /* Not needed? */
io->taskio.tag_type = CTL_TAG_SIMPLE; /* XXX */
@ -1202,7 +1197,7 @@ cfiscsi_session_register_initiator(struct cfiscsi_session *cs)
i, softc->max_initiators);
#endif
cs->cs_ctl_initid = i;
error = ctl_add_initiator(0x0, softc->fe.targ_port, cs->cs_ctl_initid);
error = ctl_add_initiator(0x0, softc->port.targ_port, cs->cs_ctl_initid);
if (error != 0) {
CFISCSI_SESSION_WARN(cs, "ctl_add_initiator failed with error %d", error);
mtx_lock(&softc->lock);
@ -1226,7 +1221,7 @@ cfiscsi_session_unregister_initiator(struct cfiscsi_session *cs)
softc = &cfiscsi_softc;
error = ctl_remove_initiator(softc->fe.targ_port, cs->cs_ctl_initid);
error = ctl_remove_initiator(softc->port.targ_port, cs->cs_ctl_initid);
if (error != 0) {
CFISCSI_SESSION_WARN(cs, "ctl_remove_initiator failed with error %d",
error);
@ -1317,7 +1312,7 @@ int
cfiscsi_init(void)
{
struct cfiscsi_softc *softc;
struct ctl_frontend *fe;
struct ctl_port *port;
int retval;
softc = &cfiscsi_softc;
@ -1331,29 +1326,29 @@ cfiscsi_init(void)
TAILQ_INIT(&softc->sessions);
TAILQ_INIT(&softc->targets);
fe = &softc->fe;
fe->port_type = CTL_PORT_ISCSI;
port = &softc->port;
port->frontend = &cfiscsi_frontend;
port->port_type = CTL_PORT_ISCSI;
/* XXX KDM what should the real number be here? */
fe->num_requested_ctl_io = 4096;
port->num_requested_ctl_io = 4096;
snprintf(softc->port_name, sizeof(softc->port_name), "iscsi");
fe->port_name = softc->port_name;
fe->port_online = cfiscsi_online;
fe->port_offline = cfiscsi_offline;
fe->onoff_arg = softc;
fe->lun_enable = cfiscsi_lun_enable;
fe->lun_disable = cfiscsi_lun_disable;
fe->targ_lun_arg = softc;
fe->ioctl = cfiscsi_ioctl;
fe->devid = cfiscsi_devid;
fe->fe_datamove = cfiscsi_datamove;
fe->fe_done = cfiscsi_done;
port->port_name = softc->port_name;
port->port_online = cfiscsi_online;
port->port_offline = cfiscsi_offline;
port->onoff_arg = softc;
port->lun_enable = cfiscsi_lun_enable;
port->lun_disable = cfiscsi_lun_disable;
port->targ_lun_arg = softc;
port->devid = cfiscsi_devid;
port->fe_datamove = cfiscsi_datamove;
port->fe_done = cfiscsi_done;
/* XXX KDM what should we report here? */
/* XXX These should probably be fetched from CTL. */
fe->max_targets = 1;
fe->max_target_id = 15;
port->max_targets = 1;
port->max_target_id = 15;
retval = ctl_frontend_register(fe, /*master_SC*/ 1);
retval = ctl_port_register(port, /*master_SC*/ 1);
if (retval != 0) {
CFISCSI_WARN("ctl_frontend_register() failed with error %d",
retval);
@ -1361,7 +1356,7 @@ cfiscsi_init(void)
goto bailout;
}
softc->max_initiators = fe->max_initiators;
softc->max_initiators = port->max_initiators;
cfiscsi_data_wait_zone = uma_zcreate("cfiscsi_data_wait",
sizeof(struct cfiscsi_data_wait), NULL, NULL, NULL, NULL,
@ -1373,20 +1368,6 @@ cfiscsi_init(void)
return (retval);
}
static int
cfiscsi_module_event_handler(module_t mod, int what, void *arg)
{
switch (what) {
case MOD_LOAD:
return (cfiscsi_init());
case MOD_UNLOAD:
return (EBUSY);
default:
return (EOPNOTSUPP);
}
}
#ifdef ICL_KERNEL_PROXY
static void
cfiscsi_accept(struct socket *so, struct sockaddr *sa, int portal_id)

View File

@ -96,7 +96,7 @@ struct icl_listen;
#endif
struct cfiscsi_softc {
struct ctl_frontend fe;
struct ctl_port port;
struct mtx lock;
char port_name[32];
int online;

View File

@ -79,7 +79,6 @@ typedef enum {
CTL_POOL_INTERNAL,
CTL_POOL_FETD,
CTL_POOL_EMERGENCY,
CTL_POOL_IOCTL,
CTL_POOL_4OTHERSC
} ctl_pool_type;
@ -110,7 +109,7 @@ typedef enum {
struct ctl_ioctl_info {
ctl_ioctl_flags flags;
uint32_t cur_tag_num;
struct ctl_frontend fe;
struct ctl_port port;
char port_name[24];
};
@ -456,7 +455,9 @@ struct ctl_softc {
STAILQ_HEAD(, ctl_be_lun) pending_lun_queue;
uint32_t num_frontends;
STAILQ_HEAD(, ctl_frontend) fe_list;
struct ctl_frontend *ctl_ports[CTL_MAX_PORTS];
uint32_t num_ports;
STAILQ_HEAD(, ctl_port) port_list;
struct ctl_port *ctl_ports[CTL_MAX_PORTS];
uint32_t num_backends;
STAILQ_HEAD(, ctl_backend_driver) be_list;
struct mtx pool_lock;

View File

@ -77,7 +77,7 @@ typedef enum {
} ctlfe_ccb_types;
struct ctlfe_softc {
struct ctl_frontend fe;
struct ctl_port port;
path_id_t path_id;
u_int maxio;
struct cam_sim *sim;
@ -198,7 +198,7 @@ MALLOC_DEFINE(M_CTLFE, "CAM CTL FE", "CAM CTL FE interface");
int ctlfeinitialize(void);
void ctlfeshutdown(void);
static periph_init_t ctlfeinit;
static periph_init_t ctlfeperiphinit;
static void ctlfeasync(void *callback_arg, uint32_t code,
struct cam_path *path, void *arg);
static periph_ctor_t ctlferegister;
@ -223,26 +223,18 @@ static void ctlfe_dump(void);
static struct periph_driver ctlfe_driver =
{
ctlfeinit, "ctl",
ctlfeperiphinit, "ctl",
TAILQ_HEAD_INITIALIZER(ctlfe_driver.units), /*generation*/ 0
};
static int ctlfe_module_event_handler(module_t, int /*modeventtype_t*/, void *);
/*
* We're not using PERIPHDRIVER_DECLARE(), because it runs at SI_SUB_DRIVERS,
* and that happens before CTL gets initialised.
*/
static moduledata_t ctlfe_moduledata = {
"ctlfe",
ctlfe_module_event_handler,
NULL
static struct ctl_frontend ctlfe_frontend =
{
.name = "camtarget",
.init = ctlfeinitialize,
.fe_dump = ctlfe_dump,
.shutdown = ctlfeshutdown,
};
DECLARE_MODULE(ctlfe, ctlfe_moduledata, SI_SUB_CONFIGURE, SI_ORDER_FOURTH);
MODULE_VERSION(ctlfe, 1);
MODULE_DEPEND(ctlfe, ctl, 1, 1, 1);
MODULE_DEPEND(ctlfe, cam, 1, 1, 1);
CTL_FRONTEND_DECLARE(ctlfe, ctlfe_frontend);
extern struct ctl_softc *control_softc;
@ -252,41 +244,29 @@ ctlfeshutdown(void)
return;
}
int
ctlfeinitialize(void)
{
STAILQ_INIT(&ctlfe_softc_list);
mtx_init(&ctlfe_list_mtx, ctlfe_mtx_desc, NULL, MTX_DEF);
periphdriver_register(&ctlfe_driver);
return (0);
}
void
ctlfeinit(void)
ctlfeperiphinit(void)
{
cam_status status;
STAILQ_INIT(&ctlfe_softc_list);
mtx_init(&ctlfe_list_mtx, ctlfe_mtx_desc, NULL, MTX_DEF);
KASSERT(control_softc != NULL, ("CTL is not initialized!"));
status = xpt_register_async(AC_PATH_REGISTERED | AC_PATH_DEREGISTERED |
AC_CONTRACT, ctlfeasync, NULL, NULL);
if (status != CAM_REQ_CMP) {
printf("ctl: Failed to attach async callback due to CAM "
"status 0x%x!\n", status);
}
}
static int
ctlfe_module_event_handler(module_t mod, int what, void *arg)
{
switch (what) {
case MOD_LOAD:
periphdriver_register(&ctlfe_driver);
return (0);
case MOD_UNLOAD:
return (EBUSY);
default:
return (EOPNOTSUPP);
}
}
static void
ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
{
@ -302,7 +282,7 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
*/
switch (code) {
case AC_PATH_REGISTERED: {
struct ctl_frontend *fe;
struct ctl_port *port;
struct ctlfe_softc *bus_softc;
struct ccb_pathinq *cpi;
int retval;
@ -384,54 +364,54 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
MTX_DEF);
STAILQ_INIT(&bus_softc->lun_softc_list);
fe = &bus_softc->fe;
port = &bus_softc->port;
port->frontend = &ctlfe_frontend;
/*
* XXX KDM should we be more accurate here ?
*/
if (cpi->transport == XPORT_FC)
fe->port_type = CTL_PORT_FC;
port->port_type = CTL_PORT_FC;
else
fe->port_type = CTL_PORT_SCSI;
port->port_type = CTL_PORT_SCSI;
/* XXX KDM what should the real number be here? */
fe->num_requested_ctl_io = 4096;
port->num_requested_ctl_io = 4096;
snprintf(bus_softc->port_name, sizeof(bus_softc->port_name),
"%s%d", cpi->dev_name, cpi->unit_number);
/*
* XXX KDM it would be nice to allocate storage in the
* frontend structure itself.
*/
fe->port_name = bus_softc->port_name;
fe->physical_port = cpi->unit_number;
fe->virtual_port = cpi->bus_id;
fe->port_online = ctlfe_online;
fe->port_offline = ctlfe_offline;
fe->onoff_arg = bus_softc;
fe->lun_enable = ctlfe_lun_enable;
fe->lun_disable = ctlfe_lun_disable;
fe->targ_lun_arg = bus_softc;
fe->fe_datamove = ctlfe_datamove_done;
fe->fe_done = ctlfe_datamove_done;
fe->fe_dump = ctlfe_dump;
port->port_name = bus_softc->port_name;
port->physical_port = cpi->unit_number;
port->virtual_port = cpi->bus_id;
port->port_online = ctlfe_online;
port->port_offline = ctlfe_offline;
port->onoff_arg = bus_softc;
port->lun_enable = ctlfe_lun_enable;
port->lun_disable = ctlfe_lun_disable;
port->targ_lun_arg = bus_softc;
port->fe_datamove = ctlfe_datamove_done;
port->fe_done = ctlfe_datamove_done;
/*
* XXX KDM the path inquiry doesn't give us the maximum
* number of targets supported.
*/
fe->max_targets = cpi->max_target;
fe->max_target_id = cpi->max_target;
port->max_targets = cpi->max_target;
port->max_target_id = cpi->max_target;
/*
* XXX KDM need to figure out whether we're the master or
* slave.
*/
#ifdef CTLFEDEBUG
printf("%s: calling ctl_frontend_register() for %s%d\n",
printf("%s: calling ctl_port_register() for %s%d\n",
__func__, cpi->dev_name, cpi->unit_number);
#endif
retval = ctl_frontend_register(fe, /*master_SC*/ 1);
retval = ctl_port_register(port, /*master_SC*/ 1);
if (retval != 0) {
printf("%s: ctl_frontend_register() failed with "
printf("%s: ctl_port_register() failed with "
"error %d!\n", __func__, retval);
mtx_destroy(&bus_softc->lun_softc_mtx);
free(bus_softc, M_CTLFE);
@ -462,7 +442,7 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
* XXX KDM are we certain at this point that there
* are no outstanding commands for this frontend?
*/
ctl_frontend_deregister(&softc->fe);
ctl_port_deregister(&softc->port);
mtx_destroy(&softc->lun_softc_mtx);
free(softc, M_CTLFE);
}
@ -505,17 +485,17 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
}
if (dev_chg->arrived != 0) {
retval = ctl_add_initiator(dev_chg->wwpn,
softc->fe.targ_port, dev_chg->target);
softc->port.targ_port, dev_chg->target);
} else {
retval = ctl_remove_initiator(
softc->fe.targ_port, dev_chg->target);
softc->port.targ_port, dev_chg->target);
}
if (retval != 0) {
printf("%s: could not %s port %d iid %u "
"WWPN %#jx!\n", __func__,
(dev_chg->arrived != 0) ? "add" :
"remove", softc->fe.targ_port,
"remove", softc->port.targ_port,
dev_chg->target,
(uintmax_t)dev_chg->wwpn);
}
@ -1202,7 +1182,7 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
* Allocate a ctl_io, pass it to CTL, and wait for the
* datamove or done.
*/
io = ctl_alloc_io(bus_softc->fe.ctl_pool_ref);
io = ctl_alloc_io(bus_softc->port.ctl_pool_ref);
if (io == NULL) {
atio->ccb_h.flags &= ~CAM_DIR_MASK;
atio->ccb_h.flags |= CAM_DIR_NONE;
@ -1235,7 +1215,7 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
*/
io->io_hdr.io_type = CTL_IO_SCSI;
io->io_hdr.nexus.initid.id = atio->init_id;
io->io_hdr.nexus.targ_port = bus_softc->fe.targ_port;
io->io_hdr.nexus.targ_port = bus_softc->port.targ_port;
io->io_hdr.nexus.targ_target.id = atio->ccb_h.target_id;
io->io_hdr.nexus.targ_lun = atio->ccb_h.target_lun;
io->scsiio.tag_num = atio->tag_id;
@ -1507,7 +1487,7 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
"seq %#x\n", __func__, inot->ccb_h.status,
inot->tag_id, inot->seq_id);
io = ctl_alloc_io(bus_softc->fe.ctl_pool_ref);
io = ctl_alloc_io(bus_softc->port.ctl_pool_ref);
if (io != NULL) {
int send_ctl_io;
@ -1518,7 +1498,7 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr =done_ccb;
inot->ccb_h.io_ptr = io;
io->io_hdr.nexus.initid.id = inot->initiator_id;
io->io_hdr.nexus.targ_port = bus_softc->fe.targ_port;
io->io_hdr.nexus.targ_port = bus_softc->port.targ_port;
io->io_hdr.nexus.targ_target.id = inot->ccb_h.target_id;
io->io_hdr.nexus.targ_lun = inot->ccb_h.target_lun;
/* XXX KDM should this be the tag_id? */
@ -1730,7 +1710,7 @@ ctlfe_onoffline(void *arg, int online)
* This should be replaced later with ddb_GetWWNN,
* or possibly a more centralized scheme. (It
* would be nice to have the WWNN/WWPN for each
* port stored in the ctl_frontend structure.)
* port stored in the ctl_port structure.)
*/
#ifdef RANDOM_WWNN
ccb->knob.xport_specific.fc.wwnn =
@ -1743,7 +1723,7 @@ ctlfe_onoffline(void *arg, int online)
0x0000000fffffff00ULL) |
/* Company ID */ 0x5000ED5000000000ULL |
/* NL-Port */ 0x3000 |
/* Port Num */ (bus_softc->fe.targ_port & 0xff);
/* Port Num */ (bus_softc->port.targ_port & 0xff);
/*
* This is a bit of an API break/reversal, but if
@ -1752,9 +1732,9 @@ ctlfe_onoffline(void *arg, int online)
* using with the frontend code so it's reported
* accurately.
*/
bus_softc->fe.wwnn =
bus_softc->port.wwnn =
ccb->knob.xport_specific.fc.wwnn;
bus_softc->fe.wwpn =
bus_softc->port.wwpn =
ccb->knob.xport_specific.fc.wwpn;
set_wwnn = 1;
#else /* RANDOM_WWNN */
@ -1763,17 +1743,17 @@ ctlfe_onoffline(void *arg, int online)
* down to the SIM. Otherwise, record what the SIM
* has reported.
*/
if ((bus_softc->fe.wwnn != 0)
&& (bus_softc->fe.wwpn != 0)) {
if ((bus_softc->port.wwnn != 0)
&& (bus_softc->port.wwpn != 0)) {
ccb->knob.xport_specific.fc.wwnn =
bus_softc->fe.wwnn;
bus_softc->port.wwnn;
ccb->knob.xport_specific.fc.wwpn =
bus_softc->fe.wwpn;
bus_softc->port.wwpn;
set_wwnn = 1;
} else {
bus_softc->fe.wwnn =
bus_softc->port.wwnn =
ccb->knob.xport_specific.fc.wwnn;
bus_softc->fe.wwpn =
bus_softc->port.wwpn =
ccb->knob.xport_specific.fc.wwpn;
}
#endif /* RANDOM_WWNN */