diff mbox series

[net-next,v6,5/8] octeon_ep_vf: add support for ndo ops

Message ID 20240207065207.3092004-6-srasheed@marvell.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series add octeon_ep_vf driver | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 1065 this patch: 1065
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1065 this patch: 1065
netdev/checkpatch warning WARNING: line length of 85 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-02-07--18-00 (tests: 772)

Commit Message

Shinas Rasheed Feb. 7, 2024, 6:52 a.m. UTC
Add support for ndo ops to set MAC address, change MTU, get stats.
Add control path support to set MAC address, change MTU, get stats,
set speed, get and set link mode.

Signed-off-by: Shinas Rasheed <srasheed@marvell.com>
---
V6:
  - No changes

V5: https://lore.kernel.org/all/20240129050254.3047778-6-srasheed@marvell.com/
  - No changes

V4: https://lore.kernel.org/all/20240108124213.2966536-6-srasheed@marvell.com/
  - Provide more stats in ndo_get_stats64 such as tx_dropped, rx_dropped
    etc.

V3: https://lore.kernel.org/all/20240105203823.2953604-6-srasheed@marvell.com/
  - No changes

V2: https://lore.kernel.org/all/20231223134000.2906144-6-srasheed@marvell.com/
  - No changes

V1: https://lore.kernel.org/all/20231221092844.2885872-6-srasheed@marvell.com/

 .../marvell/octeon_ep_vf/octep_vf_main.c      | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)

Comments

Kalesh Anakkur Purayil Feb. 7, 2024, 8:09 a.m. UTC | #1
On Wed, Feb 7, 2024 at 12:23 PM Shinas Rasheed <srasheed@marvell.com> wrote:

> Add support for ndo ops to set MAC address, change MTU, get stats.
> Add control path support to set MAC address, change MTU, get stats,
> set speed, get and set link mode.
>
[Kalesh]: You are adding support for only one ndo hook ".ndo_get_stats64"
in this patch. Am I missing something?

>
> Signed-off-by: Shinas Rasheed <srasheed@marvell.com>
> ---
> V6:
>   - No changes
>
> V5:
> https://lore.kernel.org/all/20240129050254.3047778-6-srasheed@marvell.com/
>   - No changes
>
> V4:
> https://lore.kernel.org/all/20240108124213.2966536-6-srasheed@marvell.com/
>   - Provide more stats in ndo_get_stats64 such as tx_dropped, rx_dropped
>     etc.
>
> V3:
> https://lore.kernel.org/all/20240105203823.2953604-6-srasheed@marvell.com/
>   - No changes
>
> V2:
> https://lore.kernel.org/all/20231223134000.2906144-6-srasheed@marvell.com/
>   - No changes
>
> V1:
> https://lore.kernel.org/all/20231221092844.2885872-6-srasheed@marvell.com/
>
>  .../marvell/octeon_ep_vf/octep_vf_main.c      | 58 +++++++++++++++++++
>  1 file changed, 58 insertions(+)
>
> diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c
> b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c
> index 562beed9af6a..ff879b1e846e 100644
> --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c
> +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c
> @@ -186,6 +186,23 @@ static netdev_tx_t octep_vf_start_xmit(struct sk_buff
> *skb,
>         return NETDEV_TX_OK;
>  }
>
> +int octep_vf_get_if_stats(struct octep_vf_device *oct)
>
[Kalesh]: You may want to make this function static.

