From patchwork Fri Jan 22 18:48:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 60177 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp27077lbb; Fri, 22 Jan 2016 10:49:42 -0800 (PST) X-Received: by 10.107.14.131 with SMTP id 125mr5089482ioo.57.1453488582102; Fri, 22 Jan 2016 10:49:42 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l136si13771198iol.136.2016.01.22.10.49.41; Fri, 22 Jan 2016 10:49:42 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 6FA3F618E0; Fri, 22 Jan 2016 18:49:41 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=jzuXdSzr; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 35344618E2; Fri, 22 Jan 2016 18:48:30 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B3F2C618E2; Fri, 22 Jan 2016 18:48:24 +0000 (UTC) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by lists.linaro.org (Postfix) with ESMTPS id 645A9618E2 for ; Fri, 22 Jan 2016 18:48:23 +0000 (UTC) Received: by mail-wm0-f43.google.com with SMTP id 123so25520877wmz.0 for ; Fri, 22 Jan 2016 10:48:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=t/lqs7kxtECITCzYqCkbN789r5i9GQ0twm0KnnsO+To=; b=jzuXdSzrgn3uGuqwEdpqOj26IZIDJurZRnOI0iiQkfMI3O7qZKxj8jvwpLWt8xf++Y Xkd8y6yUCa0bbBsNp6IdZFL/h2Y58rHCSizEDBUdidyc9VtINKEw87kq+vl26gNzOqjx 3N+bQhyo1oNMAvHhIf7slS3yjSr2EJn0o5ZP4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=t/lqs7kxtECITCzYqCkbN789r5i9GQ0twm0KnnsO+To=; b=F/w0sde496cUuVX/i2cRCn9A9Wd0idJKrU5NLcJ7tRHqpNwOaUP95VlMRq9ijC6l6y zqaJL0SloD1StKCQb7vVLR8AyXuTkB6bnCtpeaBtqM30ItmonSAaxQ4viNGBBCmcHOqw qk5Z1cdFOH0BEQ0I/0KOd69cnY95WirJqqjcnk+m2365Uy7FUQyoHWORhXeLG72WYv4k x2yWu6NT4bVffBXgEO/mHiMWwiNeiD8U9kcs1bppOdD9pJcMq+JdLeUDW91RmEU5nn+b 00HhQ94Vpm/a2pW/ImIS2ooZM490MDOYP8AQIIfIjrcI2eKIt2lv/Ab44PrwwXWE1j+q vgkg== X-Gm-Message-State: AG10YOQXSlAyWmGo/YbhkHBq1P6OoHnuVB+ddfV1PjP42PgqXBtdluUVsq/8biyMP40eLj8eNqI= X-Received: by 10.28.218.78 with SMTP id r75mr5326950wmg.7.1453488502596; Fri, 22 Jan 2016 10:48:22 -0800 (PST) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::1]) by smtp.gmail.com with ESMTPSA id p9sm7085262wjy.41.2016.01.22.10.48.21 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jan 2016 10:48:22 -0800 (PST) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Fri, 22 Jan 2016 18:48:04 +0000 Message-Id: <1453488486-12176-4-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1453488486-12176-1-git-send-email-stuart.haslam@linaro.org> References: <1453488486-12176-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 3/5] linux-generic: pktio: add support for netmap VALE and pipe virtual ports X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" As well as connections to a physical network interface the netmap API also supports connections to two different types for virtual ports, VALE switch ports and netmap pipe ports. VALE is a virtual switch implemented in the netmap kernel module, it works as a learning bridge and is designed to be used for connections between virtual machines. netmap pipes connect two virtual netmap ports with a crossover connection, they can be used in a setup where a master process works as a dispatcher towards slave processes. Signed-off-by: Stuart Haslam --- platform/linux-generic/include/odp_packet_netmap.h | 2 ++ platform/linux-generic/pktio/netmap.c | 29 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/include/odp_packet_netmap.h b/platform/linux-generic/include/odp_packet_netmap.h index 7caa92f..5ebdb6a 100644 --- a/platform/linux-generic/include/odp_packet_netmap.h +++ b/platform/linux-generic/include/odp_packet_netmap.h @@ -22,6 +22,8 @@ typedef struct { int sockfd; /**< control socket */ unsigned char if_mac[ETH_ALEN]; /**< eth mac address */ char ifname[IF_NAMESIZE]; /**< interface name to be used in ioctl */ + odp_bool_t is_vale; /**< is a connection to vale switch */ + odp_bool_t is_pipe; /**< is a netmap pipe */ } pkt_netmap_t; #endif diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index f15ffff..639afa8 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -128,7 +128,10 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, snprintf(pktio_entry->s.name, sizeof(pktio_entry->s.name), "%s", netdev); - if (strncmp(netdev, "netmap:", 7) == 0) { + if (strncmp(netdev, "vale", 4) == 0) { + prefix = ""; + pkt_nm->is_vale = 1; + } else if (strncmp(netdev, "netmap:", 7) == 0) { netdev += 7; prefix = ""; } else { @@ -151,11 +154,19 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, goto error; } + if (pkt_nm->tx_desc->req.nr_flags & NR_REG_PIPE_MASTER || + pkt_nm->tx_desc->req.nr_flags & NR_REG_PIPE_SLAVE) { + pkt_nm->is_pipe = 1; + } + if (mmap_desc.mem == NULL) { mmap_desc.mem = pkt_nm->rx_desc->mem; mmap_desc.memsize = pkt_nm->rx_desc->memsize; } + if (pkt_nm->is_vale || pkt_nm->is_pipe) + return 0; + sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == -1) { ODP_ERR("Cannot get device control socket\n"); @@ -334,24 +345,40 @@ static int netmap_send(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], static int netmap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { + if (pktio_entry->s.pkt_nm.is_vale || pktio_entry->s.pkt_nm.is_pipe) + return 0; + memcpy(mac_addr, pktio_entry->s.pkt_nm.if_mac, ETH_ALEN); return ETH_ALEN; } static int netmap_mtu_get(pktio_entry_t *pktio_entry) { + if (pktio_entry->s.pkt_nm.is_vale || pktio_entry->s.pkt_nm.is_pipe) + return INT_MAX; + return mtu_get_fd(pktio_entry->s.pkt_nm.sockfd, pktio_entry->s.name); } static int netmap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { + if (pktio_entry->s.pkt_nm.is_vale || pktio_entry->s.pkt_nm.is_pipe) { + __odp_errno = ENOTSUP; + return -1; + } + return promisc_mode_set_fd(pktio_entry->s.pkt_nm.sockfd, pktio_entry->s.name, enable); } static int netmap_promisc_mode_get(pktio_entry_t *pktio_entry) { + if (pktio_entry->s.pkt_nm.is_pipe || pktio_entry->s.pkt_nm.is_vale) { + __odp_errno = ENOTSUP; + return -1; + } + return promisc_mode_get_fd(pktio_entry->s.pkt_nm.sockfd, pktio_entry->s.name); }