From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by dpdk.org (Postfix) with ESMTP id A2C25B0F9 for ; Wed, 14 May 2014 20:57:42 +0200 (CEST) Received: by mail-pa0-f54.google.com with SMTP id bj1so2041663pad.27 for ; Wed, 14 May 2014 11:57:50 -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=8TI7mY7U67rXR83VqZeqNgtgAZCenwWNNxS2essAYgI=; b=Emi4yXurO9djiGKXXgIkazURrXTsglHALC53FXx9dB1C5HqYP8CLc5+dJlCLv9aR4x GeeUTQNRZeV01z6Ik64SXWdl+jLwUHIJ9Q5To9L1Egv165VhotEgDbWq4uQ5SlvraQcG UXPzfloFd5IgM+iDdvjKqvuokHOl9ESLE3tZBx+e74imeiePcIaDFHZIDDwghFpORVUi UHOHqmsmKX2tJ1+pEV/mw0p7iD/bdLkT0/AEUAcMHaRmAC+V5FDqsrpEeh3zvZYhku5R 2770d8hcEd/OE0HjyXcKO7hc/WlVmAI0+ld01ErcrWXFS3Jb4zOPWC6jD7v8Q2Y1OqTG dz+Q== X-Gm-Message-State: ALoCoQk9/7P05oh0vlK4f8PP7oEI9VRic07en2Y7h4Fg/f/URsvZ7UGEm9w5tGXMUtyWAv0WPFib X-Received: by 10.66.164.135 with SMTP id yq7mr6694415pab.126.1400093870199; Wed, 14 May 2014 11:57:50 -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 yj6sm11136940pab.19.2014.05.14.11.57.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 May 2014 11:57:48 -0700 (PDT) Message-Id: <20140514185747.444552895@networkplumber.org> User-Agent: quilt/0.61-1 Date: Wed, 14 May 2014 11:55:31 -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=igb-dev-link.patch Cc: Stephen Hemminger Subject: [dpdk-dev] [PATCH 4/6] e1000: 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:43 -0000 New common code can be used, eliminating driver code. Signed-off-by: Stephen Hemminger --- a/lib/librte_pmd_e1000/em_ethdev.c 2014-05-14 11:26:30.381274255 -0700 +++ b/lib/librte_pmd_e1000/em_ethdev.c 2014-05-14 11:42:25.976657022 -0700 @@ -157,58 +157,6 @@ static struct eth_dev_ops eth_em_ops = { .mac_addr_remove = eth_em_rar_clear, }; -/** - * 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_em_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_em_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; -} - static int eth_em_dev_init(__attribute__((unused)) struct eth_driver *eth_drv, struct rte_eth_dev *eth_dev) @@ -597,7 +545,7 @@ eth_em_stop(struct rte_eth_dev *dev) /* clear the recorded link status */ memset(&link, 0, sizeof(link)); - rte_em_dev_atomic_write_link_status(dev, &link); + rte_eth_dev_set_link(dev, &link); } static void @@ -916,8 +864,8 @@ eth_em_link_update(struct rte_eth_dev *d break; rte_delay_ms(EM_LINK_UPDATE_CHECK_INTERVAL); } - memset(&link, 0, sizeof(link)); - rte_em_dev_atomic_read_link_status(dev, &link); + + rte_eth_dev_get_link(dev, &link); old = link; /* Now we check if a transition has happened */ @@ -930,7 +878,7 @@ eth_em_link_update(struct rte_eth_dev *d link.link_duplex = 0; link.link_status = 0; } - rte_em_dev_atomic_write_link_status(dev, &link); + rte_eth_dev_set_link(dev, &link); /* not changed */ if (old.link_status == link.link_status) @@ -1281,8 +1229,7 @@ eth_em_interrupt_action(struct rte_eth_d if (ret < 0) return 0; - memset(&link, 0, sizeof(link)); - rte_em_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\n", --- a/lib/librte_pmd_e1000/igb_ethdev.c 2014-05-14 11:26:30.381274255 -0700 +++ b/lib/librte_pmd_e1000/igb_ethdev.c 2014-05-14 11:42:59.512754542 -0700 @@ -215,58 +215,6 @@ static struct eth_dev_ops igbvf_eth_dev_ .tx_queue_release = eth_igb_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_igb_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_igb_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; -} - static inline void igb_intr_enable(struct rte_eth_dev *dev) { @@ -864,7 +812,7 @@ eth_igb_stop(struct rte_eth_dev *dev) /* clear the recorded link status */ memset(&link, 0, sizeof(link)); - rte_igb_dev_atomic_write_link_status(dev, &link); + rte_eth_dev_set_link(dev, &link); } static void @@ -890,7 +838,7 @@ eth_igb_close(struct rte_eth_dev *dev) igb_dev_clear_queues(dev); memset(&link, 0, sizeof(link)); - rte_igb_dev_atomic_write_link_status(dev, &link); + rte_eth_dev_set_link(dev, &link); } static int @@ -1312,8 +1260,8 @@ eth_igb_link_update(struct rte_eth_dev * break; rte_delay_ms(IGB_LINK_UPDATE_CHECK_INTERVAL); } - memset(&link, 0, sizeof(link)); - rte_igb_dev_atomic_read_link_status(dev, &link); + + rte_eth_dev_get_link(dev, &link); old = link; /* Now we check if a transition has happened */ @@ -1326,7 +1274,7 @@ eth_igb_link_update(struct rte_eth_dev * link.link_duplex = 0; link.link_status = 0; } - rte_igb_dev_atomic_write_link_status(dev, &link); + rte_eth_dev_set_link(dev, &link); /* not changed */ if (old.link_status == link.link_status) @@ -1718,8 +1666,7 @@ eth_igb_interrupt_action(struct rte_eth_ if (ret < 0) return 0; - memset(&link, 0, sizeof(link)); - rte_igb_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\n",