From patchwork Mon Jul 22 14:08:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1134957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="W+JLmOEB"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45sk4S5qfXz9sDQ for ; Tue, 23 Jul 2019 00:09:11 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 63F5DC97; Mon, 22 Jul 2019 14:09:07 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 888ADC5C for ; Mon, 22 Jul 2019 14:09:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CDAB9224 for ; Mon, 22 Jul 2019 14:08:56 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190722140854euoutp02988a786a552d60e882624112f5b935cd~zv-BehIf61493214932euoutp02d for ; Mon, 22 Jul 2019 14:08:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190722140854euoutp02988a786a552d60e882624112f5b935cd~zv-BehIf61493214932euoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1563804534; bh=+xdojDldJI13tcCmS5PJRcR+epqE/r0jyych7NIzkUk=; h=From:To:Cc:Subject:Date:References:From; b=W+JLmOEB8DqbaUbaYgHKGOp/yMSbJJT9pcNuZxegsVeFg29aZYgHIGlbopgvhzVte ZUroCa3N6jQYFj9zc4XT+7kwi2E7pL6RCty+jNyF0xLSkPHQOXXg/DYs/4vAukMC93 Q0dfU1rJ6Rh4QYdX3R7bsdRWU4AQ8ELfDxxXYXik= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190722140854eucas1p19601678214094ea7071cb125279ef8d2~zv-BFuYTp1476614766eucas1p18; Mon, 22 Jul 2019 14:08:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A0.5C.04377.573C53D5; Mon, 22 Jul 2019 15:08:54 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190722140853eucas1p139ad7cb75b8e0c3422ce8a42e6742a2c~zv-AYsWjc1295512955eucas1p1y; Mon, 22 Jul 2019 14:08:53 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190722140853eusmtrp299f029f5b1991fab779f1aa798b9096d~zv-AKpbRr2524925249eusmtrp2S; Mon, 22 Jul 2019 14:08:53 +0000 (GMT) X-AuditID: cbfec7f4-12dff70000001119-5b-5d35c375c926 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 9F.AE.04140.573C53D5; Mon, 22 Jul 2019 15:08:53 +0100 (BST) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190722140852eusmtip2ee6187ccd1ddf6e12ef12027dec3dc42~zv_-sRtHY1060310603eusmtip2f; Mon, 22 Jul 2019 14:08:52 +0000 (GMT) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Mon, 22 Jul 2019 17:08:48 +0300 Message-Id: <20190722140848.8872-1-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEIsWRmVeSWpSXmKPExsWy7djP87plh01jDY4eZLJ4NbmB0eLOlZ9s Flfaf7JbzP30nNHi+iUeB1aPnbPusns8u/mf0eP5tR4Wj/f7rrJ59G1ZxRjAGsVlk5Kak1mW WqRvl8CVsb3TrGCVfMXhNx9YGhg3SHYxcnJICJhI3D+ynK2LkYtDSGAFo8TZJRtZQBJCAl8Y Je6c8YJIfGaU+DD/HRNMx50ZTewQRcsZJfY+j4Io+sEoMf/HbDaQBJuAjsSp1UcYQWwRAWmJ 171vWEGKmAV6GCXu3V0DlhAWsJNofP8SbCqLgKrEtNNnwabyClhJzHq9H2qbvMTqDQeYQZol BI6wSfxaepkRIuEi8WNROxuELSzx6vgWdghbRuL/zvlQzfUS91teMkI0dzBKTD/0DyphL7Hl 9TmgBg6gkzQl1u/Shwg7ShzbtpURJCwhwCdx460gSJgZyJy0bTozRJhXoqNNCKJaReL3weXM ELaUxM13n6Eu8JCYv+o2E0i5kECsxLpOnwmMcrMQVi1gZFzFKJ5aWpybnlpslJdarlecmFtc mpeul5yfu4kRGPOn/x3/soNx15+kQ4wCHIxKPLwb9pjGCrEmlhVX5h5ilOBgVhLhzTMACvGm JFZWpRblxxeV5qQWH2KU5mBREuetZngQLSSQnliSmp2aWpBaBJNl4uCUamC0OW1+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MTR: 20190722140853eucas1p139ad7cb75b8e0c3422ce8a42e6742a2c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190722140853eucas1p139ad7cb75b8e0c3422ce8a42e6742a2c References: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ilya Maximets Subject: [ovs-dev] [PATCH] netdev-afxdp: Fix use of unconfigured device. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org In case of failure of 'xsk_configure_all()', 'n_rxq' and 'xdpmode' will remain in a new state. This will result in successful reconfiguration (immediate return, because configuration is already applied) if 'netdev_reconfigure()' will be called again. Same issue was fixed previously for netdev-dpdk using 'dev->started' flag in commit: 606f66507250 ("netdev-dpdk: Don't use PMD driver if not configured successfully") Let's use similar approach with checking the 'dev->xsks' which only exists if configuration was successful. Additionally implemented 'netdev_afxdp_construct()' function to explicitly initialize all the specific fields and request the reconfiguration. CC: William Tu Fixes: 0de1b425962d ("netdev-afxdp: add new netdev type for AF_XDP.") Signed-off-by: Ilya Maximets Acked-by: William Tu --- lib/netdev-afxdp.c | 30 +++++++++++++++++++++++++++++- lib/netdev-afxdp.h | 1 + lib/netdev-linux-private.h | 1 + lib/netdev-linux.c | 4 ++-- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c index 80f13fff3..6b0b93e7f 100644 --- a/lib/netdev-afxdp.c +++ b/lib/netdev-afxdp.c @@ -525,7 +525,8 @@ netdev_afxdp_reconfigure(struct netdev *netdev) ovs_mutex_lock(&dev->mutex); if (netdev->n_rxq == dev->requested_n_rxq - && dev->xdpmode == dev->requested_xdpmode) { + && dev->xdpmode == dev->requested_xdpmode + && dev->xsks) { goto out; } @@ -965,6 +966,33 @@ netdev_afxdp_rxq_destruct(struct netdev_rxq *rxq_ OVS_UNUSED) /* Nothing. */ } +int +netdev_afxdp_construct(struct netdev *netdev) +{ + struct netdev_linux *dev = netdev_linux_cast(netdev); + int ret; + + /* Configure common netdev-linux first. */ + ret = netdev_linux_construct(netdev); + if (ret) { + return ret; + } + + /* Queues should not be used before the first reconfiguration. Clearing. */ + netdev->n_rxq = 0; + netdev->n_txq = 0; + dev->xdpmode = 0; + + dev->requested_n_rxq = NR_QUEUE; + dev->requested_xdpmode = XDP_COPY; + + dev->xsks = NULL; + dev->tx_locks = NULL; + + netdev_request_reconfigure(netdev); + return 0; +} + void netdev_afxdp_destruct(struct netdev *netdev) { diff --git a/lib/netdev-afxdp.h b/lib/netdev-afxdp.h index ea63d76cf..6a72bd9a8 100644 --- a/lib/netdev-afxdp.h +++ b/lib/netdev-afxdp.h @@ -36,6 +36,7 @@ struct netdev_stats; int netdev_afxdp_rxq_construct(struct netdev_rxq *rxq_); void netdev_afxdp_rxq_destruct(struct netdev_rxq *rxq_); +int netdev_afxdp_construct(struct netdev *netdev_); void netdev_afxdp_destruct(struct netdev *netdev_); int netdev_afxdp_rxq_recv(struct netdev_rxq *rxq_, diff --git a/lib/netdev-linux-private.h b/lib/netdev-linux-private.h index ba87f9718..a350be151 100644 --- a/lib/netdev-linux-private.h +++ b/lib/netdev-linux-private.h @@ -43,6 +43,7 @@ struct netdev_rxq_linux { int fd; }; +int netdev_linux_construct(struct netdev *); void netdev_linux_run(const struct netdev_class *); int get_stats_via_netlink(const struct netdev *netdev_, diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 877049508..2432cd176 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -906,7 +906,7 @@ netdev_linux_common_construct(struct netdev *netdev_) } /* Creates system and internal devices. */ -static int +int netdev_linux_construct(struct netdev *netdev_) { struct netdev_linux *netdev = netdev_linux_cast(netdev_); @@ -3290,7 +3290,7 @@ const struct netdev_class netdev_afxdp_class = { NETDEV_LINUX_CLASS_COMMON, .type = "afxdp", .is_pmd = true, - .construct = netdev_linux_construct, + .construct = netdev_afxdp_construct, .destruct = netdev_afxdp_destruct, .get_stats = netdev_afxdp_get_stats, .get_status = netdev_linux_get_status,