Skip to content

Commit 8f8d322

Browse files
shinas-marvelldavem330
authored andcommitted
octeon_ep_vf: add support for ndo ops
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6ca7b54 commit 8f8d322

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,23 @@ static netdev_tx_t octep_vf_start_xmit(struct sk_buff *skb,
187187
return NETDEV_TX_OK;
188188
}
189189

190+
int octep_vf_get_if_stats(struct octep_vf_device *oct)
191+
{
192+
struct octep_vf_iface_rxtx_stats vf_stats;
193+
int ret, size;
194+
195+
memset(&vf_stats, 0, sizeof(struct octep_vf_iface_rxtx_stats));
196+
ret = octep_vf_mbox_bulk_read(oct, OCTEP_PFVF_MBOX_CMD_GET_STATS,
197+
(u8 *)&vf_stats, &size);
198+
if (!ret) {
199+
memcpy(&oct->iface_rx_stats, &vf_stats.iface_rx_stats,
200+
sizeof(struct octep_vf_iface_rx_stats));
201+
memcpy(&oct->iface_tx_stats, &vf_stats.iface_tx_stats,
202+
sizeof(struct octep_vf_iface_tx_stats));
203+
}
204+
return ret;
205+
}
206+
190207
int octep_vf_get_link_info(struct octep_vf_device *oct)
191208
{
192209
int ret, size;
@@ -200,6 +217,42 @@ int octep_vf_get_link_info(struct octep_vf_device *oct)
200217
return 0;
201218
}
202219

220+
/**
221+
* octep_vf_get_stats64() - Get Octeon network device statistics.
222+
*
223+
* @netdev: kernel network device.
224+
* @stats: pointer to stats structure to be filled in.
225+
*/
226+
static void octep_vf_get_stats64(struct net_device *netdev,
227+
struct rtnl_link_stats64 *stats)
228+
{
229+
struct octep_vf_device *oct = netdev_priv(netdev);
230+
u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
231+
int q;
232+
233+
tx_packets = 0;
234+
tx_bytes = 0;
235+
rx_packets = 0;
236+
rx_bytes = 0;
237+
for (q = 0; q < oct->num_oqs; q++) {
238+
struct octep_vf_iq *iq = oct->iq[q];
239+
struct octep_vf_oq *oq = oct->oq[q];
240+
241+
tx_packets += iq->stats.instr_completed;
242+
tx_bytes += iq->stats.bytes_sent;
243+
rx_packets += oq->stats.packets;
244+
rx_bytes += oq->stats.bytes;
245+
}
246+
stats->tx_packets = tx_packets;
247+
stats->tx_bytes = tx_bytes;
248+
stats->rx_packets = rx_packets;
249+
stats->rx_bytes = rx_bytes;
250+
if (!octep_vf_get_if_stats(oct)) {
251+
stats->multicast = oct->iface_rx_stats.mcast_pkts;
252+
stats->rx_errors = oct->iface_rx_stats.err_pkts;
253+
}
254+
}
255+
203256
/**
204257
* octep_vf_tx_timeout_task - work queue task to Handle Tx queue timeout.
205258
*
@@ -312,6 +365,7 @@ static const struct net_device_ops octep_vf_netdev_ops = {
312365
.ndo_open = octep_vf_open,
313366
.ndo_stop = octep_vf_stop,
314367
.ndo_start_xmit = octep_vf_start_xmit,
368+
.ndo_get_stats64 = octep_vf_get_stats64,
315369
.ndo_tx_timeout = octep_vf_tx_timeout,
316370
.ndo_set_mac_address = octep_vf_set_mac,
317371
.ndo_change_mtu = octep_vf_change_mtu,

0 commit comments

Comments
 (0)