Skip to contentSkip to conversation

soc: octeontx2: Add RVU admin function driver

PATCH Superseded [email protected] 3 participants 45 messages Aug 28, 2018 – Aug 31, 2018

Subsystems (3)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

cover soc: octeontx2: Add RVU admin function driver

From: Sunil Goutham <[email protected]>

Resource virtualization unit (RVU) on Marvell's OcteonTX2 SOC supports multiple PCIe SRIOV physical functions (PFs) and virtual functions (VFs). PF0 is called administrative / admin function (AF) and has privilege access to registers to provision different RVU functional blocks to each of PF/VF.

This admin function (AF) driver acts as a configuration / administrative software which provisions functional blocks to a PF/VF on demand for them to work as one of the following
- A basic network controller (i.e NIC).
- NIC with packet filtering, shaping and scheduling capabilities.
- A crypto device.
- A combination of above etc.

PF/VFs communicate with admin function via a shared memory region. This patch series adds logic for the following
- RVU AF driver with functional blocks provisioning support
- Mailbox infrastructure for communication between AF and PFs.
- CGX driver which provides information about physcial network interfaces which AF processes and forwards required info to PF/VF drivers.

This is the first set of patches out of 70 odd patches.

Note: This driver neither receives any data nor processes it i.e no I/O,
just does the hardware configuration.

Aleksey Makarov (2):
soc: octeontx2: Add mailbox support infra
soc: octeontx2: Convert mbox msg id check to a macro

Geetha sowjanya (1):
soc: octeontx2: Reconfig MSIX base with IOVA

Linu Cherian (3):
soc: octeontx2: Set RVU PFs to CGX LMACs mapping
soc: octeontx2: Add support for CGX link management
soc: octeontx2: Register for CGX lmac events

Sunil Goutham (9):
soc: octeontx2: Add Marvell OcteonTX2 RVU AF driver
soc: octeontx2: Reset all RVU blocks
soc: octeontx2: Gather RVU blocks HW info
soc: octeontx2: Add mailbox IRQ and msg handlers
soc: octeontx2: Scan blocks for LFs provisioned to PF/VF
soc: octeontx2: Add RVU block LF provisioning support
soc: octeontx2: Configure block LF's MSIX vector offset
soc: octeontx2: Add Marvell OcteonTX2 CGX driver
MAINTAINERS: Add entry for Marvell OcteonTX2 Admin Function driver

 MAINTAINERS                                |   10 +
 drivers/soc/Kconfig                        |    1 +
 drivers/soc/Makefile                       |    1 +
 drivers/soc/marvell/Kconfig                |   23 +
 drivers/soc/marvell/Makefile               |    2 +
 drivers/soc/marvell/octeontx2/Makefile     |   10 +
 drivers/soc/marvell/octeontx2/cgx.c        |  529 +++++++++
 drivers/soc/marvell/octeontx2/cgx.h        |   63 ++
 drivers/soc/marvell/octeontx2/cgx_fw_if.h  |  225 ++++
 drivers/soc/marvell/octeontx2/mbox.c       |  300 +++++
 drivers/soc/marvell/octeontx2/mbox.h       |  211 ++++
 drivers/soc/marvell/octeontx2/rvu.c        | 1625 ++++++++++++++++++++++++++++
 drivers/soc/marvell/octeontx2/rvu.h        |  158 +++
 drivers/soc/marvell/octeontx2/rvu_cgx.c    |  194 ++++
 drivers/soc/marvell/octeontx2/rvu_reg.h    |  442 ++++++++
 drivers/soc/marvell/octeontx2/rvu_struct.h |   78 ++
 16 files changed, 3872 insertions(+)
 create mode 100644 drivers/soc/marvell/Kconfig
 create mode 100644 drivers/soc/marvell/Makefile
 create mode 100644 drivers/soc/marvell/octeontx2/Makefile
 create mode 100644 drivers/soc/marvell/octeontx2/cgx.c
 create mode 100644 drivers/soc/marvell/octeontx2/cgx.h
 create mode 100644 drivers/soc/marvell/octeontx2/cgx_fw_if.h
 create mode 100644 drivers/soc/marvell/octeontx2/mbox.c
 create mode 100644 drivers/soc/marvell/octeontx2/mbox.h
 create mode 100644 drivers/soc/marvell/octeontx2/rvu.c
 create mode 100644 drivers/soc/marvell/octeontx2/rvu.h
 create mode 100644 drivers/soc/marvell/octeontx2/rvu_cgx.c
 create mode 100644 drivers/soc/marvell/octeontx2/rvu_reg.h
 create mode 100644 drivers/soc/marvell/octeontx2/rvu_struct.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/15 soc: octeontx2: Add Marvell OcteonTX2 RVU AF driver

From: Sunil Goutham <[email protected]>

This patch adds basic template for Marvell OcteonTX2's resource virtualization unit (RVU) admin function (AF) driver. Just the driver registration and probe.

---
 drivers/soc/Kconfig                    |   1 +
 drivers/soc/Makefile                   |   1 +
 drivers/soc/marvell/Kconfig            |  13 ++++
 drivers/soc/marvell/Makefile           |   2 +
 drivers/soc/marvell/octeontx2/Makefile |   8 +++
 drivers/soc/marvell/octeontx2/rvu.c    | 126 +++++++++++++++++++++++++++++++++
 drivers/soc/marvell/octeontx2/rvu.h    |  31 ++++++++
 7 files changed, 182 insertions(+)
 create mode 100644 drivers/soc/marvell/Kconfig
 create mode 100644 drivers/soc/marvell/Makefile
 create mode 100644 drivers/soc/marvell/octeontx2/Makefile
 create mode 100644 drivers/soc/marvell/octeontx2/rvu.c
 create mode 100644 drivers/soc/marvell/octeontx2/rvu.h
drivers/soc/Kconfig +1 -0
index c07b4a8..42f2d0b 100644
@@ -6,6 +6,7 @@ source "drivers/soc/atmel/Kconfig"
 source "drivers/soc/bcm/Kconfig"
 source "drivers/soc/fsl/Kconfig"
 source "drivers/soc/imx/Kconfig"
+source "drivers/soc/marvell/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/renesas/Kconfig"
drivers/soc/Makefile +1 -0
index 113e884..5e18cbb 100644
@@ -12,6 +12,7 @@ obj-y				+= fsl/
 obj-$(CONFIG_ARCH_GEMINI)	+= gemini/
 obj-$(CONFIG_ARCH_MXC)		+= imx/
 obj-$(CONFIG_SOC_XWAY)		+= lantiq/
+obj-y				+= marvell/
 obj-y				+= mediatek/
 obj-$(CONFIG_ARCH_MESON)	+= amlogic/
 obj-y				+= qcom/
drivers/soc/marvell/Kconfig new file +13 -0
new file mode 100644
index 0000000..4499caf
@@ -0,0 +1,13 @@
+#
+# MARVELL SoC drivers
+#
+
+menu "Marvell SoC drivers"
+
+config OCTEONTX2_AF
+	tristate "OcteonTX2 RVU Admin Function driver"
+	depends on ARM64 && PCI
+	help
+	  This driver supports Marvell's OcteonTX2 Resource Virtualization
+	  Unit's admin function manager which manages all RVU HW resources.
+endmenu
drivers/soc/marvell/Makefile new file +2 -0
new file mode 100644
index 0000000..16e0ca0
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-y		+= octeontx2/
drivers/soc/marvell/octeontx2/Makefile new file +8 -0
new file mode 100644
index 0000000..dacbd16
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for Marvell's OcteonTX2 RVU Admin Function driver
+#
+
+obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
+
+octeontx2_af-y := rvu.o
drivers/soc/marvell/octeontx2/rvu.c new file +126 -0

126 lines not on this page · raw message

drivers/soc/marvell/octeontx2/rvu.h new file +31 -0
new file mode 100644
index 0000000..4a4b0ad
@@ -0,0 +1,31 @@
+/* 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
+
+/* 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
+
+struct rvu {
+	void __iomem		*afreg_base;
+	void __iomem		*pfreg_base;
+	struct pci_dev		*pdev;
+	struct device		*dev;
+};
+
+#endif /* RVU_H */
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/15 soc: octeontx2: Reset all RVU blocks

In reply to [email protected]

From: Sunil Goutham <[email protected]>

Go through all BLKADDRs and check which ones are implemented on this silicon and do a HW reset of each implemented block. Also added all RVU AF and PF register offsets.

---
 drivers/soc/marvell/octeontx2/rvu.c        |  78 ++++++++++++++++++++
 drivers/soc/marvell/octeontx2/rvu.h        |  37 ++++++++++
 drivers/soc/marvell/octeontx2/rvu_reg.h    | 113 +++++++++++++++++++++++++++++
 drivers/soc/marvell/octeontx2/rvu_struct.h |  36 +++++++++
 4 files changed, 264 insertions(+)
 create mode 100644 drivers/soc/marvell/octeontx2/rvu_reg.h
 create mode 100644 drivers/soc/marvell/octeontx2/rvu_struct.h
drivers/soc/marvell/octeontx2/rvu.c +78 -0
index 5af4da6..d40fabf 100644
@@ -16,6 +16,7 @@
 #include <linux/sysfs.h>
 
 #include "rvu.h"
+#include "rvu_reg.h"
 
 #define DRV_NAME	"octeontx2-af"
 #define DRV_STRING      "Marvell OcteonTX2 RVU Admin Function Driver"
@@ -33,6 +34,70 @@ MODULE_LICENSE("GPL v2");
 MODULE_VERSION(DRV_VERSION);
 MODULE_DEVICE_TABLE(pci, rvu_id_table);
 
+/* Poll a RVU block's register 'offset', for a 'zero'
+ * or 'nonzero' at bits specified by 'mask'
+ */
+int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero)
+{
+	void __iomem *reg;
+	int timeout = 100;
+	u64 reg_val;
+
+	reg = rvu->afreg_base + ((block << 28) | offset);
+	while (timeout) {
+		reg_val = readq(reg);
+		if (zero && !(reg_val & mask))
+			return 0;
+		if (!zero && (reg_val & mask))
+			return 0;
+		udelay(1);
+		cpu_relax();
+		timeout--;
+	}
+	return -EBUSY;
+}
+
+static void rvu_check_block_implemented(struct rvu *rvu)
+{
+	struct rvu_hwinfo *hw = rvu->hw;
+	struct rvu_block *block;
+	int blkid;
+	u64 cfg;
+
+	/* For each block check if 'implemented' bit is set */
+	for (blkid = 0; blkid < BLK_COUNT; blkid++) {
+		block = &hw->block[blkid];
+		cfg = rvupf_read64(rvu, RVU_PF_BLOCK_ADDRX_DISC(blkid));
+		if (cfg & BIT_ULL(11))
+			block->implemented = true;
+	}
+}
+
+static void rvu_block_reset(struct rvu *rvu, int blkaddr, u64 rst_reg)
+{
+	struct rvu_block *block = &rvu->hw->block[blkaddr];
+
+	if (!block->implemented)
+		return;
+
+	rvu_write64(rvu, blkaddr, rst_reg, BIT_ULL(0));
+	rvu_poll_reg(rvu, blkaddr, rst_reg, BIT_ULL(63), true);
+}
+
+static void rvu_reset_all_blocks(struct rvu *rvu)
+{
+	/* Do a HW reset of all RVU blocks */
+	rvu_block_reset(rvu, BLKADDR_NPA, NPA_AF_BLK_RST);
+	rvu_block_reset(rvu, BLKADDR_NIX0, NIX_AF_BLK_RST);
+	rvu_block_reset(rvu, BLKADDR_NPC, NPC_AF_BLK_RST);
+	rvu_block_reset(rvu, BLKADDR_SSO, SSO_AF_BLK_RST);
+	rvu_block_reset(rvu, BLKADDR_TIM, TIM_AF_BLK_RST);
+	rvu_block_reset(rvu, BLKADDR_CPT0, CPT_AF_BLK_RST);
+	rvu_block_reset(rvu, BLKADDR_NDC0, NDC_AF_BLK_RST);
+	rvu_block_reset(rvu, BLKADDR_NDC1, NDC_AF_BLK_RST);
+	rvu_block_reset(rvu, BLKADDR_NDC2, NDC_AF_BLK_RST);
+}
+
 static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	struct device *dev = &pdev->dev;
@@ -43,6 +108,12 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (!rvu)
 		return -ENOMEM;
 
+	rvu->hw = devm_kzalloc(dev, sizeof(struct rvu_hwinfo), GFP_KERNEL);
+	if (!rvu->hw) {
+		devm_kfree(dev, rvu);
+		return -ENOMEM;
+	}
+
 	pci_set_drvdata(pdev, rvu);
 	rvu->pdev = pdev;
 	rvu->dev = &pdev->dev;
@@ -80,6 +151,11 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto err_release_regions;
 	}
 
+	/* Check which blocks the HW supports */
+	rvu_check_block_implemented(rvu);
+
+	rvu_reset_all_blocks(rvu);
+
 	return 0;
 
 err_release_regions:
@@ -88,6 +164,7 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	pci_disable_device(pdev);
 err_freemem:
 	pci_set_drvdata(pdev, NULL);
+	devm_kfree(&pdev->dev, rvu->hw);
 	devm_kfree(dev, rvu);
 	return err;
 }
@@ -100,6 +177,7 @@ static void rvu_remove(struct pci_dev *pdev)
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
 
+	devm_kfree(&pdev->dev, rvu->hw);
 	devm_kfree(&pdev->dev, rvu);
 }
 
drivers/soc/marvell/octeontx2/rvu.h +37 -0
index 4a4b0ad..e2c54d0 100644
@@ -11,6 +11,8 @@
 #ifndef RVU_H
 #define RVU_H
 
+#include "rvu_struct.h"
+
 /* PCI device IDs */
 #define	PCI_DEVID_OCTEONTX2_RVU_AF		0xA065
 
@@ -21,11 +23,46 @@
 
 #define NAME_SIZE				32
 
+struct rvu_block {
+	bool implemented;
+};
+
+struct rvu_hwinfo {
+	struct rvu_block block[BLK_COUNT]; /* Block info */
+};
+
 struct rvu {
 	void __iomem		*afreg_base;
 	void __iomem		*pfreg_base;
 	struct pci_dev		*pdev;
 	struct device		*dev;
+	struct rvu_hwinfo       *hw;
 };
 
+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
+ */
+
+int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
+
 #endif /* RVU_H */
drivers/soc/marvell/octeontx2/rvu_reg.h new file +113 -0

113 lines not on this page · raw message

drivers/soc/marvell/octeontx2/rvu_struct.h new file +36 -0
new file mode 100644
index 0000000..4122559
@@ -0,0 +1,36 @@
+/* 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_STRUCT_H
+#define RVU_STRUCT_H
+
+/*
+ * RVU Block Address Enumeration
+ */
+enum rvu_block_addr_e {
+	BLKADDR_RVUM    = 0x0ULL,
+	BLKADDR_LMT     = 0x1ULL,
+	BLKADDR_MSIX    = 0x2ULL,
+	BLKADDR_NPA     = 0x3ULL,
+	BLKADDR_NIX0    = 0x4ULL,
+	BLKADDR_NIX1    = 0x5ULL,
+	BLKADDR_NPC     = 0x6ULL,
+	BLKADDR_SSO     = 0x7ULL,
+	BLKADDR_SSOW    = 0x8ULL,
+	BLKADDR_TIM     = 0x9ULL,
+	BLKADDR_CPT0    = 0xaULL,
+	BLKADDR_CPT1    = 0xbULL,
+	BLKADDR_NDC0    = 0xcULL,
+	BLKADDR_NDC1    = 0xdULL,
+	BLKADDR_NDC2    = 0xeULL,
+	BLK_COUNT	= 0xfULL,
+};
+
+#endif /* RVU_STRUCT_H */
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/15 soc: octeontx2: Gather RVU blocks HW info

In reply to [email protected]

From: Sunil Goutham <[email protected]>

This patch gathers NPA/NIX/SSO/SSOW/TIM/CPT RVU blocks's HW info like number of LFs. Important register offsets saved for later use to avoid code duplication for each block. A bitmap is allocated for each of the blocks which later on will be used to allocate a LF for a RVU PF/VF.

Also added RVU NIX/NPA block registers and few registers of other blocks.

---
 drivers/soc/marvell/octeontx2/rvu.c     | 167 ++++++++++++++++
 drivers/soc/marvell/octeontx2/rvu.h     |  21 ++
 drivers/soc/marvell/octeontx2/rvu_reg.h | 335 +++++++++++++++++++++++++++++++-
 3 files changed, 518 insertions(+), 5 deletions(-)
drivers/soc/marvell/octeontx2/rvu.c +167 -0
index d40fabf..fa5f40b 100644
@@ -57,6 +57,15 @@ int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero)
 	return -EBUSY;
 }
 
+int rvu_alloc_bitmap(struct rsrc_bmap *rsrc)
+{
+	rsrc->bmap = kcalloc(BITS_TO_LONGS(rsrc->max),
+			     sizeof(long), GFP_KERNEL);
+	if (!rsrc->bmap)
+		return -ENOMEM;
+	return 0;
+}
+
 static void rvu_check_block_implemented(struct rvu *rvu)
 {
 	struct rvu_hwinfo *hw = rvu->hw;
@@ -98,6 +107,157 @@ static void rvu_reset_all_blocks(struct rvu *rvu)
 	rvu_block_reset(rvu, BLKADDR_NDC2, NDC_AF_BLK_RST);
 }
 
