RDMA/ocrdma: Handle Ethernet L2 parameters for IP based GID addressing
authorMoni Shoua <monis@mellanox.com>
Thu, 12 Dec 2013 16:03:15 +0000 (18:03 +0200)
committerRoland Dreier <roland@purestorage.com>
Sun, 19 Jan 2014 23:13:58 +0000 (15:13 -0800)
This patch is similar in spirit to the "IB/mlx4: Handle Ethernet L2
parameters for IP based GID addressing".  It handles the fact that IP
based RoCE gids don't store Ethernet L2 parameters, MAC and VLAN.

When building an address handle, instead of parsing the dgid to
get the MAC and VLAN, take them from the address handle attributes.

Cc: Naresh Gottumukkala <bgottumukkala@emulex.com>
Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/ocrdma/ocrdma.h
drivers/infiniband/hw/ocrdma/ocrdma_ah.c
drivers/infiniband/hw/ocrdma/ocrdma_hw.c
drivers/infiniband/hw/ocrdma/ocrdma_hw.h

index 294dd27..7c001b9 100644 (file)
@@ -423,5 +423,17 @@ static inline int is_cqe_wr_imm(struct ocrdma_cqe *cqe)
                OCRDMA_CQE_WRITE_IMM) ? 1 : 0;
 }
 
+static inline int ocrdma_resolve_dmac(struct ocrdma_dev *dev,
+               struct ib_ah_attr *ah_attr, u8 *mac_addr)
+{
+       struct in6_addr in6;
+
+       memcpy(&in6, ah_attr->grh.dgid.raw, sizeof(in6));
+       if (rdma_is_multicast_addr(&in6))
+               rdma_get_mcast_mac(&in6, mac_addr);
+       else
+               memcpy(mac_addr, ah_attr->dmac, ETH_ALEN);
+       return 0;
+}
 
 #endif
index ee499d9..bbb7962 100644 (file)
@@ -49,7 +49,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
 
        ah->sgid_index = attr->grh.sgid_index;
 
-       vlan_tag = rdma_get_vlan_id(&attr->grh.dgid);
+       vlan_tag = attr->vlan_id;
        if (!vlan_tag || (vlan_tag > 0xFFF))
                vlan_tag = dev->pvid;
        if (vlan_tag && (vlan_tag < 0x1000)) {
@@ -64,7 +64,8 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
                eth_sz = sizeof(struct ocrdma_eth_basic);
        }
        memcpy(&eth.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN);
-       status = ocrdma_resolve_dgid(dev, &attr->grh.dgid, &eth.dmac[0]);
+       memcpy(&eth.dmac[0], attr->dmac, ETH_ALEN);
+       status = ocrdma_resolve_dmac(dev, attr, &eth.dmac[0]);
        if (status)
                return status;
        status = ocrdma_query_gid(&dev->ibdev, 1, attr->grh.sgid_index,
index 56bf32f..1664d64 100644 (file)
@@ -2076,23 +2076,6 @@ mbx_err:
        return status;
 }
 
-int ocrdma_resolve_dgid(struct ocrdma_dev *dev, union ib_gid *dgid,
-                       u8 *mac_addr)
-{
-       struct in6_addr in6;
-
-       memcpy(&in6, dgid, sizeof in6);
-       if (rdma_is_multicast_addr(&in6)) {
-               rdma_get_mcast_mac(&in6, mac_addr);
-       } else if (rdma_link_local_addr(&in6)) {
-               rdma_get_ll_mac(&in6, mac_addr);
-       } else {
-               pr_err("%s() fail to resolve mac_addr.\n", __func__);
-               return -EINVAL;
-       }
-       return 0;
-}
-
 static int ocrdma_set_av_params(struct ocrdma_qp *qp,
                                struct ocrdma_modify_qp *cmd,
                                struct ib_qp_attr *attrs)
@@ -2126,14 +2109,14 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
 
        qp->sgid_idx = ah_attr->grh.sgid_index;
        memcpy(&cmd->params.sgid[0], &sgid.raw[0], sizeof(cmd->params.sgid));
-       ocrdma_resolve_dgid(qp->dev, &ah_attr->grh.dgid, &mac_addr[0]);
+       ocrdma_resolve_dmac(qp->dev, ah_attr, &mac_addr[0]);
        cmd->params.dmac_b0_to_b3 = mac_addr[0] | (mac_addr[1] << 8) |
                                (mac_addr[2] << 16) | (mac_addr[3] << 24);
        /* convert them to LE format. */
        ocrdma_cpu_to_le32(&cmd->params.dgid[0], sizeof(cmd->params.dgid));
        ocrdma_cpu_to_le32(&cmd->params.sgid[0], sizeof(cmd->params.sgid));
        cmd->params.vlan_dmac_b4_to_b5 = mac_addr[4] | (mac_addr[5] << 8);
-       vlan_id = rdma_get_vlan_id(&sgid);
+       vlan_id = ah_attr->vlan_id;
        if (vlan_id && (vlan_id < 0x1000)) {
                cmd->params.vlan_dmac_b4_to_b5 |=
                    vlan_id << OCRDMA_QP_PARAMS_VLAN_SHIFT;
index f2a89d4..82fe332 100644 (file)
@@ -94,7 +94,6 @@ void ocrdma_ring_cq_db(struct ocrdma_dev *, u16 cq_id, bool armed,
 int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed);
 int ocrdma_query_config(struct ocrdma_dev *,
                        struct ocrdma_mbx_query_config *config);
-int ocrdma_resolve_dgid(struct ocrdma_dev *, union ib_gid *dgid, u8 *mac_addr);
 
 int ocrdma_mbx_alloc_pd(struct ocrdma_dev *, struct ocrdma_pd *);
 int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *, struct ocrdma_pd *);