114b24e2Vaishali Kulkarni/*
214b24e2Vaishali Kulkarni* CDDL HEADER START
314b24e2Vaishali Kulkarni*
414b24e2Vaishali Kulkarni* The contents of this file are subject to the terms of the
514b24e2Vaishali Kulkarni* Common Development and Distribution License, v.1,  (the "License").
614b24e2Vaishali Kulkarni* You may not use this file except in compliance with the License.
714b24e2Vaishali Kulkarni*
814b24e2Vaishali Kulkarni* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
914b24e2Vaishali Kulkarni* or http://opensource.org/licenses/CDDL-1.0.
1014b24e2Vaishali Kulkarni* See the License for the specific language governing permissions
1114b24e2Vaishali Kulkarni* and limitations under the License.
1214b24e2Vaishali Kulkarni*
1314b24e2Vaishali Kulkarni* When distributing Covered Code, include this CDDL HEADER in each
1414b24e2Vaishali Kulkarni* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1514b24e2Vaishali Kulkarni* If applicable, add the following below this CDDL HEADER, with the
1614b24e2Vaishali Kulkarni* fields enclosed by brackets "[]" replaced with your own identifying
1714b24e2Vaishali Kulkarni* information: Portions Copyright [yyyy] [name of copyright owner]
1814b24e2Vaishali Kulkarni*
1914b24e2Vaishali Kulkarni* CDDL HEADER END
2014b24e2Vaishali Kulkarni*/
2114b24e2Vaishali Kulkarni
2214b24e2Vaishali Kulkarni/*
2314b24e2Vaishali Kulkarni* Copyright 2014-2017 Cavium, Inc.
2414b24e2Vaishali Kulkarni* The contents of this file are subject to the terms of the Common Development
2514b24e2Vaishali Kulkarni* and Distribution License, v.1,  (the "License").
2614b24e2Vaishali Kulkarni
2714b24e2Vaishali Kulkarni* You may not use this file except in compliance with the License.
2814b24e2Vaishali Kulkarni
2914b24e2Vaishali Kulkarni* You can obtain a copy of the License at available
3014b24e2Vaishali Kulkarni* at http://opensource.org/licenses/CDDL-1.0
3114b24e2Vaishali Kulkarni
3214b24e2Vaishali Kulkarni* See the License for the specific language governing permissions and
3314b24e2Vaishali Kulkarni* limitations under the License.
3414b24e2Vaishali Kulkarni*/
3514b24e2Vaishali Kulkarni
3614b24e2Vaishali Kulkarni#ifndef	_BCM_OSAL_H
3714b24e2Vaishali Kulkarni#define	_BCM_OSAL_H
3814b24e2Vaishali Kulkarni
3914b24e2Vaishali Kulkarni#include <sys/ddi.h>
4014b24e2Vaishali Kulkarni#include <sys/sunddi.h>
4114b24e2Vaishali Kulkarni#include <sys/types.h>
4214b24e2Vaishali Kulkarni#include <sys/mutex.h>
4314b24e2Vaishali Kulkarni#include <sys/ksynch.h>
4414b24e2Vaishali Kulkarni#include <sys/conf.h>
4514b24e2Vaishali Kulkarni#include <sys/debug.h>
4614b24e2Vaishali Kulkarni#include <sys/kmem.h>
4714b24e2Vaishali Kulkarni#include <sys/mac.h>
4814b24e2Vaishali Kulkarni#include <sys/mac_provider.h>
4914b24e2Vaishali Kulkarni#include <sys/dditypes.h>
5014b24e2Vaishali Kulkarni#include <sys/list_impl.h>
5114b24e2Vaishali Kulkarni#include <sys/byteorder.h>
5294c3dadToomas Soome#include <sys/containerof.h>
5314b24e2Vaishali Kulkarni
5414b24e2Vaishali Kulkarni#include "qede_types.h"
5514b24e2Vaishali Kulkarni#include "qede_list.h"
5614b24e2Vaishali Kulkarni
5714b24e2Vaishali Kulkarni/*
5814b24e2Vaishali Kulkarni
5914b24e2Vaishali Kulkarni * Forward Declarations for ecore data structures
6014b24e2Vaishali Kulkarni */
6114b24e2Vaishali Kulkarnistruct ecore_dev;
6214b24e2Vaishali Kulkarnistruct ecore_hwfn;
6314b24e2Vaishali Kulkarni
6414b24e2Vaishali Kulkarni#define nothing do {} while(0)
6514b24e2Vaishali Kulkarni
6614b24e2Vaishali Kulkarni#define	INLINE	inline
6714b24e2Vaishali Kulkarni#define	__iomem
6814b24e2Vaishali Kulkarni#define OSAL_IOMEM	__iomem
6914b24e2Vaishali Kulkarni
7014b24e2Vaishali Kulkarni#ifndef likely
7114b24e2Vaishali Kulkarni#define	likely(expr)		(expr)
7214b24e2Vaishali Kulkarni#endif
7314b24e2Vaishali Kulkarni
7414b24e2Vaishali Kulkarni#ifndef	unlikely
7514b24e2Vaishali Kulkarni#define	unlikely(expr)		(expr)
7614b24e2Vaishali Kulkarni#endif
7714b24e2Vaishali Kulkarni
7814b24e2Vaishali Kulkarni/*
7914b24e2Vaishali Kulkarni * Memory related OSAL
8014b24e2Vaishali Kulkarni */
8114b24e2Vaishali Kulkarni#define	OSAL_MEM_ZERO(_dest_, _size_) \
8214b24e2Vaishali Kulkarni	(void) memset(_dest_, 0, _size_)
8314b24e2Vaishali Kulkarni#define	OSAL_MEMCPY(_dest_, _src_, _size_) \
8414b24e2Vaishali Kulkarni	memcpy(_dest_, _src_, _size_)
8514b24e2Vaishali Kulkarni#define OSAL_MEMCMP(_s1_, _s2_, _size_) \
8614b24e2Vaishali Kulkarni	memcmp(_s1_, _s2_, _size_)
8714b24e2Vaishali Kulkarni#define OSAL_MEMSET(_dest_, _val_, _size_) \
8814b24e2Vaishali Kulkarni	memset(_dest_, _val_, _size_)
8914b24e2Vaishali Kulkarni
9014b24e2Vaishali Kulkarni/*
9114b24e2Vaishali Kulkarni * The illumos DDI has sprintf returning a pointer to the resulting character
9214b24e2Vaishali Kulkarni * buffer and not the actual length. Therefore we simulate sprintf like the
9314b24e2Vaishali Kulkarni * others do.
9414b24e2Vaishali Kulkarni */
9514b24e2Vaishali Kulkarniextern size_t qede_sprintf(char *, const char *, ...);
9614b24e2Vaishali Kulkarni#define	OSAL_SPRINTF	qede_sprintf
9714b24e2Vaishali Kulkarni#define OSAL_SNPRINTF	(ssize_t)snprintf
9814b24e2Vaishali Kulkarni#define	OSAL_STRCMP	strcmp
9914b24e2Vaishali Kulkarni
10014b24e2Vaishali Kulkarni#define	GFP_KERNEL	KM_SLEEP
10114b24e2Vaishali Kulkarni#define	GFP_ATOMIC	KM_NOSLEEP
10214b24e2Vaishali Kulkarni
10314b24e2Vaishali Kulkarni/* Not used in ecore */
10414b24e2Vaishali Kulkarni#define OSAL_CALLOC(dev, GFP, num, size) OSAL_NULL
10514b24e2Vaishali Kulkarni
10614b24e2Vaishali Kulkarnivoid *qede_osal_zalloc(struct ecore_dev *, int, size_t);
10714b24e2Vaishali Kulkarni#define	OSAL_ZALLOC(_edev, _flags, _size) \
10814b24e2Vaishali Kulkarni	qede_osal_zalloc(_edev, _flags, _size)
10914b24e2Vaishali Kulkarnivoid *qede_osal_alloc(struct ecore_dev *, int, size_t);
11014b24e2Vaishali Kulkarni#define	OSAL_ALLOC(_edev, _flags, _size) \
11114b24e2Vaishali Kulkarni	qede_osal_alloc(_edev, _flags, _size)
11214b24e2Vaishali Kulkarnivoid qede_osal_free(struct ecore_dev *, void *addr);
11314b24e2Vaishali Kulkarni#define	OSAL_FREE(_edev, _addr) \
11414b24e2Vaishali Kulkarni	qede_osal_free(_edev, _addr)
11514b24e2Vaishali Kulkarni
11614b24e2Vaishali Kulkarni#define OSAL_VALLOC(_edev, _size) \
11714b24e2Vaishali Kulkarni	qede_osal_alloc(_edev, GFP_KERNEL, _size)
11814b24e2Vaishali Kulkarni
11914b24e2Vaishali Kulkarni#define OSAL_VFREE(_edev, _addr) \
12014b24e2Vaishali Kulkarni	qede_osal_free(_edev, _addr)
12114b24e2Vaishali Kulkarni
12214b24e2Vaishali Kulkarni#define OSAL_VZALLOC(_edev, _size) \
12314b24e2Vaishali Kulkarni	qede_osal_zalloc(_edev, GFP_KERNEL, _size)
12414b24e2Vaishali Kulkarni
12514b24e2Vaishali Kulkarnivoid *qede_osal_dma_alloc_coherent(struct ecore_dev *, dma_addr_t *, size_t);
12614b24e2Vaishali Kulkarni#define	OSAL_DMA_ALLOC_COHERENT(_edev_, _paddr_, _mem_size_) \
12714b24e2Vaishali Kulkarni	qede_osal_dma_alloc_coherent(_edev_, _paddr_, _mem_size_)
12814b24e2Vaishali Kulkarnivoid qede_osal_dma_free_coherent(struct ecore_dev *, void *, dma_addr_t, size_t);
12914b24e2Vaishali Kulkarni#define	OSAL_DMA_FREE_COHERENT(_edev_, _vaddr_, _paddr_, _mem_size_) \
13014b24e2Vaishali Kulkarni	qede_osal_dma_free_coherent(_edev_, _vaddr_, _paddr_, _mem_size_)
13114b24e2Vaishali Kulkarni
13214b24e2Vaishali Kulkarni/* Combine given 0xhi and 0xlo into a single U64 in format 0xhilo */
13314b24e2Vaishali Kulkarni#define	HILO_U64(hi, lo)	((((u64)(hi)) << 32) + (lo))
13414b24e2Vaishali Kulkarni
13514b24e2Vaishali Kulkarnivoid qede_osal_dma_sync(struct ecore_dev *edev, void* addr, u32 size, bool is_post);
13614b24e2Vaishali Kulkarni#define OSAL_DMA_SYNC(dev, addr, length, is_post) \
13714b24e2Vaishali Kulkarni	qede_osal_dma_sync(dev, addr, length, is_post)
13814b24e2Vaishali Kulkarni/*
13914b24e2Vaishali Kulkarni * BAR Access Related OSAL
14014b24e2Vaishali Kulkarni */
14114b24e2Vaishali Kulkarnivoid qede_osal_pci_write32(struct ecore_hwfn *hwfn, u32 addr, u32 val);
14214b24e2Vaishali Kulkarnivoid qede_osal_pci_write16(struct ecore_hwfn *hwfn, u32 addr, u16 val);
14314b24e2Vaishali Kulkarniu32 qede_osal_pci_read32(struct ecore_hwfn *hwfn, u32 addr);
14414b24e2Vaishali Kulkarniu32 *qede_osal_reg_addr(struct ecore_hwfn *hwfn, u32 addr);
14514b24e2Vaishali Kulkarnivoid qede_osal_pci_bar2_write32(struct ecore_hwfn *hwfn, u32 offset, u32 val);
14614b24e2Vaishali Kulkarni
14714b24e2Vaishali Kulkarni#define	REG_WR(_hwfn_, _addr_, _value_) \
14814b24e2Vaishali Kulkarni	qede_osal_pci_write32(_hwfn_, _addr_, _value_)
14914b24e2Vaishali Kulkarni
15014b24e2Vaishali Kulkarni#define	REG_WR16(_hwfn_, _addr_, _value_) \
15114b24e2Vaishali Kulkarni	qede_osal_pci_write16(_hwfn_, _addr_, _value_)
15214b24e2Vaishali Kulkarni
15314b24e2Vaishali Kulkarni#define	REG_RD(_hwfn_, _addr_) \
15414b24e2Vaishali Kulkarni	qede_osal_pci_read32(_hwfn_, _addr_)
15514b24e2Vaishali Kulkarni
15614b24e2Vaishali Kulkarni#define OSAL_REG_ADDR(_hwfn_, _addr_)  \
15714b24e2Vaishali Kulkarni	qede_osal_reg_addr(_hwfn_, _addr_)
15814b24e2Vaishali Kulkarni
15914b24e2Vaishali Kulkarni#define	DOORBELL(_hwfn_, _addr_, _val_) \
16014b24e2Vaishali Kulkarni	qede_osal_pci_bar2_write32(_hwfn_, _addr_, _val_)
16114b24e2Vaishali Kulkarni
16214b24e2Vaishali Kulkarnivoid qede_osal_direct_reg_write32(struct ecore_hwfn *hwfn, void *addr, u32 value);
16314b24e2Vaishali Kulkarniu32 qede_osal_direct_reg_read32(struct ecore_hwfn *hwfn, void *addr);
16414b24e2Vaishali Kulkarni/* FIXME: not correct Writes to the PCI _addr_ directly */
16514b24e2Vaishali Kulkarni#define	DIRECT_REG_WR(_hwfn, _addr, _val) \
16614b24e2Vaishali Kulkarni	qede_osal_direct_reg_write32(_hwfn, _addr, _val)
16714b24e2Vaishali Kulkarni#define	DIRECT_REG_RD(_hwfn, _addr) \
16814b24e2Vaishali Kulkarni	qede_osal_direct_reg_read32(_hwfn, _addr)
16914b24e2Vaishali Kulkarni
17014b24e2Vaishali Kulkarnistatic inline bool OSAL_NVM_IS_ACCESS_ENABLED(void *p_hwfn)
17114b24e2Vaishali Kulkarni{
17214b24e2Vaishali Kulkarni	return (1);
17314b24e2Vaishali Kulkarni}
17414b24e2Vaishali Kulkarni
17514b24e2Vaishali Kulkarni/*
17614b24e2Vaishali Kulkarni * Bit manipulation Helper functions
17714b24e2Vaishali Kulkarni */
17814b24e2Vaishali Kulkarni
17914b24e2Vaishali Kulkarni#define OSAL_BITS_PER_BYTE      (8)
18014b24e2Vaishali Kulkarni#define OSAL_BITS_PER_UL        (sizeof(unsigned long)*OSAL_BITS_PER_BYTE) /* always a power of 2 */
18114b24e2Vaishali Kulkarni#define OSAL_BITS_PER_UL_MASK   (OSAL_BITS_PER_UL - 1)
18214b24e2Vaishali Kulkarni
18314b24e2Vaishali Kulkarnistatic inline u32 osal_ffsl(unsigned long x)
18414b24e2Vaishali Kulkarni{
18514b24e2Vaishali Kulkarni	int r = 1;
18614b24e2Vaishali Kulkarni
18714b24e2Vaishali Kulkarni	if (!x)
18814b24e2Vaishali Kulkarni		return (0);
18914b24e2Vaishali Kulkarni
19014b24e2Vaishali Kulkarni	if (!(x & 0xffffffff)) {
19114b24e2Vaishali Kulkarni		x >>= 32;
19214b24e2Vaishali Kulkarni		r += 32;
19314b24e2Vaishali Kulkarni	}
19414b24e2Vaishali Kulkarni
19514b24e2Vaishali Kulkarni	if (!(x & 0xffff)) {
19614b24e2Vaishali Kulkarni		x >>= 16;
19714b24e2Vaishali Kulkarni		r += 16;
19814b24e2Vaishali Kulkarni	}
19914b24e2Vaishali Kulkarni
20014b24e2Vaishali Kulkarni	if (!(x & 0xff)) {
20114b24e2Vaishali Kulkarni		x >>= 8;
20214b24e2Vaishali Kulkarni		r += 8;
20314b24e2Vaishali Kulkarni	}
20414b24e2Vaishali Kulkarni
20514b24e2Vaishali Kulkarni	if (!(x & 0xf)) {
20614b24e2Vaishali Kulkarni		x >>= 4;
20714b24e2Vaishali Kulkarni		r += 4;
20814b24e2Vaishali Kulkarni	}
20914b24e2Vaishali Kulkarni	if (!(x & 3)) {
21014b24e2Vaishali Kulkarni		x >>= 2;
21114b24e2Vaishali Kulkarni		r += 2;
21214b24e2Vaishali Kulkarni	}
21314b24e2Vaishali Kulkarni
21414b24e2Vaishali Kulkarni	if (!(x & 1)) {
21514b24e2Vaishali Kulkarni		x >>= 1;
21614b24e2Vaishali Kulkarni		r += 1;
21714b24e2Vaishali Kulkarni	}
21814b24e2Vaishali Kulkarni
21914b24e2Vaishali Kulkarni	return (r);
22014b24e2Vaishali Kulkarni}
22114b24e2Vaishali Kulkarni
22214b24e2Vaishali Kulkarnistatic inline u32 osal_ffz(unsigned long word)
22314b24e2Vaishali Kulkarni{
22414b24e2Vaishali Kulkarni	unsigned long first_zero;
22514b24e2Vaishali Kulkarni
22614b24e2Vaishali Kulkarni	first_zero = osal_ffsl(~word);
22714b24e2Vaishali Kulkarni	return first_zero ? (first_zero-1) : OSAL_BITS_PER_UL;
22814b24e2Vaishali Kulkarni}
22914b24e2Vaishali Kulkarni
23014b24e2Vaishali Kulkarnistatic inline void OSAL_SET_BIT(u32 nr, unsigned long *addr)
23114b24e2Vaishali Kulkarni{
23214b24e2Vaishali Kulkarni	addr[nr/OSAL_BITS_PER_UL] |= 1UL << (nr & OSAL_BITS_PER_UL_MASK);
23314b24e2Vaishali Kulkarni}
23414b24e2Vaishali Kulkarni
23514b24e2Vaishali Kulkarnistatic inline void OSAL_CLEAR_BIT(u32 nr, unsigned long *addr)
23614b24e2Vaishali Kulkarni{
23714b24e2Vaishali Kulkarni	addr[nr/OSAL_BITS_PER_UL] &= ~(1UL << (nr & OSAL_BITS_PER_UL_MASK));
23814b24e2Vaishali Kulkarni}
23914b24e2Vaishali Kulkarni
24014b24e2Vaishali Kulkarnistatic inline bool OSAL_TEST_BIT(u32 nr, unsigned long *addr)
24114b24e2Vaishali Kulkarni{
24214b24e2Vaishali Kulkarni	return !!(addr[nr/OSAL_BITS_PER_UL] & (1UL << (nr & OSAL_BITS_PER_UL_MASK)));
24314b24e2Vaishali Kulkarni}
24414b24e2Vaishali Kulkarni
24514b24e2Vaishali Kulkarnistatic inline u32 OSAL_FIND_FIRST_ZERO_BIT(unsigned long *addr, u32 limit)
24614b24e2Vaishali Kulkarni{
24714b24e2Vaishali Kulkarni	u32 i;
24814b24e2Vaishali Kulkarni	u32 nwords = 0;
24914b24e2Vaishali Kulkarni
25014b24e2Vaishali Kulkarni	ASSERT(limit);
25114b24e2Vaishali Kulkarni	nwords = (limit - 1)/OSAL_BITS_PER_UL + 1;
25214b24e2Vaishali Kulkarni	for (i = 0; i < nwords && ~(addr[i]) == 0; i++);
25314b24e2Vaishali Kulkarni	return  (i == nwords)  ? limit : i*OSAL_BITS_PER_UL + osal_ffz(addr[i]);
25414b24e2Vaishali Kulkarni}
25514b24e2Vaishali Kulkarni
25614b24e2Vaishali Kulkarnistatic inline u32 OSAL_FIND_FIRST_BIT(unsigned long *addr, u32 limit)
25714b24e2Vaishali Kulkarni{
25814b24e2Vaishali Kulkarni	u32     i;
25914b24e2Vaishali Kulkarni	u32     nwords = (limit+OSAL_BITS_PER_UL-1)/OSAL_BITS_PER_UL;
26014b24e2Vaishali Kulkarni
26114b24e2Vaishali Kulkarni	for (i = 0; i < nwords ; i++)
26214b24e2Vaishali Kulkarni	{
26314b24e2Vaishali Kulkarni		if (addr[i]!=0)
26414b24e2Vaishali Kulkarni		break;
26514b24e2Vaishali Kulkarni	}
26614b24e2Vaishali Kulkarni
26714b24e2Vaishali Kulkarni	if (i == nwords) {
26814b24e2Vaishali Kulkarni		return limit;
26914b24e2Vaishali Kulkarni	} else {
27014b24e2Vaishali Kulkarni		return i*OSAL_BITS_PER_UL + osal_ffz(addr[i]);
27114b24e2Vaishali Kulkarni	}
27214b24e2Vaishali Kulkarni}
27314b24e2Vaishali Kulkarni
27414b24e2Vaishali Kulkarni
27514b24e2Vaishali Kulkarni/*
27614b24e2Vaishali Kulkarni * Time related OSAL
27714b24e2Vaishali Kulkarni */
27814b24e2Vaishali Kulkarni#define	OSAL_UDELAY(_usecs_)		drv_usecwait(_usecs_)
27914b24e2Vaishali Kulkarni#define	OSAL_MSLEEP(_msecs_)		delay(drv_usectohz(_msecs_ * 1000))
28014b24e2Vaishali Kulkarni
28114b24e2Vaishali Kulkarni/*
28214b24e2Vaishali Kulkarni * Synchronization related OSAL
28314b24e2Vaishali Kulkarni */
28414b24e2Vaishali Kulkarnitypedef kmutex_t		osal_mutex_t;
28514b24e2Vaishali Kulkarnitypedef	kmutex_t		osal_spinlock_t;
28614b24e2Vaishali Kulkarni
28714b24e2Vaishali Kulkarni/*
28814b24e2Vaishali Kulkarni * MUTEX/SPINLOCK Related NOTES:
28914b24e2Vaishali Kulkarni * 1. Currently initialize all mutex with default intr prio 0.
29014b24e2Vaishali Kulkarni * 2. Later do mutex_init in OSAL_MUTEX_ALLOC() instead of
29114b24e2Vaishali Kulkarni * OSAL_MUTEX_INIT, and use proper intr prio.
29214b24e2Vaishali Kulkarni * 3. Ensure that before calling any ecore api's, intr prio
29314b24e2Vaishali Kulkarni * is properly configured.
29414b24e2Vaishali Kulkarni */
29514b24e2Vaishali Kulkarni#define OSAL_MUTEX_ALLOC(hwfn, lock) nothing
29614b24e2Vaishali Kulkarni#define OSAL_SPIN_LOCK_ALLOC(hwfn, lock) nothing
29714b24e2Vaishali Kulkarni
29814b24e2Vaishali Kulkarni#define	OSAL_MUTEX_INIT(_lock_) \
29914b24e2Vaishali Kulkarni	mutex_init(_lock_, NULL, MUTEX_DRIVER, 0)
30014b24e2Vaishali Kulkarni#define	OSAL_SPIN_LOCK_INIT(lock) \
30114b24e2Vaishali Kulkarni	mutex_init(lock, NULL, MUTEX_DRIVER, 0)
30214b24e2Vaishali Kulkarni#define	OSAL_MUTEX_DEALLOC(_lock) \
30314b24e2Vaishali Kulkarni	mutex_destroy(_lock)
30414b24e2Vaishali Kulkarni#define OSAL_SPIN_LOCK_DEALLOC(_lock) \
30514b24e2Vaishali Kulkarni	mutex_destroy(_lock)
30614b24e2Vaishali Kulkarni
30714b24e2Vaishali Kulkarni#define	OSAL_MUTEX_ACQUIRE(lock) \
30814b24e2Vaishali Kulkarni	mutex_enter(lock)
30914b24e2Vaishali Kulkarni#define	OSAL_SPIN_LOCK(lock) \
31014b24e2Vaishali Kulkarni	mutex_enter(lock)
31114b24e2Vaishali Kulkarni#define	OSAL_SPIN_LOCK_IRQSAVE(lock, flags) \
31214b24e2Vaishali Kulkarni	OSAL_SPIN_LOCK(lock)
31314b24e2Vaishali Kulkarni#define	OSAL_MUTEX_RELEASE(lock) \
31414b24e2Vaishali Kulkarni	mutex_exit(lock)
31514b24e2Vaishali Kulkarni#define	OSAL_SPIN_UNLOCK(lock) \
31614b24e2Vaishali Kulkarni	mutex_exit(lock)
31714b24e2Vaishali Kulkarni#define	OSAL_SPIN_UNLOCK_IRQSAVE(lock, flags) \
31814b24e2Vaishali Kulkarni	OSAL_SPIN_UNLOCK(lock)
31914b24e2Vaishali Kulkarni
32014b24e2Vaishali Kulkarni/*
32114b24e2Vaishali Kulkarni * TODO: Implement dpc ISR
32214b24e2Vaishali Kulkarni */
32314b24e2Vaishali Kulkarni#define	OSAL_DPC_ALLOC(hwfn)		OSAL_ALLOC(hwfn->p_dev, GFP_KERNEL, sizeof (u64))
32414b24e2Vaishali Kulkarni#define	OSAL_DPC_INIT(dpc, hwfn)	nothing
32514b24e2Vaishali Kulkarni
32614b24e2Vaishali Kulkarni/*
32714b24e2Vaishali Kulkarni * PF recovery handler
32814b24e2Vaishali Kulkarni */
32914b24e2Vaishali Kulkarnivoid qede_osal_recovery_handler(struct ecore_hwfn *hwfn);
33014b24e2Vaishali Kulkarni#define	OSAL_SCHEDULE_RECOVERY_HANDLER(_ptr)	qede_osal_recovery_handler(_ptr)
33114b24e2Vaishali Kulkarni
33214b24e2Vaishali Kulkarni/*
33314b24e2Vaishali Kulkarni * Process DCBX Event
33414b24e2Vaishali Kulkarni */
33514b24e2Vaishali Kulkarnistatic inline void OSAL_DCBX_AEN(struct ecore_hwfn *p_hwfn, u32 mib_type)
33614b24e2Vaishali Kulkarni{
33714b24e2Vaishali Kulkarni}
33814b24e2Vaishali Kulkarni
33914b24e2Vaishali Kulkarni/*
34014b24e2Vaishali Kulkarni * Endianess Related
34114b24e2Vaishali Kulkarni */
34214b24e2Vaishali Kulkarni#define	LE_TO_HOST_32			LE_32
34314b24e2Vaishali Kulkarni#define	HOST_TO_LE_32			LE_32
34414b24e2Vaishali Kulkarni#define	HOST_TO_LE_16			LE_16
34514b24e2Vaishali Kulkarni
34614b24e2Vaishali Kulkarni#define	OSAL_BE32		u32
34714b24e2Vaishali Kulkarni#ifdef BIG_ENDIAN
34814b24e2Vaishali Kulkarni#define	OSAL_CPU_TO_BE64(val)	((val))
34914b24e2Vaishali Kulkarni#define	OSAL_CPU_TO_BE32(val)	((val))
35014b24e2Vaishali Kulkarni#define	OSAL_BE32_TO_CPU(val)	((val))
35114b24e2Vaishali Kulkarni#define OSAL_CPU_TO_LE32(val)	BSWAP_32(val)
35214b24e2Vaishali Kulkarni#define OSAL_CPU_TO_LE16(val)	BSWAP_16(val)
35314b24e2Vaishali Kulkarni#define OSAL_LE32_TO_CPU(val)	BSWAP_32(val)
35414b24e2Vaishali Kulkarni#define OSAL_LE16_TO_CPU(val)	BSWAP_16(val)
35514b24e2Vaishali Kulkarni#define OSAL_CPU_TO_LE64(val)	BSWAP_64(val)
35614b24e2Vaishali Kulkarni#else
35714b24e2Vaishali Kulkarni#define	OSAL_CPU_TO_BE64(val)	BSWAP_64(val)
35814b24e2Vaishali Kulkarni#define	OSAL_CPU_TO_BE32(val)	BSWAP_32(val)
35914b24e2Vaishali Kulkarni#define	OSAL_BE32_TO_CPU(val)	BSWAP_32(val)
36014b24e2Vaishali Kulkarni#define OSAL_CPU_TO_LE32(val)	((val))
36114b24e2Vaishali Kulkarni#define OSAL_CPU_TO_LE16(val)	((val))
36214b24e2Vaishali Kulkarni#define OSAL_LE32_TO_CPU(val)	((val))
36314b24e2Vaishali Kulkarni#define OSAL_LE16_TO_CPU(val)	((val))
36414b24e2Vaishali Kulkarni#endif
36514b24e2Vaishali Kulkarni/*
36614b24e2Vaishali Kulkarni * Physical Link Handling
36714b24e2Vaishali Kulkarni */
36814b24e2Vaishali Kulkarnivoid qede_osal_link_update(struct ecore_hwfn *hwfn);
36914b24e2Vaishali Kulkarni#define	OSAL_LINK_UPDATE(_hwfn_) \
37014b24e2Vaishali Kulkarni	qede_osal_link_update(_hwfn_)
37114b24e2Vaishali Kulkarni
37214b24e2Vaishali Kulkarni/*
37314b24e2Vaishali Kulkarni * Linked List Related OSAL,
37414b24e2Vaishali Kulkarni * and general Link list API's
37514b24e2Vaishali Kulkarni * for driver
37614b24e2Vaishali Kulkarni */
37714b24e2Vaishali Kulkarni
37814b24e2Vaishali Kulkarnitypedef u64 osal_size_t;
37914b24e2Vaishali Kulkarnitypedef u64 osal_int_ptr_t;
38014b24e2Vaishali Kulkarni#define OSAL_NULL	NULL
38114b24e2Vaishali Kulkarni
38214b24e2Vaishali Kulkarni#define	OSAL_LIST_PUSH_HEAD(_entry_at_beg_, _head_) \
38314b24e2Vaishali Kulkarni	QEDE_LIST_ADD(_entry_at_beg_, _head_)
38414b24e2Vaishali Kulkarni
38514b24e2Vaishali Kulkarni#define	OSAL_LIST_PUSH_TAIL(_entry_at_end_, _head_) \
38614b24e2Vaishali Kulkarni	QEDE_LIST_ADD_TAIL(_entry_at_end_, _head_)
38714b24e2Vaishali Kulkarni
38814b24e2Vaishali Kulkarni#define	qede_list_entry(_entry_ptr_, _type_, _member_) \
38994c3dadToomas Soome	__containerof(_entry_ptr_, _type_, _member_)
39014b24e2Vaishali Kulkarni
39114b24e2Vaishali Kulkarni#define	qede_list_first_entry(_head_, _type_, _member_) \
39214b24e2Vaishali Kulkarni	qede_list_entry((_head_)->next, _type_, _member_)
39314b24e2Vaishali Kulkarni
39414b24e2Vaishali Kulkarni#define	OSAL_LIST_FIRST_ENTRY(_list_, _type_, _member_) \
39514b24e2Vaishali Kulkarni	qede_list_first_entry(_list_, _type_, _member_)
39614b24e2Vaishali Kulkarni
39714b24e2Vaishali Kulkarni#define	OSAL_LIST_REMOVE_ENTRY(_entry_, _list_) \
39814b24e2Vaishali Kulkarni	QEDE_LIST_REMOVE(_entry_, _list_)
39914b24e2Vaishali Kulkarni
40014b24e2Vaishali Kulkarni
40114b24e2Vaishali Kulkarni#define	OSAL_LIST_IS_EMPTY(_head_) \
40214b24e2Vaishali Kulkarni	QEDE_LIST_IS_EMPTY(_head_)
40314b24e2Vaishali Kulkarni
40414b24e2Vaishali Kulkarni#define	qede_list_last_entry(_head_, _type_, _member_) \
40514b24e2Vaishali Kulkarni	qede_list_entry((_head_)->prev, _type_, _member_)
40614b24e2Vaishali Kulkarni
40714b24e2Vaishali Kulkarni#define qede_list_prev_entry(_entry_, _type_, _member_) \
40814b24e2Vaishali Kulkarni	qede_list_entry((_entry_)->_member_.prev, _type_, _member_)
40914b24e2Vaishali Kulkarni
41014b24e2Vaishali Kulkarni#define	qede_list_for_each_entry(_entry_, _head_, _type_, _member_) \
41114b24e2Vaishali Kulkarni	for (_entry_ = qede_list_last_entry(_head_, _type_, _member_); \
41214b24e2Vaishali Kulkarni	    &_entry_->_member_ != (_head_); \
41314b24e2Vaishali Kulkarni	    _entry_ = qede_list_prev_entry(_entry_, _type_, _member_))
41414b24e2Vaishali Kulkarni
41514b24e2Vaishali Kulkarni#define	OSAL_LIST_FOR_EACH_ENTRY(_entry_, _list_, _member_, _type_) \
41614b24e2Vaishali Kulkarni	qede_list_for_each_entry(_entry_, _list_, _type_, _member_)
41714b24e2Vaishali Kulkarni
41814b24e2Vaishali Kulkarni#define	qede_list_next_entry(_entry_, _type_, _member_) \
41914b24e2Vaishali Kulkarni	qede_list_entry((_entry_)->_member_.next, _type_, _member_)
42014b24e2Vaishali Kulkarni
42114b24e2Vaishali Kulkarni#define	qede_list_for_each_entry_safe(_entry_, _tmp_, _head_, _type_, _member_) \
42214b24e2Vaishali Kulkarni	for (_entry_ = qede_list_first_entry(_head_, _type_, _member_), \
42314b24e2Vaishali Kulkarni	    _tmp_ = qede_list_next_entry(_entry_, _type_, _member_); \
42414b24e2Vaishali Kulkarni	    &_entry_->_member_ != (_head_); \
42514b24e2Vaishali Kulkarni	    _entry_ = _tmp_, _tmp_ = qede_list_next_entry(_tmp_, _type_, _member_))
42614b24e2Vaishali Kulkarni
42714b24e2Vaishali Kulkarni#define	OSAL_LIST_FOR_EACH_ENTRY_SAFE(_entry_, _tmp_, _list_, \
42814b24e2Vaishali Kulkarni		_member_, _type_) \
42914b24e2Vaishali Kulkarni	qede_list_for_each_entry_safe(_entry_, _tmp_, _list_, _type_, \
43014b24e2Vaishali Kulkarni	    _member_)
43114b24e2Vaishali Kulkarni
43214b24e2Vaishali Kulkarni/*
43314b24e2Vaishali Kulkarni * PCI Access Related OSAL
43414b24e2Vaishali Kulkarni */
43514b24e2Vaishali Kulkarnivoid qede_osal_pci_read_config_byte(struct ecore_dev *, u32, u8 *);
43614b24e2Vaishali Kulkarni#define	OSAL_PCI_READ_CONFIG_BYTE(_edev_, _addr_, _dst_) \
43714b24e2Vaishali Kulkarni	qede_osal_pci_read_config_byte(_edev_, _addr_, _dst_)
43814b24e2Vaishali Kulkarnivoid qede_osal_pci_read_config_word(struct ecore_dev *, u32, u16 *);
43914b24e2Vaishali Kulkarni#define	OSAL_PCI_READ_CONFIG_WORD(_edev_, _addr_, _dst_) \
44014b24e2Vaishali Kulkarni	qede_osal_pci_read_config_word(_edev_, _addr_, _dst_)
44114b24e2Vaishali Kulkarnivoid qede_osal_pci_read_config_dword(struct ecore_dev *, u32, u32 *);
44214b24e2Vaishali Kulkarni#define	OSAL_PCI_READ_CONFIG_DWORD(_edev_, _addr_, _dst_) \
44314b24e2Vaishali Kulkarni	qede_osal_pci_read_config_dword(_edev_, _addr_, _dst_)
44414b24e2Vaishali Kulkarni
44514b24e2Vaishali Kulkarniint qede_osal_pci_find_ext_capab(struct ecore_dev *, u16);
44614b24e2Vaishali Kulkarni#define	OSAL_PCI_FIND_EXT_CAPABILITY(_edev_, _pcie_id_) \
44714b24e2Vaishali Kulkarni	qede_osal_pci_find_ext_capab(_edev_, _pcie_id_)
44814b24e2Vaishali Kulkarni
44914b24e2Vaishali Kulkarnivoid qede_osal_pci_write_config_word(struct ecore_dev *, u32, u16);
45014b24e2Vaishali Kulkarni#define OSAL_PCI_WRITE_CONFIG_WORD(ecore_dev, address, value)\
45114b24e2Vaishali Kulkarni		qede_osal_pci_write_config_word(ecore_dev, address, value)
45214b24e2Vaishali Kulkarni
45314b24e2Vaishali Kulkarniint qede_osal_pci_find_capability(struct ecore_dev *, u16);
45414b24e2Vaishali Kulkarni#define OSAL_PCI_FIND_CAPABILITY(ecore_dev, pcie_id)\
45514b24e2Vaishali Kulkarni	qede_osal_pci_find_capability(ecore_dev, pcie_id)
45614b24e2Vaishali Kulkarni/*
45714b24e2Vaishali Kulkarni * TODO : Can this be turned into a macro ??
45814b24e2Vaishali Kulkarni */
45914b24e2Vaishali Kulkarniu32 qede_osal_bar_size(struct ecore_dev *, u8);
46014b24e2Vaishali Kulkarni#define	OSAL_BAR_SIZE(_edev_, _bar_id_) \
46114b24e2Vaishali Kulkarni	(((bar_id) == 0)? 0x2000000: \
46214b24e2Vaishali Kulkarni	 ((bar_id) == 1)? 0x800000: 0)
46314b24e2Vaishali Kulkarni
46414b24e2Vaishali Kulkarni/*
46514b24e2Vaishali Kulkarni * Memory Barriers related OSAL
46614b24e2Vaishali Kulkarni */
46714b24e2Vaishali Kulkarni/*
46814b24e2Vaishali Kulkarni * TODO :Need to examine the ecore code using this Mem./IO
46914b24e2Vaishali Kulkarni * barriers and find out whether they are needed on Solaris
47014b24e2Vaishali Kulkarni */
47114b24e2Vaishali Kulkarni#define	OSAL_MMIOWB(x)	do {} while (0)
47214b24e2Vaishali Kulkarni#define	OSAL_BARRIER(x)	do {} while (0)
47314b24e2Vaishali Kulkarni#define	OSAL_SMP_RMB(x)	do {} while (0)
47414b24e2Vaishali Kulkarni#define	OSAL_SMP_WMB(x)	do {} while (0)
47514b24e2Vaishali Kulkarni#define	OSAL_RMB(x)	do {} while (0)
47614b24e2Vaishali Kulkarni#define	OSAL_WMB(x)	do {} while (0)
47714b24e2Vaishali Kulkarni
47814b24e2Vaishali Kulkarni/*
47914b24e2Vaishali Kulkarni * SR-IOV Related OSAL
48014b24e2Vaishali Kulkarni */
48114b24e2Vaishali Kulkarni#if 0
48214b24e2Vaishali Kulkarnienum _ecore_status_t qede_osal_iov_vf_acquire(struct ecore_hwfn *p_hwfn, int vf_id);
48314b24e2Vaishali Kulkarni#define OSAL_IOV_VF_ACQUIRE(p_hwfn, vf_id)	qede_osal_iov_vf_acquire(p_hwfn, vf_id)
48414b24e2Vaishali Kulkarni#define	OSAL_VF_SEND_MSG2PF()		OSAL_NULL
48514b24e2Vaishali Kulkarni#define	OSAL_VF_HANDLE_BULLETIN()	do {} while (0)
48614b24e2Vaishali Kulkarni#define	OSAL_IOV_CHK_UCAST()	        OSAL_NULL
48714b24e2Vaishali Kulkarni#define	OSAL_IOV_GET_OS_TYPE		0
48814b24e2Vaishali Kulkarni#define OSAL_IOV_VF_CLEANUP(p_hwfn,vf_id)
48914b24e2Vaishali Kulkarni#define OSAL_IOV_VF_VPORT_UPDATE(p_hwfn, vfid, params, tlvs_accepted) (0)
49014b24e2Vaishali Kulkarni#define OSAL_IOV_POST_START_VPORT(p_hwfn, vfid, vport_id, opaque_fid) {};
49114b24e2Vaishali Kulkarni
49214b24e2Vaishali Kulkarni
49314b24e2Vaishali Kulkarni
49414b24e2Vaishali Kulkarni#define	OSAL_VF_FILL_ACQUIRE_RESC_REQ(p_hwfn, req, vf_sw_info)	{}
49514b24e2Vaishali Kulkarni#define OSAL_VF_UPDATE_ACQUIRE_RESC_RESP(p_hwfn, res) (0)
49614b24e2Vaishali Kulkarni#else
49714b24e2Vaishali Kulkarni#define	OSAL_VF_SEND_MSG2PF()		OSAL_NULL
49814b24e2Vaishali Kulkarni#define OSAL_IOV_POST_START_VPORT(p_hwfn, vfid, vport_id, opaque_fid) {};
49914b24e2Vaishali Kulkarni#define OSAL_IOV_CHK_UCAST(hwfn, vfid, params) (0)
50014b24e2Vaishali Kulkarni#define OSAL_PF_VF_MSG(hwfn, vfid) (0)
50114b24e2Vaishali Kulkarni#define OSAL_VF_FLR_UPDATE(hw_fn) {}
50214b24e2Vaishali Kulkarni#define OSAL_IOV_VF_ACQUIRE(p_hwfn, vf_id) (0)
50314b24e2Vaishali Kulkarni#define OSAL_IOV_VF_CLEANUP(p_hwfn,vf_id)
50414b24e2Vaishali Kulkarni#define OSAL_IOV_VF_VPORT_UPDATE(p_hwfn, vfid, params, tlvs_accepted) (0)
50514b24e2Vaishali Kulkarni#define OSAL_VF_FILL_ACQUIRE_RESC_REQ(p_hwfn, req, vf_sw_info) {};
50614b24e2Vaishali Kulkarni
50714b24e2Vaishali Kulkarni#define OSAL_VF_UPDATE_ACQUIRE_RESC_RESP(p_hwfn, res) (0)
50814b24e2Vaishali Kulkarni
50914b24e2Vaishali Kulkarni#define	OSAL_IOV_GET_OS_TYPE()	0
51014b24e2Vaishali Kulkarni
51114b24e2Vaishali Kulkarni#endif
51214b24e2Vaishali Kulkarni/*
51314b24e2Vaishali Kulkarni * Miscellaneous OSAL
51414b24e2Vaishali Kulkarni */
51514b24e2Vaishali Kulkarni#define	OSAL_ASSERT(is_assert)		ASSERT(is_assert)
51614b24e2Vaishali Kulkarni
51714b24e2Vaishali Kulkarnivoid qede_print(char *format, ...);
51814b24e2Vaishali Kulkarni#define OSAL_WARN(is_warn, _fmt, ...) \
51914b24e2Vaishali Kulkarni     	if(is_warn) { \
52014b24e2Vaishali Kulkarni		do { \
52114b24e2Vaishali Kulkarni	       		qede_print("!"_fmt, ##__VA_ARGS__); \
52214b24e2Vaishali Kulkarni		} while (0); \
52314b24e2Vaishali Kulkarni	}
52414b24e2Vaishali Kulkarniunsigned long log2_align(unsigned long n);
52514b24e2Vaishali Kulkarni
52614b24e2Vaishali Kulkarni/* TODO: Verify this helper */
52714b24e2Vaishali Kulkarni#define	OSAL_ROUNDUP_POW_OF_TWO		log2_align
52814b24e2Vaishali Kulkarni
52914b24e2Vaishali Kulkarniu32 LOG2(u32);
53014b24e2Vaishali Kulkarni#define	OSAL_LOG2	LOG2
53114b24e2Vaishali Kulkarni
53214b24e2Vaishali Kulkarni/* Needed if ecore_roce.c is included */
53314b24e2Vaishali Kulkarni#define	OSAL_NUM_ACTIVE_CPU()			(0)
53414b24e2Vaishali Kulkarni#define	DIV_ROUND_UP(n, d)		(((n) + (d) - 1) / (d))
53514b24e2Vaishali Kulkarni#define	ROUNDUP(x, y)			((((x) + ((y) - 1)) / (y)) * (y))
53614b24e2Vaishali Kulkarni
53714b24e2Vaishali Kulkarnivoid qede_print(char *format, ...);
53814b24e2Vaishali Kulkarnivoid qede_print_err(char *format, ...);
53914b24e2Vaishali Kulkarni
54014b24e2Vaishali Kulkarni#define	PRINT(_dp_ctx, _fmt, ...) \
54114b24e2Vaishali Kulkarni	do { \
54214b24e2Vaishali Kulkarni		qede_print("!"_fmt, ##__VA_ARGS__); \
54314b24e2Vaishali Kulkarni	} while (0);
54414b24e2Vaishali Kulkarni#define	PRINT_ERR(_dp_ctx, _fmt, ...) \
54514b24e2Vaishali Kulkarni	do { \
54614b24e2Vaishali Kulkarni		qede_print_err("!"_fmt, ##__VA_ARGS__); \
54714b24e2Vaishali Kulkarni	} while (0);
54814b24e2Vaishali Kulkarni
54914b24e2Vaishali Kulkarnivoid qede_debug_before_pf_start(struct ecore_dev *edev, u8 id);
55014b24e2Vaishali Kulkarnivoid qede_debug_after_pf_stop(void *cdev, u8 my_id);
55114b24e2Vaishali Kulkarni
55214b24e2Vaishali Kulkarni#define OSAL_BEFORE_PF_START(ptr, id)	qede_debug_before_pf_start(ptr, id)
55314b24e2Vaishali Kulkarni#define	OSAL_AFTER_PF_STOP(ptr, id)	qede_debug_after_pf_stop(ptr, id)
55414b24e2Vaishali Kulkarni
55514b24e2Vaishali Kulkarni#define cpu_to_le32(val)	((val))
55614b24e2Vaishali Kulkarni#define le32_to_cpu(val)	((val))
55714b24e2Vaishali Kulkarni#define le16_to_cpu(val) 	((val))
55814b24e2Vaishali Kulkarni#define cpu_to_le16(val) 	((val))
55914b24e2Vaishali Kulkarni#define OSAL_BUILD_BUG_ON(cond) nothing
56014b24e2Vaishali Kulkarni#ifndef ARRAY_SIZE
56114b24e2Vaishali Kulkarni#define ARRAY_SIZE(_arr)	(sizeof(_arr) / sizeof((_arr)[0]))
56214b24e2Vaishali Kulkarni#endif
56314b24e2Vaishali Kulkarni#define BUILD_BUG_ON(cond)	nothing
56414b24e2Vaishali Kulkarni#define true 1
56514b24e2Vaishali Kulkarni#define false 0
56614b24e2Vaishali Kulkarni#define OSAL_VF_CQE_COMPLETION(_dev_p, _cqe, _protocol) (0)
56714b24e2Vaishali Kulkarni#define OSAL_INLINE inline
56814b24e2Vaishali Kulkarni#define OSAL_SPRINTF qede_sprintf
56914b24e2Vaishali Kulkarni#define OSAL_STRLEN strlen
57014b24e2Vaishali Kulkarni#define OSAL_STRCPY strcpy
57114b24e2Vaishali Kulkarni#define OSAL_STRNCPY strncpy
57214b24e2Vaishali Kulkarni#define OSAL_PAGE_BITS  12
57314b24e2Vaishali Kulkarni#define OSAL_PAGE_SIZE (1 << OSAL_PAGE_BITS)
57414b24e2Vaishali Kulkarni#define OSAL_UNLIKELY
57514b24e2Vaishali Kulkarni#define ARRAY_DECL static const
57614b24e2Vaishali Kulkarni
57714b24e2Vaishali Kulkarni#define OSAL_BUILD_BUG_ON(cond) nothing
57814b24e2Vaishali Kulkarni
57914b24e2Vaishali Kulkarni#define OSAL_MIN_T(type, __min1, __min2)        \
58014b24e2Vaishali Kulkarni        ((type)(__min1) < (type)(__min2) ? (type)(__min1) : (type)(__min2))
58114b24e2Vaishali Kulkarni#define OSAL_MAX_T(type, __max1, __max2)        \
58214b24e2Vaishali Kulkarni        ((type)(__max1) > (type)(__max2) ? (type)(__max1) : (type)(__max2))
58314b24e2Vaishali Kulkarni
58414b24e2Vaishali Kulkarni#define	OSAL_ARRAY_SIZE(arr)	ARRAY_SIZE(arr)
58514b24e2Vaishali Kulkarni
58614b24e2Vaishali Kulkarnivoid OSAL_CRC8_POPULATE(u8 * cdu_crc8_table, u8 polynomial);
58714b24e2Vaishali Kulkarni
58814b24e2Vaishali Kulkarniu8 OSAL_CRC8(u8 * cdu_crc8_table, u8 * data_to_crc, int data_to_crc_len, u8 init_value);
58914b24e2Vaishali Kulkarni
59014b24e2Vaishali Kulkarni#define OSAL_CACHE_LINE_SIZE 64
59114b24e2Vaishali Kulkarni#define OSAL_NUM_CPUS()  (0)
59214b24e2Vaishali Kulkarni
59314b24e2Vaishali Kulkarnivoid OSAL_DPC_SYNC(struct ecore_hwfn *p_hwfn);
59414b24e2Vaishali Kulkarni/*
59514b24e2Vaishali Kulkarni *  * TODO:  Need to implement
59614b24e2Vaishali Kulkarni *   * Call from the ecore to get the statististics of a protocol driver. Ecore client
59714b24e2Vaishali Kulkarni *    * need to populate the requested statistics. If the PF has more than one function,
59814b24e2Vaishali Kulkarni *     * driver should return the statistics sum of all the interfaces under the PF.
59914b24e2Vaishali Kulkarni *      */
60014b24e2Vaishali Kulkarni#define OSAL_GET_PROTOCOL_STATS(_ecore_dev, _type, _stats) \
60114b24e2Vaishali Kulkarni	;
60214b24e2Vaishali Kulkarni
60314b24e2Vaishali Kulkarni/*
60414b24e2Vaishali Kulkarni *  * TODO:  Need to implement
60514b24e2Vaishali Kulkarni *   * Call from ecore to the upper layer driver to request IRQs for the slowpath
60614b24e2Vaishali Kulkarni *    * interrupts handling.
60714b24e2Vaishali Kulkarni *     */
60814b24e2Vaishali Kulkarni#define OSAL_SLOWPATH_IRQ_REQ(p_hwfn) \
60914b24e2Vaishali Kulkarni	(ECORE_SUCCESS)
61014b24e2Vaishali Kulkarni
61114b24e2Vaishali Kulkarni
61214b24e2Vaishali Kulkarni
61314b24e2Vaishali Kulkarni//void OSAL_HW_ERROR_OCCURRED(struct ecore_hwfn *, enum ecore_hw_err_type);
61414b24e2Vaishali Kulkarni/*#define OSAL_HW_ERROR_OCCURRED(p_hwfn, err) \
61514b24e2Vaishali Kulkarni	qede_osal_hw_error_occurred(p_hwfn, err)
61614b24e2Vaishali Kulkarni*/
61714b24e2Vaishali Kulkarni
61814b24e2Vaishali Kulkarni#define	OSAL_HW_ERROR_OCCURRED(p_hwfn, err)	nothing
61914b24e2Vaishali Kulkarni
62014b24e2Vaishali Kulkarnivoid qede_osal_poll_mode_dpc(struct ecore_hwfn *);
62114b24e2Vaishali Kulkarni#define OSAL_POLL_MODE_DPC(p_hwfn) \
62214b24e2Vaishali Kulkarni	qede_osal_poll_mode_dpc(p_hwfn)
62314b24e2Vaishali Kulkarni
62414b24e2Vaishali Kulkarniint qede_osal_bitmap_weight(unsigned long *, uint32_t);
62514b24e2Vaishali Kulkarni#define OSAL_BITMAP_WEIGHT(bitmap, nbits) \
62614b24e2Vaishali Kulkarni	qede_osal_bitmap_weight(bitmap, nbits)
62714b24e2Vaishali Kulkarni
62814b24e2Vaishali Kulkarnivoid qede_osal_mfw_tlv_req(struct ecore_hwfn *);
62914b24e2Vaishali Kulkarni#define OSAL_MFW_TLV_REQ(p_hwfn) \
63014b24e2Vaishali Kulkarni	qede_osal_mfw_tlv_req(p_hwfn)
63114b24e2Vaishali Kulkarni
63214b24e2Vaishali Kulkarniu32 qede_osal_crc32(u32, u8 *, u64);
63314b24e2Vaishali Kulkarni#define OSAL_CRC32(crc, buf, length) \
63414b24e2Vaishali Kulkarni        qede_osal_crc32(crc, buf, length)
63514b24e2Vaishali Kulkarni
63614b24e2Vaishali Kulkarnivoid qede_osal_hw_info_change(struct ecore_hwfn *, int);
63714b24e2Vaishali Kulkarni#define OSAL_HW_INFO_CHANGE(p_hwfn, change) \
63814b24e2Vaishali Kulkarni	qede_osal_hw_info_change(p_hwfn, change)
63914b24e2Vaishali Kulkarni
64014b24e2Vaishali Kulkarni
64114b24e2Vaishali Kulkarni#endif /* _BCM_OSAL_H */
642