]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
IB/core: Add ability for drivers to report an alternate MAD size.
authorIra Weiny <ira.weiny@intel.com>
Sat, 6 Jun 2015 18:38:29 +0000 (14:38 -0400)
committerDoug Ledford <dledford@redhat.com>
Fri, 12 Jun 2015 18:49:17 +0000 (14:49 -0400)
Add max MAD size to the device immutable data set and have all drivers that
support MADs report the current IB MAD size (IB_MGMT_MAD_SIZE) to the core.

Verify MAD size data in both the MAD core and when reading the immutable data.

OPA drivers will report alternate MAD sizes in subsequent patches.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/device.c
drivers/infiniband/core/mad.c
drivers/infiniband/hw/ehca/ehca_main.c
drivers/infiniband/hw/ipath/ipath_verbs.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mthca/mthca_provider.c
drivers/infiniband/hw/ocrdma/ocrdma_main.c
drivers/infiniband/hw/qib/qib_verbs.c
include/rdma/ib_mad.h
include/rdma/ib_verbs.h

index 694bd669b2d8b8c5ca7a553b7e3f4b5734560a51..9567756ca4f9f9024032adcc0211938583e96066 100644 (file)
@@ -211,6 +211,12 @@ static int add_client_context(struct ib_device *device, struct ib_client *client
        return 0;
 }
 
+static int verify_immutable(const struct ib_device *dev, u8 port)
+{
+       return WARN_ON(!rdma_cap_ib_mad(dev, port) &&
+                           rdma_max_mad_size(dev, port) != 0);
+}
+
 static int read_port_immutable(struct ib_device *device)
 {
        int ret = -ENOMEM;
@@ -236,6 +242,11 @@ static int read_port_immutable(struct ib_device *device)
                                                 &device->port_immutable[port]);
                if (ret)
                        goto err;
+
+               if (verify_immutable(device, port)) {
+                       ret = -EINVAL;
+                       goto err;
+               }
        }
 
        ret = 0;
index b6d56e97bbaf32bc3301d94da79c4ed24c363b6e..c3452fc54e8887487faf0629daf1d85c64b0697a 100644 (file)
@@ -2939,6 +2939,9 @@ static int ib_mad_port_open(struct ib_device *device,
        int has_smi;
        struct ib_cq_init_attr cq_attr = {};
 
+       if (WARN_ON(rdma_max_mad_size(device, port_num) < IB_MGMT_MAD_SIZE))
+               return -EFAULT;
+
        /* Create new device info */
        port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL);
        if (!port_priv) {
index c0e45a46504bcb545cda89266851fdfdb2f23498..8246418cd4e085352f31954dc876c303a0b10daa 100644 (file)
@@ -46,6 +46,7 @@
 
 #include <linux/notifier.h>
 #include <linux/memory.h>
+#include <rdma/ib_mad.h>
 #include "ehca_classes.h"
 #include "ehca_iverbs.h"
 #include "ehca_mrmw.h"
@@ -444,6 +445,7 @@ static int ehca_port_immutable(struct ib_device *ibdev, u8 port_num,
        immutable->pkey_tbl_len = attr.pkey_tbl_len;
        immutable->gid_tbl_len = attr.gid_tbl_len;
        immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
+       immutable->max_mad_size = IB_MGMT_MAD_SIZE;
 
        return 0;
 }
index 78af73c62916d8ad875a01558187efb5e34eb61c..48253b839a6f741535c11a93cce685e2cce37901 100644 (file)
@@ -1996,6 +1996,7 @@ static int ipath_port_immutable(struct ib_device *ibdev, u8 port_num,
        immutable->pkey_tbl_len = attr.pkey_tbl_len;
        immutable->gid_tbl_len = attr.gid_tbl_len;
        immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
+       immutable->max_mad_size = IB_MGMT_MAD_SIZE;
 
        return 0;
 }
index 67979ea1453ac96e72d5950949853f3336664f02..166da787780c9b19f23fb5355b0dec273020cab6 100644 (file)
@@ -2189,6 +2189,8 @@ static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num,
        else
                immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE;
 
+       immutable->max_mad_size = IB_MGMT_MAD_SIZE;
+
        return 0;
 }
 
