summaryrefslogtreecommitdiff
path: root/drivers/net/mvneta/mvneta_ethdev.c
diff options
context:
space:
mode:
authorZyta Szpak <zr@semihalf.com>2018-10-03 09:22:12 +0200
committerFerruh Yigit <ferruh.yigit@intel.com>2018-10-11 18:53:48 +0200
commit88d3cb3c038ce310da4b2277150e372a6db05698 (patch)
treee81624aa875120884ed0d54a205ec0c67eae72b5 /drivers/net/mvneta/mvneta_ethdev.c
parent112ef72539610e867c7b4ac94cb4c2fbb8c646b0 (diff)
downloaddpdk-88d3cb3c038ce310da4b2277150e372a6db05698.zip
dpdk-88d3cb3c038ce310da4b2277150e372a6db05698.tar.gz
dpdk-88d3cb3c038ce310da4b2277150e372a6db05698.tar.xz
net/mvneta: add link update
Add callback for updating information about link status/info. Signed-off-by: Natalie Samsonov <nsamsono@marvell.com> Signed-off-by: Zyta Szpak <zr@semihalf.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Diffstat (limited to 'drivers/net/mvneta/mvneta_ethdev.c')
-rw-r--r--drivers/net/mvneta/mvneta_ethdev.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index 24f87e2..052e97f 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -452,6 +452,76 @@ mvneta_dev_close(struct rte_eth_dev *dev)
}
/**
+ * DPDK callback to retrieve physical link information.
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ * @param wait_to_complete
+ * Wait for request completion (ignored).
+ *
+ * @return
+ * 0 on success, negative error value otherwise.
+ */
+static int
+mvneta_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
+{
+ /*
+ * TODO
+ * once MUSDK provides necessary API use it here
+ */
+ struct mvneta_priv *priv = dev->data->dev_private;
+ struct ethtool_cmd edata;
+ struct ifreq req;
+ int ret, fd, link_up;
+
+ if (!priv->ppio)
+ return -EPERM;
+
+ edata.cmd = ETHTOOL_GSET;
+
+ strcpy(req.ifr_name, dev->data->name);
+ req.ifr_data = (void *)&edata;
+
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd == -1)
+ return -EFAULT;
+ ret = ioctl(fd, SIOCETHTOOL, &req);
+ if (ret == -1) {
+ close(fd);
+ return -EFAULT;
+ }
+
+ close(fd);
+
+ switch (ethtool_cmd_speed(&edata)) {
+ case SPEED_10:
+ dev->data->dev_link.link_speed = ETH_SPEED_NUM_10M;
+ break;
+ case SPEED_100:
+ dev->data->dev_link.link_speed = ETH_SPEED_NUM_100M;
+ break;
+ case SPEED_1000:
+ dev->data->dev_link.link_speed = ETH_SPEED_NUM_1G;
+ break;
+ case SPEED_2500:
+ dev->data->dev_link.link_speed = ETH_SPEED_NUM_2_5G;
+ break;
+ default:
+ dev->data->dev_link.link_speed = ETH_SPEED_NUM_NONE;
+ }
+
+ dev->data->dev_link.link_duplex = edata.duplex ? ETH_LINK_FULL_DUPLEX :
+ ETH_LINK_HALF_DUPLEX;
+ dev->data->dev_link.link_autoneg = edata.autoneg ? ETH_LINK_AUTONEG :
+ ETH_LINK_FIXED;
+
+ neta_ppio_get_link_state(priv->ppio, &link_up);
+ dev->data->dev_link.link_status = link_up ? ETH_LINK_UP : ETH_LINK_DOWN;
+
+ return 0;
+}
+
+/**
* DPDK callback to set the primary MAC address.
*
* @param dev
@@ -484,6 +554,7 @@ static const struct eth_dev_ops mvneta_ops = {
.dev_set_link_up = mvneta_dev_set_link_up,
.dev_set_link_down = mvneta_dev_set_link_down,
.dev_close = mvneta_dev_close,
+ .link_update = mvneta_link_update,
.mac_addr_set = mvneta_mac_addr_set,
.mtu_set = mvneta_mtu_set,
.dev_infos_get = mvneta_dev_infos_get,