1 /* bnx2x_sp.h: Qlogic Everest network driver.
3 * Copyright 2011-2013 Broadcom Corporation
4 * Copyright (c) 2014 QLogic Corporation
7 * Unless you and Qlogic execute a separate written software license
8 * agreement governing use of this software, this software is licensed to you
9 * under the terms of the GNU General Public License version 2, available
10 * at http://www.gnu.org/licenses/gpl-2.0.html (the "GPL").
12 * Notwithstanding the above, under no circumstances may you combine this
13 * software in any way with any other Qlogic software provided under a
14 * license other than the GPL, without Qlogic's express prior written
17 * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
18 * Written by: Vladislav Zolotarov
21 #ifndef BNX2X_SP_VERBS
22 #define BNX2X_SP_VERBS
27 /* Bits representing general command's configuration */
31 /* Wait until all pending commands complete */
33 /* Don't send a ramrod, only update a registry */
35 /* Configure HW according to the current object state */
37 /* Execute the next command now */
39 /* Don't add a new command and continue execution of postponed
40 * commands. If not set a new command will be added to the
41 * pending commands list.
44 /* If there is another pending ramrod, wait until it finishes and
45 * re-try to submit this one. This flag can be set only in sleepable
46 * context, and should not be set from the context that completes the
47 * ramrods as deadlock will occur.
58 /* Public slow path states */
60 BNX2X_FILTER_MAC_PENDING
,
61 BNX2X_FILTER_VLAN_PENDING
,
62 BNX2X_FILTER_VLAN_MAC_PENDING
,
63 BNX2X_FILTER_RX_MODE_PENDING
,
64 BNX2X_FILTER_RX_MODE_SCHED
,
65 BNX2X_FILTER_ISCSI_ETH_START_SCHED
,
66 BNX2X_FILTER_ISCSI_ETH_STOP_SCHED
,
67 BNX2X_FILTER_FCOE_ETH_START_SCHED
,
68 BNX2X_FILTER_FCOE_ETH_STOP_SCHED
,
69 BNX2X_FILTER_MCAST_PENDING
,
70 BNX2X_FILTER_MCAST_SCHED
,
71 BNX2X_FILTER_RSS_CONF_PENDING
,
72 BNX2X_AFEX_FCOE_Q_UPDATE_PENDING
,
73 BNX2X_AFEX_PENDING_VIFSET_MCP_ACK
76 struct bnx2x_raw_obj
{
83 /* Ramrod data buffer params */
85 dma_addr_t rdata_mapping
;
87 /* Ramrod state params */
88 int state
; /* "ramrod is pending" state bit */
89 unsigned long *pstate
; /* pointer to state buffer */
91 bnx2x_obj_type obj_type
;
93 int (*wait_comp
)(struct bnx2x
*bp
,
94 struct bnx2x_raw_obj
*o
);
96 bool (*check_pending
)(struct bnx2x_raw_obj
*o
);
97 void (*clear_pending
)(struct bnx2x_raw_obj
*o
);
98 void (*set_pending
)(struct bnx2x_raw_obj
*o
);
101 /************************* VLAN-MAC commands related parameters ***************/
102 struct bnx2x_mac_ramrod_data
{
107 struct bnx2x_vlan_ramrod_data
{
111 struct bnx2x_vlan_mac_ramrod_data
{
117 union bnx2x_classification_ramrod_data
{
118 struct bnx2x_mac_ramrod_data mac
;
119 struct bnx2x_vlan_ramrod_data vlan
;
120 struct bnx2x_vlan_mac_ramrod_data vlan_mac
;
123 /* VLAN_MAC commands */
124 enum bnx2x_vlan_mac_cmd
{
130 struct bnx2x_vlan_mac_data
{
131 /* Requested command: BNX2X_VLAN_MAC_XX */
132 enum bnx2x_vlan_mac_cmd cmd
;
133 /* used to contain the data related vlan_mac_flags bits from
136 unsigned long vlan_mac_flags
;
138 /* Needed for MOVE command */
139 struct bnx2x_vlan_mac_obj
*target_obj
;
141 union bnx2x_classification_ramrod_data u
;
144 /*************************** Exe Queue obj ************************************/
145 union bnx2x_exe_queue_cmd_data
{
146 struct bnx2x_vlan_mac_data vlan_mac
;
153 struct bnx2x_exeq_elem
{
154 struct list_head link
;
156 /* Length of this element in the exe_chunk. */
159 union bnx2x_exe_queue_cmd_data cmd_data
;
162 union bnx2x_qable_obj
;
164 union bnx2x_exeq_comp_elem
{
165 union event_ring_elem
*elem
;
168 struct bnx2x_exe_queue_obj
;
170 typedef int (*exe_q_validate
)(struct bnx2x
*bp
,
171 union bnx2x_qable_obj
*o
,
172 struct bnx2x_exeq_elem
*elem
);
174 typedef int (*exe_q_remove
)(struct bnx2x
*bp
,
175 union bnx2x_qable_obj
*o
,
176 struct bnx2x_exeq_elem
*elem
);
178 /* Return positive if entry was optimized, 0 - if not, negative
179 * in case of an error.
181 typedef int (*exe_q_optimize
)(struct bnx2x
*bp
,
182 union bnx2x_qable_obj
*o
,
183 struct bnx2x_exeq_elem
*elem
);
184 typedef int (*exe_q_execute
)(struct bnx2x
*bp
,
185 union bnx2x_qable_obj
*o
,
186 struct list_head
*exe_chunk
,
187 unsigned long *ramrod_flags
);
188 typedef struct bnx2x_exeq_elem
*
189 (*exe_q_get
)(struct bnx2x_exe_queue_obj
*o
,
190 struct bnx2x_exeq_elem
*elem
);
192 struct bnx2x_exe_queue_obj
{
193 /* Commands pending for an execution. */
194 struct list_head exe_queue
;
196 /* Commands pending for an completion. */
197 struct list_head pending_comp
;
201 /* Maximum length of commands' list for one execution */
204 union bnx2x_qable_obj
*owner
;
206 /****** Virtual functions ******/
208 * Called before commands execution for commands that are really
209 * going to be executed (after 'optimize').
211 * Must run under exe_queue->lock
213 exe_q_validate validate
;
216 * Called before removing pending commands, cleaning allocated
217 * resources (e.g., credits from validate)
222 * This will try to cancel the current pending commands list
223 * considering the new command.
225 * Returns the number of optimized commands or a negative error code
227 * Must run under exe_queue->lock
229 exe_q_optimize optimize
;
232 * Run the next commands chunk (owner specific).
234 exe_q_execute execute
;
237 * Return the exe_queue element containing the specific command
238 * if any. Otherwise return NULL.
242 /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
244 * Element in the VLAN_MAC registry list having all currently configured
247 struct bnx2x_vlan_mac_registry_elem
{
248 struct list_head link
;
250 /* Used to store the cam offset used for the mac/vlan/vlan-mac.
251 * Relevant for 57710 and 57711 only. VLANs and MACs share the
252 * same CAM for these chips.
256 /* Needed for DEL and RESTORE flows */
257 unsigned long vlan_mac_flags
;
259 union bnx2x_classification_ramrod_data u
;
262 /* Bits representing VLAN_MAC commands specific flags */
268 BNX2X_DONT_CONSUME_CAM_CREDIT
,
269 BNX2X_DONT_CONSUME_CAM_CREDIT_DEST
,
271 /* When looking for matching filters, some flags are not interesting */
272 #define BNX2X_VLAN_MAC_CMP_MASK (1 << BNX2X_UC_LIST_MAC | \
273 1 << BNX2X_ETH_MAC | \
274 1 << BNX2X_ISCSI_ETH_MAC | \
275 1 << BNX2X_NETQ_ETH_MAC)
276 #define BNX2X_VLAN_MAC_CMP_FLAGS(flags) \
277 ((flags) & BNX2X_VLAN_MAC_CMP_MASK)
279 struct bnx2x_vlan_mac_ramrod_params
{
280 /* Object to run the command from */
281 struct bnx2x_vlan_mac_obj
*vlan_mac_obj
;
283 /* General command flags: COMP_WAIT, etc. */
284 unsigned long ramrod_flags
;
286 /* Command specific configuration request */
287 struct bnx2x_vlan_mac_data user_req
;
290 struct bnx2x_vlan_mac_obj
{
291 struct bnx2x_raw_obj raw
;
293 /* Bookkeeping list: will prevent the addition of already existing
296 struct list_head head
;
297 /* Implement a simple reader/writer lock on the head list.
298 * all these fields should only be accessed under the exe_queue lock
300 u8 head_reader
; /* Num. of readers accessing head list */
301 bool head_exe_request
; /* Pending execution request. */
302 unsigned long saved_ramrod_flags
; /* Ramrods of pending execution */
304 /* TODO: Add it's initialization in the init functions */
305 struct bnx2x_exe_queue_obj exe_queue
;
307 /* MACs credit pool */
308 struct bnx2x_credit_pool_obj
*macs_pool
;
310 /* VLANs credit pool */
311 struct bnx2x_credit_pool_obj
*vlans_pool
;
313 /* RAMROD command to be used */
316 /* copy first n elements onto preallocated buffer
318 * @param n number of elements to get
319 * @param buf buffer preallocated by caller into which elements
320 * will be copied. Note elements are 4-byte aligned
321 * so buffer size must be able to accommodate the
324 * @return number of copied bytes
326 int (*get_n_elements
)(struct bnx2x
*bp
,
327 struct bnx2x_vlan_mac_obj
*o
, int n
, u8
*base
,
331 * Checks if ADD-ramrod with the given params may be performed.
333 * @return zero if the element may be added
336 int (*check_add
)(struct bnx2x
*bp
,
337 struct bnx2x_vlan_mac_obj
*o
,
338 union bnx2x_classification_ramrod_data
*data
);
341 * Checks if DEL-ramrod with the given params may be performed.
343 * @return true if the element may be deleted
345 struct bnx2x_vlan_mac_registry_elem
*
346 (*check_del
)(struct bnx2x
*bp
,
347 struct bnx2x_vlan_mac_obj
*o
,
348 union bnx2x_classification_ramrod_data
*data
);
351 * Checks if DEL-ramrod with the given params may be performed.
353 * @return true if the element may be deleted
355 bool (*check_move
)(struct bnx2x
*bp
,
356 struct bnx2x_vlan_mac_obj
*src_o
,
357 struct bnx2x_vlan_mac_obj
*dst_o
,
358 union bnx2x_classification_ramrod_data
*data
);
361 * Update the relevant credit object(s) (consume/return
364 bool (*get_credit
)(struct bnx2x_vlan_mac_obj
*o
);
365 bool (*put_credit
)(struct bnx2x_vlan_mac_obj
*o
);
366 bool (*get_cam_offset
)(struct bnx2x_vlan_mac_obj
*o
, int *offset
);
367 bool (*put_cam_offset
)(struct bnx2x_vlan_mac_obj
*o
, int offset
);
370 * Configures one rule in the ramrod data buffer.
372 void (*set_one_rule
)(struct bnx2x
*bp
,
373 struct bnx2x_vlan_mac_obj
*o
,
374 struct bnx2x_exeq_elem
*elem
, int rule_idx
,
378 * Delete all configured elements having the given
379 * vlan_mac_flags specification. Assumes no pending for
380 * execution commands. Will schedule all all currently
381 * configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
382 * specification for deletion and will use the given
383 * ramrod_flags for the last DEL operation.
387 * @param ramrod_flags RAMROD_XX flags
389 * @return 0 if the last operation has completed successfully
390 * and there are no more elements left, positive value
391 * if there are pending for completion commands,
392 * negative value in case of failure.
394 int (*delete_all
)(struct bnx2x
*bp
,
395 struct bnx2x_vlan_mac_obj
*o
,
396 unsigned long *vlan_mac_flags
,
397 unsigned long *ramrod_flags
);
400 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
401 * configured elements list.
404 * @param p Command parameters (RAMROD_COMP_WAIT bit in
405 * ramrod_flags is only taken into an account)
406 * @param ppos a pointer to the cookie that should be given back in the
407 * next call to make function handle the next element. If
408 * *ppos is set to NULL it will restart the iterator.
409 * If returned *ppos == NULL this means that the last
410 * element has been handled.
414 int (*restore
)(struct bnx2x
*bp
,
415 struct bnx2x_vlan_mac_ramrod_params
*p
,
416 struct bnx2x_vlan_mac_registry_elem
**ppos
);
419 * Should be called on a completion arrival.
423 * @param cqe Completion element we are handling
424 * @param ramrod_flags if RAMROD_CONT is set the next bulk of
425 * pending commands will be executed.
426 * RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
427 * may also be set if needed.
429 * @return 0 if there are neither pending nor waiting for
430 * completion commands. Positive value if there are
431 * pending for execution or for completion commands.
432 * Negative value in case of an error (including an
435 int (*complete
)(struct bnx2x
*bp
, struct bnx2x_vlan_mac_obj
*o
,
436 union event_ring_elem
*cqe
,
437 unsigned long *ramrod_flags
);
440 * Wait for completion of all commands. Don't schedule new ones,
441 * just wait. It assumes that the completion code will schedule
444 int (*wait
)(struct bnx2x
*bp
, struct bnx2x_vlan_mac_obj
*o
);
448 BNX2X_LLH_CAM_ISCSI_ETH_LINE
= 0,
449 BNX2X_LLH_CAM_ETH_LINE
,
450 BNX2X_LLH_CAM_MAX_PF_LINE
= NIG_REG_LLH1_FUNC_MEM_SIZE
/ 2
453 /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
455 /* RX_MODE ramrod special flags: set in rx_mode_flags field in
456 * a bnx2x_rx_mode_ramrod_params.
459 BNX2X_RX_MODE_FCOE_ETH
,
460 BNX2X_RX_MODE_ISCSI_ETH
,
464 BNX2X_ACCEPT_UNICAST
,
465 BNX2X_ACCEPT_MULTICAST
,
466 BNX2X_ACCEPT_ALL_UNICAST
,
467 BNX2X_ACCEPT_ALL_MULTICAST
,
468 BNX2X_ACCEPT_BROADCAST
,
469 BNX2X_ACCEPT_UNMATCHED
,
470 BNX2X_ACCEPT_ANY_VLAN
473 struct bnx2x_rx_mode_ramrod_params
{
474 struct bnx2x_rx_mode_obj
*rx_mode_obj
;
475 unsigned long *pstate
;
480 unsigned long ramrod_flags
;
481 unsigned long rx_mode_flags
;
483 /* rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
484 * a tstorm_eth_mac_filter_config (e1x).
487 dma_addr_t rdata_mapping
;
489 /* Rx mode settings */
490 unsigned long rx_accept_flags
;
492 /* internal switching settings */
493 unsigned long tx_accept_flags
;
496 struct bnx2x_rx_mode_obj
{
497 int (*config_rx_mode
)(struct bnx2x
*bp
,
498 struct bnx2x_rx_mode_ramrod_params
*p
);
500 int (*wait_comp
)(struct bnx2x
*bp
,
501 struct bnx2x_rx_mode_ramrod_params
*p
);
504 /********************** Set multicast group ***********************************/
506 struct bnx2x_mcast_list_elem
{
507 struct list_head link
;
511 union bnx2x_mcast_config_data
{
513 u8 bin
; /* used in a RESTORE flow */
516 struct bnx2x_mcast_ramrod_params
{
517 struct bnx2x_mcast_obj
*mcast_obj
;
519 /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
520 unsigned long ramrod_flags
;
522 struct list_head mcast_list
; /* list of struct bnx2x_mcast_list_elem */
524 * - rename it to macs_num.
525 * - Add a new command type for handling pending commands
526 * (remove "zero semantics").
528 * Length of mcast_list. If zero and ADD_CONT command - post
534 enum bnx2x_mcast_cmd
{
536 BNX2X_MCAST_CMD_CONT
,
538 BNX2X_MCAST_CMD_RESTORE
,
540 /* Following this, multicast configuration should equal to approx
541 * the set of MACs provided [i.e., remove all else].
542 * The two sub-commands are used internally to decide whether a given
543 * bin is to be added or removed
546 BNX2X_MCAST_CMD_SET_ADD
,
547 BNX2X_MCAST_CMD_SET_DEL
,
550 struct bnx2x_mcast_obj
{
551 struct bnx2x_raw_obj raw
;
555 #define BNX2X_MCAST_BINS_NUM 256
556 #define BNX2X_MCAST_VEC_SZ (BNX2X_MCAST_BINS_NUM / 64)
557 u64 vec
[BNX2X_MCAST_VEC_SZ
];
559 /** Number of BINs to clear. Should be updated
560 * immediately when a command arrives in order to
561 * properly create DEL commands.
567 struct list_head macs
;
572 /* Pending commands */
573 struct list_head pending_cmds_head
;
575 /* A state that is set in raw.pstate, when there are pending commands */
578 /* Maximal number of mcast MACs configured in one command */
581 /* Total number of currently pending MACs to configure: both
582 * in the pending commands list and in the current command.
584 int total_pending_num
;
589 * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above)
591 int (*config_mcast
)(struct bnx2x
*bp
,
592 struct bnx2x_mcast_ramrod_params
*p
,
593 enum bnx2x_mcast_cmd cmd
);
596 * Fills the ramrod data during the RESTORE flow.
600 * @param start_idx Registry index to start from
601 * @param rdata_idx Index in the ramrod data to start from
603 * @return -1 if we handled the whole registry or index of the last
604 * handled registry element.
606 int (*hdl_restore
)(struct bnx2x
*bp
, struct bnx2x_mcast_obj
*o
,
607 int start_bin
, int *rdata_idx
);
609 int (*enqueue_cmd
)(struct bnx2x
*bp
, struct bnx2x_mcast_obj
*o
,
610 struct bnx2x_mcast_ramrod_params
*p
,
611 enum bnx2x_mcast_cmd cmd
);
613 void (*set_one_rule
)(struct bnx2x
*bp
,
614 struct bnx2x_mcast_obj
*o
, int idx
,
615 union bnx2x_mcast_config_data
*cfg_data
,
616 enum bnx2x_mcast_cmd cmd
);
618 /** Checks if there are more mcast MACs to be set or a previous
619 * command is still pending.
621 bool (*check_pending
)(struct bnx2x_mcast_obj
*o
);
624 * Set/Clear/Check SCHEDULED state of the object
626 void (*set_sched
)(struct bnx2x_mcast_obj
*o
);
627 void (*clear_sched
)(struct bnx2x_mcast_obj
*o
);
628 bool (*check_sched
)(struct bnx2x_mcast_obj
*o
);
630 /* Wait until all pending commands complete */
631 int (*wait_comp
)(struct bnx2x
*bp
, struct bnx2x_mcast_obj
*o
);
634 * Handle the internal object counters needed for proper
635 * commands handling. Checks that the provided parameters are
638 int (*validate
)(struct bnx2x
*bp
,
639 struct bnx2x_mcast_ramrod_params
*p
,
640 enum bnx2x_mcast_cmd cmd
);
643 * Restore the values of internal counters in case of a failure.
645 void (*revert
)(struct bnx2x
*bp
,
646 struct bnx2x_mcast_ramrod_params
*p
,
648 enum bnx2x_mcast_cmd cmd
);
650 int (*get_registry_size
)(struct bnx2x_mcast_obj
*o
);
651 void (*set_registry_size
)(struct bnx2x_mcast_obj
*o
, int n
);
654 /*************************** Credit handling **********************************/
655 struct bnx2x_credit_pool_obj
{
657 /* Current amount of credit in the pool */
660 /* Maximum allowed credit. put() will check against it. */
663 /* Allocate a pool table statically.
665 * Currently the maximum allowed size is MAX_MAC_CREDIT_E2(272)
667 * The set bit in the table will mean that the entry is available.
669 #define BNX2X_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64)
670 u64 pool_mirror
[BNX2X_POOL_VEC_SIZE
];
672 /* Base pool offset (initialized differently */
673 int base_pool_offset
;
676 * Get the next free pool entry.
678 * @return true if there was a free entry in the pool
680 bool (*get_entry
)(struct bnx2x_credit_pool_obj
*o
, int *entry
);
683 * Return the entry back to the pool.
685 * @return true if entry is legal and has been successfully
686 * returned to the pool.
688 bool (*put_entry
)(struct bnx2x_credit_pool_obj
*o
, int entry
);
691 * Get the requested amount of credit from the pool.
693 * @param cnt Amount of requested credit
694 * @return true if the operation is successful
696 bool (*get
)(struct bnx2x_credit_pool_obj
*o
, int cnt
);
699 * Returns the credit to the pool.
701 * @param cnt Amount of credit to return
702 * @return true if the operation is successful
704 bool (*put
)(struct bnx2x_credit_pool_obj
*o
, int cnt
);
707 * Reads the current amount of credit.
709 int (*check
)(struct bnx2x_credit_pool_obj
*o
);
712 /*************************** RSS configuration ********************************/
714 /* RSS_MODE bits are mutually exclusive */
715 BNX2X_RSS_MODE_DISABLED
,
716 BNX2X_RSS_MODE_REGULAR
,
718 BNX2X_RSS_SET_SRCH
, /* Setup searcher, E1x specific flag */
727 BNX2X_RSS_IPV4_VXLAN
,
728 BNX2X_RSS_IPV6_VXLAN
,
729 BNX2X_RSS_TUNN_INNER_HDRS
,
732 struct bnx2x_config_rss_params
{
733 struct bnx2x_rss_config_obj
*rss_obj
;
735 /* may have RAMROD_COMP_WAIT set only */
736 unsigned long ramrod_flags
;
738 /* BNX2X_RSS_X bits */
739 unsigned long rss_flags
;
741 /* Number hash bits to take into an account */
744 /* Indirection table */
745 u8 ind_table
[T_ETH_INDIRECTION_TABLE_SIZE
];
747 /* RSS hash values */
750 /* valid only iff BNX2X_RSS_UPDATE_TOE is set */
754 struct bnx2x_rss_config_obj
{
755 struct bnx2x_raw_obj raw
;
757 /* RSS engine to use */
760 /* Last configured indirection table */
761 u8 ind_table
[T_ETH_INDIRECTION_TABLE_SIZE
];
763 /* flags for enabling 4-tupple hash on UDP */
767 int (*config_rss
)(struct bnx2x
*bp
,
768 struct bnx2x_config_rss_params
*p
);
771 /*********************** Queue state update ***********************************/
773 /* UPDATE command options */
775 BNX2X_Q_UPDATE_IN_VLAN_REM
,
776 BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG
,
777 BNX2X_Q_UPDATE_OUT_VLAN_REM
,
778 BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG
,
779 BNX2X_Q_UPDATE_ANTI_SPOOF
,
780 BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG
,
781 BNX2X_Q_UPDATE_ACTIVATE
,
782 BNX2X_Q_UPDATE_ACTIVATE_CHNG
,
783 BNX2X_Q_UPDATE_DEF_VLAN_EN
,
784 BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG
,
785 BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG
,
786 BNX2X_Q_UPDATE_SILENT_VLAN_REM
,
787 BNX2X_Q_UPDATE_TX_SWITCHING_CHNG
,
788 BNX2X_Q_UPDATE_TX_SWITCHING
,
789 BNX2X_Q_UPDATE_PTP_PKTS_CHNG
,
790 BNX2X_Q_UPDATE_PTP_PKTS
,
793 /* Allowed Queue states */
796 BNX2X_Q_STATE_INITIALIZED
,
797 BNX2X_Q_STATE_ACTIVE
,
798 BNX2X_Q_STATE_MULTI_COS
,
799 BNX2X_Q_STATE_MCOS_TERMINATED
,
800 BNX2X_Q_STATE_INACTIVE
,
801 BNX2X_Q_STATE_STOPPED
,
802 BNX2X_Q_STATE_TERMINATED
,
807 /* Allowed Queue states */
808 enum bnx2x_q_logical_state
{
809 BNX2X_Q_LOGICAL_STATE_ACTIVE
,
810 BNX2X_Q_LOGICAL_STATE_STOPPED
,
813 /* Allowed commands */
814 enum bnx2x_queue_cmd
{
817 BNX2X_Q_CMD_SETUP_TX_ONLY
,
818 BNX2X_Q_CMD_DEACTIVATE
,
819 BNX2X_Q_CMD_ACTIVATE
,
821 BNX2X_Q_CMD_UPDATE_TPA
,
824 BNX2X_Q_CMD_TERMINATE
,
829 /* queue SETUP + INIT flags */
832 BNX2X_Q_FLG_TPA_IPV6
,
835 BNX2X_Q_FLG_ZERO_STATS
,
844 BNX2X_Q_FLG_LEADING_RSS
,
846 BNX2X_Q_FLG_DEF_VLAN
,
847 BNX2X_Q_FLG_TX_SWITCH
,
849 BNX2X_Q_FLG_ANTI_SPOOF
,
850 BNX2X_Q_FLG_SILENT_VLAN_REM
,
851 BNX2X_Q_FLG_FORCE_DEFAULT_PRI
,
852 BNX2X_Q_FLG_REFUSE_OUTBAND_VLAN
,
853 BNX2X_Q_FLG_PCSUM_ON_PKT
,
854 BNX2X_Q_FLG_TUN_INC_INNER_IP_ID
857 /* Queue type options: queue type may be a combination of below. */
859 /** TODO: Consider moving both these flags into the init()
866 #define BNX2X_PRIMARY_CID_INDEX 0
867 #define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */
868 #define BNX2X_MULTI_TX_COS_E2_E3A0 2
869 #define BNX2X_MULTI_TX_COS_E3B0 3
870 #define BNX2X_MULTI_TX_COS 3 /* Maximum possible */
872 #define MAC_PAD (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)
873 /* DMAE channel to be used by FW for timesync workaroun. A driver that sends
874 * timesync-related ramrods must not use this DMAE command ID.
876 #define FW_DMAE_CMD_ID 6
878 struct bnx2x_queue_init_params
{
893 /* CID context in the host memory */
894 struct eth_context
*cxts
[BNX2X_MULTI_TX_COS
];
896 /* maximum number of cos supported by hardware */
900 struct bnx2x_queue_terminate_params
{
901 /* index within the tx_only cids of this queue object */
905 struct bnx2x_queue_cfc_del_params
{
906 /* index within the tx_only cids of this queue object */
910 struct bnx2x_queue_update_params
{
911 unsigned long update_flags
; /* BNX2X_Q_UPDATE_XX bits */
913 u16 silent_removal_value
;
914 u16 silent_removal_mask
;
915 /* index within the tx_only cids of this queue object */
919 struct bnx2x_queue_update_tpa_params
{
925 u8 complete_on_both_clients
;
933 u16 sge_pause_thr_low
;
934 u16 sge_pause_thr_high
;
937 struct rxq_pause_params
{
942 u16 sge_th_lo
; /* valid iff BNX2X_Q_FLG_TPA */
943 u16 sge_th_hi
; /* valid iff BNX2X_Q_FLG_TPA */
948 struct bnx2x_general_setup_params
{
949 /* valid iff BNX2X_Q_FLG_STATS */
959 struct bnx2x_rxq_setup_params
{
964 dma_addr_t rcq_np_map
;
971 /* valid iff BNX2X_Q_FLG_TPA */
978 /* valid iff BNX2X_Q_FLG_MCAST */
985 /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
986 u16 silent_removal_value
;
987 u16 silent_removal_mask
;
990 struct bnx2x_txq_setup_params
{
996 u8 cos
; /* valid iff BNX2X_Q_FLG_COS */
998 /* equals to the leading rss client id, used for TX classification*/
999 u8 tss_leading_cl_id
;
1001 /* valid iff BNX2X_Q_FLG_DEF_VLAN */
1005 struct bnx2x_queue_setup_params
{
1006 struct bnx2x_general_setup_params gen_params
;
1007 struct bnx2x_txq_setup_params txq_params
;
1008 struct bnx2x_rxq_setup_params rxq_params
;
1009 struct rxq_pause_params pause_params
;
1010 unsigned long flags
;
1013 struct bnx2x_queue_setup_tx_only_params
{
1014 struct bnx2x_general_setup_params gen_params
;
1015 struct bnx2x_txq_setup_params txq_params
;
1016 unsigned long flags
;
1017 /* index within the tx_only cids of this queue object */
1021 struct bnx2x_queue_state_params
{
1022 struct bnx2x_queue_sp_obj
*q_obj
;
1024 /* Current command */
1025 enum bnx2x_queue_cmd cmd
;
1027 /* may have RAMROD_COMP_WAIT set only */
1028 unsigned long ramrod_flags
;
1030 /* Params according to the current command */
1032 struct bnx2x_queue_update_params update
;
1033 struct bnx2x_queue_update_tpa_params update_tpa
;
1034 struct bnx2x_queue_setup_params setup
;
1035 struct bnx2x_queue_init_params init
;
1036 struct bnx2x_queue_setup_tx_only_params tx_only
;
1037 struct bnx2x_queue_terminate_params terminate
;
1038 struct bnx2x_queue_cfc_del_params cfc_del
;
1042 struct bnx2x_viflist_params
{
1044 u8 func_bit_map_res
;
1047 struct bnx2x_queue_sp_obj
{
1048 u32 cids
[BNX2X_MULTI_TX_COS
];
1052 /* number of traffic classes supported by queue.
1053 * The primary connection of the queue supports the first traffic
1054 * class. Any further traffic class is supported by a tx-only
1057 * Therefore max_cos is also a number of valid entries in the cids
1061 u8 num_tx_only
, next_tx_only
;
1063 enum bnx2x_q_state state
, next_state
;
1065 /* bits from enum bnx2x_q_type */
1068 /* BNX2X_Q_CMD_XX bits. This object implements "one
1069 * pending" paradigm but for debug and tracing purposes it's
1070 * more convenient to have different bits for different
1073 unsigned long pending
;
1075 /* Buffer to use as a ramrod data and its mapping */
1077 dma_addr_t rdata_mapping
;
1080 * Performs one state change according to the given parameters.
1082 * @return 0 in case of success and negative value otherwise.
1084 int (*send_cmd
)(struct bnx2x
*bp
,
1085 struct bnx2x_queue_state_params
*params
);
1088 * Sets the pending bit according to the requested transition.
1090 int (*set_pending
)(struct bnx2x_queue_sp_obj
*o
,
1091 struct bnx2x_queue_state_params
*params
);
1094 * Checks that the requested state transition is legal.
1096 int (*check_transition
)(struct bnx2x
*bp
,
1097 struct bnx2x_queue_sp_obj
*o
,
1098 struct bnx2x_queue_state_params
*params
);
1101 * Completes the pending command.
1103 int (*complete_cmd
)(struct bnx2x
*bp
,
1104 struct bnx2x_queue_sp_obj
*o
,
1105 enum bnx2x_queue_cmd
);
1107 int (*wait_comp
)(struct bnx2x
*bp
,
1108 struct bnx2x_queue_sp_obj
*o
,
1109 enum bnx2x_queue_cmd cmd
);
1112 /********************** Function state update *********************************/
1114 /* UPDATE command options */
1116 BNX2X_F_UPDATE_TX_SWITCH_SUSPEND_CHNG
,
1117 BNX2X_F_UPDATE_TX_SWITCH_SUSPEND
,
1118 BNX2X_F_UPDATE_SD_VLAN_TAG_CHNG
,
1119 BNX2X_F_UPDATE_SD_VLAN_ETH_TYPE_CHNG
,
1120 BNX2X_F_UPDATE_VLAN_FORCE_PRIO_CHNG
,
1121 BNX2X_F_UPDATE_VLAN_FORCE_PRIO_FLAG
,
1122 BNX2X_F_UPDATE_TUNNEL_CFG_CHNG
,
1123 BNX2X_F_UPDATE_TUNNEL_INNER_CLSS_L2GRE
,
1124 BNX2X_F_UPDATE_TUNNEL_INNER_CLSS_VXLAN
,
1125 BNX2X_F_UPDATE_TUNNEL_INNER_CLSS_L2GENEVE
,
1126 BNX2X_F_UPDATE_TUNNEL_INNER_RSS
,
1129 /* Allowed Function states */
1130 enum bnx2x_func_state
{
1131 BNX2X_F_STATE_RESET
,
1132 BNX2X_F_STATE_INITIALIZED
,
1133 BNX2X_F_STATE_STARTED
,
1134 BNX2X_F_STATE_TX_STOPPED
,
1138 /* Allowed Function commands */
1139 enum bnx2x_func_cmd
{
1140 BNX2X_F_CMD_HW_INIT
,
1143 BNX2X_F_CMD_HW_RESET
,
1144 BNX2X_F_CMD_AFEX_UPDATE
,
1145 BNX2X_F_CMD_AFEX_VIFLISTS
,
1146 BNX2X_F_CMD_TX_STOP
,
1147 BNX2X_F_CMD_TX_START
,
1148 BNX2X_F_CMD_SWITCH_UPDATE
,
1149 BNX2X_F_CMD_SET_TIMESYNC
,
1153 struct bnx2x_func_hw_init_params
{
1154 /* A load phase returned by MCP.
1157 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1158 * FW_MSG_CODE_DRV_LOAD_COMMON
1159 * FW_MSG_CODE_DRV_LOAD_PORT
1160 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1165 struct bnx2x_func_hw_reset_params
{
1166 /* A load phase returned by MCP.
1169 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1170 * FW_MSG_CODE_DRV_LOAD_COMMON
1171 * FW_MSG_CODE_DRV_LOAD_PORT
1172 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1177 struct bnx2x_func_start_params
{
1178 /* Multi Function mode:
1180 * - Switch Dependent
1181 * - Switch Independent
1185 /* Switch Dependent mode outer VLAN tag */
1188 /* Function cos mode */
1189 u8 network_cos_mode
;
1191 /* UDP dest port for VXLAN */
1194 /* UDP dest port for Geneve */
1195 u16 geneve_dst_port
;
1197 /* Enable inner Rx classifications for L2GRE packets */
1198 u8 inner_clss_l2gre
;
1200 /* Enable inner Rx classifications for L2-Geneve packets */
1201 u8 inner_clss_l2geneve
;
1203 /* Enable inner Rx classification for vxlan packets */
1204 u8 inner_clss_vxlan
;
1206 /* Enable RSS according to inner header */
1209 /* Allows accepting of packets failing MF classification, possibly
1210 * only matching a given ethertype
1213 u16 class_fail_ethtype
;
1215 /* Override priority of output packets */
1216 u8 sd_vlan_force_pri
;
1217 u8 sd_vlan_force_pri_val
;
1219 /* Replace vlan's ethertype */
1220 u16 sd_vlan_eth_type
;
1222 /* Prevent inner vlans from being added by FW */
1225 /* Inner-to-Outer vlan priority mapping */
1226 u8 c2s_pri
[MAX_VLAN_PRIORITIES
];
1231 struct bnx2x_func_switch_update_params
{
1232 unsigned long changes
; /* BNX2X_F_UPDATE_XX bits */
1237 u16 geneve_dst_port
;
1240 struct bnx2x_func_afex_update_params
{
1242 u16 afex_default_vlan
;
1243 u8 allowed_priorities
;
1246 struct bnx2x_func_afex_viflists_params
{
1249 u8 afex_vif_list_command
;
1253 struct bnx2x_func_tx_start_params
{
1254 struct priority_cos traffic_type_to_priority_cos
[MAX_TRAFFIC_TYPES
];
1257 u8 dont_add_pri_0_en
;
1258 u8 dcb_outer_pri
[MAX_TRAFFIC_TYPES
];
1261 struct bnx2x_func_set_timesync_params
{
1262 /* Reset, set or keep the current drift value */
1263 u8 drift_adjust_cmd
;
1265 /* Dec, inc or keep the current offset */
1268 /* Drift value direction */
1269 u8 add_sub_drift_adjust_value
;
1271 /* Drift, period and offset values to be used according to the commands
1274 u8 drift_adjust_value
;
1275 u32 drift_adjust_period
;
1279 struct bnx2x_func_state_params
{
1280 struct bnx2x_func_sp_obj
*f_obj
;
1282 /* Current command */
1283 enum bnx2x_func_cmd cmd
;
1285 /* may have RAMROD_COMP_WAIT set only */
1286 unsigned long ramrod_flags
;
1288 /* Params according to the current command */
1290 struct bnx2x_func_hw_init_params hw_init
;
1291 struct bnx2x_func_hw_reset_params hw_reset
;
1292 struct bnx2x_func_start_params start
;
1293 struct bnx2x_func_switch_update_params switch_update
;
1294 struct bnx2x_func_afex_update_params afex_update
;
1295 struct bnx2x_func_afex_viflists_params afex_viflists
;
1296 struct bnx2x_func_tx_start_params tx_start
;
1297 struct bnx2x_func_set_timesync_params set_timesync
;
1301 struct bnx2x_func_sp_drv_ops
{
1302 /* Init tool + runtime initialization:
1304 * - Common (per Path)
1308 int (*init_hw_cmn_chip
)(struct bnx2x
*bp
);
1309 int (*init_hw_cmn
)(struct bnx2x
*bp
);
1310 int (*init_hw_port
)(struct bnx2x
*bp
);
1311 int (*init_hw_func
)(struct bnx2x
*bp
);
1313 /* Reset Function HW: Common, Port, Function phases. */
1314 void (*reset_hw_cmn
)(struct bnx2x
*bp
);
1315 void (*reset_hw_port
)(struct bnx2x
*bp
);
1316 void (*reset_hw_func
)(struct bnx2x
*bp
);
1318 /* Init/Free GUNZIP resources */
1319 int (*gunzip_init
)(struct bnx2x
*bp
);
1320 void (*gunzip_end
)(struct bnx2x
*bp
);
1322 /* Prepare/Release FW resources */
1323 int (*init_fw
)(struct bnx2x
*bp
);
1324 void (*release_fw
)(struct bnx2x
*bp
);
1327 struct bnx2x_func_sp_obj
{
1328 enum bnx2x_func_state state
, next_state
;
1330 /* BNX2X_FUNC_CMD_XX bits. This object implements "one
1331 * pending" paradigm but for debug and tracing purposes it's
1332 * more convenient to have different bits for different
1335 unsigned long pending
;
1337 /* Buffer to use as a ramrod data and its mapping */
1339 dma_addr_t rdata_mapping
;
1341 /* Buffer to use as a afex ramrod data and its mapping.
1342 * This can't be same rdata as above because afex ramrod requests
1343 * can arrive to the object in parallel to other ramrod requests.
1346 dma_addr_t afex_rdata_mapping
;
1348 /* this mutex validates that when pending flag is taken, the next
1349 * ramrod to be sent will be the one set the pending bit
1351 struct mutex one_pending_mutex
;
1353 /* Driver interface */
1354 struct bnx2x_func_sp_drv_ops
*drv
;
1357 * Performs one state change according to the given parameters.
1359 * @return 0 in case of success and negative value otherwise.
1361 int (*send_cmd
)(struct bnx2x
*bp
,
1362 struct bnx2x_func_state_params
*params
);
1365 * Checks that the requested state transition is legal.
1367 int (*check_transition
)(struct bnx2x
*bp
,
1368 struct bnx2x_func_sp_obj
*o
,
1369 struct bnx2x_func_state_params
*params
);
1372 * Completes the pending command.
1374 int (*complete_cmd
)(struct bnx2x
*bp
,
1375 struct bnx2x_func_sp_obj
*o
,
1376 enum bnx2x_func_cmd cmd
);
1378 int (*wait_comp
)(struct bnx2x
*bp
, struct bnx2x_func_sp_obj
*o
,
1379 enum bnx2x_func_cmd cmd
);
1382 /********************** Interfaces ********************************************/
1383 /* Queueable objects set */
1384 union bnx2x_qable_obj
{
1385 struct bnx2x_vlan_mac_obj vlan_mac
;
1387 /************** Function state update *********/
1388 void bnx2x_init_func_obj(struct bnx2x
*bp
,
1389 struct bnx2x_func_sp_obj
*obj
,
1390 void *rdata
, dma_addr_t rdata_mapping
,
1391 void *afex_rdata
, dma_addr_t afex_rdata_mapping
,
1392 struct bnx2x_func_sp_drv_ops
*drv_iface
);
1394 int bnx2x_func_state_change(struct bnx2x
*bp
,
1395 struct bnx2x_func_state_params
*params
);
1397 enum bnx2x_func_state
bnx2x_func_get_state(struct bnx2x
*bp
,
1398 struct bnx2x_func_sp_obj
*o
);
1399 /******************* Queue State **************/
1400 void bnx2x_init_queue_obj(struct bnx2x
*bp
,
1401 struct bnx2x_queue_sp_obj
*obj
, u8 cl_id
, u32
*cids
,
1402 u8 cid_cnt
, u8 func_id
, void *rdata
,
1403 dma_addr_t rdata_mapping
, unsigned long type
);
1405 int bnx2x_queue_state_change(struct bnx2x
*bp
,
1406 struct bnx2x_queue_state_params
*params
);
1408 int bnx2x_get_q_logical_state(struct bnx2x
*bp
,
1409 struct bnx2x_queue_sp_obj
*obj
);
1411 /********************* VLAN-MAC ****************/
1412 void bnx2x_init_mac_obj(struct bnx2x
*bp
,
1413 struct bnx2x_vlan_mac_obj
*mac_obj
,
1414 u8 cl_id
, u32 cid
, u8 func_id
, void *rdata
,
1415 dma_addr_t rdata_mapping
, int state
,
1416 unsigned long *pstate
, bnx2x_obj_type type
,
1417 struct bnx2x_credit_pool_obj
*macs_pool
);
1419 void bnx2x_init_vlan_obj(struct bnx2x
*bp
,
1420 struct bnx2x_vlan_mac_obj
*vlan_obj
,
1421 u8 cl_id
, u32 cid
, u8 func_id
, void *rdata
,
1422 dma_addr_t rdata_mapping
, int state
,
1423 unsigned long *pstate
, bnx2x_obj_type type
,
1424 struct bnx2x_credit_pool_obj
*vlans_pool
);
1426 void bnx2x_init_vlan_mac_obj(struct bnx2x
*bp
,
1427 struct bnx2x_vlan_mac_obj
*vlan_mac_obj
,
1428 u8 cl_id
, u32 cid
, u8 func_id
, void *rdata
,
1429 dma_addr_t rdata_mapping
, int state
,
1430 unsigned long *pstate
, bnx2x_obj_type type
,
1431 struct bnx2x_credit_pool_obj
*macs_pool
,
1432 struct bnx2x_credit_pool_obj
*vlans_pool
);
1434 int bnx2x_vlan_mac_h_read_lock(struct bnx2x
*bp
,
1435 struct bnx2x_vlan_mac_obj
*o
);
1436 void bnx2x_vlan_mac_h_read_unlock(struct bnx2x
*bp
,
1437 struct bnx2x_vlan_mac_obj
*o
);
1438 int bnx2x_vlan_mac_h_write_lock(struct bnx2x
*bp
,
1439 struct bnx2x_vlan_mac_obj
*o
);
1440 int bnx2x_config_vlan_mac(struct bnx2x
*bp
,
1441 struct bnx2x_vlan_mac_ramrod_params
*p
);
1443 int bnx2x_vlan_mac_move(struct bnx2x
*bp
,
1444 struct bnx2x_vlan_mac_ramrod_params
*p
,
1445 struct bnx2x_vlan_mac_obj
*dest_o
);
1447 /********************* RX MODE ****************/
1449 void bnx2x_init_rx_mode_obj(struct bnx2x
*bp
,
1450 struct bnx2x_rx_mode_obj
*o
);
1453 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
1455 * @p: Command parameters
1457 * Return: 0 - if operation was successful and there is no pending completions,
1458 * positive number - if there are pending completions,
1459 * negative - if there were errors
1461 int bnx2x_config_rx_mode(struct bnx2x
*bp
,
1462 struct bnx2x_rx_mode_ramrod_params
*p
);
1464 /****************** MULTICASTS ****************/
1466 void bnx2x_init_mcast_obj(struct bnx2x
*bp
,
1467 struct bnx2x_mcast_obj
*mcast_obj
,
1468 u8 mcast_cl_id
, u32 mcast_cid
, u8 func_id
,
1469 u8 engine_id
, void *rdata
, dma_addr_t rdata_mapping
,
1470 int state
, unsigned long *pstate
,
1471 bnx2x_obj_type type
);
1474 * bnx2x_config_mcast - Configure multicast MACs list.
1476 * @cmd: command to execute: BNX2X_MCAST_CMD_X
1478 * May configure a new list
1479 * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up
1480 * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current
1481 * configuration, continue to execute the pending commands
1482 * (BNX2X_MCAST_CMD_CONT).
1484 * If previous command is still pending or if number of MACs to
1485 * configure is more that maximum number of MACs in one command,
1486 * the current command will be enqueued to the tail of the
1487 * pending commands list.
1489 * Return: 0 is operation was successful and there are no pending completions,
1490 * negative if there were errors, positive if there are pending
1493 int bnx2x_config_mcast(struct bnx2x
*bp
,
1494 struct bnx2x_mcast_ramrod_params
*p
,
1495 enum bnx2x_mcast_cmd cmd
);
1497 /****************** CREDIT POOL ****************/
1498 void bnx2x_init_mac_credit_pool(struct bnx2x
*bp
,
1499 struct bnx2x_credit_pool_obj
*p
, u8 func_id
,
1501 void bnx2x_init_vlan_credit_pool(struct bnx2x
*bp
,
1502 struct bnx2x_credit_pool_obj
*p
, u8 func_id
,
1504 void bnx2x_init_credit_pool(struct bnx2x_credit_pool_obj
*p
,
1505 int base
, int credit
);
1507 /****************** RSS CONFIGURATION ****************/
1508 void bnx2x_init_rss_config_obj(struct bnx2x
*bp
,
1509 struct bnx2x_rss_config_obj
*rss_obj
,
1510 u8 cl_id
, u32 cid
, u8 func_id
, u8 engine_id
,
1511 void *rdata
, dma_addr_t rdata_mapping
,
1512 int state
, unsigned long *pstate
,
1513 bnx2x_obj_type type
);
1516 * bnx2x_config_rss - Updates RSS configuration according to provided parameters
1518 * Return: 0 in case of success
1520 int bnx2x_config_rss(struct bnx2x
*bp
,
1521 struct bnx2x_config_rss_params
*p
);
1524 * bnx2x_get_rss_ind_table - Return the current ind_table configuration.
1526 * @ind_table: buffer to fill with the current indirection
1527 * table content. Should be at least
1528 * T_ETH_INDIRECTION_TABLE_SIZE bytes long.
1530 void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj
*rss_obj
,
1533 #define PF_MAC_CREDIT_E2(bp, func_num) \
1534 ((MAX_MAC_CREDIT_E2 - GET_NUM_VFS_PER_PATH(bp) * VF_MAC_CREDIT_CNT) / \
1535 func_num + GET_NUM_VFS_PER_PF(bp) * VF_MAC_CREDIT_CNT)
1537 #define PF_VLAN_CREDIT_E2(bp, func_num) \
1538 ((MAX_MAC_CREDIT_E2 - GET_NUM_VFS_PER_PATH(bp) * VF_VLAN_CREDIT_CNT) / \
1539 func_num + GET_NUM_VFS_PER_PF(bp) * VF_VLAN_CREDIT_CNT)
1541 #endif /* BNX2X_SP_VERBS */