diff mbox series

[v2,11/20] net/dpaa2: dpdmux skip reset

Message ID 20210211141620.12482-12-hemant.agrawal@nxp.com
State Superseded
Headers show
Series NXP DPAAx ethernet PMD changes | expand

Commit Message

Hemant Agrawal Feb. 11, 2021, 2:16 p.m. UTC
From: Apeksha Gupta <apeksha.gupta@nxp.com>


This is require as the interface is shared with linux and we do not want
the dpdmux to be reset. rather the default interface to kernel shall
continue.
command dpdmux_set_resetable is used to skip DPDMUX reset.
By default the DPDMUX_RESET command will reset the DPDMUX completely,
dpdmux_set_resetable command will be ignored in old MC firmware.

Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>

---
 drivers/net/dpaa2/dpaa2_mux.c         | 26 +++++++++
 drivers/net/dpaa2/mc/dpdmux.c         | 84 +++++++++++++++++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux.h     | 32 ++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h | 22 ++++++-
 4 files changed, 161 insertions(+), 3 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
index b669a16fc1..1ff00ca8f7 100644
--- a/drivers/net/dpaa2/dpaa2_mux.c
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -264,6 +264,8 @@  dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
 	struct dpaa2_dpdmux_dev *dpdmux_dev;
 	struct dpdmux_attr attr;
 	int ret;
+	uint16_t maj_ver;
+	uint16_t min_ver;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -298,6 +300,30 @@  dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
 		goto init_err;
 	}
 
+	ret = dpdmux_get_api_version(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+					&maj_ver, &min_ver);
+	if (ret) {
+		DPAA2_PMD_ERR("setting version failed in %s",
+				__func__);
+		goto init_err;
+	}
+
+	/* The new dpdmux_set/get_resetable() API are available starting with
+	 * DPDMUX_VER_MAJOR==6 and DPDMUX_VER_MINOR==6
+	 */
+	if (maj_ver >= 6 && min_ver >= 6) {
+		ret = dpdmux_set_resetable(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				dpdmux_dev->token,
+				DPDMUX_SKIP_DEFAULT_INTERFACE |
+				DPDMUX_SKIP_UNICAST_RULES |
+				DPDMUX_SKIP_MULTICAST_RULES);
+		if (ret) {
+			DPAA2_PMD_ERR("setting default interface failed in %s",
+				      __func__);
+			goto init_err;
+		}
+	}
+
 	dpdmux_dev->dpdmux_id = dpdmux_id;
 	dpdmux_dev->num_ifs = attr.num_ifs;
 
