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 C57C54378F; Tue, 26 Dec 2023 03:39:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7B6FB40A73; Tue, 26 Dec 2023 03:38:34 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2100.outbound.protection.outlook.com [40.107.236.100]) by mails.dpdk.org (Postfix) with ESMTP id 3577F406BC for ; Tue, 26 Dec 2023 03:38:31 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AYD5kjrL6C/8IJfhrSv9B5evXg5NQ03n3/Rj5vO//Yh1osYrRZmuClPwMV6mmGybSRS5C/cD6N4wfs2wrAaNMuxl/NbVrVHwzHgKRRtXjeXT2LmD10P6jBoMIKlnbNAbuiptvOgFQx6KFl0iTKhOZz+XobAyoER5p7PXlsx3L0OhvEc1Q8hp72lXnoh0E6OQsUVTHSGSk77sz+GtiqWbygogvh9lvwryKN1jiMVFHWtj/R4A0h4v8tkbIawYiGZnM7c0pKoW7WnQrETKgT3kKc9GbXCFFPCzx7xoEe/jxbeJcUGlaA9w+/xs+ALlEfMZC/fM7A0fWYFrqIWtb345YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JqJWczxxhZ2kYqddH+H41qlw9vxD3+Ylz/4Gr3TlxOY=; b=IT4VDYZ5weWcj6TtlX+e0X+jSwNPi+KxDkLzCFJ0QaaariLtS8oZX1d842XulBrK5PRkg8uEciEBu1hSH7paDP7uXDg9z7okEGkop2YEhsY00SNAjIMbfMEBcwY9uejNNd5xChvA41+dLKzBYh7rp+QywOOj9O93VmsxKnax1D9lWITqz9B8O4M8+UwCmiR009k5rAb7TsggIsWTISn2fgKMiB74VE4oPWmMoG5xVUf6isfvjmzE3UTKUWPZr1o3Ua3ec7Psdv1cTXvjI5e6SPFwKAtQvgw8SQ+gb5mweUwZ56wnG6pFdMJuv+QGTOa1D8VClAwzEd6r2AjkB22giw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JqJWczxxhZ2kYqddH+H41qlw9vxD3+Ylz/4Gr3TlxOY=; b=MFXy1L8TvZd+MHIlHRME+MDCNCK0VsLXtSA/rL1qTRci+Vd6H4c2FgORCi+oixGRP6Of87ofG/mmlEDBAnU/COknU9Mxn8p8EilM/XhatEbIOZpUPWDisg85npyMOTDN+fUqMmjZkSGtC7b+haCU8PyxFXNfund6DaIiJ+8QKCk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by MW4PR13MB5864.namprd13.prod.outlook.com (2603:10b6:303:1b7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Tue, 26 Dec 2023 02:38:29 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::45b3:d83c:cff2:4a1b]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::45b3:d83c:cff2:4a1b%6]) with mapi id 15.20.7113.026; Tue, 26 Dec 2023 02:38:29 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Peng Zhang , Chaoyong He Subject: [PATCH v5 10/14] net/nfp: handle link event of bond firmware creation Date: Tue, 26 Dec 2023 10:37:41 +0800 Message-Id: <20231226023745.3144143-11-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231226023745.3144143-1-chaoyong.he@corigine.com> References: <20231018074821.1908906-1-chaoyong.he@corigine.com> <20231226023745.3144143-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR01CA0156.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::36) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW4PR13MB5864:EE_ X-MS-Office365-Filtering-Correlation-Id: ee5a2e72-1827-449f-a1bc-08dc05bbbe60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Thm1Ahtvn8HkHha9DxqGkSsExa7ozPh7i10JavxrqTu5lFEnhIx8k12frpjo+oKVhg3LDMi609zG3h5z5UhEZkDud/UryN0pc0IJ+nK9Q8TAx3PmJGvwG3c8uZ7n+ZbmtipLMzOEGYpQEiY8zmoKk9SKfNsQysq+45wh8jYASWFlQGmxlnCIRttQWO8rhIUSGtVZv6RP6NZJGwyAww8d0dZ/LJLMBUTjUchQei2aoHT5AyzPCyj/MIee/ul49ATWpv3iEDX5SVqqhuZvrtLqlvxhU17BxFx1+Rr2FzQlaF3w9NgQA0VazaePjoa++acpJkGOwongvv4Qwus6+xe+CFTuCGcgUZUj/mlT/MaQ24CvhSAG+/A22FvUpndN6OPuuNB1VNhXsqIeDEgxbkX1xDc/4mxOiLT7MsdeWS90Ujwj626pwwS8Yqk2QABapT63EuhGi0/eC1vOUfWYW4VTHtCepE/DV0sgfX+rR9EYT/DzKcRitStAxqzIOPocHxQIImW3JKB7Z5u0bdJWhMJqtWJ75r4Ecq3NLxR421dTsEGUyHM2TLhoH+Q5s0TYnXkiK32fIFmLmnej0K8n/fxyIdvQarEUSjznM4PxfJDojxn0VekMIlVeK9k/A4QM+1OU+QFqbCPaEZToDWpfom8EvLuXC0JoNpUskG8mxCO+LxA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39840400004)(376002)(396003)(366004)(136003)(346002)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(83380400001)(41300700001)(2616005)(38100700002)(26005)(107886003)(1076003)(316002)(4326008)(54906003)(8676002)(30864003)(2906002)(5660300002)(44832011)(8936002)(478600001)(6512007)(6666004)(6506007)(52116002)(66476007)(66556008)(66946007)(6486002)(6916009)(38350700005)(86362001)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?KhCZKp2n3T90rik++ir7u3HdLH0nawBl5JhkEKieTkxat0oZBYTwl7ojLMcT?= =?us-ascii?Q?i59wBJvJxc8dTzYepsu2LAiR5jJOouALmUeGjXDZRe0K2XumypLYZW/UObjN?= =?us-ascii?Q?lhxbhBsnh4Ig+/mM9EapQAHF8wMYKvRSc8JRIf1eJRg4YQIyMddasTOpBIWN?= =?us-ascii?Q?UbZwX9YypFZKr2nyFDLw9JB7+S/UfNbDZiahJVUVsf1LlOnm+46Lg6bsRJfq?= =?us-ascii?Q?snj9ZJFyIGY8PIwD4MQojEqpjzwU3RChZ2a/f+sWUxP0UC+B5pgrvE0SrbvD?= =?us-ascii?Q?5Rl57z64/jRqh8WGVOJxIwG2heCRuyDnxXv7RxEVzEDLfp0l/CRXvpt+fjOW?= =?us-ascii?Q?tUO9OxOgVPQ1toaqWn98U6gHZ1kk00RMd02lmI9UYdaGf02Iy7xNo9D1Srnh?= =?us-ascii?Q?s5GywqXco+PGpwE5Tf6lflgUZOrDkmZNm5vAQj/5MV4wWr4Bavr4HAs7RMDa?= =?us-ascii?Q?WPhWu9xOkdmbC4P00Va+tA/sAoVvK0DhSkj7IDfb/00j4wGbLAcFPxeFp08t?= =?us-ascii?Q?ltX/ub3wgo+UBHSgaB7+beAnpnZ8tNkgLKKKRivA2TqiRKo8tB7mn4f4cjHT?= =?us-ascii?Q?Khzq735phqR8bFjj3ISsjVDtdca6zz/Ec+ik7lVYGFpBSgQN414Q47xg0J8O?= =?us-ascii?Q?Y+X2DM7/fbPg+5yC0Oy5hbB35jurtdxuZt/MzT4AuwvkepRCYRi1acDB6M7F?= =?us-ascii?Q?Y75/KAHqJlQAC7oaD6zCGR7y7LRwpU/sTGNiFelOE6yEIw0olDPt1PlqSulE?= =?us-ascii?Q?vj0q5/yYE6AoELagh7OLBoZQQFmBO0yO13QgA9nARC7VjEgOLJU2fb+UlyR4?= =?us-ascii?Q?HZrw1d/Swf5T2LtrdcF3kXFgPbHsh8XFjeD1WZtdpxcJB7rf1W+HVK+3SR+D?= =?us-ascii?Q?QrU89dtMQ2EeXEa1PsNadt1+PV0tTicKT1e6r1F1wnHNzOkdtXHIrN5x57dU?= =?us-ascii?Q?rxaGcSeYrA27+yoSHEzktJCAtpwFpIt9jzEFTLlFuanzhroqg7E1o3V/Ig8w?= =?us-ascii?Q?nt+UGd1S2ibUoRWVXViwmTciNTOLmIA6joa42iQIU0kRXQAYZx0wfNXyv4UU?= =?us-ascii?Q?TzpyNNe2QHsF/5Eecz3+4gMrZquvLob1WF78UmaGrjYpkBXeLMbqfLFakU3I?= =?us-ascii?Q?4SjWh1gDgX1CQvcR3w+ch7PDIxmYUMK1YEPt4EptpABDow1KxJQtLZmgYXAX?= =?us-ascii?Q?7xuFqhyl+3fHI7F5+kAoEMmsDEDenIHlauMMCrygCB48iCP3VhyP+2SKT2u6?= =?us-ascii?Q?ONhpf7ggAX5mCiOfy8AKQcDLSndFsaDRtlAbH756B+J8G3AhYN0na8dGBoTI?= =?us-ascii?Q?7oCkEuW6Qb95AuvpHvtgQlO+vxyRTU+UKDgkAE3PZ44BjKEV12t2eNypLrz4?= =?us-ascii?Q?wsPgvTMT0PO+k5asF3h5mafIgKcZBHXLfzbRmthXhRhidA/uOASY92gLWb95?= =?us-ascii?Q?Hhwj97Kr2P1M+kkcvQ/+O89zDX9PgHe0gy6wHtcowcmqUwg6SYPLMkFfS+vi?= =?us-ascii?Q?RDFT7Fe15TXRKR6bTvORv5gXlkBS0SO0ctA2Pi+iVuUkXzG5gMN3gwGFmQ7w?= =?us-ascii?Q?FSc6GOJEpimLprXDAKV3W497VylsOhnBhzbfhWxXPQLaSdjU8RQXoWnsmI5d?= =?us-ascii?Q?NQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee5a2e72-1827-449f-a1bc-08dc05bbbe60 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2023 02:38:29.3842 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YdRCBmW/D8V4Z21yOx6P4VLcKwhrSLVHD6Syc5NOZ6Wzjni2MkYAB4je7Pjjs2l1FE2m8fzqIrcJ6LJaBuYDcI17+8FNKzsjkmlry/wT1WQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR13MB5864 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 From: Long Wu If NFP physical representor port is a member port of bonding port, its link status changed and firmware has created the bonding port, driver will record the link status and send control message to notify firmware. Signed-off-by: Long Wu Reviewed-by: Peng Zhang Reviewed-by: Chaoyong He --- drivers/net/nfp/flower/nfp_flower_bond.c | 259 ++++++++++++++++++ drivers/net/nfp/flower/nfp_flower_bond.h | 22 ++ .../net/nfp/flower/nfp_flower_representor.c | 13 + .../net/nfp/flower/nfp_flower_representor.h | 2 + drivers/net/nfp/meson.build | 2 +- drivers/net/nfp/nfp_net_common.c | 25 ++ drivers/net/nfp/nfp_net_common.h | 1 - 7 files changed, 322 insertions(+), 2 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_bond.c b/drivers/net/nfp/flower/nfp_flower_bond.c index 4ac27f117c..c814c0d4ea 100644 --- a/drivers/net/nfp/flower/nfp_flower_bond.c +++ b/drivers/net/nfp/flower/nfp_flower_bond.c @@ -4,8 +4,11 @@ */ #include "nfp_flower_bond.h" +#include +#include #include +#include "../nfp_logs.h" #include "nfp_flower_cmsg.h" #include "nfp_flower_representor.h" @@ -43,6 +46,72 @@ nfp_flower_bond_increment_version(struct nfp_flower_bond *nfp_bond) nfp_bond->batch_ver += 2; } +static enum nfp_flower_bond_batch +nfp_flower_bond_remove_node(struct nfp_flower_bond *nfp_bond, + struct nfp_bond_group *entry, + enum nfp_flower_bond_batch batch) +{ + enum nfp_flower_bond_batch batch_out; + struct nfp_flower_bond_cmsg_args cmsg_args; + struct nfp_app_fw_flower *app_flower = nfp_bond->app_fw_flower; + + nfp_fl_bond_cmsg_args_init(&cmsg_args, entry, NULL, 0, batch); + if (nfp_flower_cmsg_bond_config_group(app_flower, &cmsg_args, &batch_out) != 0) { + PMD_DRV_LOG(ERR, "group remove failed."); + return batch_out; + } + + entry->to_remove = false; + entry->offloaded = false; + + if (entry->to_destroy) { + LIST_REMOVE(entry, next); + rte_free(entry); + } + + return batch_out; +} + +static void +nfp_flower_bond_member_work_status(struct nfp_bond_group *entry, + struct rte_eth_dev **active_eth_devs, + uint32_t *active) +{ + uint32_t i; + uint32_t *flags; + uint32_t active_count; + uint16_t member_port_id; + struct rte_eth_dev *eth_dev; + struct bond_dev_private *internals; + struct nfp_flower_representor *repr; + + active_count = 0; + + internals = entry->main_dev->data->dev_private; + for (i = 0; i < internals->member_count; i++) { + member_port_id = internals->members[i].port_id; + if (internals->current_primary_port == member_port_id || + internals->mode != BONDING_MODE_ACTIVE_BACKUP) { + eth_dev = &rte_eth_devices[member_port_id]; + repr = eth_dev->data->dev_private; + flags = &repr->bond_port_flags; + + if ((*flags & NFP_FL_BOND_PORT_CHANGED) != 0) { + *flags &= ~NFP_FL_BOND_PORT_CHANGED; + entry->dirty = true; + } + + if ((*flags & NFP_FL_BOND_PORT_TX_ENABLED) != 0 && + (*flags & NFP_FL_BOND_PORT_LINK_UP) != 0) { + active_eth_devs[active_count] = eth_dev; + active_count++; + } + } + } + + *active = active_count; +} + int nfp_flower_bond_init(struct nfp_app_fw_flower *app_fw_flower) { @@ -96,6 +165,132 @@ nfp_flower_bond_reset(struct nfp_flower_bond *nfp_bond) return nfp_flower_cmsg_bond_config_group(app_flower, &init_args, &batch); } +struct nfp_bond_group * +nfp_flower_bond_find_group(struct nfp_flower_bond *nfp_bond, + const struct rte_eth_dev *bond_dev) +{ + struct nfp_bond_group *group; + + LIST_FOREACH(group, &nfp_bond->group_list, next) { + if (group->main_dev == bond_dev) + return group; + } + + return NULL; +} + +void +nfp_flower_bond_do_work(struct nfp_flower_bond *nfp_bond) +{ + int ret; + uint32_t active_count; + struct nfp_bond_group *entry; + struct nfp_app_fw_flower *app_flower; + struct nfp_flower_bond_cmsg_args cmsg_args; + struct rte_eth_dev *active_eth_devs[RTE_MAX_ETHPORTS]; + enum nfp_flower_bond_batch batch = NFP_FLOWER_BOND_BATCH_FIRST; + + app_flower = nfp_bond->app_fw_flower; + + pthread_mutex_lock(&nfp_bond->mutex); + + LIST_FOREACH(entry, &nfp_bond->group_list, next) { + if (entry->to_remove) { + batch = nfp_flower_bond_remove_node(nfp_bond, entry, batch); + continue; + } + + nfp_flower_bond_member_work_status(entry, active_eth_devs, + &active_count); + + if (!entry->dirty) + continue; + + nfp_fl_bond_cmsg_args_init(&cmsg_args, entry, active_eth_devs, + active_count, batch); + + ret = nfp_flower_cmsg_bond_config_group(app_flower, &cmsg_args, &batch); + if (ret == 0) { + entry->offloaded = true; + entry->dirty = false; + } else { + PMD_DRV_LOG(DEBUG, "Group config failed."); + } + } + + /* End the config batch if at least one packet has been batched. */ + if (batch == NFP_FLOWER_BOND_BATCH_MEMBER) { + batch = NFP_FLOWER_BOND_BATCH_FINISHED; + nfp_fl_bond_cmsg_args_init(&cmsg_args, NULL, NULL, 0, batch); + ret = nfp_flower_cmsg_bond_config_group(app_flower, &cmsg_args, &batch); + if (ret != 0) + PMD_DRV_LOG(DEBUG, "Group batch end cmsg failed"); + } + + pthread_mutex_unlock(&nfp_bond->mutex); + + /* + * A batch of packets rx in firmware has been set for at least two timing + * units, so trigger copying at next opportunity to limit latency from + * receiving data to being available for use. + */ + rte_delay_ms(1); +} + +static void +nfp_flower_bond_change_linkstatus_event(struct nfp_flower_bond *nfp_bond, + struct rte_eth_dev *bond_dev, + struct rte_eth_dev *nfp_dev) +{ + uint32_t *bond_port_flags; + struct nfp_bond_group *group; + struct nfp_flower_representor *repr; + + if (!nfp_flower_bond_is_member_port(bond_dev, nfp_dev)) + return; + + pthread_mutex_lock(&nfp_bond->mutex); + + group = nfp_flower_bond_find_group(nfp_bond, bond_dev); + if (group == NULL) { + pthread_mutex_unlock(&nfp_bond->mutex); + return; + } + + pthread_mutex_unlock(&nfp_bond->mutex); + + repr = nfp_dev->data->dev_private; + bond_port_flags = &repr->bond_port_flags; + + if (repr->link.link_status == RTE_ETH_LINK_UP) + *bond_port_flags |= NFP_FL_BOND_PORT_LINK_UP; + else + *bond_port_flags &= ~NFP_FL_BOND_PORT_LINK_UP; + + *bond_port_flags |= NFP_FL_BOND_PORT_TX_ENABLED; + *bond_port_flags |= NFP_FL_BOND_PORT_CHANGED; +} + +int +nfp_flower_bond_event_handle(struct nfp_flower_bond *nfp_bond, + struct rte_eth_dev *bond_dev, + struct rte_eth_dev *nfp_dev, + enum nfp_flower_bond_event event) +{ + switch (event) { + case NFP_FLOWER_CHANGELINKSTATUS: + nfp_flower_bond_change_linkstatus_event(nfp_bond, bond_dev, nfp_dev); + break; + default: + PMD_DRV_LOG(ERR, "Invalid bond offload event."); + return -1; + } + + nfp_flower_bond_do_work(nfp_bond); + + return 0; +} + enum nfp_flower_bond_batch nfp_flower_bond_cmsg_payload(struct nfp_flower_bond *nfp_bond, struct nfp_flower_cmsg_bond_config *msg, @@ -147,3 +342,67 @@ nfp_flower_bond_cmsg_payload(struct nfp_flower_bond *nfp_bond, return batch; } + +bool +nfp_flower_bond_is_member_port(struct rte_eth_dev *bond_dev, + struct rte_eth_dev *nfp_dev) +{ + uint32_t i; + struct bond_dev_private *internals; + + if (!nfp_flower_is_phy_repr(nfp_dev)) + return false; + + internals = bond_dev->data->dev_private; + + for (i = 0; i < internals->member_count; i++) { + if (nfp_dev == &rte_eth_devices[internals->members[i].port_id]) + return true; + } + + return false; +} + +struct rte_eth_dev * +nfp_flower_bond_find_bond_device(struct rte_eth_dev *nfp_dev) +{ + struct nfp_bond_group *group; + struct nfp_flower_representor *repr; + struct rte_eth_dev *bond_dev = NULL; + + if (!nfp_flower_is_phy_repr(nfp_dev)) + return NULL; + + repr = nfp_dev->data->dev_private; + + pthread_mutex_lock(&repr->app_fw_flower->nfp_bond->mutex); + LIST_FOREACH(group, &repr->app_fw_flower->nfp_bond->group_list, next) { + if (nfp_flower_bond_is_member_port(group->main_dev, nfp_dev)) { + bond_dev = group->main_dev; + break; + } + } + pthread_mutex_unlock(&repr->app_fw_flower->nfp_bond->mutex); + + return bond_dev; +} + +bool +nfp_flower_bond_all_member_are_phyrepr(struct rte_eth_dev *bond_dev) +{ + uint32_t i; + struct rte_eth_dev *eth_dev; + struct bond_dev_private *internals; + + if (bond_dev == NULL) + return false; + + internals = bond_dev->data->dev_private; + for (i = 0; i < internals->member_count; i++) { + eth_dev = &rte_eth_devices[internals->members[i].port_id]; + if (!nfp_flower_is_phy_repr(eth_dev)) + return false; + } + + return true; +} diff --git a/drivers/net/nfp/flower/nfp_flower_bond.h b/drivers/net/nfp/flower/nfp_flower_bond.h index bb7ba8a1ad..80f56a6780 100644 --- a/drivers/net/nfp/flower/nfp_flower_bond.h +++ b/drivers/net/nfp/flower/nfp_flower_bond.h @@ -36,12 +36,23 @@ #define NFP_FL_BOND_SWITCH RTE_BIT32(6) #define NFP_FL_BOND_RESET RTE_BIT32(7) +/* BOND port state flags. */ +#define NFP_FL_BOND_PORT_LINK_UP RTE_BIT32(0) +#define NFP_FL_BOND_PORT_TX_ENABLED RTE_BIT32(1) +#define NFP_FL_BOND_PORT_CHANGED RTE_BIT32(2) + enum nfp_flower_bond_batch { NFP_FLOWER_BOND_BATCH_FIRST, NFP_FLOWER_BOND_BATCH_MEMBER, NFP_FLOWER_BOND_BATCH_FINISHED }; +enum nfp_flower_bond_event { + NFP_FLOWER_CHANGEUPPER, + NFP_FLOWER_CHANGELINKSTATUS, + NFP_FLOWER_UNREGISTER +}; + /* Control message payload for bond config */ struct nfp_flower_cmsg_bond_config { /** Configuration flags */ @@ -115,5 +126,16 @@ int nfp_flower_bond_reset(struct nfp_flower_bond *nfp_bond); enum nfp_flower_bond_batch nfp_flower_bond_cmsg_payload(struct nfp_flower_bond *nfp_bond, struct nfp_flower_cmsg_bond_config *msg, struct nfp_flower_bond_cmsg_args *init_args); +struct rte_eth_dev *nfp_flower_bond_find_bond_device(struct rte_eth_dev *nfp_dev); +bool nfp_flower_bond_is_member_port(struct rte_eth_dev *bond_dev, + struct rte_eth_dev *nfp_dev); +struct nfp_bond_group *nfp_flower_bond_find_group(struct nfp_flower_bond *nfp_bond, + const struct rte_eth_dev *bond_dev); +int nfp_flower_bond_event_handle(struct nfp_flower_bond *nfp_bond, + struct rte_eth_dev *bond_dev, + struct rte_eth_dev *nfp_dev, + enum nfp_flower_bond_event event); +void nfp_flower_bond_do_work(struct nfp_flower_bond *nfp_bond); +bool nfp_flower_bond_all_member_are_phyrepr(struct rte_eth_dev *bond_dev); #endif /* __NFP_FLOWER_BOND_H__ */ diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 7d8c055b80..2810a7a271 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -827,3 +827,16 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower) return ret; } + +bool +nfp_flower_is_phy_repr(struct rte_eth_dev *eth_dev) +{ + struct nfp_flower_representor *repr; + + if ((eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + repr = eth_dev->data->dev_private; + return repr->repr_type == NFP_REPR_TYPE_PHYS_PORT; + } + + return false; +} diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h index 8053617562..164e2f1322 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.h +++ b/drivers/net/nfp/flower/nfp_flower_representor.h @@ -14,6 +14,7 @@ struct nfp_flower_representor { uint32_t repr_type; uint32_t port_id; uint32_t nfp_idx; /**< Only valid for the repr of physical port */ + uint32_t bond_port_flags; char name[RTE_ETH_NAME_MAX_LEN]; struct rte_ether_addr mac_addr; struct nfp_app_fw_flower *app_fw_flower; @@ -24,5 +25,6 @@ struct nfp_flower_representor { }; int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower); +bool nfp_flower_is_phy_repr(struct rte_eth_dev *eth_dev); #endif /* __NFP_FLOWER_REPRESENTOR_H__ */ diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build index f0d4bbcecb..c309505c83 100644 --- a/drivers/net/nfp/meson.build +++ b/drivers/net/nfp/meson.build @@ -42,4 +42,4 @@ sources = files( 'nfp_rxtx.c', ) -deps += ['hash', 'security', 'common_nfp'] +deps += ['hash', 'security', 'common_nfp', 'net_bond'] diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index a438eb5871..810903c033 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -9,6 +9,7 @@ #include +#include "flower/nfp_flower.h" #include "flower/nfp_flower_representor.h" #include "nfd3/nfp_nfd3.h" #include "nfdk/nfp_nfdk.h" @@ -719,6 +720,23 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev, return 0; } +static void +nfp_net_bond_link_event_notify(struct rte_eth_dev *dev) +{ + struct rte_eth_dev *bond_dev; + struct nfp_flower_representor *repr = dev->data->dev_private; + + if (!nfp_flower_support_bond_offload(repr->app_fw_flower)) + return; + + bond_dev = nfp_flower_bond_find_bond_device(dev); + if (!nfp_flower_bond_all_member_are_phyrepr(bond_dev)) + return; + + nfp_flower_bond_event_handle(repr->app_fw_flower->nfp_bond, bond_dev, + dev, NFP_FLOWER_CHANGELINKSTATUS); +} + int nfp_net_link_update_common(struct rte_eth_dev *dev, struct nfp_net_hw *hw, @@ -753,6 +771,13 @@ nfp_net_link_update_common(struct rte_eth_dev *dev, PMD_DRV_LOG(INFO, "NIC Link is Up"); else PMD_DRV_LOG(INFO, "NIC Link is Down"); + + /* + * Link status changed and if repr is a member port in bond device, + * we need to call func to do something special. + */ + if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) + nfp_net_bond_link_event_notify(dev); } return ret; diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 66c900e3b8..9d6cf4b016 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -295,7 +295,6 @@ int nfp_net_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa); int nfp_net_fec_set(struct rte_eth_dev *dev, uint32_t fec_capa); - #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) -- 2.39.1