Commit f7dd48ea authored by Paolo Abeni's avatar Paolo Abeni
Browse files

Merge branch 'add-pf-vf-mailbox-support'

Shinas Rasheed says:

====================
add PF-VF mailbox support

This patchset aims to add PF-VF mailbox support, its related
version support, and relevant control net support for immediate
functionalities such as firmware notifications to VF.

Changes:
V6:
  - Fixed 1/4 patch to apply to top of net-next merged with net fixes

V5: https://lore.kernel.org/all/20231214164536.2670006-1-srasheed@marvell.com/
  - Refactored patches to cut out redundant changes in 1/4 patch.

V4: https://lore.kernel.org/all/20231213035816.2656851-1-srasheed@marvell.com/
  - Included tag [1/4] in subject of first patch of series which was
    lost in V3

V3: https://lore.kernel.org/all/20231211063355.2630028-1-srasheed@marvell.com/
  - Corrected error cleanup logic for PF-VF mbox setup
  - Removed double inclusion of types.h header file in octep_pfvf_mbox.c

V2: https://lore.kernel.org/all/20231209081450.2613561-1-srasheed@marvell.com/
  - Removed unused variable in PATCH 1/4

V1: https://lore.kernel.org/all/20231208070352.2606192-1-srasheed@marvell.com/
====================

Link: https://lore.kernel.org/r/20231215181425.2681426-1-srasheed@marvell.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents c49b292d 4ebb86a9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,4 +7,4 @@ obj-$(CONFIG_OCTEON_EP) += octeon_ep.o

octeon_ep-y := octep_main.o octep_cn9k_pf.o octep_tx.o octep_rx.o \
	       octep_ethtool.o octep_ctrl_mbox.o octep_ctrl_net.o \
	       octep_cnxk_pf.o
	       octep_pfvf_mbox.o octep_cnxk_pf.o
+52 −7
Original line number Diff line number Diff line
@@ -362,16 +362,55 @@ static void octep_setup_mbox_regs_cn93_pf(struct octep_device *oct, int q_no)
{
	struct octep_mbox *mbox = oct->mbox[q_no];

	mbox->q_no = q_no;

	/* PF mbox interrupt reg */
	mbox->mbox_int_reg = oct->mmio[0].hw_addr + CN93_SDP_EPF_MBOX_RINT(0);

	/* PF to VF DATA reg. PF writes into this reg */
	mbox->mbox_write_reg = oct->mmio[0].hw_addr + CN93_SDP_R_MBOX_PF_VF_DATA(q_no);
	mbox->pf_vf_data_reg = oct->mmio[0].hw_addr + CN93_SDP_MBOX_PF_VF_DATA(q_no);

	/* VF to PF DATA reg. PF reads from this reg */
	mbox->mbox_read_reg = oct->mmio[0].hw_addr + CN93_SDP_R_MBOX_VF_PF_DATA(q_no);
	mbox->vf_pf_data_reg = oct->mmio[0].hw_addr + CN93_SDP_MBOX_VF_PF_DATA(q_no);
}

/* Poll for mailbox messages from VF */
static void octep_poll_pfvf_mailbox(struct octep_device *oct)
{
	u32 vf, active_vfs, active_rings_per_vf, vf_mbox_queue;
	u64 reg0, reg1;

	reg0 = octep_read_csr64(oct, CN93_SDP_EPF_MBOX_RINT(0));
	reg1 = octep_read_csr64(oct, CN93_SDP_EPF_MBOX_RINT(1));
	if (reg0 || reg1) {
		active_vfs = CFG_GET_ACTIVE_VFS(oct->conf);
		active_rings_per_vf = CFG_GET_ACTIVE_RPVF(oct->conf);
		for (vf = 0; vf < active_vfs; vf++) {
			vf_mbox_queue = vf * active_rings_per_vf;

			if (vf_mbox_queue < 64) {
				if (!(reg0 & (0x1UL << vf_mbox_queue)))
					continue;
			} else {
				if (!(reg1 & (0x1UL << (vf_mbox_queue - 64))))
					continue;
			}

			if (!oct->mbox[vf_mbox_queue]) {
				dev_err(&oct->pdev->dev, "bad mbox vf %d\n", vf);
				continue;
			}
			schedule_work(&oct->mbox[vf_mbox_queue]->wk.work);
		}
		if (reg0)
			octep_write_csr64(oct, CN93_SDP_EPF_MBOX_RINT(0), reg0);
		if (reg1)
			octep_write_csr64(oct, CN93_SDP_EPF_MBOX_RINT(1), reg1);
	}
}

/* PF-VF mailbox interrupt handler */
static irqreturn_t octep_pfvf_mbox_intr_handler_cn93_pf(void *dev)
{
	struct octep_device *oct = (struct octep_device *)dev;

	octep_poll_pfvf_mailbox(oct);
	return IRQ_HANDLED;
}

