X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fhinic%2Fbase%2Fhinic_compat.h;h=aea332046edebb0831fae0dc1d5903dbab592776;hb=1028e5bc36b4dd4ae51580eb3e45410b6c82e153;hp=b72e8cfe26745e553710497f34bb670f81934eeb;hpb=43e34a229d3e575eb5ed075091afef0e5bf60a77;p=dpdk.git diff --git a/drivers/net/hinic/base/hinic_compat.h b/drivers/net/hinic/base/hinic_compat.h index b72e8cfe26..aea332046e 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 @@ -116,55 +117,26 @@ extern int hinic_logtype; #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_ALIGN_MIN) @@ -194,16 +166,24 @@ 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 +#define HINIC_MUTEX_TIMEOUT 10 + +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)) @@ -246,24 +226,14 @@ static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex) static inline int hinic_mutex_lock(pthread_mutex_t *pthreadmutex) { int err; + struct timespec tout; - 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); - } + (void)clock_gettime(CLOCK_TYPE, &tout); + + tout.tv_sec += HINIC_MUTEX_TIMEOUT; + err = pthread_mutex_timedlock(pthreadmutex, &tout); + if (err) + PMD_DRV_LOG(ERR, "Mutex lock failed. (ErrorNo=%d)", err); return err; }