spnic_dev_mgmt.h 1.9 KB
Newer Older
Y
Yanling Song 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright(c) 2021 Ramaxel Memory Technology, Ltd */

#ifndef SPNIC_DEV_MGMT_H
#define SPNIC_DEV_MGMT_H
#include <linux/types.h>
#include <linux/bitops.h>

#define SPHW_CHIP_NAME	"spnic"

#define SPNIC_VF_PCI_CFG_REG_BAR	0
#define SPNIC_PF_PCI_CFG_REG_BAR	1

#define SPNIC_PCI_INTR_REG_BAR		2
#define SPNIC_PCI_MGMT_REG_BAR		3 /* Only PF have mgmt bar */
#define SPNIC_PCI_DB_BAR		4

/* Structure pcidev private*/
struct spnic_pcidev {
	struct pci_dev *pcidev;
	void *hwdev;
	struct card_node *chip_node;
	struct spnic_lld_dev lld_dev;
	/* Record the service object address,
	 * such as spnic_dev and toe_dev, fc_dev
	 */
	void *uld_dev[SERVICE_T_MAX];
	/* Record the service object name */
	char uld_dev_name[SERVICE_T_MAX][IFNAMSIZ];
	/* It is a the global variable for driver to manage
	 * all function device linked list
	 */
	struct list_head node;

	bool disable_vf_load;
	bool disable_srv_load[SERVICE_T_MAX];

	void __iomem *cfg_reg_base;
	void __iomem *intr_reg_base;
	void __iomem *mgmt_reg_base;
	u64 db_dwqe_len;
	u64 db_base_phy;
	void __iomem *db_base;

	/* lock for attach/detach uld */
	struct mutex pdev_mutex;

	struct spnic_sriov_info sriov_info;

	/* setted when uld driver processing event */
	unsigned long state;
	struct pci_device_id id;

	atomic_t ref_cnt;
};

extern struct list_head g_spnic_chip_list;

extern struct spnic_uld_info g_uld_info[SERVICE_T_MAX];

int alloc_chip_node(struct spnic_pcidev *pci_adapter);

void free_chip_node(struct spnic_pcidev *pci_adapter);

void lld_lock_chip_node(void);

void lld_unlock_chip_node(void);

void spnic_lld_lock_init(void);

void lld_dev_cnt_init(struct spnic_pcidev *pci_adapter);
void wait_lld_dev_unused(struct spnic_pcidev *pci_adapter);

int spnic_get_uld_dev_name(struct spnic_pcidev *dev, enum sphw_service_type type, char *ifname);

void *spnic_get_hwdev_by_pcidev(struct pci_dev *pdev);

#endif