#include <linux/hash.h>
 #include "verbs.h"
+#include "sdma.h"
 
 #define QPN_MAX                 (1 << 24)
 #define QPNMAP_ENTRIES          (QPN_MAX / PAGE_SIZE / BITS_PER_BYTE)
        return qp;
 }
 
+/**
+ * clear_ahg - reset ahg status in qp
+ * @qp - qp pointer
+ */
+static inline void clear_ahg(struct hfi1_qp *qp)
+{
+       qp->s_hdr->ahgcount = 0;
+       qp->s_flags &= ~(HFI1_S_AHG_VALID | HFI1_S_AHG_CLEAR);
+       if (qp->s_sde && qp->s_ahgidx >= 0)
+               sdma_ahg_free(qp->s_sde, qp->s_ahgidx);
+       qp->s_ahgidx = -1;
+       qp->s_sde = NULL;
+}
+
 /**
  * hfi1_error_qp - put a QP into the error state
  * @qp: the QP to put into the error state
 
        return sizeof(struct ib_grh) / sizeof(u32);
 }
 
-/*
- * free_ahg - clear ahg from QP
- */
-void clear_ahg(struct hfi1_qp *qp)
-{
-       qp->s_hdr->ahgcount = 0;
-       qp->s_flags &= ~(HFI1_S_AHG_VALID | HFI1_S_AHG_CLEAR);
-       if (qp->s_sde)
-               sdma_ahg_free(qp->s_sde, qp->s_ahgidx);
-       qp->s_ahgidx = -1;
-       qp->s_sde = NULL;
-}
-
 #define BTH2_OFFSET (offsetof(struct hfi1_pio_header, hdr.u.oth.bth[2]) / 4)
 
 /**
 
 u32 hfi1_make_grh(struct hfi1_ibport *ibp, struct ib_grh *hdr,
                  struct ib_global_route *grh, u32 hwords, u32 nwords);
 
-void clear_ahg(struct hfi1_qp *qp);
-
 void hfi1_make_ruc_header(struct hfi1_qp *qp, struct hfi1_other_headers *ohdr,
                          u32 bth0, u32 bth2, int middle);