Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.a...@intel.com>
Signed-off-by: Remy Horton <remy.hor...@intel.com>
Signed-off-by: Declan Doherty <declan.dohe...@intel.com>
---
 lib/librte_ether/Makefile               |   2 +
 lib/librte_ether/rte_ethdev.c           |  93 ++++++++++
 lib/librte_ether/rte_ethdev.h           |  26 +++
 lib/librte_ether/rte_ether_version.map  |   9 +
 lib/librte_ether/rte_port_representor.c | 160 ++++++++++++++++++
 lib/librte_ether/rte_port_representor.h | 289 ++++++++++++++++++++++++++++++++
 6 files changed, 579 insertions(+)
 create mode 100644 lib/librte_ether/rte_port_representor.c
 create mode 100644 lib/librte_ether/rte_port_representor.h

diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile
index db692ae..b61a84b 100644
--- a/lib/librte_ether/Makefile
+++ b/lib/librte_ether/Makefile
@@ -46,6 +46,7 @@ LIBABIVER := 6
 SRCS-y += rte_ethdev.c
 SRCS-y += rte_flow.c
 SRCS-y += rte_tm.c
+SRCS-y += rte_port_representor.c
 
 #
 # Export include files
@@ -59,5 +60,6 @@ SYMLINK-y-include += rte_flow.h
 SYMLINK-y-include += rte_flow_driver.h
 SYMLINK-y-include += rte_tm.h
 SYMLINK-y-include += rte_tm_driver.h
+SYMLINK-y-include += rte_port_representor.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0597641..3bca00f 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -67,6 +67,7 @@
 
 #include "rte_ether.h"
 #include "rte_ethdev.h"
+#include "rte_port_representor.h"
 
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
@@ -360,6 +361,98 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t 
*port_id)
        return -ENODEV;
 }
 
+#define RTE_ETH_EBDF_MAX_COLONS 2
+#define RTE_ETH_EBDF_MAX_PERIODS 1
+
+static inline int
+char_to_value(char value)
+{
+       if (value >= '0' && value <= '9')
+               return value - '0';
+       if (value >= 'A' && value <= 'F')
+               return value - 'A' + 10;
+       if (value >= 'a' && value <= 'f')
+               return value - 'a' + 10;
+       return -1;
+}
+
+static int
+parse_ebdf_addr(const char * const addr_str, struct rte_pci_addr *pci_addr)
+{
+       const char *str_pos;
+
+       int cnt_colons = 0;
+       int cnt_periods = 0;
+       int nibbles[RTE_ETH_EBDF_MAX_COLONS + RTE_ETH_EBDF_MAX_PERIODS + 1];
+       int param_value;
+       int digit_value;
+
+       str_pos = addr_str;
+       param_value = 0;
+       while (*str_pos) {
+               if (isxdigit(*str_pos)) {
+                       digit_value = char_to_value(*str_pos);
+                       if (digit_value == -1)
+                               return -EINVAL;
+                       param_value = (param_value << 4) | digit_value;
+               } else if (*str_pos == ':') {
+                       if (cnt_periods != 0 ||
+                                       cnt_colons >= RTE_ETH_EBDF_MAX_COLONS)
+                               return -EINVAL;
+                       nibbles[cnt_colons++] = param_value;
+                       param_value = 0;
+               } else if (*str_pos == '.') {
+                       if (cnt_periods >= RTE_ETH_EBDF_MAX_PERIODS)
+                               return -EINVAL;
+                       nibbles[cnt_colons + cnt_periods] = param_value;
+                       param_value = 0;
+                       cnt_periods++;
+               } else
+                       return -EINVAL;
+               str_pos++;
+       }
+       nibbles[cnt_colons + cnt_periods] = param_value;
+
+       if (cnt_colons == 2 && cnt_periods == 1) {
+               pci_addr->domain = nibbles[0];
+               pci_addr->bus = nibbles[1];
+               pci_addr->devid = nibbles[2];
+               pci_addr->function = nibbles[3];
+       } else if (cnt_colons == 1 && cnt_periods == 1) {
+               pci_addr->domain = 0;
+               pci_addr->bus = nibbles[0];
+               pci_addr->devid = nibbles[1];
+               pci_addr->function = nibbles[2];
+       } else
+               return -EINVAL;
+
+       return 0;
+}
+
+int
+rte_eth_dev_get_port_by_pci_addr_str(const char *pci_str, uint8_t *port_id)
+{
+       struct rte_pci_device *pci_dev;
+       struct rte_pci_addr pci_addr;
+
+       if (parse_ebdf_addr(pci_str, &pci_addr) != 0)
+               return -EINVAL;
+
+       FOREACH_DEVICE_ON_PCIBUS(pci_dev) {
+               if (pci_dev->driver == NULL) {
+                       /* No loaded driver - skip */
+                       continue;
+               }
+               if (rte_eal_compare_pci_addr(&pci_addr, &pci_dev->addr) == 0) {
+                       /* (E)BDF resolved to device name. Now get port_id..
+                        */
+                       return rte_eth_dev_get_port_by_name(
+                               pci_dev->device.name, port_id);
+               }
+       }
+       return -ENODEV;
+}
+
 static int
 rte_eth_dev_is_detachable(uint8_t port_id)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 0adf327..9342e45 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -967,6 +967,7 @@ struct rte_eth_dev_info {
        /** Configured number of rx/tx queues */
        uint16_t nb_rx_queues; /**< Number of RX queues. */
        uint16_t nb_tx_queues; /**< Number of TX queues. */
+       uint16_t switch_domain; /**< Switch domain which port belongs to. */
 };
 
 /**
@@ -1618,6 +1619,8 @@ enum rte_eth_dev_state {
        RTE_ETH_DEV_DEFERRED,
 };
 
+struct rte_representor_broker;
+
 /**
  * @internal
  * The generic data structure associated with each ethernet device.
@@ -1633,6 +1636,8 @@ struct rte_eth_dev {
        eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */
        eth_tx_prep_t tx_pkt_prepare; /**< Pointer to PMD transmit prepare 
function. */
        struct rte_eth_dev_data *data;  /**< Pointer to device data */
