[03/10] net/nfp: add mailbox to support IPsec offload

Message ID 20230925060644.1458598-4-chaoyong.he@corigine.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series add the support of ipsec offload |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Sept. 25, 2023, 6:06 a.m. UTC
  From: Shihong Wang <shihong.wang@corigine.com>

Add general use per-vNIC mailbox area and use it for IPsec SA
offload support and get Rx/Tx packet statistics.

Signed-off-by: Shihong Wang <shihong.wang@corigine.com>
Signed-off-by: Chang Miao <chang.miao@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_common.c | 41 ++++++++++++++++++++++++++++++++++++
 drivers/net/nfp/nfp_common.h |  1 +
 drivers/net/nfp/nfp_ctrl.h   |  6 ++++++
 3 files changed, 48 insertions(+)
  

Patch

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 40027dbdfc..31dab3ae9b 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -320,6 +320,47 @@  nfp_net_ext_reconfig(struct nfp_net_hw *hw, uint32_t ctrl_ext, uint32_t update)
 	return 0;
 }
 
+/**
+ * Reconfigure the firmware via the mailbox
+ *
+ * @param hw
+ *   Device to reconfigure
+ * @param mbox_cmd
+ *   The value for the mailbox command
+ *
+ * @return
+ *   - (0) if OK to reconfigure by the mailbox.
+ *   - (-EIO) if I/O err and fail to reconfigure by the mailbox
+ */
+int
+nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
+		uint32_t mbox_cmd)
+{
+	int ret;
+	uint32_t mbox;
+
+	mbox = hw->tlv_caps.mbox_off;
+
+	rte_spinlock_lock(&hw->reconfig_lock);
+
+	nn_cfg_writeq(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
+
+	rte_wmb();
+
+	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_MBOX);
+
+	rte_spinlock_unlock(&hw->reconfig_lock);
+
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Error nft net mailbox reconfig: mbox=%#08x update=%#08x",
+				mbox_cmd, NFP_NET_CFG_UPDATE_MBOX);
+		return -EIO;
+	}
+
+	return nn_cfg_readl(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
+}
+
 /*
  * Configure an Ethernet device. This function must be invoked first
  * before any other function in the Ethernet API. This function can
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 4a19c18466..64f0af94c1 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -335,6 +335,7 @@  nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 /* Prototypes for common NFP functions */
 int nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update);
 int nfp_net_ext_reconfig(struct nfp_net_hw *hw, uint32_t ctrl_ext, uint32_t update);
+int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
 int nfp_net_configure(struct rte_eth_dev *dev);
 int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw);
 void nfp_net_log_device_information(const struct nfp_net_hw *hw);
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h
index 80a4196bea..d539846d02 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_ctrl.h
@@ -123,6 +123,7 @@ 
 #define   NFP_NET_CFG_UPDATE_IRQMOD       (0x1 <<  8) /* IRQ mod change */
 #define   NFP_NET_CFG_UPDATE_VXLAN        (0x1 <<  9) /* VXLAN port change */
 #define   NFP_NET_CFG_UPDATE_MACADDR      (0x1 << 11) /* MAC address change */
+#define   NFP_NET_CFG_UPDATE_MBOX         (0x1 << 12) /**< Mailbox update */
 #define   NFP_NET_CFG_UPDATE_ERR          (0x1U << 31) /* A error occurred */
 #define NFP_NET_CFG_TXRS_ENABLE         0x0008
 #define NFP_NET_CFG_RXRS_ENABLE         0x0010
@@ -447,6 +448,11 @@  struct nfp_net_fw_ver {
 #define NFP_NET_CFG_MBOX_BASE                 0x1800
 #define NFP_NET_CFG_MBOX_VAL                  0x1808
 #define NFP_NET_CFG_MBOX_VAL_MAX_SZ           0x1F8
+#define NFP_NET_CFG_MBOX_SIMPLE_CMD           0x0
+#define NFP_NET_CFG_MBOX_SIMPLE_RET           0x4
+#define NFP_NET_CFG_MBOX_SIMPLE_VAL           0x8
+
+#define NFP_NET_CFG_MBOX_CMD_IPSEC            3
 
 /*
  * TLV capabilities