Skip to content

Commit e70beee

Browse files
author
Nicholas Bellinger
committed
target: Pass in transport supported PI at session initialization
In order to support local WRITE_INSERT + READ_STRIP operations for non PI enabled fabrics, the fabric driver needs to be able signal what protection offload operations are supported. This is done at session initialization time so the modes can be signaled by individual se_wwn + se_portal_group endpoints, as well as optionally across different transports on the same endpoint. For iser-target, set TARGET_PROT_ALL if the underlying ib_device has already signaled PI offload support, and allow this to be exposed via a new iscsit_transport->iscsit_get_sup_prot_ops() callback. For loopback, set TARGET_PROT_ALL to signal SCSI initiator mode operation. For all other drivers, set TARGET_PROT_NORMAL to disable fabric level PI. Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Sagi Grimberg <sagig@mellanox.com> Cc: Or Gerlitz <ogerlitz@mellanox.com> Cc: Quinn Tran <quinn.tran@qlogic.com> Cc: Giridhar Malavali <giridhar.malavali@qlogic.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent d84287b commit e70beee

14 files changed

Lines changed: 52 additions & 20 deletions

File tree

‎drivers/infiniband/ulp/isert/ib_isert.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,18 @@ isert_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
21962196
device->unreg_rdma_mem(isert_cmd, isert_conn);
21972197
}
21982198

2199+
static enum target_prot_op
2200+
isert_get_sup_prot_ops(struct iscsi_conn *conn)
2201+
{
2202+
struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
2203+
struct isert_device *device = isert_conn->conn_device;
2204+
2205+
if (device->pi_capable)
2206+
return TARGET_PROT_ALL;
2207+
2208+
return TARGET_PROT_NORMAL;
2209+
}
2210+
21992211
static int
22002212
isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
22012213
bool nopout_response)
@@ -3252,6 +3264,7 @@ static struct iscsit_transport iser_target_transport = {
32523264
.iscsit_queue_data_in = isert_put_datain,
32533265
.iscsit_queue_status = isert_put_response,
32543266
.iscsit_aborted_task = isert_aborted_task,
3267+
.iscsit_get_sup_prot_ops = isert_get_sup_prot_ops,
32553268
};
32563269

32573270
static int __init isert_init(void)

‎drivers/infiniband/ulp/srpt/ib_srpt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2580,7 +2580,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
25802580
goto destroy_ib;
25812581
}
25822582

