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 C9106A054A; Thu, 11 Feb 2021 15:29:37 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F8F71CC56E; Thu, 11 Feb 2021 15:28:15 +0100 (CET) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id 220231CC505 for ; Thu, 11 Feb 2021 15:28:04 +0100 (CET) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 018E32008D8; Thu, 11 Feb 2021 15:28:04 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 8AAF52008E7; Thu, 11 Feb 2021 15:28:02 +0100 (CET) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id DCA89402E5; Thu, 11 Feb 2021 15:28:00 +0100 (CET) From: Hemant Agrawal To: dev@dpdk.org, ferruh.yigit@intel.com Date: Thu, 11 Feb 2021 19:46:11 +0530 Message-Id: <20210211141620.12482-12-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210211141620.12482-1-hemant.agrawal@nxp.com> References: <20210120142723.14090-1-hemant.agrawal@nxp.com> <20210211141620.12482-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 11/20] net/dpaa2: dpdmux skip reset 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 Sender: "dev" From: Apeksha Gupta 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 --- 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(-) 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_' 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 */ -- 2.17.1