linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Saurabh Sengar <ssengar@linux.microsoft.com>
Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
	decui@microsoft.com, linux-hyperv@vger.kernel.org,
	linux-kernel@vger.kernel.org, ssengar@microsoft.com
Subject: Re: [PATCH 5/6] tools: hv: Add new fcopy application based on uio driver
Date: Mon, 19 Feb 2024 09:53:01 +0100	[thread overview]
Message-ID: <2024021908-royal-sequester-84be@gregkh> (raw)
In-Reply-To: <1708193020-14740-6-git-send-email-ssengar@linux.microsoft.com>

On Sat, Feb 17, 2024 at 10:03:39AM -0800, Saurabh Sengar wrote:
> New fcopy application which utilizes uio_hv_vmbus_client driver

What does this "application" do?

> 
> Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
> ---
>  tools/hv/Build                 |   3 +-
>  tools/hv/Makefile              |  10 +-
>  tools/hv/hv_fcopy_uio_daemon.c | 488 +++++++++++++++++++++++++++++++++
>  3 files changed, 495 insertions(+), 6 deletions(-)
>  create mode 100644 tools/hv/hv_fcopy_uio_daemon.c
> 
> diff --git a/tools/hv/Build b/tools/hv/Build
> index 6cf51fa4b306..7d1f1698069b 100644
> --- a/tools/hv/Build
> +++ b/tools/hv/Build
> @@ -1,3 +1,4 @@
>  hv_kvp_daemon-y += hv_kvp_daemon.o
>  hv_vss_daemon-y += hv_vss_daemon.o
> -hv_fcopy_daemon-y += hv_fcopy_daemon.o
> +hv_fcopy_uio_daemon-y += hv_fcopy_uio_daemon.o
> +hv_fcopy_uio_daemon-y += vmbus_bufring.o
> diff --git a/tools/hv/Makefile b/tools/hv/Makefile
> index fe770e679ae8..944180cf916e 100644
> --- a/tools/hv/Makefile
> +++ b/tools/hv/Makefile
> @@ -17,7 +17,7 @@ MAKEFLAGS += -r
>  
>  override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
>  
> -ALL_TARGETS := hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
> +ALL_TARGETS := hv_kvp_daemon hv_vss_daemon hv_fcopy_uio_daemon
>  ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
>  
>  ALL_SCRIPTS := hv_get_dhcp_info.sh hv_get_dns_info.sh hv_set_ifconfig.sh
> @@ -39,10 +39,10 @@ $(HV_VSS_DAEMON_IN): FORCE
>  $(OUTPUT)hv_vss_daemon: $(HV_VSS_DAEMON_IN)
>  	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
>  
> -HV_FCOPY_DAEMON_IN := $(OUTPUT)hv_fcopy_daemon-in.o
> -$(HV_FCOPY_DAEMON_IN): FORCE
> -	$(Q)$(MAKE) $(build)=hv_fcopy_daemon
> -$(OUTPUT)hv_fcopy_daemon: $(HV_FCOPY_DAEMON_IN)
> +HV_FCOPY_UIO_DAEMON_IN := $(OUTPUT)hv_fcopy_uio_daemon-in.o
> +$(HV_FCOPY_UIO_DAEMON_IN): FORCE
> +	$(Q)$(MAKE) $(build)=hv_fcopy_uio_daemon
> +$(OUTPUT)hv_fcopy_uio_daemon: $(HV_FCOPY_UIO_DAEMON_IN)
>  	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
>  
>  clean:
> diff --git a/tools/hv/hv_fcopy_uio_daemon.c b/tools/hv/hv_fcopy_uio_daemon.c
> new file mode 100644
> index 000000000000..f72c899328fc
> --- /dev/null
> +++ b/tools/hv/hv_fcopy_uio_daemon.c
> @@ -0,0 +1,488 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * An implementation of host to guest copy functionality for Linux.

host to guest of what?  I think it's a specific type of host and guest,
right?

> + *
> + * Copyright (C) 2023, Microsoft, Inc.
> + *
> + * Author : K. Y. Srinivasan <kys@microsoft.com>
> + * Author : Saurabh Sengar <ssengar@microsoft.com>
> + *
> + */
> +
> +#include <dirent.h>
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <getopt.h>
> +#include <locale.h>
> +#include <stdbool.h>
> +#include <stddef.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <syslog.h>
> +#include <unistd.h>
> +#include <wchar.h>
> +#include <sys/stat.h>
> +#include <linux/hyperv.h>
> +#include <linux/limits.h>
> +#include "vmbus_bufring.h"
> +
> +#define ICMSGTYPE_NEGOTIATE	0
> +#define ICMSGTYPE_FCOPY		7
> +
> +#define WIN8_SRV_MAJOR		1
> +#define WIN8_SRV_MINOR		1
> +#define WIN8_SRV_VERSION	(WIN8_SRV_MAJOR << 16 | WIN8_SRV_MINOR)
> +
> +#define MAX_FOLDER_NAME		15
> +#define MAX_PATH_LEN		15
> +#define FCOPY_UIO		"/sys/bus/vmbus/devices/eb765408-105f-49b6-b4aa-c123b64d17d4/uio"
> +
> +#define FCOPY_VER_COUNT		1
> +static const int fcopy_versions[] = {
> +	WIN8_SRV_VERSION
> +};
> +
> +#define FW_VER_COUNT		1
> +static const int fw_versions[] = {
> +	UTIL_FW_VERSION
> +};
> +
> +#define HV_RING_SIZE		(4 * 4096)

Hey, that doesn't match the kernel driver!  Why these values?


> +
> +unsigned char desc[HV_RING_SIZE];
> +
> +static int target_fd;
> +static char target_fname[PATH_MAX];
> +static unsigned long long filesize;
> +
> +static int hv_fcopy_create_file(char *file_name, char *path_name, __u32 flags)
> +{
> +	int error = HV_E_FAIL;
> +	char *q, *p;
> +
> +	filesize = 0;
> +	p = (char *)path_name;

Why the unneeded cast?

> +	snprintf(target_fname, sizeof(target_fname), "%s/%s",
> +		 (char *)path_name, (char *)file_name);

Again, why all of the unneeded casts?  This feels very odd, so I've
stopped reading here, perhaps get an internal review first before
sending this out again?

thanks,

greg k-h

  reply	other threads:[~2024-02-19  8:53 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-17 18:03 [PATCH 0/6] Low speed Hyper-V devices support Saurabh Sengar
2024-02-17 18:03 ` [PATCH 1/6] Drivers: hv: vmbus: Add utility function for querying ring size Saurabh Sengar
2024-02-18  7:11   ` Greg KH
2024-02-18  8:03     ` Saurabh Singh Sengar
2024-02-18  9:11       ` Greg KH
2024-03-12 20:57   ` Long Li
2024-02-17 18:03 ` [PATCH 2/6] uio_hv_generic: Query the ringbuffer size for device Saurabh Sengar
2024-02-19  8:50   ` Greg KH
2024-02-19  9:40     ` Saurabh Singh Sengar
2024-02-19 10:02       ` Greg KH
2024-02-19 10:21         ` Saurabh Singh Sengar
2024-02-17 18:03 ` [PATCH 3/6] uio_hv_generic: Enable interrupt for low speed VMBus devices Saurabh Sengar
2024-03-12 20:59   ` Long Li
2024-02-17 18:03 ` [PATCH 4/6] tools: hv: Add vmbus_bufring Saurabh Sengar
2024-03-13 19:12   ` Long Li
2024-02-17 18:03 ` [PATCH 5/6] tools: hv: Add new fcopy application based on uio driver Saurabh Sengar
2024-02-19  8:53   ` Greg KH [this message]
2024-02-19  9:24     ` Saurabh Singh Sengar
2024-02-19  9:52       ` Greg KH
2024-02-19 10:23         ` Saurabh Singh Sengar
2024-03-13 19:23   ` Long Li
2024-02-17 18:03 ` [PATCH 6/6] Drivers: hv: Remove fcopy driver Saurabh Sengar
2024-03-13 19:25   ` Long Li
2024-02-18  7:10 ` [PATCH 0/6] Low speed Hyper-V devices support Greg KH
2024-02-18  7:51   ` Saurabh Singh Sengar
2024-02-18  9:09     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2024021908-royal-sequester-84be@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ssengar@linux.microsoft.com \
    --cc=ssengar@microsoft.com \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).