From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A5C6AA054F; Tue, 16 Mar 2021 11:52:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE94C24284F; Tue, 16 Mar 2021 11:51:57 +0100 (CET) Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) by mails.dpdk.org (Postfix) with ESMTP id 2CA80242845 for ; Tue, 16 Mar 2021 11:51:55 +0100 (CET) X-QQ-mid: bizesmtp11t1615891909t0dpoqsp Received: from wxdbg.localdomain.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Tue, 16 Mar 2021 18:51:49 +0800 (CST) X-QQ-SSF: 01400000002000C0E000B00A0000000 X-QQ-FEAT: CmekkwahvI8qBFqJ+qUlOnYWuVnekKH6+7GQx3ZGOforHwAsOjvwgf0Un+VPH lDdMNMNkf7fk08+1KBUgrM4AQEOTDCx/oTgPI48mnEM6840DMJ4kJAerdVKyG6F+Erlb8S6 iVizRjAY2wxeAxQqSDBLMLbQbF8kBrZzK0i/60b2a1XZLowBCDnhyCHap5WKQErBnS40r82 IK6Kh9tt9OlDG5ABwQGRUaaEUk3vfFQV/mn9t/FsPpzhUASCh79gs6yns4xJOe/b9FNFKml OrIVEupasnQ4y4Sx5mxWObhdw7y1cTKJ9sVaiYyRRNJJsC7nREjCdCRmtAOpkKv+0ikFiVM Xz8WeRs4PPJG4ntLROBhKnoURIWbA== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Tue, 16 Mar 2021 18:51:44 +0800 Message-Id: <20210316105149.110904-3-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210316105149.110904-1-jiawenwu@trustnetic.com> References: <20210316105149.110904-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v2 2/7] net/txgbe: add device arguments X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Add device arguments to support runtime options. These arguments are only set for backplane NICs. Signed-off-by: Jiawen Wu --- doc/guides/nics/txgbe.rst | 50 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_type.h | 36 ++++++++++++++++ drivers/net/txgbe/txgbe_ethdev.c | 67 +++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+) diff --git a/doc/guides/nics/txgbe.rst b/doc/guides/nics/txgbe.rst index e520f13f3..f56993c45 100644 --- a/doc/guides/nics/txgbe.rst +++ b/doc/guides/nics/txgbe.rst @@ -84,6 +84,56 @@ TXGBE PMD provides the following log types available for control: Extra logging of the messages during PMD initialization. +Runtime Options +~~~~~~~~~~~~~~~ + +The following ``devargs`` options can be enabled at runtime. They must +be passed as part of EAL arguments. For example, + +.. code-block:: console + + dpdk-testpmd -a 01:00.0,auto=1 -- -i + +Please note that following ``devargs`` are only set for backplane NICs. + +- ``auto`` (default **1**) + + Toggle behavior to use auto-negotiation mode or force mode to + link up backplane NICs. + +- ``poll`` (default **0**) + + Toggle behavior to enable/disable polling mode to receive AN interrupt. + +- ``present`` (default **1**) + + Toggle behavior to use present mode or init mode. + +- ``sgmii`` (default **0**) + + Special treatment for KX SGMII cards. + +- ``ffe_set`` (default **0**) + + Use to set PHY link mode and enable FFE parameters for user debugging. + If disabled, the FFE parameters will not take effect. Otherwise, set 1 + for SFI mode, set 2 for KR mode, set 3 for KX4 mode, set 4 for KX mode. + +- ``ffe_main`` (default **27**) + + PHY parameter used for user debugging. Setting other values to + take effect requires setting the ``ffe_set``. + +- ``ffe_pre`` (default **8**) + + PHY parameter used for user debugging. Setting other values to + take effect requires setting the ``ffe_set``. + +- ``ffe_post`` (default **44**) + + PHY parameter used for user debugging. Setting other values to + take effect requires setting the ``ffe_set``. + Driver compilation and testing ------------------------------ diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h index 2c8a3866a..008fcb25b 100644 --- a/drivers/net/txgbe/base/txgbe_type.h +++ b/drivers/net/txgbe/base/txgbe_type.h @@ -682,6 +682,33 @@ struct txgbe_phy_info { bool qsfp_shared_i2c_bus; u32 nw_mng_if_sel; u32 link_mode; + + /* Some features need tri-state capability */ + u16 ffe_set; + u16 ffe_main; + u16 ffe_pre; + u16 ffe_post; +}; + +#define TXGBE_DEVARG_BP_AUTO "auto" +#define TXGBE_DEVARG_KR_POLL "poll" +#define TXGBE_DEVARG_KR_PRESENT "present" +#define TXGBE_DEVARG_KX_SGMII "sgmii" +#define TXGBE_DEVARG_FFE_SET "ffe_set" +#define TXGBE_DEVARG_FFE_MAIN "ffe_main" +#define TXGBE_DEVARG_FFE_PRE "ffe_pre" +#define TXGBE_DEVARG_FFE_POST "ffe_post" + +static const char * const txgbe_valid_arguments[] = { + TXGBE_DEVARG_BP_AUTO, + TXGBE_DEVARG_KR_POLL, + TXGBE_DEVARG_KR_PRESENT, + TXGBE_DEVARG_KX_SGMII, + TXGBE_DEVARG_FFE_SET, + TXGBE_DEVARG_FFE_MAIN, + TXGBE_DEVARG_FFE_PRE, + TXGBE_DEVARG_FFE_POST, + NULL }; struct txgbe_mbx_stats { @@ -720,6 +747,14 @@ enum txgbe_isb_idx { TXGBE_ISB_MAX }; +struct txgbe_devargs { + u16 bp_log; + u16 auto_neg; + u16 poll; + u16 present; + u16 sgmii; +}; + struct txgbe_hw { void IOMEM *hw_addr; void *back; @@ -741,6 +776,7 @@ struct txgbe_hw { int api_version; bool allow_unsupported_sfp; bool need_crosstalk_fix; + struct txgbe_devargs devarg; uint64_t isb_dma; void IOMEM *isb_mem; diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index e3c0c5d42..cc7270a1c 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "txgbe_logs.h" #include "base/txgbe.h" @@ -469,6 +470,71 @@ txgbe_swfw_lock_reset(struct txgbe_hw *hw) hw->mac.release_swfw_sync(hw, mask); } +static int +txgbe_handle_devarg(__rte_unused const char *key, const char *value, + void *extra_args) +{ + uint16_t *n = extra_args; + + if (value == NULL || extra_args == NULL) + return -EINVAL; + + *n = (uint16_t)strtoul(value, NULL, 10); + if (*n == USHRT_MAX && errno == ERANGE) + return -1; + + return 0; +} + +static void +txgbe_parse_devargs(struct txgbe_hw *hw, struct rte_devargs *devargs) +{ + struct rte_kvargs *kvlist; + u16 auto_neg = 1; + u16 poll = 0; + u16 present = 1; + u16 sgmii = 0; + u16 ffe_set = 0; + u16 ffe_main = 27; + u16 ffe_pre = 8; + u16 ffe_post = 44; + + if (devargs == NULL) + goto null; + + kvlist = rte_kvargs_parse(devargs->args, txgbe_valid_arguments); + if (kvlist == NULL) + goto null; + + rte_kvargs_process(kvlist, TXGBE_DEVARG_BP_AUTO, + &txgbe_handle_devarg, &auto_neg); + rte_kvargs_process(kvlist, TXGBE_DEVARG_KR_POLL, + &txgbe_handle_devarg, &poll); + rte_kvargs_process(kvlist, TXGBE_DEVARG_KR_PRESENT, + &txgbe_handle_devarg, &present); + rte_kvargs_process(kvlist, TXGBE_DEVARG_KX_SGMII, + &txgbe_handle_devarg, &sgmii); + rte_kvargs_process(kvlist, TXGBE_DEVARG_FFE_SET, + &txgbe_handle_devarg, &ffe_set); + rte_kvargs_process(kvlist, TXGBE_DEVARG_FFE_MAIN, + &txgbe_handle_devarg, &ffe_main); + rte_kvargs_process(kvlist, TXGBE_DEVARG_FFE_PRE, + &txgbe_handle_devarg, &ffe_pre); + rte_kvargs_process(kvlist, TXGBE_DEVARG_FFE_POST, + &txgbe_handle_devarg, &ffe_post); + rte_kvargs_free(kvlist); + +null: + hw->devarg.auto_neg = auto_neg; + hw->devarg.poll = poll; + hw->devarg.present = present; + hw->devarg.sgmii = sgmii; + hw->phy.ffe_set = ffe_set; + hw->phy.ffe_main = ffe_main; + hw->phy.ffe_pre = ffe_pre; + hw->phy.ffe_post = ffe_post; +} + static int eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) { @@ -537,6 +603,7 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) hw->isb_dma = TMZ_PADDR(mz); hw->isb_mem = TMZ_VADDR(mz); + txgbe_parse_devargs(hw, pci_dev->device.devargs); /* Initialize the shared code (base driver) */ err = txgbe_init_shared_code(hw); if (err != 0) { -- 2.27.0