]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
rdma_cm: add rdma_reject_msg() helper function
authorSteve Wise <swise@opengridcomputing.com>
Wed, 26 Oct 2016 19:36:40 +0000 (12:36 -0700)
committerDoug Ledford <dledford@redhat.com>
Wed, 14 Dec 2016 16:38:28 +0000 (11:38 -0500)
rdma_reject_msg() returns a pointer to a string message associated with
the transport reject reason codes.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/cm.c
drivers/infiniband/core/cma.c
drivers/infiniband/core/iwcm.c
include/rdma/ib_cm.h
include/rdma/iw_cm.h
include/rdma/rdma_cm.h

index c99525512b3434d24a7882d4f869f6e675da44b2..6c64d0ce64b33b91408e70f5027861a52b49bc3c 100644 (file)
@@ -57,6 +57,54 @@ MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("InfiniBand CM");
 MODULE_LICENSE("Dual BSD/GPL");
 
+static const char * const ibcm_rej_reason_strs[] = {
+       [IB_CM_REJ_NO_QP]                       = "no QP",
+       [IB_CM_REJ_NO_EEC]                      = "no EEC",
+       [IB_CM_REJ_NO_RESOURCES]                = "no resources",
+       [IB_CM_REJ_TIMEOUT]                     = "timeout",
+       [IB_CM_REJ_UNSUPPORTED]                 = "unsupported",
+       [IB_CM_REJ_INVALID_COMM_ID]             = "invalid comm ID",
+       [IB_CM_REJ_INVALID_COMM_INSTANCE]       = "invalid comm instance",
+       [IB_CM_REJ_INVALID_SERVICE_ID]          = "invalid service ID",
+       [IB_CM_REJ_INVALID_TRANSPORT_TYPE]      = "invalid transport type",
+       [IB_CM_REJ_STALE_CONN]                  = "stale conn",
+       [IB_CM_REJ_RDC_NOT_EXIST]               = "RDC not exist",
+       [IB_CM_REJ_INVALID_GID]                 = "invalid GID",
+       [IB_CM_REJ_INVALID_LID]                 = "invalid LID",
+       [IB_CM_REJ_INVALID_SL]                  = "invalid SL",
+       [IB_CM_REJ_INVALID_TRAFFIC_CLASS]       = "invalid traffic class",
+       [IB_CM_REJ_INVALID_HOP_LIMIT]           = "invalid hop limit",
+       [IB_CM_REJ_INVALID_PACKET_RATE]         = "invalid packet rate",
+       [IB_CM_REJ_INVALID_ALT_GID]             = "invalid alt GID",
+       [IB_CM_REJ_INVALID_ALT_LID]             = "invalid alt LID",
+       [IB_CM_REJ_INVALID_ALT_SL]              = "invalid alt SL",
+       [IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS]   = "invalid alt traffic class",
+       [IB_CM_REJ_INVALID_ALT_HOP_LIMIT]       = "invalid alt hop limit",
+       [IB_CM_REJ_INVALID_ALT_PACKET_RATE]     = "invalid alt packet rate",
+       [IB_CM_REJ_PORT_CM_REDIRECT]            = "port CM redirect",
+       [IB_CM_REJ_PORT_REDIRECT]               = "port redirect",
+       [IB_CM_REJ_INVALID_MTU]                 = "invalid MTU",
+       [IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES] = "insufficient resp resources",
+       [IB_CM_REJ_CONSUMER_DEFINED]            = "consumer defined",
+       [IB_CM_REJ_INVALID_RNR_RETRY]           = "invalid RNR retry",
+       [IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID]     = "duplicate local comm ID",
+       [IB_CM_REJ_INVALID_CLASS_VERSION]       = "invalid class version",
+       [IB_CM_REJ_INVALID_FLOW_LABEL]          = "invalid flow label",
+       [IB_CM_REJ_INVALID_ALT_FLOW_LABEL]      = "invalid alt flow label",
+};
+
+const char *__attribute_const__ ibcm_reject_msg(int reason)
+{
+       size_t index = reason;
+
+       if (index < ARRAY_SIZE(ibcm_rej_reason_strs) &&
+           ibcm_rej_reason_strs[index])
+               return ibcm_rej_reason_strs[index];
+       else
+               return "unrecognized reason";
+}
+EXPORT_SYMBOL(ibcm_reject_msg);
+
 static void cm_add_one(struct ib_device *device);
 static void cm_remove_one(struct ib_device *device, void *client_data);
 
