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 7D69543275; Fri, 3 Nov 2023 07:26:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52C0F427E0; Fri, 3 Nov 2023 07:26:38 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2111.outbound.protection.outlook.com [40.107.93.111]) by mails.dpdk.org (Postfix) with ESMTP id CD824402E9 for ; Fri, 3 Nov 2023 07:26:36 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C6SeGr6VmnxDeGwP2pNiXnEiNnj5T4C2QTbpPCMcNapa7dQWa7K09LWWssa0zx5xd7gJmqqp5vDnXeNozdXgcKG4THsvNBD9w4LzvBTRVQWT10laW6VIX8fhavt7Z3fKaj3HelKnQjrwB/QwHHnqxNSHEw0ykKaFSErD+R/14xulHMvJ9JcDJecL2E7Sl9FfUQ0HrkkBPjX0FDwPN/jGlK0zSlFSUCEgmHr19/jAH9RzDwN0R4lqALYq/yW5snwsuzClhJw9010l34xakX/uuFgdArPFnw/kw1uAFZvYXSB5sb+texFotpQz4/0FIS3nZhWxODOk/+XSH8r51bN+hQ== 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=UsBITjl5kM3ImPCXok1Pl6AQjbFZ/JssMvw2CU756V0=; b=IpiJaJeUZ0zGCMjEjpNSxI0nkFfjNDE8sG4jDrQDGqP3L+pGC/v6+9Ldo1tX2SnNLaG8nomfEbC3mj0WSAt+JF1LY0w0hjV5I2YM59dfpxXacBYJk2VcRjwwQsLRmc6zLfcoJT+yNoHEhCAvsjl4laXMOPH9+FTdN3ZCDzFf8m1PPv99swaRoL+O8I/6c8C9BVg0TPH87sOgDk7mC1wQg1nv1VqjYn5hh87alkFcbxAb2OakNCtFkSgsJ7ukuFkKXyhMmXuwXnEduvw88s2MGGY0Ecabt6et/d6hhIiTY+9HzNuxRlZbcUYs1zaX2l21va8oy8Xcc6tmOmBI5wJyPQ== 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=UsBITjl5kM3ImPCXok1Pl6AQjbFZ/JssMvw2CU756V0=; b=V772ea/Qi1v3id0YqSxipSlQGjjaOZUeBHytqM+JB2Hmh1FpSAxJvAexDIm/CzB/Et1DxDSkzWX9IKfMX7EuOk59C1jlTrqhgcNYMEvSOkweKW/35I1c8zc4/J7AEeWBcJSMYFD6euKYnE8McEzIuJ35bRuDMYqMJ7lXSABztL4= 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 MN2PR13MB4102.namprd13.prod.outlook.com (2603:10b6:208:262::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.24; Fri, 3 Nov 2023 06:26:34 +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.6954.021; Fri, 3 Nov 2023 06:26:34 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 03/11] net/nfp: add the control message channel Date: Fri, 3 Nov 2023 14:25:58 +0800 Message-Id: <20231103062606.2632012-4-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231103062606.2632012-1-chaoyong.he@corigine.com> References: <20231103062606.2632012-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BYAPR02CA0044.namprd02.prod.outlook.com (2603:10b6:a03:54::21) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MN2PR13MB4102:EE_ X-MS-Office365-Filtering-Correlation-Id: 37cf59c3-e977-4b3a-f84a-08dbdc35d385 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GDdwDarwUx3Cj8aYQ7P8tZ4bQYQCNW7KnK0gp0RcY3nkal8Ml3NYeuK+9FxMB5TQErRZL9EfpomNd+vKs/2YuSuTzlxDkwPXiJbS9FbtG1AvUOVCSsns2LdcOSV3WUKSFtQCLMIDwsLn5zun6hBg28b5poBnP+T0nLxf16GUqj7DpeZRQTltzYepmkBhcOv3zZQSvdsCY0CBy6N/sFtCCqSr6X5Ox3SN/Yq3SkSBH8R+vyjieQzYnnwFQmsFu5ZDt0JbjFW20Fnq7qDYF9venc6wmAgwW/MqQLzSYqJZ6OEqpt/c+sdcDfLK/nN++/pgvHArmihCJu33DSDf5IkQfS64X99Ka0XbfjCqyTiXU0LO9+E97Dp5EOnlJbVyy5Uhrp6xmS+us0gi6gejwt9ElhTAIB0QdBczQC0AGXqdgjsKWBeAwgei5rnVeoc2CF6QxtYSiuS2l/wNIivOMQdCK9n0IvWDcU8bYRX6EXtxwqXTBjHT9otN4fL16pkM54om0zgIzuqnhImlnFLC8aujGdlGuHC02a05goRRZnRZ2LumM6LejlLMTjlrSyNzzQJgkP8z7XWRPgcFbEplgO7B5PbzNVWfCj5Na8i8uMaqzHZehd617+ZLhDAGjQkGV1ib8iuBMQtVvmBTsfQukoC/29cOxOUMt1XDBTUKYF+ZwDQ= 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)(346002)(396003)(366004)(136003)(376002)(230922051799003)(186009)(64100799003)(451199024)(1800799009)(316002)(6916009)(54906003)(66476007)(66556008)(66946007)(6666004)(6486002)(478600001)(52116002)(6506007)(15650500001)(5660300002)(38350700005)(41300700001)(36756003)(2906002)(86362001)(4326008)(8676002)(8936002)(44832011)(107886003)(1076003)(2616005)(26005)(83380400001)(38100700002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?PdMPoARRFUMLrDVscBiLk8/0MgPLjs6+2ePLv9KGM4lQPsp3UvKeodIHU2rN?= =?us-ascii?Q?f2USQQtapmXmtqo8acNYmwzHwSDdOWFs2U/EhnJiybpwKQu9VVT5NU5jwSE7?= =?us-ascii?Q?nSr7Kd7+SFOB5yp5ajEU/ziiMcnOoHQjDb3SjWzjWgPk4LR/G07PJFRgcF6g?= =?us-ascii?Q?PZu8OgwjOMzYBFcQp5QDGNG+CW2u8lqC7QZcrc695/nJWZfLrL4CBKbJtykq?= =?us-ascii?Q?MgLUu+QSMlDeqavkWklwhChyUBC5OB4tdBGKqJaReeQCCCRXrPj+4gB77cNm?= =?us-ascii?Q?SKatC0BvbB9NEnxWjX6NQ4msmGKimmnT5jbiArbCH/NJ5XTGz2Jka5E5CZNg?= =?us-ascii?Q?O9jnAFyQ9EXnbtR8afETji1sKQ/4NDiM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hyq4Ay8hbtDcoTJb66D7FC6Q1jxH0VA1r+LnoUgb2zsTg6my/18v79zd6?= =?us-ascii?Q?XGxwtevFigzvZZzZSgRCORFGUQL1KbW/gFHkBntRi90/ZreK5BtqiA0BFxo6?= =?us-ascii?Q?SowKQB1Bh1OmsdzE/TeBxSClFgycF7aFBaJFidDRYwckuFcRtubHa83YwUd8?= =?us-ascii?Q?41SA5jqywxU630beMxiUGS+lTldqwdoUejImBThUOpbwBYLoLxrY0uf9Wn2r?= =?us-ascii?Q?Kh7OgYaTXZrrW9oHBKq8LU8GiuE9RNkHBWwnU0eFdz4TbNowqH3vTy3CvbiM?= =?us-ascii?Q?/UUUPXtjqWwy5FeA03FZoW2qnRf7VYIHQyLb5FTGpXg7HnGWh19ZZYcjmJJg?= =?us-ascii?Q?IA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37cf59c3-e977-4b3a-f84a-08dbdc35d385 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2023 06:26:34.6291 (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: xXmvNs/kqpgpJzeQy3hFkJclidgrXEmnG7a6J/oChqODje68DzHNnsRa598WllRWpZdzP/6XTIuED59VfFxyO8WUisKzuDUzA/WkLKYy28g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB4102 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 Using the mailbox, which serves as the control message channel between driver and CoreNIC firmware. Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/meson.build | 1 + drivers/net/nfp/nfp_net_cmsg.c | 66 ++++++++++++++++++++++++++++++++++ drivers/net/nfp/nfp_net_cmsg.h | 37 +++++++++++++++++++ drivers/net/nfp/nfp_net_ctrl.h | 1 + 4 files changed, 105 insertions(+) create mode 100644 drivers/net/nfp/nfp_net_cmsg.c create mode 100644 drivers/net/nfp/nfp_net_cmsg.h diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build index 0d0a0bd8f4..46be6f60cd 100644 --- a/drivers/net/nfp/meson.build +++ b/drivers/net/nfp/meson.build @@ -34,6 +34,7 @@ sources = files( 'nfp_ipsec.c', 'nfp_logs.c', 'nfp_mtr.c', + 'nfp_net_cmsg.c', 'nfp_net_common.c', 'nfp_net_ctrl.c', 'nfp_net_flow.c', diff --git a/drivers/net/nfp/nfp_net_cmsg.c b/drivers/net/nfp/nfp_net_cmsg.c new file mode 100644 index 0000000000..f2f694be0b --- /dev/null +++ b/drivers/net/nfp/nfp_net_cmsg.c @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2023 Corigine, Inc. + * All rights reserved. + */ + +#include "nfp_net_cmsg.h" + +#include + +#include "nfp_logs.h" + +struct nfp_net_cmsg * +nfp_net_cmsg_alloc(uint32_t msg_size) +{ + struct nfp_net_cmsg *cmsg; + + cmsg = rte_zmalloc(NULL, msg_size, 0); + if (cmsg == NULL) { + PMD_DRV_LOG(ERR, "Failed malloc memory."); + return NULL; + } + + return cmsg; +} + +void +nfp_net_cmsg_free(struct nfp_net_cmsg *cmsg) +{ + rte_free(cmsg); +} + +int +nfp_net_cmsg_xmit(struct nfp_net_hw *hw, + struct nfp_net_cmsg *cmsg, + uint32_t msg_size) +{ + int ret; + uint32_t i; + + for (i = 0; i < msg_size; i++) + nn_cfg_writel(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, *((uint32_t *)cmsg + i)); + + ret = nfp_net_mbox_reconfig(hw, NFP_NET_CFG_MBOX_CMD_FLOW_STEER); + switch (ret) { + case NFP_NET_CFG_MBOX_RET_FS_OK: + break; + case NFP_NET_CFG_MBOX_RET_FS_ERR_NO_SPACE: + PMD_DRV_LOG(ERR, "Not enough space for cmd %u", cmsg->cmd); + ret = -ENOSPC; + break; + case NFP_NET_CFG_MBOX_RET_FS_ERR_MASK_FULL: + PMD_DRV_LOG(ERR, "The mask table is full for cmd %u", cmsg->cmd); + ret = -EXFULL; + break; + case NFP_NET_CFG_MBOX_RET_FS_ERR_CMD_INVALID: + PMD_DRV_LOG(ERR, "The mbox cmd %u invalid", cmsg->cmd); + ret = -EINVAL; + break; + default: + PMD_DRV_LOG(ERR, "Unrecognized mbox cmd %u", cmsg->cmd); + ret = -EINVAL; + break; + } + + return ret; +} diff --git a/drivers/net/nfp/nfp_net_cmsg.h b/drivers/net/nfp/nfp_net_cmsg.h new file mode 100644 index 0000000000..15e0bb60d8 --- /dev/null +++ b/drivers/net/nfp/nfp_net_cmsg.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2023 Corigine, Inc. + * All rights reserved. + */ + +#ifndef __NFP_NET_CMSG_H__ +#define __NFP_NET_CMSG_H__ + +#include "nfp_net_common.h" + +enum nfp_net_cfg_mbox_cmd { + NFP_NET_CFG_MBOX_CMD_FS_ADD_V4, /* Add Flow Steer rule for V4 table */ + NFP_NET_CFG_MBOX_CMD_FS_DEL_V4, /* Delete Flow Steer rule for V4 table */ + NFP_NET_CFG_MBOX_CMD_FS_ADD_V6, /* Add Flow Steer rule for V4 table */ + NFP_NET_CFG_MBOX_CMD_FS_DEL_V6, /* Delete Flow Steer rule for V4 table */ + NFP_NET_CFG_MBOX_CMD_FS_ADD_ETHTYPE, /* Add Flow Steer rule for Ethtype table */ + NFP_NET_CFG_MBOX_CMD_FS_DEL_ETHTYPE, /* Delete Flow Steer rule for Ethtype table */ +}; + +enum nfp_net_cfg_mbox_ret { + NFP_NET_CFG_MBOX_RET_FS_OK, /* No error happen */ + NFP_NET_CFG_MBOX_RET_FS_ERR_NO_SPACE, /* Return error code no space */ + NFP_NET_CFG_MBOX_RET_FS_ERR_MASK_FULL, /* Return error code mask table full */ + NFP_NET_CFG_MBOX_RET_FS_ERR_CMD_INVALID, /* Return error code invalid cmd */ +}; + +/* 4B cmd, and up to 500B data. */ +struct nfp_net_cmsg { + uint32_t cmd; /**< One of nfp_net_cfg_mbox_cmd */ + uint32_t data[0]; +}; + +struct nfp_net_cmsg *nfp_net_cmsg_alloc(uint32_t msg_size); +void nfp_net_cmsg_free(struct nfp_net_cmsg *cmsg); +int nfp_net_cmsg_xmit(struct nfp_net_hw *hw, struct nfp_net_cmsg *cmsg, uint32_t msg_size); + +#endif /* __NFP_NET_CMSG_H__ */ diff --git a/drivers/net/nfp/nfp_net_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h index ee1b784bb1..7ac0f89571 100644 --- a/drivers/net/nfp/nfp_net_ctrl.h +++ b/drivers/net/nfp/nfp_net_ctrl.h @@ -92,6 +92,7 @@ #define NFP_NET_CFG_MBOX_SIMPLE_VAL 0x8 #define NFP_NET_CFG_MBOX_CMD_IPSEC 3 +#define NFP_NET_CFG_MBOX_CMD_FLOW_STEER 10 /* * TLV capabilities -- 2.39.1