From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0069.outbound.protection.outlook.com [104.47.37.69]) by dpdk.org (Postfix) with ESMTP id 68333FA32 for ; Mon, 23 Jan 2017 13:01:37 +0100 (CET) Received: from BN3PR0301CA0044.namprd03.prod.outlook.com (10.160.152.140) by CY1PR0301MB1577.namprd03.prod.outlook.com (10.162.166.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Mon, 23 Jan 2017 12:01:34 +0000 Received: from BL2FFO11FD024.protection.gbl (2a01:111:f400:7c09::122) by BN3PR0301CA0044.outlook.office365.com (2a01:111:e400:401e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13 via Frontend Transport; Mon, 23 Jan 2017 12:01:34 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD024.mail.protection.outlook.com (10.173.161.103) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Mon, 23 Jan 2017 12:01:34 +0000 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v0NC07en019311; Mon, 23 Jan 2017 05:01:31 -0700 From: Hemant Agrawal To: CC: , , , , , , Hemant Agrawal Date: Mon, 23 Jan 2017 17:29:55 +0530 Message-ID: <1485172803-17288-26-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485172803-17288-1-git-send-email-hemant.agrawal@nxp.com> References: <1484832240-2048-1-git-send-email-hemant.agrawal@nxp.com> <1485172803-17288-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131296464945389762; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(336005)(39400400002)(39410400002)(39860400002)(39450400003)(39850400002)(39380400002)(39840400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(47776003)(626004)(104016004)(5890100001)(5003940100001)(8676002)(5660300001)(53936002)(97736004)(6666003)(8656002)(92566002)(189998001)(36756003)(77096006)(81156014)(50226002)(8936002)(38730400001)(81166006)(85426001)(50986999)(4326007)(305945005)(105606002)(76176999)(48376002)(68736007)(2906002)(50466002)(2351001)(86362001)(575784001)(106466001)(2950100002)(6916009)(110136003)(33646002)(54906002)(356003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1577; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD024; 1:Cfkq/JwHvyVyrD7cdiVsD2BKccVID8hBGqY+BcHcYdkW5Qz7QWRxcRJhvXlNxNb4IPVoN95RqFSqs20l9Aox+ZUMZOPB953/Y9CIziQfm1AJMygHlThc4/C4e0RXq+0CkbYcpqfTqRDzPxs5LG235AXadHO9CPmiM/lcX7qYWa3CdcddhAEUsKR/oa6GojSDtojNovCYyPjx5SHAFyY4cq5jh3kC6ik4IwpERdycwXdgDenouCv9aQxoUUlx+iTLXCzDm769XFdB76kVqFTqj84LgkBL+/ASjlEzaZtD6hht4BsEUnIQw3h46BNPJHslFuJ/me6JFXi0QAP0AwvQs61c+EIBWwMtmh1Jn1Nb08dvLvUf9bZgWjbsgCYrF8/CKguZQR5/46JTCeG+pujCDmCaK5KIJ3yikaVkeQsuBDlnMSHPYllMwlBmcuh8Vy19xYReFRbqNzmAnFBueiuDX/1SjRDo/oPeQ1jwEFsSrRJV8hmT1RU4uRIQE+ZEHihQtQYnWnKMtFmrfAUXjSKpgmescCqvLbViKyj8BNmecewAfv9Oy9vu3fzgb08haif9raWW0tAxr84o5jEszK82X6CDotfBelnUBU2joSzH1dYzsXAtTGWCykhscJMugfAck7q+3P3tKls1mTwYtm+3VkWPTLu3qL0coSHi4x5vMZLhGNOPSx1BmIo+wSf4lzYAfa7YmIxPGwjXfyuaHteCtqBr2NUbD4copQ1aMIhT+De7zSn3zXPmtvHQSw4sJdtd MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 4c36e620-d8cb-40b9-de00-08d4438793c7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR0301MB1577; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1577; 3:uB/xakIcNlvPUXqYig05yUmwQwvHJ3Ocqh9j8o+yB4NnhTh3sDVMwlwO7BTW75whZU3wkN6TO42Z9iCCD3jVSDK2P6lWvaDZnWfc501z4SZOgY0n+XDRiTWifVDmUSaQD08GRZLGZyiknt+K6T5nZplu7SpaKoewvltZxfl4Sd2bfHTCgIaIG6H6quQPixiGYpB08M9u4+rCblHh9fktPbUTT8EXghYw6iGjGTSQNC2oUkQ4hQ7a4MFxj5OZComOklrrZZ1sLnJk+4Zwacz7KwRL1O1044xzBr0iONffPAo2ep0SN/ucXPsyGNFaGJg9IScasJYyRlzzqhJmHfiTH98YwpZ5bu88lnjjBnJpw5q+MgybNDQlgjSXmhRoVH+V; 25:vneUGQVsadf1jvLwis/CradbUctAxtO60j2zFUbknMx21Djwgy8kGt5qYl1CzymbZPAo6le2frV5nBR/cgECZyDAG/JPB6FdrvCHqYDSm3xO3w5964XXo6onEx54jL2AovZA2ZhPaIB/JvK7tZQmHaW8gtiPqpMt3bzDLdBfQu6u4JqeNahyP82BC7TbhntuNdMn3v6iXQ2qF/JF0qyTit7W34bhy/Md64+KTmUxY7Bx9S67dXuEqtxnBQgwzTAHpBEYavc/EBG8d1vwk+IhH56W0a6ZD26/dibjjfDdrvG2ogXZ+KS2R9bHzPg9TzlvmrG21hMQ6oxZmZD58EAeouqvPpwcw9lqiDzY0E4hNGF4EgQnNW1nW5rCIH0T3iqd/GBWuyQSByb/MiyMF0A5T3hXQua0GDeGRAKBwDRH4M758kaimz7g+kBUjoBxzcoLj4kk6SjGWNLYu81uH2wvkw== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1577; 31:O8ZNuOkM8un0Q1cJV4PzWKMhnzt8zkp9uUDyKS3pzHv2wFEfO77CiInLj9vibJzp4/75YiQi/d6iVh+9asNnhkoivaV/f/MbmhEZeYZshfYyM6zhW58ug7M3AXbq6odmV1g1CORA2qvPrSVEnSaL9injhFq2rGNIjcoTw9CRFgtRK6GSfvLOLH0dvn1JjUyX/xe+e81j4MHvjVy7dRt3Tw91+vvNkluxOjo5O/YctlmVzxLL9JfUVxwDVALzShaQJuYcBpZoD8IfXgUmUzmfyYDOpbWry4UYF1RVTuyhqd0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123556025)(20161123559025)(20161123561025)(20161123565025); SRVR:CY1PR0301MB1577; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1577; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1577; 4:2xy0UDjhtIzT4msScJbB2E0dMZrYiC2pgdunEQQbTXmAiXtGGEuCU9VYvJZhdol8cHTSf3ZMoQCahrwTgxcjrn0uh1NtUiIXvCfDbRt+ZHKIE2+pRO4Tm+824Fya+Ut8B+nTC/OCqD+guU+HkfROiWFmcx3STGr7gpxebUYxPRTOavm3m++3/jYaYvzzQDDeQA5irSgAJAmsZAEIkLXAFtQt3e+WBoKKKNSReFUXenTh5rebvulUDsOqx+EZBuA2hXDGjSjGULnmrPls5Jovz4JVtEjT8jAy7460ObU8TNO/x33LCUo1K60eogNG8ar6He6+w00w3a2ROdHq6YCp65+xQ3rOiVgPxHKtdF10I6OueBUaRN8zi23fm48qo9mV5jFi/vQl3jipfMyxolnwqMTDQkRjJQurL/5nlS6nmm/Osc06Gf4AzreyXqPEfCjOYW7Fau2HteI4s6QYr39ARkT/qVY0qLVyhKcecC5f/eqKeQoWQZPhlFfn6zJOtMkjHTe4087A1HHdztitdULcEn1XX8qAwp9eLEJBCqBTaWJs2La28kaYKnsUnW5AzM+qa00b1uHGHQf5bQbiUKvlJu69QkYE06WMyKxkak1LYRL32+2s/DqKMWh0RemzbMZOhwd8YteN05U4+RKZOA8MRqJTZwbTDbqGK0u8UADCTqum4QTePdpA0+ZJNgjxVhi3lrvpVJI8E9MwlAN781uM2mfPpz7k+WizYkfcAuu56JHgQs2JmxYYq3aRLvY1cuMaOmXy+bHydc/5hEGj/PWTdw== X-Forefront-PRVS: 0196A226D1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1577; 23:5XU6K+DBIVr4++b/iyr5IX4jFiJSmj8mFcSxSN+?= =?us-ascii?Q?hCLYA+QCRg3osws1mHmHdJJdRthaFSM3P14LtgoFBBWH0rNBscmBX3WlGpj+?= =?us-ascii?Q?qWQlaRhvu89N6GLPtzFP5DhJUQxoGpn3+acQ9ubcgHY9utAFHL6daEbNyXOs?= =?us-ascii?Q?E7nbYgVRCATtqvUH6NgLv6ZkY0zB/3ZAa9nIuRPxRRK6TKibMghiXCEgvb8Z?= =?us-ascii?Q?imBfFT6iuggbK1z+EDPk07sKTgc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jwgU2vx+YMess9330prmxcL+bIsaQY94= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1577; 7:tQH1E7aOBTWjGVpZl1WDcO4l6FlG682BtWxvnQF1XNpW4dEpot1/XqJxcyvpwB0hIhnr2D+teMxR0ppqvm/+qXWUjtZGCCpoftD/H6EmJTYt9/bUV6ZCbAnF3YZiEKdXQtPQbjON99RtxoV4k/Wn0s9no4sS8bf36hlwirI6kueAL2ZTRVcJqV30rpjod6Pd33fAoufZgUkEevp2Q79Fo+SzFfefxLhZmrmVGdOpbcXnWBIi5GdyD+eYBMCjlGmz9WtXzPHb8mel4xIY0MZU3evoNYdwojrEdvb4FRGuYCUCNwdomqCstr5VhvB2kP74QxFER4XWxAyzsheqtqJ6Nyqc1QJWjtN2v5bDiY2BpzippPEUHjIR8VuxQWwx/B2XUIJgHAPRma4P+sHFxfqoVzOAH0jSk+Z1LLqCzKu6te2pycQabN5A9Mfy/yEzTRITHgWkFxqXJu8zJaeVsyzjvA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2017 12:01:34.3205 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1577 Subject: [dpdk-dev] [PATCHv6 25/33] net/dpaa2: add packet rx and tx 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: , X-List-Received-Date: Mon, 23 Jan 2017 12:01:38 -0000 Signed-off-by: Hemant Agrawal --- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 53 +++++++ drivers/net/dpaa2/Makefile | 1 + drivers/net/dpaa2/dpaa2_ethdev.c | 4 + drivers/net/dpaa2/dpaa2_ethdev.h | 3 + drivers/net/dpaa2/dpaa2_rxtx.c | 260 ++++++++++++++++++++++++++++++++ 5 files changed, 321 insertions(+) create mode 100644 drivers/net/dpaa2/dpaa2_rxtx.c diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h index 2a8d9e5..c26360d3 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h @@ -43,10 +43,16 @@ #ifndef true #define true 1 #endif +#define lower_32_bits(x) ((uint32_t)(x)) +#define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16)) #ifndef ETH_VLAN_HLEN #define ETH_VLAN_HLEN 4 /** < Vlan Header Length */ #endif + +#define MAX_TX_RING_SLOTS 8 + /** simple.addr_lo = lower_32_bits((uint64_t)(addr)); \ + fd->simple.addr_hi = upper_32_bits((uint64_t)(addr)); \ +} while (0) +#define DPAA2_SET_FD_LEN(fd, length) (fd)->simple.len = length +#define DPAA2_SET_FD_BPID(fd, bpid) ((fd)->simple.bpid_offset |= bpid) +#define DPAA2_SET_FD_OFFSET(fd, offset) \ + ((fd->simple.bpid_offset |= (uint32_t)(offset) << 16)) +#define DPAA2_RESET_FD_CTRL(fd) (fd)->simple.ctrl = 0 + +#define DPAA2_SET_FD_ASAL(fd, asal) ((fd)->simple.ctrl |= (asal << 16)) +#define DPAA2_SET_FD_FLC(fd, addr) do { \ + fd->simple.flc_lo = lower_32_bits((uint64_t)(addr)); \ + fd->simple.flc_hi = upper_32_bits((uint64_t)(addr)); \ +} while (0) +#define DPAA2_GET_FD_ADDR(fd) \ +((uint64_t)((((uint64_t)((fd)->simple.addr_hi)) << 32) + (fd)->simple.addr_lo)) + +#define DPAA2_GET_FD_LEN(fd) ((fd)->simple.len) +#define DPAA2_GET_FD_BPID(fd) (((fd)->simple.bpid_offset & 0x00003FFF)) +#define DPAA2_GET_FD_OFFSET(fd) (((fd)->simple.bpid_offset & 0x0FFF0000) >> 16) +#define DPAA2_INLINE_MBUF_FROM_BUF(buf, meta_data_size) \ + ((struct rte_mbuf *)((uint64_t)(buf) - (meta_data_size))) + +#define DPAA2_ASAL_VAL (DPAA2_MBUF_HW_ANNOTATION / 64) + +/* Only Enqueue Error responses will be + * pushed on FQID_ERR of Enqueue FQ + */ +#define DPAA2_EQ_RESP_ERR_FQ 0 +/* All Enqueue responses will be pushed on address + * set with qbman_eq_desc_set_response + */ +#define DPAA2_EQ_RESP_ALWAYS 1 + struct dpaa2_dpbp_dev *dpaa2_alloc_dpbp_dev(void); void dpaa2_free_dpbp_dev(struct dpaa2_dpbp_dev *dpbp); diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile index 0e59203..d52fa39 100644 --- a/drivers/net/dpaa2/Makefile +++ b/drivers/net/dpaa2/Makefile @@ -59,6 +59,7 @@ EXPORT_MAP := rte_pmd_dpaa2_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += base/dpaa2_hw_dpni.c +SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c # library dependencies diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 7e64e60..c2015f0 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -681,6 +681,8 @@ eth_dev->dev_ops = &dpaa2_ethdev_ops; eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name; + eth_dev->rx_pkt_burst = dpaa2_dev_rx; + eth_dev->tx_pkt_burst = dpaa2_dev_tx; return 0; } @@ -734,6 +736,8 @@ free(dpni); eth_dev->dev_ops = NULL; + eth_dev->rx_pkt_burst = NULL; + eth_dev->tx_pkt_burst = NULL; return 0; } diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h index a56b525..7196398 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.h +++ b/drivers/net/dpaa2/dpaa2_ethdev.h @@ -77,4 +77,7 @@ int dpaa2_remove_flow_dist(struct rte_eth_dev *eth_dev, int dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv, void *blist); +uint16_t dpaa2_dev_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts); +uint16_t dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts); + #endif /* _DPAA2_ETHDEV_H */ diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c new file mode 100644 index 0000000..25574c0 --- /dev/null +++ b/drivers/net/dpaa2/dpaa2_rxtx.c @@ -0,0 +1,260 @@ +/*- + * BSD LICENSE + * + * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. + * Copyright (c) 2016 NXP. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Freescale Semiconductor, Inc nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "dpaa2_ethdev.h" + +static inline struct rte_mbuf *__attribute__((hot)) +eth_fd_to_mbuf(const struct qbman_fd *fd) +{ + struct rte_mbuf *mbuf = DPAA2_INLINE_MBUF_FROM_BUF( + DPAA2_GET_FD_ADDR(fd), + rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size); + + /* need to repopulated some of the fields, + * as they may have changed in last transmission + */ + mbuf->nb_segs = 1; + mbuf->ol_flags = 0; + mbuf->data_off = DPAA2_GET_FD_OFFSET(fd); + mbuf->data_len = DPAA2_GET_FD_LEN(fd); + mbuf->pkt_len = mbuf->data_len; + + mbuf->packet_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4; + + mbuf->next = NULL; + rte_mbuf_refcnt_set(mbuf, 1); + + PMD_RX_LOG(DEBUG, "to mbuf - mbuf =%p, mbuf->buf_addr =%p, off = %d," + "fd_off=%d fd =%lx, meta = %d bpid =%d, len=%d\n", + mbuf, mbuf->buf_addr, mbuf->data_off, + DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_ADDR(fd), + rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size, + DPAA2_GET_FD_BPID(fd), DPAA2_GET_FD_LEN(fd)); + + return mbuf; +} + +static void __attribute__ ((noinline)) __attribute__((hot)) +eth_mbuf_to_fd(struct rte_mbuf *mbuf, + struct qbman_fd *fd, uint16_t bpid) +{ + /*Resetting the buffer pool id and offset field*/ + fd->simple.bpid_offset = 0; + + DPAA2_SET_FD_ADDR(fd, (mbuf->buf_addr)); + DPAA2_SET_FD_LEN(fd, mbuf->data_len); + DPAA2_SET_FD_BPID(fd, bpid); + DPAA2_SET_FD_OFFSET(fd, mbuf->data_off); + DPAA2_SET_FD_ASAL(fd, DPAA2_ASAL_VAL); + + PMD_TX_LOG(DEBUG, "mbuf =%p, mbuf->buf_addr =%p, off = %d," + "fd_off=%d fd =%lx, meta = %d bpid =%d, len=%d\n", + mbuf, mbuf->buf_addr, mbuf->data_off, + DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_ADDR(fd), + rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size, + DPAA2_GET_FD_BPID(fd), DPAA2_GET_FD_LEN(fd)); +} + +uint16_t +dpaa2_dev_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +{ + /* Function is responsible to receive frames for a given device and VQ*/ + struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue; + struct qbman_result *dq_storage; + uint32_t fqid = dpaa2_q->fqid; + int ret, num_rx = 0; + uint8_t is_last = 0, status; + struct qbman_swp *swp; + const struct qbman_fd *fd; + struct qbman_pull_desc pulldesc; + struct rte_eth_dev *dev = dpaa2_q->dev; + + if (unlikely(!DPAA2_PER_LCORE_DPIO)) { + ret = dpaa2_affine_qbman_swp(); + if (ret) { + RTE_LOG(ERR, PMD, "Failure in affining portal\n"); + return 0; + } + } + swp = DPAA2_PER_LCORE_PORTAL; + dq_storage = dpaa2_q->q_storage->dq_storage[0]; + + qbman_pull_desc_clear(&pulldesc); + qbman_pull_desc_set_numframes(&pulldesc, + (nb_pkts > DPAA2_DQRR_RING_SIZE) ? + DPAA2_DQRR_RING_SIZE : nb_pkts); + qbman_pull_desc_set_fq(&pulldesc, fqid); + /* todo optimization - we can have dq_storage_phys available*/ + qbman_pull_desc_set_storage(&pulldesc, dq_storage, + (dma_addr_t)(dq_storage), 1); + + /*Issue a volatile dequeue command. */ + while (1) { + if (qbman_swp_pull(swp, &pulldesc)) { + PMD_RX_LOG(ERR, "VDQ command is not issued." + "QBMAN is busy\n"); + /* Portal was busy, try again */ + continue; + } + break; + }; + + /* Receive the packets till Last Dequeue entry is found with + * respect to the above issues PULL command. + */ + while (!is_last) { + struct rte_mbuf *mbuf; + /*Check if the previous issued command is completed. + * Also seems like the SWP is shared between the + * Ethernet Driver and the SEC driver. + */ + while (!qbman_check_command_complete(swp, dq_storage)) + ; + /* Loop until the dq_storage is updated with + * new token by QBMAN + */ + while (!qbman_result_has_new_result(swp, dq_storage)) + ; + /* Check whether Last Pull command is Expired and + * setting Condition for Loop termination + */ + if (qbman_result_DQ_is_pull_complete(dq_storage)) { + is_last = 1; + /* Check for valid frame. */ + status = (uint8_t)qbman_result_DQ_flags(dq_storage); + if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0)) + continue; + } + + fd = qbman_result_DQ_fd(dq_storage); + mbuf = (struct rte_mbuf *)(DPAA2_GET_FD_ADDR(fd) + - rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size); + /* Prefeth mbuf */ + rte_prefetch0(mbuf); + /* Prefetch Annotation address for the parse results */ + rte_prefetch0((void *)((uint64_t)DPAA2_GET_FD_ADDR(fd) + + DPAA2_FD_PTA_SIZE + 16)); + + bufs[num_rx] = eth_fd_to_mbuf(fd); + bufs[num_rx]->port = dev->data->port_id; + + num_rx++; + dq_storage++; + } /* End of Packet Rx loop */ + + dpaa2_q->rx_pkts += num_rx; + + /*Return the total number of packets received to DPAA2 app*/ + return num_rx; +} + +/* + * Callback to handle sending packets through WRIOP based interface + */ +uint16_t +dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +{ + /* Function to transmit the frames to given device and VQ*/ + uint32_t loop; + int32_t ret; + struct qbman_fd fd_arr[MAX_TX_RING_SLOTS]; + uint32_t frames_to_send; + struct rte_mempool *mp; + struct qbman_eq_desc eqdesc; + struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue; + struct qbman_swp *swp; + uint16_t num_tx = 0; + uint16_t bpid; + struct rte_eth_dev *dev = dpaa2_q->dev; + struct dpaa2_dev_priv *priv = dev->data->dev_private; + + if (unlikely(!DPAA2_PER_LCORE_DPIO)) { + ret = dpaa2_affine_qbman_swp(); + if (ret) { + RTE_LOG(ERR, PMD, "Failure in affining portal\n"); + return 0; + } + } + swp = DPAA2_PER_LCORE_PORTAL; + + PMD_TX_LOG(DEBUG, "===> dev =%p, fqid =%d", dev, dpaa2_q->fqid); + + /*Prepare enqueue descriptor*/ + qbman_eq_desc_clear(&eqdesc); + qbman_eq_desc_set_no_orp(&eqdesc, DPAA2_EQ_RESP_ERR_FQ); + qbman_eq_desc_set_response(&eqdesc, 0, 0); + qbman_eq_desc_set_qd(&eqdesc, priv->qdid, + dpaa2_q->flow_id, dpaa2_q->tc_index); + + /*Clear the unused FD fields before sending*/ + while (nb_pkts) { + frames_to_send = (nb_pkts >> 3) ? MAX_TX_RING_SLOTS : nb_pkts; + + for (loop = 0; loop < frames_to_send; loop++) { + fd_arr[loop].simple.frc = 0; + DPAA2_RESET_FD_CTRL((&fd_arr[loop])); + DPAA2_SET_FD_FLC((&fd_arr[loop]), NULL); + mp = (*bufs)->pool; + bpid = mempool_to_bpid(mp); + eth_mbuf_to_fd(*bufs, &fd_arr[loop], bpid); + bufs++; + } + loop = 0; + while (loop < frames_to_send) { + loop += qbman_swp_send_multiple(swp, &eqdesc, + &fd_arr[loop], frames_to_send - loop); + } + + num_tx += frames_to_send; + dpaa2_q->tx_pkts += frames_to_send; + nb_pkts -= frames_to_send; + } + return num_tx; +} -- 1.9.1