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 */
288 /* copy first n elements onto preallocated buffer
290 * @param n number of elements to get
291 * @param buf buffer preallocated by caller into which elements
292 * will be copied. Note elements are 4-byte aligned
293 * so buffer size must be able to accomodate the
296 * @return number of copied bytes
298 int (*get_n_elements)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
302 * Checks if ADD-ramrod with the given params may be performed.
304 * @return zero if the element may be added
307 int (*check_add)(struct bnx2x_vlan_mac_obj *o,
308 union bnx2x_classification_ramrod_data *data);
311 * Checks if DEL-ramrod with the given params may be performed.
313 * @return true if the element may be deleted
315 struct bnx2x_vlan_mac_registry_elem *
316 (*check_del)(struct bnx2x_vlan_mac_obj *o,
317 union bnx2x_classification_ramrod_data *data);
320 * Checks if DEL-ramrod with the given params may be performed.
322 * @return true if the element may be deleted
324 bool (*check_move)(struct bnx2x_vlan_mac_obj *src_o,
325 struct bnx2x_vlan_mac_obj *dst_o,
326 union bnx2x_classification_ramrod_data *data);
329 * Update the relevant credit object(s) (consume/return
332 bool (*get_credit)(struct bnx2x_vlan_mac_obj *o);
333 bool (*put_credit)(struct bnx2x_vlan_mac_obj *o);
334 bool (*get_cam_offset)(struct bnx2x_vlan_mac_obj *o, int *offset);
335 bool (*put_cam_offset)(struct bnx2x_vlan_mac_obj *o, int offset);
338 * Configures one rule in the ramrod data buffer.
340 void (*set_one_rule)(struct bnx2x *bp,
341 struct bnx2x_vlan_mac_obj *o,
342 struct bnx2x_exeq_elem *elem, int rule_idx,
346 * Delete all configured elements having the given
347 * vlan_mac_flags specification. Assumes no pending for
348 * execution commands. Will schedule all all currently
349 * configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
350 * specification for deletion and will use the given
351 * ramrod_flags for the last DEL operation.
355 * @param ramrod_flags RAMROD_XX flags
357 * @return 0 if the last operation has completed successfully
358 * and there are no more elements left, positive value
359 * if there are pending for completion commands,
360 * negative value in case of failure.
362 int (*delete_all)(struct bnx2x *bp,
363 struct bnx2x_vlan_mac_obj *o,
364 unsigned long *vlan_mac_flags,
365 unsigned long *ramrod_flags);
368 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
369 * configured elements list.
372 * @param p Command parameters (RAMROD_COMP_WAIT bit in
373 * ramrod_flags is only taken into an account)
374 * @param ppos a pointer to the cooky that should be given back in the
375 * next call to make function handle the next element. If
376 * *ppos is set to NULL it will restart the iterator.
377 * If returned *ppos == NULL this means that the last
378 * element has been handled.
382 int (*restore)(struct bnx2x *bp,
383 struct bnx2x_vlan_mac_ramrod_params *p,
384 struct bnx2x_vlan_mac_registry_elem **ppos);
387 * Should be called on a completion arival.
391 * @param cqe Completion element we are handling
392 * @param ramrod_flags if RAMROD_CONT is set the next bulk of
393 * pending commands will be executed.
394 * RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
395 * may also be set if needed.
397 * @return 0 if there are neither pending nor waiting for
398 * completion commands. Positive value if there are
399 * pending for execution or for completion commands.
400 * Negative value in case of an error (including an
403 int (*complete)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
404 union event_ring_elem *cqe,
405 unsigned long *ramrod_flags);
408 * Wait for completion of all commands. Don't schedule new ones,
409 * just wait. It assumes that the completion code will schedule
412 int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o);
415 /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
417 /* RX_MODE ramrod spesial flags: set in rx_mode_flags field in
418 * a bnx2x_rx_mode_ramrod_params.
421 BNX2X_RX_MODE_FCOE_ETH,
422 BNX2X_RX_MODE_ISCSI_ETH,
426 BNX2X_ACCEPT_UNICAST,
427 BNX2X_ACCEPT_MULTICAST,
428 BNX2X_ACCEPT_ALL_UNICAST,
429 BNX2X_ACCEPT_ALL_MULTICAST,
430 BNX2X_ACCEPT_BROADCAST,
431 BNX2X_ACCEPT_UNMATCHED,
432 BNX2X_ACCEPT_ANY_VLAN
435 struct bnx2x_rx_mode_ramrod_params {
436 struct bnx2x_rx_mode_obj *rx_mode_obj;
437 unsigned long *pstate;
442 unsigned long ramrod_flags;
443 unsigned long rx_mode_flags;
446 * rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
447 * a tstorm_eth_mac_filter_config (e1x).
450 dma_addr_t rdata_mapping;
452 /* Rx mode settings */
453 unsigned long rx_accept_flags;
455 /* internal switching settings */
456 unsigned long tx_accept_flags;
459 struct bnx2x_rx_mode_obj {
460 int (*config_rx_mode)(struct bnx2x *bp,
461 struct bnx2x_rx_mode_ramrod_params *p);
463 int (*wait_comp)(struct bnx2x *bp,
464 struct bnx2x_rx_mode_ramrod_params *p);
467 /********************** Set multicast group ***********************************/
469 struct bnx2x_mcast_list_elem {
470 struct list_head link;
474 union bnx2x_mcast_config_data {
476 u8 bin; /* used in a RESTORE flow */
479 struct bnx2x_mcast_ramrod_params {
480 struct bnx2x_mcast_obj *mcast_obj;
482 /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
483 unsigned long ramrod_flags;
485 struct list_head mcast_list; /* list of struct bnx2x_mcast_list_elem */
487 * - rename it to macs_num.
488 * - Add a new command type for handling pending commands
489 * (remove "zero semantics").
491 * Length of mcast_list. If zero and ADD_CONT command - post
499 BNX2X_MCAST_CMD_CONT,
501 BNX2X_MCAST_CMD_RESTORE,
504 struct bnx2x_mcast_obj {
505 struct bnx2x_raw_obj raw;
509 #define BNX2X_MCAST_BINS_NUM 256
510 #define BNX2X_MCAST_VEC_SZ (BNX2X_MCAST_BINS_NUM / 64)
511 u64 vec[BNX2X_MCAST_VEC_SZ];
513 /** Number of BINs to clear. Should be updated
514 * immediately when a command arrives in order to
515 * properly create DEL commands.
521 struct list_head macs;
526 /* Pending commands */
527 struct list_head pending_cmds_head;
529 /* A state that is set in raw.pstate, when there are pending commands */
532 /* Maximal number of mcast MACs configured in one command */
535 /* Total number of currently pending MACs to configure: both
536 * in the pending commands list and in the current command.
538 int total_pending_num;
543 * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above)
545 int (*config_mcast)(struct bnx2x *bp,
546 struct bnx2x_mcast_ramrod_params *p, int cmd);
549 * Fills the ramrod data during the RESTORE flow.
553 * @param start_idx Registry index to start from
554 * @param rdata_idx Index in the ramrod data to start from
556 * @return -1 if we handled the whole registry or index of the last
557 * handled registry element.
559 int (*hdl_restore)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
560 int start_bin, int *rdata_idx);
562 int (*enqueue_cmd)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
563 struct bnx2x_mcast_ramrod_params *p, int cmd);
565 void (*set_one_rule)(struct bnx2x *bp,
566 struct bnx2x_mcast_obj *o, int idx,
567 union bnx2x_mcast_config_data *cfg_data, int cmd);
569 /** Checks if there are more mcast MACs to be set or a previous
570 * command is still pending.
572 bool (*check_pending)(struct bnx2x_mcast_obj *o);
575 * Set/Clear/Check SCHEDULED state of the object
577 void (*set_sched)(struct bnx2x_mcast_obj *o);
578 void (*clear_sched)(struct bnx2x_mcast_obj *o);
579 bool (*check_sched)(struct bnx2x_mcast_obj *o);
581 /* Wait until all pending commands complete */
582 int (*wait_comp)(struct bnx2x *bp, struct bnx2x_mcast_obj *o);
585 * Handle the internal object counters needed for proper
586 * commands handling. Checks that the provided parameters are
589 int (*validate)(struct bnx2x *bp,
590 struct bnx2x_mcast_ramrod_params *p, int cmd);
593 * Restore the values of internal counters in case of a failure.
595 void (*revert)(struct bnx2x *bp,
596 struct bnx2x_mcast_ramrod_params *p,
599 int (*get_registry_size)(struct bnx2x_mcast_obj *o);
600 void (*set_registry_size)(struct bnx2x_mcast_obj *o, int n);
603 /*************************** Credit handling **********************************/
604 struct bnx2x_credit_pool_obj {
606 /* Current amount of credit in the pool */
609 /* Maximum allowed credit. put() will check against it. */
613 * Allocate a pool table statically.
615 * Currently the mamimum allowed size is MAX_MAC_CREDIT_E2(272)
617 * The set bit in the table will mean that the entry is available.
619 #define BNX2X_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64)
620 u64 pool_mirror[BNX2X_POOL_VEC_SIZE];
622 /* Base pool offset (initialized differently */
623 int base_pool_offset;
626 * Get the next free pool entry.
628 * @return true if there was a free entry in the pool
630 bool (*get_entry)(struct bnx2x_credit_pool_obj *o, int *entry);
633 * Return the entry back to the pool.
635 * @return true if entry is legal and has been successfully
636 * returned to the pool.
638 bool (*put_entry)(struct bnx2x_credit_pool_obj *o, int entry);
641 * Get the requested amount of credit from the pool.
643 * @param cnt Amount of requested credit
644 * @return true if the operation is successful
646 bool (*get)(struct bnx2x_credit_pool_obj *o, int cnt);
649 * Returns the credit to the pool.
651 * @param cnt Amount of credit to return
652 * @return true if the operation is successful
654 bool (*put)(struct bnx2x_credit_pool_obj *o, int cnt);
657 * Reads the current amount of credit.
659 int (*check)(struct bnx2x_credit_pool_obj *o);
662 /*************************** RSS configuration ********************************/
664 /* RSS_MODE bits are mutually exclusive */
665 BNX2X_RSS_MODE_DISABLED,
666 BNX2X_RSS_MODE_REGULAR,
667 BNX2X_RSS_MODE_VLAN_PRI,
668 BNX2X_RSS_MODE_E1HOV_PRI,
669 BNX2X_RSS_MODE_IP_DSCP,
671 BNX2X_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */
679 struct bnx2x_config_rss_params {
680 struct bnx2x_rss_config_obj *rss_obj;
682 /* may have RAMROD_COMP_WAIT set only */
683 unsigned long ramrod_flags;
685 /* BNX2X_RSS_X bits */
686 unsigned long rss_flags;
688 /* Number hash bits to take into an account */
691 /* Indirection table */
692 u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
694 /* RSS hash values */
697 /* valid only iff BNX2X_RSS_UPDATE_TOE is set */
701 struct bnx2x_rss_config_obj {
702 struct bnx2x_raw_obj raw;
704 /* RSS engine to use */
707 /* Last configured indirection table */
708 u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
710 int (*config_rss)(struct bnx2x *bp,
711 struct bnx2x_config_rss_params *p);
714 /*********************** Queue state update ***********************************/
716 /* UPDATE command options */
718 BNX2X_Q_UPDATE_IN_VLAN_REM,
719 BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG,
720 BNX2X_Q_UPDATE_OUT_VLAN_REM,
721 BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG,
722 BNX2X_Q_UPDATE_ANTI_SPOOF,
723 BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG,
724 BNX2X_Q_UPDATE_ACTIVATE,
725 BNX2X_Q_UPDATE_ACTIVATE_CHNG,
726 BNX2X_Q_UPDATE_DEF_VLAN_EN,
727 BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG,
728 BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG,
729 BNX2X_Q_UPDATE_SILENT_VLAN_REM
732 /* Allowed Queue states */
735 BNX2X_Q_STATE_INITIALIZED,
736 BNX2X_Q_STATE_ACTIVE,
737 BNX2X_Q_STATE_MULTI_COS,
738 BNX2X_Q_STATE_MCOS_TERMINATED,
739 BNX2X_Q_STATE_INACTIVE,
740 BNX2X_Q_STATE_STOPPED,
741 BNX2X_Q_STATE_TERMINATED,
746 /* Allowed commands */
747 enum bnx2x_queue_cmd {
750 BNX2X_Q_CMD_SETUP_TX_ONLY,
751 BNX2X_Q_CMD_DEACTIVATE,
752 BNX2X_Q_CMD_ACTIVATE,
754 BNX2X_Q_CMD_UPDATE_TPA,
757 BNX2X_Q_CMD_TERMINATE,
762 /* queue SETUP + INIT flags */
765 BNX2X_Q_FLG_TPA_IPV6,
767 BNX2X_Q_FLG_ZERO_STATS,
776 BNX2X_Q_FLG_LEADING_RSS,
778 BNX2X_Q_FLG_DEF_VLAN,
779 BNX2X_Q_FLG_TX_SWITCH,
781 BNX2X_Q_FLG_ANTI_SPOOF,
782 BNX2X_Q_FLG_SILENT_VLAN_REM
785 /* Queue type options: queue type may be a compination of below. */
787 /** TODO: Consider moving both these flags into the init()
794 #define BNX2X_PRIMARY_CID_INDEX 0
795 #define BNX2X_MULTI_TX_COS_E1X 1
796 #define BNX2X_MULTI_TX_COS_E2_E3A0 2
797 #define BNX2X_MULTI_TX_COS_E3B0 3
798 #define BNX2X_MULTI_TX_COS BNX2X_MULTI_TX_COS_E3B0
801 struct bnx2x_queue_init_params {
816 /* CID context in the host memory */
817 struct eth_context *cxts[BNX2X_MULTI_TX_COS];
819 /* maximum number of cos supported by hardware */
823 struct bnx2x_queue_terminate_params {
824 /* index within the tx_only cids of this queue object */
828 struct bnx2x_queue_cfc_del_params {
829 /* index within the tx_only cids of this queue object */
833 struct bnx2x_queue_update_params {
834 unsigned long update_flags; /* BNX2X_Q_UPDATE_XX bits */
836 u16 silent_removal_value;
837 u16 silent_removal_mask;
838 /* index within the tx_only cids of this queue object */
842 struct rxq_pause_params {
847 u16 sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */
848 u16 sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */
853 struct bnx2x_general_setup_params {
854 /* valid iff BNX2X_Q_FLG_STATS */
862 struct bnx2x_rxq_setup_params {
867 dma_addr_t rcq_np_map;
874 /* valid iff BNX2X_Q_FLG_TPA */
885 /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
886 u16 silent_removal_value;
887 u16 silent_removal_mask;
890 struct bnx2x_txq_setup_params {
896 u8 cos; /* valid iff BNX2X_Q_FLG_COS */
898 /* equals to the leading rss client id, used for TX classification*/
899 u8 tss_leading_cl_id;
901 /* valid iff BNX2X_Q_FLG_DEF_VLAN */
905 struct bnx2x_queue_setup_params {
906 struct bnx2x_general_setup_params gen_params;
907 struct bnx2x_txq_setup_params txq_params;
908 struct bnx2x_rxq_setup_params rxq_params;
909 struct rxq_pause_params pause_params;
913 struct bnx2x_queue_setup_tx_only_params {
914 struct bnx2x_general_setup_params gen_params;
915 struct bnx2x_txq_setup_params txq_params;
917 /* index within the tx_only cids of this queue object */
921 struct bnx2x_queue_state_params {
922 struct bnx2x_queue_sp_obj *q_obj;
924 /* Current command */
925 enum bnx2x_queue_cmd cmd;
927 /* may have RAMROD_COMP_WAIT set only */
928 unsigned long ramrod_flags;
930 /* Params according to the current command */
932 struct bnx2x_queue_update_params update;
933 struct bnx2x_queue_setup_params setup;
934 struct bnx2x_queue_init_params init;
935 struct bnx2x_queue_setup_tx_only_params tx_only;
936 struct bnx2x_queue_terminate_params terminate;
937 struct bnx2x_queue_cfc_del_params cfc_del;
941 struct bnx2x_queue_sp_obj {
942 u32 cids[BNX2X_MULTI_TX_COS];
947 * number of traffic classes supported by queue.
948 * The primary connection of the queue suppotrs the first traffic
949 * class. Any further traffic class is suppoted by a tx-only
952 * Therefore max_cos is also a number of valid entries in the cids
956 u8 num_tx_only, next_tx_only;
958 enum bnx2x_q_state state, next_state;
960 /* bits from enum bnx2x_q_type */
963 /* BNX2X_Q_CMD_XX bits. This object implements "one
964 * pending" paradigm but for debug and tracing purposes it's
965 * more convinient to have different bits for different
968 unsigned long pending;
970 /* Buffer to use as a ramrod data and its mapping */
972 dma_addr_t rdata_mapping;
975 * Performs one state change according to the given parameters.
977 * @return 0 in case of success and negative value otherwise.
979 int (*send_cmd)(struct bnx2x *bp,
980 struct bnx2x_queue_state_params *params);
983 * Sets the pending bit according to the requested transition.
985 int (*set_pending)(struct bnx2x_queue_sp_obj *o,
986 struct bnx2x_queue_state_params *params);
989 * Checks that the requested state transition is legal.
991 int (*check_transition)(struct bnx2x *bp,
992 struct bnx2x_queue_sp_obj *o,
993 struct bnx2x_queue_state_params *params);
996 * Completes the pending command.
998 int (*complete_cmd)(struct bnx2x *bp,
999 struct bnx2x_queue_sp_obj *o,
1000 enum bnx2x_queue_cmd);
1002 int (*wait_comp)(struct bnx2x *bp,
1003 struct bnx2x_queue_sp_obj *o,
1004 enum bnx2x_queue_cmd cmd);
1007 /********************** Function state update *********************************/
1008 /* Allowed Function states */
1009 enum bnx2x_func_state {
1010 BNX2X_F_STATE_RESET,
1011 BNX2X_F_STATE_INITIALIZED,
1012 BNX2X_F_STATE_STARTED,
1013 BNX2X_F_STATE_TX_STOPPED,
1017 /* Allowed Function commands */
1018 enum bnx2x_func_cmd {
1019 BNX2X_F_CMD_HW_INIT,
1022 BNX2X_F_CMD_HW_RESET,
1023 BNX2X_F_CMD_TX_STOP,
1024 BNX2X_F_CMD_TX_START,
1028 struct bnx2x_func_hw_init_params {
1029 /* A load phase returned by MCP.
1032 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1033 * FW_MSG_CODE_DRV_LOAD_COMMON
1034 * FW_MSG_CODE_DRV_LOAD_PORT
1035 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1040 struct bnx2x_func_hw_reset_params {
1041 /* A load phase returned by MCP.
1044 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1045 * FW_MSG_CODE_DRV_LOAD_COMMON
1046 * FW_MSG_CODE_DRV_LOAD_PORT
1047 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1052 struct bnx2x_func_start_params {
1053 /* Multi Function mode:
1055 * - Switch Dependent
1056 * - Switch Independent
1060 /* Switch Dependent mode outer VLAN tag */
1063 /* Function cos mode */
1064 u8 network_cos_mode;
1067 struct bnx2x_func_tx_start_params {
1068 struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES];
1071 u8 dont_add_pri_0_en;
1074 struct bnx2x_func_state_params {
1075 struct bnx2x_func_sp_obj *f_obj;
1077 /* Current command */
1078 enum bnx2x_func_cmd cmd;
1080 /* may have RAMROD_COMP_WAIT set only */
1081 unsigned long ramrod_flags;
1083 /* Params according to the current command */
1085 struct bnx2x_func_hw_init_params hw_init;
1086 struct bnx2x_func_hw_reset_params hw_reset;
1087 struct bnx2x_func_start_params start;
1088 struct bnx2x_func_tx_start_params tx_start;
1092 struct bnx2x_func_sp_drv_ops {
1093 /* Init tool + runtime initialization:
1095 * - Common (per Path)
1099 int (*init_hw_cmn_chip)(struct bnx2x *bp);
1100 int (*init_hw_cmn)(struct bnx2x *bp);
1101 int (*init_hw_port)(struct bnx2x *bp);
1102 int (*init_hw_func)(struct bnx2x *bp);
1104 /* Reset Function HW: Common, Port, Function phases. */
1105 void (*reset_hw_cmn)(struct bnx2x *bp);
1106 void (*reset_hw_port)(struct bnx2x *bp);
1107 void (*reset_hw_func)(struct bnx2x *bp);
1109 /* Init/Free GUNZIP resources */
1110 int (*gunzip_init)(struct bnx2x *bp);
1111 void (*gunzip_end)(struct bnx2x *bp);
1113 /* Prepare/Release FW resources */
1114 int (*init_fw)(struct bnx2x *bp);
1115 void (*release_fw)(struct bnx2x *bp);
1118 struct bnx2x_func_sp_obj {
1119 enum bnx2x_func_state state, next_state;
1121 /* BNX2X_FUNC_CMD_XX bits. This object implements "one
1122 * pending" paradigm but for debug and tracing purposes it's
1123 * more convinient to have different bits for different
1126 unsigned long pending;
1128 /* Buffer to use as a ramrod data and its mapping */
1130 dma_addr_t rdata_mapping;
1132 /* this mutex validates that when pending flag is taken, the next
1133 * ramrod to be sent will be the one set the pending bit
1135 struct mutex one_pending_mutex;
1137 /* Driver interface */
1138 struct bnx2x_func_sp_drv_ops *drv;
1141 * Performs one state change according to the given parameters.
1143 * @return 0 in case of success and negative value otherwise.
1145 int (*send_cmd)(struct bnx2x *bp,
1146 struct bnx2x_func_state_params *params);
1149 * Checks that the requested state transition is legal.
1151 int (*check_transition)(struct bnx2x *bp,
1152 struct bnx2x_func_sp_obj *o,
1153 struct bnx2x_func_state_params *params);
1156 * Completes the pending command.
1158 int (*complete_cmd)(struct bnx2x *bp,
1159 struct bnx2x_func_sp_obj *o,
1160 enum bnx2x_func_cmd cmd);
1162 int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o,
1163 enum bnx2x_func_cmd cmd);
1166 /********************** Interfaces ********************************************/
1167 /* Queueable objects set */
1168 union bnx2x_qable_obj {
1169 struct bnx2x_vlan_mac_obj vlan_mac;
1171 /************** Function state update *********/
1172 void bnx2x_init_func_obj(struct bnx2x *bp,
1173 struct bnx2x_func_sp_obj *obj,
1174 void *rdata, dma_addr_t rdata_mapping,
1175 struct bnx2x_func_sp_drv_ops *drv_iface);
1177 int bnx2x_func_state_change(struct bnx2x *bp,
1178 struct bnx2x_func_state_params *params);
1180 enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp,
1181 struct bnx2x_func_sp_obj *o);
1182 /******************* Queue State **************/
1183 void bnx2x_init_queue_obj(struct bnx2x *bp,
1184 struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids,
1185 u8 cid_cnt, u8 func_id, void *rdata,
1186 dma_addr_t rdata_mapping, unsigned long type);
1188 int bnx2x_queue_state_change(struct bnx2x *bp,
1189 struct bnx2x_queue_state_params *params);
1191 /********************* VLAN-MAC ****************/
1192 void bnx2x_init_mac_obj(struct bnx2x *bp,
1193 struct bnx2x_vlan_mac_obj *mac_obj,
1194 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1195 dma_addr_t rdata_mapping, int state,
1196 unsigned long *pstate, bnx2x_obj_type type,
1197 struct bnx2x_credit_pool_obj *macs_pool);
1199 void bnx2x_init_vlan_obj(struct bnx2x *bp,
1200 struct bnx2x_vlan_mac_obj *vlan_obj,
1201 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1202 dma_addr_t rdata_mapping, int state,
1203 unsigned long *pstate, bnx2x_obj_type type,
1204 struct bnx2x_credit_pool_obj *vlans_pool);
1206 void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
1207 struct bnx2x_vlan_mac_obj *vlan_mac_obj,
1208 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1209 dma_addr_t rdata_mapping, int state,
1210 unsigned long *pstate, bnx2x_obj_type type,
1211 struct bnx2x_credit_pool_obj *macs_pool,
1212 struct bnx2x_credit_pool_obj *vlans_pool);
1214 int bnx2x_config_vlan_mac(struct bnx2x *bp,
1215 struct bnx2x_vlan_mac_ramrod_params *p);
1217 int bnx2x_vlan_mac_move(struct bnx2x *bp,
1218 struct bnx2x_vlan_mac_ramrod_params *p,
1219 struct bnx2x_vlan_mac_obj *dest_o);
1221 /********************* RX MODE ****************/
1223 void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
1224 struct bnx2x_rx_mode_obj *o);
1227 * Send and RX_MODE ramrod according to the provided parameters.
1230 * @param p Command parameters
1232 * @return 0 - if operation was successfull and there is no pending completions,
1233 * positive number - if there are pending completions,
1234 * negative - if there were errors
1236 int bnx2x_config_rx_mode(struct bnx2x *bp,
1237 struct bnx2x_rx_mode_ramrod_params *p);
1239 /****************** MULTICASTS ****************/
1241 void bnx2x_init_mcast_obj(struct bnx2x *bp,
1242 struct bnx2x_mcast_obj *mcast_obj,
1243 u8 mcast_cl_id, u32 mcast_cid, u8 func_id,
1244 u8 engine_id, void *rdata, dma_addr_t rdata_mapping,
1245 int state, unsigned long *pstate,
1246 bnx2x_obj_type type);
1249 * Configure multicast MACs list. May configure a new list
1250 * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up
1251 * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current
1252 * configuration, continue to execute the pending commands
1253 * (BNX2X_MCAST_CMD_CONT).
1255 * If previous command is still pending or if number of MACs to
1256 * configure is more that maximum number of MACs in one command,
1257 * the current command will be enqueued to the tail of the
1258 * pending commands list.
1262 * @param command to execute: BNX2X_MCAST_CMD_X
1264 * @return 0 is operation was sucessfull and there are no pending completions,
1265 * negative if there were errors, positive if there are pending
1268 int bnx2x_config_mcast(struct bnx2x *bp,
1269 struct bnx2x_mcast_ramrod_params *p, int cmd);
1271 /****************** CREDIT POOL ****************/
1272 void bnx2x_init_mac_credit_pool(struct bnx2x *bp,
1273 struct bnx2x_credit_pool_obj *p, u8 func_id,
1275 void bnx2x_init_vlan_credit_pool(struct bnx2x *bp,
1276 struct bnx2x_credit_pool_obj *p, u8 func_id,
1280 /****************** RSS CONFIGURATION ****************/
1281 void bnx2x_init_rss_config_obj(struct bnx2x *bp,
1282 struct bnx2x_rss_config_obj *rss_obj,
1283 u8 cl_id, u32 cid, u8 func_id, u8 engine_id,
1284 void *rdata, dma_addr_t rdata_mapping,
1285 int state, unsigned long *pstate,
1286 bnx2x_obj_type type);
1289 * Updates RSS configuration according to provided parameters.
1294 * @return 0 in case of success
1296 int bnx2x_config_rss(struct bnx2x *bp,
1297 struct bnx2x_config_rss_params *p);
1300 * Return the current ind_table configuration.
1303 * @param ind_table buffer to fill with the current indirection
1304 * table content. Should be at least
1305 * T_ETH_INDIRECTION_TABLE_SIZE bytes long.
1307 void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj,
1310 #endif /* BNX2X_SP_VERBS */