Add dpdk_mtu_get(), dpdk_promisc_mode_set(),
dpdk_promisc_mode_get(), and dpdk_capability() functions.

Reviewed-by: Petri Savolainen <[email protected]>
Signed-off-by: Matias Elo <[email protected]>
---
 platform/linux-generic/pktio/dpdk.c | 44 +++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index be622dd..aad4066 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -273,6 +273,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED,
                     odp_pool_t pool)
 {
        pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk;
+       struct rte_eth_dev_info dev_info;
        struct rte_mempool *pkt_pool;
        odp_pool_info_t pool_info;
        uint16_t data_room;
@@ -314,6 +315,11 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED,
                return -1;
        }
 
+       memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
+       rte_eth_dev_info_get(pkt_dpdk->port_id, &dev_info);
+       pkt_dpdk->capa.max_input_queues = dev_info.max_rx_queues;
+       pkt_dpdk->capa.max_output_queues = dev_info.max_tx_queues;
+
        /* Look for previously opened packet pool */
        pkt_pool = rte_mempool_lookup(pkt_dpdk->pool_name);
        if (pkt_pool == NULL)
@@ -554,6 +560,36 @@ static int dpdk_mac_addr_get(pktio_entry_t *pktio_entry, 
void *mac_addr)
        return ETH_ALEN;
 }
 
+static int dpdk_mtu_get(pktio_entry_t *pktio_entry)
+{
+       uint16_t mtu;
+
+       if (rte_eth_dev_get_mtu(pktio_entry->s.pkt_dpdk.port_id, &mtu) != 0)
+               return -1;
+       return mtu;
+}
+
+static int dpdk_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable)
+{
+       if (enable)
+               rte_eth_promiscuous_enable(pktio_entry->s.pkt_dpdk.port_id);
+       else
+               rte_eth_promiscuous_disable(pktio_entry->s.pkt_dpdk.port_id);
+       return 0;
+}
+
+static int dpdk_promisc_mode_get(pktio_entry_t *pktio_entry)
+{
+       return rte_eth_promiscuous_get(pktio_entry->s.pkt_dpdk.port_id);
+}
+
+static int dpdk_capability(pktio_entry_t *pktio_entry,
+                          odp_pktio_capability_t *capa)
+{
+       *capa = pktio_entry->s.pkt_dpdk.capa;
+       return 0;
+}
+
 const pktio_if_ops_t dpdk_pktio_ops = {
        .name = "dpdk",
        .init = NULL,
@@ -567,11 +603,11 @@ const pktio_if_ops_t dpdk_pktio_ops = {
        .recv_queue = dpdk_recv_queue,
        .send_queue = dpdk_send_queue,
        .link_status = NULL,
-       .mtu_get = NULL,
-       .promisc_mode_set = NULL,
-       .promisc_mode_get = NULL,
+       .mtu_get = dpdk_mtu_get,
+       .promisc_mode_set = dpdk_promisc_mode_set,
+       .promisc_mode_get = dpdk_promisc_mode_get,
        .mac_get = dpdk_mac_addr_get,
-       .capability = NULL,
+       .capability = dpdk_capability,
        .input_queues_config = NULL,
        .output_queues_config = NULL,
        .in_queues = NULL,
-- 
1.9.1

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to