Netdev Archive on lore.kernel.org help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch> To: Ido Schimmel <idosch@idosch.org> Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, jiri@nvidia.com, amcohen@nvidia.com, danieller@nvidia.com, mlxsw@nvidia.com, roopa@nvidia.com, dsahern@gmail.com, f.fainelli@gmail.com, vivien.didelot@gmail.com, saeedm@nvidia.com, tariqt@nvidia.com, ayal@nvidia.com, eranbe@nvidia.com, mkubecek@suse.cz, Ido Schimmel <idosch@nvidia.com> Subject: Re: [RFC PATCH net-next 6/6] mlxsw: spectrum_nve: Expose VXLAN counters via devlink-metric Date: Mon, 17 Aug 2020 16:29:52 +0200 [thread overview] Message-ID: <20200817142952.GC2291654@lunn.ch> (raw) In-Reply-To: <20200817125059.193242-7-idosch@idosch.org> > +static int mlxsw_sp1_nve_vxlan_metrics_init(struct mlxsw_sp *mlxsw_sp) > +{ > + struct mlxsw_sp_nve_metrics *metrics = &mlxsw_sp->nve->metrics; > + struct devlink *devlink = priv_to_devlink(mlxsw_sp->core); > + int err; > + > + err = mlxsw_sp1_nve_vxlan_counters_clear(mlxsw_sp); > + if (err) > + return err; > + > + metrics->counter_encap = > + devlink_metric_counter_create(devlink, "nve_vxlan_encap", > + &mlxsw_sp1_nve_vxlan_encap_ops, > + mlxsw_sp); > + if (IS_ERR(metrics->counter_encap)) > + return PTR_ERR(metrics->counter_encap); > + > + metrics->counter_decap = > + devlink_metric_counter_create(devlink, "nve_vxlan_decap", > + &mlxsw_sp1_nve_vxlan_decap_ops, > + mlxsw_sp); > + if (IS_ERR(metrics->counter_decap)) { > + err = PTR_ERR(metrics->counter_decap); > + goto err_counter_decap; > + } > + > + metrics->counter_decap_errors = > + devlink_metric_counter_create(devlink, "nve_vxlan_decap_errors", > + &mlxsw_sp1_nve_vxlan_decap_errors_ops, > + mlxsw_sp); > + if (IS_ERR(metrics->counter_decap_errors)) { > + err = PTR_ERR(metrics->counter_decap_errors); > + goto err_counter_decap_errors; > + } > + > + metrics->counter_decap_discards = > + devlink_metric_counter_create(devlink, "nve_vxlan_decap_discards", > + &mlxsw_sp1_nve_vxlan_decap_discards_ops, > + mlxsw_sp); > + if (IS_ERR(metrics->counter_decap_discards)) { > + err = PTR_ERR(metrics->counter_decap_discards); > + goto err_counter_decap_discards; > + } > + > + return 0; Looking at this, i wonder about the scalability of this API. With just 4 counters it looks pretty ugly. What about 50 counters? Maybe move the name into the ops structure. Then add a call devlink_metric_counters_create() where you can pass an array and array size of op structures? There are plenty of other examples in the kernel, e.g. sysfs groups, hwmon, etc. where you register a large bunch of things with the core with a single call. > +static void mlxsw_sp1_nve_vxlan_metrics_fini(struct mlxsw_sp *mlxsw_sp) > +{ > + struct mlxsw_sp_nve_metrics *metrics = &mlxsw_sp->nve->metrics; > + struct devlink *devlink = priv_to_devlink(mlxsw_sp->core); > + > + devlink_metric_destroy(devlink, metrics->counter_decap_discards); > + devlink_metric_destroy(devlink, metrics->counter_decap_errors); > + devlink_metric_destroy(devlink, metrics->counter_decap); > + devlink_metric_destroy(devlink, metrics->counter_encap); > +} I guess the most frequent use case is to remove all counters, e.g. driver unload, or when probe fails. So maybe provide a devlink_metric_destroy_all(devlink) ? Andrew
next prev parent reply other threads:[~2020-08-17 14:30 UTC|newest] Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-17 12:50 [RFC PATCH net-next 0/6] devlink: Add device metric support Ido Schimmel 2020-08-17 12:50 ` [RFC PATCH net-next 1/6] devlink: Add device metric infrastructure Ido Schimmel 2020-08-17 14:12 ` Andrew Lunn 2020-08-17 12:50 ` [RFC PATCH net-next 2/6] netdevsim: Add devlink metric support Ido Schimmel 2020-08-17 12:50 ` [RFC PATCH net-next 3/6] selftests: netdevsim: Add devlink metric tests Ido Schimmel 2020-08-17 12:50 ` [RFC PATCH net-next 4/6] mlxsw: reg: Add Tunneling NVE Counters Register Ido Schimmel 2020-08-17 12:50 ` [RFC PATCH net-next 5/6] mlxsw: reg: Add Tunneling NVE Counters Register Version 2 Ido Schimmel 2020-08-17 12:50 ` [RFC PATCH net-next 6/6] mlxsw: spectrum_nve: Expose VXLAN counters via devlink-metric Ido Schimmel 2020-08-17 14:29 ` Andrew Lunn [this message] 2020-08-18 6:59 ` Ido Schimmel 2020-08-19 0:24 ` [RFC PATCH net-next 0/6] devlink: Add device metric support Jakub Kicinski 2020-08-19 2:43 ` David Ahern 2020-08-19 3:35 ` Jakub Kicinski 2020-08-19 4:30 ` Florian Fainelli 2020-08-19 16:18 ` Jakub Kicinski 2020-08-19 17:20 ` Florian Fainelli 2020-08-19 18:07 ` Jakub Kicinski 2020-08-20 14:35 ` David Ahern 2020-08-20 16:09 ` Jakub Kicinski 2020-08-21 10:30 ` Ido Schimmel 2020-08-21 16:53 ` Jakub Kicinski 2020-08-21 19:12 ` David Ahern 2020-08-21 23:50 ` Jakub Kicinski 2020-08-21 23:59 ` David Ahern 2020-08-22 0:37 ` Jakub Kicinski 2020-08-22 1:18 ` David Ahern 2020-08-22 16:27 ` Jakub Kicinski 2020-08-23 7:04 ` Ido Schimmel 2020-08-24 19:11 ` Jakub Kicinski
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=20200817142952.GC2291654@lunn.ch \ --to=andrew@lunn.ch \ --cc=amcohen@nvidia.com \ --cc=ayal@nvidia.com \ --cc=danieller@nvidia.com \ --cc=davem@davemloft.net \ --cc=dsahern@gmail.com \ --cc=eranbe@nvidia.com \ --cc=f.fainelli@gmail.com \ --cc=idosch@idosch.org \ --cc=idosch@nvidia.com \ --cc=jiri@nvidia.com \ --cc=kuba@kernel.org \ --cc=mkubecek@suse.cz \ --cc=mlxsw@nvidia.com \ --cc=netdev@vger.kernel.org \ --cc=roopa@nvidia.com \ --cc=saeedm@nvidia.com \ --cc=tariqt@nvidia.com \ --cc=vivien.didelot@gmail.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: linkBe 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).