Skip to content

Commit 747fe00

Browse files
bvanasscheChristoph Hellwig
authored andcommitted
IB/srp: Introduce two new srp_target_port member variables
Introduce the srp_target_port member variables 'sgid' and 'pkey'. Change the type of 'orig_dgid' from __be16[8] into union ib_gid. This patch does not change any functionality but makes the "Separate target and channel variables" patch easier to verify. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 34aa654 commit 747fe00

2 files changed

Lines changed: 26 additions & 17 deletions

File tree

‎drivers/infiniband/ulp/srp/ib_srp.c‎

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static int srp_init_qp(struct srp_target_port *target,
262262

263263
ret = ib_find_pkey(target->srp_host->srp_dev->dev,
264264
target->srp_host->port,
265-
be16_to_cpu(target->path.pkey),
265+
be16_to_cpu(target->pkey),
266266
&attr->pkey_index);
267267
if (ret)
268268
goto out;
@@ -295,6 +295,10 @@ static int srp_new_cm_id(struct srp_target_port *target)
295295
if (target->cm_id)
296296
ib_destroy_cm_id(target->cm_id);
297297
target->cm_id = new_cm_id;
298+
target->path.sgid = target->sgid;
299+
target->path.dgid = target->orig_dgid;
300+
target->path.pkey = target->pkey;
301+
target->path.service_id = target->service_id;
298302

299303
return 0;
300304
}
@@ -689,7 +693,7 @@ static int srp_send_req(struct srp_target_port *target)
689693
*/
690694
if (target->io_class == SRP_REV10_IB_IO_CLASS) {
691695
memcpy(req->priv.initiator_port_id,
692-
&target->path.sgid.global.interface_id, 8);
696+
&target->sgid.global.interface_id, 8);
693697
memcpy(req->priv.initiator_port_id + 8,
694698
&target->initiator_ext, 8);
695699
memcpy(req->priv.target_port_id, &target->ioc_guid, 8);
@@ -698,7 +702,7 @@ static int srp_send_req(struct srp_target_port *target)
698702
memcpy(req->priv.initiator_port_id,
699703
&target->initiator_ext, 8);
700704
memcpy(req->priv.initiator_port_id + 8,
701-
&target->path.sgid.global.interface_id, 8);
705+
&target->sgid.global.interface_id, 8);
702706
memcpy(req->priv.target_port_id, &target->id_ext, 8);
703707
memcpy(req->priv.target_port_id + 8, &target->ioc_guid, 8);
704708
}
@@ -2175,8 +2179,8 @@ static void srp_cm_rej_handler(struct ib_cm_id *cm_id,
21752179
else
21762180
shost_printk(KERN_WARNING, shost, PFX
21772181
"SRP LOGIN from %pI6 to %pI6 REJECTED, reason 0x%08x\n",
2178-
target->path.sgid.raw,
2179-
target->orig_dgid, reason);
2182+
target->sgid.raw,
2183+
target->orig_dgid.raw, reason);
21802184
} else
21812185
shost_printk(KERN_WARNING, shost,
21822186
" REJ reason: IB_CM_REJ_CONSUMER_DEFINED,"
@@ -2442,15 +2446,15 @@ static ssize_t show_pkey(struct device *dev, struct device_attribute *attr,
24422446
{
24432447
struct srp_target_port *target = host_to_target(class_to_shost(dev));
24442448

2445-
return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey));
2449+
return sprintf(buf, "0x%04x\n", be16_to_cpu(target->pkey));
24462450
}
24472451

24482452
static ssize_t show_sgid(struct device *dev, struct device_attribute *attr,
24492453
char *buf)
24502454
{
24512455
struct srp_target_port *target = host_to_target(class_to_shost(dev));
24522456

2453-
return sprintf(buf, "%pI6\n", target->path.sgid.raw);
2457+
return sprintf(buf, "%pI6\n", target->sgid.raw);
24542458
}
24552459

24562460
static ssize_t show_dgid(struct device *dev, struct device_attribute *attr,
@@ -2466,7 +2470,7 @@ static ssize_t show_orig_dgid(struct device *dev,
24662470
{
24672471
struct srp_target_port *target = host_to_target(class_to_shost(dev));
24682472

2469-
return sprintf(buf, "%pI6\n", target->orig_dgid);
2473+
return sprintf(buf, "%pI6\n", target->orig_dgid.raw);
24702474
}
24712475

24722476
static ssize_t show_req_lim(struct device *dev,
@@ -2804,19 +2808,23 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
28042808
}
28052809

28062810
for (i = 0; i < 16; ++i) {
2807-
strlcpy(dgid, p + i * 2, 3);
2808-
target->path.dgid.raw[i] = simple_strtoul(dgid, NULL, 16);
2811+
strlcpy(dgid, p + i * 2, sizeof(dgid));
2812+
if (sscanf(dgid, "%hhx",
2813+
&target->orig_dgid.raw[i]) < 1) {
2814+
ret = -EINVAL;
2815+
kfree(p);
2816+
goto out;
2817+
}
28092818
}
28102819
kfree(p);
2811-
memcpy(target->orig_dgid, target->path.dgid.raw, 16);
28122820
break;
28132821

28142822
case SRP_OPT_PKEY:
28152823
if (match_hex(args, &token)) {
28162824
pr_warn("bad P_Key parameter '%s'\n", p);
28172825
goto out;
28182826
}
2819-
target->path.pkey = cpu_to_be16(token);
2827+
target->pkey = cpu_to_be16(token);
28202828
break;
28212829

28222830
case SRP_OPT_SERVICE_ID:
@@ -2826,7 +2834,6 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
28262834
goto out;
28272835
}
28282836
target->service_id = cpu_to_be64(simple_strtoull(p, NULL, 16));
2829-
target->path.service_id = target->service_id;
28302837
kfree(p);
28312838
break;
28322839

@@ -3036,7 +3043,7 @@ static ssize_t srp_create_target(struct device *dev,
30363043
if (ret)
30373044
goto err_free_mem;
30383045

3039-
ret = ib_query_gid(ibdev, host->port, 0, &target->path.sgid);
3046+
ret = ib_query_gid(ibdev, host->port, 0, &target->sgid);
30403047
if (ret)
30413048
goto err_free_mem;
30423049

@@ -3064,9 +3071,9 @@ static ssize_t srp_create_target(struct device *dev,
30643071
"new target: id_ext %016llx ioc_guid %016llx pkey %04x service_id %016llx sgid %pI6 dgid %pI6\n",
30653072
be64_to_cpu(target->id_ext),
30663073
be64_to_cpu(target->ioc_guid),
3067-
be16_to_cpu(target->path.pkey),
3074+
be16_to_cpu(target->pkey),
30683075
be64_to_cpu(target->service_id),
3069-
target->path.sgid.raw, target->orig_dgid);
3076+
target->sgid.raw, target->orig_dgid.raw);
30703077
}
30713078

30723079
ret = count;

‎drivers/infiniband/ulp/srp/ib_srp.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ struct srp_target_port {
157157
* command processing. Try to keep them packed into cachelines.
158158
*/
159159

160+
union ib_gid sgid;
160161
__be64 id_ext;
161162
__be64 ioc_guid;
162163
__be64 service_id;
@@ -173,8 +174,9 @@ struct srp_target_port {
173174
int comp_vector;
174175
int tl_retry_count;
175176

177+
union ib_gid orig_dgid;
178+
__be16 pkey;
176179
struct ib_sa_path_rec path;
177-
__be16 orig_dgid[8];
178180
struct ib_sa_query *path_query;
179181
int path_query_id;
180182

0 commit comments

Comments
 (0)