From patchwork Mon Nov 11 05:48:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harman Kalra X-Patchwork-Id: 62815 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EA977A04BA; Mon, 11 Nov 2019 06:49:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 40A112904; Mon, 11 Nov 2019 06:49:01 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id A7AE02142 for ; Mon, 11 Nov 2019 06:48:59 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAB5jGTe008828 for ; Sun, 10 Nov 2019 21:48:58 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=0vKuLqVf7hJayN6V0ri9JriQgRmDtGq+Mk8sFusXgdI=; b=mJh5EpfRit3u+Gh3bwWnhHpXobahVib7vOpkk2ezsxxuXr+rlmzyCsdc02kQ+aNE40HB sVnnsor+/eo/uoqH/1ZYeQS+16762ACaxEcOtOzLtaHQnpHaIVrUM06Il1zmMDI5vTdy 1CklyuEP2FHmPrPusRFqQHj592pnT1JpSIcp1XiLUY5WL9AjJdv6KEJe/dY9dJYPF5aK xDOEpHyIGBv07UsyswDDXjv3/7ircnEVSxPrM86FinAL3RvlFkia6R/yasWo3vt9LGIq 0YgqF4O/ASFwjDt8gz8MeKxRFXSxOeD1WsJZdT64F/LybL9WrQ4l+KEMmwHqZjOLLlwU gw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2w5wurn17y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sun, 10 Nov 2019 21:48:58 -0800 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 10 Nov 2019 21:48:56 -0800 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (104.47.41.53) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Sun, 10 Nov 2019 21:48:56 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+2UKXMiN3QYXihB/txthJDpwFHDYSrGnHkDjvARJcl8s5b4WuVY5Wjd/rJ/tdw4Z24JrXhUrv7uKeeMwL31NgPx8EodOKRjSjzIMymlH4/GC572cCiPVlQntR5iFlVsX2eZLYLvySY1mXm4unenHIsP2zCnCTqbMzyhflxSrfg/oiuLOyWX0fil7M66A7jbu1vfycEu5xentQBBsUzeq17uRQJNJsfXQKBd6iJizneYfuppBh8WEwc1fEFsFwCShR03mGIUo1e3WCX6WywgYOLbqFS0XKuScc5+7N4eIK9g8wRkzLbB2f0Jp0SCuDtR2UgY8w1mtgu4cZ8i9ZuPUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0vKuLqVf7hJayN6V0ri9JriQgRmDtGq+Mk8sFusXgdI=; b=PRJlIheVncKJaQ7dTTThmeelmoOGNGcHpkad4O8/fR+ZZw0Cfu25bKqwtsCfdDe77/tr9Dg1pgRcUmiKdxkcwDxp0mB+Y16/gNGu8nHBvRU+Qs/EonHRjb1vI/GIOuP2AEf6vlmwx8rlBh1acWIxb3enoSG5/L2pJCHbXnqmLumdvfUqWRqD6Hpf9U5sXGsj8YxUb6xTU5vRv6+WDWHg0IQCspm9DunflO+YFXBCHJUAJDEUb+8JH5fpRLQi+LUGuRB7UJFVtVZFbkEHlWK5uyFom3l8Yw0Gen5BpM4RnpBSBpRFTkeyTIaYdnZPPwDDQm1FwhWZQEv9X3CrE2q7UQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0vKuLqVf7hJayN6V0ri9JriQgRmDtGq+Mk8sFusXgdI=; b=GlZSUPysBycei08hmAuWsMGJI56Wd8HDmIVtZpPAHucsuYdNA7ipBvIH06sKVZQy8vOpoWs6HmnAZdNuuhcJ845CMD8xnB4sv7wGTMyHl4FZkls42BBDygge0I5SIA8jlCldaLrjUZajwJgtYaCAS/X9GBpWIZuttOMb0p0Pb5w= Received: from MN2PR18MB2848.namprd18.prod.outlook.com (20.179.21.149) by MN2PR18MB2990.namprd18.prod.outlook.com (20.179.22.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.22; Mon, 11 Nov 2019 05:48:54 +0000 Received: from MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::a8a7:cb5b:a6a6:9693]) by MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::a8a7:cb5b:a6a6:9693%7]) with mapi id 15.20.2430.027; Mon, 11 Nov 2019 05:48:54 +0000 From: Harman Kalra To: Jerin Jacob Kollanukkaran , Nithin Kumar Dabilpuram , Vamsi Krishna Attunuru , Kiran Kumar Kokkilagadda CC: "dev@dpdk.org" , Harman Kalra Thread-Topic: [PATCH] net/octeontx2: fix ptp configurations for VF Thread-Index: AQHVmFOzQFhmJqmFiE6IbDBfTjNP3w== Date: Mon, 11 Nov 2019 05:48:54 +0000 Message-ID: <1573451282-27307-1-git-send-email-hkalra@marvell.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BMXPR01CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:2c::29) To MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:3e::21) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 91d0a870-e28b-4966-33b6-08d7666ad65a x-ms-traffictypediagnostic: MN2PR18MB2990: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0218A015FA x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(346002)(376002)(39860400002)(366004)(136003)(189003)(199004)(66556008)(14444005)(386003)(6436002)(6506007)(2616005)(476003)(66066001)(26005)(4326008)(6636002)(486006)(66446008)(52116002)(66476007)(66946007)(102836004)(107886003)(64756008)(256004)(186003)(71200400001)(71190400001)(6512007)(55236004)(36756003)(2906002)(8676002)(14454004)(478600001)(110136005)(316002)(6486002)(305945005)(50226002)(7736002)(8936002)(25786009)(99286004)(86362001)(54906003)(5660300002)(6116002)(3846002)(81166006)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2990; H:MN2PR18MB2848.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: y3on/f3zUSr/gkz9c+IyXgiV3BStNsVfr8AZeDcP4PTv1MV0UV5qq40sQy2cfpx1gaHt6pE8wQ1tKcNePY7wLANy3aCVAVCGqby1ovEnERdtDT4HJSeM63YQ5MUA1FMzm+daVkAqo3z3b8POyQdzS5fRyqT2APoQKGfVqEzeP+MizxUK9TBUoET7YYIr6ttS68OZrhMeG/ZFIg2crRaAZO2SqElBzjGmsaVeioG5WbVHP6YWh1WDmYh4CeWTQnnwTnBI/tMNrQ03oZ8P8iEnyLedVcoyMSPtkRyHuJP0H9NSRMMP8Iq+wykE8vd3oOs+14aCRuQn4Gc+ACL10OY7SwfxXmR6raQSN/J98myeiUThJbCwTrPMUd3fTil+SXcuufcC5cB1dSThp6Ad2wgleB/beRJt++hDIq+NWGK5t/aNLkgPHqVKwPDynRfE39ts MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 91d0a870-e28b-4966-33b6-08d7666ad65a X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Nov 2019 05:48:54.7435 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: raPVSF/pAc3EMgNgNvc2zz8fRugpNEm5+MgF+7eNZ8ULhCG3e1DpMERfB7tW6PddMcj0fiNoT1NoA4VlRUKa3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2990 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-11_01:2019-11-08,2019-11-11 signatures=0 Subject: [dpdk-dev] [PATCH] net/octeontx2: fix ptp configurations for VF 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" Issue has been observed if PTP is already enabled on PF and later VFs are configured. Since PTP requires mbuf data off to be shifted by 8 bytes, due to this l3fwd/l2fwd was not working with VFs. Also some extra garbage bytes were observed in packet data when ptp was enabled. Fixes: b5dc3140448e ("net/octeontx2: support base PTP") Signed-off-by: Harman Kalra Acked-by: Jerin Jacob --- drivers/common/octeontx2/otx2_mbox.h | 1 + drivers/net/octeontx2/otx2_ethdev.c | 13 ++++- drivers/net/octeontx2/otx2_ethdev.h | 1 + drivers/net/octeontx2/otx2_ethdev_ops.c | 2 + drivers/net/octeontx2/otx2_ptp.c | 68 ++++++++++++++++++++++--- drivers/net/octeontx2/otx2_rx.h | 2 + 6 files changed, 79 insertions(+), 8 deletions(-) diff --git a/drivers/common/octeontx2/otx2_mbox.h b/drivers/common/octeontx2/otx2_mbox.h index c2a9e9fe6..e0e4e2f63 100644 --- a/drivers/common/octeontx2/otx2_mbox.h +++ b/drivers/common/octeontx2/otx2_mbox.h @@ -723,6 +723,7 @@ struct nix_lf_alloc_rsp { uint8_t __otx2_io lf_tx_stats; /* NIX_AF_CONST1::LF_TX_STATS */ uint16_t __otx2_io cints; /* NIX_AF_CONST2::CINTS */ uint16_t __otx2_io qints; /* NIX_AF_CONST2::QINTS */ + uint8_t __otx2_io hw_rx_tstamp_en; /*set if rx timestamping enabled */ }; struct nix_lf_free_req { diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index aab34dbcf..9274dbb96 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -86,6 +86,7 @@ nix_lf_alloc(struct otx2_eth_dev *dev, uint32_t nb_rxq, uint32_t nb_txq) dev->cints = rsp->cints; dev->qints = rsp->qints; dev->npc_flow.channel = dev->rx_chan_base; + dev->ptp_en = rsp->hw_rx_tstamp_en; return 0; } @@ -1899,7 +1900,11 @@ otx2_nix_dev_start(struct rte_eth_dev *eth_dev) struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); int rc, i; - if (eth_dev->data->nb_rx_queues != 0) { + /* MTU recalculate should be avoided here if PTP is enabled by PF, as + * otx2_nix_recalc_mtu would be invoked during otx2_nix_ptp_enable_vf + * call below. + */ + if (eth_dev->data->nb_rx_queues != 0 && !otx2_ethdev_is_ptp_en(dev)) { rc = otx2_nix_recalc_mtu(eth_dev); if (rc) return rc; @@ -1935,6 +1940,12 @@ otx2_nix_dev_start(struct rte_eth_dev *eth_dev) else otx2_nix_timesync_disable(eth_dev); + /* Update VF about data off shifted by 8 bytes if PTP already + * enabled in PF owning this VF + */ + if (otx2_ethdev_is_ptp_en(dev) && otx2_dev_is_vf(dev)) + otx2_nix_ptp_enable_vf(eth_dev); + rc = npc_rx_enable(dev); if (rc) { otx2_err("Failed to enable NPC rx %d", rc); diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h index b49e309fd..d369d4dc5 100644 --- a/drivers/net/octeontx2/otx2_ethdev.h +++ b/drivers/net/octeontx2/otx2_ethdev.h @@ -562,5 +562,6 @@ int otx2_nix_timesync_read_time(struct rte_eth_dev *eth_dev, int otx2_eth_dev_ptp_info_update(struct otx2_dev *dev, bool ptp_en); int otx2_nix_read_clock(struct rte_eth_dev *eth_dev, uint64_t *time); int otx2_nix_raw_clock_tsc_conv(struct otx2_eth_dev *dev); +void otx2_nix_ptp_enable_vf(struct rte_eth_dev *eth_dev); #endif /* __OTX2_ETHDEV_H__ */ diff --git a/drivers/net/octeontx2/otx2_ethdev_ops.c b/drivers/net/octeontx2/otx2_ethdev_ops.c index d1e77c324..45b5c5185 100644 --- a/drivers/net/octeontx2/otx2_ethdev_ops.c +++ b/drivers/net/octeontx2/otx2_ethdev_ops.c @@ -16,6 +16,8 @@ otx2_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) struct nix_frs_cfg *req; int rc; + frame_size += NIX_TIMESYNC_RX_OFFSET * otx2_ethdev_is_ptp_en(dev); + /* Check if MTU is within the allowed range */ if (frame_size < NIX_MIN_FRS || frame_size > NIX_MAX_FRS) return -EINVAL; diff --git a/drivers/net/octeontx2/otx2_ptp.c b/drivers/net/octeontx2/otx2_ptp.c index f13f0408a..f34b9339c 100644 --- a/drivers/net/octeontx2/otx2_ptp.c +++ b/drivers/net/octeontx2/otx2_ptp.c @@ -8,6 +8,38 @@ #define PTP_FREQ_ADJUST (1 << 9) +/* Function to enable ptp config for VFs */ +void +otx2_nix_ptp_enable_vf(struct rte_eth_dev *eth_dev) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + + if (otx2_nix_recalc_mtu(eth_dev)) + otx2_err("Failed to set MTU size for ptp"); + + dev->scalar_ena = true; + dev->rx_offload_flags |= NIX_RX_OFFLOAD_TSTAMP_F; + + /* Setting up the function pointers as per new offload flags */ + otx2_eth_set_rx_function(eth_dev); + otx2_eth_set_tx_function(eth_dev); +} + +static uint16_t +nix_eth_ptp_vf_burst(void *queue, struct rte_mbuf **mbufs, uint16_t pkts) +{ + struct otx2_eth_rxq *rxq = queue; + struct rte_eth_dev *eth_dev; + + RTE_SET_USED(mbufs); + RTE_SET_USED(pkts); + + eth_dev = rxq->eth_dev; + otx2_nix_ptp_enable_vf(eth_dev); + + return 0; +} + static int nix_read_raw_clock(struct otx2_eth_dev *dev, uint64_t *clock, uint64_t *tsc, uint8_t is_pmu) @@ -104,7 +136,7 @@ nix_ptp_config(struct rte_eth_dev *eth_dev, int en) struct otx2_mbox *mbox = dev->mbox; uint8_t rc = -EINVAL; - if (otx2_dev_is_vf_or_sdp(dev)) + if (otx2_dev_is_vf_or_sdp(dev) || otx2_dev_is_lbk(dev)) return rc; if (en) { @@ -153,6 +185,17 @@ otx2_eth_dev_ptp_info_update(struct otx2_dev *dev, bool ptp_en) otx2_nix_rxq_mbuf_setup(otx2_dev, eth_dev->data->port_id); } + if (otx2_dev_is_vf(otx2_dev) && !(otx2_dev_is_sdp(otx2_dev)) && + !(otx2_dev_is_lbk(otx2_dev))) { + /* In case of VF, setting of MTU cant be done directly in this + * function as this is running as part of MBOX request(PF->VF) + * and MTU setting also requires MBOX message to be + * sent(VF->PF) + */ + eth_dev->rx_pkt_burst = nix_eth_ptp_vf_burst; + rte_mb(); + } + return 0; } @@ -162,14 +205,16 @@ otx2_nix_timesync_enable(struct rte_eth_dev *eth_dev) struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); int i, rc = 0; - if (otx2_ethdev_is_ptp_en(dev)) { - otx2_info("PTP mode is already enabled "); + /* If we are VF/SDP/LBK, ptp cannot not be enabled */ + if (otx2_dev_is_vf_or_sdp(dev) || otx2_dev_is_lbk(dev)) { + otx2_info("PTP cannot be enabled in case of VF/SDP/LBK"); return -EINVAL; } - /* If we are VF, no further action can be taken */ - if (otx2_dev_is_vf_or_sdp(dev)) + if (otx2_ethdev_is_ptp_en(dev)) { + otx2_info("PTP mode is already enabled"); return -EINVAL; + } if (!(dev->rx_offload_flags & NIX_RX_OFFLOAD_PTYPE_F)) { otx2_err("Ptype offload is disabled, it should be enabled"); @@ -207,6 +252,11 @@ otx2_nix_timesync_enable(struct rte_eth_dev *eth_dev) otx2_eth_set_rx_function(eth_dev); otx2_eth_set_tx_function(eth_dev); } + + rc = otx2_nix_recalc_mtu(eth_dev); + if (rc) + otx2_err("Failed to set MTU size for ptp"); + return rc; } @@ -221,8 +271,7 @@ otx2_nix_timesync_disable(struct rte_eth_dev *eth_dev) return -EINVAL; } - /* If we are VF, nothing else can be done */ - if (otx2_dev_is_vf_or_sdp(dev)) + if (otx2_dev_is_vf_or_sdp(dev) || otx2_dev_is_lbk(dev)) return -EINVAL; dev->rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP; @@ -240,6 +289,11 @@ otx2_nix_timesync_disable(struct rte_eth_dev *eth_dev) otx2_eth_set_rx_function(eth_dev); otx2_eth_set_tx_function(eth_dev); } + + rc = otx2_nix_recalc_mtu(eth_dev); + if (rc) + otx2_err("Failed to set MTU size for ptp"); + return rc; } diff --git a/drivers/net/octeontx2/otx2_rx.h b/drivers/net/octeontx2/otx2_rx.h index 1a1ac40bd..351ad0fcb 100644 --- a/drivers/net/octeontx2/otx2_rx.h +++ b/drivers/net/octeontx2/otx2_rx.h @@ -58,6 +58,8 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, (mbuf->data_off == RTE_PKTMBUF_HEADROOM + NIX_TIMESYNC_RX_OFFSET)) { + mbuf->pkt_len -= NIX_TIMESYNC_RX_OFFSET; + /* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. */