From patchwork Mon Sep 27 13:42:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99818 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5F00FA0C46; Mon, 27 Sep 2021 17:00:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 840D841185; Mon, 27 Sep 2021 16:58:31 +0200 (CEST) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id 712DC40E3C for ; Mon, 27 Sep 2021 15:43:02 +0200 (CEST) Received: by mail-pj1-f44.google.com with SMTP id lb1-20020a17090b4a4100b001993f863df2so13732714pjb.5 for ; Mon, 27 Sep 2021 06:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yz6aDe4LWap9zJh7cnQk/JAzxo2TaQL4wy5utc+mxFE=; b=KbyrxbU/7GxGWU6TYLeeLFpLTPXOF2woy3RrLdwYg64lehHS/rTtv70QK9jaYdV+ys NHLDa8GP9aurgfnmjd3tk3lpVGFMZkdLh2HF2mstmtNVnAQH+rgCxbds6G5q1Yg0p9pC Oq2SiEm6lfpJjylK0He8h+nU9Ds1arjGj7vp0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yz6aDe4LWap9zJh7cnQk/JAzxo2TaQL4wy5utc+mxFE=; b=pYg51TBH7m2JvAn159XidoN/tY8TFGoxskPw2qrwjhWxd1m4spx8kIT6xmrPau08WU g3KpUs0hNs7mPIb8NlRhPWD7pmXDxnpwrQ4YXzrDcHHn1yF+DTRPNkNOxvUV+l9IMQs1 bzwwBHBDMBF89Buqnvrjhkxo8/MuWib6a7LAkSZFldBznp3k1WQPXzSdpFxbS6WNjDfY qtYvuznL9/VD3QsThI5PIe30Yj/r4Sund+yZ7FBuPKj32kpN+RL/wyJFPV6V3BKWmIfm E1VWz/5KKSUdWUaPf3EB7NrkYzy+AYh4Ap4QRgAy0sdIdOBHkt3uOL0Tvap0BwmiA27/ sbsQ== X-Gm-Message-State: AOAM5330VkGNMRSFLJ2GL5pgSc/9TXb3e34yAFT4hCtN3f3/8GTWi3Et HEuZ4W60ZoNkdL2Ep6FX7b2m/g== X-Google-Smtp-Source: ABdhPJzPCJo1TUsBeSxP3AYy/2bpuXThqzucs6OyGRimqdb1IhBixYBwFNZZ1FDS/E07vPIqFCy4eg== X-Received: by 2002:a17:90b:3b4c:: with SMTP id ot12mr20033623pjb.67.1632750181468; Mon, 27 Sep 2021 06:43:01 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:01 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:21 +0530 Message-Id: <20210927134231.11177-2-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 01/11] bus/vmbus: stub for FreeBSD support 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 Sender: "dev" These files are a copy of their Linux equivalents. They will be ported to FreeBSD. Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram Reviewed-by: Long Li --- drivers/bus/vmbus/freebsd/vmbus_bus.c | 376 +++++++++++++++++++++ drivers/bus/vmbus/freebsd/vmbus_uio.c | 453 ++++++++++++++++++++++++++ 2 files changed, 829 insertions(+) create mode 100644 drivers/bus/vmbus/freebsd/vmbus_bus.c create mode 100644 drivers/bus/vmbus/freebsd/vmbus_uio.c diff --git a/drivers/bus/vmbus/freebsd/vmbus_bus.c b/drivers/bus/vmbus/freebsd/vmbus_bus.c new file mode 100644 index 0000000000..3c924eee14 --- /dev/null +++ b/drivers/bus/vmbus/freebsd/vmbus_bus.c @@ -0,0 +1,376 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2018, Microsoft Corporation. + * All Rights Reserved. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "eal_filesystem.h" +#include "private.h" + +/** Pathname of VMBUS devices directory. */ +#define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices" + +/* + * GUID associated with network devices + * {f8615163-df3e-46c5-913f-f2d2f965ed0e} + */ +static const rte_uuid_t vmbus_nic_uuid = { + 0xf8, 0x61, 0x51, 0x63, + 0xdf, 0x3e, + 0x46, 0xc5, + 0x91, 0x3f, + 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0xe +}; + +extern struct rte_vmbus_bus rte_vmbus_bus; + +/* Read sysfs file to get UUID */ +static int +parse_sysfs_uuid(const char *filename, rte_uuid_t uu) +{ + char buf[BUFSIZ]; + char *cp, *in = buf; + FILE *f; + + f = fopen(filename, "r"); + if (f == NULL) { + VMBUS_LOG(ERR, "cannot open sysfs value %s: %s", + filename, strerror(errno)); + return -1; + } + + if (fgets(buf, sizeof(buf), f) == NULL) { + VMBUS_LOG(ERR, "cannot read sysfs value %s", + filename); + fclose(f); + return -1; + } + fclose(f); + + cp = strchr(buf, '\n'); + if (cp) + *cp = '\0'; + + /* strip { } notation */ + if (buf[0] == '{') { + in = buf + 1; + cp = strchr(in, '}'); + if (cp) + *cp = '\0'; + } + + if (rte_uuid_parse(in, uu) < 0) { + VMBUS_LOG(ERR, "%s %s not a valid UUID", + filename, buf); + return -1; + } + + return 0; +} + +static int +get_sysfs_string(const char *filename, char *buf, size_t buflen) +{ + char *cp; + FILE *f; + + f = fopen(filename, "r"); + if (f == NULL) { + VMBUS_LOG(ERR, "cannot open sysfs value %s:%s", + filename, strerror(errno)); + return -1; + } + + if (fgets(buf, buflen, f) == NULL) { + VMBUS_LOG(ERR, "cannot read sysfs value %s", + filename); + fclose(f); + return -1; + } + fclose(f); + + /* remove trailing newline */ + cp = memchr(buf, '\n', buflen); + if (cp) + *cp = '\0'; + + return 0; +} + +static int +vmbus_get_uio_dev(const struct rte_vmbus_device *dev, + char *dstbuf, size_t buflen) +{ + char dirname[PATH_MAX]; + unsigned int uio_num; + struct dirent *e; + DIR *dir; + + /* Assume recent kernel where uio is in uio/uioX */ + snprintf(dirname, sizeof(dirname), + SYSFS_VMBUS_DEVICES "/%s/uio", dev->device.name); + + dir = opendir(dirname); + if (dir == NULL) + return -1; /* Not a UIO device */ + + /* take the first file starting with "uio" */ + while ((e = readdir(dir)) != NULL) { + const int prefix_len = 3; + char *endptr; + + if (strncmp(e->d_name, "uio", prefix_len) != 0) + continue; + + /* try uio%d */ + errno = 0; + uio_num = strtoull(e->d_name + prefix_len, &endptr, 10); + if (errno == 0 && endptr != (e->d_name + prefix_len)) { + snprintf(dstbuf, buflen, "%s/uio%u", dirname, uio_num); + break; + } + } + closedir(dir); + + if (e == NULL) + return -1; + + return uio_num; +} + +/* Check map names with kernel names */ +static const char *map_names[VMBUS_MAX_RESOURCE] = { + [HV_TXRX_RING_MAP] = "txrx_rings", + [HV_INT_PAGE_MAP] = "int_page", + [HV_MON_PAGE_MAP] = "monitor_page", + [HV_RECV_BUF_MAP] = "recv:", + [HV_SEND_BUF_MAP] = "send:", +}; + + +/* map the resources of a vmbus device in virtual memory */ +int +rte_vmbus_map_device(struct rte_vmbus_device *dev) +{ + char uioname[PATH_MAX], filename[PATH_MAX]; + char dirname[PATH_MAX], mapname[64]; + int i; + + dev->uio_num = vmbus_get_uio_dev(dev, uioname, sizeof(uioname)); + if (dev->uio_num < 0) { + VMBUS_LOG(DEBUG, "Not managed by UIO driver, skipped"); + return 1; + } + + /* Extract resource value */ + for (i = 0; i < VMBUS_MAX_RESOURCE; i++) { + struct rte_mem_resource *res = &dev->resource[i]; + unsigned long len, gpad = 0; + char *cp; + + snprintf(dirname, sizeof(dirname), + "%s/maps/map%d", uioname, i); + + snprintf(filename, sizeof(filename), + "%s/name", dirname); + + if (get_sysfs_string(filename, mapname, sizeof(mapname)) < 0) { + VMBUS_LOG(ERR, "could not read %s", filename); + return -1; + } + + if (strncmp(map_names[i], mapname, strlen(map_names[i])) != 0) { + VMBUS_LOG(ERR, + "unexpected resource %s (expected %s)", + mapname, map_names[i]); + return -1; + } + + snprintf(filename, sizeof(filename), + "%s/size", dirname); + if (eal_parse_sysfs_value(filename, &len) < 0) { + VMBUS_LOG(ERR, + "could not read %s", filename); + return -1; + } + res->len = len; + + /* both send and receive buffers have gpad in name */ + cp = memchr(mapname, ':', sizeof(mapname)); + if (cp) + gpad = strtoul(cp+1, NULL, 0); + + /* put the GPAD value in physical address */ + res->phys_addr = gpad; + } + + return vmbus_uio_map_resource(dev); +} + +void +rte_vmbus_unmap_device(struct rte_vmbus_device *dev) +{ + vmbus_uio_unmap_resource(dev); +} + +/* Scan one vmbus sysfs entry, and fill the devices list from it. */ +static int +vmbus_scan_one(const char *name) +{ + struct rte_vmbus_device *dev, *dev2; + char filename[PATH_MAX]; + char dirname[PATH_MAX]; + unsigned long tmp; + + dev = calloc(1, sizeof(*dev)); + if (dev == NULL) + return -1; + + dev->device.bus = &rte_vmbus_bus.bus; + dev->device.name = strdup(name); + if (!dev->device.name) + goto error; + + /* sysfs base directory + * /sys/bus/vmbus/devices/7a08391f-f5a0-4ac0-9802-d13fd964f8df + * or on older kernel + * /sys/bus/vmbus/devices/vmbus_1 + */ + snprintf(dirname, sizeof(dirname), "%s/%s", + SYSFS_VMBUS_DEVICES, name); + + /* get device class */ + snprintf(filename, sizeof(filename), "%s/class_id", dirname); + if (parse_sysfs_uuid(filename, dev->class_id) < 0) + goto error; + + /* skip non-network devices */ + if (rte_uuid_compare(dev->class_id, vmbus_nic_uuid) != 0) { + free(dev); + return 0; + } + + /* get device id */ + snprintf(filename, sizeof(filename), "%s/device_id", dirname); + if (parse_sysfs_uuid(filename, dev->device_id) < 0) + goto error; + + /* get relid */ + snprintf(filename, sizeof(filename), "%s/id", dirname); + if (eal_parse_sysfs_value(filename, &tmp) < 0) + goto error; + dev->relid = tmp; + + /* get monitor id */ + snprintf(filename, sizeof(filename), "%s/monitor_id", dirname); + if (eal_parse_sysfs_value(filename, &tmp) < 0) + goto error; + dev->monitor_id = tmp; + + /* get numa node (if present) */ + snprintf(filename, sizeof(filename), "%s/numa_node", + dirname); + + if (access(filename, R_OK) == 0) { + if (eal_parse_sysfs_value(filename, &tmp) < 0) + goto error; + dev->device.numa_node = tmp; + } else { + /* if no NUMA support, set default to 0 */ + dev->device.numa_node = SOCKET_ID_ANY; + } + + dev->device.devargs = vmbus_devargs_lookup(dev); + + /* device is valid, add in list (sorted) */ + VMBUS_LOG(DEBUG, "Adding vmbus device %s", name); + + TAILQ_FOREACH(dev2, &rte_vmbus_bus.device_list, next) { + int ret; + + ret = rte_uuid_compare(dev->device_id, dev2->device_id); + if (ret > 0) + continue; + + if (ret < 0) { + vmbus_insert_device(dev2, dev); + } else { /* already registered */ + VMBUS_LOG(NOTICE, + "%s already registered", name); + free(dev); + } + return 0; + } + + vmbus_add_device(dev); + return 0; +error: + VMBUS_LOG(DEBUG, "failed"); + + free(dev); + return -1; +} + +/* + * Scan the content of the vmbus, and the devices in the devices list + */ +int +rte_vmbus_scan(void) +{ + struct dirent *e; + DIR *dir; + + dir = opendir(SYSFS_VMBUS_DEVICES); + if (dir == NULL) { + if (errno == ENOENT) + return 0; + + VMBUS_LOG(ERR, "opendir %s failed: %s", + SYSFS_VMBUS_DEVICES, strerror(errno)); + return -1; + } + + while ((e = readdir(dir)) != NULL) { + if (e->d_name[0] == '.') + continue; + + if (vmbus_scan_one(e->d_name) < 0) + goto error; + } + closedir(dir); + return 0; + +error: + closedir(dir); + return -1; +} + +void rte_vmbus_irq_mask(struct rte_vmbus_device *device) +{ + vmbus_uio_irq_control(device, 1); +} + +void rte_vmbus_irq_unmask(struct rte_vmbus_device *device) +{ + vmbus_uio_irq_control(device, 0); +} + +int rte_vmbus_irq_read(struct rte_vmbus_device *device) +{ + return vmbus_uio_irq_read(device); +} diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c new file mode 100644 index 0000000000..b52ca5bf1d --- /dev/null +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -0,0 +1,453 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2018, Microsoft Corporation. + * All Rights Reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "private.h" + +/** Pathname of VMBUS devices directory. */ +#define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices" + +static void *vmbus_map_addr; + +/* Control interrupts */ +void vmbus_uio_irq_control(struct rte_vmbus_device *dev, int32_t onoff) +{ + if (write(dev->intr_handle.fd, &onoff, sizeof(onoff)) < 0) { + VMBUS_LOG(ERR, "cannot write to %d:%s", + dev->intr_handle.fd, strerror(errno)); + } +} + +int vmbus_uio_irq_read(struct rte_vmbus_device *dev) +{ + int32_t count; + int cc; + + cc = read(dev->intr_handle.fd, &count, sizeof(count)); + if (cc < (int)sizeof(count)) { + if (cc < 0) { + VMBUS_LOG(ERR, "IRQ read failed %s", + strerror(errno)); + return -errno; + } + VMBUS_LOG(ERR, "can't read IRQ count"); + return -EINVAL; + } + + return count; +} + +void +vmbus_uio_free_resource(struct rte_vmbus_device *dev, + struct mapped_vmbus_resource *uio_res) +{ + rte_free(uio_res); + + if (dev->intr_handle.uio_cfg_fd >= 0) { + close(dev->intr_handle.uio_cfg_fd); + dev->intr_handle.uio_cfg_fd = -1; + } + + if (dev->intr_handle.fd >= 0) { + close(dev->intr_handle.fd); + dev->intr_handle.fd = -1; + dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN; + } +} + +int +vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, + struct mapped_vmbus_resource **uio_res) +{ + char devname[PATH_MAX]; /* contains the /dev/uioX */ + + /* save fd if in primary process */ + snprintf(devname, sizeof(devname), "/dev/uio%u", dev->uio_num); + dev->intr_handle.fd = open(devname, O_RDWR); + if (dev->intr_handle.fd < 0) { + VMBUS_LOG(ERR, "Cannot open %s: %s", + devname, strerror(errno)); + goto error; + } + dev->intr_handle.type = RTE_INTR_HANDLE_UIO_INTX; + + /* allocate the mapping details for secondary processes*/ + *uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0); + if (*uio_res == NULL) { + VMBUS_LOG(ERR, "cannot store uio mmap details"); + goto error; + } + + strlcpy((*uio_res)->path, devname, PATH_MAX); + rte_uuid_copy((*uio_res)->id, dev->device_id); + + return 0; + +error: + vmbus_uio_free_resource(dev, *uio_res); + return -1; +} + +static int +find_max_end_va(const struct rte_memseg_list *msl, void *arg) +{ + size_t sz = msl->memseg_arr.len * msl->page_sz; + void *end_va = RTE_PTR_ADD(msl->base_va, sz); + void **max_va = arg; + + if (*max_va < end_va) + *max_va = end_va; + return 0; +} + +/* + * TODO: this should be part of memseg api. + * code is duplicated from PCI. + */ +static void * +vmbus_find_max_end_va(void) +{ + void *va = NULL; + + rte_memseg_list_walk(find_max_end_va, &va); + return va; +} + +int +vmbus_uio_map_resource_by_index(struct rte_vmbus_device *dev, int idx, + struct mapped_vmbus_resource *uio_res, + int flags) +{ + size_t size = dev->resource[idx].len; + struct vmbus_map *maps = uio_res->maps; + void *mapaddr; + off_t offset; + int fd; + + /* devname for mmap */ + fd = open(uio_res->path, O_RDWR); + if (fd < 0) { + VMBUS_LOG(ERR, "Cannot open %s: %s", + uio_res->path, strerror(errno)); + return -1; + } + + /* try mapping somewhere close to the end of hugepages */ + if (vmbus_map_addr == NULL) + vmbus_map_addr = vmbus_find_max_end_va(); + + /* offset is special in uio it indicates which resource */ + offset = idx * rte_mem_page_size(); + + mapaddr = vmbus_map_resource(vmbus_map_addr, fd, offset, size, flags); + close(fd); + + if (mapaddr == MAP_FAILED) + return -1; + + dev->resource[idx].addr = mapaddr; + vmbus_map_addr = RTE_PTR_ADD(mapaddr, size); + + /* Record result of successful mapping for use by secondary */ + maps[idx].addr = mapaddr; + maps[idx].size = size; + + return 0; +} + +static int vmbus_uio_map_primary(struct vmbus_channel *chan, + void **ring_buf, uint32_t *ring_size) +{ + struct mapped_vmbus_resource *uio_res; + + uio_res = vmbus_uio_find_resource(chan->device); + if (!uio_res) { + VMBUS_LOG(ERR, "can not find resources!"); + return -ENOMEM; + } + + if (uio_res->nb_maps < VMBUS_MAX_RESOURCE) { + VMBUS_LOG(ERR, "VMBUS: only %u resources found!", + uio_res->nb_maps); + return -EINVAL; + } + + *ring_size = uio_res->maps[HV_TXRX_RING_MAP].size / 2; + *ring_buf = uio_res->maps[HV_TXRX_RING_MAP].addr; + return 0; +} + +static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan, + void **ring_buf, uint32_t *ring_size) +{ + char ring_path[PATH_MAX]; + size_t file_size; + struct stat sb; + void *mapaddr; + int fd; + + snprintf(ring_path, sizeof(ring_path), + "%s/%s/channels/%u/ring", + SYSFS_VMBUS_DEVICES, dev->device.name, + chan->relid); + + fd = open(ring_path, O_RDWR); + if (fd < 0) { + VMBUS_LOG(ERR, "Cannot open %s: %s", + ring_path, strerror(errno)); + return -errno; + } + + if (fstat(fd, &sb) < 0) { + VMBUS_LOG(ERR, "Cannot state %s: %s", + ring_path, strerror(errno)); + close(fd); + return -errno; + } + file_size = sb.st_size; + + if (file_size == 0 || (file_size & (rte_mem_page_size() - 1))) { + VMBUS_LOG(ERR, "incorrect size %s: %zu", + ring_path, file_size); + + close(fd); + return -EINVAL; + } + + mapaddr = vmbus_map_resource(vmbus_map_addr, fd, + 0, file_size, 0); + close(fd); + + if (mapaddr == MAP_FAILED) + return -EIO; + + *ring_size = file_size / 2; + *ring_buf = mapaddr; + + vmbus_map_addr = RTE_PTR_ADD(mapaddr, file_size); + return 0; +} + +int +vmbus_uio_map_secondary_subchan(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan) +{ + const struct vmbus_br *br = &chan->txbr; + char ring_path[PATH_MAX]; + void *mapaddr, *ring_buf; + uint32_t ring_size; + int fd; + + snprintf(ring_path, sizeof(ring_path), + "%s/%s/channels/%u/ring", + SYSFS_VMBUS_DEVICES, dev->device.name, + chan->relid); + + ring_buf = br->vbr; + ring_size = br->dsize + sizeof(struct vmbus_bufring); + VMBUS_LOG(INFO, "secondary ring_buf %p size %u", + ring_buf, ring_size); + + fd = open(ring_path, O_RDWR); + if (fd < 0) { + VMBUS_LOG(ERR, "Cannot open %s: %s", + ring_path, strerror(errno)); + return -errno; + } + + mapaddr = vmbus_map_resource(ring_buf, fd, 0, 2 * ring_size, 0); + close(fd); + + if (mapaddr == ring_buf) + return 0; + + if (mapaddr == MAP_FAILED) + VMBUS_LOG(ERR, + "mmap subchan %u in secondary failed", chan->relid); + else { + VMBUS_LOG(ERR, + "mmap subchan %u in secondary address mismatch", + chan->relid); + vmbus_unmap_resource(mapaddr, 2 * ring_size); + } + return -1; +} + +int vmbus_uio_map_rings(struct vmbus_channel *chan) +{ + const struct rte_vmbus_device *dev = chan->device; + uint32_t ring_size; + void *ring_buf; + int ret; + + /* Primary channel */ + if (chan->subchannel_id == 0) + ret = vmbus_uio_map_primary(chan, &ring_buf, &ring_size); + else + ret = vmbus_uio_map_subchan(dev, chan, &ring_buf, &ring_size); + + if (ret) + return ret; + + vmbus_br_setup(&chan->txbr, ring_buf, ring_size); + vmbus_br_setup(&chan->rxbr, (char *)ring_buf + ring_size, ring_size); + return 0; +} + +static int vmbus_uio_sysfs_read(const char *dir, const char *name, + unsigned long *val, unsigned long max_range) +{ + char path[PATH_MAX]; + FILE *f; + int ret; + + snprintf(path, sizeof(path), "%s/%s", dir, name); + f = fopen(path, "r"); + if (!f) { + VMBUS_LOG(ERR, "can't open %s:%s", + path, strerror(errno)); + return -errno; + } + + if (fscanf(f, "%lu", val) != 1) + ret = -EIO; + else if (*val > max_range) + ret = -ERANGE; + else + ret = 0; + fclose(f); + + return ret; +} + +static bool vmbus_uio_ring_present(const struct rte_vmbus_device *dev, + uint32_t relid) +{ + char ring_path[PATH_MAX]; + + /* Check if kernel has subchannel sysfs files */ + snprintf(ring_path, sizeof(ring_path), + "%s/%s/channels/%u/ring", + SYSFS_VMBUS_DEVICES, dev->device.name, relid); + + return access(ring_path, R_OK|W_OK) == 0; +} + +bool vmbus_uio_subchannels_supported(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan) +{ + return vmbus_uio_ring_present(dev, chan->relid); +} + +static bool vmbus_isnew_subchannel(struct vmbus_channel *primary, + unsigned long id) +{ + const struct vmbus_channel *c; + + STAILQ_FOREACH(c, &primary->subchannel_list, next) { + if (c->relid == id) + return false; + } + return true; +} + +int vmbus_uio_get_subchan(struct vmbus_channel *primary, + struct vmbus_channel **subchan) +{ + const struct rte_vmbus_device *dev = primary->device; + char chan_path[PATH_MAX], subchan_path[PATH_MAX]; + struct dirent *ent; + DIR *chan_dir; + int err; + + snprintf(chan_path, sizeof(chan_path), + "%s/%s/channels", + SYSFS_VMBUS_DEVICES, dev->device.name); + + chan_dir = opendir(chan_path); + if (!chan_dir) { + VMBUS_LOG(ERR, "cannot open %s: %s", + chan_path, strerror(errno)); + return -errno; + } + + while ((ent = readdir(chan_dir))) { + unsigned long relid, subid, monid; + char *endp; + + if (ent->d_name[0] == '.') + continue; + + errno = 0; + relid = strtoul(ent->d_name, &endp, 0); + if (*endp || errno != 0 || relid > UINT16_MAX) { + VMBUS_LOG(NOTICE, "not a valid channel relid: %s", + ent->d_name); + continue; + } + + if (!vmbus_isnew_subchannel(primary, relid)) { + VMBUS_LOG(DEBUG, "skip already found channel: %lu", + relid); + continue; + } + + if (!vmbus_uio_ring_present(dev, relid)) { + VMBUS_LOG(DEBUG, "ring mmap not found (yet) for: %lu", + relid); + continue; + } + + snprintf(subchan_path, sizeof(subchan_path), "%s/%lu", + chan_path, relid); + err = vmbus_uio_sysfs_read(subchan_path, "subchannel_id", + &subid, UINT16_MAX); + if (err) { + VMBUS_LOG(NOTICE, "no subchannel_id in %s:%s", + subchan_path, strerror(-err)); + goto fail; + } + + if (subid == 0) + continue; /* skip primary channel */ + + err = vmbus_uio_sysfs_read(subchan_path, "monitor_id", + &monid, UINT8_MAX); + if (err) { + VMBUS_LOG(NOTICE, "no monitor_id in %s:%s", + subchan_path, strerror(-err)); + goto fail; + } + + err = vmbus_chan_create(dev, relid, subid, monid, subchan); + if (err) { + VMBUS_LOG(ERR, "subchannel setup failed"); + goto fail; + } + break; + } + closedir(chan_dir); + + return (ent == NULL) ? -ENOENT : 0; +fail: + closedir(chan_dir); + return err; +} From patchwork Mon Sep 27 13:42:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99819 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C06A2A0C46; Mon, 27 Sep 2021 17:00:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 91FDA4118B; Mon, 27 Sep 2021 16:58:32 +0200 (CEST) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id 0A3DF40E3C for ; Mon, 27 Sep 2021 15:43:05 +0200 (CEST) Received: by mail-pl1-f172.google.com with SMTP id j15so10382771plh.7 for ; Mon, 27 Sep 2021 06:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g+TV0cKT7Na0B4z9tOAoOFjxNzWuMF94m/xPrFGaCYU=; b=EB0bq80CTOIniufFJkdu+l/BeoZ8/esTkS9iQ87jySj/MUtWKA96Ue5oXMoBhIBcbE wKr2iWwgLjS0gkal5o1fORDJ9vP16WrDvurJ2WaR1yTgaP7OE6OaHQT+mrjZGqdX9hyE o7iIKCa4kB2wPft24J9yH+xaY6itEEqP9i0fc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g+TV0cKT7Na0B4z9tOAoOFjxNzWuMF94m/xPrFGaCYU=; b=JQCX3hX7jA55uD6y2+F9kpJYMsp2MfI2uLAzkn6KOqwU2T09VSTBYneB/qNSwhLtAr Pi4K2fuQ5xbsF1V/WSg6AVexo9xZOVN+X0LrY+IPus5Lu3SOHpoecGuCjqKdJKCrSrOX bAjihKzuQc3GGMNkdK5Ehd4aeSTZmNwOwDm17Xrf0JQAwsoY4Z7mx6znf5cTymbBqiW0 NNYDBB7n29SBgH5fDaMNLWydZfuyOgo72myozeROcY9dTTQkUHq0LZDjYhMleqXY1ggs WuiYIQgN7f2aFq0iqagcjuxD7CEQs7axIXFm/F3lYjgOSdNfamzCM/VNCaRca6+tO37b A+8A== X-Gm-Message-State: AOAM530WLN6aWdIYDPJLcAauqmmqXmOaPESM2NZ3KKh1OFfNWTJjQJqk x9C19bRHphsv8sNioY7F6EFF/Q== X-Google-Smtp-Source: ABdhPJyICNyi+C5LSHtpxTK+Vy14tEVeZT1s17hVzqGYp7DOslkKGGQ4TuaybgcGZ9qkalzDToQJLw== X-Received: by 2002:a17:902:8509:b0:13d:cef8:2735 with SMTP id bj9-20020a170902850900b0013dcef82735mr22770772plb.22.1632750184124; Mon, 27 Sep 2021 06:43:04 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:03 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:22 +0530 Message-Id: <20210927134231.11177-3-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 02/11] bus/vmbus: scan and get the network device 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 Sender: "dev" Using sysctl, all the devices on the VMBUS are identified by the PMD. On finding the Network device's device id, it is added to VMBUS dev list. Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_bus.c | 241 +++++++++++++++----------- 1 file changed, 144 insertions(+), 97 deletions(-) diff --git a/drivers/bus/vmbus/freebsd/vmbus_bus.c b/drivers/bus/vmbus/freebsd/vmbus_bus.c index 3c924eee14..8eb428a154 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_bus.c +++ b/drivers/bus/vmbus/freebsd/vmbus_bus.c @@ -22,8 +22,9 @@ #include "eal_filesystem.h" #include "private.h" -/** Pathname of VMBUS devices directory. */ -#define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices" +#include +#include +#include /* * GUID associated with network devices @@ -39,44 +40,15 @@ static const rte_uuid_t vmbus_nic_uuid = { extern struct rte_vmbus_bus rte_vmbus_bus; -/* Read sysfs file to get UUID */ +/* Parse UUID */ static int parse_sysfs_uuid(const char *filename, rte_uuid_t uu) { - char buf[BUFSIZ]; - char *cp, *in = buf; - FILE *f; - - f = fopen(filename, "r"); - if (f == NULL) { - VMBUS_LOG(ERR, "cannot open sysfs value %s: %s", - filename, strerror(errno)); - return -1; - } - - if (fgets(buf, sizeof(buf), f) == NULL) { - VMBUS_LOG(ERR, "cannot read sysfs value %s", - filename); - fclose(f); - return -1; - } - fclose(f); - - cp = strchr(buf, '\n'); - if (cp) - *cp = '\0'; - - /* strip { } notation */ - if (buf[0] == '{') { - in = buf + 1; - cp = strchr(in, '}'); - if (cp) - *cp = '\0'; - } + char in[BUFSIZ]; + strncpy(in, filename, BUFSIZ); if (rte_uuid_parse(in, uu) < 0) { - VMBUS_LOG(ERR, "%s %s not a valid UUID", - filename, buf); + VMBUS_LOG(ERR, "%s not a valid UUID", in); return -1; } @@ -228,35 +200,33 @@ rte_vmbus_unmap_device(struct rte_vmbus_device *dev) vmbus_uio_unmap_resource(dev); } -/* Scan one vmbus sysfs entry, and fill the devices list from it. */ +/* Scan one vmbus entry, and fill the devices list from it. */ static int -vmbus_scan_one(const char *name) +vmbus_scan_one(const char *name, unsigned int unit_num) { struct rte_vmbus_device *dev, *dev2; - char filename[PATH_MAX]; - char dirname[PATH_MAX]; - unsigned long tmp; + char sysctlBuffer[PATH_MAX], sysctlVar[PATH_MAX]; + size_t guid_len = 36, len = PATH_MAX; + char classid[guid_len], deviceid[guid_len]; dev = calloc(1, sizeof(*dev)); if (dev == NULL) return -1; - dev->device.bus = &rte_vmbus_bus.bus; - dev->device.name = strdup(name); - if (!dev->device.name) + /* get class id and device id */ + snprintf(sysctlVar, len, "dev.%s.%u.%%pnpinfo", name, unit_num); + if (sysctlbyname(sysctlVar, &sysctlBuffer, &len, NULL, 0) < 0) goto error; - /* sysfs base directory - * /sys/bus/vmbus/devices/7a08391f-f5a0-4ac0-9802-d13fd964f8df - * or on older kernel - * /sys/bus/vmbus/devices/vmbus_1 + /* pnpinfo: classid=f912ad6d-2b17-48ea-bd65-f927a61c7684 + * deviceid=d34b2567-b9b6-42b9-8778-0a4ec0b955bf */ - snprintf(dirname, sizeof(dirname), "%s/%s", - SYSFS_VMBUS_DEVICES, name); - - /* get device class */ - snprintf(filename, sizeof(filename), "%s/class_id", dirname); - if (parse_sysfs_uuid(filename, dev->class_id) < 0) + if (sysctlBuffer[0] == 'c' && sysctlBuffer[1] == 'l' && + sysctlBuffer[7] == '=') { + strncpy(classid, &sysctlBuffer[8], guid_len); + classid[guid_len] = '\0'; + } + if (parse_sysfs_uuid(classid, dev->class_id) < 0) goto error; /* skip non-network devices */ @@ -265,35 +235,23 @@ vmbus_scan_one(const char *name) return 0; } - /* get device id */ - snprintf(filename, sizeof(filename), "%s/device_id", dirname); - if (parse_sysfs_uuid(filename, dev->device_id) < 0) - goto error; - - /* get relid */ - snprintf(filename, sizeof(filename), "%s/id", dirname); - if (eal_parse_sysfs_value(filename, &tmp) < 0) + if (sysctlBuffer[45] == 'd' && sysctlBuffer[46] == 'e' && + sysctlBuffer[47] == 'v' && sysctlBuffer[53] == '=') { + strncpy(deviceid, &sysctlBuffer[54], guid_len); + deviceid[guid_len] = '\0'; + } + if (parse_sysfs_uuid(deviceid, dev->device_id) < 0) goto error; - dev->relid = tmp; - /* get monitor id */ - snprintf(filename, sizeof(filename), "%s/monitor_id", dirname); - if (eal_parse_sysfs_value(filename, &tmp) < 0) + if (!strcmp(name, "hv_uio")) + dev->uio_num = unit_num; + else + dev->uio_num = -1; + dev->device.bus = &rte_vmbus_bus.bus; + dev->device.numa_node = 0; + dev->device.name = strdup(deviceid); + if (!dev->device.name) goto error; - dev->monitor_id = tmp; - - /* get numa node (if present) */ - snprintf(filename, sizeof(filename), "%s/numa_node", - dirname); - - if (access(filename, R_OK) == 0) { - if (eal_parse_sysfs_value(filename, &tmp) < 0) - goto error; - dev->device.numa_node = tmp; - } else { - /* if no NUMA support, set default to 0 */ - dev->device.numa_node = SOCKET_ID_ANY; - } dev->device.devargs = vmbus_devargs_lookup(dev); @@ -332,31 +290,120 @@ vmbus_scan_one(const char *name) int rte_vmbus_scan(void) { - struct dirent *e; - DIR *dir; - - dir = opendir(SYSFS_VMBUS_DEVICES); - if (dir == NULL) { - if (errno == ENOENT) - return 0; + struct u_device udev; + struct u_businfo ubus; + int dev_idx, dev_ptr, name2oid[2], oid[CTL_MAXNAME + 12], error; + size_t oidlen, rlen, ub_size; + uintptr_t vmbus_handle = 0; + char *walker, *ep; + char name[16] = "hw.bus.devices"; + char *dd_name, *dd_desc, *dd_drivername, *dd_pnpinfo, *dd_location; + + /* + * devinfo FreeBSD APP logic to fetch all the VMBus devices + * using SYSCTLs + */ + name2oid[0] = 0; + name2oid[1] = 3; + oidlen = sizeof(oid); + error = sysctl(name2oid, 2, oid, &oidlen, name, strlen(name)); + if (error < 0) { + VMBUS_LOG(DEBUG, "can't find hw.bus.devices sysctl node"); + return -ENOENT; + } + oidlen /= sizeof(int); + if (oidlen > CTL_MAXNAME) { + VMBUS_LOG(DEBUG, "hw.bus.devices oid is too large"); + return -EINVAL; + } - VMBUS_LOG(ERR, "opendir %s failed: %s", - SYSFS_VMBUS_DEVICES, strerror(errno)); - return -1; + ub_size = sizeof(ubus); + if (sysctlbyname("hw.bus.info", &ubus, &ub_size, NULL, 0) != 0) { + VMBUS_LOG(DEBUG, "sysctlbyname(\"hw.bus.info\", ...) failed"); + return -EINVAL; + } + if ((ub_size != sizeof(ubus)) || + (ubus.ub_version != BUS_USER_VERSION)) { + VMBUS_LOG(DEBUG, + "kernel bus interface version mismatch: kernel %d expected %d", + ubus.ub_version, BUS_USER_VERSION); + return -EINVAL; } - while ((e = readdir(dir)) != NULL) { - if (e->d_name[0] == '.') - continue; + oid[oidlen++] = ubus.ub_generation; + dev_ptr = oidlen++; + + /* + * Scan devices. + * + * Stop after a fairly insane number to avoid death in the case + * of kernel corruption. + */ + + for (dev_idx = 0; dev_idx < 10000; dev_idx++) { + /* + * Get the device information. + */ + oid[dev_ptr] = dev_idx; + rlen = sizeof(udev); + error = sysctl(oid, oidlen, &udev, &rlen, NULL, 0); + if (error < 0) { + if (errno == ENOENT) /* end of list */ + break; + if (errno != EINVAL) /* gen count skip, restart */ + VMBUS_LOG(DEBUG, "sysctl hw.bus.devices.%d", + dev_idx); + return errno; + } + if (rlen != sizeof(udev)) { + VMBUS_LOG(DEBUG, + "sysctl returned wrong data %zd bytes instead of %zd", + rlen, sizeof(udev)); + return -EINVAL; + } - if (vmbus_scan_one(e->d_name) < 0) - goto error; + walker = udev.dv_fields; + ep = walker + sizeof(udev.dv_fields); + dd_name = NULL; + dd_desc = NULL; + dd_drivername = NULL; + dd_pnpinfo = NULL; + dd_location = NULL; +#define UNPACK(x) \ + do { \ + x = strdup(walker); \ + if (x == NULL) \ + return -ENOMEM; \ + if (walker + strnlen(walker, ep - walker) >= ep) \ + return -EINVAL; \ + walker += strlen(walker) + 1; \ + } while (0) + + UNPACK(dd_name); + UNPACK(dd_desc); + UNPACK(dd_drivername); + UNPACK(dd_pnpinfo); + UNPACK(dd_location); +#undef UNPACK + if (*dd_drivername && !(strcmp(dd_drivername, "vmbus"))) + vmbus_handle = udev.dv_handle; + + if (vmbus_handle && (vmbus_handle == udev.dv_parent) + && *dd_pnpinfo && *dd_name) { + unsigned int driver_len = 0, unit_num = 0; + char *endptr; + + driver_len = strlen(dd_drivername); + unit_num = strtoull(&dd_name[driver_len], &endptr, 10); + VMBUS_LOG(DEBUG, "Device name:%s, pnpinfo:%s", + dd_name, dd_pnpinfo); + + if (vmbus_scan_one(dd_drivername, unit_num) < 0) + goto error; + } } - closedir(dir); return 0; - error: - closedir(dir); return -1; } From patchwork Mon Sep 27 13:42:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99820 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AE369A0C46; Mon, 27 Sep 2021 17:00:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A9D1A41192; Mon, 27 Sep 2021 16:58:33 +0200 (CEST) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id 50287410DA for ; Mon, 27 Sep 2021 15:43:07 +0200 (CEST) Received: by mail-pj1-f54.google.com with SMTP id v19so12488427pjh.2 for ; Mon, 27 Sep 2021 06:43:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qphklSi75ISsDBXC9paON1aCROjJrp9WEVfCh5Z5KOI=; b=V1rKmKiH1ytXAY4IHK0hfCnpYkku0WrlsEnBoqtnWoAZVoz5ogG6odtFYbp5ouWiw/ Srz8rDFuFg/RoKLUPeKL3WPpUN/A06k3la6AQfPW9yrhA8xWzPlfYZdynhVtDYJROwRt 6KeHQ+QdXKF5+b/bEpMpVz7XcwrHxx2jPq3kk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qphklSi75ISsDBXC9paON1aCROjJrp9WEVfCh5Z5KOI=; b=MFgX2bhY+Tui4RPsMcZMEqNQ6VeO4jq9H2WYN4UNfZSiSKHtwTNGEjgbvuWOJGNasg Z1pBssFyssmI4MSYt0PwZHk44foWLBSfbyWhRh6v+6Fscvp6t7quyOfyusjMYvB6tXK5 gHOTLH3uTMsgFveWsaD/oikvCBLY+imkvjGQ2sm9u+lgxtgmAhJDs9rBL2Tn7XhVdz2P bWwZ8w2juGHM3FTv2XEzKIRUnQjD0ABI+m8fZ+yoRjKT+b1BX9t515uOZoLnmlbOGiEW RKG2bHPgMKt9jFezOb6xH9l0EWLBKXE0Wt5CN7OrudMa3uwVmQk7VVyxzTHhCR+QEvKP VcXA== X-Gm-Message-State: AOAM533iRdKJLacLh2IwwsaJz7EK99fJ3j0qMEOfyawmegFpCAyWAnVd 263HRTCvLBZHTD1hHejexfAn9A== X-Google-Smtp-Source: ABdhPJy+1E0aBhjnodUmUldy8b+o37Ks7jDNuMZfcsPW1jxoROVKqzXGneunJAvTmcirVRiGDkbKSw== X-Received: by 2002:a17:90b:3890:: with SMTP id mu16mr20444986pjb.78.1632750186543; Mon, 27 Sep 2021 06:43:06 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:06 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:23 +0530 Message-Id: <20210927134231.11177-4-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 03/11] bus/vmbus: handle mapping of device resources 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 Sender: "dev" All resource values are published by HV_UIO driver as sysctl key value pairs and they are read at a later point of the code flow Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_bus.c | 127 -------------------------- 1 file changed, 127 deletions(-) diff --git a/drivers/bus/vmbus/freebsd/vmbus_bus.c b/drivers/bus/vmbus/freebsd/vmbus_bus.c index 8eb428a154..9b23b1131c 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_bus.c +++ b/drivers/bus/vmbus/freebsd/vmbus_bus.c @@ -55,142 +55,15 @@ parse_sysfs_uuid(const char *filename, rte_uuid_t uu) return 0; } -static int -get_sysfs_string(const char *filename, char *buf, size_t buflen) -{ - char *cp; - FILE *f; - - f = fopen(filename, "r"); - if (f == NULL) { - VMBUS_LOG(ERR, "cannot open sysfs value %s:%s", - filename, strerror(errno)); - return -1; - } - - if (fgets(buf, buflen, f) == NULL) { - VMBUS_LOG(ERR, "cannot read sysfs value %s", - filename); - fclose(f); - return -1; - } - fclose(f); - - /* remove trailing newline */ - cp = memchr(buf, '\n', buflen); - if (cp) - *cp = '\0'; - - return 0; -} - -static int -vmbus_get_uio_dev(const struct rte_vmbus_device *dev, - char *dstbuf, size_t buflen) -{ - char dirname[PATH_MAX]; - unsigned int uio_num; - struct dirent *e; - DIR *dir; - - /* Assume recent kernel where uio is in uio/uioX */ - snprintf(dirname, sizeof(dirname), - SYSFS_VMBUS_DEVICES "/%s/uio", dev->device.name); - - dir = opendir(dirname); - if (dir == NULL) - return -1; /* Not a UIO device */ - - /* take the first file starting with "uio" */ - while ((e = readdir(dir)) != NULL) { - const int prefix_len = 3; - char *endptr; - - if (strncmp(e->d_name, "uio", prefix_len) != 0) - continue; - - /* try uio%d */ - errno = 0; - uio_num = strtoull(e->d_name + prefix_len, &endptr, 10); - if (errno == 0 && endptr != (e->d_name + prefix_len)) { - snprintf(dstbuf, buflen, "%s/uio%u", dirname, uio_num); - break; - } - } - closedir(dir); - - if (e == NULL) - return -1; - - return uio_num; -} - -/* Check map names with kernel names */ -static const char *map_names[VMBUS_MAX_RESOURCE] = { - [HV_TXRX_RING_MAP] = "txrx_rings", - [HV_INT_PAGE_MAP] = "int_page", - [HV_MON_PAGE_MAP] = "monitor_page", - [HV_RECV_BUF_MAP] = "recv:", - [HV_SEND_BUF_MAP] = "send:", -}; - - /* map the resources of a vmbus device in virtual memory */ int rte_vmbus_map_device(struct rte_vmbus_device *dev) { - char uioname[PATH_MAX], filename[PATH_MAX]; - char dirname[PATH_MAX], mapname[64]; - int i; - - dev->uio_num = vmbus_get_uio_dev(dev, uioname, sizeof(uioname)); if (dev->uio_num < 0) { VMBUS_LOG(DEBUG, "Not managed by UIO driver, skipped"); return 1; } - /* Extract resource value */ - for (i = 0; i < VMBUS_MAX_RESOURCE; i++) { - struct rte_mem_resource *res = &dev->resource[i]; - unsigned long len, gpad = 0; - char *cp; - - snprintf(dirname, sizeof(dirname), - "%s/maps/map%d", uioname, i); - - snprintf(filename, sizeof(filename), - "%s/name", dirname); - - if (get_sysfs_string(filename, mapname, sizeof(mapname)) < 0) { - VMBUS_LOG(ERR, "could not read %s", filename); - return -1; - } - - if (strncmp(map_names[i], mapname, strlen(map_names[i])) != 0) { - VMBUS_LOG(ERR, - "unexpected resource %s (expected %s)", - mapname, map_names[i]); - return -1; - } - - snprintf(filename, sizeof(filename), - "%s/size", dirname); - if (eal_parse_sysfs_value(filename, &len) < 0) { - VMBUS_LOG(ERR, - "could not read %s", filename); - return -1; - } - res->len = len; - - /* both send and receive buffers have gpad in name */ - cp = memchr(mapname, ':', sizeof(mapname)); - if (cp) - gpad = strtoul(cp+1, NULL, 0); - - /* put the GPAD value in physical address */ - res->phys_addr = gpad; - } - return vmbus_uio_map_resource(dev); } From patchwork Mon Sep 27 13:42:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99821 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E879FA0C46; Mon, 27 Sep 2021 17:00:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD7BC41196; Mon, 27 Sep 2021 16:58:34 +0200 (CEST) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 291C6410DD for ; Mon, 27 Sep 2021 15:43:10 +0200 (CEST) Received: by mail-pl1-f178.google.com with SMTP id x8so8982333plv.8 for ; Mon, 27 Sep 2021 06:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lHGfUmAGv9M4RA1w8+Uve1rNW3LVrft/ZlIS+myyUWQ=; b=grd8h9MZoHfRoPhHuRfrAjDTDUOohU3eXLoiyvQJW7tjgHmZhyzRdFqLGcJcBUveFR gCoSf0gqI7MP+THcfVAP6rYaS63EhsfYJpwgwCFQKBC1t+O7Ohg+B4MkucJCn36eb0UH 3cwgMA0etHACqYhjLy+k+CyppOh7ECfQ4JIGI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lHGfUmAGv9M4RA1w8+Uve1rNW3LVrft/ZlIS+myyUWQ=; b=ymulQie2LQSCPnN/4S1QZD2qK/5H+vdbT7H/BS9s2fVyVH2Ju6RWoXGVPCAC/o7Yqy Dq/nOUE1PIe/uJZf+Vk9dOOHs8m+yAALKW82EJVnEGw92zitdbdTTH7u+3ZcjVSkUU1b hgAELAhpm5hVBaECTNNs9RNC3iO+VYIrLAiNzWGdV9iTdreyJGn2HtRWne38Bo0WxNnF l5StZuUj156Zw8l5T/uVHLRgFzQf/AUjApehf2im15GbY/j6RMF/oByr3yiOo8jByhnu wferZu+MdQM/AsNwqZOcosLCEAPH1Lu8C5FUQfqTJHYu2OdCdua+VSkhjYfjazfzOyXH EniA== X-Gm-Message-State: AOAM532w4aQtlFItCWABDBrufypdqNG+QpVQnH8tTZuUi7UvMk2SjsmM VhrSTRH8IZwRNTsKD/2mFqLJ7w== X-Google-Smtp-Source: ABdhPJxGsHAaQdPtedkrt+r6aEmWG8zuB+tUl8ptmaTYL5ehm6J/IdC/D3m/NOFk7+wcZTfPYQ8kaQ== X-Received: by 2002:a17:90b:4b51:: with SMTP id mi17mr22335pjb.120.1632750189293; Mon, 27 Sep 2021 06:43:09 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:09 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:24 +0530 Message-Id: <20210927134231.11177-5-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 04/11] bus/vmbus: get device resource values using sysctl 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 Sender: "dev" The UIO device's relid, monitor id, etc values are retrieved using following sysctl variables: $ sysctl dev.hv_uio.0 dev.hv_uio.0.send_buf.gpadl: 925241 dev.hv_uio.0.send_buf.size: 16777216 dev.hv_uio.0.recv_buf.gpadl: 925240 dev.hv_uio.0.recv_buf.size: 32505856 dev.hv_uio.0.monitor_page.size: 4096 dev.hv_uio.0.int_page.size: 4096 Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_uio.c | 98 ++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 17 deletions(-) diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c index b52ca5bf1d..fdd37dac3a 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_uio.c +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include @@ -24,8 +26,18 @@ /** Pathname of VMBUS devices directory. */ #define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices" +const char *driver_name = "hv_uio"; static void *vmbus_map_addr; +/* Check map names with kernel names */ +static const char *map_names[VMBUS_MAX_RESOURCE] = { + [HV_TXRX_RING_MAP] = "txrx_rings", + [HV_INT_PAGE_MAP] = "int_page", + [HV_MON_PAGE_MAP] = "monitor_page", + [HV_RECV_BUF_MAP] = "recv_buf", + [HV_SEND_BUF_MAP] = "send_buf", +}; + /* Control interrupts */ void vmbus_uio_irq_control(struct rte_vmbus_device *dev, int32_t onoff) { @@ -72,14 +84,75 @@ vmbus_uio_free_resource(struct rte_vmbus_device *dev, } } +static int +sysctl_get_vmbus_device_info(struct rte_vmbus_device *dev) +{ + char sysctlBuffer[PATH_MAX]; + char sysctlVar[PATH_MAX]; + size_t len = PATH_MAX, sysctl_len; + unsigned long tmp; + int i; + + snprintf(sysctlBuffer, len, "dev.%s.%d", driver_name, dev->uio_num); + + sysctl_len = sizeof(unsigned long); + /* get relid */ + snprintf(sysctlVar, len, "%s.channel.ch_id", sysctlBuffer); + if (sysctlbyname(sysctlVar, &tmp, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s", sysctlVar); + goto error; + } + dev->relid = tmp; + + /* get monitor id */ + snprintf(sysctlVar, len, "%s.channel.%u.monitor_id", sysctlBuffer, + dev->relid); + if (sysctlbyname(sysctlVar, &tmp, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s", sysctlVar); + goto error; + } + dev->monitor_id = tmp; + + /* Extract resource value */ + for (i = 0; i < VMBUS_MAX_RESOURCE; i++) { + struct rte_mem_resource *res = &dev->resource[i]; + unsigned long size, gpad = 0; + size_t sizelen = sizeof(len); + + snprintf(sysctlVar, sizeof(sysctlVar), "%s.%s.size", + sysctlBuffer, map_names[i]); + if (sysctlbyname(sysctlVar, &size, &sizelen, NULL, 0) < 0) { + VMBUS_LOG(ERR, + "could not read %s", sysctlVar); + goto error; + } + res->len = size; + + if (i == HV_RECV_BUF_MAP || i == HV_SEND_BUF_MAP) { + snprintf(sysctlVar, sizeof(sysctlVar), "%s.%s.gpadl", + sysctlBuffer, map_names[i]); + if (sysctlbyname(sysctlVar, &gpad, &sizelen, NULL, 0) < 0) { + VMBUS_LOG(ERR, + "could not read %s", sysctlVar); + goto error; + } + /* put the GPAD value in physical address */ + res->phys_addr = gpad; + } + } + return 0; +error: + return -1; +} + int vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, struct mapped_vmbus_resource **uio_res) { - char devname[PATH_MAX]; /* contains the /dev/uioX */ + char devname[PATH_MAX]; /* contains the /dev/hv_uioX */ /* save fd if in primary process */ - snprintf(devname, sizeof(devname), "/dev/uio%u", dev->uio_num); + snprintf(devname, sizeof(devname), "/dev/hv_uio%u", dev->uio_num); dev->intr_handle.fd = open(devname, O_RDWR); if (dev->intr_handle.fd < 0) { VMBUS_LOG(ERR, "Cannot open %s: %s", @@ -98,8 +171,10 @@ vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, strlcpy((*uio_res)->path, devname, PATH_MAX); rte_uuid_copy((*uio_res)->id, dev->device_id); - return 0; + if (sysctl_get_vmbus_device_info(dev) < 0) + goto error; + return 0; error: vmbus_uio_free_resource(dev, *uio_res); return -1; @@ -338,23 +413,12 @@ static int vmbus_uio_sysfs_read(const char *dir, const char *name, return ret; } -static bool vmbus_uio_ring_present(const struct rte_vmbus_device *dev, - uint32_t relid) -{ - char ring_path[PATH_MAX]; - - /* Check if kernel has subchannel sysfs files */ - snprintf(ring_path, sizeof(ring_path), - "%s/%s/channels/%u/ring", - SYSFS_VMBUS_DEVICES, dev->device.name, relid); - - return access(ring_path, R_OK|W_OK) == 0; -} - bool vmbus_uio_subchannels_supported(const struct rte_vmbus_device *dev, const struct vmbus_channel *chan) { - return vmbus_uio_ring_present(dev, chan->relid); + RTE_SET_USED(dev); + RTE_SET_USED(chan); + return true; } static bool vmbus_isnew_subchannel(struct vmbus_channel *primary, From patchwork Mon Sep 27 13:42:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99822 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6FDE8A0C46; Mon, 27 Sep 2021 17:01:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9AA94119B; Mon, 27 Sep 2021 16:58:35 +0200 (CEST) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 71711410DA for ; Mon, 27 Sep 2021 15:43:12 +0200 (CEST) Received: by mail-pl1-f179.google.com with SMTP id j14so11824600plx.4 for ; Mon, 27 Sep 2021 06:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mBf5CDb9YpfOGy+b2QPFCF6Q+KfuH//kPmg7Wt/oTc8=; b=gKrM1GVokz+jZMirKMBpHTS7qJkzI0vLwGBB9B4h0IwRdFdX2vJgCOvGV6TBV2Y9on QLRjytq+5K/uaz2jmsQuNXSk3+ALEXCNlaK79N/mtoA3L8Bi2I9i2NV1ES7P0QXR4j43 Fdw4iLO/sYIcxBbH4at34Nt5ikcxB3ewrQA4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mBf5CDb9YpfOGy+b2QPFCF6Q+KfuH//kPmg7Wt/oTc8=; b=xDwMqdNthJD9OD5sV4Q2SIBhdgXQcUoExQc/GeCAPGUrWvJVHBWw2CgwoX7OAEutv0 lUjIw0m1l2zeCAs1LmiHPCe98TDhpqy1yINhin3vDZn7tkLnffS10SxuSEE4f/L19P55 HEPrJm8+a44GsMJ0W/DHJArp073iPvHbRe2yhlnUyMVklcLMb6Y0jtCsHL6y9E43QIVs oU0EBW/p3y1WUyMZYJDS7A4qIolpUTjGRMfBIl/4Oe39u1Hllg/F2/1gySBDevgqUlLA 6BqMk5ufXsi5uAMRZrGM+Y1AK5yusWsfitI/TxJSL1Hz0uO+7dhhsou+CnYULLDP8DzU xRvQ== X-Gm-Message-State: AOAM532SsmnkJ3bgdO4Hk7kiSEQFXP3wtUF80BazKnEfgLJUUOXjLkdI Uj1mk/KnOYSRE9fkrc5qPtNh3w== X-Google-Smtp-Source: ABdhPJxPidIUWJaNy+sf/V6un9kLkWzEeSqNuyzwtwlIbc0aZlwEW2LdOC2LfxeVjuOx/cSY7xHLVQ== X-Received: by 2002:a17:902:a70e:b0:13e:1274:c352 with SMTP id w14-20020a170902a70e00b0013e1274c352mr9494plq.58.1632750191664; Mon, 27 Sep 2021 06:43:11 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:11 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:25 +0530 Message-Id: <20210927134231.11177-6-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 05/11] bus/vmbus: open subchannels 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 Sender: "dev" In FreeBSD, unlike Linux there is no sub-channel open callback that could be called by HV_UIO driver, upon their grant by the hypervisor. Thus, the PMD makes an IOCTL to the HV_UIO to open the granted sub-channels Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_uio.c | 31 +++++++++++++++++++++++++++ drivers/bus/vmbus/linux/vmbus_uio.c | 8 +++++++ drivers/bus/vmbus/private.h | 1 + drivers/bus/vmbus/rte_bus_vmbus.h | 10 +++++++++ drivers/bus/vmbus/version.map | 1 + drivers/bus/vmbus/vmbus_channel.c | 5 +++++ 6 files changed, 56 insertions(+) diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c index fdd37dac3a..022ac85302 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_uio.c +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,9 @@ /** Pathname of VMBUS devices directory. */ #define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices" +/* ioctl */ +#define HVIOOPENSUBCHAN _IOW('h', 14, uint32_t) + const char *driver_name = "hv_uio"; static void *vmbus_map_addr; @@ -515,3 +519,30 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, closedir(chan_dir); return err; } + +int vmbus_uio_subchan_open(struct rte_vmbus_device *dev, uint32_t subchan) +{ + struct mapped_vmbus_resource *uio_res; + int fd, err = 0; + + uio_res = vmbus_uio_find_resource(dev); + if (!uio_res) { + VMBUS_LOG(ERR, "cannot find uio resource"); + return -EINVAL; + } + + fd = open(uio_res->path, O_RDWR); + if (fd < 0) { + VMBUS_LOG(ERR, "Cannot open %s: %s", + uio_res->path, strerror(errno)); + return -1; + } + + if (ioctl(fd, HVIOOPENSUBCHAN, &subchan)) { + VMBUS_LOG(ERR, "open subchan ioctl failed %s: %s", + uio_res->path, strerror(errno)); + err = -1; + } + close(fd); + return err; +} diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index b52ca5bf1d..9e91ed9907 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -451,3 +451,11 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, closedir(chan_dir); return err; } + +int vmbus_uio_subchan_open(struct rte_vmbus_device *dev, + uint32_t subchan) +{ + RTE_SET_USED(dev); + RTE_SET_USED(subchan); + return 0; +} diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h index 528d60a42f..968f0b6f23 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -107,6 +107,7 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, int vmbus_uio_map_rings(struct vmbus_channel *chan); int vmbus_uio_map_secondary_subchan(const struct rte_vmbus_device *dev, const struct vmbus_channel *chan); +int vmbus_uio_subchan_open(struct rte_vmbus_device *device, uint32_t subchan); void vmbus_br_setup(struct vmbus_br *br, void *buf, unsigned int blen); diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h index 4cf73ce815..42d13c5705 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -405,6 +405,16 @@ void rte_vmbus_chan_dump(FILE *f, const struct vmbus_channel *chan); */ void rte_vmbus_unregister(struct rte_vmbus_driver *driver); +/** + * Perform IOCTL to VMBUS device + * + * @param device + * A pointer to a rte_vmbus_device structure + * @param subchan + * Count of subchannels to open + */ +int rte_vmbus_ioctl(struct rte_vmbus_device *device, uint32_t subchan); + /** Helper for VMBUS device registration from driver instance */ #define RTE_PMD_REGISTER_VMBUS(nm, vmbus_drv) \ RTE_INIT(vmbusinitfn_ ##nm) \ diff --git a/drivers/bus/vmbus/version.map b/drivers/bus/vmbus/version.map index 3cadec7fae..3509d4fc14 100644 --- a/drivers/bus/vmbus/version.map +++ b/drivers/bus/vmbus/version.map @@ -23,6 +23,7 @@ DPDK_22 { rte_vmbus_subchan_open; rte_vmbus_unmap_device; rte_vmbus_unregister; + rte_vmbus_ioctl; local: *; }; diff --git a/drivers/bus/vmbus/vmbus_channel.c b/drivers/bus/vmbus/vmbus_channel.c index f67f1c438a..f53a1b6511 100644 --- a/drivers/bus/vmbus/vmbus_channel.c +++ b/drivers/bus/vmbus/vmbus_channel.c @@ -367,6 +367,11 @@ int rte_vmbus_max_channels(const struct rte_vmbus_device *device) return 1; } +int rte_vmbus_ioctl(struct rte_vmbus_device *device, uint32_t subchan) +{ + return vmbus_uio_subchan_open(device, subchan); +} + /* Setup secondary channel */ int rte_vmbus_subchan_open(struct vmbus_channel *primary, struct vmbus_channel **new_chan) From patchwork Mon Sep 27 13:42:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99823 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 40E78A0C46; Mon, 27 Sep 2021 17:01:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0304F411A1; Mon, 27 Sep 2021 16:58:37 +0200 (CEST) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id B8DA640E3C for ; Mon, 27 Sep 2021 15:43:15 +0200 (CEST) Received: by mail-pj1-f54.google.com with SMTP id lb1-20020a17090b4a4100b001993f863df2so13733262pjb.5 for ; Mon, 27 Sep 2021 06:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z1oO9hmfz/nQz44rL3kBXq6YVMX+k7y7RSyHhViHvzQ=; b=dMM61kUsjseWam0N6eRdPS3BpO5eXyUw4d1+SArcUzSEWXqPf0Rqo2GgUDkMx7S0ZJ 9D+ZNuC4tq/bWk7d4Y9cG51zyj3NjAsYv2x3Xc4JDAHvy/9wEKIwMq/3NoE+0TxzrF/O U2E5sCpZ/bpQaaNbPdGU65tl5NaGaIXSKKnO4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z1oO9hmfz/nQz44rL3kBXq6YVMX+k7y7RSyHhViHvzQ=; b=hUj4G62EeqR9bezt5F8ZMq2zemIuMjUrMmlzKIhZS5r0zJTEvbiRPy3KSvQgcwI74b GuWMows9tCpeTkwSYD/51LdGnrI1x9HB0lpjQCTNokuJsqEqsW3D9Q8kmaiLX+J/LY1i kCkrT6PVuD/vUM30UPEZ27tl9RWUAV3WfOefFK4OpFJHwLlBAAatF2/cPctIvnW841qo hlqP3glmEqsGCQH2aHWhzB2jAb5ZKIqaeWTmzXR5JilI4WyynjuEWgcXMC1PIXAraWaK jgFXFVtFn8g5XYpThajgsNuuJkjJyS5PVYNOaAb0Bo+YPJd3P3y22kB6CJ5qMZtGrqvf jR3Q== X-Gm-Message-State: AOAM531OG52wflqy+gWG+IJE169Gz3TXdXO9GYqQeigrHTKjCLKBGYEW lK4CyHPHhZSHmGM0FsQlhL0jYg== X-Google-Smtp-Source: ABdhPJxRwJHeo8UEDhptcywuJaJkaohNsfmHz0zBLXi34TW0ZE842eo3gYZJwJ5QOIb3a5oIINyDAg== X-Received: by 2002:a17:902:b102:b0:134:a329:c2f8 with SMTP id q2-20020a170902b10200b00134a329c2f8mr54701plr.71.1632750195021; Mon, 27 Sep 2021 06:43:15 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:14 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:26 +0530 Message-Id: <20210927134231.11177-7-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 06/11] net/netvsc: request HV_UIO to open sub-channels 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 Sender: "dev" On Linux, the request does nothing, while on FreeBSD the HV_UIO kernel driver receives the request and opens the subchannels on PMDs behalf. Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/net/netvsc/hn_ethdev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 9e2a405973..6f9053c4d5 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -515,6 +515,10 @@ static int hn_subchan_configure(struct hn_data *hv, if (err) return err; + err = rte_vmbus_ioctl(hv->vmbus, subchan); + if (err) + return err; + while (subchan > 0) { struct vmbus_channel *new_sc; uint16_t chn_index; From patchwork Mon Sep 27 13:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99824 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 04AFAA0C46; Mon, 27 Sep 2021 17:01:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2AD01411A7; Mon, 27 Sep 2021 16:58:38 +0200 (CEST) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mails.dpdk.org (Postfix) with ESMTP id 7623A410DD for ; Mon, 27 Sep 2021 15:43:18 +0200 (CEST) Received: by mail-pl1-f174.google.com with SMTP id t11so11798905plq.11 for ; Mon, 27 Sep 2021 06:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ypsdkfEQUqstAzTHwOVtK+4V2nRVI41QIW0OB1Uo4Ak=; b=A4qozoIrB6hNq6Pesxr6RBAs7odlKiq2dKHL6LW0EGSR92JrNktCI43nI5ejgJW7wR 1rUPoVLT0MpoKXhAXNVA5QZ287WMXeieoc5IqlPnTmrhXA9Hpfw7EAWuViCShLXig8PX RAJQfkp21cJM2nKBwwW/3mTGoE0xi4/SFkzIw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ypsdkfEQUqstAzTHwOVtK+4V2nRVI41QIW0OB1Uo4Ak=; b=609fopmioxceEx0lM3m0YB+27FFqTUPCXUcrNC+Av+FBnhvDMEAFIWTnHi3BIZy06z KUt7RZuLxTPVvfDuaFrMX2M8wlnRDsAfZBVNExxZkpjrADoa+cTxuJ/Bzal0d92ls7Vw 4f3NGTkmUitQVspk4IEVsD9jndI+Pm2CU7ycQFUd801b3Uj7GGlC9tt6M8nenBANxE/u ZQRHMWpndS7amqERjWaU7nbxJBNahfmgma5Zu/eIuWGaGJqEvxIKy4oaT+vAd+Vz2hBM S0w5qM5gfqb3scoIdEq4XeLo21Q/byqWjtfYX/y2INk3NcM3l/38MDQ8m4X5a41h6AMt yVmA== X-Gm-Message-State: AOAM530nOADG5mcUtkX6W4a+cottjQNk8j+8gR2Ql1WbBAqNl/m1+n6y zTNxPD7NNF0JrSRUsh/PITHvng== X-Google-Smtp-Source: ABdhPJxkHlUofbS3xFYjj4lDxKkI9BDwHctPpQRloYbY1ZWeHCLwsa1myY+/QohEkNo8p88YtKiCUw== X-Received: by 2002:a17:90a:2944:: with SMTP id x4mr2079970pjf.131.1632750197671; Mon, 27 Sep 2021 06:43:17 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:17 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:27 +0530 Message-Id: <20210927134231.11177-8-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 07/11] bus/vmbus: map the subchannel resources 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 Sender: "dev" Using sysctl, the resource values of subchannels are obtained and an mmap request to made to their buffers. Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_uio.c | 181 ++++++++++---------------- 1 file changed, 66 insertions(+), 115 deletions(-) diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c index 022ac85302..14b858f39d 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_uio.c +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -24,8 +24,11 @@ #include "private.h" -/** Pathname of VMBUS devices directory. */ -#define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices" +/* Macros to distinguish mmap request + * [7-0] - Device memory region + * [15-8]- Sub-channel id + */ +#define UH_SUBCHAN_MASK_SHIFT 8 /* ioctl */ #define HVIOOPENSUBCHAN _IOW('h', 14, uint32_t) @@ -274,19 +277,17 @@ static int vmbus_uio_map_primary(struct vmbus_channel *chan, } static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev, - const struct vmbus_channel *chan, + struct vmbus_channel *chan, void **ring_buf, uint32_t *ring_size) { char ring_path[PATH_MAX]; - size_t file_size; - struct stat sb; + size_t size; void *mapaddr; + off_t offset; int fd; snprintf(ring_path, sizeof(ring_path), - "%s/%s/channels/%u/ring", - SYSFS_VMBUS_DEVICES, dev->device.name, - chan->relid); + "/dev/hv_uio%d", dev->uio_num); fd = open(ring_path, O_RDWR); if (fd < 0) { @@ -295,33 +296,21 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev, return -errno; } - if (fstat(fd, &sb) < 0) { - VMBUS_LOG(ERR, "Cannot state %s: %s", - ring_path, strerror(errno)); - close(fd); - return -errno; - } - file_size = sb.st_size; - - if (file_size == 0 || (file_size & (rte_mem_page_size() - 1))) { - VMBUS_LOG(ERR, "incorrect size %s: %zu", - ring_path, file_size); - - close(fd); - return -EINVAL; - } + /* subchannel rings are of the same size as primary */ + size = dev->resource[HV_TXRX_RING_MAP].len; + offset = (chan->relid << UH_SUBCHAN_MASK_SHIFT) * PAGE_SIZE; mapaddr = vmbus_map_resource(vmbus_map_addr, fd, - 0, file_size, 0); + offset, size, 0); close(fd); if (mapaddr == MAP_FAILED) return -EIO; - *ring_size = file_size / 2; + *ring_size = size / 2; *ring_buf = mapaddr; - vmbus_map_addr = RTE_PTR_ADD(mapaddr, file_size); + vmbus_map_addr = RTE_PTR_ADD(mapaddr, size); return 0; } @@ -336,9 +325,7 @@ vmbus_uio_map_secondary_subchan(const struct rte_vmbus_device *dev, int fd; snprintf(ring_path, sizeof(ring_path), - "%s/%s/channels/%u/ring", - SYSFS_VMBUS_DEVICES, dev->device.name, - chan->relid); + "/dev/ring%d", dev->uio_num); ring_buf = br->vbr; ring_size = br->dsize + sizeof(struct vmbus_bufring); @@ -391,32 +378,6 @@ int vmbus_uio_map_rings(struct vmbus_channel *chan) return 0; } -static int vmbus_uio_sysfs_read(const char *dir, const char *name, - unsigned long *val, unsigned long max_range) -{ - char path[PATH_MAX]; - FILE *f; - int ret; - - snprintf(path, sizeof(path), "%s/%s", dir, name); - f = fopen(path, "r"); - if (!f) { - VMBUS_LOG(ERR, "can't open %s:%s", - path, strerror(errno)); - return -errno; - } - - if (fscanf(f, "%lu", val) != 1) - ret = -EIO; - else if (*val > max_range) - ret = -ERANGE; - else - ret = 0; - fclose(f); - - return ret; -} - bool vmbus_uio_subchannels_supported(const struct rte_vmbus_device *dev, const struct vmbus_channel *chan) { @@ -426,7 +387,7 @@ bool vmbus_uio_subchannels_supported(const struct rte_vmbus_device *dev, } static bool vmbus_isnew_subchannel(struct vmbus_channel *primary, - unsigned long id) + uint16_t id) { const struct vmbus_channel *c; @@ -441,83 +402,73 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, struct vmbus_channel **subchan) { const struct rte_vmbus_device *dev = primary->device; - char chan_path[PATH_MAX], subchan_path[PATH_MAX]; - struct dirent *ent; - DIR *chan_dir; + char sysctlBuffer[PATH_MAX], sysctlVar[PATH_MAX]; + size_t len = PATH_MAX, sysctl_len; + /* nr_schan, relid, subid & monid datatype must match kernel's for sysctl */ + uint32_t relid, subid, nr_schan, i; + uint8_t monid; int err; - snprintf(chan_path, sizeof(chan_path), - "%s/%s/channels", - SYSFS_VMBUS_DEVICES, dev->device.name); - - chan_dir = opendir(chan_path); - if (!chan_dir) { - VMBUS_LOG(ERR, "cannot open %s: %s", - chan_path, strerror(errno)); - return -errno; + /* get no. of sub-channels opened by hv_uio + * dev.hv_uio.0.subchan_cnt + */ + snprintf(sysctlVar, len, "dev.%s.%d.subchan_cnt", driver_name, + dev->uio_num); + sysctl_len = sizeof(nr_schan); + if (sysctlbyname(sysctlVar, &nr_schan, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctlVar, + strerror(errno)); + return -1; } - while ((ent = readdir(chan_dir))) { - unsigned long relid, subid, monid; - char *endp; - - if (ent->d_name[0] == '.') - continue; - - errno = 0; - relid = strtoul(ent->d_name, &endp, 0); - if (*endp || errno != 0 || relid > UINT16_MAX) { - VMBUS_LOG(NOTICE, "not a valid channel relid: %s", - ent->d_name); - continue; - } - - if (!vmbus_isnew_subchannel(primary, relid)) { - VMBUS_LOG(DEBUG, "skip already found channel: %lu", - relid); - continue; + /* dev.hv_uio.0.channel.14.sub */ + snprintf(sysctlBuffer, len, "dev.%s.%d.channel.%u.sub", driver_name, + dev->uio_num, primary->relid); + for (i = 1; i <= nr_schan; i++) { + /* get relid */ + snprintf(sysctlVar, len, "%s.%u.chanid", sysctlBuffer, i); + sysctl_len = sizeof(relid); + if (sysctlbyname(sysctlVar, &relid, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctlVar, + strerror(errno)); + goto error; } - if (!vmbus_uio_ring_present(dev, relid)) { - VMBUS_LOG(DEBUG, "ring mmap not found (yet) for: %lu", - relid); + if (!vmbus_isnew_subchannel(primary, (uint16_t)relid)) { + VMBUS_LOG(DEBUG, "skip already found channel: %u", + relid); continue; } - snprintf(subchan_path, sizeof(subchan_path), "%s/%lu", - chan_path, relid); - err = vmbus_uio_sysfs_read(subchan_path, "subchannel_id", - &subid, UINT16_MAX); - if (err) { - VMBUS_LOG(NOTICE, "no subchannel_id in %s:%s", - subchan_path, strerror(-err)); - goto fail; + /* get sub-channel id */ + snprintf(sysctlVar, len, "%s.%u.ch_subidx", sysctlBuffer, i); + sysctl_len = sizeof(subid); + if (sysctlbyname(sysctlVar, &subid, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctlVar, + strerror(errno)); + goto error; } - if (subid == 0) - continue; /* skip primary channel */ - - err = vmbus_uio_sysfs_read(subchan_path, "monitor_id", - &monid, UINT8_MAX); - if (err) { - VMBUS_LOG(NOTICE, "no monitor_id in %s:%s", - subchan_path, strerror(-err)); - goto fail; + /* get monitor id */ + snprintf(sysctlVar, len, "%s.%u.monitor_id", sysctlBuffer, i); + sysctl_len = sizeof(monid); + if (sysctlbyname(sysctlVar, &monid, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctlVar, + strerror(errno)); + goto error; } - err = vmbus_chan_create(dev, relid, subid, monid, subchan); + err = vmbus_chan_create(dev, (uint16_t)relid, (uint16_t)subid, + monid, subchan); if (err) { VMBUS_LOG(ERR, "subchannel setup failed"); - goto fail; + return err; } break; } - closedir(chan_dir); - - return (ent == NULL) ? -ENOENT : 0; -fail: - closedir(chan_dir); - return err; + return 0; +error: + return -1; } int vmbus_uio_subchan_open(struct rte_vmbus_device *dev, uint32_t subchan) From patchwork Mon Sep 27 13:42:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99825 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B66C0A0C46; Mon, 27 Sep 2021 17:01:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 367A5411AB; Mon, 27 Sep 2021 16:58:39 +0200 (CEST) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id 613A7410DA for ; Mon, 27 Sep 2021 15:43:21 +0200 (CEST) Received: by mail-pj1-f44.google.com with SMTP id u1-20020a17090ae00100b0019ec31d3ba2so4238196pjy.1 for ; Mon, 27 Sep 2021 06:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Imf48FjimLm0M8J8OyFai005M0N3mInOi98nlSOlYW0=; b=UIST+WDZEpv2dtfg7zntA1lMctXdhXhw8MOc0sPljjXO9/jsN9gDzI6ZvOaEsnmjgg TX3KnaFW7Mr3ZDCquXbpzfK2162ZUbQG9oR2kOTckPeB6qUS1bfJzYo6d4Iupy3uO7gA pAHpPCrWnkjT1165NteZ1d7d7iT0El/d2em3g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Imf48FjimLm0M8J8OyFai005M0N3mInOi98nlSOlYW0=; b=jopYzsGLhRbRaK5jg+XlOaBDgFZa/kDGZlyPEOTXT138kCs/fg35W07HL0eX1tQpnA upOMRqjxP2/ayvX2K6tehEanEQHLBXLU9VrjAwMgfW5g5BiLbwcSIEX6uGuZL8dkynh+ eSAThfOJ1kli4C5r/QcV6CGBqH4wlEHwj6q0tEcYnIun7QxQrK42GdX0CStY8eR7nQU+ bfL29jZQSAborR5DVM1t8fr36i8pumbhg52jYWqYZbM6yyzZqTVvNC+wFv6rdFN1pVdU lrjeFfziCZQNakMSplHCSVQWa76R/Mcw4SuvYsIF7hMWbpVU6OxXVEpnTkKiyJ6RGBZ6 JtOg== X-Gm-Message-State: AOAM530sFK3gpKjYANCXP7k/a8htDE/sh5vUyUTASshCsnfZCDjGwyqA uFvydR+ZdOYP5W149OxIFOtJkQ== X-Google-Smtp-Source: ABdhPJw1r+TEG/EQ/FqoMbOqyb/Q9JfDAS+FvFiOSwGuzhf+1ETFogMTqI+SLRffn96JE+FlMyVJQw== X-Received: by 2002:a17:902:904b:b0:13d:c33b:294f with SMTP id w11-20020a170902904b00b0013dc33b294fmr22526551plz.35.1632750200637; Mon, 27 Sep 2021 06:43:20 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:20 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:28 +0530 Message-Id: <20210927134231.11177-9-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 08/11] net/netvsc: moving event monitoring support 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 Sender: "dev" Event monitoring is not yet supported on FreeBSD, hence moving it the OS specific files Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram Reviewed-by: Long Li --- drivers/net/netvsc/freebsd/hn_os.c | 14 ++++++++++++++ drivers/net/netvsc/hn_ethdev.c | 7 +++---- drivers/net/netvsc/hn_os.h | 6 ++++++ drivers/net/netvsc/linux/hn_os.c | 19 +++++++++++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 drivers/net/netvsc/freebsd/hn_os.c create mode 100644 drivers/net/netvsc/hn_os.h create mode 100644 drivers/net/netvsc/linux/hn_os.c diff --git a/drivers/net/netvsc/freebsd/hn_os.c b/drivers/net/netvsc/freebsd/hn_os.c new file mode 100644 index 0000000000..3bd67e06c8 --- /dev/null +++ b/drivers/net/netvsc/freebsd/hn_os.c @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2016-2021 Microsoft Corporation + */ + +#include + +#include "hn_logs.h" +#include "hn_os.h" + +int eth_hn_os_dev_event(void) +{ + PMD_DRV_LOG(DEBUG, "rte_dev_event_monitor_start not supported on FreeBSD"); + return 0; +} diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 6f9053c4d5..61d7d3daeb 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -39,6 +39,7 @@ #include "hn_rndis.h" #include "hn_nvs.h" #include "ndis.h" +#include "hn_os.h" #define HN_TX_OFFLOAD_CAPS (DEV_TX_OFFLOAD_IPV4_CKSUM | \ DEV_TX_OFFLOAD_TCP_CKSUM | \ @@ -1244,11 +1245,9 @@ static int eth_hn_probe(struct rte_vmbus_driver *drv __rte_unused, PMD_INIT_FUNC_TRACE(); - ret = rte_dev_event_monitor_start(); - if (ret) { - PMD_DRV_LOG(ERR, "Failed to start device event monitoring"); + ret = eth_hn_os_dev_event(); + if (ret) return ret; - } eth_dev = eth_dev_vmbus_allocate(dev, sizeof(struct hn_data)); if (!eth_dev) diff --git a/drivers/net/netvsc/hn_os.h b/drivers/net/netvsc/hn_os.h new file mode 100644 index 0000000000..618c53cdcd --- /dev/null +++ b/drivers/net/netvsc/hn_os.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2009-2021 Microsoft Corp. + * All rights reserved. + */ + +int eth_hn_os_dev_event(void); diff --git a/drivers/net/netvsc/linux/hn_os.c b/drivers/net/netvsc/linux/hn_os.c new file mode 100644 index 0000000000..862dc190c1 --- /dev/null +++ b/drivers/net/netvsc/linux/hn_os.c @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2016-2021 Microsoft Corporation + */ + +#include + +#include "hn_logs.h" +#include "hn_os.h" + +int eth_hn_os_dev_event(void) +{ + int ret; + + ret = rte_dev_event_monitor_start(); + if (ret) + PMD_DRV_LOG(ERR, "Failed to start device event monitoring"); + + return ret; +} From patchwork Mon Sep 27 13:42:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99826 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7CDDDA0C46; Mon, 27 Sep 2021 17:01:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 65689411B1; Mon, 27 Sep 2021 16:58:40 +0200 (CEST) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id 5F7FD40E3C for ; Mon, 27 Sep 2021 15:43:24 +0200 (CEST) Received: by mail-pg1-f177.google.com with SMTP id 75so1466759pga.3 for ; Mon, 27 Sep 2021 06:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XFHfzkQkAtV9RoDpC48spl+nGb211hhWKaRZYzd9n2g=; b=NNSxDsEDhi5dh4z4MCftARVKtK0fd/+/P08/hMUrBEwwsgOiGEv7aER38220LAdlZx jJDzJwBleMQJzdQM+sq17DkaUcXOC5GlGbTgGgNLfj9BRerWm1DG5JU28lE868+59kmW fhIFu/61CAqHcRmcTmRV+vrD4AABZ2taXMc8M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XFHfzkQkAtV9RoDpC48spl+nGb211hhWKaRZYzd9n2g=; b=QyU+R+Bm+JCajpJJnWSXIiiJJVkKSuEs0IjGh8SJdP3ZXnW6TK9mfcbESvMsjyYijK xzpXGtZvesU+N/4is5DIwmt0MAE+WZzpeuNsCtZdtLPhGuOaEAgug8gjbrVVIHXg6eAa WCbsDpnXcUcQza8sfDyvC2siLEsNfb2ZHCkAaDzW9HCMZyheNRtxo+EeZp825glh0PeE PXX15OcWmBOnMIG8KrUSyDA2gpynu1x0v1N5eqqKsG94GGBVUTXFDuYPxBFM8yo2jNk1 ekA+2KEfAUDREy7/FGacjfcFDZI6xypxHDhjJO8SRUyMglPty1tOTLlGTrpmjk2qdM1G TRVw== X-Gm-Message-State: AOAM531gB3h9Kem3ZVRCKzH7HUo6rk7549o3g9s9z/U3nEXWzvkoL6LX kLo32ELyQaX3xS8uscto7OW7jg== X-Google-Smtp-Source: ABdhPJxKi2kphyvs/vVmayUGUw0MQcAW4jFp7vs15//yD48fswP1JTT1caY6q4f+REsDXCCMbEZ5Wg== X-Received: by 2002:aa7:9682:0:b0:440:3c00:febd with SMTP id f2-20020aa79682000000b004403c00febdmr23857989pfk.81.1632750203535; Mon, 27 Sep 2021 06:43:23 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:23 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:29 +0530 Message-Id: <20210927134231.11177-10-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 09/11] net/netvsc: moving hotplug retry to OS dir 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 Sender: "dev" Moved netvsc_hotplug_retry to respective OS dir as it contains OS dependent code. For Linux, it is copied as is and for FreeBSD it is not supported yet. Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram Reviewed-by: Long Li --- drivers/net/netvsc/freebsd/hn_os.c | 8 +++ drivers/net/netvsc/hn_ethdev.c | 84 --------------------------- drivers/net/netvsc/hn_os.h | 2 + drivers/net/netvsc/linux/hn_os.c | 92 ++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 84 deletions(-) diff --git a/drivers/net/netvsc/freebsd/hn_os.c b/drivers/net/netvsc/freebsd/hn_os.c index 3bd67e06c8..2ba4c32a76 100644 --- a/drivers/net/netvsc/freebsd/hn_os.c +++ b/drivers/net/netvsc/freebsd/hn_os.c @@ -4,6 +4,8 @@ #include +#include + #include "hn_logs.h" #include "hn_os.h" @@ -12,3 +14,9 @@ int eth_hn_os_dev_event(void) PMD_DRV_LOG(DEBUG, "rte_dev_event_monitor_start not supported on FreeBSD"); return 0; } + +void netvsc_hotplug_retry(void *args) +{ + RTE_SET_USED(args); + return; +} diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 61d7d3daeb..c299b98a6c 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -57,9 +57,6 @@ #define NETVSC_ARG_TXBREAK "tx_copybreak" #define NETVSC_ARG_RX_EXTMBUF_ENABLE "rx_extmbuf_enable" -/* The max number of retry when hot adding a VF device */ -#define NETVSC_MAX_HOTADD_RETRY 10 - struct hn_xstats_name_off { char name[RTE_ETH_XSTATS_NAME_SIZE]; unsigned int offset; @@ -556,87 +553,6 @@ static int hn_subchan_configure(struct hn_data *hv, return err; } -static void netvsc_hotplug_retry(void *args) -{ - int ret; - struct hn_data *hv = args; - struct rte_eth_dev *dev = &rte_eth_devices[hv->port_id]; - struct rte_devargs *d = &hv->devargs; - char buf[256]; - - DIR *di; - struct dirent *dir; - struct ifreq req; - struct rte_ether_addr eth_addr; - int s; - - PMD_DRV_LOG(DEBUG, "%s: retry count %d", - __func__, hv->eal_hot_plug_retry); - - if (hv->eal_hot_plug_retry++ > NETVSC_MAX_HOTADD_RETRY) - return; - - snprintf(buf, sizeof(buf), "/sys/bus/pci/devices/%s/net", d->name); - di = opendir(buf); - if (!di) { - PMD_DRV_LOG(DEBUG, "%s: can't open directory %s, " - "retrying in 1 second", __func__, buf); - goto retry; - } - - while ((dir = readdir(di))) { - /* Skip . and .. directories */ - if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, "..")) - continue; - - /* trying to get mac address if this is a network device*/ - s = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); - if (s == -1) { - PMD_DRV_LOG(ERR, "Failed to create socket errno %d", - errno); - break; - } - strlcpy(req.ifr_name, dir->d_name, sizeof(req.ifr_name)); - ret = ioctl(s, SIOCGIFHWADDR, &req); - close(s); - if (ret == -1) { - PMD_DRV_LOG(ERR, - "Failed to send SIOCGIFHWADDR for device %s", - dir->d_name); - break; - } - if (req.ifr_hwaddr.sa_family != ARPHRD_ETHER) { - closedir(di); - return; - } - memcpy(eth_addr.addr_bytes, req.ifr_hwaddr.sa_data, - RTE_DIM(eth_addr.addr_bytes)); - - if (rte_is_same_ether_addr(ð_addr, dev->data->mac_addrs)) { - PMD_DRV_LOG(NOTICE, - "Found matching MAC address, adding device %s network name %s", - d->name, dir->d_name); - ret = rte_eal_hotplug_add(d->bus->name, d->name, - d->args); - if (ret) { - PMD_DRV_LOG(ERR, - "Failed to add PCI device %s", - d->name); - break; - } - } - /* When the code reaches here, we either have already added - * the device, or its MAC address did not match. - */ - closedir(di); - return; - } - closedir(di); -retry: - /* The device is still being initialized, retry after 1 second */ - rte_eal_alarm_set(1000000, netvsc_hotplug_retry, hv); -} - static void netvsc_hotadd_callback(const char *device_name, enum rte_dev_event_type type, void *arg) diff --git a/drivers/net/netvsc/hn_os.h b/drivers/net/netvsc/hn_os.h index 618c53cdcd..1fb7292b17 100644 --- a/drivers/net/netvsc/hn_os.h +++ b/drivers/net/netvsc/hn_os.h @@ -4,3 +4,5 @@ */ int eth_hn_os_dev_event(void); + +void netvsc_hotplug_retry(void *args); diff --git a/drivers/net/netvsc/linux/hn_os.c b/drivers/net/netvsc/linux/hn_os.c index 862dc190c1..9c2f4cd7a8 100644 --- a/drivers/net/netvsc/linux/hn_os.c +++ b/drivers/net/netvsc/linux/hn_os.c @@ -2,11 +2,22 @@ * Copyright(c) 2016-2021 Microsoft Corporation */ +#include +#include +#include +#include +#include + #include +#include #include "hn_logs.h" +#include "hn_var.h" #include "hn_os.h" +/* The max number of retry when hot adding a VF device */ +#define NETVSC_MAX_HOTADD_RETRY 10 + int eth_hn_os_dev_event(void) { int ret; @@ -17,3 +28,84 @@ int eth_hn_os_dev_event(void) return ret; } + +void netvsc_hotplug_retry(void *args) +{ + int ret; + struct hn_data *hv = args; + struct rte_eth_dev *dev = &rte_eth_devices[hv->port_id]; + struct rte_devargs *d = &hv->devargs; + char buf[256]; + + DIR *di; + struct dirent *dir; + struct ifreq req; + struct rte_ether_addr eth_addr; + int s; + + PMD_DRV_LOG(DEBUG, "%s: retry count %d", + __func__, hv->eal_hot_plug_retry); + + if (hv->eal_hot_plug_retry++ > NETVSC_MAX_HOTADD_RETRY) + return; + + snprintf(buf, sizeof(buf), "/sys/bus/pci/devices/%s/net", d->name); + di = opendir(buf); + if (!di) { + PMD_DRV_LOG(DEBUG, "%s: can't open directory %s, " + "retrying in 1 second", __func__, buf); + goto retry; + } + + while ((dir = readdir(di))) { + /* Skip . and .. directories */ + if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, "..")) + continue; + + /* trying to get mac address if this is a network device*/ + s = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); + if (s == -1) { + PMD_DRV_LOG(ERR, "Failed to create socket errno %d", + errno); + break; + } + strlcpy(req.ifr_name, dir->d_name, sizeof(req.ifr_name)); + ret = ioctl(s, SIOCGIFHWADDR, &req); + close(s); + if (ret == -1) { + PMD_DRV_LOG(ERR, + "Failed to send SIOCGIFHWADDR for device %s", + dir->d_name); + break; + } + if (req.ifr_hwaddr.sa_family != ARPHRD_ETHER) { + closedir(di); + return; + } + memcpy(eth_addr.addr_bytes, req.ifr_hwaddr.sa_data, + RTE_DIM(eth_addr.addr_bytes)); + + if (rte_is_same_ether_addr(ð_addr, dev->data->mac_addrs)) { + PMD_DRV_LOG(NOTICE, + "Found matching MAC address, adding device %s network name %s", + d->name, dir->d_name); + ret = rte_eal_hotplug_add(d->bus->name, d->name, + d->args); + if (ret) { + PMD_DRV_LOG(ERR, + "Failed to add PCI device %s", + d->name); + break; + } + } + /* When the code reaches here, we either have already added + * the device, or its MAC address did not match. + */ + closedir(di); + return; + } + closedir(di); +retry: + /* The device is still being initialized, retry after 1 second */ + rte_eal_alarm_set(1000000, netvsc_hotplug_retry, hv); +} From patchwork Mon Sep 27 13:42:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99827 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0148FA0C46; Mon, 27 Sep 2021 17:01:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 956CC411B7; Mon, 27 Sep 2021 16:58:41 +0200 (CEST) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by mails.dpdk.org (Postfix) with ESMTP id 3E2CC40E3C for ; Mon, 27 Sep 2021 15:43:27 +0200 (CEST) Received: by mail-pg1-f172.google.com with SMTP id n18so17800932pgm.12 for ; Mon, 27 Sep 2021 06:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nSLQbmFAXrwzndzV+q4vVZgV7qceKvCLZgoq571WrYo=; b=ifbkA5X9Ej1c9UMl5X5bbFHu4cqfHkGJyXjGXiApXCPrkYIaSebsp0KrtIlRX9OSBo 62tMXRw0EH6oWKuiVzd6+dpQli1qyChU9NUHy/t56G66jRj5AKUeDXhYcfVOwmtQpiU4 +qV+1aZynGZSN/WdvR6+lBMHhx4h3crfur1H0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nSLQbmFAXrwzndzV+q4vVZgV7qceKvCLZgoq571WrYo=; b=AeGAYeNdDYaPG2vuJl7bS4TbjUPZ1Hzy2mAMhz50lybbUW2FMTmcW9Af0TOfuGPjmu emI1gpUxAwB+9ovkXJc2CbBJd4gieH1aqq8a6M8jsjEmhrXyVNLtzBg1swktGrHN/CXK 2ebBUg6/yhIgLMJahez9F10k5jGx7J/GT9V6dLnVCGs70XuezHx0aiIaMlK8Xgyoeebl RgXKhhsSkw6Zj08ptpQTAZ1EW6EHoiDBgIqtRWAiUiOAHzy/BxXtIhwN/Uej46M4ygeL gQOh+ENsjym7z1Xrw0JwnhTKwdXbUff7uKRK6dC3WR6XGMWQ7j84AIRO93YwmUN+hN0k QD6Q== X-Gm-Message-State: AOAM5317ELYFGMMFStGhpKnHGsUrDkUeJQRx891pjz48dEP77+qFkr1t 4JfXaW/GTHOXrBL1pjhEJVQddA5yM7a2Ng== X-Google-Smtp-Source: ABdhPJx1TsfWyLMr1m2nQNHl7E7Mk+ccsueuS+uyGrOpoBq9LadlkLZqF+oUJHIkCMzuia0R65XChQ== X-Received: by 2002:a62:ab07:0:b0:440:3c5b:ae7c with SMTP id p7-20020a62ab07000000b004403c5bae7cmr23641433pff.49.1632750206483; Mon, 27 Sep 2021 06:43:26 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:26 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:30 +0530 Message-Id: <20210927134231.11177-11-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 10/11] bus/vmbus: add meson support for FreeBSD OS 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 Sender: "dev" add meson support for FreeBSD OS Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram Reviewed-by: Long Li --- drivers/bus/vmbus/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bus/vmbus/meson.build b/drivers/bus/vmbus/meson.build index 3892cbf67f..8fbe144fcd 100644 --- a/drivers/bus/vmbus/meson.build +++ b/drivers/bus/vmbus/meson.build @@ -20,7 +20,11 @@ if is_linux sources += files('linux/vmbus_bus.c', 'linux/vmbus_uio.c') includes += include_directories('linux') +elif is_freebsd + sources += files('freebsd/vmbus_bus.c', + 'freebsd/vmbus_uio.c') + includes += include_directories('freebsd') else build = false - reason = 'only supported on Linux' + reason = 'only supported on Linux & FreeBSD' endif From patchwork Mon Sep 27 13:42:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 99828 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4CBC8A0C46; Mon, 27 Sep 2021 17:01:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A87F7411BD; Mon, 27 Sep 2021 16:58:42 +0200 (CEST) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id 501D540E3C for ; Mon, 27 Sep 2021 15:43:30 +0200 (CEST) Received: by mail-pj1-f42.google.com with SMTP id d4-20020a17090ad98400b0019ece228690so3753690pjv.5 for ; Mon, 27 Sep 2021 06:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jpNEzLjdJ97WwdMsysAiJ0PAYfW5MXIUx8p7Fq8XJgU=; b=Zm48pHLX3eI+3YeCqq4UJvAW8kVfgjQxCmT6n31t9/kZC/dyMHk1kJsjcHm15F+Iuz knkKXoPVH8XZKO9M4khUcHa98FopOgQwtYw9YNMf13zdJm3ewYFwHVsbMJ2gWaGGDsHu CCV7Rb9jSf7EfbJHTTEdy8vJ7Y+EX4cxTueOU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jpNEzLjdJ97WwdMsysAiJ0PAYfW5MXIUx8p7Fq8XJgU=; b=M1A/bNCi+KGjkSyDpR6f610RiLMNfFb+T9iRAzVoEpevh8rsikq1R+Yvpg8qwEPc6W XVaTTTCXML2ZRPquAPtZvKX0Ar2h1va6mYCwZ0f3DfC3sQsuBf6encG2PNpmu0iXbt+Y MGMUo2BHg2Sw30seiofhPYj7JQtHHWSqQUMDhVWvN/QVhxS6PNcY8xTpJJCf1jlGBP5A +N0OjRaXrZGvRSHwmoGJZXJ6p0JOmsvMKbAhKvna5OAZEnEmKdm7/x4uQ8lomqkQ5ZBt sck1VxRMw2d+yfm7RNgoB2V2sUBJ9E1iqyjBSpvydox+n+JEUAHCUjxR3Uolwz0VV08k cNkw== X-Gm-Message-State: AOAM532Y2AxJikEhs6syQSBOm6K89rzWraiCYEXXZ5th4iiSFMr3JxUE 7yLhYvefWf/rgTnaGlwIIcErgg== X-Google-Smtp-Source: ABdhPJwPJrs1gTVui/jXAt6pJNGU90WP0VKOWeCrIA0qE+oXCM80PFvl+np7lafPrv9PWDk9q3ooHA== X-Received: by 2002:a17:90a:11:: with SMTP id 17mr5322pja.238.1632750209534; Mon, 27 Sep 2021 06:43:29 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:29 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:31 +0530 Message-Id: <20210927134231.11177-12-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 11/11] net/netvsc: add meson support for FreeBSD 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 Sender: "dev" add meson support for FreeBSD Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/net/netvsc/freebsd/meson.build | 6 ++++++ drivers/net/netvsc/linux/meson.build | 6 ++++++ drivers/net/netvsc/meson.build | 4 ++++ 3 files changed, 16 insertions(+) create mode 100644 drivers/net/netvsc/freebsd/meson.build create mode 100644 drivers/net/netvsc/linux/meson.build diff --git a/drivers/net/netvsc/freebsd/meson.build b/drivers/net/netvsc/freebsd/meson.build new file mode 100644 index 0000000000..78f824f701 --- /dev/null +++ b/drivers/net/netvsc/freebsd/meson.build @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Microsoft Corporation + +sources += files( + 'hn_os.c', +) diff --git a/drivers/net/netvsc/linux/meson.build b/drivers/net/netvsc/linux/meson.build new file mode 100644 index 0000000000..78f824f701 --- /dev/null +++ b/drivers/net/netvsc/linux/meson.build @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Microsoft Corporation + +sources += files( + 'hn_os.c', +) diff --git a/drivers/net/netvsc/meson.build b/drivers/net/netvsc/meson.build index f74b941f65..9dafa8ac23 100644 --- a/drivers/net/netvsc/meson.build +++ b/drivers/net/netvsc/meson.build @@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Microsoft Corporation +includes += include_directories(exec_env) + if is_windows build = false reason = 'not supported on Windows' @@ -18,3 +20,5 @@ sources = files( ) deps += ['bus_vmbus' ] + +subdir(exec_env)