@@ -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);