+static void rvu_free_hw_resources(struct rvu *rvu)
+{
+	struct rvu_hwinfo *hw = rvu->hw;
+	struct rvu_block *block;
+	int id;
+
+	/* Free all bitmaps */
+	for (id = 0; id < BLK_COUNT; id++) {
+		block = &hw->block[id];
+		kfree(block->lf.bmap);
+	}
+}
+
+static int rvu_setup_hw_resources(struct rvu *rvu)
+{
+	struct rvu_hwinfo *hw = rvu->hw;
+	struct rvu_block *block;
+	int err;
+	u64 cfg;
+
+	/* Get HW supported max RVU PF & VF count */
+	cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_CONST);
+	hw->total_pfs = (cfg >> 32) & 0xFF;
+	hw->total_vfs = (cfg >> 20) & 0xFFF;
+	hw->max_vfs_per_pf = (cfg >> 40) & 0xFF;
+
+	/* Init NPA LF's bitmap */
+	block = &hw->block[BLKADDR_NPA];
+	if (!block->implemented)
+		goto nix;
+	cfg = rvu_read64(rvu, BLKADDR_NPA, NPA_AF_CONST);
+	block->lf.max = (cfg >> 16) & 0xFFF;
+	block->addr = BLKADDR_NPA;
+	block->lfshift = 8;
+	block->lookup_reg = NPA_AF_RVU_LF_CFG_DEBUG;
+	block->pf_lfcnt_reg = RVU_PRIV_PFX_NPA_CFG;
+	block->vf_lfcnt_reg = RVU_PRIV_HWVFX_NPA_CFG;
+	block->lfcfg_reg = NPA_PRIV_LFX_CFG;
+	block->msixcfg_reg = NPA_PRIV_LFX_INT_CFG;
+	block->lfreset_reg = NPA_AF_LF_RST;
+	sprintf(block->name, "NPA");
+	err = rvu_alloc_bitmap(&block->lf);
+	if (err)
+		return err;
+
+nix:
+	/* Init NIX LF's bitmap */
+	block = &hw->block[BLKADDR_NIX0];
+	if (!block->implemented)
+		goto sso;
+	cfg = rvu_read64(rvu, BLKADDR_NIX0, NIX_AF_CONST2);
+	block->lf.max = cfg & 0xFFF;
+	block->addr = BLKADDR_NIX0;
+	block->lfshift = 8;
+	block->lookup_reg = NIX_AF_RVU_LF_CFG_DEBUG;
+	block->pf_lfcnt_reg = RVU_PRIV_PFX_NIX_CFG;
+	block->vf_lfcnt_reg = RVU_PRIV_HWVFX_NIX_CFG;
+	block->lfcfg_reg = NIX_PRIV_LFX_CFG;
+	block->msixcfg_reg = NIX_PRIV_LFX_INT_CFG;
+	block->lfreset_reg = NIX_AF_LF_RST;
+	sprintf(block->name, "NIX");
+	err = rvu_alloc_bitmap(&block->lf);
+	if (err)
+		return err;
+
+sso:
+	/* Init SSO group's bitmap */
+	block = &hw->block[BLKADDR_SSO];
+	if (!block->implemented)
+		goto ssow;
+	cfg = rvu_read64(rvu, BLKADDR_SSO, SSO_AF_CONST);
+	block->lf.max = cfg & 0xFFFF;
+	block->addr = BLKADDR_SSO;
+	block->multislot = true;
+	block->lfshift = 3;
+	block->lookup_reg = SSO_AF_RVU_LF_CFG_DEBUG;
+	block->pf_lfcnt_reg = RVU_PRIV_PFX_SSO_CFG;
+	block->vf_lfcnt_reg = RVU_PRIV_HWVFX_SSO_CFG;
+	block->lfcfg_reg = SSO_PRIV_LFX_HWGRP_CFG;
+	block->msixcfg_reg = SSO_PRIV_LFX_HWGRP_INT_CFG;
+	block->lfreset_reg = SSO_AF_LF_HWGRP_RST;
+	sprintf(block->name, "SSO GROUP");
+	err = rvu_alloc_bitmap(&block->lf);
+	if (err)
+		return err;
+
+ssow:
+	/* Init SSO workslot's bitmap */
+	block = &hw->block[BLKADDR_SSOW];
+	if (!block->implemented)
+		goto tim;
+	block->lf.max = (cfg >> 56) & 0xFF;
+	block->addr = BLKADDR_SSOW;
+	block->multislot = true;
+	block->lfshift = 3;
+	block->lookup_reg = SSOW_AF_RVU_LF_HWS_CFG_DEBUG;
+	block->pf_lfcnt_reg = RVU_PRIV_PFX_SSOW_CFG;
+	block->vf_lfcnt_reg = RVU_PRIV_HWVFX_SSOW_CFG;
+	block->lfcfg_reg = SSOW_PRIV_LFX_HWS_CFG;
+	block->msixcfg_reg = SSOW_PRIV_LFX_HWS_INT_CFG;
+	block->lfreset_reg = SSOW_AF_LF_HWS_RST;
+	sprintf(block->name, "SSOWS");
+	err = rvu_alloc_bitmap(&block->lf);
+	if (err)
+		return err;
+
+tim:
+	/* Init TIM LF's bitmap */
+	block = &hw->block[BLKADDR_TIM];
+	if (!block->implemented)
+		goto cpt;
+	cfg = rvu_read64(rvu, BLKADDR_TIM, TIM_AF_CONST);
+	block->lf.max = cfg & 0xFFFF;
+	block->addr = BLKADDR_TIM;
+	block->multislot = true;
+	block->lfshift = 3;
+	block->lookup_reg = TIM_AF_RVU_LF_CFG_DEBUG;
+	block->pf_lfcnt_reg = RVU_PRIV_PFX_TIM_CFG;
+	block->vf_lfcnt_reg = RVU_PRIV_HWVFX_TIM_CFG;
+	block->lfcfg_reg = TIM_PRIV_LFX_CFG;
+	block->msixcfg_reg = TIM_PRIV_LFX_INT_CFG;
+	block->lfreset_reg = TIM_AF_LF_RST;
+	sprintf(block->name, "TIM");
+	err = rvu_alloc_bitmap(&block->lf);
+	if (err)
+		return err;
+
+cpt:
+	/* Init CPT LF's bitmap */
+	block = &hw->block[BLKADDR_CPT0];
+	if (!block->implemented)
+		return 0;
+	cfg = rvu_read64(rvu, BLKADDR_CPT0, CPT_AF_CONSTANTS0);
+	block->lf.max = cfg & 0xFF;
+	block->addr = BLKADDR_CPT0;
+	block->multislot = true;
+	block->lfshift = 3;
+	block->lookup_reg = CPT_AF_RVU_LF_CFG_DEBUG;
+	block->pf_lfcnt_reg = RVU_PRIV_PFX_CPT_CFG;
+	block->vf_lfcnt_reg = RVU_PRIV_HWVFX_CPT_CFG;
+	block->lfcfg_reg = CPT_PRIV_LFX_CFG;
+	block->msixcfg_reg = CPT_PRIV_LFX_INT_CFG;
+	block->lfreset_reg = CPT_AF_LF_RST;
+	sprintf(block->name, "CPT");
+	err = rvu_alloc_bitmap(&block->lf);
+	if (err)
+		return err;
+
+	return 0;
+}
+
 static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	struct device *dev = &pdev->dev;
@@ -156,6 +316,10 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	rvu_reset_all_blocks(rvu);
 
+	err = rvu_setup_hw_resources(rvu);
+	if (err)
+		goto err_release_regions;
+
 	return 0;
 
 err_release_regions:
@@ -173,6 +337,9 @@ static void rvu_remove(struct pci_dev *pdev)
 {
 	struct rvu *rvu = pci_get_drvdata(pdev);
 
+	rvu_reset_all_blocks(rvu);
+	rvu_free_hw_resources(rvu);
+
 	pci_release_regions(pdev);
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
drivers/soc/marvell/octeontx2/rvu.h +21 -0
index e2c54d0..592b820 100644
@@ -23,11 +23,31 @@
 
 #define NAME_SIZE				32
 
+struct rsrc_bmap {
+	unsigned long *bmap;	/* Pointer to resource bitmap */
+	u16  max;		/* Max resource id or count */
+};
+
 struct rvu_block {
+	struct rsrc_bmap lf;
+	bool multislot;
 	bool implemented;
+	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];
 };
 
 struct rvu_hwinfo {
+	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 */
+
 	struct rvu_block block[BLK_COUNT]; /* Block info */
 };
 
@@ -63,6 +83,7 @@ static inline u64 rvupf_read64(struct rvu *rvu, u64 offset)
  * RVU
  */
 
+int rvu_alloc_bitmap(struct rsrc_bmap *rsrc);
 int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
 
 #endif /* RVU_H */
drivers/soc/marvell/octeontx2/rvu_reg.h +330 -5

342 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/15 soc: octeontx2: Add mailbox support infra

In reply to [email protected]

From: Aleksey Makarov <[email protected]>

This patch adds mailbox support infrastructure APIs. Each RVU device has a dedicated 64KB mailbox region shared with it's peer for communication. RVU AF has a separate mailbox region shared with each of RVU PFs and a RVU PF has a separate region shared with each of it's VF.

These set of APIs are used by this driver (RVU AF) and other RVU PF/VF drivers eg netdev, crypto e.t.c.

---
 drivers/soc/marvell/octeontx2/Makefile  |   2 +-
 drivers/soc/marvell/octeontx2/mbox.c    | 300 ++++++++++++++++++++++++++++++++
 drivers/soc/marvell/octeontx2/mbox.h    | 142 +++++++++++++++
 drivers/soc/marvell/octeontx2/rvu_reg.h |   4 +
 4 files changed, 447 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/marvell/octeontx2/mbox.c
 create mode 100644 drivers/soc/marvell/octeontx2/mbox.h
drivers/soc/marvell/octeontx2/Makefile +1 -1
index dacbd16..8737ec3 100644
@@ -5,4 +5,4 @@
 
 obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 
-octeontx2_af-y := rvu.o
+octeontx2_af-y := rvu.o mbox.o
drivers/soc/marvell/octeontx2/mbox.c new file +300 -0

300 lines not on this page · raw message

drivers/soc/marvell/octeontx2/mbox.h new file +142 -0

142 lines not on this page · raw message

drivers/soc/marvell/octeontx2/rvu_reg.h +4 -0
index a7995d1..3bfb1e0 100644
@@ -101,6 +101,10 @@
 #define RVU_PF_MSIX_VECX_CTL(a)             (0x008 | (a) << 4)
 #define RVU_PF_MSIX_PBAX(a)                 (0xF0000 | (a) << 3)
 
+/* RVU VF registers */
+#define	RVU_VF_VFPF_MBOX0		    (0x00000)
+#define	RVU_VF_VFPF_MBOX1		    (0x00008)
+
 /* NPA block's admin function registers */
 #define NPA_AF_BLK_RST                  (0x0000)
 #define NPA_AF_CONST                    (0x0010)
Signature · 1 line
2.7.4
#13 lore raw

PATCH 5/15 soc: octeontx2: Add mailbox IRQ and msg handlers

In reply to [email protected]

From: Sunil Goutham <[email protected]>

This patch adds support for mailbox interrupt and message handling. Mapped mailbox region and registered a workqueue for message handling. Enabled mailbox IRQ of RVU PFs and registered a interrupt handler. When IRQ is triggered work is added to the mbox workqueue for msgs to get processed.

---
 drivers/soc/marvell/octeontx2/mbox.h       |  14 +-
 drivers/soc/marvell/octeontx2/rvu.c        | 254 +++++++++++++++++++++++++++++
 drivers/soc/marvell/octeontx2/rvu.h        |  22 +++
 drivers/soc/marvell/octeontx2/rvu_struct.h |  22 +++
 4 files changed, 309 insertions(+), 3 deletions(-)
drivers/soc/marvell/octeontx2/mbox.h +11 -3
index 8e205fd..fc593f0 100644
@@ -33,6 +33,8 @@
 # error "incorrect mailbox area sizes"
 #endif
 
+#define INTR_MASK(pfvfs) ((pfvfs < 64) ? (BIT_ULL(pfvfs) - 1) : (~0ull))
+
 #define MBOX_RSP_TIMEOUT	1000 /* in ms, Time to wait for mbox response */
 
 #define MBOX_MSG_ALIGN		16  /* Align mbox msg start to 16bytes */
@@ -90,8 +92,9 @@ struct mbox_msghdr {
 
 void otx2_mbox_reset(struct otx2_mbox *mbox, int devid);
 void otx2_mbox_destroy(struct otx2_mbox *mbox);
-int otx2_mbox_init(struct otx2_mbox *mbox, void *hwbase, struct pci_dev *pdev,
-		   void *reg_base, int direction, int ndevs);
+int otx2_mbox_init(struct otx2_mbox *mbox, void __force *hwbase,
+		   struct pci_dev *pdev, void __force *reg_base,
+		   int direction, int ndevs);
 void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid);
 int otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid);
 int otx2_mbox_busy_poll_for_rsp(struct otx2_mbox *mbox, int devid);
@@ -115,7 +118,7 @@ static inline struct mbox_msghdr *otx2_mbox_alloc_msg(struct otx2_mbox *mbox,
 #define MBOX_MSG_MAX				0xFFFF
 
 #define MBOX_MESSAGES							\
-M(READY,		0x001, msg_req, msg_rsp)
+M(READY,		0x001, msg_req, ready_msg_rsp)
 
 enum {
 #define M(_name, _id, _1, _2) MBOX_MSG_ ## _name = _id,
@@ -139,4 +142,9 @@ struct msg_rsp {
 	struct mbox_msghdr hdr;
 };
 
+struct ready_msg_rsp {
+	struct mbox_msghdr hdr;
+	u16    sclk_feq;	/* SCLK frequency */
+};
+
 #endif /* MBOX_H */
drivers/soc/marvell/octeontx2/rvu.c +254 -0

274 lines not on this page · raw message

drivers/soc/marvell/octeontx2/rvu.h +22 -0
index 592b820..2fb9407 100644
@@ -12,6 +12,7 @@
 #define RVU_H
 
 #include "rvu_struct.h"
+#include "mbox.h"
 
 /* PCI device IDs */
 #define	PCI_DEVID_OCTEONTX2_RVU_AF		0xA065
@@ -23,6 +24,17 @@
 
 #define NAME_SIZE				32
 
+/* PF_FUNC */
+#define RVU_PFVF_PF_SHIFT	10
+#define RVU_PFVF_PF_MASK	0x3F
+#define RVU_PFVF_FUNC_SHIFT	0
+#define RVU_PFVF_FUNC_MASK	0x3FF
+
+struct rvu_work {
+	struct	work_struct work;
+	struct	rvu *rvu;
+};
+
 struct rsrc_bmap {
 	unsigned long *bmap;	/* Pointer to resource bitmap */
 	u16  max;		/* Max resource id or count */
@@ -57,6 +69,16 @@ struct rvu {
 	struct pci_dev		*pdev;
 	struct device		*dev;
 	struct rvu_hwinfo       *hw;
+
+	/* Mbox */
+	struct otx2_mbox	mbox;
+	struct rvu_work		*mbox_wrk;
+	struct workqueue_struct *mbox_wq;
+
+	/* MSI-X */
+	u16			num_vec;
+	char			*irq_name;
+	bool			*irq_allocated;
 };
 
 static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
drivers/soc/marvell/octeontx2/rvu_struct.h +22 -0
index 4122559..1dc1518 100644
@@ -33,4 +33,26 @@ enum rvu_block_addr_e {
 	BLK_COUNT	= 0xfULL,
 };
 
+/* RVU Admin function Interrupt Vector Enumeration */
+enum rvu_af_int_vec_e {
+	RVU_AF_INT_VEC_POISON = 0x0,
+	RVU_AF_INT_VEC_PFFLR  = 0x1,
+	RVU_AF_INT_VEC_PFME   = 0x2,
+	RVU_AF_INT_VEC_GEN    = 0x3,
+	RVU_AF_INT_VEC_MBOX   = 0x4,
+};
+
+/**
+ * RVU PF Interrupt Vector Enumeration
+ */
+enum rvu_pf_int_vec_e {
+	RVU_PF_INT_VEC_VFFLR0     = 0x0,
+	RVU_PF_INT_VEC_VFFLR1     = 0x1,
+	RVU_PF_INT_VEC_VFME0      = 0x2,
+	RVU_PF_INT_VEC_VFME1      = 0x3,
+	RVU_PF_INT_VEC_VFPF_MBOX0 = 0x4,
+	RVU_PF_INT_VEC_VFPF_MBOX1 = 0x5,
+	RVU_PF_INT_VEC_AFPF_MBOX  = 0x6,
+};
+
 #endif /* RVU_STRUCT_H */
Signature · 1 line
2.7.4
#14 lore raw

PATCH 6/15 soc: octeontx2: Convert mbox msg id check to a macro

In reply to [email protected]

From: Aleksey Makarov <[email protected]>

With 10's of mailbox messages expected to be handled in future, checking for message id could become a lengthy switch case. Hence added a macro to auto generate the switch case for each msg id.

---
 drivers/soc/marvell/octeontx2/rvu.c | 44 ++++++++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 6 deletions(-)
drivers/soc/marvell/octeontx2/rvu.c +38 -6
index e795c2f..25f79bf 100644
@@ -258,6 +258,12 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
 	return 0;
 }
 
+static int rvu_mbox_handler_READY(struct rvu *rvu, struct msg_req *req,
+				  struct ready_msg_rsp *rsp)
+{
+	return 0;
+}
+
 static int rvu_process_mbox_msg(struct rvu *rvu, int devid,
 				struct mbox_msghdr *req)
 {
@@ -265,13 +271,39 @@ static int rvu_process_mbox_msg(struct rvu *rvu, int devid,
 	if (req->sig != OTX2_MBOX_REQ_SIG)
 		goto bad_message;
 
-	if (req->id == MBOX_MSG_READY)
-		return 0;
-
+	switch (req->id) {
+#define M(_name, _id, _req_type, _rsp_type)				\
+	case _id: {							\
+		struct _rsp_type *rsp;					\
+		int err;						\
+									\
+		rsp = (struct _rsp_type *)otx2_mbox_alloc_msg(		\
+			&rvu->mbox, devid,				\
+			sizeof(struct _rsp_type));			\
+		if (rsp) {						\
+			rsp->hdr.id = _id;				\
+			rsp->hdr.sig = OTX2_MBOX_RSP_SIG;		\
+			rsp->hdr.pcifunc = req->pcifunc;		\
+			rsp->hdr.rc = 0;				\
+		}							\
+									\
+		err = rvu_mbox_handler_ ## _name(rvu,			\
+						 (struct _req_type *)req, \
+						 rsp);			\
+		if (rsp && err)						\
+			rsp->hdr.rc = err;				\
+									\
+		return rsp ? err : -ENOMEM;				\
+	}
+MBOX_MESSAGES
+#undef M
+		break;
 bad_message:
-	otx2_reply_invalid_msg(&rvu->mbox, devid, req->pcifunc,
-			       req->id);
-	return -ENODEV;
+	default:
+		otx2_reply_invalid_msg(&rvu->mbox, devid, req->pcifunc,
+				       req->id);
+		return -ENODEV;
+	}
 }
 
 static void rvu_mbox_handler(struct work_struct *work)
Signature · 1 line
2.7.4
#15 lore raw

PATCH 7/15 soc: octeontx2: Scan blocks for LFs provisioned to PF/VF

In reply to [email protected]

From: Sunil Goutham <[email protected]>

Scan all RVU blocks to find any 'LF to RVU PF/VF' mapping done by low level firmware. If found any, mark them as used in respective block's LF bitmap and also save mapped PF/VF's PF_FUNC info.

This is done to avoid reattaching a block LF to a different RVU PF/VF.

---
 drivers/soc/marvell/octeontx2/rvu.c        | 148 ++++++++++++++++++++++++++++-
 drivers/soc/marvell/octeontx2/rvu.h        |  16 ++++
 drivers/soc/marvell/octeontx2/rvu_struct.h |  18 ++++
 3 files changed, 180 insertions(+), 2 deletions(-)
drivers/soc/marvell/octeontx2/rvu.c +146 -2
index 25f79bf..9539ab9 100644
@@ -22,6 +22,8 @@
 #define DRV_STRING      "Marvell OcteonTX2 RVU Admin Function Driver"
 #define DRV_VERSION	"1.0"
 
+static int rvu_get_hwvf(struct rvu *rvu, int pcifunc);
+
 /* Supported devices */
 static const struct pci_device_id rvu_id_table[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_RVU_AF) },
@@ -66,6 +68,91 @@ int rvu_alloc_bitmap(struct rsrc_bmap *rsrc)
 	return 0;
 }
 
