From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <shreyansh.jain@nxp.com>
Subject: [dpdk-dev] [PATCH v4 16/20] net/dpaa2: add support for flow control
Date: Fri, 26 May 2017 12:21:21 +0530 [thread overview]
Message-ID: <1495781485-2236-17-git-send-email-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <1495781485-2236-1-git-send-email-hemant.agrawal@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
doc/guides/nics/features/dpaa2.ini | 1 +
drivers/net/dpaa2/dpaa2_ethdev.c | 142 ++++++++++++++++++++++++++++++++++++
drivers/net/dpaa2/mc/dpni.c | 18 +++++
drivers/net/dpaa2/mc/fsl_dpni.h | 24 ++++++
drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 8 ++
5 files changed, 193 insertions(+)
diff --git a/doc/guides/nics/features/dpaa2.ini b/doc/guides/nics/features/dpaa2.ini
index 4b1e000..720c35b 100644
--- a/doc/guides/nics/features/dpaa2.ini
+++ b/doc/guides/nics/features/dpaa2.ini
@@ -12,6 +12,7 @@ Allmulticast mode = Y
Unicast MAC filter = Y
RSS hash = Y
VLAN filter = Y
+Flow control = Y
VLAN offload = Y
L3 checksum offload = Y
L4 checksum offload = Y
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index fa9db17..edff04a 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1105,6 +1105,146 @@ void dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
return ret;
}
+static int
+dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
+{
+ int ret = -EINVAL;
+ struct dpaa2_dev_priv *priv;
+ struct fsl_mc_io *dpni;
+ struct dpni_link_state state = {0};
+
+ PMD_INIT_FUNC_TRACE();
+
+ priv = dev->data->dev_private;
+ dpni = (struct fsl_mc_io *)priv->hw;
+
+ if (dpni == NULL || fc_conf == NULL) {
+ RTE_LOG(ERR, PMD, "device not configured");
+ return ret;
+ }
+
+ ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
+ if (ret) {
+ RTE_LOG(ERR, PMD, "error: dpni_get_link_state %d", ret);
+ return ret;
+ }
+
+ memset(fc_conf, 0, sizeof(struct rte_eth_fc_conf));
+ if (state.options & DPNI_LINK_OPT_PAUSE) {
+ /* DPNI_LINK_OPT_PAUSE set
+ * if ASYM_PAUSE not set,
+ * RX Side flow control (handle received Pause frame)
+ * TX side flow control (send Pause frame)
+ * if ASYM_PAUSE set,
+ * RX Side flow control (handle received Pause frame)
+ * No TX side flow control (send Pause frame disabled)
+ */
+ if (!(state.options & DPNI_LINK_OPT_ASYM_PAUSE))
+ fc_conf->mode = RTE_FC_FULL;
+ else
+ fc_conf->mode = RTE_FC_RX_PAUSE;
+ } else {
+ /* DPNI_LINK_OPT_PAUSE not set
+ * if ASYM_PAUSE set,
+ * TX side flow control (send Pause frame)
+ * No RX side flow control (No action on pause frame rx)
+ * if ASYM_PAUSE not set,
+ * Flow control disabled
+ */
+ if (state.options & DPNI_LINK_OPT_ASYM_PAUSE)
+ fc_conf->mode = RTE_FC_TX_PAUSE;
+ else
+ fc_conf->mode = RTE_FC_NONE;
+ }
+
+ return ret;
+}
+
+static int
+dpaa2_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
+{
+ int ret = -EINVAL;
+ struct dpaa2_dev_priv *priv;
+ struct fsl_mc_io *dpni;
+ struct dpni_link_state state = {0};
+ struct dpni_link_cfg cfg = {0};
+
+ PMD_INIT_FUNC_TRACE();
+
+ priv = dev->data->dev_private;
+ dpni = (struct fsl_mc_io *)priv->hw;
+
+ if (dpni == NULL) {
+ RTE_LOG(ERR, PMD, "dpni is NULL");
+ return ret;
+ }
+
+ /* It is necessary to obtain the current state before setting fc_conf
+ * as MC would return error in case rate, autoneg or duplex values are
+ * different.
+ */
+ ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
+ if (ret) {
+ RTE_LOG(ERR, PMD, "Unable to get link state (err=%d)", ret);
+ return -1;
+ }
+
+ /* Disable link before setting configuration */
+ dpaa2_dev_set_link_down(dev);
+
+ /* Based on fc_conf, update cfg */
+ cfg.rate = state.rate;
+ cfg.options = state.options;
+
+ /* update cfg with fc_conf */
+ switch (fc_conf->mode) {
+ case RTE_FC_FULL:
+ /* Full flow control;
+ * OPT_PAUSE set, ASYM_PAUSE not set
+ */
+ cfg.options |= DPNI_LINK_OPT_PAUSE;
+ cfg.options &= ~DPNI_LINK_OPT_ASYM_PAUSE;
+ case RTE_FC_TX_PAUSE:
+ /* Enable RX flow control
+ * OPT_PAUSE not set;
+ * ASYM_PAUSE set;
+ */
+ cfg.options |= DPNI_LINK_OPT_ASYM_PAUSE;
+ cfg.options &= ~DPNI_LINK_OPT_PAUSE;
+ break;
+ case RTE_FC_RX_PAUSE:
+ /* Enable TX Flow control
+ * OPT_PAUSE set
+ * ASYM_PAUSE set
+ */
+ cfg.options |= DPNI_LINK_OPT_PAUSE;
+ cfg.options |= DPNI_LINK_OPT_ASYM_PAUSE;
+ break;
+ case RTE_FC_NONE:
+ /* Disable Flow control
+ * OPT_PAUSE not set
+ * ASYM_PAUSE not set
+ */
+ cfg.options &= ~DPNI_LINK_OPT_PAUSE;
+ cfg.options &= ~DPNI_LINK_OPT_ASYM_PAUSE;
+ break;
+ default:
+ RTE_LOG(ERR, PMD, "Incorrect Flow control flag (%d)",
+ fc_conf->mode);
+ return -1;
+ }
+
+ ret = dpni_set_link_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg);
+ if (ret)
+ RTE_LOG(ERR, PMD, "Unable to set Link configuration (err=%d)",
+ ret);
+
+ /* Enable link */
+ dpaa2_dev_set_link_up(dev);
+
+ return ret;
+}
+
static struct eth_dev_ops dpaa2_ethdev_ops = {
.dev_configure = dpaa2_eth_dev_configure,
.dev_start = dpaa2_dev_start,
@@ -1128,6 +1268,8 @@ void dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
.rx_queue_release = dpaa2_dev_rx_queue_release,
.tx_queue_setup = dpaa2_dev_tx_queue_setup,
.tx_queue_release = dpaa2_dev_tx_queue_release,
+ .flow_ctrl_get = dpaa2_flow_ctrl_get,
+ .flow_ctrl_set = dpaa2_flow_ctrl_set,
.mac_addr_add = dpaa2_dev_add_mac_addr,
.mac_addr_remove = dpaa2_dev_remove_mac_addr,
.mac_addr_set = dpaa2_dev_set_mac_addr,
diff --git a/drivers/net/dpaa2/mc/dpni.c b/drivers/net/dpaa2/mc/dpni.c
index 0ad6d11..dbe3f7c 100644
--- a/drivers/net/dpaa2/mc/dpni.c
+++ b/drivers/net/dpaa2/mc/dpni.c
@@ -444,6 +444,24 @@ int dpni_get_qdid(struct fsl_mc_io *mc_io,
return 0;
}
+
+int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
+ uint32_t cmd_flags,
+ uint16_t token,
+ const struct dpni_link_cfg *cfg)
+{
+ struct mc_command cmd = { 0 };
+
+ /* prepare command */
+ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG,
+ cmd_flags,
+ token);
+ DPNI_CMD_SET_LINK_CFG(cmd, cfg);
+
+ /* send command to mc*/
+ return mc_send_command(mc_io, &cmd);
+}
+
int dpni_get_link_state(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
diff --git a/drivers/net/dpaa2/mc/fsl_dpni.h b/drivers/net/dpaa2/mc/fsl_dpni.h
index 2f69526..bf31872 100644
--- a/drivers/net/dpaa2/mc/fsl_dpni.h
+++ b/drivers/net/dpaa2/mc/fsl_dpni.h
@@ -740,6 +740,30 @@ int dpni_get_qdid(struct fsl_mc_io *mc_io,
#define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
/**
+ * struct - Structure representing DPNI link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
+ */
+struct dpni_link_cfg {
+ uint32_t rate;
+ uint64_t options;
+};
+
+/**
+ * dpni_set_link_cfg() - set the link configuration.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPNI object
+ * @cfg: Link configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
+ uint32_t cmd_flags,
+ uint16_t token,
+ const struct dpni_link_cfg *cfg);
+
+/**
* struct dpni_link_state - Structure representing DPNI link state
* @rate: Rate
* @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
diff --git a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h
index 6e96271..4395aac 100644
--- a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h
+++ b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h
@@ -64,6 +64,7 @@
#define DPNI_CMDID_GET_LINK_STATE ((0x215 << 4) | (0x1))
#define DPNI_CMDID_SET_MAX_FRAME_LENGTH ((0x216 << 4) | (0x1))
#define DPNI_CMDID_GET_MAX_FRAME_LENGTH ((0x217 << 4) | (0x1))
+#define DPNI_CMDID_SET_LINK_CFG ((0x21a << 4) | (0x1))
#define DPNI_CMDID_SET_MCAST_PROMISC ((0x220 << 4) | (0x1))
#define DPNI_CMDID_GET_MCAST_PROMISC ((0x221 << 4) | (0x1))
@@ -238,6 +239,13 @@
} while (0)
/* cmd, param, offset, width, type, arg_name */
+#define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
+do { \
+ MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
+ MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
+} while (0)
+
+/* cmd, param, offset, width, type, arg_name */
#define DPNI_RSP_GET_LINK_STATE(cmd, state) \
do { \
MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
--
1.9.1
next prev parent reply other threads:[~2017-05-26 6:52 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-19 13:09 [dpdk-dev] [PATCH 1/4] net/dpaa2: stop using software annotation Hemant Agrawal
2017-04-19 13:09 ` [dpdk-dev] [PATCH 2/4] net/dpaa2: improve the error handling in dev init Hemant Agrawal
2017-05-12 13:51 ` Ferruh Yigit
2017-04-19 13:09 ` [dpdk-dev] [PATCH 3/4] bus/fslmc: support for multiple parallel dq requests Hemant Agrawal
2017-05-12 13:53 ` Ferruh Yigit
2017-04-19 13:09 ` [dpdk-dev] [PATCH 4/4] net/dpaa2: support parallel recv mode Hemant Agrawal
2017-05-12 13:48 ` Ferruh Yigit
2017-05-15 8:26 ` Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 PMD functional enhancements Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 01/20] mk: change to cortex-a72 Hemant Agrawal
2017-05-15 16:49 ` Ferruh Yigit
2017-05-16 15:06 ` Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 02/20] net/dpaa2: remove port level buffer layout definition Hemant Agrawal
2017-05-15 16:50 ` Ferruh Yigit
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 03/20] net/dpaa2: stop using software annotation Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 04/20] net/dpaa2: improve the error handling in dev init Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 05/20] bus/fslmc: support for parallel Rx DQ requests Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 06/20] net/dpaa2: support parallel Rx mode Hemant Agrawal
2017-05-15 12:37 ` Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 07/20] bus/fslmc: export qbman results in map file Hemant Agrawal
2017-05-15 16:55 ` Ferruh Yigit
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 08/20] net/dpaa2: add support for congestion notification Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 09/20] net/dpaa2: add support for tail drop on queue Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 10/20] bus/fslmc: update TAILQ usages in dpaa2 objects Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 11/20] net/dpaa2: add support for MAC address filtering Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 12/20] net/dpaa2: add support for multicast promiscuous mode Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 13/20] net/dpaa2: add support for VLAN filter and offload Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 14/20] net/dpaa2: add support for VLAN strip Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 15/20] net/dpaa2: add link status config support Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 16/20] net/dpaa2: add support for flow control Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 17/20] net/dpaa2: configure jumbo frames Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 18/20] bus/fslmc: add support to detect soc version Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 19/20] net/dpaa2: add support for Firmware Version get Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 20/20] bus/fslmc: reducing the debug log messages Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 PMD functional enhancements Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 01/20] mk: change to cortex-a72 Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 02/20] net/dpaa2: remove port level buffer layout definition Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 03/20] net/dpaa2: stop using software annotation Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 04/20] net/dpaa2: improve the error handling in dev init Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 05/20] bus/fslmc: support for parallel Rx DQ requests Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 06/20] net/dpaa2: support parallel Rx in eth pmd Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 07/20] bus/fslmc: export qbman results in map file Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 08/20] net/dpaa2: add support for congestion notification Hemant Agrawal
2017-05-24 11:45 ` Ferruh Yigit
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 09/20] net/dpaa2: add support for tail drop on queue Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 10/20] bus/fslmc: update TAILQ usages in dpaa2 objects Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 11/20] net/dpaa2: add support for MAC address filtering Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 12/20] net/dpaa2: add support for multicast promiscuous mode Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 13/20] net/dpaa2: add support for VLAN filter and offload Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 14/20] net/dpaa2: add support for VLAN strip Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 15/20] net/dpaa2: add link status config support Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 16/20] net/dpaa2: add support for flow control Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 17/20] net/dpaa2: configure jumbo frames Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 18/20] bus/fslmc: add support to detect soc version Hemant Agrawal
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 19/20] net/dpaa2: add support for Firmware Version get Hemant Agrawal
2017-05-24 11:43 ` Ferruh Yigit
2017-05-22 9:39 ` [dpdk-dev] [PATCH v3 20/20] bus/fslmc: reducing the debug log messages Hemant Agrawal
2017-05-24 11:49 ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 PMD functional enhancements Ferruh Yigit
2017-05-26 7:51 ` Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 " Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 01/20] mk: change to cortex-a72 Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 02/20] net/dpaa2: remove port level buffer layout definition Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 03/20] net/dpaa2: stop using software annotation Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 04/20] net/dpaa2: improve the error handling in dev init Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 05/20] bus/fslmc: support for parallel Rx DQ requests Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 06/20] net/dpaa2: support parallel Rx in eth pmd Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 07/20] bus/fslmc: export qbman results in map file Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 08/20] net/dpaa2: add support for congestion notification Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 09/20] net/dpaa2: add support for tail drop on queue Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 10/20] bus/fslmc: update TAILQ usages in dpaa2 objects Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 11/20] net/dpaa2: add support for MAC address filtering Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 12/20] net/dpaa2: add support for multicast promiscuous mode Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 13/20] net/dpaa2: add support for VLAN filter and offload Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 14/20] net/dpaa2: add support for VLAN strip Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 15/20] net/dpaa2: add link status config support Hemant Agrawal
2017-05-26 6:51 ` Hemant Agrawal [this message]
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 17/20] net/dpaa2: configure jumbo frames Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 18/20] bus/fslmc: add support to detect soc version Hemant Agrawal
2017-05-26 8:51 ` Ferruh Yigit
2017-05-26 9:26 ` [dpdk-dev] [PATCH] bus/fslmc: fix license information Shreyansh Jain
2017-05-26 9:22 ` Ferruh Yigit
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 19/20] net/dpaa2: add support for Firmware Version get Hemant Agrawal
2017-05-26 6:51 ` [dpdk-dev] [PATCH v4 20/20] bus/fslmc: reducing the debug log messages Hemant Agrawal
2017-05-26 8:47 ` [dpdk-dev] [PATCH v4 00/20] NXP DPAA2 PMD functional enhancements 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=1495781485-2236-17-git-send-email-hemant.agrawal@nxp.com \
--to=hemant.agrawal@nxp.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=shreyansh.jain@nxp.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).