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 3F49FA09F0; Wed, 16 Dec 2020 22:14:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 268B8C9E8; Wed, 16 Dec 2020 22:13:36 +0100 (CET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by dpdk.org (Postfix) with ESMTP id 00A87CA0E for ; Wed, 16 Dec 2020 22:13:31 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id f14so2195341pju.4 for ; Wed, 16 Dec 2020 13:13:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=kYLnHUD3svzutdwSn45+QKRtbE5B3RBjd4Qlgv7CvC8=; b=vGTD6NnM4IbQ3AWPzqLZ84bKSoVa/3sjYOzgfi0sCzl1vrPbfMG/F+cwQ4rcxLP9zs Pu27ed9L9FtuF+6LQhPQ6aWyAlK18f2/rkxByomYZeJ1yDxG42RU3WIdfzmYWKmL/o7N Dn07+A+I16vVhWRbfNBv5rRsNlOFIl/QCOGoVUu+hc1hnIuHVlvd8jBP7Liw/Udn10Hj Cg43LxNHdr4eXXncZh+oNdwf5AP3Ql7D1sH/zDv/x107qiJZstiWaJffDWoA/YsdQvxl R0b10Fj2AQ14qVomfqu4YAjBHaMcVJC4CJFlFfWUIuIpV31ZVU4iZaMXJI0T8bKSeVFl pd3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=kYLnHUD3svzutdwSn45+QKRtbE5B3RBjd4Qlgv7CvC8=; b=TG48As8ENsYKs2NxBQ89Ycb5uDBdQAfLqrg0MujYntEW9qBdjl2I87xgOHWKkty+wJ vkFZEDfJ+zft5Sqjrqj8mOylS2ipsrXoruo4t6CZN8buaeMH+KBb2MkOAN0z4vmJRIB8 bWGsnidweyqMsgZHOzdHCqpEQ+DM24sx5bSiKQ5iyrGbCBWrBwDM8IHa4GuBNAhdE3Qw iJGVKS66cgEg4kTrX0+P0Qt+JKSNobta8VmJcCJ5On9vhd3d962OYR4OfSJSAWs+XikW RnBHZDQb/9iexijW9KPNkIhhQeASXwy0OtVVk9tmQA21JMqciZu4K9OgiF1ckOhDs2F/ /p3w== X-Gm-Message-State: AOAM532AkdNmx7yDWtkqL2MjISXBWZTjiP+Wn7lktzndjaKyn7RxINQw 3KGsh7HGw00leurzlWtFIvp9/b7VRoi0mg== X-Google-Smtp-Source: ABdhPJzscfbx2fTfs3izZMlLUU3mPCVo6ESir25D56lnd18a0dqT8BgBzkFHqzsvN+CgEb6nU254UA== X-Received: by 2002:a17:90a:b395:: with SMTP id e21mr4647815pjr.197.1608153210946; Wed, 16 Dec 2020 13:13:30 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id r67sm3345614pfc.82.2020.12.16.13.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Dec 2020 13:13:30 -0800 (PST) From: Andrew Boyer To: dev@dpdk.org Cc: Alfredo Cardigliano , Andrew Boyer Date: Wed, 16 Dec 2020 13:12:55 -0800 Message-Id: <20201216211257.37195-6-aboyer@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201216211257.37195-1-aboyer@pensando.io> References: <20201216211257.37195-1-aboyer@pensando.io> In-Reply-To: <20201210142231.63209-1-aboyer@pensando.io> References: <20201210142231.63209-1-aboyer@pensando.io> Subject: [dpdk-dev] [PATCH v2 5/7] net/ionic: improve link state handling 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" Add UP and FW_RESET state flags. Update the stack info when the link state changes. Convert set_link_up/set_link_down to lif_start/lif_stop. Condition reported link state on UP flag. Signed-off-by: Andrew Boyer --- drivers/net/ionic/ionic_ethdev.c | 49 ++++++++++--------------------- drivers/net/ionic/ionic_ethdev.h | 4 +++ drivers/net/ionic/ionic_lif.c | 50 ++++++++++++++++++++++++++------ drivers/net/ionic/ionic_lif.h | 4 ++- 4 files changed, 64 insertions(+), 43 deletions(-) diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c index 7ab32a0d7..fd7cd510e 100644 --- a/drivers/net/ionic/ionic_ethdev.c +++ b/drivers/net/ionic/ionic_ethdev.c @@ -28,8 +28,6 @@ static int ionic_dev_stop(struct rte_eth_dev *dev); static int ionic_dev_close(struct rte_eth_dev *dev); static int ionic_dev_set_link_up(struct rte_eth_dev *dev); static int ionic_dev_set_link_down(struct rte_eth_dev *dev); -static int ionic_dev_link_update(struct rte_eth_dev *eth_dev, - int wait_to_complete); static int ionic_flow_ctrl_get(struct rte_eth_dev *eth_dev, struct rte_eth_fc_conf *fc_conf); static int ionic_flow_ctrl_set(struct rte_eth_dev *eth_dev, @@ -236,21 +234,17 @@ static int ionic_dev_set_link_up(struct rte_eth_dev *eth_dev) { struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); - struct ionic_adapter *adapter = lif->adapter; - struct ionic_dev *idev = &adapter->idev; int err; IONIC_PRINT_CALL(); - ionic_dev_cmd_port_state(idev, IONIC_PORT_ADMIN_STATE_UP); + err = ionic_lif_start(lif); + if (err) + IONIC_PRINT(ERR, "Could not start lif to set link up"); - err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT); - if (err) { - IONIC_PRINT(WARNING, "Failed to bring port UP"); - return err; - } + ionic_dev_link_update(lif->eth_dev, 0); - return 0; + return err; } /* @@ -260,24 +254,17 @@ static int ionic_dev_set_link_down(struct rte_eth_dev *eth_dev) { struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); - struct ionic_adapter *adapter = lif->adapter; - struct ionic_dev *idev = &adapter->idev; - int err; IONIC_PRINT_CALL(); - ionic_dev_cmd_port_state(idev, IONIC_PORT_ADMIN_STATE_DOWN); + ionic_lif_stop(lif); - err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT); - if (err) { - IONIC_PRINT(WARNING, "Failed to bring port DOWN"); - return err; - } + ionic_dev_link_update(lif->eth_dev, 0); return 0; } -static int +int ionic_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete __rte_unused) { @@ -291,7 +278,8 @@ ionic_dev_link_update(struct rte_eth_dev *eth_dev, memset(&link, 0, sizeof(link)); link.link_autoneg = ETH_LINK_AUTONEG; - if (!adapter->link_up) { + if (!adapter->link_up || + !(lif->state & IONIC_LIF_F_UP)) { /* Interface is down */ link.link_status = ETH_LINK_DOWN; link.link_duplex = ETH_LINK_HALF_DUPLEX; @@ -944,15 +932,12 @@ static int ionic_dev_stop(struct rte_eth_dev *eth_dev) { struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); - int err; IONIC_PRINT_CALL(); - err = ionic_lif_stop(lif); - if (err) - IONIC_PRINT(ERR, "Cannot stop LIF: %d", err); + ionic_lif_stop(lif); - return err; + return 0; } static void ionic_unconfigure_intr(struct ionic_adapter *adapter); @@ -965,17 +950,12 @@ ionic_dev_close(struct rte_eth_dev *eth_dev) { struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); struct ionic_adapter *adapter = lif->adapter; - int err; IONIC_PRINT_CALL(); if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - err = ionic_lif_stop(lif); - if (err) { - IONIC_PRINT(ERR, "Cannot stop LIF: %d", err); - return -1; - } + ionic_lif_stop(lif); ionic_lif_free_queues(lif); @@ -1076,6 +1056,9 @@ eth_ionic_dev_uninit(struct rte_eth_dev *eth_dev) ionic_lif_deinit(lif); ionic_lif_free(lif); + if (!(lif->state & IONIC_LIF_F_FW_RESET)) + ionic_lif_reset(lif); + return 0; } diff --git a/drivers/net/ionic/ionic_ethdev.h b/drivers/net/ionic/ionic_ethdev.h index 578e2301f..6cbcd0f82 100644 --- a/drivers/net/ionic/ionic_ethdev.h +++ b/drivers/net/ionic/ionic_ethdev.h @@ -5,6 +5,8 @@ #ifndef _IONIC_ETHDEV_H_ #define _IONIC_ETHDEV_H_ +#include + #define IONIC_ETH_RSS_OFFLOAD_ALL ( \ ETH_RSS_IPV4 | \ ETH_RSS_NONFRAG_IPV4_TCP | \ @@ -18,5 +20,7 @@ #define IONIC_ETH_DEV_TO_ADAPTER(eth_dev) \ (IONIC_ETH_DEV_TO_LIF(eth_dev)->adapter) +int ionic_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete); + #endif /* _IONIC_ETHDEV_H_ */ diff --git a/drivers/net/ionic/ionic_lif.c b/drivers/net/ionic/ionic_lif.c index 9b11e6310..c1a95ca7c 100644 --- a/drivers/net/ionic/ionic_lif.c +++ b/drivers/net/ionic/ionic_lif.c @@ -63,12 +63,12 @@ ionic_qcq_disable(struct ionic_qcq *qcq) return ionic_adminq_post_wait(lif, &ctx); } -int -ionic_lif_stop(struct ionic_lif *lif __rte_unused) +void +ionic_lif_stop(struct ionic_lif *lif) { - /* Carrier OFF here */ + IONIC_PRINT_CALL(); - return 0; + lif->state &= ~IONIC_LIF_F_UP; } void @@ -1098,14 +1098,32 @@ ionic_link_status_check(struct ionic_lif *lif) return; if (link_up) { - IONIC_PRINT(DEBUG, "Link up - %d Gbps", - lif->info->status.link_speed); adapter->link_speed = lif->info->status.link_speed; + IONIC_PRINT(DEBUG, "Link up - %d Gbps", + adapter->link_speed); } else { IONIC_PRINT(DEBUG, "Link down"); } adapter->link_up = link_up; + ionic_dev_link_update(lif->eth_dev, 0); +} + +static void +ionic_lif_handle_fw_down(struct ionic_lif *lif) +{ + if (lif->state & IONIC_LIF_F_FW_RESET) + return; + + lif->state |= IONIC_LIF_F_FW_RESET; + + if (lif->state & IONIC_LIF_F_UP) { + IONIC_PRINT(NOTICE, + "Surprise FW stop, stopping %s\n", lif->name); + ionic_lif_stop(lif); + } + + IONIC_PRINT(NOTICE, "FW down, %s stopped", lif->name); } static bool @@ -1127,14 +1145,27 @@ ionic_notifyq_cb(struct ionic_cq *cq, uint32_t cq_desc_index, void *cb_arg) switch (cq_desc->event.ecode) { case IONIC_EVENT_LINK_CHANGE: IONIC_PRINT(DEBUG, - "Notifyq IONIC_EVENT_LINK_CHANGE eid=%jd link_status=%d link_speed=%d", + "Notifyq IONIC_EVENT_LINK_CHANGE %s " + "eid=%jd link_status=%d link_speed=%d", + lif->name, cq_desc->event.eid, cq_desc->link_change.link_status, cq_desc->link_change.link_speed); lif->state |= IONIC_LIF_F_LINK_CHECK_NEEDED; + break; + case IONIC_EVENT_RESET: + IONIC_PRINT(NOTICE, + "Notifyq IONIC_EVENT_RESET %s " + "eid=%jd, reset_code=%d state=%d", + lif->name, + cq_desc->event.eid, + cq_desc->reset.reset_code, + cq_desc->reset.state); + ionic_lif_handle_fw_down(lif); break; + default: IONIC_PRINT(WARNING, "Notifyq bad event ecode=%d eid=%jd", cq_desc->event.ecode, cq_desc->event.eid); @@ -1618,9 +1649,10 @@ ionic_lif_start(struct ionic_lif *lif) } } - ionic_link_status_check(lif); - /* Carrier ON here */ + lif->state |= IONIC_LIF_F_UP; + + ionic_link_status_check(lif); return 0; } diff --git a/drivers/net/ionic/ionic_lif.h b/drivers/net/ionic/ionic_lif.h index cc0e4f04e..86d933606 100644 --- a/drivers/net/ionic/ionic_lif.h +++ b/drivers/net/ionic/ionic_lif.h @@ -77,6 +77,8 @@ struct ionic_qcq { #define IONIC_LIF_F_INITED BIT(0) #define IONIC_LIF_F_LINK_CHECK_NEEDED BIT(1) +#define IONIC_LIF_F_UP BIT(2) +#define IONIC_LIF_F_FW_RESET BIT(3) #define IONIC_LIF_NAME_MAX_SZ (32) @@ -127,7 +129,7 @@ int ionic_lif_init(struct ionic_lif *lif); void ionic_lif_deinit(struct ionic_lif *lif); int ionic_lif_start(struct ionic_lif *lif); -int ionic_lif_stop(struct ionic_lif *lif); +void ionic_lif_stop(struct ionic_lif *lif); int ionic_lif_configure(struct ionic_lif *lif); void ionic_lif_reset(struct ionic_lif *lif); -- 2.17.1