summaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorHayes Wang <hayeswang@realtek.com>2019-08-12 23:42:09 -0400
committerJakub Kicinski <jakub.kicinski@netronome.com>2019-08-13 21:12:09 -0400
commite4a5017ac5b3924384a36a0a043cb65bb41dd5be (patch)
treefc114ed5fafe2ab0e830e7fddd23d900736ae7d7 /drivers/net/usb
parent47922fcde5365a2d37e8d4056e537fc8a7213c39 (diff)
r8152: change rx_copybreak and rx_pending through ethtool
Let the rx_copybreak and rx_pending could be modified by ethtool. Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/r8152.c91
1 files changed, 86 insertions, 5 deletions
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 2ae04522cd5a..40d18e866269 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -26,7 +26,7 @@
26#include <linux/acpi.h> 26#include <linux/acpi.h>
27 27
28/* Information for net-next */ 28/* Information for net-next */
29#define NETNEXT_VERSION "09" 29#define NETNEXT_VERSION "10"
30 30
31/* Information for net */ 31/* Information for net */
32#define NET_VERSION "10" 32#define NET_VERSION "10"
@@ -584,7 +584,7 @@ enum rtl_register_content {
584#define TX_ALIGN 4 584#define TX_ALIGN 4
585#define RX_ALIGN 8 585#define RX_ALIGN 8
586 586
587#define RTL8152_MAX_RX_AGG (10 * RTL8152_MAX_RX) 587#define RTL8152_RX_MAX_PENDING 4096
588#define RTL8152_RXFG_HEADSZ 256 588#define RTL8152_RXFG_HEADSZ 256
589 589
590#define INTR_LINK 0x0004 590#define INTR_LINK 0x0004
@@ -756,6 +756,9 @@ struct r8152 {
756 u32 tx_qlen; 756 u32 tx_qlen;
757 u32 coalesce; 757 u32 coalesce;
758 u32 rx_buf_sz; 758 u32 rx_buf_sz;
759 u32 rx_copybreak;
760 u32 rx_pending;
761
759 u16 ocp_base; 762 u16 ocp_base;
760 u16 speed; 763 u16 speed;
761 u8 *intr_buff; 764 u8 *intr_buff;
@@ -1984,7 +1987,7 @@ static struct rx_agg *rtl_get_free_rx(struct r8152 *tp, gfp_t mflags)
1984 1987
1985 spin_unlock_irqrestore(&tp->rx_lock, flags); 1988 spin_unlock_irqrestore(&tp->rx_lock, flags);
1986 1989
1987 if (!agg_free && atomic_read(&tp->rx_count) < RTL8152_MAX_RX_AGG) 1990 if (!agg_free && atomic_read(&tp->rx_count) < tp->rx_pending)
1988 agg_free = alloc_rx_agg(tp, mflags); 1991 agg_free = alloc_rx_agg(tp, mflags);
1989 1992
1990 return agg_free; 1993 return agg_free;
@@ -2064,10 +2067,10 @@ static int rx_bottom(struct r8152 *tp, int budget)
2064 pkt_len -= ETH_FCS_LEN; 2067 pkt_len -= ETH_FCS_LEN;
2065 rx_data += sizeof(struct rx_desc); 2068 rx_data += sizeof(struct rx_desc);
2066 2069
2067 if (!agg_free || RTL8152_RXFG_HEADSZ > pkt_len) 2070 if (!agg_free || tp->rx_copybreak > pkt_len)
2068 rx_frag_head_sz = pkt_len; 2071 rx_frag_head_sz = pkt_len;
2069 else 2072 else
2070 rx_frag_head_sz = RTL8152_RXFG_HEADSZ; 2073 rx_frag_head_sz = tp->rx_copybreak;
2071 2074
2072 skb = napi_alloc_skb(napi, rx_frag_head_sz); 2075 skb = napi_alloc_skb(napi, rx_frag_head_sz);
2073 if (!skb) { 2076 if (!skb) {
@@ -5104,6 +5107,77 @@ static int rtl8152_set_coalesce(struct net_device *netdev,
5104 return ret; 5107 return ret;
5105} 5108}
5106 5109
5110static int rtl8152_get_tunable(struct net_device *netdev,
5111 const struct ethtool_tunable *tunable, void *d)
5112{
5113 struct r8152 *tp = netdev_priv(netdev);
5114
5115 switch (tunable->id) {
5116 case ETHTOOL_RX_COPYBREAK:
5117 *(u32 *)d = tp->rx_copybreak;
5118 break;
5119 default:
5120 return -EOPNOTSUPP;
5121 }
5122
5123 return 0;
5124}
5125
5126static int rtl8152_set_tunable(struct net_device *netdev,
5127 const struct ethtool_tunable *tunable,
5128 const void *d)
5129{
5130 struct r8152 *tp = netdev_priv(netdev);
5131 u32 val;
5132
5133 switch (tunable->id) {
5134 case ETHTOOL_RX_COPYBREAK:
5135 val = *(u32 *)d;
5136 if (val < ETH_ZLEN) {
5137 netif_err(tp, rx_err, netdev,
5138 "Invalid rx copy break value\n");
5139 return -EINVAL;
5140 }
5141
5142 if (tp->rx_copybreak != val) {
5143 napi_disable(&tp->napi);
5144 tp->rx_copybreak = val;
5145 napi_enable(&tp->napi);
5146 }
5147 break;
5148 default:
5149 return -EOPNOTSUPP;
5150 }
5151
5152 return 0;
5153}
5154
5155static void rtl8152_get_ringparam(struct net_device *netdev,
5156 struct ethtool_ringparam *ring)
5157{
5158 struct r8152 *tp = netdev_priv(netdev);
5159
5160 ring->rx_max_pending = RTL8152_RX_MAX_PENDING;
5161 ring->rx_pending = tp->rx_pending;
5162}
5163
5164static int rtl8152_set_ringparam(struct net_device *netdev,
5165 struct ethtool_ringparam *ring)
5166{
5167 struct r8152 *tp = netdev_priv(netdev);
5168
5169 if (ring->rx_pending < (RTL8152_MAX_RX * 2))
5170 return -EINVAL;
5171
5172 if (tp->rx_pending != ring->rx_pending) {
5173 napi_disable(&tp->napi);
5174 tp->rx_pending = ring->rx_pending;
5175 napi_enable(&tp->napi);
5176 }
5177
5178 return 0;
5179}
5180
5107static const struct ethtool_ops ops = { 5181static const struct ethtool_ops ops = {
5108 .get_drvinfo = rtl8152_get_drvinfo, 5182 .get_drvinfo = rtl8152_get_drvinfo,
5109 .get_link = ethtool_op_get_link, 5183 .get_link = ethtool_op_get_link,
@@ -5121,6 +5195,10 @@ static const struct ethtool_ops ops = {
5121 .set_eee = rtl_ethtool_set_eee, 5195 .set_eee = rtl_ethtool_set_eee,
5122 .get_link_ksettings = rtl8152_get_link_ksettings, 5196 .get_link_ksettings = rtl8152_get_link_ksettings,
5123 .set_link_ksettings = rtl8152_set_link_ksettings, 5197 .set_link_ksettings = rtl8152_set_link_ksettings,
5198 .get_tunable = rtl8152_get_tunable,
5199 .set_tunable = rtl8152_set_tunable,
5200 .get_ringparam = rtl8152_get_ringparam,
5201 .set_ringparam = rtl8152_set_ringparam,
5124}; 5202};
5125 5203
5126static int rtl8152_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) 5204static int rtl8152_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
@@ -5474,6 +5552,9 @@ static int rtl8152_probe(struct usb_interface *intf,
5474 tp->speed = tp->mii.supports_gmii ? SPEED_1000 : SPEED_100; 5552 tp->speed = tp->mii.supports_gmii ? SPEED_1000 : SPEED_100;
5475 tp->duplex = DUPLEX_FULL; 5553 tp->duplex = DUPLEX_FULL;
5476 5554
5555 tp->rx_copybreak = RTL8152_RXFG_HEADSZ;
5556 tp->rx_pending = 10 * RTL8152_MAX_RX;
5557
5477 intf->needs_remote_wakeup = 1; 5558 intf->needs_remote_wakeup = 1;
5478 5559
5479 tp->rtl_ops.init(tp); 5560 tp->rtl_ops.init(tp);