driver.h 30 KB

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