From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id 7014BA48C for ; Mon, 16 Apr 2018 11:40:22 +0200 (CEST) Received: by mail-wr0-f194.google.com with SMTP id v60so20149131wrc.7 for ; Mon, 16 Apr 2018 02:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=we5eY51S+cv1W1Hl3OuNwx0qExgi+WGk3KBVpdp8yF4=; b=dYPXnTeQUapEkk8YCWb9QoFuYUlagpKJY2KbSQfK3BCi6QpROOOY3jF3ZEfs+vElbf O3Ve/NNm+ZPrrPWRPRFXDHRmm8Vtnd8Q/4yceM+eLfBkz5DIWOFd5kQQlxgxrA3u170j vd9C4uglL/dasQ0+csK1z6S15v7P6ooaJG4Ak0uIE9fgKIWhggtR/EPT3UROlStdbBXZ VTeZieCVTPF9jETx7Rd7mIhOCLbTSJYPJzvlv4NcP87cG2AewWMbCFt4VNpreZKlB+Rn 7DhxG0jEMml3S5ydjpTRUjWKLU09Ej5yjpDswKklBL4kWUxQ+IQoq2EYodD8FQt0ILSQ +y4g== 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=we5eY51S+cv1W1Hl3OuNwx0qExgi+WGk3KBVpdp8yF4=; b=CMUr9ixNXSDL0++9/eDlC/eKAou3j3nW2Im8ju7msFMWbibs4Z8vRIJMqkkAvy39ku niyjpIQkJfUqhs1Uwt15RVhxO1vBf/x4UpS9TvYcK5Fke/zyHHU0EWnC7nBIdrCIFz7m ooQoMIdAzSD9OVk6X2qGrcDlvJj/uW5q8E21fJtNj14ieUI8a20PT5HYnNxt22yNbTrh ljye+SrhOQPdvUoidMU24SObdRBddi//24ssGomzDQwekSIf31TFG4IrOK4BaCzwL099 TFmnCULfRkzQnS06WLBDuCq82B+3JdpSVcaAZfBqvM+TBtKP4qWcmFi4i8Z4+h4OlZ6Y eMJA== X-Gm-Message-State: ALQs6tC0xZ0f/MHqJKwP+APXBGzTzFwR1z1fIIbXSRFDnHc3WliD0wVf L7iipTEhiaxJqd2L+mQ7Ae6oEucZ4ps= X-Google-Smtp-Source: AIpwx49Mh7rj9SBXxU6KbMacn1hPLJnSdDnWssUOuQ31dKXj+wcSW3Ub74pI0P5macwNJJq0gmMK+Q== X-Received: by 10.223.134.125 with SMTP id 58mr9559459wrw.102.1523871621778; Mon, 16 Apr 2018 02:40:21 -0700 (PDT) Received: from 6wind.com ([2a01:cb19:142:1800:7909:64de:56cf:6ead]) by smtp.gmail.com with ESMTPSA id a69sm470613wma.7.2018.04.16.02.40.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Apr 2018 02:40:21 -0700 (PDT) From: David Marchand To: dev@dpdk.org Cc: johndale@cisco.com, hyonkim@cisco.com, ferruh.yigit@intel.com, neescoba@cisco.com Date: Mon, 16 Apr 2018 11:40:17 +0200 Message-Id: <1523871617-15533-1-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20180219124227.19859-1-david.marchand@6wind.com> References: <20180219124227.19859-1-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH v2] net/enic: add primary mac address handler 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: , X-List-Received-Date: Mon, 16 Apr 2018 09:40:22 -0000 Modified enic_del_mac_address() to get a return value from the vnic layer. Reused the .mac_addr_add and .mac_addr_del callbacks code to implement primary mac address handler. Signed-off-by: David Marchand --- Changes since v1: - rebased on dpdk-next-net following mac_addr_set rework, - since enicpmd_remove_mac_addr() does not return an error code, I chose to expose the return value from enic_del_mac_address() so that an error can be detected in the mac_addr_set callback. The log message in enicpmd_remove_mac_addr() has been preserved. --- drivers/net/enic/enic.h | 2 +- drivers/net/enic/enic_ethdev.c | 20 +++++++++++++++++++- drivers/net/enic/enic_main.c | 5 ++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index 751ddc7..5f15e44 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -284,7 +284,7 @@ int enic_dev_stats_get(struct enic *enic, void enic_dev_stats_clear(struct enic *enic); void enic_add_packet_filter(struct enic *enic); int enic_set_mac_address(struct enic *enic, uint8_t *mac_addr); -void enic_del_mac_address(struct enic *enic, int mac_index); +int enic_del_mac_address(struct enic *enic, int mac_index); unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq *wq); void enic_send_pkt(struct enic *enic, struct vnic_wq *wq, struct rte_mbuf *tx_pkt, unsigned short len, diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 801f470..f503398 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -583,7 +583,24 @@ static void enicpmd_remove_mac_addr(struct rte_eth_dev *eth_dev, uint32_t index) return; ENICPMD_FUNC_TRACE(); - enic_del_mac_address(enic, index); + if (enic_del_mac_address(enic, index)) + dev_err(enic, "del mac addr failed\n"); +} + +static int enicpmd_set_mac_addr(struct rte_eth_dev *eth_dev, + struct ether_addr *addr) +{ + struct enic *enic = pmd_priv(eth_dev); + int ret; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -E_RTE_SECONDARY; + + ENICPMD_FUNC_TRACE(); + ret = enic_del_mac_address(enic, 0); + if (ret) + return ret; + return enic_set_mac_address(enic, addr->addr_bytes); } static int enicpmd_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) @@ -799,6 +816,7 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = { .priority_flow_ctrl_set = NULL, .mac_addr_add = enicpmd_add_mac_addr, .mac_addr_remove = enicpmd_remove_mac_addr, + .mac_addr_set = enicpmd_set_mac_addr, .filter_ctrl = enicpmd_dev_filter_ctrl, .reta_query = enicpmd_dev_rss_reta_query, .reta_update = enicpmd_dev_rss_reta_update, diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 98d4775..d9bc7fd 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -162,13 +162,12 @@ int enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats) return 0; } -void enic_del_mac_address(struct enic *enic, int mac_index) +int enic_del_mac_address(struct enic *enic, int mac_index) { struct rte_eth_dev *eth_dev = enic->rte_dev; uint8_t *mac_addr = eth_dev->data->mac_addrs[mac_index].addr_bytes; - if (vnic_dev_del_addr(enic->vdev, mac_addr)) - dev_err(enic, "del mac addr failed\n"); + return vnic_dev_del_addr(enic->vdev, mac_addr); } int enic_set_mac_address(struct enic *enic, uint8_t *mac_addr) -- 2.7.4