RDMA/ocrdma: Export udp encapsulation capability
authorSomnath Kotur <somnath.kotur@avagotech.com>
Thu, 28 Jan 2016 13:59:56 +0000 (08:59 -0500)
committerDoug Ledford <dledford@redhat.com>
Mon, 29 Feb 2016 22:12:10 +0000 (17:12 -0500)
Add support to read device configuration and initialize port-immutables
to report UDP-Encap flag during port query.

Signed-off-by: Devesh Sharma <devesh.sharma@avagotech.com>
Signed-off-by: Somnath Kotur <somnath.kotur@avagotech.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/ocrdma/ocrdma.h
drivers/infiniband/hw/ocrdma/ocrdma_hw.c
drivers/infiniband/hw/ocrdma/ocrdma_main.c
drivers/infiniband/hw/ocrdma/ocrdma_sli.h

index 12503f15fbd6b29830dee04d81f8fd4082319be2..b58833d9b909330e127c57e5fc05f1867b8be00b 100644 (file)
@@ -114,6 +114,7 @@ struct ocrdma_dev_attr {
        u8 local_ca_ack_delay;
        u8 ird;
        u8 num_ird_pages;
+       u8 udp_encap;
 };
 
 struct ocrdma_dma_mem {
@@ -598,4 +599,10 @@ static inline u8 ocrdma_get_ae_link_state(u32 ae_state)
        return ((ae_state & OCRDMA_AE_LSC_LS_MASK) >> OCRDMA_AE_LSC_LS_SHIFT);
 }
 
+static inline bool ocrdma_is_udp_encap_supported(struct ocrdma_dev *dev)
+{
+       return (dev->attr.udp_encap & OCRDMA_L3_TYPE_IPV4) ||
+              (dev->attr.udp_encap & OCRDMA_L3_TYPE_IPV6);
+}
+
 #endif
index 283ca842ff7498b308fcec85a1268dcb452d56b0..aea7f17619073bd01a9438d531dddea78a1b49c6 100644 (file)
@@ -1144,6 +1144,9 @@ static void ocrdma_get_attr(struct ocrdma_dev *dev,
        attr->max_pd =
            (rsp->max_pd_ca_ack_delay & OCRDMA_MBX_QUERY_CFG_MAX_PD_MASK) >>
            OCRDMA_MBX_QUERY_CFG_MAX_PD_SHIFT;
+       attr->udp_encap = (rsp->max_pd_ca_ack_delay &
+                          OCRDMA_MBX_QUERY_CFG_L3_TYPE_MASK) >>
+                          OCRDMA_MBX_QUERY_CFG_L3_TYPE_SHIFT;
        attr->max_dpp_pds =
           (rsp->max_dpp_pds_credits & OCRDMA_MBX_QUERY_CFG_MAX_DPP_PDS_MASK) >>
            OCRDMA_MBX_QUERY_CFG_MAX_DPP_PDS_OFFSET;
index f38743018cb454bca0e42440ebd27071e16a1ffe..3d75f65ce87e207bf958b44fe3beb98f7666f6ea 100644 (file)
@@ -89,8 +89,10 @@ static int ocrdma_port_immutable(struct ib_device *ibdev, u8 port_num,
                                 struct ib_port_immutable *immutable)
 {
        struct ib_port_attr attr;
+       struct ocrdma_dev *dev;
        int err;
 
+       dev = get_ocrdma_dev(ibdev);
        err = ocrdma_query_port(ibdev, port_num, &attr);
        if (err)
                return err;
@@ -98,6 +100,8 @@ 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;
+       if (ocrdma_is_udp_encap_supported(dev))
+               immutable->core_cap_flags |= RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP;
        immutable->max_mad_size = IB_MGMT_MAD_SIZE;
 
        return 0;
index 99dd6fdf06d7b44bcea2f0fb28b90edf54aefcc0..8d75bd4a46ffd8bd54ad917d0fa49dfd32783464 100644 (file)
@@ -140,7 +140,11 @@ enum {
        OCRDMA_DB_RQ_SHIFT              = 24
 };
 
-#define OCRDMA_ROUDP_FLAGS_SHIFT       0x03
+enum {
+       OCRDMA_L3_TYPE_IB_GRH   = 0x00,
+       OCRDMA_L3_TYPE_IPV4     = 0x01,
+       OCRDMA_L3_TYPE_IPV6     = 0x02
+};
 
 #define OCRDMA_DB_CQ_RING_ID_MASK       0x3FF  /* bits 0 - 9 */
 #define OCRDMA_DB_CQ_RING_ID_EXT_MASK  0x0C00  /* bits 10-11 of qid at 12-11 */
@@ -546,7 +550,8 @@ enum {
        OCRDMA_MBX_QUERY_CFG_CA_ACK_DELAY_SHIFT         = 8,
        OCRDMA_MBX_QUERY_CFG_CA_ACK_DELAY_MASK          = 0xFF <<
                                OCRDMA_MBX_QUERY_CFG_CA_ACK_DELAY_SHIFT,
-
+       OCRDMA_MBX_QUERY_CFG_L3_TYPE_SHIFT              = 3,
+       OCRDMA_MBX_QUERY_CFG_L3_TYPE_MASK               = 0x18,
        OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT         = 0,
        OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK          = 0xFFFF,
        OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_SHIFT        = 16,