OSDN Git Service

iscsi,iser-target: Expose supported protection ops according to t10_pi
[android-x86/kernel.git] / drivers / infiniband / ulp / isert / ib_isert.c
index 618c815..a6daabc 100644 (file)
@@ -64,7 +64,7 @@ struct rdma_cm_id *isert_setup_id(struct isert_np *isert_np);
 static inline bool
 isert_prot_cmd(struct isert_conn *conn, struct se_cmd *cmd)
 {
-       return (conn->conn_device->pi_capable &&
+       return (conn->pi_support &&
                cmd->prot_op != TARGET_PROT_NORMAL);
 }
 
@@ -2324,8 +2324,16 @@ isert_get_sup_prot_ops(struct iscsi_conn *conn)
        struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
        struct isert_device *device = isert_conn->conn_device;
 
-       if (device->pi_capable)
-               return TARGET_PROT_ALL;
+       if (conn->tpg->tpg_attrib.t10_pi) {
+               if (device->pi_capable) {
+                       pr_info("conn %p PI offload enabled\n", isert_conn);
+                       isert_conn->pi_support = true;
+                       return TARGET_PROT_ALL;
+               }
+       }
+
+       pr_info("conn %p PI offload disabled\n", isert_conn);
+       isert_conn->pi_support = false;
 
        return TARGET_PROT_NORMAL;
 }