From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8ED0EA058A; Wed, 25 Mar 2020 09:08:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DD08A1E34; Wed, 25 Mar 2020 09:08:56 +0100 (CET) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by dpdk.org (Postfix) with ESMTP id 9D1D0F3E for ; Wed, 25 Mar 2020 09:08:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585123735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lc4OqiimdbypewDWzpianWNEtPQlY/MRk4tDbJz2Yoc=; b=E4R7s8wR6ivcz4iRUdwnh8KMLgQjOQEdMYi/rq+xo32vshQhF+ZL8241+E9dajXA8O3qS1 hEvLYHx5rykjxMnPOd7odMyAzQPDhuvnMEf914as5hadnMDRtaxmUwXeX+wyOAzVMhCvh9 1HO2ViMeG/9EMZ96Tw9HcUjQ6ED7hzw= Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-DxFk58P4O0WkBwykjBhqSw-1; Wed, 25 Mar 2020 04:08:28 -0400 X-MC-Unique: DxFk58P4O0WkBwykjBhqSw-1 Received: by mail-vk1-f199.google.com with SMTP id i26so460597vkk.21 for ; Wed, 25 Mar 2020 01:08:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JNIzUL9PUszKW4lHoXuFF/ufsY6k+dJ3TznD6ab/yV0=; b=H/S7YwH4TqogyYFYUqlSPXHCp6auhzR85f+EEeHKg/FNdAASGOiyROxglTlYlhBeyT NaJhwy4YoB5ik8PH0XD4QGm6Y8nw/6LHEYImKW17iIieAsFGLyzOHvavMC5mPrlqpuRE Wt5D6bMXLvCMuGLAgbIqzHfozeqZ8PDoy9khyzKSOad2jgB7jr51OVT84x5zlxOdeIhq ebG92P4HxEf5hHrF4URvRvaFCRj+0frXtju0zNNVJ0CHHKDaoHj8dcr/2f5K5iS9gBAm V99KCCsAmfoYzG6BdWsagVr4SdfORhZ6m/ccXU+vUTymO64ICXf5OC+47rIrKFVs+fg9 BQzw== X-Gm-Message-State: ANhLgQ1M3s90z5LBpMr9+uj4awJC0SBQ9J2Z+X0TWyXEuAlxWuvyXm9d ljqCjm3w2LIRC8k4O5zHho3xCSsriwL7E5o0SPCm/HooR+2n2dpPeaLw21oqkk94pBvZXpIR8vF EtGmfG0zdE3J3GQd6lGg= X-Received: by 2002:a67:26c2:: with SMTP id m185mr1578817vsm.180.1585123707514; Wed, 25 Mar 2020 01:08:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvy0qrYCrEzW72CDI3l2J2NmDZVYAprB7ANk2gVCYMUUmqwGZCrZIzkXuCZhtT/p7PyawdEsWM3hDoKBzXjJmk= X-Received: by 2002:a67:26c2:: with SMTP id m185mr1578784vsm.180.1585123706890; Wed, 25 Mar 2020 01:08:26 -0700 (PDT) MIME-Version: 1.0 References: <20200306164104.15528-1-aostruszka@marvell.com> <20200310111037.31451-1-aostruszka@marvell.com> In-Reply-To: <20200310111037.31451-1-aostruszka@marvell.com> From: David Marchand Date: Wed, 25 Mar 2020 09:08:16 +0100 Message-ID: To: Andrzej Ostruszka Cc: dev X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH v2 0/4] Introduce IF proxy library 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" Hello Andrzej, On Tue, Mar 10, 2020 at 12:11 PM Andrzej Ostruszka wrote: > > What is this useful for > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > Usually, when an ethernet port is assigned to DPDK it vanishes from the > system and user looses ability to control it via normal configuration > utilities (e.g. those from iproute2 package). Moreover by default DPDK > application is not aware of the network configuration of the system. > > To address both of these issues application needs to: > - add some command line interface (or other mechanism) allowing for > control of the port and its configuration > - query the status of network configuration and monitor its changes > > The purpose of this library is to help with both of these tasks (as long > as they remain in domain of configuration available to the system). In > other words, if DPDK application has some special needs, that cannot be > addressed by the normal system configuration utilities, then they need > to be solved by the application itself. > > The connection between DPDK and system is based on the existence of > ports that are visible to both DPDK and system (like Tap, KNI and > possibly some other drivers). These ports serve as an interface > proxies. > > Let's visualize the action of the library by the following example: > > Linux | DPDK > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > | > | +-------+ +-------+ > | | Port1 | | Port2 | > "ip link set dev tap1 mtu 1600" | +-------+ +-------+ > | | ^ ^ ^ > | +------+ | mtu_change | | > `->| Tap1 |---' callback | | > +------+ | | > "ip addr add 198.51.100.14 \ | | | > dev tap2" | | | > | +------+ | | > +->| Tap2 |------------------' | > | +------+ addr_add callback | > "ip route add 198.0.2.0/24 \ | | | > dev tap2" | | route_add callback | > | `---------------------' > > So we have two ports Port1 and Port2 that are not visible to the system. > We create two proxy interfaces (here based on Tap driver) and bind the > ports to their proxies. When user issues a command changing MTU for > Tap1 interface the library notes this and calls "mtu_change" callback > for the Port1. Similarly when user adds an IPv4 address to the Tap2 > interface "addr_add" callback is called for the Port2 and the same > happens for configuration of routing rule pointing to Tap2. Apart from > callbacks this library can notify about changes via adding events to > notification queues. See below for more inforamtion about that and > a complete list of available callbacks. > > Please note that nothing has been mentioned about forwarding of the > packets between system and DPDK. Since the proxies are normal DPDK > ports you can receive/send to them via usual RX/TX burst API. However > since the library is not aware of the structure of packet processing > used by the application it cannot automatically forward the packets - it > is responsibility of the application to include proxy ports into its > packet processing engine. > > As mentioned above the intention of the library is to: > - provide information about network configuration that would allow > application to decide what to do with the packets received on DPDK > ports, > - allow for control of the ports via standard configuration utilities > > Although the library only helps you to identify proxy for given port > (and vice versa) and calls appropriate callbacks it does open some > interesting possibilities. For example you can use the proxy ports to > forward packets for protocols that you do not wish to handle in DPDK > application to the system protocol stack and just listen to the > configuration changes - so that way you can "offload" handling of those > protocols to the system. > > How to use it > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > Usage of this library is rather simple. You have to: > 1. Create proxy (if you don't have port suitable for being proxy or you > have one but do not wish to use it as a proxy). > 2. Bind port to proxy. > 3. Register callbacks and/or event queues. > 4. Start listening to the network configuration. > > The only mandatory requirement for DPDK port to be able to act as > a proxy is that it is visible in the system - this is checked during > port to proxy binding by calling rte_eth_dev_info_get() on proxy port > and inspecting 'if_index' field (it has to be non-zero). > One can create such port in the application by calling: > > proxy_id =3D rte_ifpx_create(RTE_IFPX_DEFAULT); > > Upon success this returns id of DPDK proxy port created > (RTE_MAX_ETHPORTS on failure). The argument selects type of proxy port > to create (currently Tap/KNI only). This function actually is just > a wrapper around: > > uint16_t rte_ifpx_create_by_devarg(const char *devarg); > > creating valid 'devarg' string for the chosen type of proxy. If you have > other driver capable of acting as a proxy you can call > rte_ifpx_create_by_devarg() directly passing appropriate argument. > > Once you have id of both port and proxy you can bind the two via: > > rte_ifpx_port_bind(port_id, proxy_id); > > This creates logical binding - as mentioned above there is no automatic > packet forwarding. With this binding whenever user changes the state of > proxy interface in the system (link up/down, change mac/mtu, add/remove > IPv4/IPv6) you get appropriate notification for the bound port. > > So far we've mentioned several times that the library calls callbacks. > They are grouped in 'struct rte_ifpx_callbacks' and user provides them > to the library via: > > rte_ifpx_callbacks_register(&cbs); > > It is worth mentioning that the context (lcore/thread) in which these > callbacks are called is implementation defined. It might differ between > different platforms, so the application needs to assume that some kind > of inter lcore/thread synchronization/communication is required. > > Apart from notification via callbacks this library also supports > notifying about the changes via adding events to the configured > notification queues. The queues are registered via: > > int rte_ifpx_queue_add(struct rte_ring *r); > > and the actual logic used is: if there is callback registered then it is > called, if it returns non-zero then event is considered completed, > otherwise event is added to each configured notification queue. > That way application can update data structures that are safe to be > modified by single writer from within callback or do the common > preprocessing steps (if any needed) in callback and data that is > replicated can be updated during handling of queued events. > > Once we have bindings in place and notification configured, the only > essential part that remains is to get the current network configuration > and start listening to its changes. This is accomplished via a call to: > > rte_ifpx_listen(); > > And basically this is all one needs to understand how to use this > library. Other less essential parts include: > - ability to query what events are available for given platform > - getting mapping between proxy and port > - unbinding the ports from proxy > - destroying proxy port > - closing the listening service > - getting basic information about proxy > > > Currently available features and implementation > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > The library's API is system independent but it obviously needs some > system dependent parts. We provide exemplary Linux implementation (based > on netlink sockets). Very similar implementation is possible for > FreeBSD (with the usage of PF_ROUTE sockets). Windows implementation > would need to differ much (probably IP Helper library would be of some he= lp). > > Here is the list of currently implemented callbacks: > > struct rte_ifpx_callbacks { > int (*mac_change)(const struct rte_ifpx_mac_change *event); > int (*mtu_change)(const struct rte_ifpx_mtu_change *event); > int (*link_change)(const struct rte_ifpx_link_change *event); > int (*addr_add)(const struct rte_ifpx_addr_change *event); > int (*addr_del)(const struct rte_ifpx_addr_change *event); > int (*addr6_add)(const struct rte_ifpx_addr6_change *event); > int (*addr6_del)(const struct rte_ifpx_addr6_change *event); > int (*route_add)(const struct rte_ifpx_route_change *event); > int (*route_del)(const struct rte_ifpx_route_change *event); > int (*route6_add)(const struct rte_ifpx_route6_change *event); > int (*route6_del)(const struct rte_ifpx_route6_change *event); > int (*neigh_add)(const struct rte_ifpx_neigh_change *event); > int (*neigh_del)(const struct rte_ifpx_neigh_change *event); > int (*neigh6_add)(const struct rte_ifpx_neigh6_change *event); > int (*neigh6_del)(const struct rte_ifpx_neigh6_change *event); > int (*cfg_done)(void); > }; > > They are all rather self-descriptive with the exception of the last one. > When the user calls rte_ifpx_listen() the library first queries the > system for its current configuration. That might require several > request/reply exchanges between DPDK and system and once it is finished > this callback is called to let application know that all info has been > gathered. > > It is worth to mention also that while typical case would be a 1-to-1 > mapping between port and proxy, the 1-to-many mapping is also supported. > In that case related callbacks will be called for each port bound to > given proxy interface - it is application responsibility to define > semantic of such mapping (e.g. all changes apply to all ports, or link > changes apply to all but other are accepted in "round robin" fashion, or > some other logic). > > As mentioned above Linux implementation is based on netlink socket. > This socket is registered as file descriptor in EAL interrupts > (similarly to how EAL alarms are implemented). > > What has changed since the RFC > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D > > - Platform dependent parts has been separated into a ifpx_platform > structure with callbacks for initialization, getting information about > the interface, listening to the changes and closing of the library. > That should allow easier reimplementation. > > - Notification scheme has been changed - instead of having just > callbacks now event queueing is also available (or a mix of those > two). > > - Filtering of events only related to the proxy ports - previously all > network configuration changes were reported. But DPDK application > doesn't need to know whole configuration - only just portion related > to the proxy ports. If a packet comes that does not match rules then > it can be forwarded via proxy to the system to decide what to do with > it. If that is not desired and such packets should be dropped then > null port can be created with proxy and e.g. default route installed > on it. > > - Removed previous example which was just printing notification. > Instead added a simplified (stripped vectorization and other > performance improvements) version of l3fwd that should serve as an > example of using this library in real applications. > > Changes in V2 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > - Cleaned up checkpatch warnings > - Removed dead/unused code and added gateway clearing in l3fwd-ifpx I can see we end up exposing structures for registering callbacks. Did you consider some ways to avoid exposure of those? (thinking of ABI maintenance for when this library will elect to non-experimental). I can see some canary at the end of an enum, can we do without it? Is there a pb with merging ifpx support into the existing l3fwd application rather than introduce a new example? --=20 David Marchand