From patchwork Thu Jun 21 13:36:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 932744 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="c2trnzY7"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BN8B4P9Yz9s19 for ; Thu, 21 Jun 2018 23:38:50 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4A007D25; Thu, 21 Jun 2018 13:36:18 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 8E899D01 for ; Thu, 21 Jun 2018 13:36:16 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0119D1A0 for ; Thu, 21 Jun 2018 13:36:15 +0000 (UTC) Received: by mail-wr0-f181.google.com with SMTP id e18-v6so3242103wrs.5 for ; Thu, 21 Jun 2018 06:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F+flqhbn6pkMob4D5V2eH9F8Q90vLKU38ufLhP/54QM=; b=c2trnzY7wRM3c8Q8QiNpyWGors0SHX4VHjQvIVVkQv8fFNip9AMzoBkQ8ZFOrAbnbU OspIVuzhGFaYtvIhAYY6Gv7PqEzShW2dPNV61rB1e5qEMrEan8f/buB8lM1WSWCO4R2j /1vH45t4QXnPSU4PesQwiwFubb7C12tty6PEszpkhCgT+8L8uEOEstZrhD8aHYNuvbnS eDlD9ZNA6Rhjx2n9v50kPDf8FQmSDfSAA5t2cQzUlcjraW8dcRJ0fVv+c8eedggLgTbZ 9wEJRH1AX3dkykfOKVvTjgeV6JlzK1NuJIwYs0V75xDHMRls7O9baqeBAvk39G1DdCtH OvCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F+flqhbn6pkMob4D5V2eH9F8Q90vLKU38ufLhP/54QM=; b=esxY17R96HEF9bQNs1KMa1i7hRSALarA9agH9JyisvW5/FUYnPBXoeMFBJbL0D7jmr +rJnvZCOf/iWrTxzl48/RfwcDE7PMmODmK56Y29qvm5hSX9YbzSWpaHBAztnfTHMgZVA WxvyV1MjbT0UI2g1XfhtHGU+E6LicGG24w7JvvzTVPcXlS6Q5CXW1fD6bpmo2az/Pfd3 LXN9J3N8iuWtFjI9wRWtVEfZK+olAupgOeuIAGHOQj8q8/HWdaO7vWicFDRa5vtbyGpp 2/SC7F6sl4wSTAGvqxoQMcH095Oh4kFBLdmZisDFJpM4iJZR/8zAsii4p6q0c117YINQ Caww== X-Gm-Message-State: APt69E2U0aH1EZU1HKIie5DCgZJRXcnLgLQcOMTJKuUPafzCKVEpC45E zQwxgInHZ3voMPXjSKqBjmqsB6WV X-Google-Smtp-Source: ADUXVKI+wMbZ3Ap4YUV85T0m/8Qgoa4MECkRQy2hSR/xoU6ehlPEg+VZJWeFedRz8+gH4bj77pFFwg== X-Received: by 2002:adf:e48e:: with SMTP id i14-v6mr23479210wrm.8.1529588174440; Thu, 21 Jun 2018 06:36:14 -0700 (PDT) Received: from jhurley-Precision-Tower-3420.netronome.com ([80.76.204.157]) by smtp.gmail.com with ESMTPSA id e63-v6sm8406382wma.46.2018.06.21.06.36.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jun 2018 06:36:13 -0700 (PDT) From: John Hurley To: dev@openvswitch.org, roid@mellanox.com, gavi@mellanox.com, paulb@mellanox.com, fbl@sysclose.org, simon.horman@netronome.com Date: Thu, 21 Jun 2018 14:36:00 +0100 Message-Id: <1529588161-15934-6-git-send-email-john.hurley@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529588161-15934-1-git-send-email-john.hurley@netronome.com> References: <1529588161-15934-1-git-send-email-john.hurley@netronome.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 5/6] netdev-linux: assign LAG devs to tc blocks X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Assign block ids to LAG masters that are added to OvS as linux-netdevs and offloaded via offload API calls. Only LAG masters are assigned to blocks. To ensure uniqueness, the block ids are determined by the netdev ifindex. Implement a get_block_id op for linux netdevs to achieve this. Signed-off-by: John Hurley Reviewed-by: Dirk van der Merwe Reviewed-by: Simon Horman --- lib/netdev-linux.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 6ed2f05..81de3b1 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2945,6 +2945,27 @@ netdev_internal_get_status(const struct netdev *netdev OVS_UNUSED, return 0; } +static uint32_t +netdev_linux_get_block_id(struct netdev *netdev_) +{ + struct netdev_linux *netdev = netdev_linux_cast(netdev_); + uint32_t block_id = 0; + + ovs_mutex_lock(&netdev->mutex); + /* Ensure the linux netdev has had its fields populated. */ + if (!(netdev->cache_valid & VALID_IFINDEX)) { + netdev_linux_update_via_netlink(netdev); + } + + /* Only assigning block ids to linux netdevs that are LAG masters. */ + if (netdev->is_lag_master) { + block_id = netdev->ifindex; + } + ovs_mutex_unlock(&netdev->mutex); + + return block_id; +} + /* Looks up the ARP table entry for 'ip' on 'netdev'. If one exists and can be * successfully retrieved, it stores the corresponding MAC address in 'mac' and * returns 0. Otherwise, it returns a positive errno value; in particular, @@ -3060,7 +3081,7 @@ exit: #define NETDEV_LINUX_CLASS(NAME, CONSTRUCT, GET_STATS, \ GET_FEATURES, GET_STATUS, \ - FLOW_OFFLOAD_API) \ + FLOW_OFFLOAD_API, GET_BLOCK_ID) \ { \ NAME, \ false, /* is_pmd */ \ @@ -3133,7 +3154,7 @@ exit: netdev_linux_rxq_drain, \ \ FLOW_OFFLOAD_API, \ - NULL /* get_block_id */ \ + GET_BLOCK_ID \ } const struct netdev_class netdev_linux_class = @@ -3143,7 +3164,8 @@ const struct netdev_class netdev_linux_class = netdev_linux_get_stats, netdev_linux_get_features, netdev_linux_get_status, - LINUX_FLOW_OFFLOAD_API); + LINUX_FLOW_OFFLOAD_API, + netdev_linux_get_block_id); const struct netdev_class netdev_tap_class = NETDEV_LINUX_CLASS( @@ -3152,7 +3174,8 @@ const struct netdev_class netdev_tap_class = netdev_tap_get_stats, netdev_linux_get_features, netdev_linux_get_status, - NO_OFFLOAD_API); + NO_OFFLOAD_API, + NULL); const struct netdev_class netdev_internal_class = NETDEV_LINUX_CLASS( @@ -3161,7 +3184,8 @@ const struct netdev_class netdev_internal_class = netdev_internal_get_stats, NULL, /* get_features */ netdev_internal_get_status, - NO_OFFLOAD_API); + NO_OFFLOAD_API, + NULL); #define CODEL_N_QUEUES 0x0000