1 /* bnx2x_sp.h: Broadcom Everest network driver.
3 * Copyright (c) 2011-2012 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,
65 BNX2X_AFEX_FCOE_Q_UPDATE_PENDING,
66 BNX2X_AFEX_PENDING_VIFSET_MCP_ACK
69 struct bnx2x_raw_obj {
76 /* Ramrod data buffer params */
78 dma_addr_t rdata_mapping;
80 /* Ramrod state params */
81 int state; /* "ramrod is pending" state bit */
82 unsigned long *pstate; /* pointer to state buffer */
84 bnx2x_obj_type obj_type;
86 int (*wait_comp)(struct bnx2x *bp,
87 struct bnx2x_raw_obj *o);
89 bool (*check_pending)(struct bnx2x_raw_obj *o);
90 void (*clear_pending)(struct bnx2x_raw_obj *o);
91 void (*set_pending)(struct bnx2x_raw_obj *o);
94 /************************* VLAN-MAC commands related parameters ***************/
95 struct bnx2x_mac_ramrod_data {
99 struct bnx2x_vlan_ramrod_data {
103 struct bnx2x_vlan_mac_ramrod_data {
108 union bnx2x_classification_ramrod_data {
109 struct bnx2x_mac_ramrod_data mac;
110 struct bnx2x_vlan_ramrod_data vlan;
111 struct bnx2x_vlan_mac_ramrod_data vlan_mac;
114 /* VLAN_MAC commands */
115 enum bnx2x_vlan_mac_cmd {
121 struct bnx2x_vlan_mac_data {
122 /* Requested command: BNX2X_VLAN_MAC_XX */
123 enum bnx2x_vlan_mac_cmd cmd;
125 * used to contain the data related vlan_mac_flags bits from
128 unsigned long vlan_mac_flags;
130 /* Needed for MOVE command */
131 struct bnx2x_vlan_mac_obj *target_obj;
133 union bnx2x_classification_ramrod_data u;
136 /*************************** Exe Queue obj ************************************/
137 union bnx2x_exe_queue_cmd_data {
138 struct bnx2x_vlan_mac_data vlan_mac;
145 struct bnx2x_exeq_elem {
146 struct list_head link;
148 /* Length of this element in the exe_chunk. */
151 union bnx2x_exe_queue_cmd_data cmd_data;
154 union bnx2x_qable_obj;
156 union bnx2x_exeq_comp_elem {
157 union event_ring_elem *elem;
160 struct bnx2x_exe_queue_obj;
162 typedef int (*exe_q_validate)(struct bnx2x *bp,
163 union bnx2x_qable_obj *o,
164 struct bnx2x_exeq_elem *elem);
166 typedef int (*exe_q_remove)(struct bnx2x *bp,
167 union bnx2x_qable_obj *o,
168 struct bnx2x_exeq_elem *elem);
170 /* Return positive if entry was optimized, 0 - if not, negative
171 * in case of an error.
173 typedef int (*exe_q_optimize)(struct bnx2x *bp,
174 union bnx2x_qable_obj *o,
175 struct bnx2x_exeq_elem *elem);
176 typedef int (*exe_q_execute)(struct bnx2x *bp,
177 union bnx2x_qable_obj *o,
178 struct list_head *exe_chunk,
179 unsigned long *ramrod_flags);
180 typedef struct bnx2x_exeq_elem *
181 (*exe_q_get)(struct bnx2x_exe_queue_obj *o,
182 struct bnx2x_exeq_elem *elem);
184 struct bnx2x_exe_queue_obj {
186 * Commands pending for an execution.
188 struct list_head exe_queue;
191 * Commands pending for an completion.
193 struct list_head pending_comp;
197 /* Maximum length of commands' list for one execution */
200 union bnx2x_qable_obj *owner;
202 /****** Virtual functions ******/
204 * Called before commands execution for commands that are really
205 * going to be executed (after 'optimize').
207 * Must run under exe_queue->lock
209 exe_q_validate validate;
212 * Called before removing pending commands, cleaning allocated
213 * resources (e.g., credits from validate)
218 * This will try to cancel the current pending commands list
219 * considering the new command.
221 * Returns the number of optimized commands or a negative error code
223 * Must run under exe_queue->lock
225 exe_q_optimize optimize;
228 * Run the next commands chunk (owner specific).
230 exe_q_execute execute;
233 * Return the exe_queue element containing the specific command
234 * if any. Otherwise return NULL.
238 /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
240 * Element in the VLAN_MAC registry list having all currenty configured
243 struct bnx2x_vlan_mac_registry_elem {
244 struct list_head link;
247 * Used to store the cam offset used for the mac/vlan/vlan-mac.
248 * Relevant for 57710 and 57711 only. VLANs and MACs share the
249 * same CAM for these chips.
253 /* Needed for DEL and RESTORE flows */
254 unsigned long vlan_mac_flags;
256 union bnx2x_classification_ramrod_data u;
259 /* Bits representing VLAN_MAC commands specific flags */
265 BNX2X_DONT_CONSUME_CAM_CREDIT,
266 BNX2X_DONT_CONSUME_CAM_CREDIT_DEST,
269 struct bnx2x_vlan_mac_ramrod_params {
270 /* Object to run the command from */
271 struct bnx2x_vlan_mac_obj *vlan_mac_obj;
273 /* General command flags: COMP_WAIT, etc. */
274 unsigned long ramrod_flags;
276 /* Command specific configuration request */
277 struct bnx2x_vlan_mac_data user_req;
280 struct bnx2x_vlan_mac_obj {
281 struct bnx2x_raw_obj raw;
283 /* Bookkeeping list: will prevent the addition of already existing
286 struct list_head head;
288 /* TODO: Add it's initialization in the init functions */
289 struct bnx2x_exe_queue_obj exe_queue;
291 /* MACs credit pool */
292 struct bnx2x_credit_pool_obj *macs_pool;
294 /* VLANs credit pool */
295 struct bnx2x_credit_pool_obj *vlans_pool;
297 /* RAMROD command to be used */
300 /* copy first n elements onto preallocated buffer
302 * @param n number of elements to get
303 * @param buf buffer preallocated by caller into which elements
304 * will be copied. Note elements are 4-byte aligned
305 * so buffer size must be able to accomodate the
308 * @return number of copied bytes
310 int (*get_n_elements)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
314 * Checks if ADD-ramrod with the given params may be performed.
316 * @return zero if the element may be added
319 int (*check_add)(struct bnx2x *bp,
320 struct bnx2x_vlan_mac_obj *o,
321 union bnx2x_classification_ramrod_data *data);
324 * Checks if DEL-ramrod with the given params may be performed.
326 * @return true if the element may be deleted
328 struct bnx2x_vlan_mac_registry_elem *
329 (*check_del)(struct bnx2x *bp,
330 struct bnx2x_vlan_mac_obj *o,
331 union bnx2x_classification_ramrod_data *data);
334 * Checks if DEL-ramrod with the given params may be performed.
336 * @return true if the element may be deleted
338 bool (*check_move)(struct bnx2x *bp,
339 struct bnx2x_vlan_mac_obj *src_o,
340 struct bnx2x_vlan_mac_obj *dst_o,
341 union bnx2x_classification_ramrod_data *data);
344 * Update the relevant credit object(s) (consume/return
347 bool (*get_credit)(struct bnx2x_vlan_mac_obj *o);
348 bool (*put_credit)(struct bnx2x_vlan_mac_obj *o);
349 bool (*get_cam_offset)(struct bnx2x_vlan_mac_obj *o, int *offset);
350 bool (*put_cam_offset)(struct bnx2x_vlan_mac_obj *o, int offset);
353 * Configures one rule in the ramrod data buffer.
355 void (*set_one_rule)(struct bnx2x *bp,
356 struct bnx2x_vlan_mac_obj *o,
357 struct bnx2x_exeq_elem *elem, int rule_idx,
361 * Delete all configured elements having the given
362 * vlan_mac_flags specification. Assumes no pending for
363 * execution commands. Will schedule all all currently
364 * configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
365 * specification for deletion and will use the given
366 * ramrod_flags for the last DEL operation.
370 * @param ramrod_flags RAMROD_XX flags
372 * @return 0 if the last operation has completed successfully
373 * and there are no more elements left, positive value
374 * if there are pending for completion commands,
375 * negative value in case of failure.
377 int (*delete_all)(struct bnx2x *bp,
378 struct bnx2x_vlan_mac_obj *o,
379 unsigned long *vlan_mac_flags,
380 unsigned long *ramrod_flags);
383 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
384 * configured elements list.
387 * @param p Command parameters (RAMROD_COMP_WAIT bit in
388 * ramrod_flags is only taken into an account)
389 * @param ppos a pointer to the cooky that should be given back in the
390 * next call to make function handle the next element. If
391 * *ppos is set to NULL it will restart the iterator.
392 * If returned *ppos == NULL this means that the last
393 * element has been handled.
397 int (*restore)(struct bnx2x *bp,
398 struct bnx2x_vlan_mac_ramrod_params *p,
399 struct bnx2x_vlan_mac_registry_elem **ppos);
402 * Should be called on a completion arival.
406 * @param cqe Completion element we are handling
407 * @param ramrod_flags if RAMROD_CONT is set the next bulk of
408 * pending commands will be executed.
409 * RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
410 * may also be set if needed.
412 * @return 0 if there are neither pending nor waiting for
413 * completion commands. Positive value if there are
414 * pending for execution or for completion commands.
415 * Negative value in case of an error (including an
418 int (*complete)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
419 union event_ring_elem *cqe,
420 unsigned long *ramrod_flags);
423 * Wait for completion of all commands. Don't schedule new ones,
424 * just wait. It assumes that the completion code will schedule
427 int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o);
431 BNX2X_LLH_CAM_ISCSI_ETH_LINE = 0,
432 BNX2X_LLH_CAM_ETH_LINE,
433 BNX2X_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2
436 void bnx2x_set_mac_in_nig(struct bnx2x *bp,
437 bool add, unsigned char *dev_addr, int index);
439 /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
441 /* RX_MODE ramrod spesial flags: set in rx_mode_flags field in
442 * a bnx2x_rx_mode_ramrod_params.
445 BNX2X_RX_MODE_FCOE_ETH,
446 BNX2X_RX_MODE_ISCSI_ETH,
450 BNX2X_ACCEPT_UNICAST,
451 BNX2X_ACCEPT_MULTICAST,
452 BNX2X_ACCEPT_ALL_UNICAST,
453 BNX2X_ACCEPT_ALL_MULTICAST,
454 BNX2X_ACCEPT_BROADCAST,
455 BNX2X_ACCEPT_UNMATCHED,
456 BNX2X_ACCEPT_ANY_VLAN
459 struct bnx2x_rx_mode_ramrod_params {
460 struct bnx2x_rx_mode_obj *rx_mode_obj;
461 unsigned long *pstate;
466 unsigned long ramrod_flags;
467 unsigned long rx_mode_flags;
470 * rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
471 * a tstorm_eth_mac_filter_config (e1x).
474 dma_addr_t rdata_mapping;
476 /* Rx mode settings */
477 unsigned long rx_accept_flags;
479 /* internal switching settings */
480 unsigned long tx_accept_flags;
483 struct bnx2x_rx_mode_obj {
484 int (*config_rx_mode)(struct bnx2x *bp,
485 struct bnx2x_rx_mode_ramrod_params *p);
487 int (*wait_comp)(struct bnx2x *bp,
488 struct bnx2x_rx_mode_ramrod_params *p);
491 /********************** Set multicast group ***********************************/
493 struct bnx2x_mcast_list_elem {
494 struct list_head link;
498 union bnx2x_mcast_config_data {
500 u8 bin; /* used in a RESTORE flow */
503 struct bnx2x_mcast_ramrod_params {
504 struct bnx2x_mcast_obj *mcast_obj;
506 /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
507 unsigned long ramrod_flags;
509 struct list_head mcast_list; /* list of struct bnx2x_mcast_list_elem */
511 * - rename it to macs_num.
512 * - Add a new command type for handling pending commands
513 * (remove "zero semantics").
515 * Length of mcast_list. If zero and ADD_CONT command - post
523 BNX2X_MCAST_CMD_CONT,
525 BNX2X_MCAST_CMD_RESTORE,
528 struct bnx2x_mcast_obj {
529 struct bnx2x_raw_obj raw;
533 #define BNX2X_MCAST_BINS_NUM 256
534 #define BNX2X_MCAST_VEC_SZ (BNX2X_MCAST_BINS_NUM / 64)
535 u64 vec[BNX2X_MCAST_VEC_SZ];
537 /** Number of BINs to clear. Should be updated
538 * immediately when a command arrives in order to
539 * properly create DEL commands.
545 struct list_head macs;
550 /* Pending commands */
551 struct list_head pending_cmds_head;
553 /* A state that is set in raw.pstate, when there are pending commands */
556 /* Maximal number of mcast MACs configured in one command */
559 /* Total number of currently pending MACs to configure: both
560 * in the pending commands list and in the current command.
562 int total_pending_num;
567 * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above)
569 int (*config_mcast)(struct bnx2x *bp,
570 struct bnx2x_mcast_ramrod_params *p, int cmd);
573 * Fills the ramrod data during the RESTORE flow.
577 * @param start_idx Registry index to start from
578 * @param rdata_idx Index in the ramrod data to start from
580 * @return -1 if we handled the whole registry or index of the last
581 * handled registry element.
583 int (*hdl_restore)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
584 int start_bin, int *rdata_idx);
586 int (*enqueue_cmd)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
587 struct bnx2x_mcast_ramrod_params *p, int cmd);
589 void (*set_one_rule)(struct bnx2x *bp,
590 struct bnx2x_mcast_obj *o, int idx,
591 union bnx2x_mcast_config_data *cfg_data, int cmd);
593 /** Checks if there are more mcast MACs to be set or a previous
594 * command is still pending.
596 bool (*check_pending)(struct bnx2x_mcast_obj *o);
599 * Set/Clear/Check SCHEDULED state of the object
601 void (*set_sched)(struct bnx2x_mcast_obj *o);
602 void (*clear_sched)(struct bnx2x_mcast_obj *o);
603 bool (*check_sched)(struct bnx2x_mcast_obj *o);
605 /* Wait until all pending commands complete */
606 int (*wait_comp)(struct bnx2x *bp, struct bnx2x_mcast_obj *o);
609 * Handle the internal object counters needed for proper
610 * commands handling. Checks that the provided parameters are
613 int (*validate)(struct bnx2x *bp,
614 struct bnx2x_mcast_ramrod_params *p, int cmd);
617 * Restore the values of internal counters in case of a failure.
619 void (*revert)(struct bnx2x *bp,
620 struct bnx2x_mcast_ramrod_params *p,
623 int (*get_registry_size)(struct bnx2x_mcast_obj *o);
624 void (*set_registry_size)(struct bnx2x_mcast_obj *o, int n);
627 /*************************** Credit handling **********************************/
628 struct bnx2x_credit_pool_obj {
630 /* Current amount of credit in the pool */
633 /* Maximum allowed credit. put() will check against it. */
637 * Allocate a pool table statically.
639 * Currently the mamimum allowed size is MAX_MAC_CREDIT_E2(272)
641 * The set bit in the table will mean that the entry is available.
643 #define BNX2X_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64)
644 u64 pool_mirror[BNX2X_POOL_VEC_SIZE];
646 /* Base pool offset (initialized differently */
647 int base_pool_offset;
650 * Get the next free pool entry.
652 * @return true if there was a free entry in the pool
654 bool (*get_entry)(struct bnx2x_credit_pool_obj *o, int *entry);
657 * Return the entry back to the pool.
659 * @return true if entry is legal and has been successfully
660 * returned to the pool.
662 bool (*put_entry)(struct bnx2x_credit_pool_obj *o, int entry);
665 * Get the requested amount of credit from the pool.
667 * @param cnt Amount of requested credit
668 * @return true if the operation is successful
670 bool (*get)(struct bnx2x_credit_pool_obj *o, int cnt);
673 * Returns the credit to the pool.
675 * @param cnt Amount of credit to return
676 * @return true if the operation is successful
678 bool (*put)(struct bnx2x_credit_pool_obj *o, int cnt);
681 * Reads the current amount of credit.
683 int (*check)(struct bnx2x_credit_pool_obj *o);
686 /*************************** RSS configuration ********************************/
688 /* RSS_MODE bits are mutually exclusive */
689 BNX2X_RSS_MODE_DISABLED,
690 BNX2X_RSS_MODE_REGULAR,
692 BNX2X_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */
702 struct bnx2x_config_rss_params {
703 struct bnx2x_rss_config_obj *rss_obj;
705 /* may have RAMROD_COMP_WAIT set only */
706 unsigned long ramrod_flags;
708 /* BNX2X_RSS_X bits */
709 unsigned long rss_flags;
711 /* Number hash bits to take into an account */
714 /* Indirection table */
715 u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
717 /* RSS hash values */
720 /* valid only iff BNX2X_RSS_UPDATE_TOE is set */
724 struct bnx2x_rss_config_obj {
725 struct bnx2x_raw_obj raw;
727 /* RSS engine to use */
730 /* Last configured indirection table */
731 u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
733 /* flags for enabling 4-tupple hash on UDP */
737 int (*config_rss)(struct bnx2x *bp,
738 struct bnx2x_config_rss_params *p);
741 /*********************** Queue state update ***********************************/
743 /* UPDATE command options */
745 BNX2X_Q_UPDATE_IN_VLAN_REM,
746 BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG,
747 BNX2X_Q_UPDATE_OUT_VLAN_REM,
748 BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG,
749 BNX2X_Q_UPDATE_ANTI_SPOOF,
750 BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG,
751 BNX2X_Q_UPDATE_ACTIVATE,
752 BNX2X_Q_UPDATE_ACTIVATE_CHNG,
753 BNX2X_Q_UPDATE_DEF_VLAN_EN,
754 BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG,
755 BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG,
756 BNX2X_Q_UPDATE_SILENT_VLAN_REM
759 /* Allowed Queue states */
762 BNX2X_Q_STATE_INITIALIZED,
763 BNX2X_Q_STATE_ACTIVE,
764 BNX2X_Q_STATE_MULTI_COS,
765 BNX2X_Q_STATE_MCOS_TERMINATED,
766 BNX2X_Q_STATE_INACTIVE,
767 BNX2X_Q_STATE_STOPPED,
768 BNX2X_Q_STATE_TERMINATED,
773 /* Allowed commands */
774 enum bnx2x_queue_cmd {
777 BNX2X_Q_CMD_SETUP_TX_ONLY,
778 BNX2X_Q_CMD_DEACTIVATE,
779 BNX2X_Q_CMD_ACTIVATE,
781 BNX2X_Q_CMD_UPDATE_TPA,
784 BNX2X_Q_CMD_TERMINATE,
789 /* queue SETUP + INIT flags */
792 BNX2X_Q_FLG_TPA_IPV6,
795 BNX2X_Q_FLG_ZERO_STATS,
804 BNX2X_Q_FLG_LEADING_RSS,
806 BNX2X_Q_FLG_DEF_VLAN,
807 BNX2X_Q_FLG_TX_SWITCH,
809 BNX2X_Q_FLG_ANTI_SPOOF,
810 BNX2X_Q_FLG_SILENT_VLAN_REM,
811 BNX2X_Q_FLG_FORCE_DEFAULT_PRI
814 /* Queue type options: queue type may be a compination of below. */
816 /** TODO: Consider moving both these flags into the init()
823 #define BNX2X_PRIMARY_CID_INDEX 0
824 #define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */
825 #define BNX2X_MULTI_TX_COS_E2_E3A0 2
826 #define BNX2X_MULTI_TX_COS_E3B0 3
827 #define BNX2X_MULTI_TX_COS 3 /* Maximum possible */
830 struct bnx2x_queue_init_params {
845 /* CID context in the host memory */
846 struct eth_context *cxts[BNX2X_MULTI_TX_COS];
848 /* maximum number of cos supported by hardware */
852 struct bnx2x_queue_terminate_params {
853 /* index within the tx_only cids of this queue object */
857 struct bnx2x_queue_cfc_del_params {
858 /* index within the tx_only cids of this queue object */
862 struct bnx2x_queue_update_params {
863 unsigned long update_flags; /* BNX2X_Q_UPDATE_XX bits */
865 u16 silent_removal_value;
866 u16 silent_removal_mask;
867 /* index within the tx_only cids of this queue object */
871 struct rxq_pause_params {
876 u16 sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */
877 u16 sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */
882 struct bnx2x_general_setup_params {
883 /* valid iff BNX2X_Q_FLG_STATS */
891 struct bnx2x_rxq_setup_params {
896 dma_addr_t rcq_np_map;
903 /* valid iff BNX2X_Q_FLG_TPA */
910 /* valid iff BNX2X_Q_FLG_MCAST */
917 /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
918 u16 silent_removal_value;
919 u16 silent_removal_mask;
922 struct bnx2x_txq_setup_params {
928 u8 cos; /* valid iff BNX2X_Q_FLG_COS */
930 /* equals to the leading rss client id, used for TX classification*/
931 u8 tss_leading_cl_id;
933 /* valid iff BNX2X_Q_FLG_DEF_VLAN */
937 struct bnx2x_queue_setup_params {
938 struct bnx2x_general_setup_params gen_params;
939 struct bnx2x_txq_setup_params txq_params;
940 struct bnx2x_rxq_setup_params rxq_params;
941 struct rxq_pause_params pause_params;
945 struct bnx2x_queue_setup_tx_only_params {
946 struct bnx2x_general_setup_params gen_params;
947 struct bnx2x_txq_setup_params txq_params;
949 /* index within the tx_only cids of this queue object */
953 struct bnx2x_queue_state_params {
954 struct bnx2x_queue_sp_obj *q_obj;
956 /* Current command */
957 enum bnx2x_queue_cmd cmd;
959 /* may have RAMROD_COMP_WAIT set only */
960 unsigned long ramrod_flags;
962 /* Params according to the current command */
964 struct bnx2x_queue_update_params update;
965 struct bnx2x_queue_setup_params setup;
966 struct bnx2x_queue_init_params init;
967 struct bnx2x_queue_setup_tx_only_params tx_only;
968 struct bnx2x_queue_terminate_params terminate;
969 struct bnx2x_queue_cfc_del_params cfc_del;
973 struct bnx2x_viflist_params {
978 struct bnx2x_queue_sp_obj {
979 u32 cids[BNX2X_MULTI_TX_COS];
984 * number of traffic classes supported by queue.
985 * The primary connection of the queue suppotrs the first traffic
986 * class. Any further traffic class is suppoted by a tx-only
989 * Therefore max_cos is also a number of valid entries in the cids
993 u8 num_tx_only, next_tx_only;
995 enum bnx2x_q_state state, next_state;
997 /* bits from enum bnx2x_q_type */
1000 /* BNX2X_Q_CMD_XX bits. This object implements "one
1001 * pending" paradigm but for debug and tracing purposes it's
1002 * more convinient to have different bits for different
1005 unsigned long pending;
1007 /* Buffer to use as a ramrod data and its mapping */
1009 dma_addr_t rdata_mapping;
1012 * Performs one state change according to the given parameters.
1014 * @return 0 in case of success and negative value otherwise.
1016 int (*send_cmd)(struct bnx2x *bp,
1017 struct bnx2x_queue_state_params *params);
1020 * Sets the pending bit according to the requested transition.
1022 int (*set_pending)(struct bnx2x_queue_sp_obj *o,
1023 struct bnx2x_queue_state_params *params);
1026 * Checks that the requested state transition is legal.
1028 int (*check_transition)(struct bnx2x *bp,
1029 struct bnx2x_queue_sp_obj *o,
1030 struct bnx2x_queue_state_params *params);
1033 * Completes the pending command.
1035 int (*complete_cmd)(struct bnx2x *bp,
1036 struct bnx2x_queue_sp_obj *o,
1037 enum bnx2x_queue_cmd);
1039 int (*wait_comp)(struct bnx2x *bp,
1040 struct bnx2x_queue_sp_obj *o,
1041 enum bnx2x_queue_cmd cmd);
1044 /********************** Function state update *********************************/
1045 /* Allowed Function states */
1046 enum bnx2x_func_state {
1047 BNX2X_F_STATE_RESET,
1048 BNX2X_F_STATE_INITIALIZED,
1049 BNX2X_F_STATE_STARTED,
1050 BNX2X_F_STATE_TX_STOPPED,
1054 /* Allowed Function commands */
1055 enum bnx2x_func_cmd {
1056 BNX2X_F_CMD_HW_INIT,
1059 BNX2X_F_CMD_HW_RESET,
1060 BNX2X_F_CMD_AFEX_UPDATE,
1061 BNX2X_F_CMD_AFEX_VIFLISTS,
1062 BNX2X_F_CMD_TX_STOP,
1063 BNX2X_F_CMD_TX_START,
1067 struct bnx2x_func_hw_init_params {
1068 /* A load phase returned by MCP.
1071 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1072 * FW_MSG_CODE_DRV_LOAD_COMMON
1073 * FW_MSG_CODE_DRV_LOAD_PORT
1074 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1079 struct bnx2x_func_hw_reset_params {
1080 /* A load phase returned by MCP.
1083 * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1084 * FW_MSG_CODE_DRV_LOAD_COMMON
1085 * FW_MSG_CODE_DRV_LOAD_PORT
1086 * FW_MSG_CODE_DRV_LOAD_FUNCTION
1091 struct bnx2x_func_start_params {
1092 /* Multi Function mode:
1094 * - Switch Dependent
1095 * - Switch Independent
1099 /* Switch Dependent mode outer VLAN tag */
1102 /* Function cos mode */
1103 u8 network_cos_mode;
1106 struct bnx2x_func_afex_update_params {
1108 u16 afex_default_vlan;
1109 u8 allowed_priorities;
1112 struct bnx2x_func_afex_viflists_params {
1115 u8 afex_vif_list_command;
1118 struct bnx2x_func_tx_start_params {
1119 struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES];
1122 u8 dont_add_pri_0_en;
1125 struct bnx2x_func_state_params {
1126 struct bnx2x_func_sp_obj *f_obj;
1128 /* Current command */
1129 enum bnx2x_func_cmd cmd;
1131 /* may have RAMROD_COMP_WAIT set only */
1132 unsigned long ramrod_flags;
1134 /* Params according to the current command */
1136 struct bnx2x_func_hw_init_params hw_init;
1137 struct bnx2x_func_hw_reset_params hw_reset;
1138 struct bnx2x_func_start_params start;
1139 struct bnx2x_func_afex_update_params afex_update;
1140 struct bnx2x_func_afex_viflists_params afex_viflists;
1141 struct bnx2x_func_tx_start_params tx_start;
1145 struct bnx2x_func_sp_drv_ops {
1146 /* Init tool + runtime initialization:
1148 * - Common (per Path)
1152 int (*init_hw_cmn_chip)(struct bnx2x *bp);
1153 int (*init_hw_cmn)(struct bnx2x *bp);
1154 int (*init_hw_port)(struct bnx2x *bp);
1155 int (*init_hw_func)(struct bnx2x *bp);
1157 /* Reset Function HW: Common, Port, Function phases. */
1158 void (*reset_hw_cmn)(struct bnx2x *bp);
1159 void (*reset_hw_port)(struct bnx2x *bp);
1160 void (*reset_hw_func)(struct bnx2x *bp);
1162 /* Init/Free GUNZIP resources */
1163 int (*gunzip_init)(struct bnx2x *bp);
1164 void (*gunzip_end)(struct bnx2x *bp);
1166 /* Prepare/Release FW resources */
1167 int (*init_fw)(struct bnx2x *bp);
1168 void (*release_fw)(struct bnx2x *bp);
1171 struct bnx2x_func_sp_obj {
1172 enum bnx2x_func_state state, next_state;
1174 /* BNX2X_FUNC_CMD_XX bits. This object implements "one
1175 * pending" paradigm but for debug and tracing purposes it's
1176 * more convinient to have different bits for different
1179 unsigned long pending;
1181 /* Buffer to use as a ramrod data and its mapping */
1183 dma_addr_t rdata_mapping;
1185 /* Buffer to use as a afex ramrod data and its mapping.
1186 * This can't be same rdata as above because afex ramrod requests
1187 * can arrive to the object in parallel to other ramrod requests.
1190 dma_addr_t afex_rdata_mapping;
1192 /* this mutex validates that when pending flag is taken, the next
1193 * ramrod to be sent will be the one set the pending bit
1195 struct mutex one_pending_mutex;
1197 /* Driver interface */
1198 struct bnx2x_func_sp_drv_ops *drv;
1201 * Performs one state change according to the given parameters.
1203 * @return 0 in case of success and negative value otherwise.
1205 int (*send_cmd)(struct bnx2x *bp,
1206 struct bnx2x_func_state_params *params);
1209 * Checks that the requested state transition is legal.
1211 int (*check_transition)(struct bnx2x *bp,
1212 struct bnx2x_func_sp_obj *o,
1213 struct bnx2x_func_state_params *params);
1216 * Completes the pending command.
1218 int (*complete_cmd)(struct bnx2x *bp,
1219 struct bnx2x_func_sp_obj *o,
1220 enum bnx2x_func_cmd cmd);
1222 int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o,
1223 enum bnx2x_func_cmd cmd);
1226 /********************** Interfaces ********************************************/
1227 /* Queueable objects set */
1228 union bnx2x_qable_obj {
1229 struct bnx2x_vlan_mac_obj vlan_mac;
1231 /************** Function state update *********/
1232 void bnx2x_init_func_obj(struct bnx2x *bp,
1233 struct bnx2x_func_sp_obj *obj,
1234 void *rdata, dma_addr_t rdata_mapping,
1235 void *afex_rdata, dma_addr_t afex_rdata_mapping,
1236 struct bnx2x_func_sp_drv_ops *drv_iface);
1238 int bnx2x_func_state_change(struct bnx2x *bp,
1239 struct bnx2x_func_state_params *params);
1241 enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp,
1242 struct bnx2x_func_sp_obj *o);
1243 /******************* Queue State **************/
1244 void bnx2x_init_queue_obj(struct bnx2x *bp,
1245 struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids,
1246 u8 cid_cnt, u8 func_id, void *rdata,
1247 dma_addr_t rdata_mapping, unsigned long type);
1249 int bnx2x_queue_state_change(struct bnx2x *bp,
1250 struct bnx2x_queue_state_params *params);
1252 /********************* VLAN-MAC ****************/
1253 void bnx2x_init_mac_obj(struct bnx2x *bp,
1254 struct bnx2x_vlan_mac_obj *mac_obj,
1255 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1256 dma_addr_t rdata_mapping, int state,
1257 unsigned long *pstate, bnx2x_obj_type type,
1258 struct bnx2x_credit_pool_obj *macs_pool);
1260 void bnx2x_init_vlan_obj(struct bnx2x *bp,
1261 struct bnx2x_vlan_mac_obj *vlan_obj,
1262 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1263 dma_addr_t rdata_mapping, int state,
1264 unsigned long *pstate, bnx2x_obj_type type,
1265 struct bnx2x_credit_pool_obj *vlans_pool);
1267 void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
1268 struct bnx2x_vlan_mac_obj *vlan_mac_obj,
1269 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1270 dma_addr_t rdata_mapping, int state,
1271 unsigned long *pstate, bnx2x_obj_type type,
1272 struct bnx2x_credit_pool_obj *macs_pool,
1273 struct bnx2x_credit_pool_obj *vlans_pool);
1275 int bnx2x_config_vlan_mac(struct bnx2x *bp,
1276 struct bnx2x_vlan_mac_ramrod_params *p);
1278 int bnx2x_vlan_mac_move(struct bnx2x *bp,
1279 struct bnx2x_vlan_mac_ramrod_params *p,
1280 struct bnx2x_vlan_mac_obj *dest_o);
1282 /********************* RX MODE ****************/
1284 void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
1285 struct bnx2x_rx_mode_obj *o);
1288 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
1290 * @p: Command parameters
1292 * Return: 0 - if operation was successfull and there is no pending completions,
1293 * positive number - if there are pending completions,
1294 * negative - if there were errors
1296 int bnx2x_config_rx_mode(struct bnx2x *bp,
1297 struct bnx2x_rx_mode_ramrod_params *p);
1299 /****************** MULTICASTS ****************/
1301 void bnx2x_init_mcast_obj(struct bnx2x *bp,
1302 struct bnx2x_mcast_obj *mcast_obj,
1303 u8 mcast_cl_id, u32 mcast_cid, u8 func_id,
1304 u8 engine_id, void *rdata, dma_addr_t rdata_mapping,
1305 int state, unsigned long *pstate,
1306 bnx2x_obj_type type);
1309 * bnx2x_config_mcast - Configure multicast MACs list.
1311 * @cmd: command to execute: BNX2X_MCAST_CMD_X
1313 * May configure a new list
1314 * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up
1315 * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current
1316 * configuration, continue to execute the pending commands
1317 * (BNX2X_MCAST_CMD_CONT).
1319 * If previous command is still pending or if number of MACs to
1320 * configure is more that maximum number of MACs in one command,
1321 * the current command will be enqueued to the tail of the
1322 * pending commands list.
1324 * Return: 0 is operation was successfull and there are no pending completions,
1325 * negative if there were errors, positive if there are pending
1328 int bnx2x_config_mcast(struct bnx2x *bp,
1329 struct bnx2x_mcast_ramrod_params *p, int cmd);
1331 /****************** CREDIT POOL ****************/
1332 void bnx2x_init_mac_credit_pool(struct bnx2x *bp,
1333 struct bnx2x_credit_pool_obj *p, u8 func_id,
1335 void bnx2x_init_vlan_credit_pool(struct bnx2x *bp,
1336 struct bnx2x_credit_pool_obj *p, u8 func_id,
1340 /****************** RSS CONFIGURATION ****************/
1341 void bnx2x_init_rss_config_obj(struct bnx2x *bp,
1342 struct bnx2x_rss_config_obj *rss_obj,
1343 u8 cl_id, u32 cid, u8 func_id, u8 engine_id,
1344 void *rdata, dma_addr_t rdata_mapping,
1345 int state, unsigned long *pstate,
1346 bnx2x_obj_type type);
1349 * bnx2x_config_rss - Updates RSS configuration according to provided parameters
1351 * Return: 0 in case of success
1353 int bnx2x_config_rss(struct bnx2x *bp,
1354 struct bnx2x_config_rss_params *p);
1357 * bnx2x_get_rss_ind_table - Return the current ind_table configuration.
1359 * @ind_table: buffer to fill with the current indirection
1360 * table content. Should be at least
1361 * T_ETH_INDIRECTION_TABLE_SIZE bytes long.
1363 void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj,
1366 #endif /* BNX2X_SP_VERBS */