/* Poll OEI events like heartbeat */
@@ -403,6 +442,7 @@ static irqreturn_t octep_oei_intr_handler_cn93_pf(void *dev)
 */
static void octep_poll_non_ioq_interrupts_cn93_pf(struct octep_device *oct)
{
	octep_poll_pfvf_mailbox(oct);
	octep_poll_oei_cn93_pf(oct);
}

@@ -646,6 +686,8 @@ static void octep_enable_interrupts_cn93_pf(struct octep_device *oct)

	octep_write_csr64(oct, CN93_SDP_EPF_MISC_RINT_ENA_W1S, intr_mask);
	octep_write_csr64(oct, CN93_SDP_EPF_DMA_RINT_ENA_W1S, intr_mask);
	octep_write_csr64(oct, CN93_SDP_EPF_MBOX_RINT_ENA_W1S(0), -1ULL);
	octep_write_csr64(oct, CN93_SDP_EPF_MBOX_RINT_ENA_W1S(1), -1ULL);

	octep_write_csr64(oct, CN93_SDP_EPF_DMA_VF_RINT_ENA_W1S(0), -1ULL);
	octep_write_csr64(oct, CN93_SDP_EPF_PP_VF_RINT_ENA_W1S(0), -1ULL);
@@ -672,6 +714,8 @@ static void octep_disable_interrupts_cn93_pf(struct octep_device *oct)

	octep_write_csr64(oct, CN93_SDP_EPF_MISC_RINT_ENA_W1C, intr_mask);
	octep_write_csr64(oct, CN93_SDP_EPF_DMA_RINT_ENA_W1C, intr_mask);
	octep_write_csr64(oct, CN93_SDP_EPF_MBOX_RINT_ENA_W1C(0), -1ULL);
	octep_write_csr64(oct, CN93_SDP_EPF_MBOX_RINT_ENA_W1C(1), -1ULL);

	octep_write_csr64(oct, CN93_SDP_EPF_DMA_VF_RINT_ENA_W1C(0), -1ULL);
	octep_write_csr64(oct, CN93_SDP_EPF_PP_VF_RINT_ENA_W1C(0), -1ULL);
@@ -807,6 +851,7 @@ void octep_device_setup_cn93_pf(struct octep_device *oct)
	oct->hw_ops.setup_oq_regs = octep_setup_oq_regs_cn93_pf;
	oct->hw_ops.setup_mbox_regs = octep_setup_mbox_regs_cn93_pf;

	oct->hw_ops.mbox_intr_handler = octep_pfvf_mbox_intr_handler_cn93_pf;
	oct->hw_ops.oei_intr_handler = octep_oei_intr_handler_cn93_pf;
	oct->hw_ops.ire_intr_handler = octep_ire_intr_handler_cn93_pf;
	oct->hw_ops.ore_intr_handler = octep_ore_intr_handler_cn93_pf;
+39 −7
Original line number Diff line number Diff line
@@ -392,16 +392,44 @@ static void octep_setup_mbox_regs_cnxk_pf(struct octep_device *oct, int q_no)
{
	struct octep_mbox *mbox = oct->mbox[q_no];

	mbox->q_no = q_no;

	/* PF mbox interrupt reg */
	mbox->mbox_int_reg = oct->mmio[0].hw_addr + CNXK_SDP_EPF_MBOX_RINT(0);

	/* PF to VF DATA reg. PF writes into this reg */
	mbox->mbox_write_reg = oct->mmio[0].hw_addr + CNXK_SDP_R_MBOX_PF_VF_DATA(q_no);
	mbox->pf_vf_data_reg = oct->mmio[0].hw_addr + CNXK_SDP_MBOX_PF_VF_DATA(q_no);

	/* VF to PF DATA reg. PF reads from this reg */
	mbox->mbox_read_reg = oct->mmio[0].hw_addr + CNXK_SDP_R_MBOX_VF_PF_DATA(q_no);
	mbox->vf_pf_data_reg = oct->mmio[0].hw_addr + CNXK_SDP_MBOX_VF_PF_DATA(q_no);
}

static void octep_poll_pfvf_mailbox_cnxk_pf(struct octep_device *oct)
{
	u32 vf, active_vfs, active_rings_per_vf, vf_mbox_queue;
	u64 reg0;

	reg0 = octep_read_csr64(oct, CNXK_SDP_EPF_MBOX_RINT(0));
	if (reg0) {
		active_vfs = CFG_GET_ACTIVE_VFS(oct->conf);
		active_rings_per_vf = CFG_GET_ACTIVE_RPVF(oct->conf);
		for (vf = 0; vf < active_vfs; vf++) {
			vf_mbox_queue = vf * active_rings_per_vf;
			if (!(reg0 & (0x1UL << vf_mbox_queue)))
				continue;

			if (!oct->mbox[vf_mbox_queue]) {
				dev_err(&oct->pdev->dev, "bad mbox vf %d\n", vf);
				continue;
			}
			schedule_work(&oct->mbox[vf_mbox_queue]->wk.work);
		}
		if (reg0)
			octep_write_csr64(oct, CNXK_SDP_EPF_MBOX_RINT(0), reg0);
	}
}

