/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "netdev-linux.h"
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <arpa/inet.h>
netdev_dev_linux_cast(const struct netdev_dev *netdev_dev)
{
const struct netdev_class *netdev_class = netdev_dev_get_class(netdev_dev);
- assert(is_netdev_linux_class(netdev_class));
+ ovs_assert(is_netdev_linux_class(netdev_class));
return CONTAINER_OF(netdev_dev, struct netdev_dev_linux, netdev_dev);
}
{
struct netdev_dev *netdev_dev = netdev_get_dev(netdev);
const struct netdev_class *netdev_class = netdev_dev_get_class(netdev_dev);
- assert(is_netdev_linux_class(netdev_class));
+ ovs_assert(is_netdev_linux_class(netdev_class));
return CONTAINER_OF(netdev, struct netdev_linux, netdev);
}
netdev_linux_miimon_wait();
}
-static int
-netdev_linux_get_drvinfo(struct netdev_dev_linux *netdev_dev)
-{
-
- int error;
-
- if (netdev_dev->cache_valid & VALID_DRVINFO) {
- return 0;
- }
-
- COVERAGE_INC(netdev_get_ethtool);
- memset(&netdev_dev->drvinfo, 0, sizeof netdev_dev->drvinfo);
- error = netdev_linux_do_ethtool(netdev_dev->netdev_dev.name,
- (struct ethtool_cmd *)&netdev_dev->drvinfo,
- ETHTOOL_GDRVINFO,
- "ETHTOOL_GDRVINFO");
- if (!error) {
- netdev_dev->cache_valid |= VALID_DRVINFO;
- }
- return error;
-}
-
static void
netdev_dev_linux_changed(struct netdev_dev_linux *dev,
unsigned int ifi_flags,
cache_notifier_ref(void)
{
if (!cache_notifier_refcount) {
- assert(!netdev_linux_cache_notifier);
+ ovs_assert(!netdev_linux_cache_notifier);
netdev_linux_cache_notifier =
rtnetlink_link_notifier_create(netdev_linux_cache_cb, NULL);
static void
cache_notifier_unref(void)
{
- assert(cache_notifier_refcount > 0);
+ ovs_assert(cache_notifier_refcount > 0);
if (!--cache_notifier_refcount) {
- assert(netdev_linux_cache_notifier);
+ ovs_assert(netdev_linux_cache_notifier);
rtnetlink_link_notifier_destroy(netdev_linux_cache_notifier);
netdev_linux_cache_notifier = NULL;
}
if (error) {
return error;
}
- assert(netdev_dev->tc == NULL);
+ ovs_assert(netdev_dev->tc == NULL);
/* Install new qdisc. */
error = new_ops->tc_install(netdev, details);
- assert((error == 0) == (netdev_dev->tc != NULL));
+ ovs_assert((error == 0) == (netdev_dev->tc != NULL));
return error;
}
}
static int
-netdev_linux_get_drv_info(const struct netdev *netdev, struct smap *smap)
+netdev_linux_get_status(const struct netdev *netdev, struct smap *smap)
{
- int error;
- struct netdev_dev_linux *netdev_dev =
- netdev_dev_linux_cast(netdev_get_dev(netdev));
+ struct netdev_dev_linux *netdev_dev;
+ int error = 0;
+
+ netdev_dev = netdev_dev_linux_cast(netdev_get_dev(netdev));
+ if (!(netdev_dev->cache_valid & VALID_DRVINFO)) {
+ struct ethtool_cmd *cmd = (struct ethtool_cmd *) &netdev_dev->drvinfo;
+
+ COVERAGE_INC(netdev_get_ethtool);
+ memset(&netdev_dev->drvinfo, 0, sizeof netdev_dev->drvinfo);
+ error = netdev_linux_do_ethtool(netdev_dev->netdev_dev.name,
+ cmd,
+ ETHTOOL_GDRVINFO,
+ "ETHTOOL_GDRVINFO");
+ if (!error) {
+ netdev_dev->cache_valid |= VALID_DRVINFO;
+ }
+ }
- error = netdev_linux_get_drvinfo(netdev_dev);
if (!error) {
smap_add(smap, "driver_name", netdev_dev->drvinfo.driver);
smap_add(smap, "driver_version", netdev_dev->drvinfo.version);
}
static int
-netdev_internal_get_drv_info(const struct netdev *netdev OVS_UNUSED,
- struct smap *smap)
+netdev_internal_get_status(const struct netdev *netdev OVS_UNUSED,
+ struct smap *smap)
{
smap_add(smap, "driver_name", "openvswitch");
return 0;
netdev_linux_destroy, \
NULL, /* get_config */ \
NULL, /* set_config */ \
+ NULL, /* get_tunnel_config */ \
\
netdev_linux_open, \
netdev_linux_close, \
netdev_linux_get_stats,
NULL, /* set_stats */
netdev_linux_get_features,
- netdev_linux_get_drv_info);
+ netdev_linux_get_status);
const struct netdev_class netdev_tap_class =
NETDEV_LINUX_CLASS(
netdev_tap_get_stats,
NULL, /* set_stats */
netdev_linux_get_features,
- netdev_linux_get_drv_info);
+ netdev_linux_get_status);
const struct netdev_class netdev_internal_class =
NETDEV_LINUX_CLASS(
netdev_internal_get_stats,
netdev_internal_set_stats,
NULL, /* get_features */
- netdev_internal_get_drv_info);
+ netdev_internal_get_status);
\f
/* HTB traffic control class. */
/* Instantiate it. */
load_error = ops->tc_load(CONST_CAST(struct netdev *, netdev), qdisc);
- assert((load_error == 0) == (netdev_dev->tc != NULL));
+ ovs_assert((load_error == 0) == (netdev_dev->tc != NULL));
ofpbuf_delete(qdisc);
return error ? error : load_error;