[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BY5PR12MB432293F4F99B09F370085925DCB69@BY5PR12MB4322.namprd12.prod.outlook.com>
Date: Mon, 1 Feb 2021 20:42:48 +0000
From: Parav Pandit <parav@...dia.com>
To: David Ahern <dsahern@...il.com>,
"stephen@...workplumber.org" <stephen@...workplumber.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: Jiri Pirko <jiri@...dia.com>
Subject: RE: [PATCH iproute2-next 3/5] devlink: Supporting add and delete of
devlink port
> From: David Ahern <dsahern@...il.com>
> Sent: Sunday, January 31, 2021 10:56 PM
>
> 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.
Yep. Doing it in v2. Added utils routine for it.
Few more functions will benefit from this helper routine post this series.
Powered by blists - more mailing lists