From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 10/13] mlx5: add flow control device operations
Date: Mon, 5 Oct 2015 19:53:06 +0200 [thread overview]
Message-ID: <1444067589-29513-11-git-send-email-adrien.mazarguil@6wind.com> (raw)
In-Reply-To: <1444067589-29513-1-git-send-email-adrien.mazarguil@6wind.com>
Like most other device control operations, those are handled by the related
kernel network device through syscalls.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
drivers/net/mlx5/mlx5.c | 2 +
drivers/net/mlx5/mlx5.h | 2 +
drivers/net/mlx5/mlx5_ethdev.c | 99 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 103 insertions(+)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index cb66186..b182d0b 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -145,6 +145,8 @@ static const struct eth_dev_ops mlx5_dev_ops = {
.tx_queue_setup = mlx5_tx_queue_setup,
.rx_queue_release = mlx5_rx_queue_release,
.tx_queue_release = mlx5_tx_queue_release,
+ .flow_ctrl_get = mlx5_dev_get_flow_ctrl,
+ .flow_ctrl_set = mlx5_dev_set_flow_ctrl,
.mac_addr_remove = mlx5_mac_addr_remove,
.mac_addr_add = mlx5_mac_addr_add,
.mtu_set = mlx5_dev_set_mtu,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 3078f13..1d488fb 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -171,6 +171,8 @@ int mlx5_dev_configure(struct rte_eth_dev *);
void mlx5_dev_infos_get(struct rte_eth_dev *, struct rte_eth_dev_info *);
int mlx5_link_update(struct rte_eth_dev *, int);
int mlx5_dev_set_mtu(struct rte_eth_dev *, uint16_t);
+int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *, struct rte_eth_fc_conf *);
+int mlx5_dev_set_flow_ctrl(struct rte_eth_dev *, struct rte_eth_fc_conf *);
int mlx5_ibv_device_to_pci_addr(const struct ibv_device *,
struct rte_pci_addr *);
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index a665725..181a877 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -694,6 +694,105 @@ out:
}
/**
+ * DPDK callback to get flow control status.
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ * @param[out] fc_conf
+ * Flow control output buffer.
+ *
+ * @return
+ * 0 on success, negative errno value on failure.
+ */
+int
+mlx5_dev_get_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
+{
+ struct priv *priv = dev->data->dev_private;
+ struct ifreq ifr;
+ struct ethtool_pauseparam ethpause = {
+ .cmd = ETHTOOL_GPAUSEPARAM
+ };
+ int ret;
+
+ ifr.ifr_data = ðpause;
+ priv_lock(priv);
+ if (priv_ifreq(priv, SIOCETHTOOL, &ifr)) {
+ ret = errno;
+ WARN("ioctl(SIOCETHTOOL, ETHTOOL_GPAUSEPARAM)"
+ " failed: %s",
+ strerror(ret));
+ goto out;
+ }
+
+ fc_conf->autoneg = ethpause.autoneg;
+ if (ethpause.rx_pause && ethpause.tx_pause)
+ fc_conf->mode = RTE_FC_FULL;
+ else if (ethpause.rx_pause)
+ fc_conf->mode = RTE_FC_RX_PAUSE;
+ else if (ethpause.tx_pause)
+ fc_conf->mode = RTE_FC_TX_PAUSE;
+ else
+ fc_conf->mode = RTE_FC_NONE;
+ ret = 0;
+
+out:
+ priv_unlock(priv);
+ assert(ret >= 0);
+ return -ret;
+}
+
+/**
+ * DPDK callback to modify flow control parameters.
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ * @param[in] fc_conf
+ * Flow control parameters.
+ *
+ * @return
+ * 0 on success, negative errno value on failure.
+ */
+int
+mlx5_dev_set_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
+{
+ struct priv *priv = dev->data->dev_private;
+ struct ifreq ifr;
+ struct ethtool_pauseparam ethpause = {
+ .cmd = ETHTOOL_SPAUSEPARAM
+ };
+ int ret;
+
+ ifr.ifr_data = ðpause;
+ ethpause.autoneg = fc_conf->autoneg;
+ if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+ (fc_conf->mode & RTE_FC_RX_PAUSE))
+ ethpause.rx_pause = 1;
+ else
+ ethpause.rx_pause = 0;
+
+ if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+ (fc_conf->mode & RTE_FC_TX_PAUSE))
+ ethpause.tx_pause = 1;
+ else
+ ethpause.tx_pause = 0;
+
+ priv_lock(priv);
+ if (priv_ifreq(priv, SIOCETHTOOL, &ifr)) {
+ ret = errno;
+ WARN("ioctl(SIOCETHTOOL, ETHTOOL_SPAUSEPARAM)"
+ " failed: %s",
+ strerror(ret));
+ goto out;
+ }
+ ret = 0;
+
+out:
+ priv_unlock(priv);
+ assert(ret >= 0);
+ return -ret;
+}
+
+/**
* Get PCI information from struct ibv_device.
*
* @param device
--
2.1.0
next prev parent reply other threads:[~2015-10-05 17:53 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-05 17:52 [dpdk-dev] [PATCH 00/13] Mellanox ConnectX-4 PMD (mlx5) Adrien Mazarguil
2015-10-05 17:52 ` [dpdk-dev] [PATCH 01/13] mlx5: new poll-mode driver for Mellanox ConnectX-4 adapters Adrien Mazarguil
2015-10-05 17:52 ` [dpdk-dev] [PATCH 02/13] mlx5: add non-scattered TX and RX support Adrien Mazarguil
2015-10-05 17:52 ` [dpdk-dev] [PATCH 03/13] mlx5: add MAC handling Adrien Mazarguil
2015-10-05 17:53 ` [dpdk-dev] [PATCH 04/13] mlx5: add device configure/start/stop Adrien Mazarguil
2015-10-05 17:53 ` [dpdk-dev] [PATCH 05/13] mlx5: add support for scattered RX and TX buffers Adrien Mazarguil
2015-10-05 17:53 ` [dpdk-dev] [PATCH 06/13] mlx5: add MTU configuration support Adrien Mazarguil
2015-10-05 17:53 ` [dpdk-dev] [PATCH 07/13] mlx5: add software counters and related callbacks Adrien Mazarguil
2015-10-05 17:53 ` [dpdk-dev] [PATCH 08/13] mlx5: add promiscuous and allmulticast RX modes Adrien Mazarguil
2015-10-05 17:53 ` [dpdk-dev] [PATCH 09/13] mlx5: add link update device operation Adrien Mazarguil
2015-10-05 17:53 ` Adrien Mazarguil [this message]
2015-10-05 17:53 ` [dpdk-dev] [PATCH 11/13] mlx5: add VLAN filtering Adrien Mazarguil
2015-10-05 17:53 ` [dpdk-dev] [PATCH 12/13] mlx5: add checksum offloading support Adrien Mazarguil
2015-10-05 17:53 ` [dpdk-dev] [PATCH 13/13] doc: add mlx5 documentation and release notes for version 2.2 Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 00/13] Mellanox ConnectX-4 PMD (mlx5) Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 01/13] mlx5: new poll-mode driver for Mellanox ConnectX-4 adapters Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 02/13] mlx5: add non-scattered TX and RX support Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 03/13] mlx5: add MAC handling Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 04/13] mlx5: add device configure/start/stop Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 05/13] mlx5: add support for scattered RX and TX buffers Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 06/13] mlx5: add MTU configuration support Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 07/13] mlx5: add software counters and related callbacks Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 08/13] mlx5: add promiscuous and allmulticast RX modes Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 09/13] mlx5: add link update device operation Adrien Mazarguil
2015-11-02 17:52 ` Stephen Hemminger
2015-11-02 18:27 ` Adrien Mazarguil
2015-11-02 18:43 ` Stephen Hemminger
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 10/13] mlx5: add flow control device operations Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 11/13] mlx5: add VLAN filtering Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 12/13] mlx5: add checksum offloading support Adrien Mazarguil
2015-10-30 18:52 ` [dpdk-dev] [PATCH v2 13/13] doc: add mlx5 documentation and release notes for version 2.2 Adrien Mazarguil
2015-10-30 23:18 ` [dpdk-dev] [PATCH v2 00/13] Mellanox ConnectX-4 PMD (mlx5) Thomas Monjalon
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=1444067589-29513-11-git-send-email-adrien.mazarguil@6wind.com \
--to=adrien.mazarguil@6wind.com \
--cc=dev@dpdk.org \
/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).