From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by dpdk.org (Postfix) with ESMTP id 692DE68D9 for ; Mon, 30 May 2016 11:40:14 +0200 (CEST) Received: by mail-lf0-f47.google.com with SMTP id k98so69999076lfi.1 for ; Mon, 30 May 2016 02:40:14 -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; bh=EPWHBy9ahgPcNk6K5OQF+yMlx/6nbMhjzTVGGoN7HGQ=; b=AP1lk1D+67bQPOxLIAKzvcraZiQU9hxt+34RFhZwjiFK4658A5jo9CQ811+BjvkEby p1Ow/I6zzze14d/5bRamI+jIzp0+XcG7YOZ9IcZgJZuZmWl5e0WHJiH3IGoQi/O3bjAz aIoyWvP080dphZKxVBv6f5AXn7rBN6PUUvZFTINiQPKqFi3BOhDzgLIok3QWpjbEWPZs s4r+dhJInBpjdVdMTXBeX+ybPU89cGlezbGqpgGY0xxgHbqoD/twU5aJqrdshBpY9adD 4dZRXQpqYGdUbRte8NAidvYS2y2bu67tWszCRqTc9VywyfLzk3x0YPMP1roYo+NyWuJ0 ZORQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EPWHBy9ahgPcNk6K5OQF+yMlx/6nbMhjzTVGGoN7HGQ=; b=QKGZGsexQ7s7oQtDD4esNIf19eDuDuwzyMdZwt5eWSCNZgdV5speKg3WPhKgGyYe/W LRx+ihhAYb0v5KHoG3uUGzqXYsswzdzjoprt7zC40tGXvjjZUbJ7ftJ/stxeSpvGtkOW mR0+f5HVjAL1SurTWcQEkYCmZ4fG3RZ3tkVdSLZ8hXKwk5UiEcNSDKTLZ8gxjPk1J6nQ +AJqV5ZIx3J8tNQALgCgpLXtyrU3j+ymPt7ODdVjoxb6xrtzNLvMaQNCeWfqLd5MKNy/ CTJz4lGjOCHS93d5E+KbsDFaL1UPlmoyu3/SPcTdslP9tUUAfsHt8/wKGrrGskGAvVTK T5Qw== X-Gm-Message-State: ALyK8tI0CryD/eYdHFpwFxwShZ30Al5mdhpz4p4iBrSZeoI+h0aaqagctVQRxbg4uujz8A== X-Received: by 10.25.201.88 with SMTP id z85mr8394963lff.140.1464601214116; Mon, 30 May 2016 02:40:14 -0700 (PDT) Received: from zr-HP-Pro-3500-Series.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id 4sm2171401ljj.2.2016.05.30.02.40.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 May 2016 02:40:13 -0700 (PDT) From: zr@semihalf.com To: remy.horton@intel.com, thomas.monjalon@6wind.com Cc: dev@dpdk.org, Zyta Szpak Date: Mon, 30 May 2016 11:40:09 +0200 Message-Id: <1464601210-7372-1-git-send-email-zr@semihalf.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH v2 1/2] ethdev: add callback to get register size in bytes 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: Mon, 30 May 2016 09:40:14 -0000 From: Zyta Szpak Version 2 of fixing the fixed register width assumption. rte_eth_dev_get_reg_length and rte_eth_dev_get_reg callbacks do not provide register size to the app in any way. It is needed to allocate proper number of bytes before retrieving registers content with rte_eth_dev_get_reg. Signed-off-by: Zyta Szpak --- lib/librte_ether/rte_ethdev.c | 12 ++++++++++++ lib/librte_ether/rte_ethdev.h | 18 ++++++++++++++++++ lib/librte_ether/rte_ether_version.map | 1 + 3 files changed, 31 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index a31018e..e0765f8 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3231,6 +3231,18 @@ rte_eth_dev_get_reg_length(uint8_t port_id) } int +rte_eth_dev_get_reg_width(uint8_t port_id) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_reg_width, -ENOTSUP); + return (*dev->dev_ops->get_reg_width)(dev); +} + +int rte_eth_dev_get_reg_info(uint8_t port_id, struct rte_dev_reg_info *info) { struct rte_eth_dev *dev; diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 2757510..552eaed 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1292,6 +1292,9 @@ typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev, typedef int (*eth_get_reg_length_t)(struct rte_eth_dev *dev); /**< @internal Retrieve device register count */ +typedef int (*eth_get_reg_width_t)(struct rte_eth_dev *dev); +/**< @internal Retrieve device register byte number */ + typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev, struct rte_dev_reg_info *info); /**< @internal Retrieve registers */ @@ -1455,6 +1458,8 @@ struct eth_dev_ops { eth_get_reg_length_t get_reg_length; /**< Get # of registers */ + eth_get_reg_width_t get_reg_width; + /**< Get # of bytes in register */ eth_get_reg_t get_reg; /**< Get registers */ eth_get_eeprom_length_t get_eeprom_length; @@ -3971,6 +3976,19 @@ int rte_eth_tx_queue_info_get(uint8_t port_id, uint16_t queue_id, */ int rte_eth_dev_get_reg_length(uint8_t port_id); +/* + * Retrieve the number of bytes in register for a specific device + * + * @param port_id + * The port identifier of the Ethernet device. + * @return + * - (>=0) number of registers if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-ENODEV) if *port_id* invalid. + * - others depends on the specific operations implementation. + */ +int rte_eth_dev_get_reg_width(uint8_t port_id); + /** * Retrieve device registers and register attributes * diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index 214ecc7..288bc63 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -130,5 +130,6 @@ DPDK_16.04 { rte_eth_tx_buffer_drop_callback; rte_eth_tx_buffer_init; rte_eth_tx_buffer_set_err_callback; + rte_eth_dev_get_reg_width; } DPDK_2.2; -- 1.9.1