+static void rvu_update_rsrc_map(struct rvu *rvu, struct rvu_pfvf *pfvf,
+				struct rvu_block *block, u16 pcifunc,
+				u16 lf, bool attach)
+{
+	int devnum, num_lfs = 0;
+	bool is_pf;
+	u64 reg;
+
+	if (lf >= block->lf.max) {
+		dev_err(&rvu->pdev->dev,
+			"%s: FATAL: LF %d is >= %s's max lfs i.e %d\n",
+			__func__, lf, block->name, block->lf.max);
+		return;
+	}
+
+	/* Check if this is for a RVU PF or VF */
+	if (pcifunc & RVU_PFVF_FUNC_MASK) {
+		is_pf = false;
+		devnum = rvu_get_hwvf(rvu, pcifunc);
+	} else {
+		is_pf = true;
+		devnum = rvu_get_pf(pcifunc);
+	}
+
+	block->fn_map[lf] = attach ? pcifunc : 0;
+
+	switch (block->type) {
+	case BLKTYPE_NPA:
+		pfvf->npalf = attach ? true : false;
+		num_lfs = pfvf->npalf;
+		break;
+	case BLKTYPE_NIX:
+		pfvf->nixlf = attach ? true : false;
+		num_lfs = pfvf->nixlf;
+		break;
+	case BLKTYPE_SSO:
+		attach ? pfvf->sso++ : pfvf->sso--;
+		num_lfs = pfvf->sso;
+		break;
+	case BLKTYPE_SSOW:
+		attach ? pfvf->ssow++ : pfvf->ssow--;
+		num_lfs = pfvf->ssow;
+		break;
+	case BLKTYPE_TIM:
+		attach ? pfvf->timlfs++ : pfvf->timlfs--;
+		num_lfs = pfvf->timlfs;
+		break;
+	case BLKTYPE_CPT:
+		attach ? pfvf->cptlfs++ : pfvf->cptlfs--;
+		num_lfs = pfvf->cptlfs;
+		break;
+	}
+
+	reg = is_pf ? block->pf_lfcnt_reg : block->vf_lfcnt_reg;
+	rvu_write64(rvu, BLKADDR_RVUM, reg | (devnum << 16), num_lfs);
+}
+
+inline int rvu_get_pf(u16 pcifunc)
+{
+	return (pcifunc >> RVU_PFVF_PF_SHIFT) & RVU_PFVF_PF_MASK;
+}
+
+static int rvu_get_hwvf(struct rvu *rvu, int pcifunc)
+{
+	int pf, func;
+	u64 cfg;
+
+	pf = rvu_get_pf(pcifunc);
+	func = pcifunc & RVU_PFVF_FUNC_MASK;
+
+	/* Get first HWVF attached to this PF */
+	cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_PFX_CFG(pf));
+
+	return ((cfg & 0xFFF) + func - 1);
+}
+
+struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc)
+{
+	/* Check if it is a PF or VF */
+	if (pcifunc & RVU_PFVF_FUNC_MASK)
+		return &rvu->hwvf[rvu_get_hwvf(rvu, pcifunc)];
+	else
+		return &rvu->pf[rvu_get_pf(pcifunc)];
+}
+
 static void rvu_check_block_implemented(struct rvu *rvu)
 {
 	struct rvu_hwinfo *hw = rvu->hw;
@@ -107,6 +194,28 @@ static void rvu_reset_all_blocks(struct rvu *rvu)
 	rvu_block_reset(rvu, BLKADDR_NDC2, NDC_AF_BLK_RST);
 }
 
