aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramit salecha <amit.salecha@qlogic.com>2011-04-06 21:58:42 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-13 14:31:04 -0400
commit8b5933c380fc66a6311739f9b36a812383f82141 (patch)
tree0552732a62a704756069e34cb945ee191a733332
parent6139e75f4a413bdc8f366fc11e437347be8abc59 (diff)
net: ethtool support to configure number of channels
Ethtool support to configure RX, TX and other channels. combined field in struct ethtool_channels to reflect set of channel (RX, TX or other). Other channel can be link interrupts, SR-IOV coordination etc. ETHTOOL_GCHANNELS will report max and current number of RX channels, max and current number of TX channels, max and current number of other channel or max and current number of combined channel. Number of channel can be modify upto max number of channel through ETHTOOL_SCHANNELS command. Ben Hutchings: o define 'combined' and 'other' types. Most multiqueue drivers pair up RX and TX queues so that most channels combine RX and TX work. o Please could you use a kernel-doc comment to describe the structure. Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Reviewed-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/ethtool.h36
-rw-r--r--net/core/ethtool.c35
2 files changed, 71 insertions, 0 deletions
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 12cfbd0be2ee..ad22a68c2e5d 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -229,6 +229,34 @@ struct ethtool_ringparam {
229 __u32 tx_pending; 229 __u32 tx_pending;
230}; 230};
231 231
232/**
233 * struct ethtool_channels - configuring number of network channel
234 * @cmd: ETHTOOL_{G,S}CHANNELS
235 * @max_rx: Read only. Maximum number of receive channel the driver support.
236 * @max_tx: Read only. Maximum number of transmit channel the driver support.
237 * @max_other: Read only. Maximum number of other channel the driver support.
238 * @max_combined: Read only. Maximum number of combined channel the driver
239 * support. Set of queues RX, TX or other.
240 * @rx_count: Valid values are in the range 1 to the max_rx.
241 * @tx_count: Valid values are in the range 1 to the max_tx.
242 * @other_count: Valid values are in the range 1 to the max_other.
243 * @combined_count: Valid values are in the range 1 to the max_combined.
244 *
245 * This can be used to configure RX, TX and other channels.
246 */
247
248struct ethtool_channels {
249 __u32 cmd;
250 __u32 max_rx;
251 __u32 max_tx;
252 __u32 max_other;
253 __u32 max_combined;
254 __u32 rx_count;
255 __u32 tx_count;
256 __u32 other_count;
257 __u32 combined_count;
258};
259
232/* for configuring link flow control parameters */ 260/* for configuring link flow control parameters */
233struct ethtool_pauseparam { 261struct ethtool_pauseparam {
234 __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */ 262 __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
@@ -818,6 +846,9 @@ bool ethtool_invalid_flags(struct net_device *dev, u32 data, u32 supported);
818 * Returns a negative error code or zero. 846 * Returns a negative error code or zero.
819 * @set_rxfh_indir: Set the contents of the RX flow hash indirection table. 847 * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
820 * Returns a negative error code or zero. 848 * Returns a negative error code or zero.
849 * @get_channels: Get number of channels.
850 * @set_channels: Set number of channels. Returns a negative error code or
851 * zero.
821 * 852 *
822 * All operations are optional (i.e. the function pointer may be set 853 * All operations are optional (i.e. the function pointer may be set
823 * to %NULL) and callers must take this into account. Callers must 854 * to %NULL) and callers must take this into account. Callers must
@@ -891,6 +922,9 @@ struct ethtool_ops {
891 struct ethtool_rxfh_indir *); 922 struct ethtool_rxfh_indir *);
892 int (*set_rxfh_indir)(struct net_device *, 923 int (*set_rxfh_indir)(struct net_device *,
893 const struct ethtool_rxfh_indir *); 924 const struct ethtool_rxfh_indir *);
925 void (*get_channels)(struct net_device *, struct ethtool_channels *);
926 int (*set_channels)(struct net_device *, struct ethtool_channels *);
927
894}; 928};
895#endif /* __KERNEL__ */ 929#endif /* __KERNEL__ */
896 930
@@ -959,6 +993,8 @@ struct ethtool_ops {
959 993
960#define ETHTOOL_GFEATURES 0x0000003a /* Get device offload settings */ 994#define ETHTOOL_GFEATURES 0x0000003a /* Get device offload settings */
961#define ETHTOOL_SFEATURES 0x0000003b /* Change device offload settings */ 995#define ETHTOOL_SFEATURES 0x0000003b /* Change device offload settings */
996#define ETHTOOL_GCHANNELS 0x0000003c /* Get no of channels */
997#define ETHTOOL_SCHANNELS 0x0000003d /* Set no of channels */
962 998
963/* compatibility with older code */ 999/* compatibility with older code */
964#define SPARC_ETH_GSET ETHTOOL_GSET 1000#define SPARC_ETH_GSET ETHTOOL_GSET
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 43ef09fedd6e..41dee2de13ad 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1446,6 +1446,35 @@ static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
1446 return dev->ethtool_ops->set_ringparam(dev, &ringparam); 1446 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
1447} 1447}
1448 1448
1449static noinline_for_stack int ethtool_get_channels(struct net_device *dev,
1450 void __user *useraddr)
1451{
1452 struct ethtool_channels channels = { .cmd = ETHTOOL_GCHANNELS };
1453
1454 if (!dev->ethtool_ops->get_channels)
1455 return -EOPNOTSUPP;
1456
1457 dev->ethtool_ops->get_channels(dev, &channels);
1458
1459 if (copy_to_user(useraddr, &channels, sizeof(channels)))
1460 return -EFAULT;
1461 return 0;
1462}
1463
1464static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
1465 void __user *useraddr)
1466{
1467 struct ethtool_channels channels;
1468
1469 if (!dev->ethtool_ops->set_channels)
1470 return -EOPNOTSUPP;
1471
1472 if (copy_from_user(&channels, useraddr, sizeof(channels)))
1473 return -EFAULT;
1474
1475 return dev->ethtool_ops->set_channels(dev, &channels);
1476}
1477
1449static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr) 1478static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
1450{ 1479{
1451 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM }; 1480 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
@@ -2007,6 +2036,12 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
2007 case ETHTOOL_SGRO: 2036 case ETHTOOL_SGRO:
2008 rc = ethtool_set_one_feature(dev, useraddr, ethcmd); 2037 rc = ethtool_set_one_feature(dev, useraddr, ethcmd);
2009 break; 2038 break;
2039 case ETHTOOL_GCHANNELS:
2040 rc = ethtool_get_channels(dev, useraddr);
2041 break;
2042 case ETHTOOL_SCHANNELS:
2043 rc = ethtool_set_channels(dev, useraddr);
2044 break;
2010 default: 2045 default:
2011 rc = -EOPNOTSUPP; 2046 rc = -EOPNOTSUPP;
2012 } 2047 }