18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
38c2ecf20Sopenharmony_ci * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
48c2ecf20Sopenharmony_ci * Copyright (c) 2006, 2007 Cisco Systems.  All rights reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
78c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
88c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
98c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
108c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
138c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
148c2ecf20Sopenharmony_ci *     conditions are met:
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
178c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
188c2ecf20Sopenharmony_ci *        disclaimer.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
218c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
228c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
238c2ecf20Sopenharmony_ci *        provided with the distribution.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
268c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
278c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
288c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
298c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
308c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
318c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
328c2ecf20Sopenharmony_ci * SOFTWARE.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#ifndef MLX4_FW_H
368c2ecf20Sopenharmony_ci#define MLX4_FW_H
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#include "mlx4.h"
398c2ecf20Sopenharmony_ci#include "icm.h"
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistruct mlx4_mod_stat_cfg {
428c2ecf20Sopenharmony_ci	u8 log_pg_sz;
438c2ecf20Sopenharmony_ci	u8 log_pg_sz_m;
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_cistruct mlx4_port_cap {
478c2ecf20Sopenharmony_ci	u8  link_state;
488c2ecf20Sopenharmony_ci	u8  supported_port_types;
498c2ecf20Sopenharmony_ci	u8  suggested_type;
508c2ecf20Sopenharmony_ci	u8  default_sense;
518c2ecf20Sopenharmony_ci	u8  log_max_macs;
528c2ecf20Sopenharmony_ci	u8  log_max_vlans;
538c2ecf20Sopenharmony_ci	int ib_mtu;
548c2ecf20Sopenharmony_ci	int max_port_width;
558c2ecf20Sopenharmony_ci	int max_vl;
568c2ecf20Sopenharmony_ci	int max_tc_eth;
578c2ecf20Sopenharmony_ci	int max_gids;
588c2ecf20Sopenharmony_ci	int max_pkeys;
598c2ecf20Sopenharmony_ci	u64 def_mac;
608c2ecf20Sopenharmony_ci	u16 eth_mtu;
618c2ecf20Sopenharmony_ci	int trans_type;
628c2ecf20Sopenharmony_ci	int vendor_oui;
638c2ecf20Sopenharmony_ci	u16 wavelength;
648c2ecf20Sopenharmony_ci	u64 trans_code;
658c2ecf20Sopenharmony_ci	u8 dmfs_optimized_state;
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistruct mlx4_dev_cap {
698c2ecf20Sopenharmony_ci	int max_srq_sz;
708c2ecf20Sopenharmony_ci	int max_qp_sz;
718c2ecf20Sopenharmony_ci	int reserved_qps;
728c2ecf20Sopenharmony_ci	int max_qps;
738c2ecf20Sopenharmony_ci	int reserved_srqs;
748c2ecf20Sopenharmony_ci	int max_srqs;
758c2ecf20Sopenharmony_ci	int max_cq_sz;
768c2ecf20Sopenharmony_ci	int reserved_cqs;
778c2ecf20Sopenharmony_ci	int max_cqs;
788c2ecf20Sopenharmony_ci	int max_mpts;
798c2ecf20Sopenharmony_ci	int reserved_eqs;
808c2ecf20Sopenharmony_ci	int max_eqs;
818c2ecf20Sopenharmony_ci	int num_sys_eqs;
828c2ecf20Sopenharmony_ci	int reserved_mtts;
838c2ecf20Sopenharmony_ci	int reserved_mrws;
848c2ecf20Sopenharmony_ci	int max_requester_per_qp;
858c2ecf20Sopenharmony_ci	int max_responder_per_qp;
868c2ecf20Sopenharmony_ci	int max_rdma_global;
878c2ecf20Sopenharmony_ci	int local_ca_ack_delay;
888c2ecf20Sopenharmony_ci	int num_ports;
898c2ecf20Sopenharmony_ci	u32 max_msg_sz;
908c2ecf20Sopenharmony_ci	u16 stat_rate_support;
918c2ecf20Sopenharmony_ci	int fs_log_max_ucast_qp_range_size;
928c2ecf20Sopenharmony_ci	int fs_max_num_qp_per_entry;
938c2ecf20Sopenharmony_ci	u64 flags;
948c2ecf20Sopenharmony_ci	u64 flags2;
958c2ecf20Sopenharmony_ci	int reserved_uars;
968c2ecf20Sopenharmony_ci	int uar_size;
978c2ecf20Sopenharmony_ci	int min_page_sz;
988c2ecf20Sopenharmony_ci	int bf_reg_size;
998c2ecf20Sopenharmony_ci	int bf_regs_per_page;
1008c2ecf20Sopenharmony_ci	int max_sq_sg;
1018c2ecf20Sopenharmony_ci	int max_sq_desc_sz;
1028c2ecf20Sopenharmony_ci	int max_rq_sg;
1038c2ecf20Sopenharmony_ci	int max_rq_desc_sz;
1048c2ecf20Sopenharmony_ci	int max_qp_per_mcg;
1058c2ecf20Sopenharmony_ci	int reserved_mgms;
1068c2ecf20Sopenharmony_ci	int max_mcgs;
1078c2ecf20Sopenharmony_ci	int reserved_pds;
1088c2ecf20Sopenharmony_ci	int max_pds;
1098c2ecf20Sopenharmony_ci	int reserved_xrcds;
1108c2ecf20Sopenharmony_ci	int max_xrcds;
1118c2ecf20Sopenharmony_ci	int qpc_entry_sz;
1128c2ecf20Sopenharmony_ci	int rdmarc_entry_sz;
1138c2ecf20Sopenharmony_ci	int altc_entry_sz;
1148c2ecf20Sopenharmony_ci	int aux_entry_sz;
1158c2ecf20Sopenharmony_ci	int srq_entry_sz;
1168c2ecf20Sopenharmony_ci	int cqc_entry_sz;
1178c2ecf20Sopenharmony_ci	int eqc_entry_sz;
1188c2ecf20Sopenharmony_ci	int dmpt_entry_sz;
1198c2ecf20Sopenharmony_ci	int cmpt_entry_sz;
1208c2ecf20Sopenharmony_ci	int mtt_entry_sz;
1218c2ecf20Sopenharmony_ci	int resize_srq;
1228c2ecf20Sopenharmony_ci	u32 bmme_flags;
1238c2ecf20Sopenharmony_ci	u32 reserved_lkey;
1248c2ecf20Sopenharmony_ci	u64 max_icm_sz;
1258c2ecf20Sopenharmony_ci	int max_gso_sz;
1268c2ecf20Sopenharmony_ci	int max_rss_tbl_sz;
1278c2ecf20Sopenharmony_ci	u32 max_counters;
1288c2ecf20Sopenharmony_ci	u32 dmfs_high_rate_qpn_base;
1298c2ecf20Sopenharmony_ci	u32 dmfs_high_rate_qpn_range;
1308c2ecf20Sopenharmony_ci	struct mlx4_rate_limit_caps rl_caps;
1318c2ecf20Sopenharmony_ci	u32 health_buffer_addrs;
1328c2ecf20Sopenharmony_ci	struct mlx4_port_cap port_cap[MLX4_MAX_PORTS + 1];
1338c2ecf20Sopenharmony_ci	bool wol_port[MLX4_MAX_PORTS + 1];
1348c2ecf20Sopenharmony_ci	bool map_clock_to_user;
1358c2ecf20Sopenharmony_ci};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cistruct mlx4_func_cap {
1388c2ecf20Sopenharmony_ci	u8	num_ports;
1398c2ecf20Sopenharmony_ci	u8	flags;
1408c2ecf20Sopenharmony_ci	u32	pf_context_behaviour;
1418c2ecf20Sopenharmony_ci	int	qp_quota;
1428c2ecf20Sopenharmony_ci	int	cq_quota;
1438c2ecf20Sopenharmony_ci	int	srq_quota;
1448c2ecf20Sopenharmony_ci	int	mpt_quota;
1458c2ecf20Sopenharmony_ci	int	mtt_quota;
1468c2ecf20Sopenharmony_ci	int	max_eq;
1478c2ecf20Sopenharmony_ci	int	reserved_eq;
1488c2ecf20Sopenharmony_ci	int	mcg_quota;
1498c2ecf20Sopenharmony_ci	struct mlx4_spec_qps spec_qps;
1508c2ecf20Sopenharmony_ci	u32	reserved_lkey;
1518c2ecf20Sopenharmony_ci	u8	physical_port;
1528c2ecf20Sopenharmony_ci	u8	flags0;
1538c2ecf20Sopenharmony_ci	u8	flags1;
1548c2ecf20Sopenharmony_ci	u64	phys_port_id;
1558c2ecf20Sopenharmony_ci	u32	extra_flags;
1568c2ecf20Sopenharmony_ci};
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cistruct mlx4_func {
1598c2ecf20Sopenharmony_ci	int	bus;
1608c2ecf20Sopenharmony_ci	int	device;
1618c2ecf20Sopenharmony_ci	int	function;
1628c2ecf20Sopenharmony_ci	int	physical_function;
1638c2ecf20Sopenharmony_ci	int	rsvd_eqs;
1648c2ecf20Sopenharmony_ci	int	max_eq;
1658c2ecf20Sopenharmony_ci	int	rsvd_uars;
1668c2ecf20Sopenharmony_ci};
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_cistruct mlx4_adapter {
1698c2ecf20Sopenharmony_ci	char board_id[MLX4_BOARD_ID_LEN];
1708c2ecf20Sopenharmony_ci	u8   inta_pin;
1718c2ecf20Sopenharmony_ci};
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_cistruct mlx4_init_hca_param {
1748c2ecf20Sopenharmony_ci	u64 qpc_base;
1758c2ecf20Sopenharmony_ci	u64 rdmarc_base;
1768c2ecf20Sopenharmony_ci	u64 auxc_base;
1778c2ecf20Sopenharmony_ci	u64 altc_base;
1788c2ecf20Sopenharmony_ci	u64 srqc_base;
1798c2ecf20Sopenharmony_ci	u64 cqc_base;
1808c2ecf20Sopenharmony_ci	u64 eqc_base;
1818c2ecf20Sopenharmony_ci	u64 mc_base;
1828c2ecf20Sopenharmony_ci	u64 dmpt_base;
1838c2ecf20Sopenharmony_ci	u64 cmpt_base;
1848c2ecf20Sopenharmony_ci	u64 mtt_base;
1858c2ecf20Sopenharmony_ci	u64 global_caps;
1868c2ecf20Sopenharmony_ci	u8 log_mc_entry_sz;
1878c2ecf20Sopenharmony_ci	u8 log_mc_hash_sz;
1888c2ecf20Sopenharmony_ci	u16 hca_core_clock; /* Internal Clock Frequency (in MHz) */
1898c2ecf20Sopenharmony_ci	u8  log_num_qps;
1908c2ecf20Sopenharmony_ci	u8  log_num_srqs;
1918c2ecf20Sopenharmony_ci	u8  log_num_cqs;
1928c2ecf20Sopenharmony_ci	u8  log_num_eqs;
1938c2ecf20Sopenharmony_ci	u16 num_sys_eqs;
1948c2ecf20Sopenharmony_ci	u8  log_rd_per_qp;
1958c2ecf20Sopenharmony_ci	u8  log_mc_table_sz;
1968c2ecf20Sopenharmony_ci	u8  log_mpt_sz;
1978c2ecf20Sopenharmony_ci	u8  log_uar_sz;
1988c2ecf20Sopenharmony_ci	u8  mw_enabled;  /* Enable memory windows */
1998c2ecf20Sopenharmony_ci	u8  uar_page_sz; /* log pg sz in 4k chunks */
2008c2ecf20Sopenharmony_ci	u8  steering_mode; /* for QUERY_HCA */
2018c2ecf20Sopenharmony_ci	u8  dmfs_high_steer_mode; /* for QUERY_HCA */
2028c2ecf20Sopenharmony_ci	u64 dev_cap_enabled;
2038c2ecf20Sopenharmony_ci	u16 cqe_size; /* For use only when CQE stride feature enabled */
2048c2ecf20Sopenharmony_ci	u16 eqe_size; /* For use only when EQE stride feature enabled */
2058c2ecf20Sopenharmony_ci	u8 rss_ip_frags;
2068c2ecf20Sopenharmony_ci	u8 phv_check_en; /* for QUERY_HCA */
2078c2ecf20Sopenharmony_ci};
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistruct mlx4_init_ib_param {
2108c2ecf20Sopenharmony_ci	int port_width;
2118c2ecf20Sopenharmony_ci	int vl_cap;
2128c2ecf20Sopenharmony_ci	int mtu_cap;
2138c2ecf20Sopenharmony_ci	u16 gid_cap;
2148c2ecf20Sopenharmony_ci	u16 pkey_cap;
2158c2ecf20Sopenharmony_ci	int set_guid0;
2168c2ecf20Sopenharmony_ci	u64 guid0;
2178c2ecf20Sopenharmony_ci	int set_node_guid;
2188c2ecf20Sopenharmony_ci	u64 node_guid;
2198c2ecf20Sopenharmony_ci	int set_si_guid;
2208c2ecf20Sopenharmony_ci	u64 si_guid;
2218c2ecf20Sopenharmony_ci};
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_cistruct mlx4_set_ib_param {
2248c2ecf20Sopenharmony_ci	int set_si_guid;
2258c2ecf20Sopenharmony_ci	int reset_qkey_viol;
2268c2ecf20Sopenharmony_ci	u64 si_guid;
2278c2ecf20Sopenharmony_ci	u32 cap_mask;
2288c2ecf20Sopenharmony_ci};
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_civoid mlx4_dev_cap_dump(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap);
2318c2ecf20Sopenharmony_ciint mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap);
2328c2ecf20Sopenharmony_ciint mlx4_QUERY_PORT(struct mlx4_dev *dev, int port, struct mlx4_port_cap *port_cap);
2338c2ecf20Sopenharmony_ciint mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u8 gen_or_port,
2348c2ecf20Sopenharmony_ci			struct mlx4_func_cap *func_cap);
2358c2ecf20Sopenharmony_ciint mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave,
2368c2ecf20Sopenharmony_ci				struct mlx4_vhcr *vhcr,
2378c2ecf20Sopenharmony_ci				struct mlx4_cmd_mailbox *inbox,
2388c2ecf20Sopenharmony_ci				struct mlx4_cmd_mailbox *outbox,
2398c2ecf20Sopenharmony_ci				struct mlx4_cmd_info *cmd);
2408c2ecf20Sopenharmony_ciint mlx4_QUERY_FUNC(struct mlx4_dev *dev, struct mlx4_func *func, int slave);
2418c2ecf20Sopenharmony_ciint mlx4_MAP_FA(struct mlx4_dev *dev, struct mlx4_icm *icm);
2428c2ecf20Sopenharmony_ciint mlx4_UNMAP_FA(struct mlx4_dev *dev);
2438c2ecf20Sopenharmony_ciint mlx4_RUN_FW(struct mlx4_dev *dev);
2448c2ecf20Sopenharmony_ciint mlx4_QUERY_FW(struct mlx4_dev *dev);
2458c2ecf20Sopenharmony_ciint mlx4_QUERY_ADAPTER(struct mlx4_dev *dev, struct mlx4_adapter *adapter);
2468c2ecf20Sopenharmony_ciint mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param);
2478c2ecf20Sopenharmony_ciint mlx4_QUERY_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param);
2488c2ecf20Sopenharmony_ciint mlx4_CLOSE_HCA(struct mlx4_dev *dev, int panic);
2498c2ecf20Sopenharmony_ciint mlx4_map_cmd(struct mlx4_dev *dev, u16 op, struct mlx4_icm *icm, u64 virt);
2508c2ecf20Sopenharmony_ciint mlx4_SET_ICM_SIZE(struct mlx4_dev *dev, u64 icm_size, u64 *aux_pages);
2518c2ecf20Sopenharmony_ciint mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm);
2528c2ecf20Sopenharmony_ciint mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev);
2538c2ecf20Sopenharmony_ciint mlx4_NOP(struct mlx4_dev *dev);
2548c2ecf20Sopenharmony_ciint mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg);
2558c2ecf20Sopenharmony_civoid mlx4_opreq_action(struct work_struct *work);
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci#endif /* MLX4_FW_H */
258