From: David Marchand <david.marchand@redhat.com>
To: Akhil Goyal <gakhil@marvell.com>
Cc: dev@dpdk.org, thomas@monjalon.net, hemant.agrawal@nxp.com,
jerinj@marvell.com, hkalra@marvell.com
Subject: Re: [PATCH v3 1/9] drivers/raw: introduce cnxk rvu lf device driver
Date: Wed, 23 Oct 2024 16:01:57 +0200 [thread overview]
Message-ID: <CAJFAV8zqP36YPaLTFMBt7Y5qMdFO4bjCctcbh=+jB=8oz5W6_w@mail.gmail.com> (raw)
In-Reply-To: <20241008184915.1356089-2-gakhil@marvell.com>
On Tue, Oct 8, 2024 at 8:49 PM Akhil Goyal <gakhil@marvell.com> wrote:
>
> CNXK product families can have a use case to allow PF and VF
> applications to communicate using mailboxes and also get notified
> of any interrupt that may occur on the device.
> Hence, a new raw device driver is added for such RVU LF devices.
> These devices can map to a PF or a VF which can send mailboxes to
> each other.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Some small comments below.
> diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
> new file mode 100644
> index 0000000000..36067909be
> --- /dev/null
> +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
> @@ -0,0 +1,123 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2024 Marvell.
> + */
> +
> +#include <bus_pci_driver.h>
> +#include <rte_common.h>
> +#include <dev_driver.h>
> +#include <rte_eal.h>
> +#include <rte_lcore.h>
> +#include <rte_pci.h>
> +#include <rte_rawdev.h>
> +#include <rte_rawdev_pmd.h>
> +
> +#include <roc_api.h>
> +
> +#include "cnxk_rvu_lf.h"
> +
> +static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
> + .dev_selftest = NULL,
> +};
> +
> +static void
> +rvu_lf_rawdev_get_name(char *name, struct rte_pci_device *pci_dev)
> +{
> + snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "RVU LF:%02x:%02x.%x",
> + pci_dev->addr.bus, pci_dev->addr.devid,
> + pci_dev->addr.function);
> +}
> +
> +static int
> +rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
> +{
> + char name[RTE_RAWDEV_NAME_MAX_LEN];
> + struct rte_rawdev *rvu_lf_rawdev;
> + struct roc_rvu_lf *roc_rvu_lf;
> + int ret;
> +
> + RTE_SET_USED(pci_drv);
> +
> + if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> + return 0;
> +
> + if (!pci_dev->mem_resource[2].addr) {
> + CNXK_RVU_LF_LOG(ERR, "BARs have invalid values: BAR0 %p\n BAR2 %p",
No \n in the middle of a log please.
> + pci_dev->mem_resource[2].addr, pci_dev->mem_resource[4].addr);
> + return -ENODEV;
> + }
> +
> + ret = roc_plt_init();
> + if (ret)
> + return ret;
> +
> + rvu_lf_rawdev_get_name(name, pci_dev);
> + rvu_lf_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_lf),
> + rte_socket_id());
> + if (rvu_lf_rawdev == NULL) {
> + CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev");
> + return -ENOMEM;
> + }
> +
> + rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops;
> + rvu_lf_rawdev->device = &pci_dev->device;
> + rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name;
> +
> + roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private;
> + roc_rvu_lf->pci_dev = pci_dev;
> +
> + ret = roc_rvu_lf_dev_init(roc_rvu_lf);
> + if (ret) {
> + rte_rawdev_pmd_release(rvu_lf_rawdev);
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static int
> +rvu_lf_remove(struct rte_pci_device *pci_dev)
> +{
> + char name[RTE_RAWDEV_NAME_MAX_LEN];
> + struct roc_rvu_lf *roc_rvu_lf;
> + struct rte_rawdev *rawdev;
> +
> + if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> + return 0;
> +
> + if (pci_dev == NULL) {
> + CNXK_RVU_LF_LOG(ERR, "invalid pci_dev");
> + return -EINVAL;
> + }
> +
> + rvu_lf_rawdev_get_name(name, pci_dev);
> + rawdev = rte_rawdev_pmd_get_named_dev(name);
> + if (rawdev == NULL) {
> + CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name);
> + return -EINVAL;
> + }
> +
> + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
> + roc_rvu_lf_dev_fini(roc_rvu_lf);
> +
> + return rte_rawdev_pmd_release(rawdev);
> +}
> +
> +static const struct rte_pci_id pci_rvu_lf_map[] = {
> + CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_PF),
> + CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_VF),
> + {
> + .vendor_id = 0,
> + },
> +};
> +
> +static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd = {
> + .id_table = pci_rvu_lf_map,
> + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
> + .probe = rvu_lf_probe,
> + .remove = rvu_lf_remove,
> +};
> +
> +RTE_PMD_REGISTER_PCI(rvu_lf_rawdev_pci_driver, cnxk_rvu_lf_rawdev_pmd);
> +RTE_PMD_REGISTER_PCI_TABLE(rvu_lf_rawdev_pci_driver, pci_rvu_lf_map);
> +RTE_PMD_REGISTER_KMOD_DEP(rvu_lf_rawdev_pci_driver, "vfio-pci");
> +RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_rvu_lf, rvu_lf, INFO);
> diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
> new file mode 100644
> index 0000000000..a23a629500
> --- /dev/null
> +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
> @@ -0,0 +1,35 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2024 Marvell.
> + */
> +
> +#ifndef _CNXK_RVU_LF_H_
> +#define _CNXK_RVU_LF_H_
> +
> +#include <stdint.h>
> +
> +#include <rte_common.h>
> +
> +/**
> + * @file cnxk_rvu_lf.h
> + *
> + * Marvell RVU LF raw PMD specific internal structures
> + *
> + * This API allows applications to manage RVU LF device in user space along with
> + * installing interrupt handlers for low latency signal processing.
> + */
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
You don't need this for non exported/internal headers.
> +
> +extern int cnxk_logtype_rvu_lf;
> +
> +#define CNXK_RVU_LF_LOG(level, fmt, args...) \
> + rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
> + "%s(): " fmt "\n", __func__, ## args)
Please convert to RTE_LOG_LINE_PREFIX.
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* _CNXK_RVU_LF_H_ */
--
David Marchand
next prev parent reply other threads:[~2024-10-23 14:08 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-07 19:33 [PATCH 0/9] " Akhil Goyal
2024-09-07 19:33 ` [PATCH 1/9] rawdev: add API to get device from index Akhil Goyal
2024-09-23 15:23 ` Jerin Jacob
2024-10-08 7:40 ` [PATCH v2] " Akhil Goyal
2024-10-08 11:59 ` David Marchand
2024-10-08 12:00 ` [EXTERNAL] " Akhil Goyal
2024-10-09 21:13 ` Akhil Goyal
2024-10-21 10:48 ` Akhil Goyal
2024-10-09 6:11 ` Hemant Agrawal
2024-10-22 19:12 ` David Marchand
2024-09-07 19:33 ` [PATCH 2/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-09-23 15:28 ` Jerin Jacob
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 1/9] " Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 5/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 6/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 7/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 8/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc Akhil Goyal
2024-10-08 11:52 ` [PATCH v2 0/9] drivers/raw: introduce cnxk rvu lf device driver David Marchand
2024-10-08 12:10 ` [EXTERNAL] " Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 1/9] " Akhil Goyal
2024-10-08 20:44 ` Stephen Hemminger
2024-10-09 18:09 ` Stephen Hemminger
2024-10-09 18:14 ` [EXTERNAL] " Akhil Goyal
2024-10-23 14:01 ` David Marchand [this message]
2024-10-08 18:49 ` [PATCH v3 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
2024-10-23 14:13 ` David Marchand
2024-10-08 18:49 ` [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
2024-10-21 21:30 ` Thomas Monjalon
2024-10-22 2:46 ` Jerin Jacob
2024-10-22 6:05 ` [EXTERNAL] " Akhil Goyal
2024-10-22 9:27 ` Thomas Monjalon
2024-10-22 10:08 ` David Marchand
2024-10-22 12:06 ` Akhil Goyal
2024-10-23 16:00 ` Thomas Monjalon
2024-10-23 19:14 ` Akhil Goyal
2024-10-23 19:29 ` Thomas Monjalon
2024-10-22 15:30 ` Stephen Hemminger
2024-10-22 17:06 ` Jerin Jacob
2024-10-08 18:49 ` [PATCH v3 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 5/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 6/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 7/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 8/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
2024-10-23 14:16 ` David Marchand
2024-10-08 18:49 ` [PATCH v3 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc Akhil Goyal
2024-09-07 19:33 ` [PATCH 3/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
2024-09-07 19:33 ` [PATCH 4/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
2024-09-07 19:33 ` [PATCH 5/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
2024-09-07 19:33 ` [PATCH 6/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
2024-09-07 19:33 ` [PATCH 7/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
2024-09-07 19:33 ` [PATCH 8/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
2024-09-07 19:33 ` [PATCH 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJFAV8zqP36YPaLTFMBt7Y5qMdFO4bjCctcbh=+jB=8oz5W6_w@mail.gmail.com' \
--to=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=hemant.agrawal@nxp.com \
--cc=hkalra@marvell.com \
--cc=jerinj@marvell.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).