bnx2x_cmn.h 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325
  1. /* bnx2x_cmn.h: Broadcom Everest network driver.
  2. *
  3. * Copyright (c) 2007-2013 Broadcom Corporation
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation.
  8. *
  9. * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
  10. * Written by: Eliezer Tamir
  11. * Based on code from Michael Chan's bnx2 driver
  12. * UDP CSUM errata workaround by Arik Gendelman
  13. * Slowpath and fastpath rework by Vladislav Zolotarov
  14. * Statistics and Link management by Yitchak Gertner
  15. *
  16. */
  17. #ifndef BNX2X_CMN_H
  18. #define BNX2X_CMN_H
  19. #include <linux/types.h>
  20. #include <linux/pci.h>
  21. #include <linux/netdevice.h>
  22. #include <linux/etherdevice.h>
  23. #include <linux/irq.h>
  24. #include "bnx2x.h"
  25. #include "bnx2x_sriov.h"
  26. /* This is used as a replacement for an MCP if it's not present */
  27. extern int bnx2x_load_count[2][3]; /* per-path: 0-common, 1-port0, 2-port1 */
  28. extern int bnx2x_num_queues;
  29. /************************ Macros ********************************/
  30. #define BNX2X_PCI_FREE(x, y, size) \
  31. do { \
  32. if (x) { \
  33. dma_free_coherent(&bp->pdev->dev, size, (void *)x, y); \
  34. x = NULL; \
  35. y = 0; \
  36. } \
  37. } while (0)
  38. #define BNX2X_FREE(x) \
  39. do { \
  40. if (x) { \
  41. kfree((void *)x); \
  42. x = NULL; \
  43. } \
  44. } while (0)
  45. #define BNX2X_PCI_ALLOC(y, size) \
  46. ({ \
  47. void *x = dma_zalloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
  48. if (x) \
  49. DP(NETIF_MSG_HW, \
  50. "BNX2X_PCI_ALLOC: Physical %Lx Virtual %p\n", \
  51. (unsigned long long)(*y), x); \
  52. x; \
  53. })
  54. #define BNX2X_PCI_FALLOC(y, size) \
  55. ({ \
  56. void *x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
  57. if (x) { \
  58. memset(x, 0xff, size); \
  59. DP(NETIF_MSG_HW, \
  60. "BNX2X_PCI_FALLOC: Physical %Lx Virtual %p\n", \
  61. (unsigned long long)(*y), x); \
  62. } \
  63. x; \
  64. })
  65. /*********************** Interfaces ****************************
  66. * Functions that need to be implemented by each driver version
  67. */
  68. /* Init */
  69. /**
  70. * bnx2x_send_unload_req - request unload mode from the MCP.
  71. *
  72. * @bp: driver handle
  73. * @unload_mode: requested function's unload mode
  74. *
  75. * Return unload mode returned by the MCP: COMMON, PORT or FUNC.
  76. */
  77. u32 bnx2x_send_unload_req(struct bnx2x *bp, int unload_mode);
  78. /**
  79. * bnx2x_send_unload_done - send UNLOAD_DONE command to the MCP.
  80. *
  81. * @bp: driver handle
  82. * @keep_link: true iff link should be kept up
  83. */
  84. void bnx2x_send_unload_done(struct bnx2x *bp, bool keep_link);
  85. /**
  86. * bnx2x_config_rss_pf - configure RSS parameters in a PF.
  87. *
  88. * @bp: driver handle
  89. * @rss_obj: RSS object to use
  90. * @ind_table: indirection table to configure
  91. * @config_hash: re-configure RSS hash keys configuration
  92. * @enable: enabled or disabled configuration
  93. */
  94. int bnx2x_rss(struct bnx2x *bp, struct bnx2x_rss_config_obj *rss_obj,
  95. bool config_hash, bool enable);
  96. /**
  97. * bnx2x__init_func_obj - init function object
  98. *
  99. * @bp: driver handle
  100. *
  101. * Initializes the Function Object with the appropriate
  102. * parameters which include a function slow path driver
  103. * interface.
  104. */
  105. void bnx2x__init_func_obj(struct bnx2x *bp);
  106. /**
  107. * bnx2x_setup_queue - setup eth queue.
  108. *
  109. * @bp: driver handle
  110. * @fp: pointer to the fastpath structure
  111. * @leading: boolean
  112. *
  113. */
  114. int bnx2x_setup_queue(struct bnx2x *bp, struct bnx2x_fastpath *fp,
  115. bool leading);
  116. /**
  117. * bnx2x_setup_leading - bring up a leading eth queue.
  118. *
  119. * @bp: driver handle
  120. */
  121. int bnx2x_setup_leading(struct bnx2x *bp);
  122. /**
  123. * bnx2x_fw_command - send the MCP a request
  124. *
  125. * @bp: driver handle
  126. * @command: request
  127. * @param: request's parameter
  128. *
  129. * block until there is a reply
  130. */
  131. u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param);
  132. /**
  133. * bnx2x_initial_phy_init - initialize link parameters structure variables.
  134. *
  135. * @bp: driver handle
  136. * @load_mode: current mode
  137. */
  138. int bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode);
  139. /**
  140. * bnx2x_link_set - configure hw according to link parameters structure.
  141. *
  142. * @bp: driver handle
  143. */
  144. void bnx2x_link_set(struct bnx2x *bp);
  145. /**
  146. * bnx2x_force_link_reset - Forces link reset, and put the PHY
  147. * in reset as well.
  148. *
  149. * @bp: driver handle
  150. */
  151. void bnx2x_force_link_reset(struct bnx2x *bp);
  152. /**
  153. * bnx2x_link_test - query link status.
  154. *
  155. * @bp: driver handle
  156. * @is_serdes: bool
  157. *
  158. * Returns 0 if link is UP.
  159. */
  160. u8 bnx2x_link_test(struct bnx2x *bp, u8 is_serdes);
  161. /**
  162. * bnx2x_drv_pulse - write driver pulse to shmem
  163. *
  164. * @bp: driver handle
  165. *
  166. * writes the value in bp->fw_drv_pulse_wr_seq to drv_pulse mbox
  167. * in the shmem.
  168. */
  169. void bnx2x_drv_pulse(struct bnx2x *bp);
  170. /**
  171. * bnx2x_igu_ack_sb - update IGU with current SB value
  172. *
  173. * @bp: driver handle
  174. * @igu_sb_id: SB id
  175. * @segment: SB segment
  176. * @index: SB index
  177. * @op: SB operation
  178. * @update: is HW update required
  179. */
  180. void bnx2x_igu_ack_sb(struct bnx2x *bp, u8 igu_sb_id, u8 segment,
  181. u16 index, u8 op, u8 update);
  182. /* Disable transactions from chip to host */
  183. void bnx2x_pf_disable(struct bnx2x *bp);
  184. int bnx2x_pretend_func(struct bnx2x *bp, u16 pretend_func_val);
  185. /**
  186. * bnx2x__link_status_update - handles link status change.
  187. *
  188. * @bp: driver handle
  189. */
  190. void bnx2x__link_status_update(struct bnx2x *bp);
  191. /**
  192. * bnx2x_link_report - report link status to upper layer.
  193. *
  194. * @bp: driver handle
  195. */
  196. void bnx2x_link_report(struct bnx2x *bp);
  197. /* None-atomic version of bnx2x_link_report() */
  198. void __bnx2x_link_report(struct bnx2x *bp);
  199. /**
  200. * bnx2x_get_mf_speed - calculate MF speed.
  201. *
  202. * @bp: driver handle
  203. *
  204. * Takes into account current linespeed and MF configuration.
  205. */
  206. u16 bnx2x_get_mf_speed(struct bnx2x *bp);
  207. /**
  208. * bnx2x_msix_sp_int - MSI-X slowpath interrupt handler
  209. *
  210. * @irq: irq number
  211. * @dev_instance: private instance
  212. */
  213. irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance);
  214. /**
  215. * bnx2x_interrupt - non MSI-X interrupt handler
  216. *
  217. * @irq: irq number
  218. * @dev_instance: private instance
  219. */
  220. irqreturn_t bnx2x_interrupt(int irq, void *dev_instance);
  221. /**
  222. * bnx2x_cnic_notify - send command to cnic driver
  223. *
  224. * @bp: driver handle
  225. * @cmd: command
  226. */
  227. int bnx2x_cnic_notify(struct bnx2x *bp, int cmd);
  228. /**
  229. * bnx2x_setup_cnic_irq_info - provides cnic with IRQ information
  230. *
  231. * @bp: driver handle
  232. */
  233. void bnx2x_setup_cnic_irq_info(struct bnx2x *bp);
  234. /**
  235. * bnx2x_setup_cnic_info - provides cnic with updated info
  236. *
  237. * @bp: driver handle
  238. */
  239. void bnx2x_setup_cnic_info(struct bnx2x *bp);
  240. /**
  241. * bnx2x_int_enable - enable HW interrupts.
  242. *
  243. * @bp: driver handle
  244. */
  245. void bnx2x_int_enable(struct bnx2x *bp);
  246. /**
  247. * bnx2x_int_disable_sync - disable interrupts.
  248. *
  249. * @bp: driver handle
  250. * @disable_hw: true, disable HW interrupts.
  251. *
  252. * This function ensures that there are no
  253. * ISRs or SP DPCs (sp_task) are running after it returns.
  254. */
  255. void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw);
  256. /**
  257. * bnx2x_nic_init_cnic - init driver internals for cnic.
  258. *
  259. * @bp: driver handle
  260. * @load_code: COMMON, PORT or FUNCTION
  261. *
  262. * Initializes:
  263. * - rings
  264. * - status blocks
  265. * - etc.
  266. */
  267. void bnx2x_nic_init_cnic(struct bnx2x *bp);
  268. /**
  269. * bnx2x_preirq_nic_init - init driver internals.
  270. *
  271. * @bp: driver handle
  272. *
  273. * Initializes:
  274. * - fastpath object
  275. * - fastpath rings
  276. * etc.
  277. */
  278. void bnx2x_pre_irq_nic_init(struct bnx2x *bp);
  279. /**
  280. * bnx2x_postirq_nic_init - init driver internals.
  281. *
  282. * @bp: driver handle
  283. * @load_code: COMMON, PORT or FUNCTION
  284. *
  285. * Initializes:
  286. * - status blocks
  287. * - slowpath rings
  288. * - etc.
  289. */
  290. void bnx2x_post_irq_nic_init(struct bnx2x *bp, u32 load_code);
  291. /**
  292. * bnx2x_alloc_mem_cnic - allocate driver's memory for cnic.
  293. *
  294. * @bp: driver handle
  295. */
  296. int bnx2x_alloc_mem_cnic(struct bnx2x *bp);
  297. /**
  298. * bnx2x_alloc_mem - allocate driver's memory.
  299. *
  300. * @bp: driver handle
  301. */
  302. int bnx2x_alloc_mem(struct bnx2x *bp);
  303. /**
  304. * bnx2x_free_mem_cnic - release driver's memory for cnic.
  305. *
  306. * @bp: driver handle
  307. */
  308. void bnx2x_free_mem_cnic(struct bnx2x *bp);
  309. /**
  310. * bnx2x_free_mem - release driver's memory.
  311. *
  312. * @bp: driver handle
  313. */
  314. void bnx2x_free_mem(struct bnx2x *bp);
  315. /**
  316. * bnx2x_set_num_queues - set number of queues according to mode.
  317. *
  318. * @bp: driver handle
  319. */
  320. void bnx2x_set_num_queues(struct bnx2x *bp);
  321. /**
  322. * bnx2x_chip_cleanup - cleanup chip internals.
  323. *
  324. * @bp: driver handle
  325. * @unload_mode: COMMON, PORT, FUNCTION
  326. * @keep_link: true iff link should be kept up.
  327. *
  328. * - Cleanup MAC configuration.
  329. * - Closes clients.
  330. * - etc.
  331. */
  332. void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode, bool keep_link);
  333. /**
  334. * bnx2x_acquire_hw_lock - acquire HW lock.
  335. *
  336. * @bp: driver handle
  337. * @resource: resource bit which was locked
  338. */
  339. int bnx2x_acquire_hw_lock(struct bnx2x *bp, u32 resource);
  340. /**
  341. * bnx2x_release_hw_lock - release HW lock.
  342. *
  343. * @bp: driver handle
  344. * @resource: resource bit which was locked
  345. */
  346. int bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource);
  347. /**
  348. * bnx2x_release_leader_lock - release recovery leader lock
  349. *
  350. * @bp: driver handle
  351. */
  352. int bnx2x_release_leader_lock(struct bnx2x *bp);
  353. /**
  354. * bnx2x_set_eth_mac - configure eth MAC address in the HW
  355. *
  356. * @bp: driver handle
  357. * @set: set or clear
  358. *
  359. * Configures according to the value in netdev->dev_addr.
  360. */
  361. int bnx2x_set_eth_mac(struct bnx2x *bp, bool set);
  362. /**
  363. * bnx2x_set_rx_mode - set MAC filtering configurations.
  364. *
  365. * @dev: netdevice
  366. *
  367. * called with netif_tx_lock from dev_mcast.c
  368. * If bp->state is OPEN, should be called with
  369. * netif_addr_lock_bh()
  370. */
  371. void bnx2x_set_rx_mode_inner(struct bnx2x *bp);
  372. /* Parity errors related */
  373. void bnx2x_set_pf_load(struct bnx2x *bp);
  374. bool bnx2x_clear_pf_load(struct bnx2x *bp);
  375. bool bnx2x_chk_parity_attn(struct bnx2x *bp, bool *global, bool print);
  376. bool bnx2x_reset_is_done(struct bnx2x *bp, int engine);
  377. void bnx2x_set_reset_in_progress(struct bnx2x *bp);
  378. void bnx2x_set_reset_global(struct bnx2x *bp);
  379. void bnx2x_disable_close_the_gate(struct bnx2x *bp);
  380. int bnx2x_init_hw_func_cnic(struct bnx2x *bp);
  381. /**
  382. * bnx2x_sp_event - handle ramrods completion.
  383. *
  384. * @fp: fastpath handle for the event
  385. * @rr_cqe: eth_rx_cqe
  386. */
  387. void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe);
  388. /**
  389. * bnx2x_ilt_set_info - prepare ILT configurations.
  390. *
  391. * @bp: driver handle
  392. */
  393. void bnx2x_ilt_set_info(struct bnx2x *bp);
  394. /**
  395. * bnx2x_ilt_set_cnic_info - prepare ILT configurations for SRC
  396. * and TM.
  397. *
  398. * @bp: driver handle
  399. */
  400. void bnx2x_ilt_set_info_cnic(struct bnx2x *bp);
  401. /**
  402. * bnx2x_dcbx_init - initialize dcbx protocol.
  403. *
  404. * @bp: driver handle
  405. */
  406. void bnx2x_dcbx_init(struct bnx2x *bp, bool update_shmem);
  407. /**
  408. * bnx2x_set_power_state - set power state to the requested value.
  409. *
  410. * @bp: driver handle
  411. * @state: required state D0 or D3hot
  412. *
  413. * Currently only D0 and D3hot are supported.
  414. */
  415. int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state);
  416. /**
  417. * bnx2x_update_max_mf_config - update MAX part of MF configuration in HW.
  418. *
  419. * @bp: driver handle
  420. * @value: new value
  421. */
  422. void bnx2x_update_max_mf_config(struct bnx2x *bp, u32 value);
  423. /* Error handling */
  424. void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl);
  425. /* dev_close main block */
  426. int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link);
  427. /* dev_open main block */
  428. int bnx2x_nic_load(struct bnx2x *bp, int load_mode);
  429. /* hard_xmit callback */
  430. netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);
  431. /* setup_tc callback */
  432. int bnx2x_setup_tc(struct net_device *dev, u8 num_tc);
  433. int bnx2x_get_vf_config(struct net_device *dev, int vf,
  434. struct ifla_vf_info *ivi);
  435. int bnx2x_set_vf_mac(struct net_device *dev, int queue, u8 *mac);
  436. int bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos);
  437. /* select_queue callback */
  438. u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
  439. void *accel_priv, select_queue_fallback_t fallback);
  440. static inline void bnx2x_update_rx_prod(struct bnx2x *bp,
  441. struct bnx2x_fastpath *fp,
  442. u16 bd_prod, u16 rx_comp_prod,
  443. u16 rx_sge_prod)
  444. {
  445. struct ustorm_eth_rx_producers rx_prods = {0};
  446. u32 i;
  447. /* Update producers */
  448. rx_prods.bd_prod = bd_prod;
  449. rx_prods.cqe_prod = rx_comp_prod;
  450. rx_prods.sge_prod = rx_sge_prod;
  451. /* Make sure that the BD and SGE data is updated before updating the
  452. * producers since FW might read the BD/SGE right after the producer
  453. * is updated.
  454. * This is only applicable for weak-ordered memory model archs such
  455. * as IA-64. The following barrier is also mandatory since FW will
  456. * assumes BDs must have buffers.
  457. */
  458. wmb();
  459. for (i = 0; i < sizeof(rx_prods)/4; i++)
  460. REG_WR(bp, fp->ustorm_rx_prods_offset + i*4,
  461. ((u32 *)&rx_prods)[i]);
  462. mmiowb(); /* keep prod updates ordered */
  463. DP(NETIF_MSG_RX_STATUS,
  464. "queue[%d]: wrote bd_prod %u cqe_prod %u sge_prod %u\n",
  465. fp->index, bd_prod, rx_comp_prod, rx_sge_prod);
  466. }
  467. /* reload helper */
  468. int bnx2x_reload_if_running(struct net_device *dev);
  469. int bnx2x_change_mac_addr(struct net_device *dev, void *p);
  470. /* NAPI poll Tx part */
  471. int bnx2x_tx_int(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata);
  472. /* suspend/resume callbacks */
  473. int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state);
  474. int bnx2x_resume(struct pci_dev *pdev);
  475. /* Release IRQ vectors */
  476. void bnx2x_free_irq(struct bnx2x *bp);
  477. void bnx2x_free_fp_mem(struct bnx2x *bp);
  478. void bnx2x_init_rx_rings(struct bnx2x *bp);
  479. void bnx2x_init_rx_rings_cnic(struct bnx2x *bp);
  480. void bnx2x_free_skbs(struct bnx2x *bp);
  481. void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw);
  482. void bnx2x_netif_start(struct bnx2x *bp);
  483. int bnx2x_load_cnic(struct bnx2x *bp);
  484. /**
  485. * bnx2x_enable_msix - set msix configuration.
  486. *
  487. * @bp: driver handle
  488. *
  489. * fills msix_table, requests vectors, updates num_queues
  490. * according to number of available vectors.
  491. */
  492. int bnx2x_enable_msix(struct bnx2x *bp);
  493. /**
  494. * bnx2x_enable_msi - request msi mode from OS, updated internals accordingly
  495. *
  496. * @bp: driver handle
  497. */
  498. int bnx2x_enable_msi(struct bnx2x *bp);
  499. /**
  500. * bnx2x_low_latency_recv - LL callback
  501. *
  502. * @napi: napi structure
  503. */
  504. int bnx2x_low_latency_recv(struct napi_struct *napi);
  505. /**
  506. * bnx2x_alloc_mem_bp - allocate memories outsize main driver structure
  507. *
  508. * @bp: driver handle
  509. */
  510. int bnx2x_alloc_mem_bp(struct bnx2x *bp);
  511. /**
  512. * bnx2x_free_mem_bp - release memories outsize main driver structure
  513. *
  514. * @bp: driver handle
  515. */
  516. void bnx2x_free_mem_bp(struct bnx2x *bp);
  517. /**
  518. * bnx2x_change_mtu - change mtu netdev callback
  519. *
  520. * @dev: net device
  521. * @new_mtu: requested mtu
  522. *
  523. */
  524. int bnx2x_change_mtu(struct net_device *dev, int new_mtu);
  525. #ifdef NETDEV_FCOE_WWNN
  526. /**
  527. * bnx2x_fcoe_get_wwn - return the requested WWN value for this port
  528. *
  529. * @dev: net_device
  530. * @wwn: output buffer
  531. * @type: WWN type: NETDEV_FCOE_WWNN (node) or NETDEV_FCOE_WWPN (port)
  532. *
  533. */
  534. int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type);
  535. #endif
  536. netdev_features_t bnx2x_fix_features(struct net_device *dev,
  537. netdev_features_t features);
  538. int bnx2x_set_features(struct net_device *dev, netdev_features_t features);
  539. /**
  540. * bnx2x_tx_timeout - tx timeout netdev callback
  541. *
  542. * @dev: net device
  543. */
  544. void bnx2x_tx_timeout(struct net_device *dev);
  545. /*********************** Inlines **********************************/
  546. /*********************** Fast path ********************************/
  547. static inline void bnx2x_update_fpsb_idx(struct bnx2x_fastpath *fp)
  548. {
  549. barrier(); /* status block is written to by the chip */
  550. fp->fp_hc_idx = fp->sb_running_index[SM_RX_ID];
  551. }
  552. static inline void bnx2x_igu_ack_sb_gen(struct bnx2x *bp, u8 igu_sb_id,
  553. u8 segment, u16 index, u8 op,
  554. u8 update, u32 igu_addr)
  555. {
  556. struct igu_regular cmd_data = {0};
  557. cmd_data.sb_id_and_flags =
  558. ((index << IGU_REGULAR_SB_INDEX_SHIFT) |
  559. (segment << IGU_REGULAR_SEGMENT_ACCESS_SHIFT) |
  560. (update << IGU_REGULAR_BUPDATE_SHIFT) |
  561. (op << IGU_REGULAR_ENABLE_INT_SHIFT));
  562. DP(NETIF_MSG_INTR, "write 0x%08x to IGU addr 0x%x\n",
  563. cmd_data.sb_id_and_flags, igu_addr);
  564. REG_WR(bp, igu_addr, cmd_data.sb_id_and_flags);
  565. /* Make sure that ACK is written */
  566. mmiowb();
  567. barrier();
  568. }
  569. static inline void bnx2x_hc_ack_sb(struct bnx2x *bp, u8 sb_id,
  570. u8 storm, u16 index, u8 op, u8 update)
  571. {
  572. u32 hc_addr = (HC_REG_COMMAND_REG + BP_PORT(bp)*32 +
  573. COMMAND_REG_INT_ACK);
  574. struct igu_ack_register igu_ack;
  575. igu_ack.status_block_index = index;
  576. igu_ack.sb_id_and_flags =
  577. ((sb_id << IGU_ACK_REGISTER_STATUS_BLOCK_ID_SHIFT) |
  578. (storm << IGU_ACK_REGISTER_STORM_ID_SHIFT) |
  579. (update << IGU_ACK_REGISTER_UPDATE_INDEX_SHIFT) |
  580. (op << IGU_ACK_REGISTER_INTERRUPT_MODE_SHIFT));
  581. REG_WR(bp, hc_addr, (*(u32 *)&igu_ack));
  582. /* Make sure that ACK is written */
  583. mmiowb();
  584. barrier();
  585. }
  586. static inline void bnx2x_ack_sb(struct bnx2x *bp, u8 igu_sb_id, u8 storm,
  587. u16 index, u8 op, u8 update)
  588. {
  589. if (bp->common.int_block == INT_BLOCK_HC)
  590. bnx2x_hc_ack_sb(bp, igu_sb_id, storm, index, op, update);
  591. else {
  592. u8 segment;
  593. if (CHIP_INT_MODE_IS_BC(bp))
  594. segment = storm;
  595. else if (igu_sb_id != bp->igu_dsb_id)
  596. segment = IGU_SEG_ACCESS_DEF;
  597. else if (storm == ATTENTION_ID)
  598. segment = IGU_SEG_ACCESS_ATTN;
  599. else
  600. segment = IGU_SEG_ACCESS_DEF;
  601. bnx2x_igu_ack_sb(bp, igu_sb_id, segment, index, op, update);
  602. }
  603. }
  604. static inline u16 bnx2x_hc_ack_int(struct bnx2x *bp)
  605. {
  606. u32 hc_addr = (HC_REG_COMMAND_REG + BP_PORT(bp)*32 +
  607. COMMAND_REG_SIMD_MASK);
  608. u32 result = REG_RD(bp, hc_addr);
  609. barrier();
  610. return result;
  611. }
  612. static inline u16 bnx2x_igu_ack_int(struct bnx2x *bp)
  613. {
  614. u32 igu_addr = (BAR_IGU_INTMEM + IGU_REG_SISR_MDPC_WMASK_LSB_UPPER*8);
  615. u32 result = REG_RD(bp, igu_addr);
  616. DP(NETIF_MSG_INTR, "read 0x%08x from IGU addr 0x%x\n",
  617. result, igu_addr);
  618. barrier();
  619. return result;
  620. }
  621. static inline u16 bnx2x_ack_int(struct bnx2x *bp)
  622. {
  623. barrier();
  624. if (bp->common.int_block == INT_BLOCK_HC)
  625. return bnx2x_hc_ack_int(bp);
  626. else
  627. return bnx2x_igu_ack_int(bp);
  628. }
  629. static inline int bnx2x_has_tx_work_unload(struct bnx2x_fp_txdata *txdata)
  630. {
  631. /* Tell compiler that consumer and producer can change */
  632. barrier();
  633. return txdata->tx_pkt_prod != txdata->tx_pkt_cons;
  634. }
  635. static inline u16 bnx2x_tx_avail(struct bnx2x *bp,
  636. struct bnx2x_fp_txdata *txdata)
  637. {
  638. s16 used;
  639. u16 prod;
  640. u16 cons;
  641. prod = txdata->tx_bd_prod;
  642. cons = txdata->tx_bd_cons;
  643. used = SUB_S16(prod, cons);
  644. #ifdef BNX2X_STOP_ON_ERROR
  645. WARN_ON(used < 0);
  646. WARN_ON(used > txdata->tx_ring_size);
  647. WARN_ON((txdata->tx_ring_size - used) > MAX_TX_AVAIL);
  648. #endif
  649. return (s16)(txdata->tx_ring_size) - used;
  650. }
  651. static inline int bnx2x_tx_queue_has_work(struct bnx2x_fp_txdata *txdata)
  652. {
  653. u16 hw_cons;
  654. /* Tell compiler that status block fields can change */
  655. barrier();
  656. hw_cons = le16_to_cpu(*txdata->tx_cons_sb);
  657. return hw_cons != txdata->tx_pkt_cons;
  658. }
  659. static inline bool bnx2x_has_tx_work(struct bnx2x_fastpath *fp)
  660. {
  661. u8 cos;
  662. for_each_cos_in_tx_queue(fp, cos)
  663. if (bnx2x_tx_queue_has_work(fp->txdata_ptr[cos]))
  664. return true;
  665. return false;
  666. }
  667. #define BNX2X_IS_CQE_COMPLETED(cqe_fp) (cqe_fp->marker == 0x0)
  668. #define BNX2X_SEED_CQE(cqe_fp) (cqe_fp->marker = 0xFFFFFFFF)
  669. static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp)
  670. {
  671. u16 cons;
  672. union eth_rx_cqe *cqe;
  673. struct eth_fast_path_rx_cqe *cqe_fp;
  674. cons = RCQ_BD(fp->rx_comp_cons);
  675. cqe = &fp->rx_comp_ring[cons];
  676. cqe_fp = &cqe->fast_path_cqe;
  677. return BNX2X_IS_CQE_COMPLETED(cqe_fp);
  678. }
  679. /**
  680. * bnx2x_tx_disable - disables tx from stack point of view
  681. *
  682. * @bp: driver handle
  683. */
  684. static inline void bnx2x_tx_disable(struct bnx2x *bp)
  685. {
  686. netif_tx_disable(bp->dev);
  687. netif_carrier_off(bp->dev);
  688. }
  689. static inline void bnx2x_free_rx_sge(struct bnx2x *bp,
  690. struct bnx2x_fastpath *fp, u16 index)
  691. {
  692. struct sw_rx_page *sw_buf = &fp->rx_page_ring[index];
  693. struct page *page = sw_buf->page;
  694. struct eth_rx_sge *sge = &fp->rx_sge_ring[index];
  695. /* Skip "next page" elements */
  696. if (!page)
  697. return;
  698. dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(sw_buf, mapping),
  699. SGE_PAGES, DMA_FROM_DEVICE);
  700. __free_pages(page, PAGES_PER_SGE_SHIFT);
  701. sw_buf->page = NULL;
  702. sge->addr_hi = 0;
  703. sge->addr_lo = 0;
  704. }
  705. static inline void bnx2x_del_all_napi_cnic(struct bnx2x *bp)
  706. {
  707. int i;
  708. for_each_rx_queue_cnic(bp, i) {
  709. napi_hash_del(&bnx2x_fp(bp, i, napi));
  710. netif_napi_del(&bnx2x_fp(bp, i, napi));
  711. }
  712. }
  713. static inline void bnx2x_del_all_napi(struct bnx2x *bp)
  714. {
  715. int i;
  716. for_each_eth_queue(bp, i) {
  717. napi_hash_del(&bnx2x_fp(bp, i, napi));
  718. netif_napi_del(&bnx2x_fp(bp, i, napi));
  719. }
  720. }
  721. int bnx2x_set_int_mode(struct bnx2x *bp);
  722. static inline void bnx2x_disable_msi(struct bnx2x *bp)
  723. {
  724. if (bp->flags & USING_MSIX_FLAG) {
  725. pci_disable_msix(bp->pdev);
  726. bp->flags &= ~(USING_MSIX_FLAG | USING_SINGLE_MSIX_FLAG);
  727. } else if (bp->flags & USING_MSI_FLAG) {
  728. pci_disable_msi(bp->pdev);
  729. bp->flags &= ~USING_MSI_FLAG;
  730. }
  731. }
  732. static inline void bnx2x_clear_sge_mask_next_elems(struct bnx2x_fastpath *fp)
  733. {
  734. int i, j;
  735. for (i = 1; i <= NUM_RX_SGE_PAGES; i++) {
  736. int idx = RX_SGE_CNT * i - 1;
  737. for (j = 0; j < 2; j++) {
  738. BIT_VEC64_CLEAR_BIT(fp->sge_mask, idx);
  739. idx--;
  740. }
  741. }
  742. }
  743. static inline void bnx2x_init_sge_ring_bit_mask(struct bnx2x_fastpath *fp)
  744. {
  745. /* Set the mask to all 1-s: it's faster to compare to 0 than to 0xf-s */
  746. memset(fp->sge_mask, 0xff, sizeof(fp->sge_mask));
  747. /* Clear the two last indices in the page to 1:
  748. these are the indices that correspond to the "next" element,
  749. hence will never be indicated and should be removed from
  750. the calculations. */
  751. bnx2x_clear_sge_mask_next_elems(fp);
  752. }
  753. /* note that we are not allocating a new buffer,
  754. * we are just moving one from cons to prod
  755. * we are not creating a new mapping,
  756. * so there is no need to check for dma_mapping_error().
  757. */
  758. static inline void bnx2x_reuse_rx_data(struct bnx2x_fastpath *fp,
  759. u16 cons, u16 prod)
  760. {
  761. struct sw_rx_bd *cons_rx_buf = &fp->rx_buf_ring[cons];
  762. struct sw_rx_bd *prod_rx_buf = &fp->rx_buf_ring[prod];
  763. struct eth_rx_bd *cons_bd = &fp->rx_desc_ring[cons];
  764. struct eth_rx_bd *prod_bd = &fp->rx_desc_ring[prod];
  765. dma_unmap_addr_set(prod_rx_buf, mapping,
  766. dma_unmap_addr(cons_rx_buf, mapping));
  767. prod_rx_buf->data = cons_rx_buf->data;
  768. *prod_bd = *cons_bd;
  769. }
  770. /************************* Init ******************************************/
  771. /* returns func by VN for current port */
  772. static inline int func_by_vn(struct bnx2x *bp, int vn)
  773. {
  774. return 2 * vn + BP_PORT(bp);
  775. }
  776. static inline int bnx2x_config_rss_eth(struct bnx2x *bp, bool config_hash)
  777. {
  778. return bnx2x_rss(bp, &bp->rss_conf_obj, config_hash, true);
  779. }
  780. /**
  781. * bnx2x_func_start - init function
  782. *
  783. * @bp: driver handle
  784. *
  785. * Must be called before sending CLIENT_SETUP for the first client.
  786. */
  787. static inline int bnx2x_func_start(struct bnx2x *bp)
  788. {
  789. struct bnx2x_func_state_params func_params = {NULL};
  790. struct bnx2x_func_start_params *start_params =
  791. &func_params.params.start;
  792. /* Prepare parameters for function state transitions */
  793. __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
  794. func_params.f_obj = &bp->func_obj;
  795. func_params.cmd = BNX2X_F_CMD_START;
  796. /* Function parameters */
  797. start_params->mf_mode = bp->mf_mode;
  798. start_params->sd_vlan_tag = bp->mf_ov;
  799. if (CHIP_IS_E2(bp) || CHIP_IS_E3(bp))
  800. start_params->network_cos_mode = STATIC_COS;
  801. else /* CHIP_IS_E1X */
  802. start_params->network_cos_mode = FW_WRR;
  803. start_params->tunnel_mode = TUNN_MODE_GRE;
  804. start_params->gre_tunnel_type = IPGRE_TUNNEL;
  805. start_params->inner_gre_rss_en = 1;
  806. if (IS_MF_UFP(bp) && BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)) {
  807. start_params->class_fail_ethtype = ETH_P_FIP;
  808. start_params->class_fail = 1;
  809. start_params->no_added_tags = 1;
  810. }
  811. return bnx2x_func_state_change(bp, &func_params);
  812. }
  813. /**
  814. * bnx2x_set_fw_mac_addr - fill in a MAC address in FW format
  815. *
  816. * @fw_hi: pointer to upper part
  817. * @fw_mid: pointer to middle part
  818. * @fw_lo: pointer to lower part
  819. * @mac: pointer to MAC address
  820. */
  821. static inline void bnx2x_set_fw_mac_addr(__le16 *fw_hi, __le16 *fw_mid,
  822. __le16 *fw_lo, u8 *mac)
  823. {
  824. ((u8 *)fw_hi)[0] = mac[1];
  825. ((u8 *)fw_hi)[1] = mac[0];
  826. ((u8 *)fw_mid)[0] = mac[3];
  827. ((u8 *)fw_mid)[1] = mac[2];
  828. ((u8 *)fw_lo)[0] = mac[5];
  829. ((u8 *)fw_lo)[1] = mac[4];
  830. }
  831. static inline void bnx2x_free_rx_sge_range(struct bnx2x *bp,
  832. struct bnx2x_fastpath *fp, int last)
  833. {
  834. int i;
  835. if (fp->disable_tpa)
  836. return;
  837. for (i = 0; i < last; i++)
  838. bnx2x_free_rx_sge(bp, fp, i);
  839. }
  840. static inline void bnx2x_set_next_page_rx_bd(struct bnx2x_fastpath *fp)
  841. {
  842. int i;
  843. for (i = 1; i <= NUM_RX_RINGS; i++) {
  844. struct eth_rx_bd *rx_bd;
  845. rx_bd = &fp->rx_desc_ring[RX_DESC_CNT * i - 2];
  846. rx_bd->addr_hi =
  847. cpu_to_le32(U64_HI(fp->rx_desc_mapping +
  848. BCM_PAGE_SIZE*(i % NUM_RX_RINGS)));
  849. rx_bd->addr_lo =
  850. cpu_to_le32(U64_LO(fp->rx_desc_mapping +
  851. BCM_PAGE_SIZE*(i % NUM_RX_RINGS)));
  852. }
  853. }
  854. /* Statistics ID are global per chip/path, while Client IDs for E1x are per
  855. * port.
  856. */
  857. static inline u8 bnx2x_stats_id(struct bnx2x_fastpath *fp)
  858. {
  859. struct bnx2x *bp = fp->bp;
  860. if (!CHIP_IS_E1x(bp)) {
  861. /* there are special statistics counters for FCoE 136..140 */
  862. if (IS_FCOE_FP(fp))
  863. return bp->cnic_base_cl_id + (bp->pf_num >> 1);
  864. return fp->cl_id;
  865. }
  866. return fp->cl_id + BP_PORT(bp) * FP_SB_MAX_E1x;
  867. }
  868. static inline void bnx2x_init_vlan_mac_fp_objs(struct bnx2x_fastpath *fp,
  869. bnx2x_obj_type obj_type)
  870. {
  871. struct bnx2x *bp = fp->bp;
  872. /* Configure classification DBs */
  873. bnx2x_init_mac_obj(bp, &bnx2x_sp_obj(bp, fp).mac_obj, fp->cl_id,
  874. fp->cid, BP_FUNC(bp), bnx2x_sp(bp, mac_rdata),
  875. bnx2x_sp_mapping(bp, mac_rdata),
  876. BNX2X_FILTER_MAC_PENDING,
  877. &bp->sp_state, obj_type,
  878. &bp->macs_pool);
  879. }
  880. /**
  881. * bnx2x_get_path_func_num - get number of active functions
  882. *
  883. * @bp: driver handle
  884. *
  885. * Calculates the number of active (not hidden) functions on the
  886. * current path.
  887. */
  888. static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
  889. {
  890. u8 func_num = 0, i;
  891. /* 57710 has only one function per-port */
  892. if (CHIP_IS_E1(bp))
  893. return 1;
  894. /* Calculate a number of functions enabled on the current
  895. * PATH/PORT.
  896. */
  897. if (CHIP_REV_IS_SLOW(bp)) {
  898. if (IS_MF(bp))
  899. func_num = 4;
  900. else
  901. func_num = 2;
  902. } else {
  903. for (i = 0; i < E1H_FUNC_MAX / 2; i++) {
  904. u32 func_config =
  905. MF_CFG_RD(bp,
  906. func_mf_config[BP_PORT(bp) + 2 * i].
  907. config);
  908. func_num +=
  909. ((func_config & FUNC_MF_CFG_FUNC_HIDE) ? 0 : 1);
  910. }
  911. }
  912. WARN_ON(!func_num);
  913. return func_num;
  914. }
  915. static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
  916. {
  917. /* RX_MODE controlling object */
  918. bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
  919. /* multicast configuration controlling object */
  920. bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
  921. BP_FUNC(bp), BP_FUNC(bp),
  922. bnx2x_sp(bp, mcast_rdata),
  923. bnx2x_sp_mapping(bp, mcast_rdata),
  924. BNX2X_FILTER_MCAST_PENDING, &bp->sp_state,
  925. BNX2X_OBJ_TYPE_RX);
  926. /* Setup CAM credit pools */
  927. bnx2x_init_mac_credit_pool(bp, &bp->macs_pool, BP_FUNC(bp),
  928. bnx2x_get_path_func_num(bp));
  929. bnx2x_init_vlan_credit_pool(bp, &bp->vlans_pool, BP_ABS_FUNC(bp)>>1,
  930. bnx2x_get_path_func_num(bp));
  931. /* RSS configuration object */
  932. bnx2x_init_rss_config_obj(bp, &bp->rss_conf_obj, bp->fp->cl_id,
  933. bp->fp->cid, BP_FUNC(bp), BP_FUNC(bp),
  934. bnx2x_sp(bp, rss_rdata),
  935. bnx2x_sp_mapping(bp, rss_rdata),
  936. BNX2X_FILTER_RSS_CONF_PENDING, &bp->sp_state,
  937. BNX2X_OBJ_TYPE_RX);
  938. }
  939. static inline u8 bnx2x_fp_qzone_id(struct bnx2x_fastpath *fp)
  940. {
  941. if (CHIP_IS_E1x(fp->bp))
  942. return fp->cl_id + BP_PORT(fp->bp) * ETH_MAX_RX_CLIENTS_E1H;
  943. else
  944. return fp->cl_id;
  945. }
  946. static inline void bnx2x_init_txdata(struct bnx2x *bp,
  947. struct bnx2x_fp_txdata *txdata, u32 cid,
  948. int txq_index, __le16 *tx_cons_sb,
  949. struct bnx2x_fastpath *fp)
  950. {
  951. txdata->cid = cid;
  952. txdata->txq_index = txq_index;
  953. txdata->tx_cons_sb = tx_cons_sb;
  954. txdata->parent_fp = fp;
  955. txdata->tx_ring_size = IS_FCOE_FP(fp) ? MAX_TX_AVAIL : bp->tx_ring_size;
  956. DP(NETIF_MSG_IFUP, "created tx data cid %d, txq %d\n",
  957. txdata->cid, txdata->txq_index);
  958. }
  959. static inline u8 bnx2x_cnic_eth_cl_id(struct bnx2x *bp, u8 cl_idx)
  960. {
  961. return bp->cnic_base_cl_id + cl_idx +
  962. (bp->pf_num >> 1) * BNX2X_MAX_CNIC_ETH_CL_ID_IDX;
  963. }
  964. static inline u8 bnx2x_cnic_fw_sb_id(struct bnx2x *bp)
  965. {
  966. /* the 'first' id is allocated for the cnic */
  967. return bp->base_fw_ndsb;
  968. }
  969. static inline u8 bnx2x_cnic_igu_sb_id(struct bnx2x *bp)
  970. {
  971. return bp->igu_base_sb;
  972. }
  973. static inline int bnx2x_clean_tx_queue(struct bnx2x *bp,
  974. struct bnx2x_fp_txdata *txdata)
  975. {
  976. int cnt = 1000;
  977. while (bnx2x_has_tx_work_unload(txdata)) {
  978. if (!cnt) {
  979. BNX2X_ERR("timeout waiting for queue[%d]: txdata->tx_pkt_prod(%d) != txdata->tx_pkt_cons(%d)\n",
  980. txdata->txq_index, txdata->tx_pkt_prod,
  981. txdata->tx_pkt_cons);
  982. #ifdef BNX2X_STOP_ON_ERROR
  983. bnx2x_panic();
  984. return -EBUSY;
  985. #else
  986. break;
  987. #endif
  988. }
  989. cnt--;
  990. usleep_range(1000, 2000);
  991. }
  992. return 0;
  993. }
  994. int bnx2x_get_link_cfg_idx(struct bnx2x *bp);
  995. static inline void __storm_memset_struct(struct bnx2x *bp,
  996. u32 addr, size_t size, u32 *data)
  997. {
  998. int i;
  999. for (i = 0; i < size/4; i++)
  1000. REG_WR(bp, addr + (i * 4), data[i]);
  1001. }
  1002. /**
  1003. * bnx2x_wait_sp_comp - wait for the outstanding SP commands.
  1004. *
  1005. * @bp: driver handle
  1006. * @mask: bits that need to be cleared
  1007. */
  1008. static inline bool bnx2x_wait_sp_comp(struct bnx2x *bp, unsigned long mask)
  1009. {
  1010. int tout = 5000; /* Wait for 5 secs tops */
  1011. while (tout--) {
  1012. smp_mb();
  1013. netif_addr_lock_bh(bp->dev);
  1014. if (!(bp->sp_state & mask)) {
  1015. netif_addr_unlock_bh(bp->dev);
  1016. return true;
  1017. }
  1018. netif_addr_unlock_bh(bp->dev);
  1019. usleep_range(1000, 2000);
  1020. }
  1021. smp_mb();
  1022. netif_addr_lock_bh(bp->dev);
  1023. if (bp->sp_state & mask) {
  1024. BNX2X_ERR("Filtering completion timed out. sp_state 0x%lx, mask 0x%lx\n",
  1025. bp->sp_state, mask);
  1026. netif_addr_unlock_bh(bp->dev);
  1027. return false;
  1028. }
  1029. netif_addr_unlock_bh(bp->dev);
  1030. return true;
  1031. }
  1032. /**
  1033. * bnx2x_set_ctx_validation - set CDU context validation values
  1034. *
  1035. * @bp: driver handle
  1036. * @cxt: context of the connection on the host memory
  1037. * @cid: SW CID of the connection to be configured
  1038. */
  1039. void bnx2x_set_ctx_validation(struct bnx2x *bp, struct eth_context *cxt,
  1040. u32 cid);
  1041. void bnx2x_update_coalesce_sb_index(struct bnx2x *bp, u8 fw_sb_id,
  1042. u8 sb_index, u8 disable, u16 usec);
  1043. void bnx2x_acquire_phy_lock(struct bnx2x *bp);
  1044. void bnx2x_release_phy_lock(struct bnx2x *bp);
  1045. /**
  1046. * bnx2x_extract_max_cfg - extract MAX BW part from MF configuration.
  1047. *
  1048. * @bp: driver handle
  1049. * @mf_cfg: MF configuration
  1050. *
  1051. */
  1052. static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg)
  1053. {
  1054. u16 max_cfg = (mf_cfg & FUNC_MF_CFG_MAX_BW_MASK) >>
  1055. FUNC_MF_CFG_MAX_BW_SHIFT;
  1056. if (!max_cfg) {
  1057. DP(NETIF_MSG_IFUP | BNX2X_MSG_ETHTOOL,
  1058. "Max BW configured to 0 - using 100 instead\n");
  1059. max_cfg = 100;
  1060. }
  1061. return max_cfg;
  1062. }
  1063. /* checks if HW supports GRO for given MTU */
  1064. static inline bool bnx2x_mtu_allows_gro(int mtu)
  1065. {
  1066. /* gro frags per page */
  1067. int fpp = SGE_PAGE_SIZE / (mtu - ETH_MAX_TPA_HEADER_SIZE);
  1068. /*
  1069. * 1. Number of frags should not grow above MAX_SKB_FRAGS
  1070. * 2. Frag must fit the page
  1071. */
  1072. return mtu <= SGE_PAGE_SIZE && (U_ETH_SGL_SIZE * fpp) <= MAX_SKB_FRAGS;
  1073. }
  1074. /**
  1075. * bnx2x_get_iscsi_info - update iSCSI params according to licensing info.
  1076. *
  1077. * @bp: driver handle
  1078. *
  1079. */
  1080. void bnx2x_get_iscsi_info(struct bnx2x *bp);
  1081. /**
  1082. * bnx2x_link_sync_notify - send notification to other functions.
  1083. *
  1084. * @bp: driver handle
  1085. *
  1086. */
  1087. static inline void bnx2x_link_sync_notify(struct bnx2x *bp)
  1088. {
  1089. int func;
  1090. int vn;
  1091. /* Set the attention towards other drivers on the same port */
  1092. for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) {
  1093. if (vn == BP_VN(bp))
  1094. continue;
  1095. func = func_by_vn(bp, vn);
  1096. REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_0 +
  1097. (LINK_SYNC_ATTENTION_BIT_FUNC_0 + func)*4, 1);
  1098. }
  1099. }
  1100. /**
  1101. * bnx2x_update_drv_flags - update flags in shmem
  1102. *
  1103. * @bp: driver handle
  1104. * @flags: flags to update
  1105. * @set: set or clear
  1106. *
  1107. */
  1108. static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set)
  1109. {
  1110. if (SHMEM2_HAS(bp, drv_flags)) {
  1111. u32 drv_flags;
  1112. bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_DRV_FLAGS);
  1113. drv_flags = SHMEM2_RD(bp, drv_flags);
  1114. if (set)
  1115. SET_FLAGS(drv_flags, flags);
  1116. else
  1117. RESET_FLAGS(drv_flags, flags);
  1118. SHMEM2_WR(bp, drv_flags, drv_flags);
  1119. DP(NETIF_MSG_IFUP, "drv_flags 0x%08x\n", drv_flags);
  1120. bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_DRV_FLAGS);
  1121. }
  1122. }
  1123. /**
  1124. * bnx2x_fill_fw_str - Fill buffer with FW version string
  1125. *
  1126. * @bp: driver handle
  1127. * @buf: character buffer to fill with the fw name
  1128. * @buf_len: length of the above buffer
  1129. *
  1130. */
  1131. void bnx2x_fill_fw_str(struct bnx2x *bp, char *buf, size_t buf_len);
  1132. int bnx2x_drain_tx_queues(struct bnx2x *bp);
  1133. void bnx2x_squeeze_objects(struct bnx2x *bp);
  1134. void bnx2x_schedule_sp_rtnl(struct bnx2x*, enum sp_rtnl_flag,
  1135. u32 verbose);
  1136. #endif /* BNX2X_CMN_H */