1 #ifndef ECORE_COMMON_H
2 #define ECORE_COMMON_H
3
4 #define ECORE_SWCID_SHIFT 17
5 #define ECORE_SWCID_MASK ((0x1 << ECORE_SWCID_SHIFT) - 1)
6
7
8 /* Manipulate a bit vector defined as an array of u64 */
9
10 /* Number of bits in one sge_mask array element */
11 #define BIT_VEC64_ELEM_SZ 64
12 #define BIT_VEC64_ELEM_SHIFT 6
13 #define BIT_VEC64_ELEM_MASK ((u64)BIT_VEC64_ELEM_SZ - 1)
14
15
16 #define __BIT_VEC64_SET_BIT(el, bit) \
17 do { \
18 el = ((el) | ((u64)0x1 << (bit))); \
19 } while (0)
20
21 #define __BIT_VEC64_CLEAR_BIT(el, bit) \
22 do { \
23 el = ((el) & (~((u64)0x1 << (bit)))); \
24 } while (0)
25
26
27 #define BIT_VEC64_SET_BIT(vec64, idx) \
28 __BIT_VEC64_SET_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
29 (idx) & BIT_VEC64_ELEM_MASK)
30
31 #define BIT_VEC64_CLEAR_BIT(vec64, idx) \
32 __BIT_VEC64_CLEAR_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
33 (idx) & BIT_VEC64_ELEM_MASK)
34
35 #define BIT_VEC64_TEST_BIT(vec64, idx) \
36 (((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT] >> \
37 ((idx) & BIT_VEC64_ELEM_MASK)) & 0x1)
38
39 /* Creates a bitmask of all ones in less significant bits.
40 idx - index of the most significant bit in the created mask */
41 #define BIT_VEC64_ONES_MASK(idx) \
42 (((u64)0x1 << (((idx) & BIT_VEC64_ELEM_MASK) + 1)) - 1)
43 #define BIT_VEC64_ELEM_ONE_MASK ((u64)(~0))
44
45
__storm_memset_struct(struct _lm_device_t * pdev,u32 addr,size_t size,u32 * data)46 static __inline void __storm_memset_struct(struct _lm_device_t *pdev,
47 u32 addr, size_t size, u32 *data)
48 {
49 u8 i;
50 for (i = 0; i < size/4; i++)
51 REG_WR(pdev, addr + (i * 4), data[i]);
52 }
53
54 #define MC_HASH_SIZE 8
55 #define MC_HASH_OFFSET(bp, i) (BAR_TSTRORM_INTMEM + \
56 TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(FUNC_ID(pdev)) + i*4)
57
58 #define ECORE_MAX_MULTICAST 64
59 #define ECORE_MAX_EMUL_MULTI 1
60
61
62 /**
63 * Fill in a MAC address the way the FW likes it
64 *
65 * @param fw_hi
66 * @param fw_mid
67 * @param fw_lo
68 * @param mac
69 */
ecore_set_fw_mac_addr(u16 * fw_hi,u16 * fw_mid,u16 * fw_lo,u8 * mac)70 static __inline void ecore_set_fw_mac_addr(u16 *fw_hi, u16 *fw_mid, u16 *fw_lo,
71 u8 *mac)
72 {
73 ((u8 *)fw_hi)[0] = mac[1];
74 ((u8 *)fw_hi)[1] = mac[0];
75 ((u8 *)fw_mid)[0] = mac[3];
76 ((u8 *)fw_mid)[1] = mac[2];
77 ((u8 *)fw_lo)[0] = mac[5];
78 ((u8 *)fw_lo)[1] = mac[4];
79 }
80
81
82 #endif
83
84