From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DF7D0A034F; Fri, 8 Oct 2021 12:58:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1048C411B1; Fri, 8 Oct 2021 12:56:23 +0200 (CEST) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTP id 21A10411E0 for ; Thu, 7 Oct 2021 20:45:14 +0200 (CEST) Received: by mail-pl1-f171.google.com with SMTP id g5so1455236plg.1 for ; Thu, 07 Oct 2021 11:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RhZRuypZixaqRcvo3/mIZDg5UuRWylSZeyVM4m3AZUI=; b=PJ8GkSFaLn4iR+1LXt35DMWGtzLeuy3NEhqAlJc+IM73BBiy6BiyX4id9owHlMQUyV og+0wWnFvsEomdEOphHJYqSBxyImhYyRonadV711zk3gCZpJF9iqmAMLJFiChT+n4Pb8 HBoyFx+y7OrtpoX7xoul9o1L6HHWQYFSipUTY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RhZRuypZixaqRcvo3/mIZDg5UuRWylSZeyVM4m3AZUI=; b=oWLm4K1Bi15cvUIFy44YulOlPAfkp0DnH/ZQ2fqG7KklOlnnRTuttPVjP4uAfjnkNH YWsNx8i+uZai/1Z3injnWBmVNodFei345bBJFUb6UFmu/eupQ+ssrfSmqc6aWV4tZvv3 4TdQ/GBXyCjZoYBEIc1AAiT6xo02Bg6XIy48lnwfiSAlAqOmqjWHJ+UwU0b1E36NmxXm GFR1eJZGNm5WoKxzh/u9XCKywfBu1zqIXaFodyP2IcNoXwRd2bFxdu5kky3BDm9bbq2B JqNztgcAWTiwHaM8o0SlW5OeNhmAwmHuLguXfzyr/zoEsedEFVGZyWngmeafHU/0SDOc A0Zg== X-Gm-Message-State: AOAM533dsW0g1uDwGpJkJd3ygJWB3QhHIgJcIRiC+kOpTljyH7Kwzj1a qEG7JCOmI5F9Qc96ul9ZGz/rSg== X-Google-Smtp-Source: ABdhPJxnZqb+yuQjJd8ZY+VMBwxf63QS24RY898NhXfN0wNWpjGQsndY4ZKGKf8cruga4Y5FsNWNfA== X-Received: by 2002:a17:90a:b382:: with SMTP id e2mr6696978pjr.119.1633632313275; Thu, 07 Oct 2021 11:45:13 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([136.185.113.102]) by smtp.gmail.com with ESMTPSA id c11sm3311586pji.38.2021.10.07.11.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 11:45:12 -0700 (PDT) From: Srikanth Kaka To: Matan Azrad , Viacheslav Ovsiienko Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Fri, 8 Oct 2021 00:13:31 +0530 Message-Id: <20211007184350.73858-23-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211007184350.73858-1-srikanth.k@oneconvergence.com> References: <20211007184350.73858-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 08 Oct 2021 12:55:54 +0200 Subject: [dpdk-dev] [PATCH v2 22/41] net/mlx5: add link state callbacks X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" mlx5_set_link_up() & mlx5_set_link_down() use IOCTL call to set link state Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/net/mlx5/freebsd/mlx5_ethdev_os.c | 56 +++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/net/mlx5/freebsd/mlx5_ethdev_os.c b/drivers/net/mlx5/freebsd/mlx5_ethdev_os.c index 10069302bb..8b2ea1c594 100644 --- a/drivers/net/mlx5/freebsd/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/freebsd/mlx5_ethdev_os.c @@ -138,6 +138,62 @@ mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) return mlx5_ifreq(dev, SIOCSIFMTU, &request); } +/** + * Set device flags. + * + * @param dev + * Pointer to Ethernet device. + * @param keep + * Bitmask for flags that must remain untouched. + * @param flags + * Bitmask for flags to modify. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep, unsigned int flags) +{ + struct ifreq request; + int ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &request); + + if (ret) + return ret; + request.ifr_flags &= keep; + request.ifr_flags |= flags & ~keep; + return mlx5_ifreq(dev, SIOCSIFFLAGS, &request); +} + +/** + * DPDK callback to bring the link DOWN. + * + * @param dev + * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_set_link_down(struct rte_eth_dev *dev) +{ + return mlx5_set_flags(dev, ~IFF_UP, ~IFF_UP); +} + +/** + * DPDK callback to bring the link UP. + * + * @param dev + * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_set_link_up(struct rte_eth_dev *dev) +{ + return mlx5_set_flags(dev, ~IFF_UP, IFF_UP); +} + /** * Get MAC address by querying netdevice. * -- 2.30.2