> +{
> +       struct octep_vf_iface_rxtx_stats vf_stats;
> +       int ret, size;
> +
> +       memset(&vf_stats, 0, sizeof(struct octep_vf_iface_rxtx_stats));
>
[Kalesh]: You can avoid memset by initializing vf_stats = {};

> +       ret = octep_vf_mbox_bulk_read(oct, OCTEP_PFVF_MBOX_CMD_GET_STATS,
> +                                     (u8 *)&vf_stats, &size);
> +       if (!ret) {
>
[Kalesh] For better alignment:
if (ret)
     return ret;

> +               memcpy(&oct->iface_rx_stats, &vf_stats.iface_rx_stats,
> +                      sizeof(struct octep_vf_iface_rx_stats));
> +               memcpy(&oct->iface_tx_stats, &vf_stats.iface_tx_stats,
> +                      sizeof(struct octep_vf_iface_tx_stats));
> +       }
> +       return ret;
> +}
> +
>  int octep_vf_get_link_info(struct octep_vf_device *oct)
>  {
>         int ret, size;
> @@ -199,6 +216,46 @@ int octep_vf_get_link_info(struct octep_vf_device
> *oct)
>         return 0;
>  }
>
> +/**
> + * octep_vf_get_stats64() - Get Octeon network device statistics.
> + *
> + * @netdev: kernel network device.
> + * @stats: pointer to stats structure to be filled in.
> + */
> +static void octep_vf_get_stats64(struct net_device *netdev,
> +                                struct rtnl_link_stats64 *stats)
> +{
> +       struct octep_vf_device *oct = netdev_priv(netdev);
> +       u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
> +       int q;
> +
> +       tx_packets = 0;
> +       tx_bytes = 0;
> +       rx_packets = 0;
> +       rx_bytes = 0;
> +       for (q = 0; q < oct->num_oqs; q++) {
> +               struct octep_vf_iq *iq = oct->iq[q];
> +               struct octep_vf_oq *oq = oct->oq[q];
> +
> +               tx_packets += iq->stats.instr_completed;
> +               tx_bytes += iq->stats.bytes_sent;
> +               rx_packets += oq->stats.packets;
> +               rx_bytes += oq->stats.bytes;
> +       }
> +       stats->tx_packets = tx_packets;
> +       stats->tx_bytes = tx_bytes;
> +       stats->rx_packets = rx_packets;
> +       stats->rx_bytes = rx_bytes;
> +       if (!octep_vf_get_if_stats(oct)) {
> +               stats->multicast = oct->iface_rx_stats.mcast_pkts;
> +               stats->rx_errors = oct->iface_rx_stats.err_pkts;
> +               stats->rx_dropped =
> oct->iface_rx_stats.dropped_pkts_fifo_full +
> +                                   oct->iface_rx_stats.err_pkts;
> +               stats->rx_missed_errors =
> oct->iface_rx_stats.dropped_pkts_fifo_full;
> +               stats->tx_dropped = oct->iface_tx_stats.dropped;
> +       }
> +}
> +
>  /**
>   * octep_vf_tx_timeout_task - work queue task to Handle Tx queue timeout.
>   *
> @@ -313,6 +370,7 @@ static const struct net_device_ops octep_vf_netdev_ops
> = {
>         .ndo_open                = octep_vf_open,
>         .ndo_stop                = octep_vf_stop,
>         .ndo_start_xmit          = octep_vf_start_xmit,
> +       .ndo_get_stats64         = octep_vf_get_stats64,
>         .ndo_tx_timeout          = octep_vf_tx_timeout,
>         .ndo_set_mac_address     = octep_vf_set_mac,
>         .ndo_change_mtu          = octep_vf_change_mtu,
> --
> 2.25.1
>
>
>
Shinas Rasheed Feb. 8, 2024, 6:54 a.m. UTC | #2
Hi Kalesh,

From: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com> 
Sent: Wednesday, February 7, 2024 1:40 PM
To: Shinas Rasheed <srasheed@marvell.com>
Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Haseeb Gani <hgani@marvell.com>; Vimlesh Kumar <vimleshk@marvell.com>; Sathesh B Edara <sedara@marvell.com>; egallen@redhat.com; mschmidt@redhat.com; pabeni@redhat.com; kuba@kernel.org; horms@kernel.org; wizhao@redhat.com; kheib@redhat.com; konguyen@redhat.com; Veerasenareddy Burru <vburru@marvell.com>; Satananda Burla <sburla@marvell.com>; David S. Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>
Subject: [EXT] Re: [PATCH net-next v6 5/8] octeon_ep_vf: add support for ndo ops


On Wed, Feb 7, 2024 at 12:23 PM Shinas Rasheed <mailto:srasheed@marvell.com> wrote:
Add support for ndo ops to set MAC address, change MTU, get stats.
Add control path support to set MAC address, change MTU, get stats,
set speed, get and set link mode.
[Kalesh]: You are adding support for only one ndo hook ".ndo_get_stats64" in this patch. Am I missing something?

I think the patches got separated. The mtu, mac changes got put in an earlier patch. I'll fix it.
Shinas Rasheed Feb. 8, 2024, 7:52 a.m. UTC | #3
From: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com> 
Sent: Wednesday, February 7, 2024 1:40 PM
To: Shinas Rasheed <srasheed@marvell.com>
Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Haseeb Gani <hgani@marvell.com>; Vimlesh Kumar <vimleshk@marvell.com>; Sathesh B Edara <sedara@marvell.com>; egallen@redhat.com; mschmidt@redhat.com; pabeni@redhat.com; kuba@kernel.org; horms@kernel.org; wizhao@redhat.com; kheib@redhat.com; konguyen@redhat.com; Veerasenareddy Burru <vburru@marvell.com>; Satananda Burla <sburla@marvell.com>; David S. Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>
Subject: [EXT] Re: [PATCH net-next v6 5/8] octeon_ep_vf: add support for ndo ops

On Wed, Feb 7, 2024 at 12:23 PM Shinas Rasheed <mailto:srasheed@marvell.com> wrote:
Add support for ndo ops to set MAC address, change MTU, get stats.
Add control path support to set MAC address, change MTU, get stats,
set speed, get and set link mode.
[Kalesh]: You are adding support for only one ndo hook ".ndo_get_stats64" in this patch. Am I missing something?

Signed-off-by: Shinas Rasheed <mailto:srasheed@marvell.com>

+int octep_vf_get_if_stats(struct octep_vf_device *oct)
[Kalesh]: You may want to make this function static. 

This is an interface api which is used in patch [7/8]

+{
+       struct octep_vf_iface_rxtx_stats vf_stats;
+       int ret, size;
+
+       memset(&vf_stats, 0, sizeof(struct octep_vf_iface_rxtx_stats));
[Kalesh]: You can avoid memset by initializing vf_stats = {}; 
+       ret = octep_vf_mbox_bulk_read(oct, OCTEP_PFVF_MBOX_CMD_GET_STATS,
+                                     (u8 *)&vf_stats, &size);
+       if (!ret) {
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c
index 562beed9af6a..ff879b1e846e 100644
--- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c
+++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c
@@ -186,6 +186,23 @@  static netdev_tx_t octep_vf_start_xmit(struct sk_buff *skb,
 	return NETDEV_TX_OK;
 }
 
+int octep_vf_get_if_stats(struct octep_vf_device *oct)
+{
+	struct octep_vf_iface_rxtx_stats vf_stats;
+	int ret, size;
+
+	memset(&vf_stats, 0, sizeof(struct octep_vf_iface_rxtx_stats));
+	ret = octep_vf_mbox_bulk_read(oct, OCTEP_PFVF_MBOX_CMD_GET_STATS,
+				      (u8 *)&vf_stats, &size);
+	if (!ret) {
+		memcpy(&oct->iface_rx_stats, &vf_stats.iface_rx_stats,
+		       sizeof(struct octep_vf_iface_rx_stats));
+		memcpy(&oct->iface_tx_stats, &vf_stats.iface_tx_stats,
+		       sizeof(struct octep_vf_iface_tx_stats));
+	}
+	return ret;
+}
+
 int octep_vf_get_link_info(struct octep_vf_device *oct)
 {
 	int ret, size;
@@ -199,6 +216,46 @@  int octep_vf_get_link_info(struct octep_vf_device *oct)
 	return 0;
 }
 
+/**
+ * octep_vf_get_stats64() - Get Octeon network device statistics.
+ *
+ * @netdev: kernel network device.
+ * @stats: pointer to stats structure to be filled in.
+ */
+static void octep_vf_get_stats64(struct net_device *netdev,
+				 struct rtnl_link_stats64 *stats)
+{
+	struct octep_vf_device *oct = netdev_priv(netdev);
+	u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
+	int q;
+
+	tx_packets = 0;
+	tx_bytes = 0;
+	rx_packets = 0;
+	rx_bytes = 0;
+	for (q = 0; q < oct->num_oqs; q++) {
+		struct octep_vf_iq *iq = oct->iq[q];
+		struct octep_vf_oq *oq = oct->oq[q];
+
+		tx_packets += iq->stats.instr_completed;
+		tx_bytes += iq->stats.bytes_sent;
+		rx_packets += oq->stats.packets;
+		rx_bytes += oq->stats.bytes;
+	}
+	stats->tx_packets = tx_packets;
+	stats->tx_bytes = tx_bytes;
+	stats->rx_packets = rx_packets;
+	stats->rx_bytes = rx_bytes;
+	if (!octep_vf_get_if_stats(oct)) {
+		stats->multicast = oct->iface_rx_stats.mcast_pkts;
+		stats->rx_errors = oct->iface_rx_stats.err_pkts;
+		stats->rx_dropped = oct->iface_rx_stats.dropped_pkts_fifo_full +
+				    oct->iface_rx_stats.err_pkts;
+		stats->rx_missed_errors = oct->iface_rx_stats.dropped_pkts_fifo_full;
+		stats->tx_dropped = oct->iface_tx_stats.dropped;
+	}
+}
+
 /**
  * octep_vf_tx_timeout_task - work queue task to Handle Tx queue timeout.
  *
@@ -313,6 +370,7 @@  static const struct net_device_ops octep_vf_netdev_ops = {
 	.ndo_open                = octep_vf_open,
 	.ndo_stop                = octep_vf_stop,
 	.ndo_start_xmit          = octep_vf_start_xmit,
+	.ndo_get_stats64         = octep_vf_get_stats64,
 	.ndo_tx_timeout          = octep_vf_tx_timeout,
 	.ndo_set_mac_address     = octep_vf_set_mac,
 	.ndo_change_mtu          = octep_vf_change_mtu,