net/qede/base: add attention formatting string
authorRasesh Mody <rasesh.mody@qlogic.com>
Wed, 19 Oct 2016 04:11:19 +0000 (21:11 -0700)
committerBruce Richardson <bruce.richardson@intel.com>
Wed, 26 Oct 2016 17:38:29 +0000 (19:38 +0200)
In case of attention from a signal that's represented by multiple bits
in misc AEU, add the format string which is populated with proper index
and resulting prints will show string as a prefix.

Signed-off-by: Rasesh Mody <rasesh.mody@qlogic.com>
drivers/net/qede/base/bcm_osal.c
drivers/net/qede/base/bcm_osal.h
drivers/net/qede/base/ecore_int.c

index 67270fd..d53dfee 100644 (file)
@@ -65,6 +65,27 @@ inline bool qede_test_bit(u32 nr, unsigned long *addr)
        return res;
 }
 
+static inline u32 qede_ffb(unsigned long word)
+{
+       unsigned long first_bit;
+
+       first_bit = __builtin_ffsl(word);
+       return first_bit ? (first_bit - 1) : OSAL_BITS_PER_UL;
+}
+
+inline u32 qede_find_first_bit(unsigned long *addr, u32 limit)
+{
+       u32 i;
+       u32 nwords = 0;
+       OSAL_BUILD_BUG_ON(!limit);
+       nwords = (limit - 1) / OSAL_BITS_PER_UL + 1;
+       for (i = 0; i < nwords; i++)
+               if (addr[i] != 0)
+                       break;
+
+       return (i == nwords) ? limit : i * OSAL_BITS_PER_UL + qede_ffb(addr[i]);
+}
+
 static inline u32 qede_ffz(unsigned long word)
 {
        unsigned long first_zero;
index 3e2aeb0..a535058 100644 (file)
@@ -301,6 +301,10 @@ bool qede_test_bit(u32, unsigned long *);
 #define OSAL_TEST_BIT(bit, bitmap) \
        qede_test_bit(bit, bitmap)
 
+u32 qede_find_first_bit(unsigned long *, u32);
+#define OSAL_FIND_FIRST_BIT(bitmap, length) \
+       qede_find_first_bit(bitmap, length)
+
 u32 qede_find_first_zero_bit(unsigned long *, u32);
 #define OSAL_FIND_FIRST_ZERO_BIT(bitmap, length) \
        qede_find_first_zero_bit(bitmap, length)
@@ -377,6 +381,8 @@ u32 qede_osal_log2(u32);
 #define OSAL_ARRAY_SIZE(arr) RTE_DIM(arr)
 #define OSAL_SPRINTF(name, pattern, ...) \
        sprintf(name, pattern, ##__VA_ARGS__)
+#define OSAL_SNPRINTF(buf, size, format, ...) \
+       snprintf(buf, size, format, ##__VA_ARGS__)
 #define OSAL_STRLEN(string) strlen(string)
 #define OSAL_STRCPY(dst, string) strcpy(dst, string)
 #define OSAL_STRNCPY(dst, string, len) strncpy(dst, string, len)
index e4c002a..04c4947 100644 (file)
@@ -783,7 +783,9 @@ static void ecore_int_deassertion_print_bit(struct ecore_hwfn *p_hwfn,
 static enum _ecore_status_t
 ecore_int_deassertion_aeu_bit(struct ecore_hwfn *p_hwfn,
                              struct aeu_invert_reg_bit *p_aeu,
-                             u32 aeu_en_reg, u32 bitmask)
+                             u32 aeu_en_reg,
+                             const char *p_bit_name,
+                             u32 bitmask)
 {
        enum _ecore_status_t rc = ECORE_INVAL;
        u32 val, mask;
@@ -795,12 +797,12 @@ ecore_int_deassertion_aeu_bit(struct ecore_hwfn *p_hwfn,
 #endif
 
        DP_INFO(p_hwfn, "Deasserted attention `%s'[%08x]\n",
-               p_aeu->bit_name, bitmask);
+               p_bit_name, bitmask);
 
        /* Call callback before clearing the interrupt status */
        if (p_aeu->cb) {
                DP_INFO(p_hwfn, "`%s (attention)': Calling Callback function\n",
-                       p_aeu->bit_name);
+                       p_bit_name);
                rc = p_aeu->cb(p_hwfn);
        }
 
@@ -812,7 +814,7 @@ ecore_int_deassertion_aeu_bit(struct ecore_hwfn *p_hwfn,
        /* Reach assertion if attention is fatal */
        if (rc != ECORE_SUCCESS) {
                DP_NOTICE(p_hwfn, true, "`%s': Fatal attention\n",
-                         p_aeu->bit_name);
+                         p_bit_name);
 
                ecore_hw_err_notify(p_hwfn, ECORE_HW_ERR_HW_ATTN);
        }
@@ -824,7 +826,7 @@ ecore_int_deassertion_aeu_bit(struct ecore_hwfn *p_hwfn,
                val = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt, aeu_en_reg);
                ecore_wr(p_hwfn, p_hwfn->p_dpc_ptt, aeu_en_reg, (val & mask));
                DP_INFO(p_hwfn, "`%s' - Disabled future attentions\n",
-                       p_aeu->bit_name);
+                       p_bit_name);
        }
 
        if (p_aeu->flags & (ATTENTION_FW_DUMP | ATTENTION_PANIC_DUMP)) {
@@ -942,8 +944,8 @@ static enum _ecore_status_t ecore_int_deassertion(struct ecore_hwfn *p_hwfn,
                         * previous assertion.
                         */
                        for (j = 0, bit_idx = 0; bit_idx < 32; j++) {
+                               unsigned long bitmask;
                                u8 bit, bit_len;
-                               u32 bitmask;
 
                                p_aeu = &sb_attn_sw->p_aeu_desc[i].bits[j];
 
@@ -961,10 +963,31 @@ static enum _ecore_status_t ecore_int_deassertion(struct ecore_hwfn *p_hwfn,
 
                                bitmask = bits & (((1 << bit_len) - 1) << bit);
                                if (bitmask) {
+                                       u32 flags = p_aeu->flags;
+                                       char bit_name[30];
+
+                                       bit = (u8)OSAL_FIND_FIRST_BIT(&bitmask,
+                                                               bit_len);
+
+                                       /* Some bits represent more than a
+                                        * a single interrupt. Correctly print
+                                        * their name.
+                                        */
+                                       if (ATTENTION_LENGTH(flags) > 2 ||
+                                           ((flags & ATTENTION_PAR_INT) &&
+                                           ATTENTION_LENGTH(flags) > 1))
+                                               OSAL_SNPRINTF(bit_name, 30,
+                                                             p_aeu->bit_name,
+                                                             bit);
+                                       else
+                                               OSAL_STRNCPY(bit_name,
+                                                            p_aeu->bit_name,
+                                                            30);
                                        /* Handle source of the attention */
                                        ecore_int_deassertion_aeu_bit(p_hwfn,
                                                                      p_aeu,
                                                                      aeu_en,
+                                                                     bit_name,
                                                                      bitmask);
                                }