diff --git a/drivers/net/dpaa2/mc/dpdmux.c b/drivers/net/dpaa2/mc/dpdmux.c
index 67d37ed4cd..57c811c70f 100644
--- a/drivers/net/dpaa2/mc/dpdmux.c
+++ b/drivers/net/dpaa2/mc/dpdmux.c
@@ -123,10 +123,12 @@  int dpdmux_create(struct fsl_mc_io *mc_io,
 	cmd_params->method = cfg->method;
 	cmd_params->manip = cfg->manip;
 	cmd_params->num_ifs = cpu_to_le16(cfg->num_ifs);
+	cmd_params->default_if = cpu_to_le16(cfg->default_if);
 	cmd_params->adv_max_dmat_entries =
 			cpu_to_le16(cfg->adv.max_dmat_entries);
 	cmd_params->adv_max_mc_groups = cpu_to_le16(cfg->adv.max_mc_groups);
 	cmd_params->adv_max_vlan_ids = cpu_to_le16(cfg->adv.max_vlan_ids);
+	cmd_params->mem_size = cpu_to_le16(cfg->adv.mem_size);
 	cmd_params->options = cpu_to_le64(cfg->adv.options);
 
 	/* send command to mc*/
@@ -278,6 +280,87 @@  int dpdmux_reset(struct fsl_mc_io *mc_io,
 	return mc_send_command(mc_io, &cmd);
 }
 
+/**
+ * dpdmux_set_resetable() - Set overall resetable DPDMUX parameters.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @skip_reset_flags:	By default all are 0.
+ *			By setting 1 will deactivate the reset.
+ *	The flags are:
+ *			DPDMUX_SKIP_DEFAULT_INTERFACE  0x01
+ *			DPDMUX_SKIP_UNICAST_RULES      0x02
+ *			DPDMUX_SKIP_MULTICAST_RULES    0x04
+ *
+ * For example, by default, through DPDMUX_RESET the default
+ * interface will be restored with the one from create.
+ * By setting DPDMUX_SKIP_DEFAULT_INTERFACE flag,
+ * through DPDMUX_RESET the default interface will not be modified.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_set_resetable(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint8_t skip_reset_flags)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_set_skip_reset_flags *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_RESETABLE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_set_skip_reset_flags *)cmd.params;
+	dpdmux_set_field(cmd_params->skip_reset_flags,
+			SKIP_RESET_FLAGS,
+			skip_reset_flags);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_get_resetable() - Get overall resetable parameters.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @skip_reset_flags:	Get the reset flags.
+ *
+ *	The flags are:
+ *			DPDMUX_SKIP_DEFAULT_INTERFACE  0x01
+ *			DPDMUX_SKIP_UNICAST_RULES      0x02
+ *			DPDMUX_SKIP_MULTICAST_RULES    0x04
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_get_resetable(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint8_t *skip_reset_flags)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_get_skip_reset_flags *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_RESETABLE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_get_skip_reset_flags *)cmd.params;
+	*skip_reset_flags = dpdmux_get_field(rsp_params->skip_reset_flags,
+			SKIP_RESET_FLAGS);
+
+	return 0;
+}
+
 /**
  * dpdmux_get_attributes() - Retrieve DPDMUX attributes
  * @mc_io:	Pointer to MC portal's I/O object
@@ -314,6 +397,7 @@  int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
 	attr->manip = rsp_params->manip;
 	attr->num_ifs = le16_to_cpu(rsp_params->num_ifs);
 	attr->mem_size = le16_to_cpu(rsp_params->mem_size);
+	attr->default_if = le16_to_cpu(rsp_params->default_if);
 
 	return 0;
 }
diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux.h b/drivers/net/dpaa2/mc/fsl_dpdmux.h
index b809aade5d..f035f0f24e 100644
--- a/drivers/net/dpaa2/mc/fsl_dpdmux.h
+++ b/drivers/net/dpaa2/mc/fsl_dpdmux.h
@@ -79,6 +79,8 @@  enum dpdmux_method {
  * @method: Defines the operation method for the DPDMUX address table
  * @manip: Required manipulation operation
  * @num_ifs: Number of interfaces (excluding the uplink interface)
+ * @default_if: Default interface number (different from uplink,
+	maximum value num_ifs)
  * @adv: Advanced parameters; default is all zeros;
  *	use this structure to change default settings
  * @adv.options: DPDMUX options - combination of 'DPDMUX_OPT_<X>' flags.
@@ -89,16 +91,20 @@  enum dpdmux_method {
  * @adv.max_vlan_ids: Maximum vlan ids allowed in the system -
  *	relevant only case of working in mac+vlan method.
  *	0 - indicates default 16 vlan ids.
+ * @adv.mem_size: Size of the memory used for internal buffers expressed as
+ * number of 256byte buffers.
  */
 struct dpdmux_cfg {
 	enum dpdmux_method method;
 	enum dpdmux_manip manip;
 	uint16_t num_ifs;
+	uint16_t default_if;
 	struct {
 		uint64_t options;
 		uint16_t max_dmat_entries;
 		uint16_t max_mc_groups;
 		uint16_t max_vlan_ids;
+		uint16_t mem_size;
 	} adv;
 };
 
@@ -130,6 +136,29 @@  int dpdmux_reset(struct fsl_mc_io *mc_io,
 		 uint32_t cmd_flags,
 		 uint16_t token);
 
+/**
+ *Setting 1 DPDMUX_RESET will not reset default interface
+ */
+#define DPDMUX_SKIP_DEFAULT_INTERFACE	0x01
+/**
+ *Setting 1 DPDMUX_RESET will not reset unicast rules
+ */
+#define DPDMUX_SKIP_UNICAST_RULES	0x02
+/**
+ *Setting 1 DPDMUX_RESET will not reset multicast rules
+ */
+#define DPDMUX_SKIP_MULTICAST_RULES	0x04
+
+int dpdmux_set_resetable(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint8_t skip_reset_flags);
+
+int dpdmux_get_resetable(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint8_t *skip_reset_flags);
+
 /**
  * struct dpdmux_attr - Structure representing DPDMUX attributes
  * @id: DPDMUX object ID
@@ -138,6 +167,8 @@  int dpdmux_reset(struct fsl_mc_io *mc_io,
  * @manip: DPDMUX manipulation type
  * @num_ifs: Number of interfaces (excluding the uplink interface)
  * @mem_size: DPDMUX frame storage memory size
+ * @default_if: Default interface number (different from uplink,
+	maximum value num_ifs)
  */
 struct dpdmux_attr {
 	int id;
@@ -146,6 +177,7 @@  struct dpdmux_attr {
 	enum dpdmux_manip manip;
 	uint16_t num_ifs;
 	uint16_t mem_size;
+	uint16_t default_if;
 };
 
 int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
index b6b8c38c41..2444e9a2e5 100644
--- a/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
+++ b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
@@ -55,6 +55,9 @@ 
 #define DPDMUX_CMDID_IF_SET_DEFAULT		DPDMUX_CMD(0x0b8)
 #define DPDMUX_CMDID_IF_GET_DEFAULT		DPDMUX_CMD(0x0b9)
 
+#define DPDMUX_CMDID_SET_RESETABLE		DPDMUX_CMD(0x0ba)
+#define DPDMUX_CMDID_GET_RESETABLE		DPDMUX_CMD(0x0bb)
+
 #define DPDMUX_MASK(field)        \
 	GENMASK(DPDMUX_##field##_SHIFT + DPDMUX_##field##_SIZE - 1, \
 		DPDMUX_##field##_SHIFT)
@@ -72,12 +75,13 @@  struct dpdmux_cmd_create {
 	uint8_t method;
 	uint8_t manip;
 	uint16_t num_ifs;
-	uint32_t pad;
+	uint16_t default_if;
+	uint16_t pad;
 
 	uint16_t adv_max_dmat_entries;
 	uint16_t adv_max_mc_groups;
 	uint16_t adv_max_vlan_ids;
-	uint16_t pad1;
+	uint16_t mem_size;
 
 	uint64_t options;
 };
@@ -100,7 +104,7 @@  struct dpdmux_rsp_get_attr {
 	uint8_t manip;
 	uint16_t num_ifs;
 	uint16_t mem_size;
-	uint16_t pad;
+	uint16_t default_if;
 
 	uint64_t pad1;
 
@@ -217,5 +221,17 @@  struct dpdmux_cmd_remove_custom_cls_entry {
 	uint64_t key_iova;
 	uint64_t mask_iova;
 };
+
+#define DPDMUX_SKIP_RESET_FLAGS_SHIFT    0
+#define DPDMUX_SKIP_RESET_FLAGS_SIZE     3
+
+struct dpdmux_cmd_set_skip_reset_flags {
+	uint8_t skip_reset_flags;
+};
+
+struct dpdmux_rsp_get_skip_reset_flags {
+	uint8_t skip_reset_flags;
+};
+
 #pragma pack(pop)
 #endif /* _FSL_DPDMUX_CMD_H */