From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9D80FA2E1B for ; Tue, 3 Sep 2019 15:33:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 77C131E8F3; Tue, 3 Sep 2019 15:33:48 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id B022C1BF21 for ; Tue, 3 Sep 2019 15:33:46 +0200 (CEST) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2019 06:33:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,463,1559545200"; d="scan'208";a="266290828" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.5]) by orsmga001.jf.intel.com with ESMTP; 03 Sep 2019 06:33:44 -0700 Date: Tue, 3 Sep 2019 21:31:52 +0800 From: Ye Xiaolong To: Andy Pei Cc: dev@dpdk.org, qi.z.zhang@intel.com, ferruh.yigit@intel.com, rosen.xu@intel.com Message-ID: <20190903133152.GA19294@intel.com> References: <1567392847-445709-1-git-send-email-andy.pei@intel.com> <1567500378-89175-1-git-send-email-andy.pei@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1567500378-89175-1-git-send-email-andy.pei@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v4] 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" On 09/03, 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: >delete unnecessary MACROs. >extract the duplicated code to a common function. > >v4: >delete unnecessary MACROs. >extract the duplicated code to a common function. > > drivers/net/ipn3ke/ipn3ke_ethdev.c | 87 ++++++++++++++++++++++++++++++++++++++ > drivers/net/ipn3ke/ipn3ke_ethdev.h | 6 +++ > 2 files changed, 93 insertions(+) > >diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c >index c226d63..e619ba3 100644 >--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c >+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c >@@ -209,6 +209,90 @@ > return 0; > } > >+static uint32_t >+ipn3ke_mtu_cal(uint32_t tx, uint32_t rx) >+{ >+ uint32_t tmp; >+ tmp = RTE_MIN(tx, rx); >+ tmp = RTE_MAX(tmp, (uint32_t)RTE_ETHER_MIN_MTU); >+ tmp = RTE_MIN(tmp, (uint32_t)(IPN3KE_MAC_FRAME_SIZE_MAX - >+ IPN3KE_ETH_OVERHEAD)); >+ return tmp; >+} >+ >+static void >+ipn3ke_mtu_set >+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel, >+uint32_t txaddr, uint32_t rxaddr) It's quite rare to start the arguments in a separate line, better to follow the common convention like static void rte_eth_dev_config_restore(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info, uint16_t port_id) Thanks, Xiaolong >+{ >+ 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, >+ txaddr, >+ mac_num, >+ eth_group_sel); >+ >+ (*hw->f_mac_read)(hw, >+ &rx, >+ rxaddr, >+ mac_num, >+ eth_group_sel); >+ >+ tmp = ipn3ke_mtu_cal(tx, rx); >+ >+ (*hw->f_mac_write)(hw, >+ tmp, >+ txaddr, >+ mac_num, >+ eth_group_sel); >+ >+ (*hw->f_mac_write)(hw, >+ tmp, >+ rxaddr, >+ mac_num, >+ eth_group_sel); >+} >+ >+static void >+ipn3ke_10G_mtu_setup >+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel) >+{ >+ ipn3ke_mtu_set(hw, mac_num, eth_group_sel, >+ IPN3KE_10G_TX_FRAME_MAXLENGTH, IPN3KE_10G_RX_FRAME_MAXLENGTH); >+} >+ >+static void >+ipn3ke_25G_mtu_setup >+(struct ipn3ke_hw *hw, uint32_t mac_num, uint32_t eth_group_sel) >+{ >+ ipn3ke_mtu_set(hw, mac_num, eth_group_sel, >+ IPN3KE_25G_MAX_TX_SIZE_CONFIG, IPN3KE_25G_MAX_RX_SIZE_CONFIG); >+} >+ >+static void >+ipn3ke_mtu_setup(struct ipn3ke_hw *hw) >+{ >+ int i; >+ if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) { >+ for (i = 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 == >+ IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) { >+ for (i = 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 +387,9 @@ > } > } > >+ /* init mtu */ >+ ipn3ke_mtu_setup(hw); >+ > ret = rte_eth_switch_domain_alloc(&hw->switch_domain_id); > if (ret) > IPN3KE_AFU_PMD_WARN("failed to allocate switch domain for device %d", >diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.h b/drivers/net/ipn3ke/ipn3ke_ethdev.h >index c7b336b..fc45826 100644 >--- a/drivers/net/ipn3ke/ipn3ke_ethdev.h >+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.h >@@ -654,6 +654,12 @@ static inline void _ipn3ke_indrct_write(struct ipn3ke_hw *hw, > #define IPN3KE_MAC_RX_FRAME_MAXLENGTH_MASK \ > IPN3KE_MASK(0xFFFF, IPN3KE_MAC_RX_FRAME_MAXLENGTH_SHIFT) > >+#define IPN3KE_25G_MAX_TX_SIZE_CONFIG 0x407 >+#define IPN3KE_25G_MAX_RX_SIZE_CONFIG 0x506 >+ >+#define IPN3KE_10G_TX_FRAME_MAXLENGTH 0x002C >+#define IPN3KE_10G_RX_FRAME_MAXLENGTH 0x00AE >+ > #define IPN3KE_REGISTER_WIDTH 32 > > /*Bits[2:0]: Configuration of TX statistics counters: >-- >1.8.3.1 >