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_HW_H
0008 #define _QED_HW_H
0009 
0010 #include <linux/types.h>
0011 #include <linux/bitops.h>
0012 #include <linux/slab.h>
0013 #include <linux/string.h>
0014 #include "qed.h"
0015 #include "qed_dev_api.h"
0016 
0017 /* Forward decleration */
0018 struct qed_ptt;
0019 
0020 enum reserved_ptts {
0021     RESERVED_PTT_EDIAG,
0022     RESERVED_PTT_USER_SPACE,
0023     RESERVED_PTT_MAIN,
0024     RESERVED_PTT_DPC,
0025     RESERVED_PTT_MAX
0026 };
0027 
0028 enum _dmae_cmd_dst_mask {
0029     DMAE_CMD_DST_MASK_NONE  = 0,
0030     DMAE_CMD_DST_MASK_PCIE  = 1,
0031     DMAE_CMD_DST_MASK_GRC   = 2
0032 };
0033 
0034 enum _dmae_cmd_src_mask {
0035     DMAE_CMD_SRC_MASK_PCIE  = 0,
0036     DMAE_CMD_SRC_MASK_GRC   = 1
0037 };
0038 
0039 enum _dmae_cmd_crc_mask {
0040     DMAE_CMD_COMP_CRC_EN_MASK_NONE  = 0,
0041     DMAE_CMD_COMP_CRC_EN_MASK_SET   = 1
0042 };
0043 
0044 /* definitions for DMA constants */
0045 #define DMAE_GO_VALUE   0x1
0046 
0047 #define DMAE_COMPLETION_VAL     0xD1AE
0048 #define DMAE_CMD_ENDIANITY      0x2
0049 
0050 #define DMAE_CMD_SIZE   14
0051 #define DMAE_CMD_SIZE_TO_FILL   (DMAE_CMD_SIZE - 5)
0052 #define DMAE_MIN_WAIT_TIME      0x2
0053 #define DMAE_MAX_CLIENTS        32
0054 
0055 /**
0056  * qed_gtt_init(): Initialize GTT windows.
0057  *
0058  * @p_hwfn: HW device data.
0059  *
0060  * Return: Void.
0061  */
0062 void qed_gtt_init(struct qed_hwfn *p_hwfn);
0063 
0064 /**
0065  * qed_ptt_invalidate(): Forces all ptt entries to be re-configured
0066  *
0067  * @p_hwfn: HW device data.
0068  *
0069  * Return: Void.
0070  */
0071 void qed_ptt_invalidate(struct qed_hwfn *p_hwfn);
0072 
0073 /**
0074  * qed_ptt_pool_alloc(): Allocate and initialize PTT pool.
0075  *
0076  * @p_hwfn: HW device data.
0077  *
0078  * Return: struct _qed_status - success (0), negative - error.
0079  */
0080 int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn);
0081 
0082 /**
0083  * qed_ptt_pool_free(): Free PTT pool.
0084  *
0085  * @p_hwfn: HW device data.
0086  *
0087  * Return: Void.
0088  */
0089 void qed_ptt_pool_free(struct qed_hwfn *p_hwfn);
0090 
0091 /**
0092  * qed_ptt_get_hw_addr(): Get PTT's GRC/HW address.
0093  *
0094  * @p_hwfn: HW device data.
0095  * @p_ptt: P_ptt
0096  *
0097  * Return: u32.
0098  */
0099 u32 qed_ptt_get_hw_addr(struct qed_hwfn *p_hwfn,
0100             struct qed_ptt *p_ptt);
0101 
0102 /**
0103  * qed_ptt_get_bar_addr(): Get PPT's external BAR address.
0104  *
0105  * @p_ptt: P_ptt
0106  *
0107  * Return: u32.
0108  */
0109 u32 qed_ptt_get_bar_addr(struct qed_ptt *p_ptt);
0110 
0111 /**
0112  * qed_ptt_set_win(): Set PTT Window's GRC BAR address
0113  *
0114  * @p_hwfn: HW device data.
0115  * @new_hw_addr: New HW address.
0116  * @p_ptt: P_Ptt
0117  *
0118  * Return: Void.
0119  */
0120 void qed_ptt_set_win(struct qed_hwfn *p_hwfn,
0121              struct qed_ptt *p_ptt,
0122              u32 new_hw_addr);
0123 
0124 /**
0125  * qed_get_reserved_ptt(): Get a specific reserved PTT.
0126  *
0127  * @p_hwfn: HW device data.
0128  * @ptt_idx: Ptt Index.
0129  *
0130  * Return: struct qed_ptt *.
0131  */
0132 struct qed_ptt *qed_get_reserved_ptt(struct qed_hwfn *p_hwfn,
0133                      enum reserved_ptts ptt_idx);
0134 
0135 /**
0136  * qed_wr(): Write value to BAR using the given ptt.
0137  *
0138  * @p_hwfn: HW device data.
0139  * @p_ptt: P_ptt.
0140  * @val: Val.
0141  * @hw_addr: HW address
0142  *
0143  * Return: Void.
0144  */
0145 void qed_wr(struct qed_hwfn *p_hwfn,
0146         struct qed_ptt *p_ptt,
0147         u32 hw_addr,
0148         u32 val);
0149 
0150 /**
0151  * qed_rd(): Read value from BAR using the given ptt.
0152  *
0153  * @p_hwfn: HW device data.
0154  * @p_ptt: P_ptt.
0155  * @hw_addr: HW address
0156  *
0157  * Return: Void.
0158  */
0159 u32 qed_rd(struct qed_hwfn *p_hwfn,
0160        struct qed_ptt *p_ptt,
0161        u32 hw_addr);
0162 
0163 /**
0164  * qed_memcpy_from(): Copy n bytes from BAR using the given ptt.
0165  *
0166  * @p_hwfn: HW device data.
0167  * @p_ptt: P_ptt.
0168  * @dest: Destination.
0169  * @hw_addr: HW address.
0170  * @n: N
0171  *
0172  * Return: Void.
0173  */
0174 void qed_memcpy_from(struct qed_hwfn *p_hwfn,
0175              struct qed_ptt *p_ptt,
0176              void *dest,
0177              u32 hw_addr,
0178              size_t n);
0179 
0180 /**
0181  * qed_memcpy_to(): Copy n bytes to BAR using the given  ptt
0182  *
0183  * @p_hwfn: HW device data.
0184  * @p_ptt: P_ptt.
0185  * @hw_addr: HW address.
0186  * @src: Source.
0187  * @n: N
0188  *
0189  * Return: Void.
0190  */
0191 void qed_memcpy_to(struct qed_hwfn *p_hwfn,
0192            struct qed_ptt *p_ptt,
0193            u32 hw_addr,
0194            void *src,
0195            size_t n);
0196 /**
0197  * qed_fid_pretend(): pretend to another function when
0198  *                    accessing the ptt window. There is no way to unpretend
0199  *                    a function. The only way to cancel a pretend is to
0200  *                    pretend back to the original function.
0201  *
0202  * @p_hwfn: HW device data.
0203  * @p_ptt: P_ptt.
0204  * @fid: fid field of pxp_pretend structure. Can contain
0205  *        either pf / vf, port/path fields are don't care.
0206  *
0207  * Return: Void.
0208  */
0209 void qed_fid_pretend(struct qed_hwfn *p_hwfn,
0210              struct qed_ptt *p_ptt,
0211              u16 fid);
0212 
0213 /**
0214  * qed_port_pretend(): Pretend to another port when accessing the ptt window
0215  *
0216  * @p_hwfn: HW device data.
0217  * @p_ptt: P_ptt.
0218  * @port_id: The port to pretend to
0219  *
0220  * Return: Void.
0221  */
0222 void qed_port_pretend(struct qed_hwfn *p_hwfn,
0223               struct qed_ptt *p_ptt,
0224               u8 port_id);
0225 
0226 /**
0227  * qed_port_unpretend(): Cancel any previously set port pretend
0228  *
0229  * @p_hwfn: HW device data.
0230  * @p_ptt: P_ptt.
0231  *
0232  * Return: Void.
0233  */
0234 void qed_port_unpretend(struct qed_hwfn *p_hwfn,
0235             struct qed_ptt *p_ptt);
0236 
0237 /**
0238  * qed_port_fid_pretend(): Pretend to another port and another function
0239  *                         when accessing the ptt window
0240  *
0241  * @p_hwfn: HW device data.
0242  * @p_ptt: P_ptt.
0243  * @port_id: The port to pretend to
0244  * @fid: fid field of pxp_pretend structure. Can contain either pf / vf.
0245  *
0246  * Return: Void.
0247  */
0248 void qed_port_fid_pretend(struct qed_hwfn *p_hwfn,
0249               struct qed_ptt *p_ptt, u8 port_id, u16 fid);
0250 
0251 /**
0252  * qed_vfid_to_concrete(): Build a concrete FID for a given VF ID
0253  *
0254  * @p_hwfn: HW device data.
0255  * @vfid: VFID.
0256  *
0257  * Return: Void.
0258  */
0259 u32 qed_vfid_to_concrete(struct qed_hwfn *p_hwfn, u8 vfid);
0260 
0261 /**
0262  * qed_dmae_idx_to_go_cmd(): Map the idx to dmae cmd
0263  *    this is declared here since other files will require it.
0264  *
0265  * @idx: Index
0266  *
0267  * Return: Void.
0268  */
0269 u32 qed_dmae_idx_to_go_cmd(u8 idx);
0270 
0271 /**
0272  * qed_dmae_info_alloc(): Init the dmae_info structure
0273  *                        which is part of p_hwfn.
0274  *
0275  * @p_hwfn: HW device data.
0276  *
0277  * Return: Int.
0278  */
0279 int qed_dmae_info_alloc(struct qed_hwfn *p_hwfn);
0280 
0281 /**
0282  * qed_dmae_info_free(): Free the dmae_info structure
0283  *                       which is part of p_hwfn.
0284  *
0285  * @p_hwfn: HW device data.
0286  *
0287  * Return: Void.
0288  */
0289 void qed_dmae_info_free(struct qed_hwfn *p_hwfn);
0290 
0291 union qed_qm_pq_params {
0292     struct {
0293         u8 q_idx;
0294     } iscsi;
0295 
0296     struct {
0297         u8 tc;
0298     }   core;
0299 
0300     struct {
0301         u8  is_vf;
0302         u8  vf_id;
0303         u8  tc;
0304     }   eth;
0305 
0306     struct {
0307         u8 dcqcn;
0308         u8 qpid;    /* roce relative */
0309     } roce;
0310 };
0311 
0312 int qed_init_fw_data(struct qed_dev *cdev,
0313              const u8 *fw_data);
0314 
0315 int qed_dmae_sanity(struct qed_hwfn *p_hwfn,
0316             struct qed_ptt *p_ptt, const char *phase);
0317 
0318 #define QED_HW_ERR_MAX_STR_SIZE 256
0319 
0320 /**
0321  * qed_hw_err_notify(): Notify upper layer driver and management FW
0322  *                      about a HW error.
0323  *
0324  * @p_hwfn: HW device data.
0325  * @p_ptt: P_ptt.
0326  * @err_type: Err Type.
0327  * @fmt: Debug data buffer to send to the MFW
0328  * @...: buffer format args
0329  *
0330  * Return void.
0331  */
0332 void __printf(4, 5) __cold qed_hw_err_notify(struct qed_hwfn *p_hwfn,
0333                          struct qed_ptt *p_ptt,
0334                          enum qed_hw_err_type err_type,
0335                          const char *fmt, ...);
0336 #endif