From patchwork Mon Apr 29 08:20:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 53138 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D64C21B3B7; Mon, 29 Apr 2019 10:20:43 +0200 (CEST) Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680048.outbound.protection.outlook.com [40.107.68.48]) by dpdk.org (Postfix) with ESMTP id 11B4F1B293; Mon, 29 Apr 2019 10:20:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector1-aquantia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZoxOdNKP1kKMjLphI+6qcIbD/gU7sU4AQtoaitJQP7E=; b=KkBKaS+Emgv90JeaArjqnA2D5EhGkMZ6UYT0YeQ5TaZmPvwe1N+W6AAx/wJXGfuI8P10mH1T0CKgkTYWN9dI7sCtxtVgGnT10GUNRAEBXGYmF6KLZrK50comeBelCyeg3BZh0q8tDq+zWPD9GK/M8IcflUOP39JOmbdzsx3vf0k= Received: from DM6PR11MB3625.namprd11.prod.outlook.com (20.178.230.149) by DM6PR11MB2841.namprd11.prod.outlook.com (20.176.100.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1835.13; Mon, 29 Apr 2019 08:20:23 +0000 Received: from DM6PR11MB3625.namprd11.prod.outlook.com ([fe80::f035:2c20:5a61:7653]) by DM6PR11MB3625.namprd11.prod.outlook.com ([fe80::f035:2c20:5a61:7653%3]) with mapi id 15.20.1835.010; Mon, 29 Apr 2019 08:20:23 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "stable@dpdk.org" Thread-Topic: [PATCH 08/11] net/atlantic: flow control settings synchronization on rx Thread-Index: AQHU/mRkdclvqqwRRkmP4e/LB8gyiw== Date: Mon, 29 Apr 2019 08:20:23 +0000 Message-ID: <78861b0be3a56a2e5d3996467e5eb05bcd395ea6.1556525874.git.igor.russkikh@aquantia.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1P190CA0016.EURP190.PROD.OUTLOOK.COM (2603:10a6:3:bc::26) To DM6PR11MB3625.namprd11.prod.outlook.com (2603:10b6:5:13a::21) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bd76f106-bfa9-422f-8c2e-08d6cc7b86a6 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:DM6PR11MB2841; x-ms-traffictypediagnostic: DM6PR11MB2841: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:61; x-forefront-prvs: 0022134A87 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(396003)(136003)(39840400004)(346002)(199004)(189003)(44832011)(99286004)(186003)(118296001)(478600001)(71200400001)(53936002)(6506007)(71190400001)(446003)(5660300002)(2351001)(14454004)(14444005)(486006)(66556008)(73956011)(66946007)(64756008)(66476007)(66446008)(386003)(52116002)(316002)(11346002)(2616005)(7736002)(476003)(72206003)(54906003)(305945005)(81166006)(1730700003)(2501003)(36756003)(76176011)(81156014)(6486002)(3846002)(66066001)(102836004)(6916009)(97736004)(8936002)(450100002)(86362001)(6116002)(6436002)(26005)(256004)(8676002)(50226002)(2906002)(25786009)(5640700003)(6512007)(68736007)(4326008)(83323001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR11MB2841; H:DM6PR11MB3625.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: nmHE2uS4Ou7CjbiZ60d/wp8Urj6OXjzqwmDCv44HshoCFMyxbQDW+2St+lxxrKI3ottybvi1Mx3jx/eL1zhKHTJ3YGNMGsjSjBC03dBFwUge8C4oEca+ecNDXyj7tRvqsfJw6IU//Qz/oDECgstzGryJA2hHFAakYaZ7yqstK7YfzGBbdwBMessDFRNhQEA3VaVbb30RsJcFggt7+3kyDojocfMN6+2MtBFc69P4siJOH8t68+zltsQTv3dRHdg7P1uXGyrp8borfcvaWO+ceEYaaliSQU666683EgmbJ+Zu2HJGMm9vBZK4vQcgRgtPdJmiMR6aTM07Hkwy3bFJf+uM+49cotS9W3eZ+JWC7715pa33Im4Naby/owFWqomZHwvxwQ6kEdCid4rgLirq7BdD5AUQreQJKrXGXsnwHvM= MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd76f106-bfa9-422f-8c2e-08d6cc7b86a6 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Apr 2019 08:20:23.4911 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2841 Subject: [dpdk-dev] [PATCH 08/11] net/atlantic: flow control settings synchronization on rx 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" From: Pavel Belous Driver should track negotiated PHY flow control settings during link state changes and update MAC level flow control configuration. Otherwise there could be unexpected pause frames generation which could lockup the datapath. Fixes: 4c1c8f76463f ("net/atlantic: add flow control configuration") cc: stable@dpdk.org Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- drivers/net/atlantic/atl_ethdev.c | 24 +++++++++++++++---- drivers/net/atlantic/atl_types.h | 1 + drivers/net/atlantic/hw_atl/hw_atl_b0.c | 6 +++++ drivers/net/atlantic/hw_atl/hw_atl_b0.h | 2 ++ .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 9 +++++++ 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 485ef159eb05..6cc8d198041e 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -1160,6 +1160,7 @@ atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused) { struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_eth_link link, old; + u32 fc = AQ_NIC_FC_OFF; int err = 0; link.link_status = ETH_LINK_DOWN; @@ -1194,6 +1195,15 @@ atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused) if (link.link_status == old.link_status) return -1; + /* Driver has to update flow control settings on RX block + * on any link event. + * We should query FW whether it negotiated FC. + */ + if (hw->aq_fw_ops->get_flow_control) { + hw->aq_fw_ops->get_flow_control(hw, &fc); + hw_atl_b0_set_fc(hw, fc, 0U); + } + if (rte_eal_alarm_set(1000 * 1000, atl_dev_delayed_handler, (void *)dev) < 0) PMD_DRV_LOG(ERR, "rte_eal_alarm_set fail"); @@ -1496,14 +1506,20 @@ static int atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) { struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + u32 fc = AQ_NIC_FC_OFF; + + if (hw->aq_fw_ops->get_flow_control == NULL) + return -ENOTSUP; + + hw->aq_fw_ops->get_flow_control(hw, &fc); - if (hw->aq_nic_cfg->flow_control == AQ_NIC_FC_OFF) + if (fc == AQ_NIC_FC_OFF) fc_conf->mode = RTE_FC_NONE; - else if (hw->aq_nic_cfg->flow_control & (AQ_NIC_FC_RX | AQ_NIC_FC_TX)) + else if (fc & (AQ_NIC_FC_RX | AQ_NIC_FC_TX)) fc_conf->mode = RTE_FC_FULL; - else if (hw->aq_nic_cfg->flow_control & AQ_NIC_FC_RX) + else if (fc & AQ_NIC_FC_RX) fc_conf->mode = RTE_FC_RX_PAUSE; - else if (hw->aq_nic_cfg->flow_control & AQ_NIC_FC_RX) + else if (fc & AQ_NIC_FC_RX) fc_conf->mode = RTE_FC_TX_PAUSE; return 0; diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h index 84a4776951db..19aaf37673cd 100644 --- a/drivers/net/atlantic/atl_types.h +++ b/drivers/net/atlantic/atl_types.h @@ -169,6 +169,7 @@ struct aq_fw_ops { int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate, u32 *supported_rates); + int (*get_flow_control)(struct aq_hw_s *self, u32 *fc); int (*set_flow_control)(struct aq_hw_s *self); int (*led_control)(struct aq_hw_s *self, u32 mode); diff --git a/drivers/net/atlantic/hw_atl/hw_atl_b0.c b/drivers/net/atlantic/hw_atl/hw_atl_b0.c index e525a8581e6f..a76268e923e6 100644 --- a/drivers/net/atlantic/hw_atl/hw_atl_b0.c +++ b/drivers/net/atlantic/hw_atl/hw_atl_b0.c @@ -26,6 +26,12 @@ int hw_atl_b0_hw_reset(struct aq_hw_s *self) return err; } +int hw_atl_b0_set_fc(struct aq_hw_s *self, u32 fc, u32 tc) +{ + hw_atl_rpb_rx_xoff_en_per_tc_set(self, !!(fc & AQ_NIC_FC_RX), tc); + return 0; +} + static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self) { u32 tc = 0U; diff --git a/drivers/net/atlantic/hw_atl/hw_atl_b0.h b/drivers/net/atlantic/hw_atl/hw_atl_b0.h index 06feb56c1620..d1ba2aceb390 100644 --- a/drivers/net/atlantic/hw_atl/hw_atl_b0.h +++ b/drivers/net/atlantic/hw_atl/hw_atl_b0.h @@ -11,6 +11,8 @@ int hw_atl_b0_hw_reset(struct aq_hw_s *self); int hw_atl_b0_hw_init(struct aq_hw_s *self, u8 *mac_addr); +int hw_atl_b0_set_fc(struct aq_hw_s *self, u32 fc, u32 tc); + int hw_atl_b0_hw_ring_tx_init(struct aq_hw_s *self, uint64_t base_addr, int index, int size, int cpu, int vec); int hw_atl_b0_hw_ring_rx_init(struct aq_hw_s *self, uint64_t base_addr, diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c index de4189441fad..e07ed5e3a8c9 100644 --- a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c +++ b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c @@ -473,7 +473,15 @@ static int aq_fw2x_get_eee_rate(struct aq_hw_s *self, u32 *rate, return err; } +static int aq_fw2x_get_flow_control(struct aq_hw_s *self, u32 *fc) +{ + u32 mpi_state = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR); + + *fc = ((mpi_state & BIT(CAPS_HI_PAUSE)) ? AQ_NIC_FC_RX : 0) | + ((mpi_state & BIT(CAPS_HI_ASYMMETRIC_PAUSE)) ? AQ_NIC_FC_TX : 0); + return 0; +} static int aq_fw2x_set_flow_control(struct aq_hw_s *self) { @@ -714,6 +722,7 @@ const struct aq_fw_ops aq_fw_2x_ops = { .get_cable_len = aq_fw2x_get_cable_len, .set_eee_rate = aq_fw2x_set_eee_rate, .get_eee_rate = aq_fw2x_get_eee_rate, + .get_flow_control = aq_fw2x_get_flow_control, .set_flow_control = aq_fw2x_set_flow_control, .led_control = aq_fw2x_led_control, .get_eeprom = aq_fw2x_get_eeprom,