From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by dpdk.org (Postfix) with ESMTP id 2FEA95911 for ; Fri, 31 Aug 2018 14:26:19 +0200 (CEST) Received: by mail-lj1-f194.google.com with SMTP id 203-v6so9889227ljj.13 for ; Fri, 31 Aug 2018 05:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fxCLrocOWbc7MOZOFrOcijmE75rnX73Ghlb+m3TTN4A=; b=vvzjwRnLZaDU3I5vjAh5BFUciUUHQBF2HXhXp+zHN/rj5Fh5jMMKO0tB+SeQqzvKvw iS/cXYi3RUHnKqg24fI/DrgcRMin132Ql7JrJo4KbtfRmwvRwq0h6qnmJNkwDJ+9Qf/O yCiLFmBx4oJvSM6oOGE/5VOa09fgN8mFyRgHEDxpqrqfpVZRpMFbgNZVfE10zbePz7LJ wrLe2jcAINNdpdMDL1fK/wBwTYkxg3Ma2uOtiiHkq6p2gKj+GETN8JAv3KCkNQ7oNJYh v6JrHUu+VU5QYXaNh/EXOpfUgSL1EuETlTQd5wq3kyEY4FjGd6VOYy41GxJK3qn6XfuO LUkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fxCLrocOWbc7MOZOFrOcijmE75rnX73Ghlb+m3TTN4A=; b=Ew0lrZevxF5QD9dQRRRU1kD6T5kmdkvZddPIlQ7D5BDOzItGg3h6dn6PzX4If4ldNB 8uDo6UEJLJybDj5ZAlA85ePkRHwXy1NkxZs62QvngskEsRdoAbOqds/QX67GDORO/uip 86EggxVGTZRhzqzPT/d16kllVMhKku9jAnPTm3zd4KGgw+nvRrKjb9AkSWsQQE4lqtjJ /u4m2H2UDtCu9qNROs4lFz16rdYZYSvrsiKzHQjFAUK0hrYn3/a6Vj4N7hq77woN2MS5 vEuE3xXrBpafmPKzE6KZqJbZr1L20XcAzgD9jyQQuLonRSWXTyg1+D9tpSXUADDObJqZ /xKw== X-Gm-Message-State: APzg51DxjoJc2k10bShO8ytGrMsxp8Y9gp/HN5o2cSxSNLiW5ua1uZaU 9xmeiD3bwtpE5WyTwpi5/zH44XbBIBI= X-Google-Smtp-Source: ANB0VdZdrqXclV55juAWe3FJofcGjsthapcS8+Kd+Xj1kF0sYYQqBXn3UNnlIqjdFQW7pvKziiy2Mw== X-Received: by 2002:a2e:8257:: with SMTP id j23-v6mr9947710ljh.49.1535718378598; Fri, 31 Aug 2018 05:26:18 -0700 (PDT) Received: from amok.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.googlemail.com with ESMTPSA id t4-v6sm1825422lfd.13.2018.08.31.05.26.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Aug 2018 05:26:17 -0700 (PDT) From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, zr@semihalf.com, tdu@semihalf.com, nsamsono@marvell.com Date: Fri, 31 Aug 2018 14:26:03 +0200 Message-Id: <1535718368-15803-8-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535718368-15803-1-git-send-email-amo@semihalf.com> References: <1535469030-18647-1-git-send-email-amo@semihalf.com> <1535718368-15803-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH v2 4/8] net/mvneta: add link update X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2018 12:26:19 -0000 From: Zyta Szpak Add callback for updating information about link status/info. Signed-off-by: Natalie Samsonov Signed-off-by: Zyta Szpak --- drivers/net/mvneta/mvneta_ethdev.c | 71 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c index 88d28f2..a7e79ea 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -1457,6 +1457,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 @@ -1489,6 +1559,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, -- 2.7.4