net/qede/base: use crc32 OSAL macro
authorRasesh Mody <rasesh.mody@cavium.com>
Tue, 19 Sep 2017 01:29:43 +0000 (18:29 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 6 Oct 2017 00:49:48 +0000 (02:49 +0200)
Move ecore_crc32() macro to within base driver to qede_crc32() and use
OSAL_CRC32() where required.

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

index 2603a8b..e3a2cb4 100644 (file)
@@ -292,3 +292,15 @@ qede_hw_err_notify(struct ecore_hwfn *p_hwfn, enum ecore_hw_err_type err_type)
        DP_ERR(p_hwfn, "HW error occurred [%s]\n", err_str);
        ecore_int_attn_clr_enable(p_hwfn->p_dev, true);
 }
+
+u32 qede_crc32(u32 crc, u8 *ptr, u32 length)
+{
+       int i;
+
+       while (length--) {
+               crc ^= *ptr++;
+               for (i = 0; i < 8; i++)
+                       crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
+       }
+       return crc;
+}
index 3acf8f7..6148982 100644 (file)
@@ -427,7 +427,9 @@ void qede_get_mcp_proto_stats(struct ecore_dev *, enum ecore_mcp_protocol_type,
        qede_get_mcp_proto_stats(dev, type, stats)
 
 #define        OSAL_SLOWPATH_IRQ_REQ(p_hwfn) (0)
-#define OSAL_CRC32(crc, buf, length) 0
+
+u32 qede_crc32(u32 crc, u8 *ptr, u32 length);
+#define OSAL_CRC32(crc, buf, length) qede_crc32(crc, buf, length)
 #define OSAL_CRC8_POPULATE(table, polynomial) nothing
 #define OSAL_CRC8(table, pdata, nbytes, crc) 0
 #define OSAL_MFW_TLV_REQ(p_hwfn) (0)
index db2873e..cb3f4c3 100644 (file)
@@ -325,19 +325,6 @@ static bool ecore_iov_validate_active_txq(struct ecore_hwfn *p_hwfn,
        return false;
 }
 
-/* TODO - this is linux crc32; Need a way to ifdef it out for linux */
-u32 ecore_crc32(u32 crc, u8 *ptr, u32 length)
-{
-       int i;
-
-       while (length--) {
-               crc ^= *ptr++;
-               for (i = 0; i < 8; i++)
-                       crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
-       }
-       return crc;
-}
-
 enum _ecore_status_t ecore_iov_post_vf_bulletin(struct ecore_hwfn *p_hwfn,
                                                int vfid,
                                                struct ecore_ptt *p_ptt)
@@ -359,8 +346,8 @@ enum _ecore_status_t ecore_iov_post_vf_bulletin(struct ecore_hwfn *p_hwfn,
 
        /* Increment bulletin board version and compute crc */
        p_bulletin->version++;
-       p_bulletin->crc = ecore_crc32(0, (u8 *)p_bulletin + crc_size,
-                                     p_vf->bulletin.size - crc_size);
+       p_bulletin->crc = OSAL_CRC32(0, (u8 *)p_bulletin + crc_size,
+                                    p_vf->bulletin.size - crc_size);
 
        DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
                   "Posting Bulletin 0x%08x to VF[%d] (CRC 0x%08x)\n",
index 3c2f58b..5eb3484 100644 (file)
@@ -263,19 +263,6 @@ enum _ecore_status_t ecore_sriov_eqe_event(struct ecore_hwfn        *p_hwfn,
                                           __le16                echo,
                                           union event_ring_data *data);
 
-/**
- * @brief calculate CRC for bulletin board validation
- *
- * @param basic crc seed
- * @param ptr to beginning of buffer
- * @length in bytes of buffer
- *
- * @return calculated crc over buffer [with respect to seed].
- */
-u32 ecore_crc32(u32 crc,
-               u8  *ptr,
-               u32 length);
-
 /**
  * @brief Mark structs of vfs that have been FLR-ed.
  *
index f4d331c..7a52621 100644 (file)
@@ -1497,8 +1497,8 @@ enum _ecore_status_t ecore_vf_read_bulletin(struct ecore_hwfn *p_hwfn,
                return ECORE_SUCCESS;
 
        /* Verify the bulletin we see is valid */
-       crc = ecore_crc32(0, (u8 *)&shadow + crc_size,
-                         p_iov->bulletin.size - crc_size);
+       crc = OSAL_CRC32(0, (u8 *)&shadow + crc_size,
+                        p_iov->bulletin.size - crc_size);
        if (crc != shadow.crc)
                return ECORE_AGAIN;