projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ofp-actions: Remove unused variable.
[openvswitch]
/
lib
/
dpif-netdev.c
diff --git
a/lib/dpif-netdev.c
b/lib/dpif-netdev.c
index 8381a8978e38bb4afd078a996088818f937def07..c9e3210f13209ef167f1d6313057d67f044dc281 100644
(file)
--- a/
lib/dpif-netdev.c
+++ b/
lib/dpif-netdev.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira
Networks
.
+ * Copyright (c) 2009, 2010, 2011, 2012 Nicira
, Inc
.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-70,8
+70,13
@@
enum { MAX_QUEUE_LEN = 128 }; /* Maximum number of packets per queue. */
enum { QUEUE_MASK = MAX_QUEUE_LEN - 1 };
BUILD_ASSERT_DECL(IS_POW2(MAX_QUEUE_LEN));
enum { QUEUE_MASK = MAX_QUEUE_LEN - 1 };
BUILD_ASSERT_DECL(IS_POW2(MAX_QUEUE_LEN));
+struct dp_netdev_upcall {
+ struct dpif_upcall upcall; /* Queued upcall information. */
+ struct ofpbuf buf; /* ofpbuf instance for upcall.packet. */
+};
+
struct dp_netdev_queue {
struct dp_netdev_queue {
- struct dp
if_upcall *
upcalls[MAX_QUEUE_LEN];
+ struct dp
_netdev_upcall
upcalls[MAX_QUEUE_LEN];
unsigned int head, tail;
};
unsigned int head, tail;
};
@@
-113,7
+118,7
@@
struct dp_netdev_flow {
long long int used; /* Last used time, in monotonic msecs. */
long long int packet_count; /* Number of packets matched. */
long long int byte_count; /* Number of bytes matched. */
long long int used; /* Last used time, in monotonic msecs. */
long long int packet_count; /* Number of packets matched. */
long long int byte_count; /* Number of bytes matched. */
-
ovs_be16 tcp_flags;
/* Bitwise-OR of seen tcp_flags values. */
+
uint8_t tcp_flags;
/* Bitwise-OR of seen tcp_flags values. */
/* Actions. */
struct nlattr *actions;
/* Actions. */
struct nlattr *actions;
@@
-165,6
+170,17
@@
get_dp_netdev(const struct dpif *dpif)
return dpif_netdev_cast(dpif)->dp;
}
return dpif_netdev_cast(dpif)->dp;
}
+static int
+dpif_netdev_enumerate(struct sset *all_dps)
+{
+ struct shash_node *node;
+
+ SHASH_FOR_EACH(node, &dp_netdevs) {
+ sset_add(all_dps, node->name);
+ }
+ return 0;
+}
+
static struct dpif *
create_dpif_netdev(struct dp_netdev *dp)
{
static struct dpif *
create_dpif_netdev(struct dp_netdev *dp)
{
@@
-248,10
+264,8
@@
dp_netdev_purge_queues(struct dp_netdev *dp)
struct dp_netdev_queue *q = &dp->queues[i];
while (q->tail != q->head) {
struct dp_netdev_queue *q = &dp->queues[i];
while (q->tail != q->head) {
- struct dpif_upcall *upcall = q->upcalls[q->tail++ & QUEUE_MASK];
-
- ofpbuf_delete(upcall->packet);
- free(upcall);
+ struct dp_netdev_upcall *u = &q->upcalls[q->tail++ & QUEUE_MASK];
+ ofpbuf_uninit(&u->buf);
}
}
}
}
}
}
@@
-396,7
+410,16
@@
dpif_netdev_port_add(struct dpif *dpif, struct netdev *netdev,
struct dp_netdev *dp = get_dp_netdev(dpif);
int port_no;
struct dp_netdev *dp = get_dp_netdev(dpif);
int port_no;
- port_no = choose_port(dpif, netdev);
+ if (*port_nop != UINT16_MAX) {
+ if (*port_nop >= MAX_PORTS) {
+ return EFBIG;
+ } else if (dp->ports[*port_nop]) {
+ return EBUSY;
+ }
+ port_no = *port_nop;
+ } else {
+ port_no = choose_port(dpif, netdev);
+ }
if (port_no >= 0) {
*port_nop = port_no;
return do_add_port(dp, netdev_get_name(netdev),
if (port_no >= 0) {
*port_nop = port_no;
return do_add_port(dp, netdev_get_name(netdev),
@@
-702,10
+725,9
@@
set_flow_actions(struct dp_netdev_flow *flow,
}
static int
}
static int
-
add_flow(struct dpif *dpif
, const struct flow *key,
- const struct nlattr *actions, size_t actions_len)
+
dp_netdev_flow_add(struct dp_netdev *dp
, const struct flow *key,
+
const struct nlattr *actions, size_t actions_len)
{
{
- struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *flow;
int error;
struct dp_netdev_flow *flow;
int error;
@@
-751,7
+773,8
@@
dpif_netdev_flow_put(struct dpif *dpif, const struct dpif_flow_put *put)
if (put->stats) {
memset(put->stats, 0, sizeof *put->stats);
}
if (put->stats) {
memset(put->stats, 0, sizeof *put->stats);
}
- return add_flow(dpif, &key, put->actions, put->actions_len);
+ return dp_netdev_flow_add(dp, &key, put->actions,
+ put->actions_len);
} else {
return EFBIG;
}
} else {
return EFBIG;
}
@@
-777,24
+800,22
@@
dpif_netdev_flow_put(struct dpif *dpif, const struct dpif_flow_put *put)
}
static int
}
static int
-dpif_netdev_flow_del(struct dpif *dpif,
- const struct nlattr *nl_key, size_t nl_key_len,
- struct dpif_flow_stats *stats)
+dpif_netdev_flow_del(struct dpif *dpif, const struct dpif_flow_del *del)
{
struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *flow;
struct flow key;
int error;
{
struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *flow;
struct flow key;
int error;
- error = dpif_netdev_flow_from_nlattrs(
nl_key, nl_
key_len, &key);
+ error = dpif_netdev_flow_from_nlattrs(
del->key, del->
key_len, &key);
if (error) {
return error;
}
flow = dp_netdev_lookup_flow(dp, &key);
if (flow) {
if (error) {
return error;
}
flow = dp_netdev_lookup_flow(dp, &key);
if (flow) {
- if (stats) {
- get_dpif_flow_stats(flow, stats);
+ if (
del->
stats) {
+ get_dpif_flow_stats(flow,
del->
stats);
}
dp_netdev_free_flow(dp, flow);
return 0;
}
dp_netdev_free_flow(dp, flow);
return 0;
@@
-895,7
+916,7
@@
dpif_netdev_execute(struct dpif *dpif, const struct dpif_execute *execute)
ofpbuf_reserve(©, DP_NETDEV_HEADROOM);
ofpbuf_put(©, execute->packet->data, execute->packet->size);
ofpbuf_reserve(©, DP_NETDEV_HEADROOM);
ofpbuf_put(©, execute->packet->data, execute->packet->size);
- flow_extract(©, 0,
0
, -1, &key);
+ flow_extract(©, 0,
NULL
, -1, &key);
error = dpif_netdev_flow_from_nlattrs(execute->key, execute->key_len,
&key);
if (!error) {
error = dpif_netdev_flow_from_nlattrs(execute->key, execute->key_len,
&key);
if (!error) {
@@
-937,13
+958,18
@@
find_nonempty_queue(struct dpif *dpif)
}
static int
}
static int
-dpif_netdev_recv(struct dpif *dpif, struct dpif_upcall *upcall)
+dpif_netdev_recv(struct dpif *dpif, struct dpif_upcall *upcall,
+ struct ofpbuf *buf)
{
struct dp_netdev_queue *q = find_nonempty_queue(dpif);
if (q) {
{
struct dp_netdev_queue *q = find_nonempty_queue(dpif);
if (q) {
- struct dpif_upcall *u = q->upcalls[q->tail++ & QUEUE_MASK];
- *upcall = *u;
- free(u);
+ struct dp_netdev_upcall *u = &q->upcalls[q->tail++ & QUEUE_MASK];
+
+ *upcall = u->upcall;
+ upcall->packet = buf;
+
+ ofpbuf_uninit(buf);
+ *buf = u->buf;
return 0;
} else {
return 0;
} else {
@@
-970,13
+996,12
@@
dpif_netdev_recv_purge(struct dpif *dpif)
}
\f
static void
}
\f
static void
-dp_netdev_flow_used(struct dp_netdev_flow *flow, struct flow *key,
- const struct ofpbuf *packet)
+dp_netdev_flow_used(struct dp_netdev_flow *flow, const struct ofpbuf *packet)
{
flow->used = time_msec();
flow->packet_count++;
flow->byte_count += packet->size;
{
flow->used = time_msec();
flow->packet_count++;
flow->byte_count += packet->size;
- flow->tcp_flags |= packet_get_tcp_flags(packet, key);
+ flow->tcp_flags |= packet_get_tcp_flags(packet,
&flow->
key);
}
static void
}
static void
@@
-989,10
+1014,10
@@
dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port,
if (packet->size < ETH_HEADER_LEN) {
return;
}
if (packet->size < ETH_HEADER_LEN) {
return;
}
- flow_extract(packet, 0,
0, port->port_no
, &key);
+ flow_extract(packet, 0,
NULL, odp_port_to_ofp_port(port->port_no)
, &key);
flow = dp_netdev_lookup_flow(dp, &key);
if (flow) {
flow = dp_netdev_lookup_flow(dp, &key);
if (flow) {
- dp_netdev_flow_used(flow,
&key,
packet);
+ dp_netdev_flow_used(flow, packet);
dp_netdev_execute_actions(dp, packet, &key,
flow->actions, flow->actions_len);
dp->n_hit++;
dp_netdev_execute_actions(dp, packet, &key,
flow->actions, flow->actions_len);
dp->n_hit++;
@@
-1065,6
+1090,7
@@
dp_netdev_output_userspace(struct dp_netdev *dp, const struct ofpbuf *packet,
int queue_no, const struct flow *flow, uint64_t arg)
{
struct dp_netdev_queue *q = &dp->queues[queue_no];
int queue_no, const struct flow *flow, uint64_t arg)
{
struct dp_netdev_queue *q = &dp->queues[queue_no];
+ struct dp_netdev_upcall *u;
struct dpif_upcall *upcall;
struct ofpbuf *buf;
size_t key_len;
struct dpif_upcall *upcall;
struct ofpbuf *buf;
size_t key_len;
@@
-1074,22
+1100,23
@@
dp_netdev_output_userspace(struct dp_netdev *dp, const struct ofpbuf *packet,
return ENOBUFS;
}
return ENOBUFS;
}
- buf = ofpbuf_new(ODPUTIL_FLOW_KEY_BYTES + 2 + packet->size);
+ u = &q->upcalls[q->head++ & QUEUE_MASK];
+
+ buf = &u->buf;
+ ofpbuf_init(buf, ODPUTIL_FLOW_KEY_BYTES + 2 + packet->size);
odp_flow_key_from_flow(buf, flow);
key_len = buf->size;
ofpbuf_pull(buf, key_len);
ofpbuf_reserve(buf, 2);
ofpbuf_put(buf, packet->data, packet->size);
odp_flow_key_from_flow(buf, flow);
key_len = buf->size;
ofpbuf_pull(buf, key_len);
ofpbuf_reserve(buf, 2);
ofpbuf_put(buf, packet->data, packet->size);
- upcall =
xzalloc(sizeof *upcall)
;
+ upcall =
&u->upcall
;
upcall->type = queue_no;
upcall->packet = buf;
upcall->key = buf->base;
upcall->key_len = key_len;
upcall->userdata = arg;
upcall->type = queue_no;
upcall->packet = buf;
upcall->key = buf->base;
upcall->key_len = key_len;
upcall->userdata = arg;
- q->upcalls[q->head++ & QUEUE_MASK] = upcall;
-
return 0;
}
return 0;
}
@@
-1239,7
+1266,7
@@
dp_netdev_execute_actions(struct dp_netdev *dp,
const struct dpif_class dpif_netdev_class = {
"netdev",
const struct dpif_class dpif_netdev_class = {
"netdev",
- NULL, /* enumerate */
+ dpif_netdev_enumerate,
dpif_netdev_open,
dpif_netdev_close,
dpif_netdev_destroy,
dpif_netdev_open,
dpif_netdev_close,
dpif_netdev_destroy,