From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by dpdk.org (Postfix) with ESMTP id F35DC1B5BD for ; Fri, 30 Nov 2018 20:47:55 +0100 (CET) Received: by mail-lf1-f66.google.com with SMTP id l10so4944189lfh.9 for ; Fri, 30 Nov 2018 11:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nfware-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4aVTcA43Gl//yQHzrbdCHU77LKjQFJOefpcsa3/1RW0=; b=pF3qHnEqmq6+Xz2r9RFHlcOYGr0/ej+cwSpQ/1wPytrsOf4tixQV3Oe9EW+5L0+lN3 QLdlvtmvE5aWh7TaO1BNi5EVP0zFaedVQ8uFgOekvQseGRml8Cbkn2EGQgURx6NtDpYM MnIFerhAABCnyXAaNPB3Tqg6h5HphgtT0+GC7LuEA3Ea3Mm+LT+rBoluFrOPMLfgn0/i U/rekQeNGG7yoRq3edEg6+CAARwGsbuh5FBRm3kuJxT0qvzswFWy2wt17H8MO6kfgyy6 wY3PVPC+CEbdf+NZy4MvASGJzY0imTa9S5uxykLEGh7NhKCT2rgv0g93STPrtiNhgKZm xKdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4aVTcA43Gl//yQHzrbdCHU77LKjQFJOefpcsa3/1RW0=; b=WHSG5T4Hc1qYkjh5po3KCi6UPeps1u3HjcH8lUU5t/TV6onrpMH2U7evtrBhGrOmIc Gy1JOIthkI4ih+PC1q+z3tJYVg0tZcithyBTAONEo7HF99fnUCMyuFnlK7SjYrKDwbn8 h95wzcXtJYK8BD2jN+65ju5PxaYjExmduwiLe0VyAKRc/i+f28nDBpFPHUEYZ4neN6No OGsNQRjp6rgEXRKXbW5jwkFoTPVqulXvlNRBKNb36lLz4NB1jiVuidwiB+UVWugCFFzC BVhNWBT/dP8sS+xNOAPFDUDdqLnq+ktQZo24X6bxFyuuJc9H6pRype5rt81jD1SlyWbO d0Lw== X-Gm-Message-State: AA+aEWbjjPoNufLOjzEpmlyYv3wbHkC9tksOLjk/nYsnm4CNzMwaU0D1 2Y9E717wFgRE/pPOlcJKDcway0iAWOg= X-Google-Smtp-Source: AFSGD/X0RQEq4c8lRtZEzjUvDXACceCGU59gKcfuHZIfZ/EvKl+cQ3ae/Ri4w9x8NbyxMOyhdtuHDg== X-Received: by 2002:a19:1d0d:: with SMTP id d13mr4285250lfd.74.1543607274973; Fri, 30 Nov 2018 11:47:54 -0800 (PST) Received: from localhost.localdomain ([212.48.63.198]) by smtp.gmail.com with ESMTPSA id r4sm966860lfe.60.2018.11.30.11.47.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 11:47:54 -0800 (PST) From: Igor Ryzhov To: dev@dpdk.org Date: Fri, 30 Nov 2018 22:47:50 +0300 Message-Id: <20181130194750.13870-1-iryzhov@nfware.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130192946.13732-1-iryzhov@nfware.com> References: <20181130192946.13732-1-iryzhov@nfware.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] kni: use kni_ethtool_ops only with unknown drivers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Nov 2018 19:47:56 -0000 Current implementation of kni_ethtool_ops just uses corresponding ethtool_ops function of underlying driver for all functions except for .get_link. This commit sets kni->net_dev->ethtool_ops directly to the ethtool_ops of the corresponding driver. For unknown drivers (all but ixgbe and i40e) we still use kni_ethtool_ops with implemented .get_link function. Signed-off-by: Igor Ryzhov --- kernel/linux/kni/Makefile | 2 +- kernel/linux/kni/kni_ethtool.c | 210 --------------------------------- kernel/linux/kni/kni_misc.c | 9 +- 3 files changed, 7 insertions(+), 214 deletions(-) diff --git a/kernel/linux/kni/Makefile b/kernel/linux/kni/Makefile index 282be7b68..ee5e1e136 100644 --- a/kernel/linux/kni/Makefile +++ b/kernel/linux/kni/Makefile @@ -30,7 +30,7 @@ endif # SRCS-y := kni_misc.c SRCS-y += kni_net.c -SRCS-$(CONFIG_RTE_KNI_KMOD_ETHTOOL) += kni_ethtool.c +SRCS-y += kni_ethtool.c SRCS-$(CONFIG_RTE_KNI_KMOD_ETHTOOL) += ethtool/ixgbe/ixgbe_main.c SRCS-$(CONFIG_RTE_KNI_KMOD_ETHTOOL) += ethtool/ixgbe/ixgbe_api.c diff --git a/kernel/linux/kni/kni_ethtool.c b/kernel/linux/kni/kni_ethtool.c index b1c84f8f0..ccfd58ef0 100644 --- a/kernel/linux/kni/kni_ethtool.c +++ b/kernel/linux/kni/kni_ethtool.c @@ -8,218 +8,8 @@ #include #include "kni_dev.h" -static int -kni_check_if_running(struct net_device *dev) -{ - struct kni_dev *priv = netdev_priv(dev); - - if (priv->lad_dev) - return 0; - else - return -EOPNOTSUPP; -} - -static void -kni_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) -{ - struct kni_dev *priv = netdev_priv(dev); - - priv->lad_dev->ethtool_ops->get_drvinfo(priv->lad_dev, info); -} - -/* ETHTOOL_GLINKSETTINGS replaces ETHTOOL_GSET */ -#ifndef ETHTOOL_GLINKSETTINGS -static int -kni_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->get_settings(priv->lad_dev, ecmd); -} -#endif - -/* ETHTOOL_SLINKSETTINGS replaces ETHTOOL_SSET */ -#ifndef ETHTOOL_SLINKSETTINGS -static int -kni_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->set_settings(priv->lad_dev, ecmd); -} -#endif - -static void -kni_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) -{ - struct kni_dev *priv = netdev_priv(dev); - - priv->lad_dev->ethtool_ops->get_wol(priv->lad_dev, wol); -} - -static int -kni_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->set_wol(priv->lad_dev, wol); -} - -static int -kni_nway_reset(struct net_device *dev) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->nway_reset(priv->lad_dev); -} - -static int -kni_get_eeprom_len(struct net_device *dev) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->get_eeprom_len(priv->lad_dev); -} - -static int -kni_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, - u8 *bytes) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->get_eeprom(priv->lad_dev, eeprom, - bytes); -} - -static int -kni_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, - u8 *bytes) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->set_eeprom(priv->lad_dev, eeprom, - bytes); -} - -static void -kni_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) -{ - struct kni_dev *priv = netdev_priv(dev); - - priv->lad_dev->ethtool_ops->get_ringparam(priv->lad_dev, ring); -} - -static int -kni_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->set_ringparam(priv->lad_dev, ring); -} - -static void -kni_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause) -{ - struct kni_dev *priv = netdev_priv(dev); - - priv->lad_dev->ethtool_ops->get_pauseparam(priv->lad_dev, pause); -} - -static int -kni_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->set_pauseparam(priv->lad_dev, - pause); -} - -static u32 -kni_get_msglevel(struct net_device *dev) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->get_msglevel(priv->lad_dev); -} - -static void -kni_set_msglevel(struct net_device *dev, u32 data) -{ - struct kni_dev *priv = netdev_priv(dev); - - priv->lad_dev->ethtool_ops->set_msglevel(priv->lad_dev, data); -} - -static int -kni_get_regs_len(struct net_device *dev) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->get_regs_len(priv->lad_dev); -} - -static void -kni_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) -{ - struct kni_dev *priv = netdev_priv(dev); - - priv->lad_dev->ethtool_ops->get_regs(priv->lad_dev, regs, p); -} - -static void -kni_get_strings(struct net_device *dev, u32 stringset, u8 *data) -{ - struct kni_dev *priv = netdev_priv(dev); - - priv->lad_dev->ethtool_ops->get_strings(priv->lad_dev, stringset, - data); -} - -static int -kni_get_sset_count(struct net_device *dev, int sset) -{ - struct kni_dev *priv = netdev_priv(dev); - - return priv->lad_dev->ethtool_ops->get_sset_count(priv->lad_dev, sset); -} - -static void -kni_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, - u64 *data) -{ - struct kni_dev *priv = netdev_priv(dev); - - priv->lad_dev->ethtool_ops->get_ethtool_stats(priv->lad_dev, stats, - data); -} - struct ethtool_ops kni_ethtool_ops = { - .begin = kni_check_if_running, - .get_drvinfo = kni_get_drvinfo, -#ifndef ETHTOOL_GLINKSETTINGS - .get_settings = kni_get_settings, -#endif -#ifndef ETHTOOL_SLINKSETTINGS - .set_settings = kni_set_settings, -#endif - .get_regs_len = kni_get_regs_len, - .get_regs = kni_get_regs, - .get_wol = kni_get_wol, - .set_wol = kni_set_wol, - .nway_reset = kni_nway_reset, .get_link = ethtool_op_get_link, - .get_eeprom_len = kni_get_eeprom_len, - .get_eeprom = kni_get_eeprom, - .set_eeprom = kni_set_eeprom, - .get_ringparam = kni_get_ringparam, - .set_ringparam = kni_set_ringparam, - .get_pauseparam = kni_get_pauseparam, - .set_pauseparam = kni_set_pauseparam, - .get_msglevel = kni_get_msglevel, - .set_msglevel = kni_set_msglevel, - .get_strings = kni_get_strings, - .get_sset_count = kni_get_sset_count, - .get_ethtool_stats = kni_get_ethtool_stats, }; void diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c index 522ae23b9..e22a1a717 100644 --- a/kernel/linux/kni/kni_misc.c +++ b/kernel/linux/kni/kni_misc.c @@ -426,7 +426,6 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, pci, lad_dev); if (ret == 0) { kni->lad_dev = lad_dev; - kni_set_ethtool_ops(kni->net_dev); } else { pr_err("Device not supported by ethtool"); kni->lad_dev = NULL; @@ -443,9 +442,13 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, pci_dev_put(pci); #endif - if (kni->lad_dev) + if (kni->lad_dev) { + kni->net_dev->ethtool_ops = kni->lad_dev->ethtool_ops; + ether_addr_copy(net_dev->dev_addr, kni->lad_dev->dev_addr); - else { + } else { + kni_set_ethtool_ops(kni->net_dev); + /* if user has provided a valid mac address */ if (is_valid_ether_addr((unsigned char *)(dev_info.mac_addr))) memcpy(net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN); -- 2.19.1