IB/mthca: Initialize grh_present before using it

build_mlx_header() was using sqp->ud_header.grh_present before it was
initialized by mthca_read_ah(). Furthermore, header->grh_present is
set by ib_ud_header_init, so there's no need to set it again in
mthca_read_ah().

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by Michael S. Tsirkin and committed by Roland Dreier 9eacee2a c063a068

+8 -5
+6 -4
drivers/infiniband/hw/mthca/mthca_av.c
··· 163 return 0; 164 } 165 166 int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, 167 struct ib_ud_header *header) 168 { ··· 177 header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28; 178 header->lrh.destination_lid = ah->av->dlid; 179 header->lrh.source_lid = cpu_to_be16(ah->av->g_slid & 0x7f); 180 - if (ah->av->g_slid & 0x80) { 181 - header->grh_present = 1; 182 header->grh.traffic_class = 183 (be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff; 184 header->grh.flow_label = ··· 188 &header->grh.source_gid); 189 memcpy(header->grh.destination_gid.raw, 190 ah->av->dgid, 16); 191 - } else { 192 - header->grh_present = 0; 193 } 194 195 return 0;
··· 163 return 0; 164 } 165 166 + int mthca_ah_grh_present(struct mthca_ah *ah) 167 + { 168 + return !!(ah->av->g_slid & 0x80); 169 + } 170 + 171 int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, 172 struct ib_ud_header *header) 173 { ··· 172 header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28; 173 header->lrh.destination_lid = ah->av->dlid; 174 header->lrh.source_lid = cpu_to_be16(ah->av->g_slid & 0x7f); 175 + if (mthca_ah_grh_present(ah)) { 176 header->grh.traffic_class = 177 (be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff; 178 header->grh.flow_label = ··· 184 &header->grh.source_gid); 185 memcpy(header->grh.destination_gid.raw, 186 ah->av->dgid, 16); 187 } 188 189 return 0;
+1
drivers/infiniband/hw/mthca/mthca_dev.h
··· 520 int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah); 521 int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, 522 struct ib_ud_header *header); 523 524 int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); 525 int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
··· 520 int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah); 521 int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, 522 struct ib_ud_header *header); 523 + int mthca_ah_grh_present(struct mthca_ah *ah); 524 525 int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); 526 int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
+1 -1
drivers/infiniband/hw/mthca/mthca_qp.c
··· 1434 u16 pkey; 1435 1436 ib_ud_header_init(256, /* assume a MAD */ 1437 - sqp->ud_header.grh_present, 1438 &sqp->ud_header); 1439 1440 err = mthca_read_ah(dev, to_mah(wr->wr.ud.ah), &sqp->ud_header);
··· 1434 u16 pkey; 1435 1436 ib_ud_header_init(256, /* assume a MAD */ 1437 + mthca_ah_grh_present(to_mah(wr->wr.ud.ah)), 1438 &sqp->ud_header); 1439 1440 err = mthca_read_ah(dev, to_mah(wr->wr.ud.ah), &sqp->ud_header);