Skip to content

Commit 562cf77

Browse files
julianwiedmanndavem330
authored andcommitted
s390/qeth: support configurable RX copybreak
Implement the ethtool hooks for the ETHTOOL_RX_COPYBREAK tunable. The copybreak is stored into netdev_priv, so that we automatically go back to the default value if the netdev is re-allocated. Signed-off-by: Julian Wiedmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3d35dbe commit 562cf77

File tree

3 files changed

+48
-10
lines changed

3 files changed

+48
-10
lines changed

drivers/s390/net/qeth_core.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ struct qeth_vnicc_info {
189189
#define QETH_IQD_MIN_TXQ 2 /* One for ucast, one for mcast. */
190190
#define QETH_IQD_MCAST_TXQ 0
191191
#define QETH_IQD_MIN_UCAST_TXQ 1
192+
193+
#define QETH_RX_COPYBREAK (PAGE_SIZE >> 1)
192194
#define QETH_IN_BUF_SIZE_DEFAULT 65536
193195
#define QETH_IN_BUF_COUNT_DEFAULT 64
194196
#define QETH_IN_BUF_COUNT_HSDEFAULT 128
@@ -219,9 +221,6 @@ struct qeth_vnicc_info {
219221
#define QETH_HIGH_WATERMARK_PACK 5
220222
#define QETH_WATERMARK_PACK_FUZZ 1
221223

222-
/* large receive scatter gather copy break */
223-
#define QETH_RX_SG_CB (PAGE_SIZE >> 1)
224-
225224
struct qeth_hdr_layer3 {
226225
__u8 id;
227226
__u8 flags;
@@ -711,7 +710,6 @@ struct qeth_card_options {
711710
struct qeth_vnicc_info vnicc; /* VNICC options */
712711
int fake_broadcast;
713712
enum qeth_discipline_id layer;
714-
int rx_sg_cb;
715713
enum qeth_ipa_isolation_modes isolation;
716714
enum qeth_ipa_isolation_modes prev_isolation;
717715
int sniffer;
@@ -770,6 +768,10 @@ struct qeth_switch_info {
770768
__u32 settings;
771769
};
772770

771+
struct qeth_priv {
772+
unsigned int rx_copybreak;
773+
};
774+
773775
#define QETH_NAPI_WEIGHT NAPI_POLL_WEIGHT
774776

775777
struct qeth_card {

drivers/s390/net/qeth_core_main.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,6 @@ static void qeth_set_initial_options(struct qeth_card *card)
12571257
{
12581258
card->options.route4.type = NO_ROUTER;
12591259
card->options.route6.type = NO_ROUTER;
1260-
card->options.rx_sg_cb = QETH_RX_SG_CB;
12611260
card->options.isolation = ISOLATION_MODE_NONE;
12621261
card->options.cq = QETH_CQ_DISABLED;
12631262
card->options.layer = QETH_DISCIPLINE_UNDETERMINED;
@@ -5268,6 +5267,7 @@ static int qeth_extract_skb(struct qeth_card *card,
52685267
int *__offset)
52695268
{
52705269
struct qdio_buffer_element *element = *__element;
5270+
struct qeth_priv *priv = netdev_priv(card->dev);
52715271
struct qdio_buffer *buffer = qethbuffer->buffer;
52725272
struct napi_struct *napi = &card->napi;
52735273
unsigned int linear_len = 0;
@@ -5343,7 +5343,7 @@ static int qeth_extract_skb(struct qeth_card *card,
53435343
}
53445344

53455345
use_rx_sg = (card->options.cq == QETH_CQ_ENABLED) ||
5346-
(skb_len > card->options.rx_sg_cb &&
5346+
(skb_len > READ_ONCE(priv->rx_copybreak) &&
53475347
!atomic_read(&card->force_alloc_skb) &&
53485348
!IS_OSN(card));
53495349

@@ -5892,25 +5892,30 @@ static void qeth_clear_dbf_list(void)
58925892
static struct net_device *qeth_alloc_netdev(struct qeth_card *card)
58935893
{
58945894
struct net_device *dev;
5895+
struct qeth_priv *priv;
58955896

58965897
switch (card->info.type) {
58975898
case QETH_CARD_TYPE_IQD:
5898-
dev = alloc_netdev_mqs(0, "hsi%d", NET_NAME_UNKNOWN,
5899+
dev = alloc_netdev_mqs(sizeof(*priv), "hsi%d", NET_NAME_UNKNOWN,
58995900
ether_setup, QETH_MAX_QUEUES, 1);
59005901
break;
59015902
case QETH_CARD_TYPE_OSM:
5902-
dev = alloc_etherdev(0);
5903+
dev = alloc_etherdev(sizeof(*priv));
59035904
break;
59045905
case QETH_CARD_TYPE_OSN:
5905-
dev = alloc_netdev(0, "osn%d", NET_NAME_UNKNOWN, ether_setup);
5906+
dev = alloc_netdev(sizeof(*priv), "osn%d", NET_NAME_UNKNOWN,
5907+
ether_setup);
59065908
break;
59075909
default:
5908-
dev = alloc_etherdev_mqs(0, QETH_MAX_QUEUES, 1);
5910+
dev = alloc_etherdev_mqs(sizeof(*priv), QETH_MAX_QUEUES, 1);
59095911
}
59105912

59115913
if (!dev)
59125914
return NULL;
59135915

5916+
priv = netdev_priv(dev);
5917+
priv->rx_copybreak = QETH_RX_COPYBREAK;
5918+
59145919
dev->ml_priv = card;
59155920
dev->watchdog_timeo = QETH_TX_TIMEOUT;
59165921
dev->min_mtu = IS_OSN(card) ? 64 : 576;

drivers/s390/net/qeth_ethtool.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,35 @@ static void qeth_get_channels(struct net_device *dev,
175175
channels->combined_count = 0;
176176
}
177177

178+
static int qeth_get_tunable(struct net_device *dev,
179+
const struct ethtool_tunable *tuna, void *data)
180+
{
181+
struct qeth_priv *priv = netdev_priv(dev);
182+
183+
switch (tuna->id) {
184+
case ETHTOOL_RX_COPYBREAK:
185+
*(u32 *)data = priv->rx_copybreak;
186+
return 0;
187+
default:
188+
return -EOPNOTSUPP;
189+
}
190+
}
191+
192+
static int qeth_set_tunable(struct net_device *dev,
193+
const struct ethtool_tunable *tuna,
194+
const void *data)
195+
{
196+
struct qeth_priv *priv = netdev_priv(dev);
197+
198+
switch (tuna->id) {
199+
case ETHTOOL_RX_COPYBREAK:
200+
WRITE_ONCE(priv->rx_copybreak, *(u32 *)data);
201+
return 0;
202+
default:
203+
return -EOPNOTSUPP;
204+
}
205+
}
206+
178207
/* Helper function to fill 'advertising' and 'supported' which are the same. */
179208
/* Autoneg and full-duplex are supported and advertised unconditionally. */
180209
/* Always advertise and support all speeds up to specified, and only one */
@@ -381,6 +410,8 @@ const struct ethtool_ops qeth_ethtool_ops = {
381410
.get_sset_count = qeth_get_sset_count,
382411
.get_drvinfo = qeth_get_drvinfo,
383412
.get_channels = qeth_get_channels,
413+
.get_tunable = qeth_get_tunable,
414+
.set_tunable = qeth_set_tunable,
384415
.get_link_ksettings = qeth_get_link_ksettings,
385416
};
386417

0 commit comments

Comments
 (0)