]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
s390/qeth: support configurable RX copybreak
authorJulian Wiedmann <jwi@linux.ibm.com>
Thu, 27 Feb 2020 17:08:16 +0000 (18:08 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Feb 2020 19:15:13 +0000 (11:15 -0800)
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 <jwi@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_core.h
drivers/s390/net/qeth_core_main.c
drivers/s390/net/qeth_ethtool.c

index 9575a627a1e18d446cf79dd7cb4011dfa2f2accf..b7d64690ea38909e20c46216486c900fa2eaf1c2 100644 (file)
@@ -189,6 +189,8 @@ struct qeth_vnicc_info {
 #define QETH_IQD_MIN_TXQ       2       /* One for ucast, one for mcast. */
 #define QETH_IQD_MCAST_TXQ     0
 #define QETH_IQD_MIN_UCAST_TXQ 1
+
+#define QETH_RX_COPYBREAK      (PAGE_SIZE >> 1)
 #define QETH_IN_BUF_SIZE_DEFAULT 65536
 #define QETH_IN_BUF_COUNT_DEFAULT 64
 #define QETH_IN_BUF_COUNT_HSDEFAULT 128
@@ -219,9 +221,6 @@ struct qeth_vnicc_info {
 #define QETH_HIGH_WATERMARK_PACK 5
 #define QETH_WATERMARK_PACK_FUZZ 1
 
-/* large receive scatter gather copy break */
-#define QETH_RX_SG_CB (PAGE_SIZE >> 1)
-
 struct qeth_hdr_layer3 {
        __u8  id;
        __u8  flags;
@@ -711,7 +710,6 @@ struct qeth_card_options {
        struct qeth_vnicc_info vnicc; /* VNICC options */
        int fake_broadcast;
        enum qeth_discipline_id layer;
-       int rx_sg_cb;
        enum qeth_ipa_isolation_modes isolation;
        enum qeth_ipa_isolation_modes prev_isolation;
        int sniffer;
@@ -770,6 +768,10 @@ struct qeth_switch_info {
        __u32 settings;
 };
 
+struct qeth_priv {
+       unsigned int rx_copybreak;
+};
+
 #define QETH_NAPI_WEIGHT NAPI_POLL_WEIGHT
 
 struct qeth_card {
index cbd2b4c46ea4dd4e229fc0fc3b027379091861c3..1bcac50bb3954b57ded504d663ca63ec3ca6ad45 100644 (file)
@@ -1257,7 +1257,6 @@ static void qeth_set_initial_options(struct qeth_card *card)
 {
        card->options.route4.type = NO_ROUTER;
        card->options.route6.type = NO_ROUTER;
-       card->options.rx_sg_cb = QETH_RX_SG_CB;
        card->options.isolation = ISOLATION_MODE_NONE;
        card->options.cq = QETH_CQ_DISABLED;
        card->options.layer = QETH_DISCIPLINE_UNDETERMINED;
@@ -5268,6 +5267,7 @@ static int qeth_extract_skb(struct qeth_card *card,
                            int *__offset)
 {
        struct qdio_buffer_element *element = *__element;
+       struct qeth_priv *priv = netdev_priv(card->dev);
        struct qdio_buffer *buffer = qethbuffer->buffer;
        struct napi_struct *napi = &card->napi;
        unsigned int linear_len = 0;
@@ -5343,7 +5343,7 @@ next_packet:
        }
 
        use_rx_sg = (card->options.cq == QETH_CQ_ENABLED) ||
-                   (skb_len > card->options.rx_sg_cb &&
+                   (skb_len > READ_ONCE(priv->rx_copybreak) &&
                     !atomic_read(&card->force_alloc_skb) &&
                     !IS_OSN(card));
 
@@ -5892,25 +5892,30 @@ static void qeth_clear_dbf_list(void)
 static struct net_device *qeth_alloc_netdev(struct qeth_card *card)
 {
        struct net_device *dev;
+       struct qeth_priv *priv;
 
        switch (card->info.type) {
        case QETH_CARD_TYPE_IQD:
-               dev = alloc_netdev_mqs(0, "hsi%d", NET_NAME_UNKNOWN,
+               dev = alloc_netdev_mqs(sizeof(*priv), "hsi%d", NET_NAME_UNKNOWN,
                                       ether_setup, QETH_MAX_QUEUES, 1);
                break;
        case QETH_CARD_TYPE_OSM:
-               dev = alloc_etherdev(0);
+               dev = alloc_etherdev(sizeof(*priv));
                break;
        case QETH_CARD_TYPE_OSN:
-               dev = alloc_netdev(0, "osn%d", NET_NAME_UNKNOWN, ether_setup);
+               dev = alloc_netdev(sizeof(*priv), "osn%d", NET_NAME_UNKNOWN,
+                                  ether_setup);
                break;
        default:
-               dev = alloc_etherdev_mqs(0, QETH_MAX_QUEUES, 1);
+               dev = alloc_etherdev_mqs(sizeof(*priv), QETH_MAX_QUEUES, 1);
        }
 
        if (!dev)
                return NULL;
 
+       priv = netdev_priv(dev);
+       priv->rx_copybreak = QETH_RX_COPYBREAK;
+
        dev->ml_priv = card;
        dev->watchdog_timeo = QETH_TX_TIMEOUT;
        dev->min_mtu = IS_OSN(card) ? 64 : 576;
index ab59bc975719dcf14df6234b11e40f14df3fa019..9052c72d5b8fb2df2c64ff6b2107540aafe3741b 100644 (file)
@@ -175,6 +175,35 @@ static void qeth_get_channels(struct net_device *dev,
        channels->combined_count = 0;
 }
 
+static int qeth_get_tunable(struct net_device *dev,
+                           const struct ethtool_tunable *tuna, void *data)
+{
+       struct qeth_priv *priv = netdev_priv(dev);
+
+       switch (tuna->id) {
+       case ETHTOOL_RX_COPYBREAK:
+               *(u32 *)data = priv->rx_copybreak;
+               return 0;
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+static int qeth_set_tunable(struct net_device *dev,
+                           const struct ethtool_tunable *tuna,
+                           const void *data)
+{
+       struct qeth_priv *priv = netdev_priv(dev);
+
+       switch (tuna->id) {
+       case ETHTOOL_RX_COPYBREAK:
+               WRITE_ONCE(priv->rx_copybreak, *(u32 *)data);
+               return 0;
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
 /* Helper function to fill 'advertising' and 'supported' which are the same. */
 /* Autoneg and full-duplex are supported and advertised unconditionally.     */
 /* Always advertise and support all speeds up to specified, and only one     */
@@ -381,6 +410,8 @@ const struct ethtool_ops qeth_ethtool_ops = {
        .get_sset_count = qeth_get_sset_count,
        .get_drvinfo = qeth_get_drvinfo,
        .get_channels = qeth_get_channels,
+       .get_tunable = qeth_get_tunable,
+       .set_tunable = qeth_set_tunable,
        .get_link_ksettings = qeth_get_link_ksettings,
 };