+       struct rte_port_representor_broker *rep_broker;
+       /**< Pointer to representor broker */
        const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
        struct rte_device *device; /**< Backing device */
        struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
@@ -1711,6 +1716,7 @@ struct rte_eth_dev_data {
        int numa_node;  /**< NUMA node connection */
        struct rte_vlan_filter_conf vlan_filter_conf;
        /**< VLAN filter configuration. */
+       uint16_t switch_domain; /**< Switch domain which port belongs to. */
 };
 
 /** Device supports hotplug detach */
@@ -1730,6 +1736,12 @@ struct rte_eth_dev_data {
 extern struct rte_eth_dev rte_eth_devices[];
 
 /**
+ * The pci device list needed to map the PF BDF to port id mapping for
+ * port representor pmd argument parsing.
+ */
+extern struct rte_pci_bus rte_pci_bus;
+
+/**
  * Iterates over valid ethdev ports.
  *
  * @param port_id
@@ -4436,6 +4448,20 @@ int rte_eth_dev_adjust_nb_rx_tx_desc(uint8_t port_id,
                                     uint16_t *nb_rx_desc,
                                     uint16_t *nb_tx_desc);
 
+/**
+* Get the port id from (E)BDF PCI address.
+*
+* @param pci_str
+*  Address as string
+* @param port_id
+*   pointer to port identifier of the device
+* @return
+*   - (0) if successful and port_id is filled.
+*   - (-ENODEV or -EINVAL) on failure.
+*/
+int rte_eth_dev_get_port_by_pci_addr_str(const char *pci_str, uint8_t 
*port_id);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index 4283728..c08d469 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -187,3 +187,12 @@ DPDK_17.08 {
        rte_tm_wred_profile_delete;
 
 } DPDK_17.05;
+
+DPDK_17.11 {
+       global:
+
+       rte_representor_broker_init;
+       rte_representor_add;
+       rte_representor_broker_fini;
+
+} DPDK_17.08;
diff --git a/lib/librte_ether/rte_port_representor.c 
b/lib/librte_ether/rte_port_representor.c
new file mode 100644
index 0000000..ed5faa5
--- /dev/null
+++ b/lib/librte_ether/rte_port_representor.c
@@ -0,0 +1,160 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "rte_ethdev.h"
+
+#include "rte_port_representor.h"
+
+/*
+ * Helper functions.
+ */
+static inline struct rte_port_representor *
+get_representor(struct rte_port_representor_list *list)
+{
+       struct rte_port_representor *rep;
+
+       rep = NULL;
+       if (list->num == 0)
+               return rep;
+
+       rep = STAILQ_FIRST(&list->head);
+       STAILQ_REMOVE_HEAD(&list->head, next);
+       list->num--;
+
+       return rep;
+}
+
+static inline void
+put_representor(struct rte_port_representor_list *list,
+       struct rte_port_representor *rep)
+{
+       STAILQ_INSERT_TAIL(&list->head, rep, next);
+       list->num++;
+}
+
+static inline void
+rem_representor(struct rte_port_representor_list *list,
+       struct rte_port_representor *rep)
+{
+       STAILQ_REMOVE(&list->head, rep, rte_port_representor, next);
+       list->num--;
+}
+
+struct rte_port_representor_broker *
+rte_representor_broker_init(struct rte_eth_dev *dev, uint16_t max_vfs,
+       struct representor_ops *ops)
+{
+       struct rte_port_representor_broker *rb;
+       uint32_t port_id;
+
+       if (!dev && !dev->data && !ops) {
+               errno = -EINVAL;
+               return NULL;
+       }
+       port_id = dev->data->port_id;
+
+       rb = rte_zmalloc_socket(NULL, sizeof(*rb), RTE_CACHE_LINE_SIZE,
+               rte_socket_id());
+       if (rb == NULL) {
+               errno = -ENOMEM;
+               return NULL;
+       }
+       /* update broker */
+       rb->pfid = port_id;
+       STAILQ_INIT(&rb->rep_list.head);
+       rb->max_vf = max_vfs;
+       rb->rep_ops = ops;
+
+       dev->rep_broker = rb;
+
+       /* update switch domain */
+       dev->data->switch_domain = port_id;
+
+       return rb;
+}
+
+void
+rte_representor_broker_free(uint32_t port_id)
+{
+       struct rte_port_representor *rep;
+       struct rte_eth_dev *eth_dev;
+       struct rte_port_representor_broker *rb;
+
+       eth_dev = &rte_eth_devices[port_id];
+       rb = eth_dev->rep_broker;
+       while (!STAILQ_EMPTY(&rb->rep_list.head)) {
+               rep = get_representor(&rb->rep_list);
+               rte_free(rep);
+       }
+       STAILQ_INIT(&rb->rep_list.head);
+       rte_free(rb);
+}
+
+struct rte_port_representor *
+rte_representor_initialize(uint32_t port_id, uint32_t vf_index,
+       struct rte_eth_dev *vdev)
+{
+       struct rte_port_representor *rep;
+       struct rte_eth_dev *eth_dev;
+       struct rte_port_representor_broker *rb;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, NULL);
+       eth_dev = &rte_eth_devices[port_id];
+       rb = eth_dev->rep_broker;
+
+       if (vf_index >= rb->max_vf) {
+               RTE_LOG(ERR, EAL, "Invalid vf_index=%u. Max allowed=%u\n",
+                       vf_index, rb->max_vf - 1);
+               errno = -EINVAL;
+               return NULL;
+       }
+
+       rep = rte_zmalloc_socket(NULL, sizeof(*rep), RTE_CACHE_LINE_SIZE,
+               rte_socket_id());
+       if (rep == NULL) {
+               RTE_LOG(ERR, EAL, "Not enough memory for representor.\n");
+               errno = -ENOMEM;
+               return NULL;
+       }
+
+       rep->pfid = rb->pfid;
+       rep->vf_index = vf_index;
+       rep->pdev = eth_dev;
+       rep->vdev = vdev;
+       vdev->data->switch_domain = eth_dev->data->switch_domain;
+       put_representor(&rb->rep_list, rep);
+       RTE_LOG(INFO, EAL, "%s: Added representor <pfid=%u, vf_index=%u>\n",
+               __func__, rb->pfid, vf_index);
+
+       return rep;
+}
diff --git a/lib/librte_ether/rte_port_representor.h 
b/lib/librte_ether/rte_port_representor.h
new file mode 100644
index 0000000..b132ead
--- /dev/null
+++ b/lib/librte_ether/rte_port_representor.h
@@ -0,0 +1,289 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_PORT_REPRESENTOR_H_
+#define _RTE_PORT_REPRESENTOR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rte_malloc.h>
+#include <rte_flow.h>
+
+struct rte_port_representor;
+
+/*
+ * Definitions of all functions exported by an Ethernet representor driver
+ * through the structure of type *representor_ops*.
+ */
+
+typedef int (*representor_link_update_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep,
+       int wait_to_complete);
+/**< @internal Get link speed, duplex mode and state (up/down) of a device. */
+
+typedef void (*representor_promiscuous_enable_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep);
+/**< @internal Function used to enable the RX promiscuous mode of a device. */
+
+typedef void (*representor_promiscuous_disable_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep);
+/**< @internal Function used to disable the RX promiscuous mode of a device. */
+
+typedef void (*representor_allmulticast_enable_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep);
+/**< @internal Enable the receipt of all multicast packets by a device. */
+
+typedef void (*representor_allmulticast_disable_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep);
+/**< @internal Disable the receipt of all multicast packets by a device. */
+
+typedef void (*representor_mac_addr_remove_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep,
+       uint32_t index);
+/**< @internal Remove MAC address from a device. */
+
+typedef int (*representor_mac_addr_add_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep,
+       struct ether_addr *mac_addr, uint32_t index, uint32_t vmdq);
+/**< @internal Add a MAC address into a device */
+
+typedef void (*representor_mac_addr_set_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep,
+       struct ether_addr *mac_addr);
+/**< @internal Set a MAC address of a device. */
+
+typedef int (*representor_stats_get_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep,
+       struct rte_eth_stats *stats);
+/**< @internal Get I/O statistics of a device. */
+
+typedef void (*representor_stats_reset_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep);
+/**< @internal Reset global I/O statistics of an Ethernet device to 0. */
+
+typedef void (*representor_dev_infos_get_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep,
+       struct rte_eth_dev_info *dev_info);
+/**< @internal Get specific information of an Ethernet device. */
+
+typedef int (*representor_vlan_filter_set_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep, uint16_t vlan_id, int on);
+/**< @internal filtering of a VLAN Tag Identifier by an Ethernet device. */
+
+typedef int (*representor_vlan_tpid_set_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep,
+       enum rte_vlan_type type, uint16_t tpid);
+/**< @internal set the outer/inner VLAN-TPID by an Ethernet device. */
+
+typedef void (*representor_vlan_offload_set_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep, int mask);
+/**< @internal set VLAN offload function by an Ethernet device. */
+
+typedef void (*representor_vlan_strip_queue_set_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep, int on);
+/**< @internal VLAN stripping enable/disable by an queue of Ethernet device. */
+
+typedef int (*representor_vlan_pvid_set_t)(
+       struct rte_port_representor_broker *rb,
+       struct rte_port_representor *prep, uint16_t vlan_id);
+/**< @internal set port based TX VLAN insertion by an Ethernet device. */
+
+typedef int (*representor_flow_validate_t)(
+               struct rte_port_representor_broker *rb,
+               struct rte_port_representor *prep,
+               const struct rte_flow_attr *attr,
+               const struct rte_flow_item pattern[],
+               const struct rte_flow_action actions[],
+               struct rte_flow_error *error);
+/**< @internal Check whether a flow rule can be created on a given port. */
+
+typedef struct rte_flow * (*representor_flow_create_t)(
+               struct rte_port_representor_broker *rb,
+               struct rte_port_representor *prep,
+               const struct rte_flow_attr *attr,
+               const struct rte_flow_item pattern[],
+               const struct rte_flow_action actions[],
+               struct rte_flow_error *error);
+/**< @internal Create a flow rule on a given port. */
+
+typedef int (*representor_flow_destroy_t)(
+               struct rte_port_representor_broker *rb,
+               struct rte_port_representor *prep,
+               struct rte_flow *flow,
+               struct rte_flow_error *error);
+/**< @internal Destroy a flow rule on a given port. */
+
+typedef int (*representor_flow_flush_t)(
+               struct rte_port_representor_broker *rb,
+               struct rte_port_representor *prep,
+               struct rte_flow_error *error);
+/**< @internal Destroy all flow rules associated with a port. */
+
+/**
+ * @internal A structure containing the functions exported by a
+ * representor PMD.
+ */
+struct representor_ops {
+       representor_link_update_t link_update; /**< Get device link state. */
+
+       representor_promiscuous_enable_t promiscuous_enable;
+       /**< Promiscuous ON. */
+
+       representor_promiscuous_disable_t promiscuous_disable;
+       /**< Promiscuous OFF. */
+
+       representor_allmulticast_enable_t allmulticast_enable;
+       /**< RX multicast ON. */
+
+       representor_allmulticast_disable_t allmulticast_disable;
+       /**< RX multicast OFF. */
+
+       representor_mac_addr_remove_t mac_addr_remove;
+       /**< Remove MAC address. */
+       representor_mac_addr_add_t mac_addr_add; /**< Add a MAC address. */
+       representor_mac_addr_set_t mac_addr_set; /**< Set a MAC address. */
+
+       representor_stats_get_t stats_get;
+       /**< Get generic device statistics. */
+       representor_stats_reset_t stats_reset;
+       /**< Reset generic device statistics. */
+
+       representor_dev_infos_get_t dev_infos_get;
+       /**< Get device info. */
+
+       representor_vlan_filter_set_t vlan_filter_set;
+       /**< Filter VLAN Setup. */
+       representor_vlan_tpid_set_t vlan_tpid_set;
+       /**< Outer/Inner VLAN TPID Setup. */
+       representor_vlan_offload_set_t vlan_offload_set;
+       /**< Set VLAN Offload. */
+       representor_vlan_strip_queue_set_t vlan_strip_queue_set;
+       /**< VLAN Stripping on queue. */
+       representor_vlan_pvid_set_t vlan_pvid_set;
+       /**< Set port based TX VLAN insertion. */
+
+       representor_flow_validate_t flow_validate;
+       /** Check whether a flow rule can be created on a given port. */
+       representor_flow_create_t flow_create;
+       /** Create a flow rule on a given port. */
+       representor_flow_destroy_t flow_destroy;
+       /** Destroy a flow rule on a given port. */
+       representor_flow_flush_t flow_flush;
+       /** Destroy all flow rules associated with a port. */
+};
+
+struct rte_port_representor {
+       uint32_t pfid; /**< parent physical function id */
+       uint32_t vf_index; /**< virtual function index */
+       struct rte_eth_dev *pdev; /**< parent PF PMD */
+       struct rte_eth_dev *vdev; /**< representor PMD */
+       STAILQ_ENTRY(rte_port_representor) next; /**< list pointer */
+};
+
+struct rte_port_representor_list {
+       uint32_t num; /**< number of representors in the list */
+       STAILQ_HEAD(, rte_port_representor) head; /**< list head */
+};
+
+struct rte_port_representor_broker {
+       uint32_t pfid; /**< physical function id that broker belongs to. */
+       uint32_t max_vf; /**< maximum number of VF to support. */
+       const struct representor_ops *rep_ops;
+       /**< supported ops by representor */
+       struct rte_port_representor_list rep_list; /**< list of representors */
+};
+
+/**
+ * Port representor broker initialization function
+ *
+ * This function is called in HW driver initialization routine if the port
+ * representor is enabled by EAL command line argument.
+ *
+ * @param dev
+ *   The eth_dev structure for physical function.
+ * @param max_vfs
+ *   The maximum number of VFs can be represented by this broker.
+ * @param ops
+ *   Supported representor ops.
+ * @return
+ *   Return the pointer to allocated memory for representor broker.
+ */
+struct rte_port_representor_broker *
+rte_representor_broker_init(struct rte_eth_dev *dev, uint16_t max_vfs,
+       struct representor_ops *ops);
+
+/**
+ * This function adds creates a representor PMD and add to the broker
+ * @param port_id
+ *    The physical function identifier
+ * @param vf_index
+ *    The virtual function index
+ * @param vdev
+ *    Pointer to the allocated rte_eth_dev structure for the representor PMD
+ * @return
+ *    Returns the pointer in broker for the representor PMD
+ */
+struct rte_port_representor *
+rte_representor_initialize(uint32_t port_id, uint32_t vf_index,
+       struct rte_eth_dev *vdev);
+
+/**
+ * This functions deallocates all the allocated memory for representor PMDs
+ * @param port_id
+ *    The physical function identifier
+ */
+void
+rte_representor_broker_free(uint32_t port_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_PORT_REPRESENTOR_H_ */
-- 
2.7.4

Reply via email to