Commit | Line | Data |
---|---|---|
1ac5a404 SX |
1 | /* |
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" | |
46 | ||
47 | #define BNXT_RE_PAGE_SIZE_4K BIT(12) | |
48 | #define BNXT_RE_PAGE_SIZE_8K BIT(13) | |
49 | #define BNXT_RE_PAGE_SIZE_64K BIT(16) | |
50 | #define BNXT_RE_PAGE_SIZE_2M BIT(21) | |
51 | #define BNXT_RE_PAGE_SIZE_8M BIT(23) | |
52 | #define BNXT_RE_PAGE_SIZE_1G BIT(30) | |
53 | ||
58d4a671 SX |
54 | #define BNXT_RE_MAX_MR_SIZE BIT(30) |
55 | ||
1ac5a404 SX |
56 | #define BNXT_RE_MAX_QPC_COUNT (64 * 1024) |
57 | #define BNXT_RE_MAX_MRW_COUNT (64 * 1024) | |
58 | #define BNXT_RE_MAX_SRQC_COUNT (64 * 1024) | |
59 | #define BNXT_RE_MAX_CQ_COUNT (64 * 1024) | |
60 | ||
3fb755b3 SK |
61 | #define BNXT_RE_UD_QP_HW_STALL 0x400000 |
62 | ||
018cf599 DS |
63 | #define BNXT_RE_RQ_WQE_THRESHOLD 32 |
64 | ||
601577b7 SX |
65 | /* |
66 | * Setting the default ack delay value to 16, which means | |
67 | * the default timeout is approx. 260ms(4 usec * 2 ^(timeout)) | |
68 | */ | |
69 | ||
70 | #define BNXT_RE_DEFAULT_ACK_DELAY 16 | |
71 | ||
1ac5a404 SX |
72 | struct bnxt_re_work { |
73 | struct work_struct work; | |
74 | unsigned long event; | |
75 | struct bnxt_re_dev *rdev; | |
76 | struct net_device *vlan_dev; | |
77 | }; | |
78 | ||
79 | struct bnxt_re_sqp_entries { | |
80 | struct bnxt_qplib_sge sge; | |
81 | u64 wrid; | |
82 | /* For storing the actual qp1 cqe */ | |
83 | struct bnxt_qplib_cqe cqe; | |
84 | struct bnxt_re_qp *qp1_qp; | |
85 | }; | |
86 | ||
87 | #define BNXT_RE_MIN_MSIX 2 | |
88 | #define BNXT_RE_MAX_MSIX 16 | |
89 | #define BNXT_RE_AEQ_IDX 0 | |
90 | #define BNXT_RE_NQ_IDX 1 | |
91 | ||
92 | struct bnxt_re_dev { | |
93 | struct ib_device ibdev; | |
94 | struct list_head list; | |
95 | unsigned long flags; | |
96 | #define BNXT_RE_FLAG_NETDEV_REGISTERED 0 | |
97 | #define BNXT_RE_FLAG_IBDEV_REGISTERED 1 | |
98 | #define BNXT_RE_FLAG_GOT_MSIX 2 | |
99 | #define BNXT_RE_FLAG_RCFW_CHANNEL_EN 8 | |
100 | #define BNXT_RE_FLAG_QOS_WORK_REG 16 | |
101 | struct net_device *netdev; | |
102 | unsigned int version, major, minor; | |
103 | struct bnxt_en_dev *en_dev; | |
104 | struct bnxt_msix_entry msix_entries[BNXT_RE_MAX_MSIX]; | |
105 | int num_msix; | |
106 | ||
107 | int id; | |
108 | ||
109 | struct delayed_work worker; | |
110 | u8 cur_prio_map; | |
111 | ||
112 | /* FP Notification Queue (CQ & SRQ) */ | |
113 | struct tasklet_struct nq_task; | |
114 | ||
115 | /* RCFW Channel */ | |
116 | struct bnxt_qplib_rcfw rcfw; | |
117 | ||
118 | /* NQ */ | |
119 | struct bnxt_qplib_nq nq; | |
120 | ||
121 | /* Device Resources */ | |
122 | struct bnxt_qplib_dev_attr dev_attr; | |
123 | struct bnxt_qplib_ctx qplib_ctx; | |
124 | struct bnxt_qplib_res qplib_res; | |
125 | struct bnxt_qplib_dpi dpi_privileged; | |
126 | ||
127 | atomic_t qp_count; | |
128 | struct mutex qp_lock; /* protect qp list */ | |
129 | struct list_head qp_list; | |
130 | ||
131 | atomic_t cq_count; | |
132 | atomic_t srq_count; | |
133 | atomic_t mr_count; | |
134 | atomic_t mw_count; | |
135 | /* Max of 2 lossless traffic class supported per port */ | |
136 | u16 cosq[2]; | |
137 | ||
138 | /* QP for for handling QP1 packets */ | |
139 | u32 sqp_id; | |
140 | struct bnxt_re_qp *qp1_sqp; | |
141 | struct bnxt_re_ah *sqp_ah; | |
142 | struct bnxt_re_sqp_entries sqp_tbl[1024]; | |
143 | }; | |
144 | ||
145 | #define to_bnxt_re_dev(ptr, member) \ | |
146 | container_of((ptr), struct bnxt_re_dev, member) | |
147 | ||
148 | #define BNXT_RE_ROCE_V1_PACKET 0 | |
149 | #define BNXT_RE_ROCEV2_IPV4_PACKET 2 | |
150 | #define BNXT_RE_ROCEV2_IPV6_PACKET 3 | |
151 | ||
152 | static inline struct device *rdev_to_dev(struct bnxt_re_dev *rdev) | |
153 | { | |
154 | if (rdev) | |
155 | return &rdev->ibdev.dev; | |
156 | return NULL; | |
157 | } | |
158 | ||
159 | #endif |