root/drivers/net/ethernet/qlogic/qed/qed_cxt.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* QLogic qed NIC Driver
   2  * Copyright (c) 2015-2017  QLogic Corporation
   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 
  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 
  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 
  56 /**
  57  * @brief qedo_cid_get_cxt_info - Returns the context info for a specific cid
  58  *
  59  *
  60  * @param p_hwfn
  61  * @param p_info in/out
  62  *
  63  * @return int
  64  */
  65 int qed_cxt_get_cid_info(struct qed_hwfn *p_hwfn,
  66                          struct qed_cxt_info *p_info);
  67 
  68 /**
  69  * @brief qed_cxt_get_tid_mem_info
  70  *
  71  * @param p_hwfn
  72  * @param p_info
  73  *
  74  * @return int
  75  */
  76 int qed_cxt_get_tid_mem_info(struct qed_hwfn *p_hwfn,
  77                              struct qed_tid_mem *p_info);
  78 
  79 #define QED_CXT_ISCSI_TID_SEG   PROTOCOLID_ISCSI
  80 #define QED_CXT_ROCE_TID_SEG    PROTOCOLID_ROCE
  81 #define QED_CXT_FCOE_TID_SEG    PROTOCOLID_FCOE
  82 enum qed_cxt_elem_type {
  83         QED_ELEM_CXT,
  84         QED_ELEM_SRQ,
  85         QED_ELEM_TASK
  86 };
  87 
  88 u32 qed_cxt_get_proto_cid_count(struct qed_hwfn *p_hwfn,
  89                                 enum protocol_type type, u32 *vf_cid);
  90 
  91 /**
  92  * @brief qed_cxt_set_pf_params - Set the PF params for cxt init
  93  *
  94  * @param p_hwfn
  95  * @param rdma_tasks - requested maximum
  96  * @return int
  97  */
  98 int qed_cxt_set_pf_params(struct qed_hwfn *p_hwfn, u32 rdma_tasks);
  99 
 100 /**
 101  * @brief qed_cxt_cfg_ilt_compute - compute ILT init parameters
 102  *
 103  * @param p_hwfn
 104  * @param last_line
 105  *
 106  * @return int
 107  */
 108 int qed_cxt_cfg_ilt_compute(struct qed_hwfn *p_hwfn, u32 *last_line);
 109 
 110 /**
 111  * @brief qed_cxt_cfg_ilt_compute_excess - how many lines can be decreased
 112  *
 113  * @param p_hwfn
 114  * @param used_lines
 115  */
 116 u32 qed_cxt_cfg_ilt_compute_excess(struct qed_hwfn *p_hwfn, u32 used_lines);
 117 
 118 /**
 119  * @brief qed_cxt_mngr_alloc - Allocate and init the context manager struct
 120  *
 121  * @param p_hwfn
 122  *
 123  * @return int
 124  */
 125 int qed_cxt_mngr_alloc(struct qed_hwfn *p_hwfn);
 126 
 127 /**
 128  * @brief qed_cxt_mngr_free
 129  *
 130  * @param p_hwfn
 131  */
 132 void qed_cxt_mngr_free(struct qed_hwfn *p_hwfn);
 133 
 134 /**
 135  * @brief qed_cxt_tables_alloc - Allocate ILT shadow, Searcher T2, acquired map
 136  *
 137  * @param p_hwfn
 138  *
 139  * @return int
 140  */
 141 int qed_cxt_tables_alloc(struct qed_hwfn *p_hwfn);
 142 
 143 /**
 144  * @brief qed_cxt_mngr_setup - Reset the acquired CIDs
 145  *
 146  * @param p_hwfn
 147  */
 148 void qed_cxt_mngr_setup(struct qed_hwfn *p_hwfn);
 149 
 150 /**
 151  * @brief qed_cxt_hw_init_common - Initailze ILT and DQ, common phase, per path.
 152  *
 153  *
 154  *
 155  * @param p_hwfn
 156  */
 157 void qed_cxt_hw_init_common(struct qed_hwfn *p_hwfn);
 158 
 159 /**
 160  * @brief qed_cxt_hw_init_pf - Initailze ILT and DQ, PF phase, per path.
 161  *
 162  * @param p_hwfn
 163  * @param p_ptt
 164  */
 165 void qed_cxt_hw_init_pf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
 166 
 167 /**
 168  * @brief qed_qm_init_pf - Initailze the QM PF phase, per path
 169  *
 170  * @param p_hwfn
 171  * @param p_ptt
 172  * @param is_pf_loading
 173  */
 174 void qed_qm_init_pf(struct qed_hwfn *p_hwfn,
 175                     struct qed_ptt *p_ptt, bool is_pf_loading);
 176 
 177 /**
 178  * @brief Reconfigures QM pf on the fly
 179  *
 180  * @param p_hwfn
 181  * @param p_ptt
 182  *
 183  * @return int
 184  */
 185 int qed_qm_reconf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
 186 
 187 #define QED_CXT_PF_CID (0xff)
 188 
 189 /**
 190  * @brief qed_cxt_release - Release a cid
 191  *
 192  * @param p_hwfn
 193  * @param cid
 194  */
 195 void qed_cxt_release_cid(struct qed_hwfn *p_hwfn, u32 cid);
 196 
 197 /**
 198  * @brief qed_cxt_release - Release a cid belonging to a vf-queue
 199  *
 200  * @param p_hwfn
 201  * @param cid
 202  * @param vfid - engine relative index. QED_CXT_PF_CID if belongs to PF
 203  */
 204 void _qed_cxt_release_cid(struct qed_hwfn *p_hwfn, u32 cid, u8 vfid);
 205 
 206 /**
 207  * @brief qed_cxt_acquire - Acquire a new cid of a specific protocol type
 208  *
 209  * @param p_hwfn
 210  * @param type
 211  * @param p_cid
 212  *
 213  * @return int
 214  */
 215 int qed_cxt_acquire_cid(struct qed_hwfn *p_hwfn,
 216                         enum protocol_type type, u32 *p_cid);
 217 
 218 /**
 219  * @brief _qed_cxt_acquire - Acquire a new cid of a specific protocol type
 220  *                           for a vf-queue
 221  *
 222  * @param p_hwfn
 223  * @param type
 224  * @param p_cid
 225  * @param vfid - engine relative index. QED_CXT_PF_CID if belongs to PF
 226  *
 227  * @return int
 228  */
 229 int _qed_cxt_acquire_cid(struct qed_hwfn *p_hwfn,
 230                          enum protocol_type type, u32 *p_cid, u8 vfid);
 231 
 232 int qed_cxt_dynamic_ilt_alloc(struct qed_hwfn *p_hwfn,
 233                               enum qed_cxt_elem_type elem_type, u32 iid);
 234 u32 qed_cxt_get_proto_tid_count(struct qed_hwfn *p_hwfn,
 235                                 enum protocol_type type);
 236 u32 qed_cxt_get_proto_cid_start(struct qed_hwfn *p_hwfn,
 237                                 enum protocol_type type);
 238 u32 qed_cxt_get_srq_count(struct qed_hwfn *p_hwfn);
 239 int qed_cxt_free_proto_ilt(struct qed_hwfn *p_hwfn, enum protocol_type proto);
 240 
 241 #define QED_CTX_WORKING_MEM 0
 242 #define QED_CTX_FL_MEM 1
 243 int qed_cxt_get_task_ctx(struct qed_hwfn *p_hwfn,
 244                          u32 tid, u8 ctx_type, void **task_ctx);
 245 #endif

/* [<][>][^][v][top][bottom][index][help] */