mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 23:05:29 +00:00
ofp-prop: New function ofpprop_put_zeros().
This will have additional users in later commits. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Jarno Rajahalme <jarno@ovn.org>
This commit is contained in:
@@ -275,6 +275,28 @@ ofpprop_put(struct ofpbuf *msg, uint64_t type, const void *value, size_t len)
|
|||||||
ofpprop_end(msg, start_ofs);
|
ofpprop_end(msg, start_ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Adds a property with the given 'type' to 'msg', consisting of a struct
|
||||||
|
* ofp_prop_header or ofp_prop_experimenter followed by enough zero bytes to
|
||||||
|
* total 'len' bytes, followed by padding to bring the property up to a
|
||||||
|
* multiple of 8 bytes. Returns the property header. */
|
||||||
|
void *
|
||||||
|
ofpprop_put_zeros(struct ofpbuf *msg, uint64_t type, size_t len)
|
||||||
|
{
|
||||||
|
void *header = ofpbuf_put_zeros(msg, ROUND_UP(len, 8));
|
||||||
|
if (!ofpprop_is_experimenter(type)) {
|
||||||
|
struct ofp_prop_header *oph = header;
|
||||||
|
oph->type = htons(type);
|
||||||
|
oph->len = htons(len);
|
||||||
|
} else {
|
||||||
|
struct ofp_prop_experimenter *ope = header;
|
||||||
|
ope->type = htons(0xffff);
|
||||||
|
ope->len = htons(len);
|
||||||
|
ope->experimenter = htonl(ofpprop_type_to_exp_id(type));
|
||||||
|
ope->exp_type = htonl(ofpprop_type_to_exp_type(type));
|
||||||
|
}
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
/* Adds a property with the given 'type' and 16-bit 'value' to 'msg'. */
|
/* Adds a property with the given 'type' and 16-bit 'value' to 'msg'. */
|
||||||
void
|
void
|
||||||
ofpprop_put_be16(struct ofpbuf *msg, uint64_t type, ovs_be16 value)
|
ofpprop_put_be16(struct ofpbuf *msg, uint64_t type, ovs_be16 value)
|
||||||
|
@@ -89,6 +89,7 @@ enum ofperr ofpprop_parse_uuid(const struct ofpbuf *, struct uuid *);
|
|||||||
/* Serializing properties. */
|
/* Serializing properties. */
|
||||||
void ofpprop_put(struct ofpbuf *, uint64_t type,
|
void ofpprop_put(struct ofpbuf *, uint64_t type,
|
||||||
const void *value, size_t len);
|
const void *value, size_t len);
|
||||||
|
void *ofpprop_put_zeros(struct ofpbuf *, uint64_t type, size_t len);
|
||||||
void ofpprop_put_be16(struct ofpbuf *, uint64_t type, ovs_be16 value);
|
void ofpprop_put_be16(struct ofpbuf *, uint64_t type, ovs_be16 value);
|
||||||
void ofpprop_put_be32(struct ofpbuf *, uint64_t type, ovs_be32 value);
|
void ofpprop_put_be32(struct ofpbuf *, uint64_t type, ovs_be32 value);
|
||||||
void ofpprop_put_be64(struct ofpbuf *, uint64_t type, ovs_be64 value);
|
void ofpprop_put_be64(struct ofpbuf *, uint64_t type, ovs_be64 value);
|
||||||
|
@@ -3868,9 +3868,7 @@ ofputil_put_ofp14_port(const struct ofputil_phy_port *pp,
|
|||||||
op->config = htonl(pp->config & OFPPC11_ALL);
|
op->config = htonl(pp->config & OFPPC11_ALL);
|
||||||
op->state = htonl(pp->state & OFPPS11_ALL);
|
op->state = htonl(pp->state & OFPPS11_ALL);
|
||||||
|
|
||||||
eth = ofpbuf_put_zeros(b, sizeof *eth);
|
eth = ofpprop_put_zeros(b, OFPPDPT14_ETHERNET, sizeof *eth);
|
||||||
eth->type = htons(OFPPDPT14_ETHERNET);
|
|
||||||
eth->length = htons(sizeof *eth);
|
|
||||||
eth->curr = netdev_port_features_to_ofp11(pp->curr);
|
eth->curr = netdev_port_features_to_ofp11(pp->curr);
|
||||||
eth->advertised = netdev_port_features_to_ofp11(pp->advertised);
|
eth->advertised = netdev_port_features_to_ofp11(pp->advertised);
|
||||||
eth->supported = netdev_port_features_to_ofp11(pp->supported);
|
eth->supported = netdev_port_features_to_ofp11(pp->supported);
|
||||||
@@ -5013,9 +5011,7 @@ ofputil_append_table_desc_reply(const struct ofputil_table_desc *td,
|
|||||||
if (td->vacancy == OFPUTIL_TABLE_VACANCY_ON) {
|
if (td->vacancy == OFPUTIL_TABLE_VACANCY_ON) {
|
||||||
struct ofp14_table_mod_prop_vacancy *otv;
|
struct ofp14_table_mod_prop_vacancy *otv;
|
||||||
|
|
||||||
otv = ofpbuf_put_zeros(reply, sizeof *otv);
|
otv = ofpprop_put_zeros(reply, OFPTMPT14_VACANCY, sizeof *otv);
|
||||||
otv->type = htons(OFPTMPT14_VACANCY);
|
|
||||||
otv->length = htons(sizeof *otv);
|
|
||||||
otv->vacancy_down = td->table_vacancy.vacancy_down;
|
otv->vacancy_down = td->table_vacancy.vacancy_down;
|
||||||
otv->vacancy_up = td->table_vacancy.vacancy_up;
|
otv->vacancy_up = td->table_vacancy.vacancy_up;
|
||||||
otv->vacancy = td->table_vacancy.vacancy;
|
otv->vacancy = td->table_vacancy.vacancy;
|
||||||
@@ -5279,7 +5275,6 @@ ofputil_encode_table_mod(const struct ofputil_table_mod *tm,
|
|||||||
case OFP14_VERSION:
|
case OFP14_VERSION:
|
||||||
case OFP15_VERSION: {
|
case OFP15_VERSION: {
|
||||||
struct ofp14_table_mod *otm;
|
struct ofp14_table_mod *otm;
|
||||||
struct ofp14_table_mod_prop_vacancy *otv;
|
|
||||||
|
|
||||||
b = ofpraw_alloc(OFPRAW_OFPT14_TABLE_MOD, ofp_version, 0);
|
b = ofpraw_alloc(OFPRAW_OFPT14_TABLE_MOD, ofp_version, 0);
|
||||||
otm = ofpbuf_put_zeros(b, sizeof *otm);
|
otm = ofpbuf_put_zeros(b, sizeof *otm);
|
||||||
@@ -5291,9 +5286,9 @@ ofputil_encode_table_mod(const struct ofputil_table_mod *tm,
|
|||||||
ofpprop_put_u32(b, OFPTMPT14_EVICTION, tm->eviction_flags);
|
ofpprop_put_u32(b, OFPTMPT14_EVICTION, tm->eviction_flags);
|
||||||
}
|
}
|
||||||
if (tm->vacancy == OFPUTIL_TABLE_VACANCY_ON) {
|
if (tm->vacancy == OFPUTIL_TABLE_VACANCY_ON) {
|
||||||
otv = ofpbuf_put_zeros(b, sizeof *otv);
|
struct ofp14_table_mod_prop_vacancy *otv;
|
||||||
otv->type = htons(OFPTMPT14_VACANCY);
|
|
||||||
otv->length = htons(sizeof *otv);
|
otv = ofpprop_put_zeros(b, OFPTMPT14_VACANCY, sizeof *otv);
|
||||||
otv->vacancy_down = tm->table_vacancy.vacancy_down;
|
otv->vacancy_down = tm->table_vacancy.vacancy_down;
|
||||||
otv->vacancy_up = tm->table_vacancy.vacancy_up;
|
otv->vacancy_up = tm->table_vacancy.vacancy_up;
|
||||||
}
|
}
|
||||||
@@ -6961,10 +6956,7 @@ ofputil_append_ofp14_port_stats(const struct ofputil_port_stats *ops,
|
|||||||
ps14->rx_errors = htonll(ops->stats.rx_errors);
|
ps14->rx_errors = htonll(ops->stats.rx_errors);
|
||||||
ps14->tx_errors = htonll(ops->stats.tx_errors);
|
ps14->tx_errors = htonll(ops->stats.tx_errors);
|
||||||
|
|
||||||
eth = ofpbuf_put_uninit(reply, sizeof *eth);
|
eth = ofpprop_put_zeros(reply, OFPPSPT14_ETHERNET, sizeof *eth);
|
||||||
eth->type = htons(OFPPSPT14_ETHERNET);
|
|
||||||
eth->length = htons(sizeof *eth);
|
|
||||||
memset(eth->pad, 0, sizeof eth->pad);
|
|
||||||
eth->rx_frame_err = htonll(ops->stats.rx_frame_errors);
|
eth->rx_frame_err = htonll(ops->stats.rx_frame_errors);
|
||||||
eth->rx_over_err = htonll(ops->stats.rx_over_errors);
|
eth->rx_over_err = htonll(ops->stats.rx_over_errors);
|
||||||
eth->rx_crc_err = htonll(ops->stats.rx_crc_errors);
|
eth->rx_crc_err = htonll(ops->stats.rx_crc_errors);
|
||||||
|
Reference in New Issue
Block a user