Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
0002 /* QLogic qed NIC Driver
0003  * Copyright (c) 2015-2017  QLogic Corporation
0004  * Copyright (c) 2019-2020 Marvell International Ltd.
0005  */
0006 
0007 #ifndef _QED_CXT_H
0008 #define _QED_CXT_H
0009 
0010 #include <linux/types.h>
0011 #include <linux/slab.h>
0012 #include <linux/qed/qed_if.h>
0013 #include "qed_hsi.h"
0014 #include "qed.h"
0015 
0016 struct qed_cxt_info {
0017     void            *p_cxt;
0018     u32         iid;
0019     enum protocol_type  type;
0020 };
0021 
0022 #define MAX_TID_BLOCKS                  512
0023 struct qed_tid_mem {
0024     u32 tid_size;
0025     u32 num_tids_per_block;
0026     u32 waste;
0027     u8 *blocks[MAX_TID_BLOCKS]; /* 4K */
0028 };
0029 
0030 /**
0031  * qed_cxt_get_cid_info(): Returns the context info for a specific cidi.
0032  *
0033  * @p_hwfn: HW device data.
0034  * @p_info: In/out.
0035  *
0036  * Return: Int.
0037  */
0038 int qed_cxt_get_cid_info(struct qed_hwfn *p_hwfn,
0039              struct qed_cxt_info *p_info);
0040 
0041 /**
0042  * qed_cxt_get_tid_mem_info(): Returns the tid mem info.
0043  *
0044  * @p_hwfn: HW device data.
0045  * @p_info: in/out.
0046  *
0047  * Return: int.
0048  */
0049 int qed_cxt_get_tid_mem_info(struct qed_hwfn *p_hwfn,
0050                  struct qed_tid_mem *p_info);
0051 
0052 #define QED_CXT_TCP_ULP_TID_SEG PROTOCOLID_TCP_ULP
0053 #define QED_CXT_ROCE_TID_SEG    PROTOCOLID_ROCE
0054 #define QED_CXT_FCOE_TID_SEG    PROTOCOLID_FCOE
0055 enum qed_cxt_elem_type {
0056     QED_ELEM_CXT,
0057     QED_ELEM_SRQ,
0058     QED_ELEM_TASK,
0059     QED_ELEM_XRC_SRQ,
0060 };
0061 
0062 u32 qed_cxt_get_proto_cid_count(struct qed_hwfn *p_hwfn,
0063                 enum protocol_type type, u32 *vf_cid);
0064 
0065 /**
0066  * qed_cxt_set_pf_params(): Set the PF params for cxt init.
0067  *
0068  * @p_hwfn: HW device data.
0069  * @rdma_tasks: Requested maximum.
0070  *
0071  * Return: int.
0072  */
0073 int qed_cxt_set_pf_params(struct qed_hwfn *p_hwfn, u32 rdma_tasks);
0074 
0075 /**
0076  * qed_cxt_cfg_ilt_compute(): Compute ILT init parameters.
0077  *
0078  * @p_hwfn: HW device data.
0079  * @last_line: Last_line.
0080  *
0081  * Return: Int
0082  */
0083 int qed_cxt_cfg_ilt_compute(struct qed_hwfn *p_hwfn, u32 *last_line);
0084 
0085 /**
0086  * qed_cxt_cfg_ilt_compute_excess(): How many lines can be decreased.
0087  *
0088  * @p_hwfn: HW device data.
0089  * @used_lines: Used lines.
0090  *
0091  * Return: Int.
0092  */
0093 u32 qed_cxt_cfg_ilt_compute_excess(struct qed_hwfn *p_hwfn, u32 used_lines);
0094 
0095 /**
0096  * qed_cxt_mngr_alloc(): Allocate and init the context manager struct.
0097  *
0098  * @p_hwfn: HW device data.
0099  *
0100  * Return: Int.
0101  */
0102 int qed_cxt_mngr_alloc(struct qed_hwfn *p_hwfn);
0103 
0104 /**
0105  * qed_cxt_mngr_free() - Context manager free.
0106  *
0107  * @p_hwfn: HW device data.
0108  *
0109  * Return: Void.
0110  */
0111 void qed_cxt_mngr_free(struct qed_hwfn *p_hwfn);
0112 
0113 /**
0114  * qed_cxt_tables_alloc(): Allocate ILT shadow, Searcher T2, acquired map.
0115  *
0116  * @p_hwfn: HW device data.
0117  *
0118  * Return: Int.
0119  */
0120 int qed_cxt_tables_alloc(struct qed_hwfn *p_hwfn);
0121 
0122 /**
0123  * qed_cxt_mngr_setup(): Reset the acquired CIDs.
0124  *
0125  * @p_hwfn: HW device data.
0126  */
0127 void qed_cxt_mngr_setup(struct qed_hwfn *p_hwfn);
0128 
0129 /**
0130  * qed_cxt_hw_init_common(): Initailze ILT and DQ, common phase, per path.
0131  *
0132  * @p_hwfn: HW device data.
0133  *
0134  * Return: Void.
0135  */
0136 void qed_cxt_hw_init_common(struct qed_hwfn *p_hwfn);
0137 
0138 /**
0139  * qed_cxt_hw_init_pf(): Initailze ILT and DQ, PF phase, per path.
0140  *
0141  * @p_hwfn: HW device data.
0142  * @p_ptt: P_ptt.
0143  *
0144  * Return: Void.
0145  */
0146 void qed_cxt_hw_init_pf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0147 
0148 /**
0149  * qed_qm_init_pf(): Initailze the QM PF phase, per path.
0150  *
0151  * @p_hwfn: HW device data.
0152  * @p_ptt: P_ptt.
0153  * @is_pf_loading: Is pf pending.
0154  *
0155  * Return: Void.
0156  */
0157 void qed_qm_init_pf(struct qed_hwfn *p_hwfn,
0158             struct qed_ptt *p_ptt, bool is_pf_loading);
0159 
0160 /**
0161  * qed_qm_reconf(): Reconfigures QM pf on the fly.
0162  *
0163  * @p_hwfn: HW device data.
0164  * @p_ptt: P_ptt.
0165  *
0166  * Return: Int.
0167  */
0168 int qed_qm_reconf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0169 
0170 #define QED_CXT_PF_CID (0xff)
0171 
0172 /**
0173  * qed_cxt_release_cid(): Release a cid.
0174  *
0175  * @p_hwfn: HW device data.
0176  * @cid: Cid.
0177  *
0178  * Return: Void.
0179  */
0180 void qed_cxt_release_cid(struct qed_hwfn *p_hwfn, u32 cid);
0181 
0182 /**
0183  * _qed_cxt_release_cid(): Release a cid belonging to a vf-queue.
0184  *
0185  * @p_hwfn: HW device data.
0186  * @cid: Cid.
0187  * @vfid: Engine relative index. QED_CXT_PF_CID if belongs to PF.
0188  *
0189  * Return: Void.
0190  */
0191 void _qed_cxt_release_cid(struct qed_hwfn *p_hwfn, u32 cid, u8 vfid);
0192 
0193 /**
0194  * qed_cxt_acquire_cid(): Acquire a new cid of a specific protocol type.
0195  *
0196  * @p_hwfn: HW device data.
0197  * @type: Type.
0198  * @p_cid: Pointer cid.
0199  *
0200  * Return: Int.
0201  */
0202 int qed_cxt_acquire_cid(struct qed_hwfn *p_hwfn,
0203             enum protocol_type type, u32 *p_cid);
0204 
0205 /**
0206  * _qed_cxt_acquire_cid(): Acquire a new cid of a specific protocol type
0207  *                         for a vf-queue.
0208  *
0209  * @p_hwfn: HW device data.
0210  * @type: Type.
0211  * @p_cid: Pointer cid.
0212  * @vfid: Engine relative index. QED_CXT_PF_CID if belongs to PF.
0213  *
0214  * Return: Int.
0215  */
0216 int _qed_cxt_acquire_cid(struct qed_hwfn *p_hwfn,
0217              enum protocol_type type, u32 *p_cid, u8 vfid);
0218 
0219 int qed_cxt_dynamic_ilt_alloc(struct qed_hwfn *p_hwfn,
0220                   enum qed_cxt_elem_type elem_type, u32 iid);
0221 u32 qed_cxt_get_proto_tid_count(struct qed_hwfn *p_hwfn,
0222                 enum protocol_type type);
0223 u32 qed_cxt_get_proto_cid_start(struct qed_hwfn *p_hwfn,
0224                 enum protocol_type type);
0225 int qed_cxt_free_proto_ilt(struct qed_hwfn *p_hwfn, enum protocol_type proto);
0226 
0227 #define QED_CTX_WORKING_MEM 0
0228 #define QED_CTX_FL_MEM 1
0229 int qed_cxt_get_task_ctx(struct qed_hwfn *p_hwfn,
0230              u32 tid, u8 ctx_type, void **task_ctx);
0231 
0232 /* Max number of connection types in HW (DQ/CDU etc.) */
0233 #define MAX_CONN_TYPES          PROTOCOLID_COMMON
0234 #define NUM_TASK_TYPES          2
0235 #define NUM_TASK_PF_SEGMENTS    4
0236 #define NUM_TASK_VF_SEGMENTS    1
0237 
0238 /* PF per protocl configuration object */
0239 #define TASK_SEGMENTS   (NUM_TASK_PF_SEGMENTS + NUM_TASK_VF_SEGMENTS)
0240 #define TASK_SEGMENT_VF (NUM_TASK_PF_SEGMENTS)
0241 
0242 struct qed_tid_seg {
0243     u32 count;
0244     u8 type;
0245     bool has_fl_mem;
0246 };
0247 
0248 struct qed_conn_type_cfg {
0249     u32 cid_count;
0250     u32 cids_per_vf;
0251     struct qed_tid_seg tid_seg[TASK_SEGMENTS];
0252 };
0253 
0254 /* ILT Client configuration,
0255  * Per connection type (protocol) resources (cids, tis, vf cids etc.)
0256  * 1 - for connection context (CDUC) and for each task context we need two
0257  * values, for regular task context and for force load memory
0258  */
0259 #define ILT_CLI_PF_BLOCKS       (1 + NUM_TASK_PF_SEGMENTS * 2)
0260 #define ILT_CLI_VF_BLOCKS       (1 + NUM_TASK_VF_SEGMENTS * 2)
0261 #define CDUC_BLK                (0)
0262 #define SRQ_BLK                 (0)
0263 #define CDUT_SEG_BLK(n)         (1 + (u8)(n))
0264 #define CDUT_FL_SEG_BLK(n, X)   (1 + (n) + NUM_TASK_ ## X ## _SEGMENTS)
0265 
0266 struct ilt_cfg_pair {
0267     u32 reg;
0268     u32 val;
0269 };
0270 
0271 struct qed_ilt_cli_blk {
0272     u32 total_size;     /* 0 means not active */
0273     u32 real_size_in_page;
0274     u32 start_line;
0275     u32 dynamic_line_offset;
0276     u32 dynamic_line_cnt;
0277 };
0278 
0279 struct qed_ilt_client_cfg {
0280     bool active;
0281 
0282     /* ILT boundaries */
0283     struct ilt_cfg_pair first;
0284     struct ilt_cfg_pair last;
0285     struct ilt_cfg_pair p_size;
0286 
0287     /* ILT client blocks for PF */
0288     struct qed_ilt_cli_blk pf_blks[ILT_CLI_PF_BLOCKS];
0289     u32 pf_total_lines;
0290 
0291     /* ILT client blocks for VFs */
0292     struct qed_ilt_cli_blk vf_blks[ILT_CLI_VF_BLOCKS];
0293     u32 vf_total_lines;
0294 };
0295 
0296 struct qed_cid_acquired_map {
0297     u32     start_cid;
0298     u32     max_count;
0299     unsigned long   *cid_map;
0300 };
0301 
0302 struct qed_src_t2 {
0303     struct phys_mem_desc *dma_mem;
0304     u32 num_pages;
0305     u64 first_free;
0306     u64 last_free;
0307 };
0308 
0309 struct qed_cxt_mngr {
0310     /* Per protocl configuration */
0311     struct qed_conn_type_cfg    conn_cfg[MAX_CONN_TYPES];
0312 
0313     /* computed ILT structure */
0314     struct qed_ilt_client_cfg   clients[MAX_ILT_CLIENTS];
0315 
0316     /* Task type sizes */
0317     u32 task_type_size[NUM_TASK_TYPES];
0318 
0319     /* total number of VFs for this hwfn -
0320      * ALL VFs are symmetric in terms of HW resources
0321      */
0322     u32 vf_count;
0323     u32 first_vf_in_pf;
0324 
0325     /* Acquired CIDs */
0326     struct qed_cid_acquired_map acquired[MAX_CONN_TYPES];
0327 
0328     struct qed_cid_acquired_map
0329     acquired_vf[MAX_CONN_TYPES][MAX_NUM_VFS];
0330 
0331     /* ILT  shadow table */
0332     struct phys_mem_desc *ilt_shadow;
0333     u32 ilt_shadow_size;
0334     u32 pf_start_line;
0335 
0336     /* Mutex for a dynamic ILT allocation */
0337     struct mutex mutex;
0338 
0339     /* SRC T2 */
0340     struct qed_src_t2 src_t2;
0341 
0342     /* total number of SRQ's for this hwfn */
0343     u32 srq_count;
0344     u32 xrc_srq_count;
0345 
0346     /* Maximal number of L2 steering filters */
0347     u32 arfs_count;
0348 
0349     u16 iscsi_task_pages;
0350     u16 fcoe_task_pages;
0351     u16 roce_task_pages;
0352     u16 eth_task_pages;
0353     u16 task_ctx_size;
0354     u16 conn_ctx_size;
0355 };
0356 
0357 u16 qed_get_cdut_num_pf_init_pages(struct qed_hwfn *p_hwfn);
0358 u16 qed_get_cdut_num_vf_init_pages(struct qed_hwfn *p_hwfn);
0359 u16 qed_get_cdut_num_pf_work_pages(struct qed_hwfn *p_hwfn);
0360 u16 qed_get_cdut_num_vf_work_pages(struct qed_hwfn *p_hwfn);
0361 
0362 u32 qed_cxt_get_ilt_page_size(struct qed_hwfn *p_hwfn,
0363                   enum ilt_clients ilt_client);
0364 
0365 u32 qed_cxt_get_total_srq_count(struct qed_hwfn *p_hwfn);
0366 
0367 #endif