+static void rvu_scan_block(struct rvu *rvu, struct rvu_block *block)
+{
+	struct rvu_pfvf *pfvf;
+	u64 cfg;
+	int lf;
+
+	for (lf = 0; lf < block->lf.max; lf++) {
+		cfg = rvu_read64(rvu, block->addr,
+				 block->lfcfg_reg | (lf << block->lfshift));
+		if (!(cfg & BIT_ULL(63)))
+			continue;
+
+		/* Set this resource as being used */
+		__set_bit(lf, block->lf.bmap);
+
+		/* Get, to whom this LF is attached */
+		pfvf = rvu_get_pfvf(rvu, (cfg >> 8) & 0xFFFF);
+		rvu_update_rsrc_map(rvu, pfvf, block,
+				    (cfg >> 8) & 0xFFFF, lf, true);
+	}
+}
+
 static void rvu_free_hw_resources(struct rvu *rvu)
 {
 	struct rvu_hwinfo *hw = rvu->hw;
@@ -124,7 +233,7 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
 {
 	struct rvu_hwinfo *hw = rvu->hw;
 	struct rvu_block *block;
-	int err;
+	int blkid, err;
 	u64 cfg;
 
 	/* Get HW supported max RVU PF & VF count */
@@ -140,6 +249,7 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
 	cfg = rvu_read64(rvu, BLKADDR_NPA, NPA_AF_CONST);
 	block->lf.max = (cfg >> 16) & 0xFFF;
 	block->addr = BLKADDR_NPA;
+	block->type = BLKTYPE_NPA;
 	block->lfshift = 8;
 	block->lookup_reg = NPA_AF_RVU_LF_CFG_DEBUG;
 	block->pf_lfcnt_reg = RVU_PRIV_PFX_NPA_CFG;
@@ -160,6 +270,7 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
 	cfg = rvu_read64(rvu, BLKADDR_NIX0, NIX_AF_CONST2);
 	block->lf.max = cfg & 0xFFF;
 	block->addr = BLKADDR_NIX0;
+	block->type = BLKTYPE_NIX;
 	block->lfshift = 8;
 	block->lookup_reg = NIX_AF_RVU_LF_CFG_DEBUG;
 	block->pf_lfcnt_reg = RVU_PRIV_PFX_NIX_CFG;
@@ -180,6 +291,7 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
 	cfg = rvu_read64(rvu, BLKADDR_SSO, SSO_AF_CONST);
 	block->lf.max = cfg & 0xFFFF;
 	block->addr = BLKADDR_SSO;
+	block->type = BLKTYPE_SSO;
 	block->multislot = true;
 	block->lfshift = 3;
 	block->lookup_reg = SSO_AF_RVU_LF_CFG_DEBUG;
@@ -200,6 +312,7 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
 		goto tim;
 	block->lf.max = (cfg >> 56) & 0xFF;
 	block->addr = BLKADDR_SSOW;
+	block->type = BLKTYPE_SSOW;
 	block->multislot = true;
 	block->lfshift = 3;
 	block->lookup_reg = SSOW_AF_RVU_LF_HWS_CFG_DEBUG;
@@ -221,6 +334,7 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
 	cfg = rvu_read64(rvu, BLKADDR_TIM, TIM_AF_CONST);
 	block->lf.max = cfg & 0xFFFF;
 	block->addr = BLKADDR_TIM;
+	block->type = BLKTYPE_TIM;
 	block->multislot = true;
 	block->lfshift = 3;
 	block->lookup_reg = TIM_AF_RVU_LF_CFG_DEBUG;
@@ -238,10 +352,11 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
 	/* Init CPT LF's bitmap */
 	block = &hw->block[BLKADDR_CPT0];
 	if (!block->implemented)
-		return 0;
+		goto init;
 	cfg = rvu_read64(rvu, BLKADDR_CPT0, CPT_AF_CONSTANTS0);
 	block->lf.max = cfg & 0xFF;
 	block->addr = BLKADDR_CPT0;
+	block->type = BLKTYPE_CPT;
 	block->multislot = true;
 	block->lfshift = 3;
 	block->lookup_reg = CPT_AF_RVU_LF_CFG_DEBUG;
@@ -255,6 +370,35 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
 	if (err)
 		return err;
 
+init:
+	/* Allocate memory for PFVF data */
+	rvu->pf = devm_kcalloc(rvu->dev, hw->total_pfs,
+			       sizeof(struct rvu_pfvf), GFP_KERNEL);
+	if (!rvu->pf)
+		return -ENOMEM;
+
+	rvu->hwvf = devm_kcalloc(rvu->dev, hw->total_vfs,
+				 sizeof(struct rvu_pfvf), GFP_KERNEL);
+	if (!rvu->hwvf)
+		return -ENOMEM;
+
+	for (blkid = 0; blkid < BLK_COUNT; blkid++) {
+		block = &hw->block[blkid];
+		if (!block->lf.bmap)
+			continue;
+
+		/* Allocate memory for block LF/slot to pcifunc mapping info */
+		block->fn_map = devm_kcalloc(rvu->dev, block->lf.max,
+					     sizeof(u16), GFP_KERNEL);
+		if (!block->fn_map)
+			return -ENOMEM;
+
+		/* Scan all blocks to check if low level firmware has
+		 * already provisioned any of the resources to a PF/VF.
+		 */
+		rvu_scan_block(rvu, block);
+	}
+
 	return 0;
 }
 
drivers/soc/marvell/octeontx2/rvu.h +16 -0
index 2fb9407..ce9897b 100644
@@ -42,9 +42,11 @@ struct rsrc_bmap {
 
 struct rvu_block {
 	struct rsrc_bmap lf;
+	u16  *fn_map; /* LF to pcifunc mapping */
 	bool multislot;
 	bool implemented;
 	u8   addr;  /* RVU_BLOCK_ADDR_E */
+	u8   type;  /* RVU_BLOCK_TYPE_E */
 	u8   lfshift;
 	u64  lookup_reg;
 	u64  pf_lfcnt_reg;
@@ -55,6 +57,16 @@ struct rvu_block {
 	unsigned char name[NAME_SIZE];
 };
 
+/* Structure for per RVU func info ie PF/VF */
+struct rvu_pfvf {
+	bool		npalf; /* Only one NPALF per RVU_FUNC */
+	bool		nixlf; /* Only one NIXLF per RVU_FUNC */
+	u16		sso;
+	u16		ssow;
+	u16		cptlfs;
+	u16		timlfs;
+};
+
 struct rvu_hwinfo {
 	u8	total_pfs;   /* MAX RVU PFs HW supports */
 	u16	total_vfs;   /* Max RVU VFs HW supports */
@@ -69,6 +81,8 @@ struct rvu {
 	struct pci_dev		*pdev;
 	struct device		*dev;
 	struct rvu_hwinfo       *hw;
+	struct rvu_pfvf		*pf;
+	struct rvu_pfvf		*hwvf;
 
 	/* Mbox */
 	struct otx2_mbox	mbox;
@@ -107,5 +121,7 @@ static inline u64 rvupf_read64(struct rvu *rvu, u64 offset)
 
 int rvu_alloc_bitmap(struct rsrc_bmap *rsrc);
 int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
+int rvu_get_pf(u16 pcifunc);
+struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc);
 
 #endif /* RVU_H */
drivers/soc/marvell/octeontx2/rvu_struct.h +18 -0
index 1dc1518..77ac751 100644
@@ -33,6 +33,24 @@ enum rvu_block_addr_e {
 	BLK_COUNT	= 0xfULL,
 };
 
+/*
+ * RVU Block Type Enumeration
+ */
+enum rvu_block_type_e {
+	BLKTYPE_RVUM = 0x0,
+	BLKTYPE_MSIX = 0x1,
+	BLKTYPE_LMT  = 0x2,
+	BLKTYPE_NIX  = 0x3,
+	BLKTYPE_NPA  = 0x4,
+	BLKTYPE_NPC  = 0x5,
+	BLKTYPE_SSO  = 0x6,
+	BLKTYPE_SSOW = 0x7,
+	BLKTYPE_TIM  = 0x8,
+	BLKTYPE_CPT  = 0x9,
+	BLKTYPE_NDC  = 0xa,
+	BLKTYPE_MAX  = 0xa,
+};
+
 /* RVU Admin function Interrupt Vector Enumeration */
 enum rvu_af_int_vec_e {
 	RVU_AF_INT_VEC_POISON = 0x0,
Signature · 1 line
2.7.4
#16 lore raw

PATCH 8/15 soc: octeontx2: Add RVU block LF provisioning support

In reply to [email protected]

From: Sunil Goutham <[email protected]>

Added support for a RVU PF/VF to request AF via mailbox to attach or detach NPA/NIX/SSO/SSOW/TIM/CPT block LFs. Also supports partial detachment and modifying current LF attached count of a certian block type.

---
 drivers/soc/marvell/octeontx2/mbox.h    |  45 ++-
 drivers/soc/marvell/octeontx2/rvu.c     | 472 +++++++++++++++++++++++++++++++-
 drivers/soc/marvell/octeontx2/rvu.h     |   8 +-
 drivers/soc/marvell/octeontx2/rvu_reg.h |   8 +-
 4 files changed, 523 insertions(+), 10 deletions(-)
drivers/soc/marvell/octeontx2/mbox.h +44 -1
index fc593f0..7280d49 100644
@@ -118,7 +118,17 @@ static inline struct mbox_msghdr *otx2_mbox_alloc_msg(struct otx2_mbox *mbox,
 #define MBOX_MSG_MAX				0xFFFF
 
 #define MBOX_MESSAGES							\
-M(READY,		0x001, msg_req, ready_msg_rsp)
+/* Generic mbox IDs (range 0x000 - 0x1FF) */				\
+M(READY,		0x001, msg_req, ready_msg_rsp)			\
+M(ATTACH_RESOURCES,	0x002, rsrc_attach, msg_rsp)			\
+M(DETACH_RESOURCES,	0x003, rsrc_detach, msg_rsp)			\
+/* CGX mbox IDs (range 0x200 - 0x3FF) */				\
+/* NPA mbox IDs (range 0x400 - 0x5FF) */				\
+/* SSO/SSOW mbox IDs (range 0x600 - 0x7FF) */				\
+/* TIM mbox IDs (range 0x800 - 0x9FF) */				\
+/* CPT mbox IDs (range 0xA00 - 0xBFF) */				\
+/* NPC mbox IDs (range 0x6000 - 0x7FFF) */				\
+/* NIX mbox IDs (range 0x8000 - 0xFFFF) */				\
 
 enum {
 #define M(_name, _id, _1, _2) MBOX_MSG_ ## _name = _id,
@@ -147,4 +157,37 @@ struct ready_msg_rsp {
 	u16    sclk_feq;	/* SCLK frequency */
 };
 
+/* Structure for requesting resource provisioning.
+ * 'modify' flag to be used when either requesting more
+ * or to detach partial of a cetain resource type.
+ * Rest of the fields specify how many of what type to
+ * be attached.
+ */
+struct rsrc_attach {
+	struct mbox_msghdr hdr;
+	u8   modify:1;
+	u8   npalf:1;
+	u8   nixlf:1;
+	u16  sso;
+	u16  ssow;
+	u16  timlfs;
+	u16  cptlfs;
+};
+
+/* Structure for relinquishing resources.
+ * 'partial' flag to be used when relinquishing all resources
+ * but only of a certain type. If not set, all resources of all
+ * types provisioned to the RVU function will be detached.
+ */
+struct rsrc_detach {
+	struct mbox_msghdr hdr;
+	u8 partial:1;
+	u8 npalf:1;
+	u8 nixlf:1;
+	u8 sso:1;
+	u8 ssow:1;
+	u8 timlfs:1;
+	u8 cptlfs:1;
+};
+
 #endif /* MBOX_H */
drivers/soc/marvell/octeontx2/rvu.c +468 -4

514 lines not on this page · raw message

drivers/soc/marvell/octeontx2/rvu.h +7 -1
index ce9897b..0f76704 100644
@@ -83,6 +83,7 @@ struct rvu {
 	struct rvu_hwinfo       *hw;
 	struct rvu_pfvf		*pf;
 	struct rvu_pfvf		*hwvf;
+	spinlock_t		rsrc_lock; /* Serialize resource alloc/free */
 
 	/* Mbox */
 	struct otx2_mbox	mbox;
@@ -120,8 +121,13 @@ static inline u64 rvupf_read64(struct rvu *rvu, u64 offset)
  */
 
 int rvu_alloc_bitmap(struct rsrc_bmap *rsrc);
-int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
+int rvu_alloc_rsrc(struct rsrc_bmap *rsrc);
+void rvu_free_rsrc(struct rsrc_bmap *rsrc, int id);
+int rvu_rsrc_free_count(struct rsrc_bmap *rsrc);
 int rvu_get_pf(u16 pcifunc);
 struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc);
+bool is_block_implemented(struct rvu_hwinfo *hw, int blkaddr);
+int rvu_get_blkaddr(struct rvu *rvu, int blktype, u16 pcifunc);
+int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
 
 #endif /* RVU_H */
drivers/soc/marvell/octeontx2/rvu_reg.h +4 -4
index 3bfb1e0..b28b310 100644
@@ -54,20 +54,20 @@
 #define RVU_PRIV_PFX_MSIX_CFG(a)            (0x8000110 | (a) << 16)
 #define RVU_PRIV_PFX_ID_CFG(a)              (0x8000120 | (a) << 16)
 #define RVU_PRIV_PFX_INT_CFG(a)             (0x8000200 | (a) << 16)
-#define RVU_PRIV_PFX_NIX_CFG                (0x8000300)
+#define RVU_PRIV_PFX_NIX0_CFG               (0x8000300)
 #define RVU_PRIV_PFX_NPA_CFG		    (0x8000310)
 #define RVU_PRIV_PFX_SSO_CFG                (0x8000320)
 #define RVU_PRIV_PFX_SSOW_CFG               (0x8000330)
 #define RVU_PRIV_PFX_TIM_CFG                (0x8000340)
-#define RVU_PRIV_PFX_CPT_CFG                (0x8000350)
+#define RVU_PRIV_PFX_CPT0_CFG               (0x8000350)
 #define RVU_PRIV_BLOCK_TYPEX_REV(a)         (0x8000400 | (a) << 3)
 #define RVU_PRIV_HWVFX_INT_CFG(a)           (0x8001280 | (a) << 16)
-#define RVU_PRIV_HWVFX_NIX_CFG              (0x8001300)
+#define RVU_PRIV_HWVFX_NIX0_CFG             (0x8001300)
 #define RVU_PRIV_HWVFX_NPA_CFG              (0x8001310)
 #define RVU_PRIV_HWVFX_SSO_CFG              (0x8001320)
 #define RVU_PRIV_HWVFX_SSOW_CFG             (0x8001330)
 #define RVU_PRIV_HWVFX_TIM_CFG              (0x8001340)
-#define RVU_PRIV_HWVFX_CPT_CFG              (0x8001350)
+#define RVU_PRIV_HWVFX_CPT0_CFG             (0x8001350)
 
 /* RVU PF registers */
 #define	RVU_PF_VFX_PFVF_MBOX0		    (0x00000)
Signature · 1 line
2.7.4
#17 lore raw

PATCH 9/15 soc: octeontx2: Configure block LF's MSIX vector offset

In reply to [email protected]

From: Sunil Goutham <[email protected]>

Firmware configures a certain number of MSIX vectors to each of enabled RVU PF/VF. When a block LF is attached to a PF/VF, number of MSIX vectors needed by that LF are set aside (out of PF/VF's total MSIX vectors) and LF's msix_offset is configured in HW.

Also added support for a RVU PF/VF to retrieve that block LF's MSIX vector offset information from AF via mbox.

---
 drivers/soc/marvell/octeontx2/mbox.h       |  18 ++
 drivers/soc/marvell/octeontx2/rvu.c        | 333 ++++++++++++++++++++++++++++-
 drivers/soc/marvell/octeontx2/rvu.h        |   7 +
 drivers/soc/marvell/octeontx2/rvu_struct.h |   2 +
 4 files changed, 357 insertions(+), 3 deletions(-)
drivers/soc/marvell/octeontx2/mbox.h +18 -0
index 7280d49..bedf0ee 100644
@@ -122,6 +122,7 @@ static inline struct mbox_msghdr *otx2_mbox_alloc_msg(struct otx2_mbox *mbox,
 M(READY,		0x001, msg_req, ready_msg_rsp)			\
 M(ATTACH_RESOURCES,	0x002, rsrc_attach, msg_rsp)			\
 M(DETACH_RESOURCES,	0x003, rsrc_detach, msg_rsp)			\
+M(MSIX_OFFSET,		0x004, msg_req, msix_offset_rsp)		\
 /* CGX mbox IDs (range 0x200 - 0x3FF) */				\
 /* NPA mbox IDs (range 0x400 - 0x5FF) */				\
 /* SSO/SSOW mbox IDs (range 0x600 - 0x7FF) */				\
@@ -190,4 +191,21 @@ struct rsrc_detach {
 	u8 cptlfs:1;
 };
 
+#define MSIX_VECTOR_INVALID	0xFFFF
+#define MAX_RVU_BLKLF_CNT	256
+
+struct msix_offset_rsp {
+	struct mbox_msghdr hdr;
+	u16  npa_msixoff;
+	u16  nix_msixoff;
+	u8   sso;
+	u8   ssow;
+	u8   timlfs;
+	u8   cptlfs;
+	u16  sso_msixoff[MAX_RVU_BLKLF_CNT];
+	u16  ssow_msixoff[MAX_RVU_BLKLF_CNT];
+	u16  timlf_msixoff[MAX_RVU_BLKLF_CNT];
+	u16  cptlf_msixoff[MAX_RVU_BLKLF_CNT];
+};
+
 #endif /* MBOX_H */
drivers/soc/marvell/octeontx2/rvu.c +330 -3

406 lines not on this page · raw message

drivers/soc/marvell/octeontx2/rvu.h +7 -0
index 0f76704..7435e83 100644
@@ -65,6 +65,11 @@ struct rvu_pfvf {
 	u16		ssow;
 	u16		cptlfs;
 	u16		timlfs;
+
+	/* Block LF's MSIX vector info */
+	struct rsrc_bmap msix;      /* Bitmap for MSIX vector alloc */
+#define MSIX_BLKLF(blkaddr, lf) (((blkaddr) << 8) | ((lf) & 0xFF))
+	u16		 *msix_lfmap; /* Vector to block LF mapping */
 };
 
 struct rvu_hwinfo {
@@ -126,7 +131,9 @@ void rvu_free_rsrc(struct rsrc_bmap *rsrc, int id);
 int rvu_rsrc_free_count(struct rsrc_bmap *rsrc);
 int rvu_get_pf(u16 pcifunc);
 struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc);
+void rvu_get_pf_numvfs(struct rvu *rvu, int pf, int *numvfs, int *hwvf);
 bool is_block_implemented(struct rvu_hwinfo *hw, int blkaddr);
+int rvu_get_lf(struct rvu *rvu, struct rvu_block *block, u16 pcifunc, u16 slot);
 int rvu_get_blkaddr(struct rvu *rvu, int blktype, u16 pcifunc);
 int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
 
drivers/soc/marvell/octeontx2/rvu_struct.h +2 -0
index 77ac751..f61c862 100644
@@ -58,6 +58,7 @@ enum rvu_af_int_vec_e {
 	RVU_AF_INT_VEC_PFME   = 0x2,
 	RVU_AF_INT_VEC_GEN    = 0x3,
 	RVU_AF_INT_VEC_MBOX   = 0x4,
+	RVU_AF_INT_VEC_CNT    = 0x5,
 };
 
 /**
@@ -71,6 +72,7 @@ enum rvu_pf_int_vec_e {
 	RVU_PF_INT_VEC_VFPF_MBOX0 = 0x4,
 	RVU_PF_INT_VEC_VFPF_MBOX1 = 0x5,
 	RVU_PF_INT_VEC_AFPF_MBOX  = 0x6,
+	RVU_PF_INT_VEC_CNT	  = 0x7,
 };
 
 #endif /* RVU_STRUCT_H */
Signature · 1 line
2.7.4
#18 lore raw

PATCH 10/15 soc: octeontx2: Reconfig MSIX base with IOVA

In reply to [email protected]

From: Geetha sowjanya <[email protected]>

HW interprets RVU_AF_MSIXTR_BASE address as an IOVA, hence create a IOMMU mapping for the physcial address configured by firmware and reconfig RVU_AF_MSIXTR_BASE with IOVA.

---
 drivers/soc/marvell/octeontx2/rvu.c | 33 ++++++++++++++++++++++++++++++---
 drivers/soc/marvell/octeontx2/rvu.h |  1 +
 2 files changed, 31 insertions(+), 3 deletions(-)
drivers/soc/marvell/octeontx2/rvu.c +30 -3
index 8ac3524..40684c9 100644
@@ -442,9 +442,10 @@ static int rvu_setup_msix_resources(struct rvu *rvu)
 {
 	struct rvu_hwinfo *hw = rvu->hw;
 	int pf, vf, numvfs, hwvf, err;
+	int nvecs, offset, max_msix;
 	struct rvu_pfvf *pfvf;
-	int nvecs, offset;
-	u64 cfg;
+	u64 cfg, phy_addr;
+	dma_addr_t iova;
 
 	for (pf = 0; pf < hw->total_pfs; pf++) {
 		cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_PFX_CFG(pf));
@@ -523,6 +524,22 @@ static int rvu_setup_msix_resources(struct rvu *rvu)
 		}
 	}
 
+	/* HW interprets RVU_AF_MSIXTR_BASE address as an IOVA, hence
+	 * create a IOMMU mapping for the physcial address configured by
+	 * firmware and reconfig RVU_AF_MSIXTR_BASE with IOVA.
+	 */
+	cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_CONST);
+	max_msix = cfg & 0xFFFFF;
+	phy_addr = rvu_read64(rvu, BLKADDR_RVUM, RVU_AF_MSIXTR_BASE);
+	iova = dma_map_single(rvu->dev, (void *)phy_addr,
+			      max_msix * PCI_MSIX_ENTRY_SIZE,
+			      DMA_BIDIRECTIONAL);
+	if (dma_mapping_error(rvu->dev, iova))
+		return -ENOMEM;
+
+	rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_MSIXTR_BASE, (u64)iova);
+	rvu->msix_base_iova = iova;
+
 	return 0;
 }
 
@@ -531,7 +548,8 @@ static void rvu_free_hw_resources(struct rvu *rvu)
 	struct rvu_hwinfo *hw = rvu->hw;
 	struct rvu_block *block;
 	struct rvu_pfvf  *pfvf;
-	int id;
+	int id, max_msix;
+	u64 cfg;
 
 	/* Free block LF bitmaps */
 	for (id = 0; id < BLK_COUNT; id++) {
@@ -549,6 +567,15 @@ static void rvu_free_hw_resources(struct rvu *rvu)
 		pfvf = &rvu->hwvf[id];
 		kfree(pfvf->msix.bmap);
 	}
+
+	/* Unmap MSIX vector base IOVA mapping */
+	if (!rvu->msix_base_iova)
+		return;
+	cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_CONST);
+	max_msix = cfg & 0xFFFFF;
+	dma_unmap_single(rvu->dev, rvu->msix_base_iova,
+			 max_msix * PCI_MSIX_ENTRY_SIZE,
+			 DMA_BIDIRECTIONAL);
 }
 
 static int rvu_setup_hw_resources(struct rvu *rvu)
drivers/soc/marvell/octeontx2/rvu.h +1 -0
index 7435e83..92c2022 100644
@@ -99,6 +99,7 @@ struct rvu {
 	u16			num_vec;
 	char			*irq_name;
 	bool			*irq_allocated;
+	dma_addr_t		msix_base_iova;
 };
 
 static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
Signature · 1 line
2.7.4
#25 lore raw

PATCH 11/15 soc: octeontx2: Add Marvell OcteonTX2 CGX driver

In reply to [email protected]

From: Sunil Goutham <[email protected]>

This patch adds basic template for Marvell OcteonTX2's CGX ethernet interface driver. Just the probe. RVU AF driver will use APIs exported by this driver for various things like PF to physical interface mapping, loopback mode, interface stats etc.

---
 drivers/soc/marvell/Kconfig            |  10 +++
 drivers/soc/marvell/octeontx2/Makefile |   2 +
 drivers/soc/marvell/octeontx2/cgx.c    | 117 +++++++++++++++++++++++++++++++++
 drivers/soc/marvell/octeontx2/cgx.h    |  20 ++++++
 4 files changed, 149 insertions(+)
 create mode 100644 drivers/soc/marvell/octeontx2/cgx.c
 create mode 100644 drivers/soc/marvell/octeontx2/cgx.h
drivers/soc/marvell/Kconfig +10 -0
index 4499caf..73c8f8d 100644
@@ -7,7 +7,17 @@ menu "Marvell SoC drivers"
 config OCTEONTX2_AF
 	tristate "OcteonTX2 RVU Admin Function driver"
 	depends on ARM64 && PCI
+	select OCTEONTX2_CGX
 	help
 	  This driver supports Marvell's OcteonTX2 Resource Virtualization
 	  Unit's admin function manager which manages all RVU HW resources.
+
+config OCTEONTX2_CGX
+	tristate "OcteonTX2 MAC interface (CGX) driver"
+	depends on ARM64 && PCI
+	select PHYLIB
+	help
+	  This driver supports programming and controlling of MAC
+	  interfaces from RVU Admin Function driver.
+
 endmenu
drivers/soc/marvell/octeontx2/Makefile +2 -0
index 8737ec3..50b8f74 100644
@@ -3,6 +3,8 @@
 # Makefile for Marvell's OcteonTX2 RVU Admin Function driver
 #
 
+obj-$(CONFIG_OCTEONTX2_CGX) += octeontx2_cgx.o
 obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 
+octeontx2_cgx-y := cgx.o
 octeontx2_af-y := rvu.o mbox.o
drivers/soc/marvell/octeontx2/cgx.c new file +117 -0

117 lines not on this page · raw message

drivers/soc/marvell/octeontx2/cgx.h new file +20 -0
new file mode 100644
index 0000000..8056264
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0
+ * Marvell OcteonTx2 CGX 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 CGX_H
+#define CGX_H
+
+ /* PCI device IDs */
+#define	PCI_DEVID_OCTEONTX2_CGX			0xA059
+
+/* PCI BAR nos */
+#define PCI_CFG_REG_BAR_NUM			0
+
+#endif /* CGX_H */
Signature · 1 line
2.7.4
#36 lore raw

PATCH 12/15 soc: octeontx2: Set RVU PFs to CGX LMACs mapping

In reply to [email protected]

From: Linu Cherian <[email protected]>

Each of the enabled CGX LMAC is considered a physical interface and RVU PFs are mapped to these. VFs of these SRIOV PFs will be virtual interfaces and share CGX LMAC along with PF.

This mapping info will be used later on for Rx/Tx pkt steering.

---
 drivers/soc/marvell/octeontx2/Makefile  |  2 +-
 drivers/soc/marvell/octeontx2/cgx.c     | 59 ++++++++++++++++++++
 drivers/soc/marvell/octeontx2/cgx.h     | 15 ++++-
 drivers/soc/marvell/octeontx2/rvu.c     |  4 ++
 drivers/soc/marvell/octeontx2/rvu.h     | 12 ++++
 drivers/soc/marvell/octeontx2/rvu_cgx.c | 97 +++++++++++++++++++++++++++++++++
 6 files changed, 186 insertions(+), 3 deletions(-)
 create mode 100644 drivers/soc/marvell/octeontx2/rvu_cgx.c
drivers/soc/marvell/octeontx2/Makefile +1 -1
index 50b8f74..74c768d 100644
@@ -7,4 +7,4 @@ obj-$(CONFIG_OCTEONTX2_CGX) += octeontx2_cgx.o
 obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 
 octeontx2_cgx-y := cgx.o
-octeontx2_af-y := rvu.o mbox.o
+octeontx2_af-y := rvu.o mbox.o rvu_cgx.o
drivers/soc/marvell/octeontx2/cgx.c +59 -0

88 lines not on this page · raw message

drivers/soc/marvell/octeontx2/cgx.h +13 -2
index 8056264..9ec72b1 100644
@@ -12,9 +12,20 @@
 #define CGX_H
 
  /* PCI device IDs */
-#define	PCI_DEVID_OCTEONTX2_CGX			0xA059
+#define	PCI_DEVID_OCTEONTX2_CGX		0xA059
 
 /* PCI BAR nos */
-#define PCI_CFG_REG_BAR_NUM			0
+#define PCI_CFG_REG_BAR_NUM		0
 
+#define MAX_CGX				3
+#define MAX_LMAC_PER_CGX		4
+#define CGX_OFFSET(x)			((x) * MAX_LMAC_PER_CGX)
+
+/* Registers */
+#define CGXX_CMRX_RX_ID_MAP		0x060
+#define CGXX_CMRX_RX_LMACS		0x128
+
+int cgx_get_cgx_cnt(void);
+int cgx_get_lmac_cnt(void *cgxd);
+void *cgx_get_pdata(int cgx_id);
 #endif /* CGX_H */
drivers/soc/marvell/octeontx2/rvu.c +4 -0
index 40684c9..d7b19e0 100644
@@ -1557,6 +1557,10 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (err)
 		goto err_hwsetup;
 
+	err = rvu_cgx_probe(rvu);
+	if (err)
+		goto err_mbox;
+
 	err = rvu_register_interrupts(rvu);
 	if (err)
 		goto err_mbox;
drivers/soc/marvell/octeontx2/rvu.h +12 -0
index 92c2022..385f597 100644
@@ -100,6 +100,16 @@ struct rvu {
 	char			*irq_name;
 	bool			*irq_allocated;
 	dma_addr_t		msix_base_iova;
+
+	/* CGX */
+#define PF_CGXMAP_BASE		1 /* PF 0 is reserved for RVU PF */
+	u8			cgx_mapped_pfs;
+	u8			cgx_cnt; /* available cgx ports */
+	u8			*pf2cgxlmac_map; /* pf to cgx_lmac map */
+	u16			*cgxlmac2pf_map; /* bitmap of mapped pfs for
+						  * every cgx lmac port
+						  */
+	void			**cgx_idmap; /* cgx id to cgx data map table */
 };
 
 static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
@@ -138,4 +148,6 @@ int rvu_get_lf(struct rvu *rvu, struct rvu_block *block, u16 pcifunc, u16 slot);
 int rvu_get_blkaddr(struct rvu *rvu, int blktype, u16 pcifunc);
 int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
 
+/* CGX APIs */
+int rvu_cgx_probe(struct rvu *rvu);
 #endif /* RVU_H */
drivers/soc/marvell/octeontx2/rvu_cgx.c new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
2.7.4
#37 lore raw

PATCH 13/15 soc: octeontx2: Add support for CGX link management

In reply to [email protected]

From: Linu Cherian <[email protected]>

CGX LMAC initialization, link status polling etc is done by low level secure firmware. For link management this patch adds a interface or communication mechanism between firmware and this kernel CGX driver.

- Firmware interface specification is defined in cgx_fw_if.h.
- Support to send/receive commands/events to/form firmware.
- events/commands implemented
* link up
* link down
* reading firmware version

---
 drivers/soc/marvell/octeontx2/cgx.c       | 361 +++++++++++++++++++++++++++++-
 drivers/soc/marvell/octeontx2/cgx.h       |  32 +++
 drivers/soc/marvell/octeontx2/cgx_fw_if.h | 225 +++++++++++++++++++
 3 files changed, 614 insertions(+), 4 deletions(-)
 create mode 100644 drivers/soc/marvell/octeontx2/cgx_fw_if.h
drivers/soc/marvell/octeontx2/cgx.c +357 -4
index 70ca2e2f1..811422f 100644
@@ -25,16 +25,43 @@
 #define DRV_STRING      "Marvell OcteonTX2 CGX/MAC Driver"
 #define DRV_VERSION	"1.0"
 
+/**
+ * struct lmac
+ * @wq_cmd_cmplt:	waitq to keep the process blocked until cmd completion
+ * @cmd_lock:		Lock to serialize the command interface
+ * @resp:		command response
+ * @event_cb:		callback for linkchange events
+ * @cmd_pend:		flag set before new command is started
+ *			flag cleared after command response is received
+ * @cgx:		parent cgx port
+ * @lmac_id:		lmac port id
+ * @name:		lmac port name
+ */
+struct lmac {
+	wait_queue_head_t wq_cmd_cmplt;
+	struct mutex cmd_lock;
+	struct cgx_evt_sts resp;
+	struct cgx_event_cb event_cb;
+	bool cmd_pend;
+	struct cgx *cgx;
+	u8 lmac_id;
+	char *name;
+};
+
 struct cgx {
 	void __iomem		*reg_base;
 	struct pci_dev		*pdev;
 	u8			cgx_id;
 	u8			lmac_count;
+	struct lmac		*lmac_idmap[MAX_LMAC_PER_CGX];
 	struct list_head	cgx_list;
 };
 
 static LIST_HEAD(cgx_list);
 
+/* CGX PHY management internal APIs */
+static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool en);
+
 /* Supported devices */
 static const struct pci_device_id cgx_id_table[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_CGX) },
@@ -47,11 +74,24 @@ MODULE_LICENSE("GPL v2");
 MODULE_VERSION(DRV_VERSION);
 MODULE_DEVICE_TABLE(pci, cgx_id_table);
 
+static void cgx_write(struct cgx *cgx, u64 lmac, u64 offset, u64 val)
+{
+	writeq(val, cgx->reg_base + (lmac << 18) + offset);
+}
+
 static u64 cgx_read(struct cgx *cgx, u64 lmac, u64 offset)
 {
 	return readq(cgx->reg_base + (lmac << 18) + offset);
 }
 
+static inline struct lmac *lmac_pdata(u8 lmac_id, struct cgx *cgx)
+{
+	if (!cgx || lmac_id >= MAX_LMAC_PER_CGX)
+		return NULL;
+
+	return cgx->lmac_idmap[lmac_id];
+}
+
 int cgx_get_cgx_cnt(void)
 {
 	struct cgx *cgx_dev;
@@ -87,18 +127,315 @@ void *cgx_get_pdata(int cgx_id)
 }
 EXPORT_SYMBOL(cgx_get_pdata);
 
-static void cgx_lmac_init(struct cgx *cgx)
+/* CGX Firmware interface low level support */
+static int cgx_fwi_cmd_send(struct cgx_cmd *cmd, struct cgx_evt_sts *rsp,
+			    struct lmac *lmac)
+{
+	struct cgx *cgx = lmac->cgx;
+	union cgx_cmdreg creg;
+	union cgx_evtreg ereg;
+	struct device *dev;
+	int err = 0;
+
+	/* Ensure no other command is in progress */
+	err = mutex_lock_interruptible(&lmac->cmd_lock);
+	if (err)
+		return err;
+
+	/* Ensure command register is free */
+	creg.val = cgx_read(cgx, lmac->lmac_id,  CGX_COMMAND_REG);
+	if (creg.cmd.own != CGX_CMD_OWN_NS) {
+		err = -EBUSY;
+		goto unlock;
+	}
+
+	/* Update ownership in command request */
+	cmd->own = CGX_CMD_OWN_FIRMWARE;
+
+	/* Mark this lmac as pending, before we start */
+	lmac->cmd_pend = true;
+
+	/* Start command in hardware */
+	creg.cmd = *cmd;
+	cgx_write(cgx, lmac->lmac_id, CGX_COMMAND_REG, creg.val);
+	creg.val = cgx_read(cgx, lmac->lmac_id,  CGX_COMMAND_REG);
+
+	/* Ensure command is completed without errors */
+	if (!wait_event_timeout(lmac->wq_cmd_cmplt, !lmac->cmd_pend,
+				msecs_to_jiffies(CGX_CMD_TIMEOUT))) {
+		dev = &cgx->pdev->dev;
+		ereg.val = cgx_read(cgx, lmac->lmac_id,  CGX_EVENT_REG);
+		if (ereg.val) {
+			dev_err(dev, "cgx port %d:%d: No event for response\n",
+				cgx->cgx_id, lmac->lmac_id);
+			/* copy event */
+			lmac->resp = ereg.evt_sts;
+		} else {
+			dev_err(dev, "cgx port %d:%d cmd timeout\n",
+				cgx->cgx_id, lmac->lmac_id);
+			err = -EIO;
+			goto unlock;
+		}
+	}
+
+	/* we have a valid command response */
+	smp_rmb(); /* Ensure the latest updates are visible */
+	*rsp = lmac->resp;
+
+unlock:
+	mutex_unlock(&lmac->cmd_lock);
+
+	return err;
+}
+
+static inline int cgx_fwi_cmd_generic(struct cgx_cmd *req,
+				      struct cgx_evt_sts *rsp,
+				      struct cgx *cgx, int lmac_id)
+{
+	struct lmac *lmac;
+	int err;
+
+	lmac = lmac_pdata(lmac_id, cgx);
+	if (!lmac)
+		return -ENODEV;
+
+	err = cgx_fwi_cmd_send(req, rsp, lmac);
+
+	/* Check for valid response */
+	if (!err) {
+		if (rsp->stat == CGX_STAT_FAIL)
+			return -EIO;
+		else
+			return 0;
+	}
+
+	return err;
+}
+
+/* Hardware event handlers */
+static inline void cgx_link_change_handler(struct cgx_lnk_sts *lstat,
+					   struct lmac *lmac)
+{
+	struct cgx *cgx = lmac->cgx;
+	struct cgx_link_event event;
+	struct device *dev = &cgx->pdev->dev;
+
+	event.lstat = *lstat;
+	event.cgx_id = cgx->cgx_id;
+	event.lmac_id = lmac->lmac_id;
+
+	if (!lmac->event_cb.notify_link_chg) {
+		dev_dbg(dev, "cgx port %d:%d Link change handler null",
+			cgx->cgx_id, lmac->lmac_id);
+		if (lstat->err_type != CGX_ERR_NONE) {
+			dev_err(dev, "cgx port %d:%d Link error %d\n",
+				cgx->cgx_id, lmac->lmac_id, lstat->err_type);
+		}
+		dev_info(dev, "cgx port %d:%d Link status %s, speed %x\n",
+			 cgx->cgx_id, lmac->lmac_id,
+			lstat->link_up ? "UP" : "DOWN", lstat->speed);
+		return;
+	}
+
+	if (lmac->event_cb.notify_link_chg(&event, lmac->event_cb.data))
+		dev_err(dev, "event notification failure\n");
+}
+
+static inline bool cgx_cmdresp_is_linkevent(struct cgx_evt_sts *rsp)
+{
+	if (rsp->id == CGX_CMD_LINK_BRING_UP ||
+	    rsp->id == CGX_CMD_LINK_BRING_DOWN)
+		return true;
+	else
+		return false;
+}
+
+static inline bool cgx_event_is_linkevent(struct cgx_evt_sts *evt)
+{
+	if (evt->id == CGX_EVT_LINK_CHANGE)
+		return true;
+	else
+		return false;
+}
+
+static irqreturn_t cgx_fwi_event_handler(int irq, void *data)
+{
+	struct lmac *lmac = data;
+	struct cgx *cgx = lmac->cgx;
+	struct cgx_evt_sts event;
+	union cgx_evtreg ereg;
+	struct device *dev;
+
+	ereg.val = cgx_read(cgx, lmac->lmac_id, CGX_EVENT_REG);
+	if (!ereg.evt_sts.ack)
+		return IRQ_NONE;
+
+	dev = &cgx->pdev->dev;
+
+	event = ereg.evt_sts;
+
+	switch (event.evt_type) {
+	case CGX_EVT_CMD_RESP:
+		/* Copy the response. Since only one command is active at a
+		 * time, there is no way a response can get overwritten
+		 */
+		lmac->resp = event;
+		/* Ensure response is updated before thread context starts */
+		smp_wmb();
+
+		/* There wont be separate events for link change initiated from
+		 * software; Hence report the command responses as events
+		 */
+		if (cgx_cmdresp_is_linkevent(&event))
+			cgx_link_change_handler(&ereg.link_sts, lmac);
+
+		/* Release thread waiting for completion  */
+		lmac->cmd_pend = false;
+		wake_up_interruptible(&lmac->wq_cmd_cmplt);
+		break;
+	case CGX_EVT_ASYNC:
+		if (cgx_event_is_linkevent(&event))
+			cgx_link_change_handler(&ereg.link_sts, lmac);
+		break;
+	default:
+		dev_err(dev, "cgx port %d:%d Unknown event received\n",
+			cgx->cgx_id, lmac->lmac_id);
+	}
+
+	/* Any new event or command response will be posted by firmware
+	 * only after the current status is acked.
+	 * Ack the interrupt register as well.
+	 */
+	cgx_write(lmac->cgx, lmac->lmac_id, CGX_EVENT_REG, 0);
+	cgx_write(lmac->cgx, lmac->lmac_id, CGXX_CMRX_INT, FW_CGX_INT);
+
+	return IRQ_HANDLED;
+}
+
+/* APIs for PHY management using CGX firmware interface */
+
+/* callback registration for hardware events like link change */
+int cgx_lmac_evh_register(struct cgx_event_cb *cb, void *cgxd, int lmac_id)
+{
+	struct lmac *lmac;
+	struct cgx *cgx = cgxd;
+
+	lmac = lmac_pdata(lmac_id, cgx);
+	if (!lmac)
+		return -ENODEV;
+
+	lmac->event_cb = *cb;
+
+	return 0;
+}
+EXPORT_SYMBOL(cgx_lmac_evh_register);
+
+static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool enable)
 {
+	struct cgx_cmd req = { 0 };
+	struct cgx_evt_sts rsp;
+
+	if (enable)
+		req.id = CGX_CMD_LINK_BRING_UP;
+	else
+		req.id = CGX_CMD_LINK_BRING_DOWN;
+
+	return cgx_fwi_cmd_generic(&req, &rsp, cgx, lmac_id);
+}
+EXPORT_SYMBOL(cgx_fwi_link_change);
+
+static inline int cgx_fwi_read_version(struct cgx_ver_s *ver, struct cgx *cgx)
+{
+	struct cgx_cmd req = { 0 };
+	union cgx_evtreg event;
+	int err;
+
+	req.id = CGX_CMD_GET_FW_VER;
+
+	err = cgx_fwi_cmd_generic(&req, &event.evt_sts, cgx, 0);
+	if (!err)
+		*ver = event.ver;
+
+	return err;
+}
+
+static int cgx_lmac_verify_fwi_version(struct cgx *cgx)
+{
+	struct cgx_ver_s ver;
+	struct device *dev = &cgx->pdev->dev;
+	int err;
+
+	err = cgx_fwi_read_version(&ver, cgx);
+	dev_dbg(dev, "Firmware command interface version = %d.%d\n",
+		ver.major_ver, ver.minor_ver);
+	if (err || ver.major_ver != CGX_FIRMWARE_MAJOR_VER ||
+	    ver.minor_ver != CGX_FIRMWARE_MINOR_VER)
+		return -EIO;
+	else
+		return 0;
+}
+
+static int cgx_lmac_init(struct cgx *cgx)
+{
+	struct lmac *lmac;
+	int i, err;
+
 	cgx->lmac_count = cgx_read(cgx, 0, CGXX_CMRX_RX_LMACS) & 0x7;
 	if (cgx->lmac_count > MAX_LMAC_PER_CGX)
 		cgx->lmac_count = MAX_LMAC_PER_CGX;
+
+	for (i = 0; i < cgx->lmac_count; i++) {
+		lmac = kcalloc(1, sizeof(struct lmac), GFP_KERNEL);
+		if (!lmac)
+			return -ENOMEM;
+		lmac->name = kcalloc(1, sizeof("cgx_fwi_xxx_yyy"), GFP_KERNEL);
+		if (!lmac->name)
+			return -ENOMEM;
+		sprintf(lmac->name, "cgx_fwi_%d_%d", cgx->cgx_id, i);
+		lmac->lmac_id = i;
+		lmac->cgx = cgx;
+		init_waitqueue_head(&lmac->wq_cmd_cmplt);
+		mutex_init(&lmac->cmd_lock);
+		err = request_irq(pci_irq_vector(cgx->pdev,
+						 CGX_LMAC_FWI + i * 9),
+				   cgx_fwi_event_handler, 0, lmac->name, lmac);
+		if (err)
+			return err;
+
+		/* Enable interrupt */
+		cgx_write(cgx, lmac->lmac_id, CGXX_CMRX_INT_ENA_W1S,
+			  FW_CGX_INT);
+
+		/* Add reference */
+		cgx->lmac_idmap[i] = lmac;
+	}
+
+	return cgx_lmac_verify_fwi_version(cgx);
+}
+
+static int cgx_lmac_exit(struct cgx *cgx)
+{
+	struct lmac *lmac;
+	int i;
+
+	/* Free all lmac related resources */
+	for (i = 0; i < cgx->lmac_count; i++) {
+		lmac = cgx->lmac_idmap[i];
+		if (!lmac)
+			continue;
+		free_irq(pci_irq_vector(cgx->pdev, CGX_LMAC_FWI + i * 9), lmac);
+		kfree(lmac->name);
+		kfree(lmac);
+	}
+
+	return 0;
 }
 
 static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-	int err;
 	struct device *dev = &pdev->dev;
 	struct cgx *cgx;
