From patchwork Thu Jun 20 19:20: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: 55132 X-Patchwork-Delegate: thomas@monjalon.net 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 505B01D468; Thu, 20 Jun 2019 21:21:01 +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 9EA771D453 for ; Thu, 20 Jun 2019 21:20:58 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id s27so2090574pgl.2 for ; Thu, 20 Jun 2019 12:20: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=lx7mNNtKZOJfi54i/SUlINrC4myA0zQHh+IpidBgz5c=; b=ivERizRALsy4X62qu2PCD3LkmDNxomhLFrrnU1prfmG+hyCS0qgVUGwMd5w4WUnAK7 pc4FEN7gZ0Szfzp+fo0xZkHY2/wVEkEgTwlY6Xjr10dWXWjtEs4n9dKHyzmg5r7rG1cm ha7b6Ej5Pf8Rc8bCvs29K/p0zZSql2UsLakJ9xFbCzDe608fDJSRg9POVeRTqdX5Vb3V KD9UxmhOM3muEdykiP6rlVC1LV9NwIYcSizwzZAW7Y+PZQkn3NDv7naZhBNmK0zEgSQ3 NeE53kUkrtC/Wi/tO7JfJIp4CyV3qmRmMetqq/tP4KZDL5gdpMB4Rpv5XCBDRNKgVduN 8o4Q== 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=lx7mNNtKZOJfi54i/SUlINrC4myA0zQHh+IpidBgz5c=; b=AT0GZkIDa30VGwNPbfKHpiYYJxMV4N/OPgbHgxBY5AFWiVGoyYXTLjf8v0jcnPWpSm n0ok0zTnVKqm4lAa+Yhkzf2a/WCjSqNKolu/yVeLW1BL7oUFarG8fb54Nca005QjJ/12 nMgPVu88qJbYz0bCRUbtfhddSg/L5iXwArRFa64rAOH885Pt90g//vT3xPBOFb/Ors1Y weC+eAAdgqS0jrYuG5UJxJ9XFB29QxpLDYAzUicxVD8lExk2me/k9aquySaAYttLpfFE wrEXUpXUlSZW2Bd5kTvLbCaHV7uQECv2b9vzctvpOz+qR4FRZ0n+Ve7XoHOkFOqSkXBf v0wg== X-Gm-Message-State: APjAAAW/r605RjM5ySIHn3HCR5faQutYy6kwP2sZEvSDzr+VS3FpVCkt yl9SetTA1SY0djtWLMuajZ1oot+aRdQ= X-Google-Smtp-Source: APXvYqwKg0QX4PFoEXuDwqmIl5kNhN6Vf+p8fM78NdR+tYaIwvdSx+d8oJiLk56nWEGWIOq+H9Hi5A== X-Received: by 2002:a63:9d43:: with SMTP id i64mr13174848pgd.404.1561058457451; Thu, 20 Jun 2019 12:20:57 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm255703pfa.2.2019.06.20.12.20.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 12:20:56 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 20 Jun 2019 12:20:40 -0700 Message-Id: <20190620192048.13814-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620192048.13814-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190620192048.13814-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 1/9] 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" 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 Thu Jun 20 19:20: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: 55133 X-Patchwork-Delegate: thomas@monjalon.net 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 572511D46E; Thu, 20 Jun 2019 21:21:06 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 40EB71D463 for ; Thu, 20 Jun 2019 21:21:00 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id q10so2201523pff.9 for ; Thu, 20 Jun 2019 12:21: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=oe0geve82kPbeuTLEhiKxz5m43I4cyFj8lTlsw5/DJo=; b=ZhBu3lmWOfs+tTwZ2IPZPXzRj/JtTSSNeAOD0LPbWHgGgViU9TDno3X9ScoDmX8gUL Bpj3MhaLfLi2dkpSnmFyznT9CenudlPn49Vl2VpAKHMrk4OI9ush5M9zEhOZCjF3I3RM vrM1mCksVm28tzcjYToISh8fK4Jx84B7YVTliZQ4D8S7G0s3xndaeNLT3FnWCskMCyXz MHdumeHT+FDeuqdsN04AGCEGRr+cnyv3Sz1hEyfK+RRxlUhAXod2o+cfKqeGqPOuKK7V WL7bfMv85IsoopVbEhMyxzARscYZj3vRTvLKwVpO9Ai3A4RAhdn1d9Iv5p7FXbsEKYoa nwoQ== 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=oe0geve82kPbeuTLEhiKxz5m43I4cyFj8lTlsw5/DJo=; b=dNx4vgw+xQoK5PzZgKptiUwSrWOlAz0VG4UaGYeGBLOXxnnneW2llenPL72wanAQ0C l67RFZZyh4sn1ZkOKQF1eUNOYCmjWynRQud9cG4N8/q10Tm5cNocAjsc1AM18TSBvU8Z RQj0B0s3GxV6ipk7snAxm5aTZkZFzq+I3PLnWUMnoEc8mrbYWFfzwCV61KopdTkjnVM0 RtC5FRx9x4lrGeN1iAqcZeZSMB2f2SvdZC0glD75536Sp6miJhGm9rJi1MiEkaSJ6eVc MXxSe889kYpaRRipAdkIqVhcSWM6d0XBSidyvChgomafPU20NxHq6ovbCtHmnSB6VK2R TEug== X-Gm-Message-State: APjAAAVYSzOnAZsEC0Pwf7r+3O8ALHVjKlAG6ZGWH3rJNWy3CdwFNFf9 NNzbesUhCBroQI9B+pZjHd7HbfpR3xM= X-Google-Smtp-Source: APXvYqyfzrBXEnX3CcBd0D+JcZjehII+mrPhJEZ5UfdgCEO4MdqnZKPQCRZYyI1PLjrxCiTJHbcx4g== X-Received: by 2002:a65:5a42:: with SMTP id z2mr14583259pgs.421.1561058458967; Thu, 20 Jun 2019 12:20:58 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm255703pfa.2.2019.06.20.12.20.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 12:20:57 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 20 Jun 2019 12:20:41 -0700 Message-Id: <20190620192048.13814-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620192048.13814-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190620192048.13814-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 2/9] 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" 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 Thu Jun 20 19:20: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: 55134 X-Patchwork-Delegate: thomas@monjalon.net 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 D79D91D479; Thu, 20 Jun 2019 21:21:09 +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 69F481D469 for ; Thu, 20 Jun 2019 21:21:01 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id p10so2092481pgn.1 for ; Thu, 20 Jun 2019 12:21: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=CZA5zLe4tbSwvOo2ZG+jag13FB9U46jQ6ezncJjNY/o=; b=IvnYuOvn335e1ljiZegMhPfH1rdT07XejsQUrsY/9pD3JUXOfV6cJAZ9mCeoZ09nKF ljhSBtlCUqEpIDbSIjcLB906W7SBPN5wPRm247+XFhQc3WxWfRFf61CI1gz1kkTEJl0r YzJeDyr0XHi/SsTQY3RbyBlDfnMsRNWV3KSckLAfzRy0CX/ztGPUTLeF7QGj8lEyvIuP PtsAo7ZtYmHimI6shbGm/mMvjCAs4nZGta0WhWae4a3xnZoCsmZpeKyIDlKEWYaxQUm1 lom7EY3SaKDQ0QlsgS65W2yUeSHXVHTZKU1KsKpBuXsrO4GNkAZGrl2VOytn2UziGjOa dMow== 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=CZA5zLe4tbSwvOo2ZG+jag13FB9U46jQ6ezncJjNY/o=; b=BjbOjc+DRbEmK6tPxx1HMMZkKl/2jRasCXcEHtzaIIKdLjTk/ClF7J+lkvedaqAbtK 9uNqxo216irBZnCyO2hWWob5NVuv7JuhN16/yEZ0Rw66PaLDncNuR3X6Zw3ogRRge67H iAwstB+nxFwa5asFxX1OZk7tv6jcMX4Jjtx2B1ll65p71joB9hoyVus5q0SoYLMHQok2 yYPitzHHEFtl041KGlBBnL2fi8L4br4l9+PmEdiPyjW2DivXja6UcvB66cy5gh2dCSRS ByTBs8EkJ3B2Jw9MUGG2DEesmyGDXg6guSePCUeEnS/3m/sHmAXpWhBDMH5EScq28aBD nSCA== X-Gm-Message-State: APjAAAXLAxv8/jqJGVA2KBFwsEeHN2a1vtLgzqg6Ti6xtTseG89JnVgQ b7ywDDrEjRbF7LvdQnytWh/p4fEQ5zg= X-Google-Smtp-Source: APXvYqy+3CYb9zLyvigJn5rcG+H/JT50ZHvofStj6rC9pNaikXrYa5OoQ6yOetnH4j5Npqw+XK32Kw== X-Received: by 2002:a63:db05:: with SMTP id e5mr14191932pgg.121.1561058460097; Thu, 20 Jun 2019 12:21:00 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm255703pfa.2.2019.06.20.12.20.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 12:20:59 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 20 Jun 2019 12:20:42 -0700 Message-Id: <20190620192048.13814-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620192048.13814-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190620192048.13814-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 3/9] 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" 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 Thu Jun 20 19:20: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: 55135 X-Patchwork-Delegate: thomas@monjalon.net 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 D31891D481; Thu, 20 Jun 2019 21:21:14 +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 969C91D469 for ; Thu, 20 Jun 2019 21:21:02 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id d126so2218269pfd.2 for ; Thu, 20 Jun 2019 12:21: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=BwV/bLfNBEHbbWxYej1CZA4dAMgB1xEzqt3/qXzzhdI=; b=fJvP8pDXSA9WHia4KYz88MUXsnYOGhu2if9O2y0cYLw/+OodVLVxMsXAj2zrxbCAj6 9Z8flDM0IiXP3i9GMjD3qib3a74QcrotbUvJIyYg3KER5A7upNXZMUxqsPBk2wA+7lUm AGzv+MFv73yUueAqLa9xL2TFLfpYEl7m191D9GrIKwSNQB5zu37ElKl+kA1avs9brktB dknYrbXdnvqzp9VMNfrV1Ys84GBEevCqu4VeB8I0cVFx5frhcEzmmeZn8wammsfOGppu F8ncuil8QIdO8VMSDLgJ1me1uZqyI7vB87i4hbZpa1LXmgIRPWr4LDKAXypRdvad8AtB Rjlw== 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=BwV/bLfNBEHbbWxYej1CZA4dAMgB1xEzqt3/qXzzhdI=; b=poXK2otLYYHsMtmgufCp8QQ7RAwp6qDtyo3NmhI4Tt7K8AY6gTZ+/mIm3SVDTWnUj5 +dUL7f0IknCJU00blenfynZgNEiENufeH9np5uHVROurf0ffNJ1DPBmErJMA9MVO/Stj eIcM8ORlkJXcjRV7BjPhclXdPZkMrQBQd+Qn6LSG8ek2uGV2zB9JSHLV5Cr98yBF397k KPXz+MEabjr774rGl3dwgC283oH3uVrH0PuikvGfOa2OZDNUGdG0af+p9uKOvlyIdS/F ChKTcqU8hRfQLtWbZ/inCvAUK+q95g2dGwGRozGwzbbdIvXLyYfN0AJMnOtaPgWG/l6A moAQ== X-Gm-Message-State: APjAAAWbjEr+OfZUQVVPOa9x2J3dY95fPStOR8HYUBehN6b+3Hr2A+Gb NMLbVa18aYmpBWnFKiEfAvohr+6k+yk= X-Google-Smtp-Source: APXvYqxLR5JZHnPt3r6JMTfSWF9iXT5J6wxQoPZJMvhPfNn3VuaGHWMYxXIOcptHdC01bvrTD2sy+w== X-Received: by 2002:a63:1658:: with SMTP id 24mr13745964pgw.167.1561058461464; Thu, 20 Jun 2019 12:21:01 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm255703pfa.2.2019.06.20.12.21.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 12:21:00 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 20 Jun 2019 12:20:43 -0700 Message-Id: <20190620192048.13814-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620192048.13814-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190620192048.13814-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 4/9] 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" Several fields were either totally unused or set and never used. 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 Thu Jun 20 19:20: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: 55136 X-Patchwork-Delegate: thomas@monjalon.net 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 38CA81D48A; Thu, 20 Jun 2019 21:21:17 +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 DF6B31D46B for ; Thu, 20 Jun 2019 21:21:03 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id m4so1476316pgk.0 for ; Thu, 20 Jun 2019 12:21:03 -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=MaX/9U1VKQDRlwJP1eh9LKqP+HAkhTNljy8r1/SknpU=; b=0V577HkMMglYmsTImfFcLBXf+WL6OR5xpxsA4zTBFQnIMhpxto7mAPnfXd+hkOi7Og ltMWkp26SLhttLigFnOtc/enXGjFgO9Eh0LAt3axhcaLOMeXvpFUNewfcoGRcsgO6Bi1 txqmuts565ULlWmJfA0JvfZHVXI4DbG23iCbkacMFrIZPouV+SApA4eK4j4R1Ne43fs1 yqY/KjKqiZo7JADFRgq2ABu326xLzTsNALADakA1iXCKqgjA9VOijrWM2J0U5YQwo54T qYKv1TOFDfccy/xE0YV5gAQOE3vMR20rI86JSuIFwpowJNdOAiG6aMBJPQTB+RMhrV8Z vSKg== 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=MaX/9U1VKQDRlwJP1eh9LKqP+HAkhTNljy8r1/SknpU=; b=SnYIZjAI2ITD560BehFWrH5w3onFOROgBkEsWG6XTm4NE6iSnNYfr3ZwgAMs0F1WNH qCSMiHGwHRrLvWX+y9CSb/v10DgBjfpVCPtUPJ9YSd9RKu32yVR7B4limF1ckvQX+1Zs jungO7aFqhXftX7MsW4+++QVmipGeesz01JdmJjVFnJnERf8z37JvMnyYilysU+oKRLF VaVEXHOt/2OADLyCJci2IeF7AKxO5ZqeNF4QnXvIvElYyhnIA1n9GY+SRIsLRLDbBCoQ +ONYcIfbqdasv2XWXvsZHMVEiBVDBQDCylGfGe3qJTDVuOK7ejqJ87K9biwsCl9bP+Z0 mKPA== X-Gm-Message-State: APjAAAUN2JIMJErvTVNpJ1nSgMbUCFzl/6RgVe/OPcElhRqKtWyYLJHh 7KDvJst6zc6wDIO2/JYVEKw7LXcsJOg= X-Google-Smtp-Source: APXvYqyAa4rz1iYP/qBRufSOFZDeRapIDdHEkMPCXQ17oDL/QmTjFou4MGkw9rD5TNAIk6SAtMjebQ== X-Received: by 2002:a63:6ecf:: with SMTP id j198mr14192429pgc.437.1561058462826; Thu, 20 Jun 2019 12:21:02 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm255703pfa.2.2019.06.20.12.21.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 12:21:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 20 Jun 2019 12:20:44 -0700 Message-Id: <20190620192048.13814-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620192048.13814-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190620192048.13814-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 5/9] 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" 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 Thu Jun 20 19:20: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: 55137 X-Patchwork-Delegate: thomas@monjalon.net 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 C64921D492; Thu, 20 Jun 2019 21:21:18 +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 19F511D467 for ; Thu, 20 Jun 2019 21:21:05 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id f25so2066824pgv.10 for ; Thu, 20 Jun 2019 12:21: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=9ZfM4adtNVrF7wT1Mjc0z707Ax+G9osFiWtI1ekyG9E=; b=BsHKJBwl9VUEkFWXS5327E2HSNc3JDo08kdmSflhKcNR/vk+do8O7NwoVxObllrIr4 dR/3V75lo7xfJqGaizCIJPF2Iptm+TkpcMN0TZCHlRVJF+IgkigxogvXH5Z0eFODvM6Q QfX3uZaShjt69gEFYHOzWOJOaQK5gSzl6PtLDje1/KsxqFF1azO8z0c2Wmtaf9H+RwDe N383YNFsyTxoWNVIaTdhPwRJR9y9vQmN2gaB7bqDBgTdlA+j6/obiNRd0PNdSs0Kab1n Sxs2w/rNYf7V4Ml6QNK9UNvjdXvgU0vQvkeasWw+sxU0ARGSaQP5WrI0YU9cHpqE0LLT rXHg== 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=9ZfM4adtNVrF7wT1Mjc0z707Ax+G9osFiWtI1ekyG9E=; b=cGycGbewS2Slb2Vqrwc1IiFIQXKZdf9cZl52whJXj1pLbECinTMa80edl6xSMjyCl3 04rcik6QySxST/uTqMTa5dlS2nLSmu+Zf4tSlp8eiMlsVdFDdueoTNu3ImLQC3s5fu2A JEjQzLI+QFT9qKPrWkOknpAKR3k5SNTsFg+MVmUd41LfiLayZQOsNvPjAa131FeobTfV wXxUjR9S4uagFTlK02PQ96ICRDyGQlrLEW7niDBDR/qB5kcZcLcC9gr1aE8nScoSvnG6 P9JTuIugopNs5UsKgQX/mXurF29fHylagtdMcZbrsZ8D2HGxi00biZXA0aB7wkks1Bq5 6loQ== X-Gm-Message-State: APjAAAUbDrHoCkEGuFE4xZ5GL2I5daxfmxlrDirk4IwTeLun6aT2m2hw 0zaN6KJAeZuaF4C99axNSaS2rrhqYOE= X-Google-Smtp-Source: APXvYqweTTjSqy2DX7zzUUPrwsAFkuqExuDAONUbp7+6r5u+mlZamQ8CpSVNd5N5pH2sUgwGYwVY0g== X-Received: by 2002:a17:90a:9291:: with SMTP id n17mr1252663pjo.66.1561058464045; Thu, 20 Jun 2019 12:21:04 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm255703pfa.2.2019.06.20.12.21.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 12:21:03 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 20 Jun 2019 12:20:45 -0700 Message-Id: <20190620192048.13814-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620192048.13814-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190620192048.13814-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 6/9] 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" 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 Thu Jun 20 19:20: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: 55138 X-Patchwork-Delegate: thomas@monjalon.net 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 03CCF1D4A0; Thu, 20 Jun 2019 21:21:21 +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 ABC0B1D472 for ; Thu, 20 Jun 2019 21:21:06 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id m30so2198930pff.8 for ; Thu, 20 Jun 2019 12:21:06 -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=zwcpHj9mObwR/3WCwV5l4XnojjP3r4EDgCtfcfF1G0s=; b=P0f3TAMc+DtV27ziIjT/x2fHZI/kML1c8dumU50OimgpK6thLmbBsL6W+6AQJQInEi GS2JD/vfH+O9se0/RJmk5pgh0QWhTVglXNq64px6olt+1q4W4hTuRywnTZkOVpMcx2zH 2VGIm32JPwqPQI5tFjphX+iYQu1Q/pIWNFpYWovUGR3bcBeN7sY3sPpheRYTrS6RkHoj 7gBDLCSXZ86UH5JOITj1bkf1MdqZi0pJRJMxdXH5EHrMlqX3Q9Ra7v/35olXVjROEH2L 7wmlk4Fhwuyw/BQTnxQDy7OdbXLAtXTWumI2hao/7jlDDOujgi2hHSpESnQ3F/qfBsl1 zIdw== 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=zwcpHj9mObwR/3WCwV5l4XnojjP3r4EDgCtfcfF1G0s=; b=NGILB65jcmvo2VRU8kWTxPXdy46AhwZ5WasQ3soa/d6fXOR8ufMLF/6eLBoIz3qwW+ zKGXQBZ3MRzQRrJTnSyNPQjs8wbbxsTj1x/Qq1bjPceUs/wJThAdQ7v22fSDMfm0jU3L yK3vuMQL7gdwdtpwdWf9NKMMfi1ozlidfdEa0uDcxcsLYr/sT3VIPlDuB3CQYIxk3LUJ CGg7xwIchXJ/u3cFMOMvDk7CTx5YUsRs8JBX91mxGkcFtnPq77Vqrlcx8iijOx1jH78x 2CAfJwiMcryxsn+hF/g49SizhxQRP59hLL7HN9E+x6qpdnxPzacmVlR9at10AchjS4ac ibXg== X-Gm-Message-State: APjAAAXvuewsJkWK8ba6v4QDzB3E8bmFWURPB6i+hgM2ela9ttLjxsVn 3SfOMRjzSLhOgGbZMfF0pR11WLhmSyE= X-Google-Smtp-Source: APXvYqyq+NNzBIz/Ffmz1xff1hv6kcr2w8084y5AJAIRTq6UU6ln5xrJOAiaO8bSBkybqVbDHfa5Xg== X-Received: by 2002:a63:2a0f:: with SMTP id q15mr14529539pgq.163.1561058465455; Thu, 20 Jun 2019 12:21:05 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm255703pfa.2.2019.06.20.12.21.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 12:21:04 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 20 Jun 2019 12:20:46 -0700 Message-Id: <20190620192048.13814-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620192048.13814-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190620192048.13814-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 7/9] 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" 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 Thu Jun 20 19:20:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55139 X-Patchwork-Delegate: thomas@monjalon.net 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 554A61D4A6; Thu, 20 Jun 2019 21:21:23 +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 5C9611D473 for ; Thu, 20 Jun 2019 21:21:08 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id n2so2062364pgp.11 for ; Thu, 20 Jun 2019 12:21:08 -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=yQGVqm3LrM7rzZPEwpU4sXdV9MaF0Mw7W9U4PD+EN1Y=; b=xbVsoMEE6cZ90Zyl5Z46sSlZMEvKpSAgqger2l/glv0rEm5quZIqACo05baDHYdnSt 6Swa6ufp1mG00OsBA9c/n2tiNjuTxmjDK5FiMnFtXjY1ZxIDI87SFSlYmML7DEy3yH4q q9cdIfzkIleBSxEVTWZAegdwAUJN1WHJIYA3wlyoTCNmy/hr7YNzfxsR2NXtjwAb7RfF 3YYcManiZE7OrKxrhIvEm+sIjtj9VI3s70ysaZhUumStw7X+uHGbZwOIYYh5Wj+ThkgJ hUT6aylxXTF1FVwPNwdQxH8RWk2fg6Ej+uWbuBg3WwyrdfWDvLSkQLcAvEpv98TVXJU+ oD+g== 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=yQGVqm3LrM7rzZPEwpU4sXdV9MaF0Mw7W9U4PD+EN1Y=; b=eRdZJfGePw0GPSUDWgYeeJQh9F6dJOgDVO0GsDMok7yNrWrHCGzoIBLEHZ68q63mN1 GWsb+jKEmNQzZFVZ5PktDl1TDmeWiwwX2D5yHp5w+pmNQJOj6cH6JE+lm553K4UOz/O0 NMsbJACBXyvwjMifjFFagQ+YJktk/oHVe4MFU77OHRHAIGui02gBOXs0rfOVT5nlPciH KdVh5DxVlLwv/XjGn9825kdd+g7O6K3AhVDIWnthyfbwiA1aQmC39uIlpWsw2mXTZAvf V22vxTTsHYrLjUgy57bHurL7nd45JeXkKRuJbr4RBHhz4zHPZZ2rLMkKVktCvo2OS6hk NJWw== X-Gm-Message-State: APjAAAXi/WWxq8WX+y3ugUQAenlG0y6QEeJ7lv9PyLnRYVvlXc1SbVdJ 9fNR4FvYIce34PyBA+0h3Pr+jBLggX0= X-Google-Smtp-Source: APXvYqz9iInm40BfS+JUYUPkf+HmZIdPz0yf6z3pfQ19uS899vkFMKjP2ThW4zIXEMrNu5e6Az2Gng== X-Received: by 2002:a17:90b:d82:: with SMTP id bg2mr1271325pjb.87.1561058467292; Thu, 20 Jun 2019 12:21:07 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm255703pfa.2.2019.06.20.12.21.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 12:21:05 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 20 Jun 2019 12:20:47 -0700 Message-Id: <20190620192048.13814-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620192048.13814-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190620192048.13814-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 8/9] 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" rte_kni does not follow standard style rules. Noticed some extra \ line continuation etc. Signed-off-by: Stephen Hemminger --- kernel/linux/kni/kni_net.c | 7 ++++--- lib/librte_kni/rte_kni.c | 38 +++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c index 06310fec57bb..320d51d7fc83 100644 --- a/kernel/linux/kni/kni_net.c +++ b/kernel/linux/kni/kni_net.c @@ -401,7 +401,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni) /* Get the number of entries in rx_q */ num_rq = kni_fifo_count(kni->rx_q); - /* Get the number of free entrie in tx_q */ + /* Get the number of free entries in tx_q */ num_tq = kni_fifo_free_count(kni->tx_q); /* Get the number of entries in alloc_q */ @@ -755,6 +755,7 @@ kni_net_config_lo_mode(char *lo_str) } else if (!strcmp(lo_str, "lo_mode_fifo_skb")) { pr_debug("loopback mode=lo_mode_fifo_skb enabled"); kni_net_rx_func = kni_net_rx_lo_fifo_skb; - } else - pr_debug("Incognizant parameter, loopback disabled"); + } else { + pr_debug("Unknown loopback parameter, disabled"); + } } 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; } From patchwork Thu Jun 20 19:20:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55140 X-Patchwork-Delegate: thomas@monjalon.net 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 ADDD71D4AF; Thu, 20 Jun 2019 21:21:25 +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 72EE41D473 for ; Thu, 20 Jun 2019 21:21:09 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id p10so2092650pgn.1 for ; Thu, 20 Jun 2019 12:21: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=VHA65NftE/bw5p/GVwIeWgkJKcWI3PGvUBPGSt32qbc=; b=mCjrPyRF6FmlFR3wtvJ7+VC8lJL/Ex60V3J1V8h8nPMC3ZM3vzbgOxJGQ54b83nJa4 dYiWXdWSXip3ttV6lDNvRbj+4m+odVKSLZ8Fjvlrg4UMqDE8D7mgZ5rv7yH0GspB3WCE LGPs9OoC8FTFHWnFxJMyRmVfsqJrOZ0fc5zzOA6RXYCrDxraZ8tnPSx5U+z9ZEcbo1xi wE0XdTNHBfwiB78h23QOHCg84Fa3yOCKvsK5j1mJBYczcIOh2rXEcErzrO+xTEjH6QRW D9Q5kew0YJipTaZPqd8j6hv8To6P6YQKFyZJ6gTqmG7uV9k9ZUOwNh8gyzsQ/NZ2C3tR jDeA== 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=VHA65NftE/bw5p/GVwIeWgkJKcWI3PGvUBPGSt32qbc=; b=QIlA2oefJHJ8f5oPK0OQ5uDGDv13DOus2tEDdB88IQufv4BRk41p0HQ5SDUurjN+bY mwN6V+ihDeZo025/nvNIFPh/NVCGkLjMiBm7gwaSVrko7UO9XXOXGU1Rehk4JocsT+t4 Ua+Nmcis4kOPYssVXuY+obhNpd7kz8LPvb3QtySDXtcyhJCsu8rYUQsjo+BoFpm1aHmd TwsBJbMVs12sP9drK0UW5kuOyoITfhVba3vqwteJ6OUtF2BJrs8v06inK+x0zy9tqaSf z793SOy1I7dV6wb/lYP8tr1iIvrR0Es64EBx6cmXelsWvw4ySoiLAul1WpgdvcprDRpC 7o4w== X-Gm-Message-State: APjAAAUMaSU7ls4A4u4HFimrIEKGJopK/tJmuB8lwl2eLyppWfuB+tMd ajmefTXtyGGFBKwB/WVEAuAxdTRVmmY= X-Google-Smtp-Source: APXvYqwR63gaOpIUYxDeOa4jq4u8GEgvUi31i9qmRCy+cqUQkoimKxyPeo/7sF9JKAQCmmJROQSDyQ== X-Received: by 2002:a17:90a:214f:: with SMTP id a73mr1256261pje.21.1561058468421; Thu, 20 Jun 2019 12:21:08 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm255703pfa.2.2019.06.20.12.21.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 12:21:07 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 20 Jun 2019 12:20:48 -0700 Message-Id: <20190620192048.13814-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620192048.13814-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190620192048.13814-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 9/9] kni: add minimal ethtool 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" Some applications use ethtool so add the minimum ethtool ops. Signed-off-by: Stephen Hemminger --- kernel/linux/kni/kni_dev.h | 2 ++ kernel/linux/kni/kni_misc.c | 1 + kernel/linux/kni/kni_net.c | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h index ceba5f73c1d9..c1ca6789ce12 100644 --- a/kernel/linux/kni/kni_dev.h +++ b/kernel/linux/kni/kni_dev.h @@ -11,6 +11,8 @@ #endif #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#define KNI_VERSION "1.0" + #include "compat.h" #include diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c index be45f823408f..2b75502a8b0e 100644 --- a/kernel/linux/kni/kni_misc.c +++ b/kernel/linux/kni/kni_misc.c @@ -21,6 +21,7 @@ #include "compat.h" #include "kni_dev.h" +MODULE_VERSION(KNI_VERSION); MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Intel Corporation"); MODULE_DESCRIPTION("Kernel Module for managing kni devices"); diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c index 320d51d7fc83..319ee2dcb19a 100644 --- a/kernel/linux/kni/kni_net.c +++ b/kernel/linux/kni/kni_net.c @@ -13,6 +13,7 @@ #include #include #include /* eth_type_trans */ +#include #include #include #include @@ -725,6 +726,18 @@ static const struct net_device_ops kni_net_netdev_ops = { #endif }; +static void kni_get_drvinfo(struct net_device *dev, + struct ethtool_drvinfo *info) +{ + strlcpy(info->version, KNI_VERSION, sizeof(info->version)); + strlcpy(info->driver, "kni", sizeof(info->driver)); +} + +static const struct ethtool_ops kni_net_ethtool_ops = { + .get_drvinfo = kni_get_drvinfo, + .get_link = ethtool_op_get_link, +}; + void kni_net_init(struct net_device *dev) { @@ -736,6 +749,7 @@ kni_net_init(struct net_device *dev) ether_setup(dev); /* assign some of the fields */ dev->netdev_ops = &kni_net_netdev_ops; dev->header_ops = &kni_net_header_ops; + dev->ethtool_ops = &kni_net_ethtool_ops; dev->watchdog_timeo = WD_TIMEOUT; }