@@ -67,6 +67,44 @@ struct ufid_to_rte_flow_data {
struct dpif_flow_stats stats;
};
+/* maybe little-endian */
+/*
+static void
+u32_to_u8_array(uint32_t var, uint8_t array[]) {
+ uint8_t len, i;
+
+ len = sizeof (var) / sizeof (array[0]);
+ ovs_assert(len == 4);
+
+ for (i = 3; i <= 0; i--) {
+ array[i] = var & 0xFF;
+ var >>= 8;
+ }
+}
+*/
+
+/* u32 && u8_array transformation */
+static void
+u32_to_u8_array(uint32_t var, uint8_t array[]) {
+ uint8_t len, i;
+
+ len = sizeof (var) / sizeof (array[0]);
+ ovs_assert(len == 4);
+
+ for (i = 0; i < 4; i++) {
+ array[i] = var & 0xFF;
+ var >>= 8;
+ }
+}
+
+static uint32_t
+u8_array_to_u32(uint8_t array[]) {
+ uint32_t *var;
+
+ var = (uint32_t *)array;
+ return *var;
+}
+
/* Find rte_flow with @ufid. */
static struct ufid_to_rte_flow_data *
ufid_to_rte_flow_data_find(const ovs_u128 *ufid)
@@ -431,7 +469,7 @@ dump_flow_pattern(struct ds *s, const struct rte_flow_item *item)
ds_put_format(s, "type spec 0x%02x \n", op_spec->type);
ds_put_format(s, "len spec %d \n", op_spec->len);
ds_put_format(s, "opdata spec 0x%08x \n",
- ntohl(op_spec->option_data));
+ u8_array_to_u32(op_spec->option_data));
} else {
ds_put_cstr(s, " Spec = null\n");
}
@@ -440,7 +478,7 @@ dump_flow_pattern(struct ds *s, const struct rte_flow_item *item)
ds_put_format(s, "type mask 0x%02x \n", op_mask->type);
ds_put_format(s, "len mask %d \n", op_mask->len);
ds_put_format(s, "opdata mask 0x%08x \n",
- ntohl(op_mask->option_data));
+ u8_array_to_u32(op_mask->option_data));
} else {
ds_put_cstr(s, " Mask = null\n");
}
@@ -833,7 +871,8 @@ parse_geneve_match(struct flow_patterns *patterns,
op_spec->class = opt->opt_class;
op_spec->type = opt->type;
op_spec->len = opt->length;
- op_spec->option_data = htonl(opt_data);
+ /*op_spec->option_data = &opt_data;*/
+ u32_to_u8_array(opt_data, op_spec->option_data);
add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_GENEVE_OPTIONS, op_spec, op_mask);
}
@@ -1632,7 +1671,8 @@ add_geneve_encap_action(struct flow_actions *actions,
op_spec->class = opt->opt_class;
op_spec->type = opt->type;
op_spec->len = opt->length;
- op_spec->option_data = htonl(opt_data);
+ /*op_spec->option_data = htonl(opt_data);*/
+ u32_to_u8_array(opt_data, op_spec->option_data);
geneve_data->items[field].type = RTE_FLOW_ITEM_TYPE_GENEVE_OPTIONS;
geneve_data->items[field].spec = op_spec;
geneve_data->items[field].mask = &rte_flow_item_geneve_options_mask;
From: Taoyunxiang <taoyunxiang@cmss.chinamobile.com> Code Source From: Self Code Description: Add Geneve option data which need transformat u32 to u8_array. Jira: #[Optional] 市场项目编号(名称):[Optional] --- lib/netdev-offload-dpdk.c | 48 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-)