From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) by dpdk.org (Postfix) with ESMTP id 9FD111B22F for ; Mon, 9 Oct 2017 17:01:16 +0200 (CEST) Received: by mail-lf0-f44.google.com with SMTP id k40so8169073lfi.4 for ; Mon, 09 Oct 2017 08:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=M4YSvSdfNwy6Dg3qidsl4/1Rv5l5IwZ/GKJSl1UfveE=; b=xfntuHECmkncJUq4l3nDHaXtANfMTJXimvs66Iczgue0mdUqkglIXT6gQs/vI9MDdO MU5DcWNccmVth2jXhS1KnAOETxeoZeHLlvuPjSLVyzkpE/5rRsuHOpUC2y2HAZm6clVE 29iwRPyWFxbiXMO4gbjYX/XI9aHNpd1JEYlyD+mOplAaNOINaFmq4MRjeOBpTsmKndSd GRg8aC1wfJVYwXnifvWCeQmfvIiS25ESNG1QljrYaFXURWcMP/w+KDwrXwyVenWF1QgX vPZVdQ4+CtVY6RCzZizigzpEWJJaCSX11taamzMbHWVoYjEnuCEUHWFQUvzxRMwi4G3x gghA== 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=M4YSvSdfNwy6Dg3qidsl4/1Rv5l5IwZ/GKJSl1UfveE=; b=tp3bDFYjQdTxqUqQJMlXUXO6Xx04x3DdQYJIC5MHKZMwwbPa3iRlr1zVAxKGHWqPji DUIqUNSf9d6TqJzeOHMoAtoptWgtshOC2gCs4IPNBL/xsv8DOa+uMpdBPj1ZuTsynFnW XhMBJKTtT1y7Na8hcfeSDZPvupmsc7jieW7hHh7nbX3qCCdweQpBxw7mGEF2MIcCosvW wN4DF0UWNo8yvvBRR4VdenmcXd0P0fHuoWIEQNM+N9XzjCSHC9ZklT8c6AOgAQ843aVb /OUhz66V5UJuGmz+hpczT8H5YzkLPqsj8LyzF1fjaKNJnCYqN0gd9BBUlUXJMsyw4Onu p9Qg== X-Gm-Message-State: AMCzsaW2FWn4a2CtZiLM3T/oZtl4WAZmUsKEJHgEKYN6r4pzgWsT4DD2 VsrcuK0BiDAaTL+IqHGQlmN6O5MljvM= X-Google-Smtp-Source: AOwi7QCWREVo4IYLSYudFbJhcQcRfJOmRGWuAC4kMvgFpH0f9ixRD1qRQpQEwTnsPgJzhJbPk+vF4A== X-Received: by 10.46.85.145 with SMTP id g17mr4525781lje.84.1507561275825; Mon, 09 Oct 2017 08:01:15 -0700 (PDT) Received: from tdu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id z64sm1352637lfa.91.2017.10.09.08.01.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Oct 2017 08:01:15 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: mw@semihalf.com, dima@marvell.com, nsamsono@marvell.com, Jianbo.liu@linaro.org, Tomasz Duszynski , Jacek Siuda Date: Mon, 9 Oct 2017 17:00:37 +0200 Message-Id: <1507561244-20115-10-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507561244-20115-1-git-send-email-tdu@semihalf.com> References: <1507031500-11473-1-git-send-email-tdu@semihalf.com> <1507561244-20115-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v4 09/16] net/mrvl: add support for mac filtering 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, 09 Oct 2017 15:01:17 -0000 Add support for unicast and multicast mac filters. Signed-off-by: Jacek Siuda Signed-off-by: Tomasz Duszynski --- doc/guides/nics/features/mrvl.ini | 2 + drivers/net/mrvl/mrvl_ethdev.c | 95 ++++++++++++++++++++++++++++++++++++++- drivers/net/mrvl/mrvl_ethdev.h | 1 + 3 files changed, 97 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/mrvl.ini b/doc/guides/nics/features/mrvl.ini index c2df525..2243749 100644 --- a/doc/guides/nics/features/mrvl.ini +++ b/doc/guides/nics/features/mrvl.ini @@ -10,3 +10,5 @@ MTU update = Y Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y +Unicast MAC filter = Y +Multicast MAC filter = Y diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c index 519aa19..daa2229 100644 --- a/drivers/net/mrvl/mrvl_ethdev.c +++ b/drivers/net/mrvl/mrvl_ethdev.c @@ -69,10 +69,11 @@ /* maximum number of available hifs */ #define MRVL_MUSDK_HIFS_MAX 9 -#define MRVL_MAC_ADDRS_MAX 1 /* prefetch shift */ #define MRVL_MUSDK_PREFETCH_SHIFT 2 +/* TCAM has 25 entries reserved for uc/mc filter entries */ +#define MRVL_MAC_ADDRS_MAX 25 #define MRVL_MATCH_LEN 16 #define MRVL_PKT_EFFEC_OFFS (MRVL_PKT_OFFS + MV_MH_SIZE) /* Maximum allowable packet size */ @@ -372,6 +373,22 @@ mrvl_dev_start(struct rte_eth_dev *dev) if (ret) return ret; + /* + * In case there are some some stale uc/mc mac addresses flush them + * here. It cannot be done during mrvl_dev_close() as port information + * is already gone at that point (due to pp2_ppio_deinit() in + * mrvl_dev_stop()). + */ + if (!priv->uc_mc_flushed) { + ret = pp2_ppio_flush_mac_addrs(priv->ppio, 1, 1); + if (ret) { + RTE_LOG(ERR, PMD, + "Failed to flush uc/mc filter list\n"); + goto out; + } + priv->uc_mc_flushed = 1; + } + /* For default QoS config, don't start classifier. */ if (mrvl_qos_cfg) { ret = mrvl_start_qos_mapping(priv); @@ -657,6 +674,80 @@ mrvl_allmulticast_disable(struct rte_eth_dev *dev) } /** + * DPDK callback to remove a MAC address. + * + * @param dev + * Pointer to Ethernet device structure. + * @param index + * MAC address index. + */ +static void +mrvl_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) +{ + struct mrvl_priv *priv = dev->data->dev_private; + char buf[ETHER_ADDR_FMT_SIZE]; + int ret; + + ret = pp2_ppio_remove_mac_addr(priv->ppio, + dev->data->mac_addrs[index].addr_bytes); + if (ret) { + ether_format_addr(buf, sizeof(buf), + &dev->data->mac_addrs[index]); + RTE_LOG(ERR, PMD, "Failed to remove mac %s\n", buf); + } +} + +/** + * DPDK callback to add a MAC address. + * + * @param dev + * Pointer to Ethernet device structure. + * @param mac_addr + * MAC address to register. + * @param index + * MAC address index. + * @param vmdq + * VMDq pool index to associate address with (unused). + * + * @return + * 0 on success, negative error value otherwise. + */ +static int +mrvl_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, + uint32_t index, uint32_t vmdq __rte_unused) +{ + struct mrvl_priv *priv = dev->data->dev_private; + char buf[ETHER_ADDR_FMT_SIZE]; + int ret; + + if (index == 0) + /* For setting index 0, mrvl_mac_addr_set() should be used.*/ + return -1; + + /* + * Maximum number of uc addresses can be tuned via kernel module mvpp2x + * parameter uc_filter_max. Maximum number of mc addresses is then + * MRVL_MAC_ADDRS_MAX - uc_filter_max. Currently it defaults to 4 and + * 21 respectively. + * + * If more than uc_filter_max uc addresses were added to filter list + * then NIC will switch to promiscuous mode automatically. + * + * If more than MRVL_MAC_ADDRS_MAX - uc_filter_max number mc addresses + * were added to filter list then NIC will switch to all-multicast mode + * automatically. + */ + ret = pp2_ppio_add_mac_addr(priv->ppio, mac_addr->addr_bytes); + if (ret) { + ether_format_addr(buf, sizeof(buf), mac_addr); + RTE_LOG(ERR, PMD, "Failed to add mac %s\n", buf); + return -1; + } + + return 0; +} + +/** * DPDK callback to set the primary MAC address. * * @param dev @@ -1006,6 +1097,8 @@ static const struct eth_dev_ops mrvl_ops = { .allmulticast_enable = mrvl_allmulticast_enable, .promiscuous_disable = mrvl_promiscuous_disable, .allmulticast_disable = mrvl_allmulticast_disable, + .mac_addr_remove = mrvl_mac_addr_remove, + .mac_addr_add = mrvl_mac_addr_add, .mac_addr_set = mrvl_mac_addr_set, .mtu_set = mrvl_mtu_set, .dev_infos_get = mrvl_dev_infos_get, diff --git a/drivers/net/mrvl/mrvl_ethdev.h b/drivers/net/mrvl/mrvl_ethdev.h index da33d05..f43f426 100644 --- a/drivers/net/mrvl/mrvl_ethdev.h +++ b/drivers/net/mrvl/mrvl_ethdev.h @@ -98,6 +98,7 @@ struct mrvl_priv { uint8_t pp_id; uint8_t ppio_id; uint8_t bpool_bit; + uint8_t uc_mc_flushed; struct pp2_ppio_params ppio_params; struct pp2_cls_qos_tbl_params qos_tbl_params; -- 2.7.4