1619c5cb6SVlad Zolotarov /* bnx2x_sp.h: Broadcom Everest network driver. 2619c5cb6SVlad Zolotarov * 385b26ea1SAriel Elior * Copyright (c) 2011-2012 Broadcom Corporation 4619c5cb6SVlad Zolotarov * 5619c5cb6SVlad Zolotarov * Unless you and Broadcom execute a separate written software license 6619c5cb6SVlad Zolotarov * agreement governing use of this software, this software is licensed to you 7619c5cb6SVlad Zolotarov * under the terms of the GNU General Public License version 2, available 8619c5cb6SVlad Zolotarov * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL"). 9619c5cb6SVlad Zolotarov * 10619c5cb6SVlad Zolotarov * Notwithstanding the above, under no circumstances may you combine this 11619c5cb6SVlad Zolotarov * software in any way with any other Broadcom software provided under a 12619c5cb6SVlad Zolotarov * license other than the GPL, without Broadcom's express prior written 13619c5cb6SVlad Zolotarov * consent. 14619c5cb6SVlad Zolotarov * 15619c5cb6SVlad Zolotarov * Maintained by: Eilon Greenstein <eilong@broadcom.com> 16619c5cb6SVlad Zolotarov * Written by: Vladislav Zolotarov 17619c5cb6SVlad Zolotarov * 18619c5cb6SVlad Zolotarov */ 19619c5cb6SVlad Zolotarov #ifndef BNX2X_SP_VERBS 20619c5cb6SVlad Zolotarov #define BNX2X_SP_VERBS 21042181f5SVladislav Zolotarov 22619c5cb6SVlad Zolotarov struct bnx2x; 23619c5cb6SVlad Zolotarov struct eth_context; 24042181f5SVladislav Zolotarov 25619c5cb6SVlad Zolotarov /* Bits representing general command's configuration */ 26619c5cb6SVlad Zolotarov enum { 27619c5cb6SVlad Zolotarov RAMROD_TX, 28619c5cb6SVlad Zolotarov RAMROD_RX, 29619c5cb6SVlad Zolotarov /* Wait until all pending commands complete */ 30619c5cb6SVlad Zolotarov RAMROD_COMP_WAIT, 31619c5cb6SVlad Zolotarov /* Don't send a ramrod, only update a registry */ 32619c5cb6SVlad Zolotarov RAMROD_DRV_CLR_ONLY, 33619c5cb6SVlad Zolotarov /* Configure HW according to the current object state */ 34619c5cb6SVlad Zolotarov RAMROD_RESTORE, 35619c5cb6SVlad Zolotarov /* Execute the next command now */ 36619c5cb6SVlad Zolotarov RAMROD_EXEC, 37619c5cb6SVlad Zolotarov /* 38619c5cb6SVlad Zolotarov * Don't add a new command and continue execution of posponed 39619c5cb6SVlad Zolotarov * commands. If not set a new command will be added to the 40619c5cb6SVlad Zolotarov * pending commands list. 41619c5cb6SVlad Zolotarov */ 42619c5cb6SVlad Zolotarov RAMROD_CONT, 43619c5cb6SVlad Zolotarov }; 44042181f5SVladislav Zolotarov 45619c5cb6SVlad Zolotarov typedef enum { 46619c5cb6SVlad Zolotarov BNX2X_OBJ_TYPE_RX, 47619c5cb6SVlad Zolotarov BNX2X_OBJ_TYPE_TX, 48619c5cb6SVlad Zolotarov BNX2X_OBJ_TYPE_RX_TX, 49619c5cb6SVlad Zolotarov } bnx2x_obj_type; 50042181f5SVladislav Zolotarov 51619c5cb6SVlad Zolotarov /* Filtering states */ 52619c5cb6SVlad Zolotarov enum { 53619c5cb6SVlad Zolotarov BNX2X_FILTER_MAC_PENDING, 54619c5cb6SVlad Zolotarov BNX2X_FILTER_VLAN_PENDING, 55619c5cb6SVlad Zolotarov BNX2X_FILTER_VLAN_MAC_PENDING, 56619c5cb6SVlad Zolotarov BNX2X_FILTER_RX_MODE_PENDING, 57619c5cb6SVlad Zolotarov BNX2X_FILTER_RX_MODE_SCHED, 58619c5cb6SVlad Zolotarov BNX2X_FILTER_ISCSI_ETH_START_SCHED, 59619c5cb6SVlad Zolotarov BNX2X_FILTER_ISCSI_ETH_STOP_SCHED, 60619c5cb6SVlad Zolotarov BNX2X_FILTER_FCOE_ETH_START_SCHED, 61619c5cb6SVlad Zolotarov BNX2X_FILTER_FCOE_ETH_STOP_SCHED, 62619c5cb6SVlad Zolotarov BNX2X_FILTER_MCAST_PENDING, 63619c5cb6SVlad Zolotarov BNX2X_FILTER_MCAST_SCHED, 64619c5cb6SVlad Zolotarov BNX2X_FILTER_RSS_CONF_PENDING, 65619c5cb6SVlad Zolotarov }; 66042181f5SVladislav Zolotarov 67619c5cb6SVlad Zolotarov struct bnx2x_raw_obj { 68619c5cb6SVlad Zolotarov u8 func_id; 69042181f5SVladislav Zolotarov 70619c5cb6SVlad Zolotarov /* Queue params */ 71619c5cb6SVlad Zolotarov u8 cl_id; 72619c5cb6SVlad Zolotarov u32 cid; 73042181f5SVladislav Zolotarov 74619c5cb6SVlad Zolotarov /* Ramrod data buffer params */ 75619c5cb6SVlad Zolotarov void *rdata; 76619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping; 77619c5cb6SVlad Zolotarov 78619c5cb6SVlad Zolotarov /* Ramrod state params */ 79619c5cb6SVlad Zolotarov int state; /* "ramrod is pending" state bit */ 80619c5cb6SVlad Zolotarov unsigned long *pstate; /* pointer to state buffer */ 81619c5cb6SVlad Zolotarov 82619c5cb6SVlad Zolotarov bnx2x_obj_type obj_type; 83619c5cb6SVlad Zolotarov 84619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, 85619c5cb6SVlad Zolotarov struct bnx2x_raw_obj *o); 86619c5cb6SVlad Zolotarov 87619c5cb6SVlad Zolotarov bool (*check_pending)(struct bnx2x_raw_obj *o); 88619c5cb6SVlad Zolotarov void (*clear_pending)(struct bnx2x_raw_obj *o); 89619c5cb6SVlad Zolotarov void (*set_pending)(struct bnx2x_raw_obj *o); 90619c5cb6SVlad Zolotarov }; 91619c5cb6SVlad Zolotarov 92619c5cb6SVlad Zolotarov /************************* VLAN-MAC commands related parameters ***************/ 93619c5cb6SVlad Zolotarov struct bnx2x_mac_ramrod_data { 94619c5cb6SVlad Zolotarov u8 mac[ETH_ALEN]; 95619c5cb6SVlad Zolotarov }; 96619c5cb6SVlad Zolotarov 97619c5cb6SVlad Zolotarov struct bnx2x_vlan_ramrod_data { 98619c5cb6SVlad Zolotarov u16 vlan; 99619c5cb6SVlad Zolotarov }; 100619c5cb6SVlad Zolotarov 101619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_data { 102619c5cb6SVlad Zolotarov u8 mac[ETH_ALEN]; 103619c5cb6SVlad Zolotarov u16 vlan; 104619c5cb6SVlad Zolotarov }; 105619c5cb6SVlad Zolotarov 106619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data { 107619c5cb6SVlad Zolotarov struct bnx2x_mac_ramrod_data mac; 108619c5cb6SVlad Zolotarov struct bnx2x_vlan_ramrod_data vlan; 109619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_data vlan_mac; 110619c5cb6SVlad Zolotarov }; 111619c5cb6SVlad Zolotarov 112619c5cb6SVlad Zolotarov /* VLAN_MAC commands */ 113619c5cb6SVlad Zolotarov enum bnx2x_vlan_mac_cmd { 114619c5cb6SVlad Zolotarov BNX2X_VLAN_MAC_ADD, 115619c5cb6SVlad Zolotarov BNX2X_VLAN_MAC_DEL, 116619c5cb6SVlad Zolotarov BNX2X_VLAN_MAC_MOVE, 117619c5cb6SVlad Zolotarov }; 118619c5cb6SVlad Zolotarov 119619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_data { 120619c5cb6SVlad Zolotarov /* Requested command: BNX2X_VLAN_MAC_XX */ 121619c5cb6SVlad Zolotarov enum bnx2x_vlan_mac_cmd cmd; 122619c5cb6SVlad Zolotarov /* 123619c5cb6SVlad Zolotarov * used to contain the data related vlan_mac_flags bits from 124619c5cb6SVlad Zolotarov * ramrod parameters. 125619c5cb6SVlad Zolotarov */ 126619c5cb6SVlad Zolotarov unsigned long vlan_mac_flags; 127619c5cb6SVlad Zolotarov 128619c5cb6SVlad Zolotarov /* Needed for MOVE command */ 129619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *target_obj; 130619c5cb6SVlad Zolotarov 131619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data u; 132619c5cb6SVlad Zolotarov }; 133619c5cb6SVlad Zolotarov 134619c5cb6SVlad Zolotarov /*************************** Exe Queue obj ************************************/ 135619c5cb6SVlad Zolotarov union bnx2x_exe_queue_cmd_data { 136619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_data vlan_mac; 137619c5cb6SVlad Zolotarov 138619c5cb6SVlad Zolotarov struct { 139619c5cb6SVlad Zolotarov /* TODO */ 140619c5cb6SVlad Zolotarov } mcast; 141619c5cb6SVlad Zolotarov }; 142619c5cb6SVlad Zolotarov 143619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem { 144619c5cb6SVlad Zolotarov struct list_head link; 145619c5cb6SVlad Zolotarov 146619c5cb6SVlad Zolotarov /* Length of this element in the exe_chunk. */ 147619c5cb6SVlad Zolotarov int cmd_len; 148619c5cb6SVlad Zolotarov 149619c5cb6SVlad Zolotarov union bnx2x_exe_queue_cmd_data cmd_data; 150619c5cb6SVlad Zolotarov }; 151619c5cb6SVlad Zolotarov 152619c5cb6SVlad Zolotarov union bnx2x_qable_obj; 153619c5cb6SVlad Zolotarov 154619c5cb6SVlad Zolotarov union bnx2x_exeq_comp_elem { 155619c5cb6SVlad Zolotarov union event_ring_elem *elem; 156619c5cb6SVlad Zolotarov }; 157619c5cb6SVlad Zolotarov 158619c5cb6SVlad Zolotarov struct bnx2x_exe_queue_obj; 159619c5cb6SVlad Zolotarov 160619c5cb6SVlad Zolotarov typedef int (*exe_q_validate)(struct bnx2x *bp, 161619c5cb6SVlad Zolotarov union bnx2x_qable_obj *o, 162619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem *elem); 163619c5cb6SVlad Zolotarov 164460a25cdSYuval Mintz typedef int (*exe_q_remove)(struct bnx2x *bp, 165460a25cdSYuval Mintz union bnx2x_qable_obj *o, 166460a25cdSYuval Mintz struct bnx2x_exeq_elem *elem); 167460a25cdSYuval Mintz 168619c5cb6SVlad Zolotarov /** 169619c5cb6SVlad Zolotarov * @return positive is entry was optimized, 0 - if not, negative 170619c5cb6SVlad Zolotarov * in case of an error. 171619c5cb6SVlad Zolotarov */ 172619c5cb6SVlad Zolotarov typedef int (*exe_q_optimize)(struct bnx2x *bp, 173619c5cb6SVlad Zolotarov union bnx2x_qable_obj *o, 174619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem *elem); 175619c5cb6SVlad Zolotarov typedef int (*exe_q_execute)(struct bnx2x *bp, 176619c5cb6SVlad Zolotarov union bnx2x_qable_obj *o, 177619c5cb6SVlad Zolotarov struct list_head *exe_chunk, 178619c5cb6SVlad Zolotarov unsigned long *ramrod_flags); 179619c5cb6SVlad Zolotarov typedef struct bnx2x_exeq_elem * 180619c5cb6SVlad Zolotarov (*exe_q_get)(struct bnx2x_exe_queue_obj *o, 181619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem *elem); 182619c5cb6SVlad Zolotarov 183619c5cb6SVlad Zolotarov struct bnx2x_exe_queue_obj { 184619c5cb6SVlad Zolotarov /* 185619c5cb6SVlad Zolotarov * Commands pending for an execution. 186619c5cb6SVlad Zolotarov */ 187619c5cb6SVlad Zolotarov struct list_head exe_queue; 188619c5cb6SVlad Zolotarov 189619c5cb6SVlad Zolotarov /* 190619c5cb6SVlad Zolotarov * Commands pending for an completion. 191619c5cb6SVlad Zolotarov */ 192619c5cb6SVlad Zolotarov struct list_head pending_comp; 193619c5cb6SVlad Zolotarov 194619c5cb6SVlad Zolotarov spinlock_t lock; 195619c5cb6SVlad Zolotarov 196619c5cb6SVlad Zolotarov /* Maximum length of commands' list for one execution */ 197619c5cb6SVlad Zolotarov int exe_chunk_len; 198619c5cb6SVlad Zolotarov 199619c5cb6SVlad Zolotarov union bnx2x_qable_obj *owner; 200619c5cb6SVlad Zolotarov 201619c5cb6SVlad Zolotarov /****** Virtual functions ******/ 202619c5cb6SVlad Zolotarov /** 203619c5cb6SVlad Zolotarov * Called before commands execution for commands that are really 204619c5cb6SVlad Zolotarov * going to be executed (after 'optimize'). 205619c5cb6SVlad Zolotarov * 206619c5cb6SVlad Zolotarov * Must run under exe_queue->lock 207619c5cb6SVlad Zolotarov */ 208619c5cb6SVlad Zolotarov exe_q_validate validate; 209619c5cb6SVlad Zolotarov 210460a25cdSYuval Mintz /** 211460a25cdSYuval Mintz * Called before removing pending commands, cleaning allocated 212460a25cdSYuval Mintz * resources (e.g., credits from validate) 213460a25cdSYuval Mintz */ 214460a25cdSYuval Mintz exe_q_remove remove; 215619c5cb6SVlad Zolotarov 216619c5cb6SVlad Zolotarov /** 217619c5cb6SVlad Zolotarov * This will try to cancel the current pending commands list 218619c5cb6SVlad Zolotarov * considering the new command. 219619c5cb6SVlad Zolotarov * 220460a25cdSYuval Mintz * Returns the number of optimized commands or a negative error code 221460a25cdSYuval Mintz * 222619c5cb6SVlad Zolotarov * Must run under exe_queue->lock 223619c5cb6SVlad Zolotarov */ 224619c5cb6SVlad Zolotarov exe_q_optimize optimize; 225619c5cb6SVlad Zolotarov 226619c5cb6SVlad Zolotarov /** 227619c5cb6SVlad Zolotarov * Run the next commands chunk (owner specific). 228619c5cb6SVlad Zolotarov */ 229619c5cb6SVlad Zolotarov exe_q_execute execute; 230619c5cb6SVlad Zolotarov 231619c5cb6SVlad Zolotarov /** 232619c5cb6SVlad Zolotarov * Return the exe_queue element containing the specific command 233619c5cb6SVlad Zolotarov * if any. Otherwise return NULL. 234619c5cb6SVlad Zolotarov */ 235619c5cb6SVlad Zolotarov exe_q_get get; 236619c5cb6SVlad Zolotarov }; 237619c5cb6SVlad Zolotarov /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/ 238619c5cb6SVlad Zolotarov /* 239619c5cb6SVlad Zolotarov * Element in the VLAN_MAC registry list having all currenty configured 240619c5cb6SVlad Zolotarov * rules. 241619c5cb6SVlad Zolotarov */ 242619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_registry_elem { 243619c5cb6SVlad Zolotarov struct list_head link; 244619c5cb6SVlad Zolotarov 245619c5cb6SVlad Zolotarov /* 246619c5cb6SVlad Zolotarov * Used to store the cam offset used for the mac/vlan/vlan-mac. 247619c5cb6SVlad Zolotarov * Relevant for 57710 and 57711 only. VLANs and MACs share the 248619c5cb6SVlad Zolotarov * same CAM for these chips. 249619c5cb6SVlad Zolotarov */ 250619c5cb6SVlad Zolotarov int cam_offset; 251619c5cb6SVlad Zolotarov 252619c5cb6SVlad Zolotarov /* Needed for DEL and RESTORE flows */ 253619c5cb6SVlad Zolotarov unsigned long vlan_mac_flags; 254619c5cb6SVlad Zolotarov 255619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data u; 256619c5cb6SVlad Zolotarov }; 257619c5cb6SVlad Zolotarov 258619c5cb6SVlad Zolotarov /* Bits representing VLAN_MAC commands specific flags */ 259619c5cb6SVlad Zolotarov enum { 260619c5cb6SVlad Zolotarov BNX2X_UC_LIST_MAC, 261619c5cb6SVlad Zolotarov BNX2X_ETH_MAC, 262619c5cb6SVlad Zolotarov BNX2X_ISCSI_ETH_MAC, 263619c5cb6SVlad Zolotarov BNX2X_NETQ_ETH_MAC, 264619c5cb6SVlad Zolotarov BNX2X_DONT_CONSUME_CAM_CREDIT, 265619c5cb6SVlad Zolotarov BNX2X_DONT_CONSUME_CAM_CREDIT_DEST, 266619c5cb6SVlad Zolotarov }; 267619c5cb6SVlad Zolotarov 268619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_params { 269619c5cb6SVlad Zolotarov /* Object to run the command from */ 270619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *vlan_mac_obj; 271619c5cb6SVlad Zolotarov 272619c5cb6SVlad Zolotarov /* General command flags: COMP_WAIT, etc. */ 273619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 274619c5cb6SVlad Zolotarov 275619c5cb6SVlad Zolotarov /* Command specific configuration request */ 276619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_data user_req; 277619c5cb6SVlad Zolotarov }; 278619c5cb6SVlad Zolotarov 279619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj { 280619c5cb6SVlad Zolotarov struct bnx2x_raw_obj raw; 281619c5cb6SVlad Zolotarov 282619c5cb6SVlad Zolotarov /* Bookkeeping list: will prevent the addition of already existing 283619c5cb6SVlad Zolotarov * entries. 284619c5cb6SVlad Zolotarov */ 285619c5cb6SVlad Zolotarov struct list_head head; 286619c5cb6SVlad Zolotarov 287619c5cb6SVlad Zolotarov /* TODO: Add it's initialization in the init functions */ 288619c5cb6SVlad Zolotarov struct bnx2x_exe_queue_obj exe_queue; 289619c5cb6SVlad Zolotarov 290619c5cb6SVlad Zolotarov /* MACs credit pool */ 291619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *macs_pool; 292619c5cb6SVlad Zolotarov 293619c5cb6SVlad Zolotarov /* VLANs credit pool */ 294619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *vlans_pool; 295619c5cb6SVlad Zolotarov 296619c5cb6SVlad Zolotarov /* RAMROD command to be used */ 297619c5cb6SVlad Zolotarov int ramrod_cmd; 298619c5cb6SVlad Zolotarov 299ed5162a0SAriel Elior /* copy first n elements onto preallocated buffer 300ed5162a0SAriel Elior * 301ed5162a0SAriel Elior * @param n number of elements to get 302ed5162a0SAriel Elior * @param buf buffer preallocated by caller into which elements 303ed5162a0SAriel Elior * will be copied. Note elements are 4-byte aligned 304ed5162a0SAriel Elior * so buffer size must be able to accomodate the 305ed5162a0SAriel Elior * aligned elements. 306ed5162a0SAriel Elior * 307ed5162a0SAriel Elior * @return number of copied bytes 308ed5162a0SAriel Elior */ 309ed5162a0SAriel Elior int (*get_n_elements)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o, 310ed5162a0SAriel Elior int n, u8 *buf); 311ed5162a0SAriel Elior 312619c5cb6SVlad Zolotarov /** 313619c5cb6SVlad Zolotarov * Checks if ADD-ramrod with the given params may be performed. 314619c5cb6SVlad Zolotarov * 315619c5cb6SVlad Zolotarov * @return zero if the element may be added 316619c5cb6SVlad Zolotarov */ 317619c5cb6SVlad Zolotarov 318619c5cb6SVlad Zolotarov int (*check_add)(struct bnx2x_vlan_mac_obj *o, 319619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data *data); 320619c5cb6SVlad Zolotarov 321619c5cb6SVlad Zolotarov /** 322619c5cb6SVlad Zolotarov * Checks if DEL-ramrod with the given params may be performed. 323619c5cb6SVlad Zolotarov * 324619c5cb6SVlad Zolotarov * @return true if the element may be deleted 325619c5cb6SVlad Zolotarov */ 326619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_registry_elem * 327619c5cb6SVlad Zolotarov (*check_del)(struct bnx2x_vlan_mac_obj *o, 328619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data *data); 329619c5cb6SVlad Zolotarov 330619c5cb6SVlad Zolotarov /** 331619c5cb6SVlad Zolotarov * Checks if DEL-ramrod with the given params may be performed. 332619c5cb6SVlad Zolotarov * 333619c5cb6SVlad Zolotarov * @return true if the element may be deleted 334619c5cb6SVlad Zolotarov */ 335619c5cb6SVlad Zolotarov bool (*check_move)(struct bnx2x_vlan_mac_obj *src_o, 336619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *dst_o, 337619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data *data); 338619c5cb6SVlad Zolotarov 339619c5cb6SVlad Zolotarov /** 340619c5cb6SVlad Zolotarov * Update the relevant credit object(s) (consume/return 341619c5cb6SVlad Zolotarov * correspondingly). 342619c5cb6SVlad Zolotarov */ 343619c5cb6SVlad Zolotarov bool (*get_credit)(struct bnx2x_vlan_mac_obj *o); 344619c5cb6SVlad Zolotarov bool (*put_credit)(struct bnx2x_vlan_mac_obj *o); 345619c5cb6SVlad Zolotarov bool (*get_cam_offset)(struct bnx2x_vlan_mac_obj *o, int *offset); 346619c5cb6SVlad Zolotarov bool (*put_cam_offset)(struct bnx2x_vlan_mac_obj *o, int offset); 347619c5cb6SVlad Zolotarov 348619c5cb6SVlad Zolotarov /** 349619c5cb6SVlad Zolotarov * Configures one rule in the ramrod data buffer. 350619c5cb6SVlad Zolotarov */ 351619c5cb6SVlad Zolotarov void (*set_one_rule)(struct bnx2x *bp, 352619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *o, 353619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem *elem, int rule_idx, 354619c5cb6SVlad Zolotarov int cam_offset); 355619c5cb6SVlad Zolotarov 356619c5cb6SVlad Zolotarov /** 357619c5cb6SVlad Zolotarov * Delete all configured elements having the given 358619c5cb6SVlad Zolotarov * vlan_mac_flags specification. Assumes no pending for 359619c5cb6SVlad Zolotarov * execution commands. Will schedule all all currently 360619c5cb6SVlad Zolotarov * configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags 361619c5cb6SVlad Zolotarov * specification for deletion and will use the given 362619c5cb6SVlad Zolotarov * ramrod_flags for the last DEL operation. 363619c5cb6SVlad Zolotarov * 364619c5cb6SVlad Zolotarov * @param bp 365619c5cb6SVlad Zolotarov * @param o 366619c5cb6SVlad Zolotarov * @param ramrod_flags RAMROD_XX flags 367619c5cb6SVlad Zolotarov * 368619c5cb6SVlad Zolotarov * @return 0 if the last operation has completed successfully 369619c5cb6SVlad Zolotarov * and there are no more elements left, positive value 370619c5cb6SVlad Zolotarov * if there are pending for completion commands, 371619c5cb6SVlad Zolotarov * negative value in case of failure. 372619c5cb6SVlad Zolotarov */ 373619c5cb6SVlad Zolotarov int (*delete_all)(struct bnx2x *bp, 374619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *o, 375619c5cb6SVlad Zolotarov unsigned long *vlan_mac_flags, 376619c5cb6SVlad Zolotarov unsigned long *ramrod_flags); 377619c5cb6SVlad Zolotarov 378619c5cb6SVlad Zolotarov /** 379619c5cb6SVlad Zolotarov * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously 380619c5cb6SVlad Zolotarov * configured elements list. 381619c5cb6SVlad Zolotarov * 382619c5cb6SVlad Zolotarov * @param bp 383619c5cb6SVlad Zolotarov * @param p Command parameters (RAMROD_COMP_WAIT bit in 384619c5cb6SVlad Zolotarov * ramrod_flags is only taken into an account) 385619c5cb6SVlad Zolotarov * @param ppos a pointer to the cooky that should be given back in the 386619c5cb6SVlad Zolotarov * next call to make function handle the next element. If 387619c5cb6SVlad Zolotarov * *ppos is set to NULL it will restart the iterator. 388619c5cb6SVlad Zolotarov * If returned *ppos == NULL this means that the last 389619c5cb6SVlad Zolotarov * element has been handled. 390619c5cb6SVlad Zolotarov * 391619c5cb6SVlad Zolotarov * @return int 392619c5cb6SVlad Zolotarov */ 393619c5cb6SVlad Zolotarov int (*restore)(struct bnx2x *bp, 394619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_params *p, 395619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_registry_elem **ppos); 396619c5cb6SVlad Zolotarov 397619c5cb6SVlad Zolotarov /** 398619c5cb6SVlad Zolotarov * Should be called on a completion arival. 399619c5cb6SVlad Zolotarov * 400619c5cb6SVlad Zolotarov * @param bp 401619c5cb6SVlad Zolotarov * @param o 402619c5cb6SVlad Zolotarov * @param cqe Completion element we are handling 403619c5cb6SVlad Zolotarov * @param ramrod_flags if RAMROD_CONT is set the next bulk of 404619c5cb6SVlad Zolotarov * pending commands will be executed. 405619c5cb6SVlad Zolotarov * RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE 406619c5cb6SVlad Zolotarov * may also be set if needed. 407619c5cb6SVlad Zolotarov * 408619c5cb6SVlad Zolotarov * @return 0 if there are neither pending nor waiting for 409619c5cb6SVlad Zolotarov * completion commands. Positive value if there are 410619c5cb6SVlad Zolotarov * pending for execution or for completion commands. 411619c5cb6SVlad Zolotarov * Negative value in case of an error (including an 412619c5cb6SVlad Zolotarov * error in the cqe). 413619c5cb6SVlad Zolotarov */ 414619c5cb6SVlad Zolotarov int (*complete)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o, 415619c5cb6SVlad Zolotarov union event_ring_elem *cqe, 416619c5cb6SVlad Zolotarov unsigned long *ramrod_flags); 417619c5cb6SVlad Zolotarov 418619c5cb6SVlad Zolotarov /** 419619c5cb6SVlad Zolotarov * Wait for completion of all commands. Don't schedule new ones, 420619c5cb6SVlad Zolotarov * just wait. It assumes that the completion code will schedule 421619c5cb6SVlad Zolotarov * for new commands. 422619c5cb6SVlad Zolotarov */ 423619c5cb6SVlad Zolotarov int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o); 424619c5cb6SVlad Zolotarov }; 425619c5cb6SVlad Zolotarov 4260a52fd01SYuval Mintz enum { 4270a52fd01SYuval Mintz BNX2X_LLH_CAM_ISCSI_ETH_LINE = 0, 4280a52fd01SYuval Mintz BNX2X_LLH_CAM_ETH_LINE, 4290a52fd01SYuval Mintz BNX2X_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2 4300a52fd01SYuval Mintz }; 4310a52fd01SYuval Mintz 4320a52fd01SYuval Mintz 433619c5cb6SVlad Zolotarov /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */ 434619c5cb6SVlad Zolotarov 435619c5cb6SVlad Zolotarov /* RX_MODE ramrod spesial flags: set in rx_mode_flags field in 436619c5cb6SVlad Zolotarov * a bnx2x_rx_mode_ramrod_params. 437619c5cb6SVlad Zolotarov */ 438619c5cb6SVlad Zolotarov enum { 439619c5cb6SVlad Zolotarov BNX2X_RX_MODE_FCOE_ETH, 440619c5cb6SVlad Zolotarov BNX2X_RX_MODE_ISCSI_ETH, 441619c5cb6SVlad Zolotarov }; 442619c5cb6SVlad Zolotarov 443619c5cb6SVlad Zolotarov enum { 444619c5cb6SVlad Zolotarov BNX2X_ACCEPT_UNICAST, 445619c5cb6SVlad Zolotarov BNX2X_ACCEPT_MULTICAST, 446619c5cb6SVlad Zolotarov BNX2X_ACCEPT_ALL_UNICAST, 447619c5cb6SVlad Zolotarov BNX2X_ACCEPT_ALL_MULTICAST, 448619c5cb6SVlad Zolotarov BNX2X_ACCEPT_BROADCAST, 449619c5cb6SVlad Zolotarov BNX2X_ACCEPT_UNMATCHED, 450619c5cb6SVlad Zolotarov BNX2X_ACCEPT_ANY_VLAN 451619c5cb6SVlad Zolotarov }; 452619c5cb6SVlad Zolotarov 453619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_ramrod_params { 454619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_obj *rx_mode_obj; 455619c5cb6SVlad Zolotarov unsigned long *pstate; 456619c5cb6SVlad Zolotarov int state; 457619c5cb6SVlad Zolotarov u8 cl_id; 458619c5cb6SVlad Zolotarov u32 cid; 459619c5cb6SVlad Zolotarov u8 func_id; 460619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 461619c5cb6SVlad Zolotarov unsigned long rx_mode_flags; 462619c5cb6SVlad Zolotarov 463619c5cb6SVlad Zolotarov /* 464619c5cb6SVlad Zolotarov * rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to 465619c5cb6SVlad Zolotarov * a tstorm_eth_mac_filter_config (e1x). 466619c5cb6SVlad Zolotarov */ 467619c5cb6SVlad Zolotarov void *rdata; 468619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping; 469619c5cb6SVlad Zolotarov 470619c5cb6SVlad Zolotarov /* Rx mode settings */ 471619c5cb6SVlad Zolotarov unsigned long rx_accept_flags; 472619c5cb6SVlad Zolotarov 473619c5cb6SVlad Zolotarov /* internal switching settings */ 474619c5cb6SVlad Zolotarov unsigned long tx_accept_flags; 475619c5cb6SVlad Zolotarov }; 476619c5cb6SVlad Zolotarov 477619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_obj { 478619c5cb6SVlad Zolotarov int (*config_rx_mode)(struct bnx2x *bp, 479619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_ramrod_params *p); 480619c5cb6SVlad Zolotarov 481619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, 482619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_ramrod_params *p); 483619c5cb6SVlad Zolotarov }; 484619c5cb6SVlad Zolotarov 485619c5cb6SVlad Zolotarov /********************** Set multicast group ***********************************/ 486619c5cb6SVlad Zolotarov 487619c5cb6SVlad Zolotarov struct bnx2x_mcast_list_elem { 488619c5cb6SVlad Zolotarov struct list_head link; 489619c5cb6SVlad Zolotarov u8 *mac; 490619c5cb6SVlad Zolotarov }; 491619c5cb6SVlad Zolotarov 492619c5cb6SVlad Zolotarov union bnx2x_mcast_config_data { 493619c5cb6SVlad Zolotarov u8 *mac; 494619c5cb6SVlad Zolotarov u8 bin; /* used in a RESTORE flow */ 495619c5cb6SVlad Zolotarov }; 496619c5cb6SVlad Zolotarov 497619c5cb6SVlad Zolotarov struct bnx2x_mcast_ramrod_params { 498619c5cb6SVlad Zolotarov struct bnx2x_mcast_obj *mcast_obj; 499619c5cb6SVlad Zolotarov 500619c5cb6SVlad Zolotarov /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */ 501619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 502619c5cb6SVlad Zolotarov 503619c5cb6SVlad Zolotarov struct list_head mcast_list; /* list of struct bnx2x_mcast_list_elem */ 504619c5cb6SVlad Zolotarov /** TODO: 505619c5cb6SVlad Zolotarov * - rename it to macs_num. 506619c5cb6SVlad Zolotarov * - Add a new command type for handling pending commands 507619c5cb6SVlad Zolotarov * (remove "zero semantics"). 508619c5cb6SVlad Zolotarov * 509619c5cb6SVlad Zolotarov * Length of mcast_list. If zero and ADD_CONT command - post 510619c5cb6SVlad Zolotarov * pending commands. 511619c5cb6SVlad Zolotarov */ 512619c5cb6SVlad Zolotarov int mcast_list_len; 513619c5cb6SVlad Zolotarov }; 514619c5cb6SVlad Zolotarov 515619c5cb6SVlad Zolotarov enum { 516619c5cb6SVlad Zolotarov BNX2X_MCAST_CMD_ADD, 517619c5cb6SVlad Zolotarov BNX2X_MCAST_CMD_CONT, 518619c5cb6SVlad Zolotarov BNX2X_MCAST_CMD_DEL, 519619c5cb6SVlad Zolotarov BNX2X_MCAST_CMD_RESTORE, 520619c5cb6SVlad Zolotarov }; 521619c5cb6SVlad Zolotarov 522619c5cb6SVlad Zolotarov struct bnx2x_mcast_obj { 523619c5cb6SVlad Zolotarov struct bnx2x_raw_obj raw; 524619c5cb6SVlad Zolotarov 525619c5cb6SVlad Zolotarov union { 526619c5cb6SVlad Zolotarov struct { 527619c5cb6SVlad Zolotarov #define BNX2X_MCAST_BINS_NUM 256 528619c5cb6SVlad Zolotarov #define BNX2X_MCAST_VEC_SZ (BNX2X_MCAST_BINS_NUM / 64) 529619c5cb6SVlad Zolotarov u64 vec[BNX2X_MCAST_VEC_SZ]; 530619c5cb6SVlad Zolotarov 531619c5cb6SVlad Zolotarov /** Number of BINs to clear. Should be updated 532619c5cb6SVlad Zolotarov * immediately when a command arrives in order to 533619c5cb6SVlad Zolotarov * properly create DEL commands. 534619c5cb6SVlad Zolotarov */ 535619c5cb6SVlad Zolotarov int num_bins_set; 536619c5cb6SVlad Zolotarov } aprox_match; 537619c5cb6SVlad Zolotarov 538619c5cb6SVlad Zolotarov struct { 539619c5cb6SVlad Zolotarov struct list_head macs; 540619c5cb6SVlad Zolotarov int num_macs_set; 541619c5cb6SVlad Zolotarov } exact_match; 542619c5cb6SVlad Zolotarov } registry; 543619c5cb6SVlad Zolotarov 544619c5cb6SVlad Zolotarov /* Pending commands */ 545619c5cb6SVlad Zolotarov struct list_head pending_cmds_head; 546619c5cb6SVlad Zolotarov 547619c5cb6SVlad Zolotarov /* A state that is set in raw.pstate, when there are pending commands */ 548619c5cb6SVlad Zolotarov int sched_state; 549619c5cb6SVlad Zolotarov 550619c5cb6SVlad Zolotarov /* Maximal number of mcast MACs configured in one command */ 551619c5cb6SVlad Zolotarov int max_cmd_len; 552619c5cb6SVlad Zolotarov 553619c5cb6SVlad Zolotarov /* Total number of currently pending MACs to configure: both 554619c5cb6SVlad Zolotarov * in the pending commands list and in the current command. 555619c5cb6SVlad Zolotarov */ 556619c5cb6SVlad Zolotarov int total_pending_num; 557619c5cb6SVlad Zolotarov 558619c5cb6SVlad Zolotarov u8 engine_id; 559619c5cb6SVlad Zolotarov 560619c5cb6SVlad Zolotarov /** 561619c5cb6SVlad Zolotarov * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above) 562619c5cb6SVlad Zolotarov */ 563619c5cb6SVlad Zolotarov int (*config_mcast)(struct bnx2x *bp, 564619c5cb6SVlad Zolotarov struct bnx2x_mcast_ramrod_params *p, int cmd); 565619c5cb6SVlad Zolotarov 566619c5cb6SVlad Zolotarov /** 567619c5cb6SVlad Zolotarov * Fills the ramrod data during the RESTORE flow. 568619c5cb6SVlad Zolotarov * 569619c5cb6SVlad Zolotarov * @param bp 570619c5cb6SVlad Zolotarov * @param o 571619c5cb6SVlad Zolotarov * @param start_idx Registry index to start from 572619c5cb6SVlad Zolotarov * @param rdata_idx Index in the ramrod data to start from 573619c5cb6SVlad Zolotarov * 574619c5cb6SVlad Zolotarov * @return -1 if we handled the whole registry or index of the last 575619c5cb6SVlad Zolotarov * handled registry element. 576619c5cb6SVlad Zolotarov */ 577619c5cb6SVlad Zolotarov int (*hdl_restore)(struct bnx2x *bp, struct bnx2x_mcast_obj *o, 578619c5cb6SVlad Zolotarov int start_bin, int *rdata_idx); 579619c5cb6SVlad Zolotarov 580619c5cb6SVlad Zolotarov int (*enqueue_cmd)(struct bnx2x *bp, struct bnx2x_mcast_obj *o, 581619c5cb6SVlad Zolotarov struct bnx2x_mcast_ramrod_params *p, int cmd); 582619c5cb6SVlad Zolotarov 583619c5cb6SVlad Zolotarov void (*set_one_rule)(struct bnx2x *bp, 584619c5cb6SVlad Zolotarov struct bnx2x_mcast_obj *o, int idx, 585619c5cb6SVlad Zolotarov union bnx2x_mcast_config_data *cfg_data, int cmd); 586619c5cb6SVlad Zolotarov 587619c5cb6SVlad Zolotarov /** Checks if there are more mcast MACs to be set or a previous 588619c5cb6SVlad Zolotarov * command is still pending. 589619c5cb6SVlad Zolotarov */ 590619c5cb6SVlad Zolotarov bool (*check_pending)(struct bnx2x_mcast_obj *o); 591619c5cb6SVlad Zolotarov 592619c5cb6SVlad Zolotarov /** 593619c5cb6SVlad Zolotarov * Set/Clear/Check SCHEDULED state of the object 594619c5cb6SVlad Zolotarov */ 595619c5cb6SVlad Zolotarov void (*set_sched)(struct bnx2x_mcast_obj *o); 596619c5cb6SVlad Zolotarov void (*clear_sched)(struct bnx2x_mcast_obj *o); 597619c5cb6SVlad Zolotarov bool (*check_sched)(struct bnx2x_mcast_obj *o); 598619c5cb6SVlad Zolotarov 599619c5cb6SVlad Zolotarov /* Wait until all pending commands complete */ 600619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, struct bnx2x_mcast_obj *o); 601619c5cb6SVlad Zolotarov 602619c5cb6SVlad Zolotarov /** 603619c5cb6SVlad Zolotarov * Handle the internal object counters needed for proper 604619c5cb6SVlad Zolotarov * commands handling. Checks that the provided parameters are 605619c5cb6SVlad Zolotarov * feasible. 606619c5cb6SVlad Zolotarov */ 607619c5cb6SVlad Zolotarov int (*validate)(struct bnx2x *bp, 608619c5cb6SVlad Zolotarov struct bnx2x_mcast_ramrod_params *p, int cmd); 609619c5cb6SVlad Zolotarov 610619c5cb6SVlad Zolotarov /** 611619c5cb6SVlad Zolotarov * Restore the values of internal counters in case of a failure. 612619c5cb6SVlad Zolotarov */ 613619c5cb6SVlad Zolotarov void (*revert)(struct bnx2x *bp, 614619c5cb6SVlad Zolotarov struct bnx2x_mcast_ramrod_params *p, 615619c5cb6SVlad Zolotarov int old_num_bins); 616619c5cb6SVlad Zolotarov 617619c5cb6SVlad Zolotarov int (*get_registry_size)(struct bnx2x_mcast_obj *o); 618619c5cb6SVlad Zolotarov void (*set_registry_size)(struct bnx2x_mcast_obj *o, int n); 619619c5cb6SVlad Zolotarov }; 620619c5cb6SVlad Zolotarov 621619c5cb6SVlad Zolotarov /*************************** Credit handling **********************************/ 622619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj { 623619c5cb6SVlad Zolotarov 624619c5cb6SVlad Zolotarov /* Current amount of credit in the pool */ 625619c5cb6SVlad Zolotarov atomic_t credit; 626619c5cb6SVlad Zolotarov 627619c5cb6SVlad Zolotarov /* Maximum allowed credit. put() will check against it. */ 628619c5cb6SVlad Zolotarov int pool_sz; 629619c5cb6SVlad Zolotarov 630619c5cb6SVlad Zolotarov /* 631619c5cb6SVlad Zolotarov * Allocate a pool table statically. 632619c5cb6SVlad Zolotarov * 633619c5cb6SVlad Zolotarov * Currently the mamimum allowed size is MAX_MAC_CREDIT_E2(272) 634619c5cb6SVlad Zolotarov * 635619c5cb6SVlad Zolotarov * The set bit in the table will mean that the entry is available. 636619c5cb6SVlad Zolotarov */ 637619c5cb6SVlad Zolotarov #define BNX2X_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64) 638619c5cb6SVlad Zolotarov u64 pool_mirror[BNX2X_POOL_VEC_SIZE]; 639619c5cb6SVlad Zolotarov 640619c5cb6SVlad Zolotarov /* Base pool offset (initialized differently */ 641619c5cb6SVlad Zolotarov int base_pool_offset; 642619c5cb6SVlad Zolotarov 643619c5cb6SVlad Zolotarov /** 644619c5cb6SVlad Zolotarov * Get the next free pool entry. 645619c5cb6SVlad Zolotarov * 646619c5cb6SVlad Zolotarov * @return true if there was a free entry in the pool 647619c5cb6SVlad Zolotarov */ 648619c5cb6SVlad Zolotarov bool (*get_entry)(struct bnx2x_credit_pool_obj *o, int *entry); 649619c5cb6SVlad Zolotarov 650619c5cb6SVlad Zolotarov /** 651619c5cb6SVlad Zolotarov * Return the entry back to the pool. 652619c5cb6SVlad Zolotarov * 653619c5cb6SVlad Zolotarov * @return true if entry is legal and has been successfully 654619c5cb6SVlad Zolotarov * returned to the pool. 655619c5cb6SVlad Zolotarov */ 656619c5cb6SVlad Zolotarov bool (*put_entry)(struct bnx2x_credit_pool_obj *o, int entry); 657619c5cb6SVlad Zolotarov 658619c5cb6SVlad Zolotarov /** 659619c5cb6SVlad Zolotarov * Get the requested amount of credit from the pool. 660619c5cb6SVlad Zolotarov * 661619c5cb6SVlad Zolotarov * @param cnt Amount of requested credit 662619c5cb6SVlad Zolotarov * @return true if the operation is successful 663619c5cb6SVlad Zolotarov */ 664619c5cb6SVlad Zolotarov bool (*get)(struct bnx2x_credit_pool_obj *o, int cnt); 665619c5cb6SVlad Zolotarov 666619c5cb6SVlad Zolotarov /** 667619c5cb6SVlad Zolotarov * Returns the credit to the pool. 668619c5cb6SVlad Zolotarov * 669619c5cb6SVlad Zolotarov * @param cnt Amount of credit to return 670619c5cb6SVlad Zolotarov * @return true if the operation is successful 671619c5cb6SVlad Zolotarov */ 672619c5cb6SVlad Zolotarov bool (*put)(struct bnx2x_credit_pool_obj *o, int cnt); 673619c5cb6SVlad Zolotarov 674619c5cb6SVlad Zolotarov /** 675619c5cb6SVlad Zolotarov * Reads the current amount of credit. 676619c5cb6SVlad Zolotarov */ 677619c5cb6SVlad Zolotarov int (*check)(struct bnx2x_credit_pool_obj *o); 678619c5cb6SVlad Zolotarov }; 679619c5cb6SVlad Zolotarov 680619c5cb6SVlad Zolotarov /*************************** RSS configuration ********************************/ 681619c5cb6SVlad Zolotarov enum { 682619c5cb6SVlad Zolotarov /* RSS_MODE bits are mutually exclusive */ 683619c5cb6SVlad Zolotarov BNX2X_RSS_MODE_DISABLED, 684619c5cb6SVlad Zolotarov BNX2X_RSS_MODE_REGULAR, 685619c5cb6SVlad Zolotarov BNX2X_RSS_MODE_VLAN_PRI, 686619c5cb6SVlad Zolotarov BNX2X_RSS_MODE_E1HOV_PRI, 687619c5cb6SVlad Zolotarov BNX2X_RSS_MODE_IP_DSCP, 688619c5cb6SVlad Zolotarov 689619c5cb6SVlad Zolotarov BNX2X_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */ 690619c5cb6SVlad Zolotarov 691619c5cb6SVlad Zolotarov BNX2X_RSS_IPV4, 692619c5cb6SVlad Zolotarov BNX2X_RSS_IPV4_TCP, 693619c5cb6SVlad Zolotarov BNX2X_RSS_IPV6, 694619c5cb6SVlad Zolotarov BNX2X_RSS_IPV6_TCP, 695619c5cb6SVlad Zolotarov }; 696619c5cb6SVlad Zolotarov 697619c5cb6SVlad Zolotarov struct bnx2x_config_rss_params { 698619c5cb6SVlad Zolotarov struct bnx2x_rss_config_obj *rss_obj; 699619c5cb6SVlad Zolotarov 700619c5cb6SVlad Zolotarov /* may have RAMROD_COMP_WAIT set only */ 701619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 702619c5cb6SVlad Zolotarov 703619c5cb6SVlad Zolotarov /* BNX2X_RSS_X bits */ 704619c5cb6SVlad Zolotarov unsigned long rss_flags; 705619c5cb6SVlad Zolotarov 706619c5cb6SVlad Zolotarov /* Number hash bits to take into an account */ 707619c5cb6SVlad Zolotarov u8 rss_result_mask; 708619c5cb6SVlad Zolotarov 709619c5cb6SVlad Zolotarov /* Indirection table */ 710619c5cb6SVlad Zolotarov u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE]; 711619c5cb6SVlad Zolotarov 712619c5cb6SVlad Zolotarov /* RSS hash values */ 713619c5cb6SVlad Zolotarov u32 rss_key[10]; 714619c5cb6SVlad Zolotarov 715619c5cb6SVlad Zolotarov /* valid only iff BNX2X_RSS_UPDATE_TOE is set */ 716619c5cb6SVlad Zolotarov u16 toe_rss_bitmap; 717619c5cb6SVlad Zolotarov }; 718619c5cb6SVlad Zolotarov 719619c5cb6SVlad Zolotarov struct bnx2x_rss_config_obj { 720619c5cb6SVlad Zolotarov struct bnx2x_raw_obj raw; 721619c5cb6SVlad Zolotarov 722619c5cb6SVlad Zolotarov /* RSS engine to use */ 723619c5cb6SVlad Zolotarov u8 engine_id; 724619c5cb6SVlad Zolotarov 725619c5cb6SVlad Zolotarov /* Last configured indirection table */ 726619c5cb6SVlad Zolotarov u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE]; 727619c5cb6SVlad Zolotarov 728619c5cb6SVlad Zolotarov int (*config_rss)(struct bnx2x *bp, 729619c5cb6SVlad Zolotarov struct bnx2x_config_rss_params *p); 730619c5cb6SVlad Zolotarov }; 731619c5cb6SVlad Zolotarov 732619c5cb6SVlad Zolotarov /*********************** Queue state update ***********************************/ 733619c5cb6SVlad Zolotarov 734619c5cb6SVlad Zolotarov /* UPDATE command options */ 735619c5cb6SVlad Zolotarov enum { 736619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_IN_VLAN_REM, 737619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG, 738619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_OUT_VLAN_REM, 739619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG, 740619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_ANTI_SPOOF, 741619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG, 742619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_ACTIVATE, 743619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_ACTIVATE_CHNG, 744619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_DEF_VLAN_EN, 745619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG, 746619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG, 747619c5cb6SVlad Zolotarov BNX2X_Q_UPDATE_SILENT_VLAN_REM 748619c5cb6SVlad Zolotarov }; 749619c5cb6SVlad Zolotarov 750619c5cb6SVlad Zolotarov /* Allowed Queue states */ 751619c5cb6SVlad Zolotarov enum bnx2x_q_state { 752619c5cb6SVlad Zolotarov BNX2X_Q_STATE_RESET, 753619c5cb6SVlad Zolotarov BNX2X_Q_STATE_INITIALIZED, 754619c5cb6SVlad Zolotarov BNX2X_Q_STATE_ACTIVE, 7556383c0b3SAriel Elior BNX2X_Q_STATE_MULTI_COS, 7566383c0b3SAriel Elior BNX2X_Q_STATE_MCOS_TERMINATED, 757619c5cb6SVlad Zolotarov BNX2X_Q_STATE_INACTIVE, 758619c5cb6SVlad Zolotarov BNX2X_Q_STATE_STOPPED, 759619c5cb6SVlad Zolotarov BNX2X_Q_STATE_TERMINATED, 760619c5cb6SVlad Zolotarov BNX2X_Q_STATE_FLRED, 761619c5cb6SVlad Zolotarov BNX2X_Q_STATE_MAX, 762619c5cb6SVlad Zolotarov }; 763619c5cb6SVlad Zolotarov 764619c5cb6SVlad Zolotarov /* Allowed commands */ 765619c5cb6SVlad Zolotarov enum bnx2x_queue_cmd { 766619c5cb6SVlad Zolotarov BNX2X_Q_CMD_INIT, 767619c5cb6SVlad Zolotarov BNX2X_Q_CMD_SETUP, 7686383c0b3SAriel Elior BNX2X_Q_CMD_SETUP_TX_ONLY, 769619c5cb6SVlad Zolotarov BNX2X_Q_CMD_DEACTIVATE, 770619c5cb6SVlad Zolotarov BNX2X_Q_CMD_ACTIVATE, 771619c5cb6SVlad Zolotarov BNX2X_Q_CMD_UPDATE, 772619c5cb6SVlad Zolotarov BNX2X_Q_CMD_UPDATE_TPA, 773619c5cb6SVlad Zolotarov BNX2X_Q_CMD_HALT, 774619c5cb6SVlad Zolotarov BNX2X_Q_CMD_CFC_DEL, 775619c5cb6SVlad Zolotarov BNX2X_Q_CMD_TERMINATE, 776619c5cb6SVlad Zolotarov BNX2X_Q_CMD_EMPTY, 777619c5cb6SVlad Zolotarov BNX2X_Q_CMD_MAX, 778619c5cb6SVlad Zolotarov }; 779619c5cb6SVlad Zolotarov 780619c5cb6SVlad Zolotarov /* queue SETUP + INIT flags */ 781619c5cb6SVlad Zolotarov enum { 782619c5cb6SVlad Zolotarov BNX2X_Q_FLG_TPA, 783f5219d8eSVladislav Zolotarov BNX2X_Q_FLG_TPA_IPV6, 784621b4d66SDmitry Kravkov BNX2X_Q_FLG_TPA_GRO, 785619c5cb6SVlad Zolotarov BNX2X_Q_FLG_STATS, 786619c5cb6SVlad Zolotarov BNX2X_Q_FLG_ZERO_STATS, 787619c5cb6SVlad Zolotarov BNX2X_Q_FLG_ACTIVE, 788619c5cb6SVlad Zolotarov BNX2X_Q_FLG_OV, 789619c5cb6SVlad Zolotarov BNX2X_Q_FLG_VLAN, 790619c5cb6SVlad Zolotarov BNX2X_Q_FLG_COS, 791619c5cb6SVlad Zolotarov BNX2X_Q_FLG_HC, 792619c5cb6SVlad Zolotarov BNX2X_Q_FLG_HC_EN, 793619c5cb6SVlad Zolotarov BNX2X_Q_FLG_DHC, 794619c5cb6SVlad Zolotarov BNX2X_Q_FLG_FCOE, 795619c5cb6SVlad Zolotarov BNX2X_Q_FLG_LEADING_RSS, 796619c5cb6SVlad Zolotarov BNX2X_Q_FLG_MCAST, 797619c5cb6SVlad Zolotarov BNX2X_Q_FLG_DEF_VLAN, 798619c5cb6SVlad Zolotarov BNX2X_Q_FLG_TX_SWITCH, 799619c5cb6SVlad Zolotarov BNX2X_Q_FLG_TX_SEC, 800619c5cb6SVlad Zolotarov BNX2X_Q_FLG_ANTI_SPOOF, 801619c5cb6SVlad Zolotarov BNX2X_Q_FLG_SILENT_VLAN_REM 802619c5cb6SVlad Zolotarov }; 803619c5cb6SVlad Zolotarov 804619c5cb6SVlad Zolotarov /* Queue type options: queue type may be a compination of below. */ 805619c5cb6SVlad Zolotarov enum bnx2x_q_type { 806619c5cb6SVlad Zolotarov /** TODO: Consider moving both these flags into the init() 807619c5cb6SVlad Zolotarov * ramrod params. 808619c5cb6SVlad Zolotarov */ 809619c5cb6SVlad Zolotarov BNX2X_Q_TYPE_HAS_RX, 810619c5cb6SVlad Zolotarov BNX2X_Q_TYPE_HAS_TX, 811619c5cb6SVlad Zolotarov }; 812619c5cb6SVlad Zolotarov 8136383c0b3SAriel Elior #define BNX2X_PRIMARY_CID_INDEX 0 8148d7b0278SAriel Elior #define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */ 8156383c0b3SAriel Elior #define BNX2X_MULTI_TX_COS_E2_E3A0 2 8166383c0b3SAriel Elior #define BNX2X_MULTI_TX_COS_E3B0 3 8178d7b0278SAriel Elior #define BNX2X_MULTI_TX_COS 3 /* Maximum possible */ 8186383c0b3SAriel Elior 8196383c0b3SAriel Elior 820619c5cb6SVlad Zolotarov struct bnx2x_queue_init_params { 821619c5cb6SVlad Zolotarov struct { 822619c5cb6SVlad Zolotarov unsigned long flags; 823619c5cb6SVlad Zolotarov u16 hc_rate; 824619c5cb6SVlad Zolotarov u8 fw_sb_id; 825619c5cb6SVlad Zolotarov u8 sb_cq_index; 826619c5cb6SVlad Zolotarov } tx; 827619c5cb6SVlad Zolotarov 828619c5cb6SVlad Zolotarov struct { 829619c5cb6SVlad Zolotarov unsigned long flags; 830619c5cb6SVlad Zolotarov u16 hc_rate; 831619c5cb6SVlad Zolotarov u8 fw_sb_id; 832619c5cb6SVlad Zolotarov u8 sb_cq_index; 833619c5cb6SVlad Zolotarov } rx; 834619c5cb6SVlad Zolotarov 835619c5cb6SVlad Zolotarov /* CID context in the host memory */ 8366383c0b3SAriel Elior struct eth_context *cxts[BNX2X_MULTI_TX_COS]; 8376383c0b3SAriel Elior 8386383c0b3SAriel Elior /* maximum number of cos supported by hardware */ 8396383c0b3SAriel Elior u8 max_cos; 8406383c0b3SAriel Elior }; 8416383c0b3SAriel Elior 8426383c0b3SAriel Elior struct bnx2x_queue_terminate_params { 8436383c0b3SAriel Elior /* index within the tx_only cids of this queue object */ 8446383c0b3SAriel Elior u8 cid_index; 8456383c0b3SAriel Elior }; 8466383c0b3SAriel Elior 8476383c0b3SAriel Elior struct bnx2x_queue_cfc_del_params { 8486383c0b3SAriel Elior /* index within the tx_only cids of this queue object */ 8496383c0b3SAriel Elior u8 cid_index; 850619c5cb6SVlad Zolotarov }; 851619c5cb6SVlad Zolotarov 852619c5cb6SVlad Zolotarov struct bnx2x_queue_update_params { 853619c5cb6SVlad Zolotarov unsigned long update_flags; /* BNX2X_Q_UPDATE_XX bits */ 854619c5cb6SVlad Zolotarov u16 def_vlan; 855619c5cb6SVlad Zolotarov u16 silent_removal_value; 856619c5cb6SVlad Zolotarov u16 silent_removal_mask; 8576383c0b3SAriel Elior /* index within the tx_only cids of this queue object */ 8586383c0b3SAriel Elior u8 cid_index; 859619c5cb6SVlad Zolotarov }; 860619c5cb6SVlad Zolotarov 861619c5cb6SVlad Zolotarov struct rxq_pause_params { 862619c5cb6SVlad Zolotarov u16 bd_th_lo; 863619c5cb6SVlad Zolotarov u16 bd_th_hi; 864619c5cb6SVlad Zolotarov u16 rcq_th_lo; 865619c5cb6SVlad Zolotarov u16 rcq_th_hi; 866619c5cb6SVlad Zolotarov u16 sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */ 867619c5cb6SVlad Zolotarov u16 sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */ 868619c5cb6SVlad Zolotarov u16 pri_map; 869619c5cb6SVlad Zolotarov }; 870619c5cb6SVlad Zolotarov 871619c5cb6SVlad Zolotarov /* general */ 872619c5cb6SVlad Zolotarov struct bnx2x_general_setup_params { 873619c5cb6SVlad Zolotarov /* valid iff BNX2X_Q_FLG_STATS */ 874619c5cb6SVlad Zolotarov u8 stat_id; 875619c5cb6SVlad Zolotarov 876619c5cb6SVlad Zolotarov u8 spcl_id; 877619c5cb6SVlad Zolotarov u16 mtu; 8786383c0b3SAriel Elior u8 cos; 879619c5cb6SVlad Zolotarov }; 880619c5cb6SVlad Zolotarov 881619c5cb6SVlad Zolotarov struct bnx2x_rxq_setup_params { 882619c5cb6SVlad Zolotarov /* dma */ 883619c5cb6SVlad Zolotarov dma_addr_t dscr_map; 884619c5cb6SVlad Zolotarov dma_addr_t sge_map; 885619c5cb6SVlad Zolotarov dma_addr_t rcq_map; 886619c5cb6SVlad Zolotarov dma_addr_t rcq_np_map; 887619c5cb6SVlad Zolotarov 888619c5cb6SVlad Zolotarov u16 drop_flags; 889619c5cb6SVlad Zolotarov u16 buf_sz; 890619c5cb6SVlad Zolotarov u8 fw_sb_id; 891619c5cb6SVlad Zolotarov u8 cl_qzone_id; 892619c5cb6SVlad Zolotarov 893619c5cb6SVlad Zolotarov /* valid iff BNX2X_Q_FLG_TPA */ 894619c5cb6SVlad Zolotarov u16 tpa_agg_sz; 895619c5cb6SVlad Zolotarov u16 sge_buf_sz; 896619c5cb6SVlad Zolotarov u8 max_sges_pkt; 897619c5cb6SVlad Zolotarov u8 max_tpa_queues; 898619c5cb6SVlad Zolotarov u8 rss_engine_id; 899619c5cb6SVlad Zolotarov 900*259afa1fSYuval Mintz /* valid iff BNX2X_Q_FLG_MCAST */ 901*259afa1fSYuval Mintz u8 mcast_engine_id; 902*259afa1fSYuval Mintz 903619c5cb6SVlad Zolotarov u8 cache_line_log; 904619c5cb6SVlad Zolotarov 905619c5cb6SVlad Zolotarov u8 sb_cq_index; 906619c5cb6SVlad Zolotarov 907619c5cb6SVlad Zolotarov /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */ 908619c5cb6SVlad Zolotarov u16 silent_removal_value; 909619c5cb6SVlad Zolotarov u16 silent_removal_mask; 910619c5cb6SVlad Zolotarov }; 911619c5cb6SVlad Zolotarov 912619c5cb6SVlad Zolotarov struct bnx2x_txq_setup_params { 913619c5cb6SVlad Zolotarov /* dma */ 914619c5cb6SVlad Zolotarov dma_addr_t dscr_map; 915619c5cb6SVlad Zolotarov 916619c5cb6SVlad Zolotarov u8 fw_sb_id; 917619c5cb6SVlad Zolotarov u8 sb_cq_index; 918619c5cb6SVlad Zolotarov u8 cos; /* valid iff BNX2X_Q_FLG_COS */ 919619c5cb6SVlad Zolotarov u16 traffic_type; 920619c5cb6SVlad Zolotarov /* equals to the leading rss client id, used for TX classification*/ 921619c5cb6SVlad Zolotarov u8 tss_leading_cl_id; 922619c5cb6SVlad Zolotarov 923619c5cb6SVlad Zolotarov /* valid iff BNX2X_Q_FLG_DEF_VLAN */ 924619c5cb6SVlad Zolotarov u16 default_vlan; 925619c5cb6SVlad Zolotarov }; 926619c5cb6SVlad Zolotarov 927619c5cb6SVlad Zolotarov struct bnx2x_queue_setup_params { 928619c5cb6SVlad Zolotarov struct bnx2x_general_setup_params gen_params; 929619c5cb6SVlad Zolotarov struct bnx2x_txq_setup_params txq_params; 9306383c0b3SAriel Elior struct bnx2x_rxq_setup_params rxq_params; 9316383c0b3SAriel Elior struct rxq_pause_params pause_params; 932619c5cb6SVlad Zolotarov unsigned long flags; 933619c5cb6SVlad Zolotarov }; 934619c5cb6SVlad Zolotarov 9356383c0b3SAriel Elior struct bnx2x_queue_setup_tx_only_params { 9366383c0b3SAriel Elior struct bnx2x_general_setup_params gen_params; 9376383c0b3SAriel Elior struct bnx2x_txq_setup_params txq_params; 9386383c0b3SAriel Elior unsigned long flags; 9396383c0b3SAriel Elior /* index within the tx_only cids of this queue object */ 9406383c0b3SAriel Elior u8 cid_index; 9416383c0b3SAriel Elior }; 942619c5cb6SVlad Zolotarov 943619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params { 944619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj *q_obj; 945619c5cb6SVlad Zolotarov 946619c5cb6SVlad Zolotarov /* Current command */ 947619c5cb6SVlad Zolotarov enum bnx2x_queue_cmd cmd; 948619c5cb6SVlad Zolotarov 949619c5cb6SVlad Zolotarov /* may have RAMROD_COMP_WAIT set only */ 950619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 951619c5cb6SVlad Zolotarov 952619c5cb6SVlad Zolotarov /* Params according to the current command */ 953619c5cb6SVlad Zolotarov union { 954619c5cb6SVlad Zolotarov struct bnx2x_queue_update_params update; 955619c5cb6SVlad Zolotarov struct bnx2x_queue_setup_params setup; 956619c5cb6SVlad Zolotarov struct bnx2x_queue_init_params init; 9576383c0b3SAriel Elior struct bnx2x_queue_setup_tx_only_params tx_only; 9586383c0b3SAriel Elior struct bnx2x_queue_terminate_params terminate; 9596383c0b3SAriel Elior struct bnx2x_queue_cfc_del_params cfc_del; 960619c5cb6SVlad Zolotarov } params; 961619c5cb6SVlad Zolotarov }; 962619c5cb6SVlad Zolotarov 963619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj { 9646383c0b3SAriel Elior u32 cids[BNX2X_MULTI_TX_COS]; 965619c5cb6SVlad Zolotarov u8 cl_id; 966619c5cb6SVlad Zolotarov u8 func_id; 967619c5cb6SVlad Zolotarov 9686383c0b3SAriel Elior /* 9696383c0b3SAriel Elior * number of traffic classes supported by queue. 9706383c0b3SAriel Elior * The primary connection of the queue suppotrs the first traffic 9716383c0b3SAriel Elior * class. Any further traffic class is suppoted by a tx-only 9726383c0b3SAriel Elior * connection. 9736383c0b3SAriel Elior * 9746383c0b3SAriel Elior * Therefore max_cos is also a number of valid entries in the cids 9756383c0b3SAriel Elior * array. 9766383c0b3SAriel Elior */ 9776383c0b3SAriel Elior u8 max_cos; 9786383c0b3SAriel Elior u8 num_tx_only, next_tx_only; 9796383c0b3SAriel Elior 980619c5cb6SVlad Zolotarov enum bnx2x_q_state state, next_state; 981619c5cb6SVlad Zolotarov 982619c5cb6SVlad Zolotarov /* bits from enum bnx2x_q_type */ 983619c5cb6SVlad Zolotarov unsigned long type; 984619c5cb6SVlad Zolotarov 985619c5cb6SVlad Zolotarov /* BNX2X_Q_CMD_XX bits. This object implements "one 986619c5cb6SVlad Zolotarov * pending" paradigm but for debug and tracing purposes it's 987619c5cb6SVlad Zolotarov * more convinient to have different bits for different 988619c5cb6SVlad Zolotarov * commands. 989619c5cb6SVlad Zolotarov */ 990619c5cb6SVlad Zolotarov unsigned long pending; 991619c5cb6SVlad Zolotarov 992619c5cb6SVlad Zolotarov /* Buffer to use as a ramrod data and its mapping */ 993619c5cb6SVlad Zolotarov void *rdata; 994619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping; 995619c5cb6SVlad Zolotarov 996619c5cb6SVlad Zolotarov /** 997619c5cb6SVlad Zolotarov * Performs one state change according to the given parameters. 998619c5cb6SVlad Zolotarov * 999619c5cb6SVlad Zolotarov * @return 0 in case of success and negative value otherwise. 1000619c5cb6SVlad Zolotarov */ 1001619c5cb6SVlad Zolotarov int (*send_cmd)(struct bnx2x *bp, 1002619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params *params); 1003619c5cb6SVlad Zolotarov 1004619c5cb6SVlad Zolotarov /** 1005619c5cb6SVlad Zolotarov * Sets the pending bit according to the requested transition. 1006619c5cb6SVlad Zolotarov */ 1007619c5cb6SVlad Zolotarov int (*set_pending)(struct bnx2x_queue_sp_obj *o, 1008619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params *params); 1009619c5cb6SVlad Zolotarov 1010619c5cb6SVlad Zolotarov /** 1011619c5cb6SVlad Zolotarov * Checks that the requested state transition is legal. 1012619c5cb6SVlad Zolotarov */ 1013619c5cb6SVlad Zolotarov int (*check_transition)(struct bnx2x *bp, 1014619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj *o, 1015619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params *params); 1016619c5cb6SVlad Zolotarov 1017619c5cb6SVlad Zolotarov /** 1018619c5cb6SVlad Zolotarov * Completes the pending command. 1019619c5cb6SVlad Zolotarov */ 1020619c5cb6SVlad Zolotarov int (*complete_cmd)(struct bnx2x *bp, 1021619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj *o, 1022619c5cb6SVlad Zolotarov enum bnx2x_queue_cmd); 1023619c5cb6SVlad Zolotarov 1024619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, 1025619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj *o, 1026619c5cb6SVlad Zolotarov enum bnx2x_queue_cmd cmd); 1027619c5cb6SVlad Zolotarov }; 1028619c5cb6SVlad Zolotarov 1029619c5cb6SVlad Zolotarov /********************** Function state update *********************************/ 1030619c5cb6SVlad Zolotarov /* Allowed Function states */ 1031619c5cb6SVlad Zolotarov enum bnx2x_func_state { 1032619c5cb6SVlad Zolotarov BNX2X_F_STATE_RESET, 1033619c5cb6SVlad Zolotarov BNX2X_F_STATE_INITIALIZED, 1034619c5cb6SVlad Zolotarov BNX2X_F_STATE_STARTED, 10356debea87SDmitry Kravkov BNX2X_F_STATE_TX_STOPPED, 1036619c5cb6SVlad Zolotarov BNX2X_F_STATE_MAX, 1037619c5cb6SVlad Zolotarov }; 1038619c5cb6SVlad Zolotarov 1039619c5cb6SVlad Zolotarov /* Allowed Function commands */ 1040619c5cb6SVlad Zolotarov enum bnx2x_func_cmd { 1041619c5cb6SVlad Zolotarov BNX2X_F_CMD_HW_INIT, 1042619c5cb6SVlad Zolotarov BNX2X_F_CMD_START, 1043619c5cb6SVlad Zolotarov BNX2X_F_CMD_STOP, 1044619c5cb6SVlad Zolotarov BNX2X_F_CMD_HW_RESET, 10456debea87SDmitry Kravkov BNX2X_F_CMD_TX_STOP, 10466debea87SDmitry Kravkov BNX2X_F_CMD_TX_START, 1047619c5cb6SVlad Zolotarov BNX2X_F_CMD_MAX, 1048619c5cb6SVlad Zolotarov }; 1049619c5cb6SVlad Zolotarov 1050619c5cb6SVlad Zolotarov struct bnx2x_func_hw_init_params { 1051619c5cb6SVlad Zolotarov /* A load phase returned by MCP. 1052619c5cb6SVlad Zolotarov * 1053619c5cb6SVlad Zolotarov * May be: 1054619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP 1055619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_COMMON 1056619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_PORT 1057619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_FUNCTION 1058619c5cb6SVlad Zolotarov */ 1059619c5cb6SVlad Zolotarov u32 load_phase; 1060619c5cb6SVlad Zolotarov }; 1061619c5cb6SVlad Zolotarov 1062619c5cb6SVlad Zolotarov struct bnx2x_func_hw_reset_params { 1063619c5cb6SVlad Zolotarov /* A load phase returned by MCP. 1064619c5cb6SVlad Zolotarov * 1065619c5cb6SVlad Zolotarov * May be: 1066619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP 1067619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_COMMON 1068619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_PORT 1069619c5cb6SVlad Zolotarov * FW_MSG_CODE_DRV_LOAD_FUNCTION 1070619c5cb6SVlad Zolotarov */ 1071619c5cb6SVlad Zolotarov u32 reset_phase; 1072619c5cb6SVlad Zolotarov }; 1073619c5cb6SVlad Zolotarov 1074619c5cb6SVlad Zolotarov struct bnx2x_func_start_params { 1075619c5cb6SVlad Zolotarov /* Multi Function mode: 1076619c5cb6SVlad Zolotarov * - Single Function 1077619c5cb6SVlad Zolotarov * - Switch Dependent 1078619c5cb6SVlad Zolotarov * - Switch Independent 1079619c5cb6SVlad Zolotarov */ 1080619c5cb6SVlad Zolotarov u16 mf_mode; 1081619c5cb6SVlad Zolotarov 1082619c5cb6SVlad Zolotarov /* Switch Dependent mode outer VLAN tag */ 1083619c5cb6SVlad Zolotarov u16 sd_vlan_tag; 1084619c5cb6SVlad Zolotarov 1085619c5cb6SVlad Zolotarov /* Function cos mode */ 1086619c5cb6SVlad Zolotarov u8 network_cos_mode; 1087619c5cb6SVlad Zolotarov }; 1088619c5cb6SVlad Zolotarov 10896debea87SDmitry Kravkov struct bnx2x_func_tx_start_params { 10906debea87SDmitry Kravkov struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES]; 10916debea87SDmitry Kravkov u8 dcb_enabled; 10926debea87SDmitry Kravkov u8 dcb_version; 10936debea87SDmitry Kravkov u8 dont_add_pri_0_en; 10946debea87SDmitry Kravkov }; 10956debea87SDmitry Kravkov 1096619c5cb6SVlad Zolotarov struct bnx2x_func_state_params { 1097619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj *f_obj; 1098619c5cb6SVlad Zolotarov 1099619c5cb6SVlad Zolotarov /* Current command */ 1100619c5cb6SVlad Zolotarov enum bnx2x_func_cmd cmd; 1101619c5cb6SVlad Zolotarov 1102619c5cb6SVlad Zolotarov /* may have RAMROD_COMP_WAIT set only */ 1103619c5cb6SVlad Zolotarov unsigned long ramrod_flags; 1104619c5cb6SVlad Zolotarov 1105619c5cb6SVlad Zolotarov /* Params according to the current command */ 1106619c5cb6SVlad Zolotarov union { 1107619c5cb6SVlad Zolotarov struct bnx2x_func_hw_init_params hw_init; 1108619c5cb6SVlad Zolotarov struct bnx2x_func_hw_reset_params hw_reset; 1109619c5cb6SVlad Zolotarov struct bnx2x_func_start_params start; 11106debea87SDmitry Kravkov struct bnx2x_func_tx_start_params tx_start; 1111619c5cb6SVlad Zolotarov } params; 1112619c5cb6SVlad Zolotarov }; 1113619c5cb6SVlad Zolotarov 1114619c5cb6SVlad Zolotarov struct bnx2x_func_sp_drv_ops { 1115619c5cb6SVlad Zolotarov /* Init tool + runtime initialization: 1116619c5cb6SVlad Zolotarov * - Common Chip 1117619c5cb6SVlad Zolotarov * - Common (per Path) 1118619c5cb6SVlad Zolotarov * - Port 1119619c5cb6SVlad Zolotarov * - Function phases 1120619c5cb6SVlad Zolotarov */ 1121619c5cb6SVlad Zolotarov int (*init_hw_cmn_chip)(struct bnx2x *bp); 1122619c5cb6SVlad Zolotarov int (*init_hw_cmn)(struct bnx2x *bp); 1123619c5cb6SVlad Zolotarov int (*init_hw_port)(struct bnx2x *bp); 1124619c5cb6SVlad Zolotarov int (*init_hw_func)(struct bnx2x *bp); 1125619c5cb6SVlad Zolotarov 1126619c5cb6SVlad Zolotarov /* Reset Function HW: Common, Port, Function phases. */ 1127619c5cb6SVlad Zolotarov void (*reset_hw_cmn)(struct bnx2x *bp); 1128619c5cb6SVlad Zolotarov void (*reset_hw_port)(struct bnx2x *bp); 1129619c5cb6SVlad Zolotarov void (*reset_hw_func)(struct bnx2x *bp); 1130619c5cb6SVlad Zolotarov 1131619c5cb6SVlad Zolotarov /* Init/Free GUNZIP resources */ 1132619c5cb6SVlad Zolotarov int (*gunzip_init)(struct bnx2x *bp); 1133619c5cb6SVlad Zolotarov void (*gunzip_end)(struct bnx2x *bp); 1134619c5cb6SVlad Zolotarov 1135619c5cb6SVlad Zolotarov /* Prepare/Release FW resources */ 1136619c5cb6SVlad Zolotarov int (*init_fw)(struct bnx2x *bp); 1137619c5cb6SVlad Zolotarov void (*release_fw)(struct bnx2x *bp); 1138619c5cb6SVlad Zolotarov }; 1139619c5cb6SVlad Zolotarov 1140619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj { 1141619c5cb6SVlad Zolotarov enum bnx2x_func_state state, next_state; 1142619c5cb6SVlad Zolotarov 1143619c5cb6SVlad Zolotarov /* BNX2X_FUNC_CMD_XX bits. This object implements "one 1144619c5cb6SVlad Zolotarov * pending" paradigm but for debug and tracing purposes it's 1145619c5cb6SVlad Zolotarov * more convinient to have different bits for different 1146619c5cb6SVlad Zolotarov * commands. 1147619c5cb6SVlad Zolotarov */ 1148619c5cb6SVlad Zolotarov unsigned long pending; 1149619c5cb6SVlad Zolotarov 1150619c5cb6SVlad Zolotarov /* Buffer to use as a ramrod data and its mapping */ 1151619c5cb6SVlad Zolotarov void *rdata; 1152619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping; 1153619c5cb6SVlad Zolotarov 1154619c5cb6SVlad Zolotarov /* this mutex validates that when pending flag is taken, the next 1155619c5cb6SVlad Zolotarov * ramrod to be sent will be the one set the pending bit 1156619c5cb6SVlad Zolotarov */ 1157619c5cb6SVlad Zolotarov struct mutex one_pending_mutex; 1158619c5cb6SVlad Zolotarov 1159619c5cb6SVlad Zolotarov /* Driver interface */ 1160619c5cb6SVlad Zolotarov struct bnx2x_func_sp_drv_ops *drv; 1161619c5cb6SVlad Zolotarov 1162619c5cb6SVlad Zolotarov /** 1163619c5cb6SVlad Zolotarov * Performs one state change according to the given parameters. 1164619c5cb6SVlad Zolotarov * 1165619c5cb6SVlad Zolotarov * @return 0 in case of success and negative value otherwise. 1166619c5cb6SVlad Zolotarov */ 1167619c5cb6SVlad Zolotarov int (*send_cmd)(struct bnx2x *bp, 1168619c5cb6SVlad Zolotarov struct bnx2x_func_state_params *params); 1169619c5cb6SVlad Zolotarov 1170619c5cb6SVlad Zolotarov /** 1171619c5cb6SVlad Zolotarov * Checks that the requested state transition is legal. 1172619c5cb6SVlad Zolotarov */ 1173619c5cb6SVlad Zolotarov int (*check_transition)(struct bnx2x *bp, 1174619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj *o, 1175619c5cb6SVlad Zolotarov struct bnx2x_func_state_params *params); 1176619c5cb6SVlad Zolotarov 1177619c5cb6SVlad Zolotarov /** 1178619c5cb6SVlad Zolotarov * Completes the pending command. 1179619c5cb6SVlad Zolotarov */ 1180619c5cb6SVlad Zolotarov int (*complete_cmd)(struct bnx2x *bp, 1181619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj *o, 1182619c5cb6SVlad Zolotarov enum bnx2x_func_cmd cmd); 1183619c5cb6SVlad Zolotarov 1184619c5cb6SVlad Zolotarov int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o, 1185619c5cb6SVlad Zolotarov enum bnx2x_func_cmd cmd); 1186619c5cb6SVlad Zolotarov }; 1187619c5cb6SVlad Zolotarov 1188619c5cb6SVlad Zolotarov /********************** Interfaces ********************************************/ 1189619c5cb6SVlad Zolotarov /* Queueable objects set */ 1190619c5cb6SVlad Zolotarov union bnx2x_qable_obj { 1191619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj vlan_mac; 1192619c5cb6SVlad Zolotarov }; 1193619c5cb6SVlad Zolotarov /************** Function state update *********/ 1194619c5cb6SVlad Zolotarov void bnx2x_init_func_obj(struct bnx2x *bp, 1195619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj *obj, 1196619c5cb6SVlad Zolotarov void *rdata, dma_addr_t rdata_mapping, 1197619c5cb6SVlad Zolotarov struct bnx2x_func_sp_drv_ops *drv_iface); 1198619c5cb6SVlad Zolotarov 1199619c5cb6SVlad Zolotarov int bnx2x_func_state_change(struct bnx2x *bp, 1200619c5cb6SVlad Zolotarov struct bnx2x_func_state_params *params); 1201619c5cb6SVlad Zolotarov 12026debea87SDmitry Kravkov enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp, 12036debea87SDmitry Kravkov struct bnx2x_func_sp_obj *o); 1204619c5cb6SVlad Zolotarov /******************* Queue State **************/ 1205619c5cb6SVlad Zolotarov void bnx2x_init_queue_obj(struct bnx2x *bp, 12066383c0b3SAriel Elior struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids, 12076383c0b3SAriel Elior u8 cid_cnt, u8 func_id, void *rdata, 12086383c0b3SAriel Elior dma_addr_t rdata_mapping, unsigned long type); 1209619c5cb6SVlad Zolotarov 1210619c5cb6SVlad Zolotarov int bnx2x_queue_state_change(struct bnx2x *bp, 1211619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params *params); 1212619c5cb6SVlad Zolotarov 1213619c5cb6SVlad Zolotarov /********************* VLAN-MAC ****************/ 1214619c5cb6SVlad Zolotarov void bnx2x_init_mac_obj(struct bnx2x *bp, 1215619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *mac_obj, 1216619c5cb6SVlad Zolotarov u8 cl_id, u32 cid, u8 func_id, void *rdata, 1217619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping, int state, 1218619c5cb6SVlad Zolotarov unsigned long *pstate, bnx2x_obj_type type, 1219619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *macs_pool); 1220619c5cb6SVlad Zolotarov 1221619c5cb6SVlad Zolotarov void bnx2x_init_vlan_obj(struct bnx2x *bp, 1222619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *vlan_obj, 1223619c5cb6SVlad Zolotarov u8 cl_id, u32 cid, u8 func_id, void *rdata, 1224619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping, int state, 1225619c5cb6SVlad Zolotarov unsigned long *pstate, bnx2x_obj_type type, 1226619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *vlans_pool); 1227619c5cb6SVlad Zolotarov 1228619c5cb6SVlad Zolotarov void bnx2x_init_vlan_mac_obj(struct bnx2x *bp, 1229619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *vlan_mac_obj, 1230619c5cb6SVlad Zolotarov u8 cl_id, u32 cid, u8 func_id, void *rdata, 1231619c5cb6SVlad Zolotarov dma_addr_t rdata_mapping, int state, 1232619c5cb6SVlad Zolotarov unsigned long *pstate, bnx2x_obj_type type, 1233619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *macs_pool, 1234619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *vlans_pool); 1235619c5cb6SVlad Zolotarov 1236619c5cb6SVlad Zolotarov int bnx2x_config_vlan_mac(struct bnx2x *bp, 1237619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_params *p); 1238619c5cb6SVlad Zolotarov 1239619c5cb6SVlad Zolotarov int bnx2x_vlan_mac_move(struct bnx2x *bp, 1240619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_params *p, 1241619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj *dest_o); 1242619c5cb6SVlad Zolotarov 1243619c5cb6SVlad Zolotarov /********************* RX MODE ****************/ 1244619c5cb6SVlad Zolotarov 1245619c5cb6SVlad Zolotarov void bnx2x_init_rx_mode_obj(struct bnx2x *bp, 1246619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_obj *o); 1247619c5cb6SVlad Zolotarov 1248619c5cb6SVlad Zolotarov /** 1249619c5cb6SVlad Zolotarov * Send and RX_MODE ramrod according to the provided parameters. 1250619c5cb6SVlad Zolotarov * 1251619c5cb6SVlad Zolotarov * @param bp 1252619c5cb6SVlad Zolotarov * @param p Command parameters 1253619c5cb6SVlad Zolotarov * 1254619c5cb6SVlad Zolotarov * @return 0 - if operation was successfull and there is no pending completions, 1255619c5cb6SVlad Zolotarov * positive number - if there are pending completions, 1256619c5cb6SVlad Zolotarov * negative - if there were errors 1257619c5cb6SVlad Zolotarov */ 1258619c5cb6SVlad Zolotarov int bnx2x_config_rx_mode(struct bnx2x *bp, 1259619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_ramrod_params *p); 1260619c5cb6SVlad Zolotarov 1261619c5cb6SVlad Zolotarov /****************** MULTICASTS ****************/ 1262619c5cb6SVlad Zolotarov 1263619c5cb6SVlad Zolotarov void bnx2x_init_mcast_obj(struct bnx2x *bp, 1264619c5cb6SVlad Zolotarov struct bnx2x_mcast_obj *mcast_obj, 1265619c5cb6SVlad Zolotarov u8 mcast_cl_id, u32 mcast_cid, u8 func_id, 1266619c5cb6SVlad Zolotarov u8 engine_id, void *rdata, dma_addr_t rdata_mapping, 1267619c5cb6SVlad Zolotarov int state, unsigned long *pstate, 1268619c5cb6SVlad Zolotarov bnx2x_obj_type type); 1269619c5cb6SVlad Zolotarov 1270619c5cb6SVlad Zolotarov /** 1271619c5cb6SVlad Zolotarov * Configure multicast MACs list. May configure a new list 1272619c5cb6SVlad Zolotarov * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up 1273619c5cb6SVlad Zolotarov * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current 1274619c5cb6SVlad Zolotarov * configuration, continue to execute the pending commands 1275619c5cb6SVlad Zolotarov * (BNX2X_MCAST_CMD_CONT). 1276619c5cb6SVlad Zolotarov * 1277619c5cb6SVlad Zolotarov * If previous command is still pending or if number of MACs to 1278619c5cb6SVlad Zolotarov * configure is more that maximum number of MACs in one command, 1279619c5cb6SVlad Zolotarov * the current command will be enqueued to the tail of the 1280619c5cb6SVlad Zolotarov * pending commands list. 1281619c5cb6SVlad Zolotarov * 1282619c5cb6SVlad Zolotarov * @param bp 1283619c5cb6SVlad Zolotarov * @param p 1284619c5cb6SVlad Zolotarov * @param command to execute: BNX2X_MCAST_CMD_X 1285619c5cb6SVlad Zolotarov * 1286619c5cb6SVlad Zolotarov * @return 0 is operation was sucessfull and there are no pending completions, 1287619c5cb6SVlad Zolotarov * negative if there were errors, positive if there are pending 1288619c5cb6SVlad Zolotarov * completions. 1289619c5cb6SVlad Zolotarov */ 1290619c5cb6SVlad Zolotarov int bnx2x_config_mcast(struct bnx2x *bp, 1291619c5cb6SVlad Zolotarov struct bnx2x_mcast_ramrod_params *p, int cmd); 1292619c5cb6SVlad Zolotarov 1293619c5cb6SVlad Zolotarov /****************** CREDIT POOL ****************/ 1294619c5cb6SVlad Zolotarov void bnx2x_init_mac_credit_pool(struct bnx2x *bp, 1295619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *p, u8 func_id, 1296619c5cb6SVlad Zolotarov u8 func_num); 1297619c5cb6SVlad Zolotarov void bnx2x_init_vlan_credit_pool(struct bnx2x *bp, 1298619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj *p, u8 func_id, 1299619c5cb6SVlad Zolotarov u8 func_num); 1300619c5cb6SVlad Zolotarov 1301619c5cb6SVlad Zolotarov 1302619c5cb6SVlad Zolotarov /****************** RSS CONFIGURATION ****************/ 1303619c5cb6SVlad Zolotarov void bnx2x_init_rss_config_obj(struct bnx2x *bp, 1304619c5cb6SVlad Zolotarov struct bnx2x_rss_config_obj *rss_obj, 1305619c5cb6SVlad Zolotarov u8 cl_id, u32 cid, u8 func_id, u8 engine_id, 1306619c5cb6SVlad Zolotarov void *rdata, dma_addr_t rdata_mapping, 1307619c5cb6SVlad Zolotarov int state, unsigned long *pstate, 1308619c5cb6SVlad Zolotarov bnx2x_obj_type type); 1309619c5cb6SVlad Zolotarov 1310619c5cb6SVlad Zolotarov /** 1311619c5cb6SVlad Zolotarov * Updates RSS configuration according to provided parameters. 1312619c5cb6SVlad Zolotarov * 1313619c5cb6SVlad Zolotarov * @param bp 1314619c5cb6SVlad Zolotarov * @param p 1315619c5cb6SVlad Zolotarov * 1316619c5cb6SVlad Zolotarov * @return 0 in case of success 1317619c5cb6SVlad Zolotarov */ 1318619c5cb6SVlad Zolotarov int bnx2x_config_rss(struct bnx2x *bp, 1319619c5cb6SVlad Zolotarov struct bnx2x_config_rss_params *p); 1320619c5cb6SVlad Zolotarov 1321619c5cb6SVlad Zolotarov /** 1322619c5cb6SVlad Zolotarov * Return the current ind_table configuration. 1323619c5cb6SVlad Zolotarov * 1324619c5cb6SVlad Zolotarov * @param bp 1325619c5cb6SVlad Zolotarov * @param ind_table buffer to fill with the current indirection 1326619c5cb6SVlad Zolotarov * table content. Should be at least 1327619c5cb6SVlad Zolotarov * T_ETH_INDIRECTION_TABLE_SIZE bytes long. 1328619c5cb6SVlad Zolotarov */ 1329619c5cb6SVlad Zolotarov void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj, 1330619c5cb6SVlad Zolotarov u8 *ind_table); 1331619c5cb6SVlad Zolotarov 1332619c5cb6SVlad Zolotarov #endif /* BNX2X_SP_VERBS */ 1333