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 80B8743795; Tue, 26 Dec 2023 08:30:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9FCD840C35; Tue, 26 Dec 2023 08:29:06 +0100 (CET) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2136.outbound.protection.outlook.com [40.107.212.136]) by mails.dpdk.org (Postfix) with ESMTP id 2D92D406B8 for ; Tue, 26 Dec 2023 08:29:05 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=deIfHXvHR11MvSNYJvsGJLoFO1fNcxo3JQqeucRcP9/+Zm8zdLiTWltWqQGq0Bhf7Zcj8IYT37okwp3gMghbAzkVWNQHBlSytJJqxGo4LcEFSe1ZH132nP3BLNN3qF6H8z1CZdYTLZBJKDuV20dAP5PVnQJGN+bFIW/yuHVW9duEvDGmOf3J+p/q59ctu9RtL5Wa+fu3HkLjfjISOPHoTt25xRUG+1Nv9DDDnxe7In9bBie3YnzstKN39bXILb6lq0muC+ikCeyXLk4rY/P4i+e5c4kkvxqRniN4266TliyRX3OdRbY9UlJbeR80mjlTETzx7U+9tNNUvmgPPlqeQA== 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=msm4+kObErOsnTDs1zcqbb+sD2m8L0kXo64hEOChBSY=; b=nVRPxw6cPHg78cqsZxPLHI7ZsGQ/3rp6rNZJEtRo9sL67+To4ndenAiB5eiH5UIzC+aH6Gl09nxrJcyfWCzxMvSrR2ffps24BMsqIOBuLs2MElZf5KTPUck8LIOjXClv9bEjssIOS6dPnusc5KoQqBh5Ge25TSbD8qhQEPQeoOoqZpZ6b2XpzkkbIVenFhQpf9Q7QYAjOqvJNUG7uZe4OLhLSJ6eF2CeL/z4ehGbeRoCtmUehTrXUWiEcEDH8MehSYBPl00fbpxYClVfNZSZoPWi8IgXYbYdeB/YQObMqpls1pakSsPGjOWp9tpAZjRm9MZwswtbJaMwQBWR31V0kg== 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=msm4+kObErOsnTDs1zcqbb+sD2m8L0kXo64hEOChBSY=; b=Ztac/iNOpGUmFihifdUfEEEOTAB4sJYZ6hrogohe25oEUhBcU9F/1ZCKTuUVmYRNbc8KaYsXFNs5Rd7kM11FazrSHIpU6nbuwCOAHuFz/5z2eEr2/1o8etVWz6n1wJFWqX14eNmmv/tqHyBAKfUzGzfF5qdNPpzpXhDRSbSK3bk= 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 CH3PR13MB6506.namprd13.prod.outlook.com (2603:10b6:610:1a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27; Tue, 26 Dec 2023 07:29:03 +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.027; Tue, 26 Dec 2023 07:29:03 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Peng Zhang , Chaoyong He Subject: [PATCH v6 10/14] net/nfp: handle link event of bond firmware creation Date: Tue, 26 Dec 2023 15:28:20 +0800 Message-Id: <20231226072824.3163121-11-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231226072824.3163121-1-chaoyong.he@corigine.com> References: <20231226023745.3144143-1-chaoyong.he@corigine.com> <20231226072824.3163121-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0239.namprd03.prod.outlook.com (2603:10b6:a03:39f::34) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CH3PR13MB6506:EE_ X-MS-Office365-Filtering-Correlation-Id: a84469cd-c792-4c44-5912-08dc05e455de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U2RLe138spLzHRiYIqjNXTq2nlaJu2gLu7cc7o9mEZZ89izcXDGfWuYk8fyNt8tIekY6+uGZuEE4TYjxP9g/vWCxOVjlnzxQsiVXWhJcEbxlaFgDCBspIR2TCiWwNWlmNG4Sx4w7IsCEEcEqYyr1k2PrLh5/kqm4rmiD2L0szrIdEeuU0I8Vte5xj7K2Z0XEplR92tOr1Fc7OUqI9xlu+dPSCCFzj32LQyHWD/ZmPyyp4A7XtoYs2oqdJ/JbRDSmT7Y7fNB0qeFb4W7tUdstpBwx3jrRBI+KWrs0E/eCnVhYIa2fthPZf1tigdsnHVg4pt/t3jBkHM1HZu7lrtOlLS6L/HzDrdmQyyPU21W1Ge/Q8+8smSxZZCH+8cJK+fjXJWNUsz631OKSH27EZhEYsdNL1v+hvNsHukYtUVAcHIUlNaCoANK+GK9bg0HAicee5CEAuX00odwAFsUzLFlKySdKZnQNAbC+R2L7MGawZ3iJgpEi9klCRpEinkQL/LXeTW56NZdNPnU1uah7HVXpyAsnCrPJLPoBDrt14hhDEj97Bd5789uFR1ZVrv+pfWFUTprexyNGBBHzl54g/weJtT+TZ+46XolRIyr808jcPvlAVrf8ao22cDCzmWiR/1GrKlVJoghKSWl/x0wselvDMcaD7WYv1yBDTz0o9MPKSpA= 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)(376002)(346002)(136003)(396003)(366004)(39840400004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(26005)(1076003)(52116002)(6666004)(2616005)(6512007)(83380400001)(5660300002)(44832011)(4326008)(8676002)(41300700001)(2906002)(30864003)(8936002)(6486002)(478600001)(316002)(6916009)(54906003)(66476007)(66556008)(66946007)(6506007)(86362001)(36756003)(38100700002)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?8yOqjt7NUJrT/tDcBj04so+EVZRWsaf5aOXJ5HsBLXVX5Xfnk2u8qYsZjHVM?= =?us-ascii?Q?nFhEuHACA7wJyCpnEDhd0OS4eyW0uCXpY8XLraztNq8Vh/TrqndudB8Vdwld?= =?us-ascii?Q?/nLLDRxYuVzrLlu1pvg0ttnXrUdige2fngiRkF9lMSVCS5moDL0sCSIXfhp2?= =?us-ascii?Q?W7jHEqbPWpy8hJM39nL0vCy4SrkmUS4Ou88N57Gnqj95gcRd2waxzyq6zFf6?= =?us-ascii?Q?5p9KftkeIVpKwS94e4VeM2gpwvVMpPh0X+R+GHlT/kf7RJxs2M8cFE6OjlsG?= =?us-ascii?Q?MPzzPfQ3l5c5AX4dBIzBsz5xSwJhg11yPG5GssAh3E3/3PQ5OXQKJX1aZrRW?= =?us-ascii?Q?0yOP0c5wmiQWFpyqc9hbU/NSdpQEmlPJ0YSVpdKLEaSwcezayWSV7WFdI7Zh?= =?us-ascii?Q?FNKSjleKAII9KTKTy3l6tHnysmMz3EgQjkkkmQn/gQPbB5zZiolJqY9AkLut?= =?us-ascii?Q?z37AL2e9jD33dv60WD8IB8oisfipe4yzYiUe0nNID7i7zh3hSKtdKgoCM6vu?= =?us-ascii?Q?iTmSiVtPNCAHvpYaLj09srRap+u/KSbVWy27gbuOhaZUThs2NtC75JOWmVVM?= =?us-ascii?Q?3KAIzgT4kDtQhTucyJd0OdkgC20JIKa1MAjiO9cdbOr0lHOMVRfT/pTIZseK?= =?us-ascii?Q?KgWXkpBYrguBYIeT2QMN7rDfY6c1Ei0I6bEuNvFmQTA+F627x0D90jSNaoND?= =?us-ascii?Q?LUJNRPaMGd+N8PifOPNCiL05rJBd8JQDoSRWIFM0NMDAxed6c+GUnf1LaI4u?= =?us-ascii?Q?9+jsoxELx4w4ZUsD3kKiyRyMxmK0mpD+dDNralH78xAuw3f6hTNSygvJa9Wp?= =?us-ascii?Q?gpDGWOMi5u6oWlhW+t+EAbl0SvJkF96btnGm6NYWi4gMk7RG9Dkaa+WyNOG6?= =?us-ascii?Q?boKGGvBDJzKj5XNN6EO9UJdNfNCOMdSlvl5VjVDsxS6OI9ushEI1iusWWlsz?= =?us-ascii?Q?/3AFsr4NPAJNn0GWhXoEs762uPkOx4xggBx7Ri2cOi59qBHx2AjB8YiL0ZdM?= =?us-ascii?Q?qdBoe9s/kkuaSzT9PRDQL10Y9T2xRLMG2ZsEF4ccyXgpLc3hiiazBfVr046D?= =?us-ascii?Q?7Oa0zXrK6okbOJ/gd+vLIvJHpNFJw/ele2e2rNFhEppFNOGq6Aw1T/7KPYuw?= =?us-ascii?Q?H9/XQZdnRDiROccoC11IJkRvMpcK8T5NqmMNI3XInbd5HQEpReYy+pVTcjme?= =?us-ascii?Q?DWk3FMJfOlgNCbv1KHXmMNNw1tOemVZQFGQHb41S2fWgXbSKf/TTEFXWKuJ8?= =?us-ascii?Q?V89DN794hr2aao6td9eBZrIWwTh44RrC/sd7Fi0ZsaA+WHoEipdK7l4mSGBG?= =?us-ascii?Q?eysKmBZaPrLOcFCo3GgyM2StkfiJVibVsjIpBPSAFvrMUD23ertYSKIILVKD?= =?us-ascii?Q?MicfEd2UGnEOzuxzABxIlSzlp/6z3c2XWGsWvaRJza4kYkyqp9WIhAb/trfk?= =?us-ascii?Q?Zytz7N5q6/j7KvdpGIj9rb89tYwmaK/7ncAMI4KTf3NXnVHs+Oa3n+n267ws?= =?us-ascii?Q?kzqndfYtbkM6Li3FnrSE9yiM225vtqAb3DbrZh08bREps5qMDCxjGVJV9Klp?= =?us-ascii?Q?MuOg1csi61A1EANClBdqwk/vom/GJi3RWAZJtA5dwuWWra5+sq0EldNGs0Y2?= =?us-ascii?Q?Wg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a84469cd-c792-4c44-5912-08dc05e455de X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2023 07:29:03.4101 (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: bSOqC38zWAN9rRj6h3j/xj7NkChh9vmmPzDr+D8exQXAKzO7bTahHtaViVN88ms46lBHnKjpULBml/uIFlit10Il49R2CSu0ilVRoWlAuFs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR13MB6506 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 e15d9e09d5..e4a09b3427 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