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 B3A40A034F; Fri, 8 Oct 2021 12:57:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3C2E411A5; Fri, 8 Oct 2021 12:56:20 +0200 (CEST) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id 5C8E6411E0 for ; Thu, 7 Oct 2021 20:45:08 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id n11so4089360plf.4 for ; Thu, 07 Oct 2021 11:45:08 -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=a+wSLUJkpwciG6xJIuov7dlmQcJLztfeSJPrTxa1d6U=; b=EPPIcMPqRJ6QH0y12bU3eh82UcdMmiRW/vLmro/sFz4smdEq/GmEW9tIA6VZBXGFIB YaZqbGxBoCNsEVuumESwh8KAqPXsShbQCD14e0YMyMDtSUr9FjiRWUnF/DSv531D58rm THAVsxtAo3dNZ2Bble+tTApxr+q0ZRDrOXPPw= 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=a+wSLUJkpwciG6xJIuov7dlmQcJLztfeSJPrTxa1d6U=; b=NVbBZvq08mjRgdZs9nL2YEeDh18abcGgQiRi58Ey1rSJSmzbMqPxgfOW+Kilg+ykwx sGSOGSxH0qcozGjPwLCg/GB4Sx+1NHluIGGElJb0pWYzmKKe5OEt5JQNGAtY3qTejmNq xo8p/0h28MOli/bl0D5m+dqV9AXBBS0BFbm8DSHN+Mi7WxDRzHZBFwTk+5ea348pfZD9 PkZRxSJc3BiVGFsPe5hMIvxdmVG/HlUwpx0ORCdyS6N+kmamsULkkQvrWr06Y+uVF73T igfjKnOxlh027M3fqn1rAF5FPbXBonB8YFfzG2z0H4dJN0ZZcIzrK/yDikINeKWNO5si aCmA== X-Gm-Message-State: AOAM5327wY3BMCeCe6oIgRDNBFEaKo7D3f6wr02IR5Zj4/3ZhD1OmbXQ fVfHIBehVMhxQvvW2RQHM8UjRQ== X-Google-Smtp-Source: ABdhPJx1YKbEj73Ms4La0x3yADr+jGC0QUvRPzOwIEXdPOn9bvrzytUA403eEWqiq2EnspFYyyLHXw== X-Received: by 2002:a17:902:7e44:b0:13e:aaf8:e259 with SMTP id a4-20020a1709027e4400b0013eaaf8e259mr5229550pln.14.1633632307620; Thu, 07 Oct 2021 11:45:07 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 11:45:06 -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:29 +0530 Message-Id: <20211007184350.73858-21-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 20/41] net/mlx5: add OS MAC routines 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" The OS MAC routines use INET socket to perform their tasks Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/net/mlx5/freebsd/mlx5_os.c | 105 +++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/drivers/net/mlx5/freebsd/mlx5_os.c b/drivers/net/mlx5/freebsd/mlx5_os.c index 53f74b9d85..71e57e6a68 100644 --- a/drivers/net/mlx5/freebsd/mlx5_os.c +++ b/drivers/net/mlx5/freebsd/mlx5_os.c @@ -27,6 +27,7 @@ #include "mlx5_autoconf.h" #include "mlx5_mr.h" #include "mlx5_verbs.h" +#include "mlx5_inet.h" /** * Get mlx5 device attributes. The glue function query_device_ex() is called @@ -257,3 +258,107 @@ mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb, *reg_mr_cb = mlx5_mr_verbs_ops.reg_mr; *dereg_mr_cb = mlx5_mr_verbs_ops.dereg_mr; } + +/** + * Remove a MAC address from device + * + * @param dev + * Pointer to Ethernet device structure. + * @param index + * MAC address index. + */ +void +mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) +{ + struct mlx5_priv *priv = dev->data->dev_private; + const int vf = priv->config.vf; + + if (vf) + mlx5_inet_mac_addr_remove(dev->data->port_id, index); +} + +/** + * Adds a MAC address to the device + * + * @param dev + * Pointer to Ethernet device structure. + * @param mac_addr + * MAC address to register. + * @param index + * MAC address index. + * + * @return + * 0 on success, a negative errno value otherwise + */ +int +mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, + uint32_t index) +{ + struct mlx5_priv *priv = dev->data->dev_private; + const int vf = priv->config.vf; + int ret = 0; + char ifname[IF_NAMESIZE]; + + mlx5_get_ifname_sysfs(priv->sh->ibdev_path, ifname); + if (vf) + ret = mlx5_inet_mac_addr_set(priv->nl_socket_route, + ifname, mac, index, + dev->data->port_id, + priv->mac_own); + return ret; +} + +/** + * Modify a VF MAC address + * + * @param priv + * Pointer to device private data. + * @param mac_addr + * MAC address to modify into. + * @param iface_idx + * Net device interface index + * @param vf_index + * VF index + * + * @return + * 0 on success, a negative errno value otherwise + */ +int +mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, + unsigned int iface_idx, + struct rte_ether_addr *mac_addr, + int vf_index) +{ + char ifname[IF_NAMESIZE]; + int ret; + + RTE_SET_USED(iface_idx); + ret = mlx5_get_ifname_sysfs(priv->sh->ibdev_path, ifname); + if (!ret) + ret = mlx5_inet_mac_addr_set(priv->nl_socket_route, ifname, + mac_addr, vf_index, + priv->dev_data->port_id, + priv->mac_own); + return ret; +} + +/** + * Flush device MAC addresses + * + * @param dev + * Pointer to Ethernet device structure. + * + */ +void +mlx5_os_mac_addr_flush(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct rte_ether_addr *lladdr = &dev->data->mac_addrs[0]; + char ifname[IF_NAMESIZE]; + + if (mlx5_get_ifname_sysfs(priv->sh->ibdev_path, ifname)) + return; + + mlx5_inet_mac_addr_flush(priv->nl_socket_route, ifname, + lladdr, dev->data->port_id); +} -- 2.30.2