driver.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  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_eswitch;
  489. struct mlx5_lag;
  490. struct mlx5_pagefault;
  491. struct mlx5_rl_entry {
  492. u32 rate;
  493. u16 index;
  494. u16 refcount;
  495. };
  496. struct mlx5_rl_table {
  497. /* protect rate limit table */
  498. struct mutex rl_lock;
  499. u16 max_size;
  500. u32 max_rate;
  501. u32 min_rate;
  502. struct mlx5_rl_entry *rl_entry;
  503. };
  504. enum port_module_event_status_type {
  505. MLX5_MODULE_STATUS_PLUGGED = 0x1,
  506. MLX5_MODULE_STATUS_UNPLUGGED = 0x2,
  507. MLX5_MODULE_STATUS_ERROR = 0x3,
  508. MLX5_MODULE_STATUS_NUM = 0x3,
  509. };
  510. enum port_module_event_error_type {
  511. MLX5_MODULE_EVENT_ERROR_POWER_BUDGET_EXCEEDED,
  512. MLX5_MODULE_EVENT_ERROR_LONG_RANGE_FOR_NON_MLNX_CABLE_MODULE,
  513. MLX5_MODULE_EVENT_ERROR_BUS_STUCK,
  514. MLX5_MODULE_EVENT_ERROR_NO_EEPROM_RETRY_TIMEOUT,
  515. MLX5_MODULE_EVENT_ERROR_ENFORCE_PART_NUMBER_LIST,
  516. MLX5_MODULE_EVENT_ERROR_UNKNOWN_IDENTIFIER,
  517. MLX5_MODULE_EVENT_ERROR_HIGH_TEMPERATURE,
  518. MLX5_MODULE_EVENT_ERROR_BAD_CABLE,
  519. MLX5_MODULE_EVENT_ERROR_UNKNOWN,
  520. MLX5_MODULE_EVENT_ERROR_NUM,
  521. };
  522. struct mlx5_port_module_event_stats {
  523. u64 status_counters[MLX5_MODULE_STATUS_NUM];
  524. u64 error_counters[MLX5_MODULE_EVENT_ERROR_NUM];
  525. };
  526. struct mlx5_priv {
  527. char name[MLX5_MAX_NAME_LEN];
  528. struct mlx5_eq_table eq_table;
  529. struct msix_entry *msix_arr;
  530. struct mlx5_irq_info *irq_info;
  531. /* pages stuff */
  532. struct workqueue_struct *pg_wq;
  533. struct rb_root page_root;
  534. int fw_pages;
  535. atomic_t reg_pages;
  536. struct list_head free_list;
  537. int vfs_pages;
  538. struct mlx5_core_health health;
  539. struct mlx5_srq_table srq_table;
  540. /* start: qp staff */
  541. struct mlx5_qp_table qp_table;
  542. struct dentry *qp_debugfs;
  543. struct dentry *eq_debugfs;
  544. struct dentry *cq_debugfs;
  545. struct dentry *cmdif_debugfs;
  546. /* end: qp staff */
  547. /* start: cq staff */
  548. struct mlx5_cq_table cq_table;
  549. /* end: cq staff */
  550. /* start: mkey staff */
  551. struct mlx5_mkey_table mkey_table;
  552. /* end: mkey staff */
  553. /* start: alloc staff */
  554. /* protect buffer alocation according to numa node */
  555. struct mutex alloc_mutex;
  556. int numa_node;
  557. struct mutex pgdir_mutex;
  558. struct list_head pgdir_list;
  559. /* end: alloc staff */
  560. struct dentry *dbg_root;
  561. /* protect mkey key part */
  562. spinlock_t mkey_lock;
  563. u8 mkey_key;
  564. struct list_head dev_list;
  565. struct list_head ctx_list;
  566. spinlock_t ctx_lock;
  567. struct mlx5_flow_steering *steering;
  568. struct mlx5_eswitch *eswitch;
  569. struct mlx5_core_sriov sriov;
  570. struct mlx5_lag *lag;
  571. unsigned long pci_dev_data;
  572. struct mlx5_fc_stats fc_stats;
  573. struct mlx5_rl_table rl_table;
  574. struct mlx5_port_module_event_stats pme_stats;
  575. #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
  576. void (*pfault)(struct mlx5_core_dev *dev,
  577. void *context,
  578. struct mlx5_pagefault *pfault);
  579. void *pfault_ctx;
  580. struct srcu_struct pfault_srcu;
  581. #endif
  582. struct mlx5_bfreg_data bfregs;
  583. struct mlx5_uars_page *uar;
  584. };
  585. enum mlx5_device_state {
  586. MLX5_DEVICE_STATE_UP,
  587. MLX5_DEVICE_STATE_INTERNAL_ERROR,
  588. };
  589. enum mlx5_interface_state {
  590. MLX5_INTERFACE_STATE_DOWN = BIT(0),
  591. MLX5_INTERFACE_STATE_UP = BIT(1),
  592. MLX5_INTERFACE_STATE_SHUTDOWN = BIT(2),
  593. };
  594. enum mlx5_pci_status {
  595. MLX5_PCI_STATUS_DISABLED,
  596. MLX5_PCI_STATUS_ENABLED,
  597. };
  598. enum mlx5_pagefault_type_flags {
  599. MLX5_PFAULT_REQUESTOR = 1 << 0,
  600. MLX5_PFAULT_WRITE = 1 << 1,
  601. MLX5_PFAULT_RDMA = 1 << 2,
  602. };
  603. /* Contains the details of a pagefault. */
  604. struct mlx5_pagefault {
  605. u32 bytes_committed;
  606. u32 token;
  607. u8 event_subtype;
  608. u8 type;
  609. union {
  610. /* Initiator or send message responder pagefault details. */
  611. struct {
  612. /* Received packet size, only valid for responders. */
  613. u32 packet_size;
  614. /*
  615. * Number of resource holding WQE, depends on type.
  616. */
  617. u32 wq_num;
  618. /*
  619. * WQE index. Refers to either the send queue or
  620. * receive queue, according to event_subtype.
  621. */
  622. u16 wqe_index;
  623. } wqe;
  624. /* RDMA responder pagefault details */
  625. struct {
  626. u32 r_key;
  627. /*
  628. * Received packet size, minimal size page fault
  629. * resolution required for forward progress.
  630. */
  631. u32 packet_size;
  632. u32 rdma_op_len;
  633. u64 rdma_va;
  634. } rdma;
  635. };
  636. struct mlx5_eq *eq;
  637. struct work_struct work;
  638. };
  639. struct mlx5_td {
  640. struct list_head tirs_list;
  641. u32 tdn;
  642. };
  643. struct mlx5e_resources {
  644. u32 pdn;
  645. struct mlx5_td td;
  646. struct mlx5_core_mkey mkey;
  647. struct mlx5_sq_bfreg bfreg;
  648. };
  649. #define MLX5_MAX_RESERVED_GIDS 8
  650. struct mlx5_rsvd_gids {
  651. unsigned int start;
  652. unsigned int count;
  653. struct ida ida;
  654. };
  655. struct mlx5_core_dev {
  656. struct pci_dev *pdev;
  657. /* sync pci state */
  658. struct mutex pci_status_mutex;
  659. enum mlx5_pci_status pci_status;
  660. u8 rev_id;
  661. char board_id[MLX5_BOARD_ID_LEN];
  662. struct mlx5_cmd cmd;
  663. struct mlx5_port_caps port_caps[MLX5_MAX_PORTS];
  664. struct {
  665. u32 hca_cur[MLX5_CAP_NUM][MLX5_UN_SZ_DW(hca_cap_union)];
  666. u32 hca_max[MLX5_CAP_NUM][MLX5_UN_SZ_DW(hca_cap_union)];
  667. u32 pcam[MLX5_ST_SZ_DW(pcam_reg)];
  668. u32 mcam[MLX5_ST_SZ_DW(mcam_reg)];
  669. } caps;
  670. phys_addr_t iseg_base;
  671. struct mlx5_init_seg __iomem *iseg;
  672. enum mlx5_device_state state;
  673. /* sync interface state */
  674. struct mutex intf_state_mutex;
  675. unsigned long intf_state;
  676. void (*event) (struct mlx5_core_dev *dev,
  677. enum mlx5_dev_event event,
  678. unsigned long param);
  679. struct mlx5_priv priv;
  680. struct mlx5_profile *profile;
  681. atomic_t num_qps;
  682. u32 issi;
  683. struct mlx5e_resources mlx5e_res;
  684. struct {
  685. struct mlx5_rsvd_gids reserved_gids;
  686. atomic_t roce_en;
  687. } roce;
  688. #ifdef CONFIG_MLX5_FPGA
  689. struct mlx5_fpga_device *fpga;
  690. #endif
  691. #ifdef CONFIG_RFS_ACCEL
  692. struct cpu_rmap *rmap;
  693. #endif
  694. };
  695. struct mlx5_db {
  696. __be32 *db;
  697. union {
  698. struct mlx5_db_pgdir *pgdir;
  699. struct mlx5_ib_user_db_page *user_page;
  700. } u;
  701. dma_addr_t dma;
  702. int index;
  703. };
  704. enum {
  705. MLX5_COMP_EQ_SIZE = 1024,
  706. };
  707. enum {
  708. MLX5_PTYS_IB = 1 << 0,
  709. MLX5_PTYS_EN = 1 << 2,
  710. };
  711. typedef void (*mlx5_cmd_cbk_t)(int status, void *context);
  712. enum {
  713. MLX5_CMD_ENT_STATE_PENDING_COMP,
  714. };
  715. struct mlx5_cmd_work_ent {
  716. unsigned long state;
  717. struct mlx5_cmd_msg *in;
  718. struct mlx5_cmd_msg *out;
  719. void *uout;
  720. int uout_size;
  721. mlx5_cmd_cbk_t callback;
  722. struct delayed_work cb_timeout_work;
  723. void *context;
  724. int idx;
  725. struct completion done;
  726. struct mlx5_cmd *cmd;
  727. struct work_struct work;
  728. struct mlx5_cmd_layout *lay;
  729. int ret;
  730. int page_queue;
  731. u8 status;
  732. u8 token;
  733. u64 ts1;
  734. u64 ts2;
  735. u16 op;
  736. bool polling;
  737. };
  738. struct mlx5_pas {
  739. u64 pa;
  740. u8 log_sz;
  741. };
  742. enum port_state_policy {
  743. MLX5_POLICY_DOWN = 0,
  744. MLX5_POLICY_UP = 1,
  745. MLX5_POLICY_FOLLOW = 2,
  746. MLX5_POLICY_INVALID = 0xffffffff
  747. };
  748. enum phy_port_state {
  749. MLX5_AAA_111
  750. };
  751. struct mlx5_hca_vport_context {
  752. u32 field_select;
  753. bool sm_virt_aware;
  754. bool has_smi;
  755. bool has_raw;
  756. enum port_state_policy policy;
  757. enum phy_port_state phys_state;
  758. enum ib_port_state vport_state;
  759. u8 port_physical_state;
  760. u64 sys_image_guid;
  761. u64 port_guid;
  762. u64 node_guid;
  763. u32 cap_mask1;
  764. u32 cap_mask1_perm;
  765. u32 cap_mask2;
  766. u32 cap_mask2_perm;
  767. u16 lid;
  768. u8 init_type_reply; /* bitmask: see ib spec 14.2.5.6 InitTypeReply */
  769. u8 lmc;
  770. u8 subnet_timeout;
  771. u16 sm_lid;
  772. u8 sm_sl;
  773. u16 qkey_violation_counter;
  774. u16 pkey_violation_counter;
  775. bool grh_required;
  776. };
  777. static inline void *mlx5_buf_offset(struct mlx5_buf *buf, int offset)
  778. {
  779. return buf->direct.buf + offset;
  780. }
  781. extern struct workqueue_struct *mlx5_core_wq;
  782. #define STRUCT_FIELD(header, field) \
  783. .struct_offset_bytes = offsetof(struct ib_unpacked_ ## header, field), \
  784. .struct_size_bytes = sizeof((struct ib_unpacked_ ## header *)0)->field
  785. static inline struct mlx5_core_dev *pci2mlx5_core_dev(struct pci_dev *pdev)
  786. {
  787. return pci_get_drvdata(pdev);
  788. }
  789. extern struct dentry *mlx5_debugfs_root;
  790. static inline u16 fw_rev_maj(struct mlx5_core_dev *dev)
  791. {
  792. return ioread32be(&dev->iseg->fw_rev) & 0xffff;
  793. }
  794. static inline u16 fw_rev_min(struct mlx5_core_dev *dev)
  795. {
  796. return ioread32be(&dev->iseg->fw_rev) >> 16;
  797. }
  798. static inline u16 fw_rev_sub(struct mlx5_core_dev *dev)
  799. {
  800. return ioread32be(&dev->iseg->cmdif_rev_fw_sub) & 0xffff;
  801. }
  802. static inline u16 cmdif_rev(struct mlx5_core_dev *dev)
  803. {
  804. return ioread32be(&dev->iseg->cmdif_rev_fw_sub) >> 16;
  805. }
  806. static inline u32 mlx5_base_mkey(const u32 key)
  807. {
  808. return key & 0xffffff00u;
  809. }
  810. int mlx5_cmd_init(struct mlx5_core_dev *dev);
  811. void mlx5_cmd_cleanup(struct mlx5_core_dev *dev);
  812. void mlx5_cmd_use_events(struct mlx5_core_dev *dev);
  813. void mlx5_cmd_use_polling(struct mlx5_core_dev *dev);
  814. int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
  815. int out_size);
  816. int mlx5_cmd_exec_cb(struct mlx5_core_dev *dev, void *in, int in_size,
  817. void *out, int out_size, mlx5_cmd_cbk_t callback,
  818. void *context);
  819. int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,
  820. void *out, int out_size);
  821. void mlx5_cmd_mbox_status(void *out, u8 *status, u32 *syndrome);
  822. int mlx5_core_get_caps(struct mlx5_core_dev *dev, enum mlx5_cap_type cap_type);
  823. int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn);
  824. int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn);
  825. void mlx5_health_cleanup(struct mlx5_core_dev *dev);
  826. int mlx5_health_init(struct mlx5_core_dev *dev);
  827. void mlx5_start_health_poll(struct mlx5_core_dev *dev);
  828. void mlx5_stop_health_poll(struct mlx5_core_dev *dev);
  829. void mlx5_drain_health_wq(struct mlx5_core_dev *dev);
  830. void mlx5_trigger_health_work(struct mlx5_core_dev *dev);
  831. void mlx5_drain_health_recovery(struct mlx5_core_dev *dev);
  832. int mlx5_buf_alloc_node(struct mlx5_core_dev *dev, int size,
  833. struct mlx5_buf *buf, int node);
  834. int mlx5_buf_alloc(struct mlx5_core_dev *dev, int size, struct mlx5_buf *buf);
  835. void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf);
  836. int mlx5_frag_buf_alloc_node(struct mlx5_core_dev *dev, int size,
  837. struct mlx5_frag_buf *buf, int node);
  838. void mlx5_frag_buf_free(struct mlx5_core_dev *dev, struct mlx5_frag_buf *buf);
  839. struct mlx5_cmd_mailbox *mlx5_alloc_cmd_mailbox_chain(struct mlx5_core_dev *dev,
  840. gfp_t flags, int npages);
  841. void mlx5_free_cmd_mailbox_chain(struct mlx5_core_dev *dev,
  842. struct mlx5_cmd_mailbox *head);
  843. int mlx5_core_create_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
  844. struct mlx5_srq_attr *in);
  845. int mlx5_core_destroy_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq);
  846. int mlx5_core_query_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
  847. struct mlx5_srq_attr *out);
  848. int mlx5_core_arm_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
  849. u16 lwm, int is_srq);
  850. void mlx5_init_mkey_table(struct mlx5_core_dev *dev);
  851. void mlx5_cleanup_mkey_table(struct mlx5_core_dev *dev);
  852. int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
  853. struct mlx5_core_mkey *mkey,
  854. u32 *in, int inlen,
  855. u32 *out, int outlen,
  856. mlx5_cmd_cbk_t callback, void *context);
  857. int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
  858. struct mlx5_core_mkey *mkey,
  859. u32 *in, int inlen);
  860. int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev,
  861. struct mlx5_core_mkey *mkey);
  862. int mlx5_core_query_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mkey *mkey,
  863. u32 *out, int outlen);
  864. int mlx5_core_dump_fill_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mkey *_mkey,
  865. u32 *mkey);
  866. int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn);
  867. int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn);
  868. int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb,
  869. u16 opmod, u8 port);
  870. void mlx5_pagealloc_init(struct mlx5_core_dev *dev);
  871. void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev);
  872. int mlx5_pagealloc_start(struct mlx5_core_dev *dev);
  873. void mlx5_pagealloc_stop(struct mlx5_core_dev *dev);
  874. void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
  875. s32 npages);
  876. int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
  877. int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
  878. void mlx5_register_debugfs(void);
  879. void mlx5_unregister_debugfs(void);
  880. int mlx5_eq_init(struct mlx5_core_dev *dev);
  881. void mlx5_eq_cleanup(struct mlx5_core_dev *dev);
  882. void mlx5_fill_page_array(struct mlx5_buf *buf, __be64 *pas);
  883. void mlx5_fill_page_frag_array(struct mlx5_frag_buf *frag_buf, __be64 *pas);
  884. void mlx5_cq_completion(struct mlx5_core_dev *dev, u32 cqn);
  885. void mlx5_rsc_event(struct mlx5_core_dev *dev, u32 rsn, int event_type);
  886. void mlx5_srq_event(struct mlx5_core_dev *dev, u32 srqn, int event_type);
  887. struct mlx5_core_srq *mlx5_core_get_srq(struct mlx5_core_dev *dev, u32 srqn);
  888. void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool forced);
  889. void mlx5_cq_event(struct mlx5_core_dev *dev, u32 cqn, int event_type);
  890. int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx,
  891. int nent, u64 mask, const char *name,
  892. enum mlx5_eq_type type);
  893. int mlx5_destroy_unmap_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
  894. int mlx5_start_eqs(struct mlx5_core_dev *dev);
  895. int mlx5_stop_eqs(struct mlx5_core_dev *dev);
  896. int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
  897. unsigned int *irqn);
  898. int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
  899. int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
  900. int mlx5_qp_debugfs_init(struct mlx5_core_dev *dev);
  901. void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev);
  902. int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in,
  903. int size_in, void *data_out, int size_out,
  904. u16 reg_num, int arg, int write);
  905. int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
  906. void mlx5_debug_eq_remove(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
  907. int mlx5_core_eq_query(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
  908. u32 *out, int outlen);
  909. int mlx5_eq_debugfs_init(struct mlx5_core_dev *dev);
  910. void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev);
  911. int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev);
  912. void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev);
  913. int mlx5_db_alloc(struct mlx5_core_dev *dev, struct mlx5_db *db);
  914. int mlx5_db_alloc_node(struct mlx5_core_dev *dev, struct mlx5_db *db,
  915. int node);
  916. void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db);
  917. const char *mlx5_command_str(int command);
  918. int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev);
  919. void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev);
  920. int mlx5_core_create_psv(struct mlx5_core_dev *dev, u32 pdn,
  921. int npsvs, u32 *sig_index);
  922. int mlx5_core_destroy_psv(struct mlx5_core_dev *dev, int psv_num);
  923. void mlx5_core_put_rsc(struct mlx5_core_rsc_common *common);
  924. int mlx5_query_odp_caps(struct mlx5_core_dev *dev,
  925. struct mlx5_odp_caps *odp_caps);
  926. int mlx5_core_query_ib_ppcnt(struct mlx5_core_dev *dev,
  927. u8 port_num, void *out, size_t sz);
  928. #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
  929. int mlx5_core_page_fault_resume(struct mlx5_core_dev *dev, u32 token,
  930. u32 wq_num, u8 type, int error);
  931. #endif
  932. int mlx5_init_rl_table(struct mlx5_core_dev *dev);
  933. void mlx5_cleanup_rl_table(struct mlx5_core_dev *dev);
  934. int mlx5_rl_add_rate(struct mlx5_core_dev *dev, u32 rate, u16 *index);
  935. void mlx5_rl_remove_rate(struct mlx5_core_dev *dev, u32 rate);
  936. bool mlx5_rl_is_in_range(struct mlx5_core_dev *dev, u32 rate);
  937. int mlx5_alloc_bfreg(struct mlx5_core_dev *mdev, struct mlx5_sq_bfreg *bfreg,
  938. bool map_wc, bool fast_path);
  939. void mlx5_free_bfreg(struct mlx5_core_dev *mdev, struct mlx5_sq_bfreg *bfreg);
  940. unsigned int mlx5_core_reserved_gids_count(struct mlx5_core_dev *dev);
  941. int mlx5_core_roce_gid_set(struct mlx5_core_dev *dev, unsigned int index,
  942. u8 roce_version, u8 roce_l3_type, const u8 *gid,
  943. const u8 *mac, bool vlan, u16 vlan_id);
  944. static inline int fw_initializing(struct mlx5_core_dev *dev)
  945. {
  946. return ioread32be(&dev->iseg->initializing) >> 31;
  947. }
  948. static inline u32 mlx5_mkey_to_idx(u32 mkey)
  949. {
  950. return mkey >> 8;
  951. }
  952. static inline u32 mlx5_idx_to_mkey(u32 mkey_idx)
  953. {
  954. return mkey_idx << 8;
  955. }
  956. static inline u8 mlx5_mkey_variant(u32 mkey)
  957. {
  958. return mkey & 0xff;
  959. }
  960. enum {
  961. MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0,
  962. MLX5_PROF_MASK_MR_CACHE = (u64)1 << 1,
  963. };
  964. enum {
  965. MAX_UMR_CACHE_ENTRY = 20,
  966. MLX5_IMR_MTT_CACHE_ENTRY,
  967. MLX5_IMR_KSM_CACHE_ENTRY,
  968. MAX_MR_CACHE_ENTRIES
  969. };
  970. enum {
  971. MLX5_INTERFACE_PROTOCOL_IB = 0,
  972. MLX5_INTERFACE_PROTOCOL_ETH = 1,
  973. };
  974. struct mlx5_interface {
  975. void * (*add)(struct mlx5_core_dev *dev);
  976. void (*remove)(struct mlx5_core_dev *dev, void *context);
  977. int (*attach)(struct mlx5_core_dev *dev, void *context);
  978. void (*detach)(struct mlx5_core_dev *dev, void *context);
  979. void (*event)(struct mlx5_core_dev *dev, void *context,
  980. enum mlx5_dev_event event, unsigned long param);
  981. void (*pfault)(struct mlx5_core_dev *dev,
  982. void *context,
  983. struct mlx5_pagefault *pfault);
  984. void * (*get_dev)(void *context);
  985. int protocol;
  986. struct list_head list;
  987. };
  988. void *mlx5_get_protocol_dev(struct mlx5_core_dev *mdev, int protocol);
  989. int mlx5_register_interface(struct mlx5_interface *intf);
  990. void mlx5_unregister_interface(struct mlx5_interface *intf);
  991. int mlx5_core_query_vendor_id(struct mlx5_core_dev *mdev, u32 *vendor_id);
  992. int mlx5_cmd_create_vport_lag(struct mlx5_core_dev *dev);
  993. int mlx5_cmd_destroy_vport_lag(struct mlx5_core_dev *dev);
  994. bool mlx5_lag_is_active(struct mlx5_core_dev *dev);
  995. struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev);
  996. struct mlx5_uars_page *mlx5_get_uars_page(struct mlx5_core_dev *mdev);
  997. void mlx5_put_uars_page(struct mlx5_core_dev *mdev, struct mlx5_uars_page *up);
  998. #ifndef CONFIG_MLX5_CORE_IPOIB
  999. static inline
  1000. struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
  1001. struct ib_device *ibdev,
  1002. const char *name,
  1003. void (*setup)(struct net_device *))
  1004. {
  1005. return ERR_PTR(-EOPNOTSUPP);
  1006. }
  1007. static inline void mlx5_rdma_netdev_free(struct net_device *netdev) {}
  1008. #else
  1009. struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
  1010. struct ib_device *ibdev,
  1011. const char *name,
  1012. void (*setup)(struct net_device *));
  1013. void mlx5_rdma_netdev_free(struct net_device *netdev);
  1014. #endif /* CONFIG_MLX5_CORE_IPOIB */
  1015. struct mlx5_profile {
  1016. u64 mask;
  1017. u8 log_max_qp;
  1018. struct {
  1019. int size;
  1020. int limit;
  1021. } mr_cache[MAX_MR_CACHE_ENTRIES];
  1022. };
  1023. enum {
  1024. MLX5_PCI_DEV_IS_VF = 1 << 0,
  1025. };
  1026. static inline int mlx5_core_is_pf(struct mlx5_core_dev *dev)
  1027. {
  1028. return !(dev->priv.pci_dev_data & MLX5_PCI_DEV_IS_VF);
  1029. }
  1030. static inline int mlx5_get_gid_table_len(u16 param)
  1031. {
  1032. if (param > 4) {
  1033. pr_warn("gid table length is zero\n");
  1034. return 0;
  1035. }
  1036. return 8 * (1 << param);
  1037. }
  1038. static inline bool mlx5_rl_is_supported(struct mlx5_core_dev *dev)
  1039. {
  1040. return !!(dev->priv.rl_table.max_size);
  1041. }
  1042. enum {
  1043. MLX5_TRIGGERED_CMD_COMP = (u64)1 << 32,
  1044. };
  1045. #endif /* MLX5_DRIVER_H */