2 * Copyright (c) 2007-2013 QLogic Corporation. All rights reserved.
4 * Eric Davis <edavis@broadcom.com>
5 * David Christensen <davidch@broadcom.com>
6 * Gary Zambrano <zambrano@broadcom.com>
8 * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
9 * Copyright (c) 2015 QLogic Corporation.
10 * All rights reserved.
13 * See LICENSE.bnx2x_pmd for copyright and licensing details.
19 #include <rte_byteorder.h>
21 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
22 #ifndef __LITTLE_ENDIAN
23 #define __LITTLE_ENDIAN RTE_LITTLE_ENDIAN
26 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
28 #define __BIG_ENDIAN RTE_BIG_ENDIAN
30 #undef __LITTLE_ENDIAN
33 #include "ecore_mfw_req.h"
34 #include "ecore_fw_defs.h"
35 #include "ecore_hsi.h"
36 #include "ecore_reg.h"
39 typedef rte_iova_t ecore_dma_addr_t; /* expected to be 64 bit wide */
40 typedef volatile int ecore_atomic_t;
43 #define ETH_ALEN ETHER_ADDR_LEN /* 6 */
45 #define ECORE_SWCID_SHIFT 17
46 #define ECORE_SWCID_MASK ((0x1 << ECORE_SWCID_SHIFT) - 1)
48 #define ECORE_MC_HASH_SIZE 8
49 #define ECORE_MC_HASH_OFFSET(sc, i) \
50 (BAR_TSTRORM_INTMEM + \
51 TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(FUNC_ID(sc)) + i*4)
53 #define ECORE_MAX_MULTICAST 64
54 #define ECORE_MAX_EMUL_MULTI 1
56 #define IRO sc->iro_array
58 typedef rte_spinlock_t ECORE_MUTEX;
59 #define ECORE_MUTEX_INIT(_mutex) rte_spinlock_init(_mutex)
60 #define ECORE_MUTEX_LOCK(_mutex) rte_spinlock_lock(_mutex)
61 #define ECORE_MUTEX_UNLOCK(_mutex) rte_spinlock_unlock(_mutex)
63 typedef rte_spinlock_t ECORE_MUTEX_SPIN;
64 #define ECORE_SPIN_LOCK_INIT(_spin, _sc) rte_spinlock_init(_spin)
65 #define ECORE_SPIN_LOCK_BH(_spin) rte_spinlock_lock(_spin) /* bh = bottom-half */
66 #define ECORE_SPIN_UNLOCK_BH(_spin) rte_spinlock_unlock(_spin) /* bh = bottom-half */
68 #define ECORE_SMP_MB_AFTER_CLEAR_BIT() mb()
69 #define ECORE_SMP_MB_BEFORE_CLEAR_BIT() mb()
70 #define ECORE_SMP_MB() mb()
71 #define ECORE_SMP_RMB() rmb()
72 #define ECORE_SMP_WMB() wmb()
73 #define ECORE_MMIOWB() wmb()
75 #define ECORE_SET_BIT_NA(bit, var) (*var |= (1 << bit))
76 #define ECORE_CLEAR_BIT_NA(bit, var) (*var &= ~(1 << bit))
78 #define ECORE_TEST_BIT(bit, var) bnx2x_test_bit(bit, var)
79 #define ECORE_SET_BIT(bit, var) bnx2x_set_bit(bit, var)
80 #define ECORE_CLEAR_BIT(bit, var) bnx2x_clear_bit(bit, var)
81 #define ECORE_TEST_AND_CLEAR_BIT(bit, var) bnx2x_test_and_clear_bit(bit, var)
83 #define atomic_load_acq_int (int)*
84 #define atomic_store_rel_int(a, v) (*a = v)
85 #define atomic_cmpset_acq_int(a, o, n) ((*a = (o & (n)) | (n)) ^ o)
87 #define atomic_load_acq_long (long)*
88 #define atomic_store_rel_long(a, v) (*a = v)
89 #define atomic_set_acq_long(a, v) (*a |= v)
90 #define atomic_clear_acq_long(a, v) (*a &= ~v)
91 #define atomic_cmpset_acq_long(a, o, n) ((*a = (o & (n)) | (n)) ^ o)
92 #define atomic_subtract_acq_long(a, v) (*a -= v)
93 #define atomic_add_acq_long(a, v) (*a += v)
95 #define ECORE_ATOMIC_READ(a) atomic_load_acq_int((volatile int *)a)
96 #define ECORE_ATOMIC_SET(a, v) atomic_store_rel_int((volatile int *)a, v)
97 #define ECORE_ATOMIC_CMPXCHG(a, o, n) bnx2x_cmpxchg((volatile int *)a, o, n)
99 #define ECORE_RET_PENDING(pending_bit, pending) \
100 (ECORE_TEST_BIT(pending_bit, pending) ? ECORE_PENDING : ECORE_SUCCESS)
102 #define ECORE_SET_FLAG(value, mask, flag) \
104 (value) &= ~(mask); \
105 (value) |= ((flag) << (mask##_SHIFT)); \
108 #define ECORE_GET_FLAG(value, mask) \
109 (((value) &= (mask)) >> (mask##_SHIFT))
111 #define ECORE_MIGHT_SLEEP()
113 #define ECORE_FCOE_CID(sc) ((sc)->fp[FCOE_IDX(sc)].cl_id)
115 #define ECORE_MEMCMP(_a, _b, _s) memcmp(_a, _b, _s)
116 #define ECORE_MEMCPY(_a, _b, _s) rte_memcpy(_a, _b, _s)
117 #define ECORE_MEMSET(_a, _c, _s) memset(_a, _c, _s)
119 #define ECORE_CPU_TO_LE16(x) htole16(x)
120 #define ECORE_CPU_TO_LE32(x) htole32(x)
122 #define ECORE_WAIT(_s, _t) DELAY(1000)
123 #define ECORE_MSLEEP(_t) DELAY((_t) * 1000)
125 #define ECORE_LIKELY(x) likely(x)
126 #define ECORE_UNLIKELY(x) unlikely(x)
128 #define ECORE_ZALLOC(_size, _flags, _sc) \
129 rte_zmalloc("", _size, RTE_CACHE_LINE_SIZE)
131 #define ECORE_CALLOC(_len, _size, _flags, _sc) \
132 rte_calloc("", _len, _size, RTE_CACHE_LINE_SIZE)
134 #define ECORE_FREE(_s, _buf, _size) \
137 #define SC_ILT(sc) ((sc)->ilt)
138 #define ILOG2(x) bnx2x_ilog2(x)
140 #define ECORE_ILT_ZALLOC(x, y, size, str) \
142 x = rte_malloc("", sizeof(struct bnx2x_dma), RTE_CACHE_LINE_SIZE); \
144 if (bnx2x_dma_alloc((struct bnx2x_softc *)sc, \
145 size, (struct bnx2x_dma *)x, \
146 str, RTE_CACHE_LINE_SIZE) != 0) { \
151 *y = ((struct bnx2x_dma *)x)->paddr; \
156 #define ECORE_ILT_FREE(x, y, size) \
165 #define ECORE_IS_VALID_ETHER_ADDR(_mac) TRUE
167 #define ECORE_IS_MF_SD_MODE IS_MF_SD_MODE
168 #define ECORE_IS_MF_SI_MODE IS_MF_SI_MODE
169 #define ECORE_IS_MF_AFEX_MODE IS_MF_AFEX_MODE
171 #define ECORE_SET_CTX_VALIDATION bnx2x_set_ctx_validation
173 #define ECORE_UPDATE_COALESCE_SB_INDEX bnx2x_update_coalesce_sb_index
175 #define ECORE_ALIGN(x, a) ((((x) + (a) - 1) / (a)) * (a))
177 #define ECORE_REG_WR_DMAE_LEN REG_WR_DMAE_LEN
179 #define ECORE_PATH_ID SC_PATH
180 #define ECORE_PORT_ID SC_PORT
181 #define ECORE_FUNC_ID SC_FUNC
182 #define ECORE_ABS_FUNC_ID SC_ABS_FUNC
184 #define CRCPOLY_LE 0xedb88320
185 uint32_t ecore_calc_crc32(uint32_t crc, uint8_t const *p,
186 uint32_t len, uint32_t magic);
188 uint8_t ecore_calc_crc8(uint32_t data, uint8_t crc);
191 static inline uint32_t
192 ECORE_CRC32_LE(uint32_t seed, uint8_t *mac, uint32_t len)
194 return ecore_calc_crc32(seed, mac, len, CRCPOLY_LE);
197 #define ecore_sp_post(_sc, _a, _b, _c, _d) \
198 bnx2x_sp_post(_sc, _a, _b, U64_HI(_c), U64_LO(_c), _d)
200 #define ECORE_DBG_BREAK_IF(exp) \
202 if (unlikely(exp)) { \
203 rte_panic("ECORE"); \
207 #define ECORE_BUG() \
209 rte_panic("BUG (%s:%d)", __FILE__, __LINE__); \
212 #define ECORE_BUG_ON(exp) \
215 rte_panic("BUG_ON (%s:%d)", __FILE__, __LINE__); \
220 #define ECORE_MSG(m, ...) \
221 PMD_DRV_LOG(DEBUG, m, ##__VA_ARGS__)
223 typedef struct _ecore_list_entry_t
225 struct _ecore_list_entry_t *next, *prev;
226 } ecore_list_entry_t;
228 typedef struct ecore_list_t
230 ecore_list_entry_t *head, *tail;
234 /* initialize the list */
235 #define ECORE_LIST_INIT(_list) \
237 (_list)->head = NULL; \
238 (_list)->tail = NULL; \
242 /* return TRUE if the element is the last on the list */
243 #define ECORE_LIST_IS_LAST(_elem, _list) \
244 (_elem == (_list)->tail)
246 /* return TRUE if the list is empty */
247 #define ECORE_LIST_IS_EMPTY(_list) \
250 /* return the first element */
251 #define ECORE_LIST_FIRST_ENTRY(_list, cast, _link) \
252 (cast *)((_list)->head)
254 /* return the next element */
255 #define ECORE_LIST_NEXT(_elem, _link, cast) \
256 (cast *)((&((_elem)->_link))->next)
258 /* push an element on the head of the list */
259 #define ECORE_LIST_PUSH_HEAD(_elem, _list) \
261 (_elem)->prev = (ecore_list_entry_t *)0; \
262 (_elem)->next = (_list)->head; \
263 if ((_list)->tail == (ecore_list_entry_t *)0) { \
264 (_list)->tail = (_elem); \
266 (_list)->head->prev = (_elem); \
268 (_list)->head = (_elem); \
272 /* push an element on the tail of the list */
273 #define ECORE_LIST_PUSH_TAIL(_elem, _list) \
275 (_elem)->next = (ecore_list_entry_t *)0; \
276 (_elem)->prev = (_list)->tail; \
277 if ((_list)->tail) { \
278 (_list)->tail->next = (_elem); \
280 (_list)->head = (_elem); \
282 (_list)->tail = (_elem); \
286 /* push list1 on the head of list2 and return with list1 as empty */
287 #define ECORE_LIST_SPLICE_INIT(_list1, _list2) \
289 (_list1)->tail->next = (_list2)->head; \
290 if ((_list2)->head) { \
291 (_list2)->head->prev = (_list1)->tail; \
293 (_list2)->tail = (_list1)->tail; \
295 (_list2)->head = (_list1)->head; \
296 (_list2)->cnt += (_list1)->cnt; \
297 (_list1)->head = NULL; \
298 (_list1)->tail = NULL; \
302 /* remove an element from the list */
303 #define ECORE_LIST_REMOVE_ENTRY(_elem, _list) \
305 if ((_list)->head == (_elem)) { \
306 if ((_list)->head) { \
307 (_list)->head = (_list)->head->next; \
308 if ((_list)->head) { \
309 (_list)->head->prev = (ecore_list_entry_t *)0; \
311 (_list)->tail = (ecore_list_entry_t *)0; \
315 } else if ((_list)->tail == (_elem)) { \
316 if ((_list)->tail) { \
317 (_list)->tail = (_list)->tail->prev; \
318 if ((_list)->tail) { \
319 (_list)->tail->next = (ecore_list_entry_t *)0; \
321 (_list)->head = (ecore_list_entry_t *)0; \
326 (_elem)->prev->next = (_elem)->next; \
327 (_elem)->next->prev = (_elem)->prev; \
333 #define ECORE_LIST_FOR_EACH_ENTRY(pos, _list, _link, cast) \
334 for (pos = ECORE_LIST_FIRST_ENTRY(_list, cast, _link); \
336 pos = ECORE_LIST_NEXT(pos, _link, cast))
338 /* walk the list (safely) */
339 #define ECORE_LIST_FOR_EACH_ENTRY_SAFE(pos, n, _list, _link, cast) \
340 for (pos = ECORE_LIST_FIRST_ENTRY(_list, cast, _lint), \
341 n = (pos) ? ECORE_LIST_NEXT(pos, _link, cast) : NULL; \
344 n = (pos) ? ECORE_LIST_NEXT(pos, _link, cast) : NULL)
347 /* Manipulate a bit vector defined as an array of uint64_t */
349 /* Number of bits in one sge_mask array element */
350 #define BIT_VEC64_ELEM_SZ 64
351 #define BIT_VEC64_ELEM_SHIFT 6
352 #define BIT_VEC64_ELEM_MASK ((uint64_t)BIT_VEC64_ELEM_SZ - 1)
354 #define __BIT_VEC64_SET_BIT(el, bit) \
356 el = ((el) | ((uint64_t)0x1 << (bit))); \
359 #define __BIT_VEC64_CLEAR_BIT(el, bit) \
361 el = ((el) & (~((uint64_t)0x1 << (bit)))); \
364 #define BIT_VEC64_SET_BIT(vec64, idx) \
365 __BIT_VEC64_SET_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
366 (idx) & BIT_VEC64_ELEM_MASK)
368 #define BIT_VEC64_CLEAR_BIT(vec64, idx) \
369 __BIT_VEC64_CLEAR_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
370 (idx) & BIT_VEC64_ELEM_MASK)
372 #define BIT_VEC64_TEST_BIT(vec64, idx) \
373 (((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT] >> \
374 ((idx) & BIT_VEC64_ELEM_MASK)) & 0x1)
377 * Creates a bitmask of all ones in less significant bits.
378 * idx - index of the most significant bit in the created mask
380 #define BIT_VEC64_ONES_MASK(idx) \
381 (((uint64_t)0x1 << (((idx) & BIT_VEC64_ELEM_MASK) + 1)) - 1)
382 #define BIT_VEC64_ELEM_ONE_MASK ((uint64_t)(~0))
384 /* fill in a MAC address the way the FW likes it */
386 ecore_set_fw_mac_addr(uint16_t *fw_hi,
391 ((uint8_t *)fw_hi)[0] = mac[1];
392 ((uint8_t *)fw_hi)[1] = mac[0];
393 ((uint8_t *)fw_mid)[0] = mac[3];
394 ((uint8_t *)fw_mid)[1] = mac[2];
395 ((uint8_t *)fw_lo)[0] = mac[5];
396 ((uint8_t *)fw_lo)[1] = mac[4];
400 enum ecore_status_t {
408 /* PENDING is not an error and should be positive */
423 /* Bits representing general command's configuration */
427 /* Wait until all pending commands complete */
429 /* Don't send a ramrod, only update a registry */
431 /* Configure HW according to the current object state */
433 /* Execute the next command now */
435 /* Don't add a new command and continue execution of posponed
436 * commands. If not set a new command will be added to the
437 * pending commands list.
440 /* If there is another pending ramrod, wait until it finishes and
441 * re-try to submit this one. This flag can be set only in sleepable
442 * context, and should not be set from the context that completes the
443 * ramrods as deadlock will occur.
451 ECORE_OBJ_TYPE_RX_TX,
454 /* Public slow path states */
456 ECORE_FILTER_MAC_PENDING,
457 ECORE_FILTER_VLAN_PENDING,
458 ECORE_FILTER_VLAN_MAC_PENDING,
459 ECORE_FILTER_RX_MODE_PENDING,
460 ECORE_FILTER_RX_MODE_SCHED,
461 ECORE_FILTER_ISCSI_ETH_START_SCHED,
462 ECORE_FILTER_ISCSI_ETH_STOP_SCHED,
463 ECORE_FILTER_FCOE_ETH_START_SCHED,
464 ECORE_FILTER_FCOE_ETH_STOP_SCHED,
465 ECORE_FILTER_MCAST_PENDING,
466 ECORE_FILTER_MCAST_SCHED,
467 ECORE_FILTER_RSS_CONF_PENDING,
468 ECORE_AFEX_FCOE_Q_UPDATE_PENDING,
469 ECORE_AFEX_PENDING_VIFSET_MCP_ACK
472 struct ecore_raw_obj {
479 /* Ramrod data buffer params */
481 ecore_dma_addr_t rdata_mapping;
483 /* Ramrod state params */
484 int state; /* "ramrod is pending" state bit */
485 unsigned long *pstate; /* pointer to state buffer */
487 ecore_obj_type obj_type;
489 int (*wait_comp)(struct bnx2x_softc *sc,
490 struct ecore_raw_obj *o);
492 int (*check_pending)(struct ecore_raw_obj *o);
493 void (*clear_pending)(struct ecore_raw_obj *o);
494 void (*set_pending)(struct ecore_raw_obj *o);
497 /************************* VLAN-MAC commands related parameters ***************/
498 struct ecore_mac_ramrod_data {
499 uint8_t mac[ETH_ALEN];
500 uint8_t is_inner_mac;
503 struct ecore_vlan_ramrod_data {
507 struct ecore_vlan_mac_ramrod_data {
508 uint8_t mac[ETH_ALEN];
509 uint8_t is_inner_mac;
513 union ecore_classification_ramrod_data {
514 struct ecore_mac_ramrod_data mac;
515 struct ecore_vlan_ramrod_data vlan;
516 struct ecore_vlan_mac_ramrod_data vlan_mac;
519 /* VLAN_MAC commands */
520 enum ecore_vlan_mac_cmd {
526 struct ecore_vlan_mac_data {
527 /* Requested command: ECORE_VLAN_MAC_XX */
528 enum ecore_vlan_mac_cmd cmd;
529 /* used to contain the data related vlan_mac_flags bits from
532 unsigned long vlan_mac_flags;
534 /* Needed for MOVE command */
535 struct ecore_vlan_mac_obj *target_obj;
537 union ecore_classification_ramrod_data u;
540 /*************************** Exe Queue obj ************************************/
541 union ecore_exe_queue_cmd_data {
542 struct ecore_vlan_mac_data vlan_mac;
548 struct ecore_exeq_elem {
549 ecore_list_entry_t link;
551 /* Length of this element in the exe_chunk. */
554 union ecore_exe_queue_cmd_data cmd_data;
557 union ecore_qable_obj;
559 union ecore_exeq_comp_elem {
560 union event_ring_elem *elem;
563 struct ecore_exe_queue_obj;
565 typedef int (*exe_q_validate)(struct bnx2x_softc *sc,
566 union ecore_qable_obj *o,
567 struct ecore_exeq_elem *elem);
569 typedef int (*exe_q_remove)(struct bnx2x_softc *sc,
570 union ecore_qable_obj *o,
571 struct ecore_exeq_elem *elem);
573 /* Return positive if entry was optimized, 0 - if not, negative
574 * in case of an error.
576 typedef int (*exe_q_optimize)(struct bnx2x_softc *sc,
577 union ecore_qable_obj *o,
578 struct ecore_exeq_elem *elem);
579 typedef int (*exe_q_execute)(struct bnx2x_softc *sc,
580 union ecore_qable_obj *o,
581 ecore_list_t *exe_chunk,
582 unsigned long *ramrod_flags);
583 typedef struct ecore_exeq_elem *
584 (*exe_q_get)(struct ecore_exe_queue_obj *o,
585 struct ecore_exeq_elem *elem);
587 struct ecore_exe_queue_obj {
588 /* Commands pending for an execution. */
589 ecore_list_t exe_queue;
591 /* Commands pending for an completion. */
592 ecore_list_t pending_comp;
594 ECORE_MUTEX_SPIN lock;
596 /* Maximum length of commands' list for one execution */
599 union ecore_qable_obj *owner;
601 /****** Virtual functions ******/
603 * Called before commands execution for commands that are really
604 * going to be executed (after 'optimize').
606 * Must run under exe_queue->lock
608 exe_q_validate validate;
611 * Called before removing pending commands, cleaning allocated
612 * resources (e.g., credits from validate)
617 * This will try to cancel the current pending commands list
618 * considering the new command.
620 * Returns the number of optimized commands or a negative error code
622 * Must run under exe_queue->lock
624 exe_q_optimize optimize;
627 * Run the next commands chunk (owner specific).
629 exe_q_execute execute;
632 * Return the exe_queue element containing the specific command
633 * if any. Otherwise return NULL.
637 /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
639 * Element in the VLAN_MAC registry list having all current configured
642 struct ecore_vlan_mac_registry_elem {
643 ecore_list_entry_t link;
645 /* Used to store the cam offset used for the mac/vlan/vlan-mac.
646 * Relevant for 57711 only. VLANs and MACs share the
647 * same CAM for these chips.
651 /* Needed for DEL and RESTORE flows */
652 unsigned long vlan_mac_flags;
654 union ecore_classification_ramrod_data u;
657 /* Bits representing VLAN_MAC commands specific flags */
663 ECORE_DONT_CONSUME_CAM_CREDIT,
664 ECORE_DONT_CONSUME_CAM_CREDIT_DEST,
667 struct ecore_vlan_mac_ramrod_params {
668 /* Object to run the command from */
669 struct ecore_vlan_mac_obj *vlan_mac_obj;
671 /* General command flags: COMP_WAIT, etc. */
672 unsigned long ramrod_flags;
674 /* Command specific configuration request */
675 struct ecore_vlan_mac_data user_req;
678 struct ecore_vlan_mac_obj {
679 struct ecore_raw_obj raw;
681 /* Bookkeeping list: will prevent the addition of already existing
685 /* Implement a simple reader/writer lock on the head list.
686 * all these fields should only be accessed under the exe_queue lock
688 uint8_t head_reader; /* Num. of readers accessing head list */
689 int head_exe_request; /* Pending execution request. */
690 unsigned long saved_ramrod_flags; /* Ramrods of pending execution */
692 /* Execution queue interface instance */
693 struct ecore_exe_queue_obj exe_queue;
695 /* MACs credit pool */
696 struct ecore_credit_pool_obj *macs_pool;
698 /* VLANs credit pool */
699 struct ecore_credit_pool_obj *vlans_pool;
701 /* RAMROD command to be used */
704 /* copy first n elements onto preallocated buffer
706 * @param n number of elements to get
707 * @param buf buffer preallocated by caller into which elements
708 * will be copied. Note elements are 4-byte aligned
709 * so buffer size must be able to accommodate the
712 * @return number of copied bytes
715 int (*get_n_elements)(struct bnx2x_softc *sc,
716 struct ecore_vlan_mac_obj *o, int n, uint8_t *base,
717 uint8_t stride, uint8_t size);
720 * Checks if ADD-ramrod with the given params may be performed.
722 * @return zero if the element may be added
725 int (*check_add)(struct bnx2x_softc *sc,
726 struct ecore_vlan_mac_obj *o,
727 union ecore_classification_ramrod_data *data);
730 * Checks if DEL-ramrod with the given params may be performed.
732 * @return TRUE if the element may be deleted
734 struct ecore_vlan_mac_registry_elem *
735 (*check_del)(struct bnx2x_softc *sc,
736 struct ecore_vlan_mac_obj *o,
737 union ecore_classification_ramrod_data *data);
740 * Checks if DEL-ramrod with the given params may be performed.
742 * @return TRUE if the element may be deleted
744 int (*check_move)(struct bnx2x_softc *sc,
745 struct ecore_vlan_mac_obj *src_o,
746 struct ecore_vlan_mac_obj *dst_o,
747 union ecore_classification_ramrod_data *data);
750 * Update the relevant credit object(s) (consume/return
753 int (*get_credit)(struct ecore_vlan_mac_obj *o);
754 int (*put_credit)(struct ecore_vlan_mac_obj *o);
755 int (*get_cam_offset)(struct ecore_vlan_mac_obj *o, int *offset);
756 int (*put_cam_offset)(struct ecore_vlan_mac_obj *o, int offset);
759 * Configures one rule in the ramrod data buffer.
761 void (*set_one_rule)(struct bnx2x_softc *sc,
762 struct ecore_vlan_mac_obj *o,
763 struct ecore_exeq_elem *elem, int rule_idx,
767 * Delete all configured elements having the given
768 * vlan_mac_flags specification. Assumes no pending for
769 * execution commands. Will schedule all all currently
770 * configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
771 * specification for deletion and will use the given
772 * ramrod_flags for the last DEL operation.
776 * @param ramrod_flags RAMROD_XX flags
778 * @return 0 if the last operation has completed successfully
779 * and there are no more elements left, positive value
780 * if there are pending for completion commands,
781 * negative value in case of failure.
783 int (*delete_all)(struct bnx2x_softc *sc,
784 struct ecore_vlan_mac_obj *o,
785 unsigned long *vlan_mac_flags,
786 unsigned long *ramrod_flags);
789 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
790 * configured elements list.
793 * @param p Command parameters (RAMROD_COMP_WAIT bit in
794 * ramrod_flags is only taken into an account)
795 * @param ppos a pointer to the cookie that should be given back in the
796 * next call to make function handle the next element. If
797 * *ppos is set to NULL it will restart the iterator.
798 * If returned *ppos == NULL this means that the last
799 * element has been handled.
803 int (*restore)(struct bnx2x_softc *sc,
804 struct ecore_vlan_mac_ramrod_params *p,
805 struct ecore_vlan_mac_registry_elem **ppos);
808 * Should be called on a completion arrival.
812 * @param cqe Completion element we are handling
813 * @param ramrod_flags if RAMROD_CONT is set the next bulk of
814 * pending commands will be executed.
815 * RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
816 * may also be set if needed.
818 * @return 0 if there are neither pending nor waiting for
819 * completion commands. Positive value if there are
820 * pending for execution or for completion commands.
821 * Negative value in case of an error (including an
824 int (*complete)(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *o,
825 union event_ring_elem *cqe,
826 unsigned long *ramrod_flags);
829 * Wait for completion of all commands. Don't schedule new ones,
830 * just wait. It assumes that the completion code will schedule
833 int (*wait)(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *o);
837 ECORE_LLH_CAM_ISCSI_ETH_LINE = 0,
838 ECORE_LLH_CAM_ETH_LINE,
839 ECORE_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2
842 /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
844 /* RX_MODE ramrod special flags: set in rx_mode_flags field in
845 * a ecore_rx_mode_ramrod_params.
848 ECORE_RX_MODE_FCOE_ETH,
849 ECORE_RX_MODE_ISCSI_ETH,
853 ECORE_ACCEPT_UNICAST,
854 ECORE_ACCEPT_MULTICAST,
855 ECORE_ACCEPT_ALL_UNICAST,
856 ECORE_ACCEPT_ALL_MULTICAST,
857 ECORE_ACCEPT_BROADCAST,
858 ECORE_ACCEPT_UNMATCHED,
859 ECORE_ACCEPT_ANY_VLAN
862 struct ecore_rx_mode_ramrod_params {
863 struct ecore_rx_mode_obj *rx_mode_obj;
864 unsigned long *pstate;
869 unsigned long ramrod_flags;
870 unsigned long rx_mode_flags;
872 /* rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
873 * a tstorm_eth_mac_filter_config (e1x).
876 ecore_dma_addr_t rdata_mapping;
878 /* Rx mode settings */
879 unsigned long rx_accept_flags;
881 /* internal switching settings */
882 unsigned long tx_accept_flags;
885 struct ecore_rx_mode_obj {
886 int (*config_rx_mode)(struct bnx2x_softc *sc,
887 struct ecore_rx_mode_ramrod_params *p);
889 int (*wait_comp)(struct bnx2x_softc *sc,
890 struct ecore_rx_mode_ramrod_params *p);
893 /********************** Set multicast group ***********************************/
895 struct ecore_mcast_list_elem {
896 ecore_list_entry_t link;
900 union ecore_mcast_config_data {
902 uint8_t bin; /* used in a RESTORE flow */
905 struct ecore_mcast_ramrod_params {
906 struct ecore_mcast_obj *mcast_obj;
908 /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
909 unsigned long ramrod_flags;
911 ecore_list_t mcast_list; /* list of struct ecore_mcast_list_elem */
915 enum ecore_mcast_cmd {
917 ECORE_MCAST_CMD_CONT,
919 ECORE_MCAST_CMD_RESTORE,
922 struct ecore_mcast_obj {
923 struct ecore_raw_obj raw;
927 #define ECORE_MCAST_BINS_NUM 256
928 #define ECORE_MCAST_VEC_SZ (ECORE_MCAST_BINS_NUM / 64)
929 uint64_t vec[ECORE_MCAST_VEC_SZ];
931 /** Number of BINs to clear. Should be updated
932 * immediately when a command arrives in order to
933 * properly create DEL commands.
944 /* Pending commands */
945 ecore_list_t pending_cmds_head;
947 /* A state that is set in raw.pstate, when there are pending commands */
950 /* Maximal number of mcast MACs configured in one command */
953 /* Total number of currently pending MACs to configure: both
954 * in the pending commands list and in the current command.
956 int total_pending_num;
961 * @param cmd command to execute (ECORE_MCAST_CMD_X, see above)
963 int (*config_mcast)(struct bnx2x_softc *sc,
964 struct ecore_mcast_ramrod_params *p,
965 enum ecore_mcast_cmd cmd);
968 * Fills the ramrod data during the RESTORE flow.
972 * @param start_idx Registry index to start from
973 * @param rdata_idx Index in the ramrod data to start from
975 * @return -1 if we handled the whole registry or index of the last
976 * handled registry element.
978 int (*hdl_restore)(struct bnx2x_softc *sc, struct ecore_mcast_obj *o,
979 int start_bin, int *rdata_idx);
981 int (*enqueue_cmd)(struct bnx2x_softc *sc, struct ecore_mcast_obj *o,
982 struct ecore_mcast_ramrod_params *p,
983 enum ecore_mcast_cmd cmd);
985 void (*set_one_rule)(struct bnx2x_softc *sc,
986 struct ecore_mcast_obj *o, int idx,
987 union ecore_mcast_config_data *cfg_data,
988 enum ecore_mcast_cmd cmd);
990 /** Checks if there are more mcast MACs to be set or a previous
991 * command is still pending.
993 int (*check_pending)(struct ecore_mcast_obj *o);
996 * Set/Clear/Check SCHEDULED state of the object
998 void (*set_sched)(struct ecore_mcast_obj *o);
999 void (*clear_sched)(struct ecore_mcast_obj *o);
1000 int (*check_sched)(struct ecore_mcast_obj *o);
1002 /* Wait until all pending commands complete */
1003 int (*wait_comp)(struct bnx2x_softc *sc, struct ecore_mcast_obj *o);
1006 * Handle the internal object counters needed for proper
1007 * commands handling. Checks that the provided parameters are
1010 int (*validate)(struct bnx2x_softc *sc,
1011 struct ecore_mcast_ramrod_params *p,
1012 enum ecore_mcast_cmd cmd);
1015 * Restore the values of internal counters in case of a failure.
1017 void (*revert)(struct bnx2x_softc *sc,
1018 struct ecore_mcast_ramrod_params *p,
1021 int (*get_registry_size)(struct ecore_mcast_obj *o);
1022 void (*set_registry_size)(struct ecore_mcast_obj *o, int n);
1025 /*************************** Credit handling **********************************/
1026 struct ecore_credit_pool_obj {
1028 /* Current amount of credit in the pool */
1029 ecore_atomic_t credit;
1031 /* Maximum allowed credit. put() will check against it. */
1034 /* Allocate a pool table statically.
1036 * Currently the maximum allowed size is MAX_MAC_CREDIT_E2(272)
1038 * The set bit in the table will mean that the entry is available.
1040 #define ECORE_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64)
1041 uint64_t pool_mirror[ECORE_POOL_VEC_SIZE];
1043 /* Base pool offset (initialized differently */
1044 int base_pool_offset;
1047 * Get the next free pool entry.
1049 * @return TRUE if there was a free entry in the pool
1051 int (*get_entry)(struct ecore_credit_pool_obj *o, int *entry);
1054 * Return the entry back to the pool.
1056 * @return TRUE if entry is legal and has been successfully
1057 * returned to the pool.
1059 int (*put_entry)(struct ecore_credit_pool_obj *o, int entry);
1062 * Get the requested amount of credit from the pool.
1064 * @param cnt Amount of requested credit
1065 * @return TRUE if the operation is successful
1067 int (*get)(struct ecore_credit_pool_obj *o, int cnt);
1070 * Returns the credit to the pool.
1072 * @param cnt Amount of credit to return
1073 * @return TRUE if the operation is successful
1075 int (*put)(struct ecore_credit_pool_obj *o, int cnt);
1078 * Reads the current amount of credit.
1080 int (*check)(struct ecore_credit_pool_obj *o);
1083 /*************************** RSS configuration ********************************/
1085 /* RSS_MODE bits are mutually exclusive */
1086 ECORE_RSS_MODE_DISABLED,
1087 ECORE_RSS_MODE_REGULAR,
1089 ECORE_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */
1098 ECORE_RSS_TUNNELING,
1101 struct ecore_config_rss_params {
1102 struct ecore_rss_config_obj *rss_obj;
1104 /* may have RAMROD_COMP_WAIT set only */
1105 unsigned long ramrod_flags;
1107 /* ECORE_RSS_X bits */
1108 unsigned long rss_flags;
1110 /* Number hash bits to take into an account */
1111 uint8_t rss_result_mask;
1113 /* Indirection table */
1114 uint8_t ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
1116 /* RSS hash values */
1117 uint32_t rss_key[10];
1119 /* valid only if ECORE_RSS_UPDATE_TOE is set */
1120 uint16_t toe_rss_bitmap;
1122 /* valid if ECORE_RSS_TUNNELING is set */
1123 uint16_t tunnel_value;
1124 uint16_t tunnel_mask;
1127 struct ecore_rss_config_obj {
1128 struct ecore_raw_obj raw;
1130 /* RSS engine to use */
1133 /* Last configured indirection table */
1134 uint8_t ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
1136 /* flags for enabling 4-tupple hash on UDP */
1140 int (*config_rss)(struct bnx2x_softc *sc,
1141 struct ecore_config_rss_params *p);
1144 /*********************** Queue state update ***********************************/
1146 /* UPDATE command options */
1148 ECORE_Q_UPDATE_IN_VLAN_REM,
1149 ECORE_Q_UPDATE_IN_VLAN_REM_CHNG,
1150 ECORE_Q_UPDATE_OUT_VLAN_REM,
1151 ECORE_Q_UPDATE_OUT_VLAN_REM_CHNG,
1152 ECORE_Q_UPDATE_ANTI_SPOOF,
1153 ECORE_Q_UPDATE_ANTI_SPOOF_CHNG,
1154 ECORE_Q_UPDATE_ACTIVATE,
1155 ECORE_Q_UPDATE_ACTIVATE_CHNG,
1156 ECORE_Q_UPDATE_DEF_VLAN_EN,
1157 ECORE_Q_UPDATE_DEF_VLAN_EN_CHNG,
1158 ECORE_Q_UPDATE_SILENT_VLAN_REM_CHNG,
1159 ECORE_Q_UPDATE_SILENT_VLAN_REM,
1160 ECORE_Q_UPDATE_TX_SWITCHING_CHNG,
1161 ECORE_Q_UPDATE_TX_SWITCHING,
1164 /* Allowed Queue states */
1165 enum ecore_q_state {
1166 ECORE_Q_STATE_RESET,
1167 ECORE_Q_STATE_INITIALIZED,
1168 ECORE_Q_STATE_ACTIVE,
1169 ECORE_Q_STATE_MULTI_COS,
1170 ECORE_Q_STATE_MCOS_TERMINATED,
1171 ECORE_Q_STATE_INACTIVE,
1172 ECORE_Q_STATE_STOPPED,
1173 ECORE_Q_STATE_TERMINATED,
1174 ECORE_Q_STATE_FLRED,
1178 /* Allowed Queue states */
1179 enum ecore_q_logical_state {
1180 ECORE_Q_LOGICAL_STATE_ACTIVE,
1181 ECORE_Q_LOGICAL_STATE_STOPPED,
1184 /* Allowed commands */
1185 enum ecore_queue_cmd {
1188 ECORE_Q_CMD_SETUP_TX_ONLY,
1189 ECORE_Q_CMD_DEACTIVATE,
1190 ECORE_Q_CMD_ACTIVATE,
1192 ECORE_Q_CMD_UPDATE_TPA,
1194 ECORE_Q_CMD_CFC_DEL,
1195 ECORE_Q_CMD_TERMINATE,
1200 /* queue SETUP + INIT flags */
1203 ECORE_Q_FLG_TPA_IPV6,
1204 ECORE_Q_FLG_TPA_GRO,
1206 ECORE_Q_FLG_ZERO_STATS,
1216 ECORE_Q_FLG_LEADING_RSS,
1218 ECORE_Q_FLG_DEF_VLAN,
1219 ECORE_Q_FLG_TX_SWITCH,
1221 ECORE_Q_FLG_ANTI_SPOOF,
1222 ECORE_Q_FLG_SILENT_VLAN_REM,
1223 ECORE_Q_FLG_FORCE_DEFAULT_PRI,
1224 ECORE_Q_FLG_REFUSE_OUTBAND_VLAN,
1225 ECORE_Q_FLG_PCSUM_ON_PKT,
1226 ECORE_Q_FLG_TUN_INC_INNER_IP_ID
1229 /* Queue type options: queue type may be a combination of below. */
1232 ECORE_Q_TYPE_HAS_RX,
1233 ECORE_Q_TYPE_HAS_TX,
1236 #define ECORE_PRIMARY_CID_INDEX 0
1237 #define ECORE_MULTI_TX_COS_E1X 3 /* QM only */
1238 #define ECORE_MULTI_TX_COS_E2_E3A0 2
1239 #define ECORE_MULTI_TX_COS_E3B0 3
1240 #define ECORE_MULTI_TX_COS 3 /* Maximum possible */
1241 #define MAC_PAD (ECORE_ALIGN(ETH_ALEN, sizeof(uint32_t)) - ETH_ALEN)
1243 struct ecore_queue_init_params {
1245 unsigned long flags;
1248 uint8_t sb_cq_index;
1252 unsigned long flags;
1255 uint8_t sb_cq_index;
1258 /* CID context in the host memory */
1259 struct eth_context *cxts[ECORE_MULTI_TX_COS];
1261 /* maximum number of cos supported by hardware */
1265 struct ecore_queue_terminate_params {
1266 /* index within the tx_only cids of this queue object */
1270 struct ecore_queue_cfc_del_params {
1271 /* index within the tx_only cids of this queue object */
1275 struct ecore_queue_update_params {
1276 unsigned long update_flags; /* ECORE_Q_UPDATE_XX bits */
1278 uint16_t silent_removal_value;
1279 uint16_t silent_removal_mask;
1280 /* index within the tx_only cids of this queue object */
1284 struct rxq_pause_params {
1289 uint16_t sge_th_lo; /* valid if ECORE_Q_FLG_TPA */
1290 uint16_t sge_th_hi; /* valid if ECORE_Q_FLG_TPA */
1295 struct ecore_general_setup_params {
1296 /* valid if ECORE_Q_FLG_STATS */
1304 struct ecore_rxq_setup_params {
1306 ecore_dma_addr_t dscr_map;
1307 ecore_dma_addr_t rcq_map;
1308 ecore_dma_addr_t rcq_np_map;
1310 uint16_t drop_flags;
1313 uint8_t cl_qzone_id;
1315 /* valid if ECORE_Q_FLG_TPA */
1316 uint16_t tpa_agg_sz;
1317 uint8_t max_tpa_queues;
1318 uint8_t rss_engine_id;
1320 /* valid if ECORE_Q_FLG_MCAST */
1321 uint8_t mcast_engine_id;
1323 uint8_t cache_line_log;
1325 uint8_t sb_cq_index;
1327 /* valid if BXN2X_Q_FLG_SILENT_VLAN_REM */
1328 uint16_t silent_removal_value;
1329 uint16_t silent_removal_mask;
1332 struct ecore_txq_setup_params {
1334 ecore_dma_addr_t dscr_map;
1337 uint8_t sb_cq_index;
1338 uint8_t cos; /* valid if ECORE_Q_FLG_COS */
1339 uint16_t traffic_type;
1340 /* equals to the leading rss client id, used for TX classification*/
1341 uint8_t tss_leading_cl_id;
1343 /* valid if ECORE_Q_FLG_DEF_VLAN */
1344 uint16_t default_vlan;
1347 struct ecore_queue_setup_params {
1348 struct ecore_general_setup_params gen_params;
1349 struct ecore_txq_setup_params txq_params;
1350 struct ecore_rxq_setup_params rxq_params;
1351 struct rxq_pause_params pause_params;
1352 unsigned long flags;
1355 struct ecore_queue_setup_tx_only_params {
1356 struct ecore_general_setup_params gen_params;
1357 struct ecore_txq_setup_params txq_params;
1358 unsigned long flags;
1359 /* index within the tx_only cids of this queue object */
1363 struct ecore_queue_state_params {
1364 struct ecore_queue_sp_obj *q_obj;
1366 /* Current command */
1367 enum ecore_queue_cmd cmd;
1369 /* may have RAMROD_COMP_WAIT set only */
1370 unsigned long ramrod_flags;
1372 /* Params according to the current command */
1374 struct ecore_queue_update_params update;
1375 struct ecore_queue_setup_params setup;
1376 struct ecore_queue_init_params init;
1377 struct ecore_queue_setup_tx_only_params tx_only;
1378 struct ecore_queue_terminate_params terminate;
1379 struct ecore_queue_cfc_del_params cfc_del;
1383 struct ecore_viflist_params {
1385 uint8_t func_bit_map_res;
1388 struct ecore_queue_sp_obj {
1389 uint32_t cids[ECORE_MULTI_TX_COS];
1393 /* number of traffic classes supported by queue.
1394 * The primary connection of the queue supports the first traffic
1395 * class. Any further traffic class is supported by a tx-only
1398 * Therefore max_cos is also a number of valid entries in the cids
1402 uint8_t num_tx_only, next_tx_only;
1404 enum ecore_q_state state, next_state;
1406 /* bits from enum ecore_q_type */
1409 /* ECORE_Q_CMD_XX bits. This object implements "one
1410 * pending" paradigm but for debug and tracing purposes it's
1411 * more convenient to have different bits for different
1414 unsigned long pending;
1416 /* Buffer to use as a ramrod data and its mapping */
1418 ecore_dma_addr_t rdata_mapping;
1421 * Performs one state change according to the given parameters.
1423 * @return 0 in case of success and negative value otherwise.
1425 int (*send_cmd)(struct bnx2x_softc *sc,
1426 struct ecore_queue_state_params *params);
1429 * Sets the pending bit according to the requested transition.
1431 int (*set_pending)(struct ecore_queue_sp_obj *o,
1432 struct ecore_queue_state_params *params);
1435 * Checks that the requested state transition is legal.
1437 int (*check_transition)(struct bnx2x_softc *sc,
1438 struct ecore_queue_sp_obj *o,
1439 struct ecore_queue_state_params *params);
1442 * Completes the pending command.
1444 int (*complete_cmd)(struct bnx2x_softc *sc,
1445 struct ecore_queue_sp_obj *o,
1446 enum ecore_queue_cmd);
1448 int (*wait_comp)(struct bnx2x_softc *sc,
1449 struct ecore_queue_sp_obj *o,
1450 enum ecore_queue_cmd cmd);
1453 /********************** Function state update *********************************/
1454 /* Allowed Function states */
1455 enum ecore_func_state {
1456 ECORE_F_STATE_RESET,
1457 ECORE_F_STATE_INITIALIZED,
1458 ECORE_F_STATE_STARTED,
1459 ECORE_F_STATE_TX_STOPPED,
1463 /* Allowed Function commands */
1464 enum ecore_func_cmd {
1465 ECORE_F_CMD_HW_INIT,
1468 ECORE_F_CMD_HW_RESET,
1469 ECORE_F_CMD_AFEX_UPDATE,
1470 ECORE_F_CMD_AFEX_VIFLISTS,
1471 ECORE_F_CMD_TX_STOP,
1472 ECORE_F_CMD_TX_START,
1473 ECORE_F_CMD_SWITCH_UPDATE,
1477 struct ecore_func_hw_init_params {
1478 /* A load phase returned by MCP.
1481 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1482 * FW_MSG_CODE_DRV_LOAD_COMMON
1483 * FW_MSG_CODE_DRV_LOAD_PORT
1484 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1486 uint32_t load_phase;
1489 struct ecore_func_hw_reset_params {
1490 /* A load phase returned by MCP.
1493 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1494 * FW_MSG_CODE_DRV_LOAD_COMMON
1495 * FW_MSG_CODE_DRV_LOAD_PORT
1496 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1498 uint32_t reset_phase;
1501 struct ecore_func_start_params {
1502 /* Multi Function mode:
1504 * - Switch Dependent
1505 * - Switch Independent
1509 /* Switch Dependent mode outer VLAN tag */
1510 uint16_t sd_vlan_tag;
1512 /* Function cos mode */
1513 uint8_t network_cos_mode;
1515 /* NVGRE classification enablement */
1516 uint8_t nvgre_clss_en;
1518 /* NO_GRE_TUNNEL/NVGRE_TUNNEL/L2GRE_TUNNEL/IPGRE_TUNNEL */
1519 uint8_t gre_tunnel_mode;
1521 /* GRE_OUTER_HEADERS_RSS/GRE_INNER_HEADERS_RSS/NVGRE_KEY_ENTROPY_RSS */
1522 uint8_t gre_tunnel_rss;
1526 struct ecore_func_switch_update_params {
1530 struct ecore_func_afex_update_params {
1532 uint16_t afex_default_vlan;
1533 uint8_t allowed_priorities;
1536 struct ecore_func_afex_viflists_params {
1537 uint16_t vif_list_index;
1538 uint8_t func_bit_map;
1539 uint8_t afex_vif_list_command;
1540 uint8_t func_to_clear;
1542 struct ecore_func_tx_start_params {
1543 struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES];
1544 uint8_t dcb_enabled;
1545 uint8_t dcb_version;
1546 uint8_t dont_add_pri_0;
1549 struct ecore_func_state_params {
1550 struct ecore_func_sp_obj *f_obj;
1552 /* Current command */
1553 enum ecore_func_cmd cmd;
1555 /* may have RAMROD_COMP_WAIT set only */
1556 unsigned long ramrod_flags;
1558 /* Params according to the current command */
1560 struct ecore_func_hw_init_params hw_init;
1561 struct ecore_func_hw_reset_params hw_reset;
1562 struct ecore_func_start_params start;
1563 struct ecore_func_switch_update_params switch_update;
1564 struct ecore_func_afex_update_params afex_update;
1565 struct ecore_func_afex_viflists_params afex_viflists;
1566 struct ecore_func_tx_start_params tx_start;
1570 struct ecore_func_sp_drv_ops {
1571 /* Init tool + runtime initialization:
1573 * - Common (per Path)
1577 int (*init_hw_cmn_chip)(struct bnx2x_softc *sc);
1578 int (*init_hw_cmn)(struct bnx2x_softc *sc);
1579 int (*init_hw_port)(struct bnx2x_softc *sc);
1580 int (*init_hw_func)(struct bnx2x_softc *sc);
1582 /* Reset Function HW: Common, Port, Function phases. */
1583 void (*reset_hw_cmn)(struct bnx2x_softc *sc);
1584 void (*reset_hw_port)(struct bnx2x_softc *sc);
1585 void (*reset_hw_func)(struct bnx2x_softc *sc);
1587 /* Prepare/Release FW resources */
1588 int (*init_fw)(struct bnx2x_softc *sc);
1589 void (*release_fw)(struct bnx2x_softc *sc);
1592 struct ecore_func_sp_obj {
1593 enum ecore_func_state state, next_state;
1595 /* ECORE_FUNC_CMD_XX bits. This object implements "one
1596 * pending" paradigm but for debug and tracing purposes it's
1597 * more convenient to have different bits for different
1600 unsigned long pending;
1602 /* Buffer to use as a ramrod data and its mapping */
1604 ecore_dma_addr_t rdata_mapping;
1606 /* Buffer to use as a afex ramrod data and its mapping.
1607 * This can't be same rdata as above because afex ramrod requests
1608 * can arrive to the object in parallel to other ramrod requests.
1611 ecore_dma_addr_t afex_rdata_mapping;
1613 /* this mutex validates that when pending flag is taken, the next
1614 * ramrod to be sent will be the one set the pending bit
1616 ECORE_MUTEX one_pending_mutex;
1618 /* Driver interface */
1619 struct ecore_func_sp_drv_ops *drv;
1622 * Performs one state change according to the given parameters.
1624 * @return 0 in case of success and negative value otherwise.
1626 int (*send_cmd)(struct bnx2x_softc *sc,
1627 struct ecore_func_state_params *params);
1630 * Checks that the requested state transition is legal.
1632 int (*check_transition)(struct bnx2x_softc *sc,
1633 struct ecore_func_sp_obj *o,
1634 struct ecore_func_state_params *params);
1637 * Completes the pending command.
1639 int (*complete_cmd)(struct bnx2x_softc *sc,
1640 struct ecore_func_sp_obj *o,
1641 enum ecore_func_cmd cmd);
1643 int (*wait_comp)(struct bnx2x_softc *sc, struct ecore_func_sp_obj *o,
1644 enum ecore_func_cmd cmd);
1647 /********************** Interfaces ********************************************/
1648 /* Queueable objects set */
1649 union ecore_qable_obj {
1650 struct ecore_vlan_mac_obj vlan_mac;
1652 /************** Function state update *********/
1653 void ecore_init_func_obj(struct bnx2x_softc *sc,
1654 struct ecore_func_sp_obj *obj,
1655 void *rdata, ecore_dma_addr_t rdata_mapping,
1656 void *afex_rdata, ecore_dma_addr_t afex_rdata_mapping,
1657 struct ecore_func_sp_drv_ops *drv_iface);
1659 int ecore_func_state_change(struct bnx2x_softc *sc,
1660 struct ecore_func_state_params *params);
1662 enum ecore_func_state ecore_func_get_state(struct bnx2x_softc *sc,
1663 struct ecore_func_sp_obj *o);
1664 /******************* Queue State **************/
1665 void ecore_init_queue_obj(struct bnx2x_softc *sc,
1666 struct ecore_queue_sp_obj *obj, uint8_t cl_id, uint32_t *cids,
1667 uint8_t cid_cnt, uint8_t func_id, void *rdata,
1668 ecore_dma_addr_t rdata_mapping, unsigned long type);
1670 int ecore_queue_state_change(struct bnx2x_softc *sc,
1671 struct ecore_queue_state_params *params);
1673 /********************* VLAN-MAC ****************/
1674 void ecore_init_mac_obj(struct bnx2x_softc *sc,
1675 struct ecore_vlan_mac_obj *mac_obj,
1676 uint8_t cl_id, uint32_t cid, uint8_t func_id, void *rdata,
1677 ecore_dma_addr_t rdata_mapping, int state,
1678 unsigned long *pstate, ecore_obj_type type,
1679 struct ecore_credit_pool_obj *macs_pool);
1681 void ecore_vlan_mac_h_read_unlock(struct bnx2x_softc *sc,
1682 struct ecore_vlan_mac_obj *o);
1683 int ecore_vlan_mac_h_write_lock(struct bnx2x_softc *sc,
1684 struct ecore_vlan_mac_obj *o);
1685 void ecore_vlan_mac_h_write_unlock(struct bnx2x_softc *sc,
1686 struct ecore_vlan_mac_obj *o);
1687 int ecore_config_vlan_mac(struct bnx2x_softc *sc,
1688 struct ecore_vlan_mac_ramrod_params *p);
1690 int ecore_vlan_mac_move(struct bnx2x_softc *sc,
1691 struct ecore_vlan_mac_ramrod_params *p,
1692 struct ecore_vlan_mac_obj *dest_o);
1694 /********************* RX MODE ****************/
1696 void ecore_init_rx_mode_obj(struct bnx2x_softc *sc,
1697 struct ecore_rx_mode_obj *o);
1700 * ecore_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
1702 * @p: Command parameters
1704 * Return: 0 - if operation was successful and there is no pending completions,
1705 * positive number - if there are pending completions,
1706 * negative - if there were errors
1708 int ecore_config_rx_mode(struct bnx2x_softc *sc,
1709 struct ecore_rx_mode_ramrod_params *p);
1711 /****************** MULTICASTS ****************/
1713 void ecore_init_mcast_obj(struct bnx2x_softc *sc,
1714 struct ecore_mcast_obj *mcast_obj,
1715 uint8_t mcast_cl_id, uint32_t mcast_cid, uint8_t func_id,
1716 uint8_t engine_id, void *rdata, ecore_dma_addr_t rdata_mapping,
1717 int state, unsigned long *pstate,
1718 ecore_obj_type type);
1721 * ecore_config_mcast - Configure multicast MACs list.
1723 * @cmd: command to execute: BNX2X_MCAST_CMD_X
1725 * May configure a new list
1726 * provided in p->mcast_list (ECORE_MCAST_CMD_ADD), clean up
1727 * (ECORE_MCAST_CMD_DEL) or restore (ECORE_MCAST_CMD_RESTORE) a current
1728 * configuration, continue to execute the pending commands
1729 * (ECORE_MCAST_CMD_CONT).
1731 * If previous command is still pending or if number of MACs to
1732 * configure is more that maximum number of MACs in one command,
1733 * the current command will be enqueued to the tail of the
1734 * pending commands list.
1736 * Return: 0 is operation was successful and there are no pending completions,
1737 * negative if there were errors, positive if there are pending
1740 int ecore_config_mcast(struct bnx2x_softc *sc,
1741 struct ecore_mcast_ramrod_params *p,
1742 enum ecore_mcast_cmd cmd);
1744 /****************** CREDIT POOL ****************/
1745 void ecore_init_mac_credit_pool(struct bnx2x_softc *sc,
1746 struct ecore_credit_pool_obj *p, uint8_t func_id,
1748 void ecore_init_vlan_credit_pool(struct bnx2x_softc *sc,
1749 struct ecore_credit_pool_obj *p, uint8_t func_id,
1752 /****************** RSS CONFIGURATION ****************/
1753 void ecore_init_rss_config_obj(struct ecore_rss_config_obj *rss_obj,
1754 uint8_t cl_id, uint32_t cid, uint8_t func_id, uint8_t engine_id,
1755 void *rdata, ecore_dma_addr_t rdata_mapping,
1756 int state, unsigned long *pstate,
1757 ecore_obj_type type);
1760 * ecore_config_rss - Updates RSS configuration according to provided parameters
1762 * Return: 0 in case of success
1764 int ecore_config_rss(struct bnx2x_softc *sc,
1765 struct ecore_config_rss_params *p);
1768 #endif /* ECORE_SP_H */