xref: /freebsd/sys/dev/bxe/ecore_sp.h (revision b0056b31e90029553894d17c441cbb2c06d31412)
14e400768SDavid Christensen /*-
27282444bSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause
37282444bSPedro F. Giffuni  *
44ef8ebfdSDavid C Somayajulu  * Copyright (c) 2007-2017 QLogic Corporation. All rights reserved.
54e400768SDavid Christensen  *
64e400768SDavid Christensen  * Redistribution and use in source and binary forms, with or without
74e400768SDavid Christensen  * modification, are permitted provided that the following conditions
84e400768SDavid Christensen  * are met:
94e400768SDavid Christensen  *
104e400768SDavid Christensen  * 1. Redistributions of source code must retain the above copyright
114e400768SDavid Christensen  *    notice, this list of conditions and the following disclaimer.
124e400768SDavid Christensen  * 2. Redistributions in binary form must reproduce the above copyright
134e400768SDavid Christensen  *    notice, this list of conditions and the following disclaimer in the
144e400768SDavid Christensen  *    documentation and/or other materials provided with the distribution.
154e400768SDavid Christensen  *
164ef8ebfdSDavid C Somayajulu  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
174e400768SDavid Christensen  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
184e400768SDavid Christensen  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
194e400768SDavid Christensen  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
204e400768SDavid Christensen  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
214e400768SDavid Christensen  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
224e400768SDavid Christensen  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
234e400768SDavid Christensen  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
244e400768SDavid Christensen  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
254e400768SDavid Christensen  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
264e400768SDavid Christensen  * THE POSSIBILITY OF SUCH DAMAGE.
274e400768SDavid Christensen  */
284e400768SDavid Christensen 
294e400768SDavid Christensen #include <sys/cdefs.h>
304e400768SDavid Christensen #ifndef ECORE_SP_H
314e400768SDavid Christensen #define ECORE_SP_H
324e400768SDavid Christensen 
334e400768SDavid Christensen 
344e400768SDavid Christensen #include <sys/types.h>
354e400768SDavid Christensen #include <sys/endian.h>
364e400768SDavid Christensen #include <sys/param.h>
374e400768SDavid Christensen #include <sys/lock.h>
384e400768SDavid Christensen #include <sys/mutex.h>
394e400768SDavid Christensen #include <sys/malloc.h>
404e400768SDavid Christensen #include <sys/kernel.h>
414e400768SDavid Christensen #include <machine/bus.h>
424e400768SDavid Christensen #include <net/ethernet.h>
434e400768SDavid Christensen 
444e400768SDavid Christensen #if _BYTE_ORDER == _LITTLE_ENDIAN
454e400768SDavid Christensen #ifndef LITTLE_ENDIAN
464e400768SDavid Christensen #define LITTLE_ENDIAN
474e400768SDavid Christensen #endif
484e400768SDavid Christensen #ifndef __LITTLE_ENDIAN
494e400768SDavid Christensen #define __LITTLE_ENDIAN
504e400768SDavid Christensen #endif
514e400768SDavid Christensen #undef BIG_ENDIAN
524e400768SDavid Christensen #undef __BIG_ENDIAN
534e400768SDavid Christensen #else /* _BIG_ENDIAN */
544e400768SDavid Christensen #ifndef BIG_ENDIAN
554e400768SDavid Christensen #define BIG_ENDIAN
564e400768SDavid Christensen #endif
574e400768SDavid Christensen #ifndef __BIG_ENDIAN
584e400768SDavid Christensen #define __BIG_ENDIAN
594e400768SDavid Christensen #endif
604e400768SDavid Christensen #undef LITTLE_ENDIAN
614e400768SDavid Christensen #undef __LITTLE_ENDIAN
624e400768SDavid Christensen #endif
634e400768SDavid Christensen 
644e400768SDavid Christensen #include "ecore_mfw_req.h"
654e400768SDavid Christensen #include "ecore_fw_defs.h"
664e400768SDavid Christensen #include "ecore_hsi.h"
674e400768SDavid Christensen #include "ecore_reg.h"
684e400768SDavid Christensen 
694e400768SDavid Christensen struct bxe_softc;
704e400768SDavid Christensen typedef bus_addr_t ecore_dma_addr_t; /* expected to be 64 bit wide */
714e400768SDavid Christensen typedef volatile int ecore_atomic_t;
724e400768SDavid Christensen 
732bd40797SEric Davis #ifndef __bool_true_false_are_defined
742bd40797SEric Davis #ifndef __cplusplus
752bd40797SEric Davis #define bool _Bool
762bd40797SEric Davis #endif /* !__cplusplus */
772bd40797SEric Davis #endif /* !__bool_true_false_are_defined$ */
784e400768SDavid Christensen 
794e400768SDavid Christensen #define ETH_ALEN ETHER_ADDR_LEN /* 6 */
804e400768SDavid Christensen 
814e400768SDavid Christensen #define ECORE_SWCID_SHIFT   17
824e400768SDavid Christensen #define ECORE_SWCID_MASK    ((0x1 << ECORE_SWCID_SHIFT) - 1)
834e400768SDavid Christensen 
844e400768SDavid Christensen #define ECORE_MC_HASH_SIZE 8
854e400768SDavid Christensen #define ECORE_MC_HASH_OFFSET(sc, i)                                          \
864e400768SDavid Christensen     (BAR_TSTRORM_INTMEM +                                                    \
874e400768SDavid Christensen      TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(FUNC_ID(sc)) + i*4)
884e400768SDavid Christensen 
894e400768SDavid Christensen #define ECORE_MAX_MULTICAST   64
904e400768SDavid Christensen #define ECORE_MAX_EMUL_MULTI  1
914e400768SDavid Christensen 
924e400768SDavid Christensen #define IRO sc->iro_array
934e400768SDavid Christensen 
944e400768SDavid Christensen typedef struct mtx ECORE_MUTEX;
954e400768SDavid Christensen #define ECORE_MUTEX_INIT(_mutex) \
964e400768SDavid Christensen     mtx_init(_mutex, "ecore_lock", "ECORE Lock", MTX_DEF)
974e400768SDavid Christensen #define ECORE_MUTEX_LOCK(_mutex)   mtx_lock(_mutex)
984e400768SDavid Christensen #define ECORE_MUTEX_UNLOCK(_mutex) mtx_unlock(_mutex)
994e400768SDavid Christensen 
1004e400768SDavid Christensen typedef struct mtx ECORE_MUTEX_SPIN;
1014e400768SDavid Christensen #define ECORE_SPIN_LOCK_INIT(_spin, _sc) \
1024e400768SDavid Christensen     mtx_init(_spin, "ecore_lock", "ECORE Lock", MTX_DEF)
1034e400768SDavid Christensen #define ECORE_SPIN_LOCK_BH(_spin)   mtx_lock(_spin) /* bh = bottom-half */
1044e400768SDavid Christensen #define ECORE_SPIN_UNLOCK_BH(_spin) mtx_unlock(_spin) /* bh = bottom-half */
1054e400768SDavid Christensen 
1064e400768SDavid Christensen #define ECORE_SMP_MB_AFTER_CLEAR_BIT()  mb()
1074e400768SDavid Christensen #define ECORE_SMP_MB_BEFORE_CLEAR_BIT() mb()
1084e400768SDavid Christensen #define ECORE_SMP_MB()                  mb()
1094e400768SDavid Christensen #define ECORE_SMP_RMB()                 rmb()
1104e400768SDavid Christensen #define ECORE_SMP_WMB()                 wmb()
1114e400768SDavid Christensen #define ECORE_MMIOWB()                  wmb()
1124e400768SDavid Christensen 
1134e400768SDavid Christensen #define ECORE_SET_BIT_NA(bit, var)   bit_set(var, bit) /* non-atomic */
1144e400768SDavid Christensen #define ECORE_CLEAR_BIT_NA(bit, var) bit_clear(var, bit) /* non-atomic */
1154e400768SDavid Christensen #define ECORE_TEST_BIT(bit, var)     bxe_test_bit(bit, var)
1164e400768SDavid Christensen #define ECORE_SET_BIT(bit, var)      bxe_set_bit(bit, var)
1174e400768SDavid Christensen #define ECORE_CLEAR_BIT(bit, var)    bxe_clear_bit(bit, var)
1184e400768SDavid Christensen #define ECORE_TEST_AND_CLEAR_BIT(bit, var) bxe_test_and_clear_bit(bit, var)
1194e400768SDavid Christensen 
1204e400768SDavid Christensen #define ECORE_ATOMIC_READ(a) atomic_load_acq_int((volatile int *)a)
1214e400768SDavid Christensen #define ECORE_ATOMIC_SET(a, v) atomic_store_rel_int((volatile int *)a, v)
1224e400768SDavid Christensen #define ECORE_ATOMIC_CMPXCHG(a, o, n) bxe_cmpxchg((volatile int *)a, o, n)
1234e400768SDavid Christensen 
1244e400768SDavid Christensen #define ECORE_RET_PENDING(pending_bit, pending) \
1254e400768SDavid Christensen     (ECORE_TEST_BIT(pending_bit, pending) ? ECORE_PENDING : ECORE_SUCCESS)
1264e400768SDavid Christensen 
1274e400768SDavid Christensen #define ECORE_SET_FLAG(value, mask, flag)      \
1284e400768SDavid Christensen     do {                                       \
1294e400768SDavid Christensen         (value) &= ~(mask);                    \
1304e400768SDavid Christensen         (value) |= ((flag) << (mask##_SHIFT)); \
1314e400768SDavid Christensen     } while (0)
1324e400768SDavid Christensen 
1334e400768SDavid Christensen #define ECORE_GET_FLAG(value, mask) \
1344e400768SDavid Christensen     (((value) &= (mask)) >> (mask##_SHIFT))
1354e400768SDavid Christensen 
1364e400768SDavid Christensen #define ECORE_MIGHT_SLEEP()
1374e400768SDavid Christensen 
1384e400768SDavid Christensen #define ECORE_FCOE_CID(sc) ((sc)->fp[FCOE_IDX(sc)].cl_id)
1394e400768SDavid Christensen 
1404e400768SDavid Christensen #define ECORE_MEMCMP(_a, _b, _s) memcmp(_a, _b, _s)
1414e400768SDavid Christensen #define ECORE_MEMCPY(_a, _b, _s) memcpy(_a, _b, _s)
1424e400768SDavid Christensen #define ECORE_MEMSET(_a, _c, _s) memset(_a, _c, _s)
1434e400768SDavid Christensen 
1444e400768SDavid Christensen #define ECORE_CPU_TO_LE16(x) htole16(x)
1454e400768SDavid Christensen #define ECORE_CPU_TO_LE32(x) htole32(x)
1464e400768SDavid Christensen 
1474e400768SDavid Christensen #define ECORE_WAIT(_s, _t) DELAY(1000)
1484e400768SDavid Christensen #define ECORE_MSLEEP(_t)   DELAY((_t) * 1000)
1494e400768SDavid Christensen 
1504e400768SDavid Christensen #define ECORE_LIKELY(x)   __predict_true(x)
1514e400768SDavid Christensen #define ECORE_UNLIKELY(x) __predict_false(x)
1524e400768SDavid Christensen 
1534e400768SDavid Christensen #define ECORE_ZALLOC(_size, _flags, _sc) \
1544e400768SDavid Christensen     malloc(_size, M_TEMP, (M_NOWAIT | M_ZERO))
1554e400768SDavid Christensen 
1564e400768SDavid Christensen #define ECORE_CALLOC(_len, _size, _flags, _sc) \
157c93a3334SPedro F. Giffuni     mallocarray(_len, _size, M_TEMP, (M_NOWAIT | M_ZERO))
1584e400768SDavid Christensen 
1594e400768SDavid Christensen #define ECORE_FREE(_s, _buf, _size) free(_buf, M_TEMP)
1604e400768SDavid Christensen 
1614e400768SDavid Christensen #define SC_ILT(sc)  ((sc)->ilt)
162*b0056b31SDoug Moore #define ILOG2(x)    ilog2(x)
1634e400768SDavid Christensen 
1644e400768SDavid Christensen #define ECORE_ILT_ZALLOC(x, y, size)                                       \
1654e400768SDavid Christensen     do {                                                                   \
1664e400768SDavid Christensen         x = malloc(sizeof(struct bxe_dma), M_DEVBUF, (M_NOWAIT | M_ZERO)); \
1674e400768SDavid Christensen         if (x) {                                                           \
1684e400768SDavid Christensen             if (bxe_dma_alloc((struct bxe_softc *)sc,                      \
1694e400768SDavid Christensen                               size, (struct bxe_dma *)x,                   \
1704e400768SDavid Christensen                               "ECORE_ILT") != 0) {                         \
1714e400768SDavid Christensen                 free(x, M_DEVBUF);                                         \
1724e400768SDavid Christensen                 x = NULL;                                                  \
1734e400768SDavid Christensen                 *y = 0;                                                    \
1744e400768SDavid Christensen             } else {                                                       \
1754e400768SDavid Christensen                 *y = ((struct bxe_dma *)x)->paddr;                         \
1764e400768SDavid Christensen             }                                                              \
1774e400768SDavid Christensen         }                                                                  \
1784e400768SDavid Christensen     } while (0)
1794e400768SDavid Christensen 
1804e400768SDavid Christensen #define ECORE_ILT_FREE(x, y, size)                   \
1814e400768SDavid Christensen     do {                                             \
1824e400768SDavid Christensen         if (x) {                                     \
1834e400768SDavid Christensen             bxe_dma_free((struct bxe_softc *)sc, x); \
1844e400768SDavid Christensen             free(x, M_DEVBUF);                       \
1854e400768SDavid Christensen             x = NULL;                                \
1864e400768SDavid Christensen             y = 0;                                   \
1874e400768SDavid Christensen         }                                            \
1884e400768SDavid Christensen     } while (0)
1894e400768SDavid Christensen 
1904e400768SDavid Christensen #define ECORE_IS_VALID_ETHER_ADDR(_mac) TRUE
1914e400768SDavid Christensen 
1924e400768SDavid Christensen #define ECORE_IS_MF_SD_MODE   IS_MF_SD_MODE
1934e400768SDavid Christensen #define ECORE_IS_MF_SI_MODE   IS_MF_SI_MODE
1944e400768SDavid Christensen #define ECORE_IS_MF_AFEX_MODE IS_MF_AFEX_MODE
1954e400768SDavid Christensen 
1964e400768SDavid Christensen #define ECORE_SET_CTX_VALIDATION bxe_set_ctx_validation
1974e400768SDavid Christensen 
1984e400768SDavid Christensen #define ECORE_UPDATE_COALESCE_SB_INDEX bxe_update_coalesce_sb_index
1994e400768SDavid Christensen 
2004e400768SDavid Christensen #define ECORE_ALIGN(x, a) ((((x) + (a) - 1) / (a)) * (a))
2014e400768SDavid Christensen 
2024e400768SDavid Christensen #define ECORE_REG_WR_DMAE_LEN REG_WR_DMAE_LEN
2034e400768SDavid Christensen 
2044e400768SDavid Christensen #define ECORE_PATH_ID     SC_PATH
2054e400768SDavid Christensen #define ECORE_PORT_ID     SC_PORT
2064e400768SDavid Christensen #define ECORE_FUNC_ID     SC_FUNC
2074e400768SDavid Christensen #define ECORE_ABS_FUNC_ID SC_ABS_FUNC
2084e400768SDavid Christensen 
2094e400768SDavid Christensen uint32_t calc_crc32(uint8_t *crc32_packet, uint32_t crc32_length,
2104e400768SDavid Christensen                     uint32_t crc32_seed, uint8_t complement);
2114e400768SDavid Christensen static inline uint32_t
2124e400768SDavid Christensen ECORE_CRC32_LE(uint32_t seed, uint8_t *mac, uint32_t len)
2134e400768SDavid Christensen {
2144e400768SDavid Christensen     uint32_t packet_buf[2] = {0};
2154e400768SDavid Christensen     memcpy(((uint8_t *)(&packet_buf[0]))+2, &mac[0], 2);
2164e400768SDavid Christensen     memcpy(&packet_buf[1], &mac[2], 4);
2174e400768SDavid Christensen     return bswap32(calc_crc32((uint8_t *)packet_buf, 8, seed, 0));
2184e400768SDavid Christensen }
2194e400768SDavid Christensen 
2204e400768SDavid Christensen #define ecore_sp_post(_sc, _a, _b, _c, _d) \
2214e400768SDavid Christensen     bxe_sp_post(_sc, _a, _b, U64_HI(_c), U64_LO(_c), _d)
2224e400768SDavid Christensen 
223e3a36fb0SDavid C Somayajulu #ifdef ECORE_STOP_ON_ERROR
224e3a36fb0SDavid C Somayajulu 
2254e400768SDavid Christensen #define ECORE_DBG_BREAK_IF(exp)     \
2264e400768SDavid Christensen     do {                            \
2274e400768SDavid Christensen         if (__predict_false(exp)) { \
2284e400768SDavid Christensen             panic("ECORE");         \
2294e400768SDavid Christensen         }                           \
2304e400768SDavid Christensen     } while (0)
2314e400768SDavid Christensen 
2324e400768SDavid Christensen #define ECORE_BUG()                               \
2334e400768SDavid Christensen     do {                                          \
2344e400768SDavid Christensen         panic("BUG (%s:%d)", __FILE__, __LINE__); \
2354e400768SDavid Christensen     } while(0);
2364e400768SDavid Christensen 
2374e400768SDavid Christensen #define ECORE_BUG_ON(exp)                                \
2384e400768SDavid Christensen     do {                                                 \
2394e400768SDavid Christensen         if (__predict_true(exp)) {                       \
2404e400768SDavid Christensen             panic("BUG_ON (%s:%d)", __FILE__, __LINE__); \
2414e400768SDavid Christensen         }                                                \
2424e400768SDavid Christensen     } while (0)
2434e400768SDavid Christensen 
244e3a36fb0SDavid C Somayajulu #else
245e3a36fb0SDavid C Somayajulu 
24641b18fabSDavid C Somayajulu 
2474ef8ebfdSDavid C Somayajulu extern unsigned long bxe_debug;
24841b18fabSDavid C Somayajulu #define BXE_DEBUG_ECORE_DBG_BREAK_IF   0x01
24941b18fabSDavid C Somayajulu #define BXE_DEBUG_ECORE_BUG            0x02
25041b18fabSDavid C Somayajulu #define BXE_DEBUG_ECORE_BUG_ON         0x04
25141b18fabSDavid C Somayajulu 
252e3a36fb0SDavid C Somayajulu #define ECORE_DBG_BREAK_IF(exp)     \
25341b18fabSDavid C Somayajulu     if (bxe_debug & BXE_DEBUG_ECORE_DBG_BREAK_IF) \
254e3a36fb0SDavid C Somayajulu         printf("%s (%s,%d)\n", __FUNCTION__, __FILE__, __LINE__);
255e3a36fb0SDavid C Somayajulu 
256e3a36fb0SDavid C Somayajulu #define ECORE_BUG(exp)     \
25741b18fabSDavid C Somayajulu     if (bxe_debug & BXE_DEBUG_ECORE_BUG) \
258e3a36fb0SDavid C Somayajulu         printf("%s (%s,%d)\n", __FUNCTION__, __FILE__, __LINE__);
259e3a36fb0SDavid C Somayajulu 
260e3a36fb0SDavid C Somayajulu #define ECORE_BUG_ON(exp)     \
26141b18fabSDavid C Somayajulu     if (bxe_debug & BXE_DEBUG_ECORE_BUG_ON) \
262e3a36fb0SDavid C Somayajulu         printf("%s (%s,%d)\n", __FUNCTION__, __FILE__, __LINE__);
263e3a36fb0SDavid C Somayajulu 
264e3a36fb0SDavid C Somayajulu 
265e3a36fb0SDavid C Somayajulu #endif /* #ifdef ECORE_STOP_ON_ERROR */
266e3a36fb0SDavid C Somayajulu 
2674e400768SDavid Christensen #define ECORE_ERR(str, ...) \
2684e400768SDavid Christensen     BLOGE(sc, "ECORE: " str, ##__VA_ARGS__)
2694e400768SDavid Christensen 
2704e400768SDavid Christensen #define DBG_SP 0x00000004 /* defined in bxe.h */
2714e400768SDavid Christensen 
2724e400768SDavid Christensen #define ECORE_MSG(sc, m, ...) \
2734e400768SDavid Christensen     BLOGD(sc, DBG_SP, "ECORE: " m, ##__VA_ARGS__)
2744e400768SDavid Christensen 
2754e400768SDavid Christensen typedef struct _ecore_list_entry_t
2764e400768SDavid Christensen {
2774e400768SDavid Christensen     struct _ecore_list_entry_t *next, *prev;
2784e400768SDavid Christensen } ecore_list_entry_t;
2794e400768SDavid Christensen 
2804e400768SDavid Christensen typedef struct ecore_list_t
2814e400768SDavid Christensen {
2824e400768SDavid Christensen     ecore_list_entry_t *head, *tail;
2834e400768SDavid Christensen     unsigned long cnt;
2844e400768SDavid Christensen } ecore_list_t;
2854e400768SDavid Christensen 
2864e400768SDavid Christensen /* initialize the list */
2874e400768SDavid Christensen #define ECORE_LIST_INIT(_list) \
2884e400768SDavid Christensen     do {                       \
2894e400768SDavid Christensen         (_list)->head = NULL;  \
2904e400768SDavid Christensen         (_list)->tail = NULL;  \
2914e400768SDavid Christensen         (_list)->cnt  = 0;     \
2924e400768SDavid Christensen     } while (0)
2934e400768SDavid Christensen 
2944e400768SDavid Christensen /* return TRUE if the element is the last on the list */
2954e400768SDavid Christensen #define ECORE_LIST_IS_LAST(_elem, _list) \
2964e400768SDavid Christensen     (_elem == (_list)->tail)
2974e400768SDavid Christensen 
2984e400768SDavid Christensen /* return TRUE if the list is empty */
2994e400768SDavid Christensen #define ECORE_LIST_IS_EMPTY(_list) \
3004e400768SDavid Christensen     ((_list)->cnt == 0)
3014e400768SDavid Christensen 
3024e400768SDavid Christensen /* return the first element */
3034e400768SDavid Christensen #define ECORE_LIST_FIRST_ENTRY(_list, cast, _link) \
3044e400768SDavid Christensen     (cast *)((_list)->head)
3054e400768SDavid Christensen 
3064e400768SDavid Christensen /* return the next element */
3074e400768SDavid Christensen #define ECORE_LIST_NEXT(_elem, _link, cast) \
3084e400768SDavid Christensen     (cast *)((&((_elem)->_link))->next)
3094e400768SDavid Christensen 
3104e400768SDavid Christensen /* push an element on the head of the list */
3114e400768SDavid Christensen #define ECORE_LIST_PUSH_HEAD(_elem, _list)              \
3124e400768SDavid Christensen     do {                                                \
3134e400768SDavid Christensen         (_elem)->prev = (ecore_list_entry_t *)0;        \
3144e400768SDavid Christensen         (_elem)->next = (_list)->head;                  \
3154e400768SDavid Christensen         if ((_list)->tail == (ecore_list_entry_t *)0) { \
3164e400768SDavid Christensen             (_list)->tail = (_elem);                    \
3174e400768SDavid Christensen         } else {                                        \
3184e400768SDavid Christensen             (_list)->head->prev = (_elem);              \
3194e400768SDavid Christensen         }                                               \
3204e400768SDavid Christensen         (_list)->head = (_elem);                        \
3214e400768SDavid Christensen         (_list)->cnt++;                                 \
3224e400768SDavid Christensen     } while (0)
3234e400768SDavid Christensen 
3244e400768SDavid Christensen /* push an element on the tail of the list */
3254e400768SDavid Christensen #define ECORE_LIST_PUSH_TAIL(_elem, _list)       \
3264e400768SDavid Christensen     do {                                         \
3274e400768SDavid Christensen         (_elem)->next = (ecore_list_entry_t *)0; \
3284e400768SDavid Christensen         (_elem)->prev = (_list)->tail;           \
3294e400768SDavid Christensen         if ((_list)->tail) {                     \
3304e400768SDavid Christensen             (_list)->tail->next = (_elem);       \
3314e400768SDavid Christensen         } else {                                 \
3324e400768SDavid Christensen             (_list)->head = (_elem);             \
3334e400768SDavid Christensen         }                                        \
3344e400768SDavid Christensen         (_list)->tail = (_elem);                 \
3354e400768SDavid Christensen         (_list)->cnt++;                          \
3364e400768SDavid Christensen     } while (0)
3374e400768SDavid Christensen 
3384e400768SDavid Christensen /* push list1 on the head of list2 and return with list1 as empty */
3394e400768SDavid Christensen #define ECORE_LIST_SPLICE_INIT(_list1, _list2)     \
3404e400768SDavid Christensen     do {                                           \
3414e400768SDavid Christensen         (_list1)->tail->next = (_list2)->head;     \
3424e400768SDavid Christensen         if ((_list2)->head) {                      \
3434e400768SDavid Christensen             (_list2)->head->prev = (_list1)->tail; \
3444e400768SDavid Christensen         } else {                                   \
3454e400768SDavid Christensen             (_list2)->tail = (_list1)->tail;       \
3464e400768SDavid Christensen         }                                          \
3474e400768SDavid Christensen         (_list2)->head = (_list1)->head;           \
3484e400768SDavid Christensen         (_list2)->cnt += (_list1)->cnt;            \
3494e400768SDavid Christensen         (_list1)->head = NULL;                     \
3504e400768SDavid Christensen         (_list1)->tail = NULL;                     \
3514e400768SDavid Christensen         (_list1)->cnt  = 0;                        \
3524e400768SDavid Christensen     } while (0)
3534e400768SDavid Christensen 
3544e400768SDavid Christensen /* remove an element from the list */
3554e400768SDavid Christensen #define ECORE_LIST_REMOVE_ENTRY(_elem, _list)                      \
3564e400768SDavid Christensen     do {                                                           \
3574e400768SDavid Christensen         if ((_list)->head == (_elem)) {                            \
3584e400768SDavid Christensen             if ((_list)->head) {                                   \
3594e400768SDavid Christensen                 (_list)->head = (_list)->head->next;               \
3604e400768SDavid Christensen                 if ((_list)->head) {                               \
3614e400768SDavid Christensen                     (_list)->head->prev = (ecore_list_entry_t *)0; \
3624e400768SDavid Christensen                 } else {                                           \
3634e400768SDavid Christensen                     (_list)->tail = (ecore_list_entry_t *)0;       \
3644e400768SDavid Christensen                 }                                                  \
3654e400768SDavid Christensen                 (_list)->cnt--;                                    \
3664e400768SDavid Christensen             }                                                      \
3674e400768SDavid Christensen         } else if ((_list)->tail == (_elem)) {                     \
3684e400768SDavid Christensen             if ((_list)->tail) {                                   \
3694e400768SDavid Christensen                 (_list)->tail = (_list)->tail->prev;               \
3704e400768SDavid Christensen                 if ((_list)->tail) {                               \
3714e400768SDavid Christensen                     (_list)->tail->next = (ecore_list_entry_t *)0; \
3724e400768SDavid Christensen                 } else {                                           \
3734e400768SDavid Christensen                     (_list)->head = (ecore_list_entry_t *)0;       \
3744e400768SDavid Christensen                 }                                                  \
3754e400768SDavid Christensen                 (_list)->cnt--;                                    \
3764e400768SDavid Christensen             }                                                      \
3774e400768SDavid Christensen         } else {                                                   \
3784e400768SDavid Christensen             (_elem)->prev->next = (_elem)->next;                   \
3794e400768SDavid Christensen             (_elem)->next->prev = (_elem)->prev;                   \
3804e400768SDavid Christensen             (_list)->cnt--;                                        \
3814e400768SDavid Christensen         }                                                          \
3824e400768SDavid Christensen     } while (0)
3834e400768SDavid Christensen 
3844e400768SDavid Christensen /* walk the list */
3854e400768SDavid Christensen #define ECORE_LIST_FOR_EACH_ENTRY(pos, _list, _link, cast) \
3864e400768SDavid Christensen     for (pos = ECORE_LIST_FIRST_ENTRY(_list, cast, _link); \
3874e400768SDavid Christensen          pos;                                              \
3884e400768SDavid Christensen          pos = ECORE_LIST_NEXT(pos, _link, cast))
3894e400768SDavid Christensen 
3904e400768SDavid Christensen /* walk the list (safely) */
3914e400768SDavid Christensen #define ECORE_LIST_FOR_EACH_ENTRY_SAFE(pos, n, _list, _link, cast) \
3924e400768SDavid Christensen      for (pos = ECORE_LIST_FIRST_ENTRY(_list, cast, _lint),        \
3934e400768SDavid Christensen           n = (pos) ? ECORE_LIST_NEXT(pos, _link, cast) : NULL;    \
3944e400768SDavid Christensen           pos != NULL;                                             \
3954e400768SDavid Christensen           pos = (cast *)n,                                         \
3964e400768SDavid Christensen           n = (pos) ? ECORE_LIST_NEXT(pos, _link, cast) : NULL)
3974e400768SDavid Christensen 
3984e400768SDavid Christensen 
3994e400768SDavid Christensen /* Manipulate a bit vector defined as an array of uint64_t */
4004e400768SDavid Christensen 
4014e400768SDavid Christensen /* Number of bits in one sge_mask array element */
4024e400768SDavid Christensen #define BIT_VEC64_ELEM_SZ     64
4034e400768SDavid Christensen #define BIT_VEC64_ELEM_SHIFT  6
4044e400768SDavid Christensen #define BIT_VEC64_ELEM_MASK   ((uint64_t)BIT_VEC64_ELEM_SZ - 1)
4054e400768SDavid Christensen 
4064e400768SDavid Christensen #define __BIT_VEC64_SET_BIT(el, bit)            \
4074e400768SDavid Christensen     do {                                        \
4084e400768SDavid Christensen         el = ((el) | ((uint64_t)0x1 << (bit))); \
4094e400768SDavid Christensen     } while (0)
4104e400768SDavid Christensen 
4114e400768SDavid Christensen #define __BIT_VEC64_CLEAR_BIT(el, bit)             \
4124e400768SDavid Christensen     do {                                           \
4134e400768SDavid Christensen         el = ((el) & (~((uint64_t)0x1 << (bit)))); \
4144e400768SDavid Christensen     } while (0)
4154e400768SDavid Christensen 
4164e400768SDavid Christensen #define BIT_VEC64_SET_BIT(vec64, idx)                           \
4174e400768SDavid Christensen     __BIT_VEC64_SET_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
4184e400768SDavid Christensen                         (idx) & BIT_VEC64_ELEM_MASK)
4194e400768SDavid Christensen 
4204e400768SDavid Christensen #define BIT_VEC64_CLEAR_BIT(vec64, idx)                           \
4214e400768SDavid Christensen     __BIT_VEC64_CLEAR_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
4224e400768SDavid Christensen                           (idx) & BIT_VEC64_ELEM_MASK)
4234e400768SDavid Christensen 
4244e400768SDavid Christensen #define BIT_VEC64_TEST_BIT(vec64, idx)          \
4254e400768SDavid Christensen     (((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT] >> \
4264e400768SDavid Christensen       ((idx) & BIT_VEC64_ELEM_MASK)) & 0x1)
4274e400768SDavid Christensen 
4284e400768SDavid Christensen /*
4294e400768SDavid Christensen  * Creates a bitmask of all ones in less significant bits.
4304e400768SDavid Christensen  * idx - index of the most significant bit in the created mask
4314e400768SDavid Christensen  */
4324e400768SDavid Christensen #define BIT_VEC64_ONES_MASK(idx)                                 \
4334e400768SDavid Christensen     (((uint64_t)0x1 << (((idx) & BIT_VEC64_ELEM_MASK) + 1)) - 1)
4344e400768SDavid Christensen #define BIT_VEC64_ELEM_ONE_MASK ((uint64_t)(~0))
4354e400768SDavid Christensen 
4364e400768SDavid Christensen /* fill in a MAC address the way the FW likes it */
4374e400768SDavid Christensen static inline void
4384e400768SDavid Christensen ecore_set_fw_mac_addr(uint16_t *fw_hi,
4394e400768SDavid Christensen                       uint16_t *fw_mid,
4404e400768SDavid Christensen                       uint16_t *fw_lo,
4414e400768SDavid Christensen                       uint8_t  *mac)
4424e400768SDavid Christensen {
4434e400768SDavid Christensen     ((uint8_t *)fw_hi)[0]  = mac[1];
4444e400768SDavid Christensen     ((uint8_t *)fw_hi)[1]  = mac[0];
4454e400768SDavid Christensen     ((uint8_t *)fw_mid)[0] = mac[3];
4464e400768SDavid Christensen     ((uint8_t *)fw_mid)[1] = mac[2];
4474e400768SDavid Christensen     ((uint8_t *)fw_lo)[0]  = mac[5];
4484e400768SDavid Christensen     ((uint8_t *)fw_lo)[1]  = mac[4];
4494e400768SDavid Christensen }
4504e400768SDavid Christensen 
4514e400768SDavid Christensen 
4524e400768SDavid Christensen enum ecore_status_t {
4534e400768SDavid Christensen     ECORE_EXISTS  = -6,
4544e400768SDavid Christensen     ECORE_IO      = -5,
4554e400768SDavid Christensen     ECORE_TIMEOUT = -4,
4564e400768SDavid Christensen     ECORE_INVAL   = -3,
4574e400768SDavid Christensen     ECORE_BUSY    = -2,
4584e400768SDavid Christensen     ECORE_NOMEM   = -1,
4594e400768SDavid Christensen     ECORE_SUCCESS = 0,
4604e400768SDavid Christensen     /* PENDING is not an error and should be positive */
4614e400768SDavid Christensen     ECORE_PENDING = 1,
4624e400768SDavid Christensen };
4634e400768SDavid Christensen 
4644e400768SDavid Christensen enum {
4654e400768SDavid Christensen     SWITCH_UPDATE,
4664e400768SDavid Christensen     AFEX_UPDATE,
4674e400768SDavid Christensen };
4684e400768SDavid Christensen 
4694e400768SDavid Christensen 
4704e400768SDavid Christensen 
4714e400768SDavid Christensen 
4724e400768SDavid Christensen struct bxe_softc;
4734e400768SDavid Christensen struct eth_context;
4744e400768SDavid Christensen 
4754e400768SDavid Christensen /* Bits representing general command's configuration */
4764e400768SDavid Christensen enum {
4774e400768SDavid Christensen 	RAMROD_TX,
4784e400768SDavid Christensen 	RAMROD_RX,
4794e400768SDavid Christensen 	/* Wait until all pending commands complete */
4804e400768SDavid Christensen 	RAMROD_COMP_WAIT,
4814e400768SDavid Christensen 	/* Don't send a ramrod, only update a registry */
4824e400768SDavid Christensen 	RAMROD_DRV_CLR_ONLY,
4834e400768SDavid Christensen 	/* Configure HW according to the current object state */
4844e400768SDavid Christensen 	RAMROD_RESTORE,
4854e400768SDavid Christensen 	 /* Execute the next command now */
4864e400768SDavid Christensen 	RAMROD_EXEC,
4874e400768SDavid Christensen 	/* Don't add a new command and continue execution of posponed
4884e400768SDavid Christensen 	 * commands. If not set a new command will be added to the
4894e400768SDavid Christensen 	 * pending commands list.
4904e400768SDavid Christensen 	 */
4914e400768SDavid Christensen 	RAMROD_CONT,
4924e400768SDavid Christensen 	/* If there is another pending ramrod, wait until it finishes and
4934e400768SDavid Christensen 	 * re-try to submit this one. This flag can be set only in sleepable
4944e400768SDavid Christensen 	 * context, and should not be set from the context that completes the
4954e400768SDavid Christensen 	 * ramrods as deadlock will occur.
4964e400768SDavid Christensen 	 */
4974e400768SDavid Christensen 	RAMROD_RETRY,
4984e400768SDavid Christensen };
4994e400768SDavid Christensen 
5004e400768SDavid Christensen typedef enum {
5014e400768SDavid Christensen 	ECORE_OBJ_TYPE_RX,
5024e400768SDavid Christensen 	ECORE_OBJ_TYPE_TX,
5034e400768SDavid Christensen 	ECORE_OBJ_TYPE_RX_TX,
5044e400768SDavid Christensen } ecore_obj_type;
5054e400768SDavid Christensen 
5064e400768SDavid Christensen /* Public slow path states */
5074e400768SDavid Christensen enum {
5084e400768SDavid Christensen 	ECORE_FILTER_MAC_PENDING,
5094e400768SDavid Christensen 	ECORE_FILTER_VLAN_PENDING,
5104e400768SDavid Christensen 	ECORE_FILTER_VLAN_MAC_PENDING,
5114e400768SDavid Christensen 	ECORE_FILTER_RX_MODE_PENDING,
5124e400768SDavid Christensen 	ECORE_FILTER_RX_MODE_SCHED,
5134e400768SDavid Christensen 	ECORE_FILTER_ISCSI_ETH_START_SCHED,
5144e400768SDavid Christensen 	ECORE_FILTER_ISCSI_ETH_STOP_SCHED,
5154e400768SDavid Christensen 	ECORE_FILTER_FCOE_ETH_START_SCHED,
5164e400768SDavid Christensen 	ECORE_FILTER_FCOE_ETH_STOP_SCHED,
5174e400768SDavid Christensen 	ECORE_FILTER_BYPASS_RX_MODE_PENDING,
5184e400768SDavid Christensen 	ECORE_FILTER_BYPASS_MAC_PENDING,
5194e400768SDavid Christensen 	ECORE_FILTER_BYPASS_RSS_CONF_PENDING,
5204e400768SDavid Christensen 	ECORE_FILTER_MCAST_PENDING,
5214e400768SDavid Christensen 	ECORE_FILTER_MCAST_SCHED,
5224e400768SDavid Christensen 	ECORE_FILTER_RSS_CONF_PENDING,
5234e400768SDavid Christensen 	ECORE_AFEX_FCOE_Q_UPDATE_PENDING,
5244ef8ebfdSDavid C Somayajulu 	ECORE_AFEX_PENDING_VIFSET_MCP_ACK,
5254ef8ebfdSDavid C Somayajulu 	ECORE_FILTER_VXLAN_PENDING
5264e400768SDavid Christensen };
5274e400768SDavid Christensen 
5284e400768SDavid Christensen struct ecore_raw_obj {
5294e400768SDavid Christensen 	uint8_t		func_id;
5304e400768SDavid Christensen 
5314e400768SDavid Christensen 	/* Queue params */
5324e400768SDavid Christensen 	uint8_t		cl_id;
5334e400768SDavid Christensen 	uint32_t		cid;
5344e400768SDavid Christensen 
5354e400768SDavid Christensen 	/* Ramrod data buffer params */
5364e400768SDavid Christensen 	void		*rdata;
5374e400768SDavid Christensen 	ecore_dma_addr_t	rdata_mapping;
5384e400768SDavid Christensen 
5394e400768SDavid Christensen 	/* Ramrod state params */
5404e400768SDavid Christensen 	int		state;   /* "ramrod is pending" state bit */
5414e400768SDavid Christensen 	unsigned long	*pstate; /* pointer to state buffer */
5424e400768SDavid Christensen 
5434e400768SDavid Christensen 	ecore_obj_type	obj_type;
5444e400768SDavid Christensen 
5454e400768SDavid Christensen 	int (*wait_comp)(struct bxe_softc *sc,
5464e400768SDavid Christensen 			 struct ecore_raw_obj *o);
5474e400768SDavid Christensen 
5484e400768SDavid Christensen 	bool (*check_pending)(struct ecore_raw_obj *o);
5494e400768SDavid Christensen 	void (*clear_pending)(struct ecore_raw_obj *o);
5504e400768SDavid Christensen 	void (*set_pending)(struct ecore_raw_obj *o);
5514e400768SDavid Christensen };
5524e400768SDavid Christensen 
5534e400768SDavid Christensen /************************* VLAN-MAC commands related parameters ***************/
5544e400768SDavid Christensen struct ecore_mac_ramrod_data {
5554e400768SDavid Christensen 	uint8_t mac[ETH_ALEN];
5564e400768SDavid Christensen 	uint8_t is_inner_mac;
5574e400768SDavid Christensen };
5584e400768SDavid Christensen 
5594e400768SDavid Christensen struct ecore_vlan_ramrod_data {
5604e400768SDavid Christensen 	uint16_t vlan;
5614e400768SDavid Christensen };
5624e400768SDavid Christensen 
5634e400768SDavid Christensen struct ecore_vlan_mac_ramrod_data {
5644e400768SDavid Christensen 	uint8_t mac[ETH_ALEN];
5654e400768SDavid Christensen 	uint8_t is_inner_mac;
5664e400768SDavid Christensen 	uint16_t vlan;
5674e400768SDavid Christensen };
5684e400768SDavid Christensen 
5694ef8ebfdSDavid C Somayajulu struct ecore_vxlan_fltr_ramrod_data {
5704ef8ebfdSDavid C Somayajulu 	uint8_t innermac[ETH_ALEN];
5714ef8ebfdSDavid C Somayajulu 	uint32_t vni;
5724ef8ebfdSDavid C Somayajulu };
5734ef8ebfdSDavid C Somayajulu 
5744e400768SDavid Christensen union ecore_classification_ramrod_data {
5754e400768SDavid Christensen 	struct ecore_mac_ramrod_data mac;
5764e400768SDavid Christensen 	struct ecore_vlan_ramrod_data vlan;
5774e400768SDavid Christensen 	struct ecore_vlan_mac_ramrod_data vlan_mac;
5784ef8ebfdSDavid C Somayajulu 	struct ecore_vxlan_fltr_ramrod_data vxlan_fltr;
5794e400768SDavid Christensen };
5804e400768SDavid Christensen 
5814e400768SDavid Christensen /* VLAN_MAC commands */
5824e400768SDavid Christensen enum ecore_vlan_mac_cmd {
5834e400768SDavid Christensen 	ECORE_VLAN_MAC_ADD,
5844e400768SDavid Christensen 	ECORE_VLAN_MAC_DEL,
5854e400768SDavid Christensen 	ECORE_VLAN_MAC_MOVE,
5864e400768SDavid Christensen };
5874e400768SDavid Christensen 
5884e400768SDavid Christensen struct ecore_vlan_mac_data {
5894e400768SDavid Christensen 	/* Requested command: ECORE_VLAN_MAC_XX */
5904e400768SDavid Christensen 	enum ecore_vlan_mac_cmd cmd;
5914e400768SDavid Christensen 	/* used to contain the data related vlan_mac_flags bits from
5924e400768SDavid Christensen 	 * ramrod parameters.
5934e400768SDavid Christensen 	 */
5944e400768SDavid Christensen 	unsigned long vlan_mac_flags;
5954e400768SDavid Christensen 
5964e400768SDavid Christensen 	/* Needed for MOVE command */
5974e400768SDavid Christensen 	struct ecore_vlan_mac_obj *target_obj;
5984e400768SDavid Christensen 
5994e400768SDavid Christensen 	union ecore_classification_ramrod_data u;
6004e400768SDavid Christensen };
6014e400768SDavid Christensen 
6024e400768SDavid Christensen /*************************** Exe Queue obj ************************************/
6034e400768SDavid Christensen union ecore_exe_queue_cmd_data {
6044e400768SDavid Christensen 	struct ecore_vlan_mac_data vlan_mac;
6054e400768SDavid Christensen 
6064e400768SDavid Christensen 	struct {
6074e400768SDavid Christensen 		/* TODO */
6084e400768SDavid Christensen 	} mcast;
6094e400768SDavid Christensen };
6104e400768SDavid Christensen 
6114e400768SDavid Christensen struct ecore_exeq_elem {
6124e400768SDavid Christensen 	ecore_list_entry_t		link;
6134e400768SDavid Christensen 
6144e400768SDavid Christensen 	/* Length of this element in the exe_chunk. */
6154e400768SDavid Christensen 	int				cmd_len;
6164e400768SDavid Christensen 
6174e400768SDavid Christensen 	union ecore_exe_queue_cmd_data	cmd_data;
6184e400768SDavid Christensen };
6194e400768SDavid Christensen 
6204e400768SDavid Christensen union ecore_qable_obj;
6214e400768SDavid Christensen 
6224e400768SDavid Christensen union ecore_exeq_comp_elem {
6234e400768SDavid Christensen 	union event_ring_elem *elem;
6244e400768SDavid Christensen };
6254e400768SDavid Christensen 
6264e400768SDavid Christensen struct ecore_exe_queue_obj;
6274e400768SDavid Christensen 
6284e400768SDavid Christensen typedef int (*exe_q_validate)(struct bxe_softc *sc,
6294e400768SDavid Christensen 			      union ecore_qable_obj *o,
6304e400768SDavid Christensen 			      struct ecore_exeq_elem *elem);
6314e400768SDavid Christensen 
6324e400768SDavid Christensen typedef int (*exe_q_remove)(struct bxe_softc *sc,
6334e400768SDavid Christensen 			    union ecore_qable_obj *o,
6344e400768SDavid Christensen 			    struct ecore_exeq_elem *elem);
6354e400768SDavid Christensen 
6364e400768SDavid Christensen /* Return positive if entry was optimized, 0 - if not, negative
6374e400768SDavid Christensen  * in case of an error.
6384e400768SDavid Christensen  */
6394e400768SDavid Christensen typedef int (*exe_q_optimize)(struct bxe_softc *sc,
6404e400768SDavid Christensen 			      union ecore_qable_obj *o,
6414e400768SDavid Christensen 			      struct ecore_exeq_elem *elem);
6424e400768SDavid Christensen typedef int (*exe_q_execute)(struct bxe_softc *sc,
6434e400768SDavid Christensen 			     union ecore_qable_obj *o,
6444e400768SDavid Christensen 			     ecore_list_t *exe_chunk,
6454e400768SDavid Christensen 			     unsigned long *ramrod_flags);
6464e400768SDavid Christensen typedef struct ecore_exeq_elem *
6474e400768SDavid Christensen 			(*exe_q_get)(struct ecore_exe_queue_obj *o,
6484e400768SDavid Christensen 				     struct ecore_exeq_elem *elem);
6494e400768SDavid Christensen 
6504e400768SDavid Christensen struct ecore_exe_queue_obj {
6514e400768SDavid Christensen 	/* Commands pending for an execution. */
6524e400768SDavid Christensen 	ecore_list_t	exe_queue;
6534e400768SDavid Christensen 
6544e400768SDavid Christensen 	/* Commands pending for an completion. */
6554e400768SDavid Christensen 	ecore_list_t	pending_comp;
6564e400768SDavid Christensen 
6574e400768SDavid Christensen 	ECORE_MUTEX_SPIN		lock;
6584e400768SDavid Christensen 
6594e400768SDavid Christensen 	/* Maximum length of commands' list for one execution */
6604e400768SDavid Christensen 	int			exe_chunk_len;
6614e400768SDavid Christensen 
6624e400768SDavid Christensen 	union ecore_qable_obj	*owner;
6634e400768SDavid Christensen 
6644e400768SDavid Christensen 	/****** Virtual functions ******/
6654e400768SDavid Christensen 	/**
6664e400768SDavid Christensen 	 * Called before commands execution for commands that are really
6674e400768SDavid Christensen 	 * going to be executed (after 'optimize').
6684e400768SDavid Christensen 	 *
6694e400768SDavid Christensen 	 * Must run under exe_queue->lock
6704e400768SDavid Christensen 	 */
6714e400768SDavid Christensen 	exe_q_validate		validate;
6724e400768SDavid Christensen 
6734e400768SDavid Christensen 	/**
6744e400768SDavid Christensen 	 * Called before removing pending commands, cleaning allocated
6754e400768SDavid Christensen 	 * resources (e.g., credits from validate)
6764e400768SDavid Christensen 	 */
6774e400768SDavid Christensen 	 exe_q_remove		remove;
6784e400768SDavid Christensen 
6794e400768SDavid Christensen 	/**
6804e400768SDavid Christensen 	 * This will try to cancel the current pending commands list
6814e400768SDavid Christensen 	 * considering the new command.
6824e400768SDavid Christensen 	 *
6834e400768SDavid Christensen 	 * Returns the number of optimized commands or a negative error code
6844e400768SDavid Christensen 	 *
6854e400768SDavid Christensen 	 * Must run under exe_queue->lock
6864e400768SDavid Christensen 	 */
6874e400768SDavid Christensen 	exe_q_optimize		optimize;
6884e400768SDavid Christensen 
6894e400768SDavid Christensen 	/**
6904e400768SDavid Christensen 	 * Run the next commands chunk (owner specific).
6914e400768SDavid Christensen 	 */
6924e400768SDavid Christensen 	exe_q_execute		execute;
6934e400768SDavid Christensen 
6944e400768SDavid Christensen 	/**
6954e400768SDavid Christensen 	 * Return the exe_queue element containing the specific command
6964e400768SDavid Christensen 	 * if any. Otherwise return NULL.
6974e400768SDavid Christensen 	 */
6984e400768SDavid Christensen 	exe_q_get		get;
6994e400768SDavid Christensen };
7004e400768SDavid Christensen /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
7014e400768SDavid Christensen /*
7024e400768SDavid Christensen  * Element in the VLAN_MAC registry list having all current configured
7034e400768SDavid Christensen  * rules.
7044e400768SDavid Christensen  */
7054e400768SDavid Christensen struct ecore_vlan_mac_registry_elem {
7064e400768SDavid Christensen 	ecore_list_entry_t	link;
7074e400768SDavid Christensen 
7084e400768SDavid Christensen 	/* Used to store the cam offset used for the mac/vlan/vlan-mac.
7094e400768SDavid Christensen 	 * Relevant for 57710 and 57711 only. VLANs and MACs share the
7104e400768SDavid Christensen 	 * same CAM for these chips.
7114e400768SDavid Christensen 	 */
7124e400768SDavid Christensen 	int			cam_offset;
7134e400768SDavid Christensen 
7144e400768SDavid Christensen 	/* Needed for DEL and RESTORE flows */
7154e400768SDavid Christensen 	unsigned long		vlan_mac_flags;
7164e400768SDavid Christensen 
7174e400768SDavid Christensen 	union ecore_classification_ramrod_data u;
7184e400768SDavid Christensen };
7194e400768SDavid Christensen 
7204e400768SDavid Christensen /* Bits representing VLAN_MAC commands specific flags */
7214e400768SDavid Christensen enum {
7224e400768SDavid Christensen 	ECORE_UC_LIST_MAC,
7234e400768SDavid Christensen 	ECORE_ETH_MAC,
7244e400768SDavid Christensen 	ECORE_ISCSI_ETH_MAC,
7254e400768SDavid Christensen 	ECORE_NETQ_ETH_MAC,
7264e400768SDavid Christensen 	ECORE_DONT_CONSUME_CAM_CREDIT,
7274e400768SDavid Christensen 	ECORE_DONT_CONSUME_CAM_CREDIT_DEST,
7284e400768SDavid Christensen };
7294ef8ebfdSDavid C Somayajulu /* When looking for matching filters, some flags are not interesting */
7304ef8ebfdSDavid C Somayajulu #define ECORE_VLAN_MAC_CMP_MASK	(1 << ECORE_UC_LIST_MAC | \
7314ef8ebfdSDavid C Somayajulu 				 1 << ECORE_ETH_MAC | \
7324ef8ebfdSDavid C Somayajulu 				 1 << ECORE_ISCSI_ETH_MAC | \
7334ef8ebfdSDavid C Somayajulu 				 1 << ECORE_NETQ_ETH_MAC)
7344ef8ebfdSDavid C Somayajulu #define ECORE_VLAN_MAC_CMP_FLAGS(flags) \
7354ef8ebfdSDavid C Somayajulu 	((flags) & ECORE_VLAN_MAC_CMP_MASK)
7364e400768SDavid Christensen 
7374e400768SDavid Christensen struct ecore_vlan_mac_ramrod_params {
7384e400768SDavid Christensen 	/* Object to run the command from */
7394e400768SDavid Christensen 	struct ecore_vlan_mac_obj *vlan_mac_obj;
7404e400768SDavid Christensen 
7414e400768SDavid Christensen 	/* General command flags: COMP_WAIT, etc. */
7424e400768SDavid Christensen 	unsigned long ramrod_flags;
7434e400768SDavid Christensen 
7444e400768SDavid Christensen 	/* Command specific configuration request */
7454e400768SDavid Christensen 	struct ecore_vlan_mac_data user_req;
7464e400768SDavid Christensen };
7474e400768SDavid Christensen 
7484e400768SDavid Christensen struct ecore_vlan_mac_obj {
7494e400768SDavid Christensen 	struct ecore_raw_obj raw;
7504e400768SDavid Christensen 
7514e400768SDavid Christensen 	/* Bookkeeping list: will prevent the addition of already existing
7524e400768SDavid Christensen 	 * entries.
7534e400768SDavid Christensen 	 */
7544e400768SDavid Christensen 	ecore_list_t		head;
7554e400768SDavid Christensen 	/* Implement a simple reader/writer lock on the head list.
7564e400768SDavid Christensen 	 * all these fields should only be accessed under the exe_queue lock
7574e400768SDavid Christensen 	 */
7584e400768SDavid Christensen 	uint8_t		head_reader; /* Num. of readers accessing head list */
7594e400768SDavid Christensen 	bool		head_exe_request; /* Pending execution request. */
7604e400768SDavid Christensen 	unsigned long	saved_ramrod_flags; /* Ramrods of pending execution */
7614e400768SDavid Christensen 
7624e400768SDavid Christensen 	/* Execution queue interface instance */
7634e400768SDavid Christensen 	struct ecore_exe_queue_obj	exe_queue;
7644e400768SDavid Christensen 
7654e400768SDavid Christensen 	/* MACs credit pool */
7664e400768SDavid Christensen 	struct ecore_credit_pool_obj	*macs_pool;
7674e400768SDavid Christensen 
7684e400768SDavid Christensen 	/* VLANs credit pool */
7694e400768SDavid Christensen 	struct ecore_credit_pool_obj	*vlans_pool;
7704e400768SDavid Christensen 
7714e400768SDavid Christensen 	/* RAMROD command to be used */
7724e400768SDavid Christensen 	int				ramrod_cmd;
7734e400768SDavid Christensen 
7744e400768SDavid Christensen 	/* copy first n elements onto preallocated buffer
7754e400768SDavid Christensen 	 *
7764e400768SDavid Christensen 	 * @param n number of elements to get
7774e400768SDavid Christensen 	 * @param buf buffer preallocated by caller into which elements
7784e400768SDavid Christensen 	 *            will be copied. Note elements are 4-byte aligned
7794e400768SDavid Christensen 	 *            so buffer size must be able to accommodate the
7804e400768SDavid Christensen 	 *            aligned elements.
7814e400768SDavid Christensen 	 *
7824e400768SDavid Christensen 	 * @return number of copied bytes
7834e400768SDavid Christensen 	 */
7844e400768SDavid Christensen 
7854e400768SDavid Christensen 	int (*get_n_elements)(struct bxe_softc *sc,
7864e400768SDavid Christensen 			      struct ecore_vlan_mac_obj *o, int n, uint8_t *base,
7874e400768SDavid Christensen 			      uint8_t stride, uint8_t size);
7884e400768SDavid Christensen 
7894e400768SDavid Christensen 	/**
7904e400768SDavid Christensen 	 * Checks if ADD-ramrod with the given params may be performed.
7914e400768SDavid Christensen 	 *
7924e400768SDavid Christensen 	 * @return zero if the element may be added
7934e400768SDavid Christensen 	 */
7944e400768SDavid Christensen 
7954e400768SDavid Christensen 	int (*check_add)(struct bxe_softc *sc,
7964e400768SDavid Christensen 			 struct ecore_vlan_mac_obj *o,
7974e400768SDavid Christensen 			 union ecore_classification_ramrod_data *data);
7984e400768SDavid Christensen 
7994e400768SDavid Christensen 	/**
8004e400768SDavid Christensen 	 * Checks if DEL-ramrod with the given params may be performed.
8014e400768SDavid Christensen 	 *
8024e400768SDavid Christensen 	 * @return TRUE if the element may be deleted
8034e400768SDavid Christensen 	 */
8044e400768SDavid Christensen 	struct ecore_vlan_mac_registry_elem *
8054e400768SDavid Christensen 		(*check_del)(struct bxe_softc *sc,
8064e400768SDavid Christensen 			     struct ecore_vlan_mac_obj *o,
8074e400768SDavid Christensen 			     union ecore_classification_ramrod_data *data);
8084e400768SDavid Christensen 
8094e400768SDavid Christensen 	/**
8104e400768SDavid Christensen 	 * Checks if DEL-ramrod with the given params may be performed.
8114e400768SDavid Christensen 	 *
8124e400768SDavid Christensen 	 * @return TRUE if the element may be deleted
8134e400768SDavid Christensen 	 */
8144e400768SDavid Christensen 	bool (*check_move)(struct bxe_softc *sc,
8154e400768SDavid Christensen 			   struct ecore_vlan_mac_obj *src_o,
8164e400768SDavid Christensen 			   struct ecore_vlan_mac_obj *dst_o,
8174e400768SDavid Christensen 			   union ecore_classification_ramrod_data *data);
8184e400768SDavid Christensen 
8194e400768SDavid Christensen 	/**
8204e400768SDavid Christensen 	 *  Update the relevant credit object(s) (consume/return
8214e400768SDavid Christensen 	 *  correspondingly).
8224e400768SDavid Christensen 	 */
8234e400768SDavid Christensen 	bool (*get_credit)(struct ecore_vlan_mac_obj *o);
8244e400768SDavid Christensen 	bool (*put_credit)(struct ecore_vlan_mac_obj *o);
8254e400768SDavid Christensen 	bool (*get_cam_offset)(struct ecore_vlan_mac_obj *o, int *offset);
8264e400768SDavid Christensen 	bool (*put_cam_offset)(struct ecore_vlan_mac_obj *o, int offset);
8274e400768SDavid Christensen 
8284e400768SDavid Christensen 	/**
8294e400768SDavid Christensen 	 * Configures one rule in the ramrod data buffer.
8304e400768SDavid Christensen 	 */
8314e400768SDavid Christensen 	void (*set_one_rule)(struct bxe_softc *sc,
8324e400768SDavid Christensen 			     struct ecore_vlan_mac_obj *o,
8334e400768SDavid Christensen 			     struct ecore_exeq_elem *elem, int rule_idx,
8344e400768SDavid Christensen 			     int cam_offset);
8354e400768SDavid Christensen 
8364e400768SDavid Christensen 	/**
8374e400768SDavid Christensen 	*  Delete all configured elements having the given
8384e400768SDavid Christensen 	*  vlan_mac_flags specification. Assumes no pending for
8394e400768SDavid Christensen 	*  execution commands. Will schedule all all currently
8404e400768SDavid Christensen 	*  configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
8414e400768SDavid Christensen 	*  specification for deletion and will use the given
8424e400768SDavid Christensen 	*  ramrod_flags for the last DEL operation.
8434e400768SDavid Christensen 	 *
8444e400768SDavid Christensen 	 * @param sc
8454e400768SDavid Christensen 	 * @param o
8464e400768SDavid Christensen 	 * @param ramrod_flags RAMROD_XX flags
8474e400768SDavid Christensen 	 *
8484e400768SDavid Christensen 	 * @return 0 if the last operation has completed successfully
8494e400768SDavid Christensen 	 *         and there are no more elements left, positive value
8504e400768SDavid Christensen 	 *         if there are pending for completion commands,
8514e400768SDavid Christensen 	 *         negative value in case of failure.
8524e400768SDavid Christensen 	 */
8534e400768SDavid Christensen 	int (*delete_all)(struct bxe_softc *sc,
8544e400768SDavid Christensen 			  struct ecore_vlan_mac_obj *o,
8554e400768SDavid Christensen 			  unsigned long *vlan_mac_flags,
8564e400768SDavid Christensen 			  unsigned long *ramrod_flags);
8574e400768SDavid Christensen 
8584e400768SDavid Christensen 	/**
8594e400768SDavid Christensen 	 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
8604e400768SDavid Christensen 	 * configured elements list.
8614e400768SDavid Christensen 	 *
8624e400768SDavid Christensen 	 * @param sc
8634e400768SDavid Christensen 	 * @param p Command parameters (RAMROD_COMP_WAIT bit in
8644e400768SDavid Christensen 	 *          ramrod_flags is only taken into an account)
8654e400768SDavid Christensen 	 * @param ppos a pointer to the cookie that should be given back in the
8664e400768SDavid Christensen 	 *        next call to make function handle the next element. If
8674e400768SDavid Christensen 	 *        *ppos is set to NULL it will restart the iterator.
8684e400768SDavid Christensen 	 *        If returned *ppos == NULL this means that the last
8694e400768SDavid Christensen 	 *        element has been handled.
8704e400768SDavid Christensen 	 *
8714e400768SDavid Christensen 	 * @return int
8724e400768SDavid Christensen 	 */
8734e400768SDavid Christensen 	int (*restore)(struct bxe_softc *sc,
8744e400768SDavid Christensen 		       struct ecore_vlan_mac_ramrod_params *p,
8754e400768SDavid Christensen 		       struct ecore_vlan_mac_registry_elem **ppos);
8764e400768SDavid Christensen 
8774e400768SDavid Christensen 	/**
8784e400768SDavid Christensen 	 * Should be called on a completion arrival.
8794e400768SDavid Christensen 	 *
8804e400768SDavid Christensen 	 * @param sc
8814e400768SDavid Christensen 	 * @param o
8824e400768SDavid Christensen 	 * @param cqe Completion element we are handling
8834e400768SDavid Christensen 	 * @param ramrod_flags if RAMROD_CONT is set the next bulk of
8844e400768SDavid Christensen 	 *		       pending commands will be executed.
8854e400768SDavid Christensen 	 *		       RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
8864e400768SDavid Christensen 	 *		       may also be set if needed.
8874e400768SDavid Christensen 	 *
8884e400768SDavid Christensen 	 * @return 0 if there are neither pending nor waiting for
8894e400768SDavid Christensen 	 *         completion commands. Positive value if there are
8904e400768SDavid Christensen 	 *         pending for execution or for completion commands.
8914e400768SDavid Christensen 	 *         Negative value in case of an error (including an
8924e400768SDavid Christensen 	 *         error in the cqe).
8934e400768SDavid Christensen 	 */
8944e400768SDavid Christensen 	int (*complete)(struct bxe_softc *sc, struct ecore_vlan_mac_obj *o,
8954e400768SDavid Christensen 			union event_ring_elem *cqe,
8964e400768SDavid Christensen 			unsigned long *ramrod_flags);
8974e400768SDavid Christensen 
8984e400768SDavid Christensen 	/**
8994e400768SDavid Christensen 	 * Wait for completion of all commands. Don't schedule new ones,
9004e400768SDavid Christensen 	 * just wait. It assumes that the completion code will schedule
9014e400768SDavid Christensen 	 * for new commands.
9024e400768SDavid Christensen 	 */
9034e400768SDavid Christensen 	int (*wait)(struct bxe_softc *sc, struct ecore_vlan_mac_obj *o);
9044e400768SDavid Christensen };
9054e400768SDavid Christensen 
9064e400768SDavid Christensen enum {
9074e400768SDavid Christensen 	ECORE_LLH_CAM_ISCSI_ETH_LINE = 0,
9084e400768SDavid Christensen 	ECORE_LLH_CAM_ETH_LINE,
9094e400768SDavid Christensen 	ECORE_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2
9104e400768SDavid Christensen };
9114e400768SDavid Christensen 
9124e400768SDavid Christensen void ecore_set_mac_in_nig(struct bxe_softc *sc,
9134e400768SDavid Christensen 			  bool add, unsigned char *dev_addr, int index);
9144e400768SDavid Christensen 
9154e400768SDavid Christensen /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
9164e400768SDavid Christensen 
9174e400768SDavid Christensen /* RX_MODE ramrod special flags: set in rx_mode_flags field in
9184e400768SDavid Christensen  * a ecore_rx_mode_ramrod_params.
9194e400768SDavid Christensen  */
9204e400768SDavid Christensen enum {
9214e400768SDavid Christensen 	ECORE_RX_MODE_FCOE_ETH,
9224e400768SDavid Christensen 	ECORE_RX_MODE_ISCSI_ETH,
9234e400768SDavid Christensen };
9244e400768SDavid Christensen 
9254e400768SDavid Christensen enum {
9264e400768SDavid Christensen 	ECORE_ACCEPT_UNICAST,
9274e400768SDavid Christensen 	ECORE_ACCEPT_MULTICAST,
9284e400768SDavid Christensen 	ECORE_ACCEPT_ALL_UNICAST,
9294e400768SDavid Christensen 	ECORE_ACCEPT_ALL_MULTICAST,
9304e400768SDavid Christensen 	ECORE_ACCEPT_BROADCAST,
9314e400768SDavid Christensen 	ECORE_ACCEPT_UNMATCHED,
9324e400768SDavid Christensen 	ECORE_ACCEPT_ANY_VLAN
9334e400768SDavid Christensen };
9344e400768SDavid Christensen 
9354e400768SDavid Christensen struct ecore_rx_mode_ramrod_params {
9364e400768SDavid Christensen 	struct ecore_rx_mode_obj *rx_mode_obj;
9374e400768SDavid Christensen 	unsigned long *pstate;
9384e400768SDavid Christensen 	int state;
9394e400768SDavid Christensen 	uint8_t cl_id;
9404e400768SDavid Christensen 	uint32_t cid;
9414e400768SDavid Christensen 	uint8_t func_id;
9424e400768SDavid Christensen 	unsigned long ramrod_flags;
9434e400768SDavid Christensen 	unsigned long rx_mode_flags;
9444e400768SDavid Christensen 
9454e400768SDavid Christensen 	/* rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
9464e400768SDavid Christensen 	 * a tstorm_eth_mac_filter_config (e1x).
9474e400768SDavid Christensen 	 */
9484e400768SDavid Christensen 	void *rdata;
9494e400768SDavid Christensen 	ecore_dma_addr_t rdata_mapping;
9504e400768SDavid Christensen 
9514e400768SDavid Christensen 	/* Rx mode settings */
9524e400768SDavid Christensen 	unsigned long rx_accept_flags;
9534e400768SDavid Christensen 
9544e400768SDavid Christensen 	/* internal switching settings */
9554e400768SDavid Christensen 	unsigned long tx_accept_flags;
9564e400768SDavid Christensen };
9574e400768SDavid Christensen 
9584e400768SDavid Christensen struct ecore_rx_mode_obj {
9594e400768SDavid Christensen 	int (*config_rx_mode)(struct bxe_softc *sc,
9604e400768SDavid Christensen 			      struct ecore_rx_mode_ramrod_params *p);
9614e400768SDavid Christensen 
9624e400768SDavid Christensen 	int (*wait_comp)(struct bxe_softc *sc,
9634e400768SDavid Christensen 			 struct ecore_rx_mode_ramrod_params *p);
9644e400768SDavid Christensen };
9654e400768SDavid Christensen 
9664e400768SDavid Christensen /********************** Set multicast group ***********************************/
9674e400768SDavid Christensen 
9684e400768SDavid Christensen struct ecore_mcast_list_elem {
9694e400768SDavid Christensen 	ecore_list_entry_t link;
9704e400768SDavid Christensen 	uint8_t *mac;
9714e400768SDavid Christensen };
9724e400768SDavid Christensen 
9734e400768SDavid Christensen union ecore_mcast_config_data {
9744e400768SDavid Christensen 	uint8_t *mac;
9754e400768SDavid Christensen 	uint8_t bin; /* used in a RESTORE flow */
9764e400768SDavid Christensen };
9774e400768SDavid Christensen 
9784e400768SDavid Christensen struct ecore_mcast_ramrod_params {
9794e400768SDavid Christensen 	struct ecore_mcast_obj *mcast_obj;
9804e400768SDavid Christensen 
9814e400768SDavid Christensen 	/* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
9824e400768SDavid Christensen 	unsigned long ramrod_flags;
9834e400768SDavid Christensen 
9844e400768SDavid Christensen 	ecore_list_t mcast_list; /* list of struct ecore_mcast_list_elem */
9854e400768SDavid Christensen 	/** TODO:
9864e400768SDavid Christensen 	 *      - rename it to macs_num.
9874e400768SDavid Christensen 	 *      - Add a new command type for handling pending commands
9884e400768SDavid Christensen 	 *        (remove "zero semantics").
9894e400768SDavid Christensen 	 *
9904e400768SDavid Christensen 	 *  Length of mcast_list. If zero and ADD_CONT command - post
9914e400768SDavid Christensen 	 *  pending commands.
9924e400768SDavid Christensen 	 */
9934e400768SDavid Christensen 	int mcast_list_len;
9944e400768SDavid Christensen };
9954e400768SDavid Christensen 
9964e400768SDavid Christensen enum ecore_mcast_cmd {
9974e400768SDavid Christensen 	ECORE_MCAST_CMD_ADD,
9984e400768SDavid Christensen 	ECORE_MCAST_CMD_CONT,
9994e400768SDavid Christensen 	ECORE_MCAST_CMD_DEL,
10004e400768SDavid Christensen 	ECORE_MCAST_CMD_RESTORE,
10014e400768SDavid Christensen };
10024e400768SDavid Christensen 
10034e400768SDavid Christensen struct ecore_mcast_obj {
10044e400768SDavid Christensen 	struct ecore_raw_obj raw;
10054e400768SDavid Christensen 
10064e400768SDavid Christensen 	union {
10074e400768SDavid Christensen 		struct {
10084e400768SDavid Christensen 		#define ECORE_MCAST_BINS_NUM	256
10094e400768SDavid Christensen 		#define ECORE_MCAST_VEC_SZ	(ECORE_MCAST_BINS_NUM / 64)
10104e400768SDavid Christensen 			uint64_t vec[ECORE_MCAST_VEC_SZ];
10114e400768SDavid Christensen 
10124e400768SDavid Christensen 			/** Number of BINs to clear. Should be updated
10134e400768SDavid Christensen 			 *  immediately when a command arrives in order to
10144e400768SDavid Christensen 			 *  properly create DEL commands.
10154e400768SDavid Christensen 			 */
10164e400768SDavid Christensen 			int num_bins_set;
10174e400768SDavid Christensen 		} aprox_match;
10184e400768SDavid Christensen 
10194e400768SDavid Christensen 		struct {
10204e400768SDavid Christensen 			ecore_list_t macs;
10214e400768SDavid Christensen 			int num_macs_set;
10224e400768SDavid Christensen 		} exact_match;
10234e400768SDavid Christensen 	} registry;
10244e400768SDavid Christensen 
10254e400768SDavid Christensen 	/* Pending commands */
10264e400768SDavid Christensen 	ecore_list_t pending_cmds_head;
10274e400768SDavid Christensen 
10284e400768SDavid Christensen 	/* A state that is set in raw.pstate, when there are pending commands */
10294e400768SDavid Christensen 	int sched_state;
10304e400768SDavid Christensen 
10314e400768SDavid Christensen 	/* Maximal number of mcast MACs configured in one command */
10324e400768SDavid Christensen 	int max_cmd_len;
10334e400768SDavid Christensen 
10344e400768SDavid Christensen 	/* Total number of currently pending MACs to configure: both
10354e400768SDavid Christensen 	 * in the pending commands list and in the current command.
10364e400768SDavid Christensen 	 */
10374e400768SDavid Christensen 	int total_pending_num;
10384e400768SDavid Christensen 
10394e400768SDavid Christensen 	uint8_t engine_id;
10404e400768SDavid Christensen 
10414e400768SDavid Christensen 	/**
10424e400768SDavid Christensen 	 * @param cmd command to execute (ECORE_MCAST_CMD_X, see above)
10434e400768SDavid Christensen 	 */
10444e400768SDavid Christensen 	int (*config_mcast)(struct bxe_softc *sc,
10454e400768SDavid Christensen 			    struct ecore_mcast_ramrod_params *p,
10464e400768SDavid Christensen 			    enum ecore_mcast_cmd cmd);
10474e400768SDavid Christensen 
10484e400768SDavid Christensen 	/**
10494e400768SDavid Christensen 	 * Fills the ramrod data during the RESTORE flow.
10504e400768SDavid Christensen 	 *
10514e400768SDavid Christensen 	 * @param sc
10524e400768SDavid Christensen 	 * @param o
10534e400768SDavid Christensen 	 * @param start_idx Registry index to start from
10544e400768SDavid Christensen 	 * @param rdata_idx Index in the ramrod data to start from
10554e400768SDavid Christensen 	 *
10564e400768SDavid Christensen 	 * @return -1 if we handled the whole registry or index of the last
10574e400768SDavid Christensen 	 *         handled registry element.
10584e400768SDavid Christensen 	 */
10594e400768SDavid Christensen 	int (*hdl_restore)(struct bxe_softc *sc, struct ecore_mcast_obj *o,
10604e400768SDavid Christensen 			   int start_bin, int *rdata_idx);
10614e400768SDavid Christensen 
10624e400768SDavid Christensen 	int (*enqueue_cmd)(struct bxe_softc *sc, struct ecore_mcast_obj *o,
10634e400768SDavid Christensen 			   struct ecore_mcast_ramrod_params *p,
10644e400768SDavid Christensen 			   enum ecore_mcast_cmd cmd);
10654e400768SDavid Christensen 
10664e400768SDavid Christensen 	void (*set_one_rule)(struct bxe_softc *sc,
10674e400768SDavid Christensen 			     struct ecore_mcast_obj *o, int idx,
10684e400768SDavid Christensen 			     union ecore_mcast_config_data *cfg_data,
10694e400768SDavid Christensen 			     enum ecore_mcast_cmd cmd);
10704e400768SDavid Christensen 
10714e400768SDavid Christensen 	/** Checks if there are more mcast MACs to be set or a previous
10724e400768SDavid Christensen 	 *  command is still pending.
10734e400768SDavid Christensen 	 */
10744e400768SDavid Christensen 	bool (*check_pending)(struct ecore_mcast_obj *o);
10754e400768SDavid Christensen 
10764e400768SDavid Christensen 	/**
10774e400768SDavid Christensen 	 * Set/Clear/Check SCHEDULED state of the object
10784e400768SDavid Christensen 	 */
10794e400768SDavid Christensen 	void (*set_sched)(struct ecore_mcast_obj *o);
10804e400768SDavid Christensen 	void (*clear_sched)(struct ecore_mcast_obj *o);
10814e400768SDavid Christensen 	bool (*check_sched)(struct ecore_mcast_obj *o);
10824e400768SDavid Christensen 
10834e400768SDavid Christensen 	/* Wait until all pending commands complete */
10844e400768SDavid Christensen 	int (*wait_comp)(struct bxe_softc *sc, struct ecore_mcast_obj *o);
10854e400768SDavid Christensen 
10864e400768SDavid Christensen 	/**
10874e400768SDavid Christensen 	 * Handle the internal object counters needed for proper
10884e400768SDavid Christensen 	 * commands handling. Checks that the provided parameters are
10894e400768SDavid Christensen 	 * feasible.
10904e400768SDavid Christensen 	 */
10914e400768SDavid Christensen 	int (*validate)(struct bxe_softc *sc,
10924e400768SDavid Christensen 			struct ecore_mcast_ramrod_params *p,
10934e400768SDavid Christensen 			enum ecore_mcast_cmd cmd);
10944e400768SDavid Christensen 
10954e400768SDavid Christensen 	/**
10964e400768SDavid Christensen 	 * Restore the values of internal counters in case of a failure.
10974e400768SDavid Christensen 	 */
10984e400768SDavid Christensen 	void (*revert)(struct bxe_softc *sc,
10994e400768SDavid Christensen 		       struct ecore_mcast_ramrod_params *p,
11004e400768SDavid Christensen 		       int old_num_bins);
11014e400768SDavid Christensen 
11024e400768SDavid Christensen 	int (*get_registry_size)(struct ecore_mcast_obj *o);
11034e400768SDavid Christensen 	void (*set_registry_size)(struct ecore_mcast_obj *o, int n);
11044e400768SDavid Christensen };
11054e400768SDavid Christensen 
11064e400768SDavid Christensen /*************************** Credit handling **********************************/
11074e400768SDavid Christensen struct ecore_credit_pool_obj {
11084e400768SDavid Christensen 
11094e400768SDavid Christensen 	/* Current amount of credit in the pool */
11104e400768SDavid Christensen 	ecore_atomic_t	credit;
11114e400768SDavid Christensen 
11124e400768SDavid Christensen 	/* Maximum allowed credit. put() will check against it. */
11134e400768SDavid Christensen 	int		pool_sz;
11144e400768SDavid Christensen 
11154e400768SDavid Christensen 	/* Allocate a pool table statically.
11164e400768SDavid Christensen 	 *
11174e400768SDavid Christensen 	 * Currently the maximum allowed size is MAX_MAC_CREDIT_E2(272)
11184e400768SDavid Christensen 	 *
11194e400768SDavid Christensen 	 * The set bit in the table will mean that the entry is available.
11204e400768SDavid Christensen 	 */
11214e400768SDavid Christensen #define ECORE_POOL_VEC_SIZE	(MAX_MAC_CREDIT_E2 / 64)
11224e400768SDavid Christensen 	uint64_t		pool_mirror[ECORE_POOL_VEC_SIZE];
11234e400768SDavid Christensen 
11244e400768SDavid Christensen 	/* Base pool offset (initialized differently */
11254e400768SDavid Christensen 	int		base_pool_offset;
11264e400768SDavid Christensen 
11274e400768SDavid Christensen 	/**
11284e400768SDavid Christensen 	 * Get the next free pool entry.
11294e400768SDavid Christensen 	 *
11304e400768SDavid Christensen 	 * @return TRUE if there was a free entry in the pool
11314e400768SDavid Christensen 	 */
11324e400768SDavid Christensen 	bool (*get_entry)(struct ecore_credit_pool_obj *o, int *entry);
11334e400768SDavid Christensen 
11344e400768SDavid Christensen 	/**
11354e400768SDavid Christensen 	 * Return the entry back to the pool.
11364e400768SDavid Christensen 	 *
11374e400768SDavid Christensen 	 * @return TRUE if entry is legal and has been successfully
11384e400768SDavid Christensen 	 *         returned to the pool.
11394e400768SDavid Christensen 	 */
11404e400768SDavid Christensen 	bool (*put_entry)(struct ecore_credit_pool_obj *o, int entry);
11414e400768SDavid Christensen 
11424e400768SDavid Christensen 	/**
11434e400768SDavid Christensen 	 * Get the requested amount of credit from the pool.
11444e400768SDavid Christensen 	 *
11454e400768SDavid Christensen 	 * @param cnt Amount of requested credit
11464e400768SDavid Christensen 	 * @return TRUE if the operation is successful
11474e400768SDavid Christensen 	 */
11484e400768SDavid Christensen 	bool (*get)(struct ecore_credit_pool_obj *o, int cnt);
11494e400768SDavid Christensen 
11504e400768SDavid Christensen 	/**
11514e400768SDavid Christensen 	 * Returns the credit to the pool.
11524e400768SDavid Christensen 	 *
11534e400768SDavid Christensen 	 * @param cnt Amount of credit to return
11544e400768SDavid Christensen 	 * @return TRUE if the operation is successful
11554e400768SDavid Christensen 	 */
11564e400768SDavid Christensen 	bool (*put)(struct ecore_credit_pool_obj *o, int cnt);
11574e400768SDavid Christensen 
11584e400768SDavid Christensen 	/**
11594e400768SDavid Christensen 	 * Reads the current amount of credit.
11604e400768SDavid Christensen 	 */
11614e400768SDavid Christensen 	int (*check)(struct ecore_credit_pool_obj *o);
11624e400768SDavid Christensen };
11634e400768SDavid Christensen 
11644e400768SDavid Christensen /*************************** RSS configuration ********************************/
11654e400768SDavid Christensen enum {
11664e400768SDavid Christensen 	/* RSS_MODE bits are mutually exclusive */
11674e400768SDavid Christensen 	ECORE_RSS_MODE_DISABLED,
11684e400768SDavid Christensen 	ECORE_RSS_MODE_REGULAR,
11694e400768SDavid Christensen 
11704e400768SDavid Christensen 	ECORE_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */
11714e400768SDavid Christensen 
11724e400768SDavid Christensen 	ECORE_RSS_IPV4,
11734e400768SDavid Christensen 	ECORE_RSS_IPV4_TCP,
11744e400768SDavid Christensen 	ECORE_RSS_IPV4_UDP,
11754e400768SDavid Christensen 	ECORE_RSS_IPV6,
11764e400768SDavid Christensen 	ECORE_RSS_IPV6_TCP,
11774e400768SDavid Christensen 	ECORE_RSS_IPV6_UDP,
11784e400768SDavid Christensen 
11794ef8ebfdSDavid C Somayajulu 	ECORE_RSS_IPV4_VXLAN,
11804ef8ebfdSDavid C Somayajulu 	ECORE_RSS_IPV6_VXLAN,
11814ef8ebfdSDavid C Somayajulu 	ECORE_RSS_TUNN_INNER_HDRS,
11824e400768SDavid Christensen };
11834e400768SDavid Christensen 
11844e400768SDavid Christensen struct ecore_config_rss_params {
11854e400768SDavid Christensen 	struct ecore_rss_config_obj *rss_obj;
11864e400768SDavid Christensen 
11874e400768SDavid Christensen 	/* may have RAMROD_COMP_WAIT set only */
11884e400768SDavid Christensen 	unsigned long	ramrod_flags;
11894e400768SDavid Christensen 
11904e400768SDavid Christensen 	/* ECORE_RSS_X bits */
11914e400768SDavid Christensen 	unsigned long	rss_flags;
11924e400768SDavid Christensen 
11934e400768SDavid Christensen 	/* Number hash bits to take into an account */
11944e400768SDavid Christensen 	uint8_t		rss_result_mask;
11954e400768SDavid Christensen 
11964e400768SDavid Christensen 	/* Indirection table */
11974e400768SDavid Christensen 	uint8_t		ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
11984e400768SDavid Christensen 
11994e400768SDavid Christensen 	/* RSS hash values */
12004e400768SDavid Christensen 	uint32_t		rss_key[10];
12014e400768SDavid Christensen 
12024e400768SDavid Christensen 	/* valid only iff ECORE_RSS_UPDATE_TOE is set */
12034e400768SDavid Christensen 	uint16_t		toe_rss_bitmap;
12044e400768SDavid Christensen };
12054e400768SDavid Christensen 
12064e400768SDavid Christensen struct ecore_rss_config_obj {
12074e400768SDavid Christensen 	struct ecore_raw_obj	raw;
12084e400768SDavid Christensen 
12094e400768SDavid Christensen 	/* RSS engine to use */
12104e400768SDavid Christensen 	uint8_t			engine_id;
12114e400768SDavid Christensen 
12124e400768SDavid Christensen 	/* Last configured indirection table */
12134e400768SDavid Christensen 	uint8_t			ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
12144e400768SDavid Christensen 
12154e400768SDavid Christensen 	/* flags for enabling 4-tupple hash on UDP */
12164e400768SDavid Christensen 	uint8_t			udp_rss_v4;
12174e400768SDavid Christensen 	uint8_t			udp_rss_v6;
12184e400768SDavid Christensen 
12194e400768SDavid Christensen 	int (*config_rss)(struct bxe_softc *sc,
12204e400768SDavid Christensen 			  struct ecore_config_rss_params *p);
12214e400768SDavid Christensen };
12224e400768SDavid Christensen 
12234e400768SDavid Christensen /*********************** Queue state update ***********************************/
12244e400768SDavid Christensen 
12254e400768SDavid Christensen /* UPDATE command options */
12264e400768SDavid Christensen enum {
12274e400768SDavid Christensen 	ECORE_Q_UPDATE_IN_VLAN_REM,
12284e400768SDavid Christensen 	ECORE_Q_UPDATE_IN_VLAN_REM_CHNG,
12294e400768SDavid Christensen 	ECORE_Q_UPDATE_OUT_VLAN_REM,
12304e400768SDavid Christensen 	ECORE_Q_UPDATE_OUT_VLAN_REM_CHNG,
12314e400768SDavid Christensen 	ECORE_Q_UPDATE_ANTI_SPOOF,
12324e400768SDavid Christensen 	ECORE_Q_UPDATE_ANTI_SPOOF_CHNG,
12334e400768SDavid Christensen 	ECORE_Q_UPDATE_ACTIVATE,
12344e400768SDavid Christensen 	ECORE_Q_UPDATE_ACTIVATE_CHNG,
12354e400768SDavid Christensen 	ECORE_Q_UPDATE_DEF_VLAN_EN,
12364e400768SDavid Christensen 	ECORE_Q_UPDATE_DEF_VLAN_EN_CHNG,
12374e400768SDavid Christensen 	ECORE_Q_UPDATE_SILENT_VLAN_REM_CHNG,
12384e400768SDavid Christensen 	ECORE_Q_UPDATE_SILENT_VLAN_REM,
12394e400768SDavid Christensen 	ECORE_Q_UPDATE_TX_SWITCHING_CHNG,
12404e400768SDavid Christensen 	ECORE_Q_UPDATE_TX_SWITCHING,
12414ef8ebfdSDavid C Somayajulu 	ECORE_Q_UPDATE_PTP_PKTS_CHNG,
12424ef8ebfdSDavid C Somayajulu 	ECORE_Q_UPDATE_PTP_PKTS,
12434e400768SDavid Christensen };
12444e400768SDavid Christensen 
12454e400768SDavid Christensen /* Allowed Queue states */
12464e400768SDavid Christensen enum ecore_q_state {
12474e400768SDavid Christensen 	ECORE_Q_STATE_RESET,
12484e400768SDavid Christensen 	ECORE_Q_STATE_INITIALIZED,
12494e400768SDavid Christensen 	ECORE_Q_STATE_ACTIVE,
12504e400768SDavid Christensen 	ECORE_Q_STATE_MULTI_COS,
12514e400768SDavid Christensen 	ECORE_Q_STATE_MCOS_TERMINATED,
12524e400768SDavid Christensen 	ECORE_Q_STATE_INACTIVE,
12534e400768SDavid Christensen 	ECORE_Q_STATE_STOPPED,
12544e400768SDavid Christensen 	ECORE_Q_STATE_TERMINATED,
12554e400768SDavid Christensen 	ECORE_Q_STATE_FLRED,
12564e400768SDavid Christensen 	ECORE_Q_STATE_MAX,
12574e400768SDavid Christensen };
12584e400768SDavid Christensen 
12594e400768SDavid Christensen /* Allowed Queue states */
12604e400768SDavid Christensen enum ecore_q_logical_state {
12614e400768SDavid Christensen 	ECORE_Q_LOGICAL_STATE_ACTIVE,
12624e400768SDavid Christensen 	ECORE_Q_LOGICAL_STATE_STOPPED,
12634e400768SDavid Christensen };
12644e400768SDavid Christensen 
12654e400768SDavid Christensen /* Allowed commands */
12664e400768SDavid Christensen enum ecore_queue_cmd {
12674e400768SDavid Christensen 	ECORE_Q_CMD_INIT,
12684e400768SDavid Christensen 	ECORE_Q_CMD_SETUP,
12694e400768SDavid Christensen 	ECORE_Q_CMD_SETUP_TX_ONLY,
12704e400768SDavid Christensen 	ECORE_Q_CMD_DEACTIVATE,
12714e400768SDavid Christensen 	ECORE_Q_CMD_ACTIVATE,
12724e400768SDavid Christensen 	ECORE_Q_CMD_UPDATE,
12734e400768SDavid Christensen 	ECORE_Q_CMD_UPDATE_TPA,
12744e400768SDavid Christensen 	ECORE_Q_CMD_HALT,
12754e400768SDavid Christensen 	ECORE_Q_CMD_CFC_DEL,
12764e400768SDavid Christensen 	ECORE_Q_CMD_TERMINATE,
12774e400768SDavid Christensen 	ECORE_Q_CMD_EMPTY,
12784e400768SDavid Christensen 	ECORE_Q_CMD_MAX,
12794e400768SDavid Christensen };
12804e400768SDavid Christensen 
12814e400768SDavid Christensen /* queue SETUP + INIT flags */
12824e400768SDavid Christensen enum {
12834e400768SDavid Christensen 	ECORE_Q_FLG_TPA,
12844e400768SDavid Christensen 	ECORE_Q_FLG_TPA_IPV6,
12854e400768SDavid Christensen 	ECORE_Q_FLG_TPA_GRO,
12864e400768SDavid Christensen 	ECORE_Q_FLG_STATS,
12874e400768SDavid Christensen 	ECORE_Q_FLG_ZERO_STATS,
12884e400768SDavid Christensen 	ECORE_Q_FLG_ACTIVE,
12894e400768SDavid Christensen 	ECORE_Q_FLG_OV,
12904e400768SDavid Christensen 	ECORE_Q_FLG_VLAN,
12914e400768SDavid Christensen 	ECORE_Q_FLG_COS,
12924e400768SDavid Christensen 	ECORE_Q_FLG_HC,
12934e400768SDavid Christensen 	ECORE_Q_FLG_HC_EN,
12944e400768SDavid Christensen 	ECORE_Q_FLG_DHC,
12954e400768SDavid Christensen 	ECORE_Q_FLG_OOO,
12964e400768SDavid Christensen 	ECORE_Q_FLG_FCOE,
12974e400768SDavid Christensen 	ECORE_Q_FLG_LEADING_RSS,
12984e400768SDavid Christensen 	ECORE_Q_FLG_MCAST,
12994e400768SDavid Christensen 	ECORE_Q_FLG_DEF_VLAN,
13004e400768SDavid Christensen 	ECORE_Q_FLG_TX_SWITCH,
13014e400768SDavid Christensen 	ECORE_Q_FLG_TX_SEC,
13024e400768SDavid Christensen 	ECORE_Q_FLG_ANTI_SPOOF,
13034e400768SDavid Christensen 	ECORE_Q_FLG_SILENT_VLAN_REM,
13044e400768SDavid Christensen 	ECORE_Q_FLG_FORCE_DEFAULT_PRI,
13054e400768SDavid Christensen 	ECORE_Q_FLG_REFUSE_OUTBAND_VLAN,
13064e400768SDavid Christensen 	ECORE_Q_FLG_PCSUM_ON_PKT,
13074e400768SDavid Christensen 	ECORE_Q_FLG_TUN_INC_INNER_IP_ID
13084e400768SDavid Christensen };
13094e400768SDavid Christensen 
13104e400768SDavid Christensen /* Queue type options: queue type may be a combination of below. */
13114e400768SDavid Christensen enum ecore_q_type {
13124e400768SDavid Christensen 	ECORE_Q_TYPE_FWD,
13134e400768SDavid Christensen 	/** TODO: Consider moving both these flags into the init()
13144e400768SDavid Christensen 	 *        ramrod params.
13154e400768SDavid Christensen 	 */
13164e400768SDavid Christensen 	ECORE_Q_TYPE_HAS_RX,
13174e400768SDavid Christensen 	ECORE_Q_TYPE_HAS_TX,
13184e400768SDavid Christensen };
13194e400768SDavid Christensen 
13204e400768SDavid Christensen #define ECORE_PRIMARY_CID_INDEX			0
13214e400768SDavid Christensen #define ECORE_MULTI_TX_COS_E1X			3 /* QM only */
13224e400768SDavid Christensen #define ECORE_MULTI_TX_COS_E2_E3A0		2
13234e400768SDavid Christensen #define ECORE_MULTI_TX_COS_E3B0			3
13244e400768SDavid Christensen #define ECORE_MULTI_TX_COS			3 /* Maximum possible */
13254e400768SDavid Christensen #define MAC_PAD (ECORE_ALIGN(ETH_ALEN, sizeof(uint32_t)) - ETH_ALEN)
13264ef8ebfdSDavid C Somayajulu /* DMAE channel to be used by FW for timesync workaroun. A driver that sends
13274ef8ebfdSDavid C Somayajulu  * timesync-related ramrods must not use this DMAE command ID.
13284ef8ebfdSDavid C Somayajulu  */
13294ef8ebfdSDavid C Somayajulu #define FW_DMAE_CMD_ID 6
13304e400768SDavid Christensen 
13314e400768SDavid Christensen struct ecore_queue_init_params {
13324e400768SDavid Christensen 	struct {
13334e400768SDavid Christensen 		unsigned long	flags;
13344e400768SDavid Christensen 		uint16_t		hc_rate;
13354e400768SDavid Christensen 		uint8_t		fw_sb_id;
13364e400768SDavid Christensen 		uint8_t		sb_cq_index;
13374e400768SDavid Christensen 	} tx;
13384e400768SDavid Christensen 
13394e400768SDavid Christensen 	struct {
13404e400768SDavid Christensen 		unsigned long	flags;
13414e400768SDavid Christensen 		uint16_t		hc_rate;
13424e400768SDavid Christensen 		uint8_t		fw_sb_id;
13434e400768SDavid Christensen 		uint8_t		sb_cq_index;
13444e400768SDavid Christensen 	} rx;
13454e400768SDavid Christensen 
13464e400768SDavid Christensen 	/* CID context in the host memory */
13474e400768SDavid Christensen 	struct eth_context *cxts[ECORE_MULTI_TX_COS];
13484e400768SDavid Christensen 
13494e400768SDavid Christensen 	/* maximum number of cos supported by hardware */
13504e400768SDavid Christensen 	uint8_t max_cos;
13514e400768SDavid Christensen };
13524e400768SDavid Christensen 
13534e400768SDavid Christensen struct ecore_queue_terminate_params {
13544e400768SDavid Christensen 	/* index within the tx_only cids of this queue object */
13554e400768SDavid Christensen 	uint8_t cid_index;
13564e400768SDavid Christensen };
13574e400768SDavid Christensen 
13584e400768SDavid Christensen struct ecore_queue_cfc_del_params {
13594e400768SDavid Christensen 	/* index within the tx_only cids of this queue object */
13604e400768SDavid Christensen 	uint8_t cid_index;
13614e400768SDavid Christensen };
13624e400768SDavid Christensen 
13634e400768SDavid Christensen struct ecore_queue_update_params {
13644e400768SDavid Christensen 	unsigned long	update_flags; /* ECORE_Q_UPDATE_XX bits */
13654e400768SDavid Christensen 	uint16_t		def_vlan;
13664e400768SDavid Christensen 	uint16_t		silent_removal_value;
13674e400768SDavid Christensen 	uint16_t		silent_removal_mask;
13684e400768SDavid Christensen /* index within the tx_only cids of this queue object */
13694e400768SDavid Christensen 	uint8_t		cid_index;
13704e400768SDavid Christensen };
13714e400768SDavid Christensen 
13724ef8ebfdSDavid C Somayajulu struct ecore_queue_update_tpa_params {
13734ef8ebfdSDavid C Somayajulu 	ecore_dma_addr_t sge_map;
13744ef8ebfdSDavid C Somayajulu 	uint8_t update_ipv4;
13754ef8ebfdSDavid C Somayajulu 	uint8_t update_ipv6;
13764ef8ebfdSDavid C Somayajulu 	uint8_t max_tpa_queues;
13774ef8ebfdSDavid C Somayajulu 	uint8_t max_sges_pkt;
13784ef8ebfdSDavid C Somayajulu 	uint8_t complete_on_both_clients;
13794ef8ebfdSDavid C Somayajulu 	uint8_t dont_verify_thr;
13804ef8ebfdSDavid C Somayajulu 	uint8_t tpa_mode;
13814ef8ebfdSDavid C Somayajulu 	uint8_t _pad;
13824ef8ebfdSDavid C Somayajulu 
13834ef8ebfdSDavid C Somayajulu 	uint16_t sge_buff_sz;
13844ef8ebfdSDavid C Somayajulu 	uint16_t max_agg_sz;
13854ef8ebfdSDavid C Somayajulu 
13864ef8ebfdSDavid C Somayajulu 	uint16_t sge_pause_thr_low;
13874ef8ebfdSDavid C Somayajulu 	uint16_t sge_pause_thr_high;
13884ef8ebfdSDavid C Somayajulu };
13894ef8ebfdSDavid C Somayajulu 
13904e400768SDavid Christensen struct rxq_pause_params {
13914e400768SDavid Christensen 	uint16_t		bd_th_lo;
13924e400768SDavid Christensen 	uint16_t		bd_th_hi;
13934e400768SDavid Christensen 	uint16_t		rcq_th_lo;
13944e400768SDavid Christensen 	uint16_t		rcq_th_hi;
13954e400768SDavid Christensen 	uint16_t		sge_th_lo; /* valid iff ECORE_Q_FLG_TPA */
13964e400768SDavid Christensen 	uint16_t		sge_th_hi; /* valid iff ECORE_Q_FLG_TPA */
13974e400768SDavid Christensen 	uint16_t		pri_map;
13984e400768SDavid Christensen };
13994e400768SDavid Christensen 
14004e400768SDavid Christensen /* general */
14014e400768SDavid Christensen struct ecore_general_setup_params {
14024e400768SDavid Christensen 	/* valid iff ECORE_Q_FLG_STATS */
14034e400768SDavid Christensen 	uint8_t		stat_id;
14044e400768SDavid Christensen 
14054e400768SDavid Christensen 	uint8_t		spcl_id;
14064e400768SDavid Christensen 	uint16_t		mtu;
14074e400768SDavid Christensen 	uint8_t		cos;
14084ef8ebfdSDavid C Somayajulu 
14094ef8ebfdSDavid C Somayajulu 	uint8_t		fp_hsi;
14104e400768SDavid Christensen };
14114e400768SDavid Christensen 
14124e400768SDavid Christensen struct ecore_rxq_setup_params {
14134e400768SDavid Christensen 	/* dma */
14144e400768SDavid Christensen 	ecore_dma_addr_t	dscr_map;
14154e400768SDavid Christensen 	ecore_dma_addr_t	sge_map;
14164e400768SDavid Christensen 	ecore_dma_addr_t	rcq_map;
14174e400768SDavid Christensen 	ecore_dma_addr_t	rcq_np_map;
14184e400768SDavid Christensen 
14194e400768SDavid Christensen 	uint16_t		drop_flags;
14204e400768SDavid Christensen 	uint16_t		buf_sz;
14214e400768SDavid Christensen 	uint8_t		fw_sb_id;
14224e400768SDavid Christensen 	uint8_t		cl_qzone_id;
14234e400768SDavid Christensen 
14244e400768SDavid Christensen 	/* valid iff ECORE_Q_FLG_TPA */
14254e400768SDavid Christensen 	uint16_t		tpa_agg_sz;
14264e400768SDavid Christensen 	uint16_t		sge_buf_sz;
14274e400768SDavid Christensen 	uint8_t		max_sges_pkt;
14284e400768SDavid Christensen 	uint8_t		max_tpa_queues;
14294e400768SDavid Christensen 	uint8_t		rss_engine_id;
14304e400768SDavid Christensen 
14314e400768SDavid Christensen 	/* valid iff ECORE_Q_FLG_MCAST */
14324e400768SDavid Christensen 	uint8_t		mcast_engine_id;
14334e400768SDavid Christensen 
14344e400768SDavid Christensen 	uint8_t		cache_line_log;
14354e400768SDavid Christensen 
14364e400768SDavid Christensen 	uint8_t		sb_cq_index;
14374e400768SDavid Christensen 
14384e400768SDavid Christensen 	/* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
14394e400768SDavid Christensen 	uint16_t silent_removal_value;
14404e400768SDavid Christensen 	uint16_t silent_removal_mask;
14414e400768SDavid Christensen };
14424e400768SDavid Christensen 
14434e400768SDavid Christensen struct ecore_txq_setup_params {
14444e400768SDavid Christensen 	/* dma */
14454e400768SDavid Christensen 	ecore_dma_addr_t	dscr_map;
14464e400768SDavid Christensen 
14474e400768SDavid Christensen 	uint8_t		fw_sb_id;
14484e400768SDavid Christensen 	uint8_t		sb_cq_index;
14494e400768SDavid Christensen 	uint8_t		cos;		/* valid iff ECORE_Q_FLG_COS */
14504e400768SDavid Christensen 	uint16_t		traffic_type;
14514e400768SDavid Christensen 	/* equals to the leading rss client id, used for TX classification*/
14524e400768SDavid Christensen 	uint8_t		tss_leading_cl_id;
14534e400768SDavid Christensen 
14544e400768SDavid Christensen 	/* valid iff ECORE_Q_FLG_DEF_VLAN */
14554e400768SDavid Christensen 	uint16_t		default_vlan;
14564e400768SDavid Christensen };
14574e400768SDavid Christensen 
14584e400768SDavid Christensen struct ecore_queue_setup_params {
14594e400768SDavid Christensen 	struct ecore_general_setup_params gen_params;
14604e400768SDavid Christensen 	struct ecore_txq_setup_params txq_params;
14614e400768SDavid Christensen 	struct ecore_rxq_setup_params rxq_params;
14624e400768SDavid Christensen 	struct rxq_pause_params pause_params;
14634e400768SDavid Christensen 	unsigned long flags;
14644e400768SDavid Christensen };
14654e400768SDavid Christensen 
14664e400768SDavid Christensen struct ecore_queue_setup_tx_only_params {
14674e400768SDavid Christensen 	struct ecore_general_setup_params	gen_params;
14684e400768SDavid Christensen 	struct ecore_txq_setup_params		txq_params;
14694e400768SDavid Christensen 	unsigned long				flags;
14704e400768SDavid Christensen 	/* index within the tx_only cids of this queue object */
14714e400768SDavid Christensen 	uint8_t					cid_index;
14724e400768SDavid Christensen };
14734e400768SDavid Christensen 
14744e400768SDavid Christensen struct ecore_queue_state_params {
14754e400768SDavid Christensen 	struct ecore_queue_sp_obj *q_obj;
14764e400768SDavid Christensen 
14774e400768SDavid Christensen 	/* Current command */
14784e400768SDavid Christensen 	enum ecore_queue_cmd cmd;
14794e400768SDavid Christensen 
14804e400768SDavid Christensen 	/* may have RAMROD_COMP_WAIT set only */
14814e400768SDavid Christensen 	unsigned long ramrod_flags;
14824e400768SDavid Christensen 
14834e400768SDavid Christensen 	/* Params according to the current command */
14844e400768SDavid Christensen 	union {
14854e400768SDavid Christensen 		struct ecore_queue_update_params	update;
14864ef8ebfdSDavid C Somayajulu 		struct ecore_queue_update_tpa_params    update_tpa;
14874e400768SDavid Christensen 		struct ecore_queue_setup_params		setup;
14884e400768SDavid Christensen 		struct ecore_queue_init_params		init;
14894e400768SDavid Christensen 		struct ecore_queue_setup_tx_only_params	tx_only;
14904e400768SDavid Christensen 		struct ecore_queue_terminate_params	terminate;
14914e400768SDavid Christensen 		struct ecore_queue_cfc_del_params	cfc_del;
14924e400768SDavid Christensen 	} params;
14934e400768SDavid Christensen };
14944e400768SDavid Christensen 
14954e400768SDavid Christensen struct ecore_viflist_params {
14964e400768SDavid Christensen 	uint8_t echo_res;
14974e400768SDavid Christensen 	uint8_t func_bit_map_res;
14984e400768SDavid Christensen };
14994e400768SDavid Christensen 
15004e400768SDavid Christensen struct ecore_queue_sp_obj {
15014e400768SDavid Christensen 	uint32_t		cids[ECORE_MULTI_TX_COS];
15024e400768SDavid Christensen 	uint8_t		cl_id;
15034e400768SDavid Christensen 	uint8_t		func_id;
15044e400768SDavid Christensen 
15054e400768SDavid Christensen 	/* number of traffic classes supported by queue.
15064e400768SDavid Christensen 	 * The primary connection of the queue supports the first traffic
15074e400768SDavid Christensen 	 * class. Any further traffic class is supported by a tx-only
15084e400768SDavid Christensen 	 * connection.
15094e400768SDavid Christensen 	 *
15104e400768SDavid Christensen 	 * Therefore max_cos is also a number of valid entries in the cids
15114e400768SDavid Christensen 	 * array.
15124e400768SDavid Christensen 	 */
15134e400768SDavid Christensen 	uint8_t max_cos;
15144e400768SDavid Christensen 	uint8_t num_tx_only, next_tx_only;
15154e400768SDavid Christensen 
15164e400768SDavid Christensen 	enum ecore_q_state state, next_state;
15174e400768SDavid Christensen 
15184e400768SDavid Christensen 	/* bits from enum ecore_q_type */
15194e400768SDavid Christensen 	unsigned long	type;
15204e400768SDavid Christensen 
15214e400768SDavid Christensen 	/* ECORE_Q_CMD_XX bits. This object implements "one
15224e400768SDavid Christensen 	 * pending" paradigm but for debug and tracing purposes it's
15234e400768SDavid Christensen 	 * more convenient to have different bits for different
15244e400768SDavid Christensen 	 * commands.
15254e400768SDavid Christensen 	 */
15264e400768SDavid Christensen 	unsigned long	pending;
15274e400768SDavid Christensen 
15284e400768SDavid Christensen 	/* Buffer to use as a ramrod data and its mapping */
15294e400768SDavid Christensen 	void		*rdata;
15304e400768SDavid Christensen 	ecore_dma_addr_t	rdata_mapping;
15314e400768SDavid Christensen 
15324e400768SDavid Christensen 	/**
15334e400768SDavid Christensen 	 * Performs one state change according to the given parameters.
15344e400768SDavid Christensen 	 *
15354e400768SDavid Christensen 	 * @return 0 in case of success and negative value otherwise.
15364e400768SDavid Christensen 	 */
15374e400768SDavid Christensen 	int (*send_cmd)(struct bxe_softc *sc,
15384e400768SDavid Christensen 			struct ecore_queue_state_params *params);
15394e400768SDavid Christensen 
15404e400768SDavid Christensen 	/**
15414e400768SDavid Christensen 	 * Sets the pending bit according to the requested transition.
15424e400768SDavid Christensen 	 */
15434e400768SDavid Christensen 	int (*set_pending)(struct ecore_queue_sp_obj *o,
15444e400768SDavid Christensen 			   struct ecore_queue_state_params *params);
15454e400768SDavid Christensen 
15464e400768SDavid Christensen 	/**
15474e400768SDavid Christensen 	 * Checks that the requested state transition is legal.
15484e400768SDavid Christensen 	 */
15494e400768SDavid Christensen 	int (*check_transition)(struct bxe_softc *sc,
15504e400768SDavid Christensen 				struct ecore_queue_sp_obj *o,
15514e400768SDavid Christensen 				struct ecore_queue_state_params *params);
15524e400768SDavid Christensen 
15534e400768SDavid Christensen 	/**
15544e400768SDavid Christensen 	 * Completes the pending command.
15554e400768SDavid Christensen 	 */
15564e400768SDavid Christensen 	int (*complete_cmd)(struct bxe_softc *sc,
15574e400768SDavid Christensen 			    struct ecore_queue_sp_obj *o,
15584e400768SDavid Christensen 			    enum ecore_queue_cmd);
15594e400768SDavid Christensen 
15604e400768SDavid Christensen 	int (*wait_comp)(struct bxe_softc *sc,
15614e400768SDavid Christensen 			 struct ecore_queue_sp_obj *o,
15624e400768SDavid Christensen 			 enum ecore_queue_cmd cmd);
15634e400768SDavid Christensen };
15644e400768SDavid Christensen 
15654e400768SDavid Christensen /********************** Function state update *********************************/
15664ef8ebfdSDavid C Somayajulu 
15674ef8ebfdSDavid C Somayajulu /* UPDATE command options */
15684ef8ebfdSDavid C Somayajulu enum {
15694ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_TX_SWITCH_SUSPEND_CHNG,
15704ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_TX_SWITCH_SUSPEND,
15714ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_SD_VLAN_TAG_CHNG,
15724ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_SD_VLAN_ETH_TYPE_CHNG,
15734ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_VLAN_FORCE_PRIO_CHNG,
15744ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_VLAN_FORCE_PRIO_FLAG,
15754ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_TUNNEL_CFG_CHNG,
15764ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_TUNNEL_INNER_CLSS_L2GRE,
15774ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_TUNNEL_INNER_CLSS_VXLAN,
15784ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_TUNNEL_INNER_CLSS_L2GENEVE,
15794ef8ebfdSDavid C Somayajulu 	ECORE_F_UPDATE_TUNNEL_INNER_RSS,
15804ef8ebfdSDavid C Somayajulu };
15814ef8ebfdSDavid C Somayajulu 
15824e400768SDavid Christensen /* Allowed Function states */
15834e400768SDavid Christensen enum ecore_func_state {
15844e400768SDavid Christensen 	ECORE_F_STATE_RESET,
15854e400768SDavid Christensen 	ECORE_F_STATE_INITIALIZED,
15864e400768SDavid Christensen 	ECORE_F_STATE_STARTED,
15874e400768SDavid Christensen 	ECORE_F_STATE_TX_STOPPED,
15884e400768SDavid Christensen 	ECORE_F_STATE_MAX,
15894e400768SDavid Christensen };
15904e400768SDavid Christensen 
15914e400768SDavid Christensen /* Allowed Function commands */
15924e400768SDavid Christensen enum ecore_func_cmd {
15934e400768SDavid Christensen 	ECORE_F_CMD_HW_INIT,
15944e400768SDavid Christensen 	ECORE_F_CMD_START,
15954e400768SDavid Christensen 	ECORE_F_CMD_STOP,
15964e400768SDavid Christensen 	ECORE_F_CMD_HW_RESET,
15974e400768SDavid Christensen 	ECORE_F_CMD_AFEX_UPDATE,
15984e400768SDavid Christensen 	ECORE_F_CMD_AFEX_VIFLISTS,
15994e400768SDavid Christensen 	ECORE_F_CMD_TX_STOP,
16004e400768SDavid Christensen 	ECORE_F_CMD_TX_START,
16014e400768SDavid Christensen 	ECORE_F_CMD_SWITCH_UPDATE,
16024ef8ebfdSDavid C Somayajulu 	ECORE_F_CMD_SET_TIMESYNC,
16034e400768SDavid Christensen 	ECORE_F_CMD_MAX,
16044e400768SDavid Christensen };
16054e400768SDavid Christensen 
16064e400768SDavid Christensen struct ecore_func_hw_init_params {
16074e400768SDavid Christensen 	/* A load phase returned by MCP.
16084e400768SDavid Christensen 	 *
16094e400768SDavid Christensen 	 * May be:
16104e400768SDavid Christensen 	 *		FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
16114e400768SDavid Christensen 	 *		FW_MSG_CODE_DRV_LOAD_COMMON
16124e400768SDavid Christensen 	 *		FW_MSG_CODE_DRV_LOAD_PORT
16134e400768SDavid Christensen 	 *		FW_MSG_CODE_DRV_LOAD_FUNCTION
16144e400768SDavid Christensen 	 */
16154e400768SDavid Christensen 	uint32_t load_phase;
16164e400768SDavid Christensen };
16174e400768SDavid Christensen 
16184e400768SDavid Christensen struct ecore_func_hw_reset_params {
16194e400768SDavid Christensen 	/* A load phase returned by MCP.
16204e400768SDavid Christensen 	 *
16214e400768SDavid Christensen 	 * May be:
16224e400768SDavid Christensen 	 *		FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
16234e400768SDavid Christensen 	 *		FW_MSG_CODE_DRV_LOAD_COMMON
16244e400768SDavid Christensen 	 *		FW_MSG_CODE_DRV_LOAD_PORT
16254e400768SDavid Christensen 	 *		FW_MSG_CODE_DRV_LOAD_FUNCTION
16264e400768SDavid Christensen 	 */
16274e400768SDavid Christensen 	uint32_t reset_phase;
16284e400768SDavid Christensen };
16294e400768SDavid Christensen 
16304e400768SDavid Christensen struct ecore_func_start_params {
16314e400768SDavid Christensen 	/* Multi Function mode:
16324e400768SDavid Christensen 	 *	- Single Function
16334e400768SDavid Christensen 	 *	- Switch Dependent
16344e400768SDavid Christensen 	 *	- Switch Independent
16354e400768SDavid Christensen 	 */
16364e400768SDavid Christensen 	uint16_t mf_mode;
16374e400768SDavid Christensen 
16384e400768SDavid Christensen 	/* Switch Dependent mode outer VLAN tag */
16394e400768SDavid Christensen 	uint16_t sd_vlan_tag;
16404e400768SDavid Christensen 
16414e400768SDavid Christensen 	/* Function cos mode */
16424e400768SDavid Christensen 	uint8_t network_cos_mode;
16434e400768SDavid Christensen 
16444ef8ebfdSDavid C Somayajulu 	/* UDP dest port for VXLAN */
16454ef8ebfdSDavid C Somayajulu 	uint16_t vxlan_dst_port;
16464e400768SDavid Christensen 
16474ef8ebfdSDavid C Somayajulu 	/* UDP dest port for Geneve */
16484ef8ebfdSDavid C Somayajulu 	uint16_t geneve_dst_port;
16494e400768SDavid Christensen 
16504ef8ebfdSDavid C Somayajulu 	/* Enable inner Rx classifications for L2GRE packets */
16514ef8ebfdSDavid C Somayajulu 	uint8_t inner_clss_l2gre;
16524e400768SDavid Christensen 
16534ef8ebfdSDavid C Somayajulu 	/* Enable inner Rx classifications for L2-Geneve packets */
16544ef8ebfdSDavid C Somayajulu 	uint8_t inner_clss_l2geneve;
16554ef8ebfdSDavid C Somayajulu 
16564ef8ebfdSDavid C Somayajulu 	/* Enable inner Rx classification for vxlan packets */
16574ef8ebfdSDavid C Somayajulu 	uint8_t inner_clss_vxlan;
16584ef8ebfdSDavid C Somayajulu 
16594ef8ebfdSDavid C Somayajulu 	/* Enable RSS according to inner header */
16604ef8ebfdSDavid C Somayajulu 	uint8_t inner_rss;
16614ef8ebfdSDavid C Somayajulu 
16624ef8ebfdSDavid C Somayajulu 	/** Allows accepting of packets failing MF classification, possibly
16634ef8ebfdSDavid C Somayajulu 	 * only matching a given ethertype
16644ef8ebfdSDavid C Somayajulu 	 */
16654ef8ebfdSDavid C Somayajulu 	uint8_t class_fail;
16664ef8ebfdSDavid C Somayajulu 	uint16_t class_fail_ethtype;
16674ef8ebfdSDavid C Somayajulu 
16684ef8ebfdSDavid C Somayajulu 	/* Override priority of output packets */
16694ef8ebfdSDavid C Somayajulu 	uint8_t sd_vlan_force_pri;
16704ef8ebfdSDavid C Somayajulu 	uint8_t sd_vlan_force_pri_val;
16714ef8ebfdSDavid C Somayajulu 
16724ef8ebfdSDavid C Somayajulu 	/* Replace vlan's ethertype */
16734ef8ebfdSDavid C Somayajulu 	uint16_t sd_vlan_eth_type;
16744ef8ebfdSDavid C Somayajulu 
16754ef8ebfdSDavid C Somayajulu 	/* Prevent inner vlans from being added by FW */
16764ef8ebfdSDavid C Somayajulu 	uint8_t no_added_tags;
16774ef8ebfdSDavid C Somayajulu 
16784ef8ebfdSDavid C Somayajulu 	/* Inner-to-Outer vlan priority mapping */
16794ef8ebfdSDavid C Somayajulu 	uint8_t c2s_pri[MAX_VLAN_PRIORITIES];
16804ef8ebfdSDavid C Somayajulu 	uint8_t c2s_pri_default;
16814ef8ebfdSDavid C Somayajulu 	uint8_t c2s_pri_valid;
16824e400768SDavid Christensen };
16834e400768SDavid Christensen 
16844e400768SDavid Christensen struct ecore_func_switch_update_params {
16854ef8ebfdSDavid C Somayajulu 	unsigned long changes; /* ECORE_F_UPDATE_XX bits */
16864ef8ebfdSDavid C Somayajulu 	uint16_t vlan;
16874ef8ebfdSDavid C Somayajulu 	uint16_t vlan_eth_type;
16884ef8ebfdSDavid C Somayajulu 	uint8_t vlan_force_prio;
16894ef8ebfdSDavid C Somayajulu 	uint16_t vxlan_dst_port;
16904ef8ebfdSDavid C Somayajulu 	uint16_t geneve_dst_port;
16914e400768SDavid Christensen };
16924e400768SDavid Christensen 
16934e400768SDavid Christensen struct ecore_func_afex_update_params {
16944e400768SDavid Christensen 	uint16_t vif_id;
16954e400768SDavid Christensen 	uint16_t afex_default_vlan;
16964e400768SDavid Christensen 	uint8_t allowed_priorities;
16974e400768SDavid Christensen };
16984e400768SDavid Christensen 
16994e400768SDavid Christensen struct ecore_func_afex_viflists_params {
17004e400768SDavid Christensen 	uint16_t vif_list_index;
17014e400768SDavid Christensen 	uint8_t func_bit_map;
17024e400768SDavid Christensen 	uint8_t afex_vif_list_command;
17034e400768SDavid Christensen 	uint8_t func_to_clear;
17044e400768SDavid Christensen };
17054ef8ebfdSDavid C Somayajulu 
17064e400768SDavid Christensen struct ecore_func_tx_start_params {
17074e400768SDavid Christensen 	struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES];
17084e400768SDavid Christensen 	uint8_t dcb_enabled;
17094e400768SDavid Christensen 	uint8_t dcb_version;
17104e400768SDavid Christensen 	uint8_t dont_add_pri_0;
17114ef8ebfdSDavid C Somayajulu 	uint8_t dcb_outer_pri[MAX_TRAFFIC_TYPES];
17124ef8ebfdSDavid C Somayajulu };
17134ef8ebfdSDavid C Somayajulu 
17144ef8ebfdSDavid C Somayajulu struct ecore_func_set_timesync_params {
17154ef8ebfdSDavid C Somayajulu 	/* Reset, set or keep the current drift value */
17164ef8ebfdSDavid C Somayajulu 	uint8_t drift_adjust_cmd;
17174ef8ebfdSDavid C Somayajulu 	/* Dec, inc or keep the current offset */
17184ef8ebfdSDavid C Somayajulu 	uint8_t offset_cmd;
17194ef8ebfdSDavid C Somayajulu 	/* Drift value direction */
17204ef8ebfdSDavid C Somayajulu 	uint8_t add_sub_drift_adjust_value;
17214ef8ebfdSDavid C Somayajulu 	/* Drift, period and offset values to be used according to the commands
17224ef8ebfdSDavid C Somayajulu 	 * above.
17234ef8ebfdSDavid C Somayajulu 	 */
17244ef8ebfdSDavid C Somayajulu 	uint8_t drift_adjust_value;
17254ef8ebfdSDavid C Somayajulu 	uint32_t drift_adjust_period;
17264ef8ebfdSDavid C Somayajulu 	uint64_t offset_delta;
17274e400768SDavid Christensen };
17284e400768SDavid Christensen 
17294e400768SDavid Christensen struct ecore_func_state_params {
17304e400768SDavid Christensen 	struct ecore_func_sp_obj *f_obj;
17314e400768SDavid Christensen 
17324e400768SDavid Christensen 	/* Current command */
17334e400768SDavid Christensen 	enum ecore_func_cmd cmd;
17344e400768SDavid Christensen 
17354e400768SDavid Christensen 	/* may have RAMROD_COMP_WAIT set only */
17364e400768SDavid Christensen 	unsigned long	ramrod_flags;
17374e400768SDavid Christensen 
17384e400768SDavid Christensen 	/* Params according to the current command */
17394e400768SDavid Christensen 	union {
17404e400768SDavid Christensen 		struct ecore_func_hw_init_params hw_init;
17414e400768SDavid Christensen 		struct ecore_func_hw_reset_params hw_reset;
17424e400768SDavid Christensen 		struct ecore_func_start_params start;
17434e400768SDavid Christensen 		struct ecore_func_switch_update_params switch_update;
17444e400768SDavid Christensen 		struct ecore_func_afex_update_params afex_update;
17454e400768SDavid Christensen 		struct ecore_func_afex_viflists_params afex_viflists;
17464e400768SDavid Christensen 		struct ecore_func_tx_start_params tx_start;
17474ef8ebfdSDavid C Somayajulu 		struct ecore_func_set_timesync_params set_timesync;
17484e400768SDavid Christensen 	} params;
17494e400768SDavid Christensen };
17504e400768SDavid Christensen 
17514e400768SDavid Christensen struct ecore_func_sp_drv_ops {
17524e400768SDavid Christensen 	/* Init tool + runtime initialization:
17534e400768SDavid Christensen 	 *      - Common Chip
17544e400768SDavid Christensen 	 *      - Common (per Path)
17554e400768SDavid Christensen 	 *      - Port
17564e400768SDavid Christensen 	 *      - Function phases
17574e400768SDavid Christensen 	 */
17584e400768SDavid Christensen 	int (*init_hw_cmn_chip)(struct bxe_softc *sc);
17594e400768SDavid Christensen 	int (*init_hw_cmn)(struct bxe_softc *sc);
17604e400768SDavid Christensen 	int (*init_hw_port)(struct bxe_softc *sc);
17614e400768SDavid Christensen 	int (*init_hw_func)(struct bxe_softc *sc);
17624e400768SDavid Christensen 
17634e400768SDavid Christensen 	/* Reset Function HW: Common, Port, Function phases. */
17644e400768SDavid Christensen 	void (*reset_hw_cmn)(struct bxe_softc *sc);
17654e400768SDavid Christensen 	void (*reset_hw_port)(struct bxe_softc *sc);
17664e400768SDavid Christensen 	void (*reset_hw_func)(struct bxe_softc *sc);
17674e400768SDavid Christensen 
17684e400768SDavid Christensen 	/* Init/Free GUNZIP resources */
17694e400768SDavid Christensen 	int (*gunzip_init)(struct bxe_softc *sc);
17704e400768SDavid Christensen 	void (*gunzip_end)(struct bxe_softc *sc);
17714e400768SDavid Christensen 
17724e400768SDavid Christensen 	/* Prepare/Release FW resources */
17734e400768SDavid Christensen 	int (*init_fw)(struct bxe_softc *sc);
17744e400768SDavid Christensen 	void (*release_fw)(struct bxe_softc *sc);
17754e400768SDavid Christensen };
17764e400768SDavid Christensen 
17774e400768SDavid Christensen struct ecore_func_sp_obj {
17784e400768SDavid Christensen 	enum ecore_func_state	state, next_state;
17794e400768SDavid Christensen 
17804e400768SDavid Christensen 	/* ECORE_FUNC_CMD_XX bits. This object implements "one
17814e400768SDavid Christensen 	 * pending" paradigm but for debug and tracing purposes it's
17824e400768SDavid Christensen 	 * more convenient to have different bits for different
17834e400768SDavid Christensen 	 * commands.
17844e400768SDavid Christensen 	 */
17854e400768SDavid Christensen 	unsigned long		pending;
17864e400768SDavid Christensen 
17874e400768SDavid Christensen 	/* Buffer to use as a ramrod data and its mapping */
17884e400768SDavid Christensen 	void			*rdata;
17894e400768SDavid Christensen 	ecore_dma_addr_t		rdata_mapping;
17904e400768SDavid Christensen 
17914e400768SDavid Christensen 	/* Buffer to use as a afex ramrod data and its mapping.
17924e400768SDavid Christensen 	 * This can't be same rdata as above because afex ramrod requests
17934e400768SDavid Christensen 	 * can arrive to the object in parallel to other ramrod requests.
17944e400768SDavid Christensen 	 */
17954e400768SDavid Christensen 	void			*afex_rdata;
17964e400768SDavid Christensen 	ecore_dma_addr_t		afex_rdata_mapping;
17974e400768SDavid Christensen 
17984e400768SDavid Christensen 	/* this mutex validates that when pending flag is taken, the next
17994e400768SDavid Christensen 	 * ramrod to be sent will be the one set the pending bit
18004e400768SDavid Christensen 	 */
18014e400768SDavid Christensen 	ECORE_MUTEX		one_pending_mutex;
18024e400768SDavid Christensen 
18034e400768SDavid Christensen 	/* Driver interface */
18044e400768SDavid Christensen 	struct ecore_func_sp_drv_ops	*drv;
18054e400768SDavid Christensen 
18064e400768SDavid Christensen 	/**
18074e400768SDavid Christensen 	 * Performs one state change according to the given parameters.
18084e400768SDavid Christensen 	 *
18094e400768SDavid Christensen 	 * @return 0 in case of success and negative value otherwise.
18104e400768SDavid Christensen 	 */
18114e400768SDavid Christensen 	int (*send_cmd)(struct bxe_softc *sc,
18124e400768SDavid Christensen 			struct ecore_func_state_params *params);
18134e400768SDavid Christensen 
18144e400768SDavid Christensen 	/**
18154e400768SDavid Christensen 	 * Checks that the requested state transition is legal.
18164e400768SDavid Christensen 	 */
18174e400768SDavid Christensen 	int (*check_transition)(struct bxe_softc *sc,
18184e400768SDavid Christensen 				struct ecore_func_sp_obj *o,
18194e400768SDavid Christensen 				struct ecore_func_state_params *params);
18204e400768SDavid Christensen 
18214e400768SDavid Christensen 	/**
18224e400768SDavid Christensen 	 * Completes the pending command.
18234e400768SDavid Christensen 	 */
18244e400768SDavid Christensen 	int (*complete_cmd)(struct bxe_softc *sc,
18254e400768SDavid Christensen 			    struct ecore_func_sp_obj *o,
18264e400768SDavid Christensen 			    enum ecore_func_cmd cmd);
18274e400768SDavid Christensen 
18284e400768SDavid Christensen 	int (*wait_comp)(struct bxe_softc *sc, struct ecore_func_sp_obj *o,
18294e400768SDavid Christensen 			 enum ecore_func_cmd cmd);
18304e400768SDavid Christensen };
18314e400768SDavid Christensen 
18324e400768SDavid Christensen /********************** Interfaces ********************************************/
18334e400768SDavid Christensen /* Queueable objects set */
18344e400768SDavid Christensen union ecore_qable_obj {
18354e400768SDavid Christensen 	struct ecore_vlan_mac_obj vlan_mac;
18364e400768SDavid Christensen };
18374e400768SDavid Christensen /************** Function state update *********/
18384e400768SDavid Christensen void ecore_init_func_obj(struct bxe_softc *sc,
18394e400768SDavid Christensen 			 struct ecore_func_sp_obj *obj,
18404e400768SDavid Christensen 			 void *rdata, ecore_dma_addr_t rdata_mapping,
18414e400768SDavid Christensen 			 void *afex_rdata, ecore_dma_addr_t afex_rdata_mapping,
18424e400768SDavid Christensen 			 struct ecore_func_sp_drv_ops *drv_iface);
18434e400768SDavid Christensen 
18444e400768SDavid Christensen int ecore_func_state_change(struct bxe_softc *sc,
18454e400768SDavid Christensen 			    struct ecore_func_state_params *params);
18464e400768SDavid Christensen 
18474e400768SDavid Christensen enum ecore_func_state ecore_func_get_state(struct bxe_softc *sc,
18484e400768SDavid Christensen 					   struct ecore_func_sp_obj *o);
18494e400768SDavid Christensen /******************* Queue State **************/
18504e400768SDavid Christensen void ecore_init_queue_obj(struct bxe_softc *sc,
18514e400768SDavid Christensen 			  struct ecore_queue_sp_obj *obj, uint8_t cl_id, uint32_t *cids,
18524e400768SDavid Christensen 			  uint8_t cid_cnt, uint8_t func_id, void *rdata,
18534e400768SDavid Christensen 			  ecore_dma_addr_t rdata_mapping, unsigned long type);
18544e400768SDavid Christensen 
18554e400768SDavid Christensen int ecore_queue_state_change(struct bxe_softc *sc,
18564e400768SDavid Christensen 			     struct ecore_queue_state_params *params);
18574e400768SDavid Christensen 
18584e400768SDavid Christensen int ecore_get_q_logical_state(struct bxe_softc *sc,
18594e400768SDavid Christensen 			       struct ecore_queue_sp_obj *obj);
18604e400768SDavid Christensen 
18614e400768SDavid Christensen /********************* VLAN-MAC ****************/
18624e400768SDavid Christensen void ecore_init_mac_obj(struct bxe_softc *sc,
18634e400768SDavid Christensen 			struct ecore_vlan_mac_obj *mac_obj,
18644e400768SDavid Christensen 			uint8_t cl_id, uint32_t cid, uint8_t func_id, void *rdata,
18654e400768SDavid Christensen 			ecore_dma_addr_t rdata_mapping, int state,
18664e400768SDavid Christensen 			unsigned long *pstate, ecore_obj_type type,
18674e400768SDavid Christensen 			struct ecore_credit_pool_obj *macs_pool);
18684e400768SDavid Christensen 
18694e400768SDavid Christensen void ecore_init_vlan_obj(struct bxe_softc *sc,
18704e400768SDavid Christensen 			 struct ecore_vlan_mac_obj *vlan_obj,
18714e400768SDavid Christensen 			 uint8_t cl_id, uint32_t cid, uint8_t func_id, void *rdata,
18724e400768SDavid Christensen 			 ecore_dma_addr_t rdata_mapping, int state,
18734e400768SDavid Christensen 			 unsigned long *pstate, ecore_obj_type type,
18744e400768SDavid Christensen 			 struct ecore_credit_pool_obj *vlans_pool);
18754e400768SDavid Christensen 
18764e400768SDavid Christensen void ecore_init_vlan_mac_obj(struct bxe_softc *sc,
18774e400768SDavid Christensen 			     struct ecore_vlan_mac_obj *vlan_mac_obj,
18784e400768SDavid Christensen 			     uint8_t cl_id, uint32_t cid, uint8_t func_id, void *rdata,
18794e400768SDavid Christensen 			     ecore_dma_addr_t rdata_mapping, int state,
18804e400768SDavid Christensen 			     unsigned long *pstate, ecore_obj_type type,
18814e400768SDavid Christensen 			     struct ecore_credit_pool_obj *macs_pool,
18824e400768SDavid Christensen 			     struct ecore_credit_pool_obj *vlans_pool);
18834e400768SDavid Christensen 
18844ef8ebfdSDavid C Somayajulu void ecore_init_vxlan_fltr_obj(struct bxe_softc *sc,
18854ef8ebfdSDavid C Somayajulu 			       struct ecore_vlan_mac_obj *vlan_mac_obj,
18864ef8ebfdSDavid C Somayajulu 			       uint8_t cl_id, uint32_t cid, uint8_t func_id, void *rdata,
18874ef8ebfdSDavid C Somayajulu 			       ecore_dma_addr_t rdata_mapping, int state,
18884ef8ebfdSDavid C Somayajulu 			       unsigned long *pstate, ecore_obj_type type,
18894ef8ebfdSDavid C Somayajulu 			       struct ecore_credit_pool_obj *macs_pool,
18904ef8ebfdSDavid C Somayajulu 			       struct ecore_credit_pool_obj *vlans_pool);
18914ef8ebfdSDavid C Somayajulu 
18924e400768SDavid Christensen int ecore_vlan_mac_h_read_lock(struct bxe_softc *sc,
18934e400768SDavid Christensen 					struct ecore_vlan_mac_obj *o);
18944e400768SDavid Christensen void ecore_vlan_mac_h_read_unlock(struct bxe_softc *sc,
18954e400768SDavid Christensen 				  struct ecore_vlan_mac_obj *o);
18964e400768SDavid Christensen int ecore_vlan_mac_h_write_lock(struct bxe_softc *sc,
18974e400768SDavid Christensen 				struct ecore_vlan_mac_obj *o);
18984e400768SDavid Christensen void ecore_vlan_mac_h_write_unlock(struct bxe_softc *sc,
18994e400768SDavid Christensen 					  struct ecore_vlan_mac_obj *o);
19004e400768SDavid Christensen int ecore_config_vlan_mac(struct bxe_softc *sc,
19014e400768SDavid Christensen 			   struct ecore_vlan_mac_ramrod_params *p);
19024e400768SDavid Christensen 
19034e400768SDavid Christensen int ecore_vlan_mac_move(struct bxe_softc *sc,
19044e400768SDavid Christensen 			struct ecore_vlan_mac_ramrod_params *p,
19054e400768SDavid Christensen 			struct ecore_vlan_mac_obj *dest_o);
19064e400768SDavid Christensen 
19074e400768SDavid Christensen /********************* RX MODE ****************/
19084e400768SDavid Christensen 
19094e400768SDavid Christensen void ecore_init_rx_mode_obj(struct bxe_softc *sc,
19104e400768SDavid Christensen 			    struct ecore_rx_mode_obj *o);
19114e400768SDavid Christensen 
19124e400768SDavid Christensen /**
19134e400768SDavid Christensen  * ecore_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
19144e400768SDavid Christensen  *
19154e400768SDavid Christensen  * @p: Command parameters
19164e400768SDavid Christensen  *
19174e400768SDavid Christensen  * Return: 0 - if operation was successful and there is no pending completions,
19184e400768SDavid Christensen  *         positive number - if there are pending completions,
19194e400768SDavid Christensen  *         negative - if there were errors
19204e400768SDavid Christensen  */
19214e400768SDavid Christensen int ecore_config_rx_mode(struct bxe_softc *sc,
19224e400768SDavid Christensen 			 struct ecore_rx_mode_ramrod_params *p);
19234e400768SDavid Christensen 
19244e400768SDavid Christensen /****************** MULTICASTS ****************/
19254e400768SDavid Christensen 
19264e400768SDavid Christensen void ecore_init_mcast_obj(struct bxe_softc *sc,
19274e400768SDavid Christensen 			  struct ecore_mcast_obj *mcast_obj,
19284e400768SDavid Christensen 			  uint8_t mcast_cl_id, uint32_t mcast_cid, uint8_t func_id,
19294e400768SDavid Christensen 			  uint8_t engine_id, void *rdata, ecore_dma_addr_t rdata_mapping,
19304e400768SDavid Christensen 			  int state, unsigned long *pstate,
19314e400768SDavid Christensen 			  ecore_obj_type type);
19324e400768SDavid Christensen 
19334e400768SDavid Christensen /**
19344e400768SDavid Christensen  * ecore_config_mcast - Configure multicast MACs list.
19354e400768SDavid Christensen  *
19364e400768SDavid Christensen  * @cmd: command to execute: BNX2X_MCAST_CMD_X
19374e400768SDavid Christensen  *
19384e400768SDavid Christensen  * May configure a new list
19394e400768SDavid Christensen  * provided in p->mcast_list (ECORE_MCAST_CMD_ADD), clean up
19404e400768SDavid Christensen  * (ECORE_MCAST_CMD_DEL) or restore (ECORE_MCAST_CMD_RESTORE) a current
19414e400768SDavid Christensen  * configuration, continue to execute the pending commands
19424e400768SDavid Christensen  * (ECORE_MCAST_CMD_CONT).
19434e400768SDavid Christensen  *
19444e400768SDavid Christensen  * If previous command is still pending or if number of MACs to
19454e400768SDavid Christensen  * configure is more that maximum number of MACs in one command,
19464e400768SDavid Christensen  * the current command will be enqueued to the tail of the
19474e400768SDavid Christensen  * pending commands list.
19484e400768SDavid Christensen  *
1949453130d9SPedro F. Giffuni  * Return: 0 is operation was successful and there are no pending completions,
19504e400768SDavid Christensen  *         negative if there were errors, positive if there are pending
19514e400768SDavid Christensen  *         completions.
19524e400768SDavid Christensen  */
19534e400768SDavid Christensen int ecore_config_mcast(struct bxe_softc *sc,
19544e400768SDavid Christensen 		       struct ecore_mcast_ramrod_params *p,
19554e400768SDavid Christensen 		       enum ecore_mcast_cmd cmd);
19564e400768SDavid Christensen 
19574e400768SDavid Christensen /****************** CREDIT POOL ****************/
19584e400768SDavid Christensen void ecore_init_mac_credit_pool(struct bxe_softc *sc,
19594e400768SDavid Christensen 				struct ecore_credit_pool_obj *p, uint8_t func_id,
19604e400768SDavid Christensen 				uint8_t func_num);
19614e400768SDavid Christensen void ecore_init_vlan_credit_pool(struct bxe_softc *sc,
19624e400768SDavid Christensen 				 struct ecore_credit_pool_obj *p, uint8_t func_id,
19634e400768SDavid Christensen 				 uint8_t func_num);
19644ef8ebfdSDavid C Somayajulu void ecore_init_credit_pool(struct ecore_credit_pool_obj *p,
19654ef8ebfdSDavid C Somayajulu 			    int base, int credit);
19664e400768SDavid Christensen 
19674e400768SDavid Christensen /****************** RSS CONFIGURATION ****************/
19684e400768SDavid Christensen void ecore_init_rss_config_obj(struct bxe_softc *sc,
19694e400768SDavid Christensen 			       struct ecore_rss_config_obj *rss_obj,
19704e400768SDavid Christensen 			       uint8_t cl_id, uint32_t cid, uint8_t func_id, uint8_t engine_id,
19714e400768SDavid Christensen 			       void *rdata, ecore_dma_addr_t rdata_mapping,
19724e400768SDavid Christensen 			       int state, unsigned long *pstate,
19734e400768SDavid Christensen 			       ecore_obj_type type);
19744e400768SDavid Christensen 
19754e400768SDavid Christensen /**
19764e400768SDavid Christensen  * ecore_config_rss - Updates RSS configuration according to provided parameters
19774e400768SDavid Christensen  *
19784e400768SDavid Christensen  * Return: 0 in case of success
19794e400768SDavid Christensen  */
19804e400768SDavid Christensen int ecore_config_rss(struct bxe_softc *sc,
19814e400768SDavid Christensen 		     struct ecore_config_rss_params *p);
19824e400768SDavid Christensen 
19834e400768SDavid Christensen /**
19844e400768SDavid Christensen  * ecore_get_rss_ind_table - Return the current ind_table configuration.
19854e400768SDavid Christensen  *
19864e400768SDavid Christensen  * @ind_table: buffer to fill with the current indirection
19874e400768SDavid Christensen  *                  table content. Should be at least
19884e400768SDavid Christensen  *                  T_ETH_INDIRECTION_TABLE_SIZE bytes long.
19894e400768SDavid Christensen  */
19904e400768SDavid Christensen void ecore_get_rss_ind_table(struct ecore_rss_config_obj *rss_obj,
19914e400768SDavid Christensen 			     uint8_t *ind_table);
19924e400768SDavid Christensen 
19934ef8ebfdSDavid C Somayajulu #define PF_MAC_CREDIT_E2(sc, func_num)					\
19944ef8ebfdSDavid C Somayajulu 	((MAX_MAC_CREDIT_E2 - GET_NUM_VFS_PER_PATH(sc) * VF_MAC_CREDIT_CNT) /	\
19954ef8ebfdSDavid C Somayajulu 	 func_num + GET_NUM_VFS_PER_PF(sc) * VF_MAC_CREDIT_CNT)
19964ef8ebfdSDavid C Somayajulu 
19974ef8ebfdSDavid C Somayajulu #define PF_VLAN_CREDIT_E2(sc, func_num)					 \
19984ef8ebfdSDavid C Somayajulu 	((MAX_MAC_CREDIT_E2 - GET_NUM_VFS_PER_PATH(sc) * VF_VLAN_CREDIT_CNT) / \
19994ef8ebfdSDavid C Somayajulu 	 func_num + GET_NUM_VFS_PER_PF(sc) * VF_VLAN_CREDIT_CNT)
20004ef8ebfdSDavid C Somayajulu 
20014e400768SDavid Christensen 
20024e400768SDavid Christensen #endif /* ECORE_SP_H */
20034e400768SDavid Christensen 
2004