linux/drivers/net/ethernet/amd/pds_core/core.h

/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright(c) 2023 Advanced Micro Devices, Inc */

#ifndef _PDSC_H_
#define _PDSC_H_

#include <linux/debugfs.h>
#include <net/devlink.h>

#include <linux/pds/pds_common.h>
#include <linux/pds/pds_core_if.h>
#include <linux/pds/pds_adminq.h>
#include <linux/pds/pds_intr.h>

#define PDSC_DRV_DESCRIPTION

#define PDSC_WATCHDOG_SECS
#define PDSC_QUEUE_NAME_MAX_SZ
#define PDSC_ADMINQ_MIN_LENGTH
#define PDSC_NOTIFYQ_LENGTH
#define PDSC_TEARDOWN_RECOVERY
#define PDSC_TEARDOWN_REMOVING
#define PDSC_SETUP_RECOVERY
#define PDSC_SETUP_INIT

struct pdsc_dev_bar {};

struct pdsc;

struct pdsc_vf {};

struct pdsc_devinfo {};

struct pdsc_queue {};

#define PDSC_INTR_NAME_MAX_SZ

struct pdsc_intr_info {};

struct pdsc_cq_info {};

struct pdsc_buf_info {};

struct pdsc_q_info {};

struct pdsc_cq {} ____cacheline_aligned_in_smp;

struct pdsc_qcq {};

struct pdsc_viftype {};

/* No state flags set means we are in a steady running state */
enum pdsc_state_flags {};

struct pdsc {};

/** enum pds_core_dbell_bits - bitwise composition of dbell values.
 *
 * @PDS_CORE_DBELL_QID_MASK:	unshifted mask of valid queue id bits.
 * @PDS_CORE_DBELL_QID_SHIFT:	queue id shift amount in dbell value.
 * @PDS_CORE_DBELL_QID:		macro to build QID component of dbell value.
 *
 * @PDS_CORE_DBELL_RING_MASK:	unshifted mask of valid ring bits.
 * @PDS_CORE_DBELL_RING_SHIFT:	ring shift amount in dbell value.
 * @PDS_CORE_DBELL_RING:	macro to build ring component of dbell value.
 *
 * @PDS_CORE_DBELL_RING_0:	ring zero dbell component value.
 * @PDS_CORE_DBELL_RING_1:	ring one dbell component value.
 * @PDS_CORE_DBELL_RING_2:	ring two dbell component value.
 * @PDS_CORE_DBELL_RING_3:	ring three dbell component value.
 *
 * @PDS_CORE_DBELL_INDEX_MASK:	bit mask of valid index bits, no shift needed.
 */
enum pds_core_dbell_bits {};

static inline void pds_core_dbell_ring(u64 __iomem *db_page,
				       enum pds_core_logical_qtype qtype,
				       u64 val)
{}

int pdsc_fw_reporter_diagnose(struct devlink_health_reporter *reporter,
			      struct devlink_fmsg *fmsg,
			      struct netlink_ext_ack *extack);
int pdsc_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
		     struct netlink_ext_ack *extack);
int pdsc_dl_flash_update(struct devlink *dl,
			 struct devlink_flash_update_params *params,
			 struct netlink_ext_ack *extack);
int pdsc_dl_enable_get(struct devlink *dl, u32 id,
		       struct devlink_param_gset_ctx *ctx);
int pdsc_dl_enable_set(struct devlink *dl, u32 id,
		       struct devlink_param_gset_ctx *ctx,
		       struct netlink_ext_ack *extack);
int pdsc_dl_enable_validate(struct devlink *dl, u32 id,
			    union devlink_param_value val,
			    struct netlink_ext_ack *extack);

void __iomem *pdsc_map_dbpage(struct pdsc *pdsc, int page_num);

void pdsc_debugfs_create(void);
void pdsc_debugfs_destroy(void);
void pdsc_debugfs_add_dev(struct pdsc *pdsc);
void pdsc_debugfs_del_dev(struct pdsc *pdsc);
void pdsc_debugfs_add_ident(struct pdsc *pdsc);
void pdsc_debugfs_add_viftype(struct pdsc *pdsc);
void pdsc_debugfs_add_irqs(struct pdsc *pdsc);
void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq);
void pdsc_debugfs_del_qcq(struct pdsc_qcq *qcq);

int pdsc_err_to_errno(enum pds_core_status_code code);
bool pdsc_is_fw_running(struct pdsc *pdsc);
bool pdsc_is_fw_good(struct pdsc *pdsc);
int pdsc_devcmd(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,
		union pds_core_dev_comp *comp, int max_seconds);
int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,
		       union pds_core_dev_comp *comp, int max_seconds);
int pdsc_devcmd_init(struct pdsc *pdsc);
int pdsc_devcmd_reset(struct pdsc *pdsc);
int pdsc_dev_init(struct pdsc *pdsc);
void pdsc_dev_uninit(struct pdsc *pdsc);

int pdsc_intr_alloc(struct pdsc *pdsc, char *name,
		    irq_handler_t handler, void *data);
void pdsc_intr_free(struct pdsc *pdsc, int index);
void pdsc_qcq_free(struct pdsc *pdsc, struct pdsc_qcq *qcq);
int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type, unsigned int index,
		   const char *name, unsigned int flags, unsigned int num_descs,
		   unsigned int desc_size, unsigned int cq_desc_size,
		   unsigned int pid, struct pdsc_qcq *qcq);
int pdsc_setup(struct pdsc *pdsc, bool init);
void pdsc_teardown(struct pdsc *pdsc, bool removing);
int pdsc_start(struct pdsc *pdsc);
void pdsc_stop(struct pdsc *pdsc);
void pdsc_health_thread(struct work_struct *work);

int pdsc_register_notify(struct notifier_block *nb);
void pdsc_unregister_notify(struct notifier_block *nb);
void pdsc_notify(unsigned long event, void *data);
int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf);
int pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf);

void pdsc_process_adminq(struct pdsc_qcq *qcq);
void pdsc_work_thread(struct work_struct *work);
irqreturn_t pdsc_adminq_isr(int irq, void *data);

int pdsc_firmware_update(struct pdsc *pdsc, const struct firmware *fw,
			 struct netlink_ext_ack *extack);

void pdsc_fw_down(struct pdsc *pdsc);
void pdsc_fw_up(struct pdsc *pdsc);
void pdsc_pci_reset_thread(struct work_struct *work);

#endif /* _PDSC_H_ */