@@ -2433,11 +2433,19 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
struct ib_ah_attr *ah_attr = &attrs->ah_attr;
union ib_gid sgid, zgid;
u32 vlan_id;
- u8 mac_addr[6];
+ u8 mac_addr[6], sgid_type, hdr_type;
+ union {
+ struct sockaddr _sockaddr;
+ struct sockaddr_in _sockaddr_in;
+ struct sockaddr_in6 _sockaddr_in6;
+ } sgid_addr, dgid_addr;
+
struct ocrdma_dev *dev = get_ocrdma_dev(qp->ibqp.device);
if ((ah_attr->ah_flags & IB_AH_GRH) == 0)
return -EINVAL;
+
+ /* Update SL */
if (atomic_cmpxchg(&dev->update_sl, 1, 0))
ocrdma_init_service_level(dev);
cmd->params.tclass_sq_psn |=
@@ -2448,6 +2456,8 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
cmd->params.hop_lmt_rq_psn |=
(ah_attr->grh.hop_limit << OCRDMA_QP_PARAMS_HOP_LMT_SHIFT);
cmd->flags |= OCRDMA_QP_PARA_FLOW_LBL_VALID;
+
+ /* GIDs */
memcpy(&cmd->params.dgid[0], &ah_attr->grh.dgid.raw[0],
sizeof(cmd->params.dgid));
status = ocrdma_query_gid(&dev->ibdev, 1,
@@ -2460,12 +2470,30 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
return -EINVAL;
qp->sgid_idx = ah_attr->grh.sgid_index;
+ status = ocrdma_query_gid_type(&dev->ibdev, 1,
+ ah_attr->grh.sgid_index, &sgid_type);
+ if (status)
+ return status;
+
+ hdr_type = ib_gid_to_network_type(sgid_type, &sgid);
memcpy(&cmd->params.sgid[0], &sgid.raw[0], sizeof(cmd->params.sgid));
status = ocrdma_resolve_dmac(dev, ah_attr, &mac_addr[0]);
if (status)
return status;
cmd->params.dmac_b0_to_b3 = mac_addr[0] | (mac_addr[1] << 8) |
(mac_addr[2] << 16) | (mac_addr[3] << 24);
+ if (hdr_type == RDMA_NETWORK_IPv4) {
+ status = rdma_gid2ip(&sgid_addr._sockaddr, &sgid);
+ if (status)
+ return status;
+ status = rdma_gid2ip(&dgid_addr._sockaddr, &ah_attr->grh.dgid);
+ if (status)
+ return status;
+ memcpy(&cmd->params.dgid[0],
+ &dgid_addr._sockaddr_in.sin_addr.s_addr, 4);
+ memcpy(&cmd->params.sgid[0],
+ &sgid_addr._sockaddr_in.sin_addr.s_addr, 4);
+ }
/* 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));
@@ -2478,6 +2506,11 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
cmd->params.rnt_rc_sl_fl |=
(dev->sl & 0x07) << OCRDMA_QP_PARAMS_SL_SHIFT;
}
+
+ cmd->params.max_sge_recv_flags |=
+ ((hdr_type <<
+ OCRDMA_QP_PARAMS_FLAGS_L3_TYPE_SHIFT) &
+ OCRDMA_QP_PARAMS_FLAGS_L3_TYPE_MASK);
return 0;
}