1 /* bnx2x_sp.h: Broadcom Everest network driver.
3 * Copyright 2011 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 */
38 * Don't add a new command and continue execution of posponed
39 * commands. If not set a new command will be added to the
40 * pending commands list.
51 /* Filtering states */
53 BNX2X_FILTER_MAC_PENDING
,
54 BNX2X_FILTER_VLAN_PENDING
,
55 BNX2X_FILTER_VLAN_MAC_PENDING
,
56 BNX2X_FILTER_RX_MODE_PENDING
,
57 BNX2X_FILTER_RX_MODE_SCHED
,
58 BNX2X_FILTER_ISCSI_ETH_START_SCHED
,
59 BNX2X_FILTER_ISCSI_ETH_STOP_SCHED
,
60 BNX2X_FILTER_FCOE_ETH_START_SCHED
,
61 BNX2X_FILTER_FCOE_ETH_STOP_SCHED
,
62 BNX2X_FILTER_MCAST_PENDING
,
63 BNX2X_FILTER_MCAST_SCHED
,
64 BNX2X_FILTER_RSS_CONF_PENDING
,
67 struct bnx2x_raw_obj
{
74 /* Ramrod data buffer params */
76 dma_addr_t rdata_mapping
;
78 /* Ramrod state params */
79 int state
; /* "ramrod is pending" state bit */
80 unsigned long *pstate
; /* pointer to state buffer */
82 bnx2x_obj_type obj_type
;
84 int (*wait_comp
)(struct bnx2x
*bp
,
85 struct bnx2x_raw_obj
*o
);
87 bool (*check_pending
)(struct bnx2x_raw_obj
*o
);
88 void (*clear_pending
)(struct bnx2x_raw_obj
*o
);
89 void (*set_pending
)(struct bnx2x_raw_obj
*o
);
92 /************************* VLAN-MAC commands related parameters ***************/
93 struct bnx2x_mac_ramrod_data
{
97 struct bnx2x_vlan_ramrod_data
{
101 struct bnx2x_vlan_mac_ramrod_data
{
106 union bnx2x_classification_ramrod_data
{
107 struct bnx2x_mac_ramrod_data mac
;
108 struct bnx2x_vlan_ramrod_data vlan
;
109 struct bnx2x_vlan_mac_ramrod_data vlan_mac
;
112 /* VLAN_MAC commands */
113 enum bnx2x_vlan_mac_cmd
{
119 struct bnx2x_vlan_mac_data
{
120 /* Requested command: BNX2X_VLAN_MAC_XX */
121 enum bnx2x_vlan_mac_cmd cmd
;
123 * used to contain the data related vlan_mac_flags bits from
126 unsigned long vlan_mac_flags
;
128 /* Needed for MOVE command */
129 struct bnx2x_vlan_mac_obj
*target_obj
;
131 union bnx2x_classification_ramrod_data u
;
134 /*************************** Exe Queue obj ************************************/
135 union bnx2x_exe_queue_cmd_data
{
136 struct bnx2x_vlan_mac_data vlan_mac
;
143 struct bnx2x_exeq_elem
{
144 struct list_head link
;
146 /* Length of this element in the exe_chunk. */
149 union bnx2x_exe_queue_cmd_data cmd_data
;
152 union bnx2x_qable_obj
;
154 union bnx2x_exeq_comp_elem
{
155 union event_ring_elem
*elem
;
158 struct bnx2x_exe_queue_obj
;
160 typedef int (*exe_q_validate
)(struct bnx2x
*bp
,
161 union bnx2x_qable_obj
*o
,
162 struct bnx2x_exeq_elem
*elem
);
165 * @return positive is entry was optimized, 0 - if not, negative
166 * in case of an error.
168 typedef int (*exe_q_optimize
)(struct bnx2x
*bp
,
169 union bnx2x_qable_obj
*o
,
170 struct bnx2x_exeq_elem
*elem
);
171 typedef int (*exe_q_execute
)(struct bnx2x
*bp
,
172 union bnx2x_qable_obj
*o
,
173 struct list_head
*exe_chunk
,
174 unsigned long *ramrod_flags
);
175 typedef struct bnx2x_exeq_elem
*
176 (*exe_q_get
)(struct bnx2x_exe_queue_obj
*o
,
177 struct bnx2x_exeq_elem
*elem
);
179 struct bnx2x_exe_queue_obj
{
181 * Commands pending for an execution.
183 struct list_head exe_queue
;
186 * Commands pending for an completion.
188 struct list_head pending_comp
;
192 /* Maximum length of commands' list for one execution */
195 union bnx2x_qable_obj
*owner
;
197 /****** Virtual functions ******/
199 * Called before commands execution for commands that are really
200 * going to be executed (after 'optimize').
202 * Must run under exe_queue->lock
204 exe_q_validate validate
;
208 * This will try to cancel the current pending commands list
209 * considering the new command.
211 * Must run under exe_queue->lock
213 exe_q_optimize optimize
;
216 * Run the next commands chunk (owner specific).
218 exe_q_execute execute
;
221 * Return the exe_queue element containing the specific command
222 * if any. Otherwise return NULL.
226 /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
228 * Element in the VLAN_MAC registry list having all currenty configured
231 struct bnx2x_vlan_mac_registry_elem
{
232 struct list_head link
;
235 * Used to store the cam offset used for the mac/vlan/vlan-mac.
236 * Relevant for 57710 and 57711 only. VLANs and MACs share the
237 * same CAM for these chips.
241 /* Needed for DEL and RESTORE flows */
242 unsigned long vlan_mac_flags
;
244 union bnx2x_classification_ramrod_data u
;
247 /* Bits representing VLAN_MAC commands specific flags */
253 BNX2X_DONT_CONSUME_CAM_CREDIT
,
254 BNX2X_DONT_CONSUME_CAM_CREDIT_DEST
,
257 struct bnx2x_vlan_mac_ramrod_params
{
258 /* Object to run the command from */
259 struct bnx2x_vlan_mac_obj
*vlan_mac_obj
;
261 /* General command flags: COMP_WAIT, etc. */
262 unsigned long ramrod_flags
;
264 /* Command specific configuration request */
265 struct bnx2x_vlan_mac_data user_req
;
268 struct bnx2x_vlan_mac_obj
{
269 struct bnx2x_raw_obj raw
;
271 /* Bookkeeping list: will prevent the addition of already existing
274 struct list_head head
;
276 /* TODO: Add it's initialization in the init functions */
277 struct bnx2x_exe_queue_obj exe_queue
;
279 /* MACs credit pool */
280 struct bnx2x_credit_pool_obj
*macs_pool
;
282 /* VLANs credit pool */
283 struct bnx2x_credit_pool_obj
*vlans_pool
;
285 /* RAMROD command to be used */
289 * Checks if ADD-ramrod with the given params may be performed.
291 * @return zero if the element may be added
294 int (*check_add
)(struct bnx2x_vlan_mac_obj
*o
,
295 union bnx2x_classification_ramrod_data
*data
);
298 * Checks if DEL-ramrod with the given params may be performed.
300 * @return true if the element may be deleted
302 struct bnx2x_vlan_mac_registry_elem
*
303 (*check_del
)(struct bnx2x_vlan_mac_obj
*o
,
304 union bnx2x_classification_ramrod_data
*data
);
307 * Checks if DEL-ramrod with the given params may be performed.
309 * @return true if the element may be deleted
311 bool (*check_move
)(struct bnx2x_vlan_mac_obj
*src_o
,
312 struct bnx2x_vlan_mac_obj
*dst_o
,
313 union bnx2x_classification_ramrod_data
*data
);
316 * Update the relevant credit object(s) (consume/return
319 bool (*get_credit
)(struct bnx2x_vlan_mac_obj
*o
);
320 bool (*put_credit
)(struct bnx2x_vlan_mac_obj
*o
);
321 bool (*get_cam_offset
)(struct bnx2x_vlan_mac_obj
*o
, int *offset
);
322 bool (*put_cam_offset
)(struct bnx2x_vlan_mac_obj
*o
, int offset
);
325 * Configures one rule in the ramrod data buffer.
327 void (*set_one_rule
)(struct bnx2x
*bp
,
328 struct bnx2x_vlan_mac_obj
*o
,
329 struct bnx2x_exeq_elem
*elem
, int rule_idx
,
333 * Delete all configured elements having the given
334 * vlan_mac_flags specification. Assumes no pending for
335 * execution commands. Will schedule all all currently
336 * configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
337 * specification for deletion and will use the given
338 * ramrod_flags for the last DEL operation.
342 * @param ramrod_flags RAMROD_XX flags
344 * @return 0 if the last operation has completed successfully
345 * and there are no more elements left, positive value
346 * if there are pending for completion commands,
347 * negative value in case of failure.
349 int (*delete_all
)(struct bnx2x
*bp
,
350 struct bnx2x_vlan_mac_obj
*o
,
351 unsigned long *vlan_mac_flags
,
352 unsigned long *ramrod_flags
);
355 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
356 * configured elements list.
359 * @param p Command parameters (RAMROD_COMP_WAIT bit in
360 * ramrod_flags is only taken into an account)
361 * @param ppos a pointer to the cooky that should be given back in the
362 * next call to make function handle the next element. If
363 * *ppos is set to NULL it will restart the iterator.
364 * If returned *ppos == NULL this means that the last
365 * element has been handled.
369 int (*restore
)(struct bnx2x
*bp
,
370 struct bnx2x_vlan_mac_ramrod_params
*p
,
371 struct bnx2x_vlan_mac_registry_elem
**ppos
);
374 * Should be called on a completion arival.
378 * @param cqe Completion element we are handling
379 * @param ramrod_flags if RAMROD_CONT is set the next bulk of
380 * pending commands will be executed.
381 * RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
382 * may also be set if needed.
384 * @return 0 if there are neither pending nor waiting for
385 * completion commands. Positive value if there are
386 * pending for execution or for completion commands.
387 * Negative value in case of an error (including an
390 int (*complete
)(struct bnx2x
*bp
, struct bnx2x_vlan_mac_obj
*o
,
391 union event_ring_elem
*cqe
,
392 unsigned long *ramrod_flags
);
395 * Wait for completion of all commands. Don't schedule new ones,
396 * just wait. It assumes that the completion code will schedule
399 int (*wait
)(struct bnx2x
*bp
, struct bnx2x_vlan_mac_obj
*o
);
402 /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
404 /* RX_MODE ramrod spesial flags: set in rx_mode_flags field in
405 * a bnx2x_rx_mode_ramrod_params.
408 BNX2X_RX_MODE_FCOE_ETH
,
409 BNX2X_RX_MODE_ISCSI_ETH
,
413 BNX2X_ACCEPT_UNICAST
,
414 BNX2X_ACCEPT_MULTICAST
,
415 BNX2X_ACCEPT_ALL_UNICAST
,
416 BNX2X_ACCEPT_ALL_MULTICAST
,
417 BNX2X_ACCEPT_BROADCAST
,
418 BNX2X_ACCEPT_UNMATCHED
,
419 BNX2X_ACCEPT_ANY_VLAN
422 struct bnx2x_rx_mode_ramrod_params
{
423 struct bnx2x_rx_mode_obj
*rx_mode_obj
;
424 unsigned long *pstate
;
429 unsigned long ramrod_flags
;
430 unsigned long rx_mode_flags
;
433 * rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
434 * a tstorm_eth_mac_filter_config (e1x).
437 dma_addr_t rdata_mapping
;
439 /* Rx mode settings */
440 unsigned long rx_accept_flags
;
442 /* internal switching settings */
443 unsigned long tx_accept_flags
;
446 struct bnx2x_rx_mode_obj
{
447 int (*config_rx_mode
)(struct bnx2x
*bp
,
448 struct bnx2x_rx_mode_ramrod_params
*p
);
450 int (*wait_comp
)(struct bnx2x
*bp
,
451 struct bnx2x_rx_mode_ramrod_params
*p
);
454 /********************** Set multicast group ***********************************/
456 struct bnx2x_mcast_list_elem
{
457 struct list_head link
;
461 union bnx2x_mcast_config_data
{
463 u8 bin
; /* used in a RESTORE flow */
466 struct bnx2x_mcast_ramrod_params
{
467 struct bnx2x_mcast_obj
*mcast_obj
;
469 /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
470 unsigned long ramrod_flags
;
472 struct list_head mcast_list
; /* list of struct bnx2x_mcast_list_elem */
474 * - rename it to macs_num.
475 * - Add a new command type for handling pending commands
476 * (remove "zero semantics").
478 * Length of mcast_list. If zero and ADD_CONT command - post
486 BNX2X_MCAST_CMD_CONT
,
488 BNX2X_MCAST_CMD_RESTORE
,
491 struct bnx2x_mcast_obj
{
492 struct bnx2x_raw_obj raw
;
496 #define BNX2X_MCAST_BINS_NUM 256
497 #define BNX2X_MCAST_VEC_SZ (BNX2X_MCAST_BINS_NUM / 64)
498 u64 vec
[BNX2X_MCAST_VEC_SZ
];
500 /** Number of BINs to clear. Should be updated
501 * immediately when a command arrives in order to
502 * properly create DEL commands.
508 struct list_head macs
;
513 /* Pending commands */
514 struct list_head pending_cmds_head
;
516 /* A state that is set in raw.pstate, when there are pending commands */
519 /* Maximal number of mcast MACs configured in one command */
522 /* Total number of currently pending MACs to configure: both
523 * in the pending commands list and in the current command.
525 int total_pending_num
;
530 * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above)
532 int (*config_mcast
)(struct bnx2x
*bp
,
533 struct bnx2x_mcast_ramrod_params
*p
, int cmd
);
536 * Fills the ramrod data during the RESTORE flow.
540 * @param start_idx Registry index to start from
541 * @param rdata_idx Index in the ramrod data to start from
543 * @return -1 if we handled the whole registry or index of the last
544 * handled registry element.
546 int (*hdl_restore
)(struct bnx2x
*bp
, struct bnx2x_mcast_obj
*o
,
547 int start_bin
, int *rdata_idx
);
549 int (*enqueue_cmd
)(struct bnx2x
*bp
, struct bnx2x_mcast_obj
*o
,
550 struct bnx2x_mcast_ramrod_params
*p
, int cmd
);
552 void (*set_one_rule
)(struct bnx2x
*bp
,
553 struct bnx2x_mcast_obj
*o
, int idx
,
554 union bnx2x_mcast_config_data
*cfg_data
, int cmd
);
556 /** Checks if there are more mcast MACs to be set or a previous
557 * command is still pending.
559 bool (*check_pending
)(struct bnx2x_mcast_obj
*o
);
562 * Set/Clear/Check SCHEDULED state of the object
564 void (*set_sched
)(struct bnx2x_mcast_obj
*o
);
565 void (*clear_sched
)(struct bnx2x_mcast_obj
*o
);
566 bool (*check_sched
)(struct bnx2x_mcast_obj
*o
);
568 /* Wait until all pending commands complete */
569 int (*wait_comp
)(struct bnx2x
*bp
, struct bnx2x_mcast_obj
*o
);
572 * Handle the internal object counters needed for proper
573 * commands handling. Checks that the provided parameters are
576 int (*validate
)(struct bnx2x
*bp
,
577 struct bnx2x_mcast_ramrod_params
*p
, int cmd
);
580 * Restore the values of internal counters in case of a failure.
582 void (*revert
)(struct bnx2x
*bp
,
583 struct bnx2x_mcast_ramrod_params
*p
,
586 int (*get_registry_size
)(struct bnx2x_mcast_obj
*o
);
587 void (*set_registry_size
)(struct bnx2x_mcast_obj
*o
, int n
);
590 /*************************** Credit handling **********************************/
591 struct bnx2x_credit_pool_obj
{
593 /* Current amount of credit in the pool */
596 /* Maximum allowed credit. put() will check against it. */
600 * Allocate a pool table statically.
602 * Currently the mamimum allowed size is MAX_MAC_CREDIT_E2(272)
604 * The set bit in the table will mean that the entry is available.
606 #define BNX2X_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64)
607 u64 pool_mirror
[BNX2X_POOL_VEC_SIZE
];
609 /* Base pool offset (initialized differently */
610 int base_pool_offset
;
613 * Get the next free pool entry.
615 * @return true if there was a free entry in the pool
617 bool (*get_entry
)(struct bnx2x_credit_pool_obj
*o
, int *entry
);
620 * Return the entry back to the pool.
622 * @return true if entry is legal and has been successfully
623 * returned to the pool.
625 bool (*put_entry
)(struct bnx2x_credit_pool_obj
*o
, int entry
);
628 * Get the requested amount of credit from the pool.
630 * @param cnt Amount of requested credit
631 * @return true if the operation is successful
633 bool (*get
)(struct bnx2x_credit_pool_obj
*o
, int cnt
);
636 * Returns the credit to the pool.
638 * @param cnt Amount of credit to return
639 * @return true if the operation is successful
641 bool (*put
)(struct bnx2x_credit_pool_obj
*o
, int cnt
);
644 * Reads the current amount of credit.
646 int (*check
)(struct bnx2x_credit_pool_obj
*o
);
649 /*************************** RSS configuration ********************************/
651 /* RSS_MODE bits are mutually exclusive */
652 BNX2X_RSS_MODE_DISABLED
,
653 BNX2X_RSS_MODE_REGULAR
,
654 BNX2X_RSS_MODE_VLAN_PRI
,
655 BNX2X_RSS_MODE_E1HOV_PRI
,
656 BNX2X_RSS_MODE_IP_DSCP
,
658 BNX2X_RSS_SET_SRCH
, /* Setup searcher, E1x specific flag */
666 struct bnx2x_config_rss_params
{
667 struct bnx2x_rss_config_obj
*rss_obj
;
669 /* may have RAMROD_COMP_WAIT set only */
670 unsigned long ramrod_flags
;
672 /* BNX2X_RSS_X bits */
673 unsigned long rss_flags
;
675 /* Number hash bits to take into an account */
678 /* Indirection table */
679 u8 ind_table
[T_ETH_INDIRECTION_TABLE_SIZE
];
681 /* RSS hash values */
684 /* valid only iff BNX2X_RSS_UPDATE_TOE is set */
688 struct bnx2x_rss_config_obj
{
689 struct bnx2x_raw_obj raw
;
691 /* RSS engine to use */
694 /* Last configured indirection table */
695 u8 ind_table
[T_ETH_INDIRECTION_TABLE_SIZE
];
697 int (*config_rss
)(struct bnx2x
*bp
,
698 struct bnx2x_config_rss_params
*p
);
701 /*********************** Queue state update ***********************************/
703 /* UPDATE command options */
705 BNX2X_Q_UPDATE_IN_VLAN_REM
,
706 BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG
,
707 BNX2X_Q_UPDATE_OUT_VLAN_REM
,
708 BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG
,
709 BNX2X_Q_UPDATE_ANTI_SPOOF
,
710 BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG
,
711 BNX2X_Q_UPDATE_ACTIVATE
,
712 BNX2X_Q_UPDATE_ACTIVATE_CHNG
,
713 BNX2X_Q_UPDATE_DEF_VLAN_EN
,
714 BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG
,
715 BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG
,
716 BNX2X_Q_UPDATE_SILENT_VLAN_REM
719 /* Allowed Queue states */
722 BNX2X_Q_STATE_INITIALIZED
,
723 BNX2X_Q_STATE_ACTIVE
,
724 BNX2X_Q_STATE_MULTI_COS
,
725 BNX2X_Q_STATE_MCOS_TERMINATED
,
726 BNX2X_Q_STATE_INACTIVE
,
727 BNX2X_Q_STATE_STOPPED
,
728 BNX2X_Q_STATE_TERMINATED
,
733 /* Allowed commands */
734 enum bnx2x_queue_cmd
{
737 BNX2X_Q_CMD_SETUP_TX_ONLY
,
738 BNX2X_Q_CMD_DEACTIVATE
,
739 BNX2X_Q_CMD_ACTIVATE
,
741 BNX2X_Q_CMD_UPDATE_TPA
,
744 BNX2X_Q_CMD_TERMINATE
,
749 /* queue SETUP + INIT flags */
752 BNX2X_Q_FLG_TPA_IPV6
,
754 BNX2X_Q_FLG_ZERO_STATS
,
763 BNX2X_Q_FLG_LEADING_RSS
,
765 BNX2X_Q_FLG_DEF_VLAN
,
766 BNX2X_Q_FLG_TX_SWITCH
,
768 BNX2X_Q_FLG_ANTI_SPOOF
,
769 BNX2X_Q_FLG_SILENT_VLAN_REM
772 /* Queue type options: queue type may be a compination of below. */
774 /** TODO: Consider moving both these flags into the init()
781 #define BNX2X_PRIMARY_CID_INDEX 0
782 #define BNX2X_MULTI_TX_COS_E1X 1
783 #define BNX2X_MULTI_TX_COS_E2_E3A0 2
784 #define BNX2X_MULTI_TX_COS_E3B0 3
785 #define BNX2X_MULTI_TX_COS BNX2X_MULTI_TX_COS_E3B0
788 struct bnx2x_queue_init_params
{
803 /* CID context in the host memory */
804 struct eth_context
*cxts
[BNX2X_MULTI_TX_COS
];
806 /* maximum number of cos supported by hardware */
810 struct bnx2x_queue_terminate_params
{
811 /* index within the tx_only cids of this queue object */
815 struct bnx2x_queue_cfc_del_params
{
816 /* index within the tx_only cids of this queue object */
820 struct bnx2x_queue_update_params
{
821 unsigned long update_flags
; /* BNX2X_Q_UPDATE_XX bits */
823 u16 silent_removal_value
;
824 u16 silent_removal_mask
;
825 /* index within the tx_only cids of this queue object */
829 struct rxq_pause_params
{
834 u16 sge_th_lo
; /* valid iff BNX2X_Q_FLG_TPA */
835 u16 sge_th_hi
; /* valid iff BNX2X_Q_FLG_TPA */
840 struct bnx2x_general_setup_params
{
841 /* valid iff BNX2X_Q_FLG_STATS */
849 struct bnx2x_rxq_setup_params
{
854 dma_addr_t rcq_np_map
;
861 /* valid iff BNX2X_Q_FLG_TPA */
872 /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
873 u16 silent_removal_value
;
874 u16 silent_removal_mask
;
877 struct bnx2x_txq_setup_params
{
883 u8 cos
; /* valid iff BNX2X_Q_FLG_COS */
885 /* equals to the leading rss client id, used for TX classification*/
886 u8 tss_leading_cl_id
;
888 /* valid iff BNX2X_Q_FLG_DEF_VLAN */
892 struct bnx2x_queue_setup_params
{
893 struct bnx2x_general_setup_params gen_params
;
894 struct bnx2x_txq_setup_params txq_params
;
895 struct bnx2x_rxq_setup_params rxq_params
;
896 struct rxq_pause_params pause_params
;
900 struct bnx2x_queue_setup_tx_only_params
{
901 struct bnx2x_general_setup_params gen_params
;
902 struct bnx2x_txq_setup_params txq_params
;
904 /* index within the tx_only cids of this queue object */
908 struct bnx2x_queue_state_params
{
909 struct bnx2x_queue_sp_obj
*q_obj
;
911 /* Current command */
912 enum bnx2x_queue_cmd cmd
;
914 /* may have RAMROD_COMP_WAIT set only */
915 unsigned long ramrod_flags
;
917 /* Params according to the current command */
919 struct bnx2x_queue_update_params update
;
920 struct bnx2x_queue_setup_params setup
;
921 struct bnx2x_queue_init_params init
;
922 struct bnx2x_queue_setup_tx_only_params tx_only
;
923 struct bnx2x_queue_terminate_params terminate
;
924 struct bnx2x_queue_cfc_del_params cfc_del
;
928 struct bnx2x_queue_sp_obj
{
929 u32 cids
[BNX2X_MULTI_TX_COS
];
934 * number of traffic classes supported by queue.
935 * The primary connection of the queue suppotrs the first traffic
936 * class. Any further traffic class is suppoted by a tx-only
939 * Therefore max_cos is also a number of valid entries in the cids
943 u8 num_tx_only
, next_tx_only
;
945 enum bnx2x_q_state state
, next_state
;
947 /* bits from enum bnx2x_q_type */
950 /* BNX2X_Q_CMD_XX bits. This object implements "one
951 * pending" paradigm but for debug and tracing purposes it's
952 * more convinient to have different bits for different
955 unsigned long pending
;
957 /* Buffer to use as a ramrod data and its mapping */
959 dma_addr_t rdata_mapping
;
962 * Performs one state change according to the given parameters.
964 * @return 0 in case of success and negative value otherwise.
966 int (*send_cmd
)(struct bnx2x
*bp
,
967 struct bnx2x_queue_state_params
*params
);
970 * Sets the pending bit according to the requested transition.
972 int (*set_pending
)(struct bnx2x_queue_sp_obj
*o
,
973 struct bnx2x_queue_state_params
*params
);
976 * Checks that the requested state transition is legal.
978 int (*check_transition
)(struct bnx2x
*bp
,
979 struct bnx2x_queue_sp_obj
*o
,
980 struct bnx2x_queue_state_params
*params
);
983 * Completes the pending command.
985 int (*complete_cmd
)(struct bnx2x
*bp
,
986 struct bnx2x_queue_sp_obj
*o
,
987 enum bnx2x_queue_cmd
);
989 int (*wait_comp
)(struct bnx2x
*bp
,
990 struct bnx2x_queue_sp_obj
*o
,
991 enum bnx2x_queue_cmd cmd
);
994 /********************** Function state update *********************************/
995 /* Allowed Function states */
996 enum bnx2x_func_state
{
998 BNX2X_F_STATE_INITIALIZED
,
999 BNX2X_F_STATE_STARTED
,
1000 BNX2X_F_STATE_TX_STOPPED
,
1004 /* Allowed Function commands */
1005 enum bnx2x_func_cmd
{
1006 BNX2X_F_CMD_HW_INIT
,
1009 BNX2X_F_CMD_HW_RESET
,
1010 BNX2X_F_CMD_TX_STOP
,
1011 BNX2X_F_CMD_TX_START
,
1015 struct bnx2x_func_hw_init_params
{
1016 /* A load phase returned by MCP.
1019 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1020 * FW_MSG_CODE_DRV_LOAD_COMMON
1021 * FW_MSG_CODE_DRV_LOAD_PORT
1022 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1027 struct bnx2x_func_hw_reset_params
{
1028 /* A load phase returned by MCP.
1031 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1032 * FW_MSG_CODE_DRV_LOAD_COMMON
1033 * FW_MSG_CODE_DRV_LOAD_PORT
1034 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1039 struct bnx2x_func_start_params
{
1040 /* Multi Function mode:
1042 * - Switch Dependent
1043 * - Switch Independent
1047 /* Switch Dependent mode outer VLAN tag */
1050 /* Function cos mode */
1051 u8 network_cos_mode
;
1054 struct bnx2x_func_tx_start_params
{
1055 struct priority_cos traffic_type_to_priority_cos
[MAX_TRAFFIC_TYPES
];
1058 u8 dont_add_pri_0_en
;
1061 struct bnx2x_func_state_params
{
1062 struct bnx2x_func_sp_obj
*f_obj
;
1064 /* Current command */
1065 enum bnx2x_func_cmd cmd
;
1067 /* may have RAMROD_COMP_WAIT set only */
1068 unsigned long ramrod_flags
;
1070 /* Params according to the current command */
1072 struct bnx2x_func_hw_init_params hw_init
;
1073 struct bnx2x_func_hw_reset_params hw_reset
;
1074 struct bnx2x_func_start_params start
;
1075 struct bnx2x_func_tx_start_params tx_start
;
1079 struct bnx2x_func_sp_drv_ops
{
1080 /* Init tool + runtime initialization:
1082 * - Common (per Path)
1086 int (*init_hw_cmn_chip
)(struct bnx2x
*bp
);
1087 int (*init_hw_cmn
)(struct bnx2x
*bp
);
1088 int (*init_hw_port
)(struct bnx2x
*bp
);
1089 int (*init_hw_func
)(struct bnx2x
*bp
);
1091 /* Reset Function HW: Common, Port, Function phases. */
1092 void (*reset_hw_cmn
)(struct bnx2x
*bp
);
1093 void (*reset_hw_port
)(struct bnx2x
*bp
);
1094 void (*reset_hw_func
)(struct bnx2x
*bp
);
1096 /* Init/Free GUNZIP resources */
1097 int (*gunzip_init
)(struct bnx2x
*bp
);
1098 void (*gunzip_end
)(struct bnx2x
*bp
);
1100 /* Prepare/Release FW resources */
1101 int (*init_fw
)(struct bnx2x
*bp
);
1102 void (*release_fw
)(struct bnx2x
*bp
);
1105 struct bnx2x_func_sp_obj
{
1106 enum bnx2x_func_state state
, next_state
;
1108 /* BNX2X_FUNC_CMD_XX bits. This object implements "one
1109 * pending" paradigm but for debug and tracing purposes it's
1110 * more convinient to have different bits for different
1113 unsigned long pending
;
1115 /* Buffer to use as a ramrod data and its mapping */
1117 dma_addr_t rdata_mapping
;
1119 /* this mutex validates that when pending flag is taken, the next
1120 * ramrod to be sent will be the one set the pending bit
1122 struct mutex one_pending_mutex
;
1124 /* Driver interface */
1125 struct bnx2x_func_sp_drv_ops
*drv
;
1128 * Performs one state change according to the given parameters.
1130 * @return 0 in case of success and negative value otherwise.
1132 int (*send_cmd
)(struct bnx2x
*bp
,
1133 struct bnx2x_func_state_params
*params
);
1136 * Checks that the requested state transition is legal.
1138 int (*check_transition
)(struct bnx2x
*bp
,
1139 struct bnx2x_func_sp_obj
*o
,
1140 struct bnx2x_func_state_params
*params
);
1143 * Completes the pending command.
1145 int (*complete_cmd
)(struct bnx2x
*bp
,
1146 struct bnx2x_func_sp_obj
*o
,
1147 enum bnx2x_func_cmd cmd
);
1149 int (*wait_comp
)(struct bnx2x
*bp
, struct bnx2x_func_sp_obj
*o
,
1150 enum bnx2x_func_cmd cmd
);
1153 /********************** Interfaces ********************************************/
1154 /* Queueable objects set */
1155 union bnx2x_qable_obj
{
1156 struct bnx2x_vlan_mac_obj vlan_mac
;
1158 /************** Function state update *********/
1159 void bnx2x_init_func_obj(struct bnx2x
*bp
,
1160 struct bnx2x_func_sp_obj
*obj
,
1161 void *rdata
, dma_addr_t rdata_mapping
,
1162 struct bnx2x_func_sp_drv_ops
*drv_iface
);
1164 int bnx2x_func_state_change(struct bnx2x
*bp
,
1165 struct bnx2x_func_state_params
*params
);
1167 enum bnx2x_func_state
bnx2x_func_get_state(struct bnx2x
*bp
,
1168 struct bnx2x_func_sp_obj
*o
);
1169 /******************* Queue State **************/
1170 void bnx2x_init_queue_obj(struct bnx2x
*bp
,
1171 struct bnx2x_queue_sp_obj
*obj
, u8 cl_id
, u32
*cids
,
1172 u8 cid_cnt
, u8 func_id
, void *rdata
,
1173 dma_addr_t rdata_mapping
, unsigned long type
);
1175 int bnx2x_queue_state_change(struct bnx2x
*bp
,
1176 struct bnx2x_queue_state_params
*params
);
1178 /********************* VLAN-MAC ****************/
1179 void bnx2x_init_mac_obj(struct bnx2x
*bp
,
1180 struct bnx2x_vlan_mac_obj
*mac_obj
,
1181 u8 cl_id
, u32 cid
, u8 func_id
, void *rdata
,
1182 dma_addr_t rdata_mapping
, int state
,
1183 unsigned long *pstate
, bnx2x_obj_type type
,
1184 struct bnx2x_credit_pool_obj
*macs_pool
);
1186 void bnx2x_init_vlan_obj(struct bnx2x
*bp
,
1187 struct bnx2x_vlan_mac_obj
*vlan_obj
,
1188 u8 cl_id
, u32 cid
, u8 func_id
, void *rdata
,
1189 dma_addr_t rdata_mapping
, int state
,
1190 unsigned long *pstate
, bnx2x_obj_type type
,
1191 struct bnx2x_credit_pool_obj
*vlans_pool
);
1193 void bnx2x_init_vlan_mac_obj(struct bnx2x
*bp
,
1194 struct bnx2x_vlan_mac_obj
*vlan_mac_obj
,
1195 u8 cl_id
, u32 cid
, u8 func_id
, void *rdata
,
1196 dma_addr_t rdata_mapping
, int state
,
1197 unsigned long *pstate
, bnx2x_obj_type type
,
1198 struct bnx2x_credit_pool_obj
*macs_pool
,
1199 struct bnx2x_credit_pool_obj
*vlans_pool
);
1201 int bnx2x_config_vlan_mac(struct bnx2x
*bp
,
1202 struct bnx2x_vlan_mac_ramrod_params
*p
);
1204 int bnx2x_vlan_mac_move(struct bnx2x
*bp
,
1205 struct bnx2x_vlan_mac_ramrod_params
*p
,
1206 struct bnx2x_vlan_mac_obj
*dest_o
);
1208 /********************* RX MODE ****************/
1210 void bnx2x_init_rx_mode_obj(struct bnx2x
*bp
,
1211 struct bnx2x_rx_mode_obj
*o
);
1214 * Send and RX_MODE ramrod according to the provided parameters.
1217 * @param p Command parameters
1219 * @return 0 - if operation was successfull and there is no pending completions,
1220 * positive number - if there are pending completions,
1221 * negative - if there were errors
1223 int bnx2x_config_rx_mode(struct bnx2x
*bp
,
1224 struct bnx2x_rx_mode_ramrod_params
*p
);
1226 /****************** MULTICASTS ****************/
1228 void bnx2x_init_mcast_obj(struct bnx2x
*bp
,
1229 struct bnx2x_mcast_obj
*mcast_obj
,
1230 u8 mcast_cl_id
, u32 mcast_cid
, u8 func_id
,
1231 u8 engine_id
, void *rdata
, dma_addr_t rdata_mapping
,
1232 int state
, unsigned long *pstate
,
1233 bnx2x_obj_type type
);
1236 * Configure multicast MACs list. May configure a new list
1237 * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up
1238 * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current
1239 * configuration, continue to execute the pending commands
1240 * (BNX2X_MCAST_CMD_CONT).
1242 * If previous command is still pending or if number of MACs to
1243 * configure is more that maximum number of MACs in one command,
1244 * the current command will be enqueued to the tail of the
1245 * pending commands list.
1249 * @param command to execute: BNX2X_MCAST_CMD_X
1251 * @return 0 is operation was sucessfull and there are no pending completions,
1252 * negative if there were errors, positive if there are pending
1255 int bnx2x_config_mcast(struct bnx2x
*bp
,
1256 struct bnx2x_mcast_ramrod_params
*p
, int cmd
);
1258 /****************** CREDIT POOL ****************/
1259 void bnx2x_init_mac_credit_pool(struct bnx2x
*bp
,
1260 struct bnx2x_credit_pool_obj
*p
, u8 func_id
,
1262 void bnx2x_init_vlan_credit_pool(struct bnx2x
*bp
,
1263 struct bnx2x_credit_pool_obj
*p
, u8 func_id
,
1267 /****************** RSS CONFIGURATION ****************/
1268 void bnx2x_init_rss_config_obj(struct bnx2x
*bp
,
1269 struct bnx2x_rss_config_obj
*rss_obj
,
1270 u8 cl_id
, u32 cid
, u8 func_id
, u8 engine_id
,
1271 void *rdata
, dma_addr_t rdata_mapping
,
1272 int state
, unsigned long *pstate
,
1273 bnx2x_obj_type type
);
1276 * Updates RSS configuration according to provided parameters.
1281 * @return 0 in case of success
1283 int bnx2x_config_rss(struct bnx2x
*bp
,
1284 struct bnx2x_config_rss_params
*p
);
1287 * Return the current ind_table configuration.
1290 * @param ind_table buffer to fill with the current indirection
1291 * table content. Should be at least
1292 * T_ETH_INDIRECTION_TABLE_SIZE bytes long.
1294 void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj
*rss_obj
,
1297 #endif /* BNX2X_SP_VERBS */