Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1 | /* QLogic qed NIC Driver |
Mintz, Yuval | e8f1cb5 | 2017-01-01 13:57:00 +0200 | [diff] [blame] | 2 | * Copyright (c) 2015-2017 QLogic Corporation |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 3 | * |
Mintz, Yuval | e8f1cb5 | 2017-01-01 13:57:00 +0200 | [diff] [blame] | 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. |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 31 | */ |
| 32 | |
| 33 | #ifndef _QED_CXT_H |
| 34 | #define _QED_CXT_H |
| 35 | |
| 36 | #include <linux/types.h> |
| 37 | #include <linux/slab.h> |
| 38 | #include <linux/qed/qed_if.h> |
| 39 | #include "qed_hsi.h" |
| 40 | #include "qed.h" |
| 41 | |
| 42 | struct qed_cxt_info { |
| 43 | void *p_cxt; |
| 44 | u32 iid; |
| 45 | enum protocol_type type; |
| 46 | }; |
| 47 | |
Yuval Mintz | dbb799c | 2016-06-03 14:35:35 +0300 | [diff] [blame] | 48 | #define MAX_TID_BLOCKS 512 |
| 49 | struct qed_tid_mem { |
| 50 | u32 tid_size; |
| 51 | u32 num_tids_per_block; |
| 52 | u32 waste; |
| 53 | u8 *blocks[MAX_TID_BLOCKS]; /* 4K */ |
| 54 | }; |
| 55 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 56 | /** |
| 57 | * @brief qed_cxt_acquire - Acquire a new cid of a specific protocol type |
| 58 | * |
| 59 | * @param p_hwfn |
| 60 | * @param type |
| 61 | * @param p_cid |
| 62 | * |
| 63 | * @return int |
| 64 | */ |
| 65 | int qed_cxt_acquire_cid(struct qed_hwfn *p_hwfn, |
| 66 | enum protocol_type type, |
| 67 | u32 *p_cid); |
| 68 | |
| 69 | /** |
| 70 | * @brief qedo_cid_get_cxt_info - Returns the context info for a specific cid |
| 71 | * |
| 72 | * |
| 73 | * @param p_hwfn |
| 74 | * @param p_info in/out |
| 75 | * |
| 76 | * @return int |
| 77 | */ |
| 78 | int qed_cxt_get_cid_info(struct qed_hwfn *p_hwfn, |
| 79 | struct qed_cxt_info *p_info); |
| 80 | |
Yuval Mintz | dbb799c | 2016-06-03 14:35:35 +0300 | [diff] [blame] | 81 | /** |
| 82 | * @brief qed_cxt_get_tid_mem_info |
| 83 | * |
| 84 | * @param p_hwfn |
| 85 | * @param p_info |
| 86 | * |
| 87 | * @return int |
| 88 | */ |
| 89 | int qed_cxt_get_tid_mem_info(struct qed_hwfn *p_hwfn, |
| 90 | struct qed_tid_mem *p_info); |
| 91 | |
| 92 | #define QED_CXT_ISCSI_TID_SEG PROTOCOLID_ISCSI |
| 93 | #define QED_CXT_ROCE_TID_SEG PROTOCOLID_ROCE |
Arun Easi | 1e128c8 | 2017-02-15 06:28:22 -0800 | [diff] [blame] | 94 | #define QED_CXT_FCOE_TID_SEG PROTOCOLID_FCOE |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 95 | enum qed_cxt_elem_type { |
| 96 | QED_ELEM_CXT, |
Yuval Mintz | dbb799c | 2016-06-03 14:35:35 +0300 | [diff] [blame] | 97 | QED_ELEM_SRQ, |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 98 | QED_ELEM_TASK |
| 99 | }; |
| 100 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 101 | u32 qed_cxt_get_proto_cid_count(struct qed_hwfn *p_hwfn, |
| 102 | enum protocol_type type, u32 *vf_cid); |
| 103 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 104 | /** |
| 105 | * @brief qed_cxt_set_pf_params - Set the PF params for cxt init |
| 106 | * |
| 107 | * @param p_hwfn |
Ram Amrani | f9dc4d1 | 2017-04-03 12:21:13 +0300 | [diff] [blame] | 108 | * @param rdma_tasks - requested maximum |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 109 | * @return int |
| 110 | */ |
Ram Amrani | f9dc4d1 | 2017-04-03 12:21:13 +0300 | [diff] [blame] | 111 | int qed_cxt_set_pf_params(struct qed_hwfn *p_hwfn, u32 rdma_tasks); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * @brief qed_cxt_cfg_ilt_compute - compute ILT init parameters |
| 115 | * |
| 116 | * @param p_hwfn |
Ram Amrani | f9dc4d1 | 2017-04-03 12:21:13 +0300 | [diff] [blame] | 117 | * @param last_line |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 118 | * |
| 119 | * @return int |
| 120 | */ |
Ram Amrani | f9dc4d1 | 2017-04-03 12:21:13 +0300 | [diff] [blame] | 121 | int qed_cxt_cfg_ilt_compute(struct qed_hwfn *p_hwfn, u32 *last_line); |
| 122 | |
| 123 | /** |
| 124 | * @brief qed_cxt_cfg_ilt_compute_excess - how many lines can be decreased |
| 125 | * |
| 126 | * @param p_hwfn |
| 127 | * @param used_lines |
| 128 | */ |
| 129 | u32 qed_cxt_cfg_ilt_compute_excess(struct qed_hwfn *p_hwfn, u32 used_lines); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * @brief qed_cxt_mngr_alloc - Allocate and init the context manager struct |
| 133 | * |
| 134 | * @param p_hwfn |
| 135 | * |
| 136 | * @return int |
| 137 | */ |
| 138 | int qed_cxt_mngr_alloc(struct qed_hwfn *p_hwfn); |
| 139 | |
| 140 | /** |
| 141 | * @brief qed_cxt_mngr_free |
| 142 | * |
| 143 | * @param p_hwfn |
| 144 | */ |
| 145 | void qed_cxt_mngr_free(struct qed_hwfn *p_hwfn); |
| 146 | |
| 147 | /** |
| 148 | * @brief qed_cxt_tables_alloc - Allocate ILT shadow, Searcher T2, acquired map |
| 149 | * |
| 150 | * @param p_hwfn |
| 151 | * |
| 152 | * @return int |
| 153 | */ |
| 154 | int qed_cxt_tables_alloc(struct qed_hwfn *p_hwfn); |
| 155 | |
| 156 | /** |
| 157 | * @brief qed_cxt_mngr_setup - Reset the acquired CIDs |
| 158 | * |
| 159 | * @param p_hwfn |
| 160 | */ |
| 161 | void qed_cxt_mngr_setup(struct qed_hwfn *p_hwfn); |
| 162 | |
| 163 | /** |
| 164 | * @brief qed_cxt_hw_init_common - Initailze ILT and DQ, common phase, per path. |
| 165 | * |
| 166 | * |
| 167 | * |
| 168 | * @param p_hwfn |
| 169 | */ |
| 170 | void qed_cxt_hw_init_common(struct qed_hwfn *p_hwfn); |
| 171 | |
| 172 | /** |
| 173 | * @brief qed_cxt_hw_init_pf - Initailze ILT and DQ, PF phase, per path. |
| 174 | * |
| 175 | * |
| 176 | * |
| 177 | * @param p_hwfn |
| 178 | */ |
| 179 | void qed_cxt_hw_init_pf(struct qed_hwfn *p_hwfn); |
| 180 | |
| 181 | /** |
| 182 | * @brief qed_qm_init_pf - Initailze the QM PF phase, per path |
| 183 | * |
| 184 | * @param p_hwfn |
| 185 | */ |
| 186 | |
| 187 | void qed_qm_init_pf(struct qed_hwfn *p_hwfn); |
| 188 | |
| 189 | /** |
Sudarsana Reddy Kalluru | 39651ab | 2016-05-17 06:44:26 -0400 | [diff] [blame] | 190 | * @brief Reconfigures QM pf on the fly |
| 191 | * |
| 192 | * @param p_hwfn |
| 193 | * @param p_ptt |
| 194 | * |
| 195 | * @return int |
| 196 | */ |
| 197 | int qed_qm_reconf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt); |
| 198 | |
| 199 | /** |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 200 | * @brief qed_cxt_release - Release a cid |
| 201 | * |
| 202 | * @param p_hwfn |
| 203 | * @param cid |
| 204 | */ |
| 205 | void qed_cxt_release_cid(struct qed_hwfn *p_hwfn, |
| 206 | u32 cid); |
Ram Amrani | 51ff172 | 2016-10-01 21:59:57 +0300 | [diff] [blame] | 207 | int qed_cxt_dynamic_ilt_alloc(struct qed_hwfn *p_hwfn, |
| 208 | enum qed_cxt_elem_type elem_type, u32 iid); |
| 209 | u32 qed_cxt_get_proto_tid_count(struct qed_hwfn *p_hwfn, |
| 210 | enum protocol_type type); |
| 211 | u32 qed_cxt_get_proto_cid_start(struct qed_hwfn *p_hwfn, |
| 212 | enum protocol_type type); |
Ram Amrani | f109394 | 2016-10-01 21:59:59 +0300 | [diff] [blame] | 213 | int qed_cxt_free_proto_ilt(struct qed_hwfn *p_hwfn, enum protocol_type proto); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 214 | |
Yuval Mintz | dbb799c | 2016-06-03 14:35:35 +0300 | [diff] [blame] | 215 | #define QED_CTX_WORKING_MEM 0 |
| 216 | #define QED_CTX_FL_MEM 1 |
Arun Easi | 1e128c8 | 2017-02-15 06:28:22 -0800 | [diff] [blame] | 217 | int qed_cxt_get_task_ctx(struct qed_hwfn *p_hwfn, |
| 218 | u32 tid, u8 ctx_type, void **task_ctx); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 219 | #endif |