raw/ifpga/base: clean up
authorTianfei Zhang <tianfei.zhang@intel.com>
Tue, 16 Apr 2019 03:17:44 +0000 (11:17 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 19 Apr 2019 12:51:54 +0000 (14:51 +0200)
clean up code:
1. use opae_memcpy instead of memcpy
2. use opae_memset instead of memset
3. disable opae_adapter_dump by default

Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com>
drivers/raw/ifpga_rawdev/base/ifpga_api.c
drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
drivers/raw/ifpga_rawdev/base/opae_debug.c
drivers/raw/ifpga_rawdev/base/opae_hw_api.c
drivers/raw/ifpga_rawdev/base/opae_osdep.h
drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h

index 540e171..77d9471 100644 (file)
@@ -202,7 +202,7 @@ static int ifpga_adapter_enumerate(struct opae_adapter *adapter)
        struct ifpga_hw *hw = malloc(sizeof(*hw));
 
        if (hw) {
-               memset(hw, 0, sizeof(*hw));
+               opae_memset(hw, 0, sizeof(*hw));
                hw->pci_data = adapter->data;
                hw->adapter = adapter;
                if (ifpga_bus_enumerate(hw))
index be7ac9e..0a27c38 100644 (file)
@@ -77,8 +77,8 @@ int fpga_get_afu_uuid(struct ifpga_port_hw *port, struct uuid *uuid)
        guidh = readq(&port_hdr->afu_header.guid.b[8]);
        spinlock_unlock(&port->lock);
 
-       memcpy(uuid->b, &guidl, sizeof(u64));
-       memcpy(uuid->b + 8, &guidh, sizeof(u64));
+       opae_memcpy(uuid->b, &guidl, sizeof(u64));
+       opae_memcpy(uuid->b + 8, &guidh, sizeof(u64));
 
        return 0;
 }
index ec0beeb..8890f4b 100644 (file)
@@ -257,7 +257,7 @@ static int fme_pr(struct ifpga_hw *hw, u32 port_id, void *buffer, u32 size,
                return -EINVAL;
        }
 
-       memset(&info, 0, sizeof(struct fpga_pr_info));
+       opae_memset(&info, 0, sizeof(struct fpga_pr_info));
        info.flags = FPGA_MGR_PARTIAL_RECONFIG;
        info.port_id = port_id;
 
index 024d7d2..88f2d5c 100644 (file)
@@ -78,13 +78,13 @@ void opae_adapter_dump(struct opae_adapter *adapter, int verbose)
 {
        struct opae_accelerator *acc;
 
-       opae_log("=====%s=====\n", __func__);
-       opae_log("OPAE Adapter %s\n", adapter->name);
-       opae_log("OPAE Adapter OPs = %p\n", adapter->ops);
-       opae_log("OPAE Adapter Private Data = %p\n", adapter->data);
-       opae_log("OPAE Manager (downstream) = %p\n", adapter->mgr);
-
        if (verbose) {
+               opae_log("=====%s=====\n", __func__);
+               opae_log("OPAE Adapter %s\n", adapter->name);
+               opae_log("OPAE Adapter OPs = %p\n", adapter->ops);
+               opae_log("OPAE Adapter Private Data = %p\n", adapter->data);
+               opae_log("OPAE Manager (downstream) = %p\n", adapter->mgr);
+
                if (adapter->mgr)
                        opae_manager_dump(adapter->mgr);
 
@@ -93,7 +93,7 @@ void opae_adapter_dump(struct opae_adapter *adapter, int verbose)
 
                if (adapter->data)
                        opae_adapter_data_dump(adapter->data);
-       }
 
-       opae_log("==========================\n");
+               opae_log("==========================\n");
+       }
 }
index 1541b67..41c5903 100644 (file)
@@ -341,7 +341,7 @@ int opae_adapter_enumerate(struct opae_adapter *adapter)
                ret = adapter->ops->enumerate(adapter);
 
        if (!ret)
-               opae_adapter_dump(adapter, 1);
+               opae_adapter_dump(adapter, 0);
 
        return ret;
 }
index 90f54f7..78fec50 100644 (file)
@@ -76,4 +76,5 @@ struct uuid {
 #define msleep(x) opae_udelay(1000 * (x))
 #define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000))
 
+#define opae_memset(a, b, c)    memset((a), (b), (c))
 #endif
index 895a1d8..6769109 100644 (file)
@@ -71,5 +71,6 @@ static inline void opae_writeq(uint64_t value, volatile void *addr)
 }
 
 #define opae_free(addr) free(addr)
+#define opae_memcpy(a, b, c) memcpy((a), (b), (c))
 
 #endif
index 76902e2..3d9a0ca 100644 (file)
@@ -11,6 +11,7 @@
 #include <rte_log.h>
 #include <rte_io.h>
 #include <rte_malloc.h>
+#include <rte_memcpy.h>
 
 #define dev_printf(level, fmt, args...) \
        RTE_LOG(level, PMD, "osdep_rte: " fmt, ## args)
@@ -42,4 +43,5 @@
 #define spinlock_lock(x) rte_spinlock_lock(x)
 #define spinlock_unlock(x) rte_spinlock_unlock(x)
 
+#define opae_memcpy(a, b, c) rte_memcpy((a), (b), (c))
 #endif