2583-
ch->sess = transport_init_session();
2583+
ch->sess = transport_init_session(TARGET_PROT_NORMAL);
25842584
if (IS_ERR(ch->sess)) {
25852585
rej->reason = __constant_cpu_to_be32(
25862586
SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);

‎drivers/scsi/qla2xxx/tcm_qla2xxx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ static int tcm_qla2xxx_check_initiator_node_acl(
14821482
}
14831483
se_tpg = &tpg->se_tpg;
14841484

1485-
se_sess = transport_init_session();
1485+
se_sess = transport_init_session(TARGET_PROT_NORMAL);
14861486
if (IS_ERR(se_sess)) {
14871487
pr_err("Unable to initialize struct se_session\n");
14881488
return PTR_ERR(se_sess);

‎drivers/target/iscsi/iscsi_target.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ static void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
511511
__iscsit_free_cmd(cmd, scsi_cmd, true);
512512
}
513513

514+
static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsi_conn *conn)
515+
{
516+
return TARGET_PROT_NORMAL;
517+
}
518+
514519
static struct iscsit_transport iscsi_target_transport = {
515520
.name = "iSCSI/TCP",
516521
.transport_type = ISCSI_TCP,
@@ -526,6 +531,7 @@ static struct iscsit_transport iscsi_target_transport = {
526531
.iscsit_queue_data_in = iscsit_queue_rsp,
527532
.iscsit_queue_status = iscsit_queue_rsp,
528533
.iscsit_aborted_task = iscsit_aborted_task,
534+
.iscsit_get_sup_prot_ops = iscsit_get_sup_prot_ops,
529535
};
530536

531537
static int __init iscsi_target_init_module(void)

‎drivers/target/iscsi/iscsi_target_login.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ static int iscsi_login_zero_tsih_s1(
259259
{
260260
struct iscsi_session *sess = NULL;
261261
struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
262+
enum target_prot_op sup_pro_ops;
262263
int ret;
263264

264265
sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL);
@@ -320,8 +321,9 @@ static int iscsi_login_zero_tsih_s1(
320321
kfree(sess);
321322
return -ENOMEM;
322323
}
324+
sup_pro_ops = conn->conn_transport->iscsit_get_sup_prot_ops(conn);
323325

324-
sess->se_sess = transport_init_session();
326+
sess->se_sess = transport_init_session(sup_pro_ops);
325327
if (IS_ERR(sess->se_sess)) {
326328
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
327329
ISCSI_LOGIN_STATUS_NO_RESOURCES);

‎drivers/target/loopback/tcm_loop.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ static int tcm_loop_make_nexus(
10181018
/*
10191019
* Initialize the struct se_session pointer
10201020
*/
1021-
tl_nexus->se_sess = transport_init_session();
1021+
tl_nexus->se_sess = transport_init_session(TARGET_PROT_ALL);
10221022
if (IS_ERR(tl_nexus->se_sess)) {
10231023
ret = PTR_ERR(tl_nexus->se_sess);
10241024
goto out;

‎drivers/target/sbp/sbp_target.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static struct sbp_session *sbp_session_create(
210210
return ERR_PTR(-ENOMEM);
211211
}
212212

213-
sess->se_sess = transport_init_session();
213+
sess->se_sess = transport_init_session(TARGET_PROT_NORMAL);
214214
if (IS_ERR(sess->se_sess)) {
215215
pr_err("failed to init se_session\n");
216216

‎drivers/target/target_core_transport.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void transport_subsystem_check_init(void)
235235
sub_api_initialized = 1;
236236
}
237237

238-
struct se_session *transport_init_session(void)
238+
struct se_session *transport_init_session(enum target_prot_op sup_prot_ops)
239239
{
240240
struct se_session *se_sess;
241241

@@ -251,6 +251,7 @@ struct se_session *transport_init_session(void)
251251
INIT_LIST_HEAD(&se_sess->sess_wait_list);
252252
spin_lock_init(&se_sess->sess_cmd_lock);
253253
kref_init(&se_sess->sess_kref);
254+
se_sess->sup_prot_ops = sup_prot_ops;
254255

255256
return se_sess;
256257
}
@@ -288,12 +289,13 @@ int transport_alloc_session_tags(struct se_session *se_sess,
288289
EXPORT_SYMBOL(transport_alloc_session_tags);
289290

290291
struct se_session *transport_init_session_tags(unsigned int tag_num,
291-
unsigned int tag_size)
292+
unsigned int tag_size,
293+
enum target_prot_op sup_prot_ops)
292294
{
293295
struct se_session *se_sess;
294296
int rc;
295297

296-
se_sess = transport_init_session();
298+
se_sess = transport_init_session(sup_prot_ops);
297299
if (IS_ERR(se_sess))
298300
return se_sess;
299301

‎drivers/target/tcm_fc/tfc_sess.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
211211
return NULL;
212212

213213
sess->se_sess = transport_init_session_tags(TCM_FC_DEFAULT_TAGS,
214-
sizeof(struct ft_cmd));
214+
sizeof(struct ft_cmd),
215+
TARGET_PROT_NORMAL);
215216
if (IS_ERR(sess->se_sess)) {
216217
kfree(sess);
217218
return NULL;

‎drivers/usb/gadget/tcm_usb_gadget.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ static int tcm_usbg_make_nexus(struct usbg_tpg *tpg, char *name)
17311731
pr_err("Unable to allocate struct tcm_vhost_nexus\n");
17321732
goto err_unlock;
17331733
}
1734-
tv_nexus->tvn_se_sess = transport_init_session();
1734+
tv_nexus->tvn_se_sess = transport_init_session(TARGET_PROT_NORMAL);
17351735
if (IS_ERR(tv_nexus->tvn_se_sess))
17361736
goto err_free;
17371737

0 commit comments

Comments
 (0)