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 1066E2C37 for ; Wed, 3 Oct 2018 09:22:24 +0200 (CEST) Received: by mail-lj1-f194.google.com with SMTP id u21-v6so4098690lja.8 for ; Wed, 03 Oct 2018 00:22:24 -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=7syenQl5rwCXLLjacOcuDiC+4lGxCUb/swfxnXKkyvU=; b=no2O/3Zg1UrkR+Ks0+Dze+n+8MJx28TL5psGQdMtmoP7DODxLjaWEByUqT1Ys3k0+V /ustmXlR+kczGzh3FWq6asptQ+2C2eyKY2a2IVznBGX4tokyYJXnBpyhJiugslQFbGl5 GlOwQ3TRWoG5hZQt0SNga1QS5nmYAOxpMuL66RV5aKbSYPIivXHkLzhkwIBbsV6dPOfc VD1AwI95c6o1VyapkZ3DtLHeYUk9Sqk3QfcNBBg8MPI8tgJxTZ4LqCGuVztuUiXNsx7z xLpaWrBP4ZQvwjxykuIEbdX9e64GvxfbI3qSNxnckslMSZU9P8mIDRj1g00mmWlRjRdn fclQ== 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=7syenQl5rwCXLLjacOcuDiC+4lGxCUb/swfxnXKkyvU=; b=D/JfyLLmKw3Z5bFEHO//2wn6UBIQEhC9cDzVOv5G9014q1vWygTEUfnEB9+DvkdsCO msF8NIsl5+YX/YCw9p15Xhk0KpOqTt5OeVpMM9N9AG6XvaKdcHbyWg/VaFnWnlAszE2R 6UKXoZJKavJC1zm9ODLXnuwypogr9v6TXYhs6Q4tC9c9CcCZ320Iymyv3GmVRkTlqAuY Z3rhWkWFgv6oIING6fBVlwf+y2m3B4AtCy/MS8DjF/aypSc3ji5iAh8bKR8lTTLldqkG EjJw+iQP6RyJjB0ECoTTP1FS0bcVDpXW4rlvhLt14E9aD9sZC14MzYN6e+Vxmtk0omzN /OYw== X-Gm-Message-State: ABuFfoiyV9pUqORbReyJhWwlmrDYEwMdUI/+20r6rKPsZKpEKayXzyyl G4vB9PNa/oxryELhkuhGtUl0jMpDESNiUA== X-Google-Smtp-Source: ACcGV62Hgmmv5J92yidlDlF8eJLmKrbRgiV9axDYlhJlI8aO3giQtcoBJOYn+a4JQwSg6c8rHLI3cw== X-Received: by 2002:a2e:1615:: with SMTP id w21-v6mr148657ljd.33.1538551343420; Wed, 03 Oct 2018 00:22:23 -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 f73-v6sm123659lfl.80.2018.10.03.00.22.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Oct 2018 00:22:22 -0700 (PDT) From: Andrzej Ostruszka X-Google-Original-From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, nadavh@marvell.com, zr@semihalf.com, tdu@semihalf.com Date: Wed, 3 Oct 2018 09:22:12 +0200 Message-Id: <1538551336-19259-5-git-send-email-andrzej.ostruszka@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538551336-19259-1-git-send-email-andrzej.ostruszka@gmail.com> References: <1538385970-21260-1-git-send-email-andrzej.ostruszka@gmail.com> <1538551336-19259-1-git-send-email-andrzej.ostruszka@gmail.com> Subject: [dpdk-dev] [PATCH v7 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, 03 Oct 2018 07:22:24 -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 aadeacb..fdea3da 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 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, -- 2.7.4