From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by dpdk.org (Postfix) with ESMTP id C37B31B20B for ; Mon, 9 Oct 2017 17:01:09 +0200 (CEST) Received: by mail-lf0-f49.google.com with SMTP id 90so19481772lfs.13 for ; Mon, 09 Oct 2017 08:01:09 -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=jgw4lMEX0fEKmpIhSUZv3zj7LfaooNhYVi19AVb7neM=; b=TAj4RJ1G8dy97RF5iNFIOCTEALbYoKqZgUVlfXGRie6uU6blmzkZ+q2HMtDgXZLUju taZlxl3HtRZjjAe8hLUxmT4QvKwIgujGomjJMgUkyISWP2dCP7qhfxBIAFPFDZTORiC8 Cb2nclNhb03ss0YEyKrWOhhME3PpHN5AN8V8JVhkEa6GOJyCQtEeHB9IBNwC9/GlkHTK KIa+7BwO/sjHWgvr/QRQBTEc8RBTbO0Jv53ZB7BgdIu2rwd8wdz2LQFvRSU1Ym03Dz3t 5LDF2JtnZxThMAFYNQClZE8Z0fDW7UOW3Hl0OWarSkDQqSG9ZnWhLm4JgTewr3o7hLuY mmkw== 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=jgw4lMEX0fEKmpIhSUZv3zj7LfaooNhYVi19AVb7neM=; b=JcaTmFaFGeBvmLlRT+nAD+vc+X/Asb7EXgT3a71Q+bCq9kXUhwZAjn/mAVgxaFJbN4 hy+tyKenq7IMI/QWV4/dDvHGstj8KnULuQ0CsWaou/N1ZrLI/8vx5hv872Z4jscovkI9 xub6uYBC1giQG7iqzRVHxHWTrFoEen/k9vtNjEtHNF96Hqt1B81UJWvxVBoZ4rIMLpF2 JKvj5XTuuFeIEPSB/zCXZdODECOLay8nny+Iz3FW7fPnRmS3Cv2WYsDG8C0ObZoFulIr fjIYPY4vRZEt63OS6C5dao/qeoNGPi4t8vJ1licB6Kd056hVeezAiiv0MjFnxfzblRuW 9B2g== X-Gm-Message-State: AMCzsaUlgbKrG8VOHKLOrA9mHxVGiPxFCOEd9Q7xNxMEG6PEUvjZVNbl h/0Wf0dpuc0x/ThNtM4NfYlm1vXBgTY= X-Google-Smtp-Source: AOwi7QDteOgp/NKJYU0wntul25mavAK6aPTvVTcUB1fPQTCCVb36q6zX9wVo9h+2im0Rg7TlFXMaEg== X-Received: by 10.46.86.17 with SMTP id k17mr4099855ljb.28.1507561269209; Mon, 09 Oct 2017 08:01:09 -0700 (PDT) Received: from tdu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id z64sm1352637lfa.91.2017.10.09.08.01.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Oct 2017 08:01:08 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: mw@semihalf.com, dima@marvell.com, nsamsono@marvell.com, Jianbo.liu@linaro.org, Tomasz Duszynski , Jacek Siuda Date: Mon, 9 Oct 2017 17:00:32 +0200 Message-Id: <1507561244-20115-5-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507561244-20115-1-git-send-email-tdu@semihalf.com> References: <1507031500-11473-1-git-send-email-tdu@semihalf.com> <1507561244-20115-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v4 04/16] net/mrvl: 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: Mon, 09 Oct 2017 15:01:10 -0000 Add support for retrieving physical link information i.e: speed, duplex and link status. Signed-off-by: Jacek Siuda Signed-off-by: Tomasz Duszynski --- doc/guides/nics/features/mrvl.ini | 7 +++++ drivers/net/mrvl/mrvl_ethdev.c | 65 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 doc/guides/nics/features/mrvl.ini diff --git a/doc/guides/nics/features/mrvl.ini b/doc/guides/nics/features/mrvl.ini new file mode 100644 index 0000000..72df92e --- /dev/null +++ b/doc/guides/nics/features/mrvl.ini @@ -0,0 +1,7 @@ +; +; Supported features of the 'mrvl' network poll mode driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Link status = Y diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c index c87d48e..4788784 100644 --- a/drivers/net/mrvl/mrvl_ethdev.c +++ b/drivers/net/mrvl/mrvl_ethdev.c @@ -478,6 +478,70 @@ mrvl_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 +mrvl_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) +{ + /* + * TODO + * once MUSDK provides necessary API use it here + */ + struct ethtool_cmd edata; + struct ifreq req; + int ret, fd; + + 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_10000: + dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G; + 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; + + return 0; +} + +/** * DPDK callback to set the primary MAC address. * * @param dev @@ -816,6 +880,7 @@ static const struct eth_dev_ops mrvl_ops = { .dev_set_link_up = mrvl_dev_set_link_up, .dev_set_link_down = mrvl_dev_set_link_down, .dev_close = mrvl_dev_close, + .link_update = mrvl_link_update, .mac_addr_set = mrvl_mac_addr_set, .dev_infos_get = mrvl_dev_infos_get, .rxq_info_get = mrvl_rxq_info_get, -- 2.7.4