static unsigned int skbedit_net_id;
 static struct tc_action_ops act_skbedit_ops;
 
+static u16 tcf_skbedit_hash(struct tcf_skbedit_params *params,
+                           struct sk_buff *skb)
+{
+       u16 queue_mapping = params->queue_mapping;
+
+       if (params->flags & SKBEDIT_F_TXQ_SKBHASH) {
+               u32 hash = skb_get_hash(skb);
+
+               queue_mapping += hash % params->mapping_mod;
+       }
+
+       return netdev_cap_txqueue(skb->dev, queue_mapping);
+}
+
 static int tcf_skbedit_act(struct sk_buff *skb, const struct tc_action *a,
                           struct tcf_result *res)
 {
 #ifdef CONFIG_NET_EGRESS
                netdev_xmit_skip_txqueue(true);
 #endif
-               skb_set_queue_mapping(skb, params->queue_mapping);
+               skb_set_queue_mapping(skb, tcf_skbedit_hash(params, skb));
        }
        if (params->flags & SKBEDIT_F_MARK) {
                skb->mark &= ~params->mask;
        [TCA_SKBEDIT_PTYPE]             = { .len = sizeof(u16) },
        [TCA_SKBEDIT_MASK]              = { .len = sizeof(u32) },
        [TCA_SKBEDIT_FLAGS]             = { .len = sizeof(u64) },
+       [TCA_SKBEDIT_QUEUE_MAPPING_MAX] = { .len = sizeof(u16) },
 };
 
 static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
        struct tcf_skbedit *d;
        u32 flags = 0, *priority = NULL, *mark = NULL, *mask = NULL;
        u16 *queue_mapping = NULL, *ptype = NULL;
+       u16 mapping_mod = 1;
        bool exists = false;
        int ret = 0, err;
        u32 index;
        if (tb[TCA_SKBEDIT_FLAGS] != NULL) {
                u64 *pure_flags = nla_data(tb[TCA_SKBEDIT_FLAGS]);
 
+               if (*pure_flags & SKBEDIT_F_TXQ_SKBHASH) {
+                       u16 *queue_mapping_max;
+
+                       if (!tb[TCA_SKBEDIT_QUEUE_MAPPING] ||
+                           !tb[TCA_SKBEDIT_QUEUE_MAPPING_MAX]) {
+                               NL_SET_ERR_MSG_MOD(extack, "Missing required range of queue_mapping.");
+                               return -EINVAL;
+                       }
+
+                       queue_mapping_max =
+                               nla_data(tb[TCA_SKBEDIT_QUEUE_MAPPING_MAX]);
+                       if (*queue_mapping_max < *queue_mapping) {
+                               NL_SET_ERR_MSG_MOD(extack, "The range of queue_mapping is invalid, max < min.");
+                               return -EINVAL;
+                       }
+
+                       mapping_mod = *queue_mapping_max - *queue_mapping + 1;
+                       flags |= SKBEDIT_F_TXQ_SKBHASH;
+               }
                if (*pure_flags & SKBEDIT_F_INHERITDSFIELD)
                        flags |= SKBEDIT_F_INHERITDSFIELD;
        }
        params_new->flags = flags;
        if (flags & SKBEDIT_F_PRIORITY)
                params_new->priority = *priority;
-       if (flags & SKBEDIT_F_QUEUE_MAPPING)
+       if (flags & SKBEDIT_F_QUEUE_MAPPING) {
                params_new->queue_mapping = *queue_mapping;
+               params_new->mapping_mod = mapping_mod;
+       }
        if (flags & SKBEDIT_F_MARK)
                params_new->mark = *mark;
        if (flags & SKBEDIT_F_PTYPE)
                goto nla_put_failure;
        if (params->flags & SKBEDIT_F_INHERITDSFIELD)
                pure_flags |= SKBEDIT_F_INHERITDSFIELD;
+       if (params->flags & SKBEDIT_F_TXQ_SKBHASH) {
+               if (nla_put_u16(skb, TCA_SKBEDIT_QUEUE_MAPPING_MAX,
+                               params->queue_mapping + params->mapping_mod - 1))
+                       goto nla_put_failure;
+
+               pure_flags |= SKBEDIT_F_TXQ_SKBHASH;
+       }
        if (pure_flags != 0 &&
            nla_put(skb, TCA_SKBEDIT_FLAGS, sizeof(pure_flags), &pure_flags))
                goto nla_put_failure;
        return nla_total_size(sizeof(struct tc_skbedit))
                + nla_total_size(sizeof(u32)) /* TCA_SKBEDIT_PRIORITY */
                + nla_total_size(sizeof(u16)) /* TCA_SKBEDIT_QUEUE_MAPPING */
+               + nla_total_size(sizeof(u16)) /* TCA_SKBEDIT_QUEUE_MAPPING_MAX */
                + nla_total_size(sizeof(u32)) /* TCA_SKBEDIT_MARK */
                + nla_total_size(sizeof(u16)) /* TCA_SKBEDIT_PTYPE */
                + nla_total_size(sizeof(u32)) /* TCA_SKBEDIT_MASK */