From patchwork Wed Oct 28 19:29:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 55714 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp137502lbr; Wed, 28 Oct 2015 12:32:17 -0700 (PDT) X-Received: by 10.141.28.136 with SMTP id f130mr62661410qhe.66.1446060737037; Wed, 28 Oct 2015 12:32:17 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v107si43538876qgd.76.2015.10.28.12.32.16; Wed, 28 Oct 2015 12:32:16 -0700 (PDT) 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.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 9671461FE1; Wed, 28 Oct 2015 19:32:16 +0000 (UTC) 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 A2BEC61FFA; Wed, 28 Oct 2015 19:30:01 +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 0D1B461FFD; Wed, 28 Oct 2015 19:29:56 +0000 (UTC) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by lists.linaro.org (Postfix) with ESMTPS id 2B35C61FC7 for ; Wed, 28 Oct 2015 19:29:26 +0000 (UTC) Received: by wicfv8 with SMTP id fv8so24956656wic.0 for ; Wed, 28 Oct 2015 12:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=cVz8lqH78igFi/OCi9uLD10LjDa5YHrEEHOKJG4hxr0=; b=YS4j1gkdzMeQRTsHe87tDLWfS5J1wwiQSEeYIUWc4Otr75x9GO28PIFhUldI/NoPuJ 5JR1fyywm7IyTW+369qqfoyZGFCkLfCZbS8FunGgU/pBPk3/ZYkN7wTqcXuPSC0m7HUe TlQWVx4rMTt1tiC3ysl43SaIG8XK9nuAsdZiFAlUP80eiUxXP7Vrz0t1241CG/u8mR4g yUB43GRTfj+rMFgFX9uvDPNM8aIeIPDrLR78Jdos/kJdTDWEBtle1gRCZmWd8M+1cMeg YBPgV17m9HzX40GgJKOukV0QKQuFgSe+1KnVOo1jeIxvv66cycGODrNlf4Rryks8Fx4v 9TlA== 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=cVz8lqH78igFi/OCi9uLD10LjDa5YHrEEHOKJG4hxr0=; b=RoPGUTWTjy/xS1zwxrJIjlgNuRopB8st+Dl6JxSGcgsR8Uv6FKGONGeTYcBg7uFNBM zHgk/iJVGlBeADic3g5VjMKG245zxmR1PwDtTffIGKykf2GPFs7LpVUh/6x4Aa8JCJyI MxlamfFxx69tXXT5oroRfVJA9V3VjMDgPTRzsXbEw/S3SYViVorchNayVQBiI3+XlEWe mwWQbhDE5Ad1DXxj43nw/gIY9pOIebUftzz2a/T269AAsB9aYNQmr919RZJDETryoDth owUi3qTnzBZiy+kbd23tGIRItcNq65By7vGJDheAX5rDGtw1xAn49Rg2H36rLes7YGIP lGNQ== X-Gm-Message-State: ALoCoQmGaOzcRqHXfAjB+jdQyjdkBmSDlcQqWfkL2CG4feFKx7/Hv8MzqhXpHIWmlvw0eqyrnoZr X-Received: by 10.180.182.8 with SMTP id ea8mr4494773wic.35.1446060565363; Wed, 28 Oct 2015 12:29:25 -0700 (PDT) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id h4sm31286154wjx.41.2015.10.28.12.29.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Oct 2015 12:29:24 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Wed, 28 Oct 2015 19:29:06 +0000 Message-Id: <1446060551-21029-5-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1446060551-21029-1-git-send-email-stuart.haslam@linaro.org> References: <1446060551-21029-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 4/9] 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 5378586..7d47fc1 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -133,7 +133,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 { @@ -156,11 +159,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"); @@ -294,24 +305,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); }