bnx2x_sp.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  1. /* bnx2x_sp.h: Broadcom Everest network driver.
  2. *
  3. * Copyright (c) 2011-2013 Broadcom Corporation
  4. *
  5. * Unless you and Broadcom execute a separate written software license
  6. * agreement governing use of this software, this software is licensed to you
  7. * under the terms of the GNU General Public License version 2, available
  8. * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
  9. *
  10. * Notwithstanding the above, under no circumstances may you combine this
  11. * software in any way with any other Broadcom software provided under a
  12. * license other than the GPL, without Broadcom's express prior written
  13. * consent.
  14. *
  15. * Maintained by: Eilon Greenstein <eilong@broadcom.com>
  16. * Written by: Vladislav Zolotarov
  17. *
  18. */
  19. #ifndef BNX2X_SP_VERBS
  20. #define BNX2X_SP_VERBS
  21. struct bnx2x;
  22. struct eth_context;
  23. /* Bits representing general command's configuration */
  24. enum {
  25. RAMROD_TX,
  26. RAMROD_RX,
  27. /* Wait until all pending commands complete */
  28. RAMROD_COMP_WAIT,
  29. /* Don't send a ramrod, only update a registry */
  30. RAMROD_DRV_CLR_ONLY,
  31. /* Configure HW according to the current object state */
  32. RAMROD_RESTORE,
  33. /* Execute the next command now */
  34. RAMROD_EXEC,
  35. /*
  36. * Don't add a new command and continue execution of posponed
  37. * commands. If not set a new command will be added to the
  38. * pending commands list.
  39. */
  40. RAMROD_CONT,
  41. /* If there is another pending ramrod, wait until it finishes and
  42. * re-try to submit this one. This flag can be set only in sleepable
  43. * context, and should not be set from the context that completes the
  44. * ramrods as deadlock will occur.
  45. */
  46. RAMROD_RETRY,
  47. };
  48. typedef enum {
  49. BNX2X_OBJ_TYPE_RX,
  50. BNX2X_OBJ_TYPE_TX,
  51. BNX2X_OBJ_TYPE_RX_TX,
  52. } bnx2x_obj_type;
  53. /* Public slow path states */
  54. enum {
  55. BNX2X_FILTER_MAC_PENDING,
  56. BNX2X_FILTER_VLAN_PENDING,
  57. BNX2X_FILTER_VLAN_MAC_PENDING,
  58. BNX2X_FILTER_RX_MODE_PENDING,
  59. BNX2X_FILTER_RX_MODE_SCHED,
  60. BNX2X_FILTER_ISCSI_ETH_START_SCHED,
  61. BNX2X_FILTER_ISCSI_ETH_STOP_SCHED,
  62. BNX2X_FILTER_FCOE_ETH_START_SCHED,
  63. BNX2X_FILTER_FCOE_ETH_STOP_SCHED,
  64. BNX2X_FILTER_MCAST_PENDING,
  65. BNX2X_FILTER_MCAST_SCHED,
  66. BNX2X_FILTER_RSS_CONF_PENDING,
  67. BNX2X_AFEX_FCOE_Q_UPDATE_PENDING,
  68. BNX2X_AFEX_PENDING_VIFSET_MCP_ACK
  69. };
  70. struct bnx2x_raw_obj {
  71. u8 func_id;
  72. /* Queue params */
  73. u8 cl_id;
  74. u32 cid;
  75. /* Ramrod data buffer params */
  76. void *rdata;
  77. dma_addr_t rdata_mapping;
  78. /* Ramrod state params */
  79. int state; /* "ramrod is pending" state bit */
  80. unsigned long *pstate; /* pointer to state buffer */
  81. bnx2x_obj_type obj_type;
  82. int (*wait_comp)(struct bnx2x *bp,
  83. struct bnx2x_raw_obj *o);
  84. bool (*check_pending)(struct bnx2x_raw_obj *o);
  85. void (*clear_pending)(struct bnx2x_raw_obj *o);
  86. void (*set_pending)(struct bnx2x_raw_obj *o);
  87. };
  88. /************************* VLAN-MAC commands related parameters ***************/
  89. struct bnx2x_mac_ramrod_data {
  90. u8 mac[ETH_ALEN];
  91. u8 is_inner_mac;
  92. };
  93. struct bnx2x_vlan_ramrod_data {
  94. u16 vlan;
  95. };
  96. struct bnx2x_vlan_mac_ramrod_data {
  97. u8 mac[ETH_ALEN];
  98. u8 is_inner_mac;
  99. u16 vlan;
  100. };
  101. union bnx2x_classification_ramrod_data {
  102. struct bnx2x_mac_ramrod_data mac;
  103. struct bnx2x_vlan_ramrod_data vlan;
  104. struct bnx2x_vlan_mac_ramrod_data vlan_mac;
  105. };
  106. /* VLAN_MAC commands */
  107. enum bnx2x_vlan_mac_cmd {
  108. BNX2X_VLAN_MAC_ADD,
  109. BNX2X_VLAN_MAC_DEL,
  110. BNX2X_VLAN_MAC_MOVE,
  111. };
  112. struct bnx2x_vlan_mac_data {
  113. /* Requested command: BNX2X_VLAN_MAC_XX */
  114. enum bnx2x_vlan_mac_cmd cmd;
  115. /*
  116. * used to contain the data related vlan_mac_flags bits from
  117. * ramrod parameters.
  118. */
  119. unsigned long vlan_mac_flags;
  120. /* Needed for MOVE command */
  121. struct bnx2x_vlan_mac_obj *target_obj;
  122. union bnx2x_classification_ramrod_data u;
  123. };
  124. /*************************** Exe Queue obj ************************************/
  125. union bnx2x_exe_queue_cmd_data {
  126. struct bnx2x_vlan_mac_data vlan_mac;
  127. struct {
  128. /* TODO */
  129. } mcast;
  130. };
  131. struct bnx2x_exeq_elem {
  132. struct list_head link;
  133. /* Length of this element in the exe_chunk. */
  134. int cmd_len;
  135. union bnx2x_exe_queue_cmd_data cmd_data;
  136. };
  137. union bnx2x_qable_obj;
  138. union bnx2x_exeq_comp_elem {
  139. union event_ring_elem *elem;
  140. };
  141. struct bnx2x_exe_queue_obj;
  142. typedef int (*exe_q_validate)(struct bnx2x *bp,
  143. union bnx2x_qable_obj *o,
  144. struct bnx2x_exeq_elem *elem);
  145. typedef int (*exe_q_remove)(struct bnx2x *bp,
  146. union bnx2x_qable_obj *o,
  147. struct bnx2x_exeq_elem *elem);
  148. /* Return positive if entry was optimized, 0 - if not, negative
  149. * in case of an error.
  150. */
  151. typedef int (*exe_q_optimize)(struct bnx2x *bp,
  152. union bnx2x_qable_obj *o,
  153. struct bnx2x_exeq_elem *elem);
  154. typedef int (*exe_q_execute)(struct bnx2x *bp,
  155. union bnx2x_qable_obj *o,
  156. struct list_head *exe_chunk,
  157. unsigned long *ramrod_flags);
  158. typedef struct bnx2x_exeq_elem *
  159. (*exe_q_get)(struct bnx2x_exe_queue_obj *o,
  160. struct bnx2x_exeq_elem *elem);
  161. struct bnx2x_exe_queue_obj {
  162. /*
  163. * Commands pending for an execution.
  164. */
  165. struct list_head exe_queue;
  166. /*
  167. * Commands pending for an completion.
  168. */
  169. struct list_head pending_comp;
  170. spinlock_t lock;
  171. /* Maximum length of commands' list for one execution */
  172. int exe_chunk_len;
  173. union bnx2x_qable_obj *owner;
  174. /****** Virtual functions ******/
  175. /**
  176. * Called before commands execution for commands that are really
  177. * going to be executed (after 'optimize').
  178. *
  179. * Must run under exe_queue->lock
  180. */
  181. exe_q_validate validate;
  182. /**
  183. * Called before removing pending commands, cleaning allocated
  184. * resources (e.g., credits from validate)
  185. */
  186. exe_q_remove remove;
  187. /**
  188. * This will try to cancel the current pending commands list
  189. * considering the new command.
  190. *
  191. * Returns the number of optimized commands or a negative error code
  192. *
  193. * Must run under exe_queue->lock
  194. */
  195. exe_q_optimize optimize;
  196. /**
  197. * Run the next commands chunk (owner specific).
  198. */
  199. exe_q_execute execute;
  200. /**
  201. * Return the exe_queue element containing the specific command
  202. * if any. Otherwise return NULL.
  203. */
  204. exe_q_get get;
  205. };
  206. /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
  207. /*
  208. * Element in the VLAN_MAC registry list having all currenty configured
  209. * rules.
  210. */
  211. struct bnx2x_vlan_mac_registry_elem {
  212. struct list_head link;
  213. /*
  214. * Used to store the cam offset used for the mac/vlan/vlan-mac.
  215. * Relevant for 57710 and 57711 only. VLANs and MACs share the
  216. * same CAM for these chips.
  217. */
  218. int cam_offset;
  219. /* Needed for DEL and RESTORE flows */
  220. unsigned long vlan_mac_flags;
  221. union bnx2x_classification_ramrod_data u;
  222. };
  223. /* Bits representing VLAN_MAC commands specific flags */
  224. enum {
  225. BNX2X_UC_LIST_MAC,
  226. BNX2X_ETH_MAC,
  227. BNX2X_ISCSI_ETH_MAC,
  228. BNX2X_NETQ_ETH_MAC,
  229. BNX2X_DONT_CONSUME_CAM_CREDIT,
  230. BNX2X_DONT_CONSUME_CAM_CREDIT_DEST,
  231. };
  232. struct bnx2x_vlan_mac_ramrod_params {
  233. /* Object to run the command from */
  234. struct bnx2x_vlan_mac_obj *vlan_mac_obj;
  235. /* General command flags: COMP_WAIT, etc. */
  236. unsigned long ramrod_flags;
  237. /* Command specific configuration request */
  238. struct bnx2x_vlan_mac_data user_req;
  239. };
  240. struct bnx2x_vlan_mac_obj {
  241. struct bnx2x_raw_obj raw;
  242. /* Bookkeeping list: will prevent the addition of already existing
  243. * entries.
  244. */
  245. struct list_head head;
  246. /* TODO: Add it's initialization in the init functions */
  247. struct bnx2x_exe_queue_obj exe_queue;
  248. /* MACs credit pool */
  249. struct bnx2x_credit_pool_obj *macs_pool;
  250. /* VLANs credit pool */
  251. struct bnx2x_credit_pool_obj *vlans_pool;
  252. /* RAMROD command to be used */
  253. int ramrod_cmd;
  254. /* copy first n elements onto preallocated buffer
  255. *
  256. * @param n number of elements to get
  257. * @param buf buffer preallocated by caller into which elements
  258. * will be copied. Note elements are 4-byte aligned
  259. * so buffer size must be able to accomodate the
  260. * aligned elements.
  261. *
  262. * @return number of copied bytes
  263. */
  264. int (*get_n_elements)(struct bnx2x *bp,
  265. struct bnx2x_vlan_mac_obj *o, int n, u8 *base,
  266. u8 stride, u8 size);
  267. /**
  268. * Checks if ADD-ramrod with the given params may be performed.
  269. *
  270. * @return zero if the element may be added
  271. */
  272. int (*check_add)(struct bnx2x *bp,
  273. struct bnx2x_vlan_mac_obj *o,
  274. union bnx2x_classification_ramrod_data *data);
  275. /**
  276. * Checks if DEL-ramrod with the given params may be performed.
  277. *
  278. * @return true if the element may be deleted
  279. */
  280. struct bnx2x_vlan_mac_registry_elem *
  281. (*check_del)(struct bnx2x *bp,
  282. struct bnx2x_vlan_mac_obj *o,
  283. union bnx2x_classification_ramrod_data *data);
  284. /**
  285. * Checks if DEL-ramrod with the given params may be performed.
  286. *
  287. * @return true if the element may be deleted
  288. */
  289. bool (*check_move)(struct bnx2x *bp,
  290. struct bnx2x_vlan_mac_obj *src_o,
  291. struct bnx2x_vlan_mac_obj *dst_o,
  292. union bnx2x_classification_ramrod_data *data);
  293. /**
  294. * Update the relevant credit object(s) (consume/return
  295. * correspondingly).
  296. */
  297. bool (*get_credit)(struct bnx2x_vlan_mac_obj *o);
  298. bool (*put_credit)(struct bnx2x_vlan_mac_obj *o);
  299. bool (*get_cam_offset)(struct bnx2x_vlan_mac_obj *o, int *offset);
  300. bool (*put_cam_offset)(struct bnx2x_vlan_mac_obj *o, int offset);
  301. /**
  302. * Configures one rule in the ramrod data buffer.
  303. */
  304. void (*set_one_rule)(struct bnx2x *bp,
  305. struct bnx2x_vlan_mac_obj *o,
  306. struct bnx2x_exeq_elem *elem, int rule_idx,
  307. int cam_offset);
  308. /**
  309. * Delete all configured elements having the given
  310. * vlan_mac_flags specification. Assumes no pending for
  311. * execution commands. Will schedule all all currently
  312. * configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
  313. * specification for deletion and will use the given
  314. * ramrod_flags for the last DEL operation.
  315. *
  316. * @param bp
  317. * @param o
  318. * @param ramrod_flags RAMROD_XX flags
  319. *
  320. * @return 0 if the last operation has completed successfully
  321. * and there are no more elements left, positive value
  322. * if there are pending for completion commands,
  323. * negative value in case of failure.
  324. */
  325. int (*delete_all)(struct bnx2x *bp,
  326. struct bnx2x_vlan_mac_obj *o,
  327. unsigned long *vlan_mac_flags,
  328. unsigned long *ramrod_flags);
  329. /**
  330. * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
  331. * configured elements list.
  332. *
  333. * @param bp
  334. * @param p Command parameters (RAMROD_COMP_WAIT bit in
  335. * ramrod_flags is only taken into an account)
  336. * @param ppos a pointer to the cooky that should be given back in the
  337. * next call to make function handle the next element. If
  338. * *ppos is set to NULL it will restart the iterator.
  339. * If returned *ppos == NULL this means that the last
  340. * element has been handled.
  341. *
  342. * @return int
  343. */
  344. int (*restore)(struct bnx2x *bp,
  345. struct bnx2x_vlan_mac_ramrod_params *p,
  346. struct bnx2x_vlan_mac_registry_elem **ppos);
  347. /**
  348. * Should be called on a completion arival.
  349. *
  350. * @param bp
  351. * @param o
  352. * @param cqe Completion element we are handling
  353. * @param ramrod_flags if RAMROD_CONT is set the next bulk of
  354. * pending commands will be executed.
  355. * RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
  356. * may also be set if needed.
  357. *
  358. * @return 0 if there are neither pending nor waiting for
  359. * completion commands. Positive value if there are
  360. * pending for execution or for completion commands.
  361. * Negative value in case of an error (including an
  362. * error in the cqe).
  363. */
  364. int (*complete)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
  365. union event_ring_elem *cqe,
  366. unsigned long *ramrod_flags);
  367. /**
  368. * Wait for completion of all commands. Don't schedule new ones,
  369. * just wait. It assumes that the completion code will schedule
  370. * for new commands.
  371. */
  372. int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o);
  373. };
  374. enum {
  375. BNX2X_LLH_CAM_ISCSI_ETH_LINE = 0,
  376. BNX2X_LLH_CAM_ETH_LINE,
  377. BNX2X_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2
  378. };
  379. void bnx2x_set_mac_in_nig(struct bnx2x *bp,
  380. bool add, unsigned char *dev_addr, int index);
  381. /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
  382. /* RX_MODE ramrod spesial flags: set in rx_mode_flags field in
  383. * a bnx2x_rx_mode_ramrod_params.
  384. */
  385. enum {
  386. BNX2X_RX_MODE_FCOE_ETH,
  387. BNX2X_RX_MODE_ISCSI_ETH,
  388. };
  389. enum {
  390. BNX2X_ACCEPT_UNICAST,
  391. BNX2X_ACCEPT_MULTICAST,
  392. BNX2X_ACCEPT_ALL_UNICAST,
  393. BNX2X_ACCEPT_ALL_MULTICAST,
  394. BNX2X_ACCEPT_BROADCAST,
  395. BNX2X_ACCEPT_UNMATCHED,
  396. BNX2X_ACCEPT_ANY_VLAN
  397. };
  398. struct bnx2x_rx_mode_ramrod_params {
  399. struct bnx2x_rx_mode_obj *rx_mode_obj;
  400. unsigned long *pstate;
  401. int state;
  402. u8 cl_id;
  403. u32 cid;
  404. u8 func_id;
  405. unsigned long ramrod_flags;
  406. unsigned long rx_mode_flags;
  407. /*
  408. * rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
  409. * a tstorm_eth_mac_filter_config (e1x).
  410. */
  411. void *rdata;
  412. dma_addr_t rdata_mapping;
  413. /* Rx mode settings */
  414. unsigned long rx_accept_flags;
  415. /* internal switching settings */
  416. unsigned long tx_accept_flags;
  417. };
  418. struct bnx2x_rx_mode_obj {
  419. int (*config_rx_mode)(struct bnx2x *bp,
  420. struct bnx2x_rx_mode_ramrod_params *p);
  421. int (*wait_comp)(struct bnx2x *bp,
  422. struct bnx2x_rx_mode_ramrod_params *p);
  423. };
  424. /********************** Set multicast group ***********************************/
  425. struct bnx2x_mcast_list_elem {
  426. struct list_head link;
  427. u8 *mac;
  428. };
  429. union bnx2x_mcast_config_data {
  430. u8 *mac;
  431. u8 bin; /* used in a RESTORE flow */
  432. };
  433. struct bnx2x_mcast_ramrod_params {
  434. struct bnx2x_mcast_obj *mcast_obj;
  435. /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
  436. unsigned long ramrod_flags;
  437. struct list_head mcast_list; /* list of struct bnx2x_mcast_list_elem */
  438. /** TODO:
  439. * - rename it to macs_num.
  440. * - Add a new command type for handling pending commands
  441. * (remove "zero semantics").
  442. *
  443. * Length of mcast_list. If zero and ADD_CONT command - post
  444. * pending commands.
  445. */
  446. int mcast_list_len;
  447. };
  448. enum bnx2x_mcast_cmd {
  449. BNX2X_MCAST_CMD_ADD,
  450. BNX2X_MCAST_CMD_CONT,
  451. BNX2X_MCAST_CMD_DEL,
  452. BNX2X_MCAST_CMD_RESTORE,
  453. };
  454. struct bnx2x_mcast_obj {
  455. struct bnx2x_raw_obj raw;
  456. union {
  457. struct {
  458. #define BNX2X_MCAST_BINS_NUM 256
  459. #define BNX2X_MCAST_VEC_SZ (BNX2X_MCAST_BINS_NUM / 64)
  460. u64 vec[BNX2X_MCAST_VEC_SZ];
  461. /** Number of BINs to clear. Should be updated
  462. * immediately when a command arrives in order to
  463. * properly create DEL commands.
  464. */
  465. int num_bins_set;
  466. } aprox_match;
  467. struct {
  468. struct list_head macs;
  469. int num_macs_set;
  470. } exact_match;
  471. } registry;
  472. /* Pending commands */
  473. struct list_head pending_cmds_head;
  474. /* A state that is set in raw.pstate, when there are pending commands */
  475. int sched_state;
  476. /* Maximal number of mcast MACs configured in one command */
  477. int max_cmd_len;
  478. /* Total number of currently pending MACs to configure: both
  479. * in the pending commands list and in the current command.
  480. */
  481. int total_pending_num;
  482. u8 engine_id;
  483. /**
  484. * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above)
  485. */
  486. int (*config_mcast)(struct bnx2x *bp,
  487. struct bnx2x_mcast_ramrod_params *p,
  488. enum bnx2x_mcast_cmd cmd);
  489. /**
  490. * Fills the ramrod data during the RESTORE flow.
  491. *
  492. * @param bp
  493. * @param o
  494. * @param start_idx Registry index to start from
  495. * @param rdata_idx Index in the ramrod data to start from
  496. *
  497. * @return -1 if we handled the whole registry or index of the last
  498. * handled registry element.
  499. */
  500. int (*hdl_restore)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
  501. int start_bin, int *rdata_idx);
  502. int (*enqueue_cmd)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
  503. struct bnx2x_mcast_ramrod_params *p,
  504. enum bnx2x_mcast_cmd cmd);
  505. void (*set_one_rule)(struct bnx2x *bp,
  506. struct bnx2x_mcast_obj *o, int idx,
  507. union bnx2x_mcast_config_data *cfg_data,
  508. enum bnx2x_mcast_cmd cmd);
  509. /** Checks if there are more mcast MACs to be set or a previous
  510. * command is still pending.
  511. */
  512. bool (*check_pending)(struct bnx2x_mcast_obj *o);
  513. /**
  514. * Set/Clear/Check SCHEDULED state of the object
  515. */
  516. void (*set_sched)(struct bnx2x_mcast_obj *o);
  517. void (*clear_sched)(struct bnx2x_mcast_obj *o);
  518. bool (*check_sched)(struct bnx2x_mcast_obj *o);
  519. /* Wait until all pending commands complete */
  520. int (*wait_comp)(struct bnx2x *bp, struct bnx2x_mcast_obj *o);
  521. /**
  522. * Handle the internal object counters needed for proper
  523. * commands handling. Checks that the provided parameters are
  524. * feasible.
  525. */
  526. int (*validate)(struct bnx2x *bp,
  527. struct bnx2x_mcast_ramrod_params *p,
  528. enum bnx2x_mcast_cmd cmd);
  529. /**
  530. * Restore the values of internal counters in case of a failure.
  531. */
  532. void (*revert)(struct bnx2x *bp,
  533. struct bnx2x_mcast_ramrod_params *p,
  534. int old_num_bins);
  535. int (*get_registry_size)(struct bnx2x_mcast_obj *o);
  536. void (*set_registry_size)(struct bnx2x_mcast_obj *o, int n);
  537. };
  538. /*************************** Credit handling **********************************/
  539. struct bnx2x_credit_pool_obj {
  540. /* Current amount of credit in the pool */
  541. atomic_t credit;
  542. /* Maximum allowed credit. put() will check against it. */
  543. int pool_sz;
  544. /*
  545. * Allocate a pool table statically.
  546. *
  547. * Currently the mamimum allowed size is MAX_MAC_CREDIT_E2(272)
  548. *
  549. * The set bit in the table will mean that the entry is available.
  550. */
  551. #define BNX2X_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64)
  552. u64 pool_mirror[BNX2X_POOL_VEC_SIZE];
  553. /* Base pool offset (initialized differently */
  554. int base_pool_offset;
  555. /**
  556. * Get the next free pool entry.
  557. *
  558. * @return true if there was a free entry in the pool
  559. */
  560. bool (*get_entry)(struct bnx2x_credit_pool_obj *o, int *entry);
  561. /**
  562. * Return the entry back to the pool.
  563. *
  564. * @return true if entry is legal and has been successfully
  565. * returned to the pool.
  566. */
  567. bool (*put_entry)(struct bnx2x_credit_pool_obj *o, int entry);
  568. /**
  569. * Get the requested amount of credit from the pool.
  570. *
  571. * @param cnt Amount of requested credit
  572. * @return true if the operation is successful
  573. */
  574. bool (*get)(struct bnx2x_credit_pool_obj *o, int cnt);
  575. /**
  576. * Returns the credit to the pool.
  577. *
  578. * @param cnt Amount of credit to return
  579. * @return true if the operation is successful
  580. */
  581. bool (*put)(struct bnx2x_credit_pool_obj *o, int cnt);
  582. /**
  583. * Reads the current amount of credit.
  584. */
  585. int (*check)(struct bnx2x_credit_pool_obj *o);
  586. };
  587. /*************************** RSS configuration ********************************/
  588. enum {
  589. /* RSS_MODE bits are mutually exclusive */
  590. BNX2X_RSS_MODE_DISABLED,
  591. BNX2X_RSS_MODE_REGULAR,
  592. BNX2X_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */
  593. BNX2X_RSS_IPV4,
  594. BNX2X_RSS_IPV4_TCP,
  595. BNX2X_RSS_IPV4_UDP,
  596. BNX2X_RSS_IPV6,
  597. BNX2X_RSS_IPV6_TCP,
  598. BNX2X_RSS_IPV6_UDP,
  599. };
  600. struct bnx2x_config_rss_params {
  601. struct bnx2x_rss_config_obj *rss_obj;
  602. /* may have RAMROD_COMP_WAIT set only */
  603. unsigned long ramrod_flags;
  604. /* BNX2X_RSS_X bits */
  605. unsigned long rss_flags;
  606. /* Number hash bits to take into an account */
  607. u8 rss_result_mask;
  608. /* Indirection table */
  609. u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
  610. /* RSS hash values */
  611. u32 rss_key[10];
  612. /* valid only iff BNX2X_RSS_UPDATE_TOE is set */
  613. u16 toe_rss_bitmap;
  614. };
  615. struct bnx2x_rss_config_obj {
  616. struct bnx2x_raw_obj raw;
  617. /* RSS engine to use */
  618. u8 engine_id;
  619. /* Last configured indirection table */
  620. u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
  621. /* flags for enabling 4-tupple hash on UDP */
  622. u8 udp_rss_v4;
  623. u8 udp_rss_v6;
  624. int (*config_rss)(struct bnx2x *bp,
  625. struct bnx2x_config_rss_params *p);
  626. };
  627. /*********************** Queue state update ***********************************/
  628. /* UPDATE command options */
  629. enum {
  630. BNX2X_Q_UPDATE_IN_VLAN_REM,
  631. BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG,
  632. BNX2X_Q_UPDATE_OUT_VLAN_REM,
  633. BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG,
  634. BNX2X_Q_UPDATE_ANTI_SPOOF,
  635. BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG,
  636. BNX2X_Q_UPDATE_ACTIVATE,
  637. BNX2X_Q_UPDATE_ACTIVATE_CHNG,
  638. BNX2X_Q_UPDATE_DEF_VLAN_EN,
  639. BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG,
  640. BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG,
  641. BNX2X_Q_UPDATE_SILENT_VLAN_REM
  642. };
  643. /* Allowed Queue states */
  644. enum bnx2x_q_state {
  645. BNX2X_Q_STATE_RESET,
  646. BNX2X_Q_STATE_INITIALIZED,
  647. BNX2X_Q_STATE_ACTIVE,
  648. BNX2X_Q_STATE_MULTI_COS,
  649. BNX2X_Q_STATE_MCOS_TERMINATED,
  650. BNX2X_Q_STATE_INACTIVE,
  651. BNX2X_Q_STATE_STOPPED,
  652. BNX2X_Q_STATE_TERMINATED,
  653. BNX2X_Q_STATE_FLRED,
  654. BNX2X_Q_STATE_MAX,
  655. };
  656. /* Allowed Queue states */
  657. enum bnx2x_q_logical_state {
  658. BNX2X_Q_LOGICAL_STATE_ACTIVE,
  659. BNX2X_Q_LOGICAL_STATE_STOPPED,
  660. };
  661. /* Allowed commands */
  662. enum bnx2x_queue_cmd {
  663. BNX2X_Q_CMD_INIT,
  664. BNX2X_Q_CMD_SETUP,
  665. BNX2X_Q_CMD_SETUP_TX_ONLY,
  666. BNX2X_Q_CMD_DEACTIVATE,
  667. BNX2X_Q_CMD_ACTIVATE,
  668. BNX2X_Q_CMD_UPDATE,
  669. BNX2X_Q_CMD_UPDATE_TPA,
  670. BNX2X_Q_CMD_HALT,
  671. BNX2X_Q_CMD_CFC_DEL,
  672. BNX2X_Q_CMD_TERMINATE,
  673. BNX2X_Q_CMD_EMPTY,
  674. BNX2X_Q_CMD_MAX,
  675. };
  676. /* queue SETUP + INIT flags */
  677. enum {
  678. BNX2X_Q_FLG_TPA,
  679. BNX2X_Q_FLG_TPA_IPV6,
  680. BNX2X_Q_FLG_TPA_GRO,
  681. BNX2X_Q_FLG_STATS,
  682. BNX2X_Q_FLG_ZERO_STATS,
  683. BNX2X_Q_FLG_ACTIVE,
  684. BNX2X_Q_FLG_OV,
  685. BNX2X_Q_FLG_VLAN,
  686. BNX2X_Q_FLG_COS,
  687. BNX2X_Q_FLG_HC,
  688. BNX2X_Q_FLG_HC_EN,
  689. BNX2X_Q_FLG_DHC,
  690. BNX2X_Q_FLG_FCOE,
  691. BNX2X_Q_FLG_LEADING_RSS,
  692. BNX2X_Q_FLG_MCAST,
  693. BNX2X_Q_FLG_DEF_VLAN,
  694. BNX2X_Q_FLG_TX_SWITCH,
  695. BNX2X_Q_FLG_TX_SEC,
  696. BNX2X_Q_FLG_ANTI_SPOOF,
  697. BNX2X_Q_FLG_SILENT_VLAN_REM,
  698. BNX2X_Q_FLG_FORCE_DEFAULT_PRI,
  699. BNX2X_Q_FLG_PCSUM_ON_PKT,
  700. BNX2X_Q_FLG_TUN_INC_INNER_IP_ID
  701. };
  702. /* Queue type options: queue type may be a compination of below. */
  703. enum bnx2x_q_type {
  704. /** TODO: Consider moving both these flags into the init()
  705. * ramrod params.
  706. */
  707. BNX2X_Q_TYPE_HAS_RX,
  708. BNX2X_Q_TYPE_HAS_TX,
  709. };
  710. #define BNX2X_PRIMARY_CID_INDEX 0
  711. #define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */
  712. #define BNX2X_MULTI_TX_COS_E2_E3A0 2
  713. #define BNX2X_MULTI_TX_COS_E3B0 3
  714. #define BNX2X_MULTI_TX_COS 3 /* Maximum possible */
  715. #define MAC_PAD (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)
  716. struct bnx2x_queue_init_params {
  717. struct {
  718. unsigned long flags;
  719. u16 hc_rate;
  720. u8 fw_sb_id;
  721. u8 sb_cq_index;
  722. } tx;
  723. struct {
  724. unsigned long flags;
  725. u16 hc_rate;
  726. u8 fw_sb_id;
  727. u8 sb_cq_index;
  728. } rx;
  729. /* CID context in the host memory */
  730. struct eth_context *cxts[BNX2X_MULTI_TX_COS];
  731. /* maximum number of cos supported by hardware */
  732. u8 max_cos;
  733. };
  734. struct bnx2x_queue_terminate_params {
  735. /* index within the tx_only cids of this queue object */
  736. u8 cid_index;
  737. };
  738. struct bnx2x_queue_cfc_del_params {
  739. /* index within the tx_only cids of this queue object */
  740. u8 cid_index;
  741. };
  742. struct bnx2x_queue_update_params {
  743. unsigned long update_flags; /* BNX2X_Q_UPDATE_XX bits */
  744. u16 def_vlan;
  745. u16 silent_removal_value;
  746. u16 silent_removal_mask;
  747. /* index within the tx_only cids of this queue object */
  748. u8 cid_index;
  749. };
  750. struct rxq_pause_params {
  751. u16 bd_th_lo;
  752. u16 bd_th_hi;
  753. u16 rcq_th_lo;
  754. u16 rcq_th_hi;
  755. u16 sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */
  756. u16 sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */
  757. u16 pri_map;
  758. };
  759. /* general */
  760. struct bnx2x_general_setup_params {
  761. /* valid iff BNX2X_Q_FLG_STATS */
  762. u8 stat_id;
  763. u8 spcl_id;
  764. u16 mtu;
  765. u8 cos;
  766. };
  767. struct bnx2x_rxq_setup_params {
  768. /* dma */
  769. dma_addr_t dscr_map;
  770. dma_addr_t sge_map;
  771. dma_addr_t rcq_map;
  772. dma_addr_t rcq_np_map;
  773. u16 drop_flags;
  774. u16 buf_sz;
  775. u8 fw_sb_id;
  776. u8 cl_qzone_id;
  777. /* valid iff BNX2X_Q_FLG_TPA */
  778. u16 tpa_agg_sz;
  779. u16 sge_buf_sz;
  780. u8 max_sges_pkt;
  781. u8 max_tpa_queues;
  782. u8 rss_engine_id;
  783. /* valid iff BNX2X_Q_FLG_MCAST */
  784. u8 mcast_engine_id;
  785. u8 cache_line_log;
  786. u8 sb_cq_index;
  787. /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
  788. u16 silent_removal_value;
  789. u16 silent_removal_mask;
  790. };
  791. struct bnx2x_txq_setup_params {
  792. /* dma */
  793. dma_addr_t dscr_map;
  794. u8 fw_sb_id;
  795. u8 sb_cq_index;
  796. u8 cos; /* valid iff BNX2X_Q_FLG_COS */
  797. u16 traffic_type;
  798. /* equals to the leading rss client id, used for TX classification*/
  799. u8 tss_leading_cl_id;
  800. /* valid iff BNX2X_Q_FLG_DEF_VLAN */
  801. u16 default_vlan;
  802. };
  803. struct bnx2x_queue_setup_params {
  804. struct bnx2x_general_setup_params gen_params;
  805. struct bnx2x_txq_setup_params txq_params;
  806. struct bnx2x_rxq_setup_params rxq_params;
  807. struct rxq_pause_params pause_params;
  808. unsigned long flags;
  809. };
  810. struct bnx2x_queue_setup_tx_only_params {
  811. struct bnx2x_general_setup_params gen_params;
  812. struct bnx2x_txq_setup_params txq_params;
  813. unsigned long flags;
  814. /* index within the tx_only cids of this queue object */
  815. u8 cid_index;
  816. };
  817. struct bnx2x_queue_state_params {
  818. struct bnx2x_queue_sp_obj *q_obj;
  819. /* Current command */
  820. enum bnx2x_queue_cmd cmd;
  821. /* may have RAMROD_COMP_WAIT set only */
  822. unsigned long ramrod_flags;
  823. /* Params according to the current command */
  824. union {
  825. struct bnx2x_queue_update_params update;
  826. struct bnx2x_queue_setup_params setup;
  827. struct bnx2x_queue_init_params init;
  828. struct bnx2x_queue_setup_tx_only_params tx_only;
  829. struct bnx2x_queue_terminate_params terminate;
  830. struct bnx2x_queue_cfc_del_params cfc_del;
  831. } params;
  832. };
  833. struct bnx2x_viflist_params {
  834. u8 echo_res;
  835. u8 func_bit_map_res;
  836. };
  837. struct bnx2x_queue_sp_obj {
  838. u32 cids[BNX2X_MULTI_TX_COS];
  839. u8 cl_id;
  840. u8 func_id;
  841. /*
  842. * number of traffic classes supported by queue.
  843. * The primary connection of the queue suppotrs the first traffic
  844. * class. Any further traffic class is suppoted by a tx-only
  845. * connection.
  846. *
  847. * Therefore max_cos is also a number of valid entries in the cids
  848. * array.
  849. */
  850. u8 max_cos;
  851. u8 num_tx_only, next_tx_only;
  852. enum bnx2x_q_state state, next_state;
  853. /* bits from enum bnx2x_q_type */
  854. unsigned long type;
  855. /* BNX2X_Q_CMD_XX bits. This object implements "one
  856. * pending" paradigm but for debug and tracing purposes it's
  857. * more convinient to have different bits for different
  858. * commands.
  859. */
  860. unsigned long pending;
  861. /* Buffer to use as a ramrod data and its mapping */
  862. void *rdata;
  863. dma_addr_t rdata_mapping;
  864. /**
  865. * Performs one state change according to the given parameters.
  866. *
  867. * @return 0 in case of success and negative value otherwise.
  868. */
  869. int (*send_cmd)(struct bnx2x *bp,
  870. struct bnx2x_queue_state_params *params);
  871. /**
  872. * Sets the pending bit according to the requested transition.
  873. */
  874. int (*set_pending)(struct bnx2x_queue_sp_obj *o,
  875. struct bnx2x_queue_state_params *params);
  876. /**
  877. * Checks that the requested state transition is legal.
  878. */
  879. int (*check_transition)(struct bnx2x *bp,
  880. struct bnx2x_queue_sp_obj *o,
  881. struct bnx2x_queue_state_params *params);
  882. /**
  883. * Completes the pending command.
  884. */
  885. int (*complete_cmd)(struct bnx2x *bp,
  886. struct bnx2x_queue_sp_obj *o,
  887. enum bnx2x_queue_cmd);
  888. int (*wait_comp)(struct bnx2x *bp,
  889. struct bnx2x_queue_sp_obj *o,
  890. enum bnx2x_queue_cmd cmd);
  891. };
  892. /********************** Function state update *********************************/
  893. /* Allowed Function states */
  894. enum bnx2x_func_state {
  895. BNX2X_F_STATE_RESET,
  896. BNX2X_F_STATE_INITIALIZED,
  897. BNX2X_F_STATE_STARTED,
  898. BNX2X_F_STATE_TX_STOPPED,
  899. BNX2X_F_STATE_MAX,
  900. };
  901. /* Allowed Function commands */
  902. enum bnx2x_func_cmd {
  903. BNX2X_F_CMD_HW_INIT,
  904. BNX2X_F_CMD_START,
  905. BNX2X_F_CMD_STOP,
  906. BNX2X_F_CMD_HW_RESET,
  907. BNX2X_F_CMD_AFEX_UPDATE,
  908. BNX2X_F_CMD_AFEX_VIFLISTS,
  909. BNX2X_F_CMD_TX_STOP,
  910. BNX2X_F_CMD_TX_START,
  911. BNX2X_F_CMD_SWITCH_UPDATE,
  912. BNX2X_F_CMD_MAX,
  913. };
  914. struct bnx2x_func_hw_init_params {
  915. /* A load phase returned by MCP.
  916. *
  917. * May be:
  918. * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
  919. * FW_MSG_CODE_DRV_LOAD_COMMON
  920. * FW_MSG_CODE_DRV_LOAD_PORT
  921. * FW_MSG_CODE_DRV_LOAD_FUNCTION
  922. */
  923. u32 load_phase;
  924. };
  925. struct bnx2x_func_hw_reset_params {
  926. /* A load phase returned by MCP.
  927. *
  928. * May be:
  929. * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
  930. * FW_MSG_CODE_DRV_LOAD_COMMON
  931. * FW_MSG_CODE_DRV_LOAD_PORT
  932. * FW_MSG_CODE_DRV_LOAD_FUNCTION
  933. */
  934. u32 reset_phase;
  935. };
  936. struct bnx2x_func_start_params {
  937. /* Multi Function mode:
  938. * - Single Function
  939. * - Switch Dependent
  940. * - Switch Independent
  941. */
  942. u16 mf_mode;
  943. /* Switch Dependent mode outer VLAN tag */
  944. u16 sd_vlan_tag;
  945. /* Function cos mode */
  946. u8 network_cos_mode;
  947. /* NVGRE classification enablement */
  948. u8 nvgre_clss_en;
  949. /* NO_GRE_TUNNEL/NVGRE_TUNNEL/L2GRE_TUNNEL/IPGRE_TUNNEL */
  950. u8 gre_tunnel_mode;
  951. /* GRE_OUTER_HEADERS_RSS/GRE_INNER_HEADERS_RSS/NVGRE_KEY_ENTROPY_RSS */
  952. u8 gre_tunnel_rss;
  953. };
  954. struct bnx2x_func_switch_update_params {
  955. u8 suspend;
  956. };
  957. struct bnx2x_func_afex_update_params {
  958. u16 vif_id;
  959. u16 afex_default_vlan;
  960. u8 allowed_priorities;
  961. };
  962. struct bnx2x_func_afex_viflists_params {
  963. u16 vif_list_index;
  964. u8 func_bit_map;
  965. u8 afex_vif_list_command;
  966. u8 func_to_clear;
  967. };
  968. struct bnx2x_func_tx_start_params {
  969. struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES];
  970. u8 dcb_enabled;
  971. u8 dcb_version;
  972. u8 dont_add_pri_0_en;
  973. };
  974. struct bnx2x_func_state_params {
  975. struct bnx2x_func_sp_obj *f_obj;
  976. /* Current command */
  977. enum bnx2x_func_cmd cmd;
  978. /* may have RAMROD_COMP_WAIT set only */
  979. unsigned long ramrod_flags;
  980. /* Params according to the current command */
  981. union {
  982. struct bnx2x_func_hw_init_params hw_init;
  983. struct bnx2x_func_hw_reset_params hw_reset;
  984. struct bnx2x_func_start_params start;
  985. struct bnx2x_func_switch_update_params switch_update;
  986. struct bnx2x_func_afex_update_params afex_update;
  987. struct bnx2x_func_afex_viflists_params afex_viflists;
  988. struct bnx2x_func_tx_start_params tx_start;
  989. } params;
  990. };
  991. struct bnx2x_func_sp_drv_ops {
  992. /* Init tool + runtime initialization:
  993. * - Common Chip
  994. * - Common (per Path)
  995. * - Port
  996. * - Function phases
  997. */
  998. int (*init_hw_cmn_chip)(struct bnx2x *bp);
  999. int (*init_hw_cmn)(struct bnx2x *bp);
  1000. int (*init_hw_port)(struct bnx2x *bp);
  1001. int (*init_hw_func)(struct bnx2x *bp);
  1002. /* Reset Function HW: Common, Port, Function phases. */
  1003. void (*reset_hw_cmn)(struct bnx2x *bp);
  1004. void (*reset_hw_port)(struct bnx2x *bp);
  1005. void (*reset_hw_func)(struct bnx2x *bp);
  1006. /* Init/Free GUNZIP resources */
  1007. int (*gunzip_init)(struct bnx2x *bp);
  1008. void (*gunzip_end)(struct bnx2x *bp);
  1009. /* Prepare/Release FW resources */
  1010. int (*init_fw)(struct bnx2x *bp);
  1011. void (*release_fw)(struct bnx2x *bp);
  1012. };
  1013. struct bnx2x_func_sp_obj {
  1014. enum bnx2x_func_state state, next_state;
  1015. /* BNX2X_FUNC_CMD_XX bits. This object implements "one
  1016. * pending" paradigm but for debug and tracing purposes it's
  1017. * more convinient to have different bits for different
  1018. * commands.
  1019. */
  1020. unsigned long pending;
  1021. /* Buffer to use as a ramrod data and its mapping */
  1022. void *rdata;
  1023. dma_addr_t rdata_mapping;
  1024. /* Buffer to use as a afex ramrod data and its mapping.
  1025. * This can't be same rdata as above because afex ramrod requests
  1026. * can arrive to the object in parallel to other ramrod requests.
  1027. */
  1028. void *afex_rdata;
  1029. dma_addr_t afex_rdata_mapping;
  1030. /* this mutex validates that when pending flag is taken, the next
  1031. * ramrod to be sent will be the one set the pending bit
  1032. */
  1033. struct mutex one_pending_mutex;
  1034. /* Driver interface */
  1035. struct bnx2x_func_sp_drv_ops *drv;
  1036. /**
  1037. * Performs one state change according to the given parameters.
  1038. *
  1039. * @return 0 in case of success and negative value otherwise.
  1040. */
  1041. int (*send_cmd)(struct bnx2x *bp,
  1042. struct bnx2x_func_state_params *params);
  1043. /**
  1044. * Checks that the requested state transition is legal.
  1045. */
  1046. int (*check_transition)(struct bnx2x *bp,
  1047. struct bnx2x_func_sp_obj *o,
  1048. struct bnx2x_func_state_params *params);
  1049. /**
  1050. * Completes the pending command.
  1051. */
  1052. int (*complete_cmd)(struct bnx2x *bp,
  1053. struct bnx2x_func_sp_obj *o,
  1054. enum bnx2x_func_cmd cmd);
  1055. int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o,
  1056. enum bnx2x_func_cmd cmd);
  1057. };
  1058. /********************** Interfaces ********************************************/
  1059. /* Queueable objects set */
  1060. union bnx2x_qable_obj {
  1061. struct bnx2x_vlan_mac_obj vlan_mac;
  1062. };
  1063. /************** Function state update *********/
  1064. void bnx2x_init_func_obj(struct bnx2x *bp,
  1065. struct bnx2x_func_sp_obj *obj,
  1066. void *rdata, dma_addr_t rdata_mapping,
  1067. void *afex_rdata, dma_addr_t afex_rdata_mapping,
  1068. struct bnx2x_func_sp_drv_ops *drv_iface);
  1069. int bnx2x_func_state_change(struct bnx2x *bp,
  1070. struct bnx2x_func_state_params *params);
  1071. enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp,
  1072. struct bnx2x_func_sp_obj *o);
  1073. /******************* Queue State **************/
  1074. void bnx2x_init_queue_obj(struct bnx2x *bp,
  1075. struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids,
  1076. u8 cid_cnt, u8 func_id, void *rdata,
  1077. dma_addr_t rdata_mapping, unsigned long type);
  1078. int bnx2x_queue_state_change(struct bnx2x *bp,
  1079. struct bnx2x_queue_state_params *params);
  1080. int bnx2x_get_q_logical_state(struct bnx2x *bp,
  1081. struct bnx2x_queue_sp_obj *obj);
  1082. /********************* VLAN-MAC ****************/
  1083. void bnx2x_init_mac_obj(struct bnx2x *bp,
  1084. struct bnx2x_vlan_mac_obj *mac_obj,
  1085. u8 cl_id, u32 cid, u8 func_id, void *rdata,
  1086. dma_addr_t rdata_mapping, int state,
  1087. unsigned long *pstate, bnx2x_obj_type type,
  1088. struct bnx2x_credit_pool_obj *macs_pool);
  1089. void bnx2x_init_vlan_obj(struct bnx2x *bp,
  1090. struct bnx2x_vlan_mac_obj *vlan_obj,
  1091. u8 cl_id, u32 cid, u8 func_id, void *rdata,
  1092. dma_addr_t rdata_mapping, int state,
  1093. unsigned long *pstate, bnx2x_obj_type type,
  1094. struct bnx2x_credit_pool_obj *vlans_pool);
  1095. void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
  1096. struct bnx2x_vlan_mac_obj *vlan_mac_obj,
  1097. u8 cl_id, u32 cid, u8 func_id, void *rdata,
  1098. dma_addr_t rdata_mapping, int state,
  1099. unsigned long *pstate, bnx2x_obj_type type,
  1100. struct bnx2x_credit_pool_obj *macs_pool,
  1101. struct bnx2x_credit_pool_obj *vlans_pool);
  1102. int bnx2x_config_vlan_mac(struct bnx2x *bp,
  1103. struct bnx2x_vlan_mac_ramrod_params *p);
  1104. int bnx2x_vlan_mac_move(struct bnx2x *bp,
  1105. struct bnx2x_vlan_mac_ramrod_params *p,
  1106. struct bnx2x_vlan_mac_obj *dest_o);
  1107. /********************* RX MODE ****************/
  1108. void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
  1109. struct bnx2x_rx_mode_obj *o);
  1110. /**
  1111. * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
  1112. *
  1113. * @p: Command parameters
  1114. *
  1115. * Return: 0 - if operation was successfull and there is no pending completions,
  1116. * positive number - if there are pending completions,
  1117. * negative - if there were errors
  1118. */
  1119. int bnx2x_config_rx_mode(struct bnx2x *bp,
  1120. struct bnx2x_rx_mode_ramrod_params *p);
  1121. /****************** MULTICASTS ****************/
  1122. void bnx2x_init_mcast_obj(struct bnx2x *bp,
  1123. struct bnx2x_mcast_obj *mcast_obj,
  1124. u8 mcast_cl_id, u32 mcast_cid, u8 func_id,
  1125. u8 engine_id, void *rdata, dma_addr_t rdata_mapping,
  1126. int state, unsigned long *pstate,
  1127. bnx2x_obj_type type);
  1128. /**
  1129. * bnx2x_config_mcast - Configure multicast MACs list.
  1130. *
  1131. * @cmd: command to execute: BNX2X_MCAST_CMD_X
  1132. *
  1133. * May configure a new list
  1134. * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up
  1135. * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current
  1136. * configuration, continue to execute the pending commands
  1137. * (BNX2X_MCAST_CMD_CONT).
  1138. *
  1139. * If previous command is still pending or if number of MACs to
  1140. * configure is more that maximum number of MACs in one command,
  1141. * the current command will be enqueued to the tail of the
  1142. * pending commands list.
  1143. *
  1144. * Return: 0 is operation was successfull and there are no pending completions,
  1145. * negative if there were errors, positive if there are pending
  1146. * completions.
  1147. */
  1148. int bnx2x_config_mcast(struct bnx2x *bp,
  1149. struct bnx2x_mcast_ramrod_params *p,
  1150. enum bnx2x_mcast_cmd cmd);
  1151. /****************** CREDIT POOL ****************/
  1152. void bnx2x_init_mac_credit_pool(struct bnx2x *bp,
  1153. struct bnx2x_credit_pool_obj *p, u8 func_id,
  1154. u8 func_num);
  1155. void bnx2x_init_vlan_credit_pool(struct bnx2x *bp,
  1156. struct bnx2x_credit_pool_obj *p, u8 func_id,
  1157. u8 func_num);
  1158. /****************** RSS CONFIGURATION ****************/
  1159. void bnx2x_init_rss_config_obj(struct bnx2x *bp,
  1160. struct bnx2x_rss_config_obj *rss_obj,
  1161. u8 cl_id, u32 cid, u8 func_id, u8 engine_id,
  1162. void *rdata, dma_addr_t rdata_mapping,
  1163. int state, unsigned long *pstate,
  1164. bnx2x_obj_type type);
  1165. /**
  1166. * bnx2x_config_rss - Updates RSS configuration according to provided parameters
  1167. *
  1168. * Return: 0 in case of success
  1169. */
  1170. int bnx2x_config_rss(struct bnx2x *bp,
  1171. struct bnx2x_config_rss_params *p);
  1172. /**
  1173. * bnx2x_get_rss_ind_table - Return the current ind_table configuration.
  1174. *
  1175. * @ind_table: buffer to fill with the current indirection
  1176. * table content. Should be at least
  1177. * T_ETH_INDIRECTION_TABLE_SIZE bytes long.
  1178. */
  1179. void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj,
  1180. u8 *ind_table);
  1181. #endif /* BNX2X_SP_VERBS */