netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Parav Pandit <parav@nvidia.com>,
	stephen@networkplumber.org, netdev@vger.kernel.org
Cc: Jiri Pirko <jiri@nvidia.com>
Subject: Re: [PATCH iproute2-next 3/5] devlink: Supporting add and delete of devlink port
Date: Sun, 31 Jan 2021 10:26:22 -0700	[thread overview]
Message-ID: <81d8561c-a9a2-f61f-6e84-414779147e60@gmail.com> (raw)
In-Reply-To: <20210129165608.134965-4-parav@nvidia.com>

On 1/29/21 9:56 AM, Parav Pandit wrote:
> @@ -1383,6 +1389,37 @@ static int reload_limit_get(struct dl *dl, const char *limitstr,
>  	return 0;
>  }
>  
> +static int port_flavour_parse(const char *flavour, uint16_t *value)
> +{
> +	if (!flavour)
> +		return -EINVAL;
> +
> +	if (strcmp(flavour, "physical") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_PHYSICAL;
> +		return 0;
> +	} else if (strcmp(flavour, "cpu") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_CPU;
> +		return 0;
> +	} else if (strcmp(flavour, "dsa") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_DSA;
> +		return 0;
> +	} else if (strcmp(flavour, "pcipf") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_PCI_PF;
> +		return 0;
> +	} else if (strcmp(flavour, "pcivf") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_PCI_VF;
> +		return 0;
> +	} else if (strcmp(flavour, "pcisf") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_PCI_SF;
> +		return 0;
> +	} else if (strcmp(flavour, "virtual") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_VIRTUAL;
> +		return 0;
> +	} else {
> +		return -EINVAL;
> +	}
> +}
use a struct for the string - value conversions; that should have been
done for port_flavour_name so it can be refactored to use that kind of
relationship. This function is just the inverse of it.

  reply	other threads:[~2021-01-31 20:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-29 16:56 [PATCH iproute2-next 0/5] Support devlink port add delete Parav Pandit
2021-01-29 16:56 ` [PATCH iproute2-next 1/5] devlink: Update kernel headers Parav Pandit
2021-01-29 16:56 ` [PATCH iproute2-next 2/5] devlink: Introduce PCI SF port flavour and attribute Parav Pandit
2021-01-29 16:56 ` [PATCH iproute2-next 3/5] devlink: Supporting add and delete of devlink port Parav Pandit
2021-01-31 17:26   ` David Ahern [this message]
2021-02-01 20:42     ` Parav Pandit
2021-01-29 16:56 ` [PATCH iproute2-next 4/5] devlink: Support get port function state Parav Pandit
2021-01-29 16:56 ` [PATCH iproute2-next 5/5] devlink: Support set of " Parav Pandit
2021-01-31 17:30   ` David Ahern
2021-02-01 20:50     ` Parav Pandit
2021-02-01 21:35 ` [PATCH iproute2-next v2 0/6] Support devlink port add delete Parav Pandit
2021-02-01 21:35   ` [PATCH iproute2-next v2 1/6] devlink: Update kernel headers Parav Pandit
2021-02-01 21:35   ` [PATCH iproute2-next v2 2/6] devlink: Introduce and use string to number mapper Parav Pandit
2021-02-01 21:35   ` [PATCH iproute2-next v2 3/6] devlink: Introduce PCI SF port flavour and attribute Parav Pandit
2021-02-01 21:35   ` [PATCH iproute2-next v2 4/6] devlink: Supporting add and delete of devlink port Parav Pandit
2021-02-01 21:35   ` [PATCH iproute2-next v2 5/6] devlink: Support get port function state Parav Pandit
2021-02-01 21:35   ` [PATCH iproute2-next v2 6/6] devlink: Support set of " Parav Pandit
2021-02-02  3:20   ` [PATCH iproute2-next v2 0/6] Support devlink port add delete David Ahern
2021-02-02  4:01     ` Parav Pandit

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=81d8561c-a9a2-f61f-6e84-414779147e60@gmail.com \
    --to=dsahern@gmail.com \
    --cc=jiri@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=parav@nvidia.com \
    --cc=stephen@networkplumber.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).