Commit 981239ee authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'support-octeon-cn98-devices'

Shinas Rasheed says:

====================
support OCTEON CN98 devices

Implement device unload control net API required for CN98
devices and add support in driver for the same.

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

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


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 000db9e9 068b2b64
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ EndPoint NIC.
Supported Devices
=================
Currently, this driver support following devices:
 * Network controller: Cavium, Inc. Device b100
 * Network controller: Cavium, Inc. Device b200
 * Network controller: Cavium, Inc. Device b400
 * Network controller: Cavium, Inc. Device b900
+20 −4
Original line number Diff line number Diff line
@@ -216,9 +216,15 @@ static void octep_init_config_cn93_pf(struct octep_device *oct)
	conf->sriov_cfg.vf_srn = CN93_SDP_EPF_RINFO_SRN(val);

	val = octep_read_csr64(oct, CN93_SDP_MAC_PF_RING_CTL(oct->pcie_port));
	if (oct->chip_id == OCTEP_PCI_DEVICE_ID_CN98_PF) {
		conf->pf_ring_cfg.srn =  CN98_SDP_MAC_PF_RING_CTL_SRN(val);
		conf->pf_ring_cfg.max_io_rings = CN98_SDP_MAC_PF_RING_CTL_RPPF(val);
		conf->pf_ring_cfg.active_io_rings = conf->pf_ring_cfg.max_io_rings;
	} else {
		conf->pf_ring_cfg.srn =  CN93_SDP_MAC_PF_RING_CTL_SRN(val);
		conf->pf_ring_cfg.max_io_rings = CN93_SDP_MAC_PF_RING_CTL_RPPF(val);
		conf->pf_ring_cfg.active_io_rings = conf->pf_ring_cfg.max_io_rings;
	}
	dev_info(&pdev->dev, "pf_srn=%u rpvf=%u nvfs=%u rppf=%u\n",
		 conf->pf_ring_cfg.srn, conf->sriov_cfg.active_rings_per_vf,
		 conf->sriov_cfg.active_vfs, conf->pf_ring_cfg.active_io_rings);
@@ -578,6 +584,13 @@ static irqreturn_t octep_ioq_intr_handler_cn93_pf(void *data)
	return IRQ_HANDLED;
}

/* soft reset of 98xx */
static int octep_soft_reset_cn98_pf(struct octep_device *oct)
{
	dev_info(&oct->pdev->dev, "CN98XX: skip soft reset\n");
	return 0;
}

/* soft reset of 93xx */
static int octep_soft_reset_cn93_pf(struct octep_device *oct)
{
@@ -806,6 +819,9 @@ void octep_device_setup_cn93_pf(struct octep_device *oct)
	oct->hw_ops.misc_intr_handler = octep_misc_intr_handler_cn93_pf;
	oct->hw_ops.rsvd_intr_handler = octep_rsvd_intr_handler_cn93_pf;
	oct->hw_ops.ioq_intr_handler = octep_ioq_intr_handler_cn93_pf;
	if (oct->chip_id == OCTEP_PCI_DEVICE_ID_CN98_PF)
		oct->hw_ops.soft_reset = octep_soft_reset_cn98_pf;
	else
		oct->hw_ops.soft_reset = octep_soft_reset_cn93_pf;
	oct->hw_ops.reinit_regs = octep_reinit_regs_cn93_pf;

+15 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ static atomic_t ctrl_net_msg_id;

/* Control plane version in which OCTEP_CTRL_NET_H2F_CMD was added */
static const u32 octep_ctrl_net_h2f_cmd_versions[OCTEP_CTRL_NET_H2F_CMD_MAX] = {
	[OCTEP_CTRL_NET_H2F_CMD_INVALID ... OCTEP_CTRL_NET_H2F_CMD_GET_INFO] =
	[OCTEP_CTRL_NET_H2F_CMD_INVALID ... OCTEP_CTRL_NET_H2F_CMD_DEV_REMOVE] =
	 OCTEP_CP_VERSION(1, 0, 0)
};

@@ -393,10 +393,24 @@ int octep_ctrl_net_get_info(struct octep_device *oct, int vfid,
	return 0;
}

int octep_ctrl_net_dev_remove(struct octep_device *oct, int vfid)
{
	struct octep_ctrl_net_wait_data d = {};
	struct octep_ctrl_net_h2f_req *req;

	req = &d.data.req;
	dev_dbg(&oct->pdev->dev, "Sending dev_unload msg to fw\n");
	init_send_req(&d.msg, req, sizeof(int), vfid);
	req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_DEV_REMOVE;

	return octep_send_mbox_req(oct, &d, false);
}
int octep_ctrl_net_uninit(struct octep_device *oct)
{
	struct octep_ctrl_net_wait_data *pos, *n;

	octep_ctrl_net_dev_remove(oct, OCTEP_CTRL_NET_INVALID_VFID);

	list_for_each_entry_safe(pos, n, &oct->ctrl_req_wait_list, list)
		pos->done = 1;

+11 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ enum octep_ctrl_net_h2f_cmd {
	OCTEP_CTRL_NET_H2F_CMD_RX_STATE,
	OCTEP_CTRL_NET_H2F_CMD_LINK_INFO,
	OCTEP_CTRL_NET_H2F_CMD_GET_INFO,
	OCTEP_CTRL_NET_H2F_CMD_DEV_REMOVE,
	OCTEP_CTRL_NET_H2F_CMD_MAX
};

@@ -370,6 +371,16 @@ void octep_ctrl_net_recv_fw_messages(struct octep_device *oct);
int octep_ctrl_net_get_info(struct octep_device *oct, int vfid,
			    struct octep_fw_info *info);

/**
 * octep_ctrl_net_dev_remove() - Indicate to firmware that a device unload has happened.
 *
 * @oct: non-null pointer to struct octep_device.
 * @vfid: Index of virtual function.
 *
 * return value: 0 on success, -errno on failure.
 */
int octep_ctrl_net_dev_remove(struct octep_device *oct, int vfid);

/**
 * octep_ctrl_net_uninit() - Uninitialize data for ctrl net.
 *
+4 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ struct workqueue_struct *octep_wq;

/* Supported Devices */
static const struct pci_device_id octep_pci_id_tbl[] = {
	{PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, OCTEP_PCI_DEVICE_ID_CN98_PF)},
	{PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, OCTEP_PCI_DEVICE_ID_CN93_PF)},
	{PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, OCTEP_PCI_DEVICE_ID_CNF95N_PF)},
	{PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, OCTEP_PCI_DEVICE_ID_CN10KA_PF)},
@@ -1147,6 +1148,8 @@ static void octep_ctrl_mbox_task(struct work_struct *work)
static const char *octep_devid_to_str(struct octep_device *oct)
{
	switch (oct->chip_id) {
	case OCTEP_PCI_DEVICE_ID_CN98_PF:
		return "CN98XX";
	case OCTEP_PCI_DEVICE_ID_CN93_PF:
		return "CN93XX";
	case OCTEP_PCI_DEVICE_ID_CNF95N_PF:
@@ -1197,6 +1200,7 @@ int octep_device_setup(struct octep_device *oct)
	dev_info(&pdev->dev, "chip_id = 0x%x\n", pdev->device);

	switch (oct->chip_id) {
	case OCTEP_PCI_DEVICE_ID_CN98_PF:
	case OCTEP_PCI_DEVICE_ID_CN93_PF:
	case OCTEP_PCI_DEVICE_ID_CNF95N_PF:
		dev_info(&pdev->dev, "Setting up OCTEON %s PF PASS%d.%d\n",
Loading