2018-10-10 12:44:21 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
* Marvell OcteonTx2 RVU Admin Function driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Marvell International Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RVU_H
|
|
|
|
#define RVU_H
|
|
|
|
|
2018-10-10 12:44:22 +00:00
|
|
|
#include "rvu_struct.h"
|
|
|
|
|
2018-10-10 12:44:21 +00:00
|
|
|
/* PCI device IDs */
|
|
|
|
#define PCI_DEVID_OCTEONTX2_RVU_AF 0xA065
|
|
|
|
|
|
|
|
/* PCI BAR nos */
|
|
|
|
#define PCI_AF_REG_BAR_NUM 0
|
|
|
|
#define PCI_PF_REG_BAR_NUM 2
|
|
|
|
#define PCI_MBOX_BAR_NUM 4
|
|
|
|
|
|
|
|
#define NAME_SIZE 32
|
|
|
|
|
2018-10-10 12:44:23 +00:00
|
|
|
struct rsrc_bmap {
|
|
|
|
unsigned long *bmap; /* Pointer to resource bitmap */
|
|
|
|
u16 max; /* Max resource id or count */
|
|
|
|
};
|
|
|
|
|
2018-10-10 12:44:22 +00:00
|
|
|
struct rvu_block {
|
2018-10-10 12:44:23 +00:00
|
|
|
struct rsrc_bmap lf;
|
|
|
|
bool multislot;
|
2018-10-10 12:44:22 +00:00
|
|
|
bool implemented;
|
2018-10-10 12:44:23 +00:00
|
|
|
u8 addr; /* RVU_BLOCK_ADDR_E */
|
|
|
|
u8 lfshift;
|
|
|
|
u64 lookup_reg;
|
|
|
|
u64 pf_lfcnt_reg;
|
|
|
|
u64 vf_lfcnt_reg;
|
|
|
|
u64 lfcfg_reg;
|
|
|
|
u64 msixcfg_reg;
|
|
|
|
u64 lfreset_reg;
|
|
|
|
unsigned char name[NAME_SIZE];
|
2018-10-10 12:44:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rvu_hwinfo {
|
2018-10-10 12:44:23 +00:00
|
|
|
u8 total_pfs; /* MAX RVU PFs HW supports */
|
|
|
|
u16 total_vfs; /* Max RVU VFs HW supports */
|
|
|
|
u16 max_vfs_per_pf; /* Max VFs that can be attached to a PF */
|
|
|
|
|
2018-10-10 12:44:22 +00:00
|
|
|
struct rvu_block block[BLK_COUNT]; /* Block info */
|
|
|
|
};
|
|
|
|
|
2018-10-10 12:44:21 +00:00
|
|
|
struct rvu {
|
|
|
|
void __iomem *afreg_base;
|
|
|
|
void __iomem *pfreg_base;
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
struct device *dev;
|
2018-10-10 12:44:22 +00:00
|
|
|
struct rvu_hwinfo *hw;
|
2018-10-10 12:44:21 +00:00
|
|
|
};
|
|
|
|
|
2018-10-10 12:44:22 +00:00
|
|
|
static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
|
|
|
|
{
|
|
|
|
writeq(val, rvu->afreg_base + ((block << 28) | offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u64 rvu_read64(struct rvu *rvu, u64 block, u64 offset)
|
|
|
|
{
|
|
|
|
return readq(rvu->afreg_base + ((block << 28) | offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rvupf_write64(struct rvu *rvu, u64 offset, u64 val)
|
|
|
|
{
|
|
|
|
writeq(val, rvu->pfreg_base + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u64 rvupf_read64(struct rvu *rvu, u64 offset)
|
|
|
|
{
|
|
|
|
return readq(rvu->pfreg_base + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Function Prototypes
|
|
|
|
* RVU
|
|
|
|
*/
|
|
|
|
|
2018-10-10 12:44:23 +00:00
|
|
|
int rvu_alloc_bitmap(struct rsrc_bmap *rsrc);
|
2018-10-10 12:44:22 +00:00
|
|
|
int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
|
|
|
|
|
2018-10-10 12:44:21 +00:00
|
|
|
#endif /* RVU_H */
|