162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
362306a36Sopenharmony_ci * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
462306a36Sopenharmony_ci * Copyright (c) 2006, 2007 Cisco Systems.  All rights reserved.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * This software is available to you under a choice of one of two
762306a36Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
862306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
962306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the
1062306a36Sopenharmony_ci * OpenIB.org BSD license below:
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
1362306a36Sopenharmony_ci *     without modification, are permitted provided that the following
1462306a36Sopenharmony_ci *     conditions are met:
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci *      - Redistributions of source code must retain the above
1762306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
1862306a36Sopenharmony_ci *        disclaimer.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
2162306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
2262306a36Sopenharmony_ci *        disclaimer in the documentation and/or other materials
2362306a36Sopenharmony_ci *        provided with the distribution.
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2662306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2762306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2862306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2962306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3062306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3162306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3262306a36Sopenharmony_ci * SOFTWARE.
3362306a36Sopenharmony_ci */
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#ifndef MLX4_FW_H
3662306a36Sopenharmony_ci#define MLX4_FW_H
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#include "mlx4.h"
3962306a36Sopenharmony_ci#include "icm.h"
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_cistruct mlx4_mod_stat_cfg {
4262306a36Sopenharmony_ci	u8 log_pg_sz;
4362306a36Sopenharmony_ci	u8 log_pg_sz_m;
4462306a36Sopenharmony_ci};
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_cistruct mlx4_port_cap {
4762306a36Sopenharmony_ci	u8  link_state;
4862306a36Sopenharmony_ci	u8  supported_port_types;
4962306a36Sopenharmony_ci	u8  suggested_type;
5062306a36Sopenharmony_ci	u8  default_sense;
5162306a36Sopenharmony_ci	u8  log_max_macs;
5262306a36Sopenharmony_ci	u8  log_max_vlans;
5362306a36Sopenharmony_ci	int ib_mtu;
5462306a36Sopenharmony_ci	int max_port_width;
5562306a36Sopenharmony_ci	int max_vl;
5662306a36Sopenharmony_ci	int max_tc_eth;
5762306a36Sopenharmony_ci	int max_gids;
5862306a36Sopenharmony_ci	int max_pkeys;
5962306a36Sopenharmony_ci	u64 def_mac;
6062306a36Sopenharmony_ci	u16 eth_mtu;
6162306a36Sopenharmony_ci	int trans_type;
6262306a36Sopenharmony_ci	int vendor_oui;
6362306a36Sopenharmony_ci	u16 wavelength;
6462306a36Sopenharmony_ci	u64 trans_code;
6562306a36Sopenharmony_ci	u8 dmfs_optimized_state;
6662306a36Sopenharmony_ci};
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_cistruct mlx4_dev_cap {
6962306a36Sopenharmony_ci	int max_srq_sz;
7062306a36Sopenharmony_ci	int max_qp_sz;
7162306a36Sopenharmony_ci	int reserved_qps;
7262306a36Sopenharmony_ci	int max_qps;
7362306a36Sopenharmony_ci	int reserved_srqs;
7462306a36Sopenharmony_ci	int max_srqs;
7562306a36Sopenharmony_ci	int max_cq_sz;
7662306a36Sopenharmony_ci	int reserved_cqs;
7762306a36Sopenharmony_ci	int max_cqs;
7862306a36Sopenharmony_ci	int max_mpts;
7962306a36Sopenharmony_ci	int reserved_eqs;
8062306a36Sopenharmony_ci	int max_eqs;
8162306a36Sopenharmony_ci	int num_sys_eqs;
8262306a36Sopenharmony_ci	int reserved_mtts;
8362306a36Sopenharmony_ci	int reserved_mrws;
8462306a36Sopenharmony_ci	int max_requester_per_qp;
8562306a36Sopenharmony_ci	int max_responder_per_qp;
8662306a36Sopenharmony_ci	int max_rdma_global;
8762306a36Sopenharmony_ci	int local_ca_ack_delay;
8862306a36Sopenharmony_ci	int num_ports;
8962306a36Sopenharmony_ci	u32 max_msg_sz;
9062306a36Sopenharmony_ci	u16 stat_rate_support;
9162306a36Sopenharmony_ci	int fs_log_max_ucast_qp_range_size;
9262306a36Sopenharmony_ci	int fs_max_num_qp_per_entry;
9362306a36Sopenharmony_ci	u64 flags;
9462306a36Sopenharmony_ci	u64 flags2;
9562306a36Sopenharmony_ci	int reserved_uars;
9662306a36Sopenharmony_ci	int uar_size;
9762306a36Sopenharmony_ci	int min_page_sz;
9862306a36Sopenharmony_ci	int bf_reg_size;
9962306a36Sopenharmony_ci	int bf_regs_per_page;
10062306a36Sopenharmony_ci	int max_sq_sg;
10162306a36Sopenharmony_ci	int max_sq_desc_sz;
10262306a36Sopenharmony_ci	int max_rq_sg;
10362306a36Sopenharmony_ci	int max_rq_desc_sz;
10462306a36Sopenharmony_ci	int max_qp_per_mcg;
10562306a36Sopenharmony_ci	int reserved_mgms;
10662306a36Sopenharmony_ci	int max_mcgs;
10762306a36Sopenharmony_ci	int reserved_pds;
10862306a36Sopenharmony_ci	int max_pds;
10962306a36Sopenharmony_ci	int reserved_xrcds;
11062306a36Sopenharmony_ci	int max_xrcds;
11162306a36Sopenharmony_ci	int qpc_entry_sz;
11262306a36Sopenharmony_ci	int rdmarc_entry_sz;
11362306a36Sopenharmony_ci	int altc_entry_sz;
11462306a36Sopenharmony_ci	int aux_entry_sz;
11562306a36Sopenharmony_ci	int srq_entry_sz;
11662306a36Sopenharmony_ci	int cqc_entry_sz;
11762306a36Sopenharmony_ci	int eqc_entry_sz;
11862306a36Sopenharmony_ci	int dmpt_entry_sz;
11962306a36Sopenharmony_ci	int cmpt_entry_sz;
12062306a36Sopenharmony_ci	int mtt_entry_sz;
12162306a36Sopenharmony_ci	int resize_srq;
12262306a36Sopenharmony_ci	u32 bmme_flags;
12362306a36Sopenharmony_ci	u32 reserved_lkey;
12462306a36Sopenharmony_ci	u64 max_icm_sz;
12562306a36Sopenharmony_ci	int max_gso_sz;
12662306a36Sopenharmony_ci	int max_rss_tbl_sz;
12762306a36Sopenharmony_ci	u32 max_counters;
12862306a36Sopenharmony_ci	u32 dmfs_high_rate_qpn_base;
12962306a36Sopenharmony_ci	u32 dmfs_high_rate_qpn_range;
13062306a36Sopenharmony_ci	struct mlx4_rate_limit_caps rl_caps;
13162306a36Sopenharmony_ci	u32 health_buffer_addrs;
13262306a36Sopenharmony_ci	struct mlx4_port_cap port_cap[MLX4_MAX_PORTS + 1];
13362306a36Sopenharmony_ci	bool wol_port[MLX4_MAX_PORTS + 1];
13462306a36Sopenharmony_ci	bool map_clock_to_user;
13562306a36Sopenharmony_ci};
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_cistruct mlx4_func_cap {
13862306a36Sopenharmony_ci	u8	num_ports;
13962306a36Sopenharmony_ci	u8	flags;
14062306a36Sopenharmony_ci	u32	pf_context_behaviour;
14162306a36Sopenharmony_ci	int	qp_quota;
14262306a36Sopenharmony_ci	int	cq_quota;
14362306a36Sopenharmony_ci	int	srq_quota;
14462306a36Sopenharmony_ci	int	mpt_quota;
14562306a36Sopenharmony_ci	int	mtt_quota;
14662306a36Sopenharmony_ci	int	max_eq;
14762306a36Sopenharmony_ci	int	reserved_eq;
14862306a36Sopenharmony_ci	int	mcg_quota;
14962306a36Sopenharmony_ci	struct mlx4_spec_qps spec_qps;
15062306a36Sopenharmony_ci	u32	reserved_lkey;
15162306a36Sopenharmony_ci	u8	physical_port;
15262306a36Sopenharmony_ci	u8	flags0;
15362306a36Sopenharmony_ci	u8	flags1;
15462306a36Sopenharmony_ci	u64	phys_port_id;
15562306a36Sopenharmony_ci	u32	extra_flags;
15662306a36Sopenharmony_ci};
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_cistruct mlx4_func {
15962306a36Sopenharmony_ci	int	bus;
16062306a36Sopenharmony_ci	int	device;
16162306a36Sopenharmony_ci	int	function;
16262306a36Sopenharmony_ci	int	physical_function;
16362306a36Sopenharmony_ci	int	rsvd_eqs;
16462306a36Sopenharmony_ci	int	max_eq;
16562306a36Sopenharmony_ci	int	rsvd_uars;
16662306a36Sopenharmony_ci};
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_cistruct mlx4_adapter {
16962306a36Sopenharmony_ci	char board_id[MLX4_BOARD_ID_LEN];
17062306a36Sopenharmony_ci	u8   inta_pin;
17162306a36Sopenharmony_ci};
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_cistruct mlx4_init_hca_param {
17462306a36Sopenharmony_ci	u64 qpc_base;
17562306a36Sopenharmony_ci	u64 rdmarc_base;
17662306a36Sopenharmony_ci	u64 auxc_base;
17762306a36Sopenharmony_ci	u64 altc_base;
17862306a36Sopenharmony_ci	u64 srqc_base;
17962306a36Sopenharmony_ci	u64 cqc_base;
18062306a36Sopenharmony_ci	u64 eqc_base;
18162306a36Sopenharmony_ci	u64 mc_base;
18262306a36Sopenharmony_ci	u64 dmpt_base;
18362306a36Sopenharmony_ci	u64 cmpt_base;
18462306a36Sopenharmony_ci	u64 mtt_base;
18562306a36Sopenharmony_ci	u64 global_caps;
18662306a36Sopenharmony_ci	u8 log_mc_entry_sz;
18762306a36Sopenharmony_ci	u8 log_mc_hash_sz;
18862306a36Sopenharmony_ci	u16 hca_core_clock; /* Internal Clock Frequency (in MHz) */
18962306a36Sopenharmony_ci	u8  log_num_qps;
19062306a36Sopenharmony_ci	u8  log_num_srqs;
19162306a36Sopenharmony_ci	u8  log_num_cqs;
19262306a36Sopenharmony_ci	u8  log_num_eqs;
19362306a36Sopenharmony_ci	u16 num_sys_eqs;
19462306a36Sopenharmony_ci	u8  log_rd_per_qp;
19562306a36Sopenharmony_ci	u8  log_mc_table_sz;
19662306a36Sopenharmony_ci	u8  log_mpt_sz;
19762306a36Sopenharmony_ci	u8  log_uar_sz;
19862306a36Sopenharmony_ci	u8  mw_enabled;  /* Enable memory windows */
19962306a36Sopenharmony_ci	u8  uar_page_sz; /* log pg sz in 4k chunks */
20062306a36Sopenharmony_ci	u8  steering_mode; /* for QUERY_HCA */
20162306a36Sopenharmony_ci	u8  dmfs_high_steer_mode; /* for QUERY_HCA */
20262306a36Sopenharmony_ci	u64 dev_cap_enabled;
20362306a36Sopenharmony_ci	u16 cqe_size; /* For use only when CQE stride feature enabled */
20462306a36Sopenharmony_ci	u16 eqe_size; /* For use only when EQE stride feature enabled */
20562306a36Sopenharmony_ci	u8 rss_ip_frags;
20662306a36Sopenharmony_ci	u8 phv_check_en; /* for QUERY_HCA */
20762306a36Sopenharmony_ci};
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_cistruct mlx4_init_ib_param {
21062306a36Sopenharmony_ci	int port_width;
21162306a36Sopenharmony_ci	int vl_cap;
21262306a36Sopenharmony_ci	int mtu_cap;
21362306a36Sopenharmony_ci	u16 gid_cap;
21462306a36Sopenharmony_ci	u16 pkey_cap;
21562306a36Sopenharmony_ci	int set_guid0;
21662306a36Sopenharmony_ci	u64 guid0;
21762306a36Sopenharmony_ci	int set_node_guid;
21862306a36Sopenharmony_ci	u64 node_guid;
21962306a36Sopenharmony_ci	int set_si_guid;
22062306a36Sopenharmony_ci	u64 si_guid;
22162306a36Sopenharmony_ci};
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_cistruct mlx4_set_ib_param {
22462306a36Sopenharmony_ci	int set_si_guid;
22562306a36Sopenharmony_ci	int reset_qkey_viol;
22662306a36Sopenharmony_ci	u64 si_guid;
22762306a36Sopenharmony_ci	u32 cap_mask;
22862306a36Sopenharmony_ci};
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_civoid mlx4_dev_cap_dump(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap);
23162306a36Sopenharmony_ciint mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap);
23262306a36Sopenharmony_ciint mlx4_QUERY_PORT(struct mlx4_dev *dev, int port, struct mlx4_port_cap *port_cap);
23362306a36Sopenharmony_ciint mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u8 gen_or_port,
23462306a36Sopenharmony_ci			struct mlx4_func_cap *func_cap);
23562306a36Sopenharmony_ciint mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave,
23662306a36Sopenharmony_ci				struct mlx4_vhcr *vhcr,
23762306a36Sopenharmony_ci				struct mlx4_cmd_mailbox *inbox,
23862306a36Sopenharmony_ci				struct mlx4_cmd_mailbox *outbox,
23962306a36Sopenharmony_ci				struct mlx4_cmd_info *cmd);
24062306a36Sopenharmony_ciint mlx4_QUERY_FUNC(struct mlx4_dev *dev, struct mlx4_func *func, int slave);
24162306a36Sopenharmony_ciint mlx4_MAP_FA(struct mlx4_dev *dev, struct mlx4_icm *icm);
24262306a36Sopenharmony_ciint mlx4_UNMAP_FA(struct mlx4_dev *dev);
24362306a36Sopenharmony_ciint mlx4_RUN_FW(struct mlx4_dev *dev);
24462306a36Sopenharmony_ciint mlx4_QUERY_FW(struct mlx4_dev *dev);
24562306a36Sopenharmony_ciint mlx4_QUERY_ADAPTER(struct mlx4_dev *dev, struct mlx4_adapter *adapter);
24662306a36Sopenharmony_ciint mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param);
24762306a36Sopenharmony_ciint mlx4_QUERY_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param);
24862306a36Sopenharmony_ciint mlx4_CLOSE_HCA(struct mlx4_dev *dev, int panic);
24962306a36Sopenharmony_ciint mlx4_map_cmd(struct mlx4_dev *dev, u16 op, struct mlx4_icm *icm, u64 virt);
25062306a36Sopenharmony_ciint mlx4_SET_ICM_SIZE(struct mlx4_dev *dev, u64 icm_size, u64 *aux_pages);
25162306a36Sopenharmony_ciint mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm);
25262306a36Sopenharmony_ciint mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev);
25362306a36Sopenharmony_ciint mlx4_NOP(struct mlx4_dev *dev);
25462306a36Sopenharmony_ciint mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg);
25562306a36Sopenharmony_civoid mlx4_opreq_action(struct work_struct *work);
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ci#endif /* MLX4_FW_H */
258