From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01hn0229.outbound.protection.outlook.com [104.47.2.229]) by dpdk.org (Postfix) with ESMTP id 7A91BDED for ; Fri, 4 May 2018 10:58:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=pM+wXYDCtUUMxPFQTKxSnJ6KocoX8IDTh7KLSQmC3wg=; b=TaHE0O6KqdyBHUUrSckDgINNe69YpdNAzNmOF3RZsFUhUvMxlJ1qC8zMeHG5RYoy4WOMmW5TPD2JWNxqrf5RJbbocgvPADDQG0UxtWcbK4Q90lLYVtxi1CXXOA1sInBzbk4UrYD8Wz3WF8VPQfsgL9nRphz+gCukwQEKPH5h1+c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; Received: from [10.232.14.39] (14.142.187.166) by AM5PR0402MB2771.eurprd04.prod.outlook.com (2603:10a6:203:98::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.735.16; Fri, 4 May 2018 08:58:07 +0000 To: "Xu, Rosen" , dev@dpdk.org Cc: declan.doherty@intel.com, bruce.richardson@intel.com, ferruh.yigit@intel.com, konstantin.ananyev@intel.com, tianfei.zhang@intel.com, hao.wu@intel.com, gaetan.rivet@6wind.com, Yanglong Wu References: <1521553556-62982-1-git-send-email-rosen.xu@intel.com> <1524735793-37302-1-git-send-email-rosen.xu@intel.com> <1524735793-37302-4-git-send-email-rosen.xu@intel.com> From: Shreyansh Jain Message-ID: <19adfc90-e90c-069c-cd90-20de6e7a98cf@nxp.com> Date: Fri, 4 May 2018 14:44:46 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1524735793-37302-4-git-send-email-rosen.xu@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: BM1PR01CA0081.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::21) To AM5PR0402MB2771.eurprd04.prod.outlook.com (2603:10a6:203:98::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(2017052603328)(7153060)(7193020); SRVR:AM5PR0402MB2771; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0402MB2771; 3:dR/LP67FJPhGw+wtroKQAAwErRqacDa1srt3Eqj+MCGzx3G4/iTCI74xqRVYm3EIeTx6tG4+AlDPOoNilYJM/8aNGDVnvcq6PusZ1Qm/ZumJukKoQnfNE/yIPik5KaQ3wGirscCzo4u6gdFC5p346YO4sW26CKcvWnHWA2bh8Bb1eellkfY4Q07xm9ncOX0MNy+NqEtBLDNFikGrye971Nh89f47AXTZWSPogPmQtTnzxVqyoaHfAaUd3JSx2dKX; 25:uDGYHqplb0n8kSKqR8j8jgbX3a9lHRJRnIGDvZ+zdf8vUPyoP4PPs3H1NgALDkuh1kaPWfjD+c7KOCWuCK0ZB7JNA49NL5qMpuLiBGcjTHUXR/zdUpeqBoOeATe+LH7orUHLGvP2KVc811Pf/4dtqeJJsWb3z7oAWlS9IpbgwBA4K3EtQPzAg7v7kD6VVGqaKzWOXedj+awlHfaOoxLl83z/hm8ecz1R788wGqnjuSb6D8TR8KYjpT2vmBXcHUOtYUP1Vjw+x0fGXv6BIkqx4meE0C2T67tYWa1YQs5YXesY3b4eXwOyQllu3N6TwT2fRZkG/3C/2Ynuzvx1SjSZPQ==; 31:q/VGHCz4hF6ZiURtc166/sITw9UnKqR2bda0WqcBSPglfdxz2GjYtA/pWQCh4WTQzudx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84Gltm116XkZYMSDfTUKAqHvcyDLVVxZw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(66839620246622)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231254)(2232076)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:AM5PR0402MB2771; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0402MB2771; X-Forefront-PRVS: 06628F7CA4 X-Forefront-Antispam-Report: SFV:SPM; SFS:(10009020)(6049001)(39860400002)(39380400002)(366004)(376002)(396003)(346002)(189003)(199004)(43544003)(31696002)(5660300001)(106356001)(105586002)(6666003)(36756003)(50466002)(55236004)(64126003)(59450400001)(66066001)(65806001)(65956001)(186003)(26005)(47776003)(478600001)(65826007)(4326008)(76176011)(25786009)(16526019)(77096007)(386003)(305945005)(6246003)(52116002)(67846002)(230700001)(7736002)(23676004)(52146003)(2486003)(5009440100003)(44832011)(956004)(68736007)(2616005)(97736004)(446003)(476003)(11346002)(486006)(53936002)(31686004)(316002)(229853002)(7416002)(81156014)(6486002)(6116002)(3846002)(2906002)(86362001)(58126008)(8936002)(81166006)(8676002)(16576012)(59010400001)(110426005); DIR:OUT; SFP:1501; SCL:5; SRVR:AM5PR0402MB2771; H:[10.232.14.39]; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTVQUjA0MDJNQjI3NzE7MjM6aWdIb3NGRXUxT2tla25OS2huSndhYU5k?= =?utf-8?B?cE5nVUpPSmExVVJyTUhXVnpDMnlOWStKSGVkMVRtVmhzSXRDRW9UNmJiSG9o?= =?utf-8?B?SHJ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g2lGRLdmm+YOh1oN9rmTlu/jSLOE18+eU/dTzgX2LNCJMLW0S86xa5+W9WZ/+1cdMxRyFd24dEN3cNVFqZo86EomOitidf13DXoCGTGC/jsLcDBhhTqgnpivpvsCZVheg6eRWofEHwA6+nM4a9lNO/S3HBB0x9e+s9TsLsrGWrIAMeCKFtSs3Y/OLe+v/s8JFJzXdglzPYmi/0eALypGCMfvVjqej3cpL2QFPcL8knjqrlC8rqOeNEpoE3C8DhYT4//+7/J2BYJxmxdNzomxfB1WLRrH47FnAvMBkeDEe0yOv4617/UCPWR50oVDuoGVbKs683Q4EPN+x8V671K+C1VqmTCCDOw4m21onEt3eJ3AcfPHIH1nGdAV7pHrcLnRX8NcQ8plYR0OpK0Z7W01LpG4IUp; 5:C0TY+nS0JQmuKAiHcfxyeTr67UHVUN/kR3zPFuuCVid4BAGYXayE/ZBDuU9vkXK+ddBZMV/xw3+nqS3c5rkobtOMisJ5h5jc/BywOCkVM+aLkDGSIXXm4ishwXTvxf1RfLWM1kSORlTymqrhaFxkYkAyiXD6nMfkw3poGCuPt/4=; 24:EJ44FbKVDJ7YTwTYuog3fPL83cFlpZNeMYFnQNvGsb3rkbKK75djtCQzPu3CFVPVeLpiChRyWwfoftdCOH5v1w== SpamDiagnosticOutput: 1:22 X-Microsoft-Exchange-Diagnostics: 1; AM5PR0402MB2771; 7:75/Q63VWvgBzUactXbzqC5uoS7b6HhVQafcS1bdAxV05FZ+12Qr71ztd8rqHYMEXcoADJUWRobPud6nOyHX+dwxQp8JmXw2xegTzUBoxjba0y2FPhuSV2XGB4SCS3cZu8Ry0JsfstRAvNGbYsB4b3N6skpuSCIOem3ktwv+YU9MGhFQsjSTthQQWDQTjj6nWLStMeFIPEYRV01DB8/fDiHKT/s5C83ZwRPj+vb+scDVSAmog7Zb29dMLf5waskH3 X-MS-Office365-Filtering-Correlation-Id: 18b07329-6345-4f88-9a74-08d5b19d286a X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2018 08:58:07.1515 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18b07329-6345-4f88-9a74-08d5b19d286a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2771 Subject: Re: [dpdk-dev] [PATCH v6 3/5] iFPGA: Add Intel FPGA BUS Rawdev Driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2018 08:58:10 -0000 Hello Rosen, Sorry for multiple review iterations, but, in the v7, can you take care of these as well: On Thursday 26 April 2018 03:13 PM, Xu, Rosen wrote: > From: Rosen Xu > > Add Intel FPGA BUS Rawdev Driver which is based on > librte_rawdev library. > > Signed-off-by: Rosen Xu > Signed-off-by: Yanglong Wu > Signed-off-by: Figo zhang > --- > config/common_base | 1 + > drivers/raw/Makefile | 1 + > drivers/raw/ifpga_rawdev/Makefile | 36 ++ > drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 597 +++++++++++++++++++++ > drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 ++ > .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + > mk/rte.app.mk | 1 + > 7 files changed, 677 insertions(+) > create mode 100644 drivers/raw/ifpga_rawdev/Makefile > create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c > create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h > create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map > [...] > +static int > +fpga_pr(struct rte_rawdev *raw_dev, u32 port_id, u64 *buffer, u32 size, > + u64 *status) > +{ > + > + struct opae_adapter *adapter; > + struct opae_manager *mgr; > + struct opae_accelerator *acc; > + struct opae_bridge *br; > + int ret; > + > + adapter = ifpga_rawdev_get_priv(raw_dev); > + if (!adapter) > + return -ENODEV; > + > + mgr = opae_adapter_get_mgr(adapter); > + if (!mgr) > + return -ENODEV; > + > + acc = opae_adapter_get_acc(adapter, port_id); > + if (!acc) > + return -ENODEV; > + > + br = opae_acc_get_br(acc); > + if (!br) > + return -ENODEV; > + > + ret = opae_manager_flash(mgr, port_id, buffer, size, status); > + if (ret) { > + printf("%s pr error %d\n", __func__, ret); Please use the debugging or error macros. > + return ret; > + } > + > + usleep(100); Hmm, is that some caveat or a stray line left from some debugging? > + ret = opae_bridge_reset(br); > + if (ret) { > + printf("%s reset port:%d error %d\n", __func__, port_id, ret); Same - debugging/error macros. > + return ret; > + } > + > + return ret; > +} > + > +static int rte_fpga_do_pr(struct rte_rawdev *rawdev, int port_id, > + const char *file_name) > +{ > + struct stat file_stat; > + int file_fd; > + int ret = 0; > + u32 buffer_size; > + void *buffer; > + u64 pr_error; > + > + if (!file_name) > + return -EINVAL; > + > + file_fd = open(file_name, O_RDONLY); > + if (file_fd < 0) { > + printf("%s: open file error: %s\n", __func__, file_name); > + printf("Message : %s\n", strerror(errno)); Same - debug/error macros > + return -EINVAL; > + } > + ret = stat(file_name, &file_stat); > + if (ret) { > + printf("stat on bitstream file failed: %s\n", file_name); One more (same is applicable across the file). > + return -EINVAL; > + } > + buffer_size = file_stat.st_size; > + printf("bitstream file size: %u\n", buffer_size); > + buffer = rte_malloc(NULL, buffer_size, 0); > + if (!buffer) { > + ret = -ENOMEM; > + goto close_fd; > + } > + > + /*read the raw data*/ > + if (buffer_size != read(file_fd, (void *)buffer, buffer_size)) { > + ret = -EINVAL; > + goto free_buffer; > + } > + > + /*do PR now*/ > + ret = fpga_pr(rawdev, port_id, buffer, buffer_size, &pr_error); > + printf("downloading to device port %d....%s.\n", port_id, > + ret ? "failed" : "success"); > + if (ret) { > + ret = -EINVAL; > + //raw_dev->ops->show_pr_error(pr_error); I am guessing this is stray from some debugging attempt. Same for the printf above. > + goto free_buffer; > + } > + > +free_buffer: > + if (buffer) > + rte_free(buffer); > +close_fd: > + close(file_fd); > + file_fd = 0; > + return ret; > +} > + > +static int ifpga_rawdev_pr(struct rte_rawdev *dev, > + rte_rawdev_obj_t pr_conf) > +{ > + struct opae_adapter *adapter; > + struct rte_afu_pr_conf *afu_pr_conf; > + int ret; > + struct uuid uuid; > + struct opae_accelerator *acc; > + > + IFPGA_RAWDEV_PMD_FUNC_TRACE(); > + > + adapter = ifpga_rawdev_get_priv(dev); > + if (!adapter) > + return -ENODEV; > + > + if (!pr_conf) > + return -EINVAL; > + > + afu_pr_conf = pr_conf; > + > + if (afu_pr_conf->pr_enable) { > + ret = rte_fpga_do_pr(dev, > + afu_pr_conf->afu_id.port, > + afu_pr_conf->bs_path); > + if (ret) { > + printf("do pr error %d\n", ret); One more > + return ret; > + } > + } > + > + acc = opae_adapter_get_acc(adapter, afu_pr_conf->afu_id.port); > + if (!acc) > + return -ENODEV; > + > + ret = opae_acc_get_uuid(acc, &uuid); > + if (ret) > + return ret; > + > + memcpy(&afu_pr_conf->afu_id.uuid_low, uuid.b, sizeof(u64)); > + memcpy(&afu_pr_conf->afu_id.uuid_high, uuid.b + 8, sizeof(u64)); > + > + printf("%s: uuid_l=0x%lx, uuid_h=0x%lx\n", __func__, > + (u64)afu_pr_conf->afu_id.uuid_low, > + (u64)afu_pr_conf->afu_id.uuid_high); debug/error macros > + > + return 0; > +} > + > +static const struct rte_rawdev_ops ifpga_rawdev_ops = { > + .dev_info_get = ifpga_rawdev_info_get, > + .dev_configure = NULL, > + .dev_start = ifpga_rawdev_start, > + .dev_stop = ifpga_rawdev_stop, > + .dev_close = ifpga_rawdev_close, > + .dev_reset = ifpga_rawdev_reset, > + > + .queue_def_conf = NULL, > + .queue_setup = NULL, > + .queue_release = NULL, > + > + .attr_get = NULL, > + .attr_set = NULL, > + > + .enqueue_bufs = NULL, > + .dequeue_bufs = NULL, > + > + .dump = NULL, > + > + .xstats_get = NULL, > + .xstats_get_names = NULL, > + .xstats_get_by_name = NULL, > + .xstats_reset = NULL, > + > + .firmware_status_get = NULL, > + .firmware_version_get = NULL, > + .firmware_load = ifpga_rawdev_pr, > + .firmware_unload = NULL, > + > + .dev_selftest = NULL, > +}; > + > +static int > +ifpga_rawdev_create(struct rte_pci_device *pci_dev, > + int socket_id) > +{ > + int ret = 0; > + struct rte_rawdev *rawdev = NULL; > + struct opae_adapter *adapter; > + struct opae_manager *mgr; > + struct opae_adapter_data_pci *data; > + char name[RTE_RAWDEV_NAME_MAX_LEN]; > + int i; > + > + if (!pci_dev) { > + IFPGA_RAWDEV_PMD_ERR("Invalid pci_dev of the device!"); > + ret = -EINVAL; > + goto cleanup; > + } > + > + memset(name, 0, sizeof(name)); > + snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%x:%02x.%x", > + pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); Alignment issue... 'pci_dev->addr.bus ... ' would start from underneath arguments of snprintf. > + > + IFPGA_RAWDEV_PMD_INFO("Init %s on NUMA node %d", name, rte_socket_id()); > + > + /* Allocate device structure */ > + rawdev = rte_rawdev_pmd_allocate(name, sizeof(struct opae_adapter), > + socket_id); > + if (rawdev == NULL) { > + IFPGA_RAWDEV_PMD_ERR("Unable to allocate rawdevice"); > + ret = -EINVAL; > + goto cleanup; > + } > + > + /* alloc OPAE_FPGA_PCI data to register to OPAE hardware level API */ > + data = opae_adapter_data_alloc(OPAE_FPGA_PCI); > + if (!data) > + return -ENOMEM; What about jumping to cleanup here? (pmd_release()) > + > + /* init opae_adapter_data_pci for device specific information */ > + for (i = 0; i < PCI_MAX_RESOURCE; i++) { > + data->region[i].phys_addr = pci_dev->mem_resource[i].phys_addr; > + data->region[i].len = pci_dev->mem_resource[i].len; > + data->region[i].addr = pci_dev->mem_resource[i].addr; > + } > + data->device_id = pci_dev->id.device_id; > + data->vendor_id = pci_dev->id.vendor_id; > + > + /* create a opae_adapter based on above device data */ > + adapter = opae_adapter_alloc(pci_dev->device.name, data); > + if (!adapter) { > + opae_adapter_data_free(data); > + return -ENOMEM; Same - you are not performing cleanup here. > + } > + > + rawdev->dev_ops = &ifpga_rawdev_ops; > + rawdev->device = &pci_dev->device; > + rawdev->driver_name = pci_dev->device.driver->name; > + > + rawdev->dev_private = adapter; > + > + /* must enumerate the adapter before use it */ > + ret = opae_adapter_enumerate(adapter); > + if (ret) > + return ret; Cleanup to be performed here. > + > + /* set opae_manager to rawdev */ > + mgr = opae_adapter_get_mgr(adapter); > + if (mgr) { > + /*PF function*/ /*PF function*/ > + IFPGA_RAWDEV_PMD_INFO("this is a PF function"); > + } > + > + return ret; > + > +cleanup: > + if (rawdev) > + rte_rawdev_pmd_release(rawdev); > + > + return ret; > +} > + > +static int > +ifpga_rawdev_destroy(struct rte_pci_device *pci_dev) > +{ > + int ret; > + struct rte_rawdev *rawdev; > + char name[RTE_RAWDEV_NAME_MAX_LEN]; > + struct opae_adapter *adapter; > + > + if (!pci_dev) { > + IFPGA_RAWDEV_PMD_ERR("Invalid pci_dev of the device!"); > + ret = -EINVAL; > + return ret; > + } > + > + memset(name, 0, sizeof(name)); > + snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%x:%02x.%x", > + pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); > + > + IFPGA_RAWDEV_PMD_INFO("Closing %s on NUMA node %d", > + name, rte_socket_id()); > + > + rawdev = rte_rawdev_pmd_get_named_dev(name); > + if (!rawdev) { > + IFPGA_RAWDEV_PMD_ERR("Invalid device name (%s)", name); > + return -EINVAL; > + } > + > + adapter = ifpga_rawdev_get_priv(rawdev); > + if (!adapter) > + return -ENODEV; > + > + opae_adapter_data_free(adapter->data); > + opae_adapter_free(adapter); > + > + /* rte_rawdev_close is called by pmd_release */ > + ret = rte_rawdev_pmd_release(rawdev); > + if (ret) > + IFPGA_RAWDEV_PMD_DEBUG("Device cleanup failed"); > + > + return 0; > +} > + > +static int > +ifpga_rawdev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, > + struct rte_pci_device *pci_dev) > +{ > + > + printf("## %s\n", __func__); One more. > + return ifpga_rawdev_create(pci_dev, rte_socket_id()); > +} > + > +static int ifpga_rawdev_pci_remove(struct rte_pci_device *pci_dev) > +{ > + return ifpga_rawdev_destroy(pci_dev); > +} > + > +static struct rte_pci_driver rte_ifpga_rawdev_pmd = { > + .id_table = pci_ifpga_map, > + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, > + .probe = ifpga_rawdev_pci_probe, > + .remove = ifpga_rawdev_pci_remove, > +}; > + > +RTE_PMD_REGISTER_PCI(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd); > +RTE_PMD_REGISTER_PCI_TABLE(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd); > +RTE_PMD_REGISTER_KMOD_DEP(ifpga_rawdev_pci_driver, "* igb_uio | uio_pci_generic | vfio-pci"); > + > +RTE_INIT(ifpga_rawdev_init_log); > +static void > +ifpga_rawdev_init_log(void) > +{ > + ifpga_rawdev_logtype = rte_log_register("driver.raw.init"); > + if (ifpga_rawdev_logtype >= 0) > + rte_log_set_level(ifpga_rawdev_logtype, RTE_LOG_NOTICE); > +} > + > +static const char * const valid_args[] = { > +#define IFPGA_ARG_NAME "ifpga" > + IFPGA_ARG_NAME, > +#define IFPGA_ARG_PORT "port" > + IFPGA_ARG_PORT, > +#define IFPGA_AFU_BTS "afu_bts" > + IFPGA_AFU_BTS, > + NULL > +}; > + > +static int > +ifpga_cfg_probe(struct rte_vdev_device *dev) > +{ > + struct rte_devargs *devargs; > + struct rte_kvargs *kvlist = NULL; > + int port; > + char *name = NULL; > + char dev_name[RTE_RAWDEV_NAME_MAX_LEN+8]; > + > + devargs = dev->device.devargs; > + > + kvlist = rte_kvargs_parse(devargs->args, valid_args); > + if (!kvlist) { > + IFPGA_RAWDEV_PMD_LOG(ERR, "error when parsing param"); > + goto end; > + } > + > + if (rte_kvargs_count(kvlist, IFPGA_ARG_NAME) == 1) { > + if (rte_kvargs_process(kvlist, IFPGA_ARG_NAME, > + &ifpga_get_string_arg, &name) < 0) { > + IFPGA_RAWDEV_PMD_ERR("error to parse %s", > + IFPGA_ARG_NAME); > + goto end; > + } > + } else { > + IFPGA_RAWDEV_PMD_ERR("arg %s is mandatory for ifpga bus", > + IFPGA_ARG_NAME); > + goto end; > + } > + > + if (rte_kvargs_count(kvlist, IFPGA_ARG_PORT) == 1) { > + if (rte_kvargs_process(kvlist, > + IFPGA_ARG_PORT, > + &ifpga_get_integer32_arg, > + &port) < 0) { > + IFPGA_RAWDEV_PMD_ERR("error to parse %s", > + IFPGA_ARG_PORT); > + goto end; > + } > + } else { > + IFPGA_RAWDEV_PMD_ERR("arg %s is mandatory for ifpga bus", > + IFPGA_ARG_PORT); > + goto end; > + } > + > + memset(dev_name, 0, sizeof(dev_name)); > + snprintf(dev_name, (RTE_RAWDEV_NAME_MAX_LEN+8), "%d|%s", Why did you do this? (adding 8 to RTE_RAWDEV_NAME_MAX_LEN)? Just add a patch to increase the value of RTE_RAWDEV_NAME_MAX_LEN. > + port, name); > + > + rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME), > + dev_name, > + devargs->args); Seems to be some alignment issue here... > +end: > + if (kvlist) > + rte_kvargs_free(kvlist); > + if (name) > + free(name); > + > + return 0; > +} > + > +static int > +ifpga_cfg_remove(struct rte_vdev_device *vdev) > +{ > + IFPGA_RAWDEV_PMD_INFO("Remove ifpga_cfg %p", > + vdev); > + > + return 0; > +} > + > +static struct rte_vdev_driver ifpga_cfg_driver = { > + .probe = ifpga_cfg_probe, > + .remove = ifpga_cfg_remove, > +}; > + > +RTE_PMD_REGISTER_VDEV(net_ifpga_cfg, ifpga_cfg_driver); > +RTE_PMD_REGISTER_ALIAS(net_ifpga_cfg, ifpga_cfg); > +RTE_PMD_REGISTER_PARAM_STRING(net_ifpga_cfg, > + "bdf= " > + "port= " > + "afu_bts="); > + > diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.h b/drivers/raw/ifpga_rawdev/ifpga_rawdev.h > new file mode 100644 > index 0000000..169dc1d > --- /dev/null > +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.h > @@ -0,0 +1,37 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2010-2018 Intel Corporation > + */ > + > +#ifndef _IFPGA_RAWDEV_H_ > +#define _IFPGA_RAWDEV_H_ > + > +extern int ifpga_rawdev_logtype; > + > +#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \ > + rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "%s(): " fmt "\n", \ > + __func__, ##args) Just a trivial comment - you want all your logs, whether INFO, ERROR etc to be appended with function name? Its your choice, but ideally you should separate. > + > +#define IFPGA_RAWDEV_PMD_FUNC_TRACE() IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>") > + > +#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \ > + IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args) > +#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \ > + IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args) > +#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \ > + IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args) > +#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \ > + IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args) > + > +enum ifpga_rawdev_device_state { > + IFPGA_IDLE, > + IFPGA_READY, > + IFPGA_ERROR > +}; > + > +static inline struct opae_adapter * > +ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev) > +{ > + return rawdev->dev_private; > +} > + > +#endif /* _IFPGA_RAWDEV_H_ */ > diff --git a/drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map b/drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map > new file mode 100644 > index 0000000..9b9ab1a > --- /dev/null > +++ b/drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map > @@ -0,0 +1,4 @@ > +DPDK_18.05 { > + > + local: *; > +}; > diff --git a/mk/rte.app.mk b/mk/rte.app.mk > index 9de2edb..4a76890 100644 > --- a/mk/rte.app.mk > +++ b/mk/rte.app.mk > @@ -249,6 +249,7 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV > > ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y) > _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -lrte_pmd_skeleton_rawdev > +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += -lrte_ifpga_rawdev > endif # CONFIG_RTE_LIBRTE_RAWDEV > > > How fast can you fix and push? I can spare time tomorrow (5/May) to re-review, if you can push by then. It might help in merging next week. - Shreyansh