[openib-general] Re: [PATCH] [SRP] srp_cm_handler expanded response handling
John Kingman
kingman at storagegear.com
Thu Oct 27 14:18:07 PDT 2005
On Thu, 27 Oct 2005, Roland Dreier wrote:
>Looks good, except:
>
> > + if (reason == 0x00010002)
>
>can you add enums for all these SRP_LOGIN_REJ reason codes rather than
>open-coding this magic number here?
OK.
Thanks,
John
Signed-off-by: John Kingman <kingman at storagegear.com>
Index: ib_srp.h
===================================================================
--- ib_srp.h (revision 3884)
+++ ib_srp.h (working copy)
@@ -76,6 +76,16 @@ enum srp_target_state {
SRP_TARGET_REMOVED
};
+enum srp_login_rej_reason {
+ SRP_UNABLE_ESTABLISH_CHANNEL = 0x00010000,
+ SRP_INSUFFICIENT_RESOURCES = 0x00010001,
+ SRP_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,
+ SRP_UNABLE_ASSOCIATE_CHANNEL = 0x00010003,
+ SRP_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,
+ SRP_MULTI_CHANNEL_UNSUPPORTED = 0x00010005,
+ SRP_CHANNEL_LIMIT_REACHED = 0x00010006
+};
+
struct srp_host {
u8 initiator_port_id[16];
struct ib_device *dev;
Index: ib_srp.c
===================================================================
--- ib_srp.c (revision 3883)
+++ ib_srp.c (working copy)
@@ -975,6 +975,7 @@ static int srp_cm_handler(struct ib_cm_i
struct ib_qp_attr *qp_attr = NULL;
int attr_mask = 0;
int comp = 0;
+ int rsp_opcode = 0;
switch (event->event) {
case IB_CM_REQ_ERROR:
@@ -985,17 +986,20 @@ static int srp_cm_handler(struct ib_cm_i
case IB_CM_REP_RECEIVED:
comp = 1;
+ rsp_opcode = *(u8 *) event->private_data;
- {
+ if (rsp_opcode == SRP_LOGIN_RSP) {
struct srp_login_rsp *rsp = event->private_data;
- /* XXX check that opcode is SRP RSP */
-
target->max_ti_iu_len = be32_to_cpu(rsp->max_ti_iu_len);
target->req_lim = be32_to_cpu(rsp->req_lim_delta);
target->scsi_host->can_queue = min(target->req_lim,
target->scsi_host->can_queue);
+ } else {
+ printk(KERN_WARNING PFX "Unhandled RSP opcode %#x\n", rsp_opcode);
+ target->status = -ECONNRESET;
+ break;
}
target->status = srp_alloc_iu_bufs(target);
@@ -1043,7 +1047,8 @@ static int srp_cm_handler(struct ib_cm_i
printk(KERN_DEBUG PFX "REJ received\n");
comp = 1;
- if (event->param.rej_rcvd.reason == IB_CM_REJ_PORT_CM_REDIRECT) {
+ switch (event->param.rej_rcvd.reason) {
+ case IB_CM_REJ_PORT_CM_REDIRECT:
cpi = event->param.rej_rcvd.ari;
target->path.dlid = cpi->redirect_lid;
target->path.pkey = cpi->redirect_pkey;
@@ -1052,23 +1057,52 @@ static int srp_cm_handler(struct ib_cm_i
target->status = target->path.dlid ?
SRP_DLID_REDIRECT : SRP_PORT_REDIRECT;
- } else if (topspin_workarounds &&
- !memcmp(&target->ioc_guid, topspin_oui, 3) &&
- event->param.rej_rcvd.reason == IB_CM_REJ_PORT_REDIRECT) {
- /*
- * Topspin/Cisco SRP gateways incorrectly send
- * reject reason code 25 when they mean 24
- * (port redirect).
- */
- memcpy(target->path.dgid.raw,
- event->param.rej_rcvd.ari, 16);
-
- printk(KERN_DEBUG PFX "Topspin/Cisco redirect to target port GID %016llx%016llx\n",
- (unsigned long long) be64_to_cpu(target->path.dgid.global.subnet_prefix),
- (unsigned long long) be64_to_cpu(target->path.dgid.global.interface_id));
+ break;
- target->status = SRP_PORT_REDIRECT;
- } else {
+ case IB_CM_REJ_PORT_REDIRECT:
+ if (topspin_workarounds &&
+ !memcmp(&target->ioc_guid, topspin_oui, 3)) {
+ /*
+ * Topspin/Cisco SRP gateways incorrectly send
+ * reject reason code 25 when they mean 24
+ * (port redirect).
+ */
+ memcpy(target->path.dgid.raw,
+ event->param.rej_rcvd.ari, 16);
+
+ printk(KERN_DEBUG PFX "Topspin/Cisco redirect to target port GID %016llx%016llx\n",
+ (unsigned long long) be64_to_cpu(target->path.dgid.global.subnet_prefix),
+ (unsigned long long) be64_to_cpu(target->path.dgid.global.interface_id));
+
+ target->status = SRP_PORT_REDIRECT;
+ } else {
+ printk(KERN_WARNING " REJ reason: IB_CM_REJ_PORT_REDIRECT\n");
+ target->status = -ECONNRESET;
+ }
+ break;
+
+ case IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID:
+ printk(KERN_WARNING " REJ reason: IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID\n");
+ target->status = -ECONNRESET;
+ break;
+
+ case IB_CM_REJ_CONSUMER_DEFINED:
+ if(*(u8 *) event->private_data == SRP_LOGIN_REJ) {
+ struct srp_login_rej *rej = event->private_data;
+ u32 reason = be32_to_cpu(rej->reason);
+
+ if (reason == SRP_REQ_IT_IU_LENGTH_TOO_LARGE)
+ printk(KERN_WARNING PFX
+ "SRP_LOGIN_REJ: requested max_it_iu_len too large\n");
+ else
+ printk(KERN_WARNING PFX
+ "SRP LOGIN REJECTED, reason 0x%8.8x\n", reason);
+ } else
+ printk(KERN_WARNING " REJ reason: IB_CM_REJ_CONSUMER_DEFINED\n");
+ target->status = -ECONNRESET;
+ break;
+
+ default:
printk(KERN_WARNING " REJ reason 0x%x\n",
event->param.rej_rcvd.reason);
target->status = -ECONNRESET;
More information about the general
mailing list