From patchwork Wed Sep 16 15:17:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaetan Rivet X-Patchwork-Id: 1365404 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=u256.net Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bs3d413L0z9sTQ for ; Thu, 17 Sep 2020 01:17:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6C3CD873C8; Wed, 16 Sep 2020 15:17:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 68rRYYzxR9lL; Wed, 16 Sep 2020 15:17:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 2DB34873BF; Wed, 16 Sep 2020 15:17:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CC5BEC0891; Wed, 16 Sep 2020 15:17:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id AD4F6C0051 for ; Wed, 16 Sep 2020 15:17:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 9B868203BB for ; Wed, 16 Sep 2020 15:17:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gt-qi0klgFV7 for ; Wed, 16 Sep 2020 15:17:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by silver.osuosl.org (Postfix) with ESMTPS id 4960422DEC for ; Wed, 16 Sep 2020 15:17:50 +0000 (UTC) X-Originating-IP: 86.254.165.59 Received: from inocybe.home (lfbn-poi-1-843-59.w86-254.abo.wanadoo.fr [86.254.165.59]) (Authenticated sender: grive@u256.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id E1436240003; Wed, 16 Sep 2020 15:17:46 +0000 (UTC) From: Gaetan Rivet To: dev@openvswitch.org Date: Wed, 16 Sep 2020 17:17:33 +0200 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Cc: Ilya Maximets Subject: [ovs-dev] [PATCH v3 1/2] netdev-dpdk: Add ability to set MAC address. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Ilya Maximets It is possible to set the MAC address of DPDK ports by calling rte_eth_dev_default_mac_addr_set(). OvS does not actually call this function for non-internal ports, but the implementation is exposed to be used in a later commit. Signed-off-by: Ilya Maximets Signed-off-by: Gaetan Rivet --- lib/netdev-dpdk.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 18c4adcc7..4ef7f78a6 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -2909,19 +2909,45 @@ netdev_dpdk_eth_send(struct netdev *netdev, int qid, return 0; } +static int +netdev_dpdk_set_etheraddr__(struct netdev_dpdk *dev, const struct eth_addr mac) + OVS_REQUIRES(dev->mutex) +{ + int err = 0; + + if (dev->type == DPDK_DEV_ETH) { + struct rte_ether_addr ea; + + memcpy(ea.addr_bytes, mac.ea, ETH_ADDR_LEN); + err = -rte_eth_dev_default_mac_addr_set(dev->port_id, &ea); + } + if (!err) { + dev->hwaddr = mac; + } else { + VLOG_WARN("%s: Failed to set requested mac("ETH_ADDR_FMT"): %s", + netdev_get_name(&dev->up), ETH_ADDR_ARGS(mac), + rte_strerror(err)); + } + + return err; +} + static int netdev_dpdk_set_etheraddr(struct netdev *netdev, const struct eth_addr mac) { struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); + int err = 0; ovs_mutex_lock(&dev->mutex); if (!eth_addr_equals(dev->hwaddr, mac)) { - dev->hwaddr = mac; - netdev_change_seq_changed(netdev); + err = netdev_dpdk_set_etheraddr__(dev, mac); + if (!err) { + netdev_change_seq_changed(netdev); + } } ovs_mutex_unlock(&dev->mutex); - return 0; + return err; } static int From patchwork Wed Sep 16 15:17:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaetan Rivet X-Patchwork-Id: 1365405 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=u256.net Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bs3dd4LcPz9sSW for ; Thu, 17 Sep 2020 01:18:29 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3F77D20485; Wed, 16 Sep 2020 15:18:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 45B+hWgkzv69; Wed, 16 Sep 2020 15:18:05 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id D49F727E4C; Wed, 16 Sep 2020 15:17:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BB339C0864; Wed, 16 Sep 2020 15:17:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id B7FE5C0051 for ; Wed, 16 Sep 2020 15:17:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A77CC86A08 for ; Wed, 16 Sep 2020 15:17:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6rempgxR5WkU for ; Wed, 16 Sep 2020 15:17:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 8A54286930 for ; Wed, 16 Sep 2020 15:17:51 +0000 (UTC) X-Originating-IP: 86.254.165.59 Received: from inocybe.home (lfbn-poi-1-843-59.w86-254.abo.wanadoo.fr [86.254.165.59]) (Authenticated sender: grive@u256.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 6CFB424000B; Wed, 16 Sep 2020 15:17:47 +0000 (UTC) From: Gaetan Rivet To: dev@openvswitch.org Date: Wed, 16 Sep 2020 17:17:34 +0200 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Cc: Eli Britstein , Ilya Maximets Subject: [ovs-dev] [PATCH v3 2/2] netdev-dpdk: Add option to configure VF MAC address. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" In some cloud topologies, using DPDK VF representors in guest requires configuring a VF before it is assigned to the guest. A first basic option for such configuration is setting the VF MAC address. Add a key 'dpdk-vf-mac' to the 'options' column of the Interface table. This option can be used as such: $ ovs-vsctl add-port br0 dpdk-rep0 -- set Interface dpdk-rep0 type=dpdk \ options:dpdk-vf-mac=00:11:22:33:44:55 Signed-off-by: Gaetan Rivet Suggested-by: Ilya Maximets Acked-by: Eli Britstein --- Documentation/topics/dpdk/phy.rst | 22 ++++++++++++ NEWS | 2 ++ lib/netdev-dpdk.c | 60 +++++++++++++++++++++++++++++++ vswitchd/vswitch.xml | 13 +++++++ 4 files changed, 97 insertions(+) diff --git a/Documentation/topics/dpdk/phy.rst b/Documentation/topics/dpdk/phy.rst index 38e52c8de..73dcb7c28 100644 --- a/Documentation/topics/dpdk/phy.rst +++ b/Documentation/topics/dpdk/phy.rst @@ -379,6 +379,28 @@ an eth device whose mac address is ``00:11:22:33:44:55``:: $ ovs-vsctl add-port br0 dpdk-mac -- set Interface dpdk-mac type=dpdk \ options:dpdk-devargs="class=eth,mac=00:11:22:33:44:55" +Representor specific configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In some topologies, a VF must be configured before being assigned to a +guest (VM) machine. This configuration is done through VF-specific fields +in the ``options`` column of the Interface table. + +.. important:: + + Some DPDK port use `bifurcated drivers `__, + which means that a kernel netdevice remains when Open vSwitch is stopped. + + In such case, any configuration applied to a VF would remain set on the + kernel netdevice, and be inherited from it when Open vSwitch is restarted, + even if the options described in this section are unset from Open vSwitch. + +.. _bifurcated-drivers: http://doc.dpdk.org/guides/linux_gsg/linux_drivers.html#bifurcated-driver + +- Configure the VF MAC address:: + + $ ovs-vsctl set Interface dpdk-rep0 options:dpdk-vf-mac=00:11:22:33:44:55 + Jumbo Frames ------------ diff --git a/NEWS b/NEWS index 2f67d5047..5ece29474 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,8 @@ v2.14.0 - 17 Aug 2020 to list and change log levels in DPDK components. * Vhost-user Dequeue zero-copy support is deprecated and will be removed in the next release. + * New 'options:dpdk-vf-mac' field for DPDK interface of VF ports, + that allows configuring the MAC address of a VF representor. - Linux datapath: * Support for kernel versions up to 5.5.x. - AF_XDP: diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 4ef7f78a6..060348369 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -523,6 +523,9 @@ struct netdev_dpdk { * otherwise interrupt mode is used. */ bool requested_lsc_interrupt_mode; bool lsc_interrupt_mode; + + /* VF configuration. */ + struct eth_addr requested_hwaddr; ); PADDED_MEMBERS(CACHE_LINE_SIZE, @@ -1685,6 +1688,16 @@ out: return ret; } +static bool +dpdk_port_is_representor(struct netdev_dpdk *dev) + OVS_REQUIRES(dev->mutex) +{ + struct rte_eth_dev_info dev_info; + + rte_eth_dev_info_get(dev->port_id, &dev_info); + return (*dev_info.dev_flags) & RTE_ETH_DEV_REPRESENTOR; +} + static int netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args) { @@ -1719,6 +1732,13 @@ netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args) } smap_add(args, "lsc_interrupt_mode", dev->lsc_interrupt_mode ? "true" : "false"); + + if (dpdk_port_is_representor(dev)) { + smap_add_format(args, "requested_hwaddr", ETH_ADDR_FMT, + ETH_ADDR_ARGS(dev->requested_hwaddr)); + smap_add_format(args, "configured_hwaddr", ETH_ADDR_FMT, + ETH_ADDR_ARGS(dev->hwaddr)); + } } ovs_mutex_unlock(&dev->mutex); @@ -1898,6 +1918,7 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args, {RTE_FC_RX_PAUSE, RTE_FC_FULL } }; const char *new_devargs; + const char *vf_mac; int err = 0; ovs_mutex_lock(&dpdk_mutex); @@ -1968,6 +1989,36 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args, goto out; } + vf_mac = smap_get(args, "dpdk-vf-mac"); + if (vf_mac) { + struct eth_addr mac; + + err = EINVAL; + + if (!dpdk_port_is_representor(dev)) { + VLOG_ERR_BUF(errp, "'%s' is trying to set the VF MAC '%s' " + "but 'options:dpdk-vf-mac' is only supported for " + "VF representors.", + netdev_get_name(netdev), vf_mac); + goto out; + } + if (!eth_addr_from_string(vf_mac, &mac)) { + VLOG_ERR_BUF(errp, "interface '%s': cannot parse VF MAC '%s'", + netdev_get_name(netdev), vf_mac); + goto out; + } + if (eth_addr_is_multicast(mac)) { + VLOG_ERR_BUF(errp, + "interface '%s': cannot set VF MAC to multicast " + "address", netdev_get_name(netdev)); + goto out; + } + if (!eth_addr_equals(dev->requested_hwaddr, mac)) { + dev->requested_hwaddr = mac; + netdev_request_reconfigure(netdev); + } + } + lsc_interrupt_mode = smap_get_bool(args, "dpdk-lsc-interrupt", false); if (dev->requested_lsc_interrupt_mode != lsc_interrupt_mode) { dev->requested_lsc_interrupt_mode = lsc_interrupt_mode; @@ -4938,6 +4989,7 @@ netdev_dpdk_reconfigure(struct netdev *netdev) && dev->lsc_interrupt_mode == dev->requested_lsc_interrupt_mode && dev->rxq_size == dev->requested_rxq_size && dev->txq_size == dev->requested_txq_size + && eth_addr_equals(dev->hwaddr, dev->requested_hwaddr) && dev->socket_id == dev->requested_socket_id && dev->started && !dev->reset_needed) { /* Reconfiguration is unnecessary */ @@ -4969,6 +5021,14 @@ netdev_dpdk_reconfigure(struct netdev *netdev) dev->txq_size = dev->requested_txq_size; rte_free(dev->tx_q); + + if (!eth_addr_equals(dev->hwaddr, dev->requested_hwaddr)) { + err = netdev_dpdk_set_etheraddr__(dev, dev->requested_hwaddr); + if (err) { + goto out; + } + } + err = dpdk_eth_dev_init(dev); if (dev->hw_ol_features & NETDEV_TX_TSO_OFFLOAD) { netdev->ol_flags |= NETDEV_TX_OFFLOAD_TCP_TSO; diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 81c84927f..c0bf03c95 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -3280,6 +3280,19 @@ ovs-vsctl add-port br0 p0 -- set Interface p0 type=patch options:peer=p1 \ descriptors will be used by default.

+ + +

+ Ethernet address to set for this VF interface. If unset then the + default MAC address is used: +

+
    +
  • For most drivers, the default MAC address assigned by + their hardware.
  • For bifurcated drivers, the MAC currently + used by the kernel netdevice.
  • +
+

This option may only be used with dpdk VF representors.

+