#include <rte_spinlock.h>
#include <rte_cycles.h>
#include <rte_log.h>
-#include <rte_config.h>
typedef uint8_t u8;
typedef int8_t s8;
#define GFP_KERNEL RTE_MEMZONE_IOVA_CONTIG
#define HINIC_PAGE_SHIFT 12
#define HINIC_PAGE_SIZE RTE_PGSIZE_4K
-#define HINIC_MEM_ALLOC_ALIGNE_MIN 8
+#define HINIC_MEM_ALLOC_ALIGN_MIN 8
#define HINIC_PAGE_SIZE_DPDK 6
{
int res;
- rte_mb();
res = ((*addr) & (1UL << nr)) != 0;
- rte_mb();
return res;
}
}
void *dma_zalloc_coherent(void *dev, size_t size, dma_addr_t *dma_handle,
- gfp_t flag);
-void *dma_zalloc_coherent_aligned(void *dev, size_t size,
- dma_addr_t *dma_handle, gfp_t flag);
-void *dma_zalloc_coherent_aligned256k(void *dev, size_t size,
- dma_addr_t *dma_handle, gfp_t flag);
+ unsigned int socket_id);
+
+void *dma_zalloc_coherent_aligned(void *hwdev, size_t size,
+ dma_addr_t *dma_handle, unsigned int socket_id);
+
+void *dma_zalloc_coherent_aligned256k(void *hwdev, size_t size,
+ dma_addr_t *dma_handle, unsigned int socket_id);
+
void dma_free_coherent(void *dev, size_t size, void *virt, dma_addr_t phys);
/* dma pool alloc and free */
#define pci_pool dma_pool
-#define pci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, handle)
+#define pci_pool_alloc(pool, handle) dma_pool_alloc(pool, handle)
#define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr)
struct dma_pool *dma_pool_create(const char *name, void *dev, size_t size,
size_t align, size_t boundary);
void dma_pool_destroy(struct dma_pool *pool);
-void *dma_pool_alloc(struct pci_pool *pool, int flags, dma_addr_t *dma_addr);
+void *dma_pool_alloc(struct pci_pool *pool, dma_addr_t *dma_addr);
void dma_pool_free(struct pci_pool *pool, void *vaddr, dma_addr_t dma);
-#define kzalloc(size, flag) rte_zmalloc(NULL, size, HINIC_MEM_ALLOC_ALIGNE_MIN)
+#define kzalloc(size, flag) rte_zmalloc(NULL, size, HINIC_MEM_ALLOC_ALIGN_MIN)
#define kzalloc_aligned(size, flag) rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE)
#define kfree(ptr) rte_free(ptr)
return res;
}
-/**
- * hinic_cpu_to_be32 - convert data to big endian 32 bit format
- * @data: the data to convert
- * @len: length of data to convert, must be Multiple of 4B
- **/
-static inline void hinic_cpu_to_be32(void *data, u32 len)
-{
- u32 i;
- u32 *mem = (u32 *)data;
-
- for (i = 0; i < (len >> 2); i++) {
- *mem = cpu_to_be32(*mem);
- mem++;
- }
-}
-
-/**
- * hinic_be32_to_cpu - convert data from big endian 32 bit format
- * @data: the data to convert
- * @len: length of data to convert, must be Multiple of 4B
- **/
-static inline void hinic_be32_to_cpu(void *data, u32 len)
-{
- u32 i;
- u32 *mem = (u32 *)data;
-
- for (i = 0; i < (len >> 2); i++) {
- *mem = be32_to_cpu(*mem);
- mem++;
- }
-}
-
static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,
const pthread_mutexattr_t *mattr)
{
return err;
}
+static inline int hinic_mutex_lock(pthread_mutex_t *pthreadmutex)
+{
+ int err;
+
+ err = pthread_mutex_lock(pthreadmutex);
+ if (!err) {
+ return err;
+ } else if (err == EOWNERDEAD) {
+ PMD_DRV_LOG(ERR, "Mutex lock failed. (ErrorNo=%d)", errno);
+#if defined(__GLIBC__)
+#if __GLIBC_PREREQ(2, 12)
+ (void)pthread_mutex_consistent(pthreadmutex);
+#else
+ (void)pthread_mutex_consistent_np(pthreadmutex);
+#endif
+#else
+ (void)pthread_mutex_consistent(pthreadmutex);
+#endif
+ } else {
+ PMD_DRV_LOG(ERR, "Mutex lock failed. (ErrorNo=%d)", errno);
+ }
+
+ return err;
+}
+
+static inline int hinic_mutex_unlock(pthread_mutex_t *pthreadmutex)
+{
+ return pthread_mutex_unlock(pthreadmutex);
+}
+
#endif /* _HINIC_COMPAT_H_ */