162306a36Sopenharmony_ci/* Broadcom NetXtreme-C/E network driver.
262306a36Sopenharmony_ci *
362306a36Sopenharmony_ci * Copyright (c) 2017 Broadcom Limited
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
662306a36Sopenharmony_ci * it under the terms of the GNU General Public License as published by
762306a36Sopenharmony_ci * the Free Software Foundation.
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef BNXT_DEVLINK_H
1162306a36Sopenharmony_ci#define BNXT_DEVLINK_H
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* Struct to hold housekeeping info needed by devlink interface */
1462306a36Sopenharmony_cistruct bnxt_dl {
1562306a36Sopenharmony_ci	struct bnxt *bp;	/* back ptr to the controlling dev */
1662306a36Sopenharmony_ci	bool remote_reset;
1762306a36Sopenharmony_ci};
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_cistatic inline struct bnxt *bnxt_get_bp_from_dl(struct devlink *dl)
2062306a36Sopenharmony_ci{
2162306a36Sopenharmony_ci	return ((struct bnxt_dl *)devlink_priv(dl))->bp;
2262306a36Sopenharmony_ci}
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_cistatic inline void bnxt_dl_remote_reload(struct bnxt *bp)
2562306a36Sopenharmony_ci{
2662306a36Sopenharmony_ci	devlink_remote_reload_actions_performed(bp->dl, 0,
2762306a36Sopenharmony_ci						BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) |
2862306a36Sopenharmony_ci						BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE));
2962306a36Sopenharmony_ci}
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_cistatic inline bool bnxt_dl_get_remote_reset(struct devlink *dl)
3262306a36Sopenharmony_ci{
3362306a36Sopenharmony_ci	return ((struct bnxt_dl *)devlink_priv(dl))->remote_reset;
3462306a36Sopenharmony_ci}
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_cistatic inline void bnxt_dl_set_remote_reset(struct devlink *dl, bool value)
3762306a36Sopenharmony_ci{
3862306a36Sopenharmony_ci	((struct bnxt_dl *)devlink_priv(dl))->remote_reset = value;
3962306a36Sopenharmony_ci}
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define NVM_OFF_MSIX_VEC_PER_PF_MAX	108
4262306a36Sopenharmony_ci#define NVM_OFF_MSIX_VEC_PER_PF_MIN	114
4362306a36Sopenharmony_ci#define NVM_OFF_IGNORE_ARI		164
4462306a36Sopenharmony_ci#define NVM_OFF_DIS_GRE_VER_CHECK	171
4562306a36Sopenharmony_ci#define NVM_OFF_ENABLE_SRIOV		401
4662306a36Sopenharmony_ci#define NVM_OFF_NVM_CFG_VER		602
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define BNXT_NVM_CFG_VER_BITS		8
4962306a36Sopenharmony_ci#define BNXT_NVM_CFG_VER_BYTES		1
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#define BNXT_MSIX_VEC_MAX	512
5262306a36Sopenharmony_ci#define BNXT_MSIX_VEC_MIN_MAX	128
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_cienum bnxt_nvm_dir_type {
5562306a36Sopenharmony_ci	BNXT_NVM_SHARED_CFG = 40,
5662306a36Sopenharmony_ci	BNXT_NVM_PORT_CFG,
5762306a36Sopenharmony_ci	BNXT_NVM_FUNC_CFG,
5862306a36Sopenharmony_ci};
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_cistruct bnxt_dl_nvm_param {
6162306a36Sopenharmony_ci	u16 id;
6262306a36Sopenharmony_ci	u16 offset;
6362306a36Sopenharmony_ci	u16 dir_type;
6462306a36Sopenharmony_ci	u16 nvm_num_bits;
6562306a36Sopenharmony_ci	u8 dl_num_bytes;
6662306a36Sopenharmony_ci};
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_cienum bnxt_dl_version_type {
6962306a36Sopenharmony_ci	BNXT_VERSION_FIXED,
7062306a36Sopenharmony_ci	BNXT_VERSION_RUNNING,
7162306a36Sopenharmony_ci	BNXT_VERSION_STORED,
7262306a36Sopenharmony_ci};
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_civoid bnxt_devlink_health_fw_report(struct bnxt *bp);
7562306a36Sopenharmony_civoid bnxt_dl_health_fw_status_update(struct bnxt *bp, bool healthy);
7662306a36Sopenharmony_civoid bnxt_dl_health_fw_recovery_done(struct bnxt *bp);
7762306a36Sopenharmony_civoid bnxt_dl_fw_reporters_create(struct bnxt *bp);
7862306a36Sopenharmony_civoid bnxt_dl_fw_reporters_destroy(struct bnxt *bp);
7962306a36Sopenharmony_ciint bnxt_dl_register(struct bnxt *bp);
8062306a36Sopenharmony_civoid bnxt_dl_unregister(struct bnxt *bp);
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci#endif /* BNXT_DEVLINK_H */
83