2014-05-02 09:54:27 +03:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013, 2014 Alexandru Copot <alex.mihai.c@gmail.com>, with support from IXIA.
|
|
|
|
|
* Copyright (c) 2013, 2014 Daniel Baluta <dbaluta@ixiacom.com>
|
packets: Remove unnecessary "packed" annotations.
I know of two reasons to mark a structure as "packed". The first is
because the structure must match some defined interface and therefore
compiler-inserted padding between or after members would cause its layout
to diverge from that interface. This is not a problem in a structure that
follows the general alignment rules that are seen in ABIs for all the
architectures that OVS cares about: basically, that a struct member needs
to be aligned on a boundary that is a multiple of the member's size.
The second reason is because instances of the struct tend to be at
misaligned addresses.
struct eth_header and struct vlan_eth_header are normally aligned on
16-bit boundaries (at least), and they contain only 16-bit members, so
there's no need to pack them. This commit removes the packed annotation.
This commit also removes the packed annotation from struct llc_header.
Since that struct only contains 8-bit members, I don't know of any benefit
to packing it, period.
This commit also removes a few more packed annotations that are much less
important.
When these packed annotations were removed, it caused a few warnings
related to casts from 'uint8_t *' to more strictly aligned pointer types,
related to struct ovs_action_push_tnl. That's because that struct had a
trailing member used to store packet headers, that was declared as
a uint8_t[]. Before, when this was cast to 'struct eth_header *', there
was no change in alignment since eth_header was packed; now that
eth_header is not packed, the compiler considers it suspicious. This
commit avoids that problem by changing the member from uint8_t[] to
uint32_t[], which assures the compiler that it is properly aligned.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
2017-05-30 08:22:03 -07:00
|
|
|
|
* Copyright (c) 2014, 2015, 2016, 2017 Nicira, Inc.
|
2014-05-02 09:54:27 +03:00
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef BUNDLES_H
|
|
|
|
|
#define BUNDLES_H 1
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
|
|
#include "connmgr.h"
|
2015-06-01 15:47:58 -07:00
|
|
|
|
#include "ofproto-provider.h"
|
2016-04-04 21:32:10 -04:00
|
|
|
|
#include "openvswitch/ofp-msgs.h"
|
2015-06-01 15:47:58 -07:00
|
|
|
|
#include "util.h"
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-06-01 18:07:39 -07:00
|
|
|
|
struct ofp_bundle_entry {
|
|
|
|
|
struct ovs_list node;
|
2016-09-14 16:51:27 -07:00
|
|
|
|
enum ofptype type; /* OFPTYPE_FLOW_MOD, OFPTYPE_PORT_MOD,
|
|
|
|
|
* OFPTYPE_GROUP_MOD, OFPTYPE_PACKET_OUT. */
|
2018-01-09 10:38:31 -08:00
|
|
|
|
struct ofp_header *msg; /* Original request, for error reporting. */
|
2015-06-01 18:07:39 -07:00
|
|
|
|
union {
|
2016-08-15 14:57:12 -07:00
|
|
|
|
struct ofproto_flow_mod ofm;
|
ofproto: Add struct ofproto_flow_mod.
It is cleaner to not use ofp_bundle_entry for non-bundle flow mods.
To address this, the new struct ofproto_flow_mod combines an
ofputil_flow_mod and the necessary execution context for executing the
start, revert, and finish phases of the flow mod, which all were
previously members of struct ofp_bundle_entry.
This also simplifies many of the function prototypes introduced with
the OF 1.4 bundles code. However, in case of learn action execution
this approach requires a new copy of the ofputil_flow_mod. This could
be avoided by making struct ofproto_flow_mod more complex, but it
seems not worth the complication.
As part of carving out the execution context from ofp_bundle_entry to
ofproto_flow_mod, the 'version' member is now also in
ofproto_flow_mod, as it makes sense for flow mods, but not for port
mods. Now that the functions operate on the version also get the full
execution context, they use 'version' instead of
'ofproto->tables_version'. This allows ofproto->tables_version to be
changed only when a new version is committed.
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2015-07-06 11:45:54 -07:00
|
|
|
|
struct ofproto_port_mod opm;
|
2016-07-29 16:52:04 -07:00
|
|
|
|
struct ofproto_group_mod ogm;
|
2016-09-14 16:51:27 -07:00
|
|
|
|
struct ofproto_packet_out opo;
|
2015-06-01 18:07:39 -07:00
|
|
|
|
};
|
|
|
|
|
};
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
packets: Remove unnecessary "packed" annotations.
I know of two reasons to mark a structure as "packed". The first is
because the structure must match some defined interface and therefore
compiler-inserted padding between or after members would cause its layout
to diverge from that interface. This is not a problem in a structure that
follows the general alignment rules that are seen in ABIs for all the
architectures that OVS cares about: basically, that a struct member needs
to be aligned on a boundary that is a multiple of the member's size.
The second reason is because instances of the struct tend to be at
misaligned addresses.
struct eth_header and struct vlan_eth_header are normally aligned on
16-bit boundaries (at least), and they contain only 16-bit members, so
there's no need to pack them. This commit removes the packed annotation.
This commit also removes the packed annotation from struct llc_header.
Since that struct only contains 8-bit members, I don't know of any benefit
to packing it, period.
This commit also removes a few more packed annotations that are much less
important.
When these packed annotations were removed, it caused a few warnings
related to casts from 'uint8_t *' to more strictly aligned pointer types,
related to struct ovs_action_push_tnl. That's because that struct had a
trailing member used to store packet headers, that was declared as
a uint8_t[]. Before, when this was cast to 'struct eth_header *', there
was no change in alignment since eth_header was packed; now that
eth_header is not packed, the compiler considers it suspicious. This
commit avoids that problem by changing the member from uint8_t[] to
uint32_t[], which assures the compiler that it is properly aligned.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
2017-05-30 08:22:03 -07:00
|
|
|
|
enum bundle_state {
|
2015-05-29 11:28:38 -07:00
|
|
|
|
BS_OPEN,
|
|
|
|
|
BS_CLOSED
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ofp_bundle {
|
|
|
|
|
struct hmap_node node; /* In struct ofconn's "bundles" hmap. */
|
2016-09-13 14:46:16 -07:00
|
|
|
|
long long int used; /* Last time bundle was used. */
|
2015-05-29 11:28:38 -07:00
|
|
|
|
uint32_t id;
|
|
|
|
|
uint16_t flags;
|
|
|
|
|
enum bundle_state state;
|
2018-01-09 10:38:31 -08:00
|
|
|
|
struct ofp_header *msg; /* Original request, for error reporting. */
|
|
|
|
|
struct ovs_list msg_list; /* List of 'struct bundle_message's */
|
2015-05-29 11:28:38 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-06-01 18:07:39 -07:00
|
|
|
|
static inline void ofp_bundle_entry_free(struct ofp_bundle_entry *);
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
2016-09-13 14:46:16 -07:00
|
|
|
|
enum ofperr ofp_bundle_open(struct ofconn *, uint32_t id, uint16_t flags,
|
|
|
|
|
const struct ofp_header *);
|
2015-06-01 18:07:39 -07:00
|
|
|
|
enum ofperr ofp_bundle_close(struct ofconn *, uint32_t id, uint16_t flags);
|
|
|
|
|
enum ofperr ofp_bundle_discard(struct ofconn *, uint32_t id);
|
|
|
|
|
enum ofperr ofp_bundle_add_message(struct ofconn *, uint32_t id,
|
2016-09-13 14:46:16 -07:00
|
|
|
|
uint16_t flags, struct ofp_bundle_entry *,
|
|
|
|
|
const struct ofp_header *);
|
2015-05-29 11:28:38 -07:00
|
|
|
|
|
2016-09-15 13:59:52 -07:00
|
|
|
|
void ofp_bundle_remove__(struct ofconn *, struct ofp_bundle *);
|
2015-06-01 18:07:39 -07:00
|
|
|
|
|
2015-06-01 15:47:58 -07:00
|
|
|
|
static inline void
|
|
|
|
|
ofp_bundle_entry_free(struct ofp_bundle_entry *entry)
|
2015-06-01 18:07:39 -07:00
|
|
|
|
{
|
|
|
|
|
if (entry) {
|
|
|
|
|
if (entry->type == OFPTYPE_FLOW_MOD) {
|
2016-08-15 14:57:12 -07:00
|
|
|
|
ofproto_flow_mod_uninit(&entry->ofm);
|
2016-07-29 16:52:04 -07:00
|
|
|
|
} else if (entry->type == OFPTYPE_GROUP_MOD) {
|
|
|
|
|
ofputil_uninit_group_mod(&entry->ogm.gm);
|
2016-09-14 16:51:27 -07:00
|
|
|
|
} else if (entry->type == OFPTYPE_PACKET_OUT) {
|
|
|
|
|
ofproto_packet_out_uninit(&entry->opo);
|
2015-06-01 18:07:39 -07:00
|
|
|
|
}
|
2018-01-09 10:38:31 -08:00
|
|
|
|
free(entry->msg);
|
2015-06-01 18:07:39 -07:00
|
|
|
|
free(entry);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|