static irqreturn_t octep_pfvf_mbox_intr_handler_cnxk_pf(void *dev)
{
	struct octep_device *oct = (struct octep_device *)dev;

	octep_poll_pfvf_mailbox_cnxk_pf(oct);
	return IRQ_HANDLED;
}

/* Poll OEI events like heartbeat */
@@ -435,6 +463,7 @@ static irqreturn_t octep_oei_intr_handler_cnxk_pf(void *dev)
 */
static void octep_poll_non_ioq_interrupts_cnxk_pf(struct octep_device *oct)
{
	octep_poll_pfvf_mailbox_cnxk_pf(oct);
	octep_poll_oei_cnxk_pf(oct);
}

@@ -682,6 +711,7 @@ static void octep_enable_interrupts_cnxk_pf(struct octep_device *oct)

	octep_write_csr64(oct, CNXK_SDP_EPF_MISC_RINT_ENA_W1S, intr_mask);
	octep_write_csr64(oct, CNXK_SDP_EPF_DMA_RINT_ENA_W1S, intr_mask);
	octep_write_csr64(oct, CNXK_SDP_EPF_MBOX_RINT_ENA_W1S(0), -1ULL);

	octep_write_csr64(oct, CNXK_SDP_EPF_DMA_VF_RINT_ENA_W1S(0), -1ULL);
	octep_write_csr64(oct, CNXK_SDP_EPF_PP_VF_RINT_ENA_W1S(0), -1ULL);
@@ -708,6 +738,7 @@ static void octep_disable_interrupts_cnxk_pf(struct octep_device *oct)

	octep_write_csr64(oct, CNXK_SDP_EPF_MISC_RINT_ENA_W1C, intr_mask);
	octep_write_csr64(oct, CNXK_SDP_EPF_DMA_RINT_ENA_W1C, intr_mask);
	octep_write_csr64(oct, CNXK_SDP_EPF_MBOX_RINT_ENA_W1C(0), -1ULL);

	octep_write_csr64(oct, CNXK_SDP_EPF_DMA_VF_RINT_ENA_W1C(0), -1ULL);
	octep_write_csr64(oct, CNXK_SDP_EPF_PP_VF_RINT_ENA_W1C(0), -1ULL);
@@ -843,6 +874,7 @@ void octep_device_setup_cnxk_pf(struct octep_device *oct)
	oct->hw_ops.setup_oq_regs = octep_setup_oq_regs_cnxk_pf;
	oct->hw_ops.setup_mbox_regs = octep_setup_mbox_regs_cnxk_pf;

	oct->hw_ops.mbox_intr_handler = octep_pfvf_mbox_intr_handler_cnxk_pf;
	oct->hw_ops.oei_intr_handler = octep_oei_intr_handler_cnxk_pf;
	oct->hw_ops.ire_intr_handler = octep_ire_intr_handler_cnxk_pf;
	oct->hw_ops.ore_intr_handler = octep_ore_intr_handler_cnxk_pf;
+3 −1
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@
 * |reserved (4 bytes)                         |
 * |-------------------------------------------|
 * |host version (8 bytes)                     |
 * |    low 32 bits                            |
 * |host status (8 bytes)                      |
 * |host reserved (104 bytes)                  |
 * |-------------------------------------------|
 * |fw version (8 bytes)                       |
 * |fw version's (8 bytes)                     |
 * |    min=high 32 bits, max=low 32 bits      |
 * |fw status (8 bytes)                        |
 * |fw reserved (104 bytes)                    |
 * |===========================================|
+6 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include "octep_config.h"
#include "octep_main.h"
#include "octep_ctrl_net.h"
#include "octep_pfvf_mbox.h"

/* Control plane version */
#define OCTEP_CP_VERSION_CURRENT	OCTEP_CP_VERSION(1, 0, 0)
@@ -329,6 +330,11 @@ static int process_mbox_notify(struct octep_device *oct,
	    octep_ctrl_net_f2h_cmd_versions[cmd] < OCTEP_CP_VERSION_CURRENT)
		return -EOPNOTSUPP;

	if (msg->hdr.s.is_vf) {
		octep_pfvf_notify(oct, msg);
		return 0;
	}

	switch (cmd) {
	case OCTEP_CTRL_NET_F2H_CMD_LINK_STATUS:
		if (netif_running(netdev)) {
Loading