From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 8B8EC4CA7 for ; Tue, 28 Aug 2018 17:10:37 +0200 (CEST) Received: by mail-lj1-f193.google.com with SMTP id m84-v6so1705059lje.10 for ; Tue, 28 Aug 2018 08:10:37 -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=W+pfG2EFa8QP6E2NLCewYJ4d4fDqLvDzQTd9rTR2W5I=; b=UDS9mKpMykas9ANjHWkhnFlThMHe4aXagNgwYnBaWddAYrzosLH6PPnMygyyKGHhBm vQW8QRlizDd964NmCasA/xxbyeT6UB1lwX0Jtxfw8K9GSVwSXYQLbKvHcmnBcZdrc2Yi RY+5qy39s6/oEe/L3dHhueFejlpJqYb0UXYsPsKoTYLHl7jWUwGXQeVQnPnIUawA94iY PRY+0GacOFIU41YaUU2caw0phcY9sSCir+HkLahqh0Nik7Y0JjTYttzV/skL+8hqTwFn uDbJL9NdtwcW8j6RtxiN2VShGS6AP7CNPSB0bHFN4AcNameCIoiTNM1kNf4HfLLZ21K/ j/lQ== 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=W+pfG2EFa8QP6E2NLCewYJ4d4fDqLvDzQTd9rTR2W5I=; b=W3DvtgxSKwD+tGDPLG8BisSClY+b2DKc8MRmowaReniJtgcgatv+IUbtb6l8Y/5oFJ AYFzxJ3hY4u1vLkzl3UL4y54Im6p3JZeLQ8bGD9MpJtlZ2L1gnCaePg1+pkQIJ/859CE vmBtWzK4uYbVj7I8STS/x4dP+bKgE3hobgB1Sqlmi7dO2xqWnY2+IdsLjqvwJrRQNK+t UecGduF6g94PSHG7wMnIdh7oHZLJnx7H8p8Vyoc2dgOHRCOM3FvT1gt6+mkWAnUtEDVX aTXo8bLmLujTh3CcBA1rdRpFmFnw03b+HexlPewpiQaO4whdwVQ+AptbYsXK1ehEeG/m qX/w== X-Gm-Message-State: APzg51BctidTgJYwR33O8C1yuqOdkkPi+wKWiVhxc9EeXfmeJriG+3lg tkzdZOMdVnTwvqQdPaq1572yzdXnyKE= X-Google-Smtp-Source: ANB0VdaGYgjhVDI324glffIqn59qsv2iF6L54BUFD92VwXdyd+yg0W8ezjyoND7P9Os8PTZTSQW9IA== X-Received: by 2002:a2e:5d9d:: with SMTP id v29-v6mr1510144lje.137.1535469036799; Tue, 28 Aug 2018 08:10:36 -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 p28-v6sm260685ljp.90.2018.08.28.08.10.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 08:10:35 -0700 (PDT) From: Andrzej Ostruszka To: dev@dpdk.org Cc: nsamsono@marvell.com Date: Tue, 28 Aug 2018 17:10:26 +0200 Message-Id: <1535469030-18647-5-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535469030-18647-1-git-send-email-amo@semihalf.com> References: <1535469030-18647-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH 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: Tue, 28 Aug 2018 15:10:37 -0000 From: Natalie Samsonov Add callback for updating information about link status/info. Signed-off-by: Natalie Samsonov --- 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 eded4eb..d1c180c 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -1464,6 +1464,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 @@ -1496,6 +1566,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