@@ -20,9 +20,12 @@
int main(int argc, char *argv[])
{
odp_instance_t instance;
+ odp_pktio_t pktio = ODP_PKTIO_INVALID;
- (void)argc;
- (void)argv;
+ if (argc == 1 || argc > 2) {
+ printf("Error: invalid parameter.\nUsage:\n\t%s <interface>\n", argv[0]);
+ exit(0);
+ }
EXAMPLE_DBG("Start DDF Application...\n");
@@ -37,6 +40,15 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ /* Open pktio*/
+ pktio = odp_pktio_open(argv[1], ODP_POOL_INVALID, NULL);
+ if (pktio == ODP_PKTIO_INVALID)
+ EXAMPLE_ERR("Error: Failed to open pktio \"%s\".\n", argv[1]);
+
+ /* Close pktio*/
+ if (odp_pktio_close(pktio))
+ EXAMPLE_ERR("Error: Failed to close pktio \"%s\".\n", argv[1]);
+
/* Print ddf objects*/
odpdrv_print_all();
@@ -2,8 +2,10 @@ LIB = $(top_builddir)/lib
AM_CPPFLAGS += -I$(srcdir) \
-I$(top_srcdir)/include \
+ -I$(top_srcdir)/include/odp/arch/@ARCH_ABI@ \
-I$(top_srcdir)/platform/@with_platform@/include \
- -I$(top_srcdir)/platform/@with_platform@/arch/@ARCH_DIR@
+ -I$(top_srcdir)/platform/@with_platform@/arch/@ARCH_DIR@ \
+ -I$(top_srcdir)/frameworks/modular
lib_LTLIBRARIES = $(LIB)/libddf_ifs.la
@@ -7,9 +7,19 @@
#include <stdio.h>
#include <string.h>
#include "odp_drv.h"
+#include <odp_packet_io_internal.h>
#include "ddf_ifs_api.h"
#include "ddf_ifs_driver.h"
+#define DDF_IFS_NAME_SIZE 50
+#define DDF_IFS_DEV_PREFIX "ddf_ifs:"
+#define DDF_IFS_DEV_PREFIX_LEN 8
+/** Packet socket using netmap mmaped rings for both Rx and Tx */
+typedef struct {
+ char dev_name[DDF_IFS_NAME_SIZE]; /**< interface name */
+} pktio_ops_ddf_ifs_data_t;
+
+
static odpdrv_driver_t ddf_ifs_driver;
static int drv_data = 12;
@@ -46,8 +56,79 @@ static int ddf_ifs_driver_remove(void)
return 0;
}
+static int ddf_ifs_init_global(void)
+{
+ printf("%s()\n", __func__);
+ return 0;
+}
+static int ddf_ifs_term_global(void)
+{
+ printf("%s()\n", __func__);
+ return 0;
+}
+
+static int ddf_ifs_open(odp_pktio_t pktio ODP_UNUSED, pktio_entry_t *pktio_entry,
+ const char *devname, odp_pool_t pool)
+{
+ pktio_ops_ddf_ifs_data_t *pkt_ddf_ifs = _ops_data(pktio_entry, ddf_ifs);
+
+ (void)pktio;
+ (void)pool;
+
+ printf("%s(%s)\n", __func__, devname);
+ if (strncmp(devname, DDF_IFS_DEV_PREFIX, DDF_IFS_DEV_PREFIX_LEN) == 0)
+ devname += DDF_IFS_DEV_PREFIX_LEN;
+ else
+ return -1;
+
+ strcpy(pkt_ddf_ifs->dev_name, devname);
+ printf("%s() - device %s oppened!!!\n", __func__,
+ pkt_ddf_ifs->dev_name);
+ return 0;
+}
+
+static int ddf_ifs_close(pktio_entry_t *pktio_entry)
+{
+ pktio_ops_ddf_ifs_data_t *pkt_ddf_ifs = _ops_data(pktio_entry, ddf_ifs);
+
+ printf("%s() - device %s closed.\n", __func__, pkt_ddf_ifs->dev_name);
+
+ return 0;
+}
+
+static pktio_ops_module_t ddf_ifs_pktio_ops = {
+ .base = {
+ .name = "ddf_ifs",
+ .init_local = NULL,
+ .term_local = NULL,
+ .init_global = ddf_ifs_init_global,
+ .term_global = ddf_ifs_term_global,
+ },
+ .open = ddf_ifs_open,
+ .close = ddf_ifs_close,
+ .start = NULL/*ddf_ifs_start*/,
+ .stop = NULL/*ddf_ifs_stop*/,
+ .stats = NULL/*ddf_ifs_stats*/,
+ .stats_reset = NULL/*ddf_ifs_stats_reset*/,
+ .pktin_ts_res = NULL,
+ .pktin_ts_from_ns = NULL,
+ .recv = NULL/*ddf_ifs_recv*/,
+ .send = NULL/*ddf_ifs_send*/,
+ .mtu_get = NULL/*ddf_ifs_mtu_get*/,
+ .promisc_mode_set = NULL/*ddf_ifs_promisc_mode_set*/,
+ .promisc_mode_get = NULL/*ddf_ifs_promisc_mode_get*/,
+ .mac_get = NULL/*ddf_ifs_mac_addr_get*/,
+ .link_status = NULL/*ddf_ifs_link_status*/,
+ .capability = NULL/*ddf_ifs_capability*/,
+ .config = NULL,
+ .input_queues_config = NULL/*ddf_ifs_input_queues_config*/,
+ .output_queues_config = NULL/*ddf_ifs_output_queues_config*/,
+ .print = NULL/*ddf_ifs_print*/,
+};
+
int register_driver(void)
{
+/* Register ddf driver*/
odpdrv_driver_param_t param = {
.name = DDF_IFS_DRV_NAME,
.devios = {{DDF_IFS_DEVIO_API_NAME, DDF_IFS_DEVIO_API_VER},
@@ -65,5 +146,12 @@ int register_driver(void)
return -1;
}
+/* Register pktio_ops module*/
+ odp_module_constructor(&ddf_ifs_pktio_ops);
+
+ odp_subsystem_register_module(pktio_ops, &ddf_ifs_pktio_ops);
+
+/* Explicit call to Init global*/
+ ddf_ifs_init_global();
return 0;
}
@@ -38,6 +38,11 @@
#ifndef ODP_MODULE_H_
#define ODP_MODULE_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#include <stdbool.h>
#include <odp/api/rwlock.h>
@@ -293,4 +298,9 @@ int __subsystem_register_module(
__subsystem_set_active(&__subsystem(name), base); \
})
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
#endif
@@ -8,6 +8,11 @@
#ifndef ODP_PKTIO_OPS_SUBSYSTEM_H_
#define ODP_PKTIO_OPS_SUBSYSTEM_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#include <odp_module.h>
#include <odp/api/packet_io.h>
@@ -78,4 +83,9 @@ typedef ODP_MODULE_CLASS(pktio_ops) {
odp_api_proto(pktio_ops, print) print;
} pktio_ops_module_t;
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
#endif
Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org> --- example/ddf_app/odp_ddf_app.c | 16 +++- example/ddf_ifs/Makefile.am | 4 +- example/ddf_ifs/ddf_ifs_driver.c | 88 ++++++++++++++++++++++ frameworks/modular/odp_module.h | 10 +++ .../include/odp_pktio_ops_subsystem.h | 10 +++ 5 files changed, 125 insertions(+), 3 deletions(-) -- 2.1.4