From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E289745BB3; Wed, 23 Oct 2024 16:08:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8230040F16; Wed, 23 Oct 2024 16:08:55 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 24AD140647 for ; Wed, 23 Oct 2024 16:08:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729692533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=68A10iNCX+4TiAvlJbtDTgkZpM5eYcCUogRkkMTy2Tw=; b=SGFj1kimC7cHuRxsr2ALdvAJz7g26QM8ikRJWskFGFxVB7+9gICv1eryug9vDQujt089fV xKGmWy1Tg6hH3IlXGrdm/gg7ZOM7izKpVECj/IP62ReMFrCjXfbKGDU2fra9g1vTAuXHzh /95WLoXA6XANOtX+srgjBA7Pmwjqa1k= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-513-tObwYLY7OruA8WdNVfF1hQ-1; Wed, 23 Oct 2024 10:08:52 -0400 X-MC-Unique: tObwYLY7OruA8WdNVfF1hQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a9a194d672bso425802166b.2 for ; Wed, 23 Oct 2024 07:08:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729692531; x=1730297331; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=68A10iNCX+4TiAvlJbtDTgkZpM5eYcCUogRkkMTy2Tw=; b=rhOKpruYOxQRLxAlP/DJMzUfpf6BtorNb+Fq98oav/vbq1tkObY3XDm+NoH5784za8 TClLR7ZsWF79FhiUaaNEa367mkNcP6UXoTcn7j7I3yDZcOj+q1DhE8iWhXENpMiCMDEm eagpRuCTv4Ivpnce64Fw/4GnYOCJ3z48zG6UqWD4W0OYw3U23/bha9Mkm0qgXSd9k4Vt QUerElFkN5nlP4hTegoWudcPU3UAluPGcWviAJ/lxPUQZSaxrwxeYJg/XMb4yXupCb1y jhjCxoLtpCzU0Cic4/YfM3ngFNFkyR0Xjb9A/or8S17R2wTEObN/wBXEV3ps7hogR/hk Ycww== X-Gm-Message-State: AOJu0YzWhaKJB2Temj+alnQBUgNem5alXFR1GO19o2pVUZCfpV2VBWbT fSFIP3jbJaM/xPh/EdLAxbfmYtBXHB8knMhXoz8Azig8wCy1q0xzkX0SbQ2t1mhfjuad/bfZG5i vH7fRTgPZEx1CocF6mYigMMQTXgzprGlwocarVDFG9PwON97ickw+UuYDwEBGUhMhECethirUq2 vCJOhfVwDT70gocqo= X-Received: by 2002:a05:6512:ea8:b0:539:f74b:62a5 with SMTP id 2adb3069b0e04-53b1a30d646mr1482581e87.25.1729692130403; Wed, 23 Oct 2024 07:02:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWjTg86rf2LxY9pmfvImpQaip0CJkRoKzHglWncRSyZZnJuAG1lA61KfXQFOELgLWxwkPxF+ltBFt3Vq+/IR4= X-Received: by 2002:a05:6512:ea8:b0:539:f74b:62a5 with SMTP id 2adb3069b0e04-53b1a30d646mr1482421e87.25.1729692129069; Wed, 23 Oct 2024 07:02:09 -0700 (PDT) MIME-Version: 1.0 References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> <20241008184915.1356089-2-gakhil@marvell.com> In-Reply-To: <20241008184915.1356089-2-gakhil@marvell.com> From: David Marchand Date: Wed, 23 Oct 2024 16:01:57 +0200 Message-ID: Subject: Re: [PATCH v3 1/9] drivers/raw: introduce cnxk rvu lf device driver To: Akhil Goyal Cc: dev@dpdk.org, thomas@monjalon.net, hemant.agrawal@nxp.com, jerinj@marvell.com, hkalra@marvell.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, Oct 8, 2024 at 8:49=E2=80=AFPM Akhil Goyal wro= te: > > 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 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 > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include "cnxk_rvu_lf.h" > + > +static const struct rte_rawdev_ops rvu_lf_rawdev_ops =3D { > + .dev_selftest =3D 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() !=3D 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 =3D roc_plt_init(); > + if (ret) > + return ret; > + > + rvu_lf_rawdev_get_name(name, pci_dev); > + rvu_lf_rawdev =3D rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_l= f), > + rte_socket_id()); > + if (rvu_lf_rawdev =3D=3D NULL) { > + CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev"); > + return -ENOMEM; > + } > + > + rvu_lf_rawdev->dev_ops =3D &rvu_lf_rawdev_ops; > + rvu_lf_rawdev->device =3D &pci_dev->device; > + rvu_lf_rawdev->driver_name =3D pci_dev->driver->driver.name; > + > + roc_rvu_lf =3D (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private; > + roc_rvu_lf->pci_dev =3D pci_dev; > + > + ret =3D 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() !=3D RTE_PROC_PRIMARY) > + return 0; > + > + if (pci_dev =3D=3D NULL) { > + CNXK_RVU_LF_LOG(ERR, "invalid pci_dev"); > + return -EINVAL; > + } > + > + rvu_lf_rawdev_get_name(name, pci_dev); > + rawdev =3D rte_rawdev_pmd_get_named_dev(name); > + if (rawdev =3D=3D NULL) { > + CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name); > + return -EINVAL; > + } > + > + roc_rvu_lf =3D (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[] =3D { > + 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 =3D 0, > + }, > +}; > + > +static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd =3D { > + .id_table =3D pci_rvu_lf_map, > + .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_A= S_VA, > + .probe =3D rvu_lf_probe, > + .remove =3D 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 > + > +#include > + > +/** > + * @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 al= ong 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_ */ --=20 David Marchand