ethdev: add hash function to RSS flow API action
[dpdk.git] / lib / librte_ether / rte_flow.c
index 80f9cb6..a2b51f1 100644 (file)
@@ -39,7 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
        MK_FLOW_ITEM(PF, 0),
        MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)),
        MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)),
-       MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */
+       MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)),
        MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
        MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
        MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
@@ -73,7 +73,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
        MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)),
        MK_FLOW_ACTION(DROP, 0),
        MK_FLOW_ACTION(COUNT, 0),
-       MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */
+       MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)),
        MK_FLOW_ACTION(PF, 0),
        MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)),
 };
@@ -282,14 +282,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
                union {
                        struct rte_flow_item_raw *raw;
                } dst;
+               size_t off;
 
        case RTE_FLOW_ITEM_TYPE_RAW:
                src.raw = item_spec;
                dst.raw = buf;
-               size = offsetof(struct rte_flow_item_raw, pattern) +
-                       src.raw->length * sizeof(*src.raw->pattern);
-               if (dst.raw)
-                       memcpy(dst.raw, src.raw, size);
+               off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw),
+                                    sizeof(*src.raw->pattern));
+               size = off + src.raw->length * sizeof(*src.raw->pattern);
+               if (dst.raw) {
+                       memcpy(dst.raw, src.raw, sizeof(*src.raw));
+                       dst.raw->pattern = memcpy((uint8_t *)dst.raw + off,
+                                                 src.raw->pattern,
+                                                 size - off);
+               }
                break;
        default:
                size = rte_flow_desc_item[item->type].size;
@@ -324,37 +330,28 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
                off = 0;
                if (dst.rss)
                        *dst.rss = (struct rte_flow_action_rss){
-                               .num = src.rss->num,
+                               .func = src.rss->func,
+                               .types = src.rss->types,
+                               .key_len = src.rss->key_len,
+                               .queue_num = src.rss->queue_num,
                        };
-               off += offsetof(struct rte_flow_action_rss, queue);
-               if (src.rss->num) {
-                       size = sizeof(*src.rss->queue) * src.rss->num;
+               off += sizeof(*src.rss);
+               if (src.rss->key_len) {
+                       off = RTE_ALIGN_CEIL(off, sizeof(double));
+                       size = sizeof(*src.rss->key) * src.rss->key_len;
                        if (dst.rss)
-                               memcpy(dst.rss->queue, src.rss->queue, size);
+                               dst.rss->key = memcpy
+                                       ((void *)((uintptr_t)dst.rss + off),
+                                        src.rss->key, size);
                        off += size;
                }
-               off = RTE_ALIGN_CEIL(off, sizeof(double));
-               if (dst.rss) {
-                       dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
-                       *(struct rte_eth_rss_conf *)(uintptr_t)
-                               dst.rss->rss_conf = (struct rte_eth_rss_conf){
-                               .rss_key_len = src.rss->rss_conf->rss_key_len,
-                               .rss_hf = src.rss->rss_conf->rss_hf,
-                       };
-               }
-               off += sizeof(*src.rss->rss_conf);
-               if (src.rss->rss_conf->rss_key_len) {
+               if (src.rss->queue_num) {
                        off = RTE_ALIGN_CEIL(off, sizeof(double));
-                       size = sizeof(*src.rss->rss_conf->rss_key) *
-                               src.rss->rss_conf->rss_key_len;
-                       if (dst.rss) {
-                               ((struct rte_eth_rss_conf *)(uintptr_t)
-                                dst.rss->rss_conf)->rss_key =
-                                       (void *)((uintptr_t)dst.rss + off);
-                               memcpy(dst.rss->rss_conf->rss_key,
-                                      src.rss->rss_conf->rss_key,
-                                      size);
-                       }
+                       size = sizeof(*src.rss->queue) * src.rss->queue_num;
+                       if (dst.rss)
+                               dst.rss->queue = memcpy
+                                       ((void *)((uintptr_t)dst.rss + off),
+                                        src.rss->queue, size);
                        off += size;
                }
                size = off;