IB/hfi1: Fix integrity check flags default values
authorJakub Pawlak <jakub.pawlak@intel.com>
Mon, 10 Oct 2016 13:14:56 +0000 (06:14 -0700)
committerDoug Ledford <dledford@redhat.com>
Tue, 15 Nov 2016 21:16:41 +0000 (16:16 -0500)
Prevent setting up integrity check flags when module is loaded
with NO_INTEGRITY capability.

Reviewed-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Jakub Pawlak <jakub.pawlak@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/hfi.h
drivers/infiniband/hw/hfi1/pio.c
drivers/infiniband/hw/hfi1/sdma.c

index 7eef11b316ff327e50b8330860db7fd88173ca51..3c06d204bafd3d9a760ed131a2479db90599f770 100644 (file)
@@ -1848,7 +1848,13 @@ extern struct mutex hfi1_mutex;
 static inline u64 hfi1_pkt_default_send_ctxt_mask(struct hfi1_devdata *dd,
                                                  u16 ctxt_type)
 {
-       u64 base_sc_integrity =
+       u64 base_sc_integrity;
+
+       /* No integrity checks if HFI1_CAP_NO_INTEGRITY is set */
+       if (HFI1_CAP_IS_KSET(NO_INTEGRITY))
+               return 0;
+
+       base_sc_integrity =
        SEND_CTXT_CHECK_ENABLE_DISALLOW_BYPASS_BAD_PKT_LEN_SMASK
        | SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK
        | SEND_CTXT_CHECK_ENABLE_DISALLOW_TOO_LONG_BYPASS_PACKETS_SMASK
@@ -1863,7 +1869,6 @@ static inline u64 hfi1_pkt_default_send_ctxt_mask(struct hfi1_devdata *dd,
        | SEND_CTXT_CHECK_ENABLE_CHECK_VL_MAPPING_SMASK
        | SEND_CTXT_CHECK_ENABLE_CHECK_OPCODE_SMASK
        | SEND_CTXT_CHECK_ENABLE_CHECK_SLID_SMASK
-       | SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK
        | SEND_CTXT_CHECK_ENABLE_CHECK_VL_SMASK
        | SEND_CTXT_CHECK_ENABLE_CHECK_ENABLE_SMASK;
 
@@ -1872,18 +1877,23 @@ static inline u64 hfi1_pkt_default_send_ctxt_mask(struct hfi1_devdata *dd,
        else
                base_sc_integrity |= HFI1_PKT_KERNEL_SC_INTEGRITY;
 
-       if (is_ax(dd))
-               /* turn off send-side job key checks - A0 */
-               return base_sc_integrity &
-                      ~SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
+       /* turn on send-side job key checks if !A0 */
+       if (!is_ax(dd))
+               base_sc_integrity |= SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
+
        return base_sc_integrity;
 }
 
 static inline u64 hfi1_pkt_base_sdma_integrity(struct hfi1_devdata *dd)
 {
-       u64 base_sdma_integrity =
+       u64 base_sdma_integrity;
+
+       /* No integrity checks if HFI1_CAP_NO_INTEGRITY is set */
+       if (HFI1_CAP_IS_KSET(NO_INTEGRITY))
+               return 0;
+
+       base_sdma_integrity =
        SEND_DMA_CHECK_ENABLE_DISALLOW_BYPASS_BAD_PKT_LEN_SMASK
-       | SEND_DMA_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK
        | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_LONG_BYPASS_PACKETS_SMASK
        | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_LONG_IB_PACKETS_SMASK
        | SEND_DMA_CHECK_ENABLE_DISALLOW_BAD_PKT_LEN_SMASK
@@ -1895,14 +1905,18 @@ static inline u64 hfi1_pkt_base_sdma_integrity(struct hfi1_devdata *dd)
        | SEND_DMA_CHECK_ENABLE_CHECK_VL_MAPPING_SMASK
        | SEND_DMA_CHECK_ENABLE_CHECK_OPCODE_SMASK
        | SEND_DMA_CHECK_ENABLE_CHECK_SLID_SMASK
-       | SEND_DMA_CHECK_ENABLE_CHECK_JOB_KEY_SMASK
        | SEND_DMA_CHECK_ENABLE_CHECK_VL_SMASK
        | SEND_DMA_CHECK_ENABLE_CHECK_ENABLE_SMASK;
 
-       if (is_ax(dd))
-               /* turn off send-side job key checks - A0 */
-               return base_sdma_integrity &
-                      ~SEND_DMA_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
+       if (!HFI1_CAP_IS_KSET(STATIC_RATE_CTRL))
+               base_sdma_integrity |=
+               SEND_DMA_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK;
+
+       /* turn on send-side job key checks if !A0 */
+       if (!is_ax(dd))
+               base_sdma_integrity |=
+                       SEND_DMA_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
+
        return base_sdma_integrity;
 }
 
index 50a3a36d93632d3e6fbb3a7afced466be2c4547b..d89b8745d4c1c3012e89c8355b3066bb116e26c9 100644 (file)
@@ -668,19 +668,12 @@ void sc_set_cr_threshold(struct send_context *sc, u32 new_threshold)
 void set_pio_integrity(struct send_context *sc)
 {
        struct hfi1_devdata *dd = sc->dd;
-       u64 reg = 0;
        u32 hw_context = sc->hw_context;
        int type = sc->type;
 
-       /*
-        * No integrity checks if HFI1_CAP_NO_INTEGRITY is set, or if
-        * we're snooping.
-        */
-       if (likely(!HFI1_CAP_IS_KSET(NO_INTEGRITY)) &&
-           dd->hfi1_snoop.mode_flag != HFI1_PORT_SNOOP_MODE)
-               reg = hfi1_pkt_default_send_ctxt_mask(dd, type);
-
-       write_kctxt_csr(dd, hw_context, SC(CHECK_ENABLE), reg);
+       write_kctxt_csr(dd, hw_context,
+                       SC(CHECK_ENABLE),
+                       hfi1_pkt_default_send_ctxt_mask(dd, type));
 }
 
 static u32 get_buffers_allocated(struct send_context *sc)
index fd39bcaa062d69683fdbefff9b610f26e15d898b..9cbe52d210778fdce2b3a5ad66d8e06dac801637 100644 (file)
@@ -2009,11 +2009,6 @@ static void sdma_hw_start_up(struct sdma_engine *sde)
        write_sde_csr(sde, SD(ENG_ERR_CLEAR), reg);
 }
 
-#define CLEAR_STATIC_RATE_CONTROL_SMASK(r) \
-(r &= ~SEND_DMA_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK)
-
-#define SET_STATIC_RATE_CONTROL_SMASK(r) \
-(r |= SEND_DMA_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK)
 /*
  * set_sdma_integrity
  *
@@ -2022,19 +2017,9 @@ static void sdma_hw_start_up(struct sdma_engine *sde)
 static void set_sdma_integrity(struct sdma_engine *sde)
 {
        struct hfi1_devdata *dd = sde->dd;
-       u64 reg;
-
-       if (unlikely(HFI1_CAP_IS_KSET(NO_INTEGRITY)))
-               return;
-
-       reg = hfi1_pkt_base_sdma_integrity(dd);
-
-       if (HFI1_CAP_IS_KSET(STATIC_RATE_CTRL))
-               CLEAR_STATIC_RATE_CONTROL_SMASK(reg);
-       else
-               SET_STATIC_RATE_CONTROL_SMASK(reg);
 
-       write_sde_csr(sde, SD(CHECK_ENABLE), reg);
+       write_sde_csr(sde, SD(CHECK_ENABLE),
+                     hfi1_pkt_base_sdma_integrity(dd));
 }
 
 static void init_sdma_regs(