net/ark: allow unique user data for each port
authorJohn Miller <john.miller@atomicrules.com>
Wed, 28 Jun 2017 10:08:22 +0000 (06:08 -0400)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 6 Jul 2017 13:00:57 +0000 (15:00 +0200)
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.

With this patch, we are providing a unique user pointer for each port
rather than a common pointer across multiple ports.

Signed-off-by: John Miller <john.miller@atomicrules.com>
drivers/net/ark/ark_ethdev.c
drivers/net/ark/ark_global.h

index c061f7b..0931712 100644 (file)
@@ -346,8 +346,9 @@ eth_ark_dev_init(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 +370,8 @@ eth_ark_dev_init(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 +412,10 @@ eth_ark_dev_init(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 +511,8 @@ eth_ark_dev_uninit(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 +533,8 @@ eth_ark_dev_configure(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 +597,8 @@ eth_ark_dev_start(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 +620,8 @@ eth_ark_dev_stop(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 +704,8 @@ eth_ark_dev_close(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 +773,7 @@ eth_ark_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
        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 +786,8 @@ eth_ark_dev_set_link_up(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 +799,8 @@ eth_ark_dev_set_link_down(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 +823,8 @@ eth_ark_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
        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 +839,8 @@ eth_ark_dev_stats_reset(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 +857,7 @@ eth_ark_macaddr_add(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 +870,8 @@ eth_ark_macaddr_remove(struct rte_eth_dev *dev, uint32_t index)
                (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 +882,8 @@ eth_ark_set_default_mac_addr(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
index a2e9e8f..58af8db 100644 (file)
@@ -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;