driver.h 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. /*
  2. * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef MLX5_DRIVER_H
  33. #define MLX5_DRIVER_H
  34. #include <linux/kernel.h>
  35. #include <linux/completion.h>
  36. #include <linux/pci.h>
  37. #include <linux/spinlock_types.h>
  38. #include <linux/semaphore.h>
  39. #include <linux/slab.h>
  40. #include <linux/vmalloc.h>
  41. #include <linux/radix-tree.h>
  42. #include <linux/workqueue.h>
  43. #include <linux/mempool.h>
  44. #include <linux/interrupt.h>
  45. #include <linux/idr.h>
  46. #include <linux/mlx5/device.h>
  47. #include <linux/mlx5/doorbell.h>
  48. #include <linux/mlx5/srq.h>
  49. #include <linux/timecounter.h>
  50. #include <linux/ptp_clock_kernel.h>
  51. enum {
  52. MLX5_BOARD_ID_LEN = 64,
  53. MLX5_MAX_NAME_LEN = 16,
  54. };
  55. enum {
  56. /* one minute for the sake of bringup. Generally, commands must always
  57. * complete and we may need to increase this timeout value
  58. */
  59. MLX5_CMD_TIMEOUT_MSEC = 60 * 1000,
  60. MLX5_CMD_WQ_MAX_NAME = 32,
  61. };
  62. enum {
  63. CMD_OWNER_SW = 0x0,
  64. CMD_OWNER_HW = 0x1,
  65. CMD_STATUS_SUCCESS = 0,
  66. };
  67. enum mlx5_sqp_t {
  68. MLX5_SQP_SMI = 0,
  69. MLX5_SQP_GSI = 1,
  70. MLX5_SQP_IEEE_1588 = 2,
  71. MLX5_SQP_SNIFFER = 3,
  72. MLX5_SQP_SYNC_UMR = 4,
  73. };
  74. enum {
  75. MLX5_MAX_PORTS = 2,
  76. };
  77. enum {
  78. MLX5_EQ_VEC_PAGES = 0,
  79. MLX5_EQ_VEC_CMD = 1,
  80. MLX5_EQ_VEC_ASYNC = 2,
  81. MLX5_EQ_VEC_PFAULT = 3,
  82. MLX5_EQ_VEC_COMP_BASE,
  83. };
  84. enum {
  85. MLX5_MAX_IRQ_NAME = 32
  86. };
  87. enum {
  88. MLX5_ATOMIC_MODE_IB_COMP = 1 << 16,
  89. MLX5_ATOMIC_MODE_CX = 2 << 16,
  90. MLX5_ATOMIC_MODE_8B = 3 << 16,
  91. MLX5_ATOMIC_MODE_16B = 4 << 16,
  92. MLX5_ATOMIC_MODE_32B = 5 << 16,
  93. MLX5_ATOMIC_MODE_64B = 6 << 16,
  94. MLX5_ATOMIC_MODE_128B = 7 << 16,
  95. MLX5_ATOMIC_MODE_256B = 8 << 16,
  96. };
  97. enum {
  98. MLX5_REG_QETCR = 0x4005,
  99. MLX5_REG_QTCT = 0x400a,
  100. MLX5_REG_DCBX_PARAM = 0x4020,
  101. MLX5_REG_DCBX_APP = 0x4021,
  102. MLX5_REG_FPGA_CAP = 0x4022,
  103. MLX5_REG_FPGA_CTRL = 0x4023,
  104. MLX5_REG_FPGA_ACCESS_REG = 0x4024,
  105. MLX5_REG_PCAP = 0x5001,
  106. MLX5_REG_PMTU = 0x5003,
  107. MLX5_REG_PTYS = 0x5004,
  108. MLX5_REG_PAOS = 0x5006,
  109. MLX5_REG_PFCC = 0x5007,
  110. MLX5_REG_PPCNT = 0x5008,
  111. MLX5_REG_PMAOS = 0x5012,
  112. MLX5_REG_PUDE = 0x5009,
  113. MLX5_REG_PMPE = 0x5010,
  114. MLX5_REG_PELC = 0x500e,
  115. MLX5_REG_PVLC = 0x500f,
  116. MLX5_REG_PCMR = 0x5041,
  117. MLX5_REG_PMLP = 0x5002,
  118. MLX5_REG_PCAM = 0x507f,
  119. MLX5_REG_NODE_DESC = 0x6001,
  120. MLX5_REG_HOST_ENDIANNESS = 0x7004,
  121. MLX5_REG_MCIA = 0x9014,
  122. MLX5_REG_MLCR = 0x902b,
  123. MLX5_REG_MPCNT = 0x9051,
  124. MLX5_REG_MTPPS = 0x9053,
  125. MLX5_REG_MTPPSE = 0x9054,
  126. MLX5_REG_MCQI = 0x9061,
  127. MLX5_REG_MCC = 0x9062,
  128. MLX5_REG_MCDA = 0x9063,
  129. MLX5_REG_MCAM = 0x907f,
  130. };
  131. enum mlx5_dcbx_oper_mode {
  132. MLX5E_DCBX_PARAM_VER_OPER_HOST = 0x0,
  133. MLX5E_DCBX_PARAM_VER_OPER_AUTO = 0x3,
  134. };
  135. enum {
  136. MLX5_ATOMIC_OPS_CMP_SWAP = 1 << 0,
  137. MLX5_ATOMIC_OPS_FETCH_ADD = 1 << 1,
  138. };
  139. enum mlx5_page_fault_resume_flags {
  140. MLX5_PAGE_FAULT_RESUME_REQUESTOR = 1 << 0,
  141. MLX5_PAGE_FAULT_RESUME_WRITE = 1 << 1,
  142. MLX5_PAGE_FAULT_RESUME_RDMA = 1 << 2,
  143. MLX5_PAGE_FAULT_RESUME_ERROR = 1 << 7,
  144. };
  145. enum dbg_rsc_type {
  146. MLX5_DBG_RSC_QP,
  147. MLX5_DBG_RSC_EQ,
  148. MLX5_DBG_RSC_CQ,
  149. };
  150. enum port_state_policy {
  151. MLX5_POLICY_DOWN = 0,
  152. MLX5_POLICY_UP = 1,
  153. MLX5_POLICY_FOLLOW = 2,
  154. MLX5_POLICY_INVALID = 0xffffffff
  155. };
  156. struct mlx5_field_desc {
  157. struct dentry *dent;
  158. int i;
  159. };
  160. struct mlx5_rsc_debug {
  161. struct mlx5_core_dev *dev;
  162. void *object;
  163. enum dbg_rsc_type type;
  164. struct dentry *root;
  165. struct mlx5_field_desc fields[0];
  166. };
  167. enum mlx5_dev_event {
  168. MLX5_DEV_EVENT_SYS_ERROR,
  169. MLX5_DEV_EVENT_PORT_UP,
  170. MLX5_DEV_EVENT_PORT_DOWN,
  171. MLX5_DEV_EVENT_PORT_INITIALIZED,
  172. MLX5_DEV_EVENT_LID_CHANGE,
  173. MLX5_DEV_EVENT_PKEY_CHANGE,
  174. MLX5_DEV_EVENT_GUID_CHANGE,
  175. MLX5_DEV_EVENT_CLIENT_REREG,
  176. MLX5_DEV_EVENT_PPS,
  177. MLX5_DEV_EVENT_DELAY_DROP_TIMEOUT,
  178. };
  179. enum mlx5_port_status {
  180. MLX5_PORT_UP = 1,
  181. MLX5_PORT_DOWN = 2,
  182. };
  183. enum mlx5_eq_type {
  184. MLX5_EQ_TYPE_COMP,
  185. MLX5_EQ_TYPE_ASYNC,
  186. #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
  187. MLX5_EQ_TYPE_PF,
  188. #endif
  189. };
  190. struct mlx5_bfreg_info {
  191. u32 *sys_pages;
  192. int num_low_latency_bfregs;
  193. unsigned int *count;
  194. /*
  195. * protect bfreg allocation data structs
  196. */
  197. struct mutex lock;
  198. u32 ver;
  199. bool lib_uar_4k;
  200. u32 num_sys_pages;
  201. };
  202. struct mlx5_cmd_first {
  203. __be32 data[4];
  204. };
  205. struct mlx5_cmd_msg {
  206. struct list_head list;
  207. struct cmd_msg_cache *parent;
  208. u32 len;
  209. struct mlx5_cmd_first first;
  210. struct mlx5_cmd_mailbox *next;
  211. };
  212. struct mlx5_cmd_debug {
  213. struct dentry *dbg_root;
  214. struct dentry *dbg_in;
  215. struct dentry *dbg_out;
  216. struct dentry *dbg_outlen;
  217. struct dentry *dbg_status;
  218. struct dentry *dbg_run;
  219. void *in_msg;
  220. void *out_msg;
  221. u8 status;
  222. u16 inlen;
  223. u16 outlen;
  224. };
  225. struct cmd_msg_cache {
  226. /* protect block chain allocations
  227. */
  228. spinlock_t lock;
  229. struct list_head head;
  230. unsigned int max_inbox_size;
  231. unsigned int num_ent;
  232. };
  233. enum {
  234. MLX5_NUM_COMMAND_CACHES = 5,
  235. };
  236. struct mlx5_cmd_stats {
  237. u64 sum;
  238. u64 n;
  239. struct dentry *root;
  240. struct dentry *avg;
  241. struct dentry *count;
  242. /* protect command average calculations */
  243. spinlock_t lock;
  244. };
  245. struct mlx5_cmd {
  246. void *cmd_alloc_buf;
  247. dma_addr_t alloc_dma;
  248. int alloc_size;
  249. void *cmd_buf;
  250. dma_addr_t dma;
  251. u16 cmdif_rev;
  252. u8 log_sz;
  253. u8 log_stride;
  254. int max_reg_cmds;
  255. int events;
  256. u32 __iomem *vector;
  257. /* protect command queue allocations
  258. */
  259. spinlock_t alloc_lock;
  260. /* protect token allocations
  261. */
  262. spinlock_t token_lock;
  263. u8 token;
  264. unsigned long bitmask;
  265. char wq_name[MLX5_CMD_WQ_MAX_NAME];
  266. struct workqueue_struct *wq;
  267. struct semaphore sem;
  268. struct semaphore pages_sem;
  269. int mode;
  270. struct mlx5_cmd_work_ent *ent_arr[MLX5_MAX_COMMANDS];
  271. struct dma_pool *pool;
  272. struct mlx5_cmd_debug dbg;
  273. struct cmd_msg_cache cache[MLX5_NUM_COMMAND_CACHES];
  274. int checksum_disabled;
  275. struct mlx5_cmd_stats stats[MLX5_CMD_OP_MAX];
  276. };
  277. struct mlx5_port_caps {
  278. int gid_table_len;
  279. int pkey_table_len;
  280. u8 ext_port_cap;
  281. bool has_smi;
  282. };
  283. struct mlx5_cmd_mailbox {
  284. void *buf;
  285. dma_addr_t dma;
  286. struct mlx5_cmd_mailbox *next;
  287. };
  288. struct mlx5_buf_list {
  289. void *buf;
  290. dma_addr_t map;
  291. };
  292. struct mlx5_buf {
  293. struct mlx5_buf_list direct;
  294. int npages;
  295. int size;
  296. u8 page_shift;
  297. };
  298. struct mlx5_frag_buf {
  299. struct mlx5_buf_list *frags;
  300. int npages;
  301. int size;
  302. u8 page_shift;
  303. };
  304. struct mlx5_eq_tasklet {
  305. struct list_head list;
  306. struct list_head process_list;
  307. struct tasklet_struct task;
  308. /* lock on completion tasklet list */
  309. spinlock_t lock;
  310. };
  311. struct mlx5_eq_pagefault {
  312. struct work_struct work;
  313. /* Pagefaults lock */
  314. spinlock_t lock;
  315. struct workqueue_struct *wq;
  316. mempool_t *pool;
  317. };
  318. struct mlx5_eq {
  319. struct mlx5_core_dev *dev;
  320. __be32 __iomem *doorbell;
  321. u32 cons_index;
  322. struct mlx5_buf buf;
  323. int size;
  324. unsigned int irqn;
  325. u8 eqn;
  326. int nent;
  327. u64 mask;
  328. struct list_head list;
  329. int index;
  330. struct mlx5_rsc_debug *dbg;
  331. enum mlx5_eq_type type;
  332. union {
  333. struct mlx5_eq_tasklet tasklet_ctx;
  334. #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
  335. struct mlx5_eq_pagefault pf_ctx;
  336. #endif
  337. };
  338. };
  339. struct mlx5_core_psv {
  340. u32 psv_idx;
  341. struct psv_layout {
  342. u32 pd;
  343. u16 syndrome;
  344. u16 reserved;
  345. u16 bg;
  346. u16 app_tag;
  347. u32 ref_tag;
  348. } psv;
  349. };
  350. struct mlx5_core_sig_ctx {
  351. struct mlx5_core_psv psv_memory;
  352. struct mlx5_core_psv psv_wire;
  353. struct ib_sig_err err_item;
  354. bool sig_status_checked;
  355. bool sig_err_exists;
  356. u32 sigerr_count;
  357. };
  358. enum {
  359. MLX5_MKEY_MR = 1,
  360. MLX5_MKEY_MW,
  361. };
  362. struct mlx5_core_mkey {
  363. u64 iova;
  364. u64 size;
  365. u32 key;
  366. u32 pd;
  367. u32 type;
  368. };
  369. #define MLX5_24BIT_MASK ((1 << 24) - 1)
  370. enum mlx5_res_type {
  371. MLX5_RES_QP = MLX5_EVENT_QUEUE_TYPE_QP,
  372. MLX5_RES_RQ = MLX5_EVENT_QUEUE_TYPE_RQ,
  373. MLX5_RES_SQ = MLX5_EVENT_QUEUE_TYPE_SQ,
  374. MLX5_RES_SRQ = 3,
  375. MLX5_RES_XSRQ = 4,
  376. MLX5_RES_XRQ = 5,
  377. };
  378. struct mlx5_core_rsc_common {
  379. enum mlx5_res_type res;
  380. atomic_t refcount;
  381. struct completion free;
  382. };
  383. struct mlx5_core_srq {
  384. struct mlx5_core_rsc_common common; /* must be first */
  385. u32 srqn;
  386. int max;
  387. int max_gs;
  388. int max_avail_gather;
  389. int wqe_shift;
  390. void (*event) (struct mlx5_core_srq *, enum mlx5_event);
  391. atomic_t refcount;
  392. struct completion free;
  393. };
  394. struct mlx5_eq_table {
  395. void __iomem *update_ci;
  396. void __iomem *update_arm_ci;
  397. struct list_head comp_eqs_list;
  398. struct mlx5_eq pages_eq;
  399. struct mlx5_eq async_eq;
  400. struct mlx5_eq cmd_eq;
  401. #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
  402. struct mlx5_eq pfault_eq;
  403. #endif
  404. int num_comp_vectors;
  405. /* protect EQs list
  406. */
  407. spinlock_t lock;
  408. };
  409. struct mlx5_uars_page {
  410. void __iomem *map;
  411. bool wc;
  412. u32 index;
  413. struct list_head list;
  414. unsigned int bfregs;
  415. unsigned long *reg_bitmap; /* for non fast path bf regs */
  416. unsigned long *fp_bitmap;
  417. unsigned int reg_avail;
  418. unsigned int fp_avail;
  419. struct kref ref_count;
  420. struct mlx5_core_dev *mdev;
  421. };
  422. struct mlx5_bfreg_head {
  423. /* protect blue flame registers allocations */
  424. struct mutex lock;
  425. struct list_head list;
  426. };
  427. struct mlx5_bfreg_data {
  428. struct mlx5_bfreg_head reg_head;
  429. struct mlx5_bfreg_head wc_head;
  430. };
  431. struct mlx5_sq_bfreg {
  432. void __iomem *map;
  433. struct mlx5_uars_page *up;
  434. bool wc;
  435. u32 index;
  436. unsigned int offset;
  437. };
  438. struct mlx5_core_health {
  439. struct health_buffer __iomem *health;
  440. __be32 __iomem *health_counter;
  441. struct timer_list timer;
  442. u32 prev;
  443. int miss_counter;
  444. bool sick;
  445. /* wq spinlock to synchronize draining */
  446. spinlock_t wq_lock;
  447. struct workqueue_struct *wq;
  448. unsigned long flags;
  449. struct work_struct work;
  450. struct delayed_work recover_work;
  451. };
  452. struct mlx5_cq_table {
  453. /* protect radix tree
  454. */
  455. spinlock_t lock;
  456. struct radix_tree_root tree;
  457. };
  458. struct mlx5_qp_table {
  459. /* protect radix tree
  460. */
  461. spinlock_t lock;
  462. struct radix_tree_root tree;
  463. };
  464. struct mlx5_srq_table {
  465. /* protect radix tree
  466. */
  467. spinlock_t lock;
  468. struct radix_tree_root tree;
  469. };
  470. struct mlx5_mkey_table {
  471. /* protect radix tree
  472. */
  473. rwlock_t lock;
  474. struct radix_tree_root tree;
  475. };
  476. struct mlx5_vf_context {
  477. int enabled;
  478. u64 port_guid;
  479. u64 node_guid;
  480. enum port_state_policy policy;
  481. };
  482. struct mlx5_core_sriov {
  483. struct mlx5_vf_context *vfs_ctx;
  484. int num_vfs;
  485. int enabled_vfs;
  486. };
  487. struct mlx5_irq_info {
  488. char name[MLX5_MAX_IRQ_NAME];
  489. };
  490. struct mlx5_fc_stats {
  491. struct rb_root counters;
  492. struct list_head addlist;
  493. /* protect addlist add/splice operations */
  494. spinlock_t addlist_lock;
  495. struct workqueue_struct *wq;
  496. struct delayed_work work;
  497. unsigned long next_query;
  498. unsigned long sampling_interval; /* jiffies */
  499. };
  500. struct mlx5_mpfs;
  501. struct mlx5_eswitch;
  502. struct mlx5_lag;
  503. struct mlx5_pagefault;
  504. struct mlx5_rl_entry {
  505. u32 rate;
  506. u16 index;
  507. u16 refcount;
  508. };
  509. struct mlx5_rl_table {
  510. /* protect rate limit table */
  511. struct mutex rl_lock;
  512. u16 max_size;
  513. u32 max_rate;
  514. u32 min_rate;
  515. struct mlx5_rl_entry *rl_entry;
  516. };
  517. enum port_module_event_status_type {
  518. MLX5_MODULE_STATUS_PLUGGED = 0x1,
  519. MLX5_MODULE_STATUS_UNPLUGGED = 0x2,
  520. MLX5_MODULE_STATUS_ERROR = 0x3,
  521. MLX5_MODULE_STATUS_NUM = 0x3,
  522. };
  523. enum port_module_event_error_type {
  524. MLX5_MODULE_EVENT_ERROR_POWER_BUDGET_EXCEEDED,
  525. MLX5_MODULE_EVENT_ERROR_LONG_RANGE_FOR_NON_MLNX_CABLE_MODULE,
  526. MLX5_MODULE_EVENT_ERROR_BUS_STUCK,
  527. MLX5_MODULE_EVENT_ERROR_NO_EEPROM_RETRY_TIMEOUT,
  528. MLX5_MODULE_EVENT_ERROR_ENFORCE_PART_NUMBER_LIST,
  529. MLX5_MODULE_EVENT_ERROR_UNKNOWN_IDENTIFIER,
  530. MLX5_MODULE_EVENT_ERROR_HIGH_TEMPERATURE,
  531. MLX5_MODULE_EVENT_ERROR_BAD_CABLE,
  532. MLX5_MODULE_EVENT_ERROR_UNKNOWN,
  533. MLX5_MODULE_EVENT_ERROR_NUM,
  534. };
  535. struct mlx5_port_module_event_stats {
  536. u64 status_counters[MLX5_MODULE_STATUS_NUM];
  537. u64 error_counters[MLX5_MODULE_EVENT_ERROR_NUM];
  538. };
  539. struct mlx5_priv {
  540. char name[MLX5_MAX_NAME_LEN];
  541. struct mlx5_eq_table eq_table;
  542. struct mlx5_irq_info *irq_info;
  543. /* pages stuff */
  544. struct workqueue_struct *pg_wq;
  545. struct rb_root page_root;
  546. int fw_pages;
  547. atomic_t reg_pages;
  548. struct list_head free_list;
  549. int vfs_pages;
  550. struct mlx5_core_health health;
  551. struct mlx5_srq_table srq_table;
  552. /* start: qp staff */
  553. struct mlx5_qp_table qp_table;
  554. struct dentry *qp_debugfs;
  555. struct dentry *eq_debugfs;
  556. struct dentry *cq_debugfs;
  557. struct dentry *cmdif_debugfs;
  558. /* end: qp staff */
  559. /* start: cq staff */
  560. struct mlx5_cq_table cq_table;
  561. /* end: cq staff */
  562. /* start: mkey staff */
  563. struct mlx5_mkey_table mkey_table;
  564. /* end: mkey staff */
  565. /* start: alloc staff */
  566. /* protect buffer alocation according to numa node */
  567. struct mutex alloc_mutex;
  568. int numa_node;
  569. struct mutex pgdir_mutex;
  570. struct list_head pgdir_list;
  571. /* end: alloc staff */
  572. struct dentry *dbg_root;
  573. /* protect mkey key part */
  574. spinlock_t mkey_lock;
  575. u8 mkey_key;
  576. struct list_head dev_list;
  577. struct list_head ctx_list;
  578. spinlock_t ctx_lock;
  579. struct list_head waiting_events_list;
  580. bool is_accum_events;
  581. struct mlx5_flow_steering *steering;
  582. struct mlx5_mpfs *mpfs;
  583. struct mlx5_eswitch *eswitch;
  584. struct mlx5_core_sriov sriov;
  585. struct mlx5_lag *lag;
  586. unsigned long pci_dev_data;
  587. struct mlx5_fc_stats fc_stats;
  588. struct mlx5_rl_table rl_table;
  589. struct mlx5_port_module_event_stats pme_stats;
  590. #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
  591. void (*pfault)(struct mlx5_core_dev *dev,
  592. void *context,
  593. struct mlx5_pagefault *pfault);
  594. void *pfault_ctx;
  595. struct srcu_struct pfault_srcu;
  596. #endif
  597. struct mlx5_bfreg_data bfregs;
  598. struct mlx5_uars_page *uar;
  599. };
  600. enum mlx5_device_state {
  601. MLX5_DEVICE_STATE_UP,
  602. MLX5_DEVICE_STATE_INTERNAL_ERROR,
  603. };
  604. enum mlx5_interface_state {
  605. MLX5_INTERFACE_STATE_UP = BIT(0),
  606. };
  607. enum mlx5_pci_status {
  608. MLX5_PCI_STATUS_DISABLED,
  609. MLX5_PCI_STATUS_ENABLED,
  610. };
  611. enum mlx5_pagefault_type_flags {
  612. MLX5_PFAULT_REQUESTOR = 1 << 0,
  613. MLX5_PFAULT_WRITE = 1 << 1,
  614. MLX5_PFAULT_RDMA = 1 << 2,
  615. };
  616. /* Contains the details of a pagefault. */
  617. struct mlx5_pagefault {
  618. u32 bytes_committed;
  619. u32 token;
  620. u8 event_subtype;
  621. u8 type;
  622. union {
  623. /* Initiator or send message responder pagefault details. */
  624. struct {
  625. /* Received packet size, only valid for responders. */
  626. u32 packet_size;
  627. /*
  628. * Number of resource holding WQE, depends on type.
  629. */
  630. u32 wq_num;
  631. /*
  632. * WQE index. Refers to either the send queue or
  633. * receive queue, according to event_subtype.
  634. */
  635. u16 wqe_index;
  636. } wqe;
  637. /* RDMA responder pagefault details */
  638. struct {
  639. u32 r_key;
  640. /*
  641. * Received packet size, minimal size page fault
  642. * resolution required for forward progress.
  643. */
  644. u32 packet_size;
  645. u32 rdma_op_len;
  646. u64 rdma_va;
  647. } rdma;
  648. };
  649. struct mlx5_eq *eq;
  650. struct work_struct work;
  651. };
  652. struct mlx5_td {
  653. struct list_head tirs_list;
  654. u32 tdn;
  655. };
  656. struct mlx5e_resources {
  657. u32 pdn;
  658. struct mlx5_td td;
  659. struct mlx5_core_mkey mkey;
  660. struct mlx5_sq_bfreg bfreg;
  661. };
  662. #define MLX5_MAX_RESERVED_GIDS 8
  663. struct mlx5_rsvd_gids {
  664. unsigned int start;
  665. unsigned int count;
  666. struct ida ida;
  667. };
  668. #define MAX_PIN_NUM 8
  669. struct mlx5_pps {
  670. u8 pin_caps[MAX_PIN_NUM];
  671. struct work_struct out_work;
  672. u64 start[MAX_PIN_NUM];
  673. u8 enabled;
  674. };
  675. struct mlx5_clock {
  676. rwlock_t lock;
  677. struct cyclecounter cycles;
  678. struct timecounter tc;
  679. struct hwtstamp_config hwtstamp_config;
  680. u32 nominal_c_mult;
  681. unsigned long overflow_period;
  682. struct delayed_work overflow_work;
  683. struct ptp_clock *ptp;
  684. struct ptp_clock_info ptp_info;
  685. struct mlx5_pps pps_info;
  686. };
  687. struct mlx5_core_dev {
  688. struct pci_dev *pdev;
  689. /* sync pci state */
  690. struct mutex pci_status_mutex;
  691. enum mlx5_pci_status pci_status;
  692. u8 rev_id;
  693. char board_id[MLX5_BOARD_ID_LEN];
  694. struct mlx5_cmd cmd;
  695. struct mlx5_port_caps port_caps[MLX5_MAX_PORTS];
  696. struct {
  697. u32 hca_cur[MLX5_CAP_NUM][MLX5_UN_SZ_DW(hca_cap_union)];
  698. u32 hca_max[MLX5_CAP_NUM][MLX5_UN_SZ_DW(hca_cap_union)];
  699. u32 pcam[MLX5_ST_SZ_DW(pcam_reg)];
  700. u32 mcam[MLX5_ST_SZ_DW(mcam_reg)];
  701. u32 fpga[MLX5_ST_SZ_DW(fpga_cap)];
  702. } caps;
  703. phys_addr_t iseg_base;
  704. struct mlx5_init_seg __iomem *iseg;
  705. enum mlx5_device_state state;
  706. /* sync interface state */
  707. struct mutex intf_state_mutex;
  708. unsigned long intf_state;
  709. void (*event) (struct mlx5_core_dev *dev,
  710. enum mlx5_dev_event event,
  711. unsigned long param);
  712. struct mlx5_priv priv;
  713. struct mlx5_profile *profile;
  714. atomic_t num_qps;
  715. u32 issi;
  716. struct mlx5e_resources mlx5e_res;
  717. struct {
  718. struct mlx5_rsvd_gids reserved_gids;
  719. atomic_t roce_en;
  720. } roce;
  721. #ifdef CONFIG_MLX5_FPGA
  722. struct mlx5_fpga_device *fpga;
  723. #endif
  724. #ifdef CONFIG_RFS_ACCEL
  725. struct cpu_rmap *rmap;
  726. #endif
  727. struct mlx5_clock clock;
  728. };
  729. struct mlx5_db {
  730. __be32 *db;
  731. union {
  732. struct mlx5_db_pgdir *pgdir;
  733. struct mlx5_ib_user_db_page *user_page;
  734. } u;
  735. dma_addr_t dma;
  736. int index;
  737. };
  738. enum {
  739. MLX5_COMP_EQ_SIZE = 1024,
  740. };
  741. enum {
  742. MLX5_PTYS_IB = 1 << 0,
  743. MLX5_PTYS_EN = 1 << 2,
  744. };
  745. typedef void (*mlx5_cmd_cbk_t)(int status, void *context);
  746. enum {
  747. MLX5_CMD_ENT_STATE_PENDING_COMP,
  748. };
  749. struct mlx5_cmd_work_ent {
  750. unsigned long state;
  751. struct mlx5_cmd_msg *in;
  752. struct mlx5_cmd_msg *out;
  753. void *uout;
  754. int uout_size;
  755. mlx5_cmd_cbk_t callback;
  756. struct delayed_work cb_timeout_work;
  757. void *context;
  758. int idx;
  759. struct completion done;
  760. struct mlx5_cmd *cmd;
  761. struct work_struct work;
  762. struct mlx5_cmd_layout *lay;
  763. int ret;
  764. int page_queue;
  765. u8 status;
  766. u8 token;
  767. u64 ts1;
  768. u64 ts2;
  769. u16 op;
  770. bool polling;
  771. };
  772. struct mlx5_pas {
  773. u64 pa;
  774. u8 log_sz;
  775. };
  776. enum phy_port_state {
  777. MLX5_AAA_111
  778. };
  779. struct mlx5_hca_vport_context {
  780. u32 field_select;
  781. bool sm_virt_aware;
  782. bool has_smi;
  783. bool has_raw;
  784. enum port_state_policy policy;
  785. enum phy_port_state phys_state;
  786. enum ib_port_state vport_state;
  787. u8 port_physical_state;
  788. u64 sys_image_guid;
  789. u64 port_guid;
  790. u64 node_guid;
  791. u32 cap_mask1;
  792. u32 cap_mask1_perm;
  793. u32 cap_mask2;
  794. u32 cap_mask2_perm;
  795. u16 lid;
  796. u8 init_type_reply; /* bitmask: see ib spec 14.2.5.6 InitTypeReply */
  797. u8 lmc;
  798. u8 subnet_timeout;
  799. u16 sm_lid;
  800. u8 sm_sl;
  801. u16 qkey_violation_counter;
  802. u16 pkey_violation_counter;
  803. bool grh_required;
  804. };
  805. static inline void *mlx5_buf_offset(struct mlx5_buf *buf, int offset)
  806. {
  807. return buf->direct.buf + offset;
  808. }
  809. #define STRUCT_FIELD(header, field) \
  810. .struct_offset_bytes = offsetof(struct ib_unpacked_ ## header, field), \
  811. .struct_size_bytes = sizeof((struct ib_unpacked_ ## header *)0)->field
  812. static inline struct mlx5_core_dev *pci2mlx5_core_dev(struct pci_dev *pdev)
  813. {
  814. return pci_get_drvdata(pdev);
  815. }
  816. extern struct dentry *mlx5_debugfs_root;
  817. static inline u16 fw_rev_maj(struct mlx5_core_dev *dev)
  818. {
  819. return ioread32be(&dev->iseg->fw_rev) & 0xffff;
  820. }
  821. static inline u16 fw_rev_min(struct mlx5_core_dev *dev)
  822. {
  823. return ioread32be(&dev->iseg->fw_rev) >> 16;
  824. }
  825. static inline u16 fw_rev_sub(struct mlx5_core_dev *dev)
  826. {
  827. return ioread32be(&dev->iseg->cmdif_rev_fw_sub) & 0xffff;
  828. }
  829. static inline u16 cmdif_rev(struct mlx5_core_dev *dev)
  830. {
  831. return ioread32be(&dev->iseg->cmdif_rev_fw_sub) >> 16;
  832. }
  833. static inline u32 mlx5_base_mkey(const u32 key)
  834. {
  835. return key & 0xffffff00u;
  836. }
  837. int mlx5_cmd_init(struct mlx5_core_dev *dev);
  838. void mlx5_cmd_cleanup(struct mlx5_core_dev *dev);
  839. void mlx5_cmd_use_events(struct mlx5_core_dev *dev);
  840. void mlx5_cmd_use_polling(struct mlx5_core_dev *dev);
  841. int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
  842. int out_size);
  843. int mlx5_cmd_exec_cb(struct mlx5_core_dev *dev, void *in, int in_size,
  844. void *out, int out_size, mlx5_cmd_cbk_t callback,
  845. void *context);
  846. int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,
  847. void *out, int out_size);
  848. void mlx5_cmd_mbox_status(void *out, u8 *status, u32 *syndrome);
  849. int mlx5_core_get_caps(struct mlx5_core_dev *dev, enum mlx5_cap_type cap_type);
  850. int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn);
  851. int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn);
  852. void mlx5_health_cleanup(struct mlx5_core_dev *dev);
  853. int mlx5_health_init(struct mlx5_core_dev *dev);
  854. void mlx5_start_health_poll(struct mlx5_core_dev *dev);
  855. void mlx5_stop_health_poll(struct mlx5_core_dev *dev);
  856. void mlx5_drain_health_wq(struct mlx5_core_dev *dev);
  857. void mlx5_trigger_health_work(struct mlx5_core_dev *dev);
  858. void mlx5_drain_health_recovery(struct mlx5_core_dev *dev);
  859. int mlx5_buf_alloc_node(struct mlx5_core_dev *dev, int size,
  860. struct mlx5_buf *buf, int node);
  861. int mlx5_buf_alloc(struct mlx5_core_dev *dev, int size, struct mlx5_buf *buf);
  862. void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf);
  863. int mlx5_frag_buf_alloc_node(struct mlx5_core_dev *dev, int size,
  864. struct mlx5_frag_buf *buf, int node);
  865. void mlx5_frag_buf_free(struct mlx5_core_dev *dev, struct mlx5_frag_buf *buf);
  866. struct mlx5_cmd_mailbox *mlx5_alloc_cmd_mailbox_chain(struct mlx5_core_dev *dev,
  867. gfp_t flags, int npages);
  868. void mlx5_free_cmd_mailbox_chain(struct mlx5_core_dev *dev,
  869. struct mlx5_cmd_mailbox *head);
  870. int mlx5_core_create_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
  871. struct mlx5_srq_attr *in);
  872. int mlx5_core_destroy_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq);
  873. int mlx5_core_query_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
  874. struct mlx5_srq_attr *out);
  875. int mlx5_core_arm_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
  876. u16 lwm, int is_srq);
  877. void mlx5_init_mkey_table(struct mlx5_core_dev *dev);
  878. void mlx5_cleanup_mkey_table(struct mlx5_core_dev *dev);
  879. int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
  880. struct mlx5_core_mkey *mkey,
  881. u32 *in, int inlen,
  882. u32 *out, int outlen,
  883. mlx5_cmd_cbk_t callback, void *context);
  884. int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
  885. struct mlx5_core_mkey *mkey,
  886. u32 *in, int inlen);
  887. int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev,
  888. struct mlx5_core_mkey *mkey);
  889. int mlx5_core_query_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mkey *mkey,
  890. u32 *out, int outlen);
  891. int mlx5_core_dump_fill_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mkey *_mkey,
  892. u32 *mkey);
  893. int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn);
  894. int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn);
  895. int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb,
  896. u16 opmod, u8 port);
  897. void mlx5_pagealloc_init(struct mlx5_core_dev *dev);
  898. void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev);
  899. int mlx5_pagealloc_start(struct mlx5_core_dev *dev);
  900. void mlx5_pagealloc_stop(struct mlx5_core_dev *dev);
  901. void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
  902. s32 npages);
  903. int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
  904. int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
  905. void mlx5_register_debugfs(void);
  906. void mlx5_unregister_debugfs(void);
  907. int mlx5_eq_init(struct mlx5_core_dev *dev);
  908. void mlx5_eq_cleanup(struct mlx5_core_dev *dev);
  909. void mlx5_fill_page_array(struct mlx5_buf *buf, __be64 *pas);
  910. void mlx5_fill_page_frag_array(struct mlx5_frag_buf *frag_buf, __be64 *pas);
  911. void mlx5_cq_completion(struct mlx5_core_dev *dev, u32 cqn);
  912. void mlx5_rsc_event(struct mlx5_core_dev *dev, u32 rsn, int event_type);
  913. void mlx5_srq_event(struct mlx5_core_dev *dev, u32 srqn, int event_type);
  914. struct mlx5_core_srq *mlx5_core_get_srq(struct mlx5_core_dev *dev, u32 srqn);
  915. void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool forced);
  916. void mlx5_cq_event(struct mlx5_core_dev *dev, u32 cqn, int event_type);
  917. int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx,
  918. int nent, u64 mask, const char *name,
  919. enum mlx5_eq_type type);
  920. int mlx5_destroy_unmap_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
  921. int mlx5_start_eqs(struct mlx5_core_dev *dev);
  922. int mlx5_stop_eqs(struct mlx5_core_dev *dev);
  923. int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
  924. unsigned int *irqn);
  925. int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
  926. int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
  927. int mlx5_qp_debugfs_init(struct mlx5_core_dev *dev);
  928. void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev);
  929. int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in,
  930. int size_in, void *data_out, int size_out,
  931. u16 reg_num, int arg, int write);
  932. int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
  933. void mlx5_debug_eq_remove(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
  934. int mlx5_core_eq_query(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
  935. u32 *out, int outlen);
  936. int mlx5_eq_debugfs_init(struct mlx5_core_dev *dev);
  937. void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev);
  938. int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev);
  939. void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev);
  940. int mlx5_db_alloc(struct mlx5_core_dev *dev, struct mlx5_db *db);
  941. int mlx5_db_alloc_node(struct mlx5_core_dev *dev, struct mlx5_db *db,
  942. int node);
  943. void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db);
  944. const char *mlx5_command_str(int command);
  945. int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev);
  946. void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev);
  947. int mlx5_core_create_psv(struct mlx5_core_dev *dev, u32 pdn,
  948. int npsvs, u32 *sig_index);
  949. int mlx5_core_destroy_psv(struct mlx5_core_dev *dev, int psv_num);
  950. void mlx5_core_put_rsc(struct mlx5_core_rsc_common *common);
  951. int mlx5_query_odp_caps(struct mlx5_core_dev *dev,
  952. struct mlx5_odp_caps *odp_caps);
  953. int mlx5_core_query_ib_ppcnt(struct mlx5_core_dev *dev,
  954. u8 port_num, void *out, size_t sz);
  955. #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
  956. int mlx5_core_page_fault_resume(struct mlx5_core_dev *dev, u32 token,
  957. u32 wq_num, u8 type, int error);
  958. #endif
  959. int mlx5_init_rl_table(struct mlx5_core_dev *dev);
  960. void mlx5_cleanup_rl_table(struct mlx5_core_dev *dev);
  961. int mlx5_rl_add_rate(struct mlx5_core_dev *dev, u32 rate, u16 *index);
  962. void mlx5_rl_remove_rate(struct mlx5_core_dev *dev, u32 rate);
  963. bool mlx5_rl_is_in_range(struct mlx5_core_dev *dev, u32 rate);
  964. int mlx5_alloc_bfreg(struct mlx5_core_dev *mdev, struct mlx5_sq_bfreg *bfreg,
  965. bool map_wc, bool fast_path);
  966. void mlx5_free_bfreg(struct mlx5_core_dev *mdev, struct mlx5_sq_bfreg *bfreg);
  967. unsigned int mlx5_core_reserved_gids_count(struct mlx5_core_dev *dev);
  968. int mlx5_core_roce_gid_set(struct mlx5_core_dev *dev, unsigned int index,
  969. u8 roce_version, u8 roce_l3_type, const u8 *gid,
  970. const u8 *mac, bool vlan, u16 vlan_id);
  971. static inline int fw_initializing(struct mlx5_core_dev *dev)
  972. {
  973. return ioread32be(&dev->iseg->initializing) >> 31;
  974. }
  975. static inline u32 mlx5_mkey_to_idx(u32 mkey)
  976. {
  977. return mkey >> 8;
  978. }
  979. static inline u32 mlx5_idx_to_mkey(u32 mkey_idx)
  980. {
  981. return mkey_idx << 8;
  982. }
  983. static inline u8 mlx5_mkey_variant(u32 mkey)
  984. {
  985. return mkey & 0xff;
  986. }
  987. enum {
  988. MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0,
  989. MLX5_PROF_MASK_MR_CACHE = (u64)1 << 1,
  990. };
  991. enum {
  992. MR_CACHE_LAST_STD_ENTRY = 20,
  993. MLX5_IMR_MTT_CACHE_ENTRY,
  994. MLX5_IMR_KSM_CACHE_ENTRY,
  995. MAX_MR_CACHE_ENTRIES
  996. };
  997. enum {
  998. MLX5_INTERFACE_PROTOCOL_IB = 0,
  999. MLX5_INTERFACE_PROTOCOL_ETH = 1,
  1000. };
  1001. struct mlx5_interface {
  1002. void * (*add)(struct mlx5_core_dev *dev);
  1003. void (*remove)(struct mlx5_core_dev *dev, void *context);
  1004. int (*attach)(struct mlx5_core_dev *dev, void *context);
  1005. void (*detach)(struct mlx5_core_dev *dev, void *context);
  1006. void (*event)(struct mlx5_core_dev *dev, void *context,
  1007. enum mlx5_dev_event event, unsigned long param);
  1008. void (*pfault)(struct mlx5_core_dev *dev,
  1009. void *context,
  1010. struct mlx5_pagefault *pfault);
  1011. void * (*get_dev)(void *context);
  1012. int protocol;
  1013. struct list_head list;
  1014. };
  1015. void *mlx5_get_protocol_dev(struct mlx5_core_dev *mdev, int protocol);
  1016. int mlx5_register_interface(struct mlx5_interface *intf);
  1017. void mlx5_unregister_interface(struct mlx5_interface *intf);
  1018. int mlx5_core_query_vendor_id(struct mlx5_core_dev *mdev, u32 *vendor_id);
  1019. int mlx5_cmd_create_vport_lag(struct mlx5_core_dev *dev);
  1020. int mlx5_cmd_destroy_vport_lag(struct mlx5_core_dev *dev);
  1021. bool mlx5_lag_is_active(struct mlx5_core_dev *dev);
  1022. struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev);
  1023. struct mlx5_uars_page *mlx5_get_uars_page(struct mlx5_core_dev *mdev);
  1024. void mlx5_put_uars_page(struct mlx5_core_dev *mdev, struct mlx5_uars_page *up);
  1025. #ifndef CONFIG_MLX5_CORE_IPOIB
  1026. static inline
  1027. struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
  1028. struct ib_device *ibdev,
  1029. const char *name,
  1030. void (*setup)(struct net_device *))
  1031. {
  1032. return ERR_PTR(-EOPNOTSUPP);
  1033. }
  1034. static inline void mlx5_rdma_netdev_free(struct net_device *netdev) {}
  1035. #else
  1036. struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
  1037. struct ib_device *ibdev,
  1038. const char *name,
  1039. void (*setup)(struct net_device *));
  1040. void mlx5_rdma_netdev_free(struct net_device *netdev);
  1041. #endif /* CONFIG_MLX5_CORE_IPOIB */
  1042. struct mlx5_profile {
  1043. u64 mask;
  1044. u8 log_max_qp;
  1045. struct {
  1046. int size;
  1047. int limit;
  1048. } mr_cache[MAX_MR_CACHE_ENTRIES];
  1049. };
  1050. enum {
  1051. MLX5_PCI_DEV_IS_VF = 1 << 0,
  1052. };
  1053. static inline int mlx5_core_is_pf(struct mlx5_core_dev *dev)
  1054. {
  1055. return !(dev->priv.pci_dev_data & MLX5_PCI_DEV_IS_VF);
  1056. }
  1057. static inline int mlx5_get_gid_table_len(u16 param)
  1058. {
  1059. if (param > 4) {
  1060. pr_warn("gid table length is zero\n");
  1061. return 0;
  1062. }
  1063. return 8 * (1 << param);
  1064. }
  1065. static inline bool mlx5_rl_is_supported(struct mlx5_core_dev *dev)
  1066. {
  1067. return !!(dev->priv.rl_table.max_size);
  1068. }
  1069. enum {
  1070. MLX5_TRIGGERED_CMD_COMP = (u64)1 << 32,
  1071. };
  1072. static inline const struct cpumask *
  1073. mlx5_get_vector_affinity(struct mlx5_core_dev *dev, int vector)
  1074. {
  1075. return pci_irq_get_affinity(dev->pdev, MLX5_EQ_VEC_COMP_BASE + vector);
  1076. }
  1077. #endif /* MLX5_DRIVER_H */