bnx2x_sp.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494
  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. BNX2X_RSS_GRE_INNER_HDRS,
  602. };
  603. struct bnx2x_config_rss_params {
  604. struct bnx2x_rss_config_obj *rss_obj;
  605. /* may have RAMROD_COMP_WAIT set only */
  606. unsigned long ramrod_flags;
  607. /* BNX2X_RSS_X bits */
  608. unsigned long rss_flags;
  609. /* Number hash bits to take into an account */
  610. u8 rss_result_mask;
  611. /* Indirection table */
  612. u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
  613. /* RSS hash values */
  614. u32 rss_key[10];
  615. /* valid only iff BNX2X_RSS_UPDATE_TOE is set */
  616. u16 toe_rss_bitmap;
  617. };
  618. struct bnx2x_rss_config_obj {
  619. struct bnx2x_raw_obj raw;
  620. /* RSS engine to use */
  621. u8 engine_id;
  622. /* Last configured indirection table */
  623. u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
  624. /* flags for enabling 4-tupple hash on UDP */
  625. u8 udp_rss_v4;
  626. u8 udp_rss_v6;
  627. int (*config_rss)(struct bnx2x *bp,
  628. struct bnx2x_config_rss_params *p);
  629. };
  630. /*********************** Queue state update ***********************************/
  631. /* UPDATE command options */
  632. enum {
  633. BNX2X_Q_UPDATE_IN_VLAN_REM,
  634. BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG,
  635. BNX2X_Q_UPDATE_OUT_VLAN_REM,
  636. BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG,
  637. BNX2X_Q_UPDATE_ANTI_SPOOF,
  638. BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG,
  639. BNX2X_Q_UPDATE_ACTIVATE,
  640. BNX2X_Q_UPDATE_ACTIVATE_CHNG,
  641. BNX2X_Q_UPDATE_DEF_VLAN_EN,
  642. BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG,
  643. BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG,
  644. BNX2X_Q_UPDATE_SILENT_VLAN_REM,
  645. BNX2X_Q_UPDATE_TX_SWITCHING_CHNG,
  646. BNX2X_Q_UPDATE_TX_SWITCHING,
  647. BNX2X_Q_UPDATE_PTP_PKTS_CHNG,
  648. BNX2X_Q_UPDATE_PTP_PKTS,
  649. };
  650. /* Allowed Queue states */
  651. enum bnx2x_q_state {
  652. BNX2X_Q_STATE_RESET,
  653. BNX2X_Q_STATE_INITIALIZED,
  654. BNX2X_Q_STATE_ACTIVE,
  655. BNX2X_Q_STATE_MULTI_COS,
  656. BNX2X_Q_STATE_MCOS_TERMINATED,
  657. BNX2X_Q_STATE_INACTIVE,
  658. BNX2X_Q_STATE_STOPPED,
  659. BNX2X_Q_STATE_TERMINATED,
  660. BNX2X_Q_STATE_FLRED,
  661. BNX2X_Q_STATE_MAX,
  662. };
  663. /* Allowed Queue states */
  664. enum bnx2x_q_logical_state {
  665. BNX2X_Q_LOGICAL_STATE_ACTIVE,
  666. BNX2X_Q_LOGICAL_STATE_STOPPED,
  667. };
  668. /* Allowed commands */
  669. enum bnx2x_queue_cmd {
  670. BNX2X_Q_CMD_INIT,
  671. BNX2X_Q_CMD_SETUP,
  672. BNX2X_Q_CMD_SETUP_TX_ONLY,
  673. BNX2X_Q_CMD_DEACTIVATE,
  674. BNX2X_Q_CMD_ACTIVATE,
  675. BNX2X_Q_CMD_UPDATE,
  676. BNX2X_Q_CMD_UPDATE_TPA,
  677. BNX2X_Q_CMD_HALT,
  678. BNX2X_Q_CMD_CFC_DEL,
  679. BNX2X_Q_CMD_TERMINATE,
  680. BNX2X_Q_CMD_EMPTY,
  681. BNX2X_Q_CMD_MAX,
  682. };
  683. /* queue SETUP + INIT flags */
  684. enum {
  685. BNX2X_Q_FLG_TPA,
  686. BNX2X_Q_FLG_TPA_IPV6,
  687. BNX2X_Q_FLG_TPA_GRO,
  688. BNX2X_Q_FLG_STATS,
  689. BNX2X_Q_FLG_ZERO_STATS,
  690. BNX2X_Q_FLG_ACTIVE,
  691. BNX2X_Q_FLG_OV,
  692. BNX2X_Q_FLG_VLAN,
  693. BNX2X_Q_FLG_COS,
  694. BNX2X_Q_FLG_HC,
  695. BNX2X_Q_FLG_HC_EN,
  696. BNX2X_Q_FLG_DHC,
  697. BNX2X_Q_FLG_FCOE,
  698. BNX2X_Q_FLG_LEADING_RSS,
  699. BNX2X_Q_FLG_MCAST,
  700. BNX2X_Q_FLG_DEF_VLAN,
  701. BNX2X_Q_FLG_TX_SWITCH,
  702. BNX2X_Q_FLG_TX_SEC,
  703. BNX2X_Q_FLG_ANTI_SPOOF,
  704. BNX2X_Q_FLG_SILENT_VLAN_REM,
  705. BNX2X_Q_FLG_FORCE_DEFAULT_PRI,
  706. BNX2X_Q_FLG_REFUSE_OUTBAND_VLAN,
  707. BNX2X_Q_FLG_PCSUM_ON_PKT,
  708. BNX2X_Q_FLG_TUN_INC_INNER_IP_ID
  709. };
  710. /* Queue type options: queue type may be a combination of below. */
  711. enum bnx2x_q_type {
  712. /** TODO: Consider moving both these flags into the init()
  713. * ramrod params.
  714. */
  715. BNX2X_Q_TYPE_HAS_RX,
  716. BNX2X_Q_TYPE_HAS_TX,
  717. };
  718. #define BNX2X_PRIMARY_CID_INDEX 0
  719. #define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */
  720. #define BNX2X_MULTI_TX_COS_E2_E3A0 2
  721. #define BNX2X_MULTI_TX_COS_E3B0 3
  722. #define BNX2X_MULTI_TX_COS 3 /* Maximum possible */
  723. #define MAC_PAD (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)
  724. /* DMAE channel to be used by FW for timesync workaroun. A driver that sends
  725. * timesync-related ramrods must not use this DMAE command ID.
  726. */
  727. #define FW_DMAE_CMD_ID 6
  728. struct bnx2x_queue_init_params {
  729. struct {
  730. unsigned long flags;
  731. u16 hc_rate;
  732. u8 fw_sb_id;
  733. u8 sb_cq_index;
  734. } tx;
  735. struct {
  736. unsigned long flags;
  737. u16 hc_rate;
  738. u8 fw_sb_id;
  739. u8 sb_cq_index;
  740. } rx;
  741. /* CID context in the host memory */
  742. struct eth_context *cxts[BNX2X_MULTI_TX_COS];
  743. /* maximum number of cos supported by hardware */
  744. u8 max_cos;
  745. };
  746. struct bnx2x_queue_terminate_params {
  747. /* index within the tx_only cids of this queue object */
  748. u8 cid_index;
  749. };
  750. struct bnx2x_queue_cfc_del_params {
  751. /* index within the tx_only cids of this queue object */
  752. u8 cid_index;
  753. };
  754. struct bnx2x_queue_update_params {
  755. unsigned long update_flags; /* BNX2X_Q_UPDATE_XX bits */
  756. u16 def_vlan;
  757. u16 silent_removal_value;
  758. u16 silent_removal_mask;
  759. /* index within the tx_only cids of this queue object */
  760. u8 cid_index;
  761. };
  762. struct bnx2x_queue_update_tpa_params {
  763. dma_addr_t sge_map;
  764. u8 update_ipv4;
  765. u8 update_ipv6;
  766. u8 max_tpa_queues;
  767. u8 max_sges_pkt;
  768. u8 complete_on_both_clients;
  769. u8 dont_verify_thr;
  770. u8 tpa_mode;
  771. u8 _pad;
  772. u16 sge_buff_sz;
  773. u16 max_agg_sz;
  774. u16 sge_pause_thr_low;
  775. u16 sge_pause_thr_high;
  776. };
  777. struct rxq_pause_params {
  778. u16 bd_th_lo;
  779. u16 bd_th_hi;
  780. u16 rcq_th_lo;
  781. u16 rcq_th_hi;
  782. u16 sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */
  783. u16 sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */
  784. u16 pri_map;
  785. };
  786. /* general */
  787. struct bnx2x_general_setup_params {
  788. /* valid iff BNX2X_Q_FLG_STATS */
  789. u8 stat_id;
  790. u8 spcl_id;
  791. u16 mtu;
  792. u8 cos;
  793. };
  794. struct bnx2x_rxq_setup_params {
  795. /* dma */
  796. dma_addr_t dscr_map;
  797. dma_addr_t sge_map;
  798. dma_addr_t rcq_map;
  799. dma_addr_t rcq_np_map;
  800. u16 drop_flags;
  801. u16 buf_sz;
  802. u8 fw_sb_id;
  803. u8 cl_qzone_id;
  804. /* valid iff BNX2X_Q_FLG_TPA */
  805. u16 tpa_agg_sz;
  806. u16 sge_buf_sz;
  807. u8 max_sges_pkt;
  808. u8 max_tpa_queues;
  809. u8 rss_engine_id;
  810. /* valid iff BNX2X_Q_FLG_MCAST */
  811. u8 mcast_engine_id;
  812. u8 cache_line_log;
  813. u8 sb_cq_index;
  814. /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
  815. u16 silent_removal_value;
  816. u16 silent_removal_mask;
  817. };
  818. struct bnx2x_txq_setup_params {
  819. /* dma */
  820. dma_addr_t dscr_map;
  821. u8 fw_sb_id;
  822. u8 sb_cq_index;
  823. u8 cos; /* valid iff BNX2X_Q_FLG_COS */
  824. u16 traffic_type;
  825. /* equals to the leading rss client id, used for TX classification*/
  826. u8 tss_leading_cl_id;
  827. /* valid iff BNX2X_Q_FLG_DEF_VLAN */
  828. u16 default_vlan;
  829. };
  830. struct bnx2x_queue_setup_params {
  831. struct bnx2x_general_setup_params gen_params;
  832. struct bnx2x_txq_setup_params txq_params;
  833. struct bnx2x_rxq_setup_params rxq_params;
  834. struct rxq_pause_params pause_params;
  835. unsigned long flags;
  836. };
  837. struct bnx2x_queue_setup_tx_only_params {
  838. struct bnx2x_general_setup_params gen_params;
  839. struct bnx2x_txq_setup_params txq_params;
  840. unsigned long flags;
  841. /* index within the tx_only cids of this queue object */
  842. u8 cid_index;
  843. };
  844. struct bnx2x_queue_state_params {
  845. struct bnx2x_queue_sp_obj *q_obj;
  846. /* Current command */
  847. enum bnx2x_queue_cmd cmd;
  848. /* may have RAMROD_COMP_WAIT set only */
  849. unsigned long ramrod_flags;
  850. /* Params according to the current command */
  851. union {
  852. struct bnx2x_queue_update_params update;
  853. struct bnx2x_queue_update_tpa_params update_tpa;
  854. struct bnx2x_queue_setup_params setup;
  855. struct bnx2x_queue_init_params init;
  856. struct bnx2x_queue_setup_tx_only_params tx_only;
  857. struct bnx2x_queue_terminate_params terminate;
  858. struct bnx2x_queue_cfc_del_params cfc_del;
  859. } params;
  860. };
  861. struct bnx2x_viflist_params {
  862. u8 echo_res;
  863. u8 func_bit_map_res;
  864. };
  865. struct bnx2x_queue_sp_obj {
  866. u32 cids[BNX2X_MULTI_TX_COS];
  867. u8 cl_id;
  868. u8 func_id;
  869. /* number of traffic classes supported by queue.
  870. * The primary connection of the queue supports the first traffic
  871. * class. Any further traffic class is supported by a tx-only
  872. * connection.
  873. *
  874. * Therefore max_cos is also a number of valid entries in the cids
  875. * array.
  876. */
  877. u8 max_cos;
  878. u8 num_tx_only, next_tx_only;
  879. enum bnx2x_q_state state, next_state;
  880. /* bits from enum bnx2x_q_type */
  881. unsigned long type;
  882. /* BNX2X_Q_CMD_XX bits. This object implements "one
  883. * pending" paradigm but for debug and tracing purposes it's
  884. * more convenient to have different bits for different
  885. * commands.
  886. */
  887. unsigned long pending;
  888. /* Buffer to use as a ramrod data and its mapping */
  889. void *rdata;
  890. dma_addr_t rdata_mapping;
  891. /**
  892. * Performs one state change according to the given parameters.
  893. *
  894. * @return 0 in case of success and negative value otherwise.
  895. */
  896. int (*send_cmd)(struct bnx2x *bp,
  897. struct bnx2x_queue_state_params *params);
  898. /**
  899. * Sets the pending bit according to the requested transition.
  900. */
  901. int (*set_pending)(struct bnx2x_queue_sp_obj *o,
  902. struct bnx2x_queue_state_params *params);
  903. /**
  904. * Checks that the requested state transition is legal.
  905. */
  906. int (*check_transition)(struct bnx2x *bp,
  907. struct bnx2x_queue_sp_obj *o,
  908. struct bnx2x_queue_state_params *params);
  909. /**
  910. * Completes the pending command.
  911. */
  912. int (*complete_cmd)(struct bnx2x *bp,
  913. struct bnx2x_queue_sp_obj *o,
  914. enum bnx2x_queue_cmd);
  915. int (*wait_comp)(struct bnx2x *bp,
  916. struct bnx2x_queue_sp_obj *o,
  917. enum bnx2x_queue_cmd cmd);
  918. };
  919. /********************** Function state update *********************************/
  920. /* UPDATE command options */
  921. enum {
  922. BNX2X_F_UPDATE_TX_SWITCH_SUSPEND_CHNG,
  923. BNX2X_F_UPDATE_TX_SWITCH_SUSPEND,
  924. BNX2X_F_UPDATE_SD_VLAN_TAG_CHNG,
  925. BNX2X_F_UPDATE_SD_VLAN_ETH_TYPE_CHNG,
  926. BNX2X_F_UPDATE_VLAN_FORCE_PRIO_CHNG,
  927. BNX2X_F_UPDATE_VLAN_FORCE_PRIO_FLAG,
  928. BNX2X_F_UPDATE_TUNNEL_CFG_CHNG,
  929. BNX2X_F_UPDATE_TUNNEL_CLSS_EN,
  930. BNX2X_F_UPDATE_TUNNEL_INNER_GRE_RSS_EN,
  931. };
  932. /* Allowed Function states */
  933. enum bnx2x_func_state {
  934. BNX2X_F_STATE_RESET,
  935. BNX2X_F_STATE_INITIALIZED,
  936. BNX2X_F_STATE_STARTED,
  937. BNX2X_F_STATE_TX_STOPPED,
  938. BNX2X_F_STATE_MAX,
  939. };
  940. /* Allowed Function commands */
  941. enum bnx2x_func_cmd {
  942. BNX2X_F_CMD_HW_INIT,
  943. BNX2X_F_CMD_START,
  944. BNX2X_F_CMD_STOP,
  945. BNX2X_F_CMD_HW_RESET,
  946. BNX2X_F_CMD_AFEX_UPDATE,
  947. BNX2X_F_CMD_AFEX_VIFLISTS,
  948. BNX2X_F_CMD_TX_STOP,
  949. BNX2X_F_CMD_TX_START,
  950. BNX2X_F_CMD_SWITCH_UPDATE,
  951. BNX2X_F_CMD_SET_TIMESYNC,
  952. BNX2X_F_CMD_MAX,
  953. };
  954. struct bnx2x_func_hw_init_params {
  955. /* A load phase returned by MCP.
  956. *
  957. * May be:
  958. * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
  959. * FW_MSG_CODE_DRV_LOAD_COMMON
  960. * FW_MSG_CODE_DRV_LOAD_PORT
  961. * FW_MSG_CODE_DRV_LOAD_FUNCTION
  962. */
  963. u32 load_phase;
  964. };
  965. struct bnx2x_func_hw_reset_params {
  966. /* A load phase returned by MCP.
  967. *
  968. * May be:
  969. * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
  970. * FW_MSG_CODE_DRV_LOAD_COMMON
  971. * FW_MSG_CODE_DRV_LOAD_PORT
  972. * FW_MSG_CODE_DRV_LOAD_FUNCTION
  973. */
  974. u32 reset_phase;
  975. };
  976. struct bnx2x_func_start_params {
  977. /* Multi Function mode:
  978. * - Single Function
  979. * - Switch Dependent
  980. * - Switch Independent
  981. */
  982. u16 mf_mode;
  983. /* Switch Dependent mode outer VLAN tag */
  984. u16 sd_vlan_tag;
  985. /* Function cos mode */
  986. u8 network_cos_mode;
  987. /* TUNN_MODE_NONE/TUNN_MODE_VXLAN/TUNN_MODE_GRE */
  988. u8 tunnel_mode;
  989. /* tunneling classification enablement */
  990. u8 tunn_clss_en;
  991. /* NVGRE_TUNNEL/L2GRE_TUNNEL/IPGRE_TUNNEL */
  992. u8 gre_tunnel_type;
  993. /* Enables Inner GRE RSS on the function, depends on the client RSS
  994. * capailities
  995. */
  996. u8 inner_gre_rss_en;
  997. /* Allows accepting of packets failing MF classification, possibly
  998. * only matching a given ethertype
  999. */
  1000. u8 class_fail;
  1001. u16 class_fail_ethtype;
  1002. /* Override priority of output packets */
  1003. u8 sd_vlan_force_pri;
  1004. u8 sd_vlan_force_pri_val;
  1005. /* Replace vlan's ethertype */
  1006. u16 sd_vlan_eth_type;
  1007. /* Prevent inner vlans from being added by FW */
  1008. u8 no_added_tags;
  1009. };
  1010. struct bnx2x_func_switch_update_params {
  1011. unsigned long changes; /* BNX2X_F_UPDATE_XX bits */
  1012. u16 vlan;
  1013. u16 vlan_eth_type;
  1014. u8 vlan_force_prio;
  1015. u8 tunnel_mode;
  1016. u8 gre_tunnel_type;
  1017. };
  1018. struct bnx2x_func_afex_update_params {
  1019. u16 vif_id;
  1020. u16 afex_default_vlan;
  1021. u8 allowed_priorities;
  1022. };
  1023. struct bnx2x_func_afex_viflists_params {
  1024. u16 vif_list_index;
  1025. u8 func_bit_map;
  1026. u8 afex_vif_list_command;
  1027. u8 func_to_clear;
  1028. };
  1029. struct bnx2x_func_tx_start_params {
  1030. struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES];
  1031. u8 dcb_enabled;
  1032. u8 dcb_version;
  1033. u8 dont_add_pri_0_en;
  1034. };
  1035. struct bnx2x_func_set_timesync_params {
  1036. /* Reset, set or keep the current drift value */
  1037. u8 drift_adjust_cmd;
  1038. /* Dec, inc or keep the current offset */
  1039. u8 offset_cmd;
  1040. /* Drift value direction */
  1041. u8 add_sub_drift_adjust_value;
  1042. /* Drift, period and offset values to be used according to the commands
  1043. * above.
  1044. */
  1045. u8 drift_adjust_value;
  1046. u32 drift_adjust_period;
  1047. u64 offset_delta;
  1048. };
  1049. struct bnx2x_func_state_params {
  1050. struct bnx2x_func_sp_obj *f_obj;
  1051. /* Current command */
  1052. enum bnx2x_func_cmd cmd;
  1053. /* may have RAMROD_COMP_WAIT set only */
  1054. unsigned long ramrod_flags;
  1055. /* Params according to the current command */
  1056. union {
  1057. struct bnx2x_func_hw_init_params hw_init;
  1058. struct bnx2x_func_hw_reset_params hw_reset;
  1059. struct bnx2x_func_start_params start;
  1060. struct bnx2x_func_switch_update_params switch_update;
  1061. struct bnx2x_func_afex_update_params afex_update;
  1062. struct bnx2x_func_afex_viflists_params afex_viflists;
  1063. struct bnx2x_func_tx_start_params tx_start;
  1064. struct bnx2x_func_set_timesync_params set_timesync;
  1065. } params;
  1066. };
  1067. struct bnx2x_func_sp_drv_ops {
  1068. /* Init tool + runtime initialization:
  1069. * - Common Chip
  1070. * - Common (per Path)
  1071. * - Port
  1072. * - Function phases
  1073. */
  1074. int (*init_hw_cmn_chip)(struct bnx2x *bp);
  1075. int (*init_hw_cmn)(struct bnx2x *bp);
  1076. int (*init_hw_port)(struct bnx2x *bp);
  1077. int (*init_hw_func)(struct bnx2x *bp);
  1078. /* Reset Function HW: Common, Port, Function phases. */
  1079. void (*reset_hw_cmn)(struct bnx2x *bp);
  1080. void (*reset_hw_port)(struct bnx2x *bp);
  1081. void (*reset_hw_func)(struct bnx2x *bp);
  1082. /* Init/Free GUNZIP resources */
  1083. int (*gunzip_init)(struct bnx2x *bp);
  1084. void (*gunzip_end)(struct bnx2x *bp);
  1085. /* Prepare/Release FW resources */
  1086. int (*init_fw)(struct bnx2x *bp);
  1087. void (*release_fw)(struct bnx2x *bp);
  1088. };
  1089. struct bnx2x_func_sp_obj {
  1090. enum bnx2x_func_state state, next_state;
  1091. /* BNX2X_FUNC_CMD_XX bits. This object implements "one
  1092. * pending" paradigm but for debug and tracing purposes it's
  1093. * more convenient to have different bits for different
  1094. * commands.
  1095. */
  1096. unsigned long pending;
  1097. /* Buffer to use as a ramrod data and its mapping */
  1098. void *rdata;
  1099. dma_addr_t rdata_mapping;
  1100. /* Buffer to use as a afex ramrod data and its mapping.
  1101. * This can't be same rdata as above because afex ramrod requests
  1102. * can arrive to the object in parallel to other ramrod requests.
  1103. */
  1104. void *afex_rdata;
  1105. dma_addr_t afex_rdata_mapping;
  1106. /* this mutex validates that when pending flag is taken, the next
  1107. * ramrod to be sent will be the one set the pending bit
  1108. */
  1109. struct mutex one_pending_mutex;
  1110. /* Driver interface */
  1111. struct bnx2x_func_sp_drv_ops *drv;
  1112. /**
  1113. * Performs one state change according to the given parameters.
  1114. *
  1115. * @return 0 in case of success and negative value otherwise.
  1116. */
  1117. int (*send_cmd)(struct bnx2x *bp,
  1118. struct bnx2x_func_state_params *params);
  1119. /**
  1120. * Checks that the requested state transition is legal.
  1121. */
  1122. int (*check_transition)(struct bnx2x *bp,
  1123. struct bnx2x_func_sp_obj *o,
  1124. struct bnx2x_func_state_params *params);
  1125. /**
  1126. * Completes the pending command.
  1127. */
  1128. int (*complete_cmd)(struct bnx2x *bp,
  1129. struct bnx2x_func_sp_obj *o,
  1130. enum bnx2x_func_cmd cmd);
  1131. int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o,
  1132. enum bnx2x_func_cmd cmd);
  1133. };
  1134. /********************** Interfaces ********************************************/
  1135. /* Queueable objects set */
  1136. union bnx2x_qable_obj {
  1137. struct bnx2x_vlan_mac_obj vlan_mac;
  1138. };
  1139. /************** Function state update *********/
  1140. void bnx2x_init_func_obj(struct bnx2x *bp,
  1141. struct bnx2x_func_sp_obj *obj,
  1142. void *rdata, dma_addr_t rdata_mapping,
  1143. void *afex_rdata, dma_addr_t afex_rdata_mapping,
  1144. struct bnx2x_func_sp_drv_ops *drv_iface);
  1145. int bnx2x_func_state_change(struct bnx2x *bp,
  1146. struct bnx2x_func_state_params *params);
  1147. enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp,
  1148. struct bnx2x_func_sp_obj *o);
  1149. /******************* Queue State **************/
  1150. void bnx2x_init_queue_obj(struct bnx2x *bp,
  1151. struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids,
  1152. u8 cid_cnt, u8 func_id, void *rdata,
  1153. dma_addr_t rdata_mapping, unsigned long type);
  1154. int bnx2x_queue_state_change(struct bnx2x *bp,
  1155. struct bnx2x_queue_state_params *params);
  1156. int bnx2x_get_q_logical_state(struct bnx2x *bp,
  1157. struct bnx2x_queue_sp_obj *obj);
  1158. /********************* VLAN-MAC ****************/
  1159. void bnx2x_init_mac_obj(struct bnx2x *bp,
  1160. struct bnx2x_vlan_mac_obj *mac_obj,
  1161. u8 cl_id, u32 cid, u8 func_id, void *rdata,
  1162. dma_addr_t rdata_mapping, int state,
  1163. unsigned long *pstate, bnx2x_obj_type type,
  1164. struct bnx2x_credit_pool_obj *macs_pool);
  1165. void bnx2x_init_vlan_obj(struct bnx2x *bp,
  1166. struct bnx2x_vlan_mac_obj *vlan_obj,
  1167. u8 cl_id, u32 cid, u8 func_id, void *rdata,
  1168. dma_addr_t rdata_mapping, int state,
  1169. unsigned long *pstate, bnx2x_obj_type type,
  1170. struct bnx2x_credit_pool_obj *vlans_pool);
  1171. int bnx2x_vlan_mac_h_read_lock(struct bnx2x *bp,
  1172. struct bnx2x_vlan_mac_obj *o);
  1173. void bnx2x_vlan_mac_h_read_unlock(struct bnx2x *bp,
  1174. struct bnx2x_vlan_mac_obj *o);
  1175. int bnx2x_vlan_mac_h_write_lock(struct bnx2x *bp,
  1176. struct bnx2x_vlan_mac_obj *o);
  1177. int bnx2x_config_vlan_mac(struct bnx2x *bp,
  1178. struct bnx2x_vlan_mac_ramrod_params *p);
  1179. int bnx2x_vlan_mac_move(struct bnx2x *bp,
  1180. struct bnx2x_vlan_mac_ramrod_params *p,
  1181. struct bnx2x_vlan_mac_obj *dest_o);
  1182. /********************* RX MODE ****************/
  1183. void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
  1184. struct bnx2x_rx_mode_obj *o);
  1185. /**
  1186. * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
  1187. *
  1188. * @p: Command parameters
  1189. *
  1190. * Return: 0 - if operation was successful and there is no pending completions,
  1191. * positive number - if there are pending completions,
  1192. * negative - if there were errors
  1193. */
  1194. int bnx2x_config_rx_mode(struct bnx2x *bp,
  1195. struct bnx2x_rx_mode_ramrod_params *p);
  1196. /****************** MULTICASTS ****************/
  1197. void bnx2x_init_mcast_obj(struct bnx2x *bp,
  1198. struct bnx2x_mcast_obj *mcast_obj,
  1199. u8 mcast_cl_id, u32 mcast_cid, u8 func_id,
  1200. u8 engine_id, void *rdata, dma_addr_t rdata_mapping,
  1201. int state, unsigned long *pstate,
  1202. bnx2x_obj_type type);
  1203. /**
  1204. * bnx2x_config_mcast - Configure multicast MACs list.
  1205. *
  1206. * @cmd: command to execute: BNX2X_MCAST_CMD_X
  1207. *
  1208. * May configure a new list
  1209. * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up
  1210. * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current
  1211. * configuration, continue to execute the pending commands
  1212. * (BNX2X_MCAST_CMD_CONT).
  1213. *
  1214. * If previous command is still pending or if number of MACs to
  1215. * configure is more that maximum number of MACs in one command,
  1216. * the current command will be enqueued to the tail of the
  1217. * pending commands list.
  1218. *
  1219. * Return: 0 is operation was successful and there are no pending completions,
  1220. * negative if there were errors, positive if there are pending
  1221. * completions.
  1222. */
  1223. int bnx2x_config_mcast(struct bnx2x *bp,
  1224. struct bnx2x_mcast_ramrod_params *p,
  1225. enum bnx2x_mcast_cmd cmd);
  1226. /****************** CREDIT POOL ****************/
  1227. void bnx2x_init_mac_credit_pool(struct bnx2x *bp,
  1228. struct bnx2x_credit_pool_obj *p, u8 func_id,
  1229. u8 func_num);
  1230. void bnx2x_init_vlan_credit_pool(struct bnx2x *bp,
  1231. struct bnx2x_credit_pool_obj *p, u8 func_id,
  1232. u8 func_num);
  1233. /****************** RSS CONFIGURATION ****************/
  1234. void bnx2x_init_rss_config_obj(struct bnx2x *bp,
  1235. struct bnx2x_rss_config_obj *rss_obj,
  1236. u8 cl_id, u32 cid, u8 func_id, u8 engine_id,
  1237. void *rdata, dma_addr_t rdata_mapping,
  1238. int state, unsigned long *pstate,
  1239. bnx2x_obj_type type);
  1240. /**
  1241. * bnx2x_config_rss - Updates RSS configuration according to provided parameters
  1242. *
  1243. * Return: 0 in case of success
  1244. */
  1245. int bnx2x_config_rss(struct bnx2x *bp,
  1246. struct bnx2x_config_rss_params *p);
  1247. /**
  1248. * bnx2x_get_rss_ind_table - Return the current ind_table configuration.
  1249. *
  1250. * @ind_table: buffer to fill with the current indirection
  1251. * table content. Should be at least
  1252. * T_ETH_INDIRECTION_TABLE_SIZE bytes long.
  1253. */
  1254. void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj,
  1255. u8 *ind_table);
  1256. #endif /* BNX2X_SP_VERBS */