From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pb0-f45.google.com (mail-pb0-f45.google.com [209.85.160.45]) by dpdk.org (Postfix) with ESMTP id ECA21B0BE for ; Wed, 14 May 2014 20:57:39 +0200 (CEST) Received: by mail-pb0-f45.google.com with SMTP id um1so2044068pbc.4 for ; Wed, 14 May 2014 11:57:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-type:content-disposition; bh=cLi+hYVlVmL71a9XizCNasQUbUxcrtmmC+iLpVYYwTs=; b=TLfZHYqSBgTInOb7KkbX3AM6YXZ05Cu4Bq7SmS3D2y5S/suZWSILYXIHSx2vf2E5xD MEONWqiRUm6rlZNHhiw1T5HKJod6tRzdX5RweKfQiDS8qQirNYjPBIncEdzuFwCSajHG 2kOfFmEybRf68dM1IZaWFD9BVSjgjbZ9xnunFZMLSnJklIzy7N5i0FSxOH/ZSPzT8WfP C5//DzQNCSYwhi2rpyZHjvnqGhhEgGrbh5jUXbkX2ZDhpcaCov1iAqyBXY/CfXYVPSR5 MlFkWIWk7P3wz7G/YcKQlxXADrsBdvn7lNeArMJjMPjvAHSdp4Ul5zvwJcFldm+fPza1 4AOA== X-Gm-Message-State: ALoCoQkpwvv89KXli02xGsT1zUeoL7VuBeDLEreujGTUjeRr6+YJ38YubT2sOW9d1nNZOTonqip/ X-Received: by 10.68.136.226 with SMTP id qd2mr6630125pbb.72.1400093867383; Wed, 14 May 2014 11:57:47 -0700 (PDT) Received: from localhost (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id sy2sm4840144pbc.28.2014.05.14.11.57.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 May 2014 11:57:46 -0700 (PDT) Message-Id: <20140514185745.171589218@networkplumber.org> User-Agent: quilt/0.61-1 Date: Wed, 14 May 2014 11:55:30 -0700 From: Stephen Hemminger To: dev@dpdk.org References: <20140514185527.771828962@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=ixgbe-dev-link.patch Cc: Stephen Hemminger Subject: [dpdk-dev] [PATCH 3/6] ixgbe: use eth_dev_{get,set}_link X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 May 2014 18:57:40 -0000 New common code can be used, eliminating driver code. Signed-off-by: Stephen Hemminger --- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c 2014-05-14 11:26:30.381274255 -0700 +++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c 2014-05-14 11:37:51.319893900 -0700 @@ -56,7 +56,6 @@ #include #include #include -#include #include #include "ixgbe_logs.h" @@ -325,58 +324,6 @@ static struct eth_dev_ops ixgbevf_eth_de .tx_queue_release = ixgbe_dev_tx_queue_release, }; -/** - * Atomically reads the link status information from global - * structure rte_eth_dev. - * - * @param dev - * - Pointer to the structure rte_eth_dev to read from. - * - Pointer to the buffer to be saved with the link status. - * - * @return - * - On success, zero. - * - On failure, negative value. - */ -static inline int -rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) -{ - struct rte_eth_link *dst = link; - struct rte_eth_link *src = &(dev->data->dev_link); - - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} - -/** - * Atomically writes the link status information into global - * structure rte_eth_dev. - * - * @param dev - * - Pointer to the structure rte_eth_dev to read from. - * - Pointer to the buffer to be saved with the link status. - * - * @return - * - On success, zero. - * - On failure, negative value. - */ -static inline int -rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) -{ - struct rte_eth_link *dst = &(dev->data->dev_link); - struct rte_eth_link *src = link; - - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} - /* * This function is the same as ixgbe_is_sfp() in ixgbe/ixgbe.h. */ @@ -1453,7 +1400,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev) /* Clear recorded link status */ memset(&link, 0, sizeof(link)); - rte_ixgbe_dev_atomic_write_link_status(dev, &link); + rte_eth_dev_set_link(dev, &link); } /* @@ -1764,11 +1711,8 @@ ixgbe_dev_link_update(struct rte_eth_dev int link_up; int diag; - link.link_status = 0; - link.link_speed = 0; - link.link_duplex = 0; - memset(&old, 0, sizeof(old)); - rte_ixgbe_dev_atomic_read_link_status(dev, &old); + memset(&link, 0, sizeof(link)); + rte_eth_dev_get_link(dev, &old); /* check if it needs to wait to complete, if lsc interrupt is enabled */ if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0) @@ -1778,14 +1722,14 @@ ixgbe_dev_link_update(struct rte_eth_dev if (diag != 0) { link.link_speed = ETH_LINK_SPEED_100; link.link_duplex = ETH_LINK_HALF_DUPLEX; - rte_ixgbe_dev_atomic_write_link_status(dev, &link); + rte_eth_dev_set_link(dev, &link); if (link.link_status == old.link_status) return -1; return 0; } if (link_up == 0) { - rte_ixgbe_dev_atomic_write_link_status(dev, &link); + rte_eth_dev_set_link(dev, &link); if (link.link_status == old.link_status) return -1; return 0; @@ -1812,7 +1756,7 @@ ixgbe_dev_link_update(struct rte_eth_dev link.link_speed = ETH_LINK_SPEED_10000; break; } - rte_ixgbe_dev_atomic_write_link_status(dev, &link); + rte_eth_dev_set_link(dev, &link); if (link.link_status == old.link_status) return -1; @@ -1946,8 +1890,7 @@ ixgbe_dev_link_status_print(struct rte_e { struct rte_eth_link link; - memset(&link, 0, sizeof(link)); - rte_ixgbe_dev_atomic_read_link_status(dev, &link); + rte_eth_dev_get_link(dev, &link); if (link.link_status) { PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s", (int)(dev->data->port_id), @@ -1993,8 +1936,7 @@ ixgbe_dev_interrupt_action(struct rte_et if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) { /* get the link status before link update, for predicting later */ - memset(&link, 0, sizeof(link)); - rte_ixgbe_dev_atomic_read_link_status(dev, &link); + rte_eth_dev_get_link(dev, &link); ixgbe_dev_link_update(dev, 0);