+	int err, nvec;
 
 	cgx = devm_kzalloc(dev, sizeof(*cgx), GFP_KERNEL);
 	if (!cgx)
@@ -128,14 +465,28 @@ static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto err_release_regions;
 	}
 
+	nvec = CGX_NVEC;
+	err = pci_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_MSIX);
+	if (err < 0 || err != nvec) {
+		dev_err(dev, "Request for %d msix vectors failed, err %d\n",
+			nvec, err);
+		goto err_release_regions;
+	}
+
 	list_add(&cgx->cgx_list, &cgx_list);
 	cgx->cgx_id = cgx_get_cgx_cnt() - 1;
-	cgx_lmac_init(cgx);
+
+	err = cgx_lmac_init(cgx);
+	if (err)
+		goto err_release_lmac;
+
 
 	return 0;
 
-err_release_regions:
+err_release_lmac:
+	cgx_lmac_exit(cgx);
 	list_del(&cgx->cgx_list);
+err_release_regions:
 	pci_release_regions(pdev);
 err_disable_device:
 	pci_disable_device(pdev);
@@ -147,7 +498,9 @@ static void cgx_remove(struct pci_dev *pdev)
 {
 	struct cgx *cgx = pci_get_drvdata(pdev);
 
+	cgx_lmac_exit(cgx);
 	list_del(&cgx->cgx_list);
+	pci_free_irq_vectors(pdev);
 	pci_release_regions(pdev);
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
drivers/soc/marvell/octeontx2/cgx.h +32 -0
index 9ec72b1..3f8879f 100644
@@ -11,6 +11,8 @@
 #ifndef CGX_H
 #define CGX_H
 
+#include "cgx_fw_if.h"
+
  /* PCI device IDs */
 #define	PCI_DEVID_OCTEONTX2_CGX		0xA059
 
@@ -22,10 +24,40 @@
 #define CGX_OFFSET(x)			((x) * MAX_LMAC_PER_CGX)
 
 /* Registers */
+#define CGXX_CMRX_INT			0x040
+#define  FW_CGX_INT				BIT_ULL(1)
+#define CGXX_CMRX_INT_ENA_W1S		0x058
 #define CGXX_CMRX_RX_ID_MAP		0x060
 #define CGXX_CMRX_RX_LMACS		0x128
+#define CGXX_SCRATCH0_REG		0x1050
+#define CGXX_SCRATCH1_REG		0x1058
+#define CGX_CONST			0x2000
+
+#define CGX_COMMAND_REG			CGXX_SCRATCH1_REG
+#define CGX_EVENT_REG			CGXX_SCRATCH0_REG
+#define CGX_CMD_TIMEOUT			2200 /* msecs */
+
+#define CGX_NVEC			37
+#define CGX_LMAC_FWI			0
+
+struct cgx_link_event {
+	struct cgx_lnk_sts lstat;
+	u8 cgx_id;
+	u8 lmac_id;
+};
+
+/**
+ * struct cgx_event_cb
+ * @notify_link_chg:	callback for link change notification
+ * @data:	data passed to callback function
+ */
+struct cgx_event_cb {
+	int (*notify_link_chg)(struct cgx_link_event *event, void *data);
+	void *data;
+};
 
 int cgx_get_cgx_cnt(void);
 int cgx_get_lmac_cnt(void *cgxd);
 void *cgx_get_pdata(int cgx_id);
+int cgx_lmac_evh_register(struct cgx_event_cb *cb, void *cgxd, int lmac_id);
 #endif /* CGX_H */
drivers/soc/marvell/octeontx2/cgx_fw_if.h new file +225 -0

225 lines not on this page · raw message

Signature · 1 line
2.7.4
#38 lore raw

PATCH 14/15 soc: octeontx2: Register for CGX lmac events

In reply to [email protected]

From: Linu Cherian <[email protected]>

Added support in RVU AF driver to register for
CGX LMAC link status change events from firmware
and managing them. Processing part will be added
in followup patches.

- Introduced eventqueue for posting events from cgx lmac. Queueing mechanism will ensure that events can be posted and firmware can be acked immediately and hence event reception and processing are decoupled.
- Events gets added to the queue by notification callback. Notification callback is expected to be atomic, since it is called from interrupt context.
- Events are dequeued and processed in a worker thread.

---
 drivers/soc/marvell/octeontx2/rvu.c     |   6 +-
 drivers/soc/marvell/octeontx2/rvu.h     |   5 ++
 drivers/soc/marvell/octeontx2/rvu_cgx.c | 101 +++++++++++++++++++++++++++++++-
 3 files changed, 108 insertions(+), 4 deletions(-)
drivers/soc/marvell/octeontx2/rvu.c +4 -2
index d7b19e0..3809517 100644
@@ -1563,10 +1563,11 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	err = rvu_register_interrupts(rvu);
 	if (err)
-		goto err_mbox;
+		goto err_cgx;
 
 	return 0;
-
+err_cgx:
+	rvu_cgx_wq_destroy(rvu);
 err_mbox:
 	rvu_mbox_destroy(rvu);
 err_hwsetup:
@@ -1588,6 +1589,7 @@ static void rvu_remove(struct pci_dev *pdev)
 	struct rvu *rvu = pci_get_drvdata(pdev);
 
 	rvu_unregister_interrupts(rvu);
+	rvu_cgx_wq_destroy(rvu);
 	rvu_mbox_destroy(rvu);
 	rvu_reset_all_blocks(rvu);
 	rvu_free_hw_resources(rvu);
drivers/soc/marvell/octeontx2/rvu.h +5 -0
index 385f597..d169fa9 100644
@@ -110,6 +110,10 @@ struct rvu {
 						  * every cgx lmac port
 						  */
 	void			**cgx_idmap; /* cgx id to cgx data map table */
+	struct			work_struct cgx_evh_work;
+	struct			workqueue_struct *cgx_evh_wq;
+	spinlock_t		cgx_evq_lock; /* cgx event queue lock */
+	struct list_head	cgx_evq_head; /* cgx event queue head */
 };
 
 static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
@@ -150,4 +154,5 @@ int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
 
 /* CGX APIs */
 int rvu_cgx_probe(struct rvu *rvu);
+void rvu_cgx_wq_destroy(struct rvu *rvu);
 #endif /* RVU_H */
drivers/soc/marvell/octeontx2/rvu_cgx.c +99 -2

119 lines not on this page · raw message

Signature · 1 line
2.7.4
#39 lore raw

PATCH 15/15 MAINTAINERS: Add entry for Marvell OcteonTX2 Admin Function driver

In reply to [email protected]

From: Sunil Goutham <[email protected]>

Added maintainers entry for Marvell OcteonTX2 SOC's RVU admin function driver.

---
 MAINTAINERS | 10 ++++++++++
 1 file changed, 10 insertions(+)
MAINTAINERS +10 -0
index 8bef28b..99ef6c1 100644
@@ -8821,6 +8821,16 @@ S:	Supported
 F:	drivers/mmc/host/sdhci-xenon*
 F:	Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt
 
+MARVELL OCTEONTX2 RVU ADMIN FUNCTION DRIVER
+M:	Sunil Goutham <[email protected]>
+M:	Linu Cherian <[email protected]>
+M:	Geetha sowjanya <[email protected]>
+M:	Jerin Jacob <[email protected]>
+L:	linux-kernel at vger.kernel.org
+L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
+S:	Maintained
+F:	drivers/soc/marvell/octeontx2
+
 MATROX FRAMEBUFFER DRIVER
 L:	linux-fbdev at vger.kernel.org
 S:	Orphan
Signature · 1 line
2.7.4
#5 lore raw

Re: [PATCH 04/15] soc: octeontx2: Add mailbox support infra

In reply to [email protected]
Quoted 10 lines · On Tue, Aug 28, 2018 at 12:57 PM <[email protected]> wrote:

From: Aleksey Makarov <[email protected]>

This patch adds mailbox support infrastructure APIs. Each RVU device has a dedicated 64KB mailbox region shared with it's peer for communication. RVU AF has a separate mailbox region shared with each of RVU PFs and a RVU PF has a separate region shared with each of it's VF.

Quoted 6 lines

These set of APIs are used by this driver (RVU AF) and other RVU PF/VF drivers eg netdev, crypto e.t.c.

Why does this driver not use the drivers/mailbox/ infrastructure?

Arnd

#19 lore raw

Re: [PATCH 10/15] soc: octeontx2: Reconfig MSIX base with IOVA

In reply to [email protected]
Quoted 9 lines · On Tue, Aug 28, 2018 at 12:58 PM <[email protected]> wrote:

From: Geetha sowjanya <[email protected]>

HW interprets RVU_AF_MSIXTR_BASE address as an IOVA, hence create a IOMMU mapping for the physcial address configured by firmware and reconfig RVU_AF_MSIXTR_BASE with IOVA.

I think this needs some more explanation. What is the difference between the MSI-X support in this driver and every other one? Are you working around a hardware bug, or is there something odd in the implementation of your irqchip driver? Do you use a GIC to handle the MSI interrupts or something else?

Arnd

#26 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

In reply to [email protected]
Quoted 9 lines · On Tue, Aug 28, 2018 at 12:58 PM <[email protected]> wrote:

From: Sunil Goutham <[email protected]>

This patch adds basic template for Marvell OcteonTX2's CGX ethernet interface driver. Just the probe. RVU AF driver will use APIs exported by this driver for various things like PF to physical interface mapping, loopback mode, interface stats etc.

Quoted 6 lines
---
 drivers/soc/marvell/Kconfig            |  10 +++
 drivers/soc/marvell/octeontx2/Makefile |   2 +
 drivers/soc/marvell/octeontx2/cgx.c    | 117 +++++++++++++++++++++++++++++++++
 drivers/soc/marvell/octeontx2/cgx.h    |  20 ++++++

If this is a regular PCI ethernet driver, why do you put it into driver/soc rather than drivers/net/ethernet/ ?

Arnd

#40 lore raw
In reply to [email protected]
Quoted 25 lines · On Tue, Aug 28, 2018 at 12:57 PM <[email protected]> wrote:

From: Sunil Goutham <[email protected]>

Resource virtualization unit (RVU) on Marvell's OcteonTX2 SOC supports multiple PCIe SRIOV physical functions (PFs) and virtual functions (VFs). PF0 is called administrative / admin function (AF) and has privilege access to registers to provision different RVU functional blocks to each of PF/VF.

This admin function (AF) driver acts as a configuration / administrative software which provisions functional blocks to a PF/VF on demand for them to work as one of the following
- A basic network controller (i.e NIC).
- NIC with packet filtering, shaping and scheduling capabilities.
- A crypto device.
- A combination of above etc.

PF/VFs communicate with admin function via a shared memory region. This patch series adds logic for the following
- RVU AF driver with functional blocks provisioning support
- Mailbox infrastructure for communication between AF and PFs.
- CGX driver which provides information about physcial network interfaces which AF processes and forwards required info to PF/VF drivers.

Quoted 4 lines

This is the first set of patches out of 70 odd patches.

Note: This driver neither receives any data nor processes it i.e no I/O,
just does the hardware configuration.

Hi Sunil,

Thanks for posting this first series, I'm glad we're seeing support for this chip family making some progress.

My feeling overall is that we need a review from the network driver folks more than the arm-soc team etc, and that maybe the driver as a whole should go into drivers/net/ethernet.

We support some couple of similar hardware already that has both support for virtual functions and for crypto offload, including the Chelsio cxgb4, Mellanox mlx5, NXP DPAA and probably others, and we need to ensure that the exposed interfaces are all compatible, and that you use the correct subsystems and in-kernel abstractions for thing that are common.

Arnd

#27 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

In reply to Arnd Bergmann
Quoted 18 lines · Arnd Bergmann
Quoted 9 lines · On Tue, Aug 28, 2018 at 12:58 PM <[email protected]> wrote:

From: Sunil Goutham <[email protected]>

This patch adds basic template for Marvell OcteonTX2's CGX ethernet interface driver. Just the probe. RVU AF driver will use APIs exported by this driver for various things like PF to physical interface mapping, loopback mode, interface stats etc.

Quoted 6 lines
---
 drivers/soc/marvell/Kconfig            |  10 +++
 drivers/soc/marvell/octeontx2/Makefile |   2 +
 drivers/soc/marvell/octeontx2/cgx.c    | 117 +++++++++++++++++++++++++++++++++
 drivers/soc/marvell/octeontx2/cgx.h    |  20 ++++++
Quoted 2 lines

If this is a regular PCI ethernet driver, why do you put it into driver/soc rather than drivers/net/ethernet/ ?

No, this is not a ethernet driver, as mentioned in the cover letter this driver and AF driver doesn't
handle any IO. There will be a separate ethernet driver (will submit that as well in future) which will
communicate with these drivers for configuring hardware.

The driver in question here is for a serdes controller which handles physical ethernet interfaces.
Admin function driver gathers info w.r.t current state of physical ethernet interfaces from this driver
and notifies actual ethernet driver about changes, if any.

Thanks,
Sunil.

Quoted 2 lines

Arnd

#20 lore raw

Re: [PATCH 10/15] soc: octeontx2: Reconfig MSIX base with IOVA

In reply to Arnd Bergmann
Quoted 12 lines · Arnd Bergmann
Quoted 9 lines · On Tue, Aug 28, 2018 at 12:58 PM <[email protected]> wrote:

From: Geetha sowjanya <[email protected]>

HW interprets RVU_AF_MSIXTR_BASE address as an IOVA, hence create a IOMMU mapping for the physcial address configured by firmware and reconfig RVU_AF_MSIXTR_BASE with IOVA.

Quoted 7 lines

I think this needs some more explanation. What is the difference between the MSI-X support in this driver and every other one? Are you working around a hardware bug, or is there something odd in the implementation of your irqchip driver? Do you use a GIC to handle the MSI interrupts or something else?

Arnd

This admin function is a PCI device which is capable of provisioning HW blocks to other PCIe SRIOV devices in the system. Each HW block (eg memory buffer pools, NIC dewscriptors, crypto engines e.t.c) needs certain no of MSIX vectors. Admin function has a set of 32K MSIX vectors in memory (not on-chip) which based on HW block provisioning to a PCI device attaches the required number of vectors to that device. Some part of this configuration is done by low level firmware.

RVU_AF_MSIXTR_BASE points to the memory region allocated for 32K MSIX vectors. If kernel is booted with IOMMU enabled and admin function device is attached to SMMU, HW will go through translation to access this MSIX vector memory region. Hence the mapping done in this patch.

Thanks,
Sunil.

#6 lore raw

Re: [PATCH 04/15] soc: octeontx2: Add mailbox support infra

In reply to Arnd Bergmann
Quoted 15 lines · Arnd Bergmann
Quoted 13 lines · On Tue, Aug 28, 2018 at 12:57 PM <[email protected]> wrote:

From: Aleksey Makarov <[email protected]>

This patch adds mailbox support infrastructure APIs. Each RVU device has a dedicated 64KB mailbox region shared with it's peer for communication. RVU AF has a separate mailbox region shared with each of RVU PFs and a RVU PF has a separate region shared with each of it's VF.

These set of APIs are used by this driver (RVU AF) and other RVU PF/VF drivers eg netdev, crypto e.t.c.

Quoted 7 lines
Quoted 3 lines

Why does this driver not use the drivers/mailbox/ infrastructure?

Arnd

This is a common administrative software driver which will be handling requests from kernel drivers and as well as drivers in userspace applications. We had to keep
mailbox communication infrastructure same across all usages.

Thanks,
Sunil.

#28 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

In reply to Sunil Kovvuri
Quoted 29 lines · Sunil Kovvuri
Quoted 18 lines · Arnd Bergmann
Quoted 9 lines · On Tue, Aug 28, 2018 at 12:58 PM <[email protected]> wrote:

From: Sunil Goutham <[email protected]>

This patch adds basic template for Marvell OcteonTX2's CGX ethernet interface driver. Just the probe. RVU AF driver will use APIs exported by this driver for various things like PF to physical interface mapping, loopback mode, interface stats etc.

Quoted 6 lines
---
 drivers/soc/marvell/Kconfig            |  10 +++
 drivers/soc/marvell/octeontx2/Makefile |   2 +
 drivers/soc/marvell/octeontx2/cgx.c    | 117 +++++++++++++++++++++++++++++++++
 drivers/soc/marvell/octeontx2/cgx.h    |  20 ++++++
Quoted 2 lines

If this is a regular PCI ethernet driver, why do you put it into driver/soc rather than drivers/net/ethernet/ ?

No, this is not a ethernet driver, as mentioned in the cover letter this driver and AF driver doesn't
handle any IO. There will be a separate ethernet driver (will submit that as well in future) which will
communicate with these drivers for configuring hardware.

Quoted 5 lines

The driver in question here is for a serdes controller which handles physical ethernet interfaces.
Admin function driver gathers info w.r.t current state of physical ethernet interfaces from this driver
and notifies actual ethernet driver about changes, if any.

Ok. Can you describe the structure that the PCI devices appear in? It might help to be make the connection between the differnet patches to understand how things fit together. In the final picture, how many different pci_driver instances do you have, and what part are they for?

Is the idea that an ethernet device driver always attaches to a virtual function that gets created by the main driver, and that the two drivers share no interfaces on the kernel side, or do you have multiple drivers linking to each other?

Arnd

#7 lore raw

Re: [PATCH 04/15] soc: octeontx2: Add mailbox support infra

In reply to Sunil Kovvuri
Quoted 21 lines · Sunil Kovvuri
Quoted 19 lines · Arnd Bergmann
Quoted 16 lines · On Tue, Aug 28, 2018 at 12:57 PM <[email protected]> wrote:

From: Aleksey Makarov <[email protected]>

This patch adds mailbox support infrastructure APIs. Each RVU device has a dedicated 64KB mailbox region shared with it's peer for communication. RVU AF has a separate mailbox region shared with each of RVU PFs and a RVU PF has a separate region shared with each of it's VF.

These set of APIs are used by this driver (RVU AF) and other RVU PF/VF drivers eg netdev, crypto e.t.c.

Quoted 5 lines
Quoted 2 lines

Why does this driver not use the drivers/mailbox/ infrastructure?

This is a common administrative software driver which will be handling requests from kernel drivers and as well as drivers in userspace applications. We had to keep mailbox communication infrastructure same across all usages.

Can you explain more about the usage of userspace applications and what interface you plan to use into the kernel?

Do you things like AF_XDP and virtual machines, or something else?

Arnd

#21 lore raw

Re: [PATCH 10/15] soc: octeontx2: Reconfig MSIX base with IOVA

In reply to Sunil Kovvuri
Quoted 28 lines · Sunil Kovvuri
Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · On Tue, Aug 28, 2018 at 12:58 PM <[email protected]> wrote:

From: Geetha sowjanya <[email protected]>

HW interprets RVU_AF_MSIXTR_BASE address as an IOVA, hence create a IOMMU mapping for the physcial address configured by firmware and reconfig RVU_AF_MSIXTR_BASE with IOVA.

Quoted 8 lines
Quoted 2 lines

I think this needs some more explanation. What is the difference between the MSI-X support in this driver and every other one? Are you working around a hardware bug, or is there something odd in the implementation of your irqchip driver? Do you use a GIC to handle the MSI interrupts or something else?

This admin function is a PCI device which is capable of provisioning HW blocks to other PCIe SRIOV devices in the system. Each HW block (eg memory buffer pools, NIC dewscriptors, crypto engines e.t.c) needs certain no of MSIX vectors. Admin function has a set of 32K MSIX vectors in memory (not on-chip) which based on HW block provisioning to a PCI device attaches the required number of vectors to that device. Some part of this configuration is done by low level firmware.

Quoted 4 lines

RVU_AF_MSIXTR_BASE points to the memory region allocated for 32K MSIX vectors. If kernel is booted with IOMMU enabled and admin function device is attached to SMMU, HW will go through translation to access this MSIX vector memory region. Hence the mapping done in this patch.

Do you mean this is not a regular PCIe MSI-X interrupt to the GIC, but something internal to your device that gets routed through the IOMMU back into the device?

I'm still confused.

Arnd

#29 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

In reply to Arnd Bergmann
Quoted 15 lines
Quoted 9 lines
Quoted 2 lines

If this is a regular PCI ethernet driver, why do you put it into driver/soc rather than drivers/net/ethernet/ ?

No, this is not a ethernet driver, as mentioned in the cover letter this driver and AF driver doesn't
handle any IO. There will be a separate ethernet driver (will submit that as well in future) which will
communicate with these drivers for configuring hardware.

Quoted 5 lines

The driver in question here is for a serdes controller which handles physical ethernet interfaces.
Admin function driver gathers info w.r.t current state of physical ethernet interfaces from this driver
and notifies actual ethernet driver about changes, if any.

Quoted 5 lines

Ok. Can you describe the structure that the PCI devices appear in? It might help to be make the connection between the differnet patches to understand how things fit together. In the final picture, how many different pci_driver instances do you have, and what part are they for?

List of PCI devices are CGX, RVU PF0-PFn SRIOV physical functions and RVU VF0-VFn SRIOV virtual functions. No of VFs per PF is configurable and done by low level firmware.

List of PCI driver instances would be CGX driver, RVU PF0 (i.e admin function) driver,
PF1-PFn either netdev driver or crypto driver, VF0-VFn functionality would be same as their PF.

The current plan is to have CGX driver, Admin function driver, PF netdev driver,
VF netdev driver and PF/VF crypto drivers.

Quoted 5 lines

Is the idea that an ethernet device driver always attaches to a virtual function that gets created by the main driver, and that the two drivers share no interfaces on the kernel side, or do you have multiple drivers linking to each other?

Ethernet device driver can attach to both physical function and virtual function whose HW resources are provisioned by admin function driver.

Yes the PF/VF ethernet drivers and these drivers won't share any kernel interfaces.
Physical ethernet interface is owned by ethernet driver only, this driver just configures which ethernet driver instance uses which physcial interface.

Quoted 2 lines

Arnd

#22 lore raw

Re: [PATCH 10/15] soc: octeontx2: Reconfig MSIX base with IOVA

In reply to Arnd Bergmann
Quoted 35 lines · Arnd Bergmann
Quoted 28 lines · Sunil Kovvuri
Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · On Tue, Aug 28, 2018 at 12:58 PM <[email protected]> wrote:

From: Geetha sowjanya <[email protected]>

HW interprets RVU_AF_MSIXTR_BASE address as an IOVA, hence create a IOMMU mapping for the physcial address configured by firmware and reconfig RVU_AF_MSIXTR_BASE with IOVA.

Quoted 8 lines
Quoted 2 lines

I think this needs some more explanation. What is the difference between the MSI-X support in this driver and every other one? Are you working around a hardware bug, or is there something odd in the implementation of your irqchip driver? Do you use a GIC to handle the MSI interrupts or something else?

This admin function is a PCI device which is capable of provisioning HW blocks to other PCIe SRIOV devices in the system. Each HW block (eg memory buffer pools, NIC dewscriptors, crypto engines e.t.c) needs certain no of MSIX vectors. Admin function has a set of 32K MSIX vectors in memory (not on-chip) which based on HW block provisioning to a PCI device attaches the required number of vectors to that device. Some part of this configuration is done by low level firmware.

Quoted 4 lines

RVU_AF_MSIXTR_BASE points to the memory region allocated for 32K MSIX vectors. If kernel is booted with IOMMU enabled and admin function device is attached to SMMU, HW will go through translation to access this MSIX vector memory region. Hence the mapping done in this patch.

Quoted 7 lines

Do you mean this is not a regular PCIe MSI-X interrupt to the GIC, but something internal to your device that gets routed through the IOMMU back into the device?

I'm still confused.

Arnd

This is a regular PCIe MSI-X interrupt, the difference is that the bunch of PCI devices
here doesn't have a fixed set of MSIX vectors. Admin function has a memory region with
32K MSIX vectors which it provisions to PCI devices based on the HW functional blocks
attached to them. A PCI device which works as a ethernet device needs X number of vectors
and a crypto device needs Y number of vectors.

Since the admin function owns the whole MSIX vector region, HW uses this device's stream ID
to access the vectors. Hence the IOMMU mapping. Once MSIX vectors are provisioned to
a PCI device they work as normal MSIX interrupt like any other device.

Thanks,
Sunil.

#8 lore raw

Re: [PATCH 04/15] soc: octeontx2: Add mailbox support infra

In reply to Arnd Bergmann
Quoted 23 lines · Arnd Bergmann
Quoted 21 lines · Sunil Kovvuri
Quoted 19 lines · Arnd Bergmann
Quoted 16 lines · On Tue, Aug 28, 2018 at 12:57 PM <[email protected]> wrote:

From: Aleksey Makarov <[email protected]>

This patch adds mailbox support infrastructure APIs. Each RVU device has a dedicated 64KB mailbox region shared with it's peer for communication. RVU AF has a separate mailbox region shared with each of RVU PFs and a RVU PF has a separate region shared with each of it's VF.

These set of APIs are used by this driver (RVU AF) and other RVU PF/VF drivers eg netdev, crypto e.t.c.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Why does this driver not use the drivers/mailbox/ infrastructure?

This is a common administrative software driver which will be handling requests from kernel drivers and as well as drivers in userspace applications. We had to keep mailbox communication infrastructure same across all usages.

Can you explain more about the usage of userspace applications and what interface you plan to use into the kernel?

Any PCI device here irrespective in what domain (kernel or userspace) they are in
use common mailbox communication. Which is
# Write a mailbox msg (format is agreed between all parties) into shared (between AF and other PF/VFs)
memory region and trigger a interrupt to admin function.
# Admin function processes the msg and puts reply in the same memory region and trigger
IRQ to the requesting device. If the device has a driver instance
in kernel then it uses
IRQ and userspace applications does polling on the IRQ status bit.

Quoted 2 lines

Do you things like AF_XDP and virtual machines, or something else?

I meant drivers in DPDK which may or may not use AF_XDP. And yes if a PCI device is attached to a virtual machine then that also uses the same mailbox communication.

Sunil.

Quoted 2 lines

Arnd

#41 lore raw
In reply to Arnd Bergmann
Quoted 29 lines · Arnd Bergmann
Quoted 27 lines · On Tue, Aug 28, 2018 at 12:57 PM <[email protected]> wrote:

From: Sunil Goutham <[email protected]>

Resource virtualization unit (RVU) on Marvell's OcteonTX2 SOC supports multiple PCIe SRIOV physical functions (PFs) and virtual functions (VFs). PF0 is called administrative / admin function (AF) and has privilege access to registers to provision different RVU functional blocks to each of PF/VF.

This admin function (AF) driver acts as a configuration / administrative software which provisions functional blocks to a PF/VF on demand for them to work as one of the following
- A basic network controller (i.e NIC).
- NIC with packet filtering, shaping and scheduling capabilities.
- A crypto device.
- A combination of above etc.

PF/VFs communicate with admin function via a shared memory region. This patch series adds logic for the following
- RVU AF driver with functional blocks provisioning support
- Mailbox infrastructure for communication between AF and PFs.
- CGX driver which provides information about physcial network interfaces which AF processes and forwards required info to PF/VF drivers.

This is the first set of patches out of 70 odd patches.

Quoted 7 lines
Quoted 2 lines

Note: This driver neither receives any data nor processes it i.e no I/O,
just does the hardware configuration.

Hi Sunil,

Thanks for posting this first series, I'm glad we're seeing support for this chip family making some progress.

Thanks.

Quoted 4 lines

My feeling overall is that we need a review from the network driver folks more than the arm-soc team etc, and that maybe the driver as a whole should go into drivers/net/ethernet.

This driver doesn't handle any network IO and moreever this driver has to handle configuration requests from crypto driver as well. There will be separate network and
crypto drivers which will be upstreamed into drivers/net/ethernet and drivers/crypto.
And in future silicons there will be different types of functional blocks which will be
added into this resource virtualization unit (RVU). Hence i thought this driver is not a
right fit in drivers/net/ethernet.

Quoted 4 lines

We support some couple of similar hardware already that has both support for virtual functions and for crypto offload, including the Chelsio cxgb4, Mellanox mlx5, NXP DPAA and probably others,

I agree, but i guess that is done to support inline crypto. Here this driver has to handle requests from normal crypto driver (drivers/crypto) as well.

Quoted 5 lines

and we need to ensure that the exposed interfaces are all compatible, and that you use the correct subsystems and in-kernel abstractions for thing that are common.

Arnd

#42 lore raw
Quoted 58 lines · Sunil Kovvuri
Quoted 29 lines · Arnd Bergmann
Quoted 27 lines · On Tue, Aug 28, 2018 at 12:57 PM <[email protected]> wrote:

From: Sunil Goutham <[email protected]>

Resource virtualization unit (RVU) on Marvell's OcteonTX2 SOC supports multiple PCIe SRIOV physical functions (PFs) and virtual functions (VFs). PF0 is called administrative / admin function (AF) and has privilege access to registers to provision different RVU functional blocks to each of PF/VF.

This admin function (AF) driver acts as a configuration / administrative software which provisions functional blocks to a PF/VF on demand for them to work as one of the following
- A basic network controller (i.e NIC).
- NIC with packet filtering, shaping and scheduling capabilities.
- A crypto device.
- A combination of above etc.

PF/VFs communicate with admin function via a shared memory region. This patch series adds logic for the following
- RVU AF driver with functional blocks provisioning support
- Mailbox infrastructure for communication between AF and PFs.
- CGX driver which provides information about physcial network interfaces which AF processes and forwards required info to PF/VF drivers.

This is the first set of patches out of 70 odd patches.

Quoted 7 lines
Quoted 2 lines

Note: This driver neither receives any data nor processes it i.e no I/O,
just does the hardware configuration.

Hi Sunil,

Thanks for posting this first series, I'm glad we're seeing support for this chip family making some progress.

Thanks.

Quoted 4 lines

My feeling overall is that we need a review from the network driver folks more than the arm-soc team etc, and that maybe the driver as a whole should go into drivers/net/ethernet.

This driver doesn't handle any network IO and moreever this driver has to handle configuration requests from crypto driver as well. There will be separate network and
crypto drivers which will be upstreamed into drivers/net/ethernet and drivers/crypto.
And in future silicons there will be different types of functional blocks which will be
added into this resource virtualization unit (RVU). Hence i thought this driver is not a
right fit in drivers/net/ethernet.

Quoted 1 line
Quoted 13 lines
Quoted 3 lines

We support some couple of similar hardware already that has both support for virtual functions and for crypto offload, including the Chelsio cxgb4, Mellanox mlx5, NXP DPAA and probably others,

I agree, but i guess that is done to support inline crypto. Here this driver has to handle requests from normal crypto driver (drivers/crypto) as well.

Quoted 5 lines

and we need to ensure that the exposed interfaces are all compatible, and that you use the correct subsystems and in-kernel abstractions for thing that are common.

Arnd

Hi Arnd,

I hope i have answered your queries.
Let us know if you have any more queries or feedback w.r.t to a individual patch or the patchset on the whole.

Thanks,
Sunil.

#43 lore raw
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

My feeling overall is that we need a review from the network driver folks more than the arm-soc team etc, and that maybe the driver as a whole should go into drivers/net/ethernet.

Quoted 10 lines
Quoted 10 lines

This driver doesn't handle any network IO and moreever this driver has to handle configuration requests from crypto driver as well. There will be separate network and
crypto drivers which will be upstreamed into drivers/net/ethernet and drivers/crypto.
And in future silicons there will be different types of functional blocks which will be
added into this resource virtualization unit (RVU). Hence i thought this driver is not a
right fit in drivers/net/ethernet.

Hi Sunil

Do you have a git branch for everything? I would like to look at the actual Ethernet driver, and the full API this driver exports to other drivers.

I think there real question here is, do you have split between this driver and the actual device drivers in the right place? For me, link up/down detection should be in the Ethernet driver, since it is not shared with the crypto driver.

Thanks
Andrew

#23 lore raw

Re: [PATCH 10/15] soc: octeontx2: Reconfig MSIX base with IOVA

In reply to Sunil Kovvuri
Quoted 33 lines · Sunil Kovvuri
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · Sunil Kovvuri
Quoted 1 line · Arnd Bergmann

On Tue, Aug 28, 2018 at 12:58 PM <[email protected]> wrote:

This admin function is a PCI device which is capable of provisioning HW blocks to other PCIe SRIOV devices in the system. Each HW block (eg memory buffer pools, NIC dewscriptors, crypto engines e.t.c) needs certain no of MSIX vectors. Admin function has a set of 32K MSIX vectors in memory (not on-chip) which based on HW block provisioning to a PCI device attaches the required number of vectors to that device. Some part of this configuration is done by low level firmware.

Quoted 9 lines
Quoted 4 lines

RVU_AF_MSIXTR_BASE points to the memory region allocated for 32K MSIX vectors. If kernel is booted with IOMMU enabled and admin function device is attached to SMMU, HW will go through translation to access this MSIX vector memory region. Hence the mapping done in this patch.

Do you mean this is not a regular PCIe MSI-X interrupt to the GIC, but something internal to your device that gets routed through the IOMMU back into the device?

This is a regular PCIe MSI-X interrupt, the difference is that the bunch of PCI devices
here doesn't have a fixed set of MSIX vectors. Admin function has a memory region with
32K MSIX vectors which it provisions to PCI devices based on the HW functional blocks
attached to them. A PCI device which works as a ethernet device needs X number of vectors
and a crypto device needs Y number of vectors.

Quoted 5 lines

Since the admin function owns the whole MSIX vector region, HW uses this device's stream ID
to access the vectors. Hence the IOMMU mapping. Once MSIX vectors are provisioned to
a PCI device they work as normal MSIX interrupt like any other device.

Ok, I think I got it now, just to confirm: the MSIX vectors you allocate in the admin device refer to memory backing the BAR that contains the MSI-X entries of the other functions, right?

I was a bit confused here and assumed that you were mapping the MMIO area of an interrupt controller that receives the interupt transactions.

Arnd

#9 lore raw

Re: [PATCH 04/15] soc: octeontx2: Add mailbox support infra

In reply to Sunil Kovvuri
Quoted 34 lines · Sunil Kovvuri
Quoted 23 lines · Arnd Bergmann
Quoted 21 lines · Sunil Kovvuri
Quoted 19 lines · Arnd Bergmann
Quoted 16 lines · On Tue, Aug 28, 2018 at 12:57 PM <[email protected]> wrote:

From: Aleksey Makarov <[email protected]>

This patch adds mailbox support infrastructure APIs. Each RVU device has a dedicated 64KB mailbox region shared with it's peer for communication. RVU AF has a separate mailbox region shared with each of RVU PFs and a RVU PF has a separate region shared with each of it's VF.

These set of APIs are used by this driver (RVU AF) and other RVU PF/VF drivers eg netdev, crypto e.t.c.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Why does this driver not use the drivers/mailbox/ infrastructure?

This is a common administrative software driver which will be handling requests from kernel drivers and as well as drivers in userspace applications. We had to keep mailbox communication infrastructure same across all usages.

Can you explain more about the usage of userspace applications and what interface you plan to use into the kernel?

Quoted 11 lines

Any PCI device here irrespective in what domain (kernel or userspace) they are in
use common mailbox communication. Which is
# Write a mailbox msg (format is agreed between all parties) into shared (between AF and other PF/VFs)
memory region and trigger a interrupt to admin function.
# Admin function processes the msg and puts reply in the same memory region and trigger
IRQ to the requesting device. If the device has a driver instance
in kernel then it uses
IRQ and userspace applications does polling on the IRQ status bit.

Ok, so the mailbox here is a communication mechanism between two device drivers that may run on the same kernel, or in different instances (user space, virtual machine, ...), but each driver only talks to the mailbox visible in its own device, right?

What is the purpose of the exported interface then? Is this just an abstraction so each of the drivers can talk to its own mailbox using a set of common helper functions?

Arnd

#30 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

In reply to Sunil Kovvuri
Quoted 26 lines · Sunil Kovvuri
Quoted 16 lines
Quoted 10 lines
Quoted 3 lines

If this is a regular PCI ethernet driver, why do you put it into driver/soc rather than drivers/net/ethernet/ ?

No, this is not a ethernet driver, as mentioned in the cover letter this driver and AF driver doesn't
handle any IO. There will be a separate ethernet driver (will submit that as well in future) which will
communicate with these drivers for configuring hardware.

Quoted 5 lines

The driver in question here is for a serdes controller which handles physical ethernet interfaces.
Admin function driver gathers info w.r.t current state of physical ethernet interfaces from this driver
and notifies actual ethernet driver about changes, if any.

Quoted 5 lines

Ok. Can you describe the structure that the PCI devices appear in? It might help to be make the connection between the differnet patches to understand how things fit together. In the final picture, how many different pci_driver instances do you have, and what part are they for?

List of PCI devices are CGX, RVU PF0-PFn SRIOV physical functions and RVU VF0-VFn SRIOV virtual functions. No of VFs per PF is configurable and done by low level firmware.

Quoted 8 lines

List of PCI driver instances would be CGX driver, RVU PF0 (i.e admin function) driver,
PF1-PFn either netdev driver or crypto driver, VF0-VFn functionality would be same as their PF.

The current plan is to have CGX driver, Admin function driver, PF netdev driver,
VF netdev driver and PF/VF crypto drivers.

Ok, I think I understand the PF/VF distinction now. One (to me) surprising aspect here is that you not just have one physical function that you can use to assign resources to multiple virtual functions, but also a second level of virtualization that is used to assign resources to "physical functions" that are less physical than the name suggests.

The part that I have not grasped yet is what the split between the CGX and the AF is for, how they relate to one another, and what the software abstraction for the two is going to be.

Quoted 5 lines
Quoted 4 lines

Is the idea that an ethernet device driver always attaches to a virtual function that gets created by the main driver, and that the two drivers share no interfaces on the kernel side, or do you have multiple drivers linking to each other?

Quoted 7 lines

Ethernet device driver can attach to both physical function and virtual function whose HW resources are provisioned by admin function driver.

Yes the PF/VF ethernet drivers and these drivers won't share any kernel interfaces.
Physical ethernet interface is owned by ethernet driver only, this driver just configures which ethernet driver instance uses which physcial interface.

Ok.

Arnd

#31 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

Quoted 36 lines · Arnd Bergmann
Quoted 26 lines · Sunil Kovvuri
Quoted 16 lines
Quoted 10 lines
Quoted 3 lines

If this is a regular PCI ethernet driver, why do you put it into driver/soc rather than drivers/net/ethernet/ ?

No, this is not a ethernet driver, as mentioned in the cover letter this driver and AF driver doesn't
handle any IO. There will be a separate ethernet driver (will submit that as well in future) which will
communicate with these drivers for configuring hardware.

Quoted 5 lines

The driver in question here is for a serdes controller which handles physical ethernet interfaces.
Admin function driver gathers info w.r.t current state of physical ethernet interfaces from this driver
and notifies actual ethernet driver about changes, if any.

Quoted 5 lines

Ok. Can you describe the structure that the PCI devices appear in? It might help to be make the connection between the differnet patches to understand how things fit together. In the final picture, how many different pci_driver instances do you have, and what part are they for?

List of PCI devices are CGX, RVU PF0-PFn SRIOV physical functions and RVU VF0-VFn SRIOV virtual functions. No of VFs per PF is configurable and done by low level firmware.

Quoted 7 lines

List of PCI driver instances would be CGX driver, RVU PF0 (i.e admin function) driver,
PF1-PFn either netdev driver or crypto driver, VF0-VFn functionality would be same as their PF.

The current plan is to have CGX driver, Admin function driver, PF netdev driver, VF netdev driver and PF/VF crypto drivers.

Quoted 6 lines

Ok, I think I understand the PF/VF distinction now. One (to me) surprising aspect here is that you not just have one physical function that you can use to assign resources to multiple virtual functions, but also a second level of virtualization that is used to assign resources to "physical functions" that are less physical than the name suggests.

Yes, PF is just for name sake, on-boot there is no difference between PFs/VFs as such.
PF0 has privilege access to assign resources to all PFs and their VFs. This admin function driver loads for PF0.

Quoted 4 lines

The part that I have not grasped yet is what the split between the CGX and the AF is for, how they relate to one another, and what the software abstraction for the two is going to be.

In HW, CGX is a separate PCI device which handles the serdes and physical ethernet interface.
Ethernet driver in drivers/net/ethernet can only communicate to admin function driver since they share a mailbox memory.
So we had to bind both CGX and admin function drivers to almost work as one, inorder to provide relavent info to ethernet drivers. That's why we have many functions
from CGX driver which AF uses.

eg: Firmware gets to know about a physical interface status change, which CGX driver gets
to know and it uses AF's mailbox communication to inform ethernet driver about the event.

Quoted 17 lines
Quoted 6 lines
Quoted 5 lines

Is the idea that an ethernet device driver always attaches to a virtual function that gets created by the main driver, and that the two drivers share no interfaces on the kernel side, or do you have multiple drivers linking to each other?

Quoted 7 lines

Ethernet device driver can attach to both physical function and virtual function whose HW resources are provisioned by admin function driver.

Yes the PF/VF ethernet drivers and these drivers won't share any kernel interfaces.
Physical ethernet interface is owned by ethernet driver only, this driver just configures which ethernet driver instance uses which physcial interface.

Ok.

Arnd

#44 lore raw
In reply to Andrew Lunn
Quoted 16 lines · Andrew Lunn
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

My feeling overall is that we need a review from the network driver folks more than the arm-soc team etc, and that maybe the driver as a whole should go into drivers/net/ethernet.

Quoted 10 lines
Quoted 10 lines

This driver doesn't handle any network IO and moreever this driver has to handle configuration requests from crypto driver as well. There will be separate network and
crypto drivers which will be upstreamed into drivers/net/ethernet and drivers/crypto.
And in future silicons there will be different types of functional blocks which will be
added into this resource virtualization unit (RVU). Hence i thought this driver is not a
right fit in drivers/net/ethernet.

Quoted 5 lines

Hi Sunil

Do you have a git branch for everything? I would like to look at the actual Ethernet driver, and the full API this driver exports to other drivers.

Hi Andrew,

I have pushed all patches into a github repo for your reference. These are not the final patches, i still need to do some minor changes before submitting
(i mean otherthan the ones i already submitted).

AF driver & CGX drivers:
https://github.com/sunilkovvuri/rvu_drivers/tree/master/drivers/soc/marvell/octeontx2

Ethernet drivers PF and VF
https://github.com/sunilkovvuri/rvu_drivers/tree/master/drivers/net/ethernet/marvell/octeontx2

Info exported/shared by AF driver with other drivers is # Mailbox communication APIs, message IDs, message structs e.t.c
https://github.com/sunilkovvuri/rvu_drivers/blob/master/drivers/soc/marvell/octeontx2/mbox.c
https://github.com/sunilkovvuri/rvu_drivers/blob/master/drivers/soc/marvell/octeontx2/mbox.h
# Other structs and APIs
https://github.com/sunilkovvuri/rvu_drivers/blob/master/drivers/soc/marvell/octeontx2/common.h
https://github.com/sunilkovvuri/rvu_drivers/blob/master/drivers/soc/marvell/octeontx2/rvu_struct.h

Quoted 6 lines

I think there real question here is, do you have split between this driver and the actual device drivers in the right place? For me, link up/down detection should be in the Ethernet driver, since it is not shared with the crypto driver.

As mentioned in the patch '[PATCH 13/15] soc: octeontx2: Add support for CGX link management',
link up/down is detected by firmware. And firmware triggers a IRQ to CGX driver, which then
takes the new status and sends a update to ethernet driver via a mailbox communication.

Ethernet driver detects the link change and does the necessary stuff.
https://github.com/sunilkovvuri/rvu_drivers/blob/master/drivers/net/ethernet/marvell/octeontx2/otx2_pf.c#L116

Quoted 2 lines

Thanks
Andrew

#10 lore raw

Re: [PATCH 04/15] soc: octeontx2: Add mailbox support infra

In reply to Arnd Bergmann
Quoted 48 lines · Arnd Bergmann
Quoted 34 lines · Sunil Kovvuri
Quoted 23 lines · Arnd Bergmann
Quoted 21 lines · Sunil Kovvuri
Quoted 19 lines · Arnd Bergmann
Quoted 16 lines · On Tue, Aug 28, 2018 at 12:57 PM <[email protected]> wrote:

From: Aleksey Makarov <[email protected]>

This patch adds mailbox support infrastructure APIs. Each RVU device has a dedicated 64KB mailbox region shared with it's peer for communication. RVU AF has a separate mailbox region shared with each of RVU PFs and a RVU PF has a separate region shared with each of it's VF.

These set of APIs are used by this driver (RVU AF) and other RVU PF/VF drivers eg netdev, crypto e.t.c.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Why does this driver not use the drivers/mailbox/ infrastructure?

This is a common administrative software driver which will be handling requests from kernel drivers and as well as drivers in userspace applications. We had to keep mailbox communication infrastructure same across all usages.

Can you explain more about the usage of userspace applications and what interface you plan to use into the kernel?

Quoted 11 lines

Any PCI device here irrespective in what domain (kernel or userspace) they are in
use common mailbox communication. Which is
# Write a mailbox msg (format is agreed between all parties) into shared (between AF and other PF/VFs)
memory region and trigger a interrupt to admin function.
# Admin function processes the msg and puts reply in the same memory region and trigger
IRQ to the requesting device. If the device has a driver instance
in kernel then it uses
IRQ and userspace applications does polling on the IRQ status bit.

Quoted 4 lines

Ok, so the mailbox here is a communication mechanism between two device drivers that may run on the same kernel, or in different instances (user space, virtual machine, ...), but each driver only talks to the mailbox visible in its own device, right?

Yes.

Quoted 6 lines

What is the purpose of the exported interface then? Is this just an abstraction so each of the drivers can talk to its own mailbox using a set of common helper functions?

Arnd

Yes, that's correct.

In kernel there will be a minimum of 3 drivers which will use this mailbox communication.
So instead of duplicating APIs and structures in every driver, we thought of adding them
in this AF driver and export them to ethernet and crypto drivers.

Thanks,
Sunil.

#24 lore raw

Re: [PATCH 10/15] soc: octeontx2: Reconfig MSIX base with IOVA

In reply to Arnd Bergmann
Quoted 41 lines · Arnd Bergmann
Quoted 33 lines · Sunil Kovvuri
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · Sunil Kovvuri
Quoted 1 line · Arnd Bergmann

On Tue, Aug 28, 2018 at 12:58 PM <[email protected]> wrote:

This admin function is a PCI device which is capable of provisioning HW blocks to other PCIe SRIOV devices in the system. Each HW block (eg memory buffer pools, NIC dewscriptors, crypto engines e.t.c) needs certain no of MSIX vectors. Admin function has a set of 32K MSIX vectors in memory (not on-chip) which based on HW block provisioning to a PCI device attaches the required number of vectors to that device. Some part of this configuration is done by low level firmware.

Quoted 9 lines
Quoted 4 lines

RVU_AF_MSIXTR_BASE points to the memory region allocated for 32K MSIX vectors. If kernel is booted with IOMMU enabled and admin function device is attached to SMMU, HW will go through translation to access this MSIX vector memory region. Hence the mapping done in this patch.

Do you mean this is not a regular PCIe MSI-X interrupt to the GIC, but something internal to your device that gets routed through the IOMMU back into the device?

This is a regular PCIe MSI-X interrupt, the difference is that the bunch of PCI devices
here doesn't have a fixed set of MSIX vectors. Admin function has a memory region with
32K MSIX vectors which it provisions to PCI devices based on the HW functional blocks
attached to them. A PCI device which works as a ethernet device needs X number of vectors
and a crypto device needs Y number of vectors.

Quoted 5 lines

Since the admin function owns the whole MSIX vector region, HW uses this device's stream ID
to access the vectors. Hence the IOMMU mapping. Once MSIX vectors are provisioned to
a PCI device they work as normal MSIX interrupt like any other device.

Quoted 3 lines

Ok, I think I got it now, just to confirm: the MSIX vectors you allocate in the admin device refer to memory backing the BAR that contains the MSI-X entries of the other functions, right?

Yes, that's correct.

Quoted 6 lines

I was a bit confused here and assumed that you were mapping the MMIO area of an interrupt controller that receives the interupt transactions.

Arnd

#11 lore raw

Re: [PATCH 04/15] soc: octeontx2: Add mailbox support infra

In reply to Sunil Kovvuri
Quoted 21 lines · Sunil Kovvuri
Quoted 15 lines · Arnd Bergmann
Quoted 13 lines · Sunil Kovvuri
Quoted 1 line · Arnd Bergmann

On Tue, Aug 28, 2018 at 2:48 PM Sunil Kovvuri <[email protected]> wrote:

Any PCI device here irrespective in what domain (kernel or userspace) they are in
use common mailbox communication. Which is
# Write a mailbox msg (format is agreed between all parties) into shared (between AF and other PF/VFs)
memory region and trigger a interrupt to admin function.
# Admin function processes the msg and puts reply in the same memory region and trigger
IRQ to the requesting device. If the device has a driver instance
in kernel then it uses
IRQ and userspace applications does polling on the IRQ status bit.

Quoted 4 lines

What is the purpose of the exported interface then? Is this just an abstraction so each of the drivers can talk to its own mailbox using a set of common helper functions?

Quoted 7 lines

Yes, that's correct.

In kernel there will be a minimum of 3 drivers which will use this mailbox communication.
So instead of duplicating APIs and structures in every driver, we thought of adding them in this AF driver and export them to ethernet and crypto drivers.

Ok. My feeling is then that the API is fine, but that it should not be part of the AF module but rather be a standalone module.

My comment about the generic mailbox API no longer applies
here: you don't have a single shared mailbox hardware interface, but each device has its own mailbox register set, so there is no point in setting up a separate device for it, but I see no need for creating an artificial dependency on the AF driver. E.g. in a virtual machine that only has one ethernet interface, you otherwise wouldn't load that driver, right?

Arnd

#32 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

In reply to Sunil Kovvuri
Quoted 9 lines · Sunil Kovvuri
Quoted 7 lines · Arnd Bergmann

On Tue, Aug 28, 2018 at 3:10 PM Sunil Kovvuri <[email protected]> wrote:
Ok, I think I understand the PF/VF distinction now. One (to me) surprising aspect here is that you not just have one physical function that you can use to assign resources to multiple virtual functions, but also a second level of virtualization that is used to assign resources to "physical functions" that are less physical than the name suggests.

Quoted 4 lines

Yes, PF is just for name sake, on-boot there is no difference between PFs/VFs as such.
PF0 has privilege access to assign resources to all PFs and their VFs. This admin function driver loads for PF0.

ok

Quoted 13 lines
Quoted 3 lines

The part that I have not grasped yet is what the split between the CGX and the AF is for, how they relate to one another, and what the software abstraction for the two is going to be.

In HW, CGX is a separate PCI device which handles the serdes and physical ethernet interface.
Ethernet driver in drivers/net/ethernet can only communicate to admin function driver since they share a mailbox memory.
So we had to bind both CGX and admin function drivers to almost work as one, inorder to provide relavent info to ethernet drivers. That's why we have many functions
from CGX driver which AF uses.

Quoted 4 lines

eg: Firmware gets to know about a physical interface status change, which CGX driver gets
to know and it uses AF's mailbox communication to inform ethernet driver about the event.

Would it make sense then to combine the CGX driver and the AF driver into a single module? It sounds like you can never really use one without the other anyway, and that would make it easier to have a sensible abstraction to user space.

Arnd

#33 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

Quoted 36 lines · Arnd Bergmann
Quoted 9 lines · Sunil Kovvuri
Quoted 7 lines · Arnd Bergmann

On Tue, Aug 28, 2018 at 3:10 PM Sunil Kovvuri <[email protected]> wrote:
Ok, I think I understand the PF/VF distinction now. One (to me) surprising aspect here is that you not just have one physical function that you can use to assign resources to multiple virtual functions, but also a second level of virtualization that is used to assign resources to "physical functions" that are less physical than the name suggests.

Quoted 4 lines

Yes, PF is just for name sake, on-boot there is no difference between PFs/VFs as such.
PF0 has privilege access to assign resources to all PFs and their VFs. This admin function driver loads for PF0.

ok

Quoted 13 lines
Quoted 3 lines

The part that I have not grasped yet is what the split between the CGX and the AF is for, how they relate to one another, and what the software abstraction for the two is going to be.

In HW, CGX is a separate PCI device which handles the serdes and physical ethernet interface.
Ethernet driver in drivers/net/ethernet can only communicate to admin function driver since they share a mailbox memory.
So we had to bind both CGX and admin function drivers to almost work as one, inorder to provide relavent info to ethernet drivers. That's why we have many functions
from CGX driver which AF uses.

Quoted 4 lines

eg: Firmware gets to know about a physical interface status change, which CGX driver gets
to know and it uses AF's mailbox communication to inform ethernet driver about the event.

Quoted 6 lines

Would it make sense then to combine the CGX driver and the AF driver into a single module? It sounds like you can never really use one without the other anyway, and that would make it easier to have a sensible abstraction to user space.

Arnd

Thanks for the suggestion, that does makes sense.
Actually i did thought about it, but i was skeptical if it would be acceptable to make
a single module out of drivers registering for two different PCI devices.

Will wait for few more days for more feedback from anyone and port v2 series.

Sunil.

#12 lore raw

Re: [PATCH 04/15] soc: octeontx2: Add mailbox support infra

In reply to Arnd Bergmann
Quoted 42 lines · Arnd Bergmann
Quoted 21 lines · Sunil Kovvuri
Quoted 15 lines · Arnd Bergmann
Quoted 13 lines · Sunil Kovvuri
Quoted 1 line · Arnd Bergmann

On Tue, Aug 28, 2018 at 2:48 PM Sunil Kovvuri <[email protected]> wrote:

Any PCI device here irrespective in what domain (kernel or userspace) they are in
use common mailbox communication. Which is
# Write a mailbox msg (format is agreed between all parties) into shared (between AF and other PF/VFs)
memory region and trigger a interrupt to admin function.
# Admin function processes the msg and puts reply in the same memory region and trigger
IRQ to the requesting device. If the device has a driver instance
in kernel then it uses
IRQ and userspace applications does polling on the IRQ status bit.

Quoted 4 lines

What is the purpose of the exported interface then? Is this just an abstraction so each of the drivers can talk to its own mailbox using a set of common helper functions?

Quoted 7 lines

Yes, that's correct.

In kernel there will be a minimum of 3 drivers which will use this mailbox communication.
So instead of duplicating APIs and structures in every driver, we thought of adding them in this AF driver and export them to ethernet and crypto drivers.

Ok. My feeling is then that the API is fine, but that it should not be part of the AF module but rather be a standalone module.

My comment about the generic mailbox API no longer applies
here: you don't have a single shared mailbox hardware interface, but each device has its own mailbox register set, so there is no point in setting up a separate device for it, but I see no need for creating an artificial dependency on the AF driver. E.g. in a virtual machine that only has one ethernet interface, you otherwise wouldn't load that driver, right?

Quoted 1 line

Arnd

Good point, thanks for catching this.
Will look into this and post a v2 series.

Thanks,
Sunil.

#34 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

In reply to Sunil Kovvuri
Quoted 7 lines · Sunil Kovvuri

On Fri, Aug 31, 2018 at 7:50 PM Arnd Bergmann <[email protected]> wrote:

Thanks for the suggestion, that does makes sense.
Actually i did thought about it, but i was skeptical if it would be acceptable to make
a single module out of drivers registering for two different PCI devices.

I don't think it matters much whether there is one module or two (others might have a strong opinion one way or the other).

What is important though are these two points:

- How to represent the two PCI devices to user space: You should only have one interface to user space I think, and this should be similar to how other drivers manage similar cases (I don't actually know what they do, but I assume you've done some research here)

- How you connect find the pair of devices: Generally speaking while the SoC might only have one of each, you shouldn't make that assumption in the code, but instead have a reliable way of having one driver wait for the other driver to finish probing so you can match the pair.

Quoted 1 line

Will wait for few more days for more feedback from anyone and port v2 series.

Ok.

Arnd

#35 lore raw

Re: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver

Quoted 20 lines · Arnd Bergmann
Quoted 7 lines · Sunil Kovvuri

On Fri, Aug 31, 2018 at 7:50 PM Arnd Bergmann <[email protected]> wrote:

Thanks for the suggestion, that does makes sense.
Actually i did thought about it, but i was skeptical if it would be acceptable to make
a single module out of drivers registering for two different PCI devices.

I don't think it matters much whether there is one module or two (others might have a strong opinion one way or the other).

What is important though are these two points:

- How to represent the two PCI devices to user space: You should only have one interface to user space I think, and this should be similar to how other drivers manage similar cases (I don't actually know what they do, but I assume you've done some research here)

Quoted 5 lines

- How you connect find the pair of devices: Generally speaking while the SoC might only have one of each, you shouldn't make that assumption in the code, but instead have a reliable way of having one driver wait for the other driver to finish probing so you can match the pair.

Agreed.
I do have a patch in works for that, i.e to defer AF driver probe till CGX driver is loaded.
https://github.com/sunilkovvuri/rvu_drivers/commit/27b449087c16224a9e93dd91d6d9f734b5210bed

Quoted 5 lines
Quoted 1 line

Will wait for few more days for more feedback from anyone and port v2 series.

Ok.

Arnd