bnx2x_sp.h 37 KB

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