X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fhinic%2Fbase%2Fhinic_compat.h;h=6dd210ec068ef73c083b16666289358cf8998435;hb=36f98ed2e33f08d93e570cfed958b666f23bd87a;hp=fe26aadd107cf609da5cb4dfb99323d46ff702cd;hpb=ce07a121c7975e9a984365dc5f2a3fa2867696cc;p=dpdk.git diff --git a/drivers/net/hinic/base/hinic_compat.h b/drivers/net/hinic/base/hinic_compat.h index fe26aadd10..6dd210ec06 100644 --- a/drivers/net/hinic/base/hinic_compat.h +++ b/drivers/net/hinic/base/hinic_compat.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -18,7 +19,6 @@ #include #include #include -#include typedef uint8_t u8; typedef int8_t s8; @@ -113,62 +113,33 @@ extern int hinic_logtype; #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 -static inline int hinic_test_bit(int nr, volatile unsigned long *addr) -{ - int res; - - res = ((*addr) & (1UL << nr)) != 0; - return res; -} - -static inline void hinic_set_bit(unsigned int nr, volatile unsigned long *addr) -{ - __sync_fetch_and_or(addr, (1UL << nr)); -} - -static inline void hinic_clear_bit(int nr, volatile unsigned long *addr) -{ - __sync_fetch_and_and(addr, ~(1UL << nr)); -} - -static inline int hinic_test_and_clear_bit(int nr, volatile unsigned long *addr) -{ - unsigned long mask = (1UL << nr); - - return __sync_fetch_and_and(addr, ~mask) & mask; -} +void *dma_zalloc_coherent(void *dev, size_t size, dma_addr_t *dma_handle, + unsigned int socket_id); -static inline int hinic_test_and_set_bit(int nr, volatile unsigned long *addr) -{ - unsigned long mask = (1UL << nr); +void *dma_zalloc_coherent_aligned(void *hwdev, size_t size, + dma_addr_t *dma_handle, unsigned int socket_id); - return __sync_fetch_and_or(addr, mask) & mask; -} +void *dma_zalloc_coherent_aligned256k(void *hwdev, size_t size, + dma_addr_t *dma_handle, unsigned int socket_id); -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); 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) @@ -195,16 +166,23 @@ static inline u32 readl(const volatile void *addr) #define spin_lock(spinlock_prt) rte_spinlock_lock(spinlock_prt) #define spin_unlock(spinlock_prt) rte_spinlock_unlock(spinlock_prt) -static inline unsigned long get_timeofday_ms(void) +#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */ +#define CLOCK_TYPE CLOCK_MONOTONIC_RAW +#else +#define CLOCK_TYPE CLOCK_MONOTONIC +#endif + +static inline unsigned long clock_gettime_ms(void) { - struct timeval tv; + struct timespec tv; - (void)gettimeofday(&tv, NULL); + (void)clock_gettime(CLOCK_TYPE, &tv); - return (unsigned long)tv.tv_sec * 1000 + tv.tv_usec / 1000; + return (unsigned long)tv.tv_sec * 1000 + + (unsigned long)tv.tv_nsec / 1000000; } -#define jiffies get_timeofday_ms() +#define jiffies clock_gettime_ms() #define msecs_to_jiffies(ms) (ms) #define time_before(now, end) ((now) < (end)) @@ -221,38 +199,6 @@ static inline u16 ilog2(u32 n) 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) {