From patchwork Tue Aug 11 12:29:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 247615 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp546309ilo; Tue, 11 Aug 2020 05:36:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqgUiOIMVBbzc6uXzBEk9uz5D+Z2ADgIKWP3XgaAXJZCjv1rcEaFKmpKyi29pjJ0KkXUVY X-Received: by 2002:a25:4609:: with SMTP id t9mr45317165yba.231.1597149362038; Tue, 11 Aug 2020 05:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597149362; cv=none; d=google.com; s=arc-20160816; b=F8YHT6Ha6GwrUtBSof0WPrU02NZmWmSzlylA7fLU/F3LKp6FO6Gd6dJa5S9bLT3YTl kQcGM9VGYsowzzWqgY8dOHGpq4o5qVIEyc+xo3ikpgyeNuRMAsxkxUqHY+t9VgxlVX8D aVZh3pBa4lnKl3fUvVbeZgGDkTEdCfxP5w/edpCza+lN98tgCf4I7NgtYmW8TXAMhPQA O+TB6a7O0jIfxboghaIzQoYnz6FHoEnmHW5BHWJCk+cktrXtB05d3lPDsTknOiTqJsIN ltZf5MBmdwQ3L0J5hReoeh0akcNh1gwrM8XaqBUqIlr7kIQjVGREzC1qdE9r4l+Dkv9w EFoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=8HbQk3PzonyTPTzjZWW6Ga8UDYIcFg3hq8IyLZwSfTA=; b=noI7RAl784koWj5uYn0JlrMEXuw59YN9i6pn+eODMrYVe7Vxd+tv2ICe89yx1kFiP7 o6dDemZvPL+TLYQa3OgBOC9sck2QaW1NYcFvg34hDZ4abAJiLveg9wAYUiitOODwnGgB mBofbv1rORgknVv5+d9dpWKPembvmhzuc5NAH7lm0VTTvp1+VDOcQjP+LSPn5f4kNIZ6 2aAHIAm4m6U/z0EGdLJJX6K2ySEbkWfXmWPIc4ilpC+BOC8vTJWD1lbStsKW42LDiONX 3Fg00b4iJI/6lUhmHCvyPM6iX01qyuPLBK2fAOSAqsKmXr7yQdcnNtYuitmATPom73gt PRRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id v6si19390761ybc.228.2020.08.11.05.36.01; Tue, 11 Aug 2020 05:36:02 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 215F11C0AF; Tue, 11 Aug 2020 14:35:34 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id A613F1C023 for ; Tue, 11 Aug 2020 14:35:29 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 7B7491A1F55; Tue, 11 Aug 2020 14:35:29 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 529891A1F5C; Tue, 11 Aug 2020 14:35:27 +0200 (CEST) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 453274030E; Tue, 11 Aug 2020 14:35:24 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: Radu Bulie , Jun Yang , Nipun Gupta Date: Tue, 11 Aug 2020 17:59:57 +0530 Message-Id: <20200811123001.30045-4-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200811123001.30045-1-hemant.agrawal@nxp.com> References: <20200711081716.25173-1-hemant.agrawal@nxp.com> <20200811123001.30045-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v4 4/8] bus/dpaa: add shared MAC support 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Radu Bulie A shared MAC interface is an interface which can be used by both kernel and userspace based on classification configuration It is defined in dts with the compatible string "fsl,dpa-ethernet-shared" which bpool will be seeded by the dpdk partition and configured as a netdev by the dpaa Linux eth driver. User space buffers from the bpool will be kmapped by the kernel. Signed-off-by: Radu Bulie Signed-off-by: Jun Yang Signed-off-by: Nipun Gupta Acked-by: Hemant Agrawal --- drivers/bus/dpaa/base/fman/fman.c | 27 ++++++++++++++++++++++----- drivers/bus/dpaa/include/fman.h | 2 ++ drivers/net/dpaa/dpaa_ethdev.c | 31 +++++++++++++++++-------------- drivers/net/dpaa/dpaa_flow.c | 18 ++++++++++++++---- 4 files changed, 55 insertions(+), 23 deletions(-) -- 2.17.1 diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index 33be9e5d7b..3ae29bf065 100644 --- a/drivers/bus/dpaa/base/fman/fman.c +++ b/drivers/bus/dpaa/base/fman/fman.c @@ -167,13 +167,21 @@ fman_if_init(const struct device_node *dpa_node) const char *mname, *fname; const char *dname = dpa_node->full_name; size_t lenp; - int _errno; + int _errno, is_shared = 0; const char *char_prop; uint32_t na; if (of_device_is_available(dpa_node) == false) return 0; + if (!of_device_is_compatible(dpa_node, "fsl,dpa-ethernet-init") && + !of_device_is_compatible(dpa_node, "fsl,dpa-ethernet-shared")) { + return 0; + } + + if (of_device_is_compatible(dpa_node, "fsl,dpa-ethernet-shared")) + is_shared = 1; + rprop = "fsl,qman-frame-queues-rx"; mprop = "fsl,fman-mac"; @@ -387,7 +395,7 @@ fman_if_init(const struct device_node *dpa_node) goto err; } - assert(lenp == (4 * sizeof(phandle))); + assert(lenp >= (4 * sizeof(phandle))); na = of_n_addr_cells(mac_node); /* Get rid of endianness (issues). Convert to host byte order */ @@ -408,7 +416,7 @@ fman_if_init(const struct device_node *dpa_node) goto err; } - assert(lenp == (4 * sizeof(phandle))); + assert(lenp >= (4 * sizeof(phandle))); /*TODO: Fix for other cases also */ na = of_n_addr_cells(mac_node); /* Get rid of endianness (issues). Convert to host byte order */ @@ -508,6 +516,9 @@ fman_if_init(const struct device_node *dpa_node) pools_phandle++; } + if (is_shared) + __if->__if.is_shared_mac = 1; + /* Parsing of the network interface is complete, add it to the list */ DPAA_BUS_LOG(DEBUG, "Found %s, Tx Channel = %x, FMAN = %x," "Port ID = %x", @@ -524,7 +535,7 @@ fman_if_init(const struct device_node *dpa_node) int fman_init(void) { - const struct device_node *dpa_node; + const struct device_node *dpa_node, *parent_node; int _errno; /* If multiple dependencies try to initialise the Fman driver, don't @@ -539,7 +550,13 @@ fman_init(void) return fman_ccsr_map_fd; } - for_each_compatible_node(dpa_node, NULL, "fsl,dpa-ethernet-init") { + parent_node = of_find_compatible_node(NULL, NULL, "fsl,dpaa"); + if (!parent_node) { + DPAA_BUS_LOG(ERR, "Unable to find fsl,dpaa node"); + return -ENODEV; + } + + for_each_child_node(parent_node, dpa_node) { _errno = fman_if_init(dpa_node); if (_errno) { FMAN_ERR(_errno, "if_init(%s)\n", dpa_node->full_name); diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h index 7a0a7d405f..cb7f18ca26 100644 --- a/drivers/bus/dpaa/include/fman.h +++ b/drivers/bus/dpaa/include/fman.h @@ -320,6 +320,8 @@ struct fman_if { struct rte_ether_addr mac_addr; /* The Qman channel to schedule Tx FQs to */ u16 tx_channel_id; + + uint8_t is_shared_mac; /* The hard-coded FQIDs for this interface. Note: this doesn't cover * the PCD nor the "Rx default" FQIDs, which are configured via FMC * and its XML-based configuration. diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index c5b9ac1a5b..c2d4803978 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -351,7 +351,8 @@ static void dpaa_eth_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - fman_if_disable_rx(fif); + if (!fif->is_shared_mac) + fman_if_disable_rx(fif); dev->tx_pkt_burst = dpaa_eth_tx_drop_all; } @@ -1807,19 +1808,21 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) fman_intf->mac_addr.addr_bytes[4], fman_intf->mac_addr.addr_bytes[5]); - - /* Disable RX mode */ - fman_if_discard_rx_errors(fman_intf); - fman_if_disable_rx(fman_intf); - /* Disable promiscuous mode */ - fman_if_promiscuous_disable(fman_intf); - /* Disable multicast */ - fman_if_reset_mcast_filter_table(fman_intf); - /* Reset interface statistics */ - fman_if_stats_reset(fman_intf); - /* Disable SG by default */ - fman_if_set_sg(fman_intf, 0); - fman_if_set_maxfrm(fman_intf, RTE_ETHER_MAX_LEN + VLAN_TAG_SIZE); + if (!fman_intf->is_shared_mac) { + /* Disable RX mode */ + fman_if_discard_rx_errors(fman_intf); + fman_if_disable_rx(fman_intf); + /* Disable promiscuous mode */ + fman_if_promiscuous_disable(fman_intf); + /* Disable multicast */ + fman_if_reset_mcast_filter_table(fman_intf); + /* Reset interface statistics */ + fman_if_stats_reset(fman_intf); + /* Disable SG by default */ + fman_if_set_sg(fman_intf, 0); + fman_if_set_maxfrm(fman_intf, + RTE_ETHER_MAX_LEN + VLAN_TAG_SIZE); + } return 0; diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c index 71ff3d8464..270c061db0 100644 --- a/drivers/net/dpaa/dpaa_flow.c +++ b/drivers/net/dpaa/dpaa_flow.c @@ -736,6 +736,14 @@ int dpaa_fm_deconfig(struct dpaa_if *dpaa_intf, } dpaa_intf->netenv_handle = NULL; + if (fif && fif->is_shared_mac) { + ret = fm_port_enable(dpaa_intf->port_handle); + if (ret != E_OK) { + DPAA_PMD_ERR("shared mac re-enable failed"); + return ret; + } + } + /* FM PORT Close */ fm_port_close(dpaa_intf->port_handle); dpaa_intf->port_handle = NULL; @@ -785,10 +793,12 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set) } } /* Set default netenv and scheme */ - ret = set_default_scheme(dpaa_intf); - if (ret) { - DPAA_PMD_ERR("Set PCD NetEnv and Scheme: Failed"); - goto unset_pcd_netenv_scheme1; + if (!fif->is_shared_mac) { + ret = set_default_scheme(dpaa_intf); + if (ret) { + DPAA_PMD_ERR("Set PCD NetEnv and Scheme: Failed"); + goto unset_pcd_netenv_scheme1; + } } /* Set Port PCD */