From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49775C3A59E for ; Tue, 3 Sep 2019 02:34:26 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id C618E217D7 for ; Tue, 3 Sep 2019 02:34:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C618E217D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 736631EB26; Tue, 3 Sep 2019 04:34:24 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id B62C93423 for ; Tue, 3 Sep 2019 04:34:22 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Sep 2019 19:34:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,461,1559545200"; d="scan'208";a="181994470" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga008.fm.intel.com with ESMTP; 02 Sep 2019 19:34:20 -0700 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 2 Sep 2019 19:34:20 -0700 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 2 Sep 2019 19:34:20 -0700 Received: from shsmsx105.ccr.corp.intel.com ([169.254.11.23]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.235]) with mapi id 14.03.0439.000; Tue, 3 Sep 2019 10:34:17 +0800 From: "Pei, Andy" To: "Ye, Xiaolong" CC: "dev@dpdk.org" , "Zhang, Qi Z" , "Yigit, Ferruh" , "Xu, Rosen" Thread-Topic: [PATCH v3] net/ipn3ke: setup MTU when HW init Thread-Index: AQHVYXBfdnbAWHH9C0G9v0Hw5FV8CKcZPDrw Date: Tue, 3 Sep 2019 02:34:17 +0000 Message-ID: <5941F446C088714A85408FA3132CFCBB0106BF60@SHSMSX105.ccr.corp.intel.com> References: <1565280090-344032-1-git-send-email-andy.pei@intel.com> <1567392847-445709-1-git-send-email-andy.pei@intel.com> <20190902092341.GD1665@intel.com> In-Reply-To: <20190902092341.GD1665@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] net/ipn3ke: setup MTU when HW init 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" HI Xiaolong, Reply inline. -----Original Message----- From: Ye, Xiaolong=20 Sent: Monday, September 2, 2019 5:24 PM To: Pei, Andy Cc: dev@dpdk.org; Zhang, Qi Z ; Yigit, Ferruh ; Xu, Rosen Subject: Re: [PATCH v3] net/ipn3ke: setup MTU when HW init Hi, Andy On 09/02, Andy Pei wrote: >set up mtu to the minimun in tx mtu, rx mtu and IPN3KE_MAC_FRAME_SIZE_MAX. > >Signed-off-by: Andy Pei >--- >Cc: qi.z.zhang@intel.com >Cc: ferruh.yigit@intel.com >Cc: rosen.xu@intel.com >Cc: xiaolong.ye@intel.com > >v2: >modify low bound and upper bound. > >v3: >modify according to community comments. Better to put more details about your changes other than the vague descript= ion. OK > > drivers/net/ipn3ke/ipn3ke_ethdev.c | 109=20 > +++++++++++++++++++++++++++++++++++++ > drivers/net/ipn3ke/ipn3ke_ethdev.h | 15 +++++ > 2 files changed, 124 insertions(+) > >diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c=20 >b/drivers/net/ipn3ke/ipn3ke_ethdev.c >index c226d63..711d48e 100644 >--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c >+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c >@@ -209,6 +209,112 @@ > return 0; > } >=20 >+static uint32_t >+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx) { >+ uint32_t tmp; >+ tmp =3D RTE_MIN(tx, rx); >+ if (tmp < RTE_ETHER_MIN_MTU) >+ tmp =3D RTE_ETHER_MIN_MTU; tmp =3D RTE_MAX(tmp, RTE_ETHER_MIN_MTU); >+ if (tmp > IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD) >+ tmp =3D IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD; tmp =3D RTE_MIN(tmp, IPN3KE_MAC_FRAME_SIZE_MAX - IPN3KE_ETH_OVERHEAD); =09 in the definition of TRE_MIN and TRE_MAX, typeof() is used. RTE_ETHER_MIN_MTU is MACRO, your expression cause complie issue. >+ return tmp; >+} >+ >+static void >+ipn3ke_10G_mtu_setup >+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel) { >+ uint32_t tx; >+ uint32_t rx; >+ uint32_t tmp; >+ >+ if (!(*hw->f_mac_read) || !(*hw->f_mac_write)) >+ return; >+ >+ (*hw->f_mac_read)(hw, >+ &tx, >+ IPN3KE_10G_TX_FRAME_MAXLENGTH, >+ mac_num, >+ eth_group_sel); >+ >+ (*hw->f_mac_read)(hw, >+ &rx, >+ IPN3KE_10G_RX_FRAME_MAXLENGTH, >+ mac_num, >+ eth_group_sel); >+ >+ tmp =3D ipn3ke_mtu_cal(tx, rx); >+ >+ (*hw->f_mac_write)(hw, >+ tmp, >+ IPN3KE_10G_TX_FRAME_MAXLENGTH, >+ mac_num, >+ eth_group_sel); >+ >+ (*hw->f_mac_write)(hw, >+ tmp, >+ IPN3KE_10G_RX_FRAME_MAXLENGTH, >+ mac_num, >+ eth_group_sel); >+} >+ >+static void >+ipn3ke_25G_mtu_setup >+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel) { >+ uint32_t tx; >+ uint32_t rx; >+ uint32_t tmp; >+ >+ if (!(*hw->f_mac_read) || !(*hw->f_mac_write)) >+ return; >+ >+ (*hw->f_mac_read)(hw, >+ &tx, >+ IPN3KE_25G_MAX_TX_SIZE_CONFIG, >+ mac_num, >+ eth_group_sel); >+ >+ (*hw->f_mac_read)(hw, >+ &rx, >+ IPN3KE_25G_MAX_RX_SIZE_CONFIG, >+ mac_num, >+ eth_group_sel); >+ >+ tmp =3D ipn3ke_mtu_cal(tx, rx); >+ >+ (*hw->f_mac_write)(hw, >+ tmp, >+ IPN3KE_25G_MAX_TX_SIZE_CONFIG, >+ mac_num, >+ eth_group_sel); >+ >+ (*hw->f_mac_write)(hw, >+ tmp, >+ IPN3KE_25G_MAX_RX_SIZE_CONFIG, >+ mac_num, >+ eth_group_sel); >+} Above 2 functions still share lots of duplicated code, can you extract the = duplicated code to a common function? OK >+ >+static void >+ipn3ke_mtu_setup(struct ipn3ke_hw *hw) { >+ int i; >+ if (hw->retimer.mac_type =3D=3D IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) = { >+ for (i =3D 0; i < hw->port_num; i++) { >+ ipn3ke_10G_mtu_setup(hw, i, 0); >+ ipn3ke_10G_mtu_setup(hw, i, 1); >+ } >+ } else if (hw->retimer.mac_type =3D=3D >+ IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) { >+ for (i =3D 0; i < hw->port_num; i++) { >+ ipn3ke_25G_mtu_setup(hw, i, 0); >+ ipn3ke_25G_mtu_setup(hw, i, 1); >+ } >+ } >+} >+ > static int > ipn3ke_hw_init(struct rte_afu_device *afu_dev, > struct ipn3ke_hw *hw) >@@ -303,6 +409,9 @@ > } > } >=20 >+ /* init mtu */ >+ ipn3ke_mtu_setup(hw); >+ > ret =3D rte_eth_switch_domain_alloc(&hw->switch_domain_id); > if (ret) > IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device=20 >%d", diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h=20 >b/drivers/net/ipn3ke/ipn3ke_ethdev.h >index c7b336b..596df08 100644 >--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h >+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h >@@ -654,6 +654,21 @@ static inline void _ipn3ke_indrct_write(struct=20 >ipn3ke_hw *hw, #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \ > IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT) >=20 >+/* Additional Feature Register */ >+#define ADD_PHY_CTRL 0x0 >+#define PHY_RESET BIT(0) >+/* registers for 25G/40G mac */ >+#define MAC_CONFIG 0x310 >+#define MAC_RESET_MASK GENMASK(2, 0) >+ >+#define IPN3KE_MAX_MTU 0xff= ff >+ >+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG 0x40= 7 >+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG 0x50= 6 >+ >+#define IPN3KE_10G_TX_FRAME_MAXLENGTH 0x00= 2C >+#define IPN3KE_10G_RX_FRAME_MAXLENGTH 0x00= AE >+ It's better to remove unused MACROs here to make the patch clean. OK Thanks, Xiaolong > #define IPN3KE_REGISTER_WIDTH 32 >=20 > /*Bits[2:0]: Configuration of TX statistics counters: >-- >1.8.3.1 >