index 36bf50ebb187eb40195f0ede0d2d3abcc47d8ccb..877e4dc9e382bd4d3a1b6f9bbdd5829d599a232b 100644 (file)
@@ -101,6 +101,20 @@ const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event)
 }
 EXPORT_SYMBOL(rdma_event_msg);
 
+const char *__attribute_const__ rdma_reject_msg(struct rdma_cm_id *id,
+                                               int reason)
+{
+       if (rdma_ib_or_roce(id->device, id->port_num))
+               return ibcm_reject_msg(reason);
+
+       if (rdma_protocol_iwarp(id->device, id->port_num))
+               return iwcm_reject_msg(reason);
+
+       WARN_ON_ONCE(1);
+       return "unrecognized transport";
+}
+EXPORT_SYMBOL(rdma_reject_msg);
+
 static void cma_add_one(struct ib_device *device);
 static void cma_remove_one(struct ib_device *device, void *client_data);
 
index 5495e22839a7eb4f2c96d44e8dfb9b1531661446..31661b5c1743649b47ba6b398c16b327e53a64ed 100644 (file)
@@ -59,6 +59,27 @@ MODULE_AUTHOR("Tom Tucker");
 MODULE_DESCRIPTION("iWARP CM");
 MODULE_LICENSE("Dual BSD/GPL");
 
+static const char * const iwcm_rej_reason_strs[] = {
+       [ECONNRESET]                    = "reset by remote host",
+       [ECONNREFUSED]                  = "refused by remote application",
+       [ETIMEDOUT]                     = "setup timeout",
+};
+
+const char *__attribute_const__ iwcm_reject_msg(int reason)
+{
+       size_t index;
+
+       /* iWARP uses negative errnos */
+       index = -reason;
+
+       if (index < ARRAY_SIZE(iwcm_rej_reason_strs) &&
+           iwcm_rej_reason_strs[index])
+               return iwcm_rej_reason_strs[index];
+       else
+               return "unrecognized reason";
+}
+EXPORT_SYMBOL(iwcm_reject_msg);
+
 static struct ibnl_client_cbs iwcm_nl_cb_table[] = {
        [RDMA_NL_IWPM_REG_PID] = {.dump = iwpm_register_pid_cb},
        [RDMA_NL_IWPM_ADD_MAPPING] = {.dump = iwpm_add_mapping_cb},
index 92a7d85917b4db3eeb73722b82c4e8335e489097..b49258b16f4ed5610cbb38b29d84f5c617afddb9 100644 (file)
@@ -603,4 +603,10 @@ struct ib_cm_sidr_rep_param {
 int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
                        struct ib_cm_sidr_rep_param *param);
 
+/**
+ * ibcm_reject_msg - return a pointer to a reject message string.
+ * @reason: Value returned in the REJECT event status field.
+ */
+const char *__attribute_const__ ibcm_reject_msg(int reason);
+
 #endif /* IB_CM_H */
index 6d0065c322b706aaad7ac34703834f12e42ea39d..5cd7701db1487e8017794edb195bb0829dc3bc15 100644 (file)
@@ -253,4 +253,10 @@ int iw_cm_disconnect(struct iw_cm_id *cm_id, int abrupt);
 int iw_cm_init_qp_attr(struct iw_cm_id *cm_id, struct ib_qp_attr *qp_attr,
                       int *qp_attr_mask);
 
+/**
+ * iwcm_reject_msg - return a pointer to a reject message string.
+ * @reason: Value returned in the REJECT event status field.
+ */
+const char *__attribute_const__ iwcm_reject_msg(int reason);
+
 #endif /* IW_CM_H */
index 81fb1d15e8bb1b64d6fa7b9ba4f5eb095604738b..f11a768be06ba97cb5545096b144db75e11197fe 100644 (file)
@@ -388,4 +388,12 @@ int rdma_set_afonly(struct rdma_cm_id *id, int afonly);
  */
 __be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr);
 
+/**
+ * rdma_reject_msg - return a pointer to a reject message string.
+ * @id: Communication identifier that received the REJECT event.
+ * @reason: Value returned in the REJECT event status field.
+ */
+const char *__attribute_const__ rdma_reject_msg(struct rdma_cm_id *id,
+                                               int reason);
+
 #endif /* RDMA_CM_H */