diff options
author | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-06-12 19:43:21 +0100 |
---|---|---|
committer | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-07-02 16:31:34 +0100 |
commit | 39944d3d6b95591eb1ac113a6816ac44c3a2832b (patch) | |
tree | a699f3e5f9355eb2a3432a7525d310a61b340b7b | |
parent | 19488c8ebc5adf449e97a7cda3db23d231f4a9f8 (diff) |
odp: configure ODP through ovsdb instead of command line
It requires a lot of changes:
- odp_init() no longer deals with command line args
- it is called from netdev_odp_register()
- when bridge_run() can access the config, it checks for other-config:odp,
but only once. Therefore enable ODP only have an effect after restart
- when found, netdev_run() calls netdev_odp_register(), usually in the second
iteration, as during the first the config is not accessible
- enable/disable needs restart
- ovs-ctl also gets this info from ovsdb, but it only works if there is
only one ovs-vswitchd registered there. Otherwise there could be
problems with kernel module loading
- ovs-ctl might start ovsdb earlier, if necessary, to check config for
module loading
- ODP_PLATFORM_PARAMS is also set from ovsdb
Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
Reviewed-and-tested-by: Ciprian Barbu <ciprian.barbu@enea.com>
-rw-r--r-- | INSTALL.ODP.md | 22 | ||||
-rw-r--r-- | lib/netdev-odp.c | 23 | ||||
-rw-r--r-- | lib/netdev-odp.h | 3 | ||||
-rw-r--r-- | lib/netdev.c | 6 | ||||
-rwxr-xr-x | utilities/ovs-ctl.in | 21 | ||||
-rw-r--r-- | vswitchd/bridge.c | 11 | ||||
-rw-r--r-- | vswitchd/ovs-vswitchd.c | 6 |
7 files changed, 57 insertions, 35 deletions
diff --git a/INSTALL.ODP.md b/INSTALL.ODP.md index 2cc543c0f..7c1dd2b2d 100644 --- a/INSTALL.ODP.md +++ b/INSTALL.ODP.md @@ -113,13 +113,29 @@ Start ovsdb-server as discussed in INSTALL doc: cd $OVS_DIR ./utilities/ovs-vsctl --no-wait init +Enable ODP for OVS (you need to restart ovs-vswitchd): + + ovs-vsctl set Open_vSwitch . other_config:odp=true + ovs-vsctl get Open_vSwitch . other_config:odp + +Disable it (you need to restart ovs-vswitchd): + + ovs-vsctl set Open_vSwitch . other_config:odp=false + +If your platform relies on startup parameters passed through +ODP_PLATFORM_PARAMS, you can also set it (you need to restart ovs-vswitchd): + + ovs-vsctl set Open_vSwitch . other_config:odp_platform_params="etc" + ovs-vsctl get Open_vSwitch . other_config:odp_platform_params + +This setting is stored in Open_vSwitch table, which has one record for every +ovs-vswitch instances. Currently you can't have more than one. + Start vswitchd: -ODP configuration arguments can be passed to vswitchd via `--odp`. -For the moment no arguments are available, but is recommended to pass --odp. e.g. export DB_SOCK=/usr/local/var/run/openvswitch/db.sock - ./vswitchd/ovs-vswitch --odp -- unix:$DB_SOCK --pidfile --detach + ./vswitchd/ovs-vswitch unix:$DB_SOCK --pidfile --detach To use ovs-vswitchd with ODP, create a bridge with datapath_type "netdev" in the configuration database. For example: diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c index 8aebf2d40..c33788e5c 100644 --- a/lib/netdev-odp.c +++ b/lib/netdev-odp.c @@ -59,7 +59,7 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); static odp_pool_t pool; static odp_pool_t struct_pool; -static int odp_initialized = 0; +int odp_initialized = 0; struct netdev_odp { struct netdev up; @@ -102,17 +102,11 @@ static void odp_abort(void) } int -odp_init(int argc, char *argv[]) +odp_init() { int result; odp_init_t params; - if (strcmp(argv[1], "--odp")) - return 0; - - argc--; - argv++; - memset(¶ms, 0, sizeof(params)); params.log_fn = &odp_override_log; params.abort_fn = &odp_abort; @@ -129,8 +123,6 @@ odp_init(int argc, char *argv[]) exit(EXIT_FAILURE); } - odp_initialized = 1; - return result; } @@ -679,12 +671,13 @@ static struct netdev_class netdev_odp_class = { void netdev_odp_register(void) { - if (!odp_initialized) { - VLOG_INFO("Not running in ODP mode\n"); - return; - } + static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; - netdev_register_provider(&netdev_odp_class); + if (ovsthread_once_start(&once)) { + odp_init(); + netdev_register_provider(&netdev_odp_class); + ovsthread_once_done(&once); + } } int diff --git a/lib/netdev-odp.h b/lib/netdev-odp.h index ba58c089b..3069d5f44 100644 --- a/lib/netdev-odp.h +++ b/lib/netdev-odp.h @@ -4,6 +4,7 @@ #include <config.h> #include "ofpbuf.h" +extern int odp_initialized; #ifdef ODP_NETDEV #include <odp.h> @@ -17,7 +18,7 @@ extern void odp_packet_parse(odp_packet_t pkt, size_t len, size_t l2_offset); void netdev_odp_register(void); void free_odp_buf(struct ofpbuf *); -int odp_init(int argc, char *argv[]); +int odp_init(void); #else diff --git a/lib/netdev.c b/lib/netdev.c index 1274d2211..31e1710ca 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -154,12 +154,10 @@ netdev_initialize(void) #endif netdev_dpdk_register(); -#ifdef ODP_NETDEV - netdev_odp_register(); -#endif - ovsthread_once_done(&once); } + if (odp_initialized) + netdev_odp_register(); } /* Performs periodic work needed by all the various kinds of netdevs. diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index 01c50cecb..5bcb01da1 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -31,6 +31,16 @@ done ## ----- ## insert_mod_if_required () { + if ! daemon_is_running ovsdb-server; then + start_ovsdb + fi + USE_ODP=`ovs_vsctl --if-exists get Open_vSwitch . other_config:odp | sed s/\"//g` + if test "X$USE_ODP" = "Xtrue"; then + USE_ODP=yes + else + USE_ODP=no + fi + # If this kernel has no module support, expect we're done. if test ! -e /proc/modules then @@ -241,12 +251,12 @@ start_forwarding () { ulimit -n $MAXFD fi + if test "X$USE_ODP" = "Xyes"; then + ODP_PLATFORM_PARAMS=`ovs_vsctl --if-exists get Open_vSwitch . other_config:odp_platform_params | sed s/\"//g` + export ODP_PLATFORM_PARAMS + fi # Start ovs-vswitchd. - if test X"$USE_ODP" != Xno; then - set ovs-vswitchd --odp -- unix:"$DB_SOCK" - else - set ovs-vswitchd unix:"$DB_SOCK" - fi + set ovs-vswitchd unix:"$DB_SOCK" set "$@" -vconsole:emer -vsyslog:err -vfile:info if test X"$MLOCKALL" != Xno; then set "$@" --mlockall @@ -535,7 +545,6 @@ set_defaults () { PROTOCOL=gre DPORT= SPORT= - USE_ODP=no type_file=$etcdir/system-type.conf version_file=$etcdir/system-version.conf diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 4d8473272..e9aac6cc7 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2842,6 +2842,17 @@ bridge_run(void) } cfg = ovsrec_open_vswitch_first(idl); +#ifdef ODP_NETDEV + if (cfg) { + static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; + + if (ovsthread_once_start(&once)) { + if (smap_get_bool(&cfg->other_config, "odp", false)) + odp_initialized = 1; + ovsthread_once_done(&once); + } + } +#endif /* Initialize the ofproto library. This only needs to run once, but * it must be done after the configuration is set. If the * initialization has already occurred, bridge_init_ofproto() diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c index 30a77b6d8..c55d2acfe 100644 --- a/vswitchd/ovs-vswitchd.c +++ b/vswitchd/ovs-vswitchd.c @@ -75,12 +75,6 @@ main(int argc, char *argv[]) argc -= retval; argv += retval; -#ifdef ODP_NETDEV - retval = odp_init(argc, argv); - argc -= retval; - argv += retval; -#endif - proctitle_init(argc, argv); service_start(&argc, &argv); remote = parse_options(argc, argv, &unixctl_path); |