From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id C7F0C5F1B for ; Fri, 31 Aug 2018 14:59:53 +0200 (CEST) Received: by mail-lf1-f68.google.com with SMTP id g6-v6so9864427lfb.11 for ; Fri, 31 Aug 2018 05:59:53 -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=v2Z/11s6mlVsTNJH2+i8Npxqhcxi88u6tC8QLTKnYl1GEZ7rWdOjKQz3lwUqu5DVxQ dV7zFUeJMbPE/Z3/67bSmxOkNI5aI/tKWeRCiAruMUAEV3jdRYzlrVnMflKpg60iXXRP yOGhb/PmqjPkbifldSy59JPYRONd/hmqpeU+NldhWcsmzB/bU0E5ueDLXheRM2XFjqfr GmHFcsKU54vNUcHnt4rGW1bsUumjTlo0Ni/5LDZO4+EKMqbvwPKEcA+Y4uOxnlYxGhNc u1wfCtLO0P2llQAOKquYn9zOXme/41fpsik8cVb/smW/15QG/fkoq8EfpkcOiO/2jHjH WBcg== 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=DX3CtDN028vZjG+/Pq7H+iQ7KGml2mmSBxpaIfwtI15cBp9bO71PnekAK8VsXjUDeQ wf0eWpOI56RRfTpFnKiRyHSx1treFvV/YNeCbZUWrxvq2NUBM47YUC78y6km9BcQufTs lPin5ICfhAAG8CZpBM2qKYE1cRq1TemD5wx/BhtrF89VCcmUagrEzQVMardkfw5uTlUq 00NWufxP9kLeYxJuSqwuQlzZTu1jqH5nVoic4Js2eynXS3SaqtSkoXCwbeT1s0peOXE5 Q7F4Pl9pOwKsuuidm/NAxBPNJ1ntTsee6QsVb4b8AlubZeA1b5z+QXw2TC9jsCH3CkL3 qztQ== X-Gm-Message-State: APzg51B7TCZGoMUIw2iAxqigpNsxKRn9W/zR55keB8FFTzTNiiRMB4Dm 50ur5A6wgqrb+j4aMbVGTLXU3wSlo4Q= X-Google-Smtp-Source: ANB0VdZ5nLuwpYUh3ub5oDbT3YJykhtgcI4e5I/6wocePY6rmSARIsZH/H+QZkP3YHxCyrEVjK0YEQ== X-Received: by 2002:ac2:428f:: with SMTP id m15-v6mr10101648lfh.52.1535720393275; Fri, 31 Aug 2018 05:59:53 -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 a66-v6sm1894220lfa.93.2018.08.31.05.59.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Aug 2018 05:59:52 -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:59:42 +0200 Message-Id: <1535720386-18775-5-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535720386-18775-1-git-send-email-amo@semihalf.com> References: <1535718368-15803-1-git-send-email-amo@semihalf.com> <1535720386-18775-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH v3 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:59:54 -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