bnx2x_sp.h 37 KB

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