DPDK patches and discussions
 help / color / mirror / Atom feed
From: Raslan Darawsheh <rasland@mellanox.com>
To: pascal.mazon@6wind.com
Cc: adrien.mazarguil@6wind.com, dev@dpdk.org,
	stephen@networkplumber.org, thomas@monjalon.net
Subject: [dpdk-dev] [PATCH] net/tap: remove Linux version check
Date: Mon, 10 Jul 2017 11:13:43 +0300	[thread overview]
Message-ID: <1499674423-4235-1-git-send-email-rasland@mellanox.com> (raw)

Remove checks of Linux kernel version
in order to support kernel with backported features.

The expected behavior with a kernel that doesn't
support flower and other bits is the following:
	-flow validate can return successfully.
	-flow create using the same rule fails.

Using the  "remote" feature without kernel flower doesn not fail silently.
The TAP instance is not initialized if the requested parameters cannot be satisfied.

it has been tested on an old kernel without required support:

PMD: Kernel refused TC filter rule creation (2): No such file or directory
PMD: tap0 failed to create implicit rules.
PMD: Can't set up remote feature: No such file of directory(2)
PMD: TAP Unable to initialize net_tap0

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 drivers/net/tap/rte_eth_tap.c | 38 +-------------------------------------
 drivers/net/tap/rte_eth_tap.h |  2 --
 drivers/net/tap/tap_flow.c    | 13 +------------
 3 files changed, 2 insertions(+), 51 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index e54758e..b9e3ee9 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -77,9 +77,6 @@
 #define ETH_TAP_MAC_ARG         "mac"
 #define ETH_TAP_MAC_FIXED       "fixed"
 
-#define FLOWER_KERNEL_VERSION KERNEL_VERSION(4, 2, 0)
-#define FLOWER_VLAN_KERNEL_VERSION KERNEL_VERSION(4, 9, 0)
-
 static struct rte_vdev_driver pmd_tap_drv;
 
 static const char *valid_arguments[] = {
@@ -1162,24 +1159,6 @@ static const struct eth_dev_ops ops = {
 };
 
 static int
-tap_kernel_support(struct pmd_internals *pmd)
-{
-	struct utsname utsname;
-	int ver[3];
-
-	if (uname(&utsname) == -1 ||
-	    sscanf(utsname.release, "%d.%d.%d",
-		   &ver[0], &ver[1], &ver[2]) != 3)
-		return 0;
-	if (KERNEL_VERSION(ver[0], ver[1], ver[2]) >= FLOWER_KERNEL_VERSION)
-		pmd->flower_support = 1;
-	if (KERNEL_VERSION(ver[0], ver[1], ver[2]) >=
-	    FLOWER_VLAN_KERNEL_VERSION)
-		pmd->flower_vlan_support = 1;
-	return 1;
-}
-
-static int
 eth_dev_tap_create(const char *name, char *tap_name, char *remote_iface,
 		   int fixed_mac_type)
 {
@@ -1278,20 +1257,6 @@ eth_dev_tap_create(const char *name, char *tap_name, char *remote_iface,
 	if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 0, LOCAL_ONLY) < 0)
 		goto error_exit;
 
-	tap_kernel_support(pmd);
-	if (!pmd->flower_support) {
-		if (remote_iface[0]) {
-			RTE_LOG(ERR, PMD,
-				"%s: kernel does not support TC rules, required for remote feature.",
-				pmd->name);
-			goto error_exit;
-		} else {
-			RTE_LOG(INFO, PMD,
-				"%s: kernel too old for Flow API support.\n",
-				pmd->name);
-			return 0;
-		}
-	}
 
 	LIST_INIT(&pmd->flows);
 	LIST_INIT(&pmd->implicit_flows);
@@ -1382,7 +1347,6 @@ eth_dev_tap_create(const char *name, char *tap_name, char *remote_iface,
 		RTE_LOG(ERR, PMD, "Remote feature requires flow support.\n");
 		goto error_exit;
 	}
-	pmd->flower_support = 0;
 	return 0;
 
 error_remote:
@@ -1546,7 +1510,7 @@ rte_pmd_tap_remove(const char *name)
 		return 0;
 
 	internals = eth_dev->data->dev_private;
-	if (internals->flower_support && internals->nlsk_fd) {
+	if (internals->nlsk_fd) {
 		tap_flow_flush(eth_dev, NULL);
 		tap_flow_implicit_flush(internals, NULL);
 		nl_final(internals->nlsk_fd);
diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h
index 2f22b2d..55c0b3f 100644
--- a/drivers/net/tap/rte_eth_tap.h
+++ b/drivers/net/tap/rte_eth_tap.h
@@ -88,8 +88,6 @@ struct pmd_internals {
 	int ioctl_sock;                   /* socket for ioctl calls */
 	int nlsk_fd;                      /* Netlink socket fd */
 	int flow_isolate;                 /* 1 if flow isolation is enabled */
-	int flower_support;               /* 1 if kernel supports, else 0 */
-	int flower_vlan_support;          /* 1 if kernel supports, else 0 */
 	LIST_HEAD(tap_flows, rte_flow) flows;        /* rte_flow rules */
 	/* implicit rte_flow rules set when a remote device is active */
 	LIST_HEAD(tap_implicit_flows, rte_flow) implicit_flows;
diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index ebf4564..6ade186 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -1042,16 +1042,13 @@ priv_flow_process(struct pmd_internals *pmd,
 		if (err)
 			goto exit_item_not_supported;
 		if (flow && cur_item->convert) {
-			if (!pmd->flower_vlan_support &&
-			    cur_item->convert == tap_flow_create_vlan)
-				goto exit_item_not_supported;
 			err = cur_item->convert(items, &data);
 			if (err)
 				goto exit_item_not_supported;
 		}
 	}
 	if (flow) {
-		if (pmd->flower_vlan_support && data.vlan) {
+		if (data.vlan) {
 			nlattr_add16(&flow->msg.nh, TCA_FLOWER_KEY_ETH_TYPE,
 				     htons(ETH_P_8021Q));
 			nlattr_add16(&flow->msg.nh,
@@ -1401,10 +1398,6 @@ tap_flow_isolate(struct rte_eth_dev *dev,
 {
 	struct pmd_internals *pmd = dev->data->dev_private;
 
-	if (!pmd->flower_support)
-		return -rte_flow_error_set(
-			error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
-			"rte_flow isolate requires TC flower kernel support");
 	if (set)
 		pmd->flow_isolate = 1;
 	else
@@ -1650,10 +1643,6 @@ tap_dev_filter_ctrl(struct rte_eth_dev *dev,
 		    enum rte_filter_op filter_op,
 		    void *arg)
 {
-	struct pmd_internals *pmd = dev->data->dev_private;
-
-	if (!pmd->flower_support)
-		return -ENOTSUP;
 	switch (filter_type) {
 	case RTE_ETH_FILTER_GENERIC:
 		if (filter_op != RTE_ETH_FILTER_GET)
-- 
2.7.4

             reply	other threads:[~2017-07-10  8:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10  8:13 Raslan Darawsheh [this message]
2017-07-10 13:33 ` Pascal Mazon
2017-07-16 10:18 ` [dpdk-dev] [PATCH v2] " Raslan Darawsheh
2017-07-17  8:32   ` Pascal Mazon
2017-07-17  9:00 ` [dpdk-dev] [PATCH v3] " Raslan Darawsheh
2017-07-18 11:52   ` Pascal Mazon
2017-07-18 12:32     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1499674423-4235-1-git-send-email-rasland@mellanox.com \
    --to=rasland@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=pascal.mazon@6wind.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).