From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by dpdk.org (Postfix) with ESMTP id E474B4CA7 for ; Wed, 19 Sep 2018 17:01:42 +0200 (CEST) Received: by mail-lf1-f67.google.com with SMTP id x20-v6so5438392lfg.2 for ; Wed, 19 Sep 2018 08:01:42 -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=KC6kjGslJAF5VcUHISN3D3dUNVM5n9jfv15yHHyMfzI=; b=ChFk+1yySzMcJFeSsSXfSjZ+JqpZo1DPHQDM8IbwNZ6jzA+QRdf3OnMwDq67LYA8XU JTz9s1B6EqGwFCsga7GojHFFv+3yPiP9XSDFNuQga822OFtiu4MARYa2Zh9HbcRuckz3 +ASdytxNIbrQ78A9hqO9NlgRmRXjXGVqSr4ebkYHmCC6RMucZ38IspYT35kl8Baa/WlE XTq3R0iQqZueWHOm6AC6kOanOABXCHzpu7FR4Vy7FeERm6+LXRwxU+r0Izw2qX4alK6M 9upV845fh6l6+a2nHD9v3KaXadUONQiFfcg+bQdQl2ouuLDmsFfR/IU7NdnLtMaub1rk btRg== 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=KC6kjGslJAF5VcUHISN3D3dUNVM5n9jfv15yHHyMfzI=; b=cp1lVAZRqV9Bp2PvCZVk8oqeTiIA6UsGTGK9BmKXxRA9lzI8WiBz7ZkMMzrFaODx0B bbUkcEgcL5imSlzCBrbrXCJCOiYNuQXSGuo1OJLkpXHTkhwf3VE/9I45wZvqr28bbtdf 2d27NhkQ0+DxV82gox9uFbu3/CCCqD+UjMqd71fLQ422QZMAeVQyYj8xFdNfMSy0hJKc 9fq3v/kACgUXUNvpviS68g2V6TfTGcri7z+w6LuwxyLjp1eyJxsJya0CrA8zo0X8IOCL 4KSXieN7u0gzZO91bl7WIednLYjsE/9aQ9vVuHrDAwoHGoj0m+5zX1cAWyx0z5904T13 mVjg== X-Gm-Message-State: APzg51AoZj8ZfYWWJnaxV+Sy2qFnT/flSL3ZwICWPzZR6CCLUwzmmRGI EH35K7oj9C7/cbLKDw990sA4ShgzDSQ= X-Google-Smtp-Source: ANB0VdbNcYk+K7/ABYgWA9NjjkuY4LIGLDVb9G78DZ1gjZnJIX44pfS7U8PAZbmzIAld/l2AqcE3vA== X-Received: by 2002:a19:14d4:: with SMTP id 81-v6mr14001796lfu.26.1537369301903; Wed, 19 Sep 2018 08:01:41 -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 z3-v6sm1107711lfj.89.2018.09.19.08.01.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Sep 2018 08:01:40 -0700 (PDT) From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, zr@semihalf.com, tdu@semihalf.com, nadavh@marvell.com Date: Wed, 19 Sep 2018 17:01:30 +0200 Message-Id: <1537369294-17099-5-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537369294-17099-1-git-send-email-amo@semihalf.com> References: <1535720386-18775-1-git-send-email-amo@semihalf.com> <1537369294-17099-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH v4 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: Wed, 19 Sep 2018 15:01:43 -0000 From: Zyta Szpak Add callback for updating information about link status/info. Signed-off-by: Natalie Samsonov Signed-off-by: Zyta Szpak --- doc/guides/nics/features/mvneta.ini | 1 + doc/guides/nics/mvneta.rst | 1 + drivers/net/mvneta/mvneta_ethdev.c | 71 +++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) diff --git a/doc/guides/nics/features/mvneta.ini b/doc/guides/nics/features/mvneta.ini index bc4e400..581ed31 100644 --- a/doc/guides/nics/features/mvneta.ini +++ b/doc/guides/nics/features/mvneta.ini @@ -5,6 +5,7 @@ ; [Features] Speed capabilities = Y +Link status = Y MTU update = Y Jumbo frame = Y CRC offload = Y diff --git a/doc/guides/nics/mvneta.rst b/doc/guides/nics/mvneta.rst index 55ffe57..85cdd1d 100644 --- a/doc/guides/nics/mvneta.rst +++ b/doc/guides/nics/mvneta.rst @@ -31,6 +31,7 @@ Features of the MVNETA PMD are: - Speed capabilities - Jumbo frame - MTU update +- Link status - CRC offload - L3 checksum offload - L4 checksum offload diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c index 80ab9ba..e40437f 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -477,6 +477,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 @@ -509,6 +579,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