Skip to contentSkip to conversation

srp_daemon: Use maximum initiator to target IU size

PATCH New Honggang LI 1 participant 1 message Oct 29, 2019 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 srp_daemon: Use maximum initiator to target IU size

From: Honggang Li <[email protected]>

"ib_srp.ko" module with immediate data support use (8 * 1024) as default immediate data size. When immediate data support enabled for "ib_srp.ko" client, the default maximum initiator to target IU size will greater than (8 * 1024). That means it also greater than the default maximum initiator to target IU size set by old "ib_srpt.ko" module, which does not support immediate data.

Pass remote maximum initiator to target IU size as a login parameter, when immediate data size greater than remote maximum initiator to target IU size.

This patch fixes backward compatibility for "ib_srp.ko" with [1] and old srp target does not support immediate data.

[1] 547ed331bbe8 ("RDMA/srp: Add parse function for maximum initiator to target IU size")

---
 srp_daemon/srp_daemon.c | 57 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
srp_daemon/srp_daemon.c +57 -0
index f0bcf923..b593e245 100644
@@ -402,6 +402,50 @@ static int is_enabled_by_rules_file(struct target_details *target)
 }
 
 
+static bool use_imm_data(void)
+{
+	bool ret = false;
+	char flag = 0;
+	int cnt;
+	int fd = open("/sys/module/ib_srp/parameters/use_imm_data", O_RDONLY);
+
+	if (fd < 0)
+		return false;
+	cnt = read(fd, &flag, 1);
+	if (cnt != 1) {
+		close(fd);
+		return false;
+	}
+
+	if (!strncmp(&flag, "Y", 1))
+		ret = true;
+	close(fd);
+	return ret;
+}
+
+static bool imm_data_size_gt_send_size(__be32 send_size)
+{
+	bool ret = false;
+	unsigned int srp_max_imm_data = 0;
+	unsigned int remote_max_it_ui_size = be32toh(send_size);
+	FILE *fp = fopen("/sys/module/ib_srp/parameters/max_imm_data", "r");
+	int cnt;
+
+	if (fp == NULL)
+		return ret;
+
+	cnt = fscanf(fp, "%d", &srp_max_imm_data);
+	if (cnt <= 0) {
+		fclose(fp);
+		return ret;
+	}
+
+	if (srp_max_imm_data > remote_max_it_ui_size)
+		ret = true;
+
+	fclose(fp);
+	return ret;
+}
 
 static int add_non_exist_target(struct target_details *target)
 {
@@ -581,6 +625,19 @@ static int add_non_exist_target(struct target_details *target)
 		}
 	}
 
+	if (use_imm_data() && imm_data_size_gt_send_size(target->ioc_prof.send_size)) {
+		len += snprintf(target_config_str+len,
+			sizeof(target_config_str) - len,
+			",max_it_iu_size=%d",
+			be32toh(target->ioc_prof.send_size));
+
+		if (len >= sizeof(target_config_str)) {
+			pr_err("Target config string is too long, ignoring target\n");
+			closedir(dir);
+			return -1;
+		}
+	}
+
 	target_config_str[len] = '\0';
 
 	pr_cmd(target_config_str, not_connected);
Signature · 1 line
2.21.0