bnx2x_sp.h 38 KB

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