aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/ocrdma/ocrdma_ah.c')
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_ah.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index 40f8536c10b0..ac02ce4e8040 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -38,7 +38,7 @@
38#define OCRDMA_VID_PCP_SHIFT 0xD 38#define OCRDMA_VID_PCP_SHIFT 0xD
39 39
40static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah, 40static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
41 struct ib_ah_attr *attr, int pdid) 41 struct ib_ah_attr *attr, union ib_gid *sgid, int pdid)
42{ 42{
43 int status = 0; 43 int status = 0;
44 u16 vlan_tag; bool vlan_enabled = false; 44 u16 vlan_tag; bool vlan_enabled = false;
@@ -49,8 +49,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
49 memset(&eth, 0, sizeof(eth)); 49 memset(&eth, 0, sizeof(eth));
50 memset(&grh, 0, sizeof(grh)); 50 memset(&grh, 0, sizeof(grh));
51 51
52 ah->sgid_index = attr->grh.sgid_index; 52 /* VLAN */
53
54 vlan_tag = attr->vlan_id; 53 vlan_tag = attr->vlan_id;
55 if (!vlan_tag || (vlan_tag > 0xFFF)) 54 if (!vlan_tag || (vlan_tag > 0xFFF))
56 vlan_tag = dev->pvid; 55 vlan_tag = dev->pvid;
@@ -65,15 +64,14 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
65 eth.eth_type = cpu_to_be16(OCRDMA_ROCE_ETH_TYPE); 64 eth.eth_type = cpu_to_be16(OCRDMA_ROCE_ETH_TYPE);
66 eth_sz = sizeof(struct ocrdma_eth_basic); 65 eth_sz = sizeof(struct ocrdma_eth_basic);
67 } 66 }
67 /* MAC */
68 memcpy(&eth.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN); 68 memcpy(&eth.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN);
69 memcpy(&eth.dmac[0], attr->dmac, ETH_ALEN);
70 status = ocrdma_resolve_dmac(dev, attr, &eth.dmac[0]); 69 status = ocrdma_resolve_dmac(dev, attr, &eth.dmac[0]);
71 if (status) 70 if (status)
72 return status; 71 return status;
73 status = ocrdma_query_gid(&dev->ibdev, 1, attr->grh.sgid_index, 72 ah->sgid_index = attr->grh.sgid_index;
74 (union ib_gid *)&grh.sgid[0]); 73 memcpy(&grh.sgid[0], sgid->raw, sizeof(union ib_gid));
75 if (status) 74 memcpy(&grh.dgid[0], attr->grh.dgid.raw, sizeof(attr->grh.dgid.raw));
76 return status;
77 75
78 grh.tclass_flow = cpu_to_be32((6 << 28) | 76 grh.tclass_flow = cpu_to_be32((6 << 28) |
79 (attr->grh.traffic_class << 24) | 77 (attr->grh.traffic_class << 24) |
@@ -81,8 +79,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
81 /* 0x1b is next header value in GRH */ 79 /* 0x1b is next header value in GRH */
82 grh.pdid_hoplimit = cpu_to_be32((pdid << 16) | 80 grh.pdid_hoplimit = cpu_to_be32((pdid << 16) |
83 (0x1b << 8) | attr->grh.hop_limit); 81 (0x1b << 8) | attr->grh.hop_limit);
84 82 /* Eth HDR */
85 memcpy(&grh.dgid[0], attr->grh.dgid.raw, sizeof(attr->grh.dgid.raw));
86 memcpy(&ah->av->eth_hdr, &eth, eth_sz); 83 memcpy(&ah->av->eth_hdr, &eth, eth_sz);
87 memcpy((u8 *)ah->av + eth_sz, &grh, sizeof(struct ocrdma_grh)); 84 memcpy((u8 *)ah->av + eth_sz, &grh, sizeof(struct ocrdma_grh));
88 if (vlan_enabled) 85 if (vlan_enabled)
@@ -98,6 +95,8 @@ struct ib_ah *ocrdma_create_ah(struct ib_pd *ibpd, struct ib_ah_attr *attr)
98 struct ocrdma_ah *ah; 95 struct ocrdma_ah *ah;
99 struct ocrdma_pd *pd = get_ocrdma_pd(ibpd); 96 struct ocrdma_pd *pd = get_ocrdma_pd(ibpd);
100 struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device); 97 struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device);
98 union ib_gid sgid;
99 u8 zmac[ETH_ALEN];
101 100
102 if (!(attr->ah_flags & IB_AH_GRH)) 101 if (!(attr->ah_flags & IB_AH_GRH))
103 return ERR_PTR(-EINVAL); 102 return ERR_PTR(-EINVAL);
@@ -111,7 +110,27 @@ struct ib_ah *ocrdma_create_ah(struct ib_pd *ibpd, struct ib_ah_attr *attr)
111 status = ocrdma_alloc_av(dev, ah); 110 status = ocrdma_alloc_av(dev, ah);
112 if (status) 111 if (status)
113 goto av_err; 112 goto av_err;
114 status = set_av_attr(dev, ah, attr, pd->id); 113
114 status = ocrdma_query_gid(&dev->ibdev, 1, attr->grh.sgid_index, &sgid);
115 if (status) {
116 pr_err("%s(): Failed to query sgid, status = %d\n",
117 __func__, status);
118 goto av_conf_err;
119 }
120
121 memset(&zmac, 0, ETH_ALEN);
122 if (pd->uctx &&
123 memcmp(attr->dmac, &zmac, ETH_ALEN)) {
124 status = rdma_addr_find_dmac_by_grh(&sgid, &attr->grh.dgid,
125 attr->dmac, &attr->vlan_id);
126 if (status) {
127 pr_err("%s(): Failed to resolve dmac from gid."
128 "status = %d\n", __func__, status);
129 goto av_conf_err;
130 }
131 }
132
133 status = set_av_attr(dev, ah, attr, &sgid, pd->id);
115 if (status) 134 if (status)
116 goto av_conf_err; 135 goto av_conf_err;
117 136
@@ -145,7 +164,7 @@ int ocrdma_query_ah(struct ib_ah *ibah, struct ib_ah_attr *attr)
145 struct ocrdma_av *av = ah->av; 164 struct ocrdma_av *av = ah->av;
146 struct ocrdma_grh *grh; 165 struct ocrdma_grh *grh;
147 attr->ah_flags |= IB_AH_GRH; 166 attr->ah_flags |= IB_AH_GRH;
148 if (ah->av->valid & Bit(1)) { 167 if (ah->av->valid & OCRDMA_AV_VALID) {
149 grh = (struct ocrdma_grh *)((u8 *)ah->av + 168 grh = (struct ocrdma_grh *)((u8 *)ah->av +
150 sizeof(struct ocrdma_eth_vlan)); 169 sizeof(struct ocrdma_eth_vlan));
151 attr->sl = be16_to_cpu(av->eth_hdr.vlan_tag) >> 13; 170 attr->sl = be16_to_cpu(av->eth_hdr.vlan_tag) >> 13;