mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
78 lines
1.6 KiB
C
78 lines
1.6 KiB
C
![]() |
/* SPDX-License-Identifier: GPL-2.0 */
|
||
|
/* Marvell OcteonTx2 RVU Ethernet driver
|
||
|
*
|
||
|
* Copyright (C) 2020 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 OTX2_COMMON_H
|
||
|
#define OTX2_COMMON_H
|
||
|
|
||
|
#include <linux/pci.h>
|
||
|
|
||
|
#include "otx2_reg.h"
|
||
|
|
||
|
/* PCI device IDs */
|
||
|
#define PCI_DEVID_OCTEONTX2_RVU_PF 0xA063
|
||
|
|
||
|
/* PCI BAR nos */
|
||
|
#define PCI_CFG_REG_BAR_NUM 2
|
||
|
|
||
|
struct otx2_hw {
|
||
|
struct pci_dev *pdev;
|
||
|
u16 rx_queues;
|
||
|
u16 tx_queues;
|
||
|
u16 max_queues;
|
||
|
};
|
||
|
|
||
|
struct otx2_nic {
|
||
|
void __iomem *reg_base;
|
||
|
struct net_device *netdev;
|
||
|
|
||
|
struct otx2_hw hw;
|
||
|
struct pci_dev *pdev;
|
||
|
struct device *dev;
|
||
|
};
|
||
|
|
||
|
/* Register read/write APIs */
|
||
|
static inline void __iomem *otx2_get_regaddr(struct otx2_nic *nic, u64 offset)
|
||
|
{
|
||
|
u64 blkaddr;
|
||
|
|
||
|
switch ((offset >> RVU_FUNC_BLKADDR_SHIFT) & RVU_FUNC_BLKADDR_MASK) {
|
||
|
case BLKTYPE_NIX:
|
||
|
blkaddr = BLKADDR_NIX0;
|
||
|
break;
|
||
|
case BLKTYPE_NPA:
|
||
|
blkaddr = BLKADDR_NPA;
|
||
|
break;
|
||
|
default:
|
||
|
blkaddr = BLKADDR_RVUM;
|
||
|
break;
|
||
|
};
|
||
|
|
||
|
offset &= ~(RVU_FUNC_BLKADDR_MASK << RVU_FUNC_BLKADDR_SHIFT);
|
||
|
offset |= (blkaddr << RVU_FUNC_BLKADDR_SHIFT);
|
||
|
|
||
|
return nic->reg_base + offset;
|
||
|
}
|
||
|
|
||
|
static inline void otx2_write64(struct otx2_nic *nic, u64 offset, u64 val)
|
||
|
{
|
||
|
void __iomem *addr = otx2_get_regaddr(nic, offset);
|
||
|
|
||
|
writeq(val, addr);
|
||
|
}
|
||
|
|
||
|
static inline u64 otx2_read64(struct otx2_nic *nic, u64 offset)
|
||
|
{
|
||
|
void __iomem *addr = otx2_get_regaddr(nic, offset);
|
||
|
|
||
|
return readq(addr);
|
||
|
}
|
||
|
|
||
|
#endif /* OTX2_COMMON_H */
|