blob: 8f047f996e220a5e682eaca43cea24cfeb21e3f0 [file] [log] [blame]
Devesh Sharma71ee6732015-07-24 05:03:59 +05301/* This file is part of the Emulex RoCE Device Driver for
2 * RoCE (RDMA over Converged Ethernet) adapters.
3 * Copyright (C) 2012-2015 Emulex. All rights reserved.
4 * EMULEX and SLI are trademarks of Emulex.
5 * www.emulex.com
6 *
7 * This software is available to you under a choice of one of two licenses.
8 * You may choose to be licensed under the terms of the GNU General Public
9 * License (GPL) Version 2, available from the file COPYING in the main
10 * directory of this source tree, or the BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * - Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in
21 * the documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Parav Panditfe2caef2012-03-21 04:09:06 +053034 *
35 * Contact Information:
36 * linux-drivers@emulex.com
37 *
38 * Emulex
39 * 3333 Susan Street
40 * Costa Mesa, CA 92626
Devesh Sharma71ee6732015-07-24 05:03:59 +053041 */
Parav Panditfe2caef2012-03-21 04:09:06 +053042
43#ifndef __OCRDMA_H__
44#define __OCRDMA_H__
45
46#include <linux/mutex.h>
47#include <linux/list.h>
48#include <linux/spinlock.h>
49#include <linux/pci.h>
50
51#include <rdma/ib_verbs.h>
52#include <rdma/ib_user_verbs.h>
Devesh Sharmafad51b72014-02-04 11:57:10 +053053#include <rdma/ib_addr.h>
Parav Panditfe2caef2012-03-21 04:09:06 +053054
55#include <be_roce.h>
56#include "ocrdma_sli.h"
57
Selvin Xavierc6a7b0d2015-10-20 14:18:00 +053058#define OCRDMA_ROCE_DRV_VERSION "11.0.0.0"
Devesh Sharma01544102014-02-04 11:57:00 +053059
60#define OCRDMA_ROCE_DRV_DESC "Emulex OneConnect RoCE Driver"
Parav Panditfe2caef2012-03-21 04:09:06 +053061#define OCRDMA_NODE_DESC "Emulex OneConnect RoCE HCA"
62
Selvin Xaviera51f06e2014-02-04 11:57:07 +053063#define OC_NAME_SH OCRDMA_NODE_DESC "(Skyhawk)"
64#define OC_NAME_UNKNOWN OCRDMA_NODE_DESC "(Unknown)"
65
66#define OC_SKH_DEVICE_PF 0x720
67#define OC_SKH_DEVICE_VF 0x728
Parav Panditfe2caef2012-03-21 04:09:06 +053068#define OCRDMA_MAX_AH 512
69
70#define OCRDMA_UVERBS(CMD_NAME) (1ull << IB_USER_VERBS_CMD_##CMD_NAME)
71
Selvin Xaviera51f06e2014-02-04 11:57:07 +053072#define convert_to_64bit(lo, hi) ((u64)hi << 32 | (u64)lo)
Mitesh Ahujab4dbe8d2014-12-18 14:13:05 +053073#define EQ_INTR_PER_SEC_THRSH_HI 150000
74#define EQ_INTR_PER_SEC_THRSH_LOW 100000
75#define EQ_AIC_MAX_EQD 20
76#define EQ_AIC_MIN_EQD 0
77
78void ocrdma_eqd_set_task(struct work_struct *work);
Selvin Xaviera51f06e2014-02-04 11:57:07 +053079
Parav Panditfe2caef2012-03-21 04:09:06 +053080struct ocrdma_dev_attr {
81 u8 fw_ver[32];
82 u32 vendor_id;
83 u32 device_id;
84 u16 max_pd;
Mitesh Ahuja9ba13772014-12-18 14:12:57 +053085 u16 max_dpp_pds;
Parav Panditfe2caef2012-03-21 04:09:06 +053086 u16 max_cq;
87 u16 max_cqe;
88 u16 max_qp;
89 u16 max_wqe;
90 u16 max_rqe;
Naresh Gottumukkala7c338802013-08-26 15:27:39 +053091 u16 max_srq;
Parav Panditfe2caef2012-03-21 04:09:06 +053092 u32 max_inline_data;
93 int max_send_sge;
94 int max_recv_sge;
Mahesh Vardhamanaiah634c5792012-06-08 21:26:11 +053095 int max_srq_sge;
Naresh Gottumukkala45e86b32013-08-07 12:52:37 +053096 int max_rdma_sge;
Parav Panditfe2caef2012-03-21 04:09:06 +053097 int max_mr;
98 u64 max_mr_size;
99 u32 max_num_mr_pbl;
Selvin Xavierac578ae2014-02-04 11:57:04 +0530100 int max_mw;
Parav Panditfe2caef2012-03-21 04:09:06 +0530101 int max_fmr;
102 int max_map_per_fmr;
103 int max_pages_per_frmr;
104 u16 max_ord_per_qp;
105 u16 max_ird_per_qp;
106
107 int device_cap_flags;
108 u8 cq_overflow_detect;
109 u8 srq_supported;
110
111 u32 wqe_size;
112 u32 rqe_size;
113 u32 ird_page_size;
114 u8 local_ca_ack_delay;
115 u8 ird;
116 u8 num_ird_pages;
117};
118
Selvin Xaviera51f06e2014-02-04 11:57:07 +0530119struct ocrdma_dma_mem {
120 void *va;
121 dma_addr_t pa;
122 u32 size;
123};
124
Parav Panditfe2caef2012-03-21 04:09:06 +0530125struct ocrdma_pbl {
126 void *va;
127 dma_addr_t pa;
128};
129
130struct ocrdma_queue_info {
131 void *va;
132 dma_addr_t dma;
133 u32 size;
134 u16 len;
135 u16 entry_size; /* Size of an element in the queue */
136 u16 id; /* qid, where to ring the doorbell. */
137 u16 head, tail;
138 bool created;
Parav Panditfe2caef2012-03-21 04:09:06 +0530139};
140
Mitesh Ahujab4dbe8d2014-12-18 14:13:05 +0530141struct ocrdma_aic_obj { /* Adaptive interrupt coalescing (AIC) info */
142 u32 prev_eqd;
143 u64 eq_intr_cnt;
144 u64 prev_eq_intr_cnt;
145};
146
Parav Panditfe2caef2012-03-21 04:09:06 +0530147struct ocrdma_eq {
148 struct ocrdma_queue_info q;
149 u32 vector;
150 int cq_cnt;
151 struct ocrdma_dev *dev;
152 char irq_name[32];
Mitesh Ahujab4dbe8d2014-12-18 14:13:05 +0530153 struct ocrdma_aic_obj aic_obj;
Parav Panditfe2caef2012-03-21 04:09:06 +0530154};
155
156struct ocrdma_mq {
157 struct ocrdma_queue_info sq;
158 struct ocrdma_queue_info cq;
159 bool rearm_cq;
160};
161
162struct mqe_ctx {
163 struct mutex lock; /* for serializing mailbox commands on MQ */
164 wait_queue_head_t cmd_wait;
165 u32 tag;
166 u16 cqe_status;
167 u16 ext_status;
168 bool cmd_done;
Mitesh Ahuja6dab0262014-06-10 19:32:21 +0530169 bool fw_error_state;
Parav Panditfe2caef2012-03-21 04:09:06 +0530170};
171
Naresh Gottumukkala1852d1d2013-09-06 15:02:47 +0530172struct ocrdma_hw_mr {
173 u32 lkey;
174 u8 fr_mr;
175 u8 remote_atomic;
176 u8 remote_rd;
177 u8 remote_wr;
178 u8 local_rd;
179 u8 local_wr;
180 u8 mw_bind;
181 u8 rsvd;
182 u64 len;
183 struct ocrdma_pbl *pbl_table;
184 u32 num_pbls;
185 u32 num_pbes;
186 u32 pbl_size;
187 u32 pbe_size;
188 u64 fbo;
189 u64 va;
190};
191
192struct ocrdma_mr {
193 struct ib_mr ibmr;
194 struct ib_umem *umem;
195 struct ocrdma_hw_mr hwmr;
196};
197
Selvin Xaviera51f06e2014-02-04 11:57:07 +0530198struct ocrdma_stats {
199 u8 type;
200 struct ocrdma_dev *dev;
201};
202
Mitesh Ahuja9ba13772014-12-18 14:12:57 +0530203struct ocrdma_pd_resource_mgr {
204 u32 pd_norm_start;
205 u16 pd_norm_count;
206 u16 pd_norm_thrsh;
207 u16 max_normal_pd;
208 u32 pd_dpp_start;
209 u16 pd_dpp_count;
210 u16 pd_dpp_thrsh;
211 u16 max_dpp_pd;
212 u16 dpp_page_index;
213 unsigned long *pd_norm_bitmap;
214 unsigned long *pd_dpp_bitmap;
215 bool pd_prealloc_valid;
216};
217
Selvin Xaviera51f06e2014-02-04 11:57:07 +0530218struct stats_mem {
219 struct ocrdma_mqe mqe;
220 void *va;
221 dma_addr_t pa;
222 u32 size;
223 char *debugfs_mem;
224};
225
226struct phy_info {
227 u16 auto_speeds_supported;
228 u16 fixed_speeds_supported;
229 u16 phy_type;
230 u16 interface_type;
231};
232
Parav Panditfe2caef2012-03-21 04:09:06 +0530233struct ocrdma_dev {
234 struct ib_device ibdev;
235 struct ocrdma_dev_attr attr;
236
237 struct mutex dev_lock; /* provides syncronise access to device data */
238 spinlock_t flush_q_lock ____cacheline_aligned;
239
240 struct ocrdma_cq **cq_tbl;
241 struct ocrdma_qp **qp_tbl;
242
Naresh Gottumukkalac88bd032013-08-26 15:27:41 +0530243 struct ocrdma_eq *eq_tbl;
Parav Panditfe2caef2012-03-21 04:09:06 +0530244 int eq_cnt;
Mitesh Ahujab4dbe8d2014-12-18 14:13:05 +0530245 struct delayed_work eqd_work;
Parav Panditfe2caef2012-03-21 04:09:06 +0530246 u16 base_eqid;
247 u16 max_eq;
248
Parav Panditfe2caef2012-03-21 04:09:06 +0530249 /* provided synchronization to sgid table for
250 * updating gid entries triggered by notifier.
251 */
252 spinlock_t sgid_lock;
253
254 int gsi_qp_created;
255 struct ocrdma_cq *gsi_sqcq;
256 struct ocrdma_cq *gsi_rqcq;
257
258 struct {
259 struct ocrdma_av *va;
260 dma_addr_t pa;
261 u32 size;
262 u32 num_ah;
263 /* provide synchronization for av
264 * entry allocations.
265 */
266 spinlock_t lock;
267 u32 ahid;
268 struct ocrdma_pbl pbl;
269 } av_tbl;
270
271 void *mbx_cmd;
272 struct ocrdma_mq mq;
273 struct mqe_ctx mqe_ctx;
274
275 struct be_dev_info nic_info;
Selvin Xaviera51f06e2014-02-04 11:57:07 +0530276 struct phy_info phy;
277 char model_number[32];
278 u32 hba_port_num;
Parav Panditfe2caef2012-03-21 04:09:06 +0530279
280 struct list_head entry;
Parav Panditfe2caef2012-03-21 04:09:06 +0530281 int id;
Selvin Xavier4f1df842014-06-10 19:32:24 +0530282 u64 *stag_arr;
Selvin Xavier31dbdd92014-06-10 19:32:13 +0530283 u8 sl; /* service level */
284 bool pfc_state;
285 atomic_t update_sl;
Naresh Gottumukkala84b105d2013-08-26 15:27:50 +0530286 u16 pvid;
Devesh Sharma21c33912014-02-04 11:56:56 +0530287 u32 asic_id;
Selvin Xaviera51f06e2014-02-04 11:57:07 +0530288
289 ulong last_stats_time;
290 struct mutex stats_lock; /* provide synch for debugfs operations */
291 struct stats_mem stats_mem;
292 struct ocrdma_stats rsrc_stats;
293 struct ocrdma_stats rx_stats;
294 struct ocrdma_stats wqe_stats;
295 struct ocrdma_stats tx_stats;
296 struct ocrdma_stats db_err_stats;
297 struct ocrdma_stats tx_qp_err_stats;
298 struct ocrdma_stats rx_qp_err_stats;
299 struct ocrdma_stats tx_dbg_stats;
300 struct ocrdma_stats rx_dbg_stats;
Selvin Xavierad56ebb2014-12-18 14:12:59 +0530301 struct ocrdma_stats driver_stats;
302 struct ocrdma_stats reset_stats;
Selvin Xaviera51f06e2014-02-04 11:57:07 +0530303 struct dentry *dir;
Selvin Xavierad56ebb2014-12-18 14:12:59 +0530304 atomic_t async_err_stats[OCRDMA_MAX_ASYNC_ERRORS];
305 atomic_t cqe_err_stats[OCRDMA_MAX_CQE_ERR];
Mitesh Ahuja9ba13772014-12-18 14:12:57 +0530306 struct ocrdma_pd_resource_mgr *pd_mgr;
Parav Panditfe2caef2012-03-21 04:09:06 +0530307};
308
309struct ocrdma_cq {
310 struct ib_cq ibcq;
Parav Panditfe2caef2012-03-21 04:09:06 +0530311 struct ocrdma_cqe *va;
312 u32 phase;
313 u32 getp; /* pointer to pending wrs to
314 * return to stack, wrap arounds
315 * at max_hw_cqe
316 */
317 u32 max_hw_cqe;
318 bool phase_change;
Devesh Sharmaea617622014-02-04 11:56:54 +0530319 bool deferred_arm, deferred_sol;
320 bool first_arm;
Parav Panditfe2caef2012-03-21 04:09:06 +0530321
322 spinlock_t cq_lock ____cacheline_aligned; /* provide synchronization
323 * to cq polling
324 */
325 /* syncronizes cq completion handler invoked from multiple context */
326 spinlock_t comp_handler_lock ____cacheline_aligned;
327 u16 id;
328 u16 eqn;
329
330 struct ocrdma_ucontext *ucontext;
331 dma_addr_t pa;
332 u32 len;
Devesh Sharmaea617622014-02-04 11:56:54 +0530333 u32 cqe_cnt;
Parav Panditfe2caef2012-03-21 04:09:06 +0530334
335 /* head of all qp's sq and rq for which cqes need to be flushed
336 * by the software.
337 */
338 struct list_head sq_head, rq_head;
339};
340
341struct ocrdma_pd {
342 struct ib_pd ibpd;
Parav Panditfe2caef2012-03-21 04:09:06 +0530343 struct ocrdma_ucontext *uctx;
Parav Panditfe2caef2012-03-21 04:09:06 +0530344 u32 id;
345 int num_dpp_qp;
346 u32 dpp_page;
347 bool dpp_enabled;
348};
349
350struct ocrdma_ah {
351 struct ib_ah ibah;
Parav Panditfe2caef2012-03-21 04:09:06 +0530352 struct ocrdma_av *av;
353 u16 sgid_index;
354 u32 id;
355};
356
357struct ocrdma_qp_hwq_info {
358 u8 *va; /* virtual address */
359 u32 max_sges;
360 u32 head, tail;
361 u32 entry_size;
362 u32 max_cnt;
363 u32 max_wqe_idx;
Parav Panditfe2caef2012-03-21 04:09:06 +0530364 u16 dbid; /* qid, where to ring the doorbell. */
365 u32 len;
366 dma_addr_t pa;
367};
368
369struct ocrdma_srq {
370 struct ib_srq ibsrq;
Parav Panditfe2caef2012-03-21 04:09:06 +0530371 u8 __iomem *db;
Parav Panditfe2caef2012-03-21 04:09:06 +0530372 struct ocrdma_qp_hwq_info rq;
Parav Panditfe2caef2012-03-21 04:09:06 +0530373 u64 *rqe_wr_id_tbl;
374 u32 *idx_bit_fields;
375 u32 bit_fields_len;
Naresh Gottumukkala9884bcd2013-06-10 04:42:42 +0000376
377 /* provide synchronization to multiple context(s) posting rqe */
378 spinlock_t q_lock ____cacheline_aligned;
379
380 struct ocrdma_pd *pd;
381 u32 id;
Parav Panditfe2caef2012-03-21 04:09:06 +0530382};
383
384struct ocrdma_qp {
385 struct ib_qp ibqp;
Parav Panditfe2caef2012-03-21 04:09:06 +0530386
387 u8 __iomem *sq_db;
Parav Panditfe2caef2012-03-21 04:09:06 +0530388 struct ocrdma_qp_hwq_info sq;
389 struct {
390 uint64_t wrid;
391 uint16_t dpp_wqe_idx;
392 uint16_t dpp_wqe;
393 uint8_t signaled;
394 uint8_t rsvd[3];
395 } *wqe_wr_id_tbl;
396 u32 max_inline_data;
Naresh Gottumukkala9884bcd2013-06-10 04:42:42 +0000397
398 /* provide synchronization to multiple context(s) posting wqe, rqe */
399 spinlock_t q_lock ____cacheline_aligned;
Parav Panditfe2caef2012-03-21 04:09:06 +0530400 struct ocrdma_cq *sq_cq;
401 /* list maintained per CQ to flush SQ errors */
402 struct list_head sq_entry;
403
404 u8 __iomem *rq_db;
405 struct ocrdma_qp_hwq_info rq;
406 u64 *rqe_wr_id_tbl;
407 struct ocrdma_cq *rq_cq;
408 struct ocrdma_srq *srq;
409 /* list maintained per CQ to flush RQ errors */
410 struct list_head rq_entry;
411
412 enum ocrdma_qp_state state; /* QP state */
413 int cap_flags;
414 u32 max_ord, max_ird;
415
416 u32 id;
417 struct ocrdma_pd *pd;
418
419 enum ib_qp_type qp_type;
420
421 int sgid_idx;
422 u32 qkey;
423 bool dpp_enabled;
424 u8 *ird_q_va;
Naresh Gottumukkala2b51a9b2013-08-26 15:27:43 +0530425 bool signaled;
Parav Panditfe2caef2012-03-21 04:09:06 +0530426};
427
Parav Panditfe2caef2012-03-21 04:09:06 +0530428struct ocrdma_ucontext {
429 struct ib_ucontext ibucontext;
Parav Panditfe2caef2012-03-21 04:09:06 +0530430
431 struct list_head mm_head;
432 struct mutex mm_list_lock; /* protects list entries of mm type */
Naresh Gottumukkalacffce992013-08-26 15:27:44 +0530433 struct ocrdma_pd *cntxt_pd;
434 int pd_in_use;
435
Parav Panditfe2caef2012-03-21 04:09:06 +0530436 struct {
437 u32 *va;
438 dma_addr_t pa;
439 u32 len;
440 } ah_tbl;
441};
442
443struct ocrdma_mm {
444 struct {
445 u64 phy_addr;
446 unsigned long len;
447 } key;
448 struct list_head entry;
449};
450
451static inline struct ocrdma_dev *get_ocrdma_dev(struct ib_device *ibdev)
452{
453 return container_of(ibdev, struct ocrdma_dev, ibdev);
454}
455
456static inline struct ocrdma_ucontext *get_ocrdma_ucontext(struct ib_ucontext
457 *ibucontext)
458{
459 return container_of(ibucontext, struct ocrdma_ucontext, ibucontext);
460}
461
462static inline struct ocrdma_pd *get_ocrdma_pd(struct ib_pd *ibpd)
463{
464 return container_of(ibpd, struct ocrdma_pd, ibpd);
465}
466
467static inline struct ocrdma_cq *get_ocrdma_cq(struct ib_cq *ibcq)
468{
469 return container_of(ibcq, struct ocrdma_cq, ibcq);
470}
471
472static inline struct ocrdma_qp *get_ocrdma_qp(struct ib_qp *ibqp)
473{
474 return container_of(ibqp, struct ocrdma_qp, ibqp);
475}
476
477static inline struct ocrdma_mr *get_ocrdma_mr(struct ib_mr *ibmr)
478{
479 return container_of(ibmr, struct ocrdma_mr, ibmr);
480}
481
482static inline struct ocrdma_ah *get_ocrdma_ah(struct ib_ah *ibah)
483{
484 return container_of(ibah, struct ocrdma_ah, ibah);
485}
486
487static inline struct ocrdma_srq *get_ocrdma_srq(struct ib_srq *ibsrq)
488{
489 return container_of(ibsrq, struct ocrdma_srq, ibsrq);
490}
491
Naresh Gottumukkaladf176ea2013-06-10 04:42:41 +0000492static inline int is_cqe_valid(struct ocrdma_cq *cq, struct ocrdma_cqe *cqe)
493{
494 int cqe_valid;
495 cqe_valid = le32_to_cpu(cqe->flags_status_srcqpn) & OCRDMA_CQE_VALID;
Naresh Gottumukkalaf99b1642013-08-07 12:52:32 +0530496 return (cqe_valid == cq->phase);
Naresh Gottumukkaladf176ea2013-06-10 04:42:41 +0000497}
498
499static inline int is_cqe_for_sq(struct ocrdma_cqe *cqe)
500{
501 return (le32_to_cpu(cqe->flags_status_srcqpn) &
502 OCRDMA_CQE_QTYPE) ? 0 : 1;
503}
504
505static inline int is_cqe_invalidated(struct ocrdma_cqe *cqe)
506{
507 return (le32_to_cpu(cqe->flags_status_srcqpn) &
508 OCRDMA_CQE_INVALIDATE) ? 1 : 0;
509}
510
511static inline int is_cqe_imm(struct ocrdma_cqe *cqe)
512{
513 return (le32_to_cpu(cqe->flags_status_srcqpn) &
514 OCRDMA_CQE_IMM) ? 1 : 0;
515}
516
517static inline int is_cqe_wr_imm(struct ocrdma_cqe *cqe)
518{
519 return (le32_to_cpu(cqe->flags_status_srcqpn) &
520 OCRDMA_CQE_WRITE_IMM) ? 1 : 0;
521}
522
Moni Shoua40aca6f2013-12-12 18:03:15 +0200523static inline int ocrdma_resolve_dmac(struct ocrdma_dev *dev,
524 struct ib_ah_attr *ah_attr, u8 *mac_addr)
525{
526 struct in6_addr in6;
527
528 memcpy(&in6, ah_attr->grh.dgid.raw, sizeof(in6));
529 if (rdma_is_multicast_addr(&in6))
530 rdma_get_mcast_mac(&in6, mac_addr);
Mitesh Ahujad27b2f12015-05-19 11:32:38 +0530531 else if (rdma_link_local_addr(&in6))
532 rdma_get_ll_mac(&in6, mac_addr);
Moni Shoua40aca6f2013-12-12 18:03:15 +0200533 else
534 memcpy(mac_addr, ah_attr->dmac, ETH_ALEN);
535 return 0;
536}
Naresh Gottumukkaladf176ea2013-06-10 04:42:41 +0000537
Selvin Xaviera51f06e2014-02-04 11:57:07 +0530538static inline char *hca_name(struct ocrdma_dev *dev)
539{
540 switch (dev->nic_info.pdev->device) {
541 case OC_SKH_DEVICE_PF:
542 case OC_SKH_DEVICE_VF:
543 return OC_NAME_SH;
544 default:
545 return OC_NAME_UNKNOWN;
546 }
547}
548
Devesh Sharmaea617622014-02-04 11:56:54 +0530549static inline int ocrdma_get_eq_table_index(struct ocrdma_dev *dev,
550 int eqid)
551{
552 int indx;
553
554 for (indx = 0; indx < dev->eq_cnt; indx++) {
555 if (dev->eq_tbl[indx].q.id == eqid)
556 return indx;
557 }
558
559 return -EINVAL;
560}
561
Devesh Sharma21c33912014-02-04 11:56:56 +0530562static inline u8 ocrdma_get_asic_type(struct ocrdma_dev *dev)
563{
564 if (dev->nic_info.dev_family == 0xF && !dev->asic_id) {
565 pci_read_config_dword(
566 dev->nic_info.pdev,
567 OCRDMA_SLI_ASIC_ID_OFFSET, &dev->asic_id);
568 }
569
570 return (dev->asic_id & OCRDMA_SLI_ASIC_GEN_NUM_MASK) >>
571 OCRDMA_SLI_ASIC_GEN_NUM_SHIFT;
572}
573
Selvin Xavier31dbdd92014-06-10 19:32:13 +0530574static inline u8 ocrdma_get_pfc_prio(u8 *pfc, u8 prio)
575{
576 return *(pfc + prio);
577}
578
579static inline u8 ocrdma_get_app_prio(u8 *app_prio, u8 prio)
580{
581 return *(app_prio + prio);
582}
583
584static inline u8 ocrdma_is_enabled_and_synced(u32 state)
585{ /* May also be used to interpret TC-state, QCN-state
586 * Appl-state and Logical-link-state in future.
587 */
588 return (state & OCRDMA_STATE_FLAG_ENABLED) &&
589 (state & OCRDMA_STATE_FLAG_SYNC);
590}
591
Parav Panditfe2caef2012-03-21 04:09:06 +0530592#endif