IB/core: Change wc.slid from 16 to 32 bits
authorHiatt, Don <don.hiatt@intel.com>
Thu, 8 Jun 2017 17:37:49 +0000 (13:37 -0400)
committerDoug Ledford <dledford@redhat.com>
Tue, 8 Aug 2017 18:50:25 +0000 (14:50 -0400)
slid field in struct ib_wc is increased to 32 bits.
This enables core components to use larger LIDs if needed.
The user ABI is unchanged and return 16 bit values when queried.

Signed-off-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Don Hiatt <don.hiatt@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/cm.c
drivers/infiniband/core/user_mad.c
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/hw/hfi1/mad.c
drivers/infiniband/hw/mlx4/mad.c
drivers/infiniband/hw/mlx5/mad.c
drivers/infiniband/hw/mthca/mthca_cmd.c
drivers/infiniband/hw/mthca/mthca_mad.c
drivers/infiniband/sw/rdmavt/cq.c
include/rdma/ib_verbs.h

index 2b4d613a347491295a51932699264c6edcd4bb51..b39ee16aa47922c44c986ddfa89fc36b05b54444 100644 (file)
@@ -1703,7 +1703,7 @@ static void cm_process_routed_req(struct cm_req_msg *req_msg, struct ib_wc *wc)
 {
        if (!cm_req_get_primary_subnet_local(req_msg)) {
                if (req_msg->primary_local_lid == IB_LID_PERMISSIVE) {
-                       req_msg->primary_local_lid = cpu_to_be16(wc->slid);
+                       req_msg->primary_local_lid = ib_slid_be16(wc->slid);
                        cm_req_set_primary_sl(req_msg, wc->sl);
                }
 
@@ -1713,7 +1713,7 @@ static void cm_process_routed_req(struct cm_req_msg *req_msg, struct ib_wc *wc)
 
        if (!cm_req_get_alt_subnet_local(req_msg)) {
                if (req_msg->alt_local_lid == IB_LID_PERMISSIVE) {
-                       req_msg->alt_local_lid = cpu_to_be16(wc->slid);
+                       req_msg->alt_local_lid = ib_slid_be16(wc->slid);
                        cm_req_set_alt_sl(req_msg, wc->sl);
                }
 
index 36a6f5c8914c2480a4a8bd6403984b2c487be5f8..ff3c67a7aaad2b9163936c8bbb25c9b709228142 100644 (file)
@@ -229,7 +229,7 @@ static void recv_handler(struct ib_mad_agent *agent,
        packet->mad.hdr.status     = 0;
        packet->mad.hdr.length     = hdr_size(file) + mad_recv_wc->mad_len;
        packet->mad.hdr.qpn        = cpu_to_be32(mad_recv_wc->wc->src_qp);
-       packet->mad.hdr.lid        = cpu_to_be16(mad_recv_wc->wc->slid);
+       packet->mad.hdr.lid        = ib_slid_be16(mad_recv_wc->wc->slid);
        packet->mad.hdr.sl         = mad_recv_wc->wc->sl;
        packet->mad.hdr.path_bits  = mad_recv_wc->wc->dlid_path_bits;
        packet->mad.hdr.pkey_index = mad_recv_wc->wc->pkey_index;
index 01e2ff0239802b72e81ea2b5b13ea0318abfcf97..eb0da3784bf46a90892b4a464722dfe458cb4836 100644 (file)
@@ -1190,7 +1190,8 @@ out:
        return ret ? ret : in_len;
 }
 
-static int copy_wc_to_user(void __user *dest, struct ib_wc *wc)
+static int copy_wc_to_user(struct ib_device *ib_dev, void __user *dest,
+                          struct ib_wc *wc)
 {
        struct ib_uverbs_wc tmp;
 
@@ -1204,7 +1205,10 @@ static int copy_wc_to_user(void __user *dest, struct ib_wc *wc)
        tmp.src_qp              = wc->src_qp;
        tmp.wc_flags            = wc->wc_flags;
        tmp.pkey_index          = wc->pkey_index;
-       tmp.slid                = wc->slid;
+       if (rdma_cap_opa_ah(ib_dev, wc->port_num))
+               tmp.slid  = OPA_TO_IB_UCAST_LID(wc->slid);
+       else
+               tmp.slid  = ib_slid_cpu16(wc->slid);
        tmp.sl                  = wc->sl;
        tmp.dlid_path_bits      = wc->dlid_path_bits;
        tmp.port_num            = wc->port_num;
@@ -1248,7 +1252,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
                if (!ret)
                        break;
 
-               ret = copy_wc_to_user(data_ptr, &wc);
+               ret = copy_wc_to_user(ib_dev, data_ptr, &wc);
                if (ret)
                        goto out_put;
 
index 5977673a52d4b7477fa315396b6d43418ca2ceb4..00ebc26cd18705ccd0cafe6a8dd4494538e0a33e 100644 (file)
@@ -3958,7 +3958,7 @@ static int opa_local_smp_check(struct hfi1_ibport *ibp,
                               const struct ib_wc *in_wc)
 {
        struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
-       u16 slid = in_wc->slid;
+       u16 slid = ib_slid_cpu16(in_wc->slid);
        u16 pkey;
 
        if (in_wc->pkey_index >= ARRAY_SIZE(ppd->pkeys))
index 00f057033cb91c15a1b596e595b892110efa00c9..04fb44e7699ea2e342d15f0b66d8dcac100ef039 100644 (file)
@@ -169,7 +169,7 @@ int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
 
                op_modifier |= 0x4;
 
-               in_modifier |= in_wc->slid << 16;
+               in_modifier |= ib_slid_cpu16(in_wc->slid) << 16;
        }
 
        err = mlx4_cmd_box(dev->dev, inmailbox->dma, outmailbox->dma, in_modifier,
@@ -625,7 +625,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
                memcpy((char *)&tun_mad->hdr.slid_mac_47_32, &(wc->smac[4]), 2);
        } else {
                tun_mad->hdr.sl_vid = cpu_to_be16(((u16)(wc->sl)) << 12);
-               tun_mad->hdr.slid_mac_47_32 = cpu_to_be16(wc->slid);
+               tun_mad->hdr.slid_mac_47_32 = ib_slid_be16(wc->slid);
        }
 
        ib_dma_sync_single_for_device(&dev->ib_dev,
@@ -826,7 +826,7 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
                }
        }
 
-       slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
+       slid = in_wc ? ib_slid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
 
        if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && slid == 0) {
                forward_trap(to_mdev(ibdev), port_num, in_mad);
index 95db929bdc34004218835724ac6f9f501caa324e..cd2264ac88ae9d12b34901aa234f25c53018dce2 100644 (file)
@@ -78,7 +78,7 @@ static int process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
        u16 slid;
        int err;
 
-       slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
+       slid = in_wc ? ib_slid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
 
        if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && slid == 0)
                return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
index 9d83a53c0c67df1ce035fba618d20257725cd486..e19ae0b9b439e640c132a5bf2dd4519e868bcd04 100644 (file)
@@ -1921,7 +1921,7 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
                        (in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0);
                MTHCA_PUT(inbox, val,               MAD_IFC_G_PATH_OFFSET);
 
-               MTHCA_PUT(inbox, in_wc->slid,       MAD_IFC_RLID_OFFSET);
+               MTHCA_PUT(inbox, ib_slid_cpu16(in_wc->slid), MAD_IFC_RLID_OFFSET);
                MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET);
 
                if (in_grh)
@@ -1929,7 +1929,7 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
 
                op_modifier |= 0x4;
 
-               in_modifier |= in_wc->slid << 16;
+               in_modifier |= ib_slid_cpu16(in_wc->slid) << 16;
        }
 
        err = mthca_cmd_box(dev, inmailbox->dma, outmailbox->dma,
index 617531f1bfc66c7327f41f58f67bc7016b96dafe..a9caadab22cfa6dd9129beeff101259d08b9f264 100644 (file)
@@ -205,7 +205,7 @@ int mthca_process_mad(struct ib_device *ibdev,
                      u16 *out_mad_pkey_index)
 {
        int err;
-       u16 slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
+       u16 slid = in_wc ? ib_slid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
        u16 prev_lid = 0;
        struct ib_port_attr pattr;
        const struct ib_mad *in_mad = (const struct ib_mad *)in;
index 0ae2ff8cf81e59ea7aea2f1cff335033ac11afbc..0335a3df74d52c372ec06ccb786693fda735c2e4 100644 (file)
@@ -107,7 +107,7 @@ void rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited)
                wc->uqueue[head].src_qp = entry->src_qp;
                wc->uqueue[head].wc_flags = entry->wc_flags;
                wc->uqueue[head].pkey_index = entry->pkey_index;
-               wc->uqueue[head].slid = entry->slid;
+               wc->uqueue[head].slid = ib_slid_cpu16(entry->slid);
                wc->uqueue[head].sl = entry->sl;
                wc->uqueue[head].dlid_path_bits = entry->dlid_path_bits;
                wc->uqueue[head].port_num = entry->port_num;
index 6205359081185d16a73ccc9d6f64ea47517425e5..7eaf7d2ab4241b3d629e111652b9000638f2b4eb 100644 (file)
@@ -948,7 +948,7 @@ struct ib_wc {
        u32                     src_qp;
        int                     wc_flags;
        u16                     pkey_index;
-       u16                     slid;
+       u32                     slid;
        u8                      sl;
        u8                      dlid_path_bits;
        u8                      port_num;       /* valid only for DR SMPs on switches */
@@ -3706,4 +3706,16 @@ static inline enum rdma_ah_attr_type rdma_ah_find_type(struct ib_device *dev,
        else
                return RDMA_AH_ATTR_TYPE_IB;
 }
+
+/* Return slid in 16bit CPU encoding */
+static inline u16 ib_slid_cpu16(u32 slid)
+{
+       return (u16)slid;
+}
+
+/* Return slid in 16bit BE encoding */
+static inline u16 ib_slid_be16(u32 slid)
+{
+       return cpu_to_be16((u16)slid);
+}
 #endif /* IB_VERBS_H */