From patchwork Wed Jun 19 18:57:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55088 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 D67E11D0EB; Wed, 19 Jun 2019 20:58:00 +0200 (CEST) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 202C31D0BA for ; Wed, 19 Jun 2019 20:57:57 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id f21so181648pgi.3 for ; Wed, 19 Jun 2019 11:57:56 -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=TDHLJk5SoEJHys6Kwh9oifNQfJW0luGXBXBjiEc+VZuR4JrUppdMqwbfq0cPq6l9YE 3qgd6+1ndNIU4cwiWvoRcWxr+Ey9Ir8VybvFC9+Z5BxyvnuSnHYWIIrMGvLJeO7YMXg3 CXT/Gcwa1/R7B9xadG4yIcdoo7+R/nefLRTL4Ye3N/8yZ/PZah/PeiBoSLWjc8+DPNF/ 05qP9RGsxZjYsEGodfUaegpw7OSI2rynamaDkeuhnTtG02X7/rub+vVEvC+9//B9kmG3 zkUd60X9AkaE4/ue2erhD0Lm0Ir6dTq5HjpioAFA1Q0Qp6RsaatSZNMwiaacchjJ+T54 NA9A== 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=JtzqZySiavkVjRfzGOSF93yydWf1W2vGWwuqmni0FH/CgeVe/MCbPtAUhKNqAIX764 y31NyCzEEIoX7eyq7qI+J0mi3BOoD6J7clJJ6rDidCCiFHNv6z++yYHqq6YpqX2wVlQY iGQMhd39pkmkBEYSprxnQBjlqXIhImnPrj8dTsyRh5Wn7OvpIsExtFjnUZS/s2gAGbVt Z9qtVqIgqAckPF7/CcyTEcme+hWNruCyXcnvwalILyH5XcO6vj6bCvf0HDOFT0MqRqyp 7Ksft+8ScduPrFo3tq0NsVA3aoPwTK+FwWyNwhDgdKQQ3Mis0n9oXiMkZwjHcs1OEyPZ lO8Q== X-Gm-Message-State: APjAAAXjygxmJKe+0w4ZQcNvLA0QYpI84fjWaRSeBUQ5GZoo5tDz57b2 ogJ3r8hKXqG65ueR941c/sM+GJgXtsw= X-Google-Smtp-Source: APXvYqzc/fqeFoRMDlz6EQKyQeUhNwwrCFildLzSUJ53Ke/jPCwdKVeCL6Z97WPu6cG7e+Mrr9+msQ== X-Received: by 2002:a63:e4c:: with SMTP id 12mr9206736pgo.309.1560970675893; Wed, 19 Jun 2019 11:57:55 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b8sm24774858pff.20.2019.06.19.11.57.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 11:57:54 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:57:39 -0700 Message-Id: <20190619185746.26866-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185746.26866-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185746.26866-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 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:57:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55089 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 2C1361D0F3; Wed, 19 Jun 2019 20:58:04 +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 2AB8F1D0D9 for ; Wed, 19 Jun 2019 20:57:58 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id y72so168749pgd.8 for ; Wed, 19 Jun 2019 11:57:58 -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=JpyK/Sxjv08uv1gpqJ3ZWm1RGnqru91O2pvOtEYAhywzTxDNmt6vNTby6jI2M/cIXU z+GjpqRkmr2x8BIeD1kXVDmKlziG8BjSrtBh8CBtoH+rUvHzkZ/qF9SqvVA/wSU+PDIB fDmMdq6doEJQggycNipYOiLsjwPoySiGcgE+mhrlZODMtQyL24RYjwNV7GoYpn0ABtxd 0/hgw4IdCg4WhxuyRY9o4219P3w0UpDuFlwsgsPhGbrBX8MTmYs03dBHkmlIQbQAidpM RIxpF4wWBiQEX+dln6rjktSewzmrEy+KIFsFNSE7VipcKqK4oWjSAeQzL+wFyYExcBuq aTUQ== 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=jrCm8H/8r4xZTY4gAIAlNSwSviApAzDbucvahrhS4NgOuPjQ33KrJjYEAvB2DgMExm ZKpGo0Lde+JaogtTosusyVpdm8F6DrAy4BR6VVx/HlWGk0E50n6JHdcWrQvhtc6+cBaM fJImwhuhd2oolbuI3ckYz6dpCmweUQ/NB1XHs8cZ3baF+wk6on3uC3O62ndeVshGgADr ILWnCk0FA9ltKhfU5ramBU5gg2ZtieBKB6kSTDl+mwoioIT9lqK+pswsaBn7TL1TEgMu RbEo00e5hJGiGxsQK20bUm2GIgfbKUgFMa7tW5la3QVwCvwppO0vLONAgwZQBqGguk4o lBtQ== X-Gm-Message-State: APjAAAVUR9a2xT63IPqya7nCgcPKvt+3vcGOXe/r7f82ThJ3nd6KFfCY D9pMOXMkvC/u7l+UZeJGP6+v6s8aY3Y= X-Google-Smtp-Source: APXvYqyw+DCqr6SZ0crZeKbMrj6wbaYdrXKerRCCV2efaxXrF0mRs+d76IY6I8ext4pBI+1/RiMw0w== X-Received: by 2002:a17:90a:2567:: with SMTP id j94mr12725877pje.121.1560970677051; Wed, 19 Jun 2019 11:57:57 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b8sm24774858pff.20.2019.06.19.11.57.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 11:57:56 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:57:40 -0700 Message-Id: <20190619185746.26866-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185746.26866-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185746.26866-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 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:57:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55090 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 392701D107; Wed, 19 Jun 2019 20:58:07 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id 4AC771D0DB for ; Wed, 19 Jun 2019 20:57:59 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id q10so129231pff.9 for ; Wed, 19 Jun 2019 11:57:59 -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=nKzDgGixkSqTch8bSDg5/OKwMe8lBRYiJjQp1BkEYJCl0Zg1rb4/0KvrH4eH6Ccd5g byhF0SQkEA7fuEk9C42KG/SxOUTcW7NTuuUWhHv++/dg9HXUlZHFq01lods+Kx/lbqY2 kvm0y/cEIKlCU89c0RiZP3hW9oJfO7jF58mmXZ7Cqxwj4pL5kfwPRKbQC3cX973GyesV FqqWhjDSFi7ehgJJT2Rshhuxb9fa+fjYJOUnXKVjGt+3IvrEhcTASRAI7M60+DR0z06X ygE5Yyok01uvdLp6wg9vlqZhD4uJro0GsbF1MAFLtEK4Z31xEHa6nQKtFamfb4qVQq/P OI7Q== 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=W69W2i4UfUzaON7tycqxoZbcqbYB0jwQsg1yf4xvtAwIs3XqcYleAVBpjp92mAPEqJ 6bDi/BrUkxExAhfTNcEPxn3CthWHTABkMO401c/Z74i/KFQ2zXQWKzq9fnAIkpwjQ/MD 18V6VcTwjZgjUsbGMu3kFyRf0FmKGywnwWyEN0UM7XYUuiCMYaNgDD1KIhY52QT5HXlq fWDJMBJJAQgvvtoMIF+1m5VK8q7FI7m2NGprVn3UFB8n/k7jfz7tPJk0c1PxUeSBV71b 5leO9ungZIg8uHioz2+qsoc2l6wDsZXLKwXeyVKkvcoKfKi/5uOHh0+riOWuL/+Fyyht WTAQ== X-Gm-Message-State: APjAAAUmuBoRrlb7PT04E2G348kOL4UXiyowovUcXI/P9ezb2li66s5g ojxAjEMDVxzihNKI7TIqgbqHSqmICiU= X-Google-Smtp-Source: APXvYqwE/RwftLmSgemp0LqaoN+N7i9kfj30TmjsFUo0cahJPCbYM5KG0iK0rCqPOpAr8yjUxu6A/A== X-Received: by 2002:a17:90a:9291:: with SMTP id n17mr12382766pjo.66.1560970678258; Wed, 19 Jun 2019 11:57:58 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b8sm24774858pff.20.2019.06.19.11.57.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 11:57:57 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:57:41 -0700 Message-Id: <20190619185746.26866-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185746.26866-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185746.26866-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 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:57:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55091 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 36A991D123; Wed, 19 Jun 2019 20:58:10 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id ACA351D0DB for ; Wed, 19 Jun 2019 20:58:00 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id l19so164579pgh.9 for ; Wed, 19 Jun 2019 11:58:00 -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=atsHReJYzXpoQFMvRpotc9wVx2cZLyeWhPC75abwttbG6pjn8FLOaVC1Z5zoylvB/c gxHzYv8eAhCi4bjwPu3aJ62mSd7tr++bcgYZwybejEKeM6UacKZ9+jhkSJ8gx+LSeksV nViQDzf4HYQnAFDvgfRuquSLhal238AZAB5D3r78y24u/L7efpgU/QbxDGcN8mmjMyNu TNpbAyeuMXFuvjHd7fPfgUf9xOC/6co+O1B8SbnUAlrxyWZR5wwt1pi9t082KWKRZcxx sh+vXbxKm5vNTNjsvcGO77IdXWLJW+YH63YrX1ZylY9IDq5kKm5iTl4T7qC/cdbp+AD0 Z1mA== 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=d3OYmz5u4P66SFSuTA203KvoalebbQjdyDF+/GeZIRxEyKG/W1IUX/g+DvvOCvzF4Y rKQYsvnA2rlaJOIojLJxrJWMAovM8gQi5stjO9Fng3AY7LY8bcy/xntXGoWW8ieh7Vn3 ScVYjMhh8L16bV31paC3hCrJgZ1Hs5VhO/oSp68CJgNOsqhwqpri4kwfLyr+SjgfC/7G CzcP1g7l6kgdl3I0MJRRC6YjFMmlDjkjO2If7PGmrldcs0qFBmnbIdnQZPo8Tup50l++ YblnzQKZJybbrWASEn6LquuD9UlGm9JNfzyLzRwzgxc1DHcTugaijAqZMFSEVNtSUmK3 29zA== X-Gm-Message-State: APjAAAXRRJ+ZaBZFUANjirqvFAcRc40dpWRTHDR/cZSwQc14/EGBJjeI 4BOR6xmpJeALbZSehfheR1/PYDbGg28= X-Google-Smtp-Source: APXvYqyjSA5UrXRYt8vXDN85knX4ok2QBNFHWNs7qTuLJ3wXkfxZrpAAQJXblbRg6ipm8Ymcyzc+IQ== X-Received: by 2002:a63:2a0f:: with SMTP id q15mr9219608pgq.163.1560970679631; Wed, 19 Jun 2019 11:57:59 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b8sm24774858pff.20.2019.06.19.11.57.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 11:57:58 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:57:42 -0700 Message-Id: <20190619185746.26866-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185746.26866-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185746.26866-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 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:57:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55092 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 AA1891D12D; Wed, 19 Jun 2019 20:58:12 +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 ACEC81D0EF for ; Wed, 19 Jun 2019 20:58:01 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id p1so202209plo.2 for ; Wed, 19 Jun 2019 11:58:01 -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=AEYEP+/jcnGHAoSfpSnYnMKABq+0iYKCVr5B+JAqIVl17MxLo0/6KEYdJqt5s37puv FqWdRYkJnQ0DbSJXn5WLfUizrNxGqiiZYfrYvv6+ghcyJz4UFjA7Uu6cUdwoSvTLD1lY PjhmAl7h2ESf8rKZokNyd/WRFKZQd6nrSfnl+SJ1/fnDfi8q1eVDV6dE/RdKaX7pYujd EtiAIR/jCMkiN3+HESPzJzsg7ZR1Uv2s6uqfholjBwomS4z73NPASvlzy6IKh23uhpYv aqLJbIXx+G8k6aKBwtsFPqi+ZBRKrArt+OMUBCa2hBBn7fRHjn2ADzs7K27E9xtSaNRx WRkA== 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=MT02QoGeiQulsaNgnQxfRVBThCZsHUGdZjncN5hMMNROoEZKhVYaUm9AoBD03JWAr9 Xk/6zl7yLBx+4RdJPa0l18ArYgU69oKqZkJvjJxapycCDHo3O1XUnDf0BHSszxJ6cKiL T5jNZCeR4Y0bubyMl6mDTkgQDMhoSKs8rhDjD4cevjNDzQCZdxmYFQi/AQlTI1DRxSSa hDrFMFOgbi+k5v5lC5i6PIeagZ4hfgWB/Dxr09DovXvOA39NxcD2D+mY4XsVziTDLTzA XRyxDUsZLWMmMgKb3hH7rkvHhtatp9rKloc5am62fVLLq90uz7hDV2vOTQkP+kGUqJXG B9Ig== X-Gm-Message-State: APjAAAXdKeTJLCts1OGm5f9AwhCEL+Z8E5TJMyEbnmgA6SConXvGgfSw foXilWE+qxBugdgSG5C9veAS8JBUREc= X-Google-Smtp-Source: APXvYqxIPKay/XCWBAU3BnnLnzY0gy6zD+5f17YuuRQor3Sfv424/gUWMwv1mj1r0WxkOuYiYOK2LQ== X-Received: by 2002:a17:902:f087:: with SMTP id go7mr94492745plb.330.1560970680712; Wed, 19 Jun 2019 11:58:00 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b8sm24774858pff.20.2019.06.19.11.57.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 11:57:59 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:57:43 -0700 Message-Id: <20190619185746.26866-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185746.26866-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185746.26866-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 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:57:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55093 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 DCD4A1D139; Wed, 19 Jun 2019 20:58:14 +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 D80251D0F0 for ; Wed, 19 Jun 2019 20:58:02 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id n2so159496pgp.11 for ; Wed, 19 Jun 2019 11:58: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=FievvR3qZSVV1KBq32+9xb9nuDdD0v5bxhQau2jtXi0=; b=YCxE4LL7OzQR6IWHbuG7zyC53UcHX6TrI4IRMihFu2qswr9BN6cCzhRM1nFO/PRSC9 yHoTgPIAm63rGx+5Su0Yb11XGAj5GZGXeZUvJNy4NWsnPoTknL12ztaG9O72oJ8TrWjL O+m2J5w1/iYJNUYwo3KkcJYb1meGXa9kuxCW3Mszr5J3TLw8ouINKWtDxXkXjNEepmBM vXdFzEgdAn8/RUdJjoSzUIUHX1+aEGbNW8k7vTTs7je2MnocPYExCrkYxr9hTeMJYsUo DJZJBvDO5wD9xUc+u8Sm7MdMPbfs+ucUhAOU6nCUGmJs+2Yqtn16UFLmh/Mg3keEGGhW UENA== 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=RhEo3/seAWBX0w7IhtcTfTGuFEM4cOn5yj5bLKwvHINluym9DRnYT2LphoeNgWj1lw xOOwIsDcgTl+JKX8Vdl1tVx/mxFGusFBDzmDPVDQPGo0nB6qC07p9eZZYjTmGqBjj4Du e+duZJUoSqtu9NMBPxsAeaaCzbvkZYc0UKOKrwPIw14FavrYsINNj6D8ul7AWL1klrGJ KjWkU1XoxjxNHwe5yZpNm1Oc64OBCtyEITGOHkgnOaj42Chpx1RzjIEqnlBjdGGrzmzW Upo8AyPF918dpyqvH/6jYAeoWZHqC2m4hwi0dHz02FEK9hHDBjEI/jPEUwQf6NG1uWWL viGw== X-Gm-Message-State: APjAAAW6L8qrFhhFSqGmVbNfdnkI1k9j1ARXSH9Vrf5t66qISDI+2KOX 9mmpD4aN0vYoXScU+kBPVu0YknlmbgA= X-Google-Smtp-Source: APXvYqw68h78Cn0vH+9LS1CItOCPGomQ/lxJxFNwohP7Bap8V4FAc6XrRIuiMXxq6+ktag82kzfQrg== X-Received: by 2002:a17:90a:2525:: with SMTP id j34mr13081468pje.11.1560970681757; Wed, 19 Jun 2019 11:58:01 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b8sm24774858pff.20.2019.06.19.11.58.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 11:58:00 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:57:44 -0700 Message-Id: <20190619185746.26866-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185746.26866-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185746.26866-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 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:57:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55094 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 2A8E91D144; Wed, 19 Jun 2019 20:58:17 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 991D01D0FE for ; Wed, 19 Jun 2019 20:58:04 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id i2so203908plt.1 for ; Wed, 19 Jun 2019 11:58: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=izo55QUJe9iBPGBP8dhjRckymadapEsbrUhHMdFoGuU=; b=hUawFW4MOG0NJIjMnF5/FbdaxzzkT9OYkziu//kiHUVDeCkbJpPCihgm6qyf9HlP4y Jf/SK65C/l1TAVasZyTFy7HCyiAHVXx2U2RqtXvSqxBxdUW0S15+LvyfaBLkNpLt0WdH Fe2+8tsJIDFq4bVBwGm/gtel8KFtwYa5cjDBEKxz0bYneyog1Lk6M68Nm6gg4VgpWDeB VLeNug7mYQUsR/leX+L9Z/1xWpDsvd1TMHpoTDGmv2Wu30zDgx4uAdFUmmpM+1sJAVi8 qAKfGREMcxXSVGXmhVogPBh1tuqAOzmcKBp+tiXxbv55xICt5gbYVwlJZ2nSXYzdV2/5 CdvA== 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=NHG3h8/y9XaeXmZLoJiYN4bZbX1rb1ViJMxmUTSY7iCyNPp5S/BZJ5HZCF80VWzI9i GLiQzSb0+CyIZxf18hHtaHxqXscCnpamCmefc+Fk0JinzQ3VrfHU9SYLg2Cr3r3OHtmL nqs9nyETEwHfYVOh6Cn5K45GY1a/yiB3up9gyI/4J8/AD98trmug9Obu4gewgD/+4NtY hjnwBHaoJPXEYnF8CAi6wj0ZGNmZpx41MUJqFPVgueDC7zN4IYFb4mPS8ieqrurLPSri zfKalCs9zEu3eGCZAWMPxD15BvnAOVTdIgrfU0wnn2287ozBunHeeMIhpEmkBZhTq5e/ RvIA== X-Gm-Message-State: APjAAAVPGlDPfs9w50kdnI96cWOqdJzORI2lGMsd0x1MZDYOUABT5x3g 51bJ1yR9A461RrfKsWfXKckK878lFuM= X-Google-Smtp-Source: APXvYqzJHmK32avgrtGUT3PomA1HEqFaojN7tVvpcArOCxMXLEOByIPAlLUTeH+72j5O1/QlsU4PfA== X-Received: by 2002:a17:902:6947:: with SMTP id k7mr47118666plt.253.1560970683395; Wed, 19 Jun 2019 11:58:03 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b8sm24774858pff.20.2019.06.19.11.58.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 11:58:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:57:45 -0700 Message-Id: <20190619185746.26866-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185746.26866-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185746.26866-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 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:57:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55095 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 218F41D14E; Wed, 19 Jun 2019 20:58:19 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id ACC501D0FE for ; Wed, 19 Jun 2019 20:58:05 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id i2so203930plt.1 for ; Wed, 19 Jun 2019 11:58: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=61Tz9e51iFsr64UJR+4GBKGdoy7QED4nKBXU34vTxeM=; b=jrih7eR2+RX3bunEg0yfKdKQOynrGr8a3l+0YQmT4y6DFPbyW5qY6Qs4IKq6tEo+Ym f+P8IqzWpoX3u3CFy6wJuM5neORAvdx22bVJ3nfd9DqcvoDNfh+m+47p2rKmVCOa5vNQ xVweopKiY05wIvME2PgZzhgMBk/OGQ2yE/DcyB6DOadYElXdRpY/uXXdXC6hvC+z/74r WuME1j8kQ7VZ4SxhjCTaSFpVwUT8bZpm7QomRhHEQvxlW0qA6VdfN3eYZ8F4gFKu3M5X RxTlCHH8/jUST+204rPCTye2JXffrb4cOtlRjesZq30jOZATZ3Nx1U0IahCfln2cgAho qZQQ== 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=TKpi+7kbtuFJZJNzmR2THXEjjqYJREVKwSl+8mwuOPexTn3Y692NJoyFDKzocRQrzD mGA2k4wno96Q+//UTI3vyfB5MxY+4B5wn0B5KfAU1VeIR6wPPTkZUwUPPL66FXhO+rSh NAk6+ii7DeajIKGkweywCa5ccJCqKwe8rAemT2jD0nKCz2dDFj9KdieUGifSU4wZKGFy 6eYlMiOaBu4zpVE3rMbC2ZFBPVN0iWB6QJosiVnh7cin7fWkDeMqUeKatwW7aE1QUGPy N/LPxHtUFbLxMrgubDg3920aTwMqzsi/nh8uU0Umpq9Q/+7VCdgBlnOXKy+nMPCDDUvQ +xHw== X-Gm-Message-State: APjAAAV8fKtq3wQMvGChYlqZ3xLvh+T0lD7K+e6u6VF+Li09Ugv43Nkh SD+nMl0M3+BZ+cDeq7FZbt4XRnsuXkY= X-Google-Smtp-Source: APXvYqwsGYWg3o53QDbFrPfchLgt6MZe0gnw4RbIkqDTXe58S8mFbLGYWBxO4tHCUq2aGtLYXhTleQ== X-Received: by 2002:a17:902:27e6:: with SMTP id i35mr119944944plg.190.1560970684681; Wed, 19 Jun 2019 11:58:04 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b8sm24774858pff.20.2019.06.19.11.58.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 11:58:03 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:57:46 -0700 Message-Id: <20190619185746.26866-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185746.26866-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185746.26866-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 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; }