index 5803859d3f7666c70a552765bca304c2256a6991..c6cb26e0c8669bb1138562adf818b626cf2394c3 100644 (file)
@@ -1203,6 +1203,7 @@ static int mlx5_port_immutable(struct ib_device *ibdev, u8 port_num,
        immutable->pkey_tbl_len = attr.pkey_tbl_len;
        immutable->gid_tbl_len = attr.gid_tbl_len;
        immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
+       immutable->max_mad_size = IB_MGMT_MAD_SIZE;
 
        return 0;
 }
index d6d7c164cc2d2890786db74982f1a599a5094e5b..93ae51dcf2ffaefb715363e2706855e66f1ce41b 100644 (file)
@@ -1264,6 +1264,7 @@ static int mthca_port_immutable(struct ib_device *ibdev, u8 port_num,
        immutable->pkey_tbl_len = attr.pkey_tbl_len;
        immutable->gid_tbl_len = attr.gid_tbl_len;
        immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
+       immutable->max_mad_size = IB_MGMT_MAD_SIZE;
 
        return 0;
 }
index f552898693579c60609c7aee65cf9ad844542133..8a1398b253a2bec42f2d0032e0aa915ce747bfd9 100644 (file)
@@ -30,6 +30,7 @@
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_user_verbs.h>
 #include <rdma/ib_addr.h>
+#include <rdma/ib_mad.h>
 
 #include <linux/netdevice.h>
 #include <net/addrconf.h>
@@ -215,6 +216,7 @@ static int ocrdma_port_immutable(struct ib_device *ibdev, u8 port_num,
        immutable->pkey_tbl_len = attr.pkey_tbl_len;
        immutable->gid_tbl_len = attr.gid_tbl_len;
        immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE;
+       immutable->max_mad_size = IB_MGMT_MAD_SIZE;
 
        return 0;
 }
index e1dad4558ed13cbf206c7a8452a91ac2c70d5b77..a05d1a372208a11f837bc10564fa51aec1fb7ab6 100644 (file)
@@ -2055,6 +2055,7 @@ static int qib_port_immutable(struct ib_device *ibdev, u8 port_num,
        immutable->pkey_tbl_len = attr.pkey_tbl_len;
        immutable->gid_tbl_len = attr.gid_tbl_len;
        immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
+       immutable->max_mad_size = IB_MGMT_MAD_SIZE;
 
        return 0;
 }
index bf03ce07c31651b526e668076e6e6bcb73519f41..349880696abc4731807d5b41840d5c1a7e16ba4d 100644 (file)
@@ -135,6 +135,7 @@ enum {
        IB_MGMT_SA_DATA = 200,
        IB_MGMT_DEVICE_HDR = 64,
        IB_MGMT_DEVICE_DATA = 192,
+       IB_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + IB_MGMT_MAD_DATA,
 };
 
 struct ib_mad_hdr {
index b02778812729e8a920aa0fb084241060f67944ad..75c349969b6ecbfceccbb47ef88cc79b4c1781ca 100644 (file)
@@ -1534,6 +1534,7 @@ struct ib_port_immutable {
        int                           pkey_tbl_len;
        int                           gid_tbl_len;
        u32                           core_cap_flags;
+       u32                           max_mad_size;
 };
 
 struct ib_device {
@@ -2052,6 +2053,23 @@ static inline bool rdma_cap_read_multi_sge(struct ib_device *device,
        return !(device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IWARP);
 }
 
+/**
+ * rdma_max_mad_size - Return the max MAD size required by this RDMA Port.
+ *
+ * @device: Device
+ * @port_num: Port number
+ *
+ * This MAD size includes the MAD headers and MAD payload.  No other headers
+ * are included.
+ *
+ * Return the max MAD size required by the Port.  Will return 0 if the port
+ * does not support MADs
+ */
+static inline size_t rdma_max_mad_size(const struct ib_device *device, u8 port_num)
+{
+       return device->port_immutable[port_num].max_mad_size;
+}
+
 int ib_query_gid(struct ib_device *device,
                 u8 port_num, int index, union ib_gid *gid);