bnx2x_sp.h 40 KB

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