Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2)  * Linux driver for VMware's vmxnet3 ethernet NIC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Copyright (C) 2008-2021, VMware, Inc. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * This program is free software; you can redistribute it and/or modify it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  * under the terms of the GNU General Public License as published by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  * Free Software Foundation; version 2 of the License and no later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  * This program is distributed in the hope that it will be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  * WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  * NON INFRINGEMENT.  See the GNU General Public License for more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  * details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)  * You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  * along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20)  * The full GNU General Public License is included in this distribution in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21)  * the file called "COPYING".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23)  * Maintained by: pv-drivers@vmware.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include "vmxnet3_int.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <net/vxlan.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include <net/geneve.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #define VXLAN_UDP_PORT 8472
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) struct vmxnet3_stat_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 	char desc[ETH_GSTRING_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) 	int  offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) /* per tq stats maintained by the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) static const struct vmxnet3_stat_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) vmxnet3_tq_dev_stats[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) 	/* description,         offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 	{ "Tx Queue#",        0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) 	{ "  TSO pkts tx",	offsetof(struct UPT1_TxStats, TSOPktsTxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 	{ "  TSO bytes tx",	offsetof(struct UPT1_TxStats, TSOBytesTxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 	{ "  ucast pkts tx",	offsetof(struct UPT1_TxStats, ucastPktsTxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 	{ "  ucast bytes tx",	offsetof(struct UPT1_TxStats, ucastBytesTxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) 	{ "  mcast pkts tx",	offsetof(struct UPT1_TxStats, mcastPktsTxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 	{ "  mcast bytes tx",	offsetof(struct UPT1_TxStats, mcastBytesTxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 	{ "  bcast pkts tx",	offsetof(struct UPT1_TxStats, bcastPktsTxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 	{ "  bcast bytes tx",	offsetof(struct UPT1_TxStats, bcastBytesTxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 	{ "  pkts tx err",	offsetof(struct UPT1_TxStats, pktsTxError) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 	{ "  pkts tx discard",	offsetof(struct UPT1_TxStats, pktsTxDiscard) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) /* per tq stats maintained by the driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) static const struct vmxnet3_stat_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) vmxnet3_tq_driver_stats[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	/* description,         offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	{"  drv dropped tx total",	offsetof(struct vmxnet3_tq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 						 drop_total) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	{ "     too many frags", offsetof(struct vmxnet3_tq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 					  drop_too_many_frags) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 	{ "     giant hdr",	offsetof(struct vmxnet3_tq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 					 drop_oversized_hdr) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 	{ "     hdr err",	offsetof(struct vmxnet3_tq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 					 drop_hdr_inspect_err) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 	{ "     tso",		offsetof(struct vmxnet3_tq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 					 drop_tso) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	{ "  ring full",	offsetof(struct vmxnet3_tq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 					 tx_ring_full) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	{ "  pkts linearized",	offsetof(struct vmxnet3_tq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 					 linearized) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 	{ "  hdr cloned",	offsetof(struct vmxnet3_tq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 					 copy_skb_header) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	{ "  giant hdr",	offsetof(struct vmxnet3_tq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 					 oversized_hdr) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) /* per rq stats maintained by the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) static const struct vmxnet3_stat_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) vmxnet3_rq_dev_stats[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 	{ "Rx Queue#",        0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 	{ "  LRO pkts rx",	offsetof(struct UPT1_RxStats, LROPktsRxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 	{ "  LRO byte rx",	offsetof(struct UPT1_RxStats, LROBytesRxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	{ "  ucast pkts rx",	offsetof(struct UPT1_RxStats, ucastPktsRxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	{ "  ucast bytes rx",	offsetof(struct UPT1_RxStats, ucastBytesRxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 	{ "  mcast pkts rx",	offsetof(struct UPT1_RxStats, mcastPktsRxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 	{ "  mcast bytes rx",	offsetof(struct UPT1_RxStats, mcastBytesRxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 	{ "  bcast pkts rx",	offsetof(struct UPT1_RxStats, bcastPktsRxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	{ "  bcast bytes rx",	offsetof(struct UPT1_RxStats, bcastBytesRxOK) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	{ "  pkts rx OOB",	offsetof(struct UPT1_RxStats, pktsRxOutOfBuf) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	{ "  pkts rx err",	offsetof(struct UPT1_RxStats, pktsRxError) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) /* per rq stats maintained by the driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) static const struct vmxnet3_stat_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) vmxnet3_rq_driver_stats[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 	/* description,         offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 	{ "  drv dropped rx total", offsetof(struct vmxnet3_rq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 					     drop_total) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 	{ "     err",		offsetof(struct vmxnet3_rq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 					 drop_err) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	{ "     fcs",		offsetof(struct vmxnet3_rq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 					 drop_fcs) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	{ "  rx buf alloc fail", offsetof(struct vmxnet3_rq_driver_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 					  rx_buf_alloc_failure) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) /* global stats maintained by the driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) static const struct vmxnet3_stat_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) vmxnet3_global_stats[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	/* description,         offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	{ "tx timeout count",	offsetof(struct vmxnet3_adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 					 tx_timeout_count) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) vmxnet3_get_stats64(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 		   struct rtnl_link_stats64 *stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 	struct vmxnet3_adapter *adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	struct vmxnet3_tq_driver_stats *drvTxStats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 	struct vmxnet3_rq_driver_stats *drvRxStats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	struct UPT1_TxStats *devTxStats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 	struct UPT1_RxStats *devRxStats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	/* Collect the dev stats into the shared area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	spin_lock_irqsave(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	spin_unlock_irqrestore(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 	for (i = 0; i < adapter->num_tx_queues; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 		devTxStats = &adapter->tqd_start[i].stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 		drvTxStats = &adapter->tx_queue[i].stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 		stats->tx_packets += devTxStats->ucastPktsTxOK +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 				     devTxStats->mcastPktsTxOK +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 				     devTxStats->bcastPktsTxOK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 		stats->tx_bytes += devTxStats->ucastBytesTxOK +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 				   devTxStats->mcastBytesTxOK +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 				   devTxStats->bcastBytesTxOK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 		stats->tx_errors += devTxStats->pktsTxError;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 		stats->tx_dropped += drvTxStats->drop_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	for (i = 0; i < adapter->num_rx_queues; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 		devRxStats = &adapter->rqd_start[i].stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 		drvRxStats = &adapter->rx_queue[i].stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 		stats->rx_packets += devRxStats->ucastPktsRxOK +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 				     devRxStats->mcastPktsRxOK +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 				     devRxStats->bcastPktsRxOK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 		stats->rx_bytes += devRxStats->ucastBytesRxOK +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 				   devRxStats->mcastBytesRxOK +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 				   devRxStats->bcastBytesRxOK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 		stats->rx_errors += devRxStats->pktsRxError;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 		stats->rx_dropped += drvRxStats->drop_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 		stats->multicast +=  devRxStats->mcastPktsRxOK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) vmxnet3_get_sset_count(struct net_device *netdev, int sset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	switch (sset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	case ETH_SS_STATS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 		return (ARRAY_SIZE(vmxnet3_tq_dev_stats) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 			ARRAY_SIZE(vmxnet3_tq_driver_stats)) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 		       adapter->num_tx_queues +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 		       (ARRAY_SIZE(vmxnet3_rq_dev_stats) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 			ARRAY_SIZE(vmxnet3_rq_driver_stats)) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 		       adapter->num_rx_queues +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 			ARRAY_SIZE(vmxnet3_global_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) /* This is a version 2 of the vmxnet3 ethtool_regs which goes hand in hand with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189)  * the version 2 of the vmxnet3 support for ethtool(8) --register-dump.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190)  * Therefore, if any registers are added, removed or modified, then a version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191)  * bump and a corresponding change in the vmxnet3 support for ethtool(8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192)  * --register-dump would be required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) vmxnet3_get_regs_len(struct net_device *netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 	return ((9 /* BAR1 registers */ +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 		(1 + adapter->intr.num_intrs) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 		(1 + adapter->num_tx_queues * 17 /* Tx queue registers */) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 		(1 + adapter->num_rx_queues * 23 /* Rx queue registers */)) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 		sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	strlcpy(drvinfo->driver, vmxnet3_driver_name, sizeof(drvinfo->driver));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	strlcpy(drvinfo->version, VMXNET3_DRIVER_VERSION_REPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 		sizeof(drvinfo->version));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 		sizeof(drvinfo->bus_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	if (stringset == ETH_SS_STATS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 		int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 		for (j = 0; j < adapter->num_tx_queues; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 			for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 				memcpy(buf, vmxnet3_tq_dev_stats[i].desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 				       ETH_GSTRING_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 				buf += ETH_GSTRING_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 			for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 			     i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 				memcpy(buf, vmxnet3_tq_driver_stats[i].desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 				       ETH_GSTRING_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 				buf += ETH_GSTRING_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 		for (j = 0; j < adapter->num_rx_queues; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 			for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 				memcpy(buf, vmxnet3_rq_dev_stats[i].desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 				       ETH_GSTRING_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 				buf += ETH_GSTRING_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 			for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 			     i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 				memcpy(buf, vmxnet3_rq_driver_stats[i].desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 				       ETH_GSTRING_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 				buf += ETH_GSTRING_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 		for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 			memcpy(buf, vmxnet3_global_stats[i].desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 				ETH_GSTRING_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 			buf += ETH_GSTRING_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) netdev_features_t vmxnet3_fix_features(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 				       netdev_features_t features)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	/* If Rx checksum is disabled, then LRO should also be disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	if (!(features & NETIF_F_RXCSUM))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 		features &= ~NETIF_F_LRO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	return features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) netdev_features_t vmxnet3_features_check(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 					 struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 					 netdev_features_t features)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	/* Validate if the tunneled packet is being offloaded by the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	if (VMXNET3_VERSION_GE_4(adapter) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	    skb->encapsulation && skb->ip_summed == CHECKSUM_PARTIAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 		u8 l4_proto = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 		u16 port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 		struct udphdr *udph;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 		switch (vlan_get_protocol(skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 		case htons(ETH_P_IP):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 			l4_proto = ip_hdr(skb)->protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 		case htons(ETH_P_IPV6):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 			l4_proto = ipv6_hdr(skb)->nexthdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 			return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 		switch (l4_proto) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 		case IPPROTO_UDP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 			udph = udp_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 			port = be16_to_cpu(udph->dest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 			/* Check if offloaded port is supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 			if (port != GENEVE_UDP_PORT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 			    port != IANA_VXLAN_UDP_PORT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 			    port != VXLAN_UDP_PORT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 				return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 			return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	return features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) static void vmxnet3_enable_encap_offloads(struct net_device *netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	if (VMXNET3_VERSION_GE_4(adapter)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 		netdev->hw_enc_features |= NETIF_F_SG | NETIF_F_RXCSUM |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 			NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_CTAG_TX |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 			NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_TSO | NETIF_F_TSO6 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 			NETIF_F_LRO | NETIF_F_GSO_UDP_TUNNEL |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 			NETIF_F_GSO_UDP_TUNNEL_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) static void vmxnet3_disable_encap_offloads(struct net_device *netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	if (VMXNET3_VERSION_GE_4(adapter)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 		netdev->hw_enc_features &= ~(NETIF_F_SG | NETIF_F_RXCSUM |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 			NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_CTAG_TX |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 			NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_TSO | NETIF_F_TSO6 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 			NETIF_F_LRO | NETIF_F_GSO_UDP_TUNNEL |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 			NETIF_F_GSO_UDP_TUNNEL_CSUM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) int vmxnet3_set_features(struct net_device *netdev, netdev_features_t features)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	netdev_features_t changed = features ^ netdev->features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	netdev_features_t tun_offload_mask = NETIF_F_GSO_UDP_TUNNEL |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 					     NETIF_F_GSO_UDP_TUNNEL_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	u8 udp_tun_enabled = (netdev->features & tun_offload_mask) != 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	if (changed & (NETIF_F_RXCSUM | NETIF_F_LRO |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 		       NETIF_F_HW_VLAN_CTAG_RX | tun_offload_mask)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 		if (features & NETIF_F_RXCSUM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 			adapter->shared->devRead.misc.uptFeatures |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 			UPT1_F_RXCSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 			adapter->shared->devRead.misc.uptFeatures &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 			~UPT1_F_RXCSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 		/* update hardware LRO capability accordingly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 		if (features & NETIF_F_LRO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 			adapter->shared->devRead.misc.uptFeatures |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 							UPT1_F_LRO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 			adapter->shared->devRead.misc.uptFeatures &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 							~UPT1_F_LRO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 		if (features & NETIF_F_HW_VLAN_CTAG_RX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 			adapter->shared->devRead.misc.uptFeatures |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 			UPT1_F_RXVLAN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 			adapter->shared->devRead.misc.uptFeatures &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 			~UPT1_F_RXVLAN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 		if ((features & tun_offload_mask) != 0 && !udp_tun_enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 			vmxnet3_enable_encap_offloads(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 			adapter->shared->devRead.misc.uptFeatures |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 			UPT1_F_RXINNEROFLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 		} else if ((features & tun_offload_mask) == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 			   udp_tun_enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 			vmxnet3_disable_encap_offloads(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 			adapter->shared->devRead.misc.uptFeatures &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 			~UPT1_F_RXINNEROFLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		spin_lock_irqsave(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 		VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 				       VMXNET3_CMD_UPDATE_FEATURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		spin_unlock_irqrestore(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) vmxnet3_get_ethtool_stats(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 			  struct ethtool_stats *stats, u64  *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	u8 *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	int j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	spin_lock_irqsave(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 	VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	spin_unlock_irqrestore(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	/* this does assume each counter is 64-bit wide */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	for (j = 0; j < adapter->num_tx_queues; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 		base = (u8 *)&adapter->tqd_start[j].stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 		*buf++ = (u64)j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		for (i = 1; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 			*buf++ = *(u64 *)(base +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 					  vmxnet3_tq_dev_stats[i].offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 		base = (u8 *)&adapter->tx_queue[j].stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 		for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 			*buf++ = *(u64 *)(base +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 					  vmxnet3_tq_driver_stats[i].offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 	for (j = 0; j < adapter->num_rx_queues; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 		base = (u8 *)&adapter->rqd_start[j].stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 		*buf++ = (u64) j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 		for (i = 1; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 			*buf++ = *(u64 *)(base +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 					  vmxnet3_rq_dev_stats[i].offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 		base = (u8 *)&adapter->rx_queue[j].stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 		for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 			*buf++ = *(u64 *)(base +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 					  vmxnet3_rq_driver_stats[i].offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	base = (u8 *)adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 		*buf++ = *(u64 *)(base + vmxnet3_global_stats[i].offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) /* This is a version 2 of the vmxnet3 ethtool_regs which goes hand in hand with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442)  * the version 2 of the vmxnet3 support for ethtool(8) --register-dump.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443)  * Therefore, if any registers are added, removed or modified, then a version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444)  * bump and a corresponding change in the vmxnet3 support for ethtool(8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445)  * --register-dump would be required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) vmxnet3_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	u32 *buf = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 	int i = 0, j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 	memset(p, 0, vmxnet3_get_regs_len(netdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 	regs->version = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	/* Update vmxnet3_get_regs_len if we want to dump more registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_UVRS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_DSAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_DSAH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_MACL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_MACH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_ICR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_ECR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	buf[j++] = adapter->intr.num_intrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	for (i = 0; i < adapter->intr.num_intrs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 		buf[j++] = VMXNET3_READ_BAR0_REG(adapter, VMXNET3_REG_IMR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 						 + i * VMXNET3_REG_ALIGN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	buf[j++] = adapter->num_tx_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	for (i = 0; i < adapter->num_tx_queues; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 		struct vmxnet3_tx_queue *tq = &adapter->tx_queue[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 		buf[j++] = VMXNET3_READ_BAR0_REG(adapter, VMXNET3_REG_TXPROD +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 						 i * VMXNET3_REG_ALIGN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 		buf[j++] = VMXNET3_GET_ADDR_LO(tq->tx_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 		buf[j++] = VMXNET3_GET_ADDR_HI(tq->tx_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 		buf[j++] = tq->tx_ring.size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 		buf[j++] = tq->tx_ring.next2fill;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 		buf[j++] = tq->tx_ring.next2comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 		buf[j++] = tq->tx_ring.gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 		buf[j++] = VMXNET3_GET_ADDR_LO(tq->data_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 		buf[j++] = VMXNET3_GET_ADDR_HI(tq->data_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 		buf[j++] = tq->data_ring.size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 		buf[j++] = tq->txdata_desc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 		buf[j++] = VMXNET3_GET_ADDR_LO(tq->comp_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 		buf[j++] = VMXNET3_GET_ADDR_HI(tq->comp_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 		buf[j++] = tq->comp_ring.size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 		buf[j++] = tq->comp_ring.next2proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 		buf[j++] = tq->comp_ring.gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 		buf[j++] = tq->stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	buf[j++] = adapter->num_rx_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 	for (i = 0; i < adapter->num_rx_queues; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 		struct vmxnet3_rx_queue *rq = &adapter->rx_queue[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 		buf[j++] =  VMXNET3_READ_BAR0_REG(adapter, VMXNET3_REG_RXPROD +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 						  i * VMXNET3_REG_ALIGN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 		buf[j++] =  VMXNET3_READ_BAR0_REG(adapter, VMXNET3_REG_RXPROD2 +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 						  i * VMXNET3_REG_ALIGN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 		buf[j++] = VMXNET3_GET_ADDR_LO(rq->rx_ring[0].basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 		buf[j++] = VMXNET3_GET_ADDR_HI(rq->rx_ring[0].basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 		buf[j++] = rq->rx_ring[0].size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 		buf[j++] = rq->rx_ring[0].next2fill;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 		buf[j++] = rq->rx_ring[0].next2comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 		buf[j++] = rq->rx_ring[0].gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 		buf[j++] = VMXNET3_GET_ADDR_LO(rq->rx_ring[1].basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		buf[j++] = VMXNET3_GET_ADDR_HI(rq->rx_ring[1].basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 		buf[j++] = rq->rx_ring[1].size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 		buf[j++] = rq->rx_ring[1].next2fill;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 		buf[j++] = rq->rx_ring[1].next2comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 		buf[j++] = rq->rx_ring[1].gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 		buf[j++] = VMXNET3_GET_ADDR_LO(rq->data_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 		buf[j++] = VMXNET3_GET_ADDR_HI(rq->data_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 		buf[j++] = rq->rx_ring[0].size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		buf[j++] = rq->data_ring.desc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 		buf[j++] = VMXNET3_GET_ADDR_LO(rq->comp_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 		buf[j++] = VMXNET3_GET_ADDR_HI(rq->comp_ring.basePA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 		buf[j++] = rq->comp_ring.size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 		buf[j++] = rq->comp_ring.next2proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 		buf[j++] = rq->comp_ring.gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) vmxnet3_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	wol->supported = WAKE_UCAST | WAKE_ARP | WAKE_MAGIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 	wol->wolopts = adapter->wol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) vmxnet3_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 	if (wol->wolopts & (WAKE_PHY | WAKE_MCAST | WAKE_BCAST |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 			    WAKE_MAGICSECURE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	adapter->wol = wol->wolopts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) vmxnet3_get_link_ksettings(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 			   struct ethtool_link_ksettings *ecmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	ethtool_link_ksettings_zero_link_mode(ecmd, supported);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	ethtool_link_ksettings_add_link_mode(ecmd, supported, 10000baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	ethtool_link_ksettings_add_link_mode(ecmd, supported, 1000baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	ethtool_link_ksettings_add_link_mode(ecmd, supported, TP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	ethtool_link_ksettings_zero_link_mode(ecmd, advertising);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	ethtool_link_ksettings_add_link_mode(ecmd, advertising, TP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	ecmd->base.port = PORT_TP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	if (adapter->link_speed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 		ecmd->base.speed = adapter->link_speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 		ecmd->base.duplex = DUPLEX_FULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 		ecmd->base.speed = SPEED_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 		ecmd->base.duplex = DUPLEX_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) vmxnet3_get_ringparam(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 		      struct ethtool_ringparam *param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	param->rx_max_pending = VMXNET3_RX_RING_MAX_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 	param->tx_max_pending = VMXNET3_TX_RING_MAX_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 	param->rx_mini_max_pending = VMXNET3_VERSION_GE_3(adapter) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 		VMXNET3_RXDATA_DESC_MAX_SIZE : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 	param->rx_jumbo_max_pending = VMXNET3_RX_RING2_MAX_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	param->rx_pending = adapter->rx_ring_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	param->tx_pending = adapter->tx_ring_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 	param->rx_mini_pending = VMXNET3_VERSION_GE_3(adapter) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 		adapter->rxdata_desc_size : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	param->rx_jumbo_pending = adapter->rx_ring2_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) vmxnet3_set_ringparam(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 		      struct ethtool_ringparam *param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	u32 new_tx_ring_size, new_rx_ring_size, new_rx_ring2_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 	u16 new_rxdata_desc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	u32 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	if (param->tx_pending == 0 || param->tx_pending >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 						VMXNET3_TX_RING_MAX_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	if (param->rx_pending == 0 || param->rx_pending >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 						VMXNET3_RX_RING_MAX_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 	if (param->rx_jumbo_pending == 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	    param->rx_jumbo_pending > VMXNET3_RX_RING2_MAX_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	/* if adapter not yet initialized, do nothing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	if (adapter->rx_buf_per_pkt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 		netdev_err(netdev, "adapter not completely initialized, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 			   "ring size cannot be changed yet\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	if (VMXNET3_VERSION_GE_3(adapter)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 		if (param->rx_mini_pending > VMXNET3_RXDATA_DESC_MAX_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	} else if (param->rx_mini_pending != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	/* round it up to a multiple of VMXNET3_RING_SIZE_ALIGN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	new_tx_ring_size = (param->tx_pending + VMXNET3_RING_SIZE_MASK) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 							~VMXNET3_RING_SIZE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	new_tx_ring_size = min_t(u32, new_tx_ring_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 				 VMXNET3_TX_RING_MAX_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	if (new_tx_ring_size > VMXNET3_TX_RING_MAX_SIZE || (new_tx_ring_size %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 						VMXNET3_RING_SIZE_ALIGN) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	/* ring0 has to be a multiple of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 	 * rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 	sz = adapter->rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	new_rx_ring_size = (param->rx_pending + sz - 1) / sz * sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	new_rx_ring_size = min_t(u32, new_rx_ring_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 				 VMXNET3_RX_RING_MAX_SIZE / sz * sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	if (new_rx_ring_size > VMXNET3_RX_RING_MAX_SIZE || (new_rx_ring_size %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 							   sz) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 	/* ring2 has to be a multiple of VMXNET3_RING_SIZE_ALIGN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	new_rx_ring2_size = (param->rx_jumbo_pending + VMXNET3_RING_SIZE_MASK) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 				~VMXNET3_RING_SIZE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	new_rx_ring2_size = min_t(u32, new_rx_ring2_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 				  VMXNET3_RX_RING2_MAX_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 	/* rx data ring buffer size has to be a multiple of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	 * VMXNET3_RXDATA_DESC_SIZE_ALIGN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	new_rxdata_desc_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 		(param->rx_mini_pending + VMXNET3_RXDATA_DESC_SIZE_MASK) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 		~VMXNET3_RXDATA_DESC_SIZE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	new_rxdata_desc_size = min_t(u16, new_rxdata_desc_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 				     VMXNET3_RXDATA_DESC_MAX_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	if (new_tx_ring_size == adapter->tx_ring_size &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	    new_rx_ring_size == adapter->rx_ring_size &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	    new_rx_ring2_size == adapter->rx_ring2_size &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	    new_rxdata_desc_size == adapter->rxdata_desc_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	 * Reset_work may be in the middle of resetting the device, wait for its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	 * completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 		usleep_range(1000, 2000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 	if (netif_running(netdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 		vmxnet3_quiesce_dev(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 		vmxnet3_reset_dev(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 		/* recreate the rx queue and the tx queue based on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 		 * new sizes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 		vmxnet3_tq_destroy_all(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 		vmxnet3_rq_destroy_all(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 		err = vmxnet3_create_queues(adapter, new_tx_ring_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 					    new_rx_ring_size, new_rx_ring2_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 					    adapter->txdata_desc_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 					    new_rxdata_desc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 		if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 			/* failed, most likely because of OOM, try default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 			 * size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 			netdev_err(netdev, "failed to apply new sizes, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 				   "try the default ones\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 			new_rx_ring_size = VMXNET3_DEF_RX_RING_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 			new_rx_ring2_size = VMXNET3_DEF_RX_RING2_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 			new_tx_ring_size = VMXNET3_DEF_TX_RING_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 			new_rxdata_desc_size = VMXNET3_VERSION_GE_3(adapter) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 				VMXNET3_DEF_RXDATA_DESC_SIZE : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 			err = vmxnet3_create_queues(adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 						    new_tx_ring_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 						    new_rx_ring_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 						    new_rx_ring2_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 						    adapter->txdata_desc_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 						    new_rxdata_desc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 			if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 				netdev_err(netdev, "failed to create queues "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 					   "with default sizes. Closing it\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 				goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 		err = vmxnet3_activate_dev(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 			netdev_err(netdev, "failed to re-activate, error %d."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 				   " Closing it\n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	adapter->tx_ring_size = new_tx_ring_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	adapter->rx_ring_size = new_rx_ring_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	adapter->rx_ring2_size = new_rx_ring2_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	adapter->rxdata_desc_size = new_rxdata_desc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 		vmxnet3_force_close(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) vmxnet3_get_rss_hash_opts(struct vmxnet3_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 			  struct ethtool_rxnfc *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	enum Vmxnet3_RSSField rss_fields;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	if (netif_running(adapter->netdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 		unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 		spin_lock_irqsave(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 		VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 				       VMXNET3_CMD_GET_RSS_FIELDS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 		rss_fields = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 		spin_unlock_irqrestore(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 		rss_fields = adapter->rss_fields;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	info->data = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	/* Report default options for RSS on vmxnet3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	switch (info->flow_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	case TCP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	case TCP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 		info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 			      RXH_IP_SRC | RXH_IP_DST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	case UDP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 		if (rss_fields & VMXNET3_RSS_FIELDS_UDPIP4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 			info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 		info->data |= RXH_IP_SRC | RXH_IP_DST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	case AH_ESP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	case AH_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	case ESP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 		if (rss_fields & VMXNET3_RSS_FIELDS_ESPIP4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 			info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	case SCTP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	case IPV4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 		info->data |= RXH_IP_SRC | RXH_IP_DST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	case UDP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 		if (rss_fields & VMXNET3_RSS_FIELDS_UDPIP6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 			info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 		info->data |= RXH_IP_SRC | RXH_IP_DST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 	case AH_ESP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	case AH_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	case ESP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	case SCTP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 	case IPV6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 		info->data |= RXH_IP_SRC | RXH_IP_DST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) vmxnet3_set_rss_hash_opt(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 			 struct vmxnet3_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 			 struct ethtool_rxnfc *nfc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	enum Vmxnet3_RSSField rss_fields = adapter->rss_fields;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	/* RSS does not support anything other than hashing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	 * to queues on src and dst IPs and ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 	if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 			  RXH_L4_B_0_1 | RXH_L4_B_2_3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	switch (nfc->flow_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	case TCP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 	case TCP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 		if (!(nfc->data & RXH_IP_SRC) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 		    !(nfc->data & RXH_IP_DST) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 		    !(nfc->data & RXH_L4_B_0_1) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 		    !(nfc->data & RXH_L4_B_2_3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	case UDP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 		if (!(nfc->data & RXH_IP_SRC) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 		    !(nfc->data & RXH_IP_DST))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 		switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 			rss_fields &= ~VMXNET3_RSS_FIELDS_UDPIP4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 		case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 			rss_fields |= VMXNET3_RSS_FIELDS_UDPIP4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	case UDP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 		if (!(nfc->data & RXH_IP_SRC) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 		    !(nfc->data & RXH_IP_DST))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 		switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 			rss_fields &= ~VMXNET3_RSS_FIELDS_UDPIP6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 			rss_fields |= VMXNET3_RSS_FIELDS_UDPIP6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	case ESP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	case AH_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	case AH_ESP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 		if (!(nfc->data & RXH_IP_SRC) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 		    !(nfc->data & RXH_IP_DST))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 		switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 			rss_fields &= ~VMXNET3_RSS_FIELDS_ESPIP4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 			rss_fields |= VMXNET3_RSS_FIELDS_ESPIP4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	case ESP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	case AH_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 	case AH_ESP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	case SCTP_V4_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	case SCTP_V6_FLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 		if (!(nfc->data & RXH_IP_SRC) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 		    !(nfc->data & RXH_IP_DST) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 		    (nfc->data & RXH_L4_B_0_1) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 		    (nfc->data & RXH_L4_B_2_3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	/* if we changed something we need to update flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 	if (rss_fields != adapter->rss_fields) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 		adapter->default_rss_fields = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 		if (netif_running(netdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 			struct Vmxnet3_DriverShared *shared = adapter->shared;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 			union Vmxnet3_CmdInfo *cmdInfo = &shared->cu.cmdInfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 			unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 			spin_lock_irqsave(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 			cmdInfo->setRssFields = rss_fields;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 			VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 					       VMXNET3_CMD_SET_RSS_FIELDS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 			/* Not all requested RSS may get applied, so get and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 			 * cache what was actually applied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 			VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 					       VMXNET3_CMD_GET_RSS_FIELDS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 			adapter->rss_fields =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 				VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 			spin_unlock_irqrestore(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 			/* When the device is activated, we will try to apply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 			 * these rules and cache the applied value later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 			adapter->rss_fields = rss_fields;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) vmxnet3_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 		  u32 *rules)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	switch (info->cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	case ETHTOOL_GRXRINGS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 		info->data = adapter->num_rx_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 	case ETHTOOL_GRXFH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 		if (!VMXNET3_VERSION_GE_4(adapter)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 			err = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) #ifdef VMXNET3_RSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 		if (!adapter->rss) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 			err = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		err = vmxnet3_get_rss_hash_opts(adapter, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 		err = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) vmxnet3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	if (!VMXNET3_VERSION_GE_4(adapter)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 		err = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) #ifdef VMXNET3_RSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 	if (!adapter->rss) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 		err = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	switch (info->cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	case ETHTOOL_SRXFH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 		err = vmxnet3_set_rss_hash_opt(netdev, adapter, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 		err = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) #ifdef VMXNET3_RSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) static u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) vmxnet3_get_rss_indir_size(struct net_device *netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	struct UPT1_RSSConf *rssConf = adapter->rss_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	return rssConf->indTableSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) vmxnet3_get_rss(struct net_device *netdev, u32 *p, u8 *key, u8 *hfunc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	struct UPT1_RSSConf *rssConf = adapter->rss_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	unsigned int n = rssConf->indTableSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	if (hfunc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 		*hfunc = ETH_RSS_HASH_TOP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	if (n > UPT1_RSS_MAX_IND_TABLE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	while (n--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 		p[n] = rssConf->indTable[n];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) vmxnet3_set_rss(struct net_device *netdev, const u32 *p, const u8 *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 		const u8 hfunc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	struct UPT1_RSSConf *rssConf = adapter->rss_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	/* We do not allow change in unsupported parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	if (key ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	    (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	for (i = 0; i < rssConf->indTableSize; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 		rssConf->indTable[i] = p[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	spin_lock_irqsave(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 			       VMXNET3_CMD_UPDATE_RSSIDT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 	spin_unlock_irqrestore(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) vmxnet3_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	if (!VMXNET3_VERSION_GE_3(adapter))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 	switch (adapter->coal_conf->coalMode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	case VMXNET3_COALESCE_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 		/* struct ethtool_coalesce is already initialized to 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	case VMXNET3_COALESCE_ADAPT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 		ec->use_adaptive_rx_coalesce = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 	case VMXNET3_COALESCE_STATIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 		ec->tx_max_coalesced_frames =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 			adapter->coal_conf->coalPara.coalStatic.tx_comp_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 		ec->rx_max_coalesced_frames =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 			adapter->coal_conf->coalPara.coalStatic.rx_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	case VMXNET3_COALESCE_RBC: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 		u32 rbc_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 		rbc_rate = adapter->coal_conf->coalPara.coalRbc.rbc_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 		ec->rx_coalesce_usecs = VMXNET3_COAL_RBC_USECS(rbc_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) vmxnet3_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 	struct Vmxnet3_DriverShared *shared = adapter->shared;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 	union Vmxnet3_CmdInfo *cmdInfo = &shared->cu.cmdInfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 	if (!VMXNET3_VERSION_GE_3(adapter))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 	if ((ec->rx_coalesce_usecs == 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 	    (ec->use_adaptive_rx_coalesce == 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	    (ec->tx_max_coalesced_frames == 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	    (ec->rx_max_coalesced_frames == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 		memset(adapter->coal_conf, 0, sizeof(*adapter->coal_conf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 		adapter->coal_conf->coalMode = VMXNET3_COALESCE_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	if (ec->rx_coalesce_usecs != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 		u32 rbc_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 		if ((ec->use_adaptive_rx_coalesce != 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 		    (ec->tx_max_coalesced_frames != 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 		    (ec->rx_max_coalesced_frames != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 		rbc_rate = VMXNET3_COAL_RBC_RATE(ec->rx_coalesce_usecs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 		if (rbc_rate < VMXNET3_COAL_RBC_MIN_RATE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 		    rbc_rate > VMXNET3_COAL_RBC_MAX_RATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 		memset(adapter->coal_conf, 0, sizeof(*adapter->coal_conf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 		adapter->coal_conf->coalMode = VMXNET3_COALESCE_RBC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 		adapter->coal_conf->coalPara.coalRbc.rbc_rate = rbc_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 	if (ec->use_adaptive_rx_coalesce != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 		if ((ec->rx_coalesce_usecs != 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 		    (ec->tx_max_coalesced_frames != 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 		    (ec->rx_max_coalesced_frames != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 		memset(adapter->coal_conf, 0, sizeof(*adapter->coal_conf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 		adapter->coal_conf->coalMode = VMXNET3_COALESCE_ADAPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 	if ((ec->tx_max_coalesced_frames != 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 	    (ec->rx_max_coalesced_frames != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 		if ((ec->rx_coalesce_usecs != 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 		    (ec->use_adaptive_rx_coalesce != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 		if ((ec->tx_max_coalesced_frames >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 		    VMXNET3_COAL_STATIC_MAX_DEPTH) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 		    (ec->rx_max_coalesced_frames >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 		     VMXNET3_COAL_STATIC_MAX_DEPTH)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 		memset(adapter->coal_conf, 0, sizeof(*adapter->coal_conf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 		adapter->coal_conf->coalMode = VMXNET3_COALESCE_STATIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 		adapter->coal_conf->coalPara.coalStatic.tx_comp_depth =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 			(ec->tx_max_coalesced_frames ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 			 ec->tx_max_coalesced_frames :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 			 VMXNET3_COAL_STATIC_DEFAULT_DEPTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 		adapter->coal_conf->coalPara.coalStatic.rx_depth =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 			(ec->rx_max_coalesced_frames ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 			 ec->rx_max_coalesced_frames :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 			 VMXNET3_COAL_STATIC_DEFAULT_DEPTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 		adapter->coal_conf->coalPara.coalStatic.tx_depth =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 			 VMXNET3_COAL_STATIC_DEFAULT_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 	adapter->default_coal_mode = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	if (netif_running(netdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 		spin_lock_irqsave(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 		cmdInfo->varConf.confVer = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 		cmdInfo->varConf.confLen =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 			cpu_to_le32(sizeof(*adapter->coal_conf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 		cmdInfo->varConf.confPA  = cpu_to_le64(adapter->coal_conf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 		VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 				       VMXNET3_CMD_SET_COALESCE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 		spin_unlock_irqrestore(&adapter->cmd_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) static const struct ethtool_ops vmxnet3_ethtool_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 	.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 				     ETHTOOL_COALESCE_MAX_FRAMES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 				     ETHTOOL_COALESCE_USE_ADAPTIVE_RX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 	.get_drvinfo       = vmxnet3_get_drvinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 	.get_regs_len      = vmxnet3_get_regs_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 	.get_regs          = vmxnet3_get_regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 	.get_wol           = vmxnet3_get_wol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 	.set_wol           = vmxnet3_set_wol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	.get_link          = ethtool_op_get_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	.get_coalesce      = vmxnet3_get_coalesce,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	.set_coalesce      = vmxnet3_set_coalesce,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	.get_strings       = vmxnet3_get_strings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	.get_sset_count	   = vmxnet3_get_sset_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	.get_ethtool_stats = vmxnet3_get_ethtool_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	.get_ringparam     = vmxnet3_get_ringparam,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 	.set_ringparam     = vmxnet3_set_ringparam,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 	.get_rxnfc         = vmxnet3_get_rxnfc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	.set_rxnfc         = vmxnet3_set_rxnfc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) #ifdef VMXNET3_RSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	.get_rxfh_indir_size = vmxnet3_get_rss_indir_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 	.get_rxfh          = vmxnet3_get_rss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 	.set_rxfh          = vmxnet3_set_rss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	.get_link_ksettings = vmxnet3_get_link_ksettings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) void vmxnet3_set_ethtool_ops(struct net_device *netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	netdev->ethtool_ops = &vmxnet3_ethtool_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) }