1 /* bnx2x_sp.h: Broadcom Everest network driver.
3 * Copyright (c) 2011-2013 Broadcom Corporation
5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you
7 * under the terms of the GNU General Public License version 2, available
8 * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
10 * Notwithstanding the above, under no circumstances may you combine this
11 * software in any way with any other Broadcom software provided under a
12 * license other than the GPL, without Broadcom's express prior written
15 * Maintained by: Eilon Greenstein <eilong@broadcom.com>
16 * Written by: Vladislav Zolotarov
19 #ifndef BNX2X_SP_VERBS
20 #define BNX2X_SP_VERBS
25 /* Bits representing general command's configuration */
29 /* Wait until all pending commands complete */
31 /* Don't send a ramrod, only update a registry */
33 /* Configure HW according to the current object state */
35 /* Execute the next command now */
37 /* Don't add a new command and continue execution of postponed
38 * commands. If not set a new command will be added to the
39 * pending commands list.
42 /* If there is another pending ramrod, wait until it finishes and
43 * re-try to submit this one. This flag can be set only in sleepable
44 * context, and should not be set from the context that completes the
45 * ramrods as deadlock will occur.
56 /* Public slow path states */
58 BNX2X_FILTER_MAC_PENDING,
59 BNX2X_FILTER_VLAN_PENDING,
60 BNX2X_FILTER_VLAN_MAC_PENDING,
61 BNX2X_FILTER_RX_MODE_PENDING,
62 BNX2X_FILTER_RX_MODE_SCHED,
63 BNX2X_FILTER_ISCSI_ETH_START_SCHED,
64 BNX2X_FILTER_ISCSI_ETH_STOP_SCHED,
65 BNX2X_FILTER_FCOE_ETH_START_SCHED,
66 BNX2X_FILTER_FCOE_ETH_STOP_SCHED,
67 BNX2X_FILTER_MCAST_PENDING,
68 BNX2X_FILTER_MCAST_SCHED,
69 BNX2X_FILTER_RSS_CONF_PENDING,
70 BNX2X_AFEX_FCOE_Q_UPDATE_PENDING,
71 BNX2X_AFEX_PENDING_VIFSET_MCP_ACK
74 struct bnx2x_raw_obj {
81 /* Ramrod data buffer params */
83 dma_addr_t rdata_mapping;
85 /* Ramrod state params */
86 int state; /* "ramrod is pending" state bit */
87 unsigned long *pstate; /* pointer to state buffer */
89 bnx2x_obj_type obj_type;
91 int (*wait_comp)(struct bnx2x *bp,
92 struct bnx2x_raw_obj *o);
94 bool (*check_pending)(struct bnx2x_raw_obj *o);
95 void (*clear_pending)(struct bnx2x_raw_obj *o);
96 void (*set_pending)(struct bnx2x_raw_obj *o);
99 /************************* VLAN-MAC commands related parameters ***************/
100 struct bnx2x_mac_ramrod_data {
105 struct bnx2x_vlan_ramrod_data {
109 struct bnx2x_vlan_mac_ramrod_data {
115 union bnx2x_classification_ramrod_data {
116 struct bnx2x_mac_ramrod_data mac;
117 struct bnx2x_vlan_ramrod_data vlan;
118 struct bnx2x_vlan_mac_ramrod_data vlan_mac;
121 /* VLAN_MAC commands */
122 enum bnx2x_vlan_mac_cmd {
128 struct bnx2x_vlan_mac_data {
129 /* Requested command: BNX2X_VLAN_MAC_XX */
130 enum bnx2x_vlan_mac_cmd cmd;
131 /* used to contain the data related vlan_mac_flags bits from
134 unsigned long vlan_mac_flags;
136 /* Needed for MOVE command */
137 struct bnx2x_vlan_mac_obj *target_obj;
139 union bnx2x_classification_ramrod_data u;
142 /*************************** Exe Queue obj ************************************/
143 union bnx2x_exe_queue_cmd_data {
144 struct bnx2x_vlan_mac_data vlan_mac;
151 struct bnx2x_exeq_elem {
152 struct list_head link;
154 /* Length of this element in the exe_chunk. */
157 union bnx2x_exe_queue_cmd_data cmd_data;
160 union bnx2x_qable_obj;
162 union bnx2x_exeq_comp_elem {
163 union event_ring_elem *elem;
166 struct bnx2x_exe_queue_obj;
168 typedef int (*exe_q_validate)(struct bnx2x *bp,
169 union bnx2x_qable_obj *o,
170 struct bnx2x_exeq_elem *elem);
172 typedef int (*exe_q_remove)(struct bnx2x *bp,
173 union bnx2x_qable_obj *o,
174 struct bnx2x_exeq_elem *elem);
176 /* Return positive if entry was optimized, 0 - if not, negative
177 * in case of an error.
179 typedef int (*exe_q_optimize)(struct bnx2x *bp,
180 union bnx2x_qable_obj *o,
181 struct bnx2x_exeq_elem *elem);
182 typedef int (*exe_q_execute)(struct bnx2x *bp,
183 union bnx2x_qable_obj *o,
184 struct list_head *exe_chunk,
185 unsigned long *ramrod_flags);
186 typedef struct bnx2x_exeq_elem *
187 (*exe_q_get)(struct bnx2x_exe_queue_obj *o,
188 struct bnx2x_exeq_elem *elem);
190 struct bnx2x_exe_queue_obj {
191 /* Commands pending for an execution. */
192 struct list_head exe_queue;
194 /* Commands pending for an completion. */
195 struct list_head pending_comp;
199 /* Maximum length of commands' list for one execution */
202 union bnx2x_qable_obj *owner;
204 /****** Virtual functions ******/
206 * Called before commands execution for commands that are really
207 * going to be executed (after 'optimize').
209 * Must run under exe_queue->lock
211 exe_q_validate validate;
214 * Called before removing pending commands, cleaning allocated
215 * resources (e.g., credits from validate)
220 * This will try to cancel the current pending commands list
221 * considering the new command.
223 * Returns the number of optimized commands or a negative error code
225 * Must run under exe_queue->lock
227 exe_q_optimize optimize;
230 * Run the next commands chunk (owner specific).
232 exe_q_execute execute;
235 * Return the exe_queue element containing the specific command
236 * if any. Otherwise return NULL.
240 /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
242 * Element in the VLAN_MAC registry list having all currently configured
245 struct bnx2x_vlan_mac_registry_elem {
246 struct list_head link;
248 /* Used to store the cam offset used for the mac/vlan/vlan-mac.
249 * Relevant for 57710 and 57711 only. VLANs and MACs share the
250 * same CAM for these chips.
254 /* Needed for DEL and RESTORE flows */
255 unsigned long vlan_mac_flags;
257 union bnx2x_classification_ramrod_data u;
260 /* Bits representing VLAN_MAC commands specific flags */
266 BNX2X_DONT_CONSUME_CAM_CREDIT,
267 BNX2X_DONT_CONSUME_CAM_CREDIT_DEST,
270 struct bnx2x_vlan_mac_ramrod_params {
271 /* Object to run the command from */
272 struct bnx2x_vlan_mac_obj *vlan_mac_obj;
274 /* General command flags: COMP_WAIT, etc. */
275 unsigned long ramrod_flags;
277 /* Command specific configuration request */
278 struct bnx2x_vlan_mac_data user_req;
281 struct bnx2x_vlan_mac_obj {
282 struct bnx2x_raw_obj raw;
284 /* Bookkeeping list: will prevent the addition of already existing
287 struct list_head head;
289 /* TODO: Add it's initialization in the init functions */
290 struct bnx2x_exe_queue_obj exe_queue;
292 /* MACs credit pool */
293 struct bnx2x_credit_pool_obj *macs_pool;
295 /* VLANs credit pool */
296 struct bnx2x_credit_pool_obj *vlans_pool;
298 /* RAMROD command to be used */
301 /* copy first n elements onto preallocated buffer
303 * @param n number of elements to get
304 * @param buf buffer preallocated by caller into which elements
305 * will be copied. Note elements are 4-byte aligned
306 * so buffer size must be able to accommodate the
309 * @return number of copied bytes
311 int (*get_n_elements)(struct bnx2x *bp,
312 struct bnx2x_vlan_mac_obj *o, int n, u8 *base,
316 * Checks if ADD-ramrod with the given params may be performed.
318 * @return zero if the element may be added
321 int (*check_add)(struct bnx2x *bp,
322 struct bnx2x_vlan_mac_obj *o,
323 union bnx2x_classification_ramrod_data *data);
326 * Checks if DEL-ramrod with the given params may be performed.
328 * @return true if the element may be deleted
330 struct bnx2x_vlan_mac_registry_elem *
331 (*check_del)(struct bnx2x *bp,
332 struct bnx2x_vlan_mac_obj *o,
333 union bnx2x_classification_ramrod_data *data);
336 * Checks if DEL-ramrod with the given params may be performed.
338 * @return true if the element may be deleted
340 bool (*check_move)(struct bnx2x *bp,
341 struct bnx2x_vlan_mac_obj *src_o,
342 struct bnx2x_vlan_mac_obj *dst_o,
343 union bnx2x_classification_ramrod_data *data);
346 * Update the relevant credit object(s) (consume/return
349 bool (*get_credit)(struct bnx2x_vlan_mac_obj *o);
350 bool (*put_credit)(struct bnx2x_vlan_mac_obj *o);
351 bool (*get_cam_offset)(struct bnx2x_vlan_mac_obj *o, int *offset);
352 bool (*put_cam_offset)(struct bnx2x_vlan_mac_obj *o, int offset);
355 * Configures one rule in the ramrod data buffer.
357 void (*set_one_rule)(struct bnx2x *bp,
358 struct bnx2x_vlan_mac_obj *o,
359 struct bnx2x_exeq_elem *elem, int rule_idx,
363 * Delete all configured elements having the given
364 * vlan_mac_flags specification. Assumes no pending for
365 * execution commands. Will schedule all all currently
366 * configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
367 * specification for deletion and will use the given
368 * ramrod_flags for the last DEL operation.
372 * @param ramrod_flags RAMROD_XX flags
374 * @return 0 if the last operation has completed successfully
375 * and there are no more elements left, positive value
376 * if there are pending for completion commands,
377 * negative value in case of failure.
379 int (*delete_all)(struct bnx2x *bp,
380 struct bnx2x_vlan_mac_obj *o,
381 unsigned long *vlan_mac_flags,
382 unsigned long *ramrod_flags);
385 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
386 * configured elements list.
389 * @param p Command parameters (RAMROD_COMP_WAIT bit in
390 * ramrod_flags is only taken into an account)
391 * @param ppos a pointer to the cookie that should be given back in the
392 * next call to make function handle the next element. If
393 * *ppos is set to NULL it will restart the iterator.
394 * If returned *ppos == NULL this means that the last
395 * element has been handled.
399 int (*restore)(struct bnx2x *bp,
400 struct bnx2x_vlan_mac_ramrod_params *p,
401 struct bnx2x_vlan_mac_registry_elem **ppos);
404 * Should be called on a completion arrival.
408 * @param cqe Completion element we are handling
409 * @param ramrod_flags if RAMROD_CONT is set the next bulk of
410 * pending commands will be executed.
411 * RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
412 * may also be set if needed.
414 * @return 0 if there are neither pending nor waiting for
415 * completion commands. Positive value if there are
416 * pending for execution or for completion commands.
417 * Negative value in case of an error (including an
420 int (*complete)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
421 union event_ring_elem *cqe,
422 unsigned long *ramrod_flags);
425 * Wait for completion of all commands. Don't schedule new ones,
426 * just wait. It assumes that the completion code will schedule
429 int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o);
433 BNX2X_LLH_CAM_ISCSI_ETH_LINE = 0,
434 BNX2X_LLH_CAM_ETH_LINE,
435 BNX2X_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2
438 void bnx2x_set_mac_in_nig(struct bnx2x *bp,
439 bool add, unsigned char *dev_addr, int index);
441 /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
443 /* RX_MODE ramrod special flags: set in rx_mode_flags field in
444 * a bnx2x_rx_mode_ramrod_params.
447 BNX2X_RX_MODE_FCOE_ETH,
448 BNX2X_RX_MODE_ISCSI_ETH,
452 BNX2X_ACCEPT_UNICAST,
453 BNX2X_ACCEPT_MULTICAST,
454 BNX2X_ACCEPT_ALL_UNICAST,
455 BNX2X_ACCEPT_ALL_MULTICAST,
456 BNX2X_ACCEPT_BROADCAST,
457 BNX2X_ACCEPT_UNMATCHED,
458 BNX2X_ACCEPT_ANY_VLAN
461 struct bnx2x_rx_mode_ramrod_params {
462 struct bnx2x_rx_mode_obj *rx_mode_obj;
463 unsigned long *pstate;
468 unsigned long ramrod_flags;
469 unsigned long rx_mode_flags;
471 /* rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
472 * a tstorm_eth_mac_filter_config (e1x).
475 dma_addr_t rdata_mapping;
477 /* Rx mode settings */
478 unsigned long rx_accept_flags;
480 /* internal switching settings */
481 unsigned long tx_accept_flags;
484 struct bnx2x_rx_mode_obj {
485 int (*config_rx_mode)(struct bnx2x *bp,
486 struct bnx2x_rx_mode_ramrod_params *p);
488 int (*wait_comp)(struct bnx2x *bp,
489 struct bnx2x_rx_mode_ramrod_params *p);
492 /********************** Set multicast group ***********************************/
494 struct bnx2x_mcast_list_elem {
495 struct list_head link;
499 union bnx2x_mcast_config_data {
501 u8 bin; /* used in a RESTORE flow */
504 struct bnx2x_mcast_ramrod_params {
505 struct bnx2x_mcast_obj *mcast_obj;
507 /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
508 unsigned long ramrod_flags;
510 struct list_head mcast_list; /* list of struct bnx2x_mcast_list_elem */
512 * - rename it to macs_num.
513 * - Add a new command type for handling pending commands
514 * (remove "zero semantics").
516 * Length of mcast_list. If zero and ADD_CONT command - post
522 enum bnx2x_mcast_cmd {
524 BNX2X_MCAST_CMD_CONT,
526 BNX2X_MCAST_CMD_RESTORE,
529 struct bnx2x_mcast_obj {
530 struct bnx2x_raw_obj raw;
534 #define BNX2X_MCAST_BINS_NUM 256
535 #define BNX2X_MCAST_VEC_SZ (BNX2X_MCAST_BINS_NUM / 64)
536 u64 vec[BNX2X_MCAST_VEC_SZ];
538 /** Number of BINs to clear. Should be updated
539 * immediately when a command arrives in order to
540 * properly create DEL commands.
546 struct list_head macs;
551 /* Pending commands */
552 struct list_head pending_cmds_head;
554 /* A state that is set in raw.pstate, when there are pending commands */
557 /* Maximal number of mcast MACs configured in one command */
560 /* Total number of currently pending MACs to configure: both
561 * in the pending commands list and in the current command.
563 int total_pending_num;
568 * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above)
570 int (*config_mcast)(struct bnx2x *bp,
571 struct bnx2x_mcast_ramrod_params *p,
572 enum bnx2x_mcast_cmd cmd);
575 * Fills the ramrod data during the RESTORE flow.
579 * @param start_idx Registry index to start from
580 * @param rdata_idx Index in the ramrod data to start from
582 * @return -1 if we handled the whole registry or index of the last
583 * handled registry element.
585 int (*hdl_restore)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
586 int start_bin, int *rdata_idx);
588 int (*enqueue_cmd)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
589 struct bnx2x_mcast_ramrod_params *p,
590 enum bnx2x_mcast_cmd cmd);
592 void (*set_one_rule)(struct bnx2x *bp,
593 struct bnx2x_mcast_obj *o, int idx,
594 union bnx2x_mcast_config_data *cfg_data,
595 enum bnx2x_mcast_cmd cmd);
597 /** Checks if there are more mcast MACs to be set or a previous
598 * command is still pending.
600 bool (*check_pending)(struct bnx2x_mcast_obj *o);
603 * Set/Clear/Check SCHEDULED state of the object
605 void (*set_sched)(struct bnx2x_mcast_obj *o);
606 void (*clear_sched)(struct bnx2x_mcast_obj *o);
607 bool (*check_sched)(struct bnx2x_mcast_obj *o);
609 /* Wait until all pending commands complete */
610 int (*wait_comp)(struct bnx2x *bp, struct bnx2x_mcast_obj *o);
613 * Handle the internal object counters needed for proper
614 * commands handling. Checks that the provided parameters are
617 int (*validate)(struct bnx2x *bp,
618 struct bnx2x_mcast_ramrod_params *p,
619 enum bnx2x_mcast_cmd cmd);
622 * Restore the values of internal counters in case of a failure.
624 void (*revert)(struct bnx2x *bp,
625 struct bnx2x_mcast_ramrod_params *p,
628 int (*get_registry_size)(struct bnx2x_mcast_obj *o);
629 void (*set_registry_size)(struct bnx2x_mcast_obj *o, int n);
632 /*************************** Credit handling **********************************/
633 struct bnx2x_credit_pool_obj {
635 /* Current amount of credit in the pool */
638 /* Maximum allowed credit. put() will check against it. */
641 /* Allocate a pool table statically.
643 * Currently the maximum allowed size is MAX_MAC_CREDIT_E2(272)
645 * The set bit in the table will mean that the entry is available.
647 #define BNX2X_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64)
648 u64 pool_mirror[BNX2X_POOL_VEC_SIZE];
650 /* Base pool offset (initialized differently */
651 int base_pool_offset;
654 * Get the next free pool entry.
656 * @return true if there was a free entry in the pool
658 bool (*get_entry)(struct bnx2x_credit_pool_obj *o, int *entry);
661 * Return the entry back to the pool.
663 * @return true if entry is legal and has been successfully
664 * returned to the pool.
666 bool (*put_entry)(struct bnx2x_credit_pool_obj *o, int entry);
669 * Get the requested amount of credit from the pool.
671 * @param cnt Amount of requested credit
672 * @return true if the operation is successful
674 bool (*get)(struct bnx2x_credit_pool_obj *o, int cnt);
677 * Returns the credit to the pool.
679 * @param cnt Amount of credit to return
680 * @return true if the operation is successful
682 bool (*put)(struct bnx2x_credit_pool_obj *o, int cnt);
685 * Reads the current amount of credit.
687 int (*check)(struct bnx2x_credit_pool_obj *o);
690 /*************************** RSS configuration ********************************/
692 /* RSS_MODE bits are mutually exclusive */
693 BNX2X_RSS_MODE_DISABLED,
694 BNX2X_RSS_MODE_REGULAR,
696 BNX2X_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */
706 struct bnx2x_config_rss_params {
707 struct bnx2x_rss_config_obj *rss_obj;
709 /* may have RAMROD_COMP_WAIT set only */
710 unsigned long ramrod_flags;
712 /* BNX2X_RSS_X bits */
713 unsigned long rss_flags;
715 /* Number hash bits to take into an account */
718 /* Indirection table */
719 u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
721 /* RSS hash values */
724 /* valid only iff BNX2X_RSS_UPDATE_TOE is set */
728 struct bnx2x_rss_config_obj {
729 struct bnx2x_raw_obj raw;
731 /* RSS engine to use */
734 /* Last configured indirection table */
735 u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
737 /* flags for enabling 4-tupple hash on UDP */
741 int (*config_rss)(struct bnx2x *bp,
742 struct bnx2x_config_rss_params *p);
745 /*********************** Queue state update ***********************************/
747 /* UPDATE command options */
749 BNX2X_Q_UPDATE_IN_VLAN_REM,
750 BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG,
751 BNX2X_Q_UPDATE_OUT_VLAN_REM,
752 BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG,
753 BNX2X_Q_UPDATE_ANTI_SPOOF,
754 BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG,
755 BNX2X_Q_UPDATE_ACTIVATE,
756 BNX2X_Q_UPDATE_ACTIVATE_CHNG,
757 BNX2X_Q_UPDATE_DEF_VLAN_EN,
758 BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG,
759 BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG,
760 BNX2X_Q_UPDATE_SILENT_VLAN_REM
763 /* Allowed Queue states */
766 BNX2X_Q_STATE_INITIALIZED,
767 BNX2X_Q_STATE_ACTIVE,
768 BNX2X_Q_STATE_MULTI_COS,
769 BNX2X_Q_STATE_MCOS_TERMINATED,
770 BNX2X_Q_STATE_INACTIVE,
771 BNX2X_Q_STATE_STOPPED,
772 BNX2X_Q_STATE_TERMINATED,
777 /* Allowed Queue states */
778 enum bnx2x_q_logical_state {
779 BNX2X_Q_LOGICAL_STATE_ACTIVE,
780 BNX2X_Q_LOGICAL_STATE_STOPPED,
783 /* Allowed commands */
784 enum bnx2x_queue_cmd {
787 BNX2X_Q_CMD_SETUP_TX_ONLY,
788 BNX2X_Q_CMD_DEACTIVATE,
789 BNX2X_Q_CMD_ACTIVATE,
791 BNX2X_Q_CMD_UPDATE_TPA,
794 BNX2X_Q_CMD_TERMINATE,
799 /* queue SETUP + INIT flags */
802 BNX2X_Q_FLG_TPA_IPV6,
805 BNX2X_Q_FLG_ZERO_STATS,
814 BNX2X_Q_FLG_LEADING_RSS,
816 BNX2X_Q_FLG_DEF_VLAN,
817 BNX2X_Q_FLG_TX_SWITCH,
819 BNX2X_Q_FLG_ANTI_SPOOF,
820 BNX2X_Q_FLG_SILENT_VLAN_REM,
821 BNX2X_Q_FLG_FORCE_DEFAULT_PRI,
822 BNX2X_Q_FLG_PCSUM_ON_PKT,
823 BNX2X_Q_FLG_TUN_INC_INNER_IP_ID
826 /* Queue type options: queue type may be a combination of below. */
828 /** TODO: Consider moving both these flags into the init()
835 #define BNX2X_PRIMARY_CID_INDEX 0
836 #define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */
837 #define BNX2X_MULTI_TX_COS_E2_E3A0 2
838 #define BNX2X_MULTI_TX_COS_E3B0 3
839 #define BNX2X_MULTI_TX_COS 3 /* Maximum possible */
841 #define MAC_PAD (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)
843 struct bnx2x_queue_init_params {
858 /* CID context in the host memory */
859 struct eth_context *cxts[BNX2X_MULTI_TX_COS];
861 /* maximum number of cos supported by hardware */
865 struct bnx2x_queue_terminate_params {
866 /* index within the tx_only cids of this queue object */
870 struct bnx2x_queue_cfc_del_params {
871 /* index within the tx_only cids of this queue object */
875 struct bnx2x_queue_update_params {
876 unsigned long update_flags; /* BNX2X_Q_UPDATE_XX bits */
878 u16 silent_removal_value;
879 u16 silent_removal_mask;
880 /* index within the tx_only cids of this queue object */
884 struct rxq_pause_params {
889 u16 sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */
890 u16 sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */
895 struct bnx2x_general_setup_params {
896 /* valid iff BNX2X_Q_FLG_STATS */
904 struct bnx2x_rxq_setup_params {
909 dma_addr_t rcq_np_map;
916 /* valid iff BNX2X_Q_FLG_TPA */
923 /* valid iff BNX2X_Q_FLG_MCAST */
930 /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
931 u16 silent_removal_value;
932 u16 silent_removal_mask;
935 struct bnx2x_txq_setup_params {
941 u8 cos; /* valid iff BNX2X_Q_FLG_COS */
943 /* equals to the leading rss client id, used for TX classification*/
944 u8 tss_leading_cl_id;
946 /* valid iff BNX2X_Q_FLG_DEF_VLAN */
950 struct bnx2x_queue_setup_params {
951 struct bnx2x_general_setup_params gen_params;
952 struct bnx2x_txq_setup_params txq_params;
953 struct bnx2x_rxq_setup_params rxq_params;
954 struct rxq_pause_params pause_params;
958 struct bnx2x_queue_setup_tx_only_params {
959 struct bnx2x_general_setup_params gen_params;
960 struct bnx2x_txq_setup_params txq_params;
962 /* index within the tx_only cids of this queue object */
966 struct bnx2x_queue_state_params {
967 struct bnx2x_queue_sp_obj *q_obj;
969 /* Current command */
970 enum bnx2x_queue_cmd cmd;
972 /* may have RAMROD_COMP_WAIT set only */
973 unsigned long ramrod_flags;
975 /* Params according to the current command */
977 struct bnx2x_queue_update_params update;
978 struct bnx2x_queue_setup_params setup;
979 struct bnx2x_queue_init_params init;
980 struct bnx2x_queue_setup_tx_only_params tx_only;
981 struct bnx2x_queue_terminate_params terminate;
982 struct bnx2x_queue_cfc_del_params cfc_del;
986 struct bnx2x_viflist_params {
991 struct bnx2x_queue_sp_obj {
992 u32 cids[BNX2X_MULTI_TX_COS];
996 /* number of traffic classes supported by queue.
997 * The primary connection of the queue supports the first traffic
998 * class. Any further traffic class is supported by a tx-only
1001 * Therefore max_cos is also a number of valid entries in the cids
1005 u8 num_tx_only, next_tx_only;
1007 enum bnx2x_q_state state, next_state;
1009 /* bits from enum bnx2x_q_type */
1012 /* BNX2X_Q_CMD_XX bits. This object implements "one
1013 * pending" paradigm but for debug and tracing purposes it's
1014 * more convenient to have different bits for different
1017 unsigned long pending;
1019 /* Buffer to use as a ramrod data and its mapping */
1021 dma_addr_t rdata_mapping;
1024 * Performs one state change according to the given parameters.
1026 * @return 0 in case of success and negative value otherwise.
1028 int (*send_cmd)(struct bnx2x *bp,
1029 struct bnx2x_queue_state_params *params);
1032 * Sets the pending bit according to the requested transition.
1034 int (*set_pending)(struct bnx2x_queue_sp_obj *o,
1035 struct bnx2x_queue_state_params *params);
1038 * Checks that the requested state transition is legal.
1040 int (*check_transition)(struct bnx2x *bp,
1041 struct bnx2x_queue_sp_obj *o,
1042 struct bnx2x_queue_state_params *params);
1045 * Completes the pending command.
1047 int (*complete_cmd)(struct bnx2x *bp,
1048 struct bnx2x_queue_sp_obj *o,
1049 enum bnx2x_queue_cmd);
1051 int (*wait_comp)(struct bnx2x *bp,
1052 struct bnx2x_queue_sp_obj *o,
1053 enum bnx2x_queue_cmd cmd);
1056 /********************** Function state update *********************************/
1057 /* Allowed Function states */
1058 enum bnx2x_func_state {
1059 BNX2X_F_STATE_RESET,
1060 BNX2X_F_STATE_INITIALIZED,
1061 BNX2X_F_STATE_STARTED,
1062 BNX2X_F_STATE_TX_STOPPED,
1066 /* Allowed Function commands */
1067 enum bnx2x_func_cmd {
1068 BNX2X_F_CMD_HW_INIT,
1071 BNX2X_F_CMD_HW_RESET,
1072 BNX2X_F_CMD_AFEX_UPDATE,
1073 BNX2X_F_CMD_AFEX_VIFLISTS,
1074 BNX2X_F_CMD_TX_STOP,
1075 BNX2X_F_CMD_TX_START,
1076 BNX2X_F_CMD_SWITCH_UPDATE,
1080 struct bnx2x_func_hw_init_params {
1081 /* A load phase returned by MCP.
1084 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1085 * FW_MSG_CODE_DRV_LOAD_COMMON
1086 * FW_MSG_CODE_DRV_LOAD_PORT
1087 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1092 struct bnx2x_func_hw_reset_params {
1093 /* A load phase returned by MCP.
1096 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1097 * FW_MSG_CODE_DRV_LOAD_COMMON
1098 * FW_MSG_CODE_DRV_LOAD_PORT
1099 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1104 struct bnx2x_func_start_params {
1105 /* Multi Function mode:
1107 * - Switch Dependent
1108 * - Switch Independent
1112 /* Switch Dependent mode outer VLAN tag */
1115 /* Function cos mode */
1116 u8 network_cos_mode;
1118 /* NVGRE classification enablement */
1121 /* NO_GRE_TUNNEL/NVGRE_TUNNEL/L2GRE_TUNNEL/IPGRE_TUNNEL */
1124 /* GRE_OUTER_HEADERS_RSS/GRE_INNER_HEADERS_RSS/NVGRE_KEY_ENTROPY_RSS */
1128 struct bnx2x_func_switch_update_params {
1132 struct bnx2x_func_afex_update_params {
1134 u16 afex_default_vlan;
1135 u8 allowed_priorities;
1138 struct bnx2x_func_afex_viflists_params {
1141 u8 afex_vif_list_command;
1144 struct bnx2x_func_tx_start_params {
1145 struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES];
1148 u8 dont_add_pri_0_en;
1151 struct bnx2x_func_state_params {
1152 struct bnx2x_func_sp_obj *f_obj;
1154 /* Current command */
1155 enum bnx2x_func_cmd cmd;
1157 /* may have RAMROD_COMP_WAIT set only */
1158 unsigned long ramrod_flags;
1160 /* Params according to the current command */
1162 struct bnx2x_func_hw_init_params hw_init;
1163 struct bnx2x_func_hw_reset_params hw_reset;
1164 struct bnx2x_func_start_params start;
1165 struct bnx2x_func_switch_update_params switch_update;
1166 struct bnx2x_func_afex_update_params afex_update;
1167 struct bnx2x_func_afex_viflists_params afex_viflists;
1168 struct bnx2x_func_tx_start_params tx_start;
1172 struct bnx2x_func_sp_drv_ops {
1173 /* Init tool + runtime initialization:
1175 * - Common (per Path)
1179 int (*init_hw_cmn_chip)(struct bnx2x *bp);
1180 int (*init_hw_cmn)(struct bnx2x *bp);
1181 int (*init_hw_port)(struct bnx2x *bp);
1182 int (*init_hw_func)(struct bnx2x *bp);
1184 /* Reset Function HW: Common, Port, Function phases. */
1185 void (*reset_hw_cmn)(struct bnx2x *bp);
1186 void (*reset_hw_port)(struct bnx2x *bp);
1187 void (*reset_hw_func)(struct bnx2x *bp);
1189 /* Init/Free GUNZIP resources */
1190 int (*gunzip_init)(struct bnx2x *bp);
1191 void (*gunzip_end)(struct bnx2x *bp);
1193 /* Prepare/Release FW resources */
1194 int (*init_fw)(struct bnx2x *bp);
1195 void (*release_fw)(struct bnx2x *bp);
1198 struct bnx2x_func_sp_obj {
1199 enum bnx2x_func_state state, next_state;
1201 /* BNX2X_FUNC_CMD_XX bits. This object implements "one
1202 * pending" paradigm but for debug and tracing purposes it's
1203 * more convenient to have different bits for different
1206 unsigned long pending;
1208 /* Buffer to use as a ramrod data and its mapping */
1210 dma_addr_t rdata_mapping;
1212 /* Buffer to use as a afex ramrod data and its mapping.
1213 * This can't be same rdata as above because afex ramrod requests
1214 * can arrive to the object in parallel to other ramrod requests.
1217 dma_addr_t afex_rdata_mapping;
1219 /* this mutex validates that when pending flag is taken, the next
1220 * ramrod to be sent will be the one set the pending bit
1222 struct mutex one_pending_mutex;
1224 /* Driver interface */
1225 struct bnx2x_func_sp_drv_ops *drv;
1228 * Performs one state change according to the given parameters.
1230 * @return 0 in case of success and negative value otherwise.
1232 int (*send_cmd)(struct bnx2x *bp,
1233 struct bnx2x_func_state_params *params);
1236 * Checks that the requested state transition is legal.
1238 int (*check_transition)(struct bnx2x *bp,
1239 struct bnx2x_func_sp_obj *o,
1240 struct bnx2x_func_state_params *params);
1243 * Completes the pending command.
1245 int (*complete_cmd)(struct bnx2x *bp,
1246 struct bnx2x_func_sp_obj *o,
1247 enum bnx2x_func_cmd cmd);
1249 int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o,
1250 enum bnx2x_func_cmd cmd);
1253 /********************** Interfaces ********************************************/
1254 /* Queueable objects set */
1255 union bnx2x_qable_obj {
1256 struct bnx2x_vlan_mac_obj vlan_mac;
1258 /************** Function state update *********/
1259 void bnx2x_init_func_obj(struct bnx2x *bp,
1260 struct bnx2x_func_sp_obj *obj,
1261 void *rdata, dma_addr_t rdata_mapping,
1262 void *afex_rdata, dma_addr_t afex_rdata_mapping,
1263 struct bnx2x_func_sp_drv_ops *drv_iface);
1265 int bnx2x_func_state_change(struct bnx2x *bp,
1266 struct bnx2x_func_state_params *params);
1268 enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp,
1269 struct bnx2x_func_sp_obj *o);
1270 /******************* Queue State **************/
1271 void bnx2x_init_queue_obj(struct bnx2x *bp,
1272 struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids,
1273 u8 cid_cnt, u8 func_id, void *rdata,
1274 dma_addr_t rdata_mapping, unsigned long type);
1276 int bnx2x_queue_state_change(struct bnx2x *bp,
1277 struct bnx2x_queue_state_params *params);
1279 int bnx2x_get_q_logical_state(struct bnx2x *bp,
1280 struct bnx2x_queue_sp_obj *obj);
1282 /********************* VLAN-MAC ****************/
1283 void bnx2x_init_mac_obj(struct bnx2x *bp,
1284 struct bnx2x_vlan_mac_obj *mac_obj,
1285 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1286 dma_addr_t rdata_mapping, int state,
1287 unsigned long *pstate, bnx2x_obj_type type,
1288 struct bnx2x_credit_pool_obj *macs_pool);
1290 void bnx2x_init_vlan_obj(struct bnx2x *bp,
1291 struct bnx2x_vlan_mac_obj *vlan_obj,
1292 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1293 dma_addr_t rdata_mapping, int state,
1294 unsigned long *pstate, bnx2x_obj_type type,
1295 struct bnx2x_credit_pool_obj *vlans_pool);
1297 void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
1298 struct bnx2x_vlan_mac_obj *vlan_mac_obj,
1299 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1300 dma_addr_t rdata_mapping, int state,
1301 unsigned long *pstate, bnx2x_obj_type type,
1302 struct bnx2x_credit_pool_obj *macs_pool,
1303 struct bnx2x_credit_pool_obj *vlans_pool);
1305 int bnx2x_config_vlan_mac(struct bnx2x *bp,
1306 struct bnx2x_vlan_mac_ramrod_params *p);
1308 int bnx2x_vlan_mac_move(struct bnx2x *bp,
1309 struct bnx2x_vlan_mac_ramrod_params *p,
1310 struct bnx2x_vlan_mac_obj *dest_o);
1312 /********************* RX MODE ****************/
1314 void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
1315 struct bnx2x_rx_mode_obj *o);
1318 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
1320 * @p: Command parameters
1322 * Return: 0 - if operation was successful and there is no pending completions,
1323 * positive number - if there are pending completions,
1324 * negative - if there were errors
1326 int bnx2x_config_rx_mode(struct bnx2x *bp,
1327 struct bnx2x_rx_mode_ramrod_params *p);
1329 /****************** MULTICASTS ****************/
1331 void bnx2x_init_mcast_obj(struct bnx2x *bp,
1332 struct bnx2x_mcast_obj *mcast_obj,
1333 u8 mcast_cl_id, u32 mcast_cid, u8 func_id,
1334 u8 engine_id, void *rdata, dma_addr_t rdata_mapping,
1335 int state, unsigned long *pstate,
1336 bnx2x_obj_type type);
1339 * bnx2x_config_mcast - Configure multicast MACs list.
1341 * @cmd: command to execute: BNX2X_MCAST_CMD_X
1343 * May configure a new list
1344 * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up
1345 * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current
1346 * configuration, continue to execute the pending commands
1347 * (BNX2X_MCAST_CMD_CONT).
1349 * If previous command is still pending or if number of MACs to
1350 * configure is more that maximum number of MACs in one command,
1351 * the current command will be enqueued to the tail of the
1352 * pending commands list.
1354 * Return: 0 is operation was successful and there are no pending completions,
1355 * negative if there were errors, positive if there are pending
1358 int bnx2x_config_mcast(struct bnx2x *bp,
1359 struct bnx2x_mcast_ramrod_params *p,
1360 enum bnx2x_mcast_cmd cmd);
1362 /****************** CREDIT POOL ****************/
1363 void bnx2x_init_mac_credit_pool(struct bnx2x *bp,
1364 struct bnx2x_credit_pool_obj *p, u8 func_id,
1366 void bnx2x_init_vlan_credit_pool(struct bnx2x *bp,
1367 struct bnx2x_credit_pool_obj *p, u8 func_id,
1370 /****************** RSS CONFIGURATION ****************/
1371 void bnx2x_init_rss_config_obj(struct bnx2x *bp,
1372 struct bnx2x_rss_config_obj *rss_obj,
1373 u8 cl_id, u32 cid, u8 func_id, u8 engine_id,
1374 void *rdata, dma_addr_t rdata_mapping,
1375 int state, unsigned long *pstate,
1376 bnx2x_obj_type type);
1379 * bnx2x_config_rss - Updates RSS configuration according to provided parameters
1381 * Return: 0 in case of success
1383 int bnx2x_config_rss(struct bnx2x *bp,
1384 struct bnx2x_config_rss_params *p);
1387 * bnx2x_get_rss_ind_table - Return the current ind_table configuration.
1389 * @ind_table: buffer to fill with the current indirection
1390 * table content. Should be at least
1391 * T_ETH_INDIRECTION_TABLE_SIZE bytes long.
1393 void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj,
1396 #endif /* BNX2X_SP_VERBS */