> From: David Ahern <dsah...@gmail.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.