From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by dpdk.org (Postfix) with ESMTP id 121205F36 for ; Thu, 20 Sep 2018 11:05:47 +0200 (CEST) Received: by mail-lj1-f196.google.com with SMTP id s12-v6so7677844ljj.0 for ; Thu, 20 Sep 2018 02:05:47 -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=SgQ2aC5mJrjaHie2bkHlf07DtwbJirUnCqLWHnarO5E=; b=ZS1l6XQ5jjoWrzSIkMKzkD1KK45R9elWKEUlgBnAH0nkBBoL0Fr+vfAwbQjLqfQBvQ SsIoxqkgjLN3aifzOMXz96aki1dwCgRnS5VdPdoZ0w8UFfYNAm1sSjevsXyeJyQkk248 3grt+k60FOo4NcKYvR419NujQpES0CRfFUkC0JDFfGXGzTtHtvtrYEo7MVuQ76jGbXvi EMafsgJIiz7MsN4aEyIURn0MJ/WN7a0UK9y+oDwR7sX1Oa6PdcMvvd0wkG1zsaohsY5v imysUGdl/jv1Lhqx1EFdUCyirvmlAv4q5RFaYfNh64t6YtaqyXrOEpbt2AfldNDZbSZN nDug== 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=SgQ2aC5mJrjaHie2bkHlf07DtwbJirUnCqLWHnarO5E=; b=kEH5NbgGscIu4PhWvx/h8W40qTtEi0lKvkn5HFSNnQldrhXyoHmBkvwqerOfvEZ6pA IqKl2+K+xlg1TuypsOLYwvYgb279HpPjg2vY4ECxL0wpUD3IF5KVO7AI6ZN05stTh8s+ AFuFfzDqZNQH5vrQxJm1a89/STlhVJKnM6yXnjcQ9Z8ShcAzBpaBpeE+moiRoX9kK7Q/ x5nKWoCoSJcC33MRAtJkSSDmeFp3QkpIcgGDX34tAxXYLnE6zk1L62Ggo18dH90AHGNJ zxXIxREC8spjl49bFySn4xTLkjmZFpOFzMVTVgm540PmTDVAX0tFQROUmHmYmbWq0OJw ZUgg== X-Gm-Message-State: ABuFfogXFpsblkva9N088kK+nJu5mk2FevkXL7HMRhVFQadu8RpuMtfS h8GnvlVJMNvEEguoEHVMuhf8h43Fgvg= X-Google-Smtp-Source: ACcGV62A4RgHdm8FhLsLr6FzoC0CC3bQ9VKjMJJ0WFMoJrdux2DAowoWLw5SpzrHtoX0LS5OUHyMrQ== X-Received: by 2002:a2e:b007:: with SMTP id y7-v6mr1241984ljk.22.1537434346472; Thu, 20 Sep 2018 02:05:46 -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 g16-v6sm4338106lje.1.2018.09.20.02.05.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Sep 2018 02:05:45 -0700 (PDT) From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, zr@semihalf.com, tdu@semihalf.com, nadavh@marvell.com Date: Thu, 20 Sep 2018 11:05:35 +0200 Message-Id: <1537434339-22570-5-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537434339-22570-1-git-send-email-amo@semihalf.com> References: <1537369294-17099-1-git-send-email-amo@semihalf.com> <1537434339-22570-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH v5 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: Thu, 20 Sep 2018 09:05:47 -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 1b26c87..e9cbff7 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