18c2ecf20Sopenharmony_ci/* Broadcom NetXtreme-C/E network driver.
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * Copyright (c) 2017 Broadcom Limited
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
68c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
78c2ecf20Sopenharmony_ci * the Free Software Foundation.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef BNXT_DEVLINK_H
118c2ecf20Sopenharmony_ci#define BNXT_DEVLINK_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* Struct to hold housekeeping info needed by devlink interface */
148c2ecf20Sopenharmony_cistruct bnxt_dl {
158c2ecf20Sopenharmony_ci	struct bnxt *bp;	/* back ptr to the controlling dev */
168c2ecf20Sopenharmony_ci};
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistatic inline struct bnxt *bnxt_get_bp_from_dl(struct devlink *dl)
198c2ecf20Sopenharmony_ci{
208c2ecf20Sopenharmony_ci	return ((struct bnxt_dl *)devlink_priv(dl))->bp;
218c2ecf20Sopenharmony_ci}
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* To clear devlink pointer from bp, pass NULL dl */
248c2ecf20Sopenharmony_cistatic inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl)
258c2ecf20Sopenharmony_ci{
268c2ecf20Sopenharmony_ci	bp->dl = dl;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	/* add a back pointer in dl to bp */
298c2ecf20Sopenharmony_ci	if (dl) {
308c2ecf20Sopenharmony_ci		struct bnxt_dl *bp_dl = devlink_priv(dl);
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci		bp_dl->bp = bp;
338c2ecf20Sopenharmony_ci	}
348c2ecf20Sopenharmony_ci}
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#define NVM_OFF_MSIX_VEC_PER_PF_MAX	108
378c2ecf20Sopenharmony_ci#define NVM_OFF_MSIX_VEC_PER_PF_MIN	114
388c2ecf20Sopenharmony_ci#define NVM_OFF_IGNORE_ARI		164
398c2ecf20Sopenharmony_ci#define NVM_OFF_DIS_GRE_VER_CHECK	171
408c2ecf20Sopenharmony_ci#define NVM_OFF_ENABLE_SRIOV		401
418c2ecf20Sopenharmony_ci#define NVM_OFF_NVM_CFG_VER		602
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define BNXT_NVM_CFG_VER_BITS		24
448c2ecf20Sopenharmony_ci#define BNXT_NVM_CFG_VER_BYTES		4
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define BNXT_MSIX_VEC_MAX	512
478c2ecf20Sopenharmony_ci#define BNXT_MSIX_VEC_MIN_MAX	128
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cienum bnxt_nvm_dir_type {
508c2ecf20Sopenharmony_ci	BNXT_NVM_SHARED_CFG = 40,
518c2ecf20Sopenharmony_ci	BNXT_NVM_PORT_CFG,
528c2ecf20Sopenharmony_ci	BNXT_NVM_FUNC_CFG,
538c2ecf20Sopenharmony_ci};
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_cistruct bnxt_dl_nvm_param {
568c2ecf20Sopenharmony_ci	u16 id;
578c2ecf20Sopenharmony_ci	u16 offset;
588c2ecf20Sopenharmony_ci	u16 dir_type;
598c2ecf20Sopenharmony_ci	u16 nvm_num_bits;
608c2ecf20Sopenharmony_ci	u8 dl_num_bytes;
618c2ecf20Sopenharmony_ci};
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_cienum bnxt_dl_version_type {
648c2ecf20Sopenharmony_ci	BNXT_VERSION_FIXED,
658c2ecf20Sopenharmony_ci	BNXT_VERSION_RUNNING,
668c2ecf20Sopenharmony_ci	BNXT_VERSION_STORED,
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_civoid bnxt_devlink_health_report(struct bnxt *bp, unsigned long event);
708c2ecf20Sopenharmony_civoid bnxt_dl_health_status_update(struct bnxt *bp, bool healthy);
718c2ecf20Sopenharmony_civoid bnxt_dl_health_recovery_done(struct bnxt *bp);
728c2ecf20Sopenharmony_civoid bnxt_dl_fw_reporters_create(struct bnxt *bp);
738c2ecf20Sopenharmony_civoid bnxt_dl_fw_reporters_destroy(struct bnxt *bp, bool all);
748c2ecf20Sopenharmony_ciint bnxt_dl_register(struct bnxt *bp);
758c2ecf20Sopenharmony_civoid bnxt_dl_unregister(struct bnxt *bp);
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#endif /* BNXT_DEVLINK_H */
78