21 #define KMSG_COMPONENT "sbp_target"
22 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
24 #include <linux/kernel.h>
25 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/string.h>
30 #include <linux/ctype.h>
33 #include <scsi/scsi.h>
41 #include <asm/unaligned.h>
51 .end = 0x1000000000000ULL,
54 static const u32 sbp_unit_directory_template[] = {
63 #define SESSION_MAINTENANCE_INTERVAL HZ
67 static void session_maintenance_work(
struct work_struct *);
68 static int sbp_run_transaction(
struct fw_card *,
int,
int,
int,
int,
69 unsigned long long,
void *,
size_t);
95 static struct sbp_session *sbp_session_find_by_guid(
101 spin_lock_bh(&tpg->
se_tpg.session_lock);
104 if (sess->
guid == guid)
107 spin_unlock_bh(&tpg->
se_tpg.session_lock);
117 spin_lock_bh(&session->
lock);
119 if (login->
lun == lun)
122 spin_unlock_bh(&session->
lock);
127 static int sbp_login_count_all_by_lun(
137 spin_lock_bh(&tpg->
se_tpg.session_lock);
141 spin_lock_bh(&sess->
lock);
143 if (login->
lun != lun)
149 spin_unlock_bh(&sess->
lock);
151 spin_unlock_bh(&tpg->
se_tpg.session_lock);
157 struct sbp_tpg *tpg,
int login_id)
163 spin_lock_bh(&tpg->
se_tpg.session_lock);
167 spin_lock_bh(&sess->
lock);
172 spin_unlock_bh(&sess->
lock);
174 spin_unlock_bh(&tpg->
se_tpg.session_lock);
179 static struct se_lun *sbp_get_lun_from_tpg(
struct sbp_tpg *tpg,
int lun)
191 se_lun = ERR_PTR(-
ENODEV);
209 pr_err(
"failed to allocate session descriptor\n");
215 pr_err(
"failed to init se_session\n");
222 snprintf(guid_str,
sizeof(guid_str),
"%016llx", guid);
226 pr_warn(
"Node ACL not found for %s\n", guid_str);
231 return ERR_PTR(-
EPERM);
234 sess->
se_sess->se_node_acl = se_nacl;
247 static void sbp_session_release(
struct sbp_session *sess,
bool cancel_work)
249 spin_lock_bh(&sess->
lock);
251 spin_unlock_bh(&sess->
lock);
254 spin_unlock_bh(&sess->
lock);
263 fw_card_put(sess->
card);
277 sbp_target_agent_unregister(login->
tgt_agt);
280 spin_lock_bh(&sess->
lock);
282 spin_unlock_bh(&sess->
lock);
284 sbp_session_release(sess, cancel_work);
293 static void sbp_management_request_login(
295 int *status_data_size)
299 struct se_lun *se_lun;
305 int login_response_len;
307 se_lun = sbp_get_lun_from_tpg(tpg,
309 if (IS_ERR(se_lun)) {
319 ret = read_peer_guid(&guid, req);
321 pr_warn(
"failed to read peer GUID: %d\n", ret);
329 pr_notice(
"mgt_agent LOGIN to LUN %d from %016llx\n",
332 sess = sbp_session_find_by_guid(tpg, guid);
334 login = sbp_login_find_by_lun(sess, se_lun);
336 pr_notice(
"initiator already logged-in\n");
353 goto already_logged_in;
362 sbp_login_count_all_by_lun(tpg, se_lun, 0)) {
363 pr_warn(
"refusing exclusive login with other active logins\n");
375 if (sbp_login_count_all_by_lun(tpg, se_lun, 1)) {
376 pr_warn(
"refusing login while another exclusive login present\n");
388 if (sbp_login_count_all_by_lun(tpg, se_lun, 0) >=
390 pr_warn(
"max number of logins reached\n");
399 sess = sbp_session_create(tpg, guid);
401 switch (PTR_ERR(sess)) {
418 sess->
card = fw_card_get(req->
card);
433 pr_err(
"failed to allocate login descriptor\n");
435 sbp_session_release(sess,
true);
449 login->
tgt_agt = sbp_target_agent_register(login);
452 pr_err(
"failed to map command block handler: %d\n", ret);
454 sbp_session_release(sess,
true);
463 spin_lock_bh(&sess->
lock);
465 spin_unlock_bh(&sess->
lock);
468 response = kzalloc(
sizeof(*response),
GFP_KERNEL);
470 pr_err(
"failed to allocate login response block\n");
472 sbp_login_release(login,
true);
482 12,
sizeof(*response));
484 ((login_response_len & 0xffff) << 16) |
487 addr_to_sbp2_pointer(login->
tgt_agt->handler.offset,
492 sbp2_pointer_to_addr(&req->
orb.ptr2), response,
495 pr_debug(
"failed to write login response block: %x\n", ret);
498 sbp_login_release(login,
true);
513 static void sbp_management_request_query_logins(
515 int *status_data_size)
517 pr_notice(
"QUERY LOGINS not implemented\n");
525 static void sbp_management_request_reconnect(
527 int *status_data_size)
535 ret = read_peer_guid(&guid, req);
537 pr_warn(
"failed to read peer GUID: %d\n", ret);
545 pr_notice(
"mgt_agent RECONNECT from %016llx\n", guid);
547 login = sbp_login_find_by_id(tpg,
551 pr_err(
"mgt_agent RECONNECT unknown login ID\n");
559 if (login->
sess->guid != guid) {
560 pr_err(
"mgt_agent RECONNECT login GUID doesn't match\n");
568 spin_lock_bh(&login->
sess->lock);
569 if (login->
sess->card)
570 fw_card_put(login->
sess->card);
575 login->
sess->card = fw_card_get(req->
card);
577 spin_unlock_bh(&login->
sess->lock);
584 static void sbp_management_request_logout(
586 int *status_data_size)
595 login = sbp_login_find_by_id(tpg,
id);
597 pr_warn(
"cannot find login: %d\n",
id);
605 pr_info(
"mgt_agent LOGOUT from LUN %d session %d\n",
609 pr_warn(
"logout from different node ID\n");
617 sbp_login_release(login,
true);
624 static void session_check_for_reset(
struct sbp_session *sess)
626 bool card_valid =
false;
628 spin_lock_bh(&sess->
lock);
631 spin_lock_irq(&sess->
card->lock);
632 card_valid = (sess->
card->local_node !=
NULL);
633 spin_unlock_irq(&sess->
card->lock);
636 fw_card_put(sess->
card);
641 if (!card_valid || (sess->
generation != sess->
card->generation)) {
642 pr_info(
"Waiting for reconnect from node: %016llx\n",
650 spin_unlock_bh(&sess->
lock);
653 static void session_reconnect_expired(
struct sbp_session *sess)
658 pr_info(
"Reconnect timer expired for node: %016llx\n", sess->
guid);
660 spin_lock_bh(&sess->
lock);
663 list_move_tail(&login->
link, &login_list);
665 spin_unlock_bh(&sess->
lock);
669 sbp_login_release(login,
false);
672 sbp_session_release(sess,
false);
681 spin_lock_bh(&sess->
lock);
683 spin_unlock_bh(&sess->
lock);
686 spin_unlock_bh(&sess->
lock);
690 session_check_for_reset(sess);
700 session_reconnect_expired(sess);
704 static int tgt_agent_rw_agent_state(
struct fw_card *
card,
int tcode,
void *
data,
711 pr_debug(
"tgt_agent AGENT_STATE READ\n");
713 spin_lock_bh(&agent->
lock);
715 spin_unlock_bh(&agent->
lock);
716 memcpy(data, &state,
sizeof(state));
729 static int tgt_agent_rw_agent_reset(
struct fw_card *card,
int tcode,
void *data,
734 pr_debug(
"tgt_agent AGENT_RESET\n");
735 spin_lock_bh(&agent->
lock);
737 spin_unlock_bh(&agent->
lock);
745 static int tgt_agent_rw_orb_pointer(
struct fw_card *card,
int tcode,
void *data,
752 spin_lock_bh(&agent->
lock);
755 spin_unlock_bh(&agent->
lock);
756 pr_notice(
"Ignoring ORB_POINTER write while active.\n");
760 spin_unlock_bh(&agent->
lock);
765 pr_debug(
"tgt_agent ORB_POINTER write: 0x%llx\n",
773 pr_debug(
"tgt_agent ORB_POINTER READ\n");
774 spin_lock_bh(&agent->
lock);
776 spin_unlock_bh(&agent->
lock);
784 static int tgt_agent_rw_doorbell(
struct fw_card *card,
int tcode,
void *data,
789 spin_lock_bh(&agent->
lock);
791 spin_unlock_bh(&agent->
lock);
792 pr_debug(
"Ignoring DOORBELL while active.\n");
796 spin_unlock_bh(&agent->
lock);
814 static int tgt_agent_rw_unsolicited_status_enable(
struct fw_card *card,
819 pr_debug(
"tgt_agent UNSOLICITED_STATUS_ENABLE\n");
838 int sess_gen, sess_node, rcode;
840 spin_lock_bh(&sess->
lock);
843 spin_unlock_bh(&sess->
lock);
845 if (generation != sess_gen) {
846 pr_notice(
"ignoring request with wrong generation\n");
851 if (source != sess_node) {
852 pr_notice(
"ignoring request from foreign node (%x != %x)\n",
859 offset -= agent->
handler.offset;
861 if (offset == 0x00 && length == 4) {
863 rcode = tgt_agent_rw_agent_state(card, tcode, data, agent);
864 }
else if (offset == 0x04 && length == 4) {
866 rcode = tgt_agent_rw_agent_reset(card, tcode, data, agent);
867 }
else if (offset == 0x08 && length == 8) {
869 rcode = tgt_agent_rw_orb_pointer(card, tcode, data, agent);
870 }
else if (offset == 0x10 && length == 4) {
872 rcode = tgt_agent_rw_doorbell(card, tcode, data, agent);
873 }
else if (offset == 0x14 && length == 4) {
875 rcode = tgt_agent_rw_unsolicited_status_enable(card, tcode,
889 static void tgt_agent_process_work(
struct work_struct *work)
894 pr_debug(
"tgt_orb ptr:0x%llx next_ORB:0x%llx data_descriptor:0x%llx misc:0x%x\n",
896 sbp2_pointer_to_addr(&req->
orb.next_orb),
897 sbp2_pointer_to_addr(&req->
orb.data_descriptor),
901 pr_debug(
"ORB with high bits set\n");
905 sbp_handle_command(req);
916 sbp_send_status(req);
917 sbp_free_request(req);
927 sbp_send_status(req);
928 sbp_free_request(req);
940 spin_lock_bh(&agent->
lock);
942 spin_unlock_bh(&agent->
lock);
947 static void tgt_agent_fetch_work(
struct work_struct *work)
957 while (next_orb && tgt_agent_check_active(agent)) {
960 spin_lock_bh(&agent->
lock);
962 spin_unlock_bh(&agent->
lock);
979 pr_debug(
"tgt_orb fetch failed: %x\n", ret);
989 spin_lock_bh(&agent->
lock);
991 spin_unlock_bh(&agent->
lock);
993 sbp_send_status(req);
994 sbp_free_request(req);
1004 next_orb = sbp2_pointer_to_addr(&req->
orb.next_orb);
1009 if (tgt_agent_check_active(agent) && !doorbell) {
1014 sbp_free_request(req);
1017 spin_lock_bh(&agent->
lock);
1018 doorbell = agent->
doorbell =
false;
1026 spin_unlock_bh(&agent->
lock);
1043 agent->
handler.address_callback = tgt_agent_rw;
1044 agent->
handler.callback_data = agent;
1053 &sbp_register_region);
1056 return ERR_PTR(ret);
1073 static int sbp_run_transaction(
struct fw_card *card,
int tcode,
int destination_id,
1074 int generation,
int speed,
unsigned long long offset,
1079 for (attempt = 1; attempt <= 5; attempt++) {
1081 generation, speed, offset, payload, length);
1091 delay = 5 * attempt * attempt;
1104 int tcode,
unsigned long long offset,
void *payload,
1112 spin_lock_bh(&sess->
lock);
1113 card = fw_card_get(sess->
card);
1116 speed = sess->
speed;
1117 spin_unlock_bh(&sess->
lock);
1119 ret = sbp_run_transaction(card, tcode, node_id, generation, speed,
1120 offset, payload, length);
1131 cmd_len = scsi_command_size(req->
orb.command_block);
1138 min_t(
int, cmd_len,
sizeof(req->
orb.command_block)));
1140 if (cmd_len >
sizeof(req->
orb.command_block)) {
1141 pr_debug(
"sbp_fetch_command: filling in long command\n");
1142 copy_len = cmd_len -
sizeof(req->
orb.command_block);
1144 ret = sbp_run_request_transaction(req,
1147 req->
cmd_buf +
sizeof(req->
orb.command_block),
1172 sbp2_pointer_to_addr(&req->
orb.data_descriptor),
1203 req->
pg_tbl[idx].segment_length);
1214 int ret, unpacked_lun;
1218 ret = sbp_fetch_command(req);
1220 pr_debug(
"sbp_handle_command: fetch command failed: %d\n", ret);
1224 ret = sbp_fetch_page_table(req);
1226 pr_debug(
"sbp_handle_command: fetch page table failed: %d\n",
1231 unpacked_lun = req->
login->lun->unpacked_lun;
1232 sbp_calc_data_length_direction(req, &data_length, &data_dir);
1234 pr_debug(
"sbp_handle_command ORB:0x%llx unpacked_lun:%d data_len:%d data_dir:%d\n",
1235 req->
orb_pointer, unpacked_lun, data_length, data_dir);
1238 req->
sense_buf, unpacked_lun, data_length,
1250 sbp_send_status(req);
1251 sbp_free_request(req);
1265 unsigned long long offset;
1282 pr_err(
"sbp_run_transaction: page size ignored\n");
1283 pg_size = 0x100 << pg_size;
1286 spin_lock_bh(&sess->
lock);
1287 card = fw_card_get(sess->
card);
1290 spin_unlock_bh(&sess->
lock);
1302 offset = sbp2_pointer_to_addr(&req->
orb.data_descriptor);
1303 length = req->
se_cmd.data_length;
1309 while (length || num_pte) {
1321 tfr_length =
min3(length, max_payload, (
int)iter.length);
1325 rcode = sbp_run_transaction(card, tcode, node_id,
1327 offset, iter.addr, tfr_length);
1332 length -= tfr_length;
1333 offset += tfr_length;
1334 iter.consumed = tfr_length;
1358 pr_debug(
"sbp_send_status: write failed: 0x%x\n", ret);
1362 pr_debug(
"sbp_send_status: status write complete for ORB: 0x%llx\n",
1376 switch (sense[0] & 0x7f) {
1390 pr_err(
"sbp_send_sense: unknown sense format: 0x%x\n",
1403 ((sense[2] & 0xe0) >> 1) |
1409 status[4] = sense[3];
1410 status[5] = sense[4];
1411 status[6] = sense[5];
1412 status[7] = sense[6];
1415 status[8] = sense[8];
1416 status[9] = sense[9];
1417 status[10] = sense[10];
1418 status[11] = sense[11];
1421 status[12] = sense[14];
1424 status[13] = sense[15];
1425 status[14] = sense[16];
1426 status[15] = sense[17];
1437 struct se_cmd *se_cmd = &req->
se_cmd;
1440 sbp_sense_mangle(req);
1449 return sbp_send_status(req);
1459 static void sbp_mgt_agent_process(
struct work_struct *work)
1465 int status_data_len = 0;
1472 pr_debug(
"mgt_orb fetch failed: %x\n", ret);
1476 pr_debug(
"mgt_orb ptr1:0x%llx ptr2:0x%llx misc:0x%x len:0x%x status_fifo:0x%llx\n",
1477 sbp2_pointer_to_addr(&req->
orb.ptr1),
1478 sbp2_pointer_to_addr(&req->
orb.ptr2),
1480 sbp2_pointer_to_addr(&req->
orb.status_fifo));
1484 pr_err(
"mgt_orb bad request\n");
1490 sbp_management_request_login(agent, req, &status_data_len);
1494 sbp_management_request_query_logins(agent, req,
1499 sbp_management_request_reconnect(agent, req, &status_data_len);
1503 pr_notice(
"SET PASSWORD not implemented\n");
1512 sbp_management_request_logout(agent, req, &status_data_len);
1516 pr_notice(
"ABORT TASK not implemented\n");
1525 pr_notice(
"ABORT TASK SET not implemented\n");
1534 pr_notice(
"LOGICAL UNIT RESET not implemented\n");
1543 pr_notice(
"TARGET RESET not implemented\n");
1552 pr_notice(
"unknown management function 0x%x\n",
1571 sbp2_pointer_to_addr(&req->
orb.status_fifo),
1572 &req->
status, 8 + status_data_len);
1574 pr_debug(
"mgt_orb status write failed: %x\n", ret);
1579 fw_card_put(req->
card);
1582 spin_lock_bh(&agent->
lock);
1584 spin_unlock_bh(&agent->
lock);
1587 static void sbp_mgt_agent_rw(
struct fw_card *card,
1588 struct fw_request *request,
int tcode,
int destination,
int source,
1589 int generation,
unsigned long long offset,
void *data,
size_t length,
1590 void *callback_data)
1596 if (!agent->
tport->enable)
1599 if ((offset != agent->
handler.offset) || (length != 8))
1606 spin_lock_bh(&agent->
lock);
1607 prev_state = agent->
state;
1609 spin_unlock_bh(&agent->
lock);
1612 pr_notice(
"ignoring management request while busy\n");
1623 req->
card = fw_card_get(card);
1628 agent->
orb_offset = sbp2_pointer_to_addr(ptr);
1634 addr_to_sbp2_pointer(agent->
orb_offset, ptr);
1657 agent->
handler.address_callback = sbp_mgt_agent_rw;
1658 agent->
handler.callback_data = agent;
1665 &sbp_register_region);
1668 return ERR_PTR(ret);
1691 static char *sbp_get_fabric_name(
void)
1721 pr_err(
"Unable to alocate struct sbp_nacl\n");
1728 static void sbp_release_fabric_acl(
1742 static void sbp_release_cmd(
struct se_cmd *se_cmd)
1747 sbp_free_request(req);
1750 static int sbp_shutdown_session(
struct se_session *se_sess)
1755 static void sbp_close_session(
struct se_session *se_sess)
1765 static int sbp_write_pending(
struct se_cmd *se_cmd)
1771 ret = sbp_rw_data(req);
1780 sbp_send_status(req);
1788 static int sbp_write_pending_status(
struct se_cmd *se_cmd)
1793 static void sbp_set_default_node_attrs(
struct se_node_acl *nacl)
1798 static u32 sbp_get_task_tag(
struct se_cmd *se_cmd)
1807 static int sbp_get_cmd_state(
struct se_cmd *se_cmd)
1812 static int sbp_queue_data_in(
struct se_cmd *se_cmd)
1818 ret = sbp_rw_data(req);
1825 sbp_send_status(req);
1829 return sbp_send_sense(req);
1836 static int sbp_queue_status(
struct se_cmd *se_cmd)
1841 return sbp_send_sense(req);
1844 static int sbp_queue_tm_rsp(
struct se_cmd *se_cmd)
1849 static int sbp_check_stop_free(
struct se_cmd *se_cmd)
1870 static u32 sbp_get_pr_transport_id(
1889 pr_debug(
"sbp transport_id: invalid hex string\n");
1897 static u32 sbp_get_pr_transport_id_len(
1917 static char *sbp_parse_pr_out_transport_id(
1921 char **port_nexus_ptr)
1931 *port_nexus_ptr =
NULL;
1934 return (
char *)&buf[8];
1955 static int sbp_update_unit_directory(
struct sbp_tport *tport)
1969 num_luns = sbp_count_se_tpg_luns(&tport->
tpg->se_tpg);
1982 num_entries =
ARRAY_SIZE(sbp_unit_directory_template) + 4 + num_luns;
1993 data[idx++] = num_entries << 16;
2000 memcpy(&data[idx], sbp_unit_directory_template,
2001 sizeof(sbp_unit_directory_template));
2002 idx +=
ARRAY_SIZE(sbp_unit_directory_template);
2006 data[idx++] = 0x54000000 | (mgt_agt_addr & 0x00ffffff);
2009 data[idx++] = 0x3a000000 |
2017 data[idx++] = 0x8d000000 | (num_luns + 1);
2019 spin_lock(&tport->
tpg->se_tpg.tpg_lun_lock);
2021 struct se_lun *se_lun = tport->
tpg->se_tpg.tpg_lun_list[
i];
2028 spin_unlock(&tport->
tpg->se_tpg.tpg_lun_lock);
2031 type = dev->
transport->get_device_type(dev);
2034 data[idx++] = 0x14000000 |
2035 ((type << 16) & 0x1f0000) |
2038 spin_lock(&tport->
tpg->se_tpg.tpg_lun_lock);
2040 spin_unlock(&tport->
tpg->se_tpg.tpg_lun_lock);
2043 data[idx++] = 2 << 16;
2044 data[idx++] = tport->
guid >> 32;
2045 data[idx++] = tport->
guid;
2067 for (cp = name; cp < &name[
SBP_NAMELEN - 1]; cp++) {
2069 if (c ==
'\n' && cp[1] ==
'\0')
2081 nibble =
tolower(c) -
'a' + 10;
2084 *wwn = (*wwn << 4) | nibble;
2090 err, cp - name, pos);
2094 static ssize_t sbp_format_wwn(
char *buf,
size_t len,
u64 wwn)
2096 return snprintf(buf, len,
"%016llx", wwn);
2107 u32 nexus_depth = 1;
2109 if (sbp_parse_wwn(name, &guid) < 0)
2112 se_nacl_new = sbp_alloc_fabric_acl(se_tpg);
2122 if (IS_ERR(se_nacl)) {
2123 sbp_release_fabric_acl(se_tpg, se_nacl_new);
2134 static void sbp_drop_nodeacl(
struct se_node_acl *se_acl)
2143 static int sbp_post_link_lun(
2145 struct se_lun *se_lun)
2149 return sbp_update_unit_directory(tpg->
tport);
2152 static void sbp_pre_unlink_lun(
2154 struct se_lun *se_lun)
2160 if (sbp_count_se_tpg_luns(&tpg->
se_tpg) == 0)
2163 ret = sbp_update_unit_directory(tport);
2165 pr_err(
"unlink LUN: failed to update unit directory\n");
2180 if (
strstr(name,
"tpgt_") != name)
2182 if (kstrtoul(name + 5, 10, &tpgt) || tpgt >
UINT_MAX)
2186 pr_err(
"Only one TPG per Unit is possible.\n");
2187 return ERR_PTR(-
EBUSY);
2192 pr_err(
"Unable to allocate struct sbp_tpg\n");
2207 tport->
mgt_agt = sbp_management_agent_register(tport);
2209 ret = PTR_ERR(tport->
mgt_agt);
2211 return ERR_PTR(ret);
2215 &tpg->
se_tpg, (
void *)tpg,
2218 sbp_management_agent_unregister(tport->
mgt_agt);
2220 return ERR_PTR(ret);
2232 sbp_management_agent_unregister(tport->
mgt_agt);
2237 static struct se_wwn *sbp_make_tport(
2245 if (sbp_parse_wwn(name, &guid) < 0)
2250 pr_err(
"Unable to allocate struct sbp_tport\n");
2260 static void sbp_drop_tport(
struct se_wwn *wwn)
2268 static ssize_t sbp_wwn_show_attr_version(
2278 &sbp_wwn_version.attr,
2282 static ssize_t sbp_tpg_show_directory_id(
2290 return sprintf(page,
"implicit\n");
2295 static ssize_t sbp_tpg_store_directory_id(
2305 pr_err(
"Cannot change the directory_id on an active target.\n");
2309 if (
strstr(page,
"implicit") == page) {
2312 if (kstrtoul(page, 16, &val) < 0)
2323 static ssize_t sbp_tpg_show_enable(
2332 static ssize_t sbp_tpg_store_enable(
2342 if (kstrtoul(page, 0, &val) < 0)
2344 if ((val != 0) && (val != 1))
2347 if (tport->
enable == val)
2351 if (sbp_count_se_tpg_luns(&tpg->
se_tpg) == 0) {
2352 pr_err(
"Cannot enable a target with no LUNs!\n");
2367 ret = sbp_update_unit_directory(tport);
2369 pr_err(
"Could not update Config ROM\n");
2380 &sbp_tpg_directory_id.attr,
2381 &sbp_tpg_enable.attr,
2385 static ssize_t sbp_tpg_attrib_show_mgt_orb_timeout(
2394 static ssize_t sbp_tpg_attrib_store_mgt_orb_timeout(
2404 if (kstrtoul(page, 0, &val) < 0)
2406 if ((val < 1) || (val > 127))
2414 ret = sbp_update_unit_directory(tport);
2421 static ssize_t sbp_tpg_attrib_show_max_reconnect_timeout(
2430 static ssize_t sbp_tpg_attrib_store_max_reconnect_timeout(
2440 if (kstrtoul(page, 0, &val) < 0)
2442 if ((val < 1) || (val > 32767))
2450 ret = sbp_update_unit_directory(tport);
2457 static ssize_t sbp_tpg_attrib_show_max_logins_per_lun(
2466 static ssize_t sbp_tpg_attrib_store_max_logins_per_lun(
2475 if (kstrtoul(page, 0, &val) < 0)
2477 if ((val < 1) || (val > 127))
2492 &sbp_tpg_attrib_mgt_orb_timeout.attr,
2493 &sbp_tpg_attrib_max_reconnect_timeout.attr,
2494 &sbp_tpg_attrib_max_logins_per_lun.attr,
2499 .get_fabric_name = sbp_get_fabric_name,
2500 .get_fabric_proto_ident = sbp_get_fabric_proto_ident,
2501 .tpg_get_wwn = sbp_get_fabric_wwn,
2502 .tpg_get_tag = sbp_get_tag,
2503 .tpg_get_default_depth = sbp_get_default_depth,
2504 .tpg_get_pr_transport_id = sbp_get_pr_transport_id,
2505 .tpg_get_pr_transport_id_len = sbp_get_pr_transport_id_len,
2506 .tpg_parse_pr_out_transport_id = sbp_parse_pr_out_transport_id,
2507 .tpg_check_demo_mode = sbp_check_true,
2508 .tpg_check_demo_mode_cache = sbp_check_true,
2509 .tpg_check_demo_mode_write_protect = sbp_check_false,
2510 .tpg_check_prod_mode_write_protect = sbp_check_false,
2511 .tpg_alloc_fabric_acl = sbp_alloc_fabric_acl,
2512 .tpg_release_fabric_acl = sbp_release_fabric_acl,
2513 .tpg_get_inst_index = sbp_tpg_get_inst_index,
2514 .release_cmd = sbp_release_cmd,
2515 .shutdown_session = sbp_shutdown_session,
2516 .close_session = sbp_close_session,
2517 .sess_get_index = sbp_sess_get_index,
2518 .write_pending = sbp_write_pending,
2519 .write_pending_status = sbp_write_pending_status,
2520 .set_default_node_attributes = sbp_set_default_node_attrs,
2521 .get_task_tag = sbp_get_task_tag,
2522 .get_cmd_state = sbp_get_cmd_state,
2523 .queue_data_in = sbp_queue_data_in,
2524 .queue_status = sbp_queue_status,
2525 .queue_tm_rsp = sbp_queue_tm_rsp,
2526 .check_stop_free = sbp_check_stop_free,
2528 .fabric_make_wwn = sbp_make_tport,
2529 .fabric_drop_wwn = sbp_drop_tport,
2530 .fabric_make_tpg = sbp_make_tpg,
2531 .fabric_drop_tpg = sbp_drop_tpg,
2532 .fabric_post_link = sbp_post_link_lun,
2533 .fabric_pre_unlink = sbp_pre_unlink_lun,
2534 .fabric_make_np =
NULL,
2535 .fabric_drop_np =
NULL,
2536 .fabric_make_nodeacl = sbp_make_nodeacl,
2537 .fabric_drop_nodeacl = sbp_drop_nodeacl,
2540 static int sbp_register_configfs(
void)
2546 if (IS_ERR(fabric)) {
2547 pr_err(
"target_fabric_configfs_init() failed\n");
2548 return PTR_ERR(fabric);
2551 fabric->
tf_ops = sbp_ops;
2556 TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = sbp_wwn_attrs;
2557 TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = sbp_tpg_base_attrs;
2558 TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = sbp_tpg_attrib_attrs;
2568 pr_err(
"target_fabric_configfs_register() failed for SBP\n");
2572 sbp_fabric_configfs = fabric;
2577 static void sbp_deregister_configfs(
void)
2579 if (!sbp_fabric_configfs)
2583 sbp_fabric_configfs =
NULL;
2586 static int __init sbp_init(
void)
2590 ret = sbp_register_configfs();
2597 static void sbp_exit(
void)
2599 sbp_deregister_configfs();