From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-f195.google.com (mail-yw0-f195.google.com [209.85.161.195]) by dpdk.org (Postfix) with ESMTP id D336B377E for ; Wed, 28 Jun 2017 12:08:34 +0200 (CEST) Received: by mail-yw0-f195.google.com with SMTP id f200so3095183ywb.0 for ; Wed, 28 Jun 2017 03:08:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atomicrules-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U7Uw4p4s8Q7BH3PDsOCxfk28SNT5A+C1Fapp0UUmbiI=; b=eWPjwfOPS3pdb7tw2Od73Vx8Xoj8f4ngU2RE+BZveLJPw+BWCz5jUWrNvZnAo4S89G FKqkjoeXrnV1ro5rQ+gylJvH0u5MtV3sr4vitmEQlarUFa1rfkjvC0W4C4vdcWmxabz6 H6XEuRmEm77THhOCEdWiRJdzbTUx6LvW7d9TzheENOlkJpo324vqEWej1cG6ec/94kkC l0pNoh5DVXMIRE8nkn8PQwqOp3tNCAgVpcY62Gi89qu+jCUFWFxd6wf2MF9nNe1KqFTR XBSTcK7yUjMA0p3DTsWxBj0Kbt+ZLqRrIx7Oo6m+HxWxyQFF+3iPHpGjG1rAGE1iKYkN PwyA== 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=U7Uw4p4s8Q7BH3PDsOCxfk28SNT5A+C1Fapp0UUmbiI=; b=OxWF8r9GVXcyStMZJ2BaIdDdrGxuI11jtR+VUC8/8xZuU1nKjIVRZN9V2K4qbvy67v MtZTYC/uAz9GsmYeEnsgKbgC5cRB7jpyJmNFrV37mmPNOHqArGMHaXpDV0msTxToORcD 4lXG2FLK+ZYhzEsNkWuDaHgegaWg1HGzWu8Bu45IhoyY3l2OHQ9r+NjcbdX6sq3PgzeE sfYAt7OWVIZmF6j8RUyBdeMO0rjI2l/BeGrrw5RBsj8sdf58vSUrjLj7lDBSNy4MSZRc gpttsixi5PSFgLT3dHR7QGwgeoKtv0cK1U4NRiGwenoxejl6Jmz70Q1QAHlcs4FCxJ7s YW9Q== X-Gm-Message-State: AKS2vOwPo2Fdu148OehFfDC12h5YQYaignqnYvapYzjnQwb1oGMdn8vY 1IkxnUD3qDyNiLBMpGg= X-Received: by 10.13.239.3 with SMTP id y3mr7017189ywe.155.1498644513705; Wed, 28 Jun 2017 03:08:33 -0700 (PDT) Received: from LOT3.lot.com (applwiedg03-a5-0-486.network.tds.net. [66.222.27.1]) by smtp.gmail.com with ESMTPSA id z187sm720951ywd.74.2017.06.28.03.08.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Jun 2017 03:08:33 -0700 (PDT) From: John Miller To: dev@dpdk.org Cc: shepard.siegel@atomicrules.com, ed.czeck@atomicrules.com, John Miller Date: Wed, 28 Jun 2017 06:08:22 -0400 Message-Id: <1498644504-30252-2-git-send-email-john.miller@atomicrules.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1498644504-30252-1-git-send-email-john.miller@atomicrules.com> References: <1498134644-14089-1-git-send-email-john.miller@atomicrules.com> <1498644504-30252-1-git-send-email-john.miller@atomicrules.com> Subject: [dpdk-dev] [PATCH v2 1/3] net/ark: allow unique user data for each port in extension calls 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: Wed, 28 Jun 2017 10:08:35 -0000 This change allows a user extension to provide unique private callback data for all ports. Arkville is a single-function multi-port device. User_data resides in the singleton Arkville structure. This structure is shared across all ports devices (eth_dev) which are created one per port. For the command extension callback we provide an opaque user pointer, which is currently implemented in the singleton Arkville structure. With this patch, we are providing a unique user pointer for each port rather than a common pointer across multiple ports. The pointers are stored in an array of size RTE_MAX_ETHPORTS in the arkville structure and are indexed by port_id in the PMD. The motivation for this change is that users of the arkville PMD extension have a unique pointer per port rather then one per function. Signed-off-by: John Miller --- drivers/net/ark/ark_ethdev.c | 51 ++++++++++++++++++++++++++++---------------- drivers/net/ark/ark_global.h | 4 ++-- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index c061f7b..e5a8ff7 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -179,6 +179,7 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, .mac_addr_add = eth_ark_macaddr_add, .mac_addr_remove = eth_ark_macaddr_remove, .mac_addr_set = eth_ark_set_default_mac_addr, + }; static int @@ -346,8 +347,9 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, } if (ark->user_ext.dev_init) { - ark->user_data = ark->user_ext.dev_init(dev, ark->a_bar, 0); - if (!ark->user_data) { + ark->user_data[dev->data->port_id] = + ark->user_ext.dev_init(dev, ark->a_bar, 0); + if (!ark->user_data[dev->data->port_id]) { PMD_DRV_LOG(INFO, "Failed to initialize PMD extension!" " continuing without it\n"); @@ -369,7 +371,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, */ if (ark->user_ext.dev_get_port_count) port_count = - ark->user_ext.dev_get_port_count(dev, ark->user_data); + ark->user_ext.dev_get_port_count(dev, + ark->user_data[dev->data->port_id]); ark->num_ports = port_count; for (p = 0; p < port_count; p++) { @@ -410,9 +413,10 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, goto error; } - if (ark->user_ext.dev_init) - ark->user_data = + if (ark->user_ext.dev_init) { + ark->user_data[eth_dev->data->port_id] = ark->user_ext.dev_init(dev, ark->a_bar, p); + } } return ret; @@ -508,7 +512,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, return 0; if (ark->user_ext.dev_uninit) - ark->user_ext.dev_uninit(dev, ark->user_data); + ark->user_ext.dev_uninit(dev, + ark->user_data[dev->data->port_id]); ark_pktgen_uninit(ark->pg); ark_pktchkr_uninit(ark->pc); @@ -529,7 +534,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, eth_ark_dev_set_link_up(dev); if (ark->user_ext.dev_configure) - return ark->user_ext.dev_configure(dev, ark->user_data); + return ark->user_ext.dev_configure(dev, + ark->user_data[dev->data->port_id]); return 0; } @@ -592,7 +598,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, } if (ark->user_ext.dev_start) - ark->user_ext.dev_start(dev, ark->user_data); + ark->user_ext.dev_start(dev, + ark->user_data[dev->data->port_id]); return 0; } @@ -614,7 +621,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, /* Stop the extension first */ if (ark->user_ext.dev_stop) - ark->user_ext.dev_stop(dev, ark->user_data); + ark->user_ext.dev_stop(dev, + ark->user_data[dev->data->port_id]); /* Stop the packet generator */ if (ark->start_pg) @@ -697,7 +705,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, uint16_t i; if (ark->user_ext.dev_close) - ark->user_ext.dev_close(dev, ark->user_data); + ark->user_ext.dev_close(dev, + ark->user_data[dev->data->port_id]); eth_ark_dev_stop(dev); eth_ark_udm_force_close(dev); @@ -765,7 +774,7 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, if (ark->user_ext.link_update) { return ark->user_ext.link_update (dev, wait_to_complete, - ark->user_data); + ark->user_data[dev->data->port_id]); } return 0; } @@ -778,7 +787,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, (struct ark_adapter *)dev->data->dev_private; if (ark->user_ext.dev_set_link_up) - return ark->user_ext.dev_set_link_up(dev, ark->user_data); + return ark->user_ext.dev_set_link_up(dev, + ark->user_data[dev->data->port_id]); return 0; } @@ -790,7 +800,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, (struct ark_adapter *)dev->data->dev_private; if (ark->user_ext.dev_set_link_down) - return ark->user_ext.dev_set_link_down(dev, ark->user_data); + return ark->user_ext.dev_set_link_down(dev, + ark->user_data[dev->data->port_id]); return 0; } @@ -813,7 +824,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, for (i = 0; i < dev->data->nb_rx_queues; i++) eth_rx_queue_stats_get(dev->data->rx_queues[i], stats); if (ark->user_ext.stats_get) - ark->user_ext.stats_get(dev, stats, ark->user_data); + ark->user_ext.stats_get(dev, stats, + ark->user_data[dev->data->port_id]); } static void @@ -828,7 +840,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, for (i = 0; i < dev->data->nb_rx_queues; i++) eth_rx_queue_stats_reset(dev->data->rx_queues[i]); if (ark->user_ext.stats_reset) - ark->user_ext.stats_reset(dev, ark->user_data); + ark->user_ext.stats_reset(dev, + ark->user_data[dev->data->port_id]); } static int @@ -845,7 +858,7 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, mac_addr, index, pool, - ark->user_data); + ark->user_data[dev->data->port_id]); return 0; } return -ENOTSUP; @@ -858,7 +871,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, (struct ark_adapter *)dev->data->dev_private; if (ark->user_ext.mac_addr_remove) - ark->user_ext.mac_addr_remove(dev, index, ark->user_data); + ark->user_ext.mac_addr_remove(dev, index, + ark->user_data[dev->data->port_id]); } static void @@ -869,7 +883,8 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, (struct ark_adapter *)dev->data->dev_private; if (ark->user_ext.mac_addr_set) - ark->user_ext.mac_addr_set(dev, mac_addr, ark->user_data); + ark->user_ext.mac_addr_set(dev, mac_addr, + ark->user_data[dev->data->port_id]); } static inline int diff --git a/drivers/net/ark/ark_global.h b/drivers/net/ark/ark_global.h index a2e9e8f..58af8db 100644 --- a/drivers/net/ark/ark_global.h +++ b/drivers/net/ark/ark_global.h @@ -64,7 +64,7 @@ #define ARK_RCPACING_BASE 0xb0000 #define ARK_EXTERNAL_BASE 0x100000 #define ARK_MPU_QOFFSET 0x00100 -#define ARK_MAX_PORTS 8 +#define ARK_MAX_PORTS RTE_MAX_ETHPORTS #define offset8(n) n #define offset16(n) ((n) / 2) @@ -110,7 +110,7 @@ struct ark_user_ext { struct ark_adapter { /* User extension private data */ - void *user_data; + void *user_data[ARK_MAX_PORTS]; /* Pointers to packet generator and checker */ int start_pg; -- 1.9.1