blob: ca32057e886f00af4287cbe586c81866a3367ae4 [file] [log] [blame]
Selvin Xavier1ac5a402017-02-10 03:19:33 -08001/*
2 * Broadcom NetXtreme-E RoCE driver.
3 *
4 * Copyright (c) 2016 - 2017, Broadcom. All rights reserved. The term
5 * Broadcom refers to Broadcom Limited and/or its subsidiaries.
6 *
7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * BSD license below:
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. 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
22 * distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 * Description: Slow Path Operators (header)
37 *
38 */
39
40#ifndef __BNXT_RE_H__
41#define __BNXT_RE_H__
42#define ROCE_DRV_MODULE_NAME "bnxt_re"
43#define ROCE_DRV_MODULE_VERSION "1.0.0"
44
45#define BNXT_RE_DESC "Broadcom NetXtreme-C/E RoCE Driver"
Somnath Kotur872f3572018-01-11 11:52:09 -050046#define BNXT_RE_PAGE_SHIFT_4K (12)
47#define BNXT_RE_PAGE_SHIFT_8K (13)
48#define BNXT_RE_PAGE_SHIFT_64K (16)
49#define BNXT_RE_PAGE_SHIFT_2M (21)
50#define BNXT_RE_PAGE_SHIFT_8M (23)
51#define BNXT_RE_PAGE_SHIFT_1G (30)
Selvin Xavier1ac5a402017-02-10 03:19:33 -080052
Somnath Kotur872f3572018-01-11 11:52:09 -050053#define BNXT_RE_PAGE_SIZE_4K BIT(BNXT_RE_PAGE_SHIFT_4K)
54#define BNXT_RE_PAGE_SIZE_8K BIT(BNXT_RE_PAGE_SHIFT_8K)
55#define BNXT_RE_PAGE_SIZE_64K BIT(BNXT_RE_PAGE_SHIFT_64K)
56#define BNXT_RE_PAGE_SIZE_2M BIT(BNXT_RE_PAGE_SHIFT_2M)
57#define BNXT_RE_PAGE_SIZE_8M BIT(BNXT_RE_PAGE_SHIFT_8M)
58#define BNXT_RE_PAGE_SIZE_1G BIT(BNXT_RE_PAGE_SHIFT_1G)
Selvin Xavier1ac5a402017-02-10 03:19:33 -080059
Somnath Kotur872f3572018-01-11 11:52:09 -050060#define BNXT_RE_MAX_MR_SIZE_LOW BIT(BNXT_RE_PAGE_SHIFT_1G)
61#define BNXT_RE_MAX_MR_SIZE_HIGH BIT(39)
62#define BNXT_RE_MAX_MR_SIZE BNXT_RE_MAX_MR_SIZE_HIGH
Selvin Xavier58d4a672017-06-29 12:28:12 -070063
Selvin Xavier1ac5a402017-02-10 03:19:33 -080064#define BNXT_RE_MAX_QPC_COUNT (64 * 1024)
65#define BNXT_RE_MAX_MRW_COUNT (64 * 1024)
66#define BNXT_RE_MAX_SRQC_COUNT (64 * 1024)
67#define BNXT_RE_MAX_CQ_COUNT (64 * 1024)
Selvin Xavierccd9d0d2018-01-11 11:52:07 -050068#define BNXT_RE_MAX_MRW_COUNT_64K (64 * 1024)
69#define BNXT_RE_MAX_MRW_COUNT_256K (256 * 1024)
70
71/* Number of MRs to reserve for PF, leaving remainder for VFs */
72#define BNXT_RE_RESVD_MR_FOR_PF (32 * 1024)
73#define BNXT_RE_MAX_GID_PER_VF 128
74
75/*
76 * Percentage of resources of each type reserved for PF.
77 * Remaining resources are divided equally among VFs.
78 * [0, 100]
79 */
80#define BNXT_RE_PCT_RSVD_FOR_PF 50
Selvin Xavier1ac5a402017-02-10 03:19:33 -080081
Somnath Kotur3fb755b2017-05-22 03:15:36 -070082#define BNXT_RE_UD_QP_HW_STALL 0x400000
83
Devesh Sharma018cf592017-05-22 03:15:40 -070084#define BNXT_RE_RQ_WQE_THRESHOLD 32
85
Selvin Xavier601577b2017-06-29 12:28:19 -070086/*
87 * Setting the default ack delay value to 16, which means
88 * the default timeout is approx. 260ms(4 usec * 2 ^(timeout))
89 */
90
91#define BNXT_RE_DEFAULT_ACK_DELAY 16
92
Selvin Xavier1ac5a402017-02-10 03:19:33 -080093struct bnxt_re_work {
94 struct work_struct work;
95 unsigned long event;
96 struct bnxt_re_dev *rdev;
97 struct net_device *vlan_dev;
98};
99
100struct bnxt_re_sqp_entries {
101 struct bnxt_qplib_sge sge;
102 u64 wrid;
103 /* For storing the actual qp1 cqe */
104 struct bnxt_qplib_cqe cqe;
105 struct bnxt_re_qp *qp1_qp;
106};
107
108#define BNXT_RE_MIN_MSIX 2
Selvin Xavier6a5df912017-08-02 01:46:18 -0700109#define BNXT_RE_MAX_MSIX 9
Selvin Xavier1ac5a402017-02-10 03:19:33 -0800110#define BNXT_RE_AEQ_IDX 0
111#define BNXT_RE_NQ_IDX 1
112
113struct bnxt_re_dev {
114 struct ib_device ibdev;
115 struct list_head list;
116 unsigned long flags;
Somnath Koturd5917302017-08-31 09:27:32 +0530117#define BNXT_RE_FLAG_NETDEV_REGISTERED 0
118#define BNXT_RE_FLAG_IBDEV_REGISTERED 1
119#define BNXT_RE_FLAG_GOT_MSIX 2
120#define BNXT_RE_FLAG_HAVE_L2_REF 3
121#define BNXT_RE_FLAG_RCFW_CHANNEL_EN 4
122#define BNXT_RE_FLAG_QOS_WORK_REG 5
123#define BNXT_RE_FLAG_TASK_IN_PROG 6
Selvin Xavier89f81002018-01-11 11:52:10 -0500124#define BNXT_RE_FLAG_ISSUE_ROCE_STATS 29
Selvin Xavier1ac5a402017-02-10 03:19:33 -0800125 struct net_device *netdev;
126 unsigned int version, major, minor;
127 struct bnxt_en_dev *en_dev;
128 struct bnxt_msix_entry msix_entries[BNXT_RE_MAX_MSIX];
129 int num_msix;
130
131 int id;
132
133 struct delayed_work worker;
134 u8 cur_prio_map;
Somnath Kotur74828b12017-08-31 09:27:33 +0530135 u8 active_speed;
136 u8 active_width;
Selvin Xavier1ac5a402017-02-10 03:19:33 -0800137
138 /* FP Notification Queue (CQ & SRQ) */
139 struct tasklet_struct nq_task;
140
141 /* RCFW Channel */
142 struct bnxt_qplib_rcfw rcfw;
143
144 /* NQ */
Selvin Xavier6a5df912017-08-02 01:46:18 -0700145 struct bnxt_qplib_nq nq[BNXT_RE_MAX_MSIX];
Selvin Xavier1ac5a402017-02-10 03:19:33 -0800146
147 /* Device Resources */
148 struct bnxt_qplib_dev_attr dev_attr;
149 struct bnxt_qplib_ctx qplib_ctx;
150 struct bnxt_qplib_res qplib_res;
151 struct bnxt_qplib_dpi dpi_privileged;
152
153 atomic_t qp_count;
154 struct mutex qp_lock; /* protect qp list */
155 struct list_head qp_list;
156
157 atomic_t cq_count;
158 atomic_t srq_count;
159 atomic_t mr_count;
160 atomic_t mw_count;
161 /* Max of 2 lossless traffic class supported per port */
162 u16 cosq[2];
163
164 /* QP for for handling QP1 packets */
165 u32 sqp_id;
166 struct bnxt_re_qp *qp1_sqp;
167 struct bnxt_re_ah *sqp_ah;
168 struct bnxt_re_sqp_entries sqp_tbl[1024];
Selvin Xavier6a5df912017-08-02 01:46:18 -0700169 atomic_t nq_alloc_cnt;
Selvin Xavierccd9d0d2018-01-11 11:52:07 -0500170 u32 is_virtfn;
171 u32 num_vfs;
Selvin Xavier89f81002018-01-11 11:52:10 -0500172 struct bnxt_qplib_roce_stats stats;
Selvin Xavier1ac5a402017-02-10 03:19:33 -0800173};
174
175#define to_bnxt_re_dev(ptr, member) \
176 container_of((ptr), struct bnxt_re_dev, member)
177
178#define BNXT_RE_ROCE_V1_PACKET 0
179#define BNXT_RE_ROCEV2_IPV4_PACKET 2
180#define BNXT_RE_ROCEV2_IPV6_PACKET 3
181
182static inline struct device *rdev_to_dev(struct bnxt_re_dev *rdev)
183{
184 if (rdev)
185 return &rdev->ibdev.dev;
186 return NULL;
187}
188
189#endif