-
-static void
-set_field_to_ofast(const struct ofpact_reg_load *load,
- struct ofpbuf *openflow)
-{
- const struct mf_field *mf = load->dst.field;
- uint16_t padded_value_len = ROUND_UP(mf->n_bytes, 8);
- struct ofp12_action_set_field *oasf;
- char *value;
-
- /* Set field is the only action of variable length (so far),
- * so handling the variable length portion is open-coded here */
- oasf = ofputil_put_OFPAT12_SET_FIELD(openflow);
- oasf->dst = htonl(mf->oxm_header);
- oasf->len = htons(ntohs(oasf->len) + padded_value_len);
-
- value = ofpbuf_put_zeros(openflow, padded_value_len);
- bitwise_copy(&load->subvalue, sizeof load->subvalue, load->dst.ofs,
- value, mf->n_bytes, load->dst.ofs, load->dst.n_bits);
-}
-
-void
-nxm_reg_load_to_nxast(const struct ofpact_reg_load *load,
- struct ofpbuf *openflow)
-{
-
- if (load->ofpact.compat == OFPUTIL_OFPAT12_SET_FIELD) {
- struct ofp_header *oh = (struct ofp_header *)openflow->l2;
-
- switch(oh->version) {
- case OFP13_VERSION:
- case OFP12_VERSION:
- set_field_to_ofast(load, openflow);
- break;
-
- case OFP11_VERSION:
- case OFP10_VERSION:
- if (load->dst.n_bits < 64) {
- reg_load_to_nxast(load, openflow);
- } else {
- /* Split into 64bit chunks */
- int chunk, ofs;
- for (ofs = 0; ofs < load->dst.n_bits; ofs += chunk) {
- struct ofpact_reg_load subload = *load;
-
- chunk = MIN(load->dst.n_bits - ofs, 64);
-
- subload.dst.field = load->dst.field;
- subload.dst.ofs = load->dst.ofs + ofs;
- subload.dst.n_bits = chunk;
- bitwise_copy(&load->subvalue, sizeof load->subvalue, ofs,
- &subload.subvalue, sizeof subload.subvalue, 0,
- chunk);
- reg_load_to_nxast(&subload, openflow);
- }
- }
- break;
-
- default:
- NOT_REACHED();
- }
- } else {
- reg_load_to_nxast(load, openflow);
- }
-}