From: Veerasenareddy Burru <vburru@marvell.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<lironh@marvell.com>, <aayarekar@marvell.com>,
<sedara@marvell.com>, <sburla@marvell.com>
Cc: <linux-doc@vger.kernel.org>,
Veerasenareddy Burru <vburru@marvell.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Jonathan Corbet" <corbet@lwn.net>, Andrew Lunn <andrew@lunn.ch>,
Lorenzo Bianconi <lorenzo@kernel.org>
Subject: [PATCH net-next 5/8] octeon_ep_vf: add support for ndo ops
Date: Tue, 8 Nov 2022 12:41:56 -0800 [thread overview]
Message-ID: <20221108204209.23071-6-vburru@marvell.com> (raw)
In-Reply-To: <20221108204209.23071-1-vburru@marvell.com>
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: Veerasenareddy Burru <vburru@marvell.com>
Signed-off-by: Sathesh Edara <sedara@marvell.com>
Signed-off-by: Satananda Burla <sburla@marvell.com>
---
.../marvell/octeon_ep_vf/octep_vf_main.c | 93 +++++++++++++++++++
1 file changed, 93 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 9d1fc867bf5d..d788846b12e7 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
@@ -183,6 +183,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;
@@ -196,6 +213,42 @@ 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;
+ }
+}
+
/**
* octep_vf_tx_timeout_task - work queue task to Handle Tx queue timeout.
*
@@ -234,11 +287,51 @@ static void octep_vf_tx_timeout(struct net_device *netdev, unsigned int txqueue)
queue_work(octep_vf_wq, &oct->tx_timeout_task);
}
+static int octep_vf_set_mac(struct net_device *netdev, void *p)
+{
+ struct octep_vf_device *oct = netdev_priv(netdev);
+ struct sockaddr *addr = (struct sockaddr *)p;
+ int err;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
+ err = octep_vf_mbox_set_mac_addr(oct, addr->sa_data);
+ if (err)
+ return err;
+
+ memcpy(oct->mac_addr, addr->sa_data, ETH_ALEN);
+ eth_hw_addr_set(netdev, addr->sa_data);
+
+ return 0;
+}
+
+static int octep_vf_change_mtu(struct net_device *netdev, int new_mtu)
+{
+ struct octep_vf_device *oct = netdev_priv(netdev);
+ struct octep_vf_iface_link_info *link_info;
+ int err;
+
+ link_info = &oct->link_info;
+ if (link_info->mtu == new_mtu)
+ return 0;
+
+ err = octep_vf_mbox_set_mtu(oct, new_mtu);
+ if (!err) {
+ oct->link_info.mtu = new_mtu;
+ netdev->mtu = new_mtu;
+ }
+ return err;
+}
+
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,
};
static const char *octep_vf_devid_to_str(struct octep_vf_device *oct)
--
2.36.0
next prev parent reply other threads:[~2022-11-08 20:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 20:41 [PATCH net-next 0/8] Add octeon_ep_vf driver Veerasenareddy Burru
2022-11-08 20:41 ` [PATCH net-next 1/8] octeon_ep_vf: Add driver framework and device initialization Veerasenareddy Burru
2022-11-09 16:02 ` kernel test robot
2022-11-10 2:47 ` Bagas Sanjaya
2022-11-08 20:41 ` [PATCH net-next 2/8] octeon_ep_vf: add hardware configuration APIs Veerasenareddy Burru
2022-11-08 20:41 ` [PATCH net-next 3/8] octeon_ep_vf: add VF-PF mailbox communication Veerasenareddy Burru
2022-11-08 20:41 ` [PATCH net-next 4/8] octeon_ep_vf: add Tx/Rx ring resource setup and cleanup Veerasenareddy Burru
2022-11-08 20:41 ` Veerasenareddy Burru [this message]
2022-11-08 20:41 ` [PATCH net-next 6/8] octeon_ep_vf: add Tx/Rx processing and interrupt support Veerasenareddy Burru
2022-11-08 20:41 ` [PATCH net-next 7/8] octeon_ep_vf: add ethtool support Veerasenareddy Burru
2022-11-08 20:41 ` [PATCH net-next 8/8] octeon_ep_vf: update MAINTAINERS Veerasenareddy Burru
2022-11-10 10:07 ` [PATCH net-next 0/8] Add octeon_ep_vf driver Leon Romanovsky
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=20221108204209.23071-6-vburru@marvell.com \
--to=vburru@marvell.com \
--cc=aayarekar@marvell.com \
--cc=andrew@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lironh@marvell.com \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sburla@marvell.com \
--cc=sedara@marvell.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: 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
all inboxes | Powered by JetHome®