14ad79e13SYuval Mintz /* bnx2x_sp.h: Qlogic Everest network driver. 2619c5cb6SVlad Zolotarov * 34ad79e13SYuval Mintz * Copyright 2011-2013 Broadcom Corporation 44ad79e13SYuval Mintz * Copyright (c) 2014 QLogic Corporation 54ad79e13SYuval Mintz * All rights reserved 6619c5cb6SVlad Zolotarov * 74ad79e13SYuval Mintz * Unless you and Qlogic execute a separate written software license 8619c5cb6SVlad Zolotarov * agreement governing use of this software, this software is licensed to you 9619c5cb6SVlad Zolotarov * under the terms of the GNU General Public License version 2, available 104ad79e13SYuval Mintz * at http://www.gnu.org/licenses/gpl-2.0.html (the "GPL"). 11619c5cb6SVlad Zolotarov * 12619c5cb6SVlad Zolotarov * Notwithstanding the above, under no circumstances may you combine this 134ad79e13SYuval Mintz * software in any way with any other Qlogic software provided under a 144ad79e13SYuval Mintz * license other than the GPL, without Qlogic's express prior written 15619c5cb6SVlad Zolotarov * consent. 16619c5cb6SVlad Zolotarov * 1708f6dd89SAriel Elior * Maintained by: Ariel Elior <ariel.elior@qlogic.com> 18619c5cb6SVlad Zolotarov * Written by: Vladislav Zolotarov 19619c5cb6SVlad Zolotarov * 20619c5cb6SVlad Zolotarov */ 21619c5cb6SVlad Zolotarov #ifndef BNX2X_SP_VERBS 22619c5cb6SVlad Zolotarov #define BNX2X_SP_VERBS 23042181f5SVladislav Zolotarov 24619c5cb6SVlad Zolotarov struct bnx2x; 25619c5cb6SVlad Zolotarov struct eth_context; 26042181f5SVladislav Zolotarov 27619c5cb6SVlad Zolotarov /* Bits representing general command's configuration */ 28619c5cb6SVlad Zolotarov enum { 29619c5cb6SVlad Zolotarov RAMROD_TX, 30619c5cb6SVlad Zolotarov RAMROD_RX, 31619c5cb6SVlad Zolotarov /* Wait until all pending commands complete */ 32619c5cb6SVlad Zolotarov RAMROD_COMP_WAIT, 33619c5cb6SVlad Zolotarov /* Don't send a ramrod, only update a registry */ 34619c5cb6SVlad Zolotarov RAMROD_DRV_CLR_ONLY, 35619c5cb6SVlad Zolotarov /* Configure HW according to the current object state */ 36619c5cb6SVlad Zolotarov RAMROD_RESTORE, 37619c5cb6SVlad Zolotarov /* Execute the next command now */ 38619c5cb6SVlad Zolotarov RAMROD_EXEC, 3916a5fd92SYuval Mintz /* Don't add a new command and continue execution of postponed 40619c5cb6SVlad Zolotarov * commands. If not set a new command will be added to the 41619c5cb6SVlad Zolotarov * pending commands list. 42619c5cb6SVlad Zolotarov */ 43619c5cb6SVlad Zolotarov RAMROD_CONT, 4455c11941SMerav Sicron /* If there is another pending ramrod, wait until it finishes and 4555c11941SMerav Sicron * re-try to submit this one. This flag can be set only in sleepable 4655c11941SMerav Sicron * context, and should not be set from the context that completes the 4755c11941SMerav Sicron * ramrods as deadlock will occur. 4855c11941SMerav Sicron */ 4955c11941SMerav Sicron RAMROD_RETRY, 50619c5cb6SVlad Zolotarov }; 51042181f5SVladislav Zolotarov 52619c5cb6SVlad Zolotarov typedef enum { 53619c5cb6SVlad Zolotarov BNX2X_OBJ_TYPE_RX, 54619c5cb6SVlad Zolotarov BNX2X_OBJ_TYPE_TX, 55619c5cb6SVlad Zolotarov BNX2X_OBJ_TYPE_RX_TX, 56619c5cb6SVlad Zolotarov } bnx2x_obj_type; 57042181f5SVladislav Zolotarov 582de67439SYuval Mintz /* Public slow path states */ 59619c5cb6SVlad Zolotarov enum { 60619c5cb6SVlad Zolotarov BNX2X_FILTER_MAC_PENDING, 61619c5cb6SVlad Zolotarov BNX2X_FILTER_VLAN_PENDING, 62619c5cb6SVlad Zolotarov BNX2X_FILTER_VLAN_MAC_PENDING, 63619c5cb6SVlad Zolotarov BNX2X_FILTER_RX_MODE_PENDING, 64619c5cb6SVlad Zolotarov BNX2X_FILTER_RX_MODE_SCHED, 65619c5cb6SVlad Zolotarov BNX2X_FILTER_ISCSI_ETH_START_SCHED, 66619c5cb6SVlad Zolotarov BNX2X_FILTER_ISCSI_ETH_STOP_SCHED, 67619c5cb6SVlad Zolotarov BNX2X_FILTER_FCOE_ETH_START_SCHED, 68619c5cb6SVlad Zolotarov BNX2X_FILTER_FCOE_ETH_STOP_SCHED, 69619c5cb6SVlad Zolotarov BNX2X_FILTER_MCAST_PENDING, 70619c5cb6SVlad Zolotarov BNX2X_FILTER_MCAST_SCHED, 71619c5cb6SVlad Zolotarov BNX2X_FILTER_RSS_CONF_PENDING, 72a3348722SBarak Witkowski BNX2X_AFEX_FCOE_Q_UPDATE_PENDING, 73a3348722SBarak Witkowski BNX2X_AFEX_PENDING_VIFSET_MCP_ACK 74619c5cb6SVlad Zolotarov }; 75042181f5SVladislav Zolotarov 76619c5cb6SVlad Zolotarov struct bnx2x_raw_obj { 77619c5cb6SVlad Zolotarov u8 func_id; 78042181f5SVladislav Zolotarov 79619c5cb6SVlad Zolotarov /* Queue params */ 80619c5cb6SVlad Zolotarov u8 cl_id; 81619c5cb6SVlad Zolotarov u32 cid; 82042181f5SVladislav Zolotarov 83619c5cb6SVlad Zolotarov /* Ramrod data buffer params */ 84619c5cb6SVlad Zolotarov void *rdata; 85619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping; 86619c5cb6SVlad Zolotarov 87619c5cb6SVlad Zolotarov /* Ramrod state params */ 88619c5cb6SVlad Zolotarov int state; /* "ramrod is pending" state bit */ 89619c5cb6SVlad Zolotarov unsigned long *pstate; /* pointer to state buffer */ 90619c5cb6SVlad Zolotarov 91619c5cb6SVlad Zolotarov bnx2x_obj_type obj_type; 92619c5cb6SVlad Zolotarov 93619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, 94619c5cb6SVlad Zolotarov struct bnx2x_raw_obj *o); 95619c5cb6SVlad Zolotarov 96619c5cb6SVlad Zolotarov bool (*check_pending)(struct bnx2x_raw_obj *o); 97619c5cb6SVlad Zolotarov void (*clear_pending)(struct bnx2x_raw_obj *o); 98619c5cb6SVlad Zolotarov void (*set_pending)(struct bnx2x_raw_obj *o); 99619c5cb6SVlad Zolotarov }; 100619c5cb6SVlad Zolotarov 101619c5cb6SVlad Zolotarov /************************* VLAN-MAC commands related parameters ***************/ 102619c5cb6SVlad Zolotarov struct bnx2x_mac_ramrod_data { 103619c5cb6SVlad Zolotarov u8 mac[ETH_ALEN]; 10491226790SDmitry Kravkov u8 is_inner_mac; 105619c5cb6SVlad Zolotarov }; 106619c5cb6SVlad Zolotarov 107619c5cb6SVlad Zolotarov struct bnx2x_vlan_ramrod_data { 108619c5cb6SVlad Zolotarov u16 vlan; 109619c5cb6SVlad Zolotarov }; 110619c5cb6SVlad Zolotarov 111619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_data { 112619c5cb6SVlad Zolotarov u8 mac[ETH_ALEN]; 11391226790SDmitry Kravkov u8 is_inner_mac; 114619c5cb6SVlad Zolotarov u16 vlan; 115619c5cb6SVlad Zolotarov }; 116619c5cb6SVlad Zolotarov 117619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data { 118619c5cb6SVlad Zolotarov struct bnx2x_mac_ramrod_data mac; 119619c5cb6SVlad Zolotarov struct bnx2x_vlan_ramrod_data vlan; 120619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_data vlan_mac; 121619c5cb6SVlad Zolotarov }; 122619c5cb6SVlad Zolotarov 123619c5cb6SVlad Zolotarov /* VLAN_MAC commands */ 124619c5cb6SVlad Zolotarov enum bnx2x_vlan_mac_cmd { 125619c5cb6SVlad Zolotarov BNX2X_VLAN_MAC_ADD, 126619c5cb6SVlad Zolotarov BNX2X_VLAN_MAC_DEL, 127619c5cb6SVlad Zolotarov BNX2X_VLAN_MAC_MOVE, 128619c5cb6SVlad Zolotarov }; 129619c5cb6SVlad Zolotarov 130619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_data { 131619c5cb6SVlad Zolotarov /* Requested command: BNX2X_VLAN_MAC_XX */ 132619c5cb6SVlad Zolotarov enum bnx2x_vlan_mac_cmd cmd; 13316a5fd92SYuval Mintz /* used to contain the data related vlan_mac_flags bits from 134619c5cb6SVlad Zolotarov * ramrod parameters. 135619c5cb6SVlad Zolotarov */ 136619c5cb6SVlad Zolotarov unsigned long vlan_mac_flags; 137619c5cb6SVlad Zolotarov 138619c5cb6SVlad Zolotarov /* Needed for MOVE command */ 139619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *target_obj; 140619c5cb6SVlad Zolotarov 141619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data u; 142619c5cb6SVlad Zolotarov }; 143619c5cb6SVlad Zolotarov 144619c5cb6SVlad Zolotarov /*************************** Exe Queue obj ************************************/ 145619c5cb6SVlad Zolotarov union bnx2x_exe_queue_cmd_data { 146619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_data vlan_mac; 147619c5cb6SVlad Zolotarov 148619c5cb6SVlad Zolotarov struct { 149619c5cb6SVlad Zolotarov /* TODO */ 150619c5cb6SVlad Zolotarov } mcast; 151619c5cb6SVlad Zolotarov }; 152619c5cb6SVlad Zolotarov 153619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem { 154619c5cb6SVlad Zolotarov struct list_head link; 155619c5cb6SVlad Zolotarov 156619c5cb6SVlad Zolotarov /* Length of this element in the exe_chunk. */ 157619c5cb6SVlad Zolotarov int cmd_len; 158619c5cb6SVlad Zolotarov 159619c5cb6SVlad Zolotarov union bnx2x_exe_queue_cmd_data cmd_data; 160619c5cb6SVlad Zolotarov }; 161619c5cb6SVlad Zolotarov 162619c5cb6SVlad Zolotarov union bnx2x_qable_obj; 163619c5cb6SVlad Zolotarov 164619c5cb6SVlad Zolotarov union bnx2x_exeq_comp_elem { 165619c5cb6SVlad Zolotarov union event_ring_elem *elem; 166619c5cb6SVlad Zolotarov }; 167619c5cb6SVlad Zolotarov 168619c5cb6SVlad Zolotarov struct bnx2x_exe_queue_obj; 169619c5cb6SVlad Zolotarov 170619c5cb6SVlad Zolotarov typedef int (*exe_q_validate)(struct bnx2x *bp, 171619c5cb6SVlad Zolotarov union bnx2x_qable_obj *o, 172619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem *elem); 173619c5cb6SVlad Zolotarov 174460a25cdSYuval Mintz typedef int (*exe_q_remove)(struct bnx2x *bp, 175460a25cdSYuval Mintz union bnx2x_qable_obj *o, 176460a25cdSYuval Mintz struct bnx2x_exeq_elem *elem); 177460a25cdSYuval Mintz 1781aa8b471SBen Hutchings /* Return positive if entry was optimized, 0 - if not, negative 179619c5cb6SVlad Zolotarov * in case of an error. 180619c5cb6SVlad Zolotarov */ 181619c5cb6SVlad Zolotarov typedef int (*exe_q_optimize)(struct bnx2x *bp, 182619c5cb6SVlad Zolotarov union bnx2x_qable_obj *o, 183619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem *elem); 184619c5cb6SVlad Zolotarov typedef int (*exe_q_execute)(struct bnx2x *bp, 185619c5cb6SVlad Zolotarov union bnx2x_qable_obj *o, 186619c5cb6SVlad Zolotarov struct list_head *exe_chunk, 187619c5cb6SVlad Zolotarov unsigned long *ramrod_flags); 188619c5cb6SVlad Zolotarov typedef struct bnx2x_exeq_elem * 189619c5cb6SVlad Zolotarov (*exe_q_get)(struct bnx2x_exe_queue_obj *o, 190619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem *elem); 191619c5cb6SVlad Zolotarov 192619c5cb6SVlad Zolotarov struct bnx2x_exe_queue_obj { 19316a5fd92SYuval Mintz /* Commands pending for an execution. */ 194619c5cb6SVlad Zolotarov struct list_head exe_queue; 195619c5cb6SVlad Zolotarov 19616a5fd92SYuval Mintz /* Commands pending for an completion. */ 197619c5cb6SVlad Zolotarov struct list_head pending_comp; 198619c5cb6SVlad Zolotarov 199619c5cb6SVlad Zolotarov spinlock_t lock; 200619c5cb6SVlad Zolotarov 201619c5cb6SVlad Zolotarov /* Maximum length of commands' list for one execution */ 202619c5cb6SVlad Zolotarov int exe_chunk_len; 203619c5cb6SVlad Zolotarov 204619c5cb6SVlad Zolotarov union bnx2x_qable_obj *owner; 205619c5cb6SVlad Zolotarov 206619c5cb6SVlad Zolotarov /****** Virtual functions ******/ 207619c5cb6SVlad Zolotarov /** 208619c5cb6SVlad Zolotarov * Called before commands execution for commands that are really 209619c5cb6SVlad Zolotarov * going to be executed (after 'optimize'). 210619c5cb6SVlad Zolotarov * 211619c5cb6SVlad Zolotarov * Must run under exe_queue->lock 212619c5cb6SVlad Zolotarov */ 213619c5cb6SVlad Zolotarov exe_q_validate validate; 214619c5cb6SVlad Zolotarov 215460a25cdSYuval Mintz /** 216460a25cdSYuval Mintz * Called before removing pending commands, cleaning allocated 217460a25cdSYuval Mintz * resources (e.g., credits from validate) 218460a25cdSYuval Mintz */ 219460a25cdSYuval Mintz exe_q_remove remove; 220619c5cb6SVlad Zolotarov 221619c5cb6SVlad Zolotarov /** 222619c5cb6SVlad Zolotarov * This will try to cancel the current pending commands list 223619c5cb6SVlad Zolotarov * considering the new command. 224619c5cb6SVlad Zolotarov * 225460a25cdSYuval Mintz * Returns the number of optimized commands or a negative error code 226460a25cdSYuval Mintz * 227619c5cb6SVlad Zolotarov * Must run under exe_queue->lock 228619c5cb6SVlad Zolotarov */ 229619c5cb6SVlad Zolotarov exe_q_optimize optimize; 230619c5cb6SVlad Zolotarov 231619c5cb6SVlad Zolotarov /** 232619c5cb6SVlad Zolotarov * Run the next commands chunk (owner specific). 233619c5cb6SVlad Zolotarov */ 234619c5cb6SVlad Zolotarov exe_q_execute execute; 235619c5cb6SVlad Zolotarov 236619c5cb6SVlad Zolotarov /** 237619c5cb6SVlad Zolotarov * Return the exe_queue element containing the specific command 238619c5cb6SVlad Zolotarov * if any. Otherwise return NULL. 239619c5cb6SVlad Zolotarov */ 240619c5cb6SVlad Zolotarov exe_q_get get; 241619c5cb6SVlad Zolotarov }; 242619c5cb6SVlad Zolotarov /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/ 243619c5cb6SVlad Zolotarov /* 24416a5fd92SYuval Mintz * Element in the VLAN_MAC registry list having all currently configured 245619c5cb6SVlad Zolotarov * rules. 246619c5cb6SVlad Zolotarov */ 247619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_registry_elem { 248619c5cb6SVlad Zolotarov struct list_head link; 249619c5cb6SVlad Zolotarov 25016a5fd92SYuval Mintz /* Used to store the cam offset used for the mac/vlan/vlan-mac. 251619c5cb6SVlad Zolotarov * Relevant for 57710 and 57711 only. VLANs and MACs share the 252619c5cb6SVlad Zolotarov * same CAM for these chips. 253619c5cb6SVlad Zolotarov */ 254619c5cb6SVlad Zolotarov int cam_offset; 255619c5cb6SVlad Zolotarov 256619c5cb6SVlad Zolotarov /* Needed for DEL and RESTORE flows */ 257619c5cb6SVlad Zolotarov unsigned long vlan_mac_flags; 258619c5cb6SVlad Zolotarov 259619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data u; 260619c5cb6SVlad Zolotarov }; 261619c5cb6SVlad Zolotarov 262619c5cb6SVlad Zolotarov /* Bits representing VLAN_MAC commands specific flags */ 263619c5cb6SVlad Zolotarov enum { 264619c5cb6SVlad Zolotarov BNX2X_UC_LIST_MAC, 265619c5cb6SVlad Zolotarov BNX2X_ETH_MAC, 266619c5cb6SVlad Zolotarov BNX2X_ISCSI_ETH_MAC, 267619c5cb6SVlad Zolotarov BNX2X_NETQ_ETH_MAC, 268619c5cb6SVlad Zolotarov BNX2X_DONT_CONSUME_CAM_CREDIT, 269619c5cb6SVlad Zolotarov BNX2X_DONT_CONSUME_CAM_CREDIT_DEST, 270619c5cb6SVlad Zolotarov }; 271e8379c79SYuval Mintz /* When looking for matching filters, some flags are not interesting */ 272e8379c79SYuval Mintz #define BNX2X_VLAN_MAC_CMP_MASK (1 << BNX2X_UC_LIST_MAC | \ 273e8379c79SYuval Mintz 1 << BNX2X_ETH_MAC | \ 274e8379c79SYuval Mintz 1 << BNX2X_ISCSI_ETH_MAC | \ 275e8379c79SYuval Mintz 1 << BNX2X_NETQ_ETH_MAC) 276e8379c79SYuval Mintz #define BNX2X_VLAN_MAC_CMP_FLAGS(flags) \ 277e8379c79SYuval Mintz ((flags) & BNX2X_VLAN_MAC_CMP_MASK) 278619c5cb6SVlad Zolotarov 279619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_params { 280619c5cb6SVlad Zolotarov /* Object to run the command from */ 281619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *vlan_mac_obj; 282619c5cb6SVlad Zolotarov 283619c5cb6SVlad Zolotarov /* General command flags: COMP_WAIT, etc. */ 284619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 285619c5cb6SVlad Zolotarov 286619c5cb6SVlad Zolotarov /* Command specific configuration request */ 287619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_data user_req; 288619c5cb6SVlad Zolotarov }; 289619c5cb6SVlad Zolotarov 290619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj { 291619c5cb6SVlad Zolotarov struct bnx2x_raw_obj raw; 292619c5cb6SVlad Zolotarov 293619c5cb6SVlad Zolotarov /* Bookkeeping list: will prevent the addition of already existing 294619c5cb6SVlad Zolotarov * entries. 295619c5cb6SVlad Zolotarov */ 296619c5cb6SVlad Zolotarov struct list_head head; 2978b09be5fSYuval Mintz /* Implement a simple reader/writer lock on the head list. 2988b09be5fSYuval Mintz * all these fields should only be accessed under the exe_queue lock 2998b09be5fSYuval Mintz */ 3008b09be5fSYuval Mintz u8 head_reader; /* Num. of readers accessing head list */ 3018b09be5fSYuval Mintz bool head_exe_request; /* Pending execution request. */ 3028b09be5fSYuval Mintz unsigned long saved_ramrod_flags; /* Ramrods of pending execution */ 303619c5cb6SVlad Zolotarov 304619c5cb6SVlad Zolotarov /* TODO: Add it's initialization in the init functions */ 305619c5cb6SVlad Zolotarov struct bnx2x_exe_queue_obj exe_queue; 306619c5cb6SVlad Zolotarov 307619c5cb6SVlad Zolotarov /* MACs credit pool */ 308619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *macs_pool; 309619c5cb6SVlad Zolotarov 310619c5cb6SVlad Zolotarov /* VLANs credit pool */ 311619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *vlans_pool; 312619c5cb6SVlad Zolotarov 313619c5cb6SVlad Zolotarov /* RAMROD command to be used */ 314619c5cb6SVlad Zolotarov int ramrod_cmd; 315619c5cb6SVlad Zolotarov 316ed5162a0SAriel Elior /* copy first n elements onto preallocated buffer 317ed5162a0SAriel Elior * 318ed5162a0SAriel Elior * @param n number of elements to get 319ed5162a0SAriel Elior * @param buf buffer preallocated by caller into which elements 320ed5162a0SAriel Elior * will be copied. Note elements are 4-byte aligned 32116a5fd92SYuval Mintz * so buffer size must be able to accommodate the 322ed5162a0SAriel Elior * aligned elements. 323ed5162a0SAriel Elior * 324ed5162a0SAriel Elior * @return number of copied bytes 325ed5162a0SAriel Elior */ 3263ec9f9caSAriel Elior int (*get_n_elements)(struct bnx2x *bp, 3273ec9f9caSAriel Elior struct bnx2x_vlan_mac_obj *o, int n, u8 *base, 3283ec9f9caSAriel Elior u8 stride, u8 size); 329ed5162a0SAriel Elior 330619c5cb6SVlad Zolotarov /** 331619c5cb6SVlad Zolotarov * Checks if ADD-ramrod with the given params may be performed. 332619c5cb6SVlad Zolotarov * 333619c5cb6SVlad Zolotarov * @return zero if the element may be added 334619c5cb6SVlad Zolotarov */ 335619c5cb6SVlad Zolotarov 33651c1a580SMerav Sicron int (*check_add)(struct bnx2x *bp, 33751c1a580SMerav Sicron struct bnx2x_vlan_mac_obj *o, 338619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data *data); 339619c5cb6SVlad Zolotarov 340619c5cb6SVlad Zolotarov /** 341619c5cb6SVlad Zolotarov * Checks if DEL-ramrod with the given params may be performed. 342619c5cb6SVlad Zolotarov * 343619c5cb6SVlad Zolotarov * @return true if the element may be deleted 344619c5cb6SVlad Zolotarov */ 345619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_registry_elem * 34651c1a580SMerav Sicron (*check_del)(struct bnx2x *bp, 34751c1a580SMerav Sicron struct bnx2x_vlan_mac_obj *o, 348619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data *data); 349619c5cb6SVlad Zolotarov 350619c5cb6SVlad Zolotarov /** 351619c5cb6SVlad Zolotarov * Checks if DEL-ramrod with the given params may be performed. 352619c5cb6SVlad Zolotarov * 353619c5cb6SVlad Zolotarov * @return true if the element may be deleted 354619c5cb6SVlad Zolotarov */ 35551c1a580SMerav Sicron bool (*check_move)(struct bnx2x *bp, 35651c1a580SMerav Sicron struct bnx2x_vlan_mac_obj *src_o, 357619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *dst_o, 358619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data *data); 359619c5cb6SVlad Zolotarov 360619c5cb6SVlad Zolotarov /** 361619c5cb6SVlad Zolotarov * Update the relevant credit object(s) (consume/return 362619c5cb6SVlad Zolotarov * correspondingly). 363619c5cb6SVlad Zolotarov */ 364619c5cb6SVlad Zolotarov bool (*get_credit)(struct bnx2x_vlan_mac_obj *o); 365619c5cb6SVlad Zolotarov bool (*put_credit)(struct bnx2x_vlan_mac_obj *o); 366619c5cb6SVlad Zolotarov bool (*get_cam_offset)(struct bnx2x_vlan_mac_obj *o, int *offset); 367619c5cb6SVlad Zolotarov bool (*put_cam_offset)(struct bnx2x_vlan_mac_obj *o, int offset); 368619c5cb6SVlad Zolotarov 369619c5cb6SVlad Zolotarov /** 370619c5cb6SVlad Zolotarov * Configures one rule in the ramrod data buffer. 371619c5cb6SVlad Zolotarov */ 372619c5cb6SVlad Zolotarov void (*set_one_rule)(struct bnx2x *bp, 373619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *o, 374619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem *elem, int rule_idx, 375619c5cb6SVlad Zolotarov int cam_offset); 376619c5cb6SVlad Zolotarov 377619c5cb6SVlad Zolotarov /** 378619c5cb6SVlad Zolotarov * Delete all configured elements having the given 379619c5cb6SVlad Zolotarov * vlan_mac_flags specification. Assumes no pending for 380619c5cb6SVlad Zolotarov * execution commands. Will schedule all all currently 381619c5cb6SVlad Zolotarov * configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags 382619c5cb6SVlad Zolotarov * specification for deletion and will use the given 383619c5cb6SVlad Zolotarov * ramrod_flags for the last DEL operation. 384619c5cb6SVlad Zolotarov * 385619c5cb6SVlad Zolotarov * @param bp 386619c5cb6SVlad Zolotarov * @param o 387619c5cb6SVlad Zolotarov * @param ramrod_flags RAMROD_XX flags 388619c5cb6SVlad Zolotarov * 389619c5cb6SVlad Zolotarov * @return 0 if the last operation has completed successfully 390619c5cb6SVlad Zolotarov * and there are no more elements left, positive value 391619c5cb6SVlad Zolotarov * if there are pending for completion commands, 392619c5cb6SVlad Zolotarov * negative value in case of failure. 393619c5cb6SVlad Zolotarov */ 394619c5cb6SVlad Zolotarov int (*delete_all)(struct bnx2x *bp, 395619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *o, 396619c5cb6SVlad Zolotarov unsigned long *vlan_mac_flags, 397619c5cb6SVlad Zolotarov unsigned long *ramrod_flags); 398619c5cb6SVlad Zolotarov 399619c5cb6SVlad Zolotarov /** 400619c5cb6SVlad Zolotarov * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously 401619c5cb6SVlad Zolotarov * configured elements list. 402619c5cb6SVlad Zolotarov * 403619c5cb6SVlad Zolotarov * @param bp 404619c5cb6SVlad Zolotarov * @param p Command parameters (RAMROD_COMP_WAIT bit in 405619c5cb6SVlad Zolotarov * ramrod_flags is only taken into an account) 40616a5fd92SYuval Mintz * @param ppos a pointer to the cookie that should be given back in the 407619c5cb6SVlad Zolotarov * next call to make function handle the next element. If 408619c5cb6SVlad Zolotarov * *ppos is set to NULL it will restart the iterator. 409619c5cb6SVlad Zolotarov * If returned *ppos == NULL this means that the last 410619c5cb6SVlad Zolotarov * element has been handled. 411619c5cb6SVlad Zolotarov * 412619c5cb6SVlad Zolotarov * @return int 413619c5cb6SVlad Zolotarov */ 414619c5cb6SVlad Zolotarov int (*restore)(struct bnx2x *bp, 415619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_params *p, 416619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_registry_elem **ppos); 417619c5cb6SVlad Zolotarov 418619c5cb6SVlad Zolotarov /** 41916a5fd92SYuval Mintz * Should be called on a completion arrival. 420619c5cb6SVlad Zolotarov * 421619c5cb6SVlad Zolotarov * @param bp 422619c5cb6SVlad Zolotarov * @param o 423619c5cb6SVlad Zolotarov * @param cqe Completion element we are handling 424619c5cb6SVlad Zolotarov * @param ramrod_flags if RAMROD_CONT is set the next bulk of 425619c5cb6SVlad Zolotarov * pending commands will be executed. 426619c5cb6SVlad Zolotarov * RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE 427619c5cb6SVlad Zolotarov * may also be set if needed. 428619c5cb6SVlad Zolotarov * 429619c5cb6SVlad Zolotarov * @return 0 if there are neither pending nor waiting for 430619c5cb6SVlad Zolotarov * completion commands. Positive value if there are 431619c5cb6SVlad Zolotarov * pending for execution or for completion commands. 432619c5cb6SVlad Zolotarov * Negative value in case of an error (including an 433619c5cb6SVlad Zolotarov * error in the cqe). 434619c5cb6SVlad Zolotarov */ 435619c5cb6SVlad Zolotarov int (*complete)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o, 436619c5cb6SVlad Zolotarov union event_ring_elem *cqe, 437619c5cb6SVlad Zolotarov unsigned long *ramrod_flags); 438619c5cb6SVlad Zolotarov 439619c5cb6SVlad Zolotarov /** 440619c5cb6SVlad Zolotarov * Wait for completion of all commands. Don't schedule new ones, 441619c5cb6SVlad Zolotarov * just wait. It assumes that the completion code will schedule 442619c5cb6SVlad Zolotarov * for new commands. 443619c5cb6SVlad Zolotarov */ 444619c5cb6SVlad Zolotarov int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o); 445619c5cb6SVlad Zolotarov }; 446619c5cb6SVlad Zolotarov 4470a52fd01SYuval Mintz enum { 4480a52fd01SYuval Mintz BNX2X_LLH_CAM_ISCSI_ETH_LINE = 0, 4490a52fd01SYuval Mintz BNX2X_LLH_CAM_ETH_LINE, 4500a52fd01SYuval Mintz BNX2X_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2 4510a52fd01SYuval Mintz }; 4520a52fd01SYuval Mintz 453619c5cb6SVlad Zolotarov /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */ 454619c5cb6SVlad Zolotarov 45516a5fd92SYuval Mintz /* RX_MODE ramrod special flags: set in rx_mode_flags field in 456619c5cb6SVlad Zolotarov * a bnx2x_rx_mode_ramrod_params. 457619c5cb6SVlad Zolotarov */ 458619c5cb6SVlad Zolotarov enum { 459619c5cb6SVlad Zolotarov BNX2X_RX_MODE_FCOE_ETH, 460619c5cb6SVlad Zolotarov BNX2X_RX_MODE_ISCSI_ETH, 461619c5cb6SVlad Zolotarov }; 462619c5cb6SVlad Zolotarov 463619c5cb6SVlad Zolotarov enum { 464619c5cb6SVlad Zolotarov BNX2X_ACCEPT_UNICAST, 465619c5cb6SVlad Zolotarov BNX2X_ACCEPT_MULTICAST, 466619c5cb6SVlad Zolotarov BNX2X_ACCEPT_ALL_UNICAST, 467619c5cb6SVlad Zolotarov BNX2X_ACCEPT_ALL_MULTICAST, 468619c5cb6SVlad Zolotarov BNX2X_ACCEPT_BROADCAST, 469619c5cb6SVlad Zolotarov BNX2X_ACCEPT_UNMATCHED, 470619c5cb6SVlad Zolotarov BNX2X_ACCEPT_ANY_VLAN 471619c5cb6SVlad Zolotarov }; 472619c5cb6SVlad Zolotarov 473619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_ramrod_params { 474619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_obj *rx_mode_obj; 475619c5cb6SVlad Zolotarov unsigned long *pstate; 476619c5cb6SVlad Zolotarov int state; 477619c5cb6SVlad Zolotarov u8 cl_id; 478619c5cb6SVlad Zolotarov u32 cid; 479619c5cb6SVlad Zolotarov u8 func_id; 480619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 481619c5cb6SVlad Zolotarov unsigned long rx_mode_flags; 482619c5cb6SVlad Zolotarov 48316a5fd92SYuval Mintz /* rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to 484619c5cb6SVlad Zolotarov * a tstorm_eth_mac_filter_config (e1x). 485619c5cb6SVlad Zolotarov */ 486619c5cb6SVlad Zolotarov void *rdata; 487619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping; 488619c5cb6SVlad Zolotarov 489619c5cb6SVlad Zolotarov /* Rx mode settings */ 490619c5cb6SVlad Zolotarov unsigned long rx_accept_flags; 491619c5cb6SVlad Zolotarov 492619c5cb6SVlad Zolotarov /* internal switching settings */ 493619c5cb6SVlad Zolotarov unsigned long tx_accept_flags; 494619c5cb6SVlad Zolotarov }; 495619c5cb6SVlad Zolotarov 496619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_obj { 497619c5cb6SVlad Zolotarov int (*config_rx_mode)(struct bnx2x *bp, 498619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_ramrod_params *p); 499619c5cb6SVlad Zolotarov 500619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, 501619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_ramrod_params *p); 502619c5cb6SVlad Zolotarov }; 503619c5cb6SVlad Zolotarov 504619c5cb6SVlad Zolotarov /********************** Set multicast group ***********************************/ 505619c5cb6SVlad Zolotarov 506619c5cb6SVlad Zolotarov struct bnx2x_mcast_list_elem { 507619c5cb6SVlad Zolotarov struct list_head link; 508619c5cb6SVlad Zolotarov u8 *mac; 509619c5cb6SVlad Zolotarov }; 510619c5cb6SVlad Zolotarov 511619c5cb6SVlad Zolotarov union bnx2x_mcast_config_data { 512619c5cb6SVlad Zolotarov u8 *mac; 513619c5cb6SVlad Zolotarov u8 bin; /* used in a RESTORE flow */ 514619c5cb6SVlad Zolotarov }; 515619c5cb6SVlad Zolotarov 516619c5cb6SVlad Zolotarov struct bnx2x_mcast_ramrod_params { 517619c5cb6SVlad Zolotarov struct bnx2x_mcast_obj *mcast_obj; 518619c5cb6SVlad Zolotarov 519619c5cb6SVlad Zolotarov /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */ 520619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 521619c5cb6SVlad Zolotarov 522619c5cb6SVlad Zolotarov struct list_head mcast_list; /* list of struct bnx2x_mcast_list_elem */ 523619c5cb6SVlad Zolotarov /** TODO: 524619c5cb6SVlad Zolotarov * - rename it to macs_num. 525619c5cb6SVlad Zolotarov * - Add a new command type for handling pending commands 526619c5cb6SVlad Zolotarov * (remove "zero semantics"). 527619c5cb6SVlad Zolotarov * 528619c5cb6SVlad Zolotarov * Length of mcast_list. If zero and ADD_CONT command - post 529619c5cb6SVlad Zolotarov * pending commands. 530619c5cb6SVlad Zolotarov */ 531619c5cb6SVlad Zolotarov int mcast_list_len; 532619c5cb6SVlad Zolotarov }; 533619c5cb6SVlad Zolotarov 53486564c3fSYuval Mintz enum bnx2x_mcast_cmd { 535619c5cb6SVlad Zolotarov BNX2X_MCAST_CMD_ADD, 536619c5cb6SVlad Zolotarov BNX2X_MCAST_CMD_CONT, 537619c5cb6SVlad Zolotarov BNX2X_MCAST_CMD_DEL, 538619c5cb6SVlad Zolotarov BNX2X_MCAST_CMD_RESTORE, 539*c7b7b483SYuval Mintz 540*c7b7b483SYuval Mintz /* Following this, multicast configuration should equal to approx 541*c7b7b483SYuval Mintz * the set of MACs provided [i.e., remove all else]. 542*c7b7b483SYuval Mintz * The two sub-commands are used internally to decide whether a given 543*c7b7b483SYuval Mintz * bin is to be added or removed 544*c7b7b483SYuval Mintz */ 545*c7b7b483SYuval Mintz BNX2X_MCAST_CMD_SET, 546*c7b7b483SYuval Mintz BNX2X_MCAST_CMD_SET_ADD, 547*c7b7b483SYuval Mintz BNX2X_MCAST_CMD_SET_DEL, 548619c5cb6SVlad Zolotarov }; 549619c5cb6SVlad Zolotarov 550619c5cb6SVlad Zolotarov struct bnx2x_mcast_obj { 551619c5cb6SVlad Zolotarov struct bnx2x_raw_obj raw; 552619c5cb6SVlad Zolotarov 553619c5cb6SVlad Zolotarov union { 554619c5cb6SVlad Zolotarov struct { 555619c5cb6SVlad Zolotarov #define BNX2X_MCAST_BINS_NUM 256 556619c5cb6SVlad Zolotarov #define BNX2X_MCAST_VEC_SZ (BNX2X_MCAST_BINS_NUM / 64) 557619c5cb6SVlad Zolotarov u64 vec[BNX2X_MCAST_VEC_SZ]; 558619c5cb6SVlad Zolotarov 559619c5cb6SVlad Zolotarov /** Number of BINs to clear. Should be updated 560619c5cb6SVlad Zolotarov * immediately when a command arrives in order to 561619c5cb6SVlad Zolotarov * properly create DEL commands. 562619c5cb6SVlad Zolotarov */ 563619c5cb6SVlad Zolotarov int num_bins_set; 564619c5cb6SVlad Zolotarov } aprox_match; 565619c5cb6SVlad Zolotarov 566619c5cb6SVlad Zolotarov struct { 567619c5cb6SVlad Zolotarov struct list_head macs; 568619c5cb6SVlad Zolotarov int num_macs_set; 569619c5cb6SVlad Zolotarov } exact_match; 570619c5cb6SVlad Zolotarov } registry; 571619c5cb6SVlad Zolotarov 572619c5cb6SVlad Zolotarov /* Pending commands */ 573619c5cb6SVlad Zolotarov struct list_head pending_cmds_head; 574619c5cb6SVlad Zolotarov 575619c5cb6SVlad Zolotarov /* A state that is set in raw.pstate, when there are pending commands */ 576619c5cb6SVlad Zolotarov int sched_state; 577619c5cb6SVlad Zolotarov 578619c5cb6SVlad Zolotarov /* Maximal number of mcast MACs configured in one command */ 579619c5cb6SVlad Zolotarov int max_cmd_len; 580619c5cb6SVlad Zolotarov 581619c5cb6SVlad Zolotarov /* Total number of currently pending MACs to configure: both 582619c5cb6SVlad Zolotarov * in the pending commands list and in the current command. 583619c5cb6SVlad Zolotarov */ 584619c5cb6SVlad Zolotarov int total_pending_num; 585619c5cb6SVlad Zolotarov 586619c5cb6SVlad Zolotarov u8 engine_id; 587619c5cb6SVlad Zolotarov 588619c5cb6SVlad Zolotarov /** 589619c5cb6SVlad Zolotarov * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above) 590619c5cb6SVlad Zolotarov */ 591619c5cb6SVlad Zolotarov int (*config_mcast)(struct bnx2x *bp, 59286564c3fSYuval Mintz struct bnx2x_mcast_ramrod_params *p, 59386564c3fSYuval Mintz enum bnx2x_mcast_cmd cmd); 594619c5cb6SVlad Zolotarov 595619c5cb6SVlad Zolotarov /** 596619c5cb6SVlad Zolotarov * Fills the ramrod data during the RESTORE flow. 597619c5cb6SVlad Zolotarov * 598619c5cb6SVlad Zolotarov * @param bp 599619c5cb6SVlad Zolotarov * @param o 600619c5cb6SVlad Zolotarov * @param start_idx Registry index to start from 601619c5cb6SVlad Zolotarov * @param rdata_idx Index in the ramrod data to start from 602619c5cb6SVlad Zolotarov * 603619c5cb6SVlad Zolotarov * @return -1 if we handled the whole registry or index of the last 604619c5cb6SVlad Zolotarov * handled registry element. 605619c5cb6SVlad Zolotarov */ 606619c5cb6SVlad Zolotarov int (*hdl_restore)(struct bnx2x *bp, struct bnx2x_mcast_obj *o, 607619c5cb6SVlad Zolotarov int start_bin, int *rdata_idx); 608619c5cb6SVlad Zolotarov 609619c5cb6SVlad Zolotarov int (*enqueue_cmd)(struct bnx2x *bp, struct bnx2x_mcast_obj *o, 61086564c3fSYuval Mintz struct bnx2x_mcast_ramrod_params *p, 61186564c3fSYuval Mintz enum bnx2x_mcast_cmd cmd); 612619c5cb6SVlad Zolotarov 613619c5cb6SVlad Zolotarov void (*set_one_rule)(struct bnx2x *bp, 614619c5cb6SVlad Zolotarov struct bnx2x_mcast_obj *o, int idx, 61586564c3fSYuval Mintz union bnx2x_mcast_config_data *cfg_data, 61686564c3fSYuval Mintz enum bnx2x_mcast_cmd cmd); 617619c5cb6SVlad Zolotarov 618619c5cb6SVlad Zolotarov /** Checks if there are more mcast MACs to be set or a previous 619619c5cb6SVlad Zolotarov * command is still pending. 620619c5cb6SVlad Zolotarov */ 621619c5cb6SVlad Zolotarov bool (*check_pending)(struct bnx2x_mcast_obj *o); 622619c5cb6SVlad Zolotarov 623619c5cb6SVlad Zolotarov /** 624619c5cb6SVlad Zolotarov * Set/Clear/Check SCHEDULED state of the object 625619c5cb6SVlad Zolotarov */ 626619c5cb6SVlad Zolotarov void (*set_sched)(struct bnx2x_mcast_obj *o); 627619c5cb6SVlad Zolotarov void (*clear_sched)(struct bnx2x_mcast_obj *o); 628619c5cb6SVlad Zolotarov bool (*check_sched)(struct bnx2x_mcast_obj *o); 629619c5cb6SVlad Zolotarov 630619c5cb6SVlad Zolotarov /* Wait until all pending commands complete */ 631619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, struct bnx2x_mcast_obj *o); 632619c5cb6SVlad Zolotarov 633619c5cb6SVlad Zolotarov /** 634619c5cb6SVlad Zolotarov * Handle the internal object counters needed for proper 635619c5cb6SVlad Zolotarov * commands handling. Checks that the provided parameters are 636619c5cb6SVlad Zolotarov * feasible. 637619c5cb6SVlad Zolotarov */ 638619c5cb6SVlad Zolotarov int (*validate)(struct bnx2x *bp, 63986564c3fSYuval Mintz struct bnx2x_mcast_ramrod_params *p, 64086564c3fSYuval Mintz enum bnx2x_mcast_cmd cmd); 641619c5cb6SVlad Zolotarov 642619c5cb6SVlad Zolotarov /** 643619c5cb6SVlad Zolotarov * Restore the values of internal counters in case of a failure. 644619c5cb6SVlad Zolotarov */ 645619c5cb6SVlad Zolotarov void (*revert)(struct bnx2x *bp, 646619c5cb6SVlad Zolotarov struct bnx2x_mcast_ramrod_params *p, 647*c7b7b483SYuval Mintz int old_num_bins, 648*c7b7b483SYuval Mintz enum bnx2x_mcast_cmd cmd); 649619c5cb6SVlad Zolotarov 650619c5cb6SVlad Zolotarov int (*get_registry_size)(struct bnx2x_mcast_obj *o); 651619c5cb6SVlad Zolotarov void (*set_registry_size)(struct bnx2x_mcast_obj *o, int n); 652619c5cb6SVlad Zolotarov }; 653619c5cb6SVlad Zolotarov 654619c5cb6SVlad Zolotarov /*************************** Credit handling **********************************/ 655619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj { 656619c5cb6SVlad Zolotarov 657619c5cb6SVlad Zolotarov /* Current amount of credit in the pool */ 658619c5cb6SVlad Zolotarov atomic_t credit; 659619c5cb6SVlad Zolotarov 660619c5cb6SVlad Zolotarov /* Maximum allowed credit. put() will check against it. */ 661619c5cb6SVlad Zolotarov int pool_sz; 662619c5cb6SVlad Zolotarov 66316a5fd92SYuval Mintz /* Allocate a pool table statically. 664619c5cb6SVlad Zolotarov * 66516a5fd92SYuval Mintz * Currently the maximum allowed size is MAX_MAC_CREDIT_E2(272) 666619c5cb6SVlad Zolotarov * 667619c5cb6SVlad Zolotarov * The set bit in the table will mean that the entry is available. 668619c5cb6SVlad Zolotarov */ 669619c5cb6SVlad Zolotarov #define BNX2X_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64) 670619c5cb6SVlad Zolotarov u64 pool_mirror[BNX2X_POOL_VEC_SIZE]; 671619c5cb6SVlad Zolotarov 672619c5cb6SVlad Zolotarov /* Base pool offset (initialized differently */ 673619c5cb6SVlad Zolotarov int base_pool_offset; 674619c5cb6SVlad Zolotarov 675619c5cb6SVlad Zolotarov /** 676619c5cb6SVlad Zolotarov * Get the next free pool entry. 677619c5cb6SVlad Zolotarov * 678619c5cb6SVlad Zolotarov * @return true if there was a free entry in the pool 679619c5cb6SVlad Zolotarov */ 680619c5cb6SVlad Zolotarov bool (*get_entry)(struct bnx2x_credit_pool_obj *o, int *entry); 681619c5cb6SVlad Zolotarov 682619c5cb6SVlad Zolotarov /** 683619c5cb6SVlad Zolotarov * Return the entry back to the pool. 684619c5cb6SVlad Zolotarov * 685619c5cb6SVlad Zolotarov * @return true if entry is legal and has been successfully 686619c5cb6SVlad Zolotarov * returned to the pool. 687619c5cb6SVlad Zolotarov */ 688619c5cb6SVlad Zolotarov bool (*put_entry)(struct bnx2x_credit_pool_obj *o, int entry); 689619c5cb6SVlad Zolotarov 690619c5cb6SVlad Zolotarov /** 691619c5cb6SVlad Zolotarov * Get the requested amount of credit from the pool. 692619c5cb6SVlad Zolotarov * 693619c5cb6SVlad Zolotarov * @param cnt Amount of requested credit 694619c5cb6SVlad Zolotarov * @return true if the operation is successful 695619c5cb6SVlad Zolotarov */ 696619c5cb6SVlad Zolotarov bool (*get)(struct bnx2x_credit_pool_obj *o, int cnt); 697619c5cb6SVlad Zolotarov 698619c5cb6SVlad Zolotarov /** 699619c5cb6SVlad Zolotarov * Returns the credit to the pool. 700619c5cb6SVlad Zolotarov * 701619c5cb6SVlad Zolotarov * @param cnt Amount of credit to return 702619c5cb6SVlad Zolotarov * @return true if the operation is successful 703619c5cb6SVlad Zolotarov */ 704619c5cb6SVlad Zolotarov bool (*put)(struct bnx2x_credit_pool_obj *o, int cnt); 705619c5cb6SVlad Zolotarov 706619c5cb6SVlad Zolotarov /** 707619c5cb6SVlad Zolotarov * Reads the current amount of credit. 708619c5cb6SVlad Zolotarov */ 709619c5cb6SVlad Zolotarov int (*check)(struct bnx2x_credit_pool_obj *o); 710619c5cb6SVlad Zolotarov }; 711619c5cb6SVlad Zolotarov 712619c5cb6SVlad Zolotarov /*************************** RSS configuration ********************************/ 713619c5cb6SVlad Zolotarov enum { 714619c5cb6SVlad Zolotarov /* RSS_MODE bits are mutually exclusive */ 715619c5cb6SVlad Zolotarov BNX2X_RSS_MODE_DISABLED, 716619c5cb6SVlad Zolotarov BNX2X_RSS_MODE_REGULAR, 717619c5cb6SVlad Zolotarov 718619c5cb6SVlad Zolotarov BNX2X_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */ 719619c5cb6SVlad Zolotarov 720619c5cb6SVlad Zolotarov BNX2X_RSS_IPV4, 721619c5cb6SVlad Zolotarov BNX2X_RSS_IPV4_TCP, 7225d317c6aSMerav Sicron BNX2X_RSS_IPV4_UDP, 723619c5cb6SVlad Zolotarov BNX2X_RSS_IPV6, 724619c5cb6SVlad Zolotarov BNX2X_RSS_IPV6_TCP, 7255d317c6aSMerav Sicron BNX2X_RSS_IPV6_UDP, 72628311f8eSYuval Mintz 72728311f8eSYuval Mintz BNX2X_RSS_IPV4_VXLAN, 72828311f8eSYuval Mintz BNX2X_RSS_IPV6_VXLAN, 72928311f8eSYuval Mintz BNX2X_RSS_TUNN_INNER_HDRS, 730619c5cb6SVlad Zolotarov }; 731619c5cb6SVlad Zolotarov 732619c5cb6SVlad Zolotarov struct bnx2x_config_rss_params { 733619c5cb6SVlad Zolotarov struct bnx2x_rss_config_obj *rss_obj; 734619c5cb6SVlad Zolotarov 735619c5cb6SVlad Zolotarov /* may have RAMROD_COMP_WAIT set only */ 736619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 737619c5cb6SVlad Zolotarov 738619c5cb6SVlad Zolotarov /* BNX2X_RSS_X bits */ 739619c5cb6SVlad Zolotarov unsigned long rss_flags; 740619c5cb6SVlad Zolotarov 741619c5cb6SVlad Zolotarov /* Number hash bits to take into an account */ 742619c5cb6SVlad Zolotarov u8 rss_result_mask; 743619c5cb6SVlad Zolotarov 744619c5cb6SVlad Zolotarov /* Indirection table */ 745619c5cb6SVlad Zolotarov u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE]; 746619c5cb6SVlad Zolotarov 747619c5cb6SVlad Zolotarov /* RSS hash values */ 748619c5cb6SVlad Zolotarov u32 rss_key[10]; 749619c5cb6SVlad Zolotarov 750619c5cb6SVlad Zolotarov /* valid only iff BNX2X_RSS_UPDATE_TOE is set */ 751619c5cb6SVlad Zolotarov u16 toe_rss_bitmap; 752619c5cb6SVlad Zolotarov }; 753619c5cb6SVlad Zolotarov 754619c5cb6SVlad Zolotarov struct bnx2x_rss_config_obj { 755619c5cb6SVlad Zolotarov struct bnx2x_raw_obj raw; 756619c5cb6SVlad Zolotarov 757619c5cb6SVlad Zolotarov /* RSS engine to use */ 758619c5cb6SVlad Zolotarov u8 engine_id; 759619c5cb6SVlad Zolotarov 760619c5cb6SVlad Zolotarov /* Last configured indirection table */ 761619c5cb6SVlad Zolotarov u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE]; 762619c5cb6SVlad Zolotarov 7635d317c6aSMerav Sicron /* flags for enabling 4-tupple hash on UDP */ 7645d317c6aSMerav Sicron u8 udp_rss_v4; 7655d317c6aSMerav Sicron u8 udp_rss_v6; 7665d317c6aSMerav Sicron 767619c5cb6SVlad Zolotarov int (*config_rss)(struct bnx2x *bp, 768619c5cb6SVlad Zolotarov struct bnx2x_config_rss_params *p); 769619c5cb6SVlad Zolotarov }; 770619c5cb6SVlad Zolotarov 771619c5cb6SVlad Zolotarov /*********************** Queue state update ***********************************/ 772619c5cb6SVlad Zolotarov 773619c5cb6SVlad Zolotarov /* UPDATE command options */ 774619c5cb6SVlad Zolotarov enum { 775619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_IN_VLAN_REM, 776619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG, 777619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_OUT_VLAN_REM, 778619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG, 779619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_ANTI_SPOOF, 780619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG, 781619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_ACTIVATE, 782619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_ACTIVATE_CHNG, 783619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_DEF_VLAN_EN, 784619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG, 785619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG, 786c14db202SYuval Mintz BNX2X_Q_UPDATE_SILENT_VLAN_REM, 787c14db202SYuval Mintz BNX2X_Q_UPDATE_TX_SWITCHING_CHNG, 788eeed018cSMichal Kalderon BNX2X_Q_UPDATE_TX_SWITCHING, 789eeed018cSMichal Kalderon BNX2X_Q_UPDATE_PTP_PKTS_CHNG, 790eeed018cSMichal Kalderon BNX2X_Q_UPDATE_PTP_PKTS, 791619c5cb6SVlad Zolotarov }; 792619c5cb6SVlad Zolotarov 793619c5cb6SVlad Zolotarov /* Allowed Queue states */ 794619c5cb6SVlad Zolotarov enum bnx2x_q_state { 795619c5cb6SVlad Zolotarov BNX2X_Q_STATE_RESET, 796619c5cb6SVlad Zolotarov BNX2X_Q_STATE_INITIALIZED, 797619c5cb6SVlad Zolotarov BNX2X_Q_STATE_ACTIVE, 7986383c0b3SAriel Elior BNX2X_Q_STATE_MULTI_COS, 7996383c0b3SAriel Elior BNX2X_Q_STATE_MCOS_TERMINATED, 800619c5cb6SVlad Zolotarov BNX2X_Q_STATE_INACTIVE, 801619c5cb6SVlad Zolotarov BNX2X_Q_STATE_STOPPED, 802619c5cb6SVlad Zolotarov BNX2X_Q_STATE_TERMINATED, 803619c5cb6SVlad Zolotarov BNX2X_Q_STATE_FLRED, 804619c5cb6SVlad Zolotarov BNX2X_Q_STATE_MAX, 805619c5cb6SVlad Zolotarov }; 806619c5cb6SVlad Zolotarov 80767c431a5SAriel Elior /* Allowed Queue states */ 80867c431a5SAriel Elior enum bnx2x_q_logical_state { 80967c431a5SAriel Elior BNX2X_Q_LOGICAL_STATE_ACTIVE, 81067c431a5SAriel Elior BNX2X_Q_LOGICAL_STATE_STOPPED, 81167c431a5SAriel Elior }; 81267c431a5SAriel Elior 813619c5cb6SVlad Zolotarov /* Allowed commands */ 814619c5cb6SVlad Zolotarov enum bnx2x_queue_cmd { 815619c5cb6SVlad Zolotarov BNX2X_Q_CMD_INIT, 816619c5cb6SVlad Zolotarov BNX2X_Q_CMD_SETUP, 8176383c0b3SAriel Elior BNX2X_Q_CMD_SETUP_TX_ONLY, 818619c5cb6SVlad Zolotarov BNX2X_Q_CMD_DEACTIVATE, 819619c5cb6SVlad Zolotarov BNX2X_Q_CMD_ACTIVATE, 820619c5cb6SVlad Zolotarov BNX2X_Q_CMD_UPDATE, 821619c5cb6SVlad Zolotarov BNX2X_Q_CMD_UPDATE_TPA, 822619c5cb6SVlad Zolotarov BNX2X_Q_CMD_HALT, 823619c5cb6SVlad Zolotarov BNX2X_Q_CMD_CFC_DEL, 824619c5cb6SVlad Zolotarov BNX2X_Q_CMD_TERMINATE, 825619c5cb6SVlad Zolotarov BNX2X_Q_CMD_EMPTY, 826619c5cb6SVlad Zolotarov BNX2X_Q_CMD_MAX, 827619c5cb6SVlad Zolotarov }; 828619c5cb6SVlad Zolotarov 829619c5cb6SVlad Zolotarov /* queue SETUP + INIT flags */ 830619c5cb6SVlad Zolotarov enum { 831619c5cb6SVlad Zolotarov BNX2X_Q_FLG_TPA, 832f5219d8eSVladislav Zolotarov BNX2X_Q_FLG_TPA_IPV6, 833621b4d66SDmitry Kravkov BNX2X_Q_FLG_TPA_GRO, 834619c5cb6SVlad Zolotarov BNX2X_Q_FLG_STATS, 835619c5cb6SVlad Zolotarov BNX2X_Q_FLG_ZERO_STATS, 836619c5cb6SVlad Zolotarov BNX2X_Q_FLG_ACTIVE, 837619c5cb6SVlad Zolotarov BNX2X_Q_FLG_OV, 838619c5cb6SVlad Zolotarov BNX2X_Q_FLG_VLAN, 839619c5cb6SVlad Zolotarov BNX2X_Q_FLG_COS, 840619c5cb6SVlad Zolotarov BNX2X_Q_FLG_HC, 841619c5cb6SVlad Zolotarov BNX2X_Q_FLG_HC_EN, 842619c5cb6SVlad Zolotarov BNX2X_Q_FLG_DHC, 843619c5cb6SVlad Zolotarov BNX2X_Q_FLG_FCOE, 844619c5cb6SVlad Zolotarov BNX2X_Q_FLG_LEADING_RSS, 845619c5cb6SVlad Zolotarov BNX2X_Q_FLG_MCAST, 846619c5cb6SVlad Zolotarov BNX2X_Q_FLG_DEF_VLAN, 847619c5cb6SVlad Zolotarov BNX2X_Q_FLG_TX_SWITCH, 848619c5cb6SVlad Zolotarov BNX2X_Q_FLG_TX_SEC, 849619c5cb6SVlad Zolotarov BNX2X_Q_FLG_ANTI_SPOOF, 850a3348722SBarak Witkowski BNX2X_Q_FLG_SILENT_VLAN_REM, 85191226790SDmitry Kravkov BNX2X_Q_FLG_FORCE_DEFAULT_PRI, 852e42780b6SDmitry Kravkov BNX2X_Q_FLG_REFUSE_OUTBAND_VLAN, 853e287a75cSDmitry Kravkov BNX2X_Q_FLG_PCSUM_ON_PKT, 854e287a75cSDmitry Kravkov BNX2X_Q_FLG_TUN_INC_INNER_IP_ID 855619c5cb6SVlad Zolotarov }; 856619c5cb6SVlad Zolotarov 85716a5fd92SYuval Mintz /* Queue type options: queue type may be a combination of below. */ 858619c5cb6SVlad Zolotarov enum bnx2x_q_type { 859619c5cb6SVlad Zolotarov /** TODO: Consider moving both these flags into the init() 860619c5cb6SVlad Zolotarov * ramrod params. 861619c5cb6SVlad Zolotarov */ 862619c5cb6SVlad Zolotarov BNX2X_Q_TYPE_HAS_RX, 863619c5cb6SVlad Zolotarov BNX2X_Q_TYPE_HAS_TX, 864619c5cb6SVlad Zolotarov }; 865619c5cb6SVlad Zolotarov 8666383c0b3SAriel Elior #define BNX2X_PRIMARY_CID_INDEX 0 8678d7b0278SAriel Elior #define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */ 8686383c0b3SAriel Elior #define BNX2X_MULTI_TX_COS_E2_E3A0 2 8696383c0b3SAriel Elior #define BNX2X_MULTI_TX_COS_E3B0 3 8708d7b0278SAriel Elior #define BNX2X_MULTI_TX_COS 3 /* Maximum possible */ 8716383c0b3SAriel Elior 8723ec9f9caSAriel Elior #define MAC_PAD (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN) 873eeed018cSMichal Kalderon /* DMAE channel to be used by FW for timesync workaroun. A driver that sends 874eeed018cSMichal Kalderon * timesync-related ramrods must not use this DMAE command ID. 875eeed018cSMichal Kalderon */ 876eeed018cSMichal Kalderon #define FW_DMAE_CMD_ID 6 8776383c0b3SAriel Elior 878619c5cb6SVlad Zolotarov struct bnx2x_queue_init_params { 879619c5cb6SVlad Zolotarov struct { 880619c5cb6SVlad Zolotarov unsigned long flags; 881619c5cb6SVlad Zolotarov u16 hc_rate; 882619c5cb6SVlad Zolotarov u8 fw_sb_id; 883619c5cb6SVlad Zolotarov u8 sb_cq_index; 884619c5cb6SVlad Zolotarov } tx; 885619c5cb6SVlad Zolotarov 886619c5cb6SVlad Zolotarov struct { 887619c5cb6SVlad Zolotarov unsigned long flags; 888619c5cb6SVlad Zolotarov u16 hc_rate; 889619c5cb6SVlad Zolotarov u8 fw_sb_id; 890619c5cb6SVlad Zolotarov u8 sb_cq_index; 891619c5cb6SVlad Zolotarov } rx; 892619c5cb6SVlad Zolotarov 893619c5cb6SVlad Zolotarov /* CID context in the host memory */ 8946383c0b3SAriel Elior struct eth_context *cxts[BNX2X_MULTI_TX_COS]; 8956383c0b3SAriel Elior 8966383c0b3SAriel Elior /* maximum number of cos supported by hardware */ 8976383c0b3SAriel Elior u8 max_cos; 8986383c0b3SAriel Elior }; 8996383c0b3SAriel Elior 9006383c0b3SAriel Elior struct bnx2x_queue_terminate_params { 9016383c0b3SAriel Elior /* index within the tx_only cids of this queue object */ 9026383c0b3SAriel Elior u8 cid_index; 9036383c0b3SAriel Elior }; 9046383c0b3SAriel Elior 9056383c0b3SAriel Elior struct bnx2x_queue_cfc_del_params { 9066383c0b3SAriel Elior /* index within the tx_only cids of this queue object */ 9076383c0b3SAriel Elior u8 cid_index; 908619c5cb6SVlad Zolotarov }; 909619c5cb6SVlad Zolotarov 910619c5cb6SVlad Zolotarov struct bnx2x_queue_update_params { 911619c5cb6SVlad Zolotarov unsigned long update_flags; /* BNX2X_Q_UPDATE_XX bits */ 912619c5cb6SVlad Zolotarov u16 def_vlan; 913619c5cb6SVlad Zolotarov u16 silent_removal_value; 914619c5cb6SVlad Zolotarov u16 silent_removal_mask; 9156383c0b3SAriel Elior /* index within the tx_only cids of this queue object */ 9166383c0b3SAriel Elior u8 cid_index; 917619c5cb6SVlad Zolotarov }; 918619c5cb6SVlad Zolotarov 91914a94ebdSMichal Kalderon struct bnx2x_queue_update_tpa_params { 92014a94ebdSMichal Kalderon dma_addr_t sge_map; 92114a94ebdSMichal Kalderon u8 update_ipv4; 92214a94ebdSMichal Kalderon u8 update_ipv6; 92314a94ebdSMichal Kalderon u8 max_tpa_queues; 92414a94ebdSMichal Kalderon u8 max_sges_pkt; 92514a94ebdSMichal Kalderon u8 complete_on_both_clients; 92614a94ebdSMichal Kalderon u8 dont_verify_thr; 92714a94ebdSMichal Kalderon u8 tpa_mode; 92814a94ebdSMichal Kalderon u8 _pad; 92914a94ebdSMichal Kalderon 93014a94ebdSMichal Kalderon u16 sge_buff_sz; 93114a94ebdSMichal Kalderon u16 max_agg_sz; 93214a94ebdSMichal Kalderon 93314a94ebdSMichal Kalderon u16 sge_pause_thr_low; 93414a94ebdSMichal Kalderon u16 sge_pause_thr_high; 93514a94ebdSMichal Kalderon }; 93614a94ebdSMichal Kalderon 937619c5cb6SVlad Zolotarov struct rxq_pause_params { 938619c5cb6SVlad Zolotarov u16 bd_th_lo; 939619c5cb6SVlad Zolotarov u16 bd_th_hi; 940619c5cb6SVlad Zolotarov u16 rcq_th_lo; 941619c5cb6SVlad Zolotarov u16 rcq_th_hi; 942619c5cb6SVlad Zolotarov u16 sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */ 943619c5cb6SVlad Zolotarov u16 sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */ 944619c5cb6SVlad Zolotarov u16 pri_map; 945619c5cb6SVlad Zolotarov }; 946619c5cb6SVlad Zolotarov 947619c5cb6SVlad Zolotarov /* general */ 948619c5cb6SVlad Zolotarov struct bnx2x_general_setup_params { 949619c5cb6SVlad Zolotarov /* valid iff BNX2X_Q_FLG_STATS */ 950619c5cb6SVlad Zolotarov u8 stat_id; 951619c5cb6SVlad Zolotarov 952619c5cb6SVlad Zolotarov u8 spcl_id; 953619c5cb6SVlad Zolotarov u16 mtu; 9546383c0b3SAriel Elior u8 cos; 95502dc4025SYuval Mintz 95602dc4025SYuval Mintz u8 fp_hsi; 957619c5cb6SVlad Zolotarov }; 958619c5cb6SVlad Zolotarov 959619c5cb6SVlad Zolotarov struct bnx2x_rxq_setup_params { 960619c5cb6SVlad Zolotarov /* dma */ 961619c5cb6SVlad Zolotarov dma_addr_t dscr_map; 962619c5cb6SVlad Zolotarov dma_addr_t sge_map; 963619c5cb6SVlad Zolotarov dma_addr_t rcq_map; 964619c5cb6SVlad Zolotarov dma_addr_t rcq_np_map; 965619c5cb6SVlad Zolotarov 966619c5cb6SVlad Zolotarov u16 drop_flags; 967619c5cb6SVlad Zolotarov u16 buf_sz; 968619c5cb6SVlad Zolotarov u8 fw_sb_id; 969619c5cb6SVlad Zolotarov u8 cl_qzone_id; 970619c5cb6SVlad Zolotarov 971619c5cb6SVlad Zolotarov /* valid iff BNX2X_Q_FLG_TPA */ 972619c5cb6SVlad Zolotarov u16 tpa_agg_sz; 973619c5cb6SVlad Zolotarov u16 sge_buf_sz; 974619c5cb6SVlad Zolotarov u8 max_sges_pkt; 975619c5cb6SVlad Zolotarov u8 max_tpa_queues; 976619c5cb6SVlad Zolotarov u8 rss_engine_id; 977619c5cb6SVlad Zolotarov 978259afa1fSYuval Mintz /* valid iff BNX2X_Q_FLG_MCAST */ 979259afa1fSYuval Mintz u8 mcast_engine_id; 980259afa1fSYuval Mintz 981619c5cb6SVlad Zolotarov u8 cache_line_log; 982619c5cb6SVlad Zolotarov 983619c5cb6SVlad Zolotarov u8 sb_cq_index; 984619c5cb6SVlad Zolotarov 985619c5cb6SVlad Zolotarov /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */ 986619c5cb6SVlad Zolotarov u16 silent_removal_value; 987619c5cb6SVlad Zolotarov u16 silent_removal_mask; 988619c5cb6SVlad Zolotarov }; 989619c5cb6SVlad Zolotarov 990619c5cb6SVlad Zolotarov struct bnx2x_txq_setup_params { 991619c5cb6SVlad Zolotarov /* dma */ 992619c5cb6SVlad Zolotarov dma_addr_t dscr_map; 993619c5cb6SVlad Zolotarov 994619c5cb6SVlad Zolotarov u8 fw_sb_id; 995619c5cb6SVlad Zolotarov u8 sb_cq_index; 996619c5cb6SVlad Zolotarov u8 cos; /* valid iff BNX2X_Q_FLG_COS */ 997619c5cb6SVlad Zolotarov u16 traffic_type; 998619c5cb6SVlad Zolotarov /* equals to the leading rss client id, used for TX classification*/ 999619c5cb6SVlad Zolotarov u8 tss_leading_cl_id; 1000619c5cb6SVlad Zolotarov 1001619c5cb6SVlad Zolotarov /* valid iff BNX2X_Q_FLG_DEF_VLAN */ 1002619c5cb6SVlad Zolotarov u16 default_vlan; 1003619c5cb6SVlad Zolotarov }; 1004619c5cb6SVlad Zolotarov 1005619c5cb6SVlad Zolotarov struct bnx2x_queue_setup_params { 1006619c5cb6SVlad Zolotarov struct bnx2x_general_setup_params gen_params; 1007619c5cb6SVlad Zolotarov struct bnx2x_txq_setup_params txq_params; 10086383c0b3SAriel Elior struct bnx2x_rxq_setup_params rxq_params; 10096383c0b3SAriel Elior struct rxq_pause_params pause_params; 1010619c5cb6SVlad Zolotarov unsigned long flags; 1011619c5cb6SVlad Zolotarov }; 1012619c5cb6SVlad Zolotarov 10136383c0b3SAriel Elior struct bnx2x_queue_setup_tx_only_params { 10146383c0b3SAriel Elior struct bnx2x_general_setup_params gen_params; 10156383c0b3SAriel Elior struct bnx2x_txq_setup_params txq_params; 10166383c0b3SAriel Elior unsigned long flags; 10176383c0b3SAriel Elior /* index within the tx_only cids of this queue object */ 10186383c0b3SAriel Elior u8 cid_index; 10196383c0b3SAriel Elior }; 1020619c5cb6SVlad Zolotarov 1021619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params { 1022619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj *q_obj; 1023619c5cb6SVlad Zolotarov 1024619c5cb6SVlad Zolotarov /* Current command */ 1025619c5cb6SVlad Zolotarov enum bnx2x_queue_cmd cmd; 1026619c5cb6SVlad Zolotarov 1027619c5cb6SVlad Zolotarov /* may have RAMROD_COMP_WAIT set only */ 1028619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 1029619c5cb6SVlad Zolotarov 1030619c5cb6SVlad Zolotarov /* Params according to the current command */ 1031619c5cb6SVlad Zolotarov union { 1032619c5cb6SVlad Zolotarov struct bnx2x_queue_update_params update; 103314a94ebdSMichal Kalderon struct bnx2x_queue_update_tpa_params update_tpa; 1034619c5cb6SVlad Zolotarov struct bnx2x_queue_setup_params setup; 1035619c5cb6SVlad Zolotarov struct bnx2x_queue_init_params init; 10366383c0b3SAriel Elior struct bnx2x_queue_setup_tx_only_params tx_only; 10376383c0b3SAriel Elior struct bnx2x_queue_terminate_params terminate; 10386383c0b3SAriel Elior struct bnx2x_queue_cfc_del_params cfc_del; 1039619c5cb6SVlad Zolotarov } params; 1040619c5cb6SVlad Zolotarov }; 1041619c5cb6SVlad Zolotarov 1042a3348722SBarak Witkowski struct bnx2x_viflist_params { 1043a3348722SBarak Witkowski u8 echo_res; 1044a3348722SBarak Witkowski u8 func_bit_map_res; 1045a3348722SBarak Witkowski }; 1046a3348722SBarak Witkowski 1047619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj { 10486383c0b3SAriel Elior u32 cids[BNX2X_MULTI_TX_COS]; 1049619c5cb6SVlad Zolotarov u8 cl_id; 1050619c5cb6SVlad Zolotarov u8 func_id; 1051619c5cb6SVlad Zolotarov 105216a5fd92SYuval Mintz /* number of traffic classes supported by queue. 105316a5fd92SYuval Mintz * The primary connection of the queue supports the first traffic 105416a5fd92SYuval Mintz * class. Any further traffic class is supported by a tx-only 10556383c0b3SAriel Elior * connection. 10566383c0b3SAriel Elior * 10576383c0b3SAriel Elior * Therefore max_cos is also a number of valid entries in the cids 10586383c0b3SAriel Elior * array. 10596383c0b3SAriel Elior */ 10606383c0b3SAriel Elior u8 max_cos; 10616383c0b3SAriel Elior u8 num_tx_only, next_tx_only; 10626383c0b3SAriel Elior 1063619c5cb6SVlad Zolotarov enum bnx2x_q_state state, next_state; 1064619c5cb6SVlad Zolotarov 1065619c5cb6SVlad Zolotarov /* bits from enum bnx2x_q_type */ 1066619c5cb6SVlad Zolotarov unsigned long type; 1067619c5cb6SVlad Zolotarov 1068619c5cb6SVlad Zolotarov /* BNX2X_Q_CMD_XX bits. This object implements "one 1069619c5cb6SVlad Zolotarov * pending" paradigm but for debug and tracing purposes it's 107016a5fd92SYuval Mintz * more convenient to have different bits for different 1071619c5cb6SVlad Zolotarov * commands. 1072619c5cb6SVlad Zolotarov */ 1073619c5cb6SVlad Zolotarov unsigned long pending; 1074619c5cb6SVlad Zolotarov 1075619c5cb6SVlad Zolotarov /* Buffer to use as a ramrod data and its mapping */ 1076619c5cb6SVlad Zolotarov void *rdata; 1077619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping; 1078619c5cb6SVlad Zolotarov 1079619c5cb6SVlad Zolotarov /** 1080619c5cb6SVlad Zolotarov * Performs one state change according to the given parameters. 1081619c5cb6SVlad Zolotarov * 1082619c5cb6SVlad Zolotarov * @return 0 in case of success and negative value otherwise. 1083619c5cb6SVlad Zolotarov */ 1084619c5cb6SVlad Zolotarov int (*send_cmd)(struct bnx2x *bp, 1085619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params *params); 1086619c5cb6SVlad Zolotarov 1087619c5cb6SVlad Zolotarov /** 1088619c5cb6SVlad Zolotarov * Sets the pending bit according to the requested transition. 1089619c5cb6SVlad Zolotarov */ 1090619c5cb6SVlad Zolotarov int (*set_pending)(struct bnx2x_queue_sp_obj *o, 1091619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params *params); 1092619c5cb6SVlad Zolotarov 1093619c5cb6SVlad Zolotarov /** 1094619c5cb6SVlad Zolotarov * Checks that the requested state transition is legal. 1095619c5cb6SVlad Zolotarov */ 1096619c5cb6SVlad Zolotarov int (*check_transition)(struct bnx2x *bp, 1097619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj *o, 1098619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params *params); 1099619c5cb6SVlad Zolotarov 1100619c5cb6SVlad Zolotarov /** 1101619c5cb6SVlad Zolotarov * Completes the pending command. 1102619c5cb6SVlad Zolotarov */ 1103619c5cb6SVlad Zolotarov int (*complete_cmd)(struct bnx2x *bp, 1104619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj *o, 1105619c5cb6SVlad Zolotarov enum bnx2x_queue_cmd); 1106619c5cb6SVlad Zolotarov 1107619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, 1108619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj *o, 1109619c5cb6SVlad Zolotarov enum bnx2x_queue_cmd cmd); 1110619c5cb6SVlad Zolotarov }; 1111619c5cb6SVlad Zolotarov 1112619c5cb6SVlad Zolotarov /********************** Function state update *********************************/ 1113e42780b6SDmitry Kravkov 1114e42780b6SDmitry Kravkov /* UPDATE command options */ 1115e42780b6SDmitry Kravkov enum { 1116e42780b6SDmitry Kravkov BNX2X_F_UPDATE_TX_SWITCH_SUSPEND_CHNG, 1117e42780b6SDmitry Kravkov BNX2X_F_UPDATE_TX_SWITCH_SUSPEND, 11187609647eSYuval Mintz BNX2X_F_UPDATE_SD_VLAN_TAG_CHNG, 11197609647eSYuval Mintz BNX2X_F_UPDATE_SD_VLAN_ETH_TYPE_CHNG, 11207609647eSYuval Mintz BNX2X_F_UPDATE_VLAN_FORCE_PRIO_CHNG, 11217609647eSYuval Mintz BNX2X_F_UPDATE_VLAN_FORCE_PRIO_FLAG, 1122e42780b6SDmitry Kravkov BNX2X_F_UPDATE_TUNNEL_CFG_CHNG, 112328311f8eSYuval Mintz BNX2X_F_UPDATE_TUNNEL_INNER_CLSS_L2GRE, 112428311f8eSYuval Mintz BNX2X_F_UPDATE_TUNNEL_INNER_CLSS_VXLAN, 112528311f8eSYuval Mintz BNX2X_F_UPDATE_TUNNEL_INNER_CLSS_L2GENEVE, 112628311f8eSYuval Mintz BNX2X_F_UPDATE_TUNNEL_INNER_RSS, 1127e42780b6SDmitry Kravkov }; 1128e42780b6SDmitry Kravkov 1129619c5cb6SVlad Zolotarov /* Allowed Function states */ 1130619c5cb6SVlad Zolotarov enum bnx2x_func_state { 1131619c5cb6SVlad Zolotarov BNX2X_F_STATE_RESET, 1132619c5cb6SVlad Zolotarov BNX2X_F_STATE_INITIALIZED, 1133619c5cb6SVlad Zolotarov BNX2X_F_STATE_STARTED, 11346debea87SDmitry Kravkov BNX2X_F_STATE_TX_STOPPED, 1135619c5cb6SVlad Zolotarov BNX2X_F_STATE_MAX, 1136619c5cb6SVlad Zolotarov }; 1137619c5cb6SVlad Zolotarov 1138619c5cb6SVlad Zolotarov /* Allowed Function commands */ 1139619c5cb6SVlad Zolotarov enum bnx2x_func_cmd { 1140619c5cb6SVlad Zolotarov BNX2X_F_CMD_HW_INIT, 1141619c5cb6SVlad Zolotarov BNX2X_F_CMD_START, 1142619c5cb6SVlad Zolotarov BNX2X_F_CMD_STOP, 1143619c5cb6SVlad Zolotarov BNX2X_F_CMD_HW_RESET, 1144a3348722SBarak Witkowski BNX2X_F_CMD_AFEX_UPDATE, 1145a3348722SBarak Witkowski BNX2X_F_CMD_AFEX_VIFLISTS, 11466debea87SDmitry Kravkov BNX2X_F_CMD_TX_STOP, 11476debea87SDmitry Kravkov BNX2X_F_CMD_TX_START, 114855c11941SMerav Sicron BNX2X_F_CMD_SWITCH_UPDATE, 1149eeed018cSMichal Kalderon BNX2X_F_CMD_SET_TIMESYNC, 1150619c5cb6SVlad Zolotarov BNX2X_F_CMD_MAX, 1151619c5cb6SVlad Zolotarov }; 1152619c5cb6SVlad Zolotarov 1153619c5cb6SVlad Zolotarov struct bnx2x_func_hw_init_params { 1154619c5cb6SVlad Zolotarov /* A load phase returned by MCP. 1155619c5cb6SVlad Zolotarov * 1156619c5cb6SVlad Zolotarov * May be: 1157619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP 1158619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_COMMON 1159619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_PORT 1160619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_FUNCTION 1161619c5cb6SVlad Zolotarov */ 1162619c5cb6SVlad Zolotarov u32 load_phase; 1163619c5cb6SVlad Zolotarov }; 1164619c5cb6SVlad Zolotarov 1165619c5cb6SVlad Zolotarov struct bnx2x_func_hw_reset_params { 1166619c5cb6SVlad Zolotarov /* A load phase returned by MCP. 1167619c5cb6SVlad Zolotarov * 1168619c5cb6SVlad Zolotarov * May be: 1169619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP 1170619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_COMMON 1171619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_PORT 1172619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_FUNCTION 1173619c5cb6SVlad Zolotarov */ 1174619c5cb6SVlad Zolotarov u32 reset_phase; 1175619c5cb6SVlad Zolotarov }; 1176619c5cb6SVlad Zolotarov 1177619c5cb6SVlad Zolotarov struct bnx2x_func_start_params { 1178619c5cb6SVlad Zolotarov /* Multi Function mode: 1179619c5cb6SVlad Zolotarov * - Single Function 1180619c5cb6SVlad Zolotarov * - Switch Dependent 1181619c5cb6SVlad Zolotarov * - Switch Independent 1182619c5cb6SVlad Zolotarov */ 1183619c5cb6SVlad Zolotarov u16 mf_mode; 1184619c5cb6SVlad Zolotarov 1185619c5cb6SVlad Zolotarov /* Switch Dependent mode outer VLAN tag */ 1186619c5cb6SVlad Zolotarov u16 sd_vlan_tag; 1187619c5cb6SVlad Zolotarov 1188619c5cb6SVlad Zolotarov /* Function cos mode */ 1189619c5cb6SVlad Zolotarov u8 network_cos_mode; 11901bc277f7SDmitry Kravkov 119128311f8eSYuval Mintz /* UDP dest port for VXLAN */ 119228311f8eSYuval Mintz u16 vxlan_dst_port; 11931bc277f7SDmitry Kravkov 119428311f8eSYuval Mintz /* UDP dest port for Geneve */ 119528311f8eSYuval Mintz u16 geneve_dst_port; 11961bc277f7SDmitry Kravkov 119728311f8eSYuval Mintz /* Enable inner Rx classifications for L2GRE packets */ 119828311f8eSYuval Mintz u8 inner_clss_l2gre; 1199e42780b6SDmitry Kravkov 120028311f8eSYuval Mintz /* Enable inner Rx classifications for L2-Geneve packets */ 120128311f8eSYuval Mintz u8 inner_clss_l2geneve; 120228311f8eSYuval Mintz 120328311f8eSYuval Mintz /* Enable inner Rx classification for vxlan packets */ 120428311f8eSYuval Mintz u8 inner_clss_vxlan; 120528311f8eSYuval Mintz 120628311f8eSYuval Mintz /* Enable RSS according to inner header */ 120728311f8eSYuval Mintz u8 inner_rss; 12087609647eSYuval Mintz 12097609647eSYuval Mintz /* Allows accepting of packets failing MF classification, possibly 12107609647eSYuval Mintz * only matching a given ethertype 12117609647eSYuval Mintz */ 12127609647eSYuval Mintz u8 class_fail; 12137609647eSYuval Mintz u16 class_fail_ethtype; 12147609647eSYuval Mintz 12157609647eSYuval Mintz /* Override priority of output packets */ 12167609647eSYuval Mintz u8 sd_vlan_force_pri; 12177609647eSYuval Mintz u8 sd_vlan_force_pri_val; 12187609647eSYuval Mintz 12197609647eSYuval Mintz /* Replace vlan's ethertype */ 12207609647eSYuval Mintz u16 sd_vlan_eth_type; 12217609647eSYuval Mintz 12227609647eSYuval Mintz /* Prevent inner vlans from being added by FW */ 12237609647eSYuval Mintz u8 no_added_tags; 122428311f8eSYuval Mintz 122528311f8eSYuval Mintz /* Inner-to-Outer vlan priority mapping */ 122628311f8eSYuval Mintz u8 c2s_pri[MAX_VLAN_PRIORITIES]; 122728311f8eSYuval Mintz u8 c2s_pri_default; 122828311f8eSYuval Mintz u8 c2s_pri_valid; 1229619c5cb6SVlad Zolotarov }; 1230619c5cb6SVlad Zolotarov 123155c11941SMerav Sicron struct bnx2x_func_switch_update_params { 1232e42780b6SDmitry Kravkov unsigned long changes; /* BNX2X_F_UPDATE_XX bits */ 12337609647eSYuval Mintz u16 vlan; 12347609647eSYuval Mintz u16 vlan_eth_type; 12357609647eSYuval Mintz u8 vlan_force_prio; 123628311f8eSYuval Mintz u16 vxlan_dst_port; 123728311f8eSYuval Mintz u16 geneve_dst_port; 123855c11941SMerav Sicron }; 123955c11941SMerav Sicron 1240a3348722SBarak Witkowski struct bnx2x_func_afex_update_params { 1241a3348722SBarak Witkowski u16 vif_id; 1242a3348722SBarak Witkowski u16 afex_default_vlan; 1243a3348722SBarak Witkowski u8 allowed_priorities; 1244a3348722SBarak Witkowski }; 1245a3348722SBarak Witkowski 1246a3348722SBarak Witkowski struct bnx2x_func_afex_viflists_params { 1247a3348722SBarak Witkowski u16 vif_list_index; 1248a3348722SBarak Witkowski u8 func_bit_map; 1249a3348722SBarak Witkowski u8 afex_vif_list_command; 1250a3348722SBarak Witkowski u8 func_to_clear; 1251a3348722SBarak Witkowski }; 1252eeed018cSMichal Kalderon 12536debea87SDmitry Kravkov struct bnx2x_func_tx_start_params { 12546debea87SDmitry Kravkov struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES]; 12556debea87SDmitry Kravkov u8 dcb_enabled; 12566debea87SDmitry Kravkov u8 dcb_version; 12576debea87SDmitry Kravkov u8 dont_add_pri_0_en; 125828311f8eSYuval Mintz u8 dcb_outer_pri[MAX_TRAFFIC_TYPES]; 12596debea87SDmitry Kravkov }; 12606debea87SDmitry Kravkov 1261eeed018cSMichal Kalderon struct bnx2x_func_set_timesync_params { 1262eeed018cSMichal Kalderon /* Reset, set or keep the current drift value */ 1263eeed018cSMichal Kalderon u8 drift_adjust_cmd; 1264eeed018cSMichal Kalderon 1265eeed018cSMichal Kalderon /* Dec, inc or keep the current offset */ 1266eeed018cSMichal Kalderon u8 offset_cmd; 1267eeed018cSMichal Kalderon 1268eeed018cSMichal Kalderon /* Drift value direction */ 1269eeed018cSMichal Kalderon u8 add_sub_drift_adjust_value; 1270eeed018cSMichal Kalderon 1271eeed018cSMichal Kalderon /* Drift, period and offset values to be used according to the commands 1272eeed018cSMichal Kalderon * above. 1273eeed018cSMichal Kalderon */ 1274eeed018cSMichal Kalderon u8 drift_adjust_value; 1275eeed018cSMichal Kalderon u32 drift_adjust_period; 1276eeed018cSMichal Kalderon u64 offset_delta; 1277eeed018cSMichal Kalderon }; 1278eeed018cSMichal Kalderon 1279619c5cb6SVlad Zolotarov struct bnx2x_func_state_params { 1280619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj *f_obj; 1281619c5cb6SVlad Zolotarov 1282619c5cb6SVlad Zolotarov /* Current command */ 1283619c5cb6SVlad Zolotarov enum bnx2x_func_cmd cmd; 1284619c5cb6SVlad Zolotarov 1285619c5cb6SVlad Zolotarov /* may have RAMROD_COMP_WAIT set only */ 1286619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 1287619c5cb6SVlad Zolotarov 1288619c5cb6SVlad Zolotarov /* Params according to the current command */ 1289619c5cb6SVlad Zolotarov union { 1290619c5cb6SVlad Zolotarov struct bnx2x_func_hw_init_params hw_init; 1291619c5cb6SVlad Zolotarov struct bnx2x_func_hw_reset_params hw_reset; 1292619c5cb6SVlad Zolotarov struct bnx2x_func_start_params start; 129355c11941SMerav Sicron struct bnx2x_func_switch_update_params switch_update; 1294a3348722SBarak Witkowski struct bnx2x_func_afex_update_params afex_update; 1295a3348722SBarak Witkowski struct bnx2x_func_afex_viflists_params afex_viflists; 12966debea87SDmitry Kravkov struct bnx2x_func_tx_start_params tx_start; 1297eeed018cSMichal Kalderon struct bnx2x_func_set_timesync_params set_timesync; 1298619c5cb6SVlad Zolotarov } params; 1299619c5cb6SVlad Zolotarov }; 1300619c5cb6SVlad Zolotarov 1301619c5cb6SVlad Zolotarov struct bnx2x_func_sp_drv_ops { 1302619c5cb6SVlad Zolotarov /* Init tool + runtime initialization: 1303619c5cb6SVlad Zolotarov * - Common Chip 1304619c5cb6SVlad Zolotarov * - Common (per Path) 1305619c5cb6SVlad Zolotarov * - Port 1306619c5cb6SVlad Zolotarov * - Function phases 1307619c5cb6SVlad Zolotarov */ 1308619c5cb6SVlad Zolotarov int (*init_hw_cmn_chip)(struct bnx2x *bp); 1309619c5cb6SVlad Zolotarov int (*init_hw_cmn)(struct bnx2x *bp); 1310619c5cb6SVlad Zolotarov int (*init_hw_port)(struct bnx2x *bp); 1311619c5cb6SVlad Zolotarov int (*init_hw_func)(struct bnx2x *bp); 1312619c5cb6SVlad Zolotarov 1313619c5cb6SVlad Zolotarov /* Reset Function HW: Common, Port, Function phases. */ 1314619c5cb6SVlad Zolotarov void (*reset_hw_cmn)(struct bnx2x *bp); 1315619c5cb6SVlad Zolotarov void (*reset_hw_port)(struct bnx2x *bp); 1316619c5cb6SVlad Zolotarov void (*reset_hw_func)(struct bnx2x *bp); 1317619c5cb6SVlad Zolotarov 1318619c5cb6SVlad Zolotarov /* Init/Free GUNZIP resources */ 1319619c5cb6SVlad Zolotarov int (*gunzip_init)(struct bnx2x *bp); 1320619c5cb6SVlad Zolotarov void (*gunzip_end)(struct bnx2x *bp); 1321619c5cb6SVlad Zolotarov 1322619c5cb6SVlad Zolotarov /* Prepare/Release FW resources */ 1323619c5cb6SVlad Zolotarov int (*init_fw)(struct bnx2x *bp); 1324619c5cb6SVlad Zolotarov void (*release_fw)(struct bnx2x *bp); 1325619c5cb6SVlad Zolotarov }; 1326619c5cb6SVlad Zolotarov 1327619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj { 1328619c5cb6SVlad Zolotarov enum bnx2x_func_state state, next_state; 1329619c5cb6SVlad Zolotarov 1330619c5cb6SVlad Zolotarov /* BNX2X_FUNC_CMD_XX bits. This object implements "one 1331619c5cb6SVlad Zolotarov * pending" paradigm but for debug and tracing purposes it's 133216a5fd92SYuval Mintz * more convenient to have different bits for different 1333619c5cb6SVlad Zolotarov * commands. 1334619c5cb6SVlad Zolotarov */ 1335619c5cb6SVlad Zolotarov unsigned long pending; 1336619c5cb6SVlad Zolotarov 1337619c5cb6SVlad Zolotarov /* Buffer to use as a ramrod data and its mapping */ 1338619c5cb6SVlad Zolotarov void *rdata; 1339619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping; 1340619c5cb6SVlad Zolotarov 1341a3348722SBarak Witkowski /* Buffer to use as a afex ramrod data and its mapping. 1342a3348722SBarak Witkowski * This can't be same rdata as above because afex ramrod requests 1343a3348722SBarak Witkowski * can arrive to the object in parallel to other ramrod requests. 1344a3348722SBarak Witkowski */ 1345a3348722SBarak Witkowski void *afex_rdata; 1346a3348722SBarak Witkowski dma_addr_t afex_rdata_mapping; 1347a3348722SBarak Witkowski 1348619c5cb6SVlad Zolotarov /* this mutex validates that when pending flag is taken, the next 1349619c5cb6SVlad Zolotarov * ramrod to be sent will be the one set the pending bit 1350619c5cb6SVlad Zolotarov */ 1351619c5cb6SVlad Zolotarov struct mutex one_pending_mutex; 1352619c5cb6SVlad Zolotarov 1353619c5cb6SVlad Zolotarov /* Driver interface */ 1354619c5cb6SVlad Zolotarov struct bnx2x_func_sp_drv_ops *drv; 1355619c5cb6SVlad Zolotarov 1356619c5cb6SVlad Zolotarov /** 1357619c5cb6SVlad Zolotarov * Performs one state change according to the given parameters. 1358619c5cb6SVlad Zolotarov * 1359619c5cb6SVlad Zolotarov * @return 0 in case of success and negative value otherwise. 1360619c5cb6SVlad Zolotarov */ 1361619c5cb6SVlad Zolotarov int (*send_cmd)(struct bnx2x *bp, 1362619c5cb6SVlad Zolotarov struct bnx2x_func_state_params *params); 1363619c5cb6SVlad Zolotarov 1364619c5cb6SVlad Zolotarov /** 1365619c5cb6SVlad Zolotarov * Checks that the requested state transition is legal. 1366619c5cb6SVlad Zolotarov */ 1367619c5cb6SVlad Zolotarov int (*check_transition)(struct bnx2x *bp, 1368619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj *o, 1369619c5cb6SVlad Zolotarov struct bnx2x_func_state_params *params); 1370619c5cb6SVlad Zolotarov 1371619c5cb6SVlad Zolotarov /** 1372619c5cb6SVlad Zolotarov * Completes the pending command. 1373619c5cb6SVlad Zolotarov */ 1374619c5cb6SVlad Zolotarov int (*complete_cmd)(struct bnx2x *bp, 1375619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj *o, 1376619c5cb6SVlad Zolotarov enum bnx2x_func_cmd cmd); 1377619c5cb6SVlad Zolotarov 1378619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o, 1379619c5cb6SVlad Zolotarov enum bnx2x_func_cmd cmd); 1380619c5cb6SVlad Zolotarov }; 1381619c5cb6SVlad Zolotarov 1382619c5cb6SVlad Zolotarov /********************** Interfaces ********************************************/ 1383619c5cb6SVlad Zolotarov /* Queueable objects set */ 1384619c5cb6SVlad Zolotarov union bnx2x_qable_obj { 1385619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj vlan_mac; 1386619c5cb6SVlad Zolotarov }; 1387619c5cb6SVlad Zolotarov /************** Function state update *********/ 1388619c5cb6SVlad Zolotarov void bnx2x_init_func_obj(struct bnx2x *bp, 1389619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj *obj, 1390619c5cb6SVlad Zolotarov void *rdata, dma_addr_t rdata_mapping, 1391a3348722SBarak Witkowski void *afex_rdata, dma_addr_t afex_rdata_mapping, 1392619c5cb6SVlad Zolotarov struct bnx2x_func_sp_drv_ops *drv_iface); 1393619c5cb6SVlad Zolotarov 1394619c5cb6SVlad Zolotarov int bnx2x_func_state_change(struct bnx2x *bp, 1395619c5cb6SVlad Zolotarov struct bnx2x_func_state_params *params); 1396619c5cb6SVlad Zolotarov 13976debea87SDmitry Kravkov enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp, 13986debea87SDmitry Kravkov struct bnx2x_func_sp_obj *o); 1399619c5cb6SVlad Zolotarov /******************* Queue State **************/ 1400619c5cb6SVlad Zolotarov void bnx2x_init_queue_obj(struct bnx2x *bp, 14016383c0b3SAriel Elior struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids, 14026383c0b3SAriel Elior u8 cid_cnt, u8 func_id, void *rdata, 14036383c0b3SAriel Elior dma_addr_t rdata_mapping, unsigned long type); 1404619c5cb6SVlad Zolotarov 1405619c5cb6SVlad Zolotarov int bnx2x_queue_state_change(struct bnx2x *bp, 1406619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params *params); 1407619c5cb6SVlad Zolotarov 140867c431a5SAriel Elior int bnx2x_get_q_logical_state(struct bnx2x *bp, 140967c431a5SAriel Elior struct bnx2x_queue_sp_obj *obj); 141067c431a5SAriel Elior 1411619c5cb6SVlad Zolotarov /********************* VLAN-MAC ****************/ 1412619c5cb6SVlad Zolotarov void bnx2x_init_mac_obj(struct bnx2x *bp, 1413619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *mac_obj, 1414619c5cb6SVlad Zolotarov u8 cl_id, u32 cid, u8 func_id, void *rdata, 1415619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping, int state, 1416619c5cb6SVlad Zolotarov unsigned long *pstate, bnx2x_obj_type type, 1417619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *macs_pool); 1418619c5cb6SVlad Zolotarov 1419619c5cb6SVlad Zolotarov void bnx2x_init_vlan_obj(struct bnx2x *bp, 1420619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *vlan_obj, 1421619c5cb6SVlad Zolotarov u8 cl_id, u32 cid, u8 func_id, void *rdata, 1422619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping, int state, 1423619c5cb6SVlad Zolotarov unsigned long *pstate, bnx2x_obj_type type, 1424619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *vlans_pool); 1425619c5cb6SVlad Zolotarov 142605cc5a39SYuval Mintz void bnx2x_init_vlan_mac_obj(struct bnx2x *bp, 142705cc5a39SYuval Mintz struct bnx2x_vlan_mac_obj *vlan_mac_obj, 142805cc5a39SYuval Mintz u8 cl_id, u32 cid, u8 func_id, void *rdata, 142905cc5a39SYuval Mintz dma_addr_t rdata_mapping, int state, 143005cc5a39SYuval Mintz unsigned long *pstate, bnx2x_obj_type type, 143105cc5a39SYuval Mintz struct bnx2x_credit_pool_obj *macs_pool, 143205cc5a39SYuval Mintz struct bnx2x_credit_pool_obj *vlans_pool); 143305cc5a39SYuval Mintz 14348b09be5fSYuval Mintz int bnx2x_vlan_mac_h_read_lock(struct bnx2x *bp, 14358b09be5fSYuval Mintz struct bnx2x_vlan_mac_obj *o); 14368b09be5fSYuval Mintz void bnx2x_vlan_mac_h_read_unlock(struct bnx2x *bp, 14378b09be5fSYuval Mintz struct bnx2x_vlan_mac_obj *o); 14388b09be5fSYuval Mintz int bnx2x_vlan_mac_h_write_lock(struct bnx2x *bp, 14398b09be5fSYuval Mintz struct bnx2x_vlan_mac_obj *o); 1440619c5cb6SVlad Zolotarov int bnx2x_config_vlan_mac(struct bnx2x *bp, 1441619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_params *p); 1442619c5cb6SVlad Zolotarov 1443619c5cb6SVlad Zolotarov int bnx2x_vlan_mac_move(struct bnx2x *bp, 1444619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_params *p, 1445619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *dest_o); 1446619c5cb6SVlad Zolotarov 1447619c5cb6SVlad Zolotarov /********************* RX MODE ****************/ 1448619c5cb6SVlad Zolotarov 1449619c5cb6SVlad Zolotarov void bnx2x_init_rx_mode_obj(struct bnx2x *bp, 1450619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_obj *o); 1451619c5cb6SVlad Zolotarov 1452619c5cb6SVlad Zolotarov /** 14531aa8b471SBen Hutchings * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters. 1454619c5cb6SVlad Zolotarov * 14551aa8b471SBen Hutchings * @p: Command parameters 1456619c5cb6SVlad Zolotarov * 145716a5fd92SYuval Mintz * Return: 0 - if operation was successful and there is no pending completions, 1458619c5cb6SVlad Zolotarov * positive number - if there are pending completions, 1459619c5cb6SVlad Zolotarov * negative - if there were errors 1460619c5cb6SVlad Zolotarov */ 1461619c5cb6SVlad Zolotarov int bnx2x_config_rx_mode(struct bnx2x *bp, 1462619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_ramrod_params *p); 1463619c5cb6SVlad Zolotarov 1464619c5cb6SVlad Zolotarov /****************** MULTICASTS ****************/ 1465619c5cb6SVlad Zolotarov 1466619c5cb6SVlad Zolotarov void bnx2x_init_mcast_obj(struct bnx2x *bp, 1467619c5cb6SVlad Zolotarov struct bnx2x_mcast_obj *mcast_obj, 1468619c5cb6SVlad Zolotarov u8 mcast_cl_id, u32 mcast_cid, u8 func_id, 1469619c5cb6SVlad Zolotarov u8 engine_id, void *rdata, dma_addr_t rdata_mapping, 1470619c5cb6SVlad Zolotarov int state, unsigned long *pstate, 1471619c5cb6SVlad Zolotarov bnx2x_obj_type type); 1472619c5cb6SVlad Zolotarov 1473619c5cb6SVlad Zolotarov /** 14741aa8b471SBen Hutchings * bnx2x_config_mcast - Configure multicast MACs list. 14751aa8b471SBen Hutchings * 14761aa8b471SBen Hutchings * @cmd: command to execute: BNX2X_MCAST_CMD_X 14771aa8b471SBen Hutchings * 14781aa8b471SBen Hutchings * May configure a new list 1479619c5cb6SVlad Zolotarov * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up 1480619c5cb6SVlad Zolotarov * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current 1481619c5cb6SVlad Zolotarov * configuration, continue to execute the pending commands 1482619c5cb6SVlad Zolotarov * (BNX2X_MCAST_CMD_CONT). 1483619c5cb6SVlad Zolotarov * 1484619c5cb6SVlad Zolotarov * If previous command is still pending or if number of MACs to 1485619c5cb6SVlad Zolotarov * configure is more that maximum number of MACs in one command, 1486619c5cb6SVlad Zolotarov * the current command will be enqueued to the tail of the 1487619c5cb6SVlad Zolotarov * pending commands list. 1488619c5cb6SVlad Zolotarov * 148916a5fd92SYuval Mintz * Return: 0 is operation was successful and there are no pending completions, 1490619c5cb6SVlad Zolotarov * negative if there were errors, positive if there are pending 1491619c5cb6SVlad Zolotarov * completions. 1492619c5cb6SVlad Zolotarov */ 1493619c5cb6SVlad Zolotarov int bnx2x_config_mcast(struct bnx2x *bp, 149486564c3fSYuval Mintz struct bnx2x_mcast_ramrod_params *p, 149586564c3fSYuval Mintz enum bnx2x_mcast_cmd cmd); 1496619c5cb6SVlad Zolotarov 1497619c5cb6SVlad Zolotarov /****************** CREDIT POOL ****************/ 1498619c5cb6SVlad Zolotarov void bnx2x_init_mac_credit_pool(struct bnx2x *bp, 1499619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *p, u8 func_id, 1500619c5cb6SVlad Zolotarov u8 func_num); 1501619c5cb6SVlad Zolotarov void bnx2x_init_vlan_credit_pool(struct bnx2x *bp, 1502619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *p, u8 func_id, 1503619c5cb6SVlad Zolotarov u8 func_num); 150405cc5a39SYuval Mintz void bnx2x_init_credit_pool(struct bnx2x_credit_pool_obj *p, 150505cc5a39SYuval Mintz int base, int credit); 1506619c5cb6SVlad Zolotarov 1507619c5cb6SVlad Zolotarov /****************** RSS CONFIGURATION ****************/ 1508619c5cb6SVlad Zolotarov void bnx2x_init_rss_config_obj(struct bnx2x *bp, 1509619c5cb6SVlad Zolotarov struct bnx2x_rss_config_obj *rss_obj, 1510619c5cb6SVlad Zolotarov u8 cl_id, u32 cid, u8 func_id, u8 engine_id, 1511619c5cb6SVlad Zolotarov void *rdata, dma_addr_t rdata_mapping, 1512619c5cb6SVlad Zolotarov int state, unsigned long *pstate, 1513619c5cb6SVlad Zolotarov bnx2x_obj_type type); 1514619c5cb6SVlad Zolotarov 1515619c5cb6SVlad Zolotarov /** 15161aa8b471SBen Hutchings * bnx2x_config_rss - Updates RSS configuration according to provided parameters 1517619c5cb6SVlad Zolotarov * 15181aa8b471SBen Hutchings * Return: 0 in case of success 1519619c5cb6SVlad Zolotarov */ 1520619c5cb6SVlad Zolotarov int bnx2x_config_rss(struct bnx2x *bp, 1521619c5cb6SVlad Zolotarov struct bnx2x_config_rss_params *p); 1522619c5cb6SVlad Zolotarov 1523619c5cb6SVlad Zolotarov /** 15241aa8b471SBen Hutchings * bnx2x_get_rss_ind_table - Return the current ind_table configuration. 1525619c5cb6SVlad Zolotarov * 15261aa8b471SBen Hutchings * @ind_table: buffer to fill with the current indirection 1527619c5cb6SVlad Zolotarov * table content. Should be at least 1528619c5cb6SVlad Zolotarov * T_ETH_INDIRECTION_TABLE_SIZE bytes long. 1529619c5cb6SVlad Zolotarov */ 1530619c5cb6SVlad Zolotarov void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj, 1531619c5cb6SVlad Zolotarov u8 *ind_table); 1532619c5cb6SVlad Zolotarov 153305cc5a39SYuval Mintz #define PF_MAC_CREDIT_E2(bp, func_num) \ 153405cc5a39SYuval Mintz ((MAX_MAC_CREDIT_E2 - GET_NUM_VFS_PER_PATH(bp) * VF_MAC_CREDIT_CNT) / \ 153505cc5a39SYuval Mintz func_num + GET_NUM_VFS_PER_PF(bp) * VF_MAC_CREDIT_CNT) 153605cc5a39SYuval Mintz 153705cc5a39SYuval Mintz #define PF_VLAN_CREDIT_E2(bp, func_num) \ 153805cc5a39SYuval Mintz ((MAX_MAC_CREDIT_E2 - GET_NUM_VFS_PER_PATH(bp) * VF_VLAN_CREDIT_CNT) / \ 153905cc5a39SYuval Mintz func_num + GET_NUM_VFS_PER_PF(bp) * VF_VLAN_CREDIT_CNT) 154005cc5a39SYuval Mintz 1541619c5cb6SVlad Zolotarov #endif /* BNX2X_SP_VERBS */ 1542