lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <55939b65-7a91-84d1-b851-0d30d9938283@kernel.org>
Date:   Tue, 14 Jun 2022 09:07:55 -0600
From:   David Ahern <dsahern@...nel.org>
To:     Eli Cohen <elic@...dia.com>, netdev@...r.kernel.org,
        virtualization@...ts.linux-foundation.org, jasowang@...hat.com,
        si-wei.liu@...cle.com, mst@...hat.com
Subject: Re: [PATCH] vdpa: Add support for reading vdpa device statistics

On 6/1/22 6:10 AM, Eli Cohen wrote:
> diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c
> index 3ae1b78f4cac..3ca3095ed783 100644
> --- a/vdpa/vdpa.c
> +++ b/vdpa/vdpa.c
> @@ -304,6 +320,14 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
>  
>  			NEXT_ARG_FWD();
>  			o_found |= VDPA_OPT_MAX_VQP;
> +		} else if ((matches(*argv, "qidx")  == 0) && (o_optional & VDPA_OPT_QUEUE_INDEX)) {

above line should be wrapped.

Also, please convert all new matches() to strcmp; we are not taking any
new users of matches() api.

> +			NEXT_ARG_FWD();
> +			err = vdpa_argv_u32(vdpa, argc, argv, &opts->queue_idx);
> +			if (err)
> +				return err;
> +
> +			NEXT_ARG_FWD();
> +			o_found |= VDPA_OPT_QUEUE_INDEX;
>  		} else {
>  			fprintf(stderr, "Unknown option \"%s\"\n", *argv);
>  			return -EINVAL;
> @@ -594,6 +618,7 @@ static void cmd_dev_help(void)
>  	fprintf(stderr, "                                                    [ max_vqp MAX_VQ_PAIRS ]\n");
>  	fprintf(stderr, "       vdpa dev del DEV\n");
>  	fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");
> +	fprintf(stderr, "Usage: vdpa dev vstats COMMAND\n");
>  }
>  
>  static const char *device_type_name(uint32_t type)
> @@ -819,6 +844,135 @@ static int cmd_dev_config(struct vdpa *vdpa, int argc, char **argv)
>  	return -ENOENT;
>  }
>  
> +#define MAX_KEY_LEN 200
> +/* 5 bytes for format */
> +#define MAX_FMT_LEN (MAX_KEY_LEN + 5 + 1)
> +
> +static void pr_out_dev_net_vstats(const struct nlmsghdr *nlh)
> +{
> +	const char *name = NULL;
> +	uint64_t features = 0;
> +	char fmt[MAX_FMT_LEN];
> +	uint16_t max_vqp = 0;
> +	bool is_ctrl = false;
> +	struct nlattr *attr;
> +	uint16_t qidx = 0;
> +	uint64_t v64;
> +
> +	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
> +		switch (attr->nla_type) {
> +		case VDPA_ATTR_DEV_NET_CFG_MAX_VQP:
> +			max_vqp = mnl_attr_get_u16(attr);
> +			break;
> +		case VDPA_ATTR_DEV_NEGOTIATED_FEATURES:
> +			features = mnl_attr_get_u64(attr);
> +			break;
> +		case VDPA_ATTR_DEV_QUEUE_INDEX:
> +			qidx = mnl_attr_get_u16(attr);
> +			is_ctrl = features & BIT(VIRTIO_NET_F_CTRL_VQ) && qidx == 2 * max_vqp;
> +			if (!is_ctrl) {
> +				if (qidx & 1)
> +					print_string(PRINT_ANY, "queue_type", "queue_type %s ",
> +						     "tx");
> +				else
> +					print_string(PRINT_ANY, "queue_type", "queue_type %s ",
> +						     "rx");
> +			} else {
> +				print_string(PRINT_ANY, "queue_type", "queue_type %s ",
> +					     "control_vq");
> +			}

the above should be in a helper function to keep line lengths at a
reasonable size.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