bnx2x_sp.h 40 KB

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