From patchwork Mon Mar 28 08:52:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Mauricio_V=C3=A1squez?= X-Patchwork-Id: 602474 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3qYZ1Y3SWbz9sDD for ; Tue, 29 Mar 2016 00:06:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=studenti.polito.it header.i=@studenti.polito.it header.b=gOI0mMWT; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7808F10306; Mon, 28 Mar 2016 01:52:38 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 7277A102F9 for ; Mon, 28 Mar 2016 01:52:37 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id DCE1E1611E4 for ; Mon, 28 Mar 2016 02:52:36 -0600 (MDT) X-ASG-Debug-ID: 1459155156-0b323711c6668840001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar6.cudamail.com with ESMTP id wAi6iu9lgiBeNLu3 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 28 Mar 2016 02:52:36 -0600 (MDT) X-Barracuda-Envelope-From: mauricio.vasquezbernal@studenti.polito.it X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO compass.polito.it) (130.192.55.110) by mx3-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 28 Mar 2016 08:52:35 -0000 Received-SPF: pass (mx3-pf1.cudamail.com: SPF record at studenti.polito.it designates 130.192.55.110 as permitted sender) X-Barracuda-Apparent-Source-IP: 130.192.55.110 X-Barracuda-RBL-IP: 130.192.55.110 Received: from localhost (localhost [127.0.0.1]) by compass.polito.it (Postfix) with ESMTP id C323E100941; Mon, 28 Mar 2016 10:52:32 +0200 (CEST) Authentication-Results: compass.polito.it (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=studenti.polito.it DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= studenti.polito.it; h=x-mailer:message-id:date:date:subject :subject:cc:to:from:from:received:received; s=y2k10; t= 1459155151; bh=z7btdb2dI0pi1roQJFL3q1icT+nH/sJC3VggcIM++NA=; b=g OI0mMWTrgxnTJwA/THEd1kfmSyOCnU/sbqiwiyiIzw+27e+KcQd7XvK6Ac66LS26 FpbRYCgFmC25YLJQY+C8DwiHPKVfVipeUuW3yG6mOsCnTMpMdt/yZoDK/YdC855L eoA6GOVfi5JhYG3wDWV1aGdq3vfhxCL7PhEixgiCvQ= X-Virus-Scanned: amavisd-new at studenti.polito.it X-Spam-Flag: NO X-Spam-Score: -6.182 X-Spam-Level: X-Spam-Status: No, score=-6.182 tagged_above=-100 required=3.5 tests=[ALL_TRUSTED=-5, AWL=0.318, BAYES_00=-1.5] autolearn=ham Received: from compass.polito.it ([127.0.0.1]) by localhost (compass.polito.it [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JTSG2dGLKUHD; Mon, 28 Mar 2016 10:52:31 +0200 (CEST) Received: from mvb-X455LJ.lan (unknown [93.56.122.220]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: s203403@studenti.polito.it) by compass.polito.it (Postfix) with ESMTPSA id A6D23100938; Mon, 28 Mar 2016 10:52:31 +0200 (CEST) X-CudaMail-Envelope-Sender: mauricio.vasquezbernal@studenti.polito.it From: Mauricio Vasquez B To: dev@openvswitch.org X-CudaMail-MID: CM-V1-327001897 X-CudaMail-DTE: 032816 X-CudaMail-Originating-IP: 130.192.55.110 Date: Mon, 28 Mar 2016 10:52:20 +0200 X-ASG-Orig-Subj: [##CM-V1-327001897##][PATCH 1/3] netdev-dpdk: add hotplug support Message-Id: <1459155142-3762-1-git-send-email-mauricio.vasquezbernal@studenti.polito.it> X-Mailer: git-send-email 1.9.1 X-GBUdb-Analysis: 0, 130.192.55.110, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-7376-c X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1459155156 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 1.85 X-Barracuda-Spam-Status: No, SCORE=1.85 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_RULE_7580B, BSF_RULE_7582B, BSF_SC5_MJ1963, DKIM_SIGNED, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.28230 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.50 BSF_RULE_7582B Custom Rule 7582B 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.75 BSF_RULE_7580B Custom Rule 7580B 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH 1/3] netdev-dpdk: add hotplug support X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" In order to use dpdk ports in ovs they have to be bound to a DPDK compatible driver before ovs is started. This patch adds the possibility to hotplug (or hot-unplug) a device after ovs has been started. The implementation adds an appctl command: netdev-dpdk/port-clt After the user attaches a new device, it has to be added to a bridge using the to use the add-port command, similarly, before detaching a device, it has to be removed using the del-port command. Signed-off-by: Mauricio Vasquez B --- lib/netdev-dpdk.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 7c4cd07..05fa0df 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1982,6 +1982,75 @@ netdev_dpdk_set_admin_state(struct unixctl_conn *conn, int argc, unixctl_command_reply(conn, "OK"); } +static void +netdev_dpdk_port_ctl(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[], void *aux OVS_UNUSED) +{ + int ret; + uint8_t port_id; + unsigned int parsed_port; + char devname[RTE_ETH_NAME_MAX_LEN]; + char response[512]; + + ovs_mutex_lock(&dpdk_mutex); + + if (strcmp(argv[1], "attach") == 0) { + ret = rte_eth_dev_attach(argv[2], &port_id); + if (ret < 0) { + snprintf(response, sizeof(response), + "Error attaching device '%s'", argv[2]); + unixctl_command_reply_error(conn, response); + goto unlock; + } + + snprintf(response, sizeof(response), + "Device '%s' has been attached as 'dpdk%d'", argv[2], port_id); + unixctl_command_reply(conn, response); + + } else if (strcmp(argv[1], "detach") == 0) { + ret = dpdk_dev_parse_name(argv[2], "dpdk", &parsed_port); + if (ret) { + snprintf(response, sizeof(response), + "'%s' is not a valid dpdk device", argv[2]); + unixctl_command_reply_error(conn, response); + goto unlock; + } + + port_id = parsed_port; + + struct netdev * netdev = netdev_from_name(argv[2]); + if (netdev) { + netdev_close(netdev); + snprintf(response, sizeof(response), + "Port '%s' is being used. Remove it before detaching", + argv[2]); + unixctl_command_reply_error(conn, response); + goto unlock; + } + + rte_eth_dev_close(port_id); + + ret = rte_eth_dev_detach(port_id, devname); + if (ret < 0) { + snprintf(response, sizeof(response), + "Port '%s' can not be detached", argv[2]); + unixctl_command_reply_error(conn, response); + goto unlock; + } + + snprintf(response, sizeof(response), + "Port '%s' has been detached", argv[2]); + unixctl_command_reply(conn, response); + } else { + snprintf(response, sizeof(response), + "'%s' is not a valid argument", argv[1]); + unixctl_command_reply_error(conn, response); + } + +unlock: + ovs_mutex_unlock(&dpdk_mutex); +} + /* * Set virtqueue flags so that we do not receive interrupts. */ @@ -2262,6 +2331,10 @@ dpdk_common_init(void) "[netdev] up|down", 1, 2, netdev_dpdk_set_admin_state, NULL); + unixctl_command_register("netdev-dpdk/port-ctl", + "attach/detach device", 2, 2, + netdev_dpdk_port_ctl, NULL); + ovs_thread_create("dpdk_watchdog", dpdk_watchdog, NULL); }