All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: David Awogbemila <awogbemila@google.com>
Cc: Catherine Sullivan <csully@google.com>,
	Yangchun Fu <yangchun@google.com>
Subject: Re: [PATCH net-next v3 1/4] gve: Add support for raw addressing device option
Date: Thu, 24 Sep 2020 16:03:35 -0700	[thread overview]
Message-ID: <20200924160335.003bdab0@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20200924010104.3196839-2-awogbemila@google.com>

On Wed, 23 Sep 2020 18:01:01 -0700 David Awogbemila wrote:
> @@ -518,6 +521,49 @@ int gve_adminq_describe_device(struct gve_priv *priv)
>  		priv->rx_desc_cnt = priv->rx_pages_per_qpl;
>  	}
>  	priv->default_num_queues = be16_to_cpu(descriptor->default_num_queues);
> +	dev_opt = (void *)(descriptor + 1);
> +
> +	num_options = be16_to_cpu(descriptor->num_device_options);
> +	for (i = 0; i < num_options; i++) {
> +		u16 option_length = be16_to_cpu(dev_opt->option_length);
> +		u16 option_id = be16_to_cpu(dev_opt->option_id);
> +
> +		if ((void *)dev_opt + sizeof(*dev_opt) + option_length > (void *)descriptor +
> +				      be16_to_cpu(descriptor->total_length)) {

Can you calculate an void *end pointer before the loop and avoid this
very long condition?

> +			dev_err(&priv->dev->dev,
> +				"options exceed device_descriptor's total length.\n");
> +			err = -EINVAL;
> +			goto free_device_descriptor;
> +		}
> +
> +		switch (option_id) {
> +		case GVE_DEV_OPT_ID_RAW_ADDRESSING:
> +			/* If the length or feature mask doesn't match,
> +			 * continue without enabling the feature.
> +			 */
> +			if (option_length != GVE_DEV_OPT_LEN_RAW_ADDRESSING ||
> +			    be32_to_cpu(dev_opt->feat_mask) !=
> +			    GVE_DEV_OPT_FEAT_MASK_RAW_ADDRESSING) {

Apply the byteswap to the constant so it's done at compilation time.

> +				dev_info(&priv->pdev->dev,
> +					 "Raw addressing device option not enabled, length or features mask did not match expected.\n");

dev_warn(), also do yourself a favor and print what the values were.

> +				priv->raw_addressing = false;
> +			} else {
> +				dev_info(&priv->pdev->dev,
> +					 "Raw addressing device option enabled.\n");
> +				priv->raw_addressing = true;

Does this really need to be printed on every boot?

> +			}
> +			break;
> +		default:
> +			/* If we don't recognize the option just continue
> +			 * without doing anything.
> +			 */
> +			dev_info(&priv->pdev->dev,
> +				 "Unrecognized device option 0x%hx not enabled.\n",

dev_dbg()

> +				   option_id);

alignment is off

> +			break;
> +		}
> +		dev_opt = (void *)dev_opt + sizeof(*dev_opt) + option_length;
> +	}

  reply	other threads:[~2020-09-24 23:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-24  1:01 [PATCH net-next v3 0/4] GVE Raw Addressing David Awogbemila
2020-09-24  1:01 ` [PATCH net-next v3 1/4] gve: Add support for raw addressing device option David Awogbemila
2020-09-24 23:03   ` Jakub Kicinski [this message]
2020-09-24  1:01 ` [PATCH net-next v3 2/4] gve: Add support for raw addressing to the rx path David Awogbemila
2020-09-24  1:01 ` [PATCH net-next v3 3/4] gve: Rx Buffer Recycling David Awogbemila
2020-09-24 23:00   ` Jakub Kicinski
2020-09-30 16:10     ` David Awogbemila
2020-09-30 21:23       ` Jakub Kicinski
2020-09-24  1:01 ` [PATCH net-next v3 4/4] gve: Add support for raw addressing in the tx path David Awogbemila
2020-09-24 22:51   ` Jakub Kicinski
2020-09-30 16:09     ` David Awogbemila
2020-09-30 21:24       ` Jakub Kicinski
2020-10-02  9:54   ` kernel test robot
2020-10-02  9:54     ` kernel test robot

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=20200924160335.003bdab0@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=awogbemila@google.com \
    --cc=csully@google.com \
    --cc=yangchun@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.