From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 03/11] net/nfp: add the control message channel
Date: Fri, 3 Nov 2023 14:25:58 +0800 [thread overview]
Message-ID: <20231103062606.2632012-4-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20231103062606.2632012-1-chaoyong.he@corigine.com>
Using the mailbox, which serves as the control message channel
between driver and CoreNIC firmware.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
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 <rte_malloc.h>
+
+#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
next prev parent reply other threads:[~2023-11-03 6:26 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 6:25 [PATCH 00/11] Add basic flow support for corenic firmware Chaoyong He
2023-11-03 6:25 ` [PATCH 01/11] net/nfp: move some source files Chaoyong He
2023-11-03 6:25 ` [PATCH 02/11] drivers: add the structures and functions for flow offload Chaoyong He
2023-11-03 6:25 ` Chaoyong He [this message]
2023-11-03 6:25 ` [PATCH 04/11] net/nfp: support flow API for CoreNIC firmware Chaoyong He
2023-11-03 6:26 ` [PATCH 05/11] net/nfp: support Ethernet flow item Chaoyong He
2023-11-03 6:26 ` [PATCH 06/11] net/nfp: support drop flow action Chaoyong He
2023-11-03 6:26 ` [PATCH 07/11] net/nfp: support IPv4 flow item Chaoyong He
2023-11-03 6:26 ` [PATCH 08/11] net/nfp: support IPv6 " Chaoyong He
2023-11-03 6:26 ` [PATCH 09/11] net/nfp: support TCP/UDP/SCTP flow items Chaoyong He
2023-11-03 6:26 ` [PATCH 10/11] drivers: support MARK flow action Chaoyong He
2023-11-03 6:26 ` [PATCH 11/11] net/nfp: support QUEUE " Chaoyong He
2023-11-03 16:12 ` [PATCH 00/11] Add basic flow support for corenic firmware Ferruh Yigit
2023-11-07 1:42 ` Chaoyong He
2023-11-07 9:18 ` Ferruh Yigit
2023-11-07 9:23 ` Chaoyong He
2023-11-07 16:50 ` Patrick Robb
2023-11-07 17:04 ` Patrick Robb
2023-11-07 20:19 ` Ferruh Yigit
2023-11-07 21:59 ` Patrick Robb
2023-11-03 17:01 ` Ferruh Yigit
2023-12-05 2:54 ` [PATCH v2 " Chaoyong He
2023-12-05 2:54 ` [PATCH v2 01/11] net/nfp: move some source files Chaoyong He
2023-12-05 2:54 ` [PATCH v2 02/11] net/nfp: add the structures and functions for flow offload Chaoyong He
2023-12-05 2:54 ` [PATCH v2 03/11] net/nfp: add the control message channel Chaoyong He
2023-12-08 19:15 ` Ferruh Yigit
2023-12-05 2:54 ` [PATCH v2 04/11] net/nfp: support flow API for CoreNIC firmware Chaoyong He
2023-12-05 2:54 ` [PATCH v2 05/11] net/nfp: support Ethernet flow item Chaoyong He
2023-12-05 2:54 ` [PATCH v2 06/11] net/nfp: support drop flow action Chaoyong He
2023-12-05 2:54 ` [PATCH v2 07/11] net/nfp: support IPv4 flow item Chaoyong He
2023-12-05 2:54 ` [PATCH v2 08/11] net/nfp: support IPv6 " Chaoyong He
2023-12-05 2:54 ` [PATCH v2 09/11] net/nfp: support TCP/UDP/SCTP flow items Chaoyong He
2023-12-05 2:54 ` [PATCH v2 10/11] net/nfp: support MARK flow action Chaoyong He
2023-12-05 2:54 ` [PATCH v2 11/11] net/nfp: support QUEUE " Chaoyong He
2023-12-08 16:39 ` [PATCH v2 00/11] Add basic flow support for corenic firmware Ferruh Yigit
2023-12-11 1:42 ` Chaoyong He
2023-12-11 14:06 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231103062606.2632012-4-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).