From patchwork Wed Jun 19 18:59:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55097 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EEFBF1D146; Wed, 19 Jun 2019 21:00:06 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id CA74F1C38D for ; Wed, 19 Jun 2019 21:00:02 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id n2so161822pgp.11 for ; Wed, 19 Jun 2019 12:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LyNzsR8H+QQKPGmEhnn+f4xkaZgLMnwHGhB18LvT0Ro=; b=JJX6XnUGudw8aTj/Fc0zLOSu8/11wxkh8XhNNb0qw+09NMM/Se1yZ5thKKlFas71x7 CBN4S/N7SU7s3YObh76CeUcloJFichbDTb6kQ9t3ubGXJFwzy7ACErkn47rd1qozAvPb RNyxM9JVQjITujUTL6unARaZXnKEFA+g5niS+M9BdJADGp5mfjLAgpqGmD0sOAnaUUmQ SPgoFlTA01yRACqVaHYH1V/pT9avP9zU+Uk8iX8xEZwPFbH3Tc3fd3MLfu4YSgCWPmTz UJvuCafE0dS3hLUKDyqbNUb0xsou+TAVG9eTwoQYGulWRxoAdwfTu2D1BFmZ8ahqW+w0 Tveg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LyNzsR8H+QQKPGmEhnn+f4xkaZgLMnwHGhB18LvT0Ro=; b=czyaU5zpTbjBKEjb9Y8Nvd1xUrnxDmIIHCbDxzfPqHvmVv3SayJ/RyDD9DAJJ8SgeC g83l5VUcFbPh9fNg7pspEZpzAFcOztrrRA+meqfjbXwnpDD2IVPzsrVSGkOyTAJxB11F fqdxy9PcbcGVG0ggtQKPTk3Gk5zNXNVtym6COyj2lVUr75KjsfQjRolyGgMIwjM+EBmp /EL9nUL4Nn1xJofGd0TR/SlXnpANs6zIOmxHaaQedekf0KW4RNtbHRw1L0fazdaOcMXg dvxLPgRMcXk9FaYgxGv93CxZ6W0Q2UqV5fvOUpAji6598rJzbWNWmywThQE126WHF28I L9sA== X-Gm-Message-State: APjAAAWPloggfYWddaQHTHSE8ti89GWm0e27M8Uqk8uIjJlW3pkMEgY0 hGeM4tvnH6IcbIDc9M+MFj1TnH5aevc= X-Google-Smtp-Source: APXvYqw09K/R0vDiPqoqXses/LCvdVLAok7S6rdbHrgJPfjtyTeJst6zc+YZQ5uVdW4+23MO5KaQRw== X-Received: by 2002:a63:1a03:: with SMTP id a3mr8631719pga.397.1560970801569; Wed, 19 Jun 2019 12:00:01 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id g8sm18613397pfi.8.2019.06.19.12.00.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 12:00:00 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:59:51 -0700 Message-Id: <20190619185958.27306-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185958.27306-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185958.27306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 1/8] kni: don't need stubs for rx_mode or ioctl 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger The netdev subsystem already handles case where network sevice does not support ioctl. If device has no rx_mode hook it is not called. Signed-off-by: Stephen Hemminger --- kernel/linux/kni/kni_net.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c index ad8365877cda..c86337d099ab 100644 --- a/kernel/linux/kni/kni_net.c +++ b/kernel/linux/kni/kni_net.c @@ -593,23 +593,6 @@ kni_net_tx_timeout(struct net_device *dev) netif_wake_queue(dev); } -/* - * Ioctl commands - */ -static int -kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - pr_debug("kni_net_ioctl group:%d cmd:%d\n", - ((struct kni_dev *)netdev_priv(dev))->group_id, cmd); - - return -EOPNOTSUPP; -} - -static void -kni_net_set_rx_mode(struct net_device *dev) -{ -} - static int kni_net_change_mtu(struct net_device *dev, int new_mtu) { @@ -758,8 +741,6 @@ static const struct net_device_ops kni_net_netdev_ops = { .ndo_change_rx_flags = kni_net_set_promiscusity, .ndo_start_xmit = kni_net_tx, .ndo_change_mtu = kni_net_change_mtu, - .ndo_do_ioctl = kni_net_ioctl, - .ndo_set_rx_mode = kni_net_set_rx_mode, .ndo_get_stats = kni_net_stats, .ndo_tx_timeout = kni_net_tx_timeout, .ndo_set_mac_address = kni_net_set_mac, From patchwork Wed Jun 19 18:59:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55098 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 485981D167; Wed, 19 Jun 2019 21:00:09 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 6D1121D123 for ; Wed, 19 Jun 2019 21:00:04 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id d126so153176pfd.2 for ; Wed, 19 Jun 2019 12:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+OFQZiHQfZ8LMLFPBeuGB6NyWoetkG0/c/wPapE/X44=; b=g/bcA+5QWXWrb3sH3L7jCymdduN8yGq295Lak4tDcFh8cNaKx9BgU5NAYEJS7xqJ2I S+aQUNRfqDkSX5qnlL1esAqfZJ1S/YRwI99IuT40rFEBSKO7pmY15/Gh19I7U6a86kzq r5QzNfoSMFy8EqUnrp6yYKa6/6gbiw++23/uXjnp5FvEuiWTYhlGk3BQqnQiBXqC7kNd ab2C9Zs5t1RFBtjdI9u/HX3FTuvT1cePiF1Aihyauvd010bOPyayBc1EkWAImrcrqfnj F9hovAAoNW9zWmzcpJlZseDaX/rJsJ6yRzYWpR2uy1k2bGAI01lPG4CnQubz+CTEaAHL mDvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+OFQZiHQfZ8LMLFPBeuGB6NyWoetkG0/c/wPapE/X44=; b=nMxIBA3BTEaOekoJxOt90vDLVUwnS+UMRAaE5MISIhweJALEXHjRzCdTV16ZVJF93G 4e1qBYPINhuU2IRktKXrQyFmPzkNjNxCvmMWLauNVCweHEA03yhT2D518KabgKA13Kuo HjadsLhex5L2ReiVUqqet6NuGlQ82aagH+A2ZXSAZaFTaFhVrRko4rwTa1Ut2cmVEuY4 VgcwlW6l6E7QqdsbV30n0dskXC1yDZbljP2tyfzOwYJgrKMTQimY4yYhqoXy99jffVpG TVuFH1M6qIqBa4nHqgf/QMmWociKDFOST3fVYT7noUstAo+Jg217Z6oE0CJB9sR5HQvc SB0Q== X-Gm-Message-State: APjAAAWPCZ2tHZmw66EK0N/zpHCmgBltjbhLsbInC3azio5gaDKsvtP8 bctBr6kOeEgPoNdxtZEkQPuKypxl9dg= X-Google-Smtp-Source: APXvYqwaXCoZDADByCDsmWP2cYMy/3jaBcdRT2UJvO7ply19gC+YTfmkk7upejWsqdpaWBl9kJ0jEQ== X-Received: by 2002:a63:3d0f:: with SMTP id k15mr9145385pga.343.1560970803355; Wed, 19 Jun 2019 12:00:03 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id g8sm18613397pfi.8.2019.06.19.12.00.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 12:00:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:59:52 -0700 Message-Id: <20190619185958.27306-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185958.27306-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185958.27306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 2/8] kni: use netdev_alloc_skb 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger netdev_alloc_skb is optimized to any alignment or setup of skb->dev that is required. The kernel has chosen to not pad packets on x86 (for many years), because it is faster. Signed-off-by: Stephen Hemminger --- kernel/linux/kni/kni_net.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c index c86337d099ab..cce5e7eb991f 100644 --- a/kernel/linux/kni/kni_net.c +++ b/kernel/linux/kni/kni_net.c @@ -340,16 +340,13 @@ kni_net_rx_normal(struct kni_dev *kni) data_kva = kva2data_kva(kva); kni->va[i] = pa2va(kni->pa[i], kva); - skb = dev_alloc_skb(len + 2); + skb = netdev_alloc_skb(dev, len); if (!skb) { /* Update statistics */ kni->stats.rx_dropped++; continue; } - /* Align IP on 16B boundary */ - skb_reserve(skb, 2); - if (kva->nb_segs == 1) { memcpy(skb_put(skb, len), data_kva, len); } else { @@ -368,7 +365,6 @@ kni_net_rx_normal(struct kni_dev *kni) } } - skb->dev = dev; skb->protocol = eth_type_trans(skb, dev); skb->ip_summed = CHECKSUM_UNNECESSARY; @@ -512,26 +508,20 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) data_kva = kva2data_kva(kva); kni->va[i] = pa2va(kni->pa[i], kva); - skb = dev_alloc_skb(len + 2); + skb = netdev_alloc_skb(dev, len); if (skb) { - /* Align IP on 16B boundary */ - skb_reserve(skb, 2); memcpy(skb_put(skb, len), data_kva, len); - skb->dev = dev; skb->ip_summed = CHECKSUM_UNNECESSARY; dev_kfree_skb(skb); } /* Simulate real usage, allocate/copy skb twice */ - skb = dev_alloc_skb(len + 2); + skb = netdev_alloc_skb(dev, len); if (skb == NULL) { kni->stats.rx_dropped++; continue; } - /* Align IP on 16B boundary */ - skb_reserve(skb, 2); - if (kva->nb_segs == 1) { memcpy(skb_put(skb, len), data_kva, len); } else { @@ -550,7 +540,6 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) } } - skb->dev = dev; skb->ip_summed = CHECKSUM_UNNECESSARY; kni->stats.rx_bytes += len; From patchwork Wed Jun 19 18:59:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55099 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3FD001D172; Wed, 19 Jun 2019 21:00:12 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 046701D144 for ; Wed, 19 Jun 2019 21:00:06 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id l19so166952pgh.9 for ; Wed, 19 Jun 2019 12:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5KQLa8JXU7iYjmTO14hFZMlxbnfGbb4eamPcVTXkkaE=; b=GSDKYXKXFg2WhB7hcjdEZ5vW91rSmc74hvYm4PZGrWBrSUNWMciWIboNoardYeUh4B BfujVxhRkej81vNAAIY20ts7TmmsMiTX3LvaIq096z1+vx1kQTqeKEKzwcQO/nIITRrh y0C73eWhwjPCp9wyoiFNqKtSKXIFLl3I7e7SWaE3BomL18yjRUQsP1FecA9032jjb9XT WixcN+JNBJT+tre7hM7JuCGHxFbDiNF3wfMB+XTYfzAb281ebkPyglM5tqL2rumIHpn3 5eFsq14r88vz0GhJQWguB5BJjUMCmMzhkOBHdqMsPbWOI9EkFKgEKHiJw9pngamiwUr8 8HkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5KQLa8JXU7iYjmTO14hFZMlxbnfGbb4eamPcVTXkkaE=; b=WqEbHRcJon06jEKs1Y+bPk2q4GFi2ZRchL4WdSYMXpWYEKJltvkZD7A+QA28jQ1F1X WYonC0obygcT+qOOUMvJ7B6wenTaiOgizBd+G/MX/8UquEufbOc9OvW5DMqMl2Y00uzC 4PJa6/Jt8C1p8OE4ranSPLFlDwHFzIiKHLU0vvz7WYCYFTUdlRJTj4FeMiucC82hk6s1 xOm+p9paCGzioOKdtJbTcf4zWv8UYO9Jeo/c+WAwycc6Ocos6GxoKNzJjZhESRBqk57w ezLosyh33nvV4sXhtuwPEmCV6IpgsoZxLoXrob8xkccC7U2DQJe+VcFfmqISpKjdN6K/ bbsQ== X-Gm-Message-State: APjAAAVUXnacERxLkeHnjonPfCzlEj8D/9E/BPekIBIKs1zA0dmEjADI VOoHMnp6+5Ebv8k+W2a0dOJgn7T6b9A= X-Google-Smtp-Source: APXvYqxXZ5T/VY3R5KR/pBDkkVjFV02bnv26P45QtA7867pInjcWD0b4tDFCzWE7lrhQvWChm47vUg== X-Received: by 2002:a65:448b:: with SMTP id l11mr8875537pgq.74.1560970804843; Wed, 19 Jun 2019 12:00:04 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id g8sm18613397pfi.8.2019.06.19.12.00.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 12:00:03 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:59:53 -0700 Message-Id: <20190619185958.27306-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185958.27306-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185958.27306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 3/8] kni: don't keep stats in kni_net 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger Since kernel 2.6.28 the network subsystem has provided dev->stats for devices to use statistics handling and is the default if no ndo_get_stats is provided. This allow allows for 64 bit (rather than just 32 bit) statistics with KNI. Signed-off-by: Stephen Hemminger --- kernel/linux/kni/kni_dev.h | 1 - kernel/linux/kni/kni_net.c | 43 +++++++++++++------------------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h index d57bce647e4a..21e4b0d92368 100644 --- a/kernel/linux/kni/kni_dev.h +++ b/kernel/linux/kni/kni_dev.h @@ -39,7 +39,6 @@ struct kni_dev { /* kni list */ struct list_head list; - struct net_device_stats stats; int status; uint16_t group_id; /* Group ID of a group of KNI devices */ uint32_t core_id; /* Core ID to bind */ diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c index cce5e7eb991f..06310fec57bb 100644 --- a/kernel/linux/kni/kni_net.c +++ b/kernel/linux/kni/kni_net.c @@ -291,15 +291,15 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev) /* Free skb and update statistics */ dev_kfree_skb(skb); - kni->stats.tx_bytes += len; - kni->stats.tx_packets++; + dev->stats.tx_bytes += len; + dev->stats.tx_packets++; return NETDEV_TX_OK; drop: /* Free skb and update statistics */ dev_kfree_skb(skb); - kni->stats.tx_dropped++; + dev->stats.tx_dropped++; return NETDEV_TX_OK; } @@ -343,7 +343,7 @@ kni_net_rx_normal(struct kni_dev *kni) skb = netdev_alloc_skb(dev, len); if (!skb) { /* Update statistics */ - kni->stats.rx_dropped++; + dev->stats.rx_dropped++; continue; } @@ -372,8 +372,8 @@ kni_net_rx_normal(struct kni_dev *kni) netif_rx_ni(skb); /* Update statistics */ - kni->stats.rx_bytes += len; - kni->stats.rx_packets++; + dev->stats.rx_bytes += len; + dev->stats.rx_packets++; } /* Burst enqueue mbufs into free_q */ @@ -396,6 +396,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni) void *data_kva; struct rte_kni_mbuf *alloc_kva; void *alloc_data_kva; + struct net_device *dev = kni->net_dev; /* Get the number of entries in rx_q */ num_rq = kni_fifo_count(kni->rx_q); @@ -443,8 +444,8 @@ kni_net_rx_lo_fifo(struct kni_dev *kni) alloc_kva->pkt_len = len; alloc_kva->data_len = len; - kni->stats.tx_bytes += len; - kni->stats.rx_bytes += len; + dev->stats.tx_bytes += len; + dev->stats.rx_bytes += len; } /* Burst enqueue mbufs into tx_q */ @@ -464,8 +465,8 @@ kni_net_rx_lo_fifo(struct kni_dev *kni) * Update statistic, and enqueue/dequeue failure is impossible, * as all queues are checked at first. */ - kni->stats.tx_packets += num; - kni->stats.rx_packets += num; + dev->stats.tx_packets += num; + dev->stats.rx_packets += num; } /* @@ -518,7 +519,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) /* Simulate real usage, allocate/copy skb twice */ skb = netdev_alloc_skb(dev, len); if (skb == NULL) { - kni->stats.rx_dropped++; + dev->stats.rx_dropped++; continue; } @@ -542,8 +543,8 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) skb->ip_summed = CHECKSUM_UNNECESSARY; - kni->stats.rx_bytes += len; - kni->stats.rx_packets++; + dev->stats.rx_bytes += len; + dev->stats.rx_packets++; /* call tx interface */ kni_net_tx(skb, dev); @@ -573,12 +574,10 @@ kni_net_rx(struct kni_dev *kni) static void kni_net_tx_timeout(struct net_device *dev) { - struct kni_dev *kni = netdev_priv(dev); - pr_debug("Transmit timeout at %ld, latency %ld\n", jiffies, jiffies - dev_trans_start(dev)); - kni->stats.tx_errors++; + dev->stats.tx_errors++; netif_wake_queue(dev); } @@ -627,17 +626,6 @@ kni_net_poll_resp(struct kni_dev *kni) wake_up_interruptible(&kni->wq); } -/* - * Return statistics to the caller - */ -static struct net_device_stats * -kni_net_stats(struct net_device *dev) -{ - struct kni_dev *kni = netdev_priv(dev); - - return &kni->stats; -} - /* * Fill the eth header */ @@ -730,7 +718,6 @@ static const struct net_device_ops kni_net_netdev_ops = { .ndo_change_rx_flags = kni_net_set_promiscusity, .ndo_start_xmit = kni_net_tx, .ndo_change_mtu = kni_net_change_mtu, - .ndo_get_stats = kni_net_stats, .ndo_tx_timeout = kni_net_tx_timeout, .ndo_set_mac_address = kni_net_set_mac, #ifdef HAVE_CHANGE_CARRIER_CB From patchwork Wed Jun 19 18:59:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55100 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7E9611D177; Wed, 19 Jun 2019 21:00:15 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id D8E1C1D12D for ; Wed, 19 Jun 2019 21:00:07 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id p184so138673pfp.7 for ; Wed, 19 Jun 2019 12:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eVpCCGqv4anpgjgB0iS05xOJSNV5B1c7nQVpCcdAfXk=; b=GImtclffayvUf//LAax4etCiT9hF5txTmRf9RIZJC+/XfiGXjkKtPtEMec+4EqYTKL L/igjL5ShHb6tgoBqdf0f4z/vbjkUJuXEK+Th2RdXBTjiCG3HtLazX3UKLNMZcokZwMR Lji3Y6Wu6ktjFus/0vjSukyvUnU2OrEHSNtDOTBzju9sYmL8rhQuHgNp0Pr9CHca7DsG 7uCRnAjRoqcXVbuJejJw6Ru4LZ5JsnF0F0NZOY3UUUyqckYsAhEPsse5QWGFjzPY7LXP 8J4myOQoHYswQDZmm7p9cFBkHi6PCjbklBlgBslw4b/r3d6o4Ce1tbDA3mgMhQUDHQCp 3t/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eVpCCGqv4anpgjgB0iS05xOJSNV5B1c7nQVpCcdAfXk=; b=mYosd/ybRq6HKjjh20rEWutBOEeYxrV3pp1a6seffmepu8BAFZeEXOiwjyXpaUn+ej 7rEvXWgy8xfPn343bNi4O4zoEOSkzWIgxkIbzXEIlotTrohOdjpygwWfYNCl5cNpLC9y IFHCWJWFGBX55HvS+l0dmylW0XCXT+PSS3n8tHYkohGj7ptbj+5T5xAFbzfViuGcxEz9 WWZKCdsN0Eq5xzGeLeUH5A+87TrpUcy3pU1EPPgUTidP/trGmk7kJMPJjL6bXE8jukEW nS1UZa2oiN4McIpCzS0hBizL4CL1h8/BtZovAG35KBppiVdd6ou3Lv34q5f1tScgoOQg uefQ== X-Gm-Message-State: APjAAAU83PnVGnmvaTQ59JC1GFHia4F3rWRC85swAKYReUj2ZyfKnX9I ORhpImsK4r1Y1Fgmg22ICSvSBpk5nhw= X-Google-Smtp-Source: APXvYqw2ohikQCjwU/VrKi3qpRwUMO3jRuA02UD6UuG/C1MjYuLFYKPvttoO/7z3esfjm2asfsRkqw== X-Received: by 2002:a63:1b46:: with SMTP id b6mr1493689pgm.183.1560970806455; Wed, 19 Jun 2019 12:00:06 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id g8sm18613397pfi.8.2019.06.19.12.00.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 12:00:05 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:59:54 -0700 Message-Id: <20190619185958.27306-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185958.27306-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185958.27306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 4/8] kni: drop unused fields 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger The kni net structure only exists in driver no API/ABI. Several fields were either totally unused or set and never used. The fields in dev_info do need to stay in the ABI but kernel can ignore them. Signed-off-by: Stephen Hemminger kni: drop unused status element Yet another ethtool leftover. Signed-off-by: Stephen Hemminger --- kernel/linux/kni/kni_dev.h | 5 ----- kernel/linux/kni/kni_misc.c | 1 - 2 files changed, 6 deletions(-) diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h index 21e4b0d92368..f3e6c3ca4efa 100644 --- a/kernel/linux/kni/kni_dev.h +++ b/kernel/linux/kni/kni_dev.h @@ -39,8 +39,6 @@ struct kni_dev { /* kni list */ struct list_head list; - int status; - uint16_t group_id; /* Group ID of a group of KNI devices */ uint32_t core_id; /* Core ID to bind */ char name[RTE_KNI_NAMESIZE]; /* Network device name */ struct task_struct *pthread; @@ -79,9 +77,6 @@ struct kni_dev { /* mbuf size */ uint32_t mbuf_size; - /* synchro for request processing */ - unsigned long synchro; - /* buffers */ void *pa[MBUF_BURST_SZ]; void *va[MBUF_BURST_SZ]; diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c index 1fc5eeb9c8ca..b59cf24c2184 100644 --- a/kernel/linux/kni/kni_misc.c +++ b/kernel/linux/kni/kni_misc.c @@ -346,7 +346,6 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, kni = netdev_priv(net_dev); kni->net_dev = net_dev; - kni->group_id = dev_info.group_id; kni->core_id = dev_info.core_id; strncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE); From patchwork Wed Jun 19 18:59:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55101 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EDD031D17E; Wed, 19 Jun 2019 21:00:17 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 189191D163 for ; Wed, 19 Jun 2019 21:00:09 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id e5so181836pls.13 for ; Wed, 19 Jun 2019 12:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KIWdTWngvMzOCsjHwiLdXVCXjGw42l15HHKsPengMUk=; b=MADSBUYwOXMfcIaW7+4bmLxhJ9DXSNR6ciUohNDe66nV9no3qm+haUqnAfQZuIukQQ nIy0DXWq7Yd1OZXoKX+PI+EYAttjoqF88ntlNHDx0BSJ4jVs+EwQTOLKXbj65PaPpooG 7C/5szdKnogcRCMpCPnxhATxS8geS7QD9vQnOH1JO/8+hmhXHDx+9Bx7iZPvtR4AJd6w 7e+orx3F9Se/z8Dc84T5TuwRdbqMAgHTnYHd8HrGOW7+woFrppFZYNKkCarrZKkqaXLF ZO8lvQO/KSjJ4Ss3OJr7wbGFKcgproA4crqG92s3oRq8nH1k7oOg+r0UtE0fGKHliR4n id+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KIWdTWngvMzOCsjHwiLdXVCXjGw42l15HHKsPengMUk=; b=O1159wGvhxrkTO9jqiKFVjnR78TQ6ub/e7hBed1qOcJtDaEIhansvSKj/+1nFjtIL+ O9jQY+VAkvLoiua6xIZVjau4jRSqJAIctSkGYlkTts7nrbJ79WEdVyaLYqto/sx/xFFE zo02DkdvK25BozyNI5vCNGrcyRgmNqiZUJs0nLIim4KBO/Pm5FfIg4zi0lfy/N6gFKon R1OrMG8nyOK8hyFY/TerprmZsGN5rJgHYAX6GNP6H10hKfnOVJqyswL5QD1WyLh2XvzJ 3GKBGgwtJg6roB3vUWBiMP+rKErCFiqzs0eVdD5dZrUClxl1avxj6BNP6ruTntNJ65yn H5Hw== X-Gm-Message-State: APjAAAU6G+WeouDqh0yARmM81S7DtnAfoKjpuEn5SxAQSwHafD70Qzok /+aIb9pFHcaYsqmZaEBND/H0GUKQ6fE= X-Google-Smtp-Source: APXvYqzo0+otnyhmm6yrvd6qGJ6GAR0xVbKelb6kUGIKAdKNUL4BVKJhjAxAtd4hb7Z/bephoEkwGw== X-Received: by 2002:a17:902:a411:: with SMTP id p17mr62003213plq.104.1560970808067; Wed, 19 Jun 2019 12:00:08 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id g8sm18613397pfi.8.2019.06.19.12.00.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 12:00:07 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:59:55 -0700 Message-Id: <20190619185958.27306-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185958.27306-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185958.27306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 5/8] kni: use proper type for kni fifo's 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger Using void * instead of proper type is unsafe practice. Signed-off-by: Stephen Hemminger --- kernel/linux/kni/kni_dev.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h index f3e6c3ca4efa..ceba5f73c1d9 100644 --- a/kernel/linux/kni/kni_dev.h +++ b/kernel/linux/kni/kni_dev.h @@ -51,22 +51,22 @@ struct kni_dev { struct net_device *net_dev; /* queue for packets to be sent out */ - void *tx_q; + struct rte_kni_fifo *tx_q; /* queue for the packets received */ - void *rx_q; + struct rte_kni_fifo *rx_q; /* queue for the allocated mbufs those can be used to save sk buffs */ - void *alloc_q; + struct rte_kni_fifo *alloc_q; /* free queue for the mbufs to be freed */ - void *free_q; + struct rte_kni_fifo *free_q; /* request queue */ - void *req_q; + struct rte_kni_fifo *req_q; /* response queue */ - void *resp_q; + struct rte_kni_fifo *resp_q; void *sync_kva; void *sync_va; From patchwork Wed Jun 19 18:59:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55102 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8A0061D187; Wed, 19 Jun 2019 21:00:20 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id A354B1D163 for ; Wed, 19 Jun 2019 21:00:10 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id a93so194962pla.7 for ; Wed, 19 Jun 2019 12:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FievvR3qZSVV1KBq32+9xb9nuDdD0v5bxhQau2jtXi0=; b=EBoOLn1f3lR7Oh2FSQiyP0BjOPpi3th438KdVsChFCVp0/XOdNHhgBNtgFSxfNJq2e WnLcfb1nhZ6fOcvncDuJ/Ia8l+AvgadwYCS8vZgCoxJeG3g0rgmFyjqsMSFNBc9ghvCk Uv9yk9WD7s0SmP9X3A9YatZ14m9gyCsikVdiz6hzivWxSmXi9ZCopYiftPla3GTK0Xd3 456Ks12pT5jyc802NquopKfb+Yo/7FHkP3oClBzLMchfYFDHD9mydRSCPYKpy1VG5iiu uALlI4s0FU6Zczk28fOKAV+6TqrDuP0ru2OdkfPGhTQuLmBw36qlaq0oA7fT+M2z00Q0 1HFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FievvR3qZSVV1KBq32+9xb9nuDdD0v5bxhQau2jtXi0=; b=PKOx/goENcomQ1O9k1MfYH+E5s3IxoH5G2DTcJimhbK5jEk8LhQrd6V24Byd1OkQIk K7SJa2mOcI9H4cyFyWTZ05UOqqicMG/Sj03Q7R49yoMIqe46CqclZXOL27E7Caek4610 9Yb5NL/6nJQkVwsppvo3KYK8h8n95KYFtehmFRDTGcSQIfRWySCMy0aa0k3FYEYsLvIU Z51d2nTJHnCO/WucoH4A3y8Xf9jclEmSm74atT+shRAtpzgNRsPoDz6xqhrG4WXZX1Tz Md7fhfcCF0/GhFVfOnIYajoUrztGdtJjRpzZZ9016dPhy8pd8EaXGPDYL1PRn2DHyjr2 uHDg== X-Gm-Message-State: APjAAAUq5Y/HXjcHN2orLex2wbL91b2J8RPD87N/MMyVHJNnrYyBQTUF +DBvNmmU/wW5wM1CXtK0inorwh7PRPU= X-Google-Smtp-Source: APXvYqzPRbyUyYouS1eKKwXWn4bp2iFCzc7SUo2/3d4uw92yd/a8BM4HnyEzASqVf3Q96K/4HCnBkw== X-Received: by 2002:a17:902:7883:: with SMTP id q3mr119301451pll.89.1560970809624; Wed, 19 Jun 2019 12:00:09 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id g8sm18613397pfi.8.2019.06.19.12.00.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 12:00:08 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:59:56 -0700 Message-Id: <20190619185958.27306-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185958.27306-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185958.27306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 6/8] kni: return -EFAULT if copy_from_user fails 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger The correct thing to return if user gives a bad data is to return -EFAULT. Logging is also discouraged because it could be used as a DoS attack. Signed-off-by: Stephen Hemminger --- kernel/linux/kni/kni_misc.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c index b59cf24c2184..be45f823408f 100644 --- a/kernel/linux/kni/kni_misc.c +++ b/kernel/linux/kni/kni_misc.c @@ -301,11 +301,8 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, return -EINVAL; /* Copy kni info from user space */ - ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info)); - if (ret) { - pr_err("copy_from_user in kni_ioctl_create"); - return -EIO; - } + if (copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info))) + return -EFAULT; /* Check if name is zero-ended */ if (strnlen(dev_info.name, sizeof(dev_info.name)) == sizeof(dev_info.name)) { @@ -427,15 +424,12 @@ kni_ioctl_release(struct net *net, uint32_t ioctl_num, if (_IOC_SIZE(ioctl_num) > sizeof(dev_info)) return -EINVAL; - ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info)); - if (ret) { - pr_err("copy_from_user in kni_ioctl_release"); - return -EIO; - } + if (copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info))) + return -EFAULT; /* Release the network device according to its name */ if (strlen(dev_info.name) == 0) - return ret; + return -EINVAL; down_write(&knet->kni_list_lock); list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { From patchwork Wed Jun 19 18:59:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55103 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AAAFF1D194; Wed, 19 Jun 2019 21:00:23 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 188101D170 for ; Wed, 19 Jun 2019 21:00:12 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id a93so195000pla.7 for ; Wed, 19 Jun 2019 12:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=izo55QUJe9iBPGBP8dhjRckymadapEsbrUhHMdFoGuU=; b=uwC46/eTTfVTzZDPjiez1JrvUGX+Jnjf1GRn5lz/EP6GJsYqcYN3HbIgXvYrvkcDXm 1UACZKzCzXiCo7dGDw4tukjPvX5GtckOlucv47VhvAnRId4scmTleYSTpW1Yml6t7MKb 5E6zsVfx2D6B9w7bGAnKuZ0jxqRdiu9H0MaI0ChN9So/Uzqd5gPlgKqyzwvd66AN1e69 V8HR2hKMZRujCWkjUfeH7yRINEInC6HO8eh0heTyk+4RSNPGOF4i7x6k091azKWe/M+M d1Uq40SLhUxA7045DuGbVdNERLdCh9rTSEZoPrMaOQgVVAU6p42Y041uhqO2APCKbNur yyoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=izo55QUJe9iBPGBP8dhjRckymadapEsbrUhHMdFoGuU=; b=VnSZ8OLsUBXWcFHaDPydh6eZUPBCJ+UJrWtjQt7JYy3HjbhQYlBo21UzmFbrgKXI2X o2ekvhvjJng445pCbb9xDMFLH030mhth/ZlX3QBXgU4E33wfzDywXyZg2ML+iGuDwmrj LT9vPXEuq5OYovA8mX6d7OfUg3N+NPXujyaZBS8sroqgPgL2pw2kI7rgJdeN3Zi1VSpf z/6boxRl/zh//UeBF7nE35VDXIi9xidZFP0lLzzbCaenHP5rKBs+JnYXNwaBb8BjRFOv pIQzxDN497h8zA6xHEdydw+VlrVY9TyjVMv04lmCFAbXnhB4GefoJpEtgk/WaxM11IWk EttA== X-Gm-Message-State: APjAAAWtKdNIT3pCm/F39zkv/To5Yt7BWTGBip+n1tK1kIMtthRem9p8 N8dj8v0jL/TdxiCf237lQIINZBCyb0Y= X-Google-Smtp-Source: APXvYqzTPOHEc4yIX1klRLmdu7zYyJ2Uv4WoRcKHozv+3fmzql2JOPs/rRZlIqouJIP2dfig1/xGAg== X-Received: by 2002:a17:902:b495:: with SMTP id y21mr119102985plr.243.1560970810993; Wed, 19 Jun 2019 12:00:10 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id g8sm18613397pfi.8.2019.06.19.12.00.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 12:00:09 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:59:57 -0700 Message-Id: <20190619185958.27306-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185958.27306-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185958.27306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 7/8] doc: update KNI documentation 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger Make the KNI documentation reflect modern kernel networking. Ifconfig has been superseded by iproute2 for 15 years. Iproute2 is well maintained, supports current feature set. Ethtool is no longer supported by KNI. Tshark is a better replacement for tcpdump. Signed-off-by: Stephen Hemminger --- .../sample_app_ug/kernel_nic_interface.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/guides/sample_app_ug/kernel_nic_interface.rst b/doc/guides/sample_app_ug/kernel_nic_interface.rst index a7e549d5213a..422bd8c98465 100644 --- a/doc/guides/sample_app_ug/kernel_nic_interface.rst +++ b/doc/guides/sample_app_ug/kernel_nic_interface.rst @@ -21,14 +21,14 @@ The FIFO queues contain pointers to data packets in the DPDK. This: * Provides a faster mechanism to interface with the kernel net stack and eliminates system calls -* Facilitates the DPDK using standard Linux* userspace net tools (tcpdump, ftp, and so on) +* Facilitates the DPDK using standard Linux* userspace net tools (tshark, rsync, and so on) * Eliminate the copy_to_user and copy_from_user operations on packets. The Kernel NIC Interface sample application is a simple example that demonstrates the use of the DPDK to create a path for packets to go through the Linux* kernel. This is done by creating one or more kernel net devices for each of the DPDK ports. -The application allows the use of standard Linux tools (ethtool, ifconfig, tcpdump) with the DPDK ports and +The application allows the use of standard Linux tools (iproute, tshark) with the DPDK ports and also the exchange of packets between the DPDK application and the Linux* kernel. The Kernel NIC Interface sample application requires that the @@ -220,13 +220,13 @@ Enable KNI interface and assign an IP address: .. code-block:: console - # ifconfig vEth0_0 192.168.0.1 + # ip addr add dev vEth0_0 192.168.0.1 Show KNI interface configuration and statistics: .. code-block:: console - # ifconfig vEth0_0 + # ip -s -d addr show vEth0_0 The user can also check and reset the packet statistics inside the ``kni`` application by sending the app the USR1 and USR2 signals: @@ -234,16 +234,16 @@ application by sending the app the USR1 and USR2 signals: .. code-block:: console # Print statistics - # kill -SIGUSR1 `pidof kni` + # pkill -USR1 kni # Zero statistics - # kill -SIGUSR2 `pidof kni` + # pkill -USR2 kni Dump network traffic: .. code-block:: console - # tcpdump -i vEth0_0 + # tshark -n -i vEth0_0 The normal Linux commands can also be used to change the MAC address and MTU size used by the physical NIC which corresponds to the KNI interface. @@ -254,13 +254,13 @@ Change the MAC address: .. code-block:: console - # ifconfig vEth0_0 hw ether 0C:01:02:03:04:08 + # ip link set dev vEth0_0 lladdr 0C:01:02:03:04:08 Change the MTU size: .. code-block:: console - # ifconfig vEth0_0 mtu 1450 + # ip link set dev vEth0_0 mtu 1450 When the ``kni`` application is closed, all the KNI interfaces are deleted from the Linux kernel. From patchwork Wed Jun 19 18:59:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55104 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DC9FB1D366; Wed, 19 Jun 2019 21:00:25 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 961121D144 for ; Wed, 19 Jun 2019 21:00:13 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id g4so196758plb.5 for ; Wed, 19 Jun 2019 12:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=61Tz9e51iFsr64UJR+4GBKGdoy7QED4nKBXU34vTxeM=; b=2FEjCyir0N0NP+FWumvbrB8g9kusrFZFa4iBxAFNEqkDRya4LTB5sdELmwgwmhHgIF rrh1WmHyXBb2449Qo2sbV5NSOQntXg5t2W+uzKtfdegeOmawxhvUgSSxBrvz9QID1/KS aHJwA5zncpk7SyUlawtpklz6YAnJINNKbkasLmu0YGfoPb2gr9DmowaC52iRhMPG1lkm R6aK4LBZn5L1mpVUC+B8jOdHKUzF/+v8lhwqLouFJqgNhqIu982v1R2FWy6SYeAQ9nbA fQesfOu/5PK58c8H4LoPSduscpYflaWhZweAm0CG+Siqed8vYOLz8zqYmb88EgD4gAs4 kPIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=61Tz9e51iFsr64UJR+4GBKGdoy7QED4nKBXU34vTxeM=; b=H1DD8f4DQe1IoLoArano3OfdLXum67XphndEL2yGfQtK4z96Kog49xha5vw0tVcI3e wOoMAO01Hji0j+utfbypgLSkN+a9zPl/GtuvKqVpN7y/23+KTSiddF2UXZekcG2VGGUV i4rLfBZizk5kaxDMXg6okg+JJZ+Nqi5sKI4rtETy9LIhuvBo+A1Fu9t2sxjSY3nuiX0S 9Luxr9oC/5hH/tu/QPR55PQzP3PlRsej3KtdBwKa3WEfcm1Q8GRk0OWPkNRFryYWhAOe zm1HRjto6/Gt6odTAxGyUAoSQxKD6u82il8HpPNUzgiIVsyWCUzmuyp85jVxaEAs7dpw 0mzw== X-Gm-Message-State: APjAAAUVLvPPrQycUiO3mC2aWdJVwgsiqxMbERNgIcnqPodJTAaU2YlO YzCW7Qa8BdBy+XADX2DqEv2NXnLB3qk= X-Google-Smtp-Source: APXvYqyHvFe4OcwV2475tSzvZpNSNKdG6KACCPSE1Fk79f6UZZ24AeM8d4UN+J3SqmUsZ/Pxe71yOg== X-Received: by 2002:a17:902:290b:: with SMTP id g11mr118695632plb.26.1560970812440; Wed, 19 Jun 2019 12:00:12 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id g8sm18613397pfi.8.2019.06.19.12.00.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 12:00:11 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:59:58 -0700 Message-Id: <20190619185958.27306-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185958.27306-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185958.27306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 8/8] kni: fix style issues 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger rte_kni does not follow standard style rules. Noticed some extra \ line continuation etc. Signed-off-by: Stephen Hemminger --- lib/librte_kni/rte_kni.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index e29d0cc7df3c..9b6acc382fc3 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -59,7 +59,7 @@ struct rte_kni { uint16_t group_id; /**< Group ID of KNI devices */ uint32_t slot_id; /**< KNI pool slot ID */ struct rte_mempool *pktmbuf_pool; /**< pkt mbuf mempool */ - unsigned mbuf_size; /**< mbuf size */ + unsigned int mbuf_size; /**< mbuf size */ const struct rte_memzone *m_tx_q; /**< TX queue memzone */ const struct rte_memzone *m_rx_q; /**< RX queue memzone */ @@ -78,7 +78,7 @@ struct rte_kni { /* For request & response */ struct rte_kni_fifo *req_q; /**< Request queue */ struct rte_kni_fifo *resp_q; /**< Response queue */ - void * sync_addr; /**< Req/Resp Mem address */ + void *sync_addr; /**< Req/Resp Mem address */ struct rte_kni_ops ops; /**< operations for request */ }; @@ -473,7 +473,7 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on) int rte_kni_handle_request(struct rte_kni *kni) { - unsigned ret; + unsigned int ret; struct rte_kni_request *req = NULL; if (kni == NULL) @@ -498,8 +498,8 @@ rte_kni_handle_request(struct rte_kni *kni) break; case RTE_KNI_REQ_CFG_NETWORK_IF: /* Set network interface up/down */ if (kni->ops.config_network_if) - req->result = kni->ops.config_network_if(\ - kni->ops.port_id, req->if_up); + req->result = kni->ops.config_network_if(kni->ops.port_id, + req->if_up); break; case RTE_KNI_REQ_CHANGE_MAC_ADDR: /* Change MAC Address */ if (kni->ops.config_mac_address) @@ -534,7 +534,7 @@ rte_kni_handle_request(struct rte_kni *kni) } unsigned -rte_kni_tx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num) +rte_kni_tx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num) { void *phy_mbufs[num]; unsigned int ret; @@ -552,9 +552,9 @@ rte_kni_tx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num) } unsigned -rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num) +rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num) { - unsigned ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num); + unsigned int ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num); /* If buffers removed, allocate mbufs and then put them into alloc_q */ if (ret) @@ -605,7 +605,7 @@ kni_allocate_mbufs(struct rte_kni *kni) return; } - allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) \ + allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) & (MAX_MBUF_BURST_NUM - 1); for (i = 0; i < allocq_free; i++) { pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool); @@ -659,35 +659,35 @@ static enum kni_ops_status kni_check_request_register(struct rte_kni_ops *ops) { /* check if KNI request ops has been registered*/ - if( NULL == ops ) + if (ops == NULL) return KNI_REQ_NO_REGISTER; - if ((ops->change_mtu == NULL) - && (ops->config_network_if == NULL) - && (ops->config_mac_address == NULL) - && (ops->config_promiscusity == NULL)) + if (ops->change_mtu == NULL + && ops->config_network_if == NULL + && ops->config_mac_address == NULL + && ops->config_promiscusity == NULL) return KNI_REQ_NO_REGISTER; return KNI_REQ_REGISTERED; } int -rte_kni_register_handlers(struct rte_kni *kni,struct rte_kni_ops *ops) +rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops) { enum kni_ops_status req_status; - if (NULL == ops) { + if (ops == NULL) { RTE_LOG(ERR, KNI, "Invalid KNI request operation.\n"); return -1; } - if (NULL == kni) { + if (kni == NULL) { RTE_LOG(ERR, KNI, "Invalid kni info.\n"); return -1; } req_status = kni_check_request_register(&kni->ops); - if ( KNI_REQ_REGISTERED == req_status) { + if (req_status == KNI_REQ_REGISTERED) { RTE_LOG(ERR, KNI, "The KNI request operation has already registered.\n"); return -1; } @@ -699,7 +699,7 @@ rte_kni_register_handlers(struct rte_kni *kni,struct rte_kni_ops *ops) int rte_kni_unregister_handlers(struct rte_kni *kni) { - if (NULL == kni) { + if (kni == NULL) { RTE_LOG(ERR, KNI, "Invalid kni